diff --git a/.gitattributes b/.gitattributes index c4b5fa0751..23c253a26d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,7 @@ * text=auto eol=lf -crates/ruff/resources/test/fixtures/isort/line_ending_crlf.py text eol=crlf -crates/ruff/resources/test/fixtures/pycodestyle/W605_1.py text eol=crlf +crates/ruff_linter/resources/test/fixtures/isort/line_ending_crlf.py text eol=crlf +crates/ruff_linter/resources/test/fixtures/pycodestyle/W605_1.py text eol=crlf ruff.schema.json linguist-generated=true text=auto eol=lf *.md.snap linguist-language=Markdown diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 9cd29adcda..4bb9fa1bd6 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -6,4 +6,4 @@ # - Order is important. The last matching pattern has the most precedence. # Jupyter -/crates/ruff/src/jupyter/ @dhruvmanila +/crates/ruff_linter/src/jupyter/ @dhruvmanila diff --git a/.gitignore b/.gitignore index 9a12d51c7b..c36085eaa4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # Benchmarking cpython (CONTRIBUTING.md) -crates/ruff/resources/test/cpython +crates/ruff_linter/resources/test/cpython # generate_mkdocs.py mkdocs.generated.yml # check_ecosystem.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d2ec61a421..5da5eb2037 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,8 +2,8 @@ fail_fast: true exclude: | (?x)^( - crates/ruff/resources/.*| - crates/ruff/src/rules/.*/snapshots/.*| + crates/ruff_linter/resources/.*| + crates/ruff_linter/src/rules/.*/snapshots/.*| crates/ruff_cli/resources/.*| crates/ruff_python_formatter/resources/.*| crates/ruff_python_formatter/tests/snapshots/.*| @@ -50,7 +50,7 @@ repos: require_serial: true exclude: | (?x)^( - crates/ruff/resources/.*| + crates/ruff_linter/resources/.*| crates/ruff_python_formatter/resources/.* )$ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e7afa965e6..80b796ca9e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -112,11 +112,11 @@ Ruff is structured as a monorepo with a [flat crate structure](https://matklad.g such that all crates are contained in a flat `crates` directory. The vast majority of the code, including all lint rules, lives in the `ruff` crate (located at -`crates/ruff`). As a contributor, that's the crate that'll be most relevant to you. +`crates/ruff_linter`). As a contributor, that's the crate that'll be most relevant to you. At time of writing, the repository includes the following crates: -- `crates/ruff`: library crate containing all lint rules and the core logic for running them. +- `crates/ruff_linter`: library crate containing all lint rules and the core logic for running them. If you're working on a rule, this is the crate for you. - `crates/ruff_benchmark`: binary crate for running micro-benchmarks. - `crates/ruff_cache`: library crate for caching lint results. @@ -153,7 +153,7 @@ At a high level, the steps involved in adding a new lint rule are as follows: 1. Determine a name for the new rule as per our [rule naming convention](#rule-naming-convention) (e.g., `AssertFalse`, as in, "allow `assert False`"). -1. Create a file for your rule (e.g., `crates/ruff/src/rules/flake8_bugbear/rules/assert_false.rs`). +1. Create a file for your rule (e.g., `crates/ruff_linter/src/rules/flake8_bugbear/rules/assert_false.rs`). 1. In that file, define a violation struct (e.g., `pub struct AssertFalse`). You can grep for `#[violation]` to see examples. @@ -162,21 +162,21 @@ At a high level, the steps involved in adding a new lint rule are as follows: (e.g., `pub(crate) fn assert_false`) based on whatever inputs are required for the rule (e.g., an `ast::StmtAssert` node). -1. Define the logic for invoking the diagnostic in `crates/ruff/src/checkers/ast/analyze` (for - AST-based rules), `crates/ruff/src/checkers/tokens.rs` (for token-based rules), - `crates/ruff/src/checkers/physical_lines.rs` (for text-based rules), - `crates/ruff/src/checkers/filesystem.rs` (for filesystem-based rules), etc. For AST-based rules, +1. Define the logic for invoking the diagnostic in `crates/ruff_linter/src/checkers/ast/analyze` (for + AST-based rules), `crates/ruff_linter/src/checkers/tokens.rs` (for token-based rules), + `crates/ruff_linter/src/checkers/physical_lines.rs` (for text-based rules), + `crates/ruff_linter/src/checkers/filesystem.rs` (for filesystem-based rules), etc. For AST-based rules, you'll likely want to modify `analyze/statement.rs` (if your rule is based on analyzing statements, like imports) or `analyze/expression.rs` (if your rule is based on analyzing expressions, like function calls). -1. Map the violation struct to a rule code in `crates/ruff/src/codes.rs` (e.g., `B011`). +1. Map the violation struct to a rule code in `crates/ruff_linter/src/codes.rs` (e.g., `B011`). 1. Add proper [testing](#rule-testing-fixtures-and-snapshots) for your rule. 1. Update the generated files (documentation and generated code). -To trigger the violation, you'll likely want to augment the logic in `crates/ruff/src/checkers/ast.rs` +To trigger the violation, you'll likely want to augment the logic in `crates/ruff_linter/src/checkers/ast.rs` to call your new function at the appropriate time and with the appropriate inputs. The `Checker` defined therein is a Python AST visitor, which iterates over the AST, building up a semantic model, and calling out to lint rule analyzer functions as it goes. @@ -221,7 +221,7 @@ Ruff's output for each fixture, which you can then commit alongside your changes Once you've completed the code for the rule itself, you can define tests with the following steps: -1. Add a Python file to `crates/ruff/resources/test/fixtures/[linter]` that contains the code you +1. Add a Python file to `crates/ruff_linter/resources/test/fixtures/[linter]` that contains the code you want to test. The file name should match the rule name (e.g., `E402.py`), and it should include examples of both violations and non-violations. @@ -230,16 +230,16 @@ Once you've completed the code for the rule itself, you can define tests with th For example, if you're adding a new rule named `E402`, you would run: ```shell - cargo run -p ruff_cli -- check crates/ruff/resources/test/fixtures/pycodestyle/E402.py --no-cache --select E402 + cargo run -p ruff_cli -- check crates/ruff_linter/resources/test/fixtures/pycodestyle/E402.py --no-cache --select E402 ``` **Note:** Only a subset of rules are enabled by default. When testing a new rule, ensure that you activate it by adding `--select ${rule_code}` to the command. -1. Add the test to the relevant `crates/ruff/src/rules/[linter]/mod.rs` file. If you're contributing +1. Add the test to the relevant `crates/ruff_linter/src/rules/[linter]/mod.rs` file. If you're contributing a rule to a pre-existing set, you should be able to find a similar example to pattern-match against. If you're adding a new linter, you'll need to create a new `mod.rs` file (see, - e.g., `crates/ruff/src/rules/flake8_bugbear/mod.rs`) + e.g., `crates/ruff_linter/src/rules/flake8_bugbear/mod.rs`) 1. Run `cargo test`. Your test will fail, but you'll be prompted to follow-up with `cargo insta review`. Run `cargo insta review`, review and accept the generated snapshot, @@ -251,11 +251,11 @@ Once you've completed the code for the rule itself, you can define tests with th Ruff's user-facing settings live in a few different places. -First, the command-line options are defined via the `Cli` struct in `crates/ruff/src/cli.rs`. +First, the command-line options are defined via the `Cli` struct in `crates/ruff_linter/src/cli.rs`. -Second, the `pyproject.toml` options are defined in `crates/ruff/src/settings/options.rs` (via the -`Options` struct), `crates/ruff/src/settings/configuration.rs` (via the `Configuration` struct), and -`crates/ruff/src/settings/mod.rs` (via the `Settings` struct). These represent, respectively: the +Second, the `pyproject.toml` options are defined in `crates/ruff_linter/src/settings/options.rs` (via the +`Options` struct), `crates/ruff_linter/src/settings/configuration.rs` (via the `Configuration` struct), and +`crates/ruff_linter/src/settings/mod.rs` (via the `Settings` struct). These represent, respectively: the schema used to parse the `pyproject.toml` file; an internal, intermediate representation; and the final, internal representation used to power Ruff. @@ -265,11 +265,11 @@ To add a new configuration option, you'll likely want to modify these latter few variables (e.g., `_`). Note that plugin-specific configuration options are defined in their own modules (e.g., -`crates/ruff/src/flake8_unused_arguments/settings.rs`). +`crates/ruff_linter/src/flake8_unused_arguments/settings.rs`). You may also want to add the new configuration option to the `flake8-to-ruff` tool, which is responsible for converting `flake8` configuration files to Ruff's TOML format. This logic -lives in `crates/ruff/src/flake8_to_ruff/converter.rs`. +lives in `crates/ruff_linter/src/flake8_to_ruff/converter.rs`. Finally, regenerate the documentation and generated code with `cargo dev generate-all`. @@ -362,46 +362,46 @@ First, clone [CPython](https://github.com/python/cpython). It's a large and dive which makes it a good target for benchmarking. ```shell -git clone --branch 3.10 https://github.com/python/cpython.git crates/ruff/resources/test/cpython +git clone --branch 3.10 https://github.com/python/cpython.git crates/ruff_linter/resources/test/cpython ``` To benchmark the release build: ```shell cargo build --release && hyperfine --warmup 10 \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache -e" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ -e" + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache -e" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ -e" -Benchmark 1: ./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache +Benchmark 1: ./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache Time (mean ± σ): 293.8 ms ± 3.2 ms [User: 2384.6 ms, System: 90.3 ms] Range (min … max): 289.9 ms … 301.6 ms 10 runs -Benchmark 2: ./target/release/ruff ./crates/ruff/resources/test/cpython/ +Benchmark 2: ./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ Time (mean ± σ): 48.0 ms ± 3.1 ms [User: 65.2 ms, System: 124.7 ms] Range (min … max): 45.0 ms … 66.7 ms 62 runs Summary - './target/release/ruff ./crates/ruff/resources/test/cpython/' ran - 6.12 ± 0.41 times faster than './target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache' + './target/release/ruff ./crates/ruff_linter/resources/test/cpython/' ran + 6.12 ± 0.41 times faster than './target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache' ``` To benchmark against the ecosystem's existing tools: ```shell hyperfine --ignore-failure --warmup 5 \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache" \ - "pyflakes crates/ruff/resources/test/cpython" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache" \ + "pyflakes crates/ruff_linter/resources/test/cpython" \ "autoflake --recursive --expand-star-imports --remove-all-unused-imports --remove-unused-variables --remove-duplicate-keys resources/test/cpython" \ - "pycodestyle crates/ruff/resources/test/cpython" \ - "flake8 crates/ruff/resources/test/cpython" + "pycodestyle crates/ruff_linter/resources/test/cpython" \ + "flake8 crates/ruff_linter/resources/test/cpython" -Benchmark 1: ./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache +Benchmark 1: ./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache Time (mean ± σ): 294.3 ms ± 3.3 ms [User: 2467.5 ms, System: 89.6 ms] Range (min … max): 291.1 ms … 302.8 ms 10 runs Warning: Ignoring non-zero exit code. -Benchmark 2: pyflakes crates/ruff/resources/test/cpython +Benchmark 2: pyflakes crates/ruff_linter/resources/test/cpython Time (mean ± σ): 15.786 s ± 0.143 s [User: 15.560 s, System: 0.214 s] Range (min … max): 15.640 s … 16.157 s 10 runs @@ -411,31 +411,31 @@ Benchmark 3: autoflake --recursive --expand-star-imports --remove-all-unused-imp Time (mean ± σ): 6.175 s ± 0.169 s [User: 54.102 s, System: 1.057 s] Range (min … max): 5.950 s … 6.391 s 10 runs -Benchmark 4: pycodestyle crates/ruff/resources/test/cpython +Benchmark 4: pycodestyle crates/ruff_linter/resources/test/cpython Time (mean ± σ): 46.921 s ± 0.508 s [User: 46.699 s, System: 0.202 s] Range (min … max): 46.171 s … 47.863 s 10 runs Warning: Ignoring non-zero exit code. -Benchmark 5: flake8 crates/ruff/resources/test/cpython +Benchmark 5: flake8 crates/ruff_linter/resources/test/cpython Time (mean ± σ): 12.260 s ± 0.321 s [User: 102.934 s, System: 1.230 s] Range (min … max): 11.848 s … 12.933 s 10 runs Warning: Ignoring non-zero exit code. Summary - './target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache' ran + './target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache' ran 20.98 ± 0.62 times faster than 'autoflake --recursive --expand-star-imports --remove-all-unused-imports --remove-unused-variables --remove-duplicate-keys resources/test/cpython' - 41.66 ± 1.18 times faster than 'flake8 crates/ruff/resources/test/cpython' - 53.64 ± 0.77 times faster than 'pyflakes crates/ruff/resources/test/cpython' - 159.43 ± 2.48 times faster than 'pycodestyle crates/ruff/resources/test/cpython' + 41.66 ± 1.18 times faster than 'flake8 crates/ruff_linter/resources/test/cpython' + 53.64 ± 0.77 times faster than 'pyflakes crates/ruff_linter/resources/test/cpython' + 159.43 ± 2.48 times faster than 'pycodestyle crates/ruff_linter/resources/test/cpython' ``` To benchmark a subset of rules, e.g. `LineTooLong` and `DocLineTooLong`: ```shell cargo build --release && hyperfine --warmup 10 \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache -e --select W505,E501" + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache -e --select W505,E501" ``` You can run `poetry install` from `./scripts/benchmarks` to create a working environment for the @@ -468,10 +468,10 @@ rm Lib/test/bad_coding.py \ Lib/test/test_typing.py ``` -Then, from `crates/ruff/resources/test/cpython`, run: `time pylint -j 0 -E $(git ls-files '*.py')`. This +Then, from `crates/ruff_linter/resources/test/cpython`, run: `time pylint -j 0 -E $(git ls-files '*.py')`. This will execute Pylint with maximum parallelism and only report errors. -To benchmark Pyupgrade, run the following from `crates/ruff/resources/test/cpython`: +To benchmark Pyupgrade, run the following from `crates/ruff_linter/resources/test/cpython`: ```shell hyperfine --ignore-failure --warmup 5 --prepare "git reset --hard HEAD" \ diff --git a/Cargo.lock b/Cargo.lock index d28cc0a8fb..414a958cf3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -822,7 +822,7 @@ dependencies = [ "pep440_rs", "pretty_assertions", "regex", - "ruff", + "ruff_linter", "ruff_workspace", "rustc-hash", "serde", @@ -2029,7 +2029,173 @@ dependencies = [ ] [[package]] -name = "ruff" +name = "ruff_benchmark" +version = "0.0.0" +dependencies = [ + "codspeed-criterion-compat", + "criterion", + "mimalloc", + "once_cell", + "ruff_linter", + "ruff_python_ast", + "ruff_python_formatter", + "ruff_python_index", + "ruff_python_parser", + "serde", + "serde_json", + "tikv-jemallocator", + "ureq", + "url", +] + +[[package]] +name = "ruff_cache" +version = "0.0.0" +dependencies = [ + "filetime", + "glob", + "globset", + "itertools 0.11.0", + "regex", + "ruff_macros", +] + +[[package]] +name = "ruff_cli" +version = "0.0.290" +dependencies = [ + "annotate-snippets 0.9.1", + "anyhow", + "argfile", + "assert_cmd", + "bincode", + "bitflags 2.4.0", + "cachedir", + "chrono", + "clap", + "clap_complete_command", + "clearscreen", + "colored", + "filetime", + "glob", + "ignore", + "insta", + "insta-cmd", + "is-macro", + "itertools 0.11.0", + "itoa", + "log", + "mimalloc", + "notify", + "path-absolutize", + "rayon", + "regex", + "ruff_cache", + "ruff_diagnostics", + "ruff_formatter", + "ruff_linter", + "ruff_macros", + "ruff_notebook", + "ruff_python_ast", + "ruff_python_formatter", + "ruff_python_stdlib", + "ruff_python_trivia", + "ruff_source_file", + "ruff_text_size", + "ruff_workspace", + "rustc-hash", + "serde", + "serde_json", + "shellexpand", + "similar", + "strum", + "tempfile", + "test-case", + "thiserror", + "tikv-jemallocator", + "tracing", + "ureq", + "walkdir", + "wild", +] + +[[package]] +name = "ruff_dev" +version = "0.0.0" +dependencies = [ + "anyhow", + "clap", + "ignore", + "imara-diff", + "indicatif", + "indoc", + "itertools 0.11.0", + "libcst", + "once_cell", + "pretty_assertions", + "rayon", + "regex", + "ruff_cli", + "ruff_diagnostics", + "ruff_formatter", + "ruff_linter", + "ruff_notebook", + "ruff_python_ast", + "ruff_python_codegen", + "ruff_python_formatter", + "ruff_python_literal", + "ruff_python_parser", + "ruff_python_stdlib", + "ruff_python_trivia", + "ruff_workspace", + "schemars", + "serde", + "serde_json", + "similar", + "strum", + "strum_macros", + "tempfile", + "toml", + "tracing", + "tracing-indicatif", + "tracing-subscriber", +] + +[[package]] +name = "ruff_diagnostics" +version = "0.0.0" +dependencies = [ + "anyhow", + "log", + "ruff_text_size", + "serde", +] + +[[package]] +name = "ruff_formatter" +version = "0.0.0" +dependencies = [ + "drop_bomb", + "insta", + "ruff_text_size", + "rustc-hash", + "schemars", + "serde", + "static_assertions", + "tracing", + "unicode-width", +] + +[[package]] +name = "ruff_index" +version = "0.0.0" +dependencies = [ + "ruff_macros", + "static_assertions", +] + +[[package]] +name = "ruff_linter" version = "0.0.290" dependencies = [ "annotate-snippets 0.9.1", @@ -2094,172 +2260,6 @@ dependencies = [ "wsl", ] -[[package]] -name = "ruff_benchmark" -version = "0.0.0" -dependencies = [ - "codspeed-criterion-compat", - "criterion", - "mimalloc", - "once_cell", - "ruff", - "ruff_python_ast", - "ruff_python_formatter", - "ruff_python_index", - "ruff_python_parser", - "serde", - "serde_json", - "tikv-jemallocator", - "ureq", - "url", -] - -[[package]] -name = "ruff_cache" -version = "0.0.0" -dependencies = [ - "filetime", - "glob", - "globset", - "itertools 0.11.0", - "regex", - "ruff_macros", -] - -[[package]] -name = "ruff_cli" -version = "0.0.290" -dependencies = [ - "annotate-snippets 0.9.1", - "anyhow", - "argfile", - "assert_cmd", - "bincode", - "bitflags 2.4.0", - "cachedir", - "chrono", - "clap", - "clap_complete_command", - "clearscreen", - "colored", - "filetime", - "glob", - "ignore", - "insta", - "insta-cmd", - "is-macro", - "itertools 0.11.0", - "itoa", - "log", - "mimalloc", - "notify", - "path-absolutize", - "rayon", - "regex", - "ruff", - "ruff_cache", - "ruff_diagnostics", - "ruff_formatter", - "ruff_macros", - "ruff_notebook", - "ruff_python_ast", - "ruff_python_formatter", - "ruff_python_stdlib", - "ruff_python_trivia", - "ruff_source_file", - "ruff_text_size", - "ruff_workspace", - "rustc-hash", - "serde", - "serde_json", - "shellexpand", - "similar", - "strum", - "tempfile", - "test-case", - "thiserror", - "tikv-jemallocator", - "tracing", - "ureq", - "walkdir", - "wild", -] - -[[package]] -name = "ruff_dev" -version = "0.0.0" -dependencies = [ - "anyhow", - "clap", - "ignore", - "imara-diff", - "indicatif", - "indoc", - "itertools 0.11.0", - "libcst", - "once_cell", - "pretty_assertions", - "rayon", - "regex", - "ruff", - "ruff_cli", - "ruff_diagnostics", - "ruff_formatter", - "ruff_notebook", - "ruff_python_ast", - "ruff_python_codegen", - "ruff_python_formatter", - "ruff_python_literal", - "ruff_python_parser", - "ruff_python_stdlib", - "ruff_python_trivia", - "ruff_workspace", - "schemars", - "serde", - "serde_json", - "similar", - "strum", - "strum_macros", - "tempfile", - "toml", - "tracing", - "tracing-indicatif", - "tracing-subscriber", -] - -[[package]] -name = "ruff_diagnostics" -version = "0.0.0" -dependencies = [ - "anyhow", - "log", - "ruff_text_size", - "serde", -] - -[[package]] -name = "ruff_formatter" -version = "0.0.0" -dependencies = [ - "drop_bomb", - "insta", - "ruff_text_size", - "rustc-hash", - "schemars", - "serde", - "static_assertions", - "tracing", - "unicode-width", -] - -[[package]] -name = "ruff_index" -version = "0.0.0" -dependencies = [ - "ruff_macros", - "static_assertions", -] - [[package]] name = "ruff_macros" version = "0.0.0" @@ -2492,9 +2492,9 @@ dependencies = [ "console_log", "js-sys", "log", - "ruff", "ruff_diagnostics", "ruff_formatter", + "ruff_linter", "ruff_python_ast", "ruff_python_codegen", "ruff_python_formatter", @@ -2525,8 +2525,8 @@ dependencies = [ "path-absolutize", "pep440_rs", "regex", - "ruff", "ruff_cache", + "ruff_linter", "ruff_macros", "rustc-hash", "schemars", diff --git a/crates/flake8_to_ruff/Cargo.toml b/crates/flake8_to_ruff/Cargo.toml index a03f0bbded..9fa7bfdda5 100644 --- a/crates/flake8_to_ruff/Cargo.toml +++ b/crates/flake8_to_ruff/Cargo.toml @@ -13,7 +13,7 @@ repository = { workspace = true } license = { workspace = true } [dependencies] -ruff = { path = "../ruff", default-features = false } +ruff_linter = { path = "../ruff_linter", default-features = false } ruff_workspace = { path = "../ruff_workspace" } anyhow = { workspace = true } diff --git a/crates/flake8_to_ruff/src/black.rs b/crates/flake8_to_ruff/src/black.rs index e9c6df6fb6..2db11a4695 100644 --- a/crates/flake8_to_ruff/src/black.rs +++ b/crates/flake8_to_ruff/src/black.rs @@ -1,7 +1,7 @@ //! Extract Black configuration settings from a pyproject.toml. -use ruff::line_width::LineLength; -use ruff::settings::types::PythonVersion; +use ruff_linter::line_width::LineLength; +use ruff_linter::settings::types::PythonVersion; use serde::{Deserialize, Serialize}; #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Default)] diff --git a/crates/flake8_to_ruff/src/converter.rs b/crates/flake8_to_ruff/src/converter.rs index 5903cfed80..0caafa0b54 100644 --- a/crates/flake8_to_ruff/src/converter.rs +++ b/crates/flake8_to_ruff/src/converter.rs @@ -3,17 +3,17 @@ use std::str::FromStr; use itertools::Itertools; -use ruff::line_width::LineLength; -use ruff::registry::Linter; -use ruff::rule_selector::RuleSelector; -use ruff::rules::flake8_pytest_style::types::{ +use ruff_linter::line_width::LineLength; +use ruff_linter::registry::Linter; +use ruff_linter::rule_selector::RuleSelector; +use ruff_linter::rules::flake8_pytest_style::types::{ ParametrizeNameType, ParametrizeValuesRowType, ParametrizeValuesType, }; -use ruff::rules::flake8_quotes::settings::Quote; -use ruff::rules::flake8_tidy_imports::settings::Strictness; -use ruff::rules::pydocstyle::settings::Convention; -use ruff::settings::types::PythonVersion; -use ruff::warn_user; +use ruff_linter::rules::flake8_quotes::settings::Quote; +use ruff_linter::rules::flake8_tidy_imports::settings::Strictness; +use ruff_linter::rules::pydocstyle::settings::Convention; +use ruff_linter::settings::types::PythonVersion; +use ruff_linter::warn_user; use ruff_workspace::options::{ Flake8AnnotationsOptions, Flake8BugbearOptions, Flake8BuiltinsOptions, Flake8ErrMsgOptions, Flake8PytestStyleOptions, Flake8QuotesOptions, Flake8TidyImportsOptions, McCabeOptions, @@ -458,12 +458,12 @@ mod tests { use pep440_rs::VersionSpecifiers; use pretty_assertions::assert_eq; - use ruff::line_width::LineLength; - use ruff::registry::Linter; - use ruff::rule_selector::RuleSelector; - use ruff::rules::flake8_quotes; - use ruff::rules::pydocstyle::settings::Convention; - use ruff::settings::types::PythonVersion; + use ruff_linter::line_width::LineLength; + use ruff_linter::registry::Linter; + use ruff_linter::rule_selector::RuleSelector; + use ruff_linter::rules::flake8_quotes; + use ruff_linter::rules::pydocstyle::settings::Convention; + use ruff_linter::settings::types::PythonVersion; use ruff_workspace::options::{Flake8QuotesOptions, Options, PydocstyleOptions}; use ruff_workspace::pyproject::Pyproject; diff --git a/crates/flake8_to_ruff/src/main.rs b/crates/flake8_to_ruff/src/main.rs index 55b8530392..940a75f0b2 100644 --- a/crates/flake8_to_ruff/src/main.rs +++ b/crates/flake8_to_ruff/src/main.rs @@ -19,7 +19,7 @@ use crate::converter::convert; use crate::external_config::ExternalConfig; use crate::plugin::Plugin; use crate::pyproject::parse; -use ruff::logging::{set_up_logging, LogLevel}; +use ruff_linter::logging::{set_up_logging, LogLevel}; #[derive(Parser)] #[command( diff --git a/crates/flake8_to_ruff/src/parser.rs b/crates/flake8_to_ruff/src/parser.rs index eab56b0dbe..468992ddf9 100644 --- a/crates/flake8_to_ruff/src/parser.rs +++ b/crates/flake8_to_ruff/src/parser.rs @@ -3,10 +3,11 @@ use std::str::FromStr; use anyhow::{bail, Result}; use once_cell::sync::Lazy; use regex::Regex; -use ruff::settings::types::PatternPrefixPair; -use ruff::{warn_user, RuleSelector}; use rustc_hash::FxHashMap; +use ruff_linter::settings::types::PatternPrefixPair; +use ruff_linter::{warn_user, RuleSelector}; + static COMMA_SEPARATED_LIST_RE: Lazy = Lazy::new(|| Regex::new(r"[,\s]").unwrap()); /// Parse a comma-separated list of `RuleSelector` values (e.g., @@ -192,11 +193,11 @@ pub(crate) fn collect_per_file_ignores( #[cfg(test)] mod tests { use anyhow::Result; - use ruff::RuleSelector; - use ruff::codes; - use ruff::registry::Linter; - use ruff::settings::types::PatternPrefixPair; + use ruff_linter::codes; + use ruff_linter::registry::Linter; + use ruff_linter::settings::types::PatternPrefixPair; + use ruff_linter::RuleSelector; use super::{parse_files_to_codes_mapping, parse_prefix_codes, parse_strings}; diff --git a/crates/flake8_to_ruff/src/plugin.rs b/crates/flake8_to_ruff/src/plugin.rs index 4c43dbabfe..37c8795f57 100644 --- a/crates/flake8_to_ruff/src/plugin.rs +++ b/crates/flake8_to_ruff/src/plugin.rs @@ -3,9 +3,9 @@ use std::fmt; use std::str::FromStr; use anyhow::anyhow; -use ruff::registry::Linter; -use ruff::settings::types::PreviewMode; -use ruff::RuleSelector; +use ruff_linter::registry::Linter; +use ruff_linter::settings::types::PreviewMode; +use ruff_linter::RuleSelector; #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq)] pub enum Plugin { diff --git a/crates/ruff/resources/test/project/README.md b/crates/ruff/resources/test/project/README.md deleted file mode 100644 index bdeaebd78e..0000000000 --- a/crates/ruff/resources/test/project/README.md +++ /dev/null @@ -1,96 +0,0 @@ -# project - -An example multi-package Python project used to test setting resolution and other complex -behaviors. - -## Expected behavior - -Running from the repo root should pick up and enforce the appropriate settings for each package: - -```console -∴ cargo run -p ruff_cli -- check crates/ruff/resources/test/project/ -crates/ruff/resources/test/project/examples/.dotfiles/script.py:1:1: I001 [*] Import block is un-sorted or un-formatted -crates/ruff/resources/test/project/examples/.dotfiles/script.py:1:8: F401 [*] `numpy` imported but unused -crates/ruff/resources/test/project/examples/.dotfiles/script.py:2:17: F401 [*] `app.app_file` imported but unused -crates/ruff/resources/test/project/examples/docs/docs/file.py:1:1: I001 [*] Import block is un-sorted or un-formatted -crates/ruff/resources/test/project/examples/docs/docs/file.py:8:5: F841 [*] Local variable `x` is assigned to but never used -crates/ruff/resources/test/project/project/file.py:1:8: F401 [*] `os` imported but unused -crates/ruff/resources/test/project/project/import_file.py:1:1: I001 [*] Import block is un-sorted or un-formatted -Found 7 errors. -[*] 7 potentially fixable with the --fix option. -``` - -Running from the project directory itself should exhibit the same behavior: - -```console -∴ (cd crates/ruff/resources/test/project/ && cargo run -p ruff_cli -- check .) -examples/.dotfiles/script.py:1:1: I001 [*] Import block is un-sorted or un-formatted -examples/.dotfiles/script.py:1:8: F401 [*] `numpy` imported but unused -examples/.dotfiles/script.py:2:17: F401 [*] `app.app_file` imported but unused -examples/docs/docs/file.py:1:1: I001 [*] Import block is un-sorted or un-formatted -examples/docs/docs/file.py:8:5: F841 [*] Local variable `x` is assigned to but never used -project/file.py:1:8: F401 [*] `os` imported but unused -project/import_file.py:1:1: I001 [*] Import block is un-sorted or un-formatted -Found 7 errors. -[*] 7 potentially fixable with the --fix option. -``` - -Running from the sub-package directory should exhibit the same behavior, but omit the top-level -files: - -```console -∴ (cd crates/ruff/resources/test/project/examples/docs && cargo run -p ruff_cli -- check .) -docs/file.py:1:1: I001 [*] Import block is un-sorted or un-formatted -docs/file.py:8:5: F841 [*] Local variable `x` is assigned to but never used -Found 2 errors. -[*] 2 potentially fixable with the --fix option. -``` - -`--config` should force Ruff to use the specified `pyproject.toml` for all files, and resolve -file paths from the current working directory: - -```console -∴ (cargo run -p ruff_cli -- check --config=crates/ruff/resources/test/project/pyproject.toml crates/ruff/resources/test/project/) -crates/ruff/resources/test/project/examples/.dotfiles/script.py:1:8: F401 [*] `numpy` imported but unused -crates/ruff/resources/test/project/examples/.dotfiles/script.py:2:17: F401 [*] `app.app_file` imported but unused -crates/ruff/resources/test/project/examples/docs/docs/concepts/file.py:1:8: F401 [*] `os` imported but unused -crates/ruff/resources/test/project/examples/docs/docs/file.py:1:1: I001 [*] Import block is un-sorted or un-formatted -crates/ruff/resources/test/project/examples/docs/docs/file.py:1:8: F401 [*] `os` imported but unused -crates/ruff/resources/test/project/examples/docs/docs/file.py:3:8: F401 [*] `numpy` imported but unused -crates/ruff/resources/test/project/examples/docs/docs/file.py:4:27: F401 [*] `docs.concepts.file` imported but unused -crates/ruff/resources/test/project/examples/excluded/script.py:1:8: F401 [*] `os` imported but unused -crates/ruff/resources/test/project/project/file.py:1:8: F401 [*] `os` imported but unused -Found 9 errors. -[*] 9 potentially fixable with the --fix option. -``` - -Running from a parent directory should "ignore" the `exclude` (hence, `concepts/file.py` gets -included in the output): - -```console -∴ (cd crates/ruff/resources/test/project/examples && cargo run -p ruff_cli -- check --config=docs/ruff.toml .) -docs/docs/concepts/file.py:5:5: F841 [*] Local variable `x` is assigned to but never used -docs/docs/file.py:1:1: I001 [*] Import block is un-sorted or un-formatted -docs/docs/file.py:8:5: F841 [*] Local variable `x` is assigned to but never used -excluded/script.py:5:5: F841 [*] Local variable `x` is assigned to but never used -Found 4 errors. -[*] 4 potentially fixable with the --fix option. -``` - -Passing an excluded directory directly should report errors in the contained files: - -```console -∴ cargo run -p ruff_cli -- check crates/ruff/resources/test/project/examples/excluded/ -crates/ruff/resources/test/project/examples/excluded/script.py:1:8: F401 [*] `os` imported but unused -Found 1 error. -[*] 1 potentially fixable with the --fix option. -``` - -Unless we `--force-exclude`: - -```console -∴ cargo run -p ruff_cli -- check crates/ruff/resources/test/project/examples/excluded/ --force-exclude -warning: No Python files found under the given path(s) -∴ cargo run -p ruff_cli -- check crates/ruff/resources/test/project/examples/excluded/script.py --force-exclude -warning: No Python files found under the given path(s) -``` diff --git a/crates/ruff/src/comments/snapshots/ruff__comments__shebang__tests__shebang_end_of_line.snap b/crates/ruff/src/comments/snapshots/ruff__comments__shebang__tests__shebang_end_of_line.snap deleted file mode 100644 index 87d72c9d88..0000000000 --- a/crates/ruff/src/comments/snapshots/ruff__comments__shebang__tests__shebang_end_of_line.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: crates/ruff/src/comments/shebang.rs -expression: "ShebangDirective::try_extract(source)" ---- -None diff --git a/crates/ruff/src/comments/snapshots/ruff__comments__shebang__tests__shebang_leading_space.snap b/crates/ruff/src/comments/snapshots/ruff__comments__shebang__tests__shebang_leading_space.snap deleted file mode 100644 index 87d72c9d88..0000000000 --- a/crates/ruff/src/comments/snapshots/ruff__comments__shebang__tests__shebang_leading_space.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: crates/ruff/src/comments/shebang.rs -expression: "ShebangDirective::try_extract(source)" ---- -None diff --git a/crates/ruff/src/comments/snapshots/ruff__comments__shebang__tests__shebang_match.snap b/crates/ruff/src/comments/snapshots/ruff__comments__shebang__tests__shebang_match.snap deleted file mode 100644 index 9078c810d1..0000000000 --- a/crates/ruff/src/comments/snapshots/ruff__comments__shebang__tests__shebang_match.snap +++ /dev/null @@ -1,9 +0,0 @@ ---- -source: crates/ruff/src/comments/shebang.rs -expression: "ShebangDirective::try_extract(source)" ---- -Some( - ShebangDirective( - "/usr/bin/env python", - ), -) diff --git a/crates/ruff/src/comments/snapshots/ruff__comments__shebang__tests__shebang_match_trailing_comment.snap b/crates/ruff/src/comments/snapshots/ruff__comments__shebang__tests__shebang_match_trailing_comment.snap deleted file mode 100644 index c309559855..0000000000 --- a/crates/ruff/src/comments/snapshots/ruff__comments__shebang__tests__shebang_match_trailing_comment.snap +++ /dev/null @@ -1,9 +0,0 @@ ---- -source: crates/ruff/src/comments/shebang.rs -expression: "ShebangDirective::try_extract(source)" ---- -Some( - ShebangDirective( - "/usr/bin/env python # trailing comment", - ), -) diff --git a/crates/ruff/src/comments/snapshots/ruff__comments__shebang__tests__shebang_non_match.snap b/crates/ruff/src/comments/snapshots/ruff__comments__shebang__tests__shebang_non_match.snap deleted file mode 100644 index 87d72c9d88..0000000000 --- a/crates/ruff/src/comments/snapshots/ruff__comments__shebang__tests__shebang_non_match.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: crates/ruff/src/comments/shebang.rs -expression: "ShebangDirective::try_extract(source)" ---- -None diff --git a/crates/ruff/src/message/snapshots/ruff__message__azure__tests__output.snap b/crates/ruff/src/message/snapshots/ruff__message__azure__tests__output.snap deleted file mode 100644 index 253a845856..0000000000 --- a/crates/ruff/src/message/snapshots/ruff__message__azure__tests__output.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: crates/ruff/src/message/azure.rs -expression: content ---- -##vso[task.logissue type=error;sourcepath=fib.py;linenumber=1;columnnumber=8;code=F401;]`os` imported but unused -##vso[task.logissue type=error;sourcepath=fib.py;linenumber=6;columnnumber=5;code=F841;]Local variable `x` is assigned to but never used -##vso[task.logissue type=error;sourcepath=undef.py;linenumber=1;columnnumber=4;code=F821;]Undefined name `a` - diff --git a/crates/ruff/src/message/snapshots/ruff__message__github__tests__output.snap b/crates/ruff/src/message/snapshots/ruff__message__github__tests__output.snap deleted file mode 100644 index 2ec3ca4609..0000000000 --- a/crates/ruff/src/message/snapshots/ruff__message__github__tests__output.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: crates/ruff/src/message/github.rs -expression: content ---- -::error title=Ruff (F401),file=fib.py,line=1,col=8,endLine=1,endColumn=10::fib.py:1:8: F401 `os` imported but unused -::error title=Ruff (F841),file=fib.py,line=6,col=5,endLine=6,endColumn=6::fib.py:6:5: F841 Local variable `x` is assigned to but never used -::error title=Ruff (F821),file=undef.py,line=1,col=4,endLine=1,endColumn=5::undef.py:1:4: F821 Undefined name `a` - diff --git a/crates/ruff/src/message/snapshots/ruff__message__gitlab__tests__output.snap b/crates/ruff/src/message/snapshots/ruff__message__gitlab__tests__output.snap deleted file mode 100644 index 43e03eb1b2..0000000000 --- a/crates/ruff/src/message/snapshots/ruff__message__gitlab__tests__output.snap +++ /dev/null @@ -1,42 +0,0 @@ ---- -source: crates/ruff/src/message/gitlab.rs -expression: redact_fingerprint(&content) ---- -[ - { - "description": "(F401) `os` imported but unused", - "fingerprint": "", - "location": { - "lines": { - "begin": 1, - "end": 1 - }, - "path": "fib.py" - }, - "severity": "major" - }, - { - "description": "(F841) Local variable `x` is assigned to but never used", - "fingerprint": "", - "location": { - "lines": { - "begin": 6, - "end": 6 - }, - "path": "fib.py" - }, - "severity": "major" - }, - { - "description": "(F821) Undefined name `a`", - "fingerprint": "", - "location": { - "lines": { - "begin": 1, - "end": 1 - }, - "path": "undef.py" - }, - "severity": "major" - } -] diff --git a/crates/ruff/src/message/snapshots/ruff__message__grouped__tests__default.snap b/crates/ruff/src/message/snapshots/ruff__message__grouped__tests__default.snap deleted file mode 100644 index 00d89c9ceb..0000000000 --- a/crates/ruff/src/message/snapshots/ruff__message__grouped__tests__default.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/message/grouped.rs -expression: content ---- -fib.py: - 1:8 F401 `os` imported but unused - 6:5 F841 Local variable `x` is assigned to but never used - -undef.py: - 1:4 F821 Undefined name `a` - - diff --git a/crates/ruff/src/message/snapshots/ruff__message__grouped__tests__fix_status.snap b/crates/ruff/src/message/snapshots/ruff__message__grouped__tests__fix_status.snap deleted file mode 100644 index cab38cae85..0000000000 --- a/crates/ruff/src/message/snapshots/ruff__message__grouped__tests__fix_status.snap +++ /dev/null @@ -1,31 +0,0 @@ ---- -source: crates/ruff/src/message/grouped.rs -expression: content ---- -fib.py: - 1:8 F401 [*] `os` imported but unused - | - 1 | import os - | ^^ F401 - | - = help: Remove unused import: `os` - - 6:5 F841 [*] Local variable `x` is assigned to but never used - | - 4 | def fibonacci(n): - 5 | """Compute the nth number in the Fibonacci sequence.""" - 6 | x = 1 - | ^ F841 - 7 | if n == 0: - 8 | return 0 - | - = help: Remove assignment to unused variable `x` - -undef.py: - 1:4 F821 Undefined name `a` - | - 1 | if a == 1: pass - | ^ F821 - | - - diff --git a/crates/ruff/src/message/snapshots/ruff__message__grouped__tests__show_source.snap b/crates/ruff/src/message/snapshots/ruff__message__grouped__tests__show_source.snap deleted file mode 100644 index 47e5d78278..0000000000 --- a/crates/ruff/src/message/snapshots/ruff__message__grouped__tests__show_source.snap +++ /dev/null @@ -1,31 +0,0 @@ ---- -source: crates/ruff/src/message/grouped.rs -expression: content ---- -fib.py: - 1:8 F401 `os` imported but unused - | - 1 | import os - | ^^ F401 - | - = help: Remove unused import: `os` - - 6:5 F841 Local variable `x` is assigned to but never used - | - 4 | def fibonacci(n): - 5 | """Compute the nth number in the Fibonacci sequence.""" - 6 | x = 1 - | ^ F841 - 7 | if n == 0: - 8 | return 0 - | - = help: Remove assignment to unused variable `x` - -undef.py: - 1:4 F821 Undefined name `a` - | - 1 | if a == 1: pass - | ^ F821 - | - - diff --git a/crates/ruff/src/message/snapshots/ruff__message__json__tests__output.snap b/crates/ruff/src/message/snapshots/ruff__message__json__tests__output.snap deleted file mode 100644 index 698d481d46..0000000000 --- a/crates/ruff/src/message/snapshots/ruff__message__json__tests__output.snap +++ /dev/null @@ -1,86 +0,0 @@ ---- -source: crates/ruff/src/message/json.rs -expression: content ---- -[ - { - "code": "F401", - "end_location": { - "column": 10, - "row": 1 - }, - "filename": "fib.py", - "fix": { - "applicability": "Suggested", - "edits": [ - { - "content": "", - "end_location": { - "column": 1, - "row": 2 - }, - "location": { - "column": 1, - "row": 1 - } - } - ], - "message": "Remove unused import: `os`" - }, - "location": { - "column": 8, - "row": 1 - }, - "message": "`os` imported but unused", - "noqa_row": 1, - "url": "https://docs.astral.sh/ruff/rules/unused-import" - }, - { - "code": "F841", - "end_location": { - "column": 6, - "row": 6 - }, - "filename": "fib.py", - "fix": { - "applicability": "Suggested", - "edits": [ - { - "content": "", - "end_location": { - "column": 10, - "row": 6 - }, - "location": { - "column": 5, - "row": 6 - } - } - ], - "message": "Remove assignment to unused variable `x`" - }, - "location": { - "column": 5, - "row": 6 - }, - "message": "Local variable `x` is assigned to but never used", - "noqa_row": 6, - "url": "https://docs.astral.sh/ruff/rules/unused-variable" - }, - { - "code": "F821", - "end_location": { - "column": 5, - "row": 1 - }, - "filename": "undef.py", - "fix": null, - "location": { - "column": 4, - "row": 1 - }, - "message": "Undefined name `a`", - "noqa_row": 1, - "url": "https://docs.astral.sh/ruff/rules/undefined-name" - } -] diff --git a/crates/ruff/src/message/snapshots/ruff__message__json_lines__tests__output.snap b/crates/ruff/src/message/snapshots/ruff__message__json_lines__tests__output.snap deleted file mode 100644 index 2c5ce088bf..0000000000 --- a/crates/ruff/src/message/snapshots/ruff__message__json_lines__tests__output.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: crates/ruff/src/message/json_lines.rs -expression: content ---- -{"code":"F401","end_location":{"column":10,"row":1},"filename":"fib.py","fix":{"applicability":"Suggested","edits":[{"content":"","end_location":{"column":1,"row":2},"location":{"column":1,"row":1}}],"message":"Remove unused import: `os`"},"location":{"column":8,"row":1},"message":"`os` imported but unused","noqa_row":1,"url":"https://docs.astral.sh/ruff/rules/unused-import"} -{"code":"F841","end_location":{"column":6,"row":6},"filename":"fib.py","fix":{"applicability":"Suggested","edits":[{"content":"","end_location":{"column":10,"row":6},"location":{"column":5,"row":6}}],"message":"Remove assignment to unused variable `x`"},"location":{"column":5,"row":6},"message":"Local variable `x` is assigned to but never used","noqa_row":6,"url":"https://docs.astral.sh/ruff/rules/unused-variable"} -{"code":"F821","end_location":{"column":5,"row":1},"filename":"undef.py","fix":null,"location":{"column":4,"row":1},"message":"Undefined name `a`","noqa_row":1,"url":"https://docs.astral.sh/ruff/rules/undefined-name"} - diff --git a/crates/ruff/src/message/snapshots/ruff__message__junit__tests__output.snap b/crates/ruff/src/message/snapshots/ruff__message__junit__tests__output.snap deleted file mode 100644 index 55292e9c77..0000000000 --- a/crates/ruff/src/message/snapshots/ruff__message__junit__tests__output.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: crates/ruff/src/message/junit.rs -expression: content ---- - - - - - line 1, col 8, `os` imported but unused - - - line 6, col 5, Local variable `x` is assigned to but never used - - - - - line 1, col 4, Undefined name `a` - - - - diff --git a/crates/ruff/src/message/snapshots/ruff__message__pylint__tests__output.snap b/crates/ruff/src/message/snapshots/ruff__message__pylint__tests__output.snap deleted file mode 100644 index 6ce020233a..0000000000 --- a/crates/ruff/src/message/snapshots/ruff__message__pylint__tests__output.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: crates/ruff/src/message/pylint.rs -expression: content ---- -fib.py:1: [F401] `os` imported but unused -fib.py:6: [F841] Local variable `x` is assigned to but never used -undef.py:1: [F821] Undefined name `a` - diff --git a/crates/ruff/src/message/snapshots/ruff__message__text__tests__default.snap b/crates/ruff/src/message/snapshots/ruff__message__text__tests__default.snap deleted file mode 100644 index 2be643a858..0000000000 --- a/crates/ruff/src/message/snapshots/ruff__message__text__tests__default.snap +++ /dev/null @@ -1,29 +0,0 @@ ---- -source: crates/ruff/src/message/text.rs -expression: content ---- -fib.py:1:8: F401 `os` imported but unused - | -1 | import os - | ^^ F401 - | - = help: Remove unused import: `os` - -fib.py:6:5: F841 Local variable `x` is assigned to but never used - | -4 | def fibonacci(n): -5 | """Compute the nth number in the Fibonacci sequence.""" -6 | x = 1 - | ^ F841 -7 | if n == 0: -8 | return 0 - | - = help: Remove assignment to unused variable `x` - -undef.py:1:4: F821 Undefined name `a` - | -1 | if a == 1: pass - | ^ F821 - | - - diff --git a/crates/ruff/src/message/snapshots/ruff__message__text__tests__fix_status.snap b/crates/ruff/src/message/snapshots/ruff__message__text__tests__fix_status.snap deleted file mode 100644 index c626c0195a..0000000000 --- a/crates/ruff/src/message/snapshots/ruff__message__text__tests__fix_status.snap +++ /dev/null @@ -1,29 +0,0 @@ ---- -source: crates/ruff/src/message/text.rs -expression: content ---- -fib.py:1:8: F401 [*] `os` imported but unused - | -1 | import os - | ^^ F401 - | - = help: Remove unused import: `os` - -fib.py:6:5: F841 [*] Local variable `x` is assigned to but never used - | -4 | def fibonacci(n): -5 | """Compute the nth number in the Fibonacci sequence.""" -6 | x = 1 - | ^ F841 -7 | if n == 0: -8 | return 0 - | - = help: Remove assignment to unused variable `x` - -undef.py:1:4: F821 Undefined name `a` - | -1 | if a == 1: pass - | ^ F821 - | - - diff --git a/crates/ruff/src/rules/airflow/snapshots/ruff__rules__airflow__tests__AIR001_AIR001.py.snap b/crates/ruff/src/rules/airflow/snapshots/ruff__rules__airflow__tests__AIR001_AIR001.py.snap deleted file mode 100644 index e63f50e065..0000000000 --- a/crates/ruff/src/rules/airflow/snapshots/ruff__rules__airflow__tests__AIR001_AIR001.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/airflow/mod.rs ---- -AIR001.py:11:1: AIR001 Task variable name should match the `task_id`: "my_task" - | - 9 | my_task_2 = PythonOperator(callable=my_callable, task_id="my_task_2") -10 | -11 | incorrect_name = PythonOperator(task_id="my_task") - | ^^^^^^^^^^^^^^ AIR001 -12 | incorrect_name_2 = PythonOperator(callable=my_callable, task_id="my_task_2") - | - -AIR001.py:12:1: AIR001 Task variable name should match the `task_id`: "my_task_2" - | -11 | incorrect_name = PythonOperator(task_id="my_task") -12 | incorrect_name_2 = PythonOperator(callable=my_callable, task_id="my_task_2") - | ^^^^^^^^^^^^^^^^ AIR001 -13 | -14 | from my_module import MyClass - | - - diff --git a/crates/ruff/src/rules/eradicate/snapshots/ruff__rules__eradicate__tests__ERA001_ERA001.py.snap b/crates/ruff/src/rules/eradicate/snapshots/ruff__rules__eradicate__tests__ERA001_ERA001.py.snap deleted file mode 100644 index 18aa504d2b..0000000000 --- a/crates/ruff/src/rules/eradicate/snapshots/ruff__rules__eradicate__tests__ERA001_ERA001.py.snap +++ /dev/null @@ -1,151 +0,0 @@ ---- -source: crates/ruff/src/rules/eradicate/mod.rs ---- -ERA001.py:1:1: ERA001 [*] Found commented-out code - | -1 | #import os - | ^^^^^^^^^^ ERA001 -2 | # from foo import junk -3 | #a = 3 - | - = help: Remove commented-out code - -ℹ Possible fix -1 |-#import os -2 1 | # from foo import junk -3 2 | #a = 3 -4 3 | a = 4 - -ERA001.py:2:1: ERA001 [*] Found commented-out code - | -1 | #import os -2 | # from foo import junk - | ^^^^^^^^^^^^^^^^^^^^^^ ERA001 -3 | #a = 3 -4 | a = 4 - | - = help: Remove commented-out code - -ℹ Possible fix -1 1 | #import os -2 |-# from foo import junk -3 2 | #a = 3 -4 3 | a = 4 -5 4 | #foo(1, 2, 3) - -ERA001.py:3:1: ERA001 [*] Found commented-out code - | -1 | #import os -2 | # from foo import junk -3 | #a = 3 - | ^^^^^^ ERA001 -4 | a = 4 -5 | #foo(1, 2, 3) - | - = help: Remove commented-out code - -ℹ Possible fix -1 1 | #import os -2 2 | # from foo import junk -3 |-#a = 3 -4 3 | a = 4 -5 4 | #foo(1, 2, 3) -6 5 | - -ERA001.py:5:1: ERA001 [*] Found commented-out code - | -3 | #a = 3 -4 | a = 4 -5 | #foo(1, 2, 3) - | ^^^^^^^^^^^^^ ERA001 -6 | -7 | def foo(x, y, z): - | - = help: Remove commented-out code - -ℹ Possible fix -2 2 | # from foo import junk -3 3 | #a = 3 -4 4 | a = 4 -5 |-#foo(1, 2, 3) -6 5 | -7 6 | def foo(x, y, z): -8 7 | content = 1 # print('hello') - -ERA001.py:13:5: ERA001 [*] Found commented-out code - | -11 | # This is a real comment. -12 | # # This is a (nested) comment. -13 | #return True - | ^^^^^^^^^^^^ ERA001 -14 | return False - | - = help: Remove commented-out code - -ℹ Possible fix -10 10 | -11 11 | # This is a real comment. -12 12 | # # This is a (nested) comment. -13 |- #return True -14 13 | return False -15 14 | -16 15 | #import os # noqa: ERA001 - -ERA001.py:21:5: ERA001 [*] Found commented-out code - | -19 | class A(): -20 | pass -21 | # b = c - | ^^^^^^^ ERA001 - | - = help: Remove commented-out code - -ℹ Possible fix -18 18 | -19 19 | class A(): -20 20 | pass -21 |- # b = c -22 21 | -23 22 | -24 23 | dictionary = { - -ERA001.py:26:5: ERA001 [*] Found commented-out code - | -24 | dictionary = { -25 | # "key1": 123, # noqa: ERA001 -26 | # "key2": 456, - | ^^^^^^^^^^^^^^ ERA001 -27 | # "key3": 789, # test -28 | } - | - = help: Remove commented-out code - -ℹ Possible fix -23 23 | -24 24 | dictionary = { -25 25 | # "key1": 123, # noqa: ERA001 -26 |- # "key2": 456, -27 26 | # "key3": 789, # test -28 27 | } -29 28 | - -ERA001.py:27:5: ERA001 [*] Found commented-out code - | -25 | # "key1": 123, # noqa: ERA001 -26 | # "key2": 456, -27 | # "key3": 789, # test - | ^^^^^^^^^^^^^^^^^^^^^^ ERA001 -28 | } - | - = help: Remove commented-out code - -ℹ Possible fix -24 24 | dictionary = { -25 25 | # "key1": 123, # noqa: ERA001 -26 26 | # "key2": 456, -27 |- # "key3": 789, # test -28 27 | } -29 28 | -30 29 | #import os # noqa - - diff --git a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT101_YTT101.py.snap b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT101_YTT101.py.snap deleted file mode 100644 index b558840bd8..0000000000 --- a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT101_YTT101.py.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_2020/mod.rs ---- -YTT101.py:6:7: YTT101 `sys.version[:3]` referenced (python3.10), use `sys.version_info` - | -4 | print(sys.version) -5 | -6 | print(sys.version[:3]) - | ^^^^^^^^^^^ YTT101 -7 | print(version[:3]) -8 | print(v[:3]) - | - -YTT101.py:7:7: YTT101 `sys.version[:3]` referenced (python3.10), use `sys.version_info` - | -6 | print(sys.version[:3]) -7 | print(version[:3]) - | ^^^^^^^ YTT101 -8 | print(v[:3]) - | - -YTT101.py:8:7: YTT101 `sys.version[:3]` referenced (python3.10), use `sys.version_info` - | - 6 | print(sys.version[:3]) - 7 | print(version[:3]) - 8 | print(v[:3]) - | ^ YTT101 - 9 | -10 | # the tool is timid and only flags certain numeric slices - | - - diff --git a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT102_YTT102.py.snap b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT102_YTT102.py.snap deleted file mode 100644 index 802e0b201d..0000000000 --- a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT102_YTT102.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_2020/mod.rs ---- -YTT102.py:4:12: YTT102 `sys.version[2]` referenced (python3.10), use `sys.version_info` - | -2 | from sys import version -3 | -4 | py_minor = sys.version[2] - | ^^^^^^^^^^^ YTT102 -5 | py_minor = version[2] - | - -YTT102.py:5:12: YTT102 `sys.version[2]` referenced (python3.10), use `sys.version_info` - | -4 | py_minor = sys.version[2] -5 | py_minor = version[2] - | ^^^^^^^ YTT102 - | - - diff --git a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT103_YTT103.py.snap b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT103_YTT103.py.snap deleted file mode 100644 index c7c8bce4f1..0000000000 --- a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT103_YTT103.py.snap +++ /dev/null @@ -1,50 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_2020/mod.rs ---- -YTT103.py:4:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` - | -2 | from sys import version -3 | -4 | version < "3.5" - | ^^^^^^^ YTT103 -5 | sys.version < "3.5" -6 | sys.version <= "3.5" - | - -YTT103.py:5:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` - | -4 | version < "3.5" -5 | sys.version < "3.5" - | ^^^^^^^^^^^ YTT103 -6 | sys.version <= "3.5" -7 | sys.version > "3.5" - | - -YTT103.py:6:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` - | -4 | version < "3.5" -5 | sys.version < "3.5" -6 | sys.version <= "3.5" - | ^^^^^^^^^^^ YTT103 -7 | sys.version > "3.5" -8 | sys.version >= "3.5" - | - -YTT103.py:7:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` - | -5 | sys.version < "3.5" -6 | sys.version <= "3.5" -7 | sys.version > "3.5" - | ^^^^^^^^^^^ YTT103 -8 | sys.version >= "3.5" - | - -YTT103.py:8:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` - | -6 | sys.version <= "3.5" -7 | sys.version > "3.5" -8 | sys.version >= "3.5" - | ^^^^^^^^^^^ YTT103 - | - - diff --git a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT201_YTT201.py.snap b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT201_YTT201.py.snap deleted file mode 100644 index 5384677806..0000000000 --- a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT201_YTT201.py.snap +++ /dev/null @@ -1,40 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_2020/mod.rs ---- -YTT201.py:7:7: YTT201 `sys.version_info[0] == 3` referenced (python4), use `>=` - | -5 | PY3 = sys.version_info[0] >= 3 -6 | -7 | PY3 = sys.version_info[0] == 3 - | ^^^^^^^^^^^^^^^^^^^ YTT201 -8 | PY3 = version_info[0] == 3 -9 | PY2 = sys.version_info[0] != 3 - | - -YTT201.py:8:7: YTT201 `sys.version_info[0] == 3` referenced (python4), use `>=` - | - 7 | PY3 = sys.version_info[0] == 3 - 8 | PY3 = version_info[0] == 3 - | ^^^^^^^^^^^^^^^ YTT201 - 9 | PY2 = sys.version_info[0] != 3 -10 | PY2 = version_info[0] != 3 - | - -YTT201.py:9:7: YTT201 `sys.version_info[0] == 3` referenced (python4), use `>=` - | - 7 | PY3 = sys.version_info[0] == 3 - 8 | PY3 = version_info[0] == 3 - 9 | PY2 = sys.version_info[0] != 3 - | ^^^^^^^^^^^^^^^^^^^ YTT201 -10 | PY2 = version_info[0] != 3 - | - -YTT201.py:10:7: YTT201 `sys.version_info[0] == 3` referenced (python4), use `>=` - | - 8 | PY3 = version_info[0] == 3 - 9 | PY2 = sys.version_info[0] != 3 -10 | PY2 = version_info[0] != 3 - | ^^^^^^^^^^^^^^^ YTT201 - | - - diff --git a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT202_YTT202.py.snap b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT202_YTT202.py.snap deleted file mode 100644 index 9e97881717..0000000000 --- a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT202_YTT202.py.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_2020/mod.rs ---- -YTT202.py:4:4: YTT202 `six.PY3` referenced (python4), use `not six.PY2` - | -2 | from six import PY3 -3 | -4 | if six.PY3: - | ^^^^^^^ YTT202 -5 | print("3") -6 | if PY3: - | - -YTT202.py:6:4: YTT202 `six.PY3` referenced (python4), use `not six.PY2` - | -4 | if six.PY3: -5 | print("3") -6 | if PY3: - | ^^^ YTT202 -7 | print("3") - | - - diff --git a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT203_YTT203.py.snap b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT203_YTT203.py.snap deleted file mode 100644 index 3a7c81447c..0000000000 --- a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT203_YTT203.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_2020/mod.rs ---- -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 | -4 | sys.version_info[1] >= 5 - | ^^^^^^^^^^^^^^^^^^^ YTT203 -5 | version_info[1] < 6 - | - -YTT203.py:5:1: YTT203 `sys.version_info[1]` compared to integer (python4), compare `sys.version_info` to tuple - | -4 | sys.version_info[1] >= 5 -5 | version_info[1] < 6 - | ^^^^^^^^^^^^^^^ YTT203 - | - - diff --git a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT204_YTT204.py.snap b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT204_YTT204.py.snap deleted file mode 100644 index 602db6e4a1..0000000000 --- a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT204_YTT204.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_2020/mod.rs ---- -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 | -4 | sys.version_info.minor <= 7 - | ^^^^^^^^^^^^^^^^^^^^^^ YTT204 -5 | version_info.minor > 8 - | - -YTT204.py:5:1: YTT204 `sys.version_info.minor` compared to integer (python4), compare `sys.version_info` to tuple - | -4 | sys.version_info.minor <= 7 -5 | version_info.minor > 8 - | ^^^^^^^^^^^^^^^^^^ YTT204 - | - - diff --git a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT301_YTT301.py.snap b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT301_YTT301.py.snap deleted file mode 100644 index e7ebc0133a..0000000000 --- a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT301_YTT301.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_2020/mod.rs ---- -YTT301.py:4:12: YTT301 `sys.version[0]` referenced (python10), use `sys.version_info` - | -2 | from sys import version -3 | -4 | py_major = sys.version[0] - | ^^^^^^^^^^^ YTT301 -5 | py_major = version[0] - | - -YTT301.py:5:12: YTT301 `sys.version[0]` referenced (python10), use `sys.version_info` - | -4 | py_major = sys.version[0] -5 | py_major = version[0] - | ^^^^^^^ YTT301 - | - - diff --git a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT302_YTT302.py.snap b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT302_YTT302.py.snap deleted file mode 100644 index f05678199a..0000000000 --- a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT302_YTT302.py.snap +++ /dev/null @@ -1,50 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_2020/mod.rs ---- -YTT302.py:4:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info` - | -2 | from sys import version -3 | -4 | version < "3" - | ^^^^^^^ YTT302 -5 | sys.version < "3" -6 | sys.version <= "3" - | - -YTT302.py:5:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info` - | -4 | version < "3" -5 | sys.version < "3" - | ^^^^^^^^^^^ YTT302 -6 | sys.version <= "3" -7 | sys.version > "3" - | - -YTT302.py:6:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info` - | -4 | version < "3" -5 | sys.version < "3" -6 | sys.version <= "3" - | ^^^^^^^^^^^ YTT302 -7 | sys.version > "3" -8 | sys.version >= "3" - | - -YTT302.py:7:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info` - | -5 | sys.version < "3" -6 | sys.version <= "3" -7 | sys.version > "3" - | ^^^^^^^^^^^ YTT302 -8 | sys.version >= "3" - | - -YTT302.py:8:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info` - | -6 | sys.version <= "3" -7 | sys.version > "3" -8 | sys.version >= "3" - | ^^^^^^^^^^^ YTT302 - | - - diff --git a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT303_YTT303.py.snap b/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT303_YTT303.py.snap deleted file mode 100644 index 43bd099221..0000000000 --- a/crates/ruff/src/rules/flake8_2020/snapshots/ruff__rules__flake8_2020__tests__YTT303_YTT303.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_2020/mod.rs ---- -YTT303.py:4:7: YTT303 `sys.version[:1]` referenced (python10), use `sys.version_info` - | -2 | from sys import version -3 | -4 | print(sys.version[:1]) - | ^^^^^^^^^^^ YTT303 -5 | print(version[:1]) - | - -YTT303.py:5:7: YTT303 `sys.version[:1]` referenced (python10), use `sys.version_info` - | -4 | print(sys.version[:1]) -5 | print(version[:1]) - | ^^^^^^^ YTT303 - | - - diff --git a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__allow_nested_overload.snap b/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__allow_nested_overload.snap deleted file mode 100644 index 6c8856dcfa..0000000000 --- a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__allow_nested_overload.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_annotations/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__allow_overload.snap b/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__allow_overload.snap deleted file mode 100644 index d9c0c2a7dd..0000000000 --- a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__allow_overload.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_annotations/mod.rs ---- -allow_overload.py:29:9: ANN201 Missing return type annotation for public function `bar` - | -28 | class X: -29 | def bar(i): - | ^^^ ANN201 -30 | return i - | - - diff --git a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__allow_star_arg_any.snap b/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__allow_star_arg_any.snap deleted file mode 100644 index 0731cfd1ce..0000000000 --- a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__allow_star_arg_any.snap +++ /dev/null @@ -1,36 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_annotations/mod.rs ---- -allow_star_arg_any.py:10:12: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` - | - 9 | # ANN401 -10 | def foo(a: Any, *args: str, **kwargs: str) -> int: - | ^^^ ANN401 -11 | pass - | - -allow_star_arg_any.py:15:47: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo` - | -14 | # ANN401 -15 | def foo(a: int, *args: str, **kwargs: str) -> Any: - | ^^^ ANN401 -16 | pass - | - -allow_star_arg_any.py:40:29: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` - | -39 | # ANN401 -40 | def foo_method(self, a: Any, *params: str, **options: str) -> int: - | ^^^ ANN401 -41 | pass - | - -allow_star_arg_any.py:44:67: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo_method` - | -43 | # ANN401 -44 | def foo_method(self, a: int, *params: str, **options: str) -> Any: - | ^^^ ANN401 -45 | pass - | - - diff --git a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__defaults.snap b/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__defaults.snap deleted file mode 100644 index 03944c6d78..0000000000 --- a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__defaults.snap +++ /dev/null @@ -1,263 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_annotations/mod.rs ---- -annotation_presence.py:5:5: ANN201 Missing return type annotation for public function `foo` - | -4 | # Error -5 | def foo(a, b): - | ^^^ ANN201 -6 | pass - | - -annotation_presence.py:5:9: ANN001 Missing type annotation for function argument `a` - | -4 | # Error -5 | def foo(a, b): - | ^ ANN001 -6 | pass - | - -annotation_presence.py:5:12: ANN001 Missing type annotation for function argument `b` - | -4 | # Error -5 | def foo(a, b): - | ^ ANN001 -6 | pass - | - -annotation_presence.py:10:5: ANN201 Missing return type annotation for public function `foo` - | - 9 | # Error -10 | def foo(a: int, b): - | ^^^ ANN201 -11 | pass - | - -annotation_presence.py:10:17: ANN001 Missing type annotation for function argument `b` - | - 9 | # Error -10 | def foo(a: int, b): - | ^ ANN001 -11 | pass - | - -annotation_presence.py:15:17: ANN001 Missing type annotation for function argument `b` - | -14 | # Error -15 | def foo(a: int, b) -> int: - | ^ ANN001 -16 | pass - | - -annotation_presence.py:20:5: ANN201 Missing return type annotation for public function `foo` - | -19 | # Error -20 | def foo(a: int, b: int): - | ^^^ ANN201 -21 | pass - | - -annotation_presence.py:25:5: ANN201 Missing return type annotation for public function `foo` - | -24 | # Error -25 | def foo(): - | ^^^ ANN201 -26 | pass - | - -annotation_presence.py:45:12: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` - | -44 | # ANN401 -45 | def foo(a: Any, *args: str, **kwargs: str) -> int: - | ^^^ ANN401 -46 | pass - | - -annotation_presence.py:50:47: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo` - | -49 | # ANN401 -50 | def foo(a: int, *args: str, **kwargs: str) -> Any: - | ^^^ ANN401 -51 | pass - | - -annotation_presence.py:55:24: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*args` - | -54 | # ANN401 -55 | def foo(a: int, *args: Any, **kwargs: Any) -> int: - | ^^^ ANN401 -56 | pass - | - -annotation_presence.py:55:39: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**kwargs` - | -54 | # ANN401 -55 | def foo(a: int, *args: Any, **kwargs: Any) -> int: - | ^^^ ANN401 -56 | pass - | - -annotation_presence.py:60:24: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*args` - | -59 | # ANN401 -60 | def foo(a: int, *args: Any, **kwargs: str) -> int: - | ^^^ ANN401 -61 | pass - | - -annotation_presence.py:65:39: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**kwargs` - | -64 | # ANN401 -65 | def foo(a: int, *args: str, **kwargs: Any) -> int: - | ^^^ ANN401 -66 | pass - | - -annotation_presence.py:75:13: ANN101 Missing type annotation for `self` in method - | -74 | # ANN101 -75 | def foo(self, a: int, b: int) -> int: - | ^^^^ ANN101 -76 | pass - | - -annotation_presence.py:79:29: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` - | -78 | # ANN401 -79 | def foo(self: "Foo", a: Any, *params: str, **options: str) -> int: - | ^^^ ANN401 -80 | pass - | - -annotation_presence.py:83:67: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo` - | -82 | # ANN401 -83 | def foo(self: "Foo", a: int, *params: str, **options: str) -> Any: - | ^^^ ANN401 -84 | pass - | - -annotation_presence.py:87:43: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*params` - | -86 | # ANN401 -87 | def foo(self: "Foo", a: int, *params: Any, **options: Any) -> int: - | ^^^ ANN401 -88 | pass - | - -annotation_presence.py:87:59: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**options` - | -86 | # ANN401 -87 | def foo(self: "Foo", a: int, *params: Any, **options: Any) -> int: - | ^^^ ANN401 -88 | pass - | - -annotation_presence.py:91:43: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*params` - | -90 | # ANN401 -91 | def foo(self: "Foo", a: int, *params: Any, **options: str) -> int: - | ^^^ ANN401 -92 | pass - | - -annotation_presence.py:95:59: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**options` - | -94 | # ANN401 -95 | def foo(self: "Foo", a: int, *params: str, **options: Any) -> int: - | ^^^ ANN401 -96 | pass - | - -annotation_presence.py:130:13: ANN102 Missing type annotation for `cls` in classmethod - | -128 | # ANN102 -129 | @classmethod -130 | def foo(cls, a: int, b: int) -> int: - | ^^^ ANN102 -131 | pass - | - -annotation_presence.py:134:13: ANN101 Missing type annotation for `self` in method - | -133 | # ANN101 -134 | def foo(self, /, a: int, b: int) -> int: - | ^^^^ ANN101 -135 | pass - | - -annotation_presence.py:149:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` - | -148 | # ANN401 -149 | def f(a: Any | int) -> None: ... - | ^^^^^^^^^ ANN401 -150 | def f(a: int | Any) -> None: ... -151 | def f(a: Union[str, bytes, Any]) -> None: ... - | - -annotation_presence.py:150:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` - | -148 | # ANN401 -149 | def f(a: Any | int) -> None: ... -150 | def f(a: int | Any) -> None: ... - | ^^^^^^^^^ ANN401 -151 | def f(a: Union[str, bytes, Any]) -> None: ... -152 | def f(a: Optional[Any]) -> None: ... - | - -annotation_presence.py:151:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` - | -149 | def f(a: Any | int) -> None: ... -150 | def f(a: int | Any) -> None: ... -151 | def f(a: Union[str, bytes, Any]) -> None: ... - | ^^^^^^^^^^^^^^^^^^^^^^ ANN401 -152 | def f(a: Optional[Any]) -> None: ... -153 | def f(a: Annotated[Any, ...]) -> None: ... - | - -annotation_presence.py:152:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` - | -150 | def f(a: int | Any) -> None: ... -151 | def f(a: Union[str, bytes, Any]) -> None: ... -152 | def f(a: Optional[Any]) -> None: ... - | ^^^^^^^^^^^^^ ANN401 -153 | def f(a: Annotated[Any, ...]) -> None: ... -154 | def f(a: "Union[str, bytes, Any]") -> None: ... - | - -annotation_presence.py:153:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` - | -151 | def f(a: Union[str, bytes, Any]) -> None: ... -152 | def f(a: Optional[Any]) -> None: ... -153 | def f(a: Annotated[Any, ...]) -> None: ... - | ^^^^^^^^^^^^^^^^^^^ ANN401 -154 | def f(a: "Union[str, bytes, Any]") -> None: ... - | - -annotation_presence.py:154:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` - | -152 | def f(a: Optional[Any]) -> None: ... -153 | def f(a: Annotated[Any, ...]) -> None: ... -154 | def f(a: "Union[str, bytes, Any]") -> None: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^ ANN401 - | - -annotation_presence.py:159:9: ANN204 [*] Missing return type annotation for special method `__init__` - | -157 | class Foo: -158 | @decorator() -159 | def __init__(self: "Foo", foo: int): - | ^^^^^^^^ ANN204 -160 | ... - | - = help: Add `None` return type - -ℹ Suggested fix -156 156 | -157 157 | class Foo: -158 158 | @decorator() -159 |- def __init__(self: "Foo", foo: int): - 159 |+ def __init__(self: "Foo", foo: int) -> None: -160 160 | ... - - diff --git a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__ignore_fully_untyped.snap b/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__ignore_fully_untyped.snap deleted file mode 100644 index 11460a4399..0000000000 --- a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__ignore_fully_untyped.snap +++ /dev/null @@ -1,41 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_annotations/mod.rs ---- -ignore_fully_untyped.py:24:5: ANN201 Missing return type annotation for public function `error_partially_typed_1` - | -24 | def error_partially_typed_1(a: int, b): - | ^^^^^^^^^^^^^^^^^^^^^^^ ANN201 -25 | pass - | - -ignore_fully_untyped.py:24:37: ANN001 Missing type annotation for function argument `b` - | -24 | def error_partially_typed_1(a: int, b): - | ^ ANN001 -25 | pass - | - -ignore_fully_untyped.py:28:37: ANN001 Missing type annotation for function argument `b` - | -28 | def error_partially_typed_2(a: int, b) -> int: - | ^ ANN001 -29 | pass - | - -ignore_fully_untyped.py:32:5: ANN201 Missing return type annotation for public function `error_partially_typed_3` - | -32 | def error_partially_typed_3(a: int, b: int): - | ^^^^^^^^^^^^^^^^^^^^^^^ ANN201 -33 | pass - | - -ignore_fully_untyped.py:43:9: ANN201 Missing return type annotation for public function `error_typed_self` - | -41 | pass -42 | -43 | def error_typed_self(self: X): - | ^^^^^^^^^^^^^^^^ ANN201 -44 | pass - | - - diff --git a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__mypy_init_return.snap b/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__mypy_init_return.snap deleted file mode 100644 index e12aa959f5..0000000000 --- a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__mypy_init_return.snap +++ /dev/null @@ -1,70 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_annotations/mod.rs ---- -mypy_init_return.py:5:9: ANN204 [*] Missing return type annotation for special method `__init__` - | -3 | # Error -4 | class Foo: -5 | def __init__(self): - | ^^^^^^^^ ANN204 -6 | ... - | - = help: Add `None` return type - -ℹ Suggested fix -2 2 | -3 3 | # Error -4 4 | class Foo: -5 |- def __init__(self): - 5 |+ def __init__(self) -> None: -6 6 | ... -7 7 | -8 8 | - -mypy_init_return.py:11:9: ANN204 [*] Missing return type annotation for special method `__init__` - | - 9 | # Error -10 | class Foo: -11 | def __init__(self, foo): - | ^^^^^^^^ ANN204 -12 | ... - | - = help: Add `None` return type - -ℹ Suggested fix -8 8 | -9 9 | # Error -10 10 | class Foo: -11 |- def __init__(self, foo): - 11 |+ def __init__(self, foo) -> None: -12 12 | ... -13 13 | -14 14 | - -mypy_init_return.py:40:5: ANN202 Missing return type annotation for private function `__init__` - | -39 | # Error -40 | def __init__(self, foo: int): - | ^^^^^^^^ ANN202 -41 | ... - | - -mypy_init_return.py:47:9: ANN204 [*] Missing return type annotation for special method `__init__` - | -45 | # of a vararg falsely indicated that the function has a typed argument. -46 | class Foo: -47 | def __init__(self, *arg): - | ^^^^^^^^ ANN204 -48 | ... - | - = help: Add `None` return type - -ℹ Suggested fix -44 44 | # Error – used to be ok for a moment since the mere presence -45 45 | # of a vararg falsely indicated that the function has a typed argument. -46 46 | class Foo: -47 |- def __init__(self, *arg): - 47 |+ def __init__(self, *arg) -> None: -48 48 | ... - - diff --git a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__simple_magic_methods.snap b/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__simple_magic_methods.snap deleted file mode 100644 index 58772fbe14..0000000000 --- a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__simple_magic_methods.snap +++ /dev/null @@ -1,279 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_annotations/mod.rs ---- -simple_magic_methods.py:2:9: ANN204 [*] Missing return type annotation for special method `__str__` - | -1 | class Foo: -2 | def __str__(self): - | ^^^^^^^ ANN204 -3 | ... - | - = help: Add `None` return type - -ℹ Suggested fix -1 1 | class Foo: -2 |- def __str__(self): - 2 |+ def __str__(self) -> str: -3 3 | ... -4 4 | -5 5 | def __repr__(self): - -simple_magic_methods.py:5:9: ANN204 [*] Missing return type annotation for special method `__repr__` - | -3 | ... -4 | -5 | def __repr__(self): - | ^^^^^^^^ ANN204 -6 | ... - | - = help: Add `None` return type - -ℹ Suggested fix -2 2 | def __str__(self): -3 3 | ... -4 4 | -5 |- def __repr__(self): - 5 |+ def __repr__(self) -> str: -6 6 | ... -7 7 | -8 8 | def __len__(self): - -simple_magic_methods.py:8:9: ANN204 [*] Missing return type annotation for special method `__len__` - | -6 | ... -7 | -8 | def __len__(self): - | ^^^^^^^ ANN204 -9 | ... - | - = help: Add `None` return type - -ℹ Suggested fix -5 5 | def __repr__(self): -6 6 | ... -7 7 | -8 |- def __len__(self): - 8 |+ def __len__(self) -> int: -9 9 | ... -10 10 | -11 11 | def __length_hint__(self): - -simple_magic_methods.py:11:9: ANN204 [*] Missing return type annotation for special method `__length_hint__` - | - 9 | ... -10 | -11 | def __length_hint__(self): - | ^^^^^^^^^^^^^^^ ANN204 -12 | ... - | - = help: Add `None` return type - -ℹ Suggested fix -8 8 | def __len__(self): -9 9 | ... -10 10 | -11 |- def __length_hint__(self): - 11 |+ def __length_hint__(self) -> int: -12 12 | ... -13 13 | -14 14 | def __init__(self): - -simple_magic_methods.py:14:9: ANN204 [*] Missing return type annotation for special method `__init__` - | -12 | ... -13 | -14 | def __init__(self): - | ^^^^^^^^ ANN204 -15 | ... - | - = help: Add `None` return type - -ℹ Suggested fix -11 11 | def __length_hint__(self): -12 12 | ... -13 13 | -14 |- def __init__(self): - 14 |+ def __init__(self) -> None: -15 15 | ... -16 16 | -17 17 | def __del__(self): - -simple_magic_methods.py:17:9: ANN204 [*] Missing return type annotation for special method `__del__` - | -15 | ... -16 | -17 | def __del__(self): - | ^^^^^^^ ANN204 -18 | ... - | - = help: Add `None` return type - -ℹ Suggested fix -14 14 | def __init__(self): -15 15 | ... -16 16 | -17 |- def __del__(self): - 17 |+ def __del__(self) -> None: -18 18 | ... -19 19 | -20 20 | def __bool__(self): - -simple_magic_methods.py:20:9: ANN204 [*] Missing return type annotation for special method `__bool__` - | -18 | ... -19 | -20 | def __bool__(self): - | ^^^^^^^^ ANN204 -21 | ... - | - = help: Add `None` return type - -ℹ Suggested fix -17 17 | def __del__(self): -18 18 | ... -19 19 | -20 |- def __bool__(self): - 20 |+ def __bool__(self) -> bool: -21 21 | ... -22 22 | -23 23 | def __bytes__(self): - -simple_magic_methods.py:23:9: ANN204 [*] Missing return type annotation for special method `__bytes__` - | -21 | ... -22 | -23 | def __bytes__(self): - | ^^^^^^^^^ ANN204 -24 | ... - | - = help: Add `None` return type - -ℹ Suggested fix -20 20 | def __bool__(self): -21 21 | ... -22 22 | -23 |- def __bytes__(self): - 23 |+ def __bytes__(self) -> bytes: -24 24 | ... -25 25 | -26 26 | def __format__(self, format_spec): - -simple_magic_methods.py:26:9: ANN204 [*] Missing return type annotation for special method `__format__` - | -24 | ... -25 | -26 | def __format__(self, format_spec): - | ^^^^^^^^^^ ANN204 -27 | ... - | - = help: Add `None` return type - -ℹ Suggested fix -23 23 | def __bytes__(self): -24 24 | ... -25 25 | -26 |- def __format__(self, format_spec): - 26 |+ def __format__(self, format_spec) -> str: -27 27 | ... -28 28 | -29 29 | def __contains__(self, item): - -simple_magic_methods.py:29:9: ANN204 [*] Missing return type annotation for special method `__contains__` - | -27 | ... -28 | -29 | def __contains__(self, item): - | ^^^^^^^^^^^^ ANN204 -30 | ... - | - = help: Add `None` return type - -ℹ Suggested fix -26 26 | def __format__(self, format_spec): -27 27 | ... -28 28 | -29 |- def __contains__(self, item): - 29 |+ def __contains__(self, item) -> bool: -30 30 | ... -31 31 | -32 32 | def __complex__(self): - -simple_magic_methods.py:32:9: ANN204 [*] Missing return type annotation for special method `__complex__` - | -30 | ... -31 | -32 | def __complex__(self): - | ^^^^^^^^^^^ ANN204 -33 | ... - | - = help: Add `None` return type - -ℹ Suggested fix -29 29 | def __contains__(self, item): -30 30 | ... -31 31 | -32 |- def __complex__(self): - 32 |+ def __complex__(self) -> complex: -33 33 | ... -34 34 | -35 35 | def __int__(self): - -simple_magic_methods.py:35:9: ANN204 [*] Missing return type annotation for special method `__int__` - | -33 | ... -34 | -35 | def __int__(self): - | ^^^^^^^ ANN204 -36 | ... - | - = help: Add `None` return type - -ℹ Suggested fix -32 32 | def __complex__(self): -33 33 | ... -34 34 | -35 |- def __int__(self): - 35 |+ def __int__(self) -> int: -36 36 | ... -37 37 | -38 38 | def __float__(self): - -simple_magic_methods.py:38:9: ANN204 [*] Missing return type annotation for special method `__float__` - | -36 | ... -37 | -38 | def __float__(self): - | ^^^^^^^^^ ANN204 -39 | ... - | - = help: Add `None` return type - -ℹ Suggested fix -35 35 | def __int__(self): -36 36 | ... -37 37 | -38 |- def __float__(self): - 38 |+ def __float__(self) -> float: -39 39 | ... -40 40 | -41 41 | def __index__(self): - -simple_magic_methods.py:41:9: ANN204 [*] Missing return type annotation for special method `__index__` - | -39 | ... -40 | -41 | def __index__(self): - | ^^^^^^^^^ ANN204 -42 | ... - | - = help: Add `None` return type - -ℹ Suggested fix -38 38 | def __float__(self): -39 39 | ... -40 40 | -41 |- def __index__(self): - 41 |+ def __index__(self) -> int: -42 42 | ... - - diff --git a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__suppress_dummy_args.snap b/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__suppress_dummy_args.snap deleted file mode 100644 index 6c8856dcfa..0000000000 --- a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__suppress_dummy_args.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_annotations/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__suppress_none_returning.snap b/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__suppress_none_returning.snap deleted file mode 100644 index b516544708..0000000000 --- a/crates/ruff/src/rules/flake8_annotations/snapshots/ruff__rules__flake8_annotations__tests__suppress_none_returning.snap +++ /dev/null @@ -1,29 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_annotations/mod.rs ---- -suppress_none_returning.py:45:5: ANN201 Missing return type annotation for public function `foo` - | -44 | # Error -45 | def foo(): - | ^^^ ANN201 -46 | return True - | - -suppress_none_returning.py:50:5: ANN201 Missing return type annotation for public function `foo` - | -49 | # Error -50 | def foo(): - | ^^^ ANN201 -51 | a = 2 + 2 -52 | if a == 4: - | - -suppress_none_returning.py:59:9: ANN001 Missing type annotation for function argument `a` - | -58 | # Error (on the argument, but not the return type) -59 | def foo(a): - | ^ ANN001 -60 | a = 2 + 2 - | - - diff --git a/crates/ruff/src/rules/flake8_async/snapshots/ruff__rules__flake8_async__tests__ASYNC100_ASYNC100.py.snap b/crates/ruff/src/rules/flake8_async/snapshots/ruff__rules__flake8_async__tests__ASYNC100_ASYNC100.py.snap deleted file mode 100644 index 7eb28ea781..0000000000 --- a/crates/ruff/src/rules/flake8_async/snapshots/ruff__rules__flake8_async__tests__ASYNC100_ASYNC100.py.snap +++ /dev/null @@ -1,39 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_async/mod.rs ---- -ASYNC100.py:7:5: ASYNC100 Async functions should not call blocking HTTP methods - | -6 | async def foo(): -7 | urllib.request.urlopen("http://example.com/foo/bar").read() - | ^^^^^^^^^^^^^^^^^^^^^^ ASYNC100 - | - -ASYNC100.py:11:5: ASYNC100 Async functions should not call blocking HTTP methods - | -10 | async def foo(): -11 | requests.get() - | ^^^^^^^^^^^^ ASYNC100 - | - -ASYNC100.py:15:5: ASYNC100 Async functions should not call blocking HTTP methods - | -14 | async def foo(): -15 | httpx.get() - | ^^^^^^^^^ ASYNC100 - | - -ASYNC100.py:19:5: ASYNC100 Async functions should not call blocking HTTP methods - | -18 | async def foo(): -19 | requests.post() - | ^^^^^^^^^^^^^ ASYNC100 - | - -ASYNC100.py:23:5: ASYNC100 Async functions should not call blocking HTTP methods - | -22 | async def foo(): -23 | httpx.post() - | ^^^^^^^^^^ ASYNC100 - | - - diff --git a/crates/ruff/src/rules/flake8_async/snapshots/ruff__rules__flake8_async__tests__ASYNC101_ASYNC101.py.snap b/crates/ruff/src/rules/flake8_async/snapshots/ruff__rules__flake8_async__tests__ASYNC101_ASYNC101.py.snap deleted file mode 100644 index de9fbdbd99..0000000000 --- a/crates/ruff/src/rules/flake8_async/snapshots/ruff__rules__flake8_async__tests__ASYNC101_ASYNC101.py.snap +++ /dev/null @@ -1,46 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_async/mod.rs ---- -ASYNC101.py:7:5: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods - | -6 | async def foo(): -7 | open("foo") - | ^^^^ ASYNC101 - | - -ASYNC101.py:11:5: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods - | -10 | async def foo(): -11 | time.sleep(1) - | ^^^^^^^^^^ ASYNC101 - | - -ASYNC101.py:15:5: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods - | -14 | async def foo(): -15 | subprocess.run("foo") - | ^^^^^^^^^^^^^^ ASYNC101 - | - -ASYNC101.py:19:5: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods - | -18 | async def foo(): -19 | subprocess.call("foo") - | ^^^^^^^^^^^^^^^ ASYNC101 - | - -ASYNC101.py:27:5: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods - | -26 | async def foo(): -27 | os.wait4(10) - | ^^^^^^^^ ASYNC101 - | - -ASYNC101.py:31:5: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods - | -30 | async def foo(): -31 | os.wait(12) - | ^^^^^^^ ASYNC101 - | - - diff --git a/crates/ruff/src/rules/flake8_async/snapshots/ruff__rules__flake8_async__tests__ASYNC102_ASYNC102.py.snap b/crates/ruff/src/rules/flake8_async/snapshots/ruff__rules__flake8_async__tests__ASYNC102_ASYNC102.py.snap deleted file mode 100644 index 0a2c08e20b..0000000000 --- a/crates/ruff/src/rules/flake8_async/snapshots/ruff__rules__flake8_async__tests__ASYNC102_ASYNC102.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_async/mod.rs ---- -ASYNC102.py:5:5: ASYNC102 Async functions should not call synchronous `os` methods - | -4 | async def foo(): -5 | os.popen() - | ^^^^^^^^ ASYNC102 - | - -ASYNC102.py:9:5: ASYNC102 Async functions should not call synchronous `os` methods - | -8 | async def foo(): -9 | os.spawnl() - | ^^^^^^^^^ ASYNC102 - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S101_S101.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S101_S101.py.snap deleted file mode 100644 index 1157f9f143..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S101_S101.py.snap +++ /dev/null @@ -1,27 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S101.py:1:1: S101 Use of `assert` detected - | -1 | assert True # S101 - | ^^^^^^ S101 - | - -S101.py:6:5: S101 Use of `assert` detected - | -4 | def fn(): -5 | x = 1 -6 | assert x == 1 # S101 - | ^^^^^^ S101 -7 | assert x == 2 # S101 - | - -S101.py:7:5: S101 Use of `assert` detected - | -5 | x = 1 -6 | assert x == 1 # S101 -7 | assert x == 2 # S101 - | ^^^^^^ S101 - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S102_S102.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S102_S102.py.snap deleted file mode 100644 index 075092ceda..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S102_S102.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S102.py:3:5: S102 Use of `exec` detected - | -1 | def fn(): -2 | # Error -3 | exec('x = 2') - | ^^^^ S102 -4 | -5 | exec('y = 3') - | - -S102.py:5:1: S102 Use of `exec` detected - | -3 | exec('x = 2') -4 | -5 | exec('y = 3') - | ^^^^ S102 - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S103_S103.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S103_S103.py.snap deleted file mode 100644 index 46708b1439..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S103_S103.py.snap +++ /dev/null @@ -1,131 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S103.py:6:25: S103 `os.chmod` setting a permissive mask `0o227` on file or directory - | -4 | keyfile = "foo" -5 | -6 | os.chmod("/etc/passwd", 0o227) # Error - | ^^^^^ S103 -7 | os.chmod("/etc/passwd", 0o7) # Error -8 | os.chmod("/etc/passwd", 0o664) # OK - | - -S103.py:7:25: S103 `os.chmod` setting a permissive mask `0o7` on file or directory - | -6 | os.chmod("/etc/passwd", 0o227) # Error -7 | os.chmod("/etc/passwd", 0o7) # Error - | ^^^ S103 -8 | os.chmod("/etc/passwd", 0o664) # OK -9 | os.chmod("/etc/passwd", 0o777) # Error - | - -S103.py:9:25: S103 `os.chmod` setting a permissive mask `0o777` on file or directory - | - 7 | os.chmod("/etc/passwd", 0o7) # Error - 8 | os.chmod("/etc/passwd", 0o664) # OK - 9 | os.chmod("/etc/passwd", 0o777) # Error - | ^^^^^ S103 -10 | os.chmod("/etc/passwd", 0o770) # Error -11 | os.chmod("/etc/passwd", 0o776) # Error - | - -S103.py:10:25: S103 `os.chmod` setting a permissive mask `0o770` on file or directory - | - 8 | os.chmod("/etc/passwd", 0o664) # OK - 9 | os.chmod("/etc/passwd", 0o777) # Error -10 | os.chmod("/etc/passwd", 0o770) # Error - | ^^^^^ S103 -11 | os.chmod("/etc/passwd", 0o776) # Error -12 | os.chmod("/etc/passwd", 0o760) # OK - | - -S103.py:11:25: S103 `os.chmod` setting a permissive mask `0o776` on file or directory - | - 9 | os.chmod("/etc/passwd", 0o777) # Error -10 | os.chmod("/etc/passwd", 0o770) # Error -11 | os.chmod("/etc/passwd", 0o776) # Error - | ^^^^^ S103 -12 | os.chmod("/etc/passwd", 0o760) # OK -13 | os.chmod("~/.bashrc", 511) # Error - | - -S103.py:13:23: S103 `os.chmod` setting a permissive mask `0o777` on file or directory - | -11 | os.chmod("/etc/passwd", 0o776) # Error -12 | os.chmod("/etc/passwd", 0o760) # OK -13 | os.chmod("~/.bashrc", 511) # Error - | ^^^ S103 -14 | os.chmod("/etc/hosts", 0o777) # Error -15 | os.chmod("/tmp/oh_hai", 0x1FF) # Error - | - -S103.py:14:24: S103 `os.chmod` setting a permissive mask `0o777` on file or directory - | -12 | os.chmod("/etc/passwd", 0o760) # OK -13 | os.chmod("~/.bashrc", 511) # Error -14 | os.chmod("/etc/hosts", 0o777) # Error - | ^^^^^ S103 -15 | os.chmod("/tmp/oh_hai", 0x1FF) # Error -16 | os.chmod("/etc/passwd", stat.S_IRWXU) # OK - | - -S103.py:15:25: S103 `os.chmod` setting a permissive mask `0o777` on file or directory - | -13 | os.chmod("~/.bashrc", 511) # Error -14 | os.chmod("/etc/hosts", 0o777) # Error -15 | os.chmod("/tmp/oh_hai", 0x1FF) # Error - | ^^^^^ S103 -16 | os.chmod("/etc/passwd", stat.S_IRWXU) # OK -17 | os.chmod(keyfile, 0o777) # Error - | - -S103.py:17:19: S103 `os.chmod` setting a permissive mask `0o777` on file or directory - | -15 | os.chmod("/tmp/oh_hai", 0x1FF) # Error -16 | os.chmod("/etc/passwd", stat.S_IRWXU) # OK -17 | os.chmod(keyfile, 0o777) # Error - | ^^^^^ S103 -18 | os.chmod(keyfile, 0o7 | 0o70 | 0o700) # Error -19 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU) # Error - | - -S103.py:18:19: S103 `os.chmod` setting a permissive mask `0o777` on file or directory - | -16 | os.chmod("/etc/passwd", stat.S_IRWXU) # OK -17 | os.chmod(keyfile, 0o777) # Error -18 | os.chmod(keyfile, 0o7 | 0o70 | 0o700) # Error - | ^^^^^^^^^^^^^^^^^^ S103 -19 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU) # Error -20 | os.chmod("~/hidden_exec", stat.S_IXGRP) # Error - | - -S103.py:19:19: S103 `os.chmod` setting a permissive mask `0o777` on file or directory - | -17 | os.chmod(keyfile, 0o777) # Error -18 | os.chmod(keyfile, 0o7 | 0o70 | 0o700) # Error -19 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S103 -20 | os.chmod("~/hidden_exec", stat.S_IXGRP) # Error -21 | os.chmod("~/hidden_exec", stat.S_IXOTH) # OK - | - -S103.py:20:27: S103 `os.chmod` setting a permissive mask `0o10` on file or directory - | -18 | os.chmod(keyfile, 0o7 | 0o70 | 0o700) # Error -19 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU) # Error -20 | os.chmod("~/hidden_exec", stat.S_IXGRP) # Error - | ^^^^^^^^^^^^ S103 -21 | os.chmod("~/hidden_exec", stat.S_IXOTH) # OK -22 | os.chmod("/etc/passwd", stat.S_IWOTH) # Error - | - -S103.py:22:25: S103 `os.chmod` setting a permissive mask `0o2` on file or directory - | -20 | os.chmod("~/hidden_exec", stat.S_IXGRP) # Error -21 | os.chmod("~/hidden_exec", stat.S_IXOTH) # OK -22 | os.chmod("/etc/passwd", stat.S_IWOTH) # Error - | ^^^^^^^^^^^^ S103 - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S104_S104.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S104_S104.py.snap deleted file mode 100644 index a6597d94ab..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S104_S104.py.snap +++ /dev/null @@ -1,35 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S104.py:9:1: S104 Possible binding to all interfaces - | - 8 | # Error - 9 | "0.0.0.0" - | ^^^^^^^^^ S104 -10 | '0.0.0.0' - | - -S104.py:10:1: S104 Possible binding to all interfaces - | - 8 | # Error - 9 | "0.0.0.0" -10 | '0.0.0.0' - | ^^^^^^^^^ S104 - | - -S104.py:14:6: S104 Possible binding to all interfaces - | -13 | # Error -14 | func("0.0.0.0") - | ^^^^^^^^^ S104 - | - -S104.py:18:9: S104 Possible binding to all interfaces - | -17 | def my_func(): -18 | x = "0.0.0.0" - | ^^^^^^^^^ S104 -19 | print(x) - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S105_S105.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S105_S105.py.snap deleted file mode 100644 index 76110502f3..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S105_S105.py.snap +++ /dev/null @@ -1,377 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S105.py:13:12: S105 Possible hardcoded password assigned to: "password" - | -12 | # Errors -13 | password = "s3cr3t" - | ^^^^^^^^ S105 -14 | _pass = "s3cr3t" -15 | passwd = "s3cr3t" - | - -S105.py:14:9: S105 Possible hardcoded password assigned to: "_pass" - | -12 | # Errors -13 | password = "s3cr3t" -14 | _pass = "s3cr3t" - | ^^^^^^^^ S105 -15 | passwd = "s3cr3t" -16 | pwd = "s3cr3t" - | - -S105.py:15:10: S105 Possible hardcoded password assigned to: "passwd" - | -13 | password = "s3cr3t" -14 | _pass = "s3cr3t" -15 | passwd = "s3cr3t" - | ^^^^^^^^ S105 -16 | pwd = "s3cr3t" -17 | secret = "s3cr3t" - | - -S105.py:16:7: S105 Possible hardcoded password assigned to: "pwd" - | -14 | _pass = "s3cr3t" -15 | passwd = "s3cr3t" -16 | pwd = "s3cr3t" - | ^^^^^^^^ S105 -17 | secret = "s3cr3t" -18 | token = "s3cr3t" - | - -S105.py:17:10: S105 Possible hardcoded password assigned to: "secret" - | -15 | passwd = "s3cr3t" -16 | pwd = "s3cr3t" -17 | secret = "s3cr3t" - | ^^^^^^^^ S105 -18 | token = "s3cr3t" -19 | secrete = "s3cr3t" - | - -S105.py:18:9: S105 Possible hardcoded password assigned to: "token" - | -16 | pwd = "s3cr3t" -17 | secret = "s3cr3t" -18 | token = "s3cr3t" - | ^^^^^^^^ S105 -19 | secrete = "s3cr3t" -20 | safe = password = "s3cr3t" - | - -S105.py:19:11: S105 Possible hardcoded password assigned to: "secrete" - | -17 | secret = "s3cr3t" -18 | token = "s3cr3t" -19 | secrete = "s3cr3t" - | ^^^^^^^^ S105 -20 | safe = password = "s3cr3t" -21 | password = safe = "s3cr3t" - | - -S105.py:20:19: S105 Possible hardcoded password assigned to: "password" - | -18 | token = "s3cr3t" -19 | secrete = "s3cr3t" -20 | safe = password = "s3cr3t" - | ^^^^^^^^ S105 -21 | password = safe = "s3cr3t" -22 | PASSWORD = "s3cr3t" - | - -S105.py:21:19: S105 Possible hardcoded password assigned to: "password" - | -19 | secrete = "s3cr3t" -20 | safe = password = "s3cr3t" -21 | password = safe = "s3cr3t" - | ^^^^^^^^ S105 -22 | PASSWORD = "s3cr3t" -23 | PassWord = "s3cr3t" - | - -S105.py:22:12: S105 Possible hardcoded password assigned to: "PASSWORD" - | -20 | safe = password = "s3cr3t" -21 | password = safe = "s3cr3t" -22 | PASSWORD = "s3cr3t" - | ^^^^^^^^ S105 -23 | PassWord = "s3cr3t" - | - -S105.py:23:12: S105 Possible hardcoded password assigned to: "PassWord" - | -21 | password = safe = "s3cr3t" -22 | PASSWORD = "s3cr3t" -23 | PassWord = "s3cr3t" - | ^^^^^^^^ S105 -24 | -25 | d["password"] = "s3cr3t" - | - -S105.py:25:17: S105 Possible hardcoded password assigned to: "password" - | -23 | PassWord = "s3cr3t" -24 | -25 | d["password"] = "s3cr3t" - | ^^^^^^^^ S105 -26 | d["pass"] = "s3cr3t" -27 | d["passwd"] = "s3cr3t" - | - -S105.py:26:13: S105 Possible hardcoded password assigned to: "pass" - | -25 | d["password"] = "s3cr3t" -26 | d["pass"] = "s3cr3t" - | ^^^^^^^^ S105 -27 | d["passwd"] = "s3cr3t" -28 | d["pwd"] = "s3cr3t" - | - -S105.py:27:15: S105 Possible hardcoded password assigned to: "passwd" - | -25 | d["password"] = "s3cr3t" -26 | d["pass"] = "s3cr3t" -27 | d["passwd"] = "s3cr3t" - | ^^^^^^^^ S105 -28 | d["pwd"] = "s3cr3t" -29 | d["secret"] = "s3cr3t" - | - -S105.py:28:12: S105 Possible hardcoded password assigned to: "pwd" - | -26 | d["pass"] = "s3cr3t" -27 | d["passwd"] = "s3cr3t" -28 | d["pwd"] = "s3cr3t" - | ^^^^^^^^ S105 -29 | d["secret"] = "s3cr3t" -30 | d["token"] = "s3cr3t" - | - -S105.py:29:15: S105 Possible hardcoded password assigned to: "secret" - | -27 | d["passwd"] = "s3cr3t" -28 | d["pwd"] = "s3cr3t" -29 | d["secret"] = "s3cr3t" - | ^^^^^^^^ S105 -30 | d["token"] = "s3cr3t" -31 | d["secrete"] = "s3cr3t" - | - -S105.py:30:14: S105 Possible hardcoded password assigned to: "token" - | -28 | d["pwd"] = "s3cr3t" -29 | d["secret"] = "s3cr3t" -30 | d["token"] = "s3cr3t" - | ^^^^^^^^ S105 -31 | d["secrete"] = "s3cr3t" -32 | safe = d["password"] = "s3cr3t" - | - -S105.py:31:16: S105 Possible hardcoded password assigned to: "secrete" - | -29 | d["secret"] = "s3cr3t" -30 | d["token"] = "s3cr3t" -31 | d["secrete"] = "s3cr3t" - | ^^^^^^^^ S105 -32 | safe = d["password"] = "s3cr3t" -33 | d["password"] = safe = "s3cr3t" - | - -S105.py:32:24: S105 Possible hardcoded password assigned to: "password" - | -30 | d["token"] = "s3cr3t" -31 | d["secrete"] = "s3cr3t" -32 | safe = d["password"] = "s3cr3t" - | ^^^^^^^^ S105 -33 | d["password"] = safe = "s3cr3t" - | - -S105.py:33:24: S105 Possible hardcoded password assigned to: "password" - | -31 | d["secrete"] = "s3cr3t" -32 | safe = d["password"] = "s3cr3t" -33 | d["password"] = safe = "s3cr3t" - | ^^^^^^^^ S105 - | - -S105.py:37:16: S105 Possible hardcoded password assigned to: "password" - | -36 | class MyClass: -37 | password = "s3cr3t" - | ^^^^^^^^ S105 -38 | safe = password - | - -S105.py:41:20: S105 Possible hardcoded password assigned to: "password" - | -41 | MyClass.password = "s3cr3t" - | ^^^^^^^^ S105 -42 | MyClass._pass = "s3cr3t" -43 | MyClass.passwd = "s3cr3t" - | - -S105.py:42:17: S105 Possible hardcoded password assigned to: "_pass" - | -41 | MyClass.password = "s3cr3t" -42 | MyClass._pass = "s3cr3t" - | ^^^^^^^^ S105 -43 | MyClass.passwd = "s3cr3t" -44 | MyClass.pwd = "s3cr3t" - | - -S105.py:43:18: S105 Possible hardcoded password assigned to: "passwd" - | -41 | MyClass.password = "s3cr3t" -42 | MyClass._pass = "s3cr3t" -43 | MyClass.passwd = "s3cr3t" - | ^^^^^^^^ S105 -44 | MyClass.pwd = "s3cr3t" -45 | MyClass.secret = "s3cr3t" - | - -S105.py:44:15: S105 Possible hardcoded password assigned to: "pwd" - | -42 | MyClass._pass = "s3cr3t" -43 | MyClass.passwd = "s3cr3t" -44 | MyClass.pwd = "s3cr3t" - | ^^^^^^^^ S105 -45 | MyClass.secret = "s3cr3t" -46 | MyClass.token = "s3cr3t" - | - -S105.py:45:18: S105 Possible hardcoded password assigned to: "secret" - | -43 | MyClass.passwd = "s3cr3t" -44 | MyClass.pwd = "s3cr3t" -45 | MyClass.secret = "s3cr3t" - | ^^^^^^^^ S105 -46 | MyClass.token = "s3cr3t" -47 | MyClass.secrete = "s3cr3t" - | - -S105.py:46:17: S105 Possible hardcoded password assigned to: "token" - | -44 | MyClass.pwd = "s3cr3t" -45 | MyClass.secret = "s3cr3t" -46 | MyClass.token = "s3cr3t" - | ^^^^^^^^ S105 -47 | MyClass.secrete = "s3cr3t" - | - -S105.py:47:19: S105 Possible hardcoded password assigned to: "secrete" - | -45 | MyClass.secret = "s3cr3t" -46 | MyClass.token = "s3cr3t" -47 | MyClass.secrete = "s3cr3t" - | ^^^^^^^^ S105 -48 | -49 | password == "s3cr3t" - | - -S105.py:49:13: S105 Possible hardcoded password assigned to: "password" - | -47 | MyClass.secrete = "s3cr3t" -48 | -49 | password == "s3cr3t" - | ^^^^^^^^ S105 -50 | _pass == "s3cr3t" -51 | passwd == "s3cr3t" - | - -S105.py:50:10: S105 Possible hardcoded password assigned to: "_pass" - | -49 | password == "s3cr3t" -50 | _pass == "s3cr3t" - | ^^^^^^^^ S105 -51 | passwd == "s3cr3t" -52 | pwd == "s3cr3t" - | - -S105.py:51:11: S105 Possible hardcoded password assigned to: "passwd" - | -49 | password == "s3cr3t" -50 | _pass == "s3cr3t" -51 | passwd == "s3cr3t" - | ^^^^^^^^ S105 -52 | pwd == "s3cr3t" -53 | secret == "s3cr3t" - | - -S105.py:52:8: S105 Possible hardcoded password assigned to: "pwd" - | -50 | _pass == "s3cr3t" -51 | passwd == "s3cr3t" -52 | pwd == "s3cr3t" - | ^^^^^^^^ S105 -53 | secret == "s3cr3t" -54 | token == "s3cr3t" - | - -S105.py:53:11: S105 Possible hardcoded password assigned to: "secret" - | -51 | passwd == "s3cr3t" -52 | pwd == "s3cr3t" -53 | secret == "s3cr3t" - | ^^^^^^^^ S105 -54 | token == "s3cr3t" -55 | secrete == "s3cr3t" - | - -S105.py:54:10: S105 Possible hardcoded password assigned to: "token" - | -52 | pwd == "s3cr3t" -53 | secret == "s3cr3t" -54 | token == "s3cr3t" - | ^^^^^^^^ S105 -55 | secrete == "s3cr3t" -56 | password == safe == "s3cr3t" - | - -S105.py:55:12: S105 Possible hardcoded password assigned to: "secrete" - | -53 | secret == "s3cr3t" -54 | token == "s3cr3t" -55 | secrete == "s3cr3t" - | ^^^^^^^^ S105 -56 | password == safe == "s3cr3t" - | - -S105.py:56:21: S105 Possible hardcoded password assigned to: "password" - | -54 | token == "s3cr3t" -55 | secrete == "s3cr3t" -56 | password == safe == "s3cr3t" - | ^^^^^^^^ S105 -57 | -58 | if token == "1\n2": - | - -S105.py:58:13: S105 Possible hardcoded password assigned to: "token" - | -56 | password == safe == "s3cr3t" -57 | -58 | if token == "1\n2": - | ^^^^^^ S105 -59 | pass - | - -S105.py:61:13: S105 Possible hardcoded password assigned to: "token" - | -59 | pass -60 | -61 | if token == "3\t4": - | ^^^^^^ S105 -62 | pass - | - -S105.py:64:13: S105 Possible hardcoded password assigned to: "token" - | -62 | pass -63 | -64 | if token == "5\r6": - | ^^^^^^ S105 -65 | pass - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S106_S106.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S106_S106.py.snap deleted file mode 100644 index aba4b12cb6..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S106_S106.py.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S106.py:14:9: S106 Possible hardcoded password assigned to argument: "password" - | -13 | # Error -14 | func(1, password="s3cr3t") - | ^^^^^^^^^^^^^^^^^ S106 - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S107_S107.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S107_S107.py.snap deleted file mode 100644 index ccfba2b0c9..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S107_S107.py.snap +++ /dev/null @@ -1,39 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S107.py:5:29: S107 Possible hardcoded password assigned to function default: "password" - | -5 | def default(first, password="default"): - | ^^^^^^^^^ S107 -6 | pass - | - -S107.py:13:45: S107 Possible hardcoded password assigned to function default: "password" - | -13 | def default_posonly(first, /, pos, password="posonly"): - | ^^^^^^^^^ S107 -14 | pass - | - -S107.py:21:39: S107 Possible hardcoded password assigned to function default: "password" - | -21 | def default_kwonly(first, *, password="kwonly"): - | ^^^^^^^^ S107 -22 | pass - | - -S107.py:29:39: S107 Possible hardcoded password assigned to function default: "secret" - | -29 | def default_all(first, /, pos, secret="posonly", *, password="kwonly"): - | ^^^^^^^^^ S107 -30 | pass - | - -S107.py:29:62: S107 Possible hardcoded password assigned to function default: "password" - | -29 | def default_all(first, /, pos, secret="posonly", *, password="kwonly"): - | ^^^^^^^^ S107 -30 | pass - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S108_S108.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S108_S108.py.snap deleted file mode 100644 index a120a5264f..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S108_S108.py.snap +++ /dev/null @@ -1,31 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S108.py:5:11: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" - | -3 | f.write("def") -4 | -5 | with open("/tmp/abc", "w") as f: - | ^^^^^^^^^^ S108 -6 | f.write("def") - | - -S108.py:8:11: S108 Probable insecure usage of temporary file or directory: "/var/tmp/123" - | -6 | f.write("def") -7 | -8 | with open("/var/tmp/123", "w") as f: - | ^^^^^^^^^^^^^^ S108 -9 | f.write("def") - | - -S108.py:11:11: S108 Probable insecure usage of temporary file or directory: "/dev/shm/unit/test" - | - 9 | f.write("def") -10 | -11 | with open("/dev/shm/unit/test", "w") as f: - | ^^^^^^^^^^^^^^^^^^^^ S108 -12 | f.write("def") - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S108_extend.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S108_extend.snap deleted file mode 100644 index 696be4b82c..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S108_extend.snap +++ /dev/null @@ -1,39 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S108.py:5:11: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" - | -3 | f.write("def") -4 | -5 | with open("/tmp/abc", "w") as f: - | ^^^^^^^^^^ S108 -6 | f.write("def") - | - -S108.py:8:11: S108 Probable insecure usage of temporary file or directory: "/var/tmp/123" - | -6 | f.write("def") -7 | -8 | with open("/var/tmp/123", "w") as f: - | ^^^^^^^^^^^^^^ S108 -9 | f.write("def") - | - -S108.py:11:11: S108 Probable insecure usage of temporary file or directory: "/dev/shm/unit/test" - | - 9 | f.write("def") -10 | -11 | with open("/dev/shm/unit/test", "w") as f: - | ^^^^^^^^^^^^^^^^^^^^ S108 -12 | f.write("def") - | - -S108.py:15:11: S108 Probable insecure usage of temporary file or directory: "/foo/bar" - | -14 | # not ok by config -15 | with open("/foo/bar", "w") as f: - | ^^^^^^^^^^ S108 -16 | f.write("def") - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S110_S110.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S110_S110.py.snap deleted file mode 100644 index fb6205e781..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S110_S110.py.snap +++ /dev/null @@ -1,26 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S110.py:3:1: S110 `try`-`except`-`pass` detected, consider logging the exception - | -1 | try: -2 | pass -3 | / except Exception: -4 | | pass - | |________^ S110 -5 | -6 | try: - | - -S110.py:8:1: S110 `try`-`except`-`pass` detected, consider logging the exception - | - 6 | try: - 7 | pass - 8 | / except: - 9 | | pass - | |________^ S110 -10 | -11 | try: - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S110_typed.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S110_typed.snap deleted file mode 100644 index 5aed61cbe7..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S110_typed.snap +++ /dev/null @@ -1,35 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S110.py:3:1: S110 `try`-`except`-`pass` detected, consider logging the exception - | -1 | try: -2 | pass -3 | / except Exception: -4 | | pass - | |________^ S110 -5 | -6 | try: - | - -S110.py:8:1: S110 `try`-`except`-`pass` detected, consider logging the exception - | - 6 | try: - 7 | pass - 8 | / except: - 9 | | pass - | |________^ S110 -10 | -11 | try: - | - -S110.py:13:1: S110 `try`-`except`-`pass` detected, consider logging the exception - | -11 | try: -12 | pass -13 | / except ValueError: -14 | | pass - | |________^ S110 - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S112_S112.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S112_S112.py.snap deleted file mode 100644 index b7a7969275..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S112_S112.py.snap +++ /dev/null @@ -1,48 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S112.py:3:1: S112 `try`-`except`-`continue` detected, consider logging the exception - | -1 | try: -2 | pass -3 | / except Exception: -4 | | continue - | |____________^ S112 -5 | -6 | try: - | - -S112.py:8:1: S112 `try`-`except`-`continue` detected, consider logging the exception - | - 6 | try: - 7 | pass - 8 | / except: - 9 | | continue - | |____________^ S112 -10 | -11 | try: - | - -S112.py:13:1: S112 `try`-`except`-`continue` detected, consider logging the exception - | -11 | try: -12 | pass -13 | / except (Exception,): -14 | | continue - | |____________^ S112 -15 | -16 | try: - | - -S112.py:18:1: S112 `try`-`except`-`continue` detected, consider logging the exception - | -16 | try: -17 | pass -18 | / except (Exception, ValueError): -19 | | continue - | |____________^ S112 -20 | -21 | try: - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S113_S113.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S113_S113.py.snap deleted file mode 100644 index a1d0b8924e..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S113_S113.py.snap +++ /dev/null @@ -1,142 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S113.py:3:1: S113 Probable use of requests call without timeout - | -1 | import requests -2 | -3 | requests.get('https://gmail.com') - | ^^^^^^^^^^^^ S113 -4 | requests.get('https://gmail.com', timeout=None) -5 | requests.get('https://gmail.com', timeout=5) - | - -S113.py:4:35: S113 Probable use of requests call with timeout set to `None` - | -3 | requests.get('https://gmail.com') -4 | requests.get('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 -5 | requests.get('https://gmail.com', timeout=5) -6 | requests.post('https://gmail.com') - | - -S113.py:6:1: S113 Probable use of requests call without timeout - | -4 | requests.get('https://gmail.com', timeout=None) -5 | requests.get('https://gmail.com', timeout=5) -6 | requests.post('https://gmail.com') - | ^^^^^^^^^^^^^ S113 -7 | requests.post('https://gmail.com', timeout=None) -8 | requests.post('https://gmail.com', timeout=5) - | - -S113.py:7:36: S113 Probable use of requests call with timeout set to `None` - | -5 | requests.get('https://gmail.com', timeout=5) -6 | requests.post('https://gmail.com') -7 | requests.post('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 -8 | requests.post('https://gmail.com', timeout=5) -9 | requests.put('https://gmail.com') - | - -S113.py:9:1: S113 Probable use of requests call without timeout - | - 7 | requests.post('https://gmail.com', timeout=None) - 8 | requests.post('https://gmail.com', timeout=5) - 9 | requests.put('https://gmail.com') - | ^^^^^^^^^^^^ S113 -10 | requests.put('https://gmail.com', timeout=None) -11 | requests.put('https://gmail.com', timeout=5) - | - -S113.py:10:35: S113 Probable use of requests call with timeout set to `None` - | - 8 | requests.post('https://gmail.com', timeout=5) - 9 | requests.put('https://gmail.com') -10 | requests.put('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 -11 | requests.put('https://gmail.com', timeout=5) -12 | requests.delete('https://gmail.com') - | - -S113.py:12:1: S113 Probable use of requests call without timeout - | -10 | requests.put('https://gmail.com', timeout=None) -11 | requests.put('https://gmail.com', timeout=5) -12 | requests.delete('https://gmail.com') - | ^^^^^^^^^^^^^^^ S113 -13 | requests.delete('https://gmail.com', timeout=None) -14 | requests.delete('https://gmail.com', timeout=5) - | - -S113.py:13:38: S113 Probable use of requests call with timeout set to `None` - | -11 | requests.put('https://gmail.com', timeout=5) -12 | requests.delete('https://gmail.com') -13 | requests.delete('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 -14 | requests.delete('https://gmail.com', timeout=5) -15 | requests.patch('https://gmail.com') - | - -S113.py:15:1: S113 Probable use of requests call without timeout - | -13 | requests.delete('https://gmail.com', timeout=None) -14 | requests.delete('https://gmail.com', timeout=5) -15 | requests.patch('https://gmail.com') - | ^^^^^^^^^^^^^^ S113 -16 | requests.patch('https://gmail.com', timeout=None) -17 | requests.patch('https://gmail.com', timeout=5) - | - -S113.py:16:37: S113 Probable use of requests call with timeout set to `None` - | -14 | requests.delete('https://gmail.com', timeout=5) -15 | requests.patch('https://gmail.com') -16 | requests.patch('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 -17 | requests.patch('https://gmail.com', timeout=5) -18 | requests.options('https://gmail.com') - | - -S113.py:18:1: S113 Probable use of requests call without timeout - | -16 | requests.patch('https://gmail.com', timeout=None) -17 | requests.patch('https://gmail.com', timeout=5) -18 | requests.options('https://gmail.com') - | ^^^^^^^^^^^^^^^^ S113 -19 | requests.options('https://gmail.com', timeout=None) -20 | requests.options('https://gmail.com', timeout=5) - | - -S113.py:19:39: S113 Probable use of requests call with timeout set to `None` - | -17 | requests.patch('https://gmail.com', timeout=5) -18 | requests.options('https://gmail.com') -19 | requests.options('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 -20 | requests.options('https://gmail.com', timeout=5) -21 | requests.head('https://gmail.com') - | - -S113.py:21:1: S113 Probable use of requests call without timeout - | -19 | requests.options('https://gmail.com', timeout=None) -20 | requests.options('https://gmail.com', timeout=5) -21 | requests.head('https://gmail.com') - | ^^^^^^^^^^^^^ S113 -22 | requests.head('https://gmail.com', timeout=None) -23 | requests.head('https://gmail.com', timeout=5) - | - -S113.py:22:36: S113 Probable use of requests call with timeout set to `None` - | -20 | requests.options('https://gmail.com', timeout=5) -21 | requests.head('https://gmail.com') -22 | requests.head('https://gmail.com', timeout=None) - | ^^^^^^^^^^^^ S113 -23 | requests.head('https://gmail.com', timeout=5) - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S201_S201.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S201_S201.py.snap deleted file mode 100644 index 7f1c3af924..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S201_S201.py.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S201.py:10:9: S201 Use of `debug=True` in Flask app detected - | - 9 | # OK -10 | app.run(debug=True) - | ^^^^^^^^^^ S201 -11 | -12 | # Errors - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S301_S301.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S301_S301.py.snap deleted file mode 100644 index 76f99c07c8..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S301_S301.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -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 | -3 | pickle.loads() - | ^^^^^^^^^^^^^^ S301 - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S307_S307.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S307_S307.py.snap deleted file mode 100644 index f5c6ac82d8..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S307_S307.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S307.py:3:7: S307 Use of possibly insecure function; consider using `ast.literal_eval` - | -1 | import os -2 | -3 | print(eval("1+1")) # S307 - | ^^^^^^^^^^^ S307 -4 | print(eval("os.getcwd()")) # S307 - | - -S307.py:4:7: S307 Use of possibly insecure function; consider using `ast.literal_eval` - | -3 | print(eval("1+1")) # S307 -4 | print(eval("os.getcwd()")) # S307 - | ^^^^^^^^^^^^^^^^^^^ S307 - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S312_S312.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S312_S312.py.snap deleted file mode 100644 index 3ddfc864e5..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S312_S312.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -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 | -3 | Telnet("localhost", 23) - | ^^^^^^^^^^^^^^^^^^^^^^^ S312 - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S324_S324.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S324_S324.py.snap deleted file mode 100644 index fed5786a7a..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S324_S324.py.snap +++ /dev/null @@ -1,133 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S324.py:7:13: S324 Probable use of insecure hash functions in `hashlib`: `md5` - | -5 | # Invalid -6 | -7 | hashlib.new('md5') - | ^^^^^ S324 -8 | -9 | hashlib.new('md4', b'test') - | - -S324.py:9:13: S324 Probable use of insecure hash functions in `hashlib`: `md4` - | - 7 | hashlib.new('md5') - 8 | - 9 | hashlib.new('md4', b'test') - | ^^^^^ S324 -10 | -11 | hashlib.new(name='md5', data=b'test') - | - -S324.py:11:18: S324 Probable use of insecure hash functions in `hashlib`: `md5` - | - 9 | hashlib.new('md4', b'test') -10 | -11 | hashlib.new(name='md5', data=b'test') - | ^^^^^ S324 -12 | -13 | hashlib.new('MD4', data=b'test') - | - -S324.py:13:13: S324 Probable use of insecure hash functions in `hashlib`: `MD4` - | -11 | hashlib.new(name='md5', data=b'test') -12 | -13 | hashlib.new('MD4', data=b'test') - | ^^^^^ S324 -14 | -15 | hashlib.new('sha1') - | - -S324.py:15:13: S324 Probable use of insecure hash functions in `hashlib`: `sha1` - | -13 | hashlib.new('MD4', data=b'test') -14 | -15 | hashlib.new('sha1') - | ^^^^^^ S324 -16 | -17 | hashlib.new('sha1', data=b'test') - | - -S324.py:17:13: S324 Probable use of insecure hash functions in `hashlib`: `sha1` - | -15 | hashlib.new('sha1') -16 | -17 | hashlib.new('sha1', data=b'test') - | ^^^^^^ S324 -18 | -19 | hashlib.new('sha', data=b'test') - | - -S324.py:19:13: S324 Probable use of insecure hash functions in `hashlib`: `sha` - | -17 | hashlib.new('sha1', data=b'test') -18 | -19 | hashlib.new('sha', data=b'test') - | ^^^^^ S324 -20 | -21 | hashlib.new(name='SHA', data=b'test') - | - -S324.py:21:18: S324 Probable use of insecure hash functions in `hashlib`: `SHA` - | -19 | hashlib.new('sha', data=b'test') -20 | -21 | hashlib.new(name='SHA', data=b'test') - | ^^^^^ S324 -22 | -23 | hashlib.sha(data=b'test') - | - -S324.py:23:1: S324 Probable use of insecure hash functions in `hashlib`: `sha` - | -21 | hashlib.new(name='SHA', data=b'test') -22 | -23 | hashlib.sha(data=b'test') - | ^^^^^^^^^^^ S324 -24 | -25 | hashlib.md5() - | - -S324.py:25:1: S324 Probable use of insecure hash functions in `hashlib`: `md5` - | -23 | hashlib.sha(data=b'test') -24 | -25 | hashlib.md5() - | ^^^^^^^^^^^ S324 -26 | -27 | hashlib_new('sha1') - | - -S324.py:27:13: S324 Probable use of insecure hash functions in `hashlib`: `sha1` - | -25 | hashlib.md5() -26 | -27 | hashlib_new('sha1') - | ^^^^^^ S324 -28 | -29 | hashlib_sha1('sha1') - | - -S324.py:29:1: S324 Probable use of insecure hash functions in `hashlib`: `sha1` - | -27 | hashlib_new('sha1') -28 | -29 | hashlib_sha1('sha1') - | ^^^^^^^^^^^^ S324 -30 | -31 | # usedforsecurity arg only available in Python 3.9+ - | - -S324.py:32:13: S324 Probable use of insecure hash functions in `hashlib`: `sha1` - | -31 | # usedforsecurity arg only available in Python 3.9+ -32 | hashlib.new('sha1', usedforsecurity=True) - | ^^^^^^ S324 -33 | -34 | # Valid - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S501_S501.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S501_S501.py.snap deleted file mode 100644 index 4875cf2e1f..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S501_S501.py.snap +++ /dev/null @@ -1,180 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S501.py:5:47: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks - | -4 | requests.get('https://gmail.com', timeout=30, verify=True) -5 | requests.get('https://gmail.com', timeout=30, verify=False) - | ^^^^^^^^^^^^ S501 -6 | requests.post('https://gmail.com', timeout=30, verify=True) -7 | requests.post('https://gmail.com', timeout=30, verify=False) - | - -S501.py:7:48: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks - | -5 | requests.get('https://gmail.com', timeout=30, verify=False) -6 | requests.post('https://gmail.com', timeout=30, verify=True) -7 | requests.post('https://gmail.com', timeout=30, verify=False) - | ^^^^^^^^^^^^ S501 -8 | requests.put('https://gmail.com', timeout=30, verify=True) -9 | requests.put('https://gmail.com', timeout=30, verify=False) - | - -S501.py:9:47: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks - | - 7 | requests.post('https://gmail.com', timeout=30, verify=False) - 8 | requests.put('https://gmail.com', timeout=30, verify=True) - 9 | requests.put('https://gmail.com', timeout=30, verify=False) - | ^^^^^^^^^^^^ S501 -10 | requests.delete('https://gmail.com', timeout=30, verify=True) -11 | requests.delete('https://gmail.com', timeout=30, verify=False) - | - -S501.py:11:50: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks - | - 9 | requests.put('https://gmail.com', timeout=30, verify=False) -10 | requests.delete('https://gmail.com', timeout=30, verify=True) -11 | requests.delete('https://gmail.com', timeout=30, verify=False) - | ^^^^^^^^^^^^ S501 -12 | requests.patch('https://gmail.com', timeout=30, verify=True) -13 | requests.patch('https://gmail.com', timeout=30, verify=False) - | - -S501.py:13:49: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks - | -11 | requests.delete('https://gmail.com', timeout=30, verify=False) -12 | requests.patch('https://gmail.com', timeout=30, verify=True) -13 | requests.patch('https://gmail.com', timeout=30, verify=False) - | ^^^^^^^^^^^^ S501 -14 | requests.options('https://gmail.com', timeout=30, verify=True) -15 | requests.options('https://gmail.com', timeout=30, verify=False) - | - -S501.py:15:51: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks - | -13 | requests.patch('https://gmail.com', timeout=30, verify=False) -14 | requests.options('https://gmail.com', timeout=30, verify=True) -15 | requests.options('https://gmail.com', timeout=30, verify=False) - | ^^^^^^^^^^^^ S501 -16 | requests.head('https://gmail.com', timeout=30, verify=True) -17 | requests.head('https://gmail.com', timeout=30, verify=False) - | - -S501.py:17:48: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks - | -15 | requests.options('https://gmail.com', timeout=30, verify=False) -16 | requests.head('https://gmail.com', timeout=30, verify=True) -17 | requests.head('https://gmail.com', timeout=30, verify=False) - | ^^^^^^^^^^^^ S501 -18 | -19 | httpx.request('GET', 'https://gmail.com', verify=True) - | - -S501.py:20:43: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks - | -19 | httpx.request('GET', 'https://gmail.com', verify=True) -20 | httpx.request('GET', 'https://gmail.com', verify=False) - | ^^^^^^^^^^^^ S501 -21 | httpx.get('https://gmail.com', verify=True) -22 | httpx.get('https://gmail.com', verify=False) - | - -S501.py:22:32: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks - | -20 | httpx.request('GET', 'https://gmail.com', verify=False) -21 | httpx.get('https://gmail.com', verify=True) -22 | httpx.get('https://gmail.com', verify=False) - | ^^^^^^^^^^^^ S501 -23 | httpx.options('https://gmail.com', verify=True) -24 | httpx.options('https://gmail.com', verify=False) - | - -S501.py:24:36: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks - | -22 | httpx.get('https://gmail.com', verify=False) -23 | httpx.options('https://gmail.com', verify=True) -24 | httpx.options('https://gmail.com', verify=False) - | ^^^^^^^^^^^^ S501 -25 | httpx.head('https://gmail.com', verify=True) -26 | httpx.head('https://gmail.com', verify=False) - | - -S501.py:26:33: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks - | -24 | httpx.options('https://gmail.com', verify=False) -25 | httpx.head('https://gmail.com', verify=True) -26 | httpx.head('https://gmail.com', verify=False) - | ^^^^^^^^^^^^ S501 -27 | httpx.post('https://gmail.com', verify=True) -28 | httpx.post('https://gmail.com', verify=False) - | - -S501.py:28:33: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks - | -26 | httpx.head('https://gmail.com', verify=False) -27 | httpx.post('https://gmail.com', verify=True) -28 | httpx.post('https://gmail.com', verify=False) - | ^^^^^^^^^^^^ S501 -29 | httpx.put('https://gmail.com', verify=True) -30 | httpx.put('https://gmail.com', verify=False) - | - -S501.py:30:32: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks - | -28 | httpx.post('https://gmail.com', verify=False) -29 | httpx.put('https://gmail.com', verify=True) -30 | httpx.put('https://gmail.com', verify=False) - | ^^^^^^^^^^^^ S501 -31 | httpx.patch('https://gmail.com', verify=True) -32 | httpx.patch('https://gmail.com', verify=False) - | - -S501.py:32:34: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks - | -30 | httpx.put('https://gmail.com', verify=False) -31 | httpx.patch('https://gmail.com', verify=True) -32 | httpx.patch('https://gmail.com', verify=False) - | ^^^^^^^^^^^^ S501 -33 | httpx.delete('https://gmail.com', verify=True) -34 | httpx.delete('https://gmail.com', verify=False) - | - -S501.py:34:35: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks - | -32 | httpx.patch('https://gmail.com', verify=False) -33 | httpx.delete('https://gmail.com', verify=True) -34 | httpx.delete('https://gmail.com', verify=False) - | ^^^^^^^^^^^^ S501 -35 | httpx.stream('https://gmail.com', verify=True) -36 | httpx.stream('https://gmail.com', verify=False) - | - -S501.py:36:35: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks - | -34 | httpx.delete('https://gmail.com', verify=False) -35 | httpx.stream('https://gmail.com', verify=True) -36 | httpx.stream('https://gmail.com', verify=False) - | ^^^^^^^^^^^^ S501 -37 | httpx.Client() -38 | httpx.Client(verify=False) - | - -S501.py:38:14: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks - | -36 | httpx.stream('https://gmail.com', verify=False) -37 | httpx.Client() -38 | httpx.Client(verify=False) - | ^^^^^^^^^^^^ S501 -39 | httpx.AsyncClient() -40 | httpx.AsyncClient(verify=False) - | - -S501.py:40:19: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks - | -38 | httpx.Client(verify=False) -39 | httpx.AsyncClient() -40 | httpx.AsyncClient(verify=False) - | ^^^^^^^^^^^^ S501 - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S506_S506.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S506_S506.py.snap deleted file mode 100644 index 73c718e2e9..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S506_S506.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S506.py:10:9: S506 Probable use of unsafe `yaml.load`. Allows instantiation of arbitrary objects. Consider `yaml.safe_load`. - | - 8 | def test_yaml_load(): - 9 | ystr = yaml.dump({"a": 1, "b": 2, "c": 3}) -10 | y = yaml.load(ystr) - | ^^^^^^^^^ S506 -11 | yaml.dump(y) -12 | try: - | - -S506.py:24:24: S506 Probable use of unsafe loader `Loader` with `yaml.load`. Allows instantiation of arbitrary objects. Consider `yaml.safe_load`. - | -24 | yaml.load("{}", Loader=yaml.Loader) - | ^^^^^^^^^^^ S506 -25 | -26 | # no issue should be found - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S507_S507.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S507_S507.py.snap deleted file mode 100644 index f2257bc78b..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S507_S507.py.snap +++ /dev/null @@ -1,62 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S507.py:13:40: S507 Paramiko call with policy set to automatically trust the unknown host key - | -12 | # Errors -13 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy) - | ^^^^^^^^^^^^^^^^^^^^ S507 -14 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) -15 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) - | - -S507.py:14:40: S507 Paramiko call with policy set to automatically trust the unknown host key - | -12 | # Errors -13 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy) -14 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) - | ^^^^^^^^^^^^^^^^^^^^ S507 -15 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) -16 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) - | - -S507.py:15:40: S507 Paramiko call with policy set to automatically trust the unknown host key - | -13 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy) -14 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) -15 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) - | ^^^^^^^^^^^^^ S507 -16 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) -17 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) - | - -S507.py:16:47: S507 Paramiko call with policy set to automatically trust the unknown host key - | -14 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) -15 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) -16 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) - | ^^^^^^^^^^^^^^^^^^^^ S507 -17 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) -18 | ssh_client.set_missing_host_key_policy(policy=WarningPolicy) - | - -S507.py:17:47: S507 Paramiko call with policy set to automatically trust the unknown host key - | -15 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) -16 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) -17 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) - | ^^^^^^^^^^^^^^^^^^^^ S507 -18 | ssh_client.set_missing_host_key_policy(policy=WarningPolicy) - | - -S507.py:18:47: S507 Paramiko call with policy set to automatically trust the unknown host key - | -16 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) -17 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) -18 | ssh_client.set_missing_host_key_policy(policy=WarningPolicy) - | ^^^^^^^^^^^^^ S507 -19 | -20 | # Unrelated - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S508_S508.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S508_S508.py.snap deleted file mode 100644 index b166212ea0..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S508_S508.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S508.py:3:25: S508 The use of SNMPv1 and SNMPv2 is insecure. Use SNMPv3 if able. - | -1 | from pysnmp.hlapi import CommunityData -2 | -3 | CommunityData("public", mpModel=0) # S508 - | ^^^^^^^^^ S508 -4 | CommunityData("public", mpModel=1) # S508 - | - -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 | -6 | CommunityData("public", mpModel=2) # OK - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S509_S509.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S509_S509.py.snap deleted file mode 100644 index d5ac86abb3..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S509_S509.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S509.py:4:12: S509 You should not use SNMPv3 without encryption. `noAuthNoPriv` & `authNoPriv` is insecure. - | -4 | insecure = UsmUserData("securityName") # S509 - | ^^^^^^^^^^^ S509 -5 | auth_no_priv = UsmUserData("securityName", "authName") # S509 - | - -S509.py:5:16: S509 You should not use SNMPv3 without encryption. `noAuthNoPriv` & `authNoPriv` is insecure. - | -4 | insecure = UsmUserData("securityName") # S509 -5 | auth_no_priv = UsmUserData("securityName", "authName") # S509 - | ^^^^^^^^^^^ S509 -6 | -7 | less_insecure = UsmUserData("securityName", "authName", "privName") # OK - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S601_S601.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S601_S601.py.snap deleted file mode 100644 index dc76be8916..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S601_S601.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S601.py:3:1: S601 Possible shell injection via Paramiko call; check inputs are properly sanitized - | -1 | import paramiko -2 | -3 | paramiko.exec_command('something; really; unsafe') - | ^^^^^^^^^^^^^^^^^^^^^ S601 - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S602_S602.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S602_S602.py.snap deleted file mode 100644 index 6e61024d56..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S602_S602.py.snap +++ /dev/null @@ -1,117 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S602.py:4:15: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` - | -3 | # Check different Popen wrappers are checked. -4 | Popen("true", shell=True) - | ^^^^^^^^^^ S602 -5 | call("true", shell=True) -6 | check_call("true", shell=True) - | - -S602.py:5:14: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` - | -3 | # Check different Popen wrappers are checked. -4 | Popen("true", shell=True) -5 | call("true", shell=True) - | ^^^^^^^^^^ S602 -6 | check_call("true", shell=True) -7 | check_output("true", shell=True) - | - -S602.py:6:20: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` - | -4 | Popen("true", shell=True) -5 | call("true", shell=True) -6 | check_call("true", shell=True) - | ^^^^^^^^^^ S602 -7 | check_output("true", shell=True) -8 | run("true", shell=True) - | - -S602.py:7:22: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` - | -5 | call("true", shell=True) -6 | check_call("true", shell=True) -7 | check_output("true", shell=True) - | ^^^^^^^^^^ S602 -8 | run("true", shell=True) - | - -S602.py:8:13: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` - | - 6 | check_call("true", shell=True) - 7 | check_output("true", shell=True) - 8 | run("true", shell=True) - | ^^^^^^^^^^ S602 - 9 | -10 | # Check values that truthy values are treated as true. - | - -S602.py:11:15: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` - | -10 | # Check values that truthy values are treated as true. -11 | Popen("true", shell=1) - | ^^^^^^^ S602 -12 | Popen("true", shell=[1]) -13 | Popen("true", shell={1: 1}) - | - -S602.py:12:15: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` - | -10 | # Check values that truthy values are treated as true. -11 | Popen("true", shell=1) -12 | Popen("true", shell=[1]) - | ^^^^^^^^^ S602 -13 | Popen("true", shell={1: 1}) -14 | Popen("true", shell=(1,)) - | - -S602.py:13:15: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` - | -11 | Popen("true", shell=1) -12 | Popen("true", shell=[1]) -13 | Popen("true", shell={1: 1}) - | ^^^^^^^^^^^^ S602 -14 | Popen("true", shell=(1,)) - | - -S602.py:14:15: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` - | -12 | Popen("true", shell=[1]) -13 | Popen("true", shell={1: 1}) -14 | Popen("true", shell=(1,)) - | ^^^^^^^^^^ S602 -15 | -16 | # Check command argument looks unsafe. - | - -S602.py:18:19: S602 `subprocess` call with `shell=True` identified, security issue - | -16 | # Check command argument looks unsafe. -17 | var_string = "true" -18 | Popen(var_string, shell=True) - | ^^^^^^^^^^ S602 -19 | Popen([var_string], shell=True) -20 | Popen([var_string, ""], shell=True) - | - -S602.py:19:21: S602 `subprocess` call with `shell=True` identified, security issue - | -17 | var_string = "true" -18 | Popen(var_string, shell=True) -19 | Popen([var_string], shell=True) - | ^^^^^^^^^^ S602 -20 | Popen([var_string, ""], shell=True) - | - -S602.py:20:25: S602 `subprocess` call with `shell=True` identified, security issue - | -18 | Popen(var_string, shell=True) -19 | Popen([var_string], shell=True) -20 | Popen([var_string, ""], shell=True) - | ^^^^^^^^^^ S602 - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S603_S603.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S603_S603.py.snap deleted file mode 100644 index 30ae0878a7..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S603_S603.py.snap +++ /dev/null @@ -1,106 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S603.py:4:15: S603 `subprocess` call: check for execution of untrusted input - | -3 | # Different Popen wrappers are checked. -4 | Popen("true", shell=False) - | ^^^^^^^^^^^ S603 -5 | call("true", shell=False) -6 | check_call("true", shell=False) - | - -S603.py:5:14: S603 `subprocess` call: check for execution of untrusted input - | -3 | # Different Popen wrappers are checked. -4 | Popen("true", shell=False) -5 | call("true", shell=False) - | ^^^^^^^^^^^ S603 -6 | check_call("true", shell=False) -7 | check_output("true", shell=False) - | - -S603.py:6:20: S603 `subprocess` call: check for execution of untrusted input - | -4 | Popen("true", shell=False) -5 | call("true", shell=False) -6 | check_call("true", shell=False) - | ^^^^^^^^^^^ S603 -7 | check_output("true", shell=False) -8 | run("true", shell=False) - | - -S603.py:7:22: S603 `subprocess` call: check for execution of untrusted input - | -5 | call("true", shell=False) -6 | check_call("true", shell=False) -7 | check_output("true", shell=False) - | ^^^^^^^^^^^ S603 -8 | run("true", shell=False) - | - -S603.py:8:13: S603 `subprocess` call: check for execution of untrusted input - | - 6 | check_call("true", shell=False) - 7 | check_output("true", shell=False) - 8 | run("true", shell=False) - | ^^^^^^^^^^^ S603 - 9 | -10 | # Values that falsey values are treated as false. - | - -S603.py:11:15: S603 `subprocess` call: check for execution of untrusted input - | -10 | # Values that falsey values are treated as false. -11 | Popen("true", shell=0) - | ^^^^^^^ S603 -12 | Popen("true", shell=[]) -13 | Popen("true", shell={}) - | - -S603.py:12:15: S603 `subprocess` call: check for execution of untrusted input - | -10 | # Values that falsey values are treated as false. -11 | Popen("true", shell=0) -12 | Popen("true", shell=[]) - | ^^^^^^^^ S603 -13 | Popen("true", shell={}) -14 | Popen("true", shell=None) - | - -S603.py:13:15: S603 `subprocess` call: check for execution of untrusted input - | -11 | Popen("true", shell=0) -12 | Popen("true", shell=[]) -13 | Popen("true", shell={}) - | ^^^^^^^^ S603 -14 | Popen("true", shell=None) - | - -S603.py:14:15: S603 `subprocess` call: check for execution of untrusted input - | -12 | Popen("true", shell=[]) -13 | Popen("true", shell={}) -14 | Popen("true", shell=None) - | ^^^^^^^^^^ S603 -15 | -16 | # Unknown values are treated as falsey. - | - -S603.py:17:15: 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 | -19 | # No value is also caught. - | - -S603.py:20:7: S603 `subprocess` call: check for execution of untrusted input - | -19 | # No value is also caught. -20 | Popen("true") - | ^^^^^^ S603 - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S604_S604.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S604_S604.py.snap deleted file mode 100644 index 83e9248dfb..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S604_S604.py.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S604.py:5:5: S604 Function call with `shell=True` parameter identified, security issue - | -5 | foo(shell=True) - | ^^^^^^^^^^ S604 - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S605_S605.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S605_S605.py.snap deleted file mode 100644 index 5f191afb53..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S605_S605.py.snap +++ /dev/null @@ -1,147 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S605.py:7:11: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` - | -6 | # Check all shell functions. -7 | os.system("true") - | ^^^^^^ S605 -8 | os.popen("true") -9 | os.popen2("true") - | - -S605.py:8:10: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` - | - 6 | # Check all shell functions. - 7 | os.system("true") - 8 | os.popen("true") - | ^^^^^^ S605 - 9 | os.popen2("true") -10 | os.popen3("true") - | - -S605.py:9:11: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` - | - 7 | os.system("true") - 8 | os.popen("true") - 9 | os.popen2("true") - | ^^^^^^ S605 -10 | os.popen3("true") -11 | os.popen4("true") - | - -S605.py:10:11: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` - | - 8 | os.popen("true") - 9 | os.popen2("true") -10 | os.popen3("true") - | ^^^^^^ S605 -11 | os.popen4("true") -12 | popen2.popen2("true") - | - -S605.py:11:11: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` - | - 9 | os.popen2("true") -10 | os.popen3("true") -11 | os.popen4("true") - | ^^^^^^ S605 -12 | popen2.popen2("true") -13 | popen2.popen3("true") - | - -S605.py:12:15: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` - | -10 | os.popen3("true") -11 | os.popen4("true") -12 | popen2.popen2("true") - | ^^^^^^ S605 -13 | popen2.popen3("true") -14 | popen2.popen4("true") - | - -S605.py:13:15: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` - | -11 | os.popen4("true") -12 | popen2.popen2("true") -13 | popen2.popen3("true") - | ^^^^^^ S605 -14 | popen2.popen4("true") -15 | popen2.Popen3("true") - | - -S605.py:14:15: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` - | -12 | popen2.popen2("true") -13 | popen2.popen3("true") -14 | popen2.popen4("true") - | ^^^^^^ S605 -15 | popen2.Popen3("true") -16 | popen2.Popen4("true") - | - -S605.py:15:15: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` - | -13 | popen2.popen3("true") -14 | popen2.popen4("true") -15 | popen2.Popen3("true") - | ^^^^^^ S605 -16 | popen2.Popen4("true") -17 | commands.getoutput("true") - | - -S605.py:16:15: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` - | -14 | popen2.popen4("true") -15 | popen2.Popen3("true") -16 | popen2.Popen4("true") - | ^^^^^^ S605 -17 | commands.getoutput("true") -18 | commands.getstatusoutput("true") - | - -S605.py:17:20: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` - | -15 | popen2.Popen3("true") -16 | popen2.Popen4("true") -17 | commands.getoutput("true") - | ^^^^^^ S605 -18 | commands.getstatusoutput("true") - | - -S605.py:18:26: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` - | -16 | popen2.Popen4("true") -17 | commands.getoutput("true") -18 | commands.getstatusoutput("true") - | ^^^^^^ S605 - | - -S605.py:23:11: S605 Starting a process with a shell, possible injection detected - | -21 | # Check command argument looks unsafe. -22 | var_string = "true" -23 | os.system(var_string) - | ^^^^^^^^^^ S605 -24 | os.system([var_string]) -25 | os.system([var_string, ""]) - | - -S605.py:24:11: S605 Starting a process with a shell, possible injection detected - | -22 | var_string = "true" -23 | os.system(var_string) -24 | os.system([var_string]) - | ^^^^^^^^^^^^ S605 -25 | os.system([var_string, ""]) - | - -S605.py:25:11: S605 Starting a process with a shell, possible injection detected - | -23 | os.system(var_string) -24 | os.system([var_string]) -25 | os.system([var_string, ""]) - | ^^^^^^^^^^^^^^^^ S605 - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S606_S606.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S606_S606.py.snap deleted file mode 100644 index 9e1d9b71f4..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S606_S606.py.snap +++ /dev/null @@ -1,170 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S606.py:4:1: S606 Starting a process without a shell - | -3 | # Check all shell functions. -4 | os.execl("true") - | ^^^^^^^^ S606 -5 | os.execle("true") -6 | os.execlp("true") - | - -S606.py:5:1: S606 Starting a process without a shell - | -3 | # Check all shell functions. -4 | os.execl("true") -5 | os.execle("true") - | ^^^^^^^^^ S606 -6 | os.execlp("true") -7 | os.execlpe("true") - | - -S606.py:6:1: S606 Starting a process without a shell - | -4 | os.execl("true") -5 | os.execle("true") -6 | os.execlp("true") - | ^^^^^^^^^ S606 -7 | os.execlpe("true") -8 | os.execv("true") - | - -S606.py:7:1: S606 Starting a process without a shell - | -5 | os.execle("true") -6 | os.execlp("true") -7 | os.execlpe("true") - | ^^^^^^^^^^ S606 -8 | os.execv("true") -9 | os.execve("true") - | - -S606.py:8:1: S606 Starting a process without a shell - | - 6 | os.execlp("true") - 7 | os.execlpe("true") - 8 | os.execv("true") - | ^^^^^^^^ S606 - 9 | os.execve("true") -10 | os.execvp("true") - | - -S606.py:9:1: S606 Starting a process without a shell - | - 7 | os.execlpe("true") - 8 | os.execv("true") - 9 | os.execve("true") - | ^^^^^^^^^ S606 -10 | os.execvp("true") -11 | os.execvpe("true") - | - -S606.py:10:1: S606 Starting a process without a shell - | - 8 | os.execv("true") - 9 | os.execve("true") -10 | os.execvp("true") - | ^^^^^^^^^ S606 -11 | os.execvpe("true") -12 | os.spawnl("true") - | - -S606.py:11:1: S606 Starting a process without a shell - | - 9 | os.execve("true") -10 | os.execvp("true") -11 | os.execvpe("true") - | ^^^^^^^^^^ S606 -12 | os.spawnl("true") -13 | os.spawnle("true") - | - -S606.py:12:1: S606 Starting a process without a shell - | -10 | os.execvp("true") -11 | os.execvpe("true") -12 | os.spawnl("true") - | ^^^^^^^^^ S606 -13 | os.spawnle("true") -14 | os.spawnlp("true") - | - -S606.py:13:1: S606 Starting a process without a shell - | -11 | os.execvpe("true") -12 | os.spawnl("true") -13 | os.spawnle("true") - | ^^^^^^^^^^ S606 -14 | os.spawnlp("true") -15 | os.spawnlpe("true") - | - -S606.py:14:1: S606 Starting a process without a shell - | -12 | os.spawnl("true") -13 | os.spawnle("true") -14 | os.spawnlp("true") - | ^^^^^^^^^^ S606 -15 | os.spawnlpe("true") -16 | os.spawnv("true") - | - -S606.py:15:1: S606 Starting a process without a shell - | -13 | os.spawnle("true") -14 | os.spawnlp("true") -15 | os.spawnlpe("true") - | ^^^^^^^^^^^ S606 -16 | os.spawnv("true") -17 | os.spawnve("true") - | - -S606.py:16:1: S606 Starting a process without a shell - | -14 | os.spawnlp("true") -15 | os.spawnlpe("true") -16 | os.spawnv("true") - | ^^^^^^^^^ S606 -17 | os.spawnve("true") -18 | os.spawnvp("true") - | - -S606.py:17:1: S606 Starting a process without a shell - | -15 | os.spawnlpe("true") -16 | os.spawnv("true") -17 | os.spawnve("true") - | ^^^^^^^^^^ S606 -18 | os.spawnvp("true") -19 | os.spawnvpe("true") - | - -S606.py:18:1: S606 Starting a process without a shell - | -16 | os.spawnv("true") -17 | os.spawnve("true") -18 | os.spawnvp("true") - | ^^^^^^^^^^ S606 -19 | os.spawnvpe("true") -20 | os.startfile("true") - | - -S606.py:19:1: S606 Starting a process without a shell - | -17 | os.spawnve("true") -18 | os.spawnvp("true") -19 | os.spawnvpe("true") - | ^^^^^^^^^^^ S606 -20 | os.startfile("true") - | - -S606.py:20:1: S606 Starting a process without a shell - | -18 | os.spawnvp("true") -19 | os.spawnvpe("true") -20 | os.startfile("true") - | ^^^^^^^^^^^^ S606 - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S607_S607.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S607_S607.py.snap deleted file mode 100644 index 611bd4b5b0..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S607_S607.py.snap +++ /dev/null @@ -1,223 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S607.py:9:11: S607 Starting a process with a partial executable path - | - 7 | subprocess.check_output("true") - 8 | subprocess.run("true") - 9 | os.system("true") - | ^^^^^^ S607 -10 | os.popen("true") -11 | os.popen2("true") - | - -S607.py:10:10: S607 Starting a process with a partial executable path - | - 8 | subprocess.run("true") - 9 | os.system("true") -10 | os.popen("true") - | ^^^^^^ S607 -11 | os.popen2("true") -12 | os.popen3("true") - | - -S607.py:11:11: S607 Starting a process with a partial executable path - | - 9 | os.system("true") -10 | os.popen("true") -11 | os.popen2("true") - | ^^^^^^ S607 -12 | os.popen3("true") -13 | os.popen4("true") - | - -S607.py:12:11: S607 Starting a process with a partial executable path - | -10 | os.popen("true") -11 | os.popen2("true") -12 | os.popen3("true") - | ^^^^^^ S607 -13 | os.popen4("true") -14 | popen2.popen2("true") - | - -S607.py:13:11: S607 Starting a process with a partial executable path - | -11 | os.popen2("true") -12 | os.popen3("true") -13 | os.popen4("true") - | ^^^^^^ S607 -14 | popen2.popen2("true") -15 | popen2.popen3("true") - | - -S607.py:21:10: S607 Starting a process with a partial executable path - | -19 | commands.getoutput("true") -20 | commands.getstatusoutput("true") -21 | os.execl("true") - | ^^^^^^ S607 -22 | os.execle("true") -23 | os.execlp("true") - | - -S607.py:22:11: S607 Starting a process with a partial executable path - | -20 | commands.getstatusoutput("true") -21 | os.execl("true") -22 | os.execle("true") - | ^^^^^^ S607 -23 | os.execlp("true") -24 | os.execlpe("true") - | - -S607.py:23:11: S607 Starting a process with a partial executable path - | -21 | os.execl("true") -22 | os.execle("true") -23 | os.execlp("true") - | ^^^^^^ S607 -24 | os.execlpe("true") -25 | os.execv("true") - | - -S607.py:24:12: S607 Starting a process with a partial executable path - | -22 | os.execle("true") -23 | os.execlp("true") -24 | os.execlpe("true") - | ^^^^^^ S607 -25 | os.execv("true") -26 | os.execve("true") - | - -S607.py:25:10: S607 Starting a process with a partial executable path - | -23 | os.execlp("true") -24 | os.execlpe("true") -25 | os.execv("true") - | ^^^^^^ S607 -26 | os.execve("true") -27 | os.execvp("true") - | - -S607.py:26:11: S607 Starting a process with a partial executable path - | -24 | os.execlpe("true") -25 | os.execv("true") -26 | os.execve("true") - | ^^^^^^ S607 -27 | os.execvp("true") -28 | os.execvpe("true") - | - -S607.py:27:11: S607 Starting a process with a partial executable path - | -25 | os.execv("true") -26 | os.execve("true") -27 | os.execvp("true") - | ^^^^^^ S607 -28 | os.execvpe("true") -29 | os.spawnl("true") - | - -S607.py:28:12: S607 Starting a process with a partial executable path - | -26 | os.execve("true") -27 | os.execvp("true") -28 | os.execvpe("true") - | ^^^^^^ S607 -29 | os.spawnl("true") -30 | os.spawnle("true") - | - -S607.py:29:11: S607 Starting a process with a partial executable path - | -27 | os.execvp("true") -28 | os.execvpe("true") -29 | os.spawnl("true") - | ^^^^^^ S607 -30 | os.spawnle("true") -31 | os.spawnlp("true") - | - -S607.py:30:12: S607 Starting a process with a partial executable path - | -28 | os.execvpe("true") -29 | os.spawnl("true") -30 | os.spawnle("true") - | ^^^^^^ S607 -31 | os.spawnlp("true") -32 | os.spawnlpe("true") - | - -S607.py:31:12: S607 Starting a process with a partial executable path - | -29 | os.spawnl("true") -30 | os.spawnle("true") -31 | os.spawnlp("true") - | ^^^^^^ S607 -32 | os.spawnlpe("true") -33 | os.spawnv("true") - | - -S607.py:32:13: S607 Starting a process with a partial executable path - | -30 | os.spawnle("true") -31 | os.spawnlp("true") -32 | os.spawnlpe("true") - | ^^^^^^ S607 -33 | os.spawnv("true") -34 | os.spawnve("true") - | - -S607.py:33:11: S607 Starting a process with a partial executable path - | -31 | os.spawnlp("true") -32 | os.spawnlpe("true") -33 | os.spawnv("true") - | ^^^^^^ S607 -34 | os.spawnve("true") -35 | os.spawnvp("true") - | - -S607.py:34:12: S607 Starting a process with a partial executable path - | -32 | os.spawnlpe("true") -33 | os.spawnv("true") -34 | os.spawnve("true") - | ^^^^^^ S607 -35 | os.spawnvp("true") -36 | os.spawnvpe("true") - | - -S607.py:35:12: S607 Starting a process with a partial executable path - | -33 | os.spawnv("true") -34 | os.spawnve("true") -35 | os.spawnvp("true") - | ^^^^^^ S607 -36 | os.spawnvpe("true") -37 | os.startfile("true") - | - -S607.py:36:13: S607 Starting a process with a partial executable path - | -34 | os.spawnve("true") -35 | os.spawnvp("true") -36 | os.spawnvpe("true") - | ^^^^^^ S607 -37 | os.startfile("true") - | - -S607.py:37:14: S607 Starting a process with a partial executable path - | -35 | os.spawnvp("true") -36 | os.spawnvpe("true") -37 | os.startfile("true") - | ^^^^^^ S607 -38 | -39 | # Check it does not fail for full paths. - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S608_S608.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S608_S608.py.snap deleted file mode 100644 index 6107faa2c6..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S608_S608.py.snap +++ /dev/null @@ -1,482 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S608.py:2:10: S608 Possible SQL injection vector through string-based query construction - | -1 | # single-line failures -2 | query1 = "SELECT %s FROM table" % (var,) # bad - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -3 | query2 = "SELECT var FROM " + table -4 | query3 = "SELECT " + val + " FROM " + table - | - -S608.py:3:10: S608 Possible SQL injection vector through string-based query construction - | -1 | # single-line failures -2 | query1 = "SELECT %s FROM table" % (var,) # bad -3 | query2 = "SELECT var FROM " + table - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -4 | query3 = "SELECT " + val + " FROM " + table -5 | query4 = "SELECT {} FROM table;".format(var) - | - -S608.py:4:10: S608 Possible SQL injection vector through string-based query construction - | -2 | query1 = "SELECT %s FROM table" % (var,) # bad -3 | query2 = "SELECT var FROM " + table -4 | query3 = "SELECT " + val + " FROM " + table - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -5 | query4 = "SELECT {} FROM table;".format(var) -6 | query5 = f"SELECT * FROM table WHERE var = {var}" - | - -S608.py:5:10: S608 Possible SQL injection vector through string-based query construction - | -3 | query2 = "SELECT var FROM " + table -4 | query3 = "SELECT " + val + " FROM " + table -5 | query4 = "SELECT {} FROM table;".format(var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -6 | query5 = f"SELECT * FROM table WHERE var = {var}" - | - -S608.py:6:10: S608 Possible SQL injection vector through string-based query construction - | -4 | query3 = "SELECT " + val + " FROM " + table -5 | query4 = "SELECT {} FROM table;".format(var) -6 | query5 = f"SELECT * FROM table WHERE var = {var}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -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 | - 8 | query6 = "DELETE FROM table WHERE var = %s" % (var,) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 - 9 | query7 = "DELETE FROM table WHERE VAR = " + var -10 | query8 = "DELETE FROM " + table + "WHERE var = " + var - | - -S608.py:9:10: S608 Possible SQL injection vector through string-based query construction - | - 8 | query6 = "DELETE FROM table WHERE var = %s" % (var,) - 9 | query7 = "DELETE FROM table WHERE VAR = " + var - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -10 | query8 = "DELETE FROM " + table + "WHERE var = " + var -11 | query9 = "DELETE FROM table WHERE var = {}".format(var) - | - -S608.py:10:10: S608 Possible SQL injection vector through string-based query construction - | - 8 | query6 = "DELETE FROM table WHERE var = %s" % (var,) - 9 | query7 = "DELETE FROM table WHERE VAR = " + var -10 | query8 = "DELETE FROM " + table + "WHERE var = " + var - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -11 | query9 = "DELETE FROM table WHERE var = {}".format(var) -12 | query10 = f"DELETE FROM table WHERE var = {var}" - | - -S608.py:11:10: S608 Possible SQL injection vector through string-based query construction - | - 9 | query7 = "DELETE FROM table WHERE VAR = " + var -10 | query8 = "DELETE FROM " + table + "WHERE var = " + var -11 | query9 = "DELETE FROM table WHERE var = {}".format(var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -12 | query10 = f"DELETE FROM table WHERE var = {var}" - | - -S608.py:12:11: S608 Possible SQL injection vector through string-based query construction - | -10 | query8 = "DELETE FROM " + table + "WHERE var = " + var -11 | query9 = "DELETE FROM table WHERE var = {}".format(var) -12 | query10 = f"DELETE FROM table WHERE var = {var}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -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 | -14 | query11 = "INSERT INTO table VALUES (%s)" % (var,) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -15 | query12 = "INSERT INTO TABLE VALUES (" + var + ")" -16 | query13 = "INSERT INTO {} VALUES ({})".format(table, var) - | - -S608.py:15:11: S608 Possible SQL injection vector through string-based query construction - | -14 | query11 = "INSERT INTO table VALUES (%s)" % (var,) -15 | query12 = "INSERT INTO TABLE VALUES (" + var + ")" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -16 | query13 = "INSERT INTO {} VALUES ({})".format(table, var) -17 | query14 = f"INSERT INTO {table} VALUES var = {var}" - | - -S608.py:16:11: S608 Possible SQL injection vector through string-based query construction - | -14 | query11 = "INSERT INTO table VALUES (%s)" % (var,) -15 | query12 = "INSERT INTO TABLE VALUES (" + var + ")" -16 | query13 = "INSERT INTO {} VALUES ({})".format(table, var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -17 | query14 = f"INSERT INTO {table} VALUES var = {var}" - | - -S608.py:17:11: S608 Possible SQL injection vector through string-based query construction - | -15 | query12 = "INSERT INTO TABLE VALUES (" + var + ")" -16 | query13 = "INSERT INTO {} VALUES ({})".format(table, var) -17 | query14 = f"INSERT INTO {table} VALUES var = {var}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -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 | -19 | query15 = "UPDATE %s SET var = %s" % (table, var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -20 | query16 = "UPDATE " + table + " SET var = " + var -21 | query17 = "UPDATE {} SET var = {}".format(table, var) - | - -S608.py:20:11: S608 Possible SQL injection vector through string-based query construction - | -19 | query15 = "UPDATE %s SET var = %s" % (table, var) -20 | query16 = "UPDATE " + table + " SET var = " + var - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -21 | query17 = "UPDATE {} SET var = {}".format(table, var) -22 | query18 = f"UPDATE {table} SET var = {var}" - | - -S608.py:21:11: S608 Possible SQL injection vector through string-based query construction - | -19 | query15 = "UPDATE %s SET var = %s" % (table, var) -20 | query16 = "UPDATE " + table + " SET var = " + var -21 | query17 = "UPDATE {} SET var = {}".format(table, var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -22 | query18 = f"UPDATE {table} SET var = {var}" - | - -S608.py:22:11: S608 Possible SQL injection vector through string-based query construction - | -20 | query16 = "UPDATE " + table + " SET var = " + var -21 | query17 = "UPDATE {} SET var = {}".format(table, var) -22 | query18 = f"UPDATE {table} SET var = {var}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -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 | -24 | query19 = "select %s from table" % (var,) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -25 | query20 = "select var from " + table -26 | query21 = "select " + val + " from " + table - | - -S608.py:25:11: S608 Possible SQL injection vector through string-based query construction - | -24 | query19 = "select %s from table" % (var,) -25 | query20 = "select var from " + table - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -26 | query21 = "select " + val + " from " + table -27 | query22 = "select {} from table;".format(var) - | - -S608.py:26:11: S608 Possible SQL injection vector through string-based query construction - | -24 | query19 = "select %s from table" % (var,) -25 | query20 = "select var from " + table -26 | query21 = "select " + val + " from " + table - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -27 | query22 = "select {} from table;".format(var) -28 | query23 = f"select * from table where var = {var}" - | - -S608.py:27:11: S608 Possible SQL injection vector through string-based query construction - | -25 | query20 = "select var from " + table -26 | query21 = "select " + val + " from " + table -27 | query22 = "select {} from table;".format(var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -28 | query23 = f"select * from table where var = {var}" - | - -S608.py:28:11: S608 Possible SQL injection vector through string-based query construction - | -26 | query21 = "select " + val + " from " + table -27 | query22 = "select {} from table;".format(var) -28 | query23 = f"select * from table where var = {var}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -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 | -30 | query24 = "delete from table where var = %s" % (var,) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -31 | query25 = "delete from table where var = " + var -32 | query26 = "delete from " + table + "where var = " + var - | - -S608.py:31:11: S608 Possible SQL injection vector through string-based query construction - | -30 | query24 = "delete from table where var = %s" % (var,) -31 | query25 = "delete from table where var = " + var - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -32 | query26 = "delete from " + table + "where var = " + var -33 | query27 = "delete from table where var = {}".format(var) - | - -S608.py:32:11: S608 Possible SQL injection vector through string-based query construction - | -30 | query24 = "delete from table where var = %s" % (var,) -31 | query25 = "delete from table where var = " + var -32 | query26 = "delete from " + table + "where var = " + var - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -33 | query27 = "delete from table where var = {}".format(var) -34 | query28 = f"delete from table where var = {var}" - | - -S608.py:33:11: S608 Possible SQL injection vector through string-based query construction - | -31 | query25 = "delete from table where var = " + var -32 | query26 = "delete from " + table + "where var = " + var -33 | query27 = "delete from table where var = {}".format(var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -34 | query28 = f"delete from table where var = {var}" - | - -S608.py:34:11: S608 Possible SQL injection vector through string-based query construction - | -32 | query26 = "delete from " + table + "where var = " + var -33 | query27 = "delete from table where var = {}".format(var) -34 | query28 = f"delete from table where var = {var}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -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 | -36 | query29 = "insert into table values (%s)" % (var,) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -37 | query30 = "insert into table values (" + var + ")" -38 | query31 = "insert into {} values ({})".format(table, var) - | - -S608.py:37:11: S608 Possible SQL injection vector through string-based query construction - | -36 | query29 = "insert into table values (%s)" % (var,) -37 | query30 = "insert into table values (" + var + ")" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -38 | query31 = "insert into {} values ({})".format(table, var) -39 | query32 = f"insert into {table} values var = {var}" - | - -S608.py:38:11: S608 Possible SQL injection vector through string-based query construction - | -36 | query29 = "insert into table values (%s)" % (var,) -37 | query30 = "insert into table values (" + var + ")" -38 | query31 = "insert into {} values ({})".format(table, var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -39 | query32 = f"insert into {table} values var = {var}" - | - -S608.py:39:11: S608 Possible SQL injection vector through string-based query construction - | -37 | query30 = "insert into table values (" + var + ")" -38 | query31 = "insert into {} values ({})".format(table, var) -39 | query32 = f"insert into {table} values var = {var}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -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 | -41 | query33 = "update %s set var = %s" % (table, var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -42 | query34 = "update " + table + " set var = " + var -43 | query35 = "update {} set var = {}".format(table, var) - | - -S608.py:42:11: S608 Possible SQL injection vector through string-based query construction - | -41 | query33 = "update %s set var = %s" % (table, var) -42 | query34 = "update " + table + " set var = " + var - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -43 | query35 = "update {} set var = {}".format(table, var) -44 | query36 = f"update {table} set var = {var}" - | - -S608.py:43:11: S608 Possible SQL injection vector through string-based query construction - | -41 | query33 = "update %s set var = %s" % (table, var) -42 | query34 = "update " + table + " set var = " + var -43 | query35 = "update {} set var = {}".format(table, var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -44 | query36 = f"update {table} set var = {var}" - | - -S608.py:44:11: S608 Possible SQL injection vector through string-based query construction - | -42 | query34 = "update " + table + " set var = " + var -43 | query35 = "update {} set var = {}".format(table, var) -44 | query36 = f"update {table} set var = {var}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -45 | -46 | # multi-line failures - | - -S608.py:48:12: S608 Possible SQL injection vector through string-based query construction - | -46 | # multi-line failures -47 | def query37(): -48 | return """ - | ____________^ -49 | | SELECT * -50 | | FROM table -51 | | WHERE var = %s -52 | | """ % var - | |_____________^ S608 -53 | -54 | def query38(): - | - -S608.py:55:12: S608 Possible SQL injection vector through string-based query construction - | -54 | def query38(): -55 | return """ - | ____________^ -56 | | SELECT * -57 | | FROM TABLE -58 | | WHERE var = -59 | | """ + var - | |_____________^ S608 -60 | -61 | def query39(): - | - -S608.py:62:12: S608 Possible SQL injection vector through string-based query construction - | -61 | def query39(): -62 | return """ - | ____________^ -63 | | SELECT * -64 | | FROM table -65 | | WHERE var = {} -66 | | """.format(var) - | |___________________^ S608 -67 | -68 | def query40(): - | - -S608.py:69:12: S608 Possible SQL injection vector through string-based query construction - | -68 | def query40(): -69 | return f""" - | ____________^ -70 | | SELECT * -71 | | FROM table -72 | | WHERE var = {var} -73 | | """ - | |_______^ S608 -74 | -75 | def query41(): - | - -S608.py:77:9: S608 Possible SQL injection vector through string-based query construction - | -75 | def query41(): -76 | return ( -77 | "SELECT * " - | _________^ -78 | | "FROM table " -79 | | f"WHERE var = {var}" - | |____________________________^ S608 -80 | ) - | - -S608.py:83:26: S608 Possible SQL injection vector through string-based query construction - | -82 | # # cursor-wrapped failures -83 | query42 = cursor.execute("SELECT * FROM table WHERE var = %s" % var) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -84 | query43 = cursor.execute(f"SELECT * FROM table WHERE var = {var}") -85 | query44 = cursor.execute("SELECT * FROM table WHERE var = {}".format(var)) - | - -S608.py:84:26: S608 Possible SQL injection vector through string-based query construction - | -82 | # # cursor-wrapped failures -83 | query42 = cursor.execute("SELECT * FROM table WHERE var = %s" % var) -84 | query43 = cursor.execute(f"SELECT * FROM table WHERE var = {var}") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -85 | query44 = cursor.execute("SELECT * FROM table WHERE var = {}".format(var)) -86 | query45 = cursor.executemany("SELECT * FROM table WHERE var = %s" % var, []) - | - -S608.py:85:26: S608 Possible SQL injection vector through string-based query construction - | -83 | query42 = cursor.execute("SELECT * FROM table WHERE var = %s" % var) -84 | query43 = cursor.execute(f"SELECT * FROM table WHERE var = {var}") -85 | query44 = cursor.execute("SELECT * FROM table WHERE var = {}".format(var)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -86 | query45 = cursor.executemany("SELECT * FROM table WHERE var = %s" % var, []) - | - -S608.py:86:30: S608 Possible SQL injection vector through string-based query construction - | -84 | query43 = cursor.execute(f"SELECT * FROM table WHERE var = {var}") -85 | query44 = cursor.execute("SELECT * FROM table WHERE var = {}".format(var)) -86 | query45 = cursor.executemany("SELECT * FROM table WHERE var = %s" % var, []) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -87 | -88 | # # pass - | - -S608.py:98:9: S608 Possible SQL injection vector through string-based query construction - | - 97 | # # INSERT without INTO (e.g. MySQL and derivatives) - 98 | query = "INSERT table VALUES (%s)" % (var,) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 - 99 | -100 | # # REPLACE (e.g. MySQL and derivatives, SQLite) - | - -S608.py:101:9: S608 Possible SQL injection vector through string-based query construction - | -100 | # # REPLACE (e.g. MySQL and derivatives, SQLite) -101 | query = "REPLACE INTO table VALUES (%s)" % (var,) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -102 | query = "REPLACE table VALUES (%s)" % (var,) - | - -S608.py:102:9: S608 Possible SQL injection vector through string-based query construction - | -100 | # # REPLACE (e.g. MySQL and derivatives, SQLite) -101 | query = "REPLACE INTO table VALUES (%s)" % (var,) -102 | query = "REPLACE table VALUES (%s)" % (var,) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 -103 | -104 | query = "Deselect something that is not SQL even though it has a ' from ' somewhere in %s." % "there" - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S609_S609.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S609_S609.py.snap deleted file mode 100644 index 77f2dda9c1..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S609_S609.py.snap +++ /dev/null @@ -1,41 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S609.py:4:1: S609 Possible wildcard injection in call due to `*` usage - | -2 | import subprocess -3 | -4 | os.popen("chmod +w foo*") - | ^^^^^^^^ S609 -5 | subprocess.Popen("/bin/chown root: *", shell=True) -6 | subprocess.Popen(["/usr/local/bin/rsync", "*", "some_where:"], shell=True) - | - -S609.py:5:1: S609 Possible wildcard injection in call due to `*` usage - | -4 | os.popen("chmod +w foo*") -5 | subprocess.Popen("/bin/chown root: *", shell=True) - | ^^^^^^^^^^^^^^^^ S609 -6 | subprocess.Popen(["/usr/local/bin/rsync", "*", "some_where:"], shell=True) -7 | subprocess.Popen("/usr/local/bin/rsync * no_injection_here:") - | - -S609.py:6:1: S609 Possible wildcard injection in call due to `*` usage - | -4 | os.popen("chmod +w foo*") -5 | subprocess.Popen("/bin/chown root: *", shell=True) -6 | subprocess.Popen(["/usr/local/bin/rsync", "*", "some_where:"], shell=True) - | ^^^^^^^^^^^^^^^^ S609 -7 | subprocess.Popen("/usr/local/bin/rsync * no_injection_here:") -8 | os.system("tar cf foo.tar bar/*") - | - -S609.py:8:1: S609 Possible wildcard injection in call due to `*` usage - | -6 | subprocess.Popen(["/usr/local/bin/rsync", "*", "some_where:"], shell=True) -7 | subprocess.Popen("/usr/local/bin/rsync * no_injection_here:") -8 | os.system("tar cf foo.tar bar/*") - | ^^^^^^^^^ S609 - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S612_S612.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S612_S612.py.snap deleted file mode 100644 index a86254f6e3..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S612_S612.py.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -S612.py:3:5: S612 Use of insecure `logging.config.listen` detected - | -1 | import logging.config -2 | -3 | t = logging.config.listen(9999) - | ^^^^^^^^^^^^^^^^^^^^^ S612 -4 | -5 | def verify_func(): - | - - diff --git a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S701_S701.py.snap b/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S701_S701.py.snap deleted file mode 100644 index c8927f68d0..0000000000 --- a/crates/ruff/src/rules/flake8_bandit/snapshots/ruff__rules__flake8_bandit__tests__S701_S701.py.snap +++ /dev/null @@ -1,51 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bandit/mod.rs ---- -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. - | - 7 | templateEnv = jinja2.Environment(autoescape=True, - 8 | loader=templateLoader ) - 9 | Environment(loader=templateLoader, load=templateLoader, autoescape=something) # S701 - | ^^^^^^^^^^^^^^^^^^^^ S701 -10 | templateEnv = jinja2.Environment(autoescape=False, loader=templateLoader ) # S701 -11 | Environment(loader=templateLoader, - | - -S701.py:10:34: S701 Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function. - | - 8 | loader=templateLoader ) - 9 | Environment(loader=templateLoader, load=templateLoader, autoescape=something) # S701 -10 | templateEnv = jinja2.Environment(autoescape=False, loader=templateLoader ) # S701 - | ^^^^^^^^^^^^^^^^ S701 -11 | Environment(loader=templateLoader, -12 | load=templateLoader, - | - -S701.py:13:13: S701 Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function. - | -11 | Environment(loader=templateLoader, -12 | load=templateLoader, -13 | autoescape=False) # S701 - | ^^^^^^^^^^^^^^^^ S701 -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 | -15 | Environment(loader=templateLoader, # S701 - | ^^^^^^^^^^^ S701 -16 | load=templateLoader) - | - -S701.py:29:36: S701 Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function. - | -27 | def fake_func(): -28 | return 'foobar' -29 | Environment(loader=templateLoader, autoescape=fake_func()) # S701 - | ^^^^^^^^^^^^^^^^^^^^^^ S701 - | - - diff --git a/crates/ruff/src/rules/flake8_blind_except/snapshots/ruff__rules__flake8_blind_except__tests__BLE001_BLE.py.snap b/crates/ruff/src/rules/flake8_blind_except/snapshots/ruff__rules__flake8_blind_except__tests__BLE001_BLE.py.snap deleted file mode 100644 index 51e15bbf6a..0000000000 --- a/crates/ruff/src/rules/flake8_blind_except/snapshots/ruff__rules__flake8_blind_except__tests__BLE001_BLE.py.snap +++ /dev/null @@ -1,97 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_blind_except/mod.rs ---- -BLE.py:25:8: BLE001 Do not catch blind exception: `BaseException` - | -23 | except Exception as e: -24 | raise e -25 | except BaseException: - | ^^^^^^^^^^^^^ BLE001 -26 | pass - | - -BLE.py:31:8: BLE001 Do not catch blind exception: `Exception` - | -29 | try: -30 | pass -31 | except Exception: - | ^^^^^^^^^ BLE001 -32 | pass -33 | finally: - | - -BLE.py:42:8: BLE001 Do not catch blind exception: `Exception` - | -40 | try: -41 | pass -42 | except Exception as e: - | ^^^^^^^^^ BLE001 -43 | try: -44 | raise e - | - -BLE.py:45:12: BLE001 Do not catch blind exception: `BaseException` - | -43 | try: -44 | raise e -45 | except BaseException: - | ^^^^^^^^^^^^^ BLE001 -46 | pass - | - -BLE.py:54:8: BLE001 Do not catch blind exception: `Exception` - | -52 | except BaseException as e: -53 | raise e -54 | except Exception: - | ^^^^^^^^^ BLE001 -55 | pass - | - -BLE.py:60:8: BLE001 Do not catch blind exception: `Exception` - | -58 | try: -59 | pass -60 | except Exception as e: - | ^^^^^^^^^ BLE001 -61 | raise bad -62 | except BaseException: - | - -BLE.py:62:8: BLE001 Do not catch blind exception: `BaseException` - | -60 | except Exception as e: -61 | raise bad -62 | except BaseException: - | ^^^^^^^^^^^^^ BLE001 -63 | pass - | - -BLE.py:69:8: BLE001 Do not catch blind exception: `Exception` - | -67 | try: -68 | pass -69 | except Exception: - | ^^^^^^^^^ BLE001 -70 | logging.error("...") - | - -BLE.py:75:8: BLE001 Do not catch blind exception: `Exception` - | -73 | try: -74 | pass -75 | except Exception: - | ^^^^^^^^^ BLE001 -76 | logging.error("...", exc_info=False) - | - -BLE.py:81:8: BLE001 Do not catch blind exception: `Exception` - | -79 | try: -80 | pass -81 | except Exception: - | ^^^^^^^^^ BLE001 -82 | logging.error("...", exc_info=None) - | - - diff --git a/crates/ruff/src/rules/flake8_boolean_trap/snapshots/ruff__rules__flake8_boolean_trap__tests__FBT001_FBT.py.snap b/crates/ruff/src/rules/flake8_boolean_trap/snapshots/ruff__rules__flake8_boolean_trap__tests__FBT001_FBT.py.snap deleted file mode 100644 index b1c02ae694..0000000000 --- a/crates/ruff/src/rules/flake8_boolean_trap/snapshots/ruff__rules__flake8_boolean_trap__tests__FBT001_FBT.py.snap +++ /dev/null @@ -1,92 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_boolean_trap/mod.rs ---- -FBT.py:4:5: FBT001 Boolean-typed positional argument in function definition - | -2 | posonly_nohint, -3 | posonly_nonboolhint: int, -4 | posonly_boolhint: bool, - | ^^^^^^^^^^^^^^^^ FBT001 -5 | posonly_boolstrhint: "bool", -6 | /, - | - -FBT.py:5:5: FBT001 Boolean-typed positional argument in function definition - | -3 | posonly_nonboolhint: int, -4 | posonly_boolhint: bool, -5 | posonly_boolstrhint: "bool", - | ^^^^^^^^^^^^^^^^^^^ FBT001 -6 | /, -7 | offset, - | - -FBT.py:10:5: FBT001 Boolean-typed positional argument in function definition - | - 8 | posorkw_nonvalued_nohint, - 9 | posorkw_nonvalued_nonboolhint: int, -10 | posorkw_nonvalued_boolhint: bool, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001 -11 | posorkw_nonvalued_boolstrhint: "bool", -12 | posorkw_boolvalued_nohint=True, - | - -FBT.py:11:5: FBT001 Boolean-typed positional argument in function definition - | - 9 | posorkw_nonvalued_nonboolhint: int, -10 | posorkw_nonvalued_boolhint: bool, -11 | posorkw_nonvalued_boolstrhint: "bool", - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001 -12 | posorkw_boolvalued_nohint=True, -13 | posorkw_boolvalued_nonboolhint: int = True, - | - -FBT.py:14:5: FBT001 Boolean-typed positional argument in function definition - | -12 | posorkw_boolvalued_nohint=True, -13 | posorkw_boolvalued_nonboolhint: int = True, -14 | posorkw_boolvalued_boolhint: bool = True, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001 -15 | posorkw_boolvalued_boolstrhint: "bool" = True, -16 | posorkw_nonboolvalued_nohint=1, - | - -FBT.py:15:5: FBT001 Boolean-typed positional argument in function definition - | -13 | posorkw_boolvalued_nonboolhint: int = True, -14 | posorkw_boolvalued_boolhint: bool = True, -15 | posorkw_boolvalued_boolstrhint: "bool" = True, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001 -16 | posorkw_nonboolvalued_nohint=1, -17 | posorkw_nonboolvalued_nonboolhint: int = 2, - | - -FBT.py:18:5: FBT001 Boolean-typed positional argument in function definition - | -16 | posorkw_nonboolvalued_nohint=1, -17 | posorkw_nonboolvalued_nonboolhint: int = 2, -18 | posorkw_nonboolvalued_boolhint: bool = 3, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001 -19 | posorkw_nonboolvalued_boolstrhint: "bool" = 4, -20 | *, - | - -FBT.py:19:5: FBT001 Boolean-typed positional argument in function definition - | -17 | posorkw_nonboolvalued_nonboolhint: int = 2, -18 | posorkw_nonboolvalued_boolhint: bool = 3, -19 | posorkw_nonboolvalued_boolstrhint: "bool" = 4, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001 -20 | *, -21 | kwonly_nonvalued_nohint, - | - -FBT.py:87:19: FBT001 Boolean-typed positional argument in function definition - | -86 | # FBT001: Boolean positional arg in function definition -87 | def foo(self, value: bool) -> None: - | ^^^^^ FBT001 -88 | pass - | - - diff --git a/crates/ruff/src/rules/flake8_boolean_trap/snapshots/ruff__rules__flake8_boolean_trap__tests__FBT002_FBT.py.snap b/crates/ruff/src/rules/flake8_boolean_trap/snapshots/ruff__rules__flake8_boolean_trap__tests__FBT002_FBT.py.snap deleted file mode 100644 index 688254791d..0000000000 --- a/crates/ruff/src/rules/flake8_boolean_trap/snapshots/ruff__rules__flake8_boolean_trap__tests__FBT002_FBT.py.snap +++ /dev/null @@ -1,44 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_boolean_trap/mod.rs ---- -FBT.py:12:5: FBT002 Boolean default positional argument in function definition - | -10 | posorkw_nonvalued_boolhint: bool, -11 | posorkw_nonvalued_boolstrhint: "bool", -12 | posorkw_boolvalued_nohint=True, - | ^^^^^^^^^^^^^^^^^^^^^^^^^ FBT002 -13 | posorkw_boolvalued_nonboolhint: int = True, -14 | posorkw_boolvalued_boolhint: bool = True, - | - -FBT.py:13:5: FBT002 Boolean default positional argument in function definition - | -11 | posorkw_nonvalued_boolstrhint: "bool", -12 | posorkw_boolvalued_nohint=True, -13 | posorkw_boolvalued_nonboolhint: int = True, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT002 -14 | posorkw_boolvalued_boolhint: bool = True, -15 | posorkw_boolvalued_boolstrhint: "bool" = True, - | - -FBT.py:14:5: FBT002 Boolean default positional argument in function definition - | -12 | posorkw_boolvalued_nohint=True, -13 | posorkw_boolvalued_nonboolhint: int = True, -14 | posorkw_boolvalued_boolhint: bool = True, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT002 -15 | posorkw_boolvalued_boolstrhint: "bool" = True, -16 | posorkw_nonboolvalued_nohint=1, - | - -FBT.py:15:5: FBT002 Boolean default positional argument in function definition - | -13 | posorkw_boolvalued_nonboolhint: int = True, -14 | posorkw_boolvalued_boolhint: bool = True, -15 | posorkw_boolvalued_boolstrhint: "bool" = True, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT002 -16 | posorkw_nonboolvalued_nohint=1, -17 | posorkw_nonboolvalued_nonboolhint: int = 2, - | - - diff --git a/crates/ruff/src/rules/flake8_boolean_trap/snapshots/ruff__rules__flake8_boolean_trap__tests__FBT003_FBT.py.snap b/crates/ruff/src/rules/flake8_boolean_trap/snapshots/ruff__rules__flake8_boolean_trap__tests__FBT003_FBT.py.snap deleted file mode 100644 index 9da28a09c3..0000000000 --- a/crates/ruff/src/rules/flake8_boolean_trap/snapshots/ruff__rules__flake8_boolean_trap__tests__FBT003_FBT.py.snap +++ /dev/null @@ -1,41 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_boolean_trap/mod.rs ---- -FBT.py:42:11: FBT003 Boolean positional value in function call - | -42 | used("a", True) - | ^^^^ FBT003 -43 | used(do=True) - | - -FBT.py:57:11: FBT003 Boolean positional value in function call - | -55 | {}.pop(True, False) -56 | dict.fromkeys(("world",), True) -57 | {}.deploy(True, False) - | ^^^^ FBT003 -58 | getattr(someobj, attrname, False) -59 | mylist.index(True) - | - -FBT.py:57:17: FBT003 Boolean positional value in function call - | -55 | {}.pop(True, False) -56 | dict.fromkeys(("world",), True) -57 | {}.deploy(True, False) - | ^^^^^ FBT003 -58 | getattr(someobj, attrname, False) -59 | mylist.index(True) - | - -FBT.py:69:38: FBT003 Boolean positional value in function call - | -67 | os.set_blocking(0, False) -68 | g_action.set_enabled(True) -69 | settings.set_enable_developer_extras(True) - | ^^^^ FBT003 -70 | foo.is_(True) -71 | bar.is_not(False) - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B002_B002.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B002_B002.py.snap deleted file mode 100644 index d20338980c..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B002_B002.py.snap +++ /dev/null @@ -1,36 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B002.py:18:9: B002 Python does not support the unary prefix increment operator (`++`) - | -17 | def this_is_buggy(n): -18 | x = ++n - | ^^^ B002 -19 | y = --n -20 | return x, y - | - -B002.py:19:9: B002 Python does not support the unary prefix decrement operator (`--`) - | -17 | def this_is_buggy(n): -18 | x = ++n -19 | y = --n - | ^^^ B002 -20 | return x, y - | - -B002.py:24:12: B002 Python does not support the unary prefix increment operator (`++`) - | -23 | def this_is_buggy_too(n): -24 | return ++n, --n - | ^^^ B002 - | - -B002.py:24:17: B002 Python does not support the unary prefix decrement operator (`--`) - | -23 | def this_is_buggy_too(n): -24 | return ++n, --n - | ^^^ B002 - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B003_B003.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B003_B003.py.snap deleted file mode 100644 index ccce07920e..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B003_B003.py.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B003.py:9:1: B003 Assigning to `os.environ` doesn't clear the environment - | - 7 | from os import environ - 8 | - 9 | os.environ = {} - | ^^^^^^^^^^ B003 -10 | environ = {} # that's fine, assigning a new meaning to the module-level name - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B004_B004.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B004_B004.py.snap deleted file mode 100644 index 8ed1636e2f..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B004_B004.py.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B004.py:3:8: B004 [*] Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results. - | -1 | def this_is_a_bug(): -2 | o = object() -3 | if hasattr(o, "__call__"): - | ^^^^^^^^^^^^^^^^^^^^^^ B004 -4 | print("Ooh, callable! Or is it?") -5 | if getattr(o, "__call__", False): - | - = help: Replace with `callable()` - -ℹ Fix -1 1 | def this_is_a_bug(): -2 2 | o = object() -3 |- if hasattr(o, "__call__"): - 3 |+ if callable(o): -4 4 | print("Ooh, callable! Or is it?") -5 5 | if getattr(o, "__call__", False): -6 6 | print("Ooh, callable! Or is it?") - -B004.py:5:8: B004 Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results. - | -3 | if hasattr(o, "__call__"): -4 | print("Ooh, callable! Or is it?") -5 | if getattr(o, "__call__", False): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B004 -6 | print("Ooh, callable! Or is it?") - | - = help: Replace with `callable()` - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B005_B005.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B005_B005.py.snap deleted file mode 100644 index dc45e43384..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B005_B005.py.snap +++ /dev/null @@ -1,84 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B005.py:4:1: B005 Using `.strip()` with multi-character strings is misleading the reader - | -2 | s.strip(s) # no warning -3 | s.strip("we") # no warning -4 | s.strip(".facebook.com") # warning - | ^^^^^^^^^^^^^^^^^^^^^^^^ B005 -5 | s.strip("e") # no warning -6 | s.strip("\n\t ") # no warning - | - -B005.py:7:1: B005 Using `.strip()` with multi-character strings is misleading the reader - | -5 | s.strip("e") # no warning -6 | s.strip("\n\t ") # no warning -7 | s.strip(r"\n\t ") # warning - | ^^^^^^^^^^^^^^^^^ B005 -8 | s.lstrip(s) # no warning -9 | s.lstrip("we") # no warning - | - -B005.py:10:1: B005 Using `.strip()` with multi-character strings is misleading the reader - | - 8 | s.lstrip(s) # no warning - 9 | s.lstrip("we") # no warning -10 | s.lstrip(".facebook.com") # warning - | ^^^^^^^^^^^^^^^^^^^^^^^^^ B005 -11 | s.lstrip("e") # no warning -12 | s.lstrip("\n\t ") # no warning - | - -B005.py:13:1: B005 Using `.strip()` with multi-character strings is misleading the reader - | -11 | s.lstrip("e") # no warning -12 | s.lstrip("\n\t ") # no warning -13 | s.lstrip(r"\n\t ") # warning - | ^^^^^^^^^^^^^^^^^^ B005 -14 | s.rstrip(s) # no warning -15 | s.rstrip("we") # warning - | - -B005.py:16:1: B005 Using `.strip()` with multi-character strings is misleading the reader - | -14 | s.rstrip(s) # no warning -15 | s.rstrip("we") # warning -16 | s.rstrip(".facebook.com") # warning - | ^^^^^^^^^^^^^^^^^^^^^^^^^ B005 -17 | s.rstrip("e") # no warning -18 | s.rstrip("\n\t ") # no warning - | - -B005.py:19:1: B005 Using `.strip()` with multi-character strings is misleading the reader - | -17 | s.rstrip("e") # no warning -18 | s.rstrip("\n\t ") # no warning -19 | s.rstrip(r"\n\t ") # warning - | ^^^^^^^^^^^^^^^^^^ B005 -20 | s.strip("a") # no warning -21 | s.strip("あ") # no warning - | - -B005.py:22:1: B005 Using `.strip()` with multi-character strings is misleading the reader - | -20 | s.strip("a") # no warning -21 | s.strip("あ") # no warning -22 | s.strip("ああ") # warning - | ^^^^^^^^^^^^^^^ B005 -23 | s.strip("\ufeff") # no warning -24 | s.strip("\u0074\u0065\u0073\u0074") # warning - | - -B005.py:24:1: B005 Using `.strip()` with multi-character strings is misleading the reader - | -22 | s.strip("ああ") # warning -23 | s.strip("\ufeff") # no warning -24 | s.strip("\u0074\u0065\u0073\u0074") # warning - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B005 -25 | -26 | from somewhere import other_type, strip - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_1.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_1.py.snap deleted file mode 100644 index 092572890d..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_1.py.snap +++ /dev/null @@ -1,26 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B006_1.py:3:22: B006 [*] Do not use mutable data structures for argument defaults - | -1 | # Docstring followed by a newline -2 | -3 | def foobar(foor, bar={}): - | ^^ B006 -4 | """ -5 | """ - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -1 1 | # Docstring followed by a newline -2 2 | -3 |-def foobar(foor, bar={}): - 3 |+def foobar(foor, bar=None): -4 4 | """ -5 5 | """ - 6 |+ - 7 |+ if bar is None: - 8 |+ bar = {} - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_2.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_2.py.snap deleted file mode 100644 index 1e34f109fb..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_2.py.snap +++ /dev/null @@ -1,27 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -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 | -4 | def foobar(foor, bar={}): - | ^^ B006 -5 | """ -6 | """ - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -1 1 | # Docstring followed by whitespace with no newline -2 2 | # Regression test for https://github.com/astral-sh/ruff/issues/7155 -3 3 | -4 |-def foobar(foor, bar={}): - 4 |+def foobar(foor, bar=None): -5 5 | """ -6 |- """ - 6 |+ """ - 7 |+ if bar is None: - 8 |+ bar = {} - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_3.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_3.py.snap deleted file mode 100644 index 037d2d67cf..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_3.py.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B006_3.py:4:22: B006 [*] Do not use mutable data structures for argument defaults - | -4 | def foobar(foor, bar={}): - | ^^ B006 -5 | """ -6 | """ - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -1 1 | # Docstring with no newline -2 2 | -3 3 | -4 |-def foobar(foor, bar={}): - 4 |+def foobar(foor, bar=None): - 5 |+ """ -5 6 | """ -6 |- """ - 7 |+ if bar is None: - 8 |+ bar = {} - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_4.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_4.py.snap deleted file mode 100644 index 7d7b16b041..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_4.py.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B006_4.py:7:26: B006 [*] Do not use mutable data structures for argument defaults - | -6 | class FormFeedIndent: -7 | def __init__(self, a=[]): - | ^^ B006 -8 | print(a) - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -4 4 | -5 5 | -6 6 | class FormFeedIndent: -7 |- def __init__(self, a=[]): - 7 |+ def __init__(self, a=None): - 8 |+ if a is None: - 9 |+ a = [] -8 10 | print(a) -9 11 | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_B008.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_B008.py.snap deleted file mode 100644 index 05c860d523..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B006_B006_B008.py.snap +++ /dev/null @@ -1,498 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B006_B008.py:63:25: B006 [*] Do not use mutable data structures for argument defaults - | -63 | def this_is_wrong(value=[1, 2, 3]): - | ^^^^^^^^^ B006 -64 | ... - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -60 60 | # Flag mutable literals/comprehensions -61 61 | -62 62 | -63 |-def this_is_wrong(value=[1, 2, 3]): - 63 |+def this_is_wrong(value=None): - 64 |+ if value is None: - 65 |+ value = [1, 2, 3] -64 66 | ... -65 67 | -66 68 | - -B006_B008.py:67:30: B006 [*] Do not use mutable data structures for argument defaults - | -67 | def this_is_also_wrong(value={}): - | ^^ B006 -68 | ... - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -64 64 | ... -65 65 | -66 66 | -67 |-def this_is_also_wrong(value={}): - 67 |+def this_is_also_wrong(value=None): - 68 |+ if value is None: - 69 |+ value = {} -68 70 | ... -69 71 | -70 72 | - -B006_B008.py:73:52: B006 [*] Do not use mutable data structures for argument defaults - | -71 | class Foo: -72 | @staticmethod -73 | def this_is_also_wrong_and_more_indented(value={}): - | ^^ B006 -74 | pass - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -70 70 | -71 71 | class Foo: -72 72 | @staticmethod -73 |- def this_is_also_wrong_and_more_indented(value={}): - 73 |+ def this_is_also_wrong_and_more_indented(value=None): - 74 |+ if value is None: - 75 |+ value = {} -74 76 | pass -75 77 | -76 78 | - -B006_B008.py:77:31: B006 [*] Do not use mutable data structures for argument defaults - | -77 | def multiline_arg_wrong(value={ - | _______________________________^ -78 | | -79 | | }): - | |_^ B006 -80 | ... - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -74 74 | pass -75 75 | -76 76 | -77 |-def multiline_arg_wrong(value={ -78 |- -79 |-}): - 77 |+def multiline_arg_wrong(value=None): - 78 |+ if value is None: - 79 |+ value = {} -80 80 | ... -81 81 | -82 82 | def single_line_func_wrong(value = {}): ... - -B006_B008.py:82:36: B006 Do not use mutable data structures for argument defaults - | -80 | ... -81 | -82 | def single_line_func_wrong(value = {}): ... - | ^^ B006 - | - = help: Replace with `None`; initialize within function - -B006_B008.py:85:20: B006 [*] Do not use mutable data structures for argument defaults - | -85 | def and_this(value=set()): - | ^^^^^ B006 -86 | ... - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -82 82 | def single_line_func_wrong(value = {}): ... -83 83 | -84 84 | -85 |-def and_this(value=set()): - 85 |+def and_this(value=None): - 86 |+ if value is None: - 87 |+ value = set() -86 88 | ... -87 89 | -88 90 | - -B006_B008.py:89:20: B006 [*] Do not use mutable data structures for argument defaults - | -89 | def this_too(value=collections.OrderedDict()): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ B006 -90 | ... - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -86 86 | ... -87 87 | -88 88 | -89 |-def this_too(value=collections.OrderedDict()): - 89 |+def this_too(value=None): - 90 |+ if value is None: - 91 |+ value = collections.OrderedDict() -90 92 | ... -91 93 | -92 94 | - -B006_B008.py:93:32: B006 [*] Do not use mutable data structures for argument defaults - | -93 | async def async_this_too(value=collections.defaultdict()): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ B006 -94 | ... - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -90 90 | ... -91 91 | -92 92 | -93 |-async def async_this_too(value=collections.defaultdict()): - 93 |+async def async_this_too(value=None): - 94 |+ if value is None: - 95 |+ value = collections.defaultdict() -94 96 | ... -95 97 | -96 98 | - -B006_B008.py:97:26: B006 [*] Do not use mutable data structures for argument defaults - | -97 | def dont_forget_me(value=collections.deque()): - | ^^^^^^^^^^^^^^^^^^^ B006 -98 | ... - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -94 94 | ... -95 95 | -96 96 | -97 |-def dont_forget_me(value=collections.deque()): - 97 |+def dont_forget_me(value=None): - 98 |+ if value is None: - 99 |+ value = collections.deque() -98 100 | ... -99 101 | -100 102 | - -B006_B008.py:102:46: B006 [*] Do not use mutable data structures for argument defaults - | -101 | # N.B. we're also flagging the function call in the comprehension -102 | def list_comprehension_also_not_okay(default=[i**2 for i in range(3)]): - | ^^^^^^^^^^^^^^^^^^^^^^^^ B006 -103 | pass - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -99 99 | -100 100 | -101 101 | # N.B. we're also flagging the function call in the comprehension -102 |-def list_comprehension_also_not_okay(default=[i**2 for i in range(3)]): - 102 |+def list_comprehension_also_not_okay(default=None): - 103 |+ if default is None: - 104 |+ default = [i ** 2 for i in range(3)] -103 105 | pass -104 106 | -105 107 | - -B006_B008.py:106:46: B006 [*] Do not use mutable data structures for argument defaults - | -106 | def dict_comprehension_also_not_okay(default={i: i**2 for i in range(3)}): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B006 -107 | pass - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -103 103 | pass -104 104 | -105 105 | -106 |-def dict_comprehension_also_not_okay(default={i: i**2 for i in range(3)}): - 106 |+def dict_comprehension_also_not_okay(default=None): - 107 |+ if default is None: - 108 |+ default = {i: i ** 2 for i in range(3)} -107 109 | pass -108 110 | -109 111 | - -B006_B008.py:110:45: B006 [*] Do not use mutable data structures for argument defaults - | -110 | def set_comprehension_also_not_okay(default={i**2 for i in range(3)}): - | ^^^^^^^^^^^^^^^^^^^^^^^^ B006 -111 | pass - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -107 107 | pass -108 108 | -109 109 | -110 |-def set_comprehension_also_not_okay(default={i**2 for i in range(3)}): - 110 |+def set_comprehension_also_not_okay(default=None): - 111 |+ if default is None: - 112 |+ default = {i ** 2 for i in range(3)} -111 113 | pass -112 114 | -113 115 | - -B006_B008.py:114:33: B006 [*] Do not use mutable data structures for argument defaults - | -114 | def kwonlyargs_mutable(*, value=[]): - | ^^ B006 -115 | ... - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -111 111 | pass -112 112 | -113 113 | -114 |-def kwonlyargs_mutable(*, value=[]): - 114 |+def kwonlyargs_mutable(*, value=None): - 115 |+ if value is None: - 116 |+ value = [] -115 117 | ... -116 118 | -117 119 | - -B006_B008.py:239:20: B006 [*] Do not use mutable data structures for argument defaults - | -237 | # B006 and B008 -238 | # We should handle arbitrary nesting of these B008. -239 | def nested_combo(a=[float(3), dt.datetime.now()]): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B006 -240 | pass - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -236 236 | -237 237 | # B006 and B008 -238 238 | # We should handle arbitrary nesting of these B008. -239 |-def nested_combo(a=[float(3), dt.datetime.now()]): - 239 |+def nested_combo(a=None): - 240 |+ if a is None: - 241 |+ a = [float(3), dt.datetime.now()] -240 242 | pass -241 243 | -242 244 | - -B006_B008.py:276:27: B006 [*] Do not use mutable data structures for argument defaults - | -275 | def mutable_annotations( -276 | a: list[int] | None = [], - | ^^ B006 -277 | b: Optional[Dict[int, int]] = {}, -278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -273 273 | -274 274 | -275 275 | def mutable_annotations( -276 |- a: list[int] | None = [], - 276 |+ a: list[int] | None = None, -277 277 | b: Optional[Dict[int, int]] = {}, -278 278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), -279 279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), -280 280 | ): - 281 |+ if a is None: - 282 |+ a = [] -281 283 | pass -282 284 | -283 285 | - -B006_B008.py:277:35: B006 [*] Do not use mutable data structures for argument defaults - | -275 | def mutable_annotations( -276 | a: list[int] | None = [], -277 | b: Optional[Dict[int, int]] = {}, - | ^^ B006 -278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), -279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -274 274 | -275 275 | def mutable_annotations( -276 276 | a: list[int] | None = [], -277 |- b: Optional[Dict[int, int]] = {}, - 277 |+ b: Optional[Dict[int, int]] = None, -278 278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), -279 279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), -280 280 | ): - 281 |+ if b is None: - 282 |+ b = {} -281 283 | pass -282 284 | -283 285 | - -B006_B008.py:278:62: B006 [*] Do not use mutable data structures for argument defaults - | -276 | a: list[int] | None = [], -277 | b: Optional[Dict[int, int]] = {}, -278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), - | ^^^^^ B006 -279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), -280 | ): - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -275 275 | def mutable_annotations( -276 276 | a: list[int] | None = [], -277 277 | b: Optional[Dict[int, int]] = {}, -278 |- c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), - 278 |+ c: Annotated[Union[Set[str], abc.Sized], "annotation"] = None, -279 279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), -280 280 | ): - 281 |+ if c is None: - 282 |+ c = set() -281 283 | pass -282 284 | -283 285 | - -B006_B008.py:279:80: B006 [*] Do not use mutable data structures for argument defaults - | -277 | b: Optional[Dict[int, int]] = {}, -278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), -279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), - | ^^^^^ B006 -280 | ): -281 | pass - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -276 276 | a: list[int] | None = [], -277 277 | b: Optional[Dict[int, int]] = {}, -278 278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), -279 |- d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), - 279 |+ d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = None, -280 280 | ): - 281 |+ if d is None: - 282 |+ d = set() -281 283 | pass -282 284 | -283 285 | - -B006_B008.py:284:52: B006 [*] Do not use mutable data structures for argument defaults - | -284 | def single_line_func_wrong(value: dict[str, str] = {}): - | ^^ B006 -285 | """Docstring""" - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -281 281 | pass -282 282 | -283 283 | -284 |-def single_line_func_wrong(value: dict[str, str] = {}): - 284 |+def single_line_func_wrong(value: dict[str, str] = None): -285 285 | """Docstring""" - 286 |+ if value is None: - 287 |+ value = {} -286 288 | -287 289 | -288 290 | def single_line_func_wrong(value: dict[str, str] = {}): - -B006_B008.py:288:52: B006 [*] Do not use mutable data structures for argument defaults - | -288 | def single_line_func_wrong(value: dict[str, str] = {}): - | ^^ B006 -289 | """Docstring""" -290 | ... - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -285 285 | """Docstring""" -286 286 | -287 287 | -288 |-def single_line_func_wrong(value: dict[str, str] = {}): - 288 |+def single_line_func_wrong(value: dict[str, str] = None): -289 289 | """Docstring""" - 290 |+ if value is None: - 291 |+ value = {} -290 292 | ... -291 293 | -292 294 | - -B006_B008.py:293:52: B006 Do not use mutable data structures for argument defaults - | -293 | def single_line_func_wrong(value: dict[str, str] = {}): - | ^^ B006 -294 | """Docstring"""; ... - | - = help: Replace with `None`; initialize within function - -B006_B008.py:297:52: B006 Do not use mutable data structures for argument defaults - | -297 | def single_line_func_wrong(value: dict[str, str] = {}): - | ^^ B006 -298 | """Docstring"""; \ -299 | ... - | - = help: Replace with `None`; initialize within function - -B006_B008.py:302:52: B006 [*] Do not use mutable data structures for argument defaults - | -302 | def single_line_func_wrong(value: dict[str, str] = { - | ____________________________________________________^ -303 | | # This is a comment -304 | | }): - | |_^ B006 -305 | """Docstring""" - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -299 299 | ... -300 300 | -301 301 | -302 |-def single_line_func_wrong(value: dict[str, str] = { -303 |- # This is a comment -304 |-}): - 302 |+def single_line_func_wrong(value: dict[str, str] = None): -305 303 | """Docstring""" - 304 |+ if value is None: - 305 |+ value = {} -306 306 | -307 307 | -308 308 | def single_line_func_wrong(value: dict[str, str] = {}) \ - -B006_B008.py:308:52: B006 Do not use mutable data structures for argument defaults - | -308 | def single_line_func_wrong(value: dict[str, str] = {}) \ - | ^^ B006 -309 | : \ -310 | """Docstring""" - | - = help: Replace with `None`; initialize within function - -B006_B008.py:313:52: B006 [*] Do not use mutable data structures for argument defaults - | -313 | def single_line_func_wrong(value: dict[str, str] = {}): - | ^^ B006 -314 | """Docstring without newline""" - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -310 310 | """Docstring""" -311 311 | -312 312 | -313 |-def single_line_func_wrong(value: dict[str, str] = {}): -314 |- """Docstring without newline""" - 313 |+def single_line_func_wrong(value: dict[str, str] = None): - 314 |+ """Docstring without newline""" - 315 |+ if value is None: - 316 |+ value = {} - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B007_B007.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B007_B007.py.snap deleted file mode 100644 index 90bd5b3f6a..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B007_B007.py.snap +++ /dev/null @@ -1,186 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -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 | -6 | for i in range(10): # name not used within the loop; B007 - | ^ B007 -7 | print(10) - | - = help: Rename unused `i` to `_i` - -B007.py:18:13: B007 [*] Loop control variable `k` not used within loop body - | -16 | for i in range(10): -17 | for j in range(10): -18 | for k in range(10): # k not used, i and j used transitively - | ^ B007 -19 | print(i + j) - | - = help: Rename unused `k` to `_k` - -ℹ Suggested fix -15 15 | -16 16 | for i in range(10): -17 17 | for j in range(10): -18 |- for k in range(10): # k not used, i and j used transitively - 18 |+ for _k in range(10): # k not used, i and j used transitively -19 19 | print(i + j) -20 20 | -21 21 | - -B007.py:30:5: B007 Loop control variable `i` not used within loop body - | -30 | for i, (j, (k, l)) in strange_generator(): # i, k not used - | ^ B007 -31 | print(j, l) - | - = help: Rename unused `i` to `_i` - -B007.py:30:13: B007 [*] Loop control variable `k` not used within loop body - | -30 | for i, (j, (k, l)) in strange_generator(): # i, k not used - | ^ B007 -31 | print(j, l) - | - = help: Rename unused `k` to `_k` - -ℹ Suggested fix -27 27 | yield i, (j, (k, l)) -28 28 | -29 29 | -30 |-for i, (j, (k, l)) in strange_generator(): # i, k not used - 30 |+for i, (j, (_k, l)) in strange_generator(): # i, k not used -31 31 | print(j, l) -32 32 | -33 33 | FMT = "{foo} {bar}" - -B007.py:34:10: B007 Loop control variable `bar` may not be used within loop body - | -33 | FMT = "{foo} {bar}" -34 | for foo, bar in [(1, 2)]: - | ^^^ B007 -35 | if foo: -36 | print(FMT.format(**locals())) - | - = help: Rename unused `bar` to `_bar` - -B007.py:38:10: B007 Loop control variable `bar` may not be used within loop body - | -36 | print(FMT.format(**locals())) -37 | -38 | for foo, bar in [(1, 2)]: - | ^^^ B007 -39 | if foo: -40 | print(FMT.format(**globals())) - | - = help: Rename unused `bar` to `_bar` - -B007.py:42:10: B007 Loop control variable `bar` may not be used within loop body - | -40 | print(FMT.format(**globals())) -41 | -42 | for foo, bar in [(1, 2)]: - | ^^^ B007 -43 | if foo: -44 | print(FMT.format(**vars())) - | - = help: Rename unused `bar` to `_bar` - -B007.py:46:10: B007 Loop control variable `bar` may not be used within loop body - | -44 | print(FMT.format(**vars())) -45 | -46 | for foo, bar in [(1, 2)]: - | ^^^ B007 -47 | print(FMT.format(foo=foo, bar=eval("bar"))) - | - = help: Rename unused `bar` to `_bar` - -B007.py:52:14: B007 [*] Loop control variable `bar` not used within loop body - | -50 | def f(): -51 | # Fixable. -52 | for foo, bar, baz in (["1", "2", "3"],): - | ^^^ B007 -53 | if foo or baz: -54 | break - | - = help: Rename unused `bar` to `_bar` - -ℹ Suggested fix -49 49 | -50 50 | def f(): -51 51 | # Fixable. -52 |- for foo, bar, baz in (["1", "2", "3"],): - 52 |+ for foo, _bar, baz in (["1", "2", "3"],): -53 53 | if foo or baz: -54 54 | break -55 55 | - -B007.py:59:14: B007 Loop control variable `bar` not used within loop body - | -57 | def f(): -58 | # Unfixable due to usage of `bar` outside of loop. -59 | for foo, bar, baz in (["1", "2", "3"],): - | ^^^ B007 -60 | if foo or baz: -61 | break - | - = help: Rename unused `bar` to `_bar` - -B007.py:68:14: B007 [*] Loop control variable `bar` not used within loop body - | -66 | def f(): -67 | # Fixable. -68 | for foo, bar, baz in (["1", "2", "3"],): - | ^^^ B007 -69 | if foo or baz: -70 | break - | - = help: Rename unused `bar` to `_bar` - -ℹ Suggested fix -65 65 | -66 66 | def f(): -67 67 | # Fixable. -68 |- for foo, bar, baz in (["1", "2", "3"],): - 68 |+ for foo, _bar, baz in (["1", "2", "3"],): -69 69 | if foo or baz: -70 70 | break -71 71 | - -B007.py:77:14: B007 Loop control variable `bar` not used within loop body - | -75 | def f(): -76 | # Unfixable. -77 | for foo, bar, baz in (["1", "2", "3"],): - | ^^^ B007 -78 | if foo or baz: -79 | break - | - = help: Rename unused `bar` to `_bar` - -B007.py:88:14: B007 Loop control variable `bar` not used within loop body - | -86 | def f(): -87 | # Unfixable (false negative) due to usage of `bar` outside of loop. -88 | for foo, bar, baz in (["1", "2", "3"],): - | ^^^ B007 -89 | if foo or baz: -90 | break - | - = help: Rename unused `bar` to `_bar` - -B007.py:98:5: B007 Loop control variable `line_` not used within loop body - | -96 | # Unfixable due to trailing underscore (`_line_` wouldn't be considered an ignorable -97 | # variable name). -98 | for line_ in range(self.header_lines): - | ^^^^^ B007 -99 | fp.readline() - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B008_B006_B008.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B008_B006_B008.py.snap deleted file mode 100644 index cae75c719a..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B008_B006_B008.py.snap +++ /dev/null @@ -1,83 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B006_B008.py:102:61: B008 Do not perform function call `range` in argument defaults - | -101 | # N.B. we're also flagging the function call in the comprehension -102 | def list_comprehension_also_not_okay(default=[i**2 for i in range(3)]): - | ^^^^^^^^ B008 -103 | pass - | - -B006_B008.py:106:64: B008 Do not perform function call `range` in argument defaults - | -106 | def dict_comprehension_also_not_okay(default={i: i**2 for i in range(3)}): - | ^^^^^^^^ B008 -107 | pass - | - -B006_B008.py:110:60: B008 Do not perform function call `range` in argument defaults - | -110 | def set_comprehension_also_not_okay(default={i**2 for i in range(3)}): - | ^^^^^^^^ B008 -111 | pass - | - -B006_B008.py:126:39: B008 Do not perform function call `time.time` in argument defaults - | -124 | # B008 -125 | # Flag function calls as default args (including if they are part of a sub-expression) -126 | def in_fact_all_calls_are_wrong(value=time.time()): - | ^^^^^^^^^^^ B008 -127 | ... - | - -B006_B008.py:130:12: B008 Do not perform function call `dt.datetime.now` in argument defaults - | -130 | def f(when=dt.datetime.now() + dt.timedelta(days=7)): - | ^^^^^^^^^^^^^^^^^ B008 -131 | pass - | - -B006_B008.py:134:30: B008 Do not perform function call in argument defaults - | -134 | def can_even_catch_lambdas(a=(lambda x: x)()): - | ^^^^^^^^^^^^^^^ B008 -135 | ... - | - -B006_B008.py:239:31: B008 Do not perform function call `dt.datetime.now` in argument defaults - | -237 | # B006 and B008 -238 | # We should handle arbitrary nesting of these B008. -239 | def nested_combo(a=[float(3), dt.datetime.now()]): - | ^^^^^^^^^^^^^^^^^ B008 -240 | pass - | - -B006_B008.py:245:22: B008 Do not perform function call `map` in argument defaults - | -243 | # Don't flag nested B006 since we can't guarantee that -244 | # it isn't made mutable by the outer operation. -245 | def no_nested_b006(a=map(lambda s: s.upper(), ["a", "b", "c"])): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B008 -246 | pass - | - -B006_B008.py:250:19: B008 Do not perform function call `random.randint` in argument defaults - | -249 | # B008-ception. -250 | def nested_b008(a=random.randint(0, dt.datetime.now().year)): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B008 -251 | pass - | - -B006_B008.py:250:37: B008 Do not perform function call `dt.datetime.now` in argument defaults - | -249 | # B008-ception. -250 | def nested_b008(a=random.randint(0, dt.datetime.now().year)): - | ^^^^^^^^^^^^^^^^^ B008 -251 | pass - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B009_B009_B010.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B009_B009_B010.py.snap deleted file mode 100644 index 6682a2bd80..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B009_B009_B010.py.snap +++ /dev/null @@ -1,334 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B009_B010.py:19:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. - | -18 | # Invalid usage -19 | getattr(foo, "bar") - | ^^^^^^^^^^^^^^^^^^^ B009 -20 | getattr(foo, "_123abc") -21 | getattr(foo, "__123abc__") - | - = help: Replace `getattr` with attribute access - -ℹ Suggested fix -16 16 | getattr(foo, "__123abc") -17 17 | -18 18 | # Invalid usage -19 |-getattr(foo, "bar") - 19 |+foo.bar -20 20 | getattr(foo, "_123abc") -21 21 | getattr(foo, "__123abc__") -22 22 | getattr(foo, "abc123") - -B009_B010.py:20:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. - | -18 | # Invalid usage -19 | getattr(foo, "bar") -20 | getattr(foo, "_123abc") - | ^^^^^^^^^^^^^^^^^^^^^^^ B009 -21 | getattr(foo, "__123abc__") -22 | getattr(foo, "abc123") - | - = help: Replace `getattr` with attribute access - -ℹ Suggested fix -17 17 | -18 18 | # Invalid usage -19 19 | getattr(foo, "bar") -20 |-getattr(foo, "_123abc") - 20 |+foo._123abc -21 21 | getattr(foo, "__123abc__") -22 22 | getattr(foo, "abc123") -23 23 | getattr(foo, r"abc123") - -B009_B010.py:21:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. - | -19 | getattr(foo, "bar") -20 | getattr(foo, "_123abc") -21 | getattr(foo, "__123abc__") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ B009 -22 | getattr(foo, "abc123") -23 | getattr(foo, r"abc123") - | - = help: Replace `getattr` with attribute access - -ℹ Suggested fix -18 18 | # Invalid usage -19 19 | getattr(foo, "bar") -20 20 | getattr(foo, "_123abc") -21 |-getattr(foo, "__123abc__") - 21 |+foo.__123abc__ -22 22 | getattr(foo, "abc123") -23 23 | getattr(foo, r"abc123") -24 24 | _ = lambda x: getattr(x, "bar") - -B009_B010.py:22:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. - | -20 | getattr(foo, "_123abc") -21 | getattr(foo, "__123abc__") -22 | getattr(foo, "abc123") - | ^^^^^^^^^^^^^^^^^^^^^^ B009 -23 | getattr(foo, r"abc123") -24 | _ = lambda x: getattr(x, "bar") - | - = help: Replace `getattr` with attribute access - -ℹ Suggested fix -19 19 | getattr(foo, "bar") -20 20 | getattr(foo, "_123abc") -21 21 | getattr(foo, "__123abc__") -22 |-getattr(foo, "abc123") - 22 |+foo.abc123 -23 23 | getattr(foo, r"abc123") -24 24 | _ = lambda x: getattr(x, "bar") -25 25 | if getattr(x, "bar"): - -B009_B010.py:23:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. - | -21 | getattr(foo, "__123abc__") -22 | getattr(foo, "abc123") -23 | getattr(foo, r"abc123") - | ^^^^^^^^^^^^^^^^^^^^^^^ B009 -24 | _ = lambda x: getattr(x, "bar") -25 | if getattr(x, "bar"): - | - = help: Replace `getattr` with attribute access - -ℹ Suggested fix -20 20 | getattr(foo, "_123abc") -21 21 | getattr(foo, "__123abc__") -22 22 | getattr(foo, "abc123") -23 |-getattr(foo, r"abc123") - 23 |+foo.abc123 -24 24 | _ = lambda x: getattr(x, "bar") -25 25 | if getattr(x, "bar"): -26 26 | pass - -B009_B010.py:24:15: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. - | -22 | getattr(foo, "abc123") -23 | getattr(foo, r"abc123") -24 | _ = lambda x: getattr(x, "bar") - | ^^^^^^^^^^^^^^^^^ B009 -25 | if getattr(x, "bar"): -26 | pass - | - = help: Replace `getattr` with attribute access - -ℹ Suggested fix -21 21 | getattr(foo, "__123abc__") -22 22 | getattr(foo, "abc123") -23 23 | getattr(foo, r"abc123") -24 |-_ = lambda x: getattr(x, "bar") - 24 |+_ = lambda x: x.bar -25 25 | if getattr(x, "bar"): -26 26 | pass -27 27 | getattr(1, "real") - -B009_B010.py:25:4: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. - | -23 | getattr(foo, r"abc123") -24 | _ = lambda x: getattr(x, "bar") -25 | if getattr(x, "bar"): - | ^^^^^^^^^^^^^^^^^ B009 -26 | pass -27 | getattr(1, "real") - | - = help: Replace `getattr` with attribute access - -ℹ Suggested fix -22 22 | getattr(foo, "abc123") -23 23 | getattr(foo, r"abc123") -24 24 | _ = lambda x: getattr(x, "bar") -25 |-if getattr(x, "bar"): - 25 |+if x.bar: -26 26 | pass -27 27 | getattr(1, "real") -28 28 | getattr(1., "real") - -B009_B010.py:27:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. - | -25 | if getattr(x, "bar"): -26 | pass -27 | getattr(1, "real") - | ^^^^^^^^^^^^^^^^^^ B009 -28 | getattr(1., "real") -29 | getattr(1.0, "real") - | - = help: Replace `getattr` with attribute access - -ℹ Suggested fix -24 24 | _ = lambda x: getattr(x, "bar") -25 25 | if getattr(x, "bar"): -26 26 | pass -27 |-getattr(1, "real") - 27 |+(1).real -28 28 | getattr(1., "real") -29 29 | getattr(1.0, "real") -30 30 | getattr(1j, "real") - -B009_B010.py:28:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. - | -26 | pass -27 | getattr(1, "real") -28 | getattr(1., "real") - | ^^^^^^^^^^^^^^^^^^^ B009 -29 | getattr(1.0, "real") -30 | getattr(1j, "real") - | - = help: Replace `getattr` with attribute access - -ℹ Suggested fix -25 25 | if getattr(x, "bar"): -26 26 | pass -27 27 | getattr(1, "real") -28 |-getattr(1., "real") - 28 |+(1.).real -29 29 | getattr(1.0, "real") -30 30 | getattr(1j, "real") -31 31 | getattr(True, "real") - -B009_B010.py:29:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. - | -27 | getattr(1, "real") -28 | getattr(1., "real") -29 | getattr(1.0, "real") - | ^^^^^^^^^^^^^^^^^^^^ B009 -30 | getattr(1j, "real") -31 | getattr(True, "real") - | - = help: Replace `getattr` with attribute access - -ℹ Suggested fix -26 26 | pass -27 27 | getattr(1, "real") -28 28 | getattr(1., "real") -29 |-getattr(1.0, "real") - 29 |+(1.0).real -30 30 | getattr(1j, "real") -31 31 | getattr(True, "real") -32 32 | getattr(x := 1, "real") - -B009_B010.py:30:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. - | -28 | getattr(1., "real") -29 | getattr(1.0, "real") -30 | getattr(1j, "real") - | ^^^^^^^^^^^^^^^^^^^ B009 -31 | getattr(True, "real") -32 | getattr(x := 1, "real") - | - = help: Replace `getattr` with attribute access - -ℹ Suggested fix -27 27 | getattr(1, "real") -28 28 | getattr(1., "real") -29 29 | getattr(1.0, "real") -30 |-getattr(1j, "real") - 30 |+(1j).real -31 31 | getattr(True, "real") -32 32 | getattr(x := 1, "real") -33 33 | getattr(x + y, "real") - -B009_B010.py:31:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. - | -29 | getattr(1.0, "real") -30 | getattr(1j, "real") -31 | getattr(True, "real") - | ^^^^^^^^^^^^^^^^^^^^^ B009 -32 | getattr(x := 1, "real") -33 | getattr(x + y, "real") - | - = help: Replace `getattr` with attribute access - -ℹ Suggested fix -28 28 | getattr(1., "real") -29 29 | getattr(1.0, "real") -30 30 | getattr(1j, "real") -31 |-getattr(True, "real") - 31 |+(True).real -32 32 | getattr(x := 1, "real") -33 33 | getattr(x + y, "real") -34 34 | getattr("foo" - -B009_B010.py:32:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. - | -30 | getattr(1j, "real") -31 | getattr(True, "real") -32 | getattr(x := 1, "real") - | ^^^^^^^^^^^^^^^^^^^^^^^ B009 -33 | getattr(x + y, "real") -34 | getattr("foo" - | - = help: Replace `getattr` with attribute access - -ℹ Suggested fix -29 29 | getattr(1.0, "real") -30 30 | getattr(1j, "real") -31 31 | getattr(True, "real") -32 |-getattr(x := 1, "real") - 32 |+(x := 1).real -33 33 | getattr(x + y, "real") -34 34 | getattr("foo" -35 35 | "bar", "real") - -B009_B010.py:33:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. - | -31 | getattr(True, "real") -32 | getattr(x := 1, "real") -33 | getattr(x + y, "real") - | ^^^^^^^^^^^^^^^^^^^^^^ B009 -34 | getattr("foo" -35 | "bar", "real") - | - = help: Replace `getattr` with attribute access - -ℹ Suggested fix -30 30 | getattr(1j, "real") -31 31 | getattr(True, "real") -32 32 | getattr(x := 1, "real") -33 |-getattr(x + y, "real") - 33 |+(x + y).real -34 34 | getattr("foo" -35 35 | "bar", "real") -36 36 | - -B009_B010.py:34:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. - | -32 | getattr(x := 1, "real") -33 | getattr(x + y, "real") -34 | / getattr("foo" -35 | | "bar", "real") - | |______________________^ B009 - | - = help: Replace `getattr` with attribute access - -ℹ Suggested fix -31 31 | getattr(True, "real") -32 32 | getattr(x := 1, "real") -33 33 | getattr(x + y, "real") -34 |-getattr("foo" -35 |- "bar", "real") - 34 |+("foo" - 35 |+ "bar").real -36 36 | -37 37 | -38 38 | # Valid setattr usage - -B009_B010.py:58:8: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. - | -57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458885 -58 | assert getattr(func, '_rpc')is True - | ^^^^^^^^^^^^^^^^^^^^^ B009 - | - = help: Replace `getattr` with attribute access - -ℹ Suggested fix -55 55 | setattr(foo.bar, r"baz", None) -56 56 | -57 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458885 -58 |-assert getattr(func, '_rpc')is True - 58 |+assert func._rpc is True - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B010_B009_B010.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B010_B009_B010.py.snap deleted file mode 100644 index 7eeea02966..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B010_B009_B010.py.snap +++ /dev/null @@ -1,128 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B009_B010.py:50:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. - | -49 | # Invalid usage -50 | setattr(foo, "bar", None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ B010 -51 | setattr(foo, "_123abc", None) -52 | setattr(foo, "__123abc__", None) - | - = help: Replace `setattr` with assignment - -ℹ Suggested fix -47 47 | pass -48 48 | -49 49 | # Invalid usage -50 |-setattr(foo, "bar", None) - 50 |+foo.bar = None -51 51 | setattr(foo, "_123abc", None) -52 52 | setattr(foo, "__123abc__", None) -53 53 | setattr(foo, "abc123", None) - -B009_B010.py:51:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. - | -49 | # Invalid usage -50 | setattr(foo, "bar", None) -51 | setattr(foo, "_123abc", None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 -52 | setattr(foo, "__123abc__", None) -53 | setattr(foo, "abc123", None) - | - = help: Replace `setattr` with assignment - -ℹ Suggested fix -48 48 | -49 49 | # Invalid usage -50 50 | setattr(foo, "bar", None) -51 |-setattr(foo, "_123abc", None) - 51 |+foo._123abc = None -52 52 | setattr(foo, "__123abc__", None) -53 53 | setattr(foo, "abc123", None) -54 54 | setattr(foo, r"abc123", None) - -B009_B010.py:52:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. - | -50 | setattr(foo, "bar", None) -51 | setattr(foo, "_123abc", None) -52 | setattr(foo, "__123abc__", None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 -53 | setattr(foo, "abc123", None) -54 | setattr(foo, r"abc123", None) - | - = help: Replace `setattr` with assignment - -ℹ Suggested fix -49 49 | # Invalid usage -50 50 | setattr(foo, "bar", None) -51 51 | setattr(foo, "_123abc", None) -52 |-setattr(foo, "__123abc__", None) - 52 |+foo.__123abc__ = None -53 53 | setattr(foo, "abc123", None) -54 54 | setattr(foo, r"abc123", None) -55 55 | setattr(foo.bar, r"baz", None) - -B009_B010.py:53:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. - | -51 | setattr(foo, "_123abc", None) -52 | setattr(foo, "__123abc__", None) -53 | setattr(foo, "abc123", None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 -54 | setattr(foo, r"abc123", None) -55 | setattr(foo.bar, r"baz", None) - | - = help: Replace `setattr` with assignment - -ℹ Suggested fix -50 50 | setattr(foo, "bar", None) -51 51 | setattr(foo, "_123abc", None) -52 52 | setattr(foo, "__123abc__", None) -53 |-setattr(foo, "abc123", None) - 53 |+foo.abc123 = None -54 54 | setattr(foo, r"abc123", None) -55 55 | setattr(foo.bar, r"baz", None) -56 56 | - -B009_B010.py:54:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. - | -52 | setattr(foo, "__123abc__", None) -53 | setattr(foo, "abc123", None) -54 | setattr(foo, r"abc123", None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 -55 | setattr(foo.bar, r"baz", None) - | - = help: Replace `setattr` with assignment - -ℹ Suggested fix -51 51 | setattr(foo, "_123abc", None) -52 52 | setattr(foo, "__123abc__", None) -53 53 | setattr(foo, "abc123", None) -54 |-setattr(foo, r"abc123", None) - 54 |+foo.abc123 = None -55 55 | setattr(foo.bar, r"baz", None) -56 56 | -57 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458885 - -B009_B010.py:55:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. - | -53 | setattr(foo, "abc123", None) -54 | setattr(foo, r"abc123", None) -55 | setattr(foo.bar, r"baz", None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 -56 | -57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458885 - | - = help: Replace `setattr` with assignment - -ℹ Suggested fix -52 52 | setattr(foo, "__123abc__", None) -53 53 | setattr(foo, "abc123", None) -54 54 | setattr(foo, r"abc123", None) -55 |-setattr(foo.bar, r"baz", None) - 55 |+foo.bar.baz = None -56 56 | -57 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458885 -58 58 | assert getattr(func, '_rpc')is True - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B011_B011.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B011_B011.py.snap deleted file mode 100644 index f2e6f4553b..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B011_B011.py.snap +++ /dev/null @@ -1,39 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B011.py:8:8: B011 [*] Do not `assert False` (`python -O` removes these calls), raise `AssertionError()` - | - 7 | assert 1 != 2 - 8 | assert False - | ^^^^^ B011 - 9 | assert 1 != 2, "message" -10 | assert False, "message" - | - = help: Replace `assert False` - -ℹ Suggested fix -5 5 | """ -6 6 | -7 7 | assert 1 != 2 -8 |-assert False - 8 |+raise AssertionError() -9 9 | assert 1 != 2, "message" -10 10 | assert False, "message" - -B011.py:10:8: B011 [*] Do not `assert False` (`python -O` removes these calls), raise `AssertionError()` - | - 8 | assert False - 9 | assert 1 != 2, "message" -10 | assert False, "message" - | ^^^^^ B011 - | - = help: Replace `assert False` - -ℹ Suggested fix -7 7 | assert 1 != 2 -8 8 | assert False -9 9 | assert 1 != 2, "message" -10 |-assert False, "message" - 10 |+raise AssertionError("message") - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B012_B012.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B012_B012.py.snap deleted file mode 100644 index 8ae2dd7e2d..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B012_B012.py.snap +++ /dev/null @@ -1,104 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B012.py:5:9: B012 `return` inside `finally` blocks cause exceptions to be silenced - | -3 | pass -4 | finally: -5 | return # warning - | ^^^^^^ B012 - | - -B012.py:13:13: B012 `return` inside `finally` blocks cause exceptions to be silenced - | -11 | finally: -12 | if 1 + 0 == 2 - 1: -13 | return # warning - | ^^^^^^ B012 - | - -B012.py:21:13: B012 `return` inside `finally` blocks cause exceptions to be silenced - | -19 | finally: -20 | try: -21 | return # warning - | ^^^^^^ B012 -22 | except Exception: -23 | pass - | - -B012.py:31:13: B012 `return` inside `finally` blocks cause exceptions to be silenced - | -29 | pass -30 | finally: -31 | return # warning - | ^^^^^^ B012 -32 | finally: -33 | pass - | - -B012.py:44:21: B012 `return` inside `finally` blocks cause exceptions to be silenced - | -42 | pass -43 | finally: -44 | return # warning - | ^^^^^^ B012 -45 | -46 | finally: - | - -B012.py:66:13: B012 `break` inside `finally` blocks cause exceptions to be silenced - | -64 | pass -65 | finally: -66 | break # warning - | ^^^^^ B012 -67 | -68 | def j(): - | - -B012.py:78:13: B012 `continue` inside `finally` blocks cause exceptions to be silenced - | -76 | pass -77 | finally: -78 | continue # warning - | ^^^^^^^^ B012 -79 | -80 | def j(): - | - -B012.py:94:13: B012 `return` inside `finally` blocks cause exceptions to be silenced - | -92 | continue # no warning -93 | while True: -94 | return # warning - | ^^^^^^ B012 - | - -B012.py:101:9: B012 `continue` inside `finally` blocks cause exceptions to be silenced - | - 99 | pass -100 | finally: -101 | continue # warning - | ^^^^^^^^ B012 -102 | -103 | while True: - | - -B012.py:107:9: B012 `break` inside `finally` blocks cause exceptions to be silenced - | -105 | pass -106 | finally: -107 | break # warning - | ^^^^^ B012 - | - -B012.py:118:17: B012 `break` inside `finally` blocks cause exceptions to be silenced - | -116 | y = 0 -117 | case 0, *x: -118 | break # warning - | ^^^^^ B012 - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B013_B013.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B013_B013.py.snap deleted file mode 100644 index 01c7ebda55..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B013_B013.py.snap +++ /dev/null @@ -1,64 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B013.py:5:8: B013 [*] A length-one tuple literal is redundant in exception handlers - | -3 | try: -4 | pass -5 | except (ValueError,): - | ^^^^^^^^^^^^^ B013 -6 | pass -7 | except AttributeError: - | - = help: Replace with `except ValueError` - -ℹ Fix -2 2 | -3 3 | try: -4 4 | pass -5 |-except (ValueError,): - 5 |+except ValueError: -6 6 | pass -7 7 | except AttributeError: -8 8 | pass - -B013.py:11:8: B013 [*] A length-one tuple literal is redundant in exception handlers - | - 9 | except (ImportError, TypeError): -10 | pass -11 | except (*retriable_exceptions,): - | ^^^^^^^^^^^^^^^^^^^^^^^^ B013 -12 | pass -13 | except(ValueError,): - | - = help: Replace with `except retriable_exceptions` - -ℹ Fix -8 8 | pass -9 9 | except (ImportError, TypeError): -10 10 | pass -11 |-except (*retriable_exceptions,): - 11 |+except retriable_exceptions: -12 12 | pass -13 13 | except(ValueError,): -14 14 | pass - -B013.py:13:7: B013 [*] A length-one tuple literal is redundant in exception handlers - | -11 | except (*retriable_exceptions,): -12 | pass -13 | except(ValueError,): - | ^^^^^^^^^^^^^ B013 -14 | pass - | - = help: Replace with `except ValueError` - -ℹ Fix -10 10 | pass -11 11 | except (*retriable_exceptions,): -12 12 | pass -13 |-except(ValueError,): - 13 |+except ValueError: -14 14 | pass - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B014_B014.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B014_B014.py.snap deleted file mode 100644 index 52e3ea5167..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B014_B014.py.snap +++ /dev/null @@ -1,85 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B014.py:17:8: B014 [*] Exception handler with duplicate exception: `OSError` - | -15 | try: -16 | pass -17 | except (OSError, OSError) as err: - | ^^^^^^^^^^^^^^^^^^ B014 -18 | # Duplicate exception types are useless -19 | pass - | - = help: De-duplicate exceptions - -ℹ Fix -14 14 | -15 15 | try: -16 16 | pass -17 |-except (OSError, OSError) as err: - 17 |+except OSError as err: -18 18 | # Duplicate exception types are useless -19 19 | pass -20 20 | - -B014.py:28:8: B014 [*] Exception handler with duplicate exception: `MyError` - | -26 | try: -27 | pass -28 | except (MyError, MyError): - | ^^^^^^^^^^^^^^^^^^ B014 -29 | # Detect duplicate non-builtin errors -30 | pass - | - = help: De-duplicate exceptions - -ℹ Fix -25 25 | -26 26 | try: -27 27 | pass -28 |-except (MyError, MyError): - 28 |+except MyError: -29 29 | # Detect duplicate non-builtin errors -30 30 | pass -31 31 | - -B014.py:49:8: B014 [*] Exception handler with duplicate exception: `re.error` - | -47 | try: -48 | pass -49 | except (re.error, re.error): - | ^^^^^^^^^^^^^^^^^^^^ B014 -50 | # Duplicate exception types as attributes -51 | pass - | - = help: De-duplicate exceptions - -ℹ Fix -46 46 | -47 47 | try: -48 48 | pass -49 |-except (re.error, re.error): - 49 |+except re.error: -50 50 | # Duplicate exception types as attributes -51 51 | pass -52 52 | - -B014.py:82:8: B014 [*] Exception handler with duplicate exception: `ValueError` - | -80 | try: -81 | pass -82 | except (ValueError, ValueError, TypeError): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B014 -83 | pass - | - = help: De-duplicate exceptions - -ℹ Fix -79 79 | # https://github.com/astral-sh/ruff/issues/6412 -80 80 | try: -81 81 | pass -82 |-except (ValueError, ValueError, TypeError): - 82 |+except (ValueError, TypeError): -83 83 | pass - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B015_B015.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B015_B015.py.snap deleted file mode 100644 index 7ae2c3b1ac..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B015_B015.py.snap +++ /dev/null @@ -1,37 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B015.py:3:1: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. - | -1 | assert 1 == 1 -2 | -3 | 1 == 1 - | ^^^^^^ B015 -4 | -5 | assert 1 in (1, 2) - | - -B015.py:7:1: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. - | -5 | assert 1 in (1, 2) -6 | -7 | 1 in (1, 2) - | ^^^^^^^^^^^ B015 - | - -B015.py:17:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. - | -15 | assert 1 in (1, 2) -16 | -17 | 1 in (1, 2) - | ^^^^^^^^^^^ B015 - | - -B015.py:24:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. - | -23 | class TestClass: -24 | 1 == 1 - | ^^^^^^ B015 - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B016_B016.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B016_B016.py.snap deleted file mode 100644 index 7e8bba9ecf..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B016_B016.py.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B016.py:6:7: B016 Cannot raise a literal. Did you intend to return it or raise an Exception? - | -4 | """ -5 | -6 | raise False - | ^^^^^ B016 -7 | raise 1 -8 | raise "string" - | - -B016.py:7:7: B016 Cannot raise a literal. Did you intend to return it or raise an Exception? - | -6 | raise False -7 | raise 1 - | ^ B016 -8 | raise "string" -9 | raise Exception(False) - | - -B016.py:8:7: B016 Cannot raise a literal. Did you intend to return it or raise an Exception? - | - 6 | raise False - 7 | raise 1 - 8 | raise "string" - | ^^^^^^^^ B016 - 9 | raise Exception(False) -10 | raise Exception(1) - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B017_B017.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B017_B017.py.snap deleted file mode 100644 index d6a332dfc2..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B017_B017.py.snap +++ /dev/null @@ -1,38 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B017.py:23:14: B017 `assertRaises(Exception)` should be considered evil - | -21 | class Foobar(unittest.TestCase): -22 | def evil_raises(self) -> None: -23 | with self.assertRaises(Exception): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017 -24 | raise Exception("Evil I say!") - | - -B017.py:27:14: B017 `assertRaises(BaseException)` should be considered evil - | -26 | def also_evil_raises(self) -> None: -27 | with self.assertRaises(BaseException): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017 -28 | raise Exception("Evil I say!") - | - -B017.py:45:10: B017 `pytest.raises(Exception)` should be considered evil - | -44 | def test_pytest_raises(): -45 | with pytest.raises(Exception): - | ^^^^^^^^^^^^^^^^^^^^^^^^ B017 -46 | raise ValueError("Hello") - | - -B017.py:48:10: B017 `pytest.raises(Exception)` should be considered evil - | -46 | raise ValueError("Hello") -47 | -48 | with pytest.raises(Exception), pytest.raises(ValueError): - | ^^^^^^^^^^^^^^^^^^^^^^^^ B017 -49 | raise ValueError("Hello") - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B018_B018.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B018_B018.py.snap deleted file mode 100644 index 99309aa29b..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B018_B018.py.snap +++ /dev/null @@ -1,258 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B018.py:11:5: B018 Found useless expression. Either assign it to a variable or remove it. - | - 9 | "str" # Str (no raise) -10 | f"{int}" # JoinedStr (no raise) -11 | 1j # Number (complex) - | ^^ B018 -12 | 1 # Number (int) -13 | 1.0 # Number (float) - | - -B018.py:12:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -10 | f"{int}" # JoinedStr (no raise) -11 | 1j # Number (complex) -12 | 1 # Number (int) - | ^ B018 -13 | 1.0 # Number (float) -14 | b"foo" # Binary - | - -B018.py:13:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -11 | 1j # Number (complex) -12 | 1 # Number (int) -13 | 1.0 # Number (float) - | ^^^ B018 -14 | b"foo" # Binary -15 | True # NameConstant (True) - | - -B018.py:14:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -12 | 1 # Number (int) -13 | 1.0 # Number (float) -14 | b"foo" # Binary - | ^^^^^^ B018 -15 | True # NameConstant (True) -16 | False # NameConstant (False) - | - -B018.py:15:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -13 | 1.0 # Number (float) -14 | b"foo" # Binary -15 | True # NameConstant (True) - | ^^^^ B018 -16 | False # NameConstant (False) -17 | None # NameConstant (None) - | - -B018.py:16:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -14 | b"foo" # Binary -15 | True # NameConstant (True) -16 | False # NameConstant (False) - | ^^^^^ B018 -17 | None # NameConstant (None) -18 | [1, 2] # list - | - -B018.py:17:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -15 | True # NameConstant (True) -16 | False # NameConstant (False) -17 | None # NameConstant (None) - | ^^^^ B018 -18 | [1, 2] # list -19 | {1, 2} # set - | - -B018.py:18:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -16 | False # NameConstant (False) -17 | None # NameConstant (None) -18 | [1, 2] # list - | ^^^^^^ B018 -19 | {1, 2} # set -20 | {"foo": "bar"} # dict - | - -B018.py:19:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -17 | None # NameConstant (None) -18 | [1, 2] # list -19 | {1, 2} # set - | ^^^^^^ B018 -20 | {"foo": "bar"} # dict - | - -B018.py:20:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -18 | [1, 2] # list -19 | {1, 2} # set -20 | {"foo": "bar"} # dict - | ^^^^^^^^^^^^^^ B018 - | - -B018.py:24:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -23 | class Foo3: -24 | 123 - | ^^^ B018 -25 | a = 2 -26 | "str" - | - -B018.py:27:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -25 | a = 2 -26 | "str" -27 | 1 - | ^ B018 - | - -B018.py:39:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -37 | "str" # Str (no raise) -38 | f"{int}" # JoinedStr (no raise) -39 | 1j # Number (complex) - | ^^ B018 -40 | 1 # Number (int) -41 | 1.0 # Number (float) - | - -B018.py:40:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -38 | f"{int}" # JoinedStr (no raise) -39 | 1j # Number (complex) -40 | 1 # Number (int) - | ^ B018 -41 | 1.0 # Number (float) -42 | b"foo" # Binary - | - -B018.py:41:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -39 | 1j # Number (complex) -40 | 1 # Number (int) -41 | 1.0 # Number (float) - | ^^^ B018 -42 | b"foo" # Binary -43 | True # NameConstant (True) - | - -B018.py:42:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -40 | 1 # Number (int) -41 | 1.0 # Number (float) -42 | b"foo" # Binary - | ^^^^^^ B018 -43 | True # NameConstant (True) -44 | False # NameConstant (False) - | - -B018.py:43:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -41 | 1.0 # Number (float) -42 | b"foo" # Binary -43 | True # NameConstant (True) - | ^^^^ B018 -44 | False # NameConstant (False) -45 | None # NameConstant (None) - | - -B018.py:44:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -42 | b"foo" # Binary -43 | True # NameConstant (True) -44 | False # NameConstant (False) - | ^^^^^ B018 -45 | None # NameConstant (None) -46 | [1, 2] # list - | - -B018.py:45:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -43 | True # NameConstant (True) -44 | False # NameConstant (False) -45 | None # NameConstant (None) - | ^^^^ B018 -46 | [1, 2] # list -47 | {1, 2} # set - | - -B018.py:46:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -44 | False # NameConstant (False) -45 | None # NameConstant (None) -46 | [1, 2] # list - | ^^^^^^ B018 -47 | {1, 2} # set -48 | {"foo": "bar"} # dict - | - -B018.py:47:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -45 | None # NameConstant (None) -46 | [1, 2] # list -47 | {1, 2} # set - | ^^^^^^ B018 -48 | {"foo": "bar"} # dict - | - -B018.py:48:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -46 | [1, 2] # list -47 | {1, 2} # set -48 | {"foo": "bar"} # dict - | ^^^^^^^^^^^^^^ B018 - | - -B018.py:52:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -51 | def foo3(): -52 | 123 - | ^^^ B018 -53 | a = 2 -54 | "str" - | - -B018.py:55:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -53 | a = 2 -54 | "str" -55 | 3 - | ^ B018 - | - -B018.py:63:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -62 | def foo5(): -63 | foo.bar # Attribute (raise) - | ^^^^^^^ B018 -64 | object().__class__ # Attribute (raise) -65 | "foo" + "bar" # BinOp (raise) - | - -B018.py:64:5: B018 Found useless attribute access. Either assign it to a variable or remove it. - | -62 | def foo5(): -63 | foo.bar # Attribute (raise) -64 | object().__class__ # Attribute (raise) - | ^^^^^^^^^^^^^^^^^^ B018 -65 | "foo" + "bar" # BinOp (raise) - | - -B018.py:65:5: B018 Found useless expression. Either assign it to a variable or remove it. - | -63 | foo.bar # Attribute (raise) -64 | object().__class__ # Attribute (raise) -65 | "foo" + "bar" # BinOp (raise) - | ^^^^^^^^^^^^^ B018 - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B019_B019.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B019_B019.py.snap deleted file mode 100644 index 013db64170..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B019_B019.py.snap +++ /dev/null @@ -1,83 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B019.py:78:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks - | -77 | # Remaining methods should emit B019 -78 | @functools.cache - | ^^^^^^^^^^^^^^^^ B019 -79 | def cached_instance_method(self, y): -80 | ... - | - -B019.py:82:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks - | -80 | ... -81 | -82 | @cache - | ^^^^^^ B019 -83 | def another_cached_instance_method(self, y): -84 | ... - | - -B019.py:86:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks - | -84 | ... -85 | -86 | @functools.cache() - | ^^^^^^^^^^^^^^^^^^ B019 -87 | def called_cached_instance_method(self, y): -88 | ... - | - -B019.py:90:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks - | -88 | ... -89 | -90 | @cache() - | ^^^^^^^^ B019 -91 | def another_called_cached_instance_method(self, y): -92 | ... - | - -B019.py:94:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks - | -92 | ... -93 | -94 | @functools.lru_cache - | ^^^^^^^^^^^^^^^^^^^^ B019 -95 | def lru_cached_instance_method(self, y): -96 | ... - | - -B019.py:98:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks - | - 96 | ... - 97 | - 98 | @lru_cache - | ^^^^^^^^^^ B019 - 99 | def another_lru_cached_instance_method(self, y): -100 | ... - | - -B019.py:102:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks - | -100 | ... -101 | -102 | @functools.lru_cache() - | ^^^^^^^^^^^^^^^^^^^^^^ B019 -103 | def called_lru_cached_instance_method(self, y): -104 | ... - | - -B019.py:106:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks - | -104 | ... -105 | -106 | @lru_cache() - | ^^^^^^^^^^^^ B019 -107 | def another_called_lru_cached_instance_method(self, y): -108 | ... - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B020_B020.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B020_B020.py.snap deleted file mode 100644 index d0499fd83e..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B020_B020.py.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B020.py:8:5: B020 Loop control variable `items` overrides iterable it iterates - | -6 | items = [1, 2, 3] -7 | -8 | for items in items: - | ^^^^^ B020 -9 | print(items) - | - -B020.py:21:10: B020 Loop control variable `values` overrides iterable it iterates - | -19 | print(f"{key}, {value}") -20 | -21 | for key, values in values.items(): - | ^^^^^^ B020 -22 | print(f"{key}, {values}") - | - -B020.py:36:5: B020 Loop control variable `vars` overrides iterable it iterates - | -35 | # However we still call out reassigning the iterable in the comprehension. -36 | for vars in [i for i in vars]: - | ^^^^ B020 -37 | print(vars) - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B021_B021.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B021_B021.py.snap deleted file mode 100644 index 2070abfde7..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B021_B021.py.snap +++ /dev/null @@ -1,80 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B021.py:1:1: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. - | -1 | / f""" -2 | | Should emit: -3 | | B021 - on lines 14, 22, 30, 38, 46, 54, 62, 70, 73 -4 | | """ - | |___^ B021 -5 | -6 | VARIABLE = "world" - | - -B021.py:14:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. - | -13 | def foo2(): -14 | f"""hello {VARIABLE}!""" - | ^^^^^^^^^^^^^^^^^^^^^^^^ B021 - | - -B021.py:22:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. - | -21 | class bar2: -22 | f"""hello {VARIABLE}!""" - | ^^^^^^^^^^^^^^^^^^^^^^^^ B021 - | - -B021.py:30:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. - | -29 | def foo2(): -30 | f"""hello {VARIABLE}!""" - | ^^^^^^^^^^^^^^^^^^^^^^^^ B021 - | - -B021.py:38:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. - | -37 | class bar2: -38 | f"""hello {VARIABLE}!""" - | ^^^^^^^^^^^^^^^^^^^^^^^^ B021 - | - -B021.py:46:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. - | -45 | def foo2(): -46 | f"hello {VARIABLE}!" - | ^^^^^^^^^^^^^^^^^^^^ B021 - | - -B021.py:54:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. - | -53 | class bar2: -54 | f"hello {VARIABLE}!" - | ^^^^^^^^^^^^^^^^^^^^ B021 - | - -B021.py:62:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. - | -61 | def foo2(): -62 | f"hello {VARIABLE}!" - | ^^^^^^^^^^^^^^^^^^^^ B021 - | - -B021.py:70:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. - | -69 | class bar2: -70 | f"hello {VARIABLE}!" - | ^^^^^^^^^^^^^^^^^^^^ B021 - | - -B021.py:74:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. - | -73 | def baz(): -74 | f"""I'm probably a docstring: {VARIABLE}!""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B021 -75 | print(f"""I'm a normal string""") -76 | f"""Don't detect me!""" - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B022_B022.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B022_B022.py.snap deleted file mode 100644 index b8ee8ab800..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B022_B022.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -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 | - 9 | with contextlib.suppress(): - | ^^^^^^^^^^^^^^^^^^^^^ B022 -10 | raise ValueError - | - -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 | -12 | with suppress(): - | ^^^^^^^^^^ B022 -13 | raise ValueError - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B023_B023.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B023_B023.py.snap deleted file mode 100644 index b312e8ab7d..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B023_B023.py.snap +++ /dev/null @@ -1,224 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B023.py:12:30: B023 Function definition does not bind loop variable `x` - | -10 | y = x + 1 -11 | # Subject to late-binding problems -12 | functions.append(lambda: x) - | ^ B023 -13 | functions.append(lambda: y) # not just the loop var - | - -B023.py:13:30: B023 Function definition does not bind loop variable `y` - | -11 | # Subject to late-binding problems -12 | functions.append(lambda: x) -13 | functions.append(lambda: y) # not just the loop var - | ^ B023 -14 | -15 | def f_bad_1(): - | - -B023.py:16:16: B023 Function definition does not bind loop variable `x` - | -15 | def f_bad_1(): -16 | return x - | ^ B023 -17 | -18 | # Actually OK - | - -B023.py:28:19: B023 Function definition does not bind loop variable `x` - | -27 | def check_inside_functions_too(): -28 | ls = [lambda: x for x in range(2)] # error - | ^ B023 -29 | st = {lambda: x for x in range(2)} # error -30 | gn = (lambda: x for x in range(2)) # error - | - -B023.py:29:19: B023 Function definition does not bind loop variable `x` - | -27 | def check_inside_functions_too(): -28 | ls = [lambda: x for x in range(2)] # error -29 | st = {lambda: x for x in range(2)} # error - | ^ B023 -30 | gn = (lambda: x for x in range(2)) # error -31 | dt = {x: lambda: x for x in range(2)} # error - | - -B023.py:30:19: B023 Function definition does not bind loop variable `x` - | -28 | ls = [lambda: x for x in range(2)] # error -29 | st = {lambda: x for x in range(2)} # error -30 | gn = (lambda: x for x in range(2)) # error - | ^ B023 -31 | dt = {x: lambda: x for x in range(2)} # error - | - -B023.py:31:22: B023 Function definition does not bind loop variable `x` - | -29 | st = {lambda: x for x in range(2)} # error -30 | gn = (lambda: x for x in range(2)) # error -31 | dt = {x: lambda: x for x in range(2)} # error - | ^ B023 - | - -B023.py:40:34: B023 Function definition does not bind loop variable `x` - | -38 | async def container_for_problems(): -39 | async for x in pointless_async_iterable(): -40 | functions.append(lambda: x) # error - | ^ B023 -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 | -42 | [lambda: x async for x in pointless_async_iterable()] # error - | ^ B023 - | - -B023.py:50:30: B023 Function definition does not bind loop variable `a` - | -48 | a = a_ = a - 1 -49 | b += 1 -50 | functions.append(lambda: a) # error - | ^ B023 -51 | functions.append(lambda: a_) # error -52 | functions.append(lambda: b) # error - | - -B023.py:51:30: B023 Function definition does not bind loop variable `a_` - | -49 | b += 1 -50 | functions.append(lambda: a) # error -51 | functions.append(lambda: a_) # error - | ^^ B023 -52 | functions.append(lambda: b) # error -53 | functions.append(lambda: c) # error, but not a name error due to late binding - | - -B023.py:52:30: B023 Function definition does not bind loop variable `b` - | -50 | functions.append(lambda: a) # error -51 | functions.append(lambda: a_) # error -52 | functions.append(lambda: b) # error - | ^ B023 -53 | functions.append(lambda: c) # error, but not a name error due to late binding -54 | c: bool = a > 3 - | - -B023.py:53:30: B023 Function definition does not bind loop variable `c` - | -51 | functions.append(lambda: a_) # error -52 | functions.append(lambda: b) # error -53 | functions.append(lambda: c) # error, but not a name error due to late binding - | ^ B023 -54 | c: bool = a > 3 -55 | if not c: - | - -B023.py:61:17: B023 Function definition does not bind loop variable `j` - | -59 | for j in range(2): -60 | for k in range(3): -61 | lambda: j * k # error - | ^ B023 - | - -B023.py:61:21: B023 Function definition does not bind loop variable `k` - | -59 | for j in range(2): -60 | for k in range(3): -61 | lambda: j * k # error - | ^ B023 - | - -B023.py:68:10: B023 Function definition does not bind loop variable `l` - | -66 | def f(): -67 | j = None # OK because it's an assignment -68 | [l for k in range(2)] # error for l, not for k - | ^ B023 -69 | -70 | assert a and functions - | - -B023.py:82:16: B023 Function definition does not bind loop variable `i` - | -81 | for i in range(3): -82 | lambda: f"{i}" - | ^ B023 - | - -B023.py:117:24: B023 Function definition does not bind loop variable `x` - | -115 | for x in range(2): -116 | # It's not a complete get-out-of-linting-free construct - these should fail: -117 | min([None, lambda: x], key=repr) - | ^ B023 -118 | sorted([None, lambda: x], key=repr) -119 | any(filter(bool, [None, lambda: x])) - | - -B023.py:118:27: B023 Function definition does not bind loop variable `x` - | -116 | # It's not a complete get-out-of-linting-free construct - these should fail: -117 | min([None, lambda: x], key=repr) -118 | sorted([None, lambda: x], key=repr) - | ^ B023 -119 | any(filter(bool, [None, lambda: x])) -120 | list(filter(bool, [None, lambda: x])) - | - -B023.py:119:37: B023 Function definition does not bind loop variable `x` - | -117 | min([None, lambda: x], key=repr) -118 | sorted([None, lambda: x], key=repr) -119 | any(filter(bool, [None, lambda: x])) - | ^ B023 -120 | list(filter(bool, [None, lambda: x])) -121 | all(reduce(bool, [None, lambda: x])) - | - -B023.py:120:38: B023 Function definition does not bind loop variable `x` - | -118 | sorted([None, lambda: x], key=repr) -119 | any(filter(bool, [None, lambda: x])) -120 | list(filter(bool, [None, lambda: x])) - | ^ B023 -121 | all(reduce(bool, [None, lambda: x])) - | - -B023.py:121:37: B023 Function definition does not bind loop variable `x` - | -119 | any(filter(bool, [None, lambda: x])) -120 | list(filter(bool, [None, lambda: x])) -121 | all(reduce(bool, [None, lambda: x])) - | ^ B023 -122 | -123 | # But all these should be OK: - | - -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 | -173 | if False: - | - -B023.py:174:29: B023 Function definition does not bind loop variable `i` - | -173 | if False: -174 | return [lambda: i for i in range(3)] # error - | ^ B023 - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B024_B024.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B024_B024.py.snap deleted file mode 100644 index 7187426cc5..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B024_B024.py.snap +++ /dev/null @@ -1,52 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B024.py:18:7: B024 `Base_1` is an abstract base class, but it has no abstract methods - | -18 | class Base_1(ABC): # error - | ^^^^^^ B024 -19 | def method(self): -20 | foo() - | - -B024.py:71:7: B024 `MetaBase_1` is an abstract base class, but it has no abstract methods - | -71 | class MetaBase_1(metaclass=ABCMeta): # error - | ^^^^^^^^^^ B024 -72 | def method(self): -73 | foo() - | - -B024.py:82:7: B024 `abc_Base_1` is an abstract base class, but it has no abstract methods - | -82 | class abc_Base_1(abc.ABC): # error - | ^^^^^^^^^^ B024 -83 | def method(self): -84 | foo() - | - -B024.py:87:7: B024 `abc_Base_2` is an abstract base class, but it has no abstract methods - | -87 | class abc_Base_2(metaclass=abc.ABCMeta): # error - | ^^^^^^^^^^ B024 -88 | def method(self): -89 | foo() - | - -B024.py:92:7: B024 `notabc_Base_1` is an abstract base class, but it has no abstract methods - | -92 | class notabc_Base_1(notabc.ABC): # error - | ^^^^^^^^^^^^^ B024 -93 | def method(self): -94 | foo() - | - -B024.py:141:7: B024 `abc_set_class_variable_4` is an abstract base class, but it has no abstract methods - | -140 | # this doesn't actually declare a class variable, it's just an expression -141 | class abc_set_class_variable_4(ABC): # error - | ^^^^^^^^^^^^^^^^^^^^^^^^ B024 -142 | foo - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B025_B025.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B025_B025.py.snap deleted file mode 100644 index 68f4e56156..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B025_B025.py.snap +++ /dev/null @@ -1,41 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B025.py:19:8: B025 try-except block with duplicate exception `ValueError` - | -17 | except ValueError: -18 | a = 2 -19 | except ValueError: - | ^^^^^^^^^^ B025 -20 | a = 2 - | - -B025.py:28:8: B025 try-except block with duplicate exception `pickle.PickleError` - | -26 | except ValueError: -27 | a = 2 -28 | except pickle.PickleError: - | ^^^^^^^^^^^^^^^^^^ B025 -29 | a = 2 - | - -B025.py:35:8: B025 try-except block with duplicate exception `ValueError` - | -33 | except (ValueError, TypeError): -34 | a = 2 -35 | except ValueError: - | ^^^^^^^^^^ B025 -36 | a = 2 -37 | except (OSError, TypeError): - | - -B025.py:37:18: B025 try-except block with duplicate exception `TypeError` - | -35 | except ValueError: -36 | a = 2 -37 | except (OSError, TypeError): - | ^^^^^^^^^ B025 -38 | a = 2 - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B026_B026.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B026_B026.py.snap deleted file mode 100644 index aa172af706..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B026_B026.py.snap +++ /dev/null @@ -1,70 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B026.py:16:16: B026 Star-arg unpacking after a keyword argument is strongly discouraged - | -14 | foo("bar", baz="baz", bam="bam") -15 | foo(bar="bar", baz="baz", bam="bam") -16 | foo(bam="bam", *["bar", "baz"]) - | ^^^^^^^^^^^^^^^ B026 -17 | foo(bam="bam", *bar_baz) -18 | foo(baz="baz", bam="bam", *["bar"]) - | - -B026.py:17:16: B026 Star-arg unpacking after a keyword argument is strongly discouraged - | -15 | foo(bar="bar", baz="baz", bam="bam") -16 | foo(bam="bam", *["bar", "baz"]) -17 | foo(bam="bam", *bar_baz) - | ^^^^^^^^ B026 -18 | foo(baz="baz", bam="bam", *["bar"]) -19 | foo(bar="bar", baz="baz", bam="bam", *[]) - | - -B026.py:18:27: B026 Star-arg unpacking after a keyword argument is strongly discouraged - | -16 | foo(bam="bam", *["bar", "baz"]) -17 | foo(bam="bam", *bar_baz) -18 | foo(baz="baz", bam="bam", *["bar"]) - | ^^^^^^^^ B026 -19 | foo(bar="bar", baz="baz", bam="bam", *[]) -20 | foo(bam="bam", *["bar"], *["baz"]) - | - -B026.py:19:38: B026 Star-arg unpacking after a keyword argument is strongly discouraged - | -17 | foo(bam="bam", *bar_baz) -18 | foo(baz="baz", bam="bam", *["bar"]) -19 | foo(bar="bar", baz="baz", bam="bam", *[]) - | ^^^ B026 -20 | foo(bam="bam", *["bar"], *["baz"]) -21 | foo(*["bar"], bam="bam", *["baz"]) - | - -B026.py:20:16: B026 Star-arg unpacking after a keyword argument is strongly discouraged - | -18 | foo(baz="baz", bam="bam", *["bar"]) -19 | foo(bar="bar", baz="baz", bam="bam", *[]) -20 | foo(bam="bam", *["bar"], *["baz"]) - | ^^^^^^^^ B026 -21 | foo(*["bar"], bam="bam", *["baz"]) - | - -B026.py:20:26: B026 Star-arg unpacking after a keyword argument is strongly discouraged - | -18 | foo(baz="baz", bam="bam", *["bar"]) -19 | foo(bar="bar", baz="baz", bam="bam", *[]) -20 | foo(bam="bam", *["bar"], *["baz"]) - | ^^^^^^^^ B026 -21 | foo(*["bar"], bam="bam", *["baz"]) - | - -B026.py:21:26: B026 Star-arg unpacking after a keyword argument is strongly discouraged - | -19 | foo(bar="bar", baz="baz", bam="bam", *[]) -20 | foo(bam="bam", *["bar"], *["baz"]) -21 | foo(*["bar"], bam="bam", *["baz"]) - | ^^^^^^^^ B026 - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B027_B027.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B027_B027.py.snap deleted file mode 100644 index 2655abdbb6..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B027_B027.py.snap +++ /dev/null @@ -1,56 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -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 - | _____^ -19 | | ... - | |___________^ B027 -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 - | _____^ -22 | | pass - | |____________^ B027 -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 - | _____^ -25 | | """docstring""" -26 | | ... - | |___________^ B027 -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 - | _____^ -29 | | """multiple ellipsis/pass""" -30 | | ... -31 | | pass -32 | | ... -33 | | pass - | |____________^ B027 -34 | -35 | @notabstract - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B027_B027.pyi.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B027_B027.pyi.snap deleted file mode 100644 index ebd951da0a..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B027_B027.pyi.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B028_B028.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B028_B028.py.snap deleted file mode 100644 index 6777d186cf..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B028_B028.py.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B028.py:8:1: B028 No explicit `stacklevel` keyword argument found - | - 6 | """ - 7 | - 8 | warnings.warn(DeprecationWarning("test")) - | ^^^^^^^^^^^^^ B028 - 9 | warnings.warn(DeprecationWarning("test"), source=None) -10 | warnings.warn(DeprecationWarning("test"), source=None, stacklevel=2) - | - -B028.py:9:1: B028 No explicit `stacklevel` keyword argument found - | - 8 | warnings.warn(DeprecationWarning("test")) - 9 | warnings.warn(DeprecationWarning("test"), source=None) - | ^^^^^^^^^^^^^ B028 -10 | warnings.warn(DeprecationWarning("test"), source=None, stacklevel=2) -11 | warnings.warn(DeprecationWarning("test"), stacklevel=1) - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B029_B029.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B029_B029.py.snap deleted file mode 100644 index d0615ea492..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B029_B029.py.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B029.py:8:1: B029 Using `except ():` with an empty tuple does not catch anything; add exceptions to handle - | - 6 | try: - 7 | pass - 8 | / except (): - 9 | | pass - | |________^ B029 -10 | -11 | try: - | - -B029.py:13:1: B029 Using `except ():` with an empty tuple does not catch anything; add exceptions to handle - | -11 | try: -12 | pass -13 | / except () as e: -14 | | pass - | |________^ B029 - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B030_B030.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B030_B030.py.snap deleted file mode 100644 index a108535056..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B030_B030.py.snap +++ /dev/null @@ -1,49 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B030.py:12:8: B030 `except` handlers should only be exception classes or tuples of exception classes - | -10 | try: -11 | pass -12 | except 1: # error - | ^ B030 -13 | pass - | - -B030.py:17:9: B030 `except` handlers should only be exception classes or tuples of exception classes - | -15 | try: -16 | pass -17 | except (1, ValueError): # error - | ^ B030 -18 | pass - | - -B030.py:22:21: B030 `except` handlers should only be exception classes or tuples of exception classes - | -20 | try: -21 | pass -22 | except (ValueError, (RuntimeError, (KeyError, TypeError))): # error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B030 -23 | pass - | - -B030.py:27:37: B030 `except` handlers should only be exception classes or tuples of exception classes - | -25 | try: -26 | pass -27 | except (ValueError, *(RuntimeError, (KeyError, TypeError))): # error - | ^^^^^^^^^^^^^^^^^^^^^ B030 -28 | pass - | - -B030.py:33:29: B030 `except` handlers should only be exception classes or tuples of exception classes - | -31 | try: -32 | pass -33 | except (*a, *(RuntimeError, (KeyError, TypeError))): # error - | ^^^^^^^^^^^^^^^^^^^^^ B030 -34 | pass - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B031_B031.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B031_B031.py.snap deleted file mode 100644 index 203fcf77f5..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B031_B031.py.snap +++ /dev/null @@ -1,198 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B031.py:27:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | -25 | for shopper in shoppers: -26 | shopper = shopper.title() -27 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 -28 | # We're outside the nested loop and used the group again. -29 | collect_shop_items(shopper, section_items) # B031 - | - -B031.py:29:33: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | -27 | collect_shop_items(shopper, section_items) # B031 -28 | # We're outside the nested loop and used the group again. -29 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 -30 | -31 | for _section, section_items in groupby(items, key=lambda p: p[1]): - | - -B031.py:33:31: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | -31 | for _section, section_items in groupby(items, key=lambda p: p[1]): -32 | collect_shop_items("Jane", section_items) -33 | collect_shop_items("Joe", section_items) # B031 - | ^^^^^^^^^^^^^ B031 - | - -B031.py:40:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | -38 | countdown = 3 -39 | while countdown > 0: -40 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 -41 | countdown -= 1 - | - -B031.py:46:29: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | -44 | collection = [] -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 | -48 | unique_items = set() - | - -B031.py:56:17: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | -55 | # But it should be detected when used again -56 | for item in section_items: # B031 - | ^^^^^^^^^^^^^ B031 -57 | another_set.add(item) - | - -B031.py:79:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | -77 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): -78 | for shopper in shoppers: -79 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 -80 | -81 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): - | - -B031.py:82:38: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | -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 | -84 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): - | - -B031.py:94:65: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | -92 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): -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 | -96 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): - | - -B031.py:101:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | - 99 | else: -100 | collect_shop_items(shopper, section_items) -101 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 -102 | -103 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): - | - -B031.py:108:41: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | -106 | collect_shop_items(shopper, section_items) -107 | if _section == "greens": -108 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 -109 | elif _section == "frozen items": -110 | collect_shop_items(shopper, section_items) # B031 - | - -B031.py:110:41: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | -108 | collect_shop_items(shopper, section_items) # B031 -109 | elif _section == "frozen items": -110 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 -111 | else: -112 | collect_shop_items(shopper, section_items) # B031 - | - -B031.py:112:41: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | -110 | collect_shop_items(shopper, section_items) # B031 -111 | else: -112 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 -113 | collect_shop_items(shopper, section_items) # B031 -114 | elif _section == "frozen items": - | - -B031.py:113:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | -111 | else: -112 | collect_shop_items(shopper, section_items) # B031 -113 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 -114 | elif _section == "frozen items": -115 | # Mix `match` and `if` statements - | - -B031.py:120:49: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | -118 | collect_shop_items(shopper, section_items) -119 | if _section == "fourth": -120 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 -121 | case _: -122 | collect_shop_items(shopper, section_items) - | - -B031.py:126:33: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | -124 | collect_shop_items(shopper, section_items) -125 | # Now, it should detect -126 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 -127 | -128 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): - | - -B031.py:135:49: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | -133 | match shopper: -134 | case "Jane": -135 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 -136 | case _: -137 | collect_shop_items(shopper, section_items) # B031 - | - -B031.py:137:49: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | -135 | collect_shop_items(shopper, section_items) # B031 -136 | case _: -137 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 -138 | case "frozen items": -139 | collect_shop_items(shopper, section_items) - | - -B031.py:140:41: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | -138 | case "frozen items": -139 | collect_shop_items(shopper, section_items) -140 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 -141 | case _: -142 | collect_shop_items(shopper, section_items) - | - -B031.py:144:33: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage - | -142 | collect_shop_items(shopper, section_items) -143 | # Now, it should detect -144 | collect_shop_items(shopper, section_items) # B031 - | ^^^^^^^^^^^^^ B031 -145 | -146 | for group in groupby(items, key=lambda p: p[1]): - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B032_B032.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B032_B032.py.snap deleted file mode 100644 index 2a43fa7849..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B032_B032.py.snap +++ /dev/null @@ -1,78 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B032.py:9:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? - | - 7 | dct = {"a": 1} - 8 | - 9 | dct["b"]: 2 - | ^^^^^^^^^^^ B032 -10 | dct.b: 2 - | - -B032.py:10:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? - | - 9 | dct["b"]: 2 -10 | dct.b: 2 - | ^^^^^^^^ B032 -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 | -12 | dct["b"]: "test" - | ^^^^^^^^^^^^^^^^ B032 -13 | dct.b: "test" - | - -B032.py:13:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? - | -12 | dct["b"]: "test" -13 | dct.b: "test" - | ^^^^^^^^^^^^^ B032 -14 | -15 | test = "test" - | - -B032.py:16:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? - | -15 | test = "test" -16 | dct["b"]: test - | ^^^^^^^^^^^^^^ B032 -17 | dct["b"]: test.lower() -18 | dct.b: test - | - -B032.py:17:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? - | -15 | test = "test" -16 | dct["b"]: test -17 | dct["b"]: test.lower() - | ^^^^^^^^^^^^^^^^^^^^^^ B032 -18 | dct.b: test -19 | dct.b: test.lower() - | - -B032.py:18:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? - | -16 | dct["b"]: test -17 | dct["b"]: test.lower() -18 | dct.b: test - | ^^^^^^^^^^^ B032 -19 | dct.b: test.lower() - | - -B032.py:19:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? - | -17 | dct["b"]: test.lower() -18 | dct.b: test -19 | dct.b: test.lower() - | ^^^^^^^^^^^^^^^^^^^ B032 -20 | -21 | # Do not flag below - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B033_B033.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B033_B033.py.snap deleted file mode 100644 index 93e6e1154a..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B033_B033.py.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B033.py:4:35: B033 Sets should not contain duplicate item `"value1"` - | -2 | # Errors. -3 | ### -4 | incorrect_set = {"value1", 23, 5, "value1"} - | ^^^^^^^^ B033 -5 | incorrect_set = {1, 1} - | - -B033.py:5:21: B033 Sets should not contain duplicate item `1` - | -3 | ### -4 | incorrect_set = {"value1", 23, 5, "value1"} -5 | incorrect_set = {1, 1} - | ^ B033 -6 | -7 | ### - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B034_B034.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B034_B034.py.snap deleted file mode 100644 index 44efbb7d97..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B034_B034.py.snap +++ /dev/null @@ -1,102 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B034.py:5:1: B034 `re.sub` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions - | -4 | # B034 -5 | re.sub("a", "b", "aaa", re.IGNORECASE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 -6 | re.sub("a", "b", "aaa", 5) -7 | re.sub("a", "b", "aaa", 5, re.IGNORECASE) - | - -B034.py:6:1: B034 `re.sub` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions - | -4 | # B034 -5 | re.sub("a", "b", "aaa", re.IGNORECASE) -6 | re.sub("a", "b", "aaa", 5) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 -7 | re.sub("a", "b", "aaa", 5, re.IGNORECASE) -8 | re.subn("a", "b", "aaa", re.IGNORECASE) - | - -B034.py:7:1: B034 `re.sub` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions - | -5 | re.sub("a", "b", "aaa", re.IGNORECASE) -6 | re.sub("a", "b", "aaa", 5) -7 | re.sub("a", "b", "aaa", 5, re.IGNORECASE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 -8 | re.subn("a", "b", "aaa", re.IGNORECASE) -9 | re.subn("a", "b", "aaa", 5) - | - -B034.py:8:1: B034 `re.subn` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions - | - 6 | re.sub("a", "b", "aaa", 5) - 7 | re.sub("a", "b", "aaa", 5, re.IGNORECASE) - 8 | re.subn("a", "b", "aaa", re.IGNORECASE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 - 9 | re.subn("a", "b", "aaa", 5) -10 | re.subn("a", "b", "aaa", 5, re.IGNORECASE) - | - -B034.py:9:1: B034 `re.subn` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions - | - 7 | re.sub("a", "b", "aaa", 5, re.IGNORECASE) - 8 | re.subn("a", "b", "aaa", re.IGNORECASE) - 9 | re.subn("a", "b", "aaa", 5) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 -10 | re.subn("a", "b", "aaa", 5, re.IGNORECASE) -11 | re.split(" ", "a a a a", re.I) - | - -B034.py:10:1: B034 `re.subn` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions - | - 8 | re.subn("a", "b", "aaa", re.IGNORECASE) - 9 | re.subn("a", "b", "aaa", 5) -10 | re.subn("a", "b", "aaa", 5, re.IGNORECASE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 -11 | re.split(" ", "a a a a", re.I) -12 | re.split(" ", "a a a a", 2) - | - -B034.py:11:1: B034 `re.split` should pass `maxsplit` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions - | - 9 | re.subn("a", "b", "aaa", 5) -10 | re.subn("a", "b", "aaa", 5, re.IGNORECASE) -11 | re.split(" ", "a a a a", re.I) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 -12 | re.split(" ", "a a a a", 2) -13 | re.split(" ", "a a a a", 2, re.I) - | - -B034.py:12:1: B034 `re.split` should pass `maxsplit` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions - | -10 | re.subn("a", "b", "aaa", 5, re.IGNORECASE) -11 | re.split(" ", "a a a a", re.I) -12 | re.split(" ", "a a a a", 2) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 -13 | re.split(" ", "a a a a", 2, re.I) -14 | sub("a", "b", "aaa", re.IGNORECASE) - | - -B034.py:13:1: B034 `re.split` should pass `maxsplit` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions - | -11 | re.split(" ", "a a a a", re.I) -12 | re.split(" ", "a a a a", 2) -13 | re.split(" ", "a a a a", 2, re.I) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 -14 | sub("a", "b", "aaa", re.IGNORECASE) - | - -B034.py:14:1: B034 `re.sub` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions - | -12 | re.split(" ", "a a a a", 2) -13 | re.split(" ", "a a a a", 2, re.I) -14 | sub("a", "b", "aaa", re.IGNORECASE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 -15 | -16 | # OK - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B904_B904.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B904_B904.py.snap deleted file mode 100644 index 0b2a9b71ba..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B904_B904.py.snap +++ /dev/null @@ -1,70 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -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 - | - 8 | except ValueError: - 9 | if "abc": -10 | raise TypeError - | ^^^^^^^^^^^^^^^ B904 -11 | raise UserWarning -12 | except AssertionError: - | - -B904.py:11:5: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling - | - 9 | if "abc": -10 | raise TypeError -11 | raise UserWarning - | ^^^^^^^^^^^^^^^^^ B904 -12 | except AssertionError: -13 | raise # Bare `raise` should not be an error - | - -B904.py:16:5: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling - | -14 | except Exception as err: -15 | assert err -16 | raise Exception("No cause here...") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904 -17 | except BaseException as err: -18 | raise err - | - -B904.py:20:5: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling - | -18 | raise err -19 | except BaseException as err: -20 | raise some_other_err - | ^^^^^^^^^^^^^^^^^^^^ B904 -21 | finally: -22 | raise Exception("Nothing to chain from, so no warning here") - | - -B904.py:63:9: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling - | -61 | except Exception as e: -62 | if ...: -63 | raise RuntimeError("boom!") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904 -64 | else: -65 | raise RuntimeError("bang!") - | - -B904.py:65:9: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling - | -63 | raise RuntimeError("boom!") -64 | else: -65 | raise RuntimeError("bang!") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904 - | - -B904.py:73:13: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling - | -71 | match 0: -72 | case 0: -73 | raise RuntimeError("boom!") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904 - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B905.py.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B905.py.snap deleted file mode 100644 index fd4e2b36b3..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__B905.py.snap +++ /dev/null @@ -1,88 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B905.py:4:1: B905 `zip()` without an explicit `strict=` parameter - | -3 | # Errors -4 | zip() - | ^^^^^ B905 -5 | zip(range(3)) -6 | zip("a", "b") - | - -B905.py:5:1: B905 `zip()` without an explicit `strict=` parameter - | -3 | # Errors -4 | zip() -5 | zip(range(3)) - | ^^^^^^^^^^^^^ B905 -6 | zip("a", "b") -7 | zip("a", "b", *zip("c")) - | - -B905.py:6:1: B905 `zip()` without an explicit `strict=` parameter - | -4 | zip() -5 | zip(range(3)) -6 | zip("a", "b") - | ^^^^^^^^^^^^^ B905 -7 | zip("a", "b", *zip("c")) -8 | zip(zip("a"), strict=False) - | - -B905.py:7:1: B905 `zip()` without an explicit `strict=` parameter - | -5 | zip(range(3)) -6 | zip("a", "b") -7 | zip("a", "b", *zip("c")) - | ^^^^^^^^^^^^^^^^^^^^^^^^ B905 -8 | zip(zip("a"), strict=False) -9 | zip(zip("a", strict=True)) - | - -B905.py:7:16: B905 `zip()` without an explicit `strict=` parameter - | -5 | zip(range(3)) -6 | zip("a", "b") -7 | zip("a", "b", *zip("c")) - | ^^^^^^^^ B905 -8 | zip(zip("a"), strict=False) -9 | zip(zip("a", strict=True)) - | - -B905.py:8:5: B905 `zip()` without an explicit `strict=` parameter - | -6 | zip("a", "b") -7 | zip("a", "b", *zip("c")) -8 | zip(zip("a"), strict=False) - | ^^^^^^^^ B905 -9 | zip(zip("a", strict=True)) - | - -B905.py:9:1: B905 `zip()` without an explicit `strict=` parameter - | - 7 | zip("a", "b", *zip("c")) - 8 | zip(zip("a"), strict=False) - 9 | zip(zip("a", strict=True)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ B905 -10 | -11 | # OK - | - -B905.py:24:1: B905 `zip()` without an explicit `strict=` parameter - | -23 | # Errors (limited iterators). -24 | zip([1, 2, 3], repeat(1, 1)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B905 -25 | zip([1, 2, 3], repeat(1, times=4)) - | - -B905.py:25:1: B905 `zip()` without an explicit `strict=` parameter - | -23 | # Errors (limited iterators). -24 | zip([1, 2, 3], repeat(1, 1)) -25 | zip([1, 2, 3], repeat(1, times=4)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B905 - | - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__extend_immutable_calls_arg_annotation.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__extend_immutable_calls_arg_annotation.snap deleted file mode 100644 index 7bc5a28612..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__extend_immutable_calls_arg_annotation.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B006_extended.py:17:55: B006 [*] Do not use mutable data structures for argument defaults - | -17 | def error_due_to_missing_import(foo: ImmutableTypeA = []): - | ^^ B006 -18 | ... - | - = help: Replace with `None`; initialize within function - -ℹ Possible fix -14 14 | ... -15 15 | -16 16 | -17 |-def error_due_to_missing_import(foo: ImmutableTypeA = []): - 17 |+def error_due_to_missing_import(foo: ImmutableTypeA = None): - 18 |+ if foo is None: - 19 |+ foo = [] -18 20 | ... - - diff --git a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__extend_immutable_calls_arg_default.snap b/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__extend_immutable_calls_arg_default.snap deleted file mode 100644 index 88a9b19016..0000000000 --- a/crates/ruff/src/rules/flake8_bugbear/snapshots/ruff__rules__flake8_bugbear__tests__extend_immutable_calls_arg_default.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_bugbear/mod.rs ---- -B008_extended.py:24:51: B008 Do not perform function call `Depends` in argument defaults - | -24 | def error_due_to_missing_import(data: List[str] = Depends(None)): - | ^^^^^^^^^^^^^ B008 -25 | ... - | - - diff --git a/crates/ruff/src/rules/flake8_builtins/snapshots/ruff__rules__flake8_builtins__tests__A001_A001.py.snap b/crates/ruff/src/rules/flake8_builtins/snapshots/ruff__rules__flake8_builtins__tests__A001_A001.py.snap deleted file mode 100644 index 4ae541d094..0000000000 --- a/crates/ruff/src/rules/flake8_builtins/snapshots/ruff__rules__flake8_builtins__tests__A001_A001.py.snap +++ /dev/null @@ -1,187 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_builtins/mod.rs ---- -A001.py:1:16: A001 Variable `sum` is shadowing a Python builtin - | -1 | import some as sum - | ^^^ A001 -2 | from some import other as int -3 | from directory import new as dir - | - -A001.py:2:27: A001 Variable `int` is shadowing a Python builtin - | -1 | import some as sum -2 | from some import other as int - | ^^^ A001 -3 | from directory import new as dir - | - -A001.py:3:30: A001 Variable `dir` is shadowing a Python builtin - | -1 | import some as sum -2 | from some import other as int -3 | from directory import new as dir - | ^^^ A001 -4 | -5 | print = 1 - | - -A001.py:5:1: A001 Variable `print` is shadowing a Python builtin - | -3 | from directory import new as dir -4 | -5 | print = 1 - | ^^^^^ A001 -6 | copyright: 'annotation' = 2 -7 | (complex := 3) - | - -A001.py:6:1: A001 Variable `copyright` is shadowing a Python builtin - | -5 | print = 1 -6 | copyright: 'annotation' = 2 - | ^^^^^^^^^ A001 -7 | (complex := 3) -8 | float = object = 4 - | - -A001.py:7:2: A001 Variable `complex` is shadowing a Python builtin - | -5 | print = 1 -6 | copyright: 'annotation' = 2 -7 | (complex := 3) - | ^^^^^^^ A001 -8 | float = object = 4 -9 | min, max = 5, 6 - | - -A001.py:8:1: A001 Variable `float` is shadowing a Python builtin - | -6 | copyright: 'annotation' = 2 -7 | (complex := 3) -8 | float = object = 4 - | ^^^^^ A001 -9 | min, max = 5, 6 - | - -A001.py:8:9: A001 Variable `object` is shadowing a Python builtin - | -6 | copyright: 'annotation' = 2 -7 | (complex := 3) -8 | float = object = 4 - | ^^^^^^ A001 -9 | min, max = 5, 6 - | - -A001.py:9:1: A001 Variable `min` is shadowing a Python builtin - | - 7 | (complex := 3) - 8 | float = object = 4 - 9 | min, max = 5, 6 - | ^^^ A001 -10 | -11 | id = 4 - | - -A001.py:9:6: A001 Variable `max` is shadowing a Python builtin - | - 7 | (complex := 3) - 8 | float = object = 4 - 9 | min, max = 5, 6 - | ^^^ A001 -10 | -11 | id = 4 - | - -A001.py:11:1: A001 Variable `id` is shadowing a Python builtin - | - 9 | min, max = 5, 6 -10 | -11 | id = 4 - | ^^ A001 -12 | -13 | def bytes(): - | - -A001.py:13:5: A001 Variable `bytes` is shadowing a Python builtin - | -11 | id = 4 -12 | -13 | def bytes(): - | ^^^^^ A001 -14 | pass - | - -A001.py:16:7: A001 Variable `slice` is shadowing a Python builtin - | -14 | pass -15 | -16 | class slice: - | ^^^^^ A001 -17 | pass - | - -A001.py:21:23: A001 Variable `ValueError` is shadowing a Python builtin - | -19 | try: -20 | ... -21 | except ImportError as ValueError: - | ^^^^^^^^^^ A001 -22 | ... - | - -A001.py:24:5: A001 Variable `memoryview` is shadowing a Python builtin - | -22 | ... -23 | -24 | for memoryview, *bytearray in []: - | ^^^^^^^^^^ A001 -25 | pass - | - -A001.py:24:18: A001 Variable `bytearray` is shadowing a Python builtin - | -22 | ... -23 | -24 | for memoryview, *bytearray in []: - | ^^^^^^^^^ A001 -25 | pass - | - -A001.py:27:22: A001 Variable `str` is shadowing a Python builtin - | -25 | pass -26 | -27 | with open('file') as str, open('file2') as (all, any): - | ^^^ A001 -28 | pass - | - -A001.py:27:45: A001 Variable `all` is shadowing a Python builtin - | -25 | pass -26 | -27 | with open('file') as str, open('file2') as (all, any): - | ^^^ A001 -28 | pass - | - -A001.py:27:50: A001 Variable `any` is shadowing a Python builtin - | -25 | pass -26 | -27 | with open('file') as str, open('file2') as (all, any): - | ^^^ A001 -28 | pass - | - -A001.py:30:8: A001 Variable `sum` is shadowing a Python builtin - | -28 | pass -29 | -30 | [0 for sum in ()] - | ^^^ A001 - | - - diff --git a/crates/ruff/src/rules/flake8_builtins/snapshots/ruff__rules__flake8_builtins__tests__A001_A001.py_builtins_ignorelist.snap b/crates/ruff/src/rules/flake8_builtins/snapshots/ruff__rules__flake8_builtins__tests__A001_A001.py_builtins_ignorelist.snap deleted file mode 100644 index ce715c0d0a..0000000000 --- a/crates/ruff/src/rules/flake8_builtins/snapshots/ruff__rules__flake8_builtins__tests__A001_A001.py_builtins_ignorelist.snap +++ /dev/null @@ -1,167 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_builtins/mod.rs ---- -A001.py:1:16: A001 Variable `sum` is shadowing a Python builtin - | -1 | import some as sum - | ^^^ A001 -2 | from some import other as int -3 | from directory import new as dir - | - -A001.py:2:27: A001 Variable `int` is shadowing a Python builtin - | -1 | import some as sum -2 | from some import other as int - | ^^^ A001 -3 | from directory import new as dir - | - -A001.py:5:1: A001 Variable `print` is shadowing a Python builtin - | -3 | from directory import new as dir -4 | -5 | print = 1 - | ^^^^^ A001 -6 | copyright: 'annotation' = 2 -7 | (complex := 3) - | - -A001.py:6:1: A001 Variable `copyright` is shadowing a Python builtin - | -5 | print = 1 -6 | copyright: 'annotation' = 2 - | ^^^^^^^^^ A001 -7 | (complex := 3) -8 | float = object = 4 - | - -A001.py:7:2: A001 Variable `complex` is shadowing a Python builtin - | -5 | print = 1 -6 | copyright: 'annotation' = 2 -7 | (complex := 3) - | ^^^^^^^ A001 -8 | float = object = 4 -9 | min, max = 5, 6 - | - -A001.py:8:1: A001 Variable `float` is shadowing a Python builtin - | -6 | copyright: 'annotation' = 2 -7 | (complex := 3) -8 | float = object = 4 - | ^^^^^ A001 -9 | min, max = 5, 6 - | - -A001.py:8:9: A001 Variable `object` is shadowing a Python builtin - | -6 | copyright: 'annotation' = 2 -7 | (complex := 3) -8 | float = object = 4 - | ^^^^^^ A001 -9 | min, max = 5, 6 - | - -A001.py:9:1: A001 Variable `min` is shadowing a Python builtin - | - 7 | (complex := 3) - 8 | float = object = 4 - 9 | min, max = 5, 6 - | ^^^ A001 -10 | -11 | id = 4 - | - -A001.py:9:6: A001 Variable `max` is shadowing a Python builtin - | - 7 | (complex := 3) - 8 | float = object = 4 - 9 | min, max = 5, 6 - | ^^^ A001 -10 | -11 | id = 4 - | - -A001.py:13:5: A001 Variable `bytes` is shadowing a Python builtin - | -11 | id = 4 -12 | -13 | def bytes(): - | ^^^^^ A001 -14 | pass - | - -A001.py:16:7: A001 Variable `slice` is shadowing a Python builtin - | -14 | pass -15 | -16 | class slice: - | ^^^^^ A001 -17 | pass - | - -A001.py:21:23: A001 Variable `ValueError` is shadowing a Python builtin - | -19 | try: -20 | ... -21 | except ImportError as ValueError: - | ^^^^^^^^^^ A001 -22 | ... - | - -A001.py:24:5: A001 Variable `memoryview` is shadowing a Python builtin - | -22 | ... -23 | -24 | for memoryview, *bytearray in []: - | ^^^^^^^^^^ A001 -25 | pass - | - -A001.py:24:18: A001 Variable `bytearray` is shadowing a Python builtin - | -22 | ... -23 | -24 | for memoryview, *bytearray in []: - | ^^^^^^^^^ A001 -25 | pass - | - -A001.py:27:22: A001 Variable `str` is shadowing a Python builtin - | -25 | pass -26 | -27 | with open('file') as str, open('file2') as (all, any): - | ^^^ A001 -28 | pass - | - -A001.py:27:45: A001 Variable `all` is shadowing a Python builtin - | -25 | pass -26 | -27 | with open('file') as str, open('file2') as (all, any): - | ^^^ A001 -28 | pass - | - -A001.py:27:50: A001 Variable `any` is shadowing a Python builtin - | -25 | pass -26 | -27 | with open('file') as str, open('file2') as (all, any): - | ^^^ A001 -28 | pass - | - -A001.py:30:8: A001 Variable `sum` is shadowing a Python builtin - | -28 | pass -29 | -30 | [0 for sum in ()] - | ^^^ A001 - | - - diff --git a/crates/ruff/src/rules/flake8_builtins/snapshots/ruff__rules__flake8_builtins__tests__A002_A002.py.snap b/crates/ruff/src/rules/flake8_builtins/snapshots/ruff__rules__flake8_builtins__tests__A002_A002.py.snap deleted file mode 100644 index 6069b088e6..0000000000 --- a/crates/ruff/src/rules/flake8_builtins/snapshots/ruff__rules__flake8_builtins__tests__A002_A002.py.snap +++ /dev/null @@ -1,72 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_builtins/mod.rs ---- -A002.py:1:11: A002 Argument `str` is shadowing a Python builtin - | -1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^ A002 -2 | pass - | - -A002.py:1:19: A002 Argument `type` is shadowing a Python builtin - | -1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^^ A002 -2 | pass - | - -A002.py:1:26: A002 Argument `complex` is shadowing a Python builtin - | -1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^^^^^ A002 -2 | pass - | - -A002.py:1:35: A002 Argument `Exception` is shadowing a Python builtin - | -1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^^^^^^^ A002 -2 | pass - | - -A002.py:1:48: A002 Argument `getattr` is shadowing a Python builtin - | -1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^^^^^ A002 -2 | pass - | - -A002.py:5:17: A002 Argument `bytes` is shadowing a Python builtin - | -5 | async def func2(bytes): - | ^^^^^ A002 -6 | pass - | - -A002.py:8:17: A002 Argument `id` is shadowing a Python builtin - | -6 | pass -7 | -8 | async def func3(id, dir): - | ^^ A002 -9 | pass - | - -A002.py:8:21: A002 Argument `dir` is shadowing a Python builtin - | -6 | pass -7 | -8 | async def func3(id, dir): - | ^^^ A002 -9 | pass - | - -A002.py:11:16: A002 Argument `float` is shadowing a Python builtin - | - 9 | pass -10 | -11 | map([], lambda float: ...) - | ^^^^^ A002 - | - - diff --git a/crates/ruff/src/rules/flake8_builtins/snapshots/ruff__rules__flake8_builtins__tests__A002_A002.py_builtins_ignorelist.snap b/crates/ruff/src/rules/flake8_builtins/snapshots/ruff__rules__flake8_builtins__tests__A002_A002.py_builtins_ignorelist.snap deleted file mode 100644 index 5264d432df..0000000000 --- a/crates/ruff/src/rules/flake8_builtins/snapshots/ruff__rules__flake8_builtins__tests__A002_A002.py_builtins_ignorelist.snap +++ /dev/null @@ -1,54 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_builtins/mod.rs ---- -A002.py:1:11: A002 Argument `str` is shadowing a Python builtin - | -1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^ A002 -2 | pass - | - -A002.py:1:19: A002 Argument `type` is shadowing a Python builtin - | -1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^^ A002 -2 | pass - | - -A002.py:1:26: A002 Argument `complex` is shadowing a Python builtin - | -1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^^^^^ A002 -2 | pass - | - -A002.py:1:35: A002 Argument `Exception` is shadowing a Python builtin - | -1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^^^^^^^ A002 -2 | pass - | - -A002.py:1:48: A002 Argument `getattr` is shadowing a Python builtin - | -1 | def func1(str, /, type, *complex, Exception, **getattr): - | ^^^^^^^ A002 -2 | pass - | - -A002.py:5:17: A002 Argument `bytes` is shadowing a Python builtin - | -5 | async def func2(bytes): - | ^^^^^ A002 -6 | pass - | - -A002.py:11:16: A002 Argument `float` is shadowing a Python builtin - | - 9 | pass -10 | -11 | map([], lambda float: ...) - | ^^^^^ A002 - | - - diff --git a/crates/ruff/src/rules/flake8_builtins/snapshots/ruff__rules__flake8_builtins__tests__A003_A003.py.snap b/crates/ruff/src/rules/flake8_builtins/snapshots/ruff__rules__flake8_builtins__tests__A003_A003.py.snap deleted file mode 100644 index 5da7f00304..0000000000 --- a/crates/ruff/src/rules/flake8_builtins/snapshots/ruff__rules__flake8_builtins__tests__A003_A003.py.snap +++ /dev/null @@ -1,68 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_builtins/mod.rs ---- -A003.py:2:5: A003 Class attribute `ImportError` is shadowing a Python builtin - | -1 | class MyClass: -2 | ImportError = 4 - | ^^^^^^^^^^^ A003 -3 | id: int -4 | dir = "/" - | - -A003.py:3:5: A003 Class attribute `id` is shadowing a Python builtin - | -1 | class MyClass: -2 | ImportError = 4 -3 | id: int - | ^^ A003 -4 | dir = "/" - | - -A003.py:4:5: A003 Class attribute `dir` is shadowing a Python builtin - | -2 | ImportError = 4 -3 | id: int -4 | dir = "/" - | ^^^ A003 -5 | -6 | def __init__(self): - | - -A003.py:11:9: A003 Class attribute `str` is shadowing a Python builtin - | - 9 | self.dir = "." -10 | -11 | def str(self): - | ^^^ A003 -12 | pass - | - -A003.py:29:9: A003 Class attribute `str` is shadowing a Python builtin - | -27 | ... -28 | -29 | def str(self) -> None: - | ^^^ A003 -30 | ... - | - -A003.py:40:9: A003 Class attribute `str` is shadowing a Python builtin - | -38 | ... -39 | -40 | def str(self) -> None: - | ^^^ A003 -41 | ... - | - -A003.py:52:9: A003 Class attribute `int` is shadowing a Python builtin - | -50 | pass -51 | -52 | def int(self): - | ^^^ A003 -53 | pass - | - - diff --git a/crates/ruff/src/rules/flake8_builtins/snapshots/ruff__rules__flake8_builtins__tests__A003_A003.py_builtins_ignorelist.snap b/crates/ruff/src/rules/flake8_builtins/snapshots/ruff__rules__flake8_builtins__tests__A003_A003.py_builtins_ignorelist.snap deleted file mode 100644 index 7c86544588..0000000000 --- a/crates/ruff/src/rules/flake8_builtins/snapshots/ruff__rules__flake8_builtins__tests__A003_A003.py_builtins_ignorelist.snap +++ /dev/null @@ -1,49 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_builtins/mod.rs ---- -A003.py:2:5: A003 Class attribute `ImportError` is shadowing a Python builtin - | -1 | class MyClass: -2 | ImportError = 4 - | ^^^^^^^^^^^ A003 -3 | id: int -4 | dir = "/" - | - -A003.py:11:9: A003 Class attribute `str` is shadowing a Python builtin - | - 9 | self.dir = "." -10 | -11 | def str(self): - | ^^^ A003 -12 | pass - | - -A003.py:29:9: A003 Class attribute `str` is shadowing a Python builtin - | -27 | ... -28 | -29 | def str(self) -> None: - | ^^^ A003 -30 | ... - | - -A003.py:40:9: A003 Class attribute `str` is shadowing a Python builtin - | -38 | ... -39 | -40 | def str(self) -> None: - | ^^^ A003 -41 | ... - | - -A003.py:52:9: A003 Class attribute `int` is shadowing a Python builtin - | -50 | pass -51 | -52 | def int(self): - | ^^^ A003 -53 | pass - | - - diff --git a/crates/ruff/src/rules/flake8_commas/snapshots/ruff__rules__flake8_commas__tests__COM81.py.snap b/crates/ruff/src/rules/flake8_commas/snapshots/ruff__rules__flake8_commas__tests__COM81.py.snap deleted file mode 100644 index e4314c5b64..0000000000 --- a/crates/ruff/src/rules/flake8_commas/snapshots/ruff__rules__flake8_commas__tests__COM81.py.snap +++ /dev/null @@ -1,942 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_commas/mod.rs ---- -COM81.py:4:18: COM812 [*] Trailing comma missing - | -2 | bad_function_call( -3 | param1='test', -4 | param2='test' - | COM812 -5 | ) -6 | # ==> bad_list.py <== - | - = help: Add trailing comma - -ℹ Fix -1 1 | # ==> bad_function_call.py <== -2 2 | bad_function_call( -3 3 | param1='test', -4 |- param2='test' - 4 |+ param2='test', -5 5 | ) -6 6 | # ==> bad_list.py <== -7 7 | bad_list = [ - -COM81.py:10:6: COM812 [*] Trailing comma missing - | - 8 | 1, - 9 | 2, -10 | 3 - | COM812 -11 | ] - | - = help: Add trailing comma - -ℹ Fix -7 7 | bad_list = [ -8 8 | 1, -9 9 | 2, -10 |- 3 - 10 |+ 3, -11 11 | ] -12 12 | -13 13 | bad_list_with_comment = [ - -COM81.py:16:6: COM812 [*] Trailing comma missing - | -14 | 1, -15 | 2, -16 | 3 - | COM812 -17 | # still needs a comma! -18 | ] - | - = help: Add trailing comma - -ℹ Fix -13 13 | bad_list_with_comment = [ -14 14 | 1, -15 15 | 2, -16 |- 3 - 16 |+ 3, -17 17 | # still needs a comma! -18 18 | ] -19 19 | - -COM81.py:23:6: COM812 [*] Trailing comma missing - | -21 | 1, -22 | 2, -23 | 3 - | COM812 - | - = help: Add trailing comma - -ℹ Fix -20 20 | bad_list_with_extra_empty = [ -21 21 | 1, -22 22 | 2, -23 |- 3 - 23 |+ 3, -24 24 | -25 25 | -26 26 | - -COM81.py:36:8: COM818 Trailing comma on bare tuple prohibited - | -34 | foo = (1,) -35 | -36 | foo = 1, - | ^ COM818 -37 | -38 | bar = 1; foo = bar, - | - -COM81.py:38:19: COM818 Trailing comma on bare tuple prohibited - | -36 | foo = 1, -37 | -38 | bar = 1; foo = bar, - | ^ COM818 -39 | -40 | foo = ( - | - -COM81.py:45:8: COM818 Trailing comma on bare tuple prohibited - | -43 | ) -44 | -45 | foo = 3, - | ^ COM818 -46 | -47 | class A(object): - | - -COM81.py:49:10: COM818 Trailing comma on bare tuple prohibited - | -47 | class A(object): -48 | foo = 3 -49 | bar = 10, - | ^ COM818 -50 | foo_bar = 2 - | - -COM81.py:56:32: COM818 Trailing comma on bare tuple prohibited - | -54 | from foo import bar, baz -55 | -56 | group_by = function_call('arg'), - | ^ COM818 -57 | -58 | group_by = ('foobar' * 3), - | - -COM81.py:58:26: COM818 Trailing comma on bare tuple prohibited - | -56 | group_by = function_call('arg'), -57 | -58 | group_by = ('foobar' * 3), - | ^ COM818 -59 | -60 | def foo(): - | - -COM81.py:61:17: COM818 Trailing comma on bare tuple prohibited - | -60 | def foo(): -61 | return False, - | ^ COM818 -62 | -63 | # ==> callable_before_parenth_form.py <== - | - -COM81.py:70:8: COM812 [*] Trailing comma missing - | -69 | {'foo': foo}['foo']( -70 | bar - | COM812 -71 | ) - | - = help: Add trailing comma - -ℹ Fix -67 67 | pass -68 68 | -69 69 | {'foo': foo}['foo']( -70 |- bar - 70 |+ bar, -71 71 | ) -72 72 | -73 73 | {'foo': foo}['foo']( - -COM81.py:78:8: COM812 [*] Trailing comma missing - | -77 | (foo)( -78 | bar - | COM812 -79 | ) - | - = help: Add trailing comma - -ℹ Fix -75 75 | ) -76 76 | -77 77 | (foo)( -78 |- bar - 78 |+ bar, -79 79 | ) -80 80 | -81 81 | (foo)[0]( - -COM81.py:86:8: COM812 [*] Trailing comma missing - | -85 | [foo][0]( -86 | bar - | COM812 -87 | ) - | - = help: Add trailing comma - -ℹ Fix -83 83 | ) -84 84 | -85 85 | [foo][0]( -86 |- bar - 86 |+ bar, -87 87 | ) -88 88 | -89 89 | [foo][0]( - -COM81.py:152:6: COM812 [*] Trailing comma missing - | -150 | # ==> keyword_before_parenth_form/base_bad.py <== -151 | from x import ( -152 | y - | COM812 -153 | ) - | - = help: Add trailing comma - -ℹ Fix -149 149 | -150 150 | # ==> keyword_before_parenth_form/base_bad.py <== -151 151 | from x import ( -152 |- y - 152 |+ y, -153 153 | ) -154 154 | -155 155 | assert( - -COM81.py:158:11: COM812 [*] Trailing comma missing - | -156 | SyntaxWarning, -157 | ThrownHere, -158 | Anyway - | COM812 -159 | ) - | - = help: Add trailing comma - -ℹ Fix -155 155 | assert( -156 156 | SyntaxWarning, -157 157 | ThrownHere, -158 |- Anyway - 158 |+ Anyway, -159 159 | ) -160 160 | -161 161 | # async await is fine outside an async def - -COM81.py:293:15: COM812 [*] Trailing comma missing - | -291 | # ==> multiline_bad_dict.py <== -292 | multiline_bad_dict = { -293 | "bad": 123 - | COM812 -294 | } -295 | # ==> multiline_bad_function_def.py <== - | - = help: Add trailing comma - -ℹ Fix -290 290 | -291 291 | # ==> multiline_bad_dict.py <== -292 292 | multiline_bad_dict = { -293 |- "bad": 123 - 293 |+ "bad": 123, -294 294 | } -295 295 | # ==> multiline_bad_function_def.py <== -296 296 | def func_good( - -COM81.py:304:14: COM812 [*] Trailing comma missing - | -302 | def func_bad( -303 | a = 3, -304 | b = 2 - | COM812 -305 | ): -306 | pass - | - = help: Add trailing comma - -ℹ Fix -301 301 | -302 302 | def func_bad( -303 303 | a = 3, -304 |- b = 2 - 304 |+ b = 2, -305 305 | ): -306 306 | pass -307 307 | - -COM81.py:310:14: COM812 [*] Trailing comma missing - | -308 | # ==> multiline_bad_function_one_param.py <== -309 | def func( -310 | a = 3 - | COM812 -311 | ): -312 | pass - | - = help: Add trailing comma - -ℹ Fix -307 307 | -308 308 | # ==> multiline_bad_function_one_param.py <== -309 309 | def func( -310 |- a = 3 - 310 |+ a = 3, -311 311 | ): -312 312 | pass -313 313 | - -COM81.py:316:10: COM812 [*] Trailing comma missing - | -315 | func( -316 | a = 3 - | COM812 -317 | ) - | - = help: Add trailing comma - -ℹ Fix -313 313 | -314 314 | -315 315 | func( -316 |- a = 3 - 316 |+ a = 3, -317 317 | ) -318 318 | -319 319 | # ==> multiline_bad_or_dict.py <== - -COM81.py:322:15: COM812 [*] Trailing comma missing - | -320 | multiline_bad_or_dict = { -321 | "good": True or False, -322 | "bad": 123 - | COM812 -323 | } - | - = help: Add trailing comma - -ℹ Fix -319 319 | # ==> multiline_bad_or_dict.py <== -320 320 | multiline_bad_or_dict = { -321 321 | "good": True or False, -322 |- "bad": 123 - 322 |+ "bad": 123, -323 323 | } -324 324 | -325 325 | # ==> multiline_good_dict.py <== - -COM81.py:368:15: COM812 [*] Trailing comma missing - | -366 | multiline_index_access[ -367 | "probably fine", -368 | "not good" - | COM812 -369 | ] - | - = help: Add trailing comma - -ℹ Fix -365 365 | -366 366 | multiline_index_access[ -367 367 | "probably fine", -368 |- "not good" - 368 |+ "not good", -369 369 | ] -370 370 | -371 371 | multiline_index_access[ - -COM81.py:375:15: COM812 [*] Trailing comma missing - | -373 | "fine", -374 | : -375 | "not good" - | COM812 -376 | ] - | - = help: Add trailing comma - -ℹ Fix -372 372 | "fine", -373 373 | "fine", -374 374 | : -375 |- "not good" - 375 |+ "not good", -376 376 | ] -377 377 | -378 378 | # ==> multiline_string.py <== - -COM81.py:404:15: COM812 [*] Trailing comma missing - | -402 | "fine" -403 | : -404 | "not fine" - | COM812 -405 | ] - | - = help: Add trailing comma - -ℹ Fix -401 401 | "fine", -402 402 | "fine" -403 403 | : -404 |- "not fine" - 404 |+ "not fine", -405 405 | ] -406 406 | -407 407 | multiline_index_access[ - -COM81.py:432:15: COM812 [*] Trailing comma missing - | -430 | : -431 | "fine", -432 | "not fine" - | COM812 -433 | ] - | - = help: Add trailing comma - -ℹ Fix -429 429 | "fine" -430 430 | : -431 431 | "fine", -432 |- "not fine" - 432 |+ "not fine", -433 433 | ] -434 434 | -435 435 | multiline_index_access[ - -COM81.py:485:21: COM819 [*] Trailing comma prohibited - | -484 | # ==> prohibited.py <== -485 | foo = ['a', 'b', 'c',] - | ^ COM819 -486 | -487 | bar = { a: b,} - | - = help: Remove trailing comma - -ℹ Fix -482 482 | ) -483 483 | -484 484 | # ==> prohibited.py <== -485 |-foo = ['a', 'b', 'c',] - 485 |+foo = ['a', 'b', 'c'] -486 486 | -487 487 | bar = { a: b,} -488 488 | - -COM81.py:487:13: COM819 [*] Trailing comma prohibited - | -485 | foo = ['a', 'b', 'c',] -486 | -487 | bar = { a: b,} - | ^ COM819 -488 | -489 | def bah(ham, spam,): - | - = help: Remove trailing comma - -ℹ Fix -484 484 | # ==> prohibited.py <== -485 485 | foo = ['a', 'b', 'c',] -486 486 | -487 |-bar = { a: b,} - 487 |+bar = { a: b} -488 488 | -489 489 | def bah(ham, spam,): -490 490 | pass - -COM81.py:489:18: COM819 [*] Trailing comma prohibited - | -487 | bar = { a: b,} -488 | -489 | def bah(ham, spam,): - | ^ COM819 -490 | pass - | - = help: Remove trailing comma - -ℹ Fix -486 486 | -487 487 | bar = { a: b,} -488 488 | -489 |-def bah(ham, spam,): - 489 |+def bah(ham, spam): -490 490 | pass -491 491 | -492 492 | (0,) - -COM81.py:494:6: COM819 [*] Trailing comma prohibited - | -492 | (0,) -493 | -494 | (0, 1,) - | ^ COM819 -495 | -496 | foo = ['a', 'b', 'c', ] - | - = help: Remove trailing comma - -ℹ Fix -491 491 | -492 492 | (0,) -493 493 | -494 |-(0, 1,) - 494 |+(0, 1) -495 495 | -496 496 | foo = ['a', 'b', 'c', ] -497 497 | - -COM81.py:496:21: COM819 [*] Trailing comma prohibited - | -494 | (0, 1,) -495 | -496 | foo = ['a', 'b', 'c', ] - | ^ COM819 -497 | -498 | bar = { a: b, } - | - = help: Remove trailing comma - -ℹ Fix -493 493 | -494 494 | (0, 1,) -495 495 | -496 |-foo = ['a', 'b', 'c', ] - 496 |+foo = ['a', 'b', 'c' ] -497 497 | -498 498 | bar = { a: b, } -499 499 | - -COM81.py:498:13: COM819 [*] Trailing comma prohibited - | -496 | foo = ['a', 'b', 'c', ] -497 | -498 | bar = { a: b, } - | ^ COM819 -499 | -500 | def bah(ham, spam, ): - | - = help: Remove trailing comma - -ℹ Fix -495 495 | -496 496 | foo = ['a', 'b', 'c', ] -497 497 | -498 |-bar = { a: b, } - 498 |+bar = { a: b } -499 499 | -500 500 | def bah(ham, spam, ): -501 501 | pass - -COM81.py:500:18: COM819 [*] Trailing comma prohibited - | -498 | bar = { a: b, } -499 | -500 | def bah(ham, spam, ): - | ^ COM819 -501 | pass - | - = help: Remove trailing comma - -ℹ Fix -497 497 | -498 498 | bar = { a: b, } -499 499 | -500 |-def bah(ham, spam, ): - 500 |+def bah(ham, spam ): -501 501 | pass -502 502 | -503 503 | (0, ) - -COM81.py:505:6: COM819 [*] Trailing comma prohibited - | -503 | (0, ) -504 | -505 | (0, 1, ) - | ^ COM819 -506 | -507 | image[:, :, 0] - | - = help: Remove trailing comma - -ℹ Fix -502 502 | -503 503 | (0, ) -504 504 | -505 |-(0, 1, ) - 505 |+(0, 1 ) -506 506 | -507 507 | image[:, :, 0] -508 508 | - -COM81.py:511:10: COM819 [*] Trailing comma prohibited - | -509 | image[:,] -510 | -511 | image[:,:,] - | ^ COM819 -512 | -513 | lambda x, : - | - = help: Remove trailing comma - -ℹ Fix -508 508 | -509 509 | image[:,] -510 510 | -511 |-image[:,:,] - 511 |+image[:,:] -512 512 | -513 513 | lambda x, : -514 514 | - -COM81.py:513:9: COM819 [*] Trailing comma prohibited - | -511 | image[:,:,] -512 | -513 | lambda x, : - | ^ COM819 -514 | -515 | # ==> unpack.py <== - | - = help: Remove trailing comma - -ℹ Fix -510 510 | -511 511 | image[:,:,] -512 512 | -513 |-lambda x, : - 513 |+lambda x : -514 514 | -515 515 | # ==> unpack.py <== -516 516 | def function( - -COM81.py:519:13: COM812 [*] Trailing comma missing - | -517 | foo, -518 | bar, -519 | **kwargs - | COM812 -520 | ): -521 | pass - | - = help: Add trailing comma - -ℹ Fix -516 516 | def function( -517 517 | foo, -518 518 | bar, -519 |- **kwargs - 519 |+ **kwargs, -520 520 | ): -521 521 | pass -522 522 | - -COM81.py:526:10: COM812 [*] Trailing comma missing - | -524 | foo, -525 | bar, -526 | *args - | COM812 -527 | ): -528 | pass - | - = help: Add trailing comma - -ℹ Fix -523 523 | def function( -524 524 | foo, -525 525 | bar, -526 |- *args - 526 |+ *args, -527 527 | ): -528 528 | pass -529 529 | - -COM81.py:534:16: COM812 [*] Trailing comma missing - | -532 | bar, -533 | *args, -534 | extra_kwarg - | COM812 -535 | ): -536 | pass - | - = help: Add trailing comma - -ℹ Fix -531 531 | foo, -532 532 | bar, -533 533 | *args, -534 |- extra_kwarg - 534 |+ extra_kwarg, -535 535 | ): -536 536 | pass -537 537 | - -COM81.py:541:13: COM812 [*] Trailing comma missing - | -539 | foo, -540 | bar, -541 | **kwargs - | COM812 -542 | ) - | - = help: Add trailing comma - -ℹ Fix -538 538 | result = function( -539 539 | foo, -540 540 | bar, -541 |- **kwargs - 541 |+ **kwargs, -542 542 | ) -543 543 | -544 544 | result = function( - -COM81.py:547:24: COM812 [*] Trailing comma missing - | -545 | foo, -546 | bar, -547 | **not_called_kwargs - | COM812 -548 | ) - | - = help: Add trailing comma - -ℹ Fix -544 544 | result = function( -545 545 | foo, -546 546 | bar, -547 |- **not_called_kwargs - 547 |+ **not_called_kwargs, -548 548 | ) -549 549 | -550 550 | def foo( - -COM81.py:554:15: COM812 [*] Trailing comma missing - | -552 | spam, -553 | *args, -554 | kwarg_only - | COM812 -555 | ): -556 | pass - | - = help: Add trailing comma - -ℹ Fix -551 551 | ham, -552 552 | spam, -553 553 | *args, -554 |- kwarg_only - 554 |+ kwarg_only, -555 555 | ): -556 556 | pass -557 557 | - -COM81.py:561:13: COM812 [*] Trailing comma missing - | -560 | foo( -561 | **kwargs - | COM812 -562 | ) - | - = help: Add trailing comma - -ℹ Fix -558 558 | # In python 3.5 if it's not a function def, commas are mandatory. -559 559 | -560 560 | foo( -561 |- **kwargs - 561 |+ **kwargs, -562 562 | ) -563 563 | -564 564 | { - -COM81.py:565:13: COM812 [*] Trailing comma missing - | -564 | { -565 | **kwargs - | COM812 -566 | } - | - = help: Add trailing comma - -ℹ Fix -562 562 | ) -563 563 | -564 564 | { -565 |- **kwargs - 565 |+ **kwargs, -566 566 | } -567 567 | -568 568 | ( - -COM81.py:573:10: COM812 [*] Trailing comma missing - | -572 | { -573 | *args - | COM812 -574 | } - | - = help: Add trailing comma - -ℹ Fix -570 570 | ) -571 571 | -572 572 | { -573 |- *args - 573 |+ *args, -574 574 | } -575 575 | -576 576 | [ - -COM81.py:577:10: COM812 [*] Trailing comma missing - | -576 | [ -577 | *args - | COM812 -578 | ] - | - = help: Add trailing comma - -ℹ Fix -574 574 | } -575 575 | -576 576 | [ -577 |- *args - 577 |+ *args, -578 578 | ] -579 579 | -580 580 | def foo( - -COM81.py:583:10: COM812 [*] Trailing comma missing - | -581 | ham, -582 | spam, -583 | *args - | COM812 -584 | ): -585 | pass - | - = help: Add trailing comma - -ℹ Fix -580 580 | def foo( -581 581 | ham, -582 582 | spam, -583 |- *args - 583 |+ *args, -584 584 | ): -585 585 | pass -586 586 | - -COM81.py:590:13: COM812 [*] Trailing comma missing - | -588 | ham, -589 | spam, -590 | **kwargs - | COM812 -591 | ): -592 | pass - | - = help: Add trailing comma - -ℹ Fix -587 587 | def foo( -588 588 | ham, -589 589 | spam, -590 |- **kwargs - 590 |+ **kwargs, -591 591 | ): -592 592 | pass -593 593 | - -COM81.py:598:15: COM812 [*] Trailing comma missing - | -596 | spam, -597 | *args, -598 | kwarg_only - | COM812 -599 | ): -600 | pass - | - = help: Add trailing comma - -ℹ Fix -595 595 | ham, -596 596 | spam, -597 597 | *args, -598 |- kwarg_only - 598 |+ kwarg_only, -599 599 | ): -600 600 | pass -601 601 | - -COM81.py:627:20: COM812 [*] Trailing comma missing - | -625 | foo, -626 | bar, -627 | **{'ham': spam} - | COM812 -628 | ) - | - = help: Add trailing comma - -ℹ Fix -624 624 | result = function( -625 625 | foo, -626 626 | bar, -627 |- **{'ham': spam} - 627 |+ **{'ham': spam}, -628 628 | ) -629 629 | -630 630 | # Make sure the COM812 and UP034 rules don't autofix simultaneously and cause a syntax error. - -COM81.py:632:42: COM812 [*] Trailing comma missing - | -630 | # Make sure the COM812 and UP034 rules don't autofix simultaneously and cause a syntax error. -631 | the_first_one = next( -632 | (i for i in range(10) if i // 2 == 0) # COM812 fix should include the final bracket - | COM812 -633 | ) - | - = help: Add trailing comma - -ℹ Fix -629 629 | -630 630 | # Make sure the COM812 and UP034 rules don't autofix simultaneously and cause a syntax error. -631 631 | the_first_one = next( -632 |- (i for i in range(10) if i // 2 == 0) # COM812 fix should include the final bracket - 632 |+ (i for i in range(10) if i // 2 == 0), # COM812 fix should include the final bracket -633 633 | ) -634 634 | -635 635 | foo = namedtuple( - - diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C400_C400.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C400_C400.py.snap deleted file mode 100644 index af696b6d36..0000000000 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C400_C400.py.snap +++ /dev/null @@ -1,42 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_comprehensions/mod.rs ---- -C400.py:1:5: C400 [*] Unnecessary generator (rewrite as a `list` comprehension) - | -1 | x = list(x for x in range(3)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ C400 -2 | x = list( -3 | x for x in range(3) - | - = help: Rewrite as a `list` comprehension - -ℹ Suggested fix -1 |-x = list(x for x in range(3)) - 1 |+x = [x for x in range(3)] -2 2 | x = list( -3 3 | x for x in range(3) -4 4 | ) - -C400.py:2:5: C400 [*] Unnecessary generator (rewrite as a `list` comprehension) - | -1 | x = list(x for x in range(3)) -2 | x = list( - | _____^ -3 | | x for x in range(3) -4 | | ) - | |_^ C400 - | - = help: Rewrite as a `list` comprehension - -ℹ Suggested fix -1 1 | x = list(x for x in range(3)) -2 |-x = list( - 2 |+x = [ -3 3 | x for x in range(3) -4 |-) - 4 |+] -5 5 | -6 6 | -7 7 | def list(*args, **kwargs): - - diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C401_C401.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C401_C401.py.snap deleted file mode 100644 index 911c26f903..0000000000 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C401_C401.py.snap +++ /dev/null @@ -1,255 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_comprehensions/mod.rs ---- -C401.py:1:5: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) - | -1 | x = set(x for x in range(3)) - | ^^^^^^^^^^^^^^^^^^^^^^^^ C401 -2 | x = set(x for x in range(3)) -3 | y = f"{set(a if a < 6 else 0 for a in range(3))}" - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -1 |-x = set(x for x in range(3)) - 1 |+x = {x for x in range(3)} -2 2 | x = set(x for x in range(3)) -3 3 | y = f"{set(a if a < 6 else 0 for a in range(3))}" -4 4 | _ = "{}".format(set(a if a < 6 else 0 for a in range(3))) - -C401.py:2:5: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) - | -1 | x = set(x for x in range(3)) -2 | x = set(x for x in range(3)) - | ^^^^^^^^^^^^^^^^^^^^^^^^ C401 -3 | y = f"{set(a if a < 6 else 0 for a in range(3))}" -4 | _ = "{}".format(set(a if a < 6 else 0 for a in range(3))) - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -1 1 | x = set(x for x in range(3)) -2 |-x = set(x for x in range(3)) - 2 |+x = {x for x in range(3)} -3 3 | y = f"{set(a if a < 6 else 0 for a in range(3))}" -4 4 | _ = "{}".format(set(a if a < 6 else 0 for a in range(3))) -5 5 | print(f"Hello {set(a for a in range(3))} World") - -C401.py:3:8: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) - | -1 | x = set(x for x in range(3)) -2 | x = set(x for x in range(3)) -3 | y = f"{set(a if a < 6 else 0 for a in range(3))}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C401 -4 | _ = "{}".format(set(a if a < 6 else 0 for a in range(3))) -5 | print(f"Hello {set(a for a in range(3))} World") - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -1 1 | x = set(x for x in range(3)) -2 2 | x = set(x for x in range(3)) -3 |-y = f"{set(a if a < 6 else 0 for a in range(3))}" - 3 |+y = f"{ {a if a < 6 else 0 for a in range(3)} }" -4 4 | _ = "{}".format(set(a if a < 6 else 0 for a in range(3))) -5 5 | print(f"Hello {set(a for a in range(3))} World") -6 6 | - -C401.py:4:17: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) - | -2 | x = set(x for x in range(3)) -3 | y = f"{set(a if a < 6 else 0 for a in range(3))}" -4 | _ = "{}".format(set(a if a < 6 else 0 for a in range(3))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C401 -5 | print(f"Hello {set(a for a in range(3))} World") - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -1 1 | x = set(x for x in range(3)) -2 2 | x = set(x for x in range(3)) -3 3 | y = f"{set(a if a < 6 else 0 for a in range(3))}" -4 |-_ = "{}".format(set(a if a < 6 else 0 for a in range(3))) - 4 |+_ = "{}".format({a if a < 6 else 0 for a in range(3)}) -5 5 | print(f"Hello {set(a for a in range(3))} World") -6 6 | -7 7 | - -C401.py:5:16: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) - | -3 | y = f"{set(a if a < 6 else 0 for a in range(3))}" -4 | _ = "{}".format(set(a if a < 6 else 0 for a in range(3))) -5 | print(f"Hello {set(a for a in range(3))} World") - | ^^^^^^^^^^^^^^^^^^^^^^^^ C401 - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -2 2 | x = set(x for x in range(3)) -3 3 | y = f"{set(a if a < 6 else 0 for a in range(3))}" -4 4 | _ = "{}".format(set(a if a < 6 else 0 for a in range(3))) -5 |-print(f"Hello {set(a for a in range(3))} World") - 5 |+print(f"Hello { {a for a in range(3)} } World") -6 6 | -7 7 | -8 8 | def f(x): - -C401.py:12:16: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) - | -12 | print(f'Hello {set(a for a in "abc")} World') - | ^^^^^^^^^^^^^^^^^^^^^ C401 -13 | print(f"Hello {set(a for a in 'abc')} World") -14 | print(f"Hello {set(f(a) for a in 'abc')} World") - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -9 9 | return x -10 10 | -11 11 | -12 |-print(f'Hello {set(a for a in "abc")} World') - 12 |+print(f'Hello { {a for a in "abc"} } World') -13 13 | print(f"Hello {set(a for a in 'abc')} World") -14 14 | print(f"Hello {set(f(a) for a in 'abc')} World") -15 15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") - -C401.py:13:16: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) - | -12 | print(f'Hello {set(a for a in "abc")} World') -13 | print(f"Hello {set(a for a in 'abc')} World") - | ^^^^^^^^^^^^^^^^^^^^^ C401 -14 | print(f"Hello {set(f(a) for a in 'abc')} World") -15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -10 10 | -11 11 | -12 12 | print(f'Hello {set(a for a in "abc")} World') -13 |-print(f"Hello {set(a for a in 'abc')} World") - 13 |+print(f"Hello { {a for a in 'abc'} } World") -14 14 | print(f"Hello {set(f(a) for a in 'abc')} World") -15 15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") -16 16 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") - -C401.py:14:16: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) - | -12 | print(f'Hello {set(a for a in "abc")} World') -13 | print(f"Hello {set(a for a in 'abc')} World") -14 | print(f"Hello {set(f(a) for a in 'abc')} World") - | ^^^^^^^^^^^^^^^^^^^^^^^^ C401 -15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") -16 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -11 11 | -12 12 | print(f'Hello {set(a for a in "abc")} World') -13 13 | print(f"Hello {set(a for a in 'abc')} World") -14 |-print(f"Hello {set(f(a) for a in 'abc')} World") - 14 |+print(f"Hello { {f(a) for a in 'abc'} } World") -15 15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") -16 16 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") -17 17 | - -C401.py:15:10: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) - | -13 | print(f"Hello {set(a for a in 'abc')} World") -14 | print(f"Hello {set(f(a) for a in 'abc')} World") -15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") - | ^^^^^^^^^^^^^^^^^^^^^ C401 -16 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -12 12 | print(f'Hello {set(a for a in "abc")} World') -13 13 | print(f"Hello {set(a for a in 'abc')} World") -14 14 | print(f"Hello {set(f(a) for a in 'abc')} World") -15 |-print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") - 15 |+print(f"{ {a for a in 'abc'} - set(a for a in 'ab')}") -16 16 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") -17 17 | -18 18 | # The fix generated for this diagnostic is incorrect, as we add additional space - -C401.py:15:34: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) - | -13 | print(f"Hello {set(a for a in 'abc')} World") -14 | print(f"Hello {set(f(a) for a in 'abc')} World") -15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") - | ^^^^^^^^^^^^^^^^^^^^ C401 -16 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -12 12 | print(f'Hello {set(a for a in "abc")} World') -13 13 | print(f"Hello {set(a for a in 'abc')} World") -14 14 | print(f"Hello {set(f(a) for a in 'abc')} World") -15 |-print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") - 15 |+print(f"{set(a for a in 'abc') - {a for a in 'ab'} }") -16 16 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") -17 17 | -18 18 | # The fix generated for this diagnostic is incorrect, as we add additional space - -C401.py:16:11: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) - | -14 | print(f"Hello {set(f(a) for a in 'abc')} World") -15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") -16 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") - | ^^^^^^^^^^^^^^^^^^^^^ C401 -17 | -18 | # The fix generated for this diagnostic is incorrect, as we add additional space - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -13 13 | print(f"Hello {set(a for a in 'abc')} World") -14 14 | print(f"Hello {set(f(a) for a in 'abc')} World") -15 15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") -16 |-print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") - 16 |+print(f"{ {a for a in 'abc'} - set(a for a in 'ab') }") -17 17 | -18 18 | # The fix generated for this diagnostic is incorrect, as we add additional space -19 19 | # around the set comprehension. - -C401.py:16:35: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) - | -14 | print(f"Hello {set(f(a) for a in 'abc')} World") -15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") -16 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") - | ^^^^^^^^^^^^^^^^^^^^ C401 -17 | -18 | # The fix generated for this diagnostic is incorrect, as we add additional space - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -13 13 | print(f"Hello {set(a for a in 'abc')} World") -14 14 | print(f"Hello {set(f(a) for a in 'abc')} World") -15 15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") -16 |-print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") - 16 |+print(f"{ set(a for a in 'abc') - {a for a in 'ab'} }") -17 17 | -18 18 | # The fix generated for this diagnostic is incorrect, as we add additional space -19 19 | # around the set comprehension. - -C401.py:20:12: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) - | -18 | # The fix generated for this diagnostic is incorrect, as we add additional space -19 | # around the set comprehension. -20 | print(f"{ {set(a for a in 'abc')} }") - | ^^^^^^^^^^^^^^^^^^^^^ C401 - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -17 17 | -18 18 | # The fix generated for this diagnostic is incorrect, as we add additional space -19 19 | # around the set comprehension. -20 |-print(f"{ {set(a for a in 'abc')} }") - 20 |+print(f"{ { {a for a in 'abc'} } }") - - diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C402_C402.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C402_C402.py.snap deleted file mode 100644 index 29edd8c8a1..0000000000 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C402_C402.py.snap +++ /dev/null @@ -1,269 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_comprehensions/mod.rs ---- -C402.py:1:1: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) - | -1 | dict((x, x) for x in range(3)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 -2 | dict( -3 | (x, x) for x in range(3) - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -1 |-dict((x, x) for x in range(3)) - 1 |+{x: x for x in range(3)} -2 2 | dict( -3 3 | (x, x) for x in range(3) -4 4 | ) - -C402.py:2:1: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) - | -1 | dict((x, x) for x in range(3)) -2 | / dict( -3 | | (x, x) for x in range(3) -4 | | ) - | |_^ C402 -5 | dict(((x, x) for x in range(3)), z=3) -6 | y = f'{dict((x, x) for x in range(3))}' - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -1 1 | dict((x, x) for x in range(3)) -2 |-dict( -3 |- (x, x) for x in range(3) -4 |-) - 2 |+{ - 3 |+ x: x for x in range(3) - 4 |+} -5 5 | dict(((x, x) for x in range(3)), z=3) -6 6 | y = f'{dict((x, x) for x in range(3))}' -7 7 | print(f'Hello {dict((x, x) for x in range(3))} World') - -C402.py:6:8: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) - | -4 | ) -5 | dict(((x, x) for x in range(3)), z=3) -6 | y = f'{dict((x, x) for x in range(3))}' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 -7 | print(f'Hello {dict((x, x) for x in range(3))} World') -8 | print(f"Hello {dict((x, x) for x in 'abc')} World") - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -3 3 | (x, x) for x in range(3) -4 4 | ) -5 5 | dict(((x, x) for x in range(3)), z=3) -6 |-y = f'{dict((x, x) for x in range(3))}' - 6 |+y = f'{ {x: x for x in range(3)} }' -7 7 | print(f'Hello {dict((x, x) for x in range(3))} World') -8 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") -9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') - -C402.py:7:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) - | -5 | dict(((x, x) for x in range(3)), z=3) -6 | y = f'{dict((x, x) for x in range(3))}' -7 | print(f'Hello {dict((x, x) for x in range(3))} World') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 -8 | print(f"Hello {dict((x, x) for x in 'abc')} World") -9 | print(f'Hello {dict((x, x) for x in "abc")} World') - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -4 4 | ) -5 5 | dict(((x, x) for x in range(3)), z=3) -6 6 | y = f'{dict((x, x) for x in range(3))}' -7 |-print(f'Hello {dict((x, x) for x in range(3))} World') - 7 |+print(f'Hello { {x: x for x in range(3)} } World') -8 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") -9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') -10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') - -C402.py:8:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) - | - 6 | y = f'{dict((x, x) for x in range(3))}' - 7 | print(f'Hello {dict((x, x) for x in range(3))} World') - 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 - 9 | print(f'Hello {dict((x, x) for x in "abc")} World') -10 | print(f'Hello {dict((x,x) for x in "abc")} World') - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -5 5 | dict(((x, x) for x in range(3)), z=3) -6 6 | y = f'{dict((x, x) for x in range(3))}' -7 7 | print(f'Hello {dict((x, x) for x in range(3))} World') -8 |-print(f"Hello {dict((x, x) for x in 'abc')} World") - 8 |+print(f"Hello { {x: x for x in 'abc'} } World") -9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') -10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') -11 11 | - -C402.py:9:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) - | - 7 | print(f'Hello {dict((x, x) for x in range(3))} World') - 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") - 9 | print(f'Hello {dict((x, x) for x in "abc")} World') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 -10 | print(f'Hello {dict((x,x) for x in "abc")} World') - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -6 6 | y = f'{dict((x, x) for x in range(3))}' -7 7 | print(f'Hello {dict((x, x) for x in range(3))} World') -8 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") -9 |-print(f'Hello {dict((x, x) for x in "abc")} World') - 9 |+print(f'Hello { {x: x for x in "abc"} } World') -10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') -11 11 | -12 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' - -C402.py:10:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) - | - 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") - 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 | -12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -7 7 | print(f'Hello {dict((x, x) for x in range(3))} World') -8 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") -9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') -10 |-print(f'Hello {dict((x,x) for x in "abc")} World') - 10 |+print(f'Hello { {x: x for x in "abc"} } World') -11 11 | -12 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' -13 13 | f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' - -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 | -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)) }' - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') -10 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))}' - 12 |+f'{ {x: x for x in range(3)} | dict((x, x) for x in range(3))}' -13 13 | f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' -14 14 | -15 15 | def f(x): - -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 | -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)) }' - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') -10 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))}' - 12 |+f'{dict((x, x) for x in range(3)) | {x: x for x in range(3)} }' -13 13 | f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' -14 14 | -15 15 | def f(x): - -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 | -15 | def f(x): - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') -11 11 | -12 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)) }' - 13 |+f'{ {x: x for x in range(3)} | dict((x, x) for x in range(3)) }' -14 14 | -15 15 | def f(x): -16 16 | return x - -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 | -15 | def f(x): - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') -11 11 | -12 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)) }' - 13 |+f'{ dict((x, x) for x in range(3)) | {x: x for x in range(3)} }' -14 14 | -15 15 | def f(x): -16 16 | return x - -C402.py:18:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) - | -16 | return x -17 | -18 | print(f'Hello {dict((x,f(x)) for x in "abc")} World') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 -19 | -20 | # Regression test for: https://github.com/astral-sh/ruff/issues/7086 - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -15 15 | def f(x): -16 16 | return x -17 17 | -18 |-print(f'Hello {dict((x,f(x)) for x in "abc")} World') - 18 |+print(f'Hello { {x: f(x) for x in "abc"} } World') -19 19 | -20 20 | # Regression test for: https://github.com/astral-sh/ruff/issues/7086 -21 21 | dict((k,v)for k,v in d.iteritems() if k in only_args) - -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 | -23 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458940 - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -18 18 | print(f'Hello {dict((x,f(x)) for x in "abc")} World') -19 19 | -20 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) - 21 |+{k: v for k,v in d.iteritems() if k in only_args} -22 22 | -23 23 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458940 -24 24 | dict((*v, k) for k, v in enumerate(calendar.month_abbr)) - - diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C403_C403.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C403_C403.py.snap deleted file mode 100644 index 62946f9d58..0000000000 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C403_C403.py.snap +++ /dev/null @@ -1,172 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_comprehensions/mod.rs ---- -C403.py:1:5: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) - | -1 | s = set([x for x in range(3)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ C403 -2 | s = set( -3 | [x for x in range(3)] - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -1 |-s = set([x for x in range(3)]) - 1 |+s = {x for x in range(3)} -2 2 | s = set( -3 3 | [x for x in range(3)] -4 4 | ) - -C403.py:2:5: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) - | -1 | s = set([x for x in range(3)]) -2 | s = set( - | _____^ -3 | | [x for x in range(3)] -4 | | ) - | |_^ C403 -5 | -6 | s = f"{set([x for x in 'ab'])}" - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -1 1 | s = set([x for x in range(3)]) -2 |-s = set( -3 |- [x for x in range(3)] -4 |-) - 2 |+s = { - 3 |+ x for x in range(3) - 4 |+} -5 5 | -6 6 | s = f"{set([x for x in 'ab'])}" -7 7 | s = f'{set([x for x in "ab"])}' - -C403.py:6:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) - | -4 | ) -5 | -6 | s = f"{set([x for x in 'ab'])}" - | ^^^^^^^^^^^^^^^^^^^^^^ C403 -7 | s = f'{set([x for x in "ab"])}' - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -3 3 | [x for x in range(3)] -4 4 | ) -5 5 | -6 |-s = f"{set([x for x in 'ab'])}" - 6 |+s = f"{ {x for x in 'ab'} }" -7 7 | s = f'{set([x for x in "ab"])}' -8 8 | -9 9 | def f(x): - -C403.py:7:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) - | -6 | s = f"{set([x for x in 'ab'])}" -7 | s = f'{set([x for x in "ab"])}' - | ^^^^^^^^^^^^^^^^^^^^^^ C403 -8 | -9 | def f(x): - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -4 4 | ) -5 5 | -6 6 | s = f"{set([x for x in 'ab'])}" -7 |-s = f'{set([x for x in "ab"])}' - 7 |+s = f'{ {x for x in "ab"} }' -8 8 | -9 9 | def f(x): -10 10 | return x - -C403.py:12:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) - | -10 | return x -11 | -12 | s = f"{set([f(x) for x in 'ab'])}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^ C403 -13 | -14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -9 9 | def f(x): -10 10 | return x -11 11 | -12 |-s = f"{set([f(x) for x in 'ab'])}" - 12 |+s = f"{ {f(x) for x in 'ab'} }" -13 13 | -14 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" -15 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" - -C403.py:14:9: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) - | -12 | s = f"{set([f(x) for x in 'ab'])}" -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'])}" - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -11 11 | -12 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']) }" - 14 |+s = f"{ {x for x in 'ab'} | set([x for x in 'ab']) }" -15 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" - -C403.py:14:34: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) - | -12 | s = f"{set([f(x) for x in 'ab'])}" -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'])}" - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -11 11 | -12 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']) }" - 14 |+s = f"{ set([x for x in 'ab']) | {x for x in 'ab'} }" -15 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" - -C403.py:15:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) - | -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 - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -12 12 | s = f"{set([f(x) for x in 'ab'])}" -13 13 | -14 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'])}" - 15 |+s = f"{ {x for x in 'ab'} | set([x for x in 'ab'])}" - -C403.py:15:33: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) - | -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 - | - = help: Rewrite as a `set` comprehension - -ℹ Suggested fix -12 12 | s = f"{set([f(x) for x in 'ab'])}" -13 13 | -14 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'])}" - 15 |+s = f"{set([x for x in 'ab']) | {x for x in 'ab'} }" - - diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C404_C404.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C404_C404.py.snap deleted file mode 100644 index 8e4eb5a2ed..0000000000 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C404_C404.py.snap +++ /dev/null @@ -1,196 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_comprehensions/mod.rs ---- -C404.py:1:1: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) - | -1 | dict([(i, i) for i in range(3)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 -2 | dict([(i, i) for i in range(3)], z=4) - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -1 |-dict([(i, i) for i in range(3)]) - 1 |+{i: i for i in range(3)} -2 2 | dict([(i, i) for i in range(3)], z=4) -3 3 | -4 4 | def f(x): - -C404.py:7:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) - | -5 | return x -6 | -7 | f'{dict([(s,s) for s in "ab"])}' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 -8 | f"{dict([(s,s) for s in 'ab'])}" -9 | f"{dict([(s, s) for s in 'ab'])}" - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -4 4 | def f(x): -5 5 | return x -6 6 | -7 |-f'{dict([(s,s) for s in "ab"])}' - 7 |+f'{ {s: s for s in "ab"} }' -8 8 | f"{dict([(s,s) for s in 'ab'])}" -9 9 | f"{dict([(s, s) for s in 'ab'])}" -10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" - -C404.py:8:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) - | - 7 | f'{dict([(s,s) for s in "ab"])}' - 8 | f"{dict([(s,s) for s in 'ab'])}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 - 9 | f"{dict([(s, s) for s in 'ab'])}" -10 | f"{dict([(s,f(s)) for s in 'ab'])}" - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -5 5 | return x -6 6 | -7 7 | f'{dict([(s,s) for s in "ab"])}' -8 |-f"{dict([(s,s) for s in 'ab'])}" - 8 |+f"{ {s: s for s in 'ab'} }" -9 9 | f"{dict([(s, s) for s in 'ab'])}" -10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" -11 11 | - -C404.py:9:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) - | - 7 | f'{dict([(s,s) for s in "ab"])}' - 8 | f"{dict([(s,s) for s in 'ab'])}" - 9 | f"{dict([(s, s) for s in 'ab'])}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 -10 | f"{dict([(s,f(s)) for s in 'ab'])}" - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -6 6 | -7 7 | f'{dict([(s,s) for s in "ab"])}' -8 8 | f"{dict([(s,s) for s in 'ab'])}" -9 |-f"{dict([(s, s) for s in 'ab'])}" - 9 |+f"{ {s: s for s in 'ab'} }" -10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" -11 11 | -12 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' - -C404.py:10:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) - | - 8 | f"{dict([(s,s) for s in 'ab'])}" - 9 | f"{dict([(s, s) for s in 'ab'])}" -10 | f"{dict([(s,f(s)) for s in 'ab'])}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 -11 | -12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -7 7 | f'{dict([(s,s) for s in "ab"])}' -8 8 | f"{dict([(s,s) for s in 'ab'])}" -9 9 | f"{dict([(s, s) for s in 'ab'])}" -10 |-f"{dict([(s,f(s)) for s in 'ab'])}" - 10 |+f"{ {s: f(s) for s in 'ab'} }" -11 11 | -12 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' -13 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' - -C404.py:12:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) - | -10 | f"{dict([(s,f(s)) for s in 'ab'])}" -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"]) }' - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -9 9 | f"{dict([(s, s) for s in 'ab'])}" -10 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"])}' - 12 |+f'{ {s: s for s in "ab"} | dict([(s,s) for s in "ab"])}' -13 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' -14 14 | -15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 - -C404.py:12:34: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) - | -10 | f"{dict([(s,f(s)) for s in 'ab'])}" -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"]) }' - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -9 9 | f"{dict([(s, s) for s in 'ab'])}" -10 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"])}' - 12 |+f'{dict([(s,s) for s in "ab"]) | {s: s for s in "ab"} }' -13 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' -14 14 | -15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 - -C404.py:13:5: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) - | -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 | -15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" -11 11 | -12 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"]) }' - 13 |+f'{ {s: s for s in "ab"} | dict([(s,s) for s in "ab"]) }' -14 14 | -15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 -16 16 | saved.append(dict([(k, v)for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]])) - -C404.py:13:35: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) - | -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 | -15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" -11 11 | -12 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"]) }' - 13 |+f'{ dict([(s,s) for s in "ab"]) | {s: s for s in "ab"} }' -14 14 | -15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 -16 16 | saved.append(dict([(k, v)for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]])) - -C404.py:16:14: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) - | -15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 -16 | saved.append(dict([(k, v)for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]])) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 - | - = help: Rewrite as a `dict` comprehension - -ℹ Suggested fix -13 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' -14 14 | -15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 -16 |-saved.append(dict([(k, v)for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]])) - 16 |+saved.append({k: v for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]}) - - diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C405_C405.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C405_C405.py.snap deleted file mode 100644 index ab40972046..0000000000 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C405_C405.py.snap +++ /dev/null @@ -1,413 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_comprehensions/mod.rs ---- -C405.py:1:1: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) - | -1 | set([1, 2]) - | ^^^^^^^^^^^ C405 -2 | set((1, 2)) -3 | set([]) - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -1 |-set([1, 2]) - 1 |+{1, 2} -2 2 | set((1, 2)) -3 3 | set([]) -4 4 | set(()) - -C405.py:2:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) - | -1 | set([1, 2]) -2 | set((1, 2)) - | ^^^^^^^^^^^ C405 -3 | set([]) -4 | set(()) - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -1 1 | set([1, 2]) -2 |-set((1, 2)) - 2 |+{1, 2} -3 3 | set([]) -4 4 | set(()) -5 5 | set() - -C405.py:3:1: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) - | -1 | set([1, 2]) -2 | set((1, 2)) -3 | set([]) - | ^^^^^^^ C405 -4 | set(()) -5 | set() - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -1 1 | set([1, 2]) -2 2 | set((1, 2)) -3 |-set([]) - 3 |+set() -4 4 | set(()) -5 5 | set() -6 6 | set((1,)) - -C405.py:4:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) - | -2 | set((1, 2)) -3 | set([]) -4 | set(()) - | ^^^^^^^ C405 -5 | set() -6 | set((1,)) - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -1 1 | set([1, 2]) -2 2 | set((1, 2)) -3 3 | set([]) -4 |-set(()) -5 4 | set() - 5 |+set() -6 6 | set((1,)) -7 7 | set(( -8 8 | 1, - -C405.py:6:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) - | -4 | set(()) -5 | set() -6 | set((1,)) - | ^^^^^^^^^ C405 -7 | set(( -8 | 1, - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -3 3 | set([]) -4 4 | set(()) -5 5 | set() -6 |-set((1,)) - 6 |+{1} -7 7 | set(( -8 8 | 1, -9 9 | )) - -C405.py:7:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) - | - 5 | set() - 6 | set((1,)) - 7 | / set(( - 8 | | 1, - 9 | | )) - | |__^ C405 -10 | set([ -11 | 1, - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -4 4 | set(()) -5 5 | set() -6 6 | set((1,)) -7 |-set(( - 7 |+{ -8 8 | 1, -9 |-)) - 9 |+} -10 10 | set([ -11 11 | 1, -12 12 | ]) - -C405.py:10:1: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) - | - 8 | 1, - 9 | )) -10 | / set([ -11 | | 1, -12 | | ]) - | |__^ C405 -13 | set( -14 | (1,) - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -7 7 | set(( -8 8 | 1, -9 9 | )) -10 |-set([ - 10 |+{ -11 11 | 1, -12 |-]) - 12 |+} -13 13 | set( -14 14 | (1,) -15 15 | ) - -C405.py:13:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) - | -11 | 1, -12 | ]) -13 | / set( -14 | | (1,) -15 | | ) - | |_^ C405 -16 | set( -17 | [1,] - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -10 10 | set([ -11 11 | 1, -12 12 | ]) -13 |-set( -14 |- (1,) -15 |-) - 13 |+{1} -16 14 | set( -17 15 | [1,] -18 16 | ) - -C405.py:16:1: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) - | -14 | (1,) -15 | ) -16 | / set( -17 | | [1,] -18 | | ) - | |_^ C405 -19 | f"{set([1,2,3])}" -20 | f"{set(['a', 'b'])}" - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -13 13 | set( -14 14 | (1,) -15 15 | ) -16 |-set( -17 |- [1,] -18 |-) - 16 |+{1,} -19 17 | f"{set([1,2,3])}" -20 18 | f"{set(['a', 'b'])}" -21 19 | f'{set(["a", "b"])}' - -C405.py:19:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) - | -17 | [1,] -18 | ) -19 | f"{set([1,2,3])}" - | ^^^^^^^^^^^^ C405 -20 | f"{set(['a', 'b'])}" -21 | f'{set(["a", "b"])}' - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -16 16 | set( -17 17 | [1,] -18 18 | ) -19 |-f"{set([1,2,3])}" - 19 |+f"{ {1,2,3} }" -20 20 | f"{set(['a', 'b'])}" -21 21 | f'{set(["a", "b"])}' -22 22 | - -C405.py:20:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) - | -18 | ) -19 | f"{set([1,2,3])}" -20 | f"{set(['a', 'b'])}" - | ^^^^^^^^^^^^^^^ C405 -21 | f'{set(["a", "b"])}' - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -17 17 | [1,] -18 18 | ) -19 19 | f"{set([1,2,3])}" -20 |-f"{set(['a', 'b'])}" - 20 |+f"{ {'a', 'b'} }" -21 21 | f'{set(["a", "b"])}' -22 22 | -23 23 | f"{set(['a', 'b']) - set(['a'])}" - -C405.py:21:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) - | -19 | f"{set([1,2,3])}" -20 | f"{set(['a', 'b'])}" -21 | f'{set(["a", "b"])}' - | ^^^^^^^^^^^^^^^ C405 -22 | -23 | f"{set(['a', 'b']) - set(['a'])}" - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -18 18 | ) -19 19 | f"{set([1,2,3])}" -20 20 | f"{set(['a', 'b'])}" -21 |-f'{set(["a", "b"])}' - 21 |+f'{ {"a", "b"} }' -22 22 | -23 23 | f"{set(['a', 'b']) - set(['a'])}" -24 24 | f"{ set(['a', 'b']) - set(['a']) }" - -C405.py:23:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) - | -21 | f'{set(["a", "b"])}' -22 | -23 | f"{set(['a', 'b']) - set(['a'])}" - | ^^^^^^^^^^^^^^^ C405 -24 | f"{ set(['a', 'b']) - set(['a']) }" -25 | f"a {set(['a', 'b']) - set(['a'])} b" - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -20 20 | f"{set(['a', 'b'])}" -21 21 | f'{set(["a", "b"])}' -22 22 | -23 |-f"{set(['a', 'b']) - set(['a'])}" - 23 |+f"{ {'a', 'b'} - set(['a'])}" -24 24 | f"{ set(['a', 'b']) - set(['a']) }" -25 25 | f"a {set(['a', 'b']) - set(['a'])} b" -26 26 | f"a { set(['a', 'b']) - set(['a']) } b" - -C405.py:23:22: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) - | -21 | f'{set(["a", "b"])}' -22 | -23 | f"{set(['a', 'b']) - set(['a'])}" - | ^^^^^^^^^^ C405 -24 | f"{ set(['a', 'b']) - set(['a']) }" -25 | f"a {set(['a', 'b']) - set(['a'])} b" - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -20 20 | f"{set(['a', 'b'])}" -21 21 | f'{set(["a", "b"])}' -22 22 | -23 |-f"{set(['a', 'b']) - set(['a'])}" - 23 |+f"{set(['a', 'b']) - {'a'} }" -24 24 | f"{ set(['a', 'b']) - set(['a']) }" -25 25 | f"a {set(['a', 'b']) - set(['a'])} b" -26 26 | f"a { set(['a', 'b']) - set(['a']) } b" - -C405.py:24:5: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) - | -23 | f"{set(['a', 'b']) - set(['a'])}" -24 | f"{ set(['a', 'b']) - set(['a']) }" - | ^^^^^^^^^^^^^^^ C405 -25 | f"a {set(['a', 'b']) - set(['a'])} b" -26 | f"a { set(['a', 'b']) - set(['a']) } b" - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -21 21 | f'{set(["a", "b"])}' -22 22 | -23 23 | f"{set(['a', 'b']) - set(['a'])}" -24 |-f"{ set(['a', 'b']) - set(['a']) }" - 24 |+f"{ {'a', 'b'} - set(['a']) }" -25 25 | f"a {set(['a', 'b']) - set(['a'])} b" -26 26 | f"a { set(['a', 'b']) - set(['a']) } b" - -C405.py:24:23: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) - | -23 | f"{set(['a', 'b']) - set(['a'])}" -24 | f"{ set(['a', 'b']) - set(['a']) }" - | ^^^^^^^^^^ C405 -25 | f"a {set(['a', 'b']) - set(['a'])} b" -26 | f"a { set(['a', 'b']) - set(['a']) } b" - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -21 21 | f'{set(["a", "b"])}' -22 22 | -23 23 | f"{set(['a', 'b']) - set(['a'])}" -24 |-f"{ set(['a', 'b']) - set(['a']) }" - 24 |+f"{ set(['a', 'b']) - {'a'} }" -25 25 | f"a {set(['a', 'b']) - set(['a'])} b" -26 26 | f"a { set(['a', 'b']) - set(['a']) } b" - -C405.py:25:6: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) - | -23 | f"{set(['a', 'b']) - set(['a'])}" -24 | f"{ set(['a', 'b']) - set(['a']) }" -25 | f"a {set(['a', 'b']) - set(['a'])} b" - | ^^^^^^^^^^^^^^^ C405 -26 | f"a { set(['a', 'b']) - set(['a']) } b" - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -22 22 | -23 23 | f"{set(['a', 'b']) - set(['a'])}" -24 24 | f"{ set(['a', 'b']) - set(['a']) }" -25 |-f"a {set(['a', 'b']) - set(['a'])} b" - 25 |+f"a { {'a', 'b'} - set(['a'])} b" -26 26 | f"a { set(['a', 'b']) - set(['a']) } b" - -C405.py:25:24: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) - | -23 | f"{set(['a', 'b']) - set(['a'])}" -24 | f"{ set(['a', 'b']) - set(['a']) }" -25 | f"a {set(['a', 'b']) - set(['a'])} b" - | ^^^^^^^^^^ C405 -26 | f"a { set(['a', 'b']) - set(['a']) } b" - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -22 22 | -23 23 | f"{set(['a', 'b']) - set(['a'])}" -24 24 | f"{ set(['a', 'b']) - set(['a']) }" -25 |-f"a {set(['a', 'b']) - set(['a'])} b" - 25 |+f"a {set(['a', 'b']) - {'a'} } b" -26 26 | f"a { set(['a', 'b']) - set(['a']) } b" - -C405.py:26:7: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) - | -24 | f"{ set(['a', 'b']) - set(['a']) }" -25 | f"a {set(['a', 'b']) - set(['a'])} b" -26 | f"a { set(['a', 'b']) - set(['a']) } b" - | ^^^^^^^^^^^^^^^ C405 - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -23 23 | f"{set(['a', 'b']) - set(['a'])}" -24 24 | f"{ set(['a', 'b']) - set(['a']) }" -25 25 | f"a {set(['a', 'b']) - set(['a'])} b" -26 |-f"a { set(['a', 'b']) - set(['a']) } b" - 26 |+f"a { {'a', 'b'} - set(['a']) } b" - -C405.py:26:25: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) - | -24 | f"{ set(['a', 'b']) - set(['a']) }" -25 | f"a {set(['a', 'b']) - set(['a'])} b" -26 | f"a { set(['a', 'b']) - set(['a']) } b" - | ^^^^^^^^^^ C405 - | - = help: Rewrite as a `set` literal - -ℹ Suggested fix -23 23 | f"{set(['a', 'b']) - set(['a'])}" -24 24 | f"{ set(['a', 'b']) - set(['a']) }" -25 25 | f"a {set(['a', 'b']) - set(['a'])} b" -26 |-f"a { set(['a', 'b']) - set(['a']) } b" - 26 |+f"a { set(['a', 'b']) - {'a'} } b" - - diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C406_C406.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C406_C406.py.snap deleted file mode 100644 index 60b3ef2c68..0000000000 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C406_C406.py.snap +++ /dev/null @@ -1,75 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_comprehensions/mod.rs ---- -C406.py:1:6: C406 [*] Unnecessary `list` literal (rewrite as a `dict` literal) - | -1 | d1 = dict([(1, 2)]) - | ^^^^^^^^^^^^^^ C406 -2 | d2 = dict(((1, 2),)) -3 | d3 = dict([]) - | - = help: Rewrite as a `dict` literal - -ℹ Suggested fix -1 |-d1 = dict([(1, 2)]) - 1 |+d1 = {1: 2} -2 2 | d2 = dict(((1, 2),)) -3 3 | d3 = dict([]) -4 4 | d4 = dict(()) - -C406.py:2:6: C406 [*] Unnecessary `tuple` literal (rewrite as a `dict` literal) - | -1 | d1 = dict([(1, 2)]) -2 | d2 = dict(((1, 2),)) - | ^^^^^^^^^^^^^^^ C406 -3 | d3 = dict([]) -4 | d4 = dict(()) - | - = help: Rewrite as a `dict` literal - -ℹ Suggested fix -1 1 | d1 = dict([(1, 2)]) -2 |-d2 = dict(((1, 2),)) - 2 |+d2 = {1: 2,} -3 3 | d3 = dict([]) -4 4 | d4 = dict(()) -5 5 | d5 = dict() - -C406.py:3:6: C406 [*] Unnecessary `list` literal (rewrite as a `dict` literal) - | -1 | d1 = dict([(1, 2)]) -2 | d2 = dict(((1, 2),)) -3 | d3 = dict([]) - | ^^^^^^^^ C406 -4 | d4 = dict(()) -5 | d5 = dict() - | - = help: Rewrite as a `dict` literal - -ℹ Suggested fix -1 1 | d1 = dict([(1, 2)]) -2 2 | d2 = dict(((1, 2),)) -3 |-d3 = dict([]) - 3 |+d3 = {} -4 4 | d4 = dict(()) -5 5 | d5 = dict() - -C406.py:4:6: C406 [*] Unnecessary `tuple` literal (rewrite as a `dict` literal) - | -2 | d2 = dict(((1, 2),)) -3 | d3 = dict([]) -4 | d4 = dict(()) - | ^^^^^^^^ C406 -5 | d5 = dict() - | - = help: Rewrite as a `dict` literal - -ℹ Suggested fix -1 1 | d1 = dict([(1, 2)]) -2 2 | d2 = dict(((1, 2),)) -3 3 | d3 = dict([]) -4 |-d4 = dict(()) - 4 |+d4 = {} -5 5 | d5 = dict() - - diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C408_C408.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C408_C408.py.snap deleted file mode 100644 index 14e935917b..0000000000 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C408_C408.py.snap +++ /dev/null @@ -1,308 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_comprehensions/mod.rs ---- -C408.py:1:5: C408 [*] Unnecessary `tuple` call (rewrite as a literal) - | -1 | t = tuple() - | ^^^^^^^ C408 -2 | l = list() -3 | d1 = dict() - | - = help: Rewrite as a literal - -ℹ Suggested fix -1 |-t = tuple() - 1 |+t = () -2 2 | l = list() -3 3 | d1 = dict() -4 4 | d2 = dict(a=1) - -C408.py:2:5: C408 [*] Unnecessary `list` call (rewrite as a literal) - | -1 | t = tuple() -2 | l = list() - | ^^^^^^ C408 -3 | d1 = dict() -4 | d2 = dict(a=1) - | - = help: Rewrite as a literal - -ℹ Suggested fix -1 1 | t = tuple() -2 |-l = list() - 2 |+l = [] -3 3 | d1 = dict() -4 4 | d2 = dict(a=1) -5 5 | d3 = dict(**d2) - -C408.py:3:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) - | -1 | t = tuple() -2 | l = list() -3 | d1 = dict() - | ^^^^^^ C408 -4 | d2 = dict(a=1) -5 | d3 = dict(**d2) - | - = help: Rewrite as a literal - -ℹ Suggested fix -1 1 | t = tuple() -2 2 | l = list() -3 |-d1 = dict() - 3 |+d1 = {} -4 4 | d2 = dict(a=1) -5 5 | d3 = dict(**d2) -6 6 | - -C408.py:4:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) - | -2 | l = list() -3 | d1 = dict() -4 | d2 = dict(a=1) - | ^^^^^^^^^ C408 -5 | d3 = dict(**d2) - | - = help: Rewrite as a literal - -ℹ Suggested fix -1 1 | t = tuple() -2 2 | l = list() -3 3 | d1 = dict() -4 |-d2 = dict(a=1) - 4 |+d2 = {"a": 1} -5 5 | d3 = dict(**d2) -6 6 | -7 7 | - -C408.py:14:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) - | -12 | a = list() -13 | -14 | f"{dict(x='y')}" - | ^^^^^^^^^^^ C408 -15 | f'{dict(x="y")}' -16 | f"{dict()}" - | - = help: Rewrite as a literal - -ℹ Suggested fix -11 11 | -12 12 | a = list() -13 13 | -14 |-f"{dict(x='y')}" - 14 |+f"{ {'x': 'y'} }" -15 15 | f'{dict(x="y")}' -16 16 | f"{dict()}" -17 17 | f"a {dict()} b" - -C408.py:15:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) - | -14 | f"{dict(x='y')}" -15 | f'{dict(x="y")}' - | ^^^^^^^^^^^ C408 -16 | f"{dict()}" -17 | f"a {dict()} b" - | - = help: Rewrite as a literal - -ℹ Suggested fix -12 12 | a = list() -13 13 | -14 14 | f"{dict(x='y')}" -15 |-f'{dict(x="y")}' - 15 |+f'{ {"x": "y"} }' -16 16 | f"{dict()}" -17 17 | f"a {dict()} b" -18 18 | - -C408.py:16:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) - | -14 | f"{dict(x='y')}" -15 | f'{dict(x="y")}' -16 | f"{dict()}" - | ^^^^^^ C408 -17 | f"a {dict()} b" - | - = help: Rewrite as a literal - -ℹ Suggested fix -13 13 | -14 14 | f"{dict(x='y')}" -15 15 | f'{dict(x="y")}' -16 |-f"{dict()}" - 16 |+f"{ {} }" -17 17 | f"a {dict()} b" -18 18 | -19 19 | f"{dict(x='y') | dict(y='z')}" - -C408.py:17:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) - | -15 | f'{dict(x="y")}' -16 | f"{dict()}" -17 | f"a {dict()} b" - | ^^^^^^ C408 -18 | -19 | f"{dict(x='y') | dict(y='z')}" - | - = help: Rewrite as a literal - -ℹ Suggested fix -14 14 | f"{dict(x='y')}" -15 15 | f'{dict(x="y")}' -16 16 | f"{dict()}" -17 |-f"a {dict()} b" - 17 |+f"a { {} } b" -18 18 | -19 19 | f"{dict(x='y') | dict(y='z')}" -20 20 | f"{ dict(x='y') | dict(y='z') }" - -C408.py:19:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) - | -17 | f"a {dict()} b" -18 | -19 | f"{dict(x='y') | dict(y='z')}" - | ^^^^^^^^^^^ C408 -20 | f"{ dict(x='y') | dict(y='z') }" -21 | f"a {dict(x='y') | dict(y='z')} b" - | - = help: Rewrite as a literal - -ℹ Suggested fix -16 16 | f"{dict()}" -17 17 | f"a {dict()} b" -18 18 | -19 |-f"{dict(x='y') | dict(y='z')}" - 19 |+f"{ {'x': 'y'} | dict(y='z')}" -20 20 | f"{ dict(x='y') | dict(y='z') }" -21 21 | f"a {dict(x='y') | dict(y='z')} b" -22 22 | f"a { dict(x='y') | dict(y='z') } b" - -C408.py:19:18: C408 [*] Unnecessary `dict` call (rewrite as a literal) - | -17 | f"a {dict()} b" -18 | -19 | f"{dict(x='y') | dict(y='z')}" - | ^^^^^^^^^^^ C408 -20 | f"{ dict(x='y') | dict(y='z') }" -21 | f"a {dict(x='y') | dict(y='z')} b" - | - = help: Rewrite as a literal - -ℹ Suggested fix -16 16 | f"{dict()}" -17 17 | f"a {dict()} b" -18 18 | -19 |-f"{dict(x='y') | dict(y='z')}" - 19 |+f"{dict(x='y') | {'y': 'z'} }" -20 20 | f"{ dict(x='y') | dict(y='z') }" -21 21 | f"a {dict(x='y') | dict(y='z')} b" -22 22 | f"a { dict(x='y') | dict(y='z') } b" - -C408.py:20:5: C408 [*] Unnecessary `dict` call (rewrite as a literal) - | -19 | f"{dict(x='y') | dict(y='z')}" -20 | f"{ dict(x='y') | dict(y='z') }" - | ^^^^^^^^^^^ C408 -21 | f"a {dict(x='y') | dict(y='z')} b" -22 | f"a { dict(x='y') | dict(y='z') } b" - | - = help: Rewrite as a literal - -ℹ Suggested fix -17 17 | f"a {dict()} b" -18 18 | -19 19 | f"{dict(x='y') | dict(y='z')}" -20 |-f"{ dict(x='y') | dict(y='z') }" - 20 |+f"{ {'x': 'y'} | dict(y='z') }" -21 21 | f"a {dict(x='y') | dict(y='z')} b" -22 22 | f"a { dict(x='y') | dict(y='z') } b" - -C408.py:20:19: C408 [*] Unnecessary `dict` call (rewrite as a literal) - | -19 | f"{dict(x='y') | dict(y='z')}" -20 | f"{ dict(x='y') | dict(y='z') }" - | ^^^^^^^^^^^ C408 -21 | f"a {dict(x='y') | dict(y='z')} b" -22 | f"a { dict(x='y') | dict(y='z') } b" - | - = help: Rewrite as a literal - -ℹ Suggested fix -17 17 | f"a {dict()} b" -18 18 | -19 19 | f"{dict(x='y') | dict(y='z')}" -20 |-f"{ dict(x='y') | dict(y='z') }" - 20 |+f"{ dict(x='y') | {'y': 'z'} }" -21 21 | f"a {dict(x='y') | dict(y='z')} b" -22 22 | f"a { dict(x='y') | dict(y='z') } b" - -C408.py:21:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) - | -19 | f"{dict(x='y') | dict(y='z')}" -20 | f"{ dict(x='y') | dict(y='z') }" -21 | f"a {dict(x='y') | dict(y='z')} b" - | ^^^^^^^^^^^ C408 -22 | f"a { dict(x='y') | dict(y='z') } b" - | - = help: Rewrite as a literal - -ℹ Suggested fix -18 18 | -19 19 | f"{dict(x='y') | dict(y='z')}" -20 20 | f"{ dict(x='y') | dict(y='z') }" -21 |-f"a {dict(x='y') | dict(y='z')} b" - 21 |+f"a { {'x': 'y'} | dict(y='z')} b" -22 22 | f"a { dict(x='y') | dict(y='z') } b" - -C408.py:21:20: C408 [*] Unnecessary `dict` call (rewrite as a literal) - | -19 | f"{dict(x='y') | dict(y='z')}" -20 | f"{ dict(x='y') | dict(y='z') }" -21 | f"a {dict(x='y') | dict(y='z')} b" - | ^^^^^^^^^^^ C408 -22 | f"a { dict(x='y') | dict(y='z') } b" - | - = help: Rewrite as a literal - -ℹ Suggested fix -18 18 | -19 19 | f"{dict(x='y') | dict(y='z')}" -20 20 | f"{ dict(x='y') | dict(y='z') }" -21 |-f"a {dict(x='y') | dict(y='z')} b" - 21 |+f"a {dict(x='y') | {'y': 'z'} } b" -22 22 | f"a { dict(x='y') | dict(y='z') } b" - -C408.py:22:7: C408 [*] Unnecessary `dict` call (rewrite as a literal) - | -20 | f"{ dict(x='y') | dict(y='z') }" -21 | f"a {dict(x='y') | dict(y='z')} b" -22 | f"a { dict(x='y') | dict(y='z') } b" - | ^^^^^^^^^^^ C408 - | - = help: Rewrite as a literal - -ℹ Suggested fix -19 19 | f"{dict(x='y') | dict(y='z')}" -20 20 | f"{ dict(x='y') | dict(y='z') }" -21 21 | f"a {dict(x='y') | dict(y='z')} b" -22 |-f"a { dict(x='y') | dict(y='z') } b" - 22 |+f"a { {'x': 'y'} | dict(y='z') } b" - -C408.py:22:21: C408 [*] Unnecessary `dict` call (rewrite as a literal) - | -20 | f"{ dict(x='y') | dict(y='z') }" -21 | f"a {dict(x='y') | dict(y='z')} b" -22 | f"a { dict(x='y') | dict(y='z') } b" - | ^^^^^^^^^^^ C408 - | - = help: Rewrite as a literal - -ℹ Suggested fix -19 19 | f"{dict(x='y') | dict(y='z')}" -20 20 | f"{ dict(x='y') | dict(y='z') }" -21 21 | f"a {dict(x='y') | dict(y='z')} b" -22 |-f"a { dict(x='y') | dict(y='z') } b" - 22 |+f"a { dict(x='y') | {'y': 'z'} } b" - - diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C408_C408.py_allow_dict_calls_with_keyword_arguments.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C408_C408.py_allow_dict_calls_with_keyword_arguments.snap deleted file mode 100644 index 3e82b4247b..0000000000 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C408_C408.py_allow_dict_calls_with_keyword_arguments.snap +++ /dev/null @@ -1,99 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_comprehensions/mod.rs ---- -C408.py:1:5: C408 [*] Unnecessary `tuple` call (rewrite as a literal) - | -1 | t = tuple() - | ^^^^^^^ C408 -2 | l = list() -3 | d1 = dict() - | - = help: Rewrite as a literal - -ℹ Suggested fix -1 |-t = tuple() - 1 |+t = () -2 2 | l = list() -3 3 | d1 = dict() -4 4 | d2 = dict(a=1) - -C408.py:2:5: C408 [*] Unnecessary `list` call (rewrite as a literal) - | -1 | t = tuple() -2 | l = list() - | ^^^^^^ C408 -3 | d1 = dict() -4 | d2 = dict(a=1) - | - = help: Rewrite as a literal - -ℹ Suggested fix -1 1 | t = tuple() -2 |-l = list() - 2 |+l = [] -3 3 | d1 = dict() -4 4 | d2 = dict(a=1) -5 5 | d3 = dict(**d2) - -C408.py:3:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) - | -1 | t = tuple() -2 | l = list() -3 | d1 = dict() - | ^^^^^^ C408 -4 | d2 = dict(a=1) -5 | d3 = dict(**d2) - | - = help: Rewrite as a literal - -ℹ Suggested fix -1 1 | t = tuple() -2 2 | l = list() -3 |-d1 = dict() - 3 |+d1 = {} -4 4 | d2 = dict(a=1) -5 5 | d3 = dict(**d2) -6 6 | - -C408.py:16:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) - | -14 | f"{dict(x='y')}" -15 | f'{dict(x="y")}' -16 | f"{dict()}" - | ^^^^^^ C408 -17 | f"a {dict()} b" - | - = help: Rewrite as a literal - -ℹ Suggested fix -13 13 | -14 14 | f"{dict(x='y')}" -15 15 | f'{dict(x="y")}' -16 |-f"{dict()}" - 16 |+f"{ {} }" -17 17 | f"a {dict()} b" -18 18 | -19 19 | f"{dict(x='y') | dict(y='z')}" - -C408.py:17:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) - | -15 | f'{dict(x="y")}' -16 | f"{dict()}" -17 | f"a {dict()} b" - | ^^^^^^ C408 -18 | -19 | f"{dict(x='y') | dict(y='z')}" - | - = help: Rewrite as a literal - -ℹ Suggested fix -14 14 | f"{dict(x='y')}" -15 15 | f'{dict(x="y")}' -16 16 | f"{dict()}" -17 |-f"a {dict()} b" - 17 |+f"a { {} } b" -18 18 | -19 19 | f"{dict(x='y') | dict(y='z')}" -20 20 | f"{ dict(x='y') | dict(y='z') }" - - diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C409_C409.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C409_C409.py.snap deleted file mode 100644 index f82a48c953..0000000000 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C409_C409.py.snap +++ /dev/null @@ -1,108 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_comprehensions/mod.rs ---- -C409.py:1:6: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite as a `tuple` literal) - | -1 | t1 = tuple([]) - | ^^^^^^^^^ C409 -2 | t2 = tuple([1, 2]) -3 | t3 = tuple((1, 2)) - | - = help: Rewrite as a `tuple` literal - -ℹ Suggested fix -1 |-t1 = tuple([]) - 1 |+t1 = () -2 2 | t2 = tuple([1, 2]) -3 3 | t3 = tuple((1, 2)) -4 4 | t4 = tuple([ - -C409.py:2:6: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite as a `tuple` literal) - | -1 | t1 = tuple([]) -2 | t2 = tuple([1, 2]) - | ^^^^^^^^^^^^^ C409 -3 | t3 = tuple((1, 2)) -4 | t4 = tuple([ - | - = help: Rewrite as a `tuple` literal - -ℹ Suggested fix -1 1 | t1 = tuple([]) -2 |-t2 = tuple([1, 2]) - 2 |+t2 = (1, 2) -3 3 | t3 = tuple((1, 2)) -4 4 | t4 = tuple([ -5 5 | 1, - -C409.py:3:6: C409 [*] Unnecessary `tuple` literal passed to `tuple()` (remove the outer call to `tuple()`) - | -1 | t1 = tuple([]) -2 | t2 = tuple([1, 2]) -3 | t3 = tuple((1, 2)) - | ^^^^^^^^^^^^^ C409 -4 | t4 = tuple([ -5 | 1, - | - = help: Remove outer `tuple` call - -ℹ Suggested fix -1 1 | t1 = tuple([]) -2 2 | t2 = tuple([1, 2]) -3 |-t3 = tuple((1, 2)) - 3 |+t3 = (1, 2) -4 4 | t4 = tuple([ -5 5 | 1, -6 6 | 2 - -C409.py:4:6: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite as a `tuple` literal) - | -2 | t2 = tuple([1, 2]) -3 | t3 = tuple((1, 2)) -4 | t4 = tuple([ - | ______^ -5 | | 1, -6 | | 2 -7 | | ]) - | |__^ C409 -8 | t5 = tuple( -9 | (1, 2) - | - = help: Rewrite as a `tuple` literal - -ℹ Suggested fix -1 1 | t1 = tuple([]) -2 2 | t2 = tuple([1, 2]) -3 3 | t3 = tuple((1, 2)) -4 |-t4 = tuple([ - 4 |+t4 = ( -5 5 | 1, -6 6 | 2 -7 |-]) - 7 |+) -8 8 | t5 = tuple( -9 9 | (1, 2) -10 10 | ) - -C409.py:8:6: C409 [*] Unnecessary `tuple` literal passed to `tuple()` (remove the outer call to `tuple()`) - | - 6 | 2 - 7 | ]) - 8 | t5 = tuple( - | ______^ - 9 | | (1, 2) -10 | | ) - | |_^ C409 - | - = help: Remove outer `tuple` call - -ℹ Suggested fix -5 5 | 1, -6 6 | 2 -7 7 | ]) -8 |-t5 = tuple( -9 |- (1, 2) -10 |-) - 8 |+t5 = (1, 2) - - diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C410_C410.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C410_C410.py.snap deleted file mode 100644 index b40c8f6249..0000000000 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C410_C410.py.snap +++ /dev/null @@ -1,70 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_comprehensions/mod.rs ---- -C410.py:1:6: C410 [*] Unnecessary `list` literal passed to `list()` (remove the outer call to `list()`) - | -1 | l1 = list([1, 2]) - | ^^^^^^^^^^^^ C410 -2 | l2 = list((1, 2)) -3 | l3 = list([]) - | - = help: Remove outer `list` call - -ℹ Suggested fix -1 |-l1 = list([1, 2]) - 1 |+l1 = [1, 2] -2 2 | l2 = list((1, 2)) -3 3 | l3 = list([]) -4 4 | l4 = list(()) - -C410.py:2:6: C410 [*] Unnecessary `tuple` literal passed to `list()` (rewrite as a `list` literal) - | -1 | l1 = list([1, 2]) -2 | l2 = list((1, 2)) - | ^^^^^^^^^^^^ C410 -3 | l3 = list([]) -4 | l4 = list(()) - | - = help: Rewrite as a `list` literal - -ℹ Suggested fix -1 1 | l1 = list([1, 2]) -2 |-l2 = list((1, 2)) - 2 |+l2 = [1, 2] -3 3 | l3 = list([]) -4 4 | l4 = list(()) - -C410.py:3:6: C410 [*] Unnecessary `list` literal passed to `list()` (remove the outer call to `list()`) - | -1 | l1 = list([1, 2]) -2 | l2 = list((1, 2)) -3 | l3 = list([]) - | ^^^^^^^^ C410 -4 | l4 = list(()) - | - = help: Remove outer `list` call - -ℹ Suggested fix -1 1 | l1 = list([1, 2]) -2 2 | l2 = list((1, 2)) -3 |-l3 = list([]) - 3 |+l3 = [] -4 4 | l4 = list(()) - -C410.py:4:6: C410 [*] Unnecessary `tuple` literal passed to `list()` (rewrite as a `list` literal) - | -2 | l2 = list((1, 2)) -3 | l3 = list([]) -4 | l4 = list(()) - | ^^^^^^^^ C410 - | - = help: Rewrite as a `list` literal - -ℹ Suggested fix -1 1 | l1 = list([1, 2]) -2 2 | l2 = list((1, 2)) -3 3 | l3 = list([]) -4 |-l4 = list(()) - 4 |+l4 = [] - - diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C411_C411.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C411_C411.py.snap deleted file mode 100644 index 1f7b4c0576..0000000000 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C411_C411.py.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_comprehensions/mod.rs ---- -C411.py:2:1: C411 [*] Unnecessary `list` call (remove the outer call to `list()`) - | -1 | x = [1, 2, 3] -2 | list([i for i in x]) - | ^^^^^^^^^^^^^^^^^^^^ C411 - | - = help: Remove outer `list` call - -ℹ Suggested fix -1 1 | x = [1, 2, 3] -2 |-list([i for i in x]) - 2 |+[i for i in x] - - diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C413_C413.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C413_C413.py.snap deleted file mode 100644 index 50c61206c2..0000000000 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C413_C413.py.snap +++ /dev/null @@ -1,229 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_comprehensions/mod.rs ---- -C413.py:3:1: C413 [*] Unnecessary `list` call around `sorted()` - | -1 | x = [2, 3, 1] -2 | list(x) -3 | list(sorted(x)) - | ^^^^^^^^^^^^^^^ C413 -4 | reversed(sorted(x)) -5 | reversed(sorted(x, key=lambda e: e)) - | - = help: Remove unnecessary `list` call - -ℹ Fix -1 1 | x = [2, 3, 1] -2 2 | list(x) -3 |-list(sorted(x)) - 3 |+sorted(x) -4 4 | reversed(sorted(x)) -5 5 | reversed(sorted(x, key=lambda e: e)) -6 6 | reversed(sorted(x, reverse=True)) - -C413.py:4:1: C413 [*] Unnecessary `reversed` call around `sorted()` - | -2 | list(x) -3 | list(sorted(x)) -4 | reversed(sorted(x)) - | ^^^^^^^^^^^^^^^^^^^ C413 -5 | reversed(sorted(x, key=lambda e: e)) -6 | reversed(sorted(x, reverse=True)) - | - = help: Remove unnecessary `reversed` call - -ℹ Suggested fix -1 1 | x = [2, 3, 1] -2 2 | list(x) -3 3 | list(sorted(x)) -4 |-reversed(sorted(x)) - 4 |+sorted(x, reverse=True) -5 5 | reversed(sorted(x, key=lambda e: e)) -6 6 | reversed(sorted(x, reverse=True)) -7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) - -C413.py:5:1: C413 [*] Unnecessary `reversed` call around `sorted()` - | -3 | list(sorted(x)) -4 | reversed(sorted(x)) -5 | reversed(sorted(x, key=lambda e: e)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 -6 | reversed(sorted(x, reverse=True)) -7 | reversed(sorted(x, key=lambda e: e, reverse=True)) - | - = help: Remove unnecessary `reversed` call - -ℹ Suggested fix -2 2 | list(x) -3 3 | list(sorted(x)) -4 4 | reversed(sorted(x)) -5 |-reversed(sorted(x, key=lambda e: e)) - 5 |+sorted(x, key=lambda e: e, reverse=True) -6 6 | reversed(sorted(x, reverse=True)) -7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) -8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) - -C413.py:6:1: C413 [*] Unnecessary `reversed` call around `sorted()` - | -4 | reversed(sorted(x)) -5 | reversed(sorted(x, key=lambda e: e)) -6 | reversed(sorted(x, reverse=True)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 -7 | reversed(sorted(x, key=lambda e: e, reverse=True)) -8 | reversed(sorted(x, reverse=True, key=lambda e: e)) - | - = help: Remove unnecessary `reversed` call - -ℹ Suggested fix -3 3 | list(sorted(x)) -4 4 | reversed(sorted(x)) -5 5 | reversed(sorted(x, key=lambda e: e)) -6 |-reversed(sorted(x, reverse=True)) - 6 |+sorted(x, reverse=False) -7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) -8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) -9 9 | reversed(sorted(x, reverse=False)) - -C413.py:7:1: C413 [*] Unnecessary `reversed` call around `sorted()` - | -5 | reversed(sorted(x, key=lambda e: e)) -6 | reversed(sorted(x, reverse=True)) -7 | reversed(sorted(x, key=lambda e: e, reverse=True)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 -8 | reversed(sorted(x, reverse=True, key=lambda e: e)) -9 | reversed(sorted(x, reverse=False)) - | - = help: Remove unnecessary `reversed` call - -ℹ Suggested fix -4 4 | reversed(sorted(x)) -5 5 | reversed(sorted(x, key=lambda e: e)) -6 6 | reversed(sorted(x, reverse=True)) -7 |-reversed(sorted(x, key=lambda e: e, reverse=True)) - 7 |+sorted(x, key=lambda e: e, reverse=False) -8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) -9 9 | reversed(sorted(x, reverse=False)) -10 10 | reversed(sorted(x, reverse=x)) - -C413.py:8:1: C413 [*] Unnecessary `reversed` call around `sorted()` - | - 6 | reversed(sorted(x, reverse=True)) - 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) - 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 - 9 | reversed(sorted(x, reverse=False)) -10 | reversed(sorted(x, reverse=x)) - | - = help: Remove unnecessary `reversed` call - -ℹ Suggested fix -5 5 | reversed(sorted(x, key=lambda e: e)) -6 6 | reversed(sorted(x, reverse=True)) -7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) -8 |-reversed(sorted(x, reverse=True, key=lambda e: e)) - 8 |+sorted(x, reverse=False, key=lambda e: e) -9 9 | reversed(sorted(x, reverse=False)) -10 10 | reversed(sorted(x, reverse=x)) -11 11 | reversed(sorted(x, reverse=not x)) - -C413.py:9:1: C413 [*] Unnecessary `reversed` call around `sorted()` - | - 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) - 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) - 9 | reversed(sorted(x, reverse=False)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 -10 | reversed(sorted(x, reverse=x)) -11 | reversed(sorted(x, reverse=not x)) - | - = help: Remove unnecessary `reversed` call - -ℹ Suggested fix -6 6 | reversed(sorted(x, reverse=True)) -7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) -8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) -9 |-reversed(sorted(x, reverse=False)) - 9 |+sorted(x, reverse=True) -10 10 | reversed(sorted(x, reverse=x)) -11 11 | reversed(sorted(x, reverse=not x)) -12 12 | - -C413.py:10:1: C413 [*] Unnecessary `reversed` call around `sorted()` - | - 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) - 9 | reversed(sorted(x, reverse=False)) -10 | reversed(sorted(x, reverse=x)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 -11 | reversed(sorted(x, reverse=not x)) - | - = help: Remove unnecessary `reversed` call - -ℹ Suggested fix -7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) -8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) -9 9 | reversed(sorted(x, reverse=False)) -10 |-reversed(sorted(x, reverse=x)) - 10 |+sorted(x, reverse=not x) -11 11 | reversed(sorted(x, reverse=not x)) -12 12 | -13 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 - -C413.py:11:1: C413 [*] Unnecessary `reversed` call around `sorted()` - | - 9 | reversed(sorted(x, reverse=False)) -10 | reversed(sorted(x, reverse=x)) -11 | reversed(sorted(x, reverse=not x)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 -12 | -13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 - | - = help: Remove unnecessary `reversed` call - -ℹ Suggested fix -8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) -9 9 | reversed(sorted(x, reverse=False)) -10 10 | reversed(sorted(x, reverse=x)) -11 |-reversed(sorted(x, reverse=not x)) - 11 |+sorted(x, reverse=x) -12 12 | -13 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 -14 14 | reversed(sorted(i for i in range(42))) - -C413.py:14:1: C413 [*] Unnecessary `reversed` call around `sorted()` - | -13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 -14 | reversed(sorted(i for i in range(42))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 -15 | reversed(sorted((i for i in range(42)), reverse=True)) - | - = help: Remove unnecessary `reversed` call - -ℹ Suggested fix -11 11 | reversed(sorted(x, reverse=not x)) -12 12 | -13 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 -14 |-reversed(sorted(i for i in range(42))) - 14 |+sorted((i for i in range(42)), reverse=True) -15 15 | reversed(sorted((i for i in range(42)), reverse=True)) -16 16 | -17 17 | - -C413.py:15:1: C413 [*] Unnecessary `reversed` call around `sorted()` - | -13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 -14 | reversed(sorted(i for i in range(42))) -15 | reversed(sorted((i for i in range(42)), reverse=True)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 - | - = help: Remove unnecessary `reversed` call - -ℹ Suggested fix -12 12 | -13 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 -14 14 | reversed(sorted(i for i in range(42))) -15 |-reversed(sorted((i for i in range(42)), reverse=True)) - 15 |+sorted((i for i in range(42)), reverse=False) -16 16 | -17 17 | -18 18 | def reversed(*args, **kwargs): - - diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C414_C414.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C414_C414.py.snap deleted file mode 100644 index 2aabf2b2f9..0000000000 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C414_C414.py.snap +++ /dev/null @@ -1,470 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_comprehensions/mod.rs ---- -C414.py:2:1: C414 [*] Unnecessary `list` call within `list()` - | -1 | x = [1, 2, 3] -2 | list(list(x)) - | ^^^^^^^^^^^^^ C414 -3 | list(tuple(x)) -4 | tuple(list(x)) - | - = help: Remove the inner `list` call - -ℹ Suggested fix -1 1 | x = [1, 2, 3] -2 |-list(list(x)) - 2 |+list(x) -3 3 | list(tuple(x)) -4 4 | tuple(list(x)) -5 5 | tuple(tuple(x)) - -C414.py:3:1: C414 [*] Unnecessary `tuple` call within `list()` - | -1 | x = [1, 2, 3] -2 | list(list(x)) -3 | list(tuple(x)) - | ^^^^^^^^^^^^^^ C414 -4 | tuple(list(x)) -5 | tuple(tuple(x)) - | - = help: Remove the inner `tuple` call - -ℹ Suggested fix -1 1 | x = [1, 2, 3] -2 2 | list(list(x)) -3 |-list(tuple(x)) - 3 |+list(x) -4 4 | tuple(list(x)) -5 5 | tuple(tuple(x)) -6 6 | set(set(x)) - -C414.py:4:1: C414 [*] Unnecessary `list` call within `tuple()` - | -2 | list(list(x)) -3 | list(tuple(x)) -4 | tuple(list(x)) - | ^^^^^^^^^^^^^^ C414 -5 | tuple(tuple(x)) -6 | set(set(x)) - | - = help: Remove the inner `list` call - -ℹ Suggested fix -1 1 | x = [1, 2, 3] -2 2 | list(list(x)) -3 3 | list(tuple(x)) -4 |-tuple(list(x)) - 4 |+tuple(x) -5 5 | tuple(tuple(x)) -6 6 | set(set(x)) -7 7 | set(list(x)) - -C414.py:5:1: C414 [*] Unnecessary `tuple` call within `tuple()` - | -3 | list(tuple(x)) -4 | tuple(list(x)) -5 | tuple(tuple(x)) - | ^^^^^^^^^^^^^^^ C414 -6 | set(set(x)) -7 | set(list(x)) - | - = help: Remove the inner `tuple` call - -ℹ Suggested fix -2 2 | list(list(x)) -3 3 | list(tuple(x)) -4 4 | tuple(list(x)) -5 |-tuple(tuple(x)) - 5 |+tuple(x) -6 6 | set(set(x)) -7 7 | set(list(x)) -8 8 | set(tuple(x)) - -C414.py:6:1: C414 [*] Unnecessary `set` call within `set()` - | -4 | tuple(list(x)) -5 | tuple(tuple(x)) -6 | set(set(x)) - | ^^^^^^^^^^^ C414 -7 | set(list(x)) -8 | set(tuple(x)) - | - = help: Remove the inner `set` call - -ℹ Suggested fix -3 3 | list(tuple(x)) -4 4 | tuple(list(x)) -5 5 | tuple(tuple(x)) -6 |-set(set(x)) - 6 |+set(x) -7 7 | set(list(x)) -8 8 | set(tuple(x)) -9 9 | set(sorted(x)) - -C414.py:7:1: C414 [*] Unnecessary `list` call within `set()` - | -5 | tuple(tuple(x)) -6 | set(set(x)) -7 | set(list(x)) - | ^^^^^^^^^^^^ C414 -8 | set(tuple(x)) -9 | set(sorted(x)) - | - = help: Remove the inner `list` call - -ℹ Suggested fix -4 4 | tuple(list(x)) -5 5 | tuple(tuple(x)) -6 6 | set(set(x)) -7 |-set(list(x)) - 7 |+set(x) -8 8 | set(tuple(x)) -9 9 | set(sorted(x)) -10 10 | set(sorted(x, key=lambda y: y)) - -C414.py:8:1: C414 [*] Unnecessary `tuple` call within `set()` - | - 6 | set(set(x)) - 7 | set(list(x)) - 8 | set(tuple(x)) - | ^^^^^^^^^^^^^ C414 - 9 | set(sorted(x)) -10 | set(sorted(x, key=lambda y: y)) - | - = help: Remove the inner `tuple` call - -ℹ Suggested fix -5 5 | tuple(tuple(x)) -6 6 | set(set(x)) -7 7 | set(list(x)) -8 |-set(tuple(x)) - 8 |+set(x) -9 9 | set(sorted(x)) -10 10 | set(sorted(x, key=lambda y: y)) -11 11 | set(reversed(x)) - -C414.py:9:1: C414 [*] Unnecessary `sorted` call within `set()` - | - 7 | set(list(x)) - 8 | set(tuple(x)) - 9 | set(sorted(x)) - | ^^^^^^^^^^^^^^ C414 -10 | set(sorted(x, key=lambda y: y)) -11 | set(reversed(x)) - | - = help: Remove the inner `sorted` call - -ℹ Suggested fix -6 6 | set(set(x)) -7 7 | set(list(x)) -8 8 | set(tuple(x)) -9 |-set(sorted(x)) - 9 |+set(x) -10 10 | set(sorted(x, key=lambda y: y)) -11 11 | set(reversed(x)) -12 12 | sorted(list(x)) - -C414.py:10:1: C414 [*] Unnecessary `sorted` call within `set()` - | - 8 | set(tuple(x)) - 9 | set(sorted(x)) -10 | set(sorted(x, key=lambda y: y)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C414 -11 | set(reversed(x)) -12 | sorted(list(x)) - | - = help: Remove the inner `sorted` call - -ℹ Suggested fix -7 7 | set(list(x)) -8 8 | set(tuple(x)) -9 9 | set(sorted(x)) -10 |-set(sorted(x, key=lambda y: y)) - 10 |+set(x, ) -11 11 | set(reversed(x)) -12 12 | sorted(list(x)) -13 13 | sorted(tuple(x)) - -C414.py:11:1: C414 [*] Unnecessary `reversed` call within `set()` - | - 9 | set(sorted(x)) -10 | set(sorted(x, key=lambda y: y)) -11 | set(reversed(x)) - | ^^^^^^^^^^^^^^^^ C414 -12 | sorted(list(x)) -13 | sorted(tuple(x)) - | - = help: Remove the inner `reversed` call - -ℹ Suggested fix -8 8 | set(tuple(x)) -9 9 | set(sorted(x)) -10 10 | set(sorted(x, key=lambda y: y)) -11 |-set(reversed(x)) - 11 |+set(x) -12 12 | sorted(list(x)) -13 13 | sorted(tuple(x)) -14 14 | sorted(sorted(x)) - -C414.py:12:1: C414 [*] Unnecessary `list` call within `sorted()` - | -10 | set(sorted(x, key=lambda y: y)) -11 | set(reversed(x)) -12 | sorted(list(x)) - | ^^^^^^^^^^^^^^^ C414 -13 | sorted(tuple(x)) -14 | sorted(sorted(x)) - | - = help: Remove the inner `list` call - -ℹ Suggested fix -9 9 | set(sorted(x)) -10 10 | set(sorted(x, key=lambda y: y)) -11 11 | set(reversed(x)) -12 |-sorted(list(x)) - 12 |+sorted(x) -13 13 | sorted(tuple(x)) -14 14 | sorted(sorted(x)) -15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) - -C414.py:13:1: C414 [*] Unnecessary `tuple` call within `sorted()` - | -11 | set(reversed(x)) -12 | sorted(list(x)) -13 | sorted(tuple(x)) - | ^^^^^^^^^^^^^^^^ C414 -14 | sorted(sorted(x)) -15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) - | - = help: Remove the inner `tuple` call - -ℹ Suggested fix -10 10 | set(sorted(x, key=lambda y: y)) -11 11 | set(reversed(x)) -12 12 | sorted(list(x)) -13 |-sorted(tuple(x)) - 13 |+sorted(x) -14 14 | sorted(sorted(x)) -15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) -16 16 | sorted(sorted(x, reverse=True), reverse=True) - -C414.py:14:1: C414 [*] Unnecessary `sorted` call within `sorted()` - | -12 | sorted(list(x)) -13 | sorted(tuple(x)) -14 | sorted(sorted(x)) - | ^^^^^^^^^^^^^^^^^ C414 -15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) -16 | sorted(sorted(x, reverse=True), reverse=True) - | - = help: Remove the inner `sorted` call - -ℹ Suggested fix -11 11 | set(reversed(x)) -12 12 | sorted(list(x)) -13 13 | sorted(tuple(x)) -14 |-sorted(sorted(x)) - 14 |+sorted(x) -15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) -16 16 | sorted(sorted(x, reverse=True), reverse=True) -17 17 | sorted(reversed(x)) - -C414.py:15:1: C414 [*] Unnecessary `sorted` call within `sorted()` - | -13 | sorted(tuple(x)) -14 | sorted(sorted(x)) -15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C414 -16 | sorted(sorted(x, reverse=True), reverse=True) -17 | sorted(reversed(x)) - | - = help: Remove the inner `sorted` call - -ℹ Suggested fix -12 12 | sorted(list(x)) -13 13 | sorted(tuple(x)) -14 14 | sorted(sorted(x)) -15 |-sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) - 15 |+sorted(x, reverse=False, key=foo) -16 16 | sorted(sorted(x, reverse=True), reverse=True) -17 17 | sorted(reversed(x)) -18 18 | sorted(list(x), key=lambda y: y) - -C414.py:16:1: C414 [*] Unnecessary `sorted` call within `sorted()` - | -14 | sorted(sorted(x)) -15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) -16 | sorted(sorted(x, reverse=True), reverse=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C414 -17 | sorted(reversed(x)) -18 | sorted(list(x), key=lambda y: y) - | - = help: Remove the inner `sorted` call - -ℹ Suggested fix -13 13 | sorted(tuple(x)) -14 14 | sorted(sorted(x)) -15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) -16 |-sorted(sorted(x, reverse=True), reverse=True) - 16 |+sorted(x, reverse=True) -17 17 | sorted(reversed(x)) -18 18 | sorted(list(x), key=lambda y: y) -19 19 | tuple( - -C414.py:17:1: C414 [*] Unnecessary `reversed` call within `sorted()` - | -15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) -16 | sorted(sorted(x, reverse=True), reverse=True) -17 | sorted(reversed(x)) - | ^^^^^^^^^^^^^^^^^^^ C414 -18 | sorted(list(x), key=lambda y: y) -19 | tuple( - | - = help: Remove the inner `reversed` call - -ℹ Suggested fix -14 14 | sorted(sorted(x)) -15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) -16 16 | sorted(sorted(x, reverse=True), reverse=True) -17 |-sorted(reversed(x)) - 17 |+sorted(x) -18 18 | sorted(list(x), key=lambda y: y) -19 19 | tuple( -20 20 | list( - -C414.py:18:1: C414 [*] Unnecessary `list` call within `sorted()` - | -16 | sorted(sorted(x, reverse=True), reverse=True) -17 | sorted(reversed(x)) -18 | sorted(list(x), key=lambda y: y) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C414 -19 | tuple( -20 | list( - | - = help: Remove the inner `list` call - -ℹ Suggested fix -15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) -16 16 | sorted(sorted(x, reverse=True), reverse=True) -17 17 | sorted(reversed(x)) -18 |-sorted(list(x), key=lambda y: y) - 18 |+sorted(x, key=lambda y: y) -19 19 | tuple( -20 20 | list( -21 21 | [x, 3, "hell"\ - -C414.py:19:1: C414 [*] Unnecessary `list` call within `tuple()` - | -17 | sorted(reversed(x)) -18 | sorted(list(x), key=lambda y: y) -19 | / tuple( -20 | | list( -21 | | [x, 3, "hell"\ -22 | | "o"] -23 | | ) -24 | | ) - | |_^ C414 -25 | set(set()) -26 | set(list()) - | - = help: Remove the inner `list` call - -ℹ Suggested fix -17 17 | sorted(reversed(x)) -18 18 | sorted(list(x), key=lambda y: y) -19 19 | tuple( -20 |- list( -21 |- [x, 3, "hell"\ - 20 |+ [x, 3, "hell"\ -22 21 | "o"] -23 22 | ) -24 |-) -25 23 | set(set()) -26 24 | set(list()) -27 25 | set(tuple()) - -C414.py:25:1: C414 [*] Unnecessary `set` call within `set()` - | -23 | ) -24 | ) -25 | set(set()) - | ^^^^^^^^^^ C414 -26 | set(list()) -27 | set(tuple()) - | - = help: Remove the inner `set` call - -ℹ Suggested fix -22 22 | "o"] -23 23 | ) -24 24 | ) -25 |-set(set()) - 25 |+set() -26 26 | set(list()) -27 27 | set(tuple()) -28 28 | sorted(reversed()) - -C414.py:26:1: C414 [*] Unnecessary `list` call within `set()` - | -24 | ) -25 | set(set()) -26 | set(list()) - | ^^^^^^^^^^^ C414 -27 | set(tuple()) -28 | sorted(reversed()) - | - = help: Remove the inner `list` call - -ℹ Suggested fix -23 23 | ) -24 24 | ) -25 25 | set(set()) -26 |-set(list()) - 26 |+set() -27 27 | set(tuple()) -28 28 | sorted(reversed()) -29 29 | - -C414.py:27:1: C414 [*] Unnecessary `tuple` call within `set()` - | -25 | set(set()) -26 | set(list()) -27 | set(tuple()) - | ^^^^^^^^^^^^ C414 -28 | sorted(reversed()) - | - = help: Remove the inner `tuple` call - -ℹ Suggested fix -24 24 | ) -25 25 | set(set()) -26 26 | set(list()) -27 |-set(tuple()) - 27 |+set() -28 28 | sorted(reversed()) -29 29 | -30 30 | # Nested sorts with differing keyword arguments. Not flagged. - -C414.py:28:1: C414 [*] Unnecessary `reversed` call within `sorted()` - | -26 | set(list()) -27 | set(tuple()) -28 | sorted(reversed()) - | ^^^^^^^^^^^^^^^^^^ C414 -29 | -30 | # Nested sorts with differing keyword arguments. Not flagged. - | - = help: Remove the inner `reversed` call - -ℹ Suggested fix -25 25 | set(set()) -26 26 | set(list()) -27 27 | set(tuple()) -28 |-sorted(reversed()) - 28 |+sorted() -29 29 | -30 30 | # Nested sorts with differing keyword arguments. Not flagged. -31 31 | sorted(sorted(x, key=lambda y: y)) - - diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C415_C415.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C415_C415.py.snap deleted file mode 100644 index b35ecea57e..0000000000 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C415_C415.py.snap +++ /dev/null @@ -1,43 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_comprehensions/mod.rs ---- -C415.py:2:5: C415 Unnecessary subscript reversal of iterable within `set()` - | -1 | lst = [2, 1, 3] -2 | a = set(lst[::-1]) - | ^^^^^^^^^^^^^^ C415 -3 | b = reversed(lst[::-1]) -4 | c = sorted(lst[::-1]) - | - -C415.py:3:5: C415 Unnecessary subscript reversal of iterable within `reversed()` - | -1 | lst = [2, 1, 3] -2 | a = set(lst[::-1]) -3 | b = reversed(lst[::-1]) - | ^^^^^^^^^^^^^^^^^^^ C415 -4 | c = sorted(lst[::-1]) -5 | d = sorted(lst[::-1], reverse=True) - | - -C415.py:4:5: C415 Unnecessary subscript reversal of iterable within `sorted()` - | -2 | a = set(lst[::-1]) -3 | b = reversed(lst[::-1]) -4 | c = sorted(lst[::-1]) - | ^^^^^^^^^^^^^^^^^ C415 -5 | d = sorted(lst[::-1], reverse=True) -6 | e = set(lst[2:-1]) - | - -C415.py:5:5: C415 Unnecessary subscript reversal of iterable within `sorted()` - | -3 | b = reversed(lst[::-1]) -4 | c = sorted(lst[::-1]) -5 | d = sorted(lst[::-1], reverse=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C415 -6 | e = set(lst[2:-1]) -7 | f = set(lst[:1:-1]) - | - - diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C416_C416.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C416_C416.py.snap deleted file mode 100644 index 96188e987e..0000000000 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C416_C416.py.snap +++ /dev/null @@ -1,143 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_comprehensions/mod.rs ---- -C416.py:6:1: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`) - | -4 | d = {"a": 1, "b": 2, "c": 3} -5 | -6 | [i for i in x] - | ^^^^^^^^^^^^^^ C416 -7 | {i for i in x} -8 | {k: v for k, v in y} - | - = help: Rewrite using `list()` - -ℹ Suggested fix -3 3 | z = [(1,), (2,), (3,)] -4 4 | d = {"a": 1, "b": 2, "c": 3} -5 5 | -6 |-[i for i in x] - 6 |+list(x) -7 7 | {i for i in x} -8 8 | {k: v for k, v in y} -9 9 | {k: v for k, v in d.items()} - -C416.py:7:1: C416 [*] Unnecessary `set` comprehension (rewrite using `set()`) - | -6 | [i for i in x] -7 | {i for i in x} - | ^^^^^^^^^^^^^^ C416 -8 | {k: v for k, v in y} -9 | {k: v for k, v in d.items()} - | - = help: Rewrite using `set()` - -ℹ Suggested fix -4 4 | d = {"a": 1, "b": 2, "c": 3} -5 5 | -6 6 | [i for i in x] -7 |-{i for i in x} - 7 |+set(x) -8 8 | {k: v for k, v in y} -9 9 | {k: v for k, v in d.items()} -10 10 | [(k, v) for k, v in d.items()] - -C416.py:8:1: C416 [*] Unnecessary `dict` comprehension (rewrite using `dict()`) - | - 6 | [i for i in x] - 7 | {i for i in x} - 8 | {k: v for k, v in y} - | ^^^^^^^^^^^^^^^^^^^^ C416 - 9 | {k: v for k, v in d.items()} -10 | [(k, v) for k, v in d.items()] - | - = help: Rewrite using `dict()` - -ℹ Suggested fix -5 5 | -6 6 | [i for i in x] -7 7 | {i for i in x} -8 |-{k: v for k, v in y} - 8 |+dict(y) -9 9 | {k: v for k, v in d.items()} -10 10 | [(k, v) for k, v in d.items()] -11 11 | {k: (a, b) for k, (a, b) in d.items()} - -C416.py:9:1: C416 [*] Unnecessary `dict` comprehension (rewrite using `dict()`) - | - 7 | {i for i in x} - 8 | {k: v for k, v in y} - 9 | {k: v for k, v in d.items()} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C416 -10 | [(k, v) for k, v in d.items()] -11 | {k: (a, b) for k, (a, b) in d.items()} - | - = help: Rewrite using `dict()` - -ℹ Suggested fix -6 6 | [i for i in x] -7 7 | {i for i in x} -8 8 | {k: v for k, v in y} -9 |-{k: v for k, v in d.items()} - 9 |+dict(d.items()) -10 10 | [(k, v) for k, v in d.items()] -11 11 | {k: (a, b) for k, (a, b) in d.items()} -12 12 | - -C416.py:10:1: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`) - | - 8 | {k: v for k, v in y} - 9 | {k: v for k, v in d.items()} -10 | [(k, v) for k, v in d.items()] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C416 -11 | {k: (a, b) for k, (a, b) in d.items()} - | - = help: Rewrite using `list()` - -ℹ Suggested fix -7 7 | {i for i in x} -8 8 | {k: v for k, v in y} -9 9 | {k: v for k, v in d.items()} -10 |-[(k, v) for k, v in d.items()] - 10 |+list(d.items()) -11 11 | {k: (a, b) for k, (a, b) in d.items()} -12 12 | -13 13 | [i for i, in z] - -C416.py:11:1: C416 [*] Unnecessary `dict` comprehension (rewrite using `dict()`) - | - 9 | {k: v for k, v in d.items()} -10 | [(k, v) for k, v in d.items()] -11 | {k: (a, b) for k, (a, b) in d.items()} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C416 -12 | -13 | [i for i, in z] - | - = help: Rewrite using `dict()` - -ℹ Suggested fix -8 8 | {k: v for k, v in y} -9 9 | {k: v for k, v in d.items()} -10 10 | [(k, v) for k, v in d.items()] -11 |-{k: (a, b) for k, (a, b) in d.items()} - 11 |+dict(d.items()) -12 12 | -13 13 | [i for i, in z] -14 14 | [i for i, j in y] - -C416.py:24:70: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`) - | -23 | # Regression test for: https://github.com/astral-sh/ruff/issues/7196 -24 | any(len(symbol_table.get_by_type(symbol_type)) > 0 for symbol_type in[t for t in SymbolType]) - | ^^^^^^^^^^^^^^^^^^^^^^^ C416 - | - = help: Rewrite using `list()` - -ℹ Suggested fix -21 21 | {k: v if v else None for k, v in y} -22 22 | -23 23 | # Regression test for: https://github.com/astral-sh/ruff/issues/7196 -24 |-any(len(symbol_table.get_by_type(symbol_type)) > 0 for symbol_type in[t for t in SymbolType]) - 24 |+any(len(symbol_table.get_by_type(symbol_type)) > 0 for symbol_type in list(SymbolType)) - - diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C417_C417.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C417_C417.py.snap deleted file mode 100644 index ef82a61589..0000000000 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C417_C417.py.snap +++ /dev/null @@ -1,367 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_comprehensions/mod.rs ---- -C417.py:3:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) - | -1 | # Errors. -2 | nums = [1, 2, 3] -3 | map(lambda x: x + 1, nums) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -4 | map(lambda x: str(x), nums) -5 | list(map(lambda x: x * 2, nums)) - | - = help: Replace `map` with a generator expression - -ℹ Suggested fix -1 1 | # Errors. -2 2 | nums = [1, 2, 3] -3 |-map(lambda x: x + 1, nums) - 3 |+(x + 1 for x in nums) -4 4 | map(lambda x: str(x), nums) -5 5 | list(map(lambda x: x * 2, nums)) -6 6 | set(map(lambda x: x % 2 == 0, nums)) - -C417.py:4:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) - | -2 | nums = [1, 2, 3] -3 | map(lambda x: x + 1, nums) -4 | map(lambda x: str(x), nums) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -5 | list(map(lambda x: x * 2, nums)) -6 | set(map(lambda x: x % 2 == 0, nums)) - | - = help: Replace `map` with a generator expression - -ℹ Suggested fix -1 1 | # Errors. -2 2 | nums = [1, 2, 3] -3 3 | map(lambda x: x + 1, nums) -4 |-map(lambda x: str(x), nums) - 4 |+(str(x) for x in nums) -5 5 | list(map(lambda x: x * 2, nums)) -6 6 | set(map(lambda x: x % 2 == 0, nums)) -7 7 | dict(map(lambda v: (v, v**2), nums)) - -C417.py:5:1: C417 [*] Unnecessary `map` usage (rewrite using a `list` comprehension) - | -3 | map(lambda x: x + 1, nums) -4 | map(lambda x: str(x), nums) -5 | list(map(lambda x: x * 2, nums)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -6 | set(map(lambda x: x % 2 == 0, nums)) -7 | dict(map(lambda v: (v, v**2), nums)) - | - = help: Replace `map` with a `list` comprehension - -ℹ Suggested fix -2 2 | nums = [1, 2, 3] -3 3 | map(lambda x: x + 1, nums) -4 4 | map(lambda x: str(x), nums) -5 |-list(map(lambda x: x * 2, nums)) - 5 |+[x * 2 for x in nums] -6 6 | set(map(lambda x: x % 2 == 0, nums)) -7 7 | dict(map(lambda v: (v, v**2), nums)) -8 8 | dict(map(lambda v: [v, v**2], nums)) - -C417.py:6:1: C417 [*] Unnecessary `map` usage (rewrite using a `set` comprehension) - | -4 | map(lambda x: str(x), nums) -5 | list(map(lambda x: x * 2, nums)) -6 | set(map(lambda x: x % 2 == 0, nums)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -7 | dict(map(lambda v: (v, v**2), nums)) -8 | dict(map(lambda v: [v, v**2], nums)) - | - = help: Replace `map` with a `set` comprehension - -ℹ Suggested fix -3 3 | map(lambda x: x + 1, nums) -4 4 | map(lambda x: str(x), nums) -5 5 | list(map(lambda x: x * 2, nums)) -6 |-set(map(lambda x: x % 2 == 0, nums)) - 6 |+{x % 2 == 0 for x in nums} -7 7 | dict(map(lambda v: (v, v**2), nums)) -8 8 | dict(map(lambda v: [v, v**2], nums)) -9 9 | map(lambda: "const", nums) - -C417.py:7:1: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehension) - | -5 | list(map(lambda x: x * 2, nums)) -6 | set(map(lambda x: x % 2 == 0, nums)) -7 | dict(map(lambda v: (v, v**2), nums)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -8 | dict(map(lambda v: [v, v**2], nums)) -9 | map(lambda: "const", nums) - | - = help: Replace `map` with a `dict` comprehension - -ℹ Suggested fix -4 4 | map(lambda x: str(x), nums) -5 5 | list(map(lambda x: x * 2, nums)) -6 6 | set(map(lambda x: x % 2 == 0, nums)) -7 |-dict(map(lambda v: (v, v**2), nums)) - 7 |+{v: v**2 for v in nums} -8 8 | dict(map(lambda v: [v, v**2], nums)) -9 9 | map(lambda: "const", nums) -10 10 | map(lambda _: 3.0, nums) - -C417.py:8:1: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehension) - | - 6 | set(map(lambda x: x % 2 == 0, nums)) - 7 | dict(map(lambda v: (v, v**2), nums)) - 8 | dict(map(lambda v: [v, v**2], nums)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 - 9 | map(lambda: "const", nums) -10 | map(lambda _: 3.0, nums) - | - = help: Replace `map` with a `dict` comprehension - -ℹ Suggested fix -5 5 | list(map(lambda x: x * 2, nums)) -6 6 | set(map(lambda x: x % 2 == 0, nums)) -7 7 | dict(map(lambda v: (v, v**2), nums)) -8 |-dict(map(lambda v: [v, v**2], nums)) - 8 |+{v: v**2 for v in nums} -9 9 | map(lambda: "const", nums) -10 10 | map(lambda _: 3.0, nums) -11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) - -C417.py:9:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) - | - 7 | dict(map(lambda v: (v, v**2), nums)) - 8 | dict(map(lambda v: [v, v**2], nums)) - 9 | map(lambda: "const", nums) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -10 | map(lambda _: 3.0, nums) -11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) - | - = help: Replace `map` with a generator expression - -ℹ Suggested fix -6 6 | set(map(lambda x: x % 2 == 0, nums)) -7 7 | dict(map(lambda v: (v, v**2), nums)) -8 8 | dict(map(lambda v: [v, v**2], nums)) -9 |-map(lambda: "const", nums) - 9 |+("const" for _ in nums) -10 10 | map(lambda _: 3.0, nums) -11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -12 12 | all(map(lambda v: isinstance(v, dict), nums)) - -C417.py:10:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) - | - 8 | dict(map(lambda v: [v, v**2], nums)) - 9 | map(lambda: "const", nums) -10 | map(lambda _: 3.0, nums) - | ^^^^^^^^^^^^^^^^^^^^^^^^ C417 -11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -12 | all(map(lambda v: isinstance(v, dict), nums)) - | - = help: Replace `map` with a generator expression - -ℹ Suggested fix -7 7 | dict(map(lambda v: (v, v**2), nums)) -8 8 | dict(map(lambda v: [v, v**2], nums)) -9 9 | map(lambda: "const", nums) -10 |-map(lambda _: 3.0, nums) - 10 |+(3.0 for _ in nums) -11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -12 12 | all(map(lambda v: isinstance(v, dict), nums)) -13 13 | filter(func, map(lambda v: v, nums)) - -C417.py:11:13: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) - | - 9 | map(lambda: "const", nums) -10 | map(lambda _: 3.0, nums) -11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -12 | all(map(lambda v: isinstance(v, dict), nums)) -13 | filter(func, map(lambda v: v, nums)) - | - = help: Replace `map` with a generator expression - -ℹ Suggested fix -8 8 | dict(map(lambda v: [v, v**2], nums)) -9 9 | map(lambda: "const", nums) -10 10 | map(lambda _: 3.0, nums) -11 |-_ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) - 11 |+_ = "".join((x in nums and "1" or "0" for x in range(123))) -12 12 | all(map(lambda v: isinstance(v, dict), nums)) -13 13 | filter(func, map(lambda v: v, nums)) -14 14 | list(map(lambda x, y: x * y, nums)) - -C417.py:12:5: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) - | -10 | map(lambda _: 3.0, nums) -11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -12 | all(map(lambda v: isinstance(v, dict), nums)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -13 | filter(func, map(lambda v: v, nums)) -14 | list(map(lambda x, y: x * y, nums)) - | - = help: Replace `map` with a generator expression - -ℹ Suggested fix -9 9 | map(lambda: "const", nums) -10 10 | map(lambda _: 3.0, nums) -11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -12 |-all(map(lambda v: isinstance(v, dict), nums)) - 12 |+all((isinstance(v, dict) for v in nums)) -13 13 | filter(func, map(lambda v: v, nums)) -14 14 | list(map(lambda x, y: x * y, nums)) -15 15 | - -C417.py:13:14: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) - | -11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -12 | all(map(lambda v: isinstance(v, dict), nums)) -13 | filter(func, map(lambda v: v, nums)) - | ^^^^^^^^^^^^^^^^^^^^^^ C417 -14 | list(map(lambda x, y: x * y, nums)) - | - = help: Replace `map` with a generator expression - -ℹ Suggested fix -10 10 | map(lambda _: 3.0, nums) -11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -12 12 | all(map(lambda v: isinstance(v, dict), nums)) -13 |-filter(func, map(lambda v: v, nums)) - 13 |+filter(func, (v for v in nums)) -14 14 | list(map(lambda x, y: x * y, nums)) -15 15 | -16 16 | # When inside f-string, then the fix should be surrounded by whitespace - -C417.py:14:1: C417 [*] Unnecessary `map` usage (rewrite using a `list` comprehension) - | -12 | all(map(lambda v: isinstance(v, dict), nums)) -13 | filter(func, map(lambda v: v, nums)) -14 | list(map(lambda x, y: x * y, nums)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -15 | -16 | # When inside f-string, then the fix should be surrounded by whitespace - | - = help: Replace `map` with a `list` comprehension - -ℹ Suggested fix -11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) -12 12 | all(map(lambda v: isinstance(v, dict), nums)) -13 13 | filter(func, map(lambda v: v, nums)) -14 |-list(map(lambda x, y: x * y, nums)) - 14 |+[x * y for x, y in nums] -15 15 | -16 16 | # When inside f-string, then the fix should be surrounded by whitespace -17 17 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" - -C417.py:17:8: C417 [*] Unnecessary `map` usage (rewrite using a `set` comprehension) - | -16 | # When inside f-string, then the fix should be surrounded by whitespace -17 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -18 | _ = f"{dict(map(lambda v: (v, v**2), nums))}" - | - = help: Replace `map` with a `set` comprehension - -ℹ Suggested fix -14 14 | list(map(lambda x, y: x * y, nums)) -15 15 | -16 16 | # When inside f-string, then the fix should be surrounded by whitespace -17 |-_ = f"{set(map(lambda x: x % 2 == 0, nums))}" - 17 |+_ = f"{ {x % 2 == 0 for x in nums} }" -18 18 | _ = f"{dict(map(lambda v: (v, v**2), nums))}" -19 19 | -20 20 | # False negatives. - -C417.py:18:8: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehension) - | -16 | # When inside f-string, then the fix should be surrounded by whitespace -17 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" -18 | _ = f"{dict(map(lambda v: (v, v**2), nums))}" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -19 | -20 | # False negatives. - | - = help: Replace `map` with a `dict` comprehension - -ℹ Suggested fix -15 15 | -16 16 | # When inside f-string, then the fix should be surrounded by whitespace -17 17 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" -18 |-_ = f"{dict(map(lambda v: (v, v**2), nums))}" - 18 |+_ = f"{ {v: v**2 for v in nums} }" -19 19 | -20 20 | # False negatives. -21 21 | map(lambda x=2, y=1: x + y, nums, nums) - -C417.py:36:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) - | -35 | # Error: the `x` is overridden by the inner lambda. -36 | map(lambda x: lambda x: x, range(4)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -37 | -38 | # Ok because of the default parameters, and variadic arguments. - | - = help: Replace `map` with a generator expression - -ℹ Suggested fix -33 33 | map(lambda x: lambda: x, range(4)) -34 34 | -35 35 | # Error: the `x` is overridden by the inner lambda. -36 |-map(lambda x: lambda x: x, range(4)) - 36 |+(lambda x: x for x in range(4)) -37 37 | -38 38 | # Ok because of the default parameters, and variadic arguments. -39 39 | map(lambda x=1: x, nums) - -C417.py:47:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) - | -46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 -47 | map(lambda x: x, y if y else z) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -48 | map(lambda x: x, (y if y else z)) -49 | map(lambda x: x, (x, y, z)) - | - = help: Replace `map` with a generator expression - -ℹ Suggested fix -44 44 | dict(map(lambda k, v: (k, v), keys, values)) -45 45 | -46 46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 -47 |-map(lambda x: x, y if y else z) - 47 |+(x for x in (y if y else z)) -48 48 | map(lambda x: x, (y if y else z)) -49 49 | map(lambda x: x, (x, y, z)) - -C417.py:48:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) - | -46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 -47 | map(lambda x: x, y if y else z) -48 | map(lambda x: x, (y if y else z)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 -49 | map(lambda x: x, (x, y, z)) - | - = help: Replace `map` with a generator expression - -ℹ Suggested fix -45 45 | -46 46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 -47 47 | map(lambda x: x, y if y else z) -48 |-map(lambda x: x, (y if y else z)) - 48 |+(x for x in (y if y else z)) -49 49 | map(lambda x: x, (x, y, z)) - -C417.py:49:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) - | -47 | map(lambda x: x, y if y else z) -48 | map(lambda x: x, (y if y else z)) -49 | map(lambda x: x, (x, y, z)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 - | - = help: Replace `map` with a generator expression - -ℹ Suggested fix -46 46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 -47 47 | map(lambda x: x, y if y else z) -48 48 | map(lambda x: x, (y if y else z)) -49 |-map(lambda x: x, (x, y, z)) - 49 |+(x for x in (x, y, z)) - - diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C418_C418.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C418_C418.py.snap deleted file mode 100644 index a37a92ba42..0000000000 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C418_C418.py.snap +++ /dev/null @@ -1,83 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_comprehensions/mod.rs ---- -C418.py:1:1: C418 [*] Unnecessary `dict` literal passed to `dict()` (remove the outer call to `dict()`) - | -1 | dict({}) - | ^^^^^^^^ C418 -2 | dict({'a': 1}) -3 | dict({'x': 1 for x in range(10)}) - | - = help: Remove outer `dict` call - -ℹ Suggested fix -1 |-dict({}) - 1 |+{} -2 2 | dict({'a': 1}) -3 3 | dict({'x': 1 for x in range(10)}) -4 4 | dict( - -C418.py:2:1: C418 [*] Unnecessary `dict` literal passed to `dict()` (remove the outer call to `dict()`) - | -1 | dict({}) -2 | dict({'a': 1}) - | ^^^^^^^^^^^^^^ C418 -3 | dict({'x': 1 for x in range(10)}) -4 | dict( - | - = help: Remove outer `dict` call - -ℹ Suggested fix -1 1 | dict({}) -2 |-dict({'a': 1}) - 2 |+{'a': 1} -3 3 | dict({'x': 1 for x in range(10)}) -4 4 | dict( -5 5 | {'x': 1 for x in range(10)} - -C418.py:3:1: C418 [*] Unnecessary `dict` comprehension passed to `dict()` (remove the outer call to `dict()`) - | -1 | dict({}) -2 | dict({'a': 1}) -3 | dict({'x': 1 for x in range(10)}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C418 -4 | dict( -5 | {'x': 1 for x in range(10)} - | - = help: Remove outer `dict` call - -ℹ Suggested fix -1 1 | dict({}) -2 2 | dict({'a': 1}) -3 |-dict({'x': 1 for x in range(10)}) - 3 |+{'x': 1 for x in range(10)} -4 4 | dict( -5 5 | {'x': 1 for x in range(10)} -6 6 | ) - -C418.py:4:1: C418 [*] Unnecessary `dict` comprehension passed to `dict()` (remove the outer call to `dict()`) - | -2 | dict({'a': 1}) -3 | dict({'x': 1 for x in range(10)}) -4 | / dict( -5 | | {'x': 1 for x in range(10)} -6 | | ) - | |_^ C418 -7 | -8 | dict({}, a=1) - | - = help: Remove outer `dict` call - -ℹ Suggested fix -1 1 | dict({}) -2 2 | dict({'a': 1}) -3 3 | dict({'x': 1 for x in range(10)}) -4 |-dict( -5 |- {'x': 1 for x in range(10)} -6 |-) - 4 |+{'x': 1 for x in range(10)} -7 5 | -8 6 | dict({}, a=1) -9 7 | dict({x: 1 for x in range(1)}, a=1) - - diff --git a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C419_C419.py.snap b/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C419_C419.py.snap deleted file mode 100644 index c0546111c4..0000000000 --- a/crates/ruff/src/rules/flake8_comprehensions/snapshots/ruff__rules__flake8_comprehensions__tests__C419_C419.py.snap +++ /dev/null @@ -1,164 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_comprehensions/mod.rs ---- -C419.py:1:5: C419 [*] Unnecessary list comprehension. - | -1 | any([x.id for x in bar]) - | ^^^^^^^^^^^^^^^^^^^ C419 -2 | all([x.id for x in bar]) -3 | any( # first comment - | - = help: Remove unnecessary list comprehension - -ℹ Suggested fix -1 |-any([x.id for x in bar]) - 1 |+any(x.id for x in bar) -2 2 | all([x.id for x in bar]) -3 3 | any( # first comment -4 4 | [x.id for x in bar], # second comment - -C419.py:2:5: C419 [*] Unnecessary list comprehension. - | -1 | any([x.id for x in bar]) -2 | all([x.id for x in bar]) - | ^^^^^^^^^^^^^^^^^^^ C419 -3 | any( # first comment -4 | [x.id for x in bar], # second comment - | - = help: Remove unnecessary list comprehension - -ℹ Suggested fix -1 1 | any([x.id for x in bar]) -2 |-all([x.id for x in bar]) - 2 |+all(x.id for x in bar) -3 3 | any( # first comment -4 4 | [x.id for x in bar], # second comment -5 5 | ) # third comment - -C419.py:4:5: C419 [*] Unnecessary list comprehension. - | -2 | all([x.id for x in bar]) -3 | any( # first comment -4 | [x.id for x in bar], # second comment - | ^^^^^^^^^^^^^^^^^^^ C419 -5 | ) # third comment -6 | all( # first comment - | - = help: Remove unnecessary list comprehension - -ℹ Suggested fix -1 1 | any([x.id for x in bar]) -2 2 | all([x.id for x in bar]) -3 3 | any( # first comment -4 |- [x.id for x in bar], # second comment - 4 |+ x.id for x in bar # second comment -5 5 | ) # third comment -6 6 | all( # first comment -7 7 | [x.id for x in bar], # second comment - -C419.py:7:5: C419 [*] Unnecessary list comprehension. - | -5 | ) # third comment -6 | all( # first comment -7 | [x.id for x in bar], # second comment - | ^^^^^^^^^^^^^^^^^^^ C419 -8 | ) # third comment -9 | any({x.id for x in bar}) - | - = help: Remove unnecessary list comprehension - -ℹ Suggested fix -4 4 | [x.id for x in bar], # second comment -5 5 | ) # third comment -6 6 | all( # first comment -7 |- [x.id for x in bar], # second comment - 7 |+ x.id for x in bar # second comment -8 8 | ) # third comment -9 9 | any({x.id for x in bar}) -10 10 | - -C419.py:9:5: C419 [*] Unnecessary list comprehension. - | - 7 | [x.id for x in bar], # second comment - 8 | ) # third comment - 9 | any({x.id for x in bar}) - | ^^^^^^^^^^^^^^^^^^^ C419 -10 | -11 | # OK - | - = help: Remove unnecessary list comprehension - -ℹ Suggested fix -6 6 | all( # first comment -7 7 | [x.id for x in bar], # second comment -8 8 | ) # third comment -9 |-any({x.id for x in bar}) - 9 |+any(x.id for x in bar) -10 10 | -11 11 | # OK -12 12 | all(x.id for x in bar) - -C419.py:24:5: C419 [*] Unnecessary list comprehension. - | -22 | # Special comment handling -23 | any( -24 | [ # lbracket comment - | _____^ -25 | | # second line comment -26 | | i.bit_count() -27 | | # random middle comment -28 | | for i in range(5) # rbracket comment -29 | | ] # rpar comment - | |_____^ C419 -30 | # trailing comment -31 | ) - | - = help: Remove unnecessary list comprehension - -ℹ Suggested fix -21 21 | -22 22 | # Special comment handling -23 23 | any( -24 |- [ # lbracket comment -25 |- # second line comment -26 |- i.bit_count() - 24 |+ # lbracket comment - 25 |+ # second line comment - 26 |+ i.bit_count() -27 27 | # random middle comment -28 |- for i in range(5) # rbracket comment -29 |- ] # rpar comment - 28 |+ for i in range(5) # rbracket comment # rpar comment -30 29 | # trailing comment -31 30 | ) -32 31 | - -C419.py:35:5: C419 [*] Unnecessary list comprehension. - | -33 | # Weird case where the function call, opening bracket, and comment are all -34 | # on the same line. -35 | any([ # lbracket comment - | _____^ -36 | | # second line comment -37 | | i.bit_count() for i in range(5) # rbracket comment -38 | | ] # rpar comment - | |_____^ C419 -39 | ) - | - = help: Remove unnecessary list comprehension - -ℹ Suggested fix -32 32 | -33 33 | # Weird case where the function call, opening bracket, and comment are all -34 34 | # on the same line. -35 |-any([ # lbracket comment -36 |- # second line comment -37 |- i.bit_count() for i in range(5) # rbracket comment -38 |- ] # rpar comment - 35 |+any( - 36 |+# lbracket comment - 37 |+# second line comment - 38 |+i.bit_count() for i in range(5) # rbracket comment # rpar comment -39 39 | ) - - diff --git a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__char_boundary.snap b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__char_boundary.snap deleted file mode 100644 index 914f3528d0..0000000000 --- a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__char_boundary.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_copyright/mod.rs ---- -:1:1: CPY001 Missing copyright notice at top of file - | -1 | কককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককক - | CPY001 - | - - diff --git a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__invalid_author.snap b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__invalid_author.snap deleted file mode 100644 index 4393791320..0000000000 --- a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__invalid_author.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_copyright/mod.rs ---- -:1:1: CPY001 Missing copyright notice at top of file - | -1 | # Copyright (C) 2023 Some Author - | CPY001 -2 | -3 | import os - | - - diff --git a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__late_notice.snap b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__late_notice.snap deleted file mode 100644 index 17efa2aa8d..0000000000 --- a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__late_notice.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_copyright/mod.rs ---- -:1:1: CPY001 Missing copyright notice at top of file - | -1 | # Content Content Content Content Content Content Content Content Content Content - | CPY001 -2 | # Content Content Content Content Content Content Content Content Content Content -3 | # Content Content Content Content Content Content Content Content Content Content - | - - diff --git a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice.snap b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice.snap deleted file mode 100644 index 383a7b0dac..0000000000 --- a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_copyright/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_c.snap b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_c.snap deleted file mode 100644 index 383a7b0dac..0000000000 --- a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_c.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_copyright/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_caps.snap b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_caps.snap deleted file mode 100644 index 383a7b0dac..0000000000 --- a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_caps.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_copyright/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_range.snap b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_range.snap deleted file mode 100644 index 383a7b0dac..0000000000 --- a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__notice_with_range.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_copyright/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__small_file.snap b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__small_file.snap deleted file mode 100644 index 383a7b0dac..0000000000 --- a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__small_file.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_copyright/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__valid_author.snap b/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__valid_author.snap deleted file mode 100644 index 383a7b0dac..0000000000 --- a/crates/ruff/src/rules/flake8_copyright/snapshots/ruff__rules__flake8_copyright__tests__valid_author.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_copyright/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ001_DTZ001.py.snap b/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ001_DTZ001.py.snap deleted file mode 100644 index 70434e4d3e..0000000000 --- a/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ001_DTZ001.py.snap +++ /dev/null @@ -1,49 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_datetimez/mod.rs ---- -DTZ001.py:4:1: DTZ001 The use of `datetime.datetime()` without `tzinfo` argument is not allowed - | -3 | # no args -4 | datetime.datetime(2000, 1, 1, 0, 0, 0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 -5 | -6 | # none args - | - -DTZ001.py:7:1: DTZ001 The use of `datetime.datetime()` without `tzinfo` argument is not allowed - | -6 | # none args -7 | datetime.datetime(2000, 1, 1, 0, 0, 0, 0, None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 -8 | -9 | # not none arg - | - -DTZ001.py:13:1: DTZ001 The use of `datetime.datetime()` without `tzinfo` argument is not allowed - | -12 | # no kwargs -13 | datetime.datetime(2000, 1, 1, fold=1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 -14 | -15 | # none kwargs - | - -DTZ001.py:16:1: DTZ001 The use of `datetime.datetime()` without `tzinfo` argument is not allowed - | -15 | # none kwargs -16 | datetime.datetime(2000, 1, 1, tzinfo=None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 -17 | -18 | from datetime import datetime - | - -DTZ001.py:21:1: DTZ001 The use of `datetime.datetime()` without `tzinfo` argument is not allowed - | -20 | # no args unqualified -21 | datetime(2000, 1, 1, 0, 0, 0) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 -22 | -23 | # uses `astimezone` method - | - - diff --git a/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ002_DTZ002.py.snap b/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ002_DTZ002.py.snap deleted file mode 100644 index 8ea66ef3ee..0000000000 --- a/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ002_DTZ002.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_datetimez/mod.rs ---- -DTZ002.py:4:1: DTZ002 The use of `datetime.datetime.today()` is not allowed, use `datetime.datetime.now(tz=)` instead - | -3 | # qualified -4 | datetime.datetime.today() - | ^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ002 -5 | -6 | from datetime import datetime - | - -DTZ002.py:9:1: DTZ002 The use of `datetime.datetime.today()` is not allowed, use `datetime.datetime.now(tz=)` instead - | - 8 | # unqualified - 9 | datetime.today() - | ^^^^^^^^^^^^^^^^ DTZ002 -10 | -11 | # uses `astimezone` method - | - - diff --git a/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ003_DTZ003.py.snap b/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ003_DTZ003.py.snap deleted file mode 100644 index 3bf5215e39..0000000000 --- a/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ003_DTZ003.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_datetimez/mod.rs ---- -DTZ003.py:4:1: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead - | -3 | # qualified -4 | datetime.datetime.utcnow() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ003 -5 | -6 | from datetime import datetime - | - -DTZ003.py:9:1: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead - | - 8 | # unqualified - 9 | datetime.utcnow() - | ^^^^^^^^^^^^^^^^^ DTZ003 -10 | -11 | # uses `astimezone` method - | - - diff --git a/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ004_DTZ004.py.snap b/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ004_DTZ004.py.snap deleted file mode 100644 index 95f2f2e68a..0000000000 --- a/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ004_DTZ004.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_datetimez/mod.rs ---- -DTZ004.py:4:1: DTZ004 The use of `datetime.datetime.utcfromtimestamp()` is not allowed, use `datetime.datetime.fromtimestamp(ts, tz=)` instead - | -3 | # qualified -4 | datetime.datetime.utcfromtimestamp(1234) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ004 -5 | -6 | from datetime import datetime - | - -DTZ004.py:9:1: DTZ004 The use of `datetime.datetime.utcfromtimestamp()` is not allowed, use `datetime.datetime.fromtimestamp(ts, tz=)` instead - | - 8 | # unqualified - 9 | datetime.utcfromtimestamp(1234) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ004 -10 | -11 | # uses `astimezone` method - | - - diff --git a/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ005_DTZ005.py.snap b/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ005_DTZ005.py.snap deleted file mode 100644 index e037abffa6..0000000000 --- a/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ005_DTZ005.py.snap +++ /dev/null @@ -1,49 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_datetimez/mod.rs ---- -DTZ005.py:4:1: DTZ005 The use of `datetime.datetime.now()` without `tz` argument is not allowed - | -3 | # no args -4 | datetime.datetime.now() - | ^^^^^^^^^^^^^^^^^^^^^^^ DTZ005 -5 | -6 | # wrong keywords - | - -DTZ005.py:7:1: DTZ005 The use of `datetime.datetime.now()` without `tz` argument is not allowed - | -6 | # wrong keywords -7 | datetime.datetime.now(bad=datetime.timezone.utc) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ005 -8 | -9 | # none args - | - -DTZ005.py:10:1: DTZ005 The use of `datetime.datetime.now()` without `tz` argument is not allowed - | - 9 | # none args -10 | datetime.datetime.now(None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ005 -11 | -12 | # none keywords - | - -DTZ005.py:13:1: DTZ005 The use of `datetime.datetime.now()` without `tz` argument is not allowed - | -12 | # none keywords -13 | datetime.datetime.now(tz=None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ005 -14 | -15 | from datetime import datetime - | - -DTZ005.py:18:1: DTZ005 The use of `datetime.datetime.now()` without `tz` argument is not allowed - | -17 | # no args unqualified -18 | datetime.now() - | ^^^^^^^^^^^^^^ DTZ005 -19 | -20 | # uses `astimezone` method - | - - diff --git a/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ006_DTZ006.py.snap b/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ006_DTZ006.py.snap deleted file mode 100644 index d5cba0cd7c..0000000000 --- a/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ006_DTZ006.py.snap +++ /dev/null @@ -1,49 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_datetimez/mod.rs ---- -DTZ006.py:4:1: DTZ006 The use of `datetime.datetime.fromtimestamp()` without `tz` argument is not allowed - | -3 | # no args -4 | datetime.datetime.fromtimestamp(1234) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 -5 | -6 | # wrong keywords - | - -DTZ006.py:7:1: DTZ006 The use of `datetime.datetime.fromtimestamp()` without `tz` argument is not allowed - | -6 | # wrong keywords -7 | datetime.datetime.fromtimestamp(1234, bad=datetime.timezone.utc) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 -8 | -9 | # none args - | - -DTZ006.py:10:1: DTZ006 The use of `datetime.datetime.fromtimestamp()` without `tz` argument is not allowed - | - 9 | # none args -10 | datetime.datetime.fromtimestamp(1234, None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 -11 | -12 | # none keywords - | - -DTZ006.py:13:1: DTZ006 The use of `datetime.datetime.fromtimestamp()` without `tz` argument is not allowed - | -12 | # none keywords -13 | datetime.datetime.fromtimestamp(1234, tz=None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 -14 | -15 | from datetime import datetime - | - -DTZ006.py:18:1: DTZ006 The use of `datetime.datetime.fromtimestamp()` without `tz` argument is not allowed - | -17 | # no args unqualified -18 | datetime.fromtimestamp(1234) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 -19 | -20 | # uses `astimezone` method - | - - diff --git a/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ007_DTZ007.py.snap b/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ007_DTZ007.py.snap deleted file mode 100644 index 3cc06876f0..0000000000 --- a/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ007_DTZ007.py.snap +++ /dev/null @@ -1,47 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_datetimez/mod.rs ---- -DTZ007.py:4:1: DTZ007 The use of `datetime.datetime.strptime()` without %z must be followed by `.replace(tzinfo=)` or `.astimezone()` - | -3 | # bad format -4 | datetime.datetime.strptime("something", "%H:%M:%S%Z") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 -5 | -6 | # no replace or astimezone - | - -DTZ007.py:7:1: DTZ007 The use of `datetime.datetime.strptime()` without %z must be followed by `.replace(tzinfo=)` or `.astimezone()` - | -6 | # no replace or astimezone -7 | datetime.datetime.strptime("something", "something") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 -8 | -9 | # wrong replace - | - -DTZ007.py:10:1: DTZ007 The use of `datetime.datetime.strptime()` without %z must be followed by `.replace(tzinfo=)` or `.astimezone()` - | - 9 | # wrong replace -10 | datetime.datetime.strptime("something", "something").replace(hour=1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 -11 | -12 | # none replace - | - -DTZ007.py:13:1: DTZ007 The use of `datetime.datetime.strptime()` without %z must be followed by `.replace(tzinfo=)` or `.astimezone()` - | -12 | # none replace -13 | datetime.datetime.strptime("something", "something").replace(tzinfo=None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 -14 | -15 | # OK - | - -DTZ007.py:35:1: DTZ007 The use of `datetime.datetime.strptime()` without %z must be followed by `.replace(tzinfo=)` or `.astimezone()` - | -34 | # no replace orastimezone unqualified -35 | datetime.strptime("something", "something") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 - | - - diff --git a/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ011_DTZ011.py.snap b/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ011_DTZ011.py.snap deleted file mode 100644 index daedfde5b4..0000000000 --- a/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ011_DTZ011.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_datetimez/mod.rs ---- -DTZ011.py:4:1: DTZ011 The use of `datetime.date.today()` is not allowed, use `datetime.datetime.now(tz=).date()` instead - | -3 | # qualified -4 | datetime.date.today() - | ^^^^^^^^^^^^^^^^^^^^^ DTZ011 -5 | -6 | from datetime import date - | - -DTZ011.py:9:1: DTZ011 The use of `datetime.date.today()` is not allowed, use `datetime.datetime.now(tz=).date()` instead - | -8 | # unqualified -9 | date.today() - | ^^^^^^^^^^^^ DTZ011 - | - - diff --git a/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ012_DTZ012.py.snap b/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ012_DTZ012.py.snap deleted file mode 100644 index 49b5aeeb27..0000000000 --- a/crates/ruff/src/rules/flake8_datetimez/snapshots/ruff__rules__flake8_datetimez__tests__DTZ012_DTZ012.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_datetimez/mod.rs ---- -DTZ012.py:4:1: DTZ012 The use of `datetime.date.fromtimestamp()` is not allowed, use `datetime.datetime.fromtimestamp(ts, tz=).date()` instead - | -3 | # qualified -4 | datetime.date.fromtimestamp(1234) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ012 -5 | -6 | from datetime import date - | - -DTZ012.py:9:1: DTZ012 The use of `datetime.date.fromtimestamp()` is not allowed, use `datetime.datetime.fromtimestamp(ts, tz=).date()` instead - | -8 | # unqualified -9 | date.fromtimestamp(1234) - | ^^^^^^^^^^^^^^^^^^^^^^^^ DTZ012 - | - - diff --git a/crates/ruff/src/rules/flake8_debugger/snapshots/ruff__rules__flake8_debugger__tests__T100_T100.py.snap b/crates/ruff/src/rules/flake8_debugger/snapshots/ruff__rules__flake8_debugger__tests__T100_T100.py.snap deleted file mode 100644 index f204bc1be4..0000000000 --- a/crates/ruff/src/rules/flake8_debugger/snapshots/ruff__rules__flake8_debugger__tests__T100_T100.py.snap +++ /dev/null @@ -1,88 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_debugger/mod.rs ---- -T100.py:1:1: T100 Trace found: `breakpoint` used - | -1 | breakpoint() - | ^^^^^^^^^^^^ T100 -2 | -3 | import pdb - | - -T100.py:3:1: T100 Import for `pdb` found - | -1 | breakpoint() -2 | -3 | import pdb - | ^^^^^^^^^^ T100 -4 | import builtins -5 | from builtins import breakpoint - | - -T100.py:5:1: T100 Import for `builtins.breakpoint` found - | -3 | import pdb -4 | import builtins -5 | from builtins import breakpoint - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ T100 -6 | from pdb import set_trace as st -7 | from celery.contrib.rdb import set_trace - | - -T100.py:6:1: T100 Import for `pdb.set_trace` found - | -4 | import builtins -5 | from builtins import breakpoint -6 | from pdb import set_trace as st - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ T100 -7 | from celery.contrib.rdb import set_trace -8 | from celery.contrib import rdb - | - -T100.py:7:1: T100 Import for `celery.contrib.rdb.set_trace` found - | -5 | from builtins import breakpoint -6 | from pdb import set_trace as st -7 | from celery.contrib.rdb import set_trace - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ T100 -8 | from celery.contrib import rdb -9 | import celery.contrib.rdb - | - -T100.py:9:1: T100 Import for `celery.contrib.rdb` found - | - 7 | from celery.contrib.rdb import set_trace - 8 | from celery.contrib import rdb - 9 | import celery.contrib.rdb - | ^^^^^^^^^^^^^^^^^^^^^^^^^ T100 -10 | -11 | breakpoint() - | - -T100.py:11:1: T100 Trace found: `builtins.breakpoint` used - | - 9 | import celery.contrib.rdb -10 | -11 | breakpoint() - | ^^^^^^^^^^^^ T100 -12 | st() -13 | set_trace() - | - -T100.py:12:1: T100 Trace found: `pdb.set_trace` used - | -11 | breakpoint() -12 | st() - | ^^^^ T100 -13 | set_trace() - | - -T100.py:13:1: T100 Trace found: `celery.contrib.rdb.set_trace` used - | -11 | breakpoint() -12 | st() -13 | set_trace() - | ^^^^^^^^^^^ T100 - | - - diff --git a/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ001_DJ001.py.snap b/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ001_DJ001.py.snap deleted file mode 100644 index a6fa006bfe..0000000000 --- a/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ001_DJ001.py.snap +++ /dev/null @@ -1,172 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_django/mod.rs ---- -DJ001.py:7:17: DJ001 Avoid using `null=True` on string-based fields such as CharField - | -6 | class IncorrectModel(models.Model): -7 | charfield = models.CharField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 -8 | textfield = models.TextField(max_length=255, null=True) -9 | slugfield = models.SlugField(max_length=255, null=True) - | - -DJ001.py:8:17: DJ001 Avoid using `null=True` on string-based fields such as TextField - | - 6 | class IncorrectModel(models.Model): - 7 | charfield = models.CharField(max_length=255, null=True) - 8 | textfield = models.TextField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 - 9 | slugfield = models.SlugField(max_length=255, null=True) -10 | emailfield = models.EmailField(max_length=255, null=True) - | - -DJ001.py:9:17: DJ001 Avoid using `null=True` on string-based fields such as SlugField - | - 7 | charfield = models.CharField(max_length=255, null=True) - 8 | textfield = models.TextField(max_length=255, null=True) - 9 | slugfield = models.SlugField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 -10 | emailfield = models.EmailField(max_length=255, null=True) -11 | filepathfield = models.FilePathField(max_length=255, null=True) - | - -DJ001.py:10:18: DJ001 Avoid using `null=True` on string-based fields such as EmailField - | - 8 | textfield = models.TextField(max_length=255, null=True) - 9 | slugfield = models.SlugField(max_length=255, null=True) -10 | emailfield = models.EmailField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 -11 | filepathfield = models.FilePathField(max_length=255, null=True) -12 | urlfield = models.URLField(max_length=255, null=True) - | - -DJ001.py:11:21: DJ001 Avoid using `null=True` on string-based fields such as FilePathField - | - 9 | slugfield = models.SlugField(max_length=255, null=True) -10 | emailfield = models.EmailField(max_length=255, null=True) -11 | filepathfield = models.FilePathField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 -12 | urlfield = models.URLField(max_length=255, null=True) - | - -DJ001.py:12:16: DJ001 Avoid using `null=True` on string-based fields such as URLField - | -10 | emailfield = models.EmailField(max_length=255, null=True) -11 | filepathfield = models.FilePathField(max_length=255, null=True) -12 | urlfield = models.URLField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 - | - -DJ001.py:16:17: DJ001 Avoid using `null=True` on string-based fields such as CharField - | -15 | class IncorrectModelWithAlias(DjangoModel): -16 | charfield = DjangoModel.CharField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 -17 | textfield = SmthCharField(max_length=255, null=True) -18 | slugfield = models.SlugField(max_length=255, null=True) - | - -DJ001.py:17:17: DJ001 Avoid using `null=True` on string-based fields such as CharField - | -15 | class IncorrectModelWithAlias(DjangoModel): -16 | charfield = DjangoModel.CharField(max_length=255, null=True) -17 | textfield = SmthCharField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 -18 | slugfield = models.SlugField(max_length=255, null=True) -19 | emailfield = models.EmailField(max_length=255, null=True) - | - -DJ001.py:18:17: DJ001 Avoid using `null=True` on string-based fields such as SlugField - | -16 | charfield = DjangoModel.CharField(max_length=255, null=True) -17 | textfield = SmthCharField(max_length=255, null=True) -18 | slugfield = models.SlugField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 -19 | emailfield = models.EmailField(max_length=255, null=True) -20 | filepathfield = models.FilePathField(max_length=255, null=True) - | - -DJ001.py:19:18: DJ001 Avoid using `null=True` on string-based fields such as EmailField - | -17 | textfield = SmthCharField(max_length=255, null=True) -18 | slugfield = models.SlugField(max_length=255, null=True) -19 | emailfield = models.EmailField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 -20 | filepathfield = models.FilePathField(max_length=255, null=True) -21 | urlfield = models.URLField(max_length=255, null=True) - | - -DJ001.py:20:21: DJ001 Avoid using `null=True` on string-based fields such as FilePathField - | -18 | slugfield = models.SlugField(max_length=255, null=True) -19 | emailfield = models.EmailField(max_length=255, null=True) -20 | filepathfield = models.FilePathField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 -21 | urlfield = models.URLField(max_length=255, null=True) - | - -DJ001.py:21:16: DJ001 Avoid using `null=True` on string-based fields such as URLField - | -19 | emailfield = models.EmailField(max_length=255, null=True) -20 | filepathfield = models.FilePathField(max_length=255, null=True) -21 | urlfield = models.URLField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 - | - -DJ001.py:25:17: DJ001 Avoid using `null=True` on string-based fields such as CharField - | -24 | class IncorrectModelWithoutSuperclass: -25 | charfield = DjangoModel.CharField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 -26 | textfield = SmthCharField(max_length=255, null=True) -27 | slugfield = models.SlugField(max_length=255, null=True) - | - -DJ001.py:26:17: DJ001 Avoid using `null=True` on string-based fields such as CharField - | -24 | class IncorrectModelWithoutSuperclass: -25 | charfield = DjangoModel.CharField(max_length=255, null=True) -26 | textfield = SmthCharField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 -27 | slugfield = models.SlugField(max_length=255, null=True) -28 | emailfield = models.EmailField(max_length=255, null=True) - | - -DJ001.py:27:17: DJ001 Avoid using `null=True` on string-based fields such as SlugField - | -25 | charfield = DjangoModel.CharField(max_length=255, null=True) -26 | textfield = SmthCharField(max_length=255, null=True) -27 | slugfield = models.SlugField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 -28 | emailfield = models.EmailField(max_length=255, null=True) -29 | filepathfield = models.FilePathField(max_length=255, null=True) - | - -DJ001.py:28:18: DJ001 Avoid using `null=True` on string-based fields such as EmailField - | -26 | textfield = SmthCharField(max_length=255, null=True) -27 | slugfield = models.SlugField(max_length=255, null=True) -28 | emailfield = models.EmailField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 -29 | filepathfield = models.FilePathField(max_length=255, null=True) -30 | urlfield = models.URLField(max_length=255, null=True) - | - -DJ001.py:29:21: DJ001 Avoid using `null=True` on string-based fields such as FilePathField - | -27 | slugfield = models.SlugField(max_length=255, null=True) -28 | emailfield = models.EmailField(max_length=255, null=True) -29 | filepathfield = models.FilePathField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 -30 | urlfield = models.URLField(max_length=255, null=True) - | - -DJ001.py:30:16: DJ001 Avoid using `null=True` on string-based fields such as URLField - | -28 | emailfield = models.EmailField(max_length=255, null=True) -29 | filepathfield = models.FilePathField(max_length=255, null=True) -30 | urlfield = models.URLField(max_length=255, null=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 - | - - diff --git a/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ003_DJ003.py.snap b/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ003_DJ003.py.snap deleted file mode 100644 index 014661f8f5..0000000000 --- a/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ003_DJ003.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_django/mod.rs ---- -DJ003.py:5:42: DJ003 Avoid passing `locals()` as context to a `render` function - | -4 | def test_view1(request): -5 | return render(request, "index.html", locals()) - | ^^^^^^^^ DJ003 - | - -DJ003.py:9:50: DJ003 Avoid passing `locals()` as context to a `render` function - | -8 | def test_view2(request): -9 | return render(request, "index.html", context=locals()) - | ^^^^^^^^ DJ003 - | - - diff --git a/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ006_DJ006.py.snap b/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ006_DJ006.py.snap deleted file mode 100644 index 2ba4b024b8..0000000000 --- a/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ006_DJ006.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_django/mod.rs ---- -DJ006.py:6:9: DJ006 Do not use `exclude` with `ModelForm`, use `fields` instead - | -4 | class TestModelForm1(forms.ModelForm): -5 | class Meta: -6 | exclude = ["bar"] - | ^^^^^^^ DJ006 - | - - diff --git a/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ007_DJ007.py.snap b/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ007_DJ007.py.snap deleted file mode 100644 index 00719cd28a..0000000000 --- a/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ007_DJ007.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_django/mod.rs ---- -DJ007.py:6:9: DJ007 Do not use `__all__` with `ModelForm`, use `fields` instead - | -4 | class TestModelForm1(forms.ModelForm): -5 | class Meta: -6 | fields = "__all__" - | ^^^^^^^^^^^^^^^^^^ DJ007 - | - -DJ007.py:11:9: DJ007 Do not use `__all__` with `ModelForm`, use `fields` instead - | - 9 | class TestModelForm2(forms.ModelForm): -10 | class Meta: -11 | fields = b"__all__" - | ^^^^^^^^^^^^^^^^^^^ DJ007 - | - - diff --git a/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ008_DJ008.py.snap b/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ008_DJ008.py.snap deleted file mode 100644 index 2aae3d948b..0000000000 --- a/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ008_DJ008.py.snap +++ /dev/null @@ -1,26 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_django/mod.rs ---- -DJ008.py:6:7: DJ008 Model does not define `__str__` method - | -5 | # Models without __str__ -6 | class TestModel1(models.Model): - | ^^^^^^^^^^ DJ008 -7 | new_field = models.CharField(max_length=10) - | - -DJ008.py:21:7: DJ008 Model does not define `__str__` method - | -21 | class TestModel2(Model): - | ^^^^^^^^^^ DJ008 -22 | new_field = models.CharField(max_length=10) - | - -DJ008.py:36:7: DJ008 Model does not define `__str__` method - | -36 | class TestModel3(Model): - | ^^^^^^^^^^ DJ008 -37 | new_field = models.CharField(max_length=10) - | - - diff --git a/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ012_DJ012.py.snap b/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ012_DJ012.py.snap deleted file mode 100644 index d187a99a41..0000000000 --- a/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ012_DJ012.py.snap +++ /dev/null @@ -1,57 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_django/mod.rs ---- -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 | -28 | first_name = models.CharField(max_length=32) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ012 - | - -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 | -43 | first_name = models.CharField(max_length=32) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ012 - | - -DJ012.py:56:5: DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: `__str__` method should come before custom method - | -54 | pass -55 | -56 | def __str__(self): - | _____^ -57 | | return "foobar" - | |_______________________^ DJ012 - | - -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): - | _____^ -70 | | pass - | |____________^ DJ012 - | - -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 | -123 | first_name = models.CharField(max_length=32) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ012 -124 | last_name = models.CharField(max_length=32) - | - -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 | -129 | middle_name = models.CharField(max_length=32) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ012 - | - - diff --git a/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ013_DJ013.py.snap b/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ013_DJ013.py.snap deleted file mode 100644 index a10ff04665..0000000000 --- a/crates/ruff/src/rules/flake8_django/snapshots/ruff__rules__flake8_django__tests__DJ013_DJ013.py.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_django/mod.rs ---- -DJ013.py:15:1: DJ013 `@receiver` decorator must be on top of all the other decorators - | -14 | @test_decorator -15 | @receiver(pre_save, sender=MyModel) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ013 -16 | def incorrect_pre_save_handler(): -17 | pass - | - -DJ013.py:35:1: DJ013 `@receiver` decorator must be on top of all the other decorators - | -33 | @receiver(pre_save, sender=MyModel) -34 | @test_decorator -35 | @receiver(pre_save, sender=MyModel) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ013 -36 | def incorrect_multiple(): -37 | pass - | - - diff --git a/crates/ruff/src/rules/flake8_errmsg/snapshots/ruff__rules__flake8_errmsg__tests__custom.snap b/crates/ruff/src/rules/flake8_errmsg/snapshots/ruff__rules__flake8_errmsg__tests__custom.snap deleted file mode 100644 index d81a528ec0..0000000000 --- a/crates/ruff/src/rules/flake8_errmsg/snapshots/ruff__rules__flake8_errmsg__tests__custom.snap +++ /dev/null @@ -1,180 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_errmsg/mod.rs ---- -EM.py:5:24: EM101 [*] Exception must not use a string literal, assign to variable first - | -4 | def f_a(): -5 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 - | - = help: Assign to variable; remove string literal - -ℹ Suggested fix -2 2 | -3 3 | -4 4 | def f_a(): -5 |- raise RuntimeError("This is an example exception") - 5 |+ msg = "This is an example exception" - 6 |+ raise RuntimeError(msg) -6 7 | -7 8 | -8 9 | def f_a_short(): - -EM.py:18:24: EM102 [*] Exception must not use an f-string literal, assign to variable first - | -16 | def f_b(): -17 | example = "example" -18 | raise RuntimeError(f"This is an {example} exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM102 - | - = help: Assign to variable; remove f-string literal - -ℹ Suggested fix -15 15 | -16 16 | def f_b(): -17 17 | example = "example" -18 |- raise RuntimeError(f"This is an {example} exception") - 18 |+ msg = f"This is an {example} exception" - 19 |+ raise RuntimeError(msg) -19 20 | -20 21 | -21 22 | def f_c(): - -EM.py:22:24: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first - | -21 | def f_c(): -22 | raise RuntimeError("This is an {example} exception".format(example="example")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM103 - | - = help: Assign to variable; remove `.format()` string - -ℹ Suggested fix -19 19 | -20 20 | -21 21 | def f_c(): -22 |- raise RuntimeError("This is an {example} exception".format(example="example")) - 22 |+ msg = "This is an {example} exception".format(example="example") - 23 |+ raise RuntimeError(msg) -23 24 | -24 25 | -25 26 | def f_ok(): - -EM.py:32:24: EM101 Exception must not use a string literal, assign to variable first - | -30 | def f_unfixable(): -31 | msg = "hello" -32 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 - | - = help: Assign to variable; remove string literal - -EM.py:39:24: EM101 [*] Exception must not use a string literal, assign to variable first - | -37 | msg = "hello" -38 | -39 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 - | - = help: Assign to variable; remove string literal - -ℹ Suggested fix -36 36 | def nested(): -37 37 | msg = "hello" -38 38 | -39 |- raise RuntimeError("This is an example exception") - 39 |+ msg = "This is an example exception" - 40 |+ raise RuntimeError(msg) -40 41 | -41 42 | -42 43 | def f_msg_in_parent_scope(): - -EM.py:46:28: EM101 Exception must not use a string literal, assign to variable first - | -45 | def nested(): -46 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 - | - = help: Assign to variable; remove string literal - -EM.py:51:28: EM101 [*] Exception must not use a string literal, assign to variable first - | -49 | def f_fix_indentation_check(foo): -50 | if foo: -51 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 -52 | else: -53 | if foo == "foo": - | - = help: Assign to variable; remove string literal - -ℹ Suggested fix -48 48 | -49 49 | def f_fix_indentation_check(foo): -50 50 | if foo: -51 |- raise RuntimeError("This is an example exception") - 51 |+ msg = "This is an example exception" - 52 |+ raise RuntimeError(msg) -52 53 | else: -53 54 | if foo == "foo": -54 55 | raise RuntimeError(f"This is an exception: {foo}") - -EM.py:54:32: EM102 [*] Exception must not use an f-string literal, assign to variable first - | -52 | else: -53 | if foo == "foo": -54 | raise RuntimeError(f"This is an exception: {foo}") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM102 -55 | raise RuntimeError("This is an exception: {}".format(foo)) - | - = help: Assign to variable; remove f-string literal - -ℹ Suggested fix -51 51 | raise RuntimeError("This is an example exception") -52 52 | else: -53 53 | if foo == "foo": -54 |- raise RuntimeError(f"This is an exception: {foo}") - 54 |+ msg = f"This is an exception: {foo}" - 55 |+ raise RuntimeError(msg) -55 56 | raise RuntimeError("This is an exception: {}".format(foo)) -56 57 | -57 58 | - -EM.py:55:24: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first - | -53 | if foo == "foo": -54 | raise RuntimeError(f"This is an exception: {foo}") -55 | raise RuntimeError("This is an exception: {}".format(foo)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM103 - | - = help: Assign to variable; remove `.format()` string - -ℹ Suggested fix -52 52 | else: -53 53 | if foo == "foo": -54 54 | raise RuntimeError(f"This is an exception: {foo}") -55 |- raise RuntimeError("This is an exception: {}".format(foo)) - 55 |+ msg = "This is an exception: {}".format(foo) - 56 |+ raise RuntimeError(msg) -56 57 | -57 58 | -58 59 | # Report these, but don't fix them - -EM.py:59:28: EM101 Exception must not use a string literal, assign to variable first - | -58 | # Report these, but don't fix them -59 | if foo: raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 -60 | if foo: x = 1; raise RuntimeError("This is an example exception") - | - = help: Assign to variable; remove string literal - -EM.py:60:35: EM101 Exception must not use a string literal, assign to variable first - | -58 | # Report these, but don't fix them -59 | if foo: raise RuntimeError("This is an example exception") -60 | if foo: x = 1; raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 - | - = help: Assign to variable; remove string literal - - diff --git a/crates/ruff/src/rules/flake8_errmsg/snapshots/ruff__rules__flake8_errmsg__tests__defaults.snap b/crates/ruff/src/rules/flake8_errmsg/snapshots/ruff__rules__flake8_errmsg__tests__defaults.snap deleted file mode 100644 index 0d9bfcb9e0..0000000000 --- a/crates/ruff/src/rules/flake8_errmsg/snapshots/ruff__rules__flake8_errmsg__tests__defaults.snap +++ /dev/null @@ -1,218 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_errmsg/mod.rs ---- -EM.py:5:24: EM101 [*] Exception must not use a string literal, assign to variable first - | -4 | def f_a(): -5 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 - | - = help: Assign to variable; remove string literal - -ℹ Suggested fix -2 2 | -3 3 | -4 4 | def f_a(): -5 |- raise RuntimeError("This is an example exception") - 5 |+ msg = "This is an example exception" - 6 |+ raise RuntimeError(msg) -6 7 | -7 8 | -8 9 | def f_a_short(): - -EM.py:9:24: EM101 [*] Exception must not use a string literal, assign to variable first - | -8 | def f_a_short(): -9 | raise RuntimeError("Error") - | ^^^^^^^ EM101 - | - = help: Assign to variable; remove string literal - -ℹ Suggested fix -6 6 | -7 7 | -8 8 | def f_a_short(): -9 |- raise RuntimeError("Error") - 9 |+ msg = "Error" - 10 |+ raise RuntimeError(msg) -10 11 | -11 12 | -12 13 | def f_a_empty(): - -EM.py:13:24: EM101 [*] Exception must not use a string literal, assign to variable first - | -12 | def f_a_empty(): -13 | raise RuntimeError("") - | ^^ EM101 - | - = help: Assign to variable; remove string literal - -ℹ Suggested fix -10 10 | -11 11 | -12 12 | def f_a_empty(): -13 |- raise RuntimeError("") - 13 |+ msg = "" - 14 |+ raise RuntimeError(msg) -14 15 | -15 16 | -16 17 | def f_b(): - -EM.py:18:24: EM102 [*] Exception must not use an f-string literal, assign to variable first - | -16 | def f_b(): -17 | example = "example" -18 | raise RuntimeError(f"This is an {example} exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM102 - | - = help: Assign to variable; remove f-string literal - -ℹ Suggested fix -15 15 | -16 16 | def f_b(): -17 17 | example = "example" -18 |- raise RuntimeError(f"This is an {example} exception") - 18 |+ msg = f"This is an {example} exception" - 19 |+ raise RuntimeError(msg) -19 20 | -20 21 | -21 22 | def f_c(): - -EM.py:22:24: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first - | -21 | def f_c(): -22 | raise RuntimeError("This is an {example} exception".format(example="example")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM103 - | - = help: Assign to variable; remove `.format()` string - -ℹ Suggested fix -19 19 | -20 20 | -21 21 | def f_c(): -22 |- raise RuntimeError("This is an {example} exception".format(example="example")) - 22 |+ msg = "This is an {example} exception".format(example="example") - 23 |+ raise RuntimeError(msg) -23 24 | -24 25 | -25 26 | def f_ok(): - -EM.py:32:24: EM101 Exception must not use a string literal, assign to variable first - | -30 | def f_unfixable(): -31 | msg = "hello" -32 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 - | - = help: Assign to variable; remove string literal - -EM.py:39:24: EM101 [*] Exception must not use a string literal, assign to variable first - | -37 | msg = "hello" -38 | -39 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 - | - = help: Assign to variable; remove string literal - -ℹ Suggested fix -36 36 | def nested(): -37 37 | msg = "hello" -38 38 | -39 |- raise RuntimeError("This is an example exception") - 39 |+ msg = "This is an example exception" - 40 |+ raise RuntimeError(msg) -40 41 | -41 42 | -42 43 | def f_msg_in_parent_scope(): - -EM.py:46:28: EM101 Exception must not use a string literal, assign to variable first - | -45 | def nested(): -46 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 - | - = help: Assign to variable; remove string literal - -EM.py:51:28: EM101 [*] Exception must not use a string literal, assign to variable first - | -49 | def f_fix_indentation_check(foo): -50 | if foo: -51 | raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 -52 | else: -53 | if foo == "foo": - | - = help: Assign to variable; remove string literal - -ℹ Suggested fix -48 48 | -49 49 | def f_fix_indentation_check(foo): -50 50 | if foo: -51 |- raise RuntimeError("This is an example exception") - 51 |+ msg = "This is an example exception" - 52 |+ raise RuntimeError(msg) -52 53 | else: -53 54 | if foo == "foo": -54 55 | raise RuntimeError(f"This is an exception: {foo}") - -EM.py:54:32: EM102 [*] Exception must not use an f-string literal, assign to variable first - | -52 | else: -53 | if foo == "foo": -54 | raise RuntimeError(f"This is an exception: {foo}") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM102 -55 | raise RuntimeError("This is an exception: {}".format(foo)) - | - = help: Assign to variable; remove f-string literal - -ℹ Suggested fix -51 51 | raise RuntimeError("This is an example exception") -52 52 | else: -53 53 | if foo == "foo": -54 |- raise RuntimeError(f"This is an exception: {foo}") - 54 |+ msg = f"This is an exception: {foo}" - 55 |+ raise RuntimeError(msg) -55 56 | raise RuntimeError("This is an exception: {}".format(foo)) -56 57 | -57 58 | - -EM.py:55:24: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first - | -53 | if foo == "foo": -54 | raise RuntimeError(f"This is an exception: {foo}") -55 | raise RuntimeError("This is an exception: {}".format(foo)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM103 - | - = help: Assign to variable; remove `.format()` string - -ℹ Suggested fix -52 52 | else: -53 53 | if foo == "foo": -54 54 | raise RuntimeError(f"This is an exception: {foo}") -55 |- raise RuntimeError("This is an exception: {}".format(foo)) - 55 |+ msg = "This is an exception: {}".format(foo) - 56 |+ raise RuntimeError(msg) -56 57 | -57 58 | -58 59 | # Report these, but don't fix them - -EM.py:59:28: EM101 Exception must not use a string literal, assign to variable first - | -58 | # Report these, but don't fix them -59 | if foo: raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 -60 | if foo: x = 1; raise RuntimeError("This is an example exception") - | - = help: Assign to variable; remove string literal - -EM.py:60:35: EM101 Exception must not use a string literal, assign to variable first - | -58 | # Report these, but don't fix them -59 | if foo: raise RuntimeError("This is an example exception") -60 | if foo: x = 1; raise RuntimeError("This is an example exception") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 - | - = help: Assign to variable; remove string literal - - diff --git a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE001_1.py.snap b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE001_1.py.snap deleted file mode 100644 index ce8d160f86..0000000000 --- a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE001_1.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_executable/mod.rs ---- -EXE001_1.py:1:1: EXE001 Shebang is present but file is not executable - | -1 | #!/usr/bin/python - | ^^^^^^^^^^^^^^^^^ EXE001 -2 | -3 | if __name__ == '__main__': - | - - diff --git a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE001_2.py.snap b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE001_2.py.snap deleted file mode 100644 index 49d4bb0c77..0000000000 --- a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE001_2.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_executable/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE001_3.py.snap b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE001_3.py.snap deleted file mode 100644 index 49d4bb0c77..0000000000 --- a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE001_3.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_executable/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE002_1.py.snap b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE002_1.py.snap deleted file mode 100644 index a63902d2cf..0000000000 --- a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE002_1.py.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_executable/mod.rs ---- -EXE002_1.py:1:1: EXE002 The file is executable but no shebang is present - | -1 | if __name__ == '__main__': - | EXE002 -2 | print('I should be executable.') - | - - diff --git a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE002_2.py.snap b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE002_2.py.snap deleted file mode 100644 index 49d4bb0c77..0000000000 --- a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE002_2.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_executable/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE002_3.py.snap b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE002_3.py.snap deleted file mode 100644 index 49d4bb0c77..0000000000 --- a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE002_3.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_executable/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE003.py.snap b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE003.py.snap deleted file mode 100644 index 5ac99db866..0000000000 --- a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE003.py.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_executable/mod.rs ---- -EXE003.py:1:1: EXE003 Shebang should contain `python` - | -1 | #!/usr/bin/bash - | ^^^^^^^^^^^^^^^ EXE003 -2 | print("hello world") - | - - diff --git a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_1.py.snap b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_1.py.snap deleted file mode 100644 index 1cda8e5af0..0000000000 --- a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_1.py.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_executable/mod.rs ---- -EXE004_1.py:1:1: EXE004 [*] Avoid whitespace before shebang - | -1 | #!/usr/bin/python - | ^^^^ EXE004 - | - = help: Remove whitespace before shebang - -ℹ Fix -1 |- #!/usr/bin/python - 1 |+#!/usr/bin/python - - diff --git a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_2.py.snap b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_2.py.snap deleted file mode 100644 index 49d4bb0c77..0000000000 --- a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_2.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_executable/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_3.py.snap b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_3.py.snap deleted file mode 100644 index 7a1b02bc25..0000000000 --- a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_3.py.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_executable/mod.rs ---- -EXE004_3.py:2:7: EXE005 Shebang should be at the beginning of the file - | -2 | pass #!/usr/bin/env python - | ^^^^^^^^^^^^^^^^^^^^^ EXE005 - | - - diff --git a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_4.py.snap b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_4.py.snap deleted file mode 100644 index 06f93a1885..0000000000 --- a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_4.py.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_executable/mod.rs ---- -EXE004_4.py:1:1: EXE004 [*] Avoid whitespace before shebang - | -1 | / -2 | | #!/usr/bin/env python - | |____^ EXE004 - | - = help: Remove whitespace before shebang - -ℹ Fix -1 |- -2 |- #!/usr/bin/env python - 1 |+#!/usr/bin/env python - - diff --git a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_1.py.snap b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_1.py.snap deleted file mode 100644 index 510c0ee5f9..0000000000 --- a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_1.py.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_executable/mod.rs ---- -EXE005_1.py:3:1: EXE005 Shebang should be at the beginning of the file - | -2 | # A python comment -3 | #!/usr/bin/python - | ^^^^^^^^^^^^^^^^^ EXE005 - | - - diff --git a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_2.py.snap b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_2.py.snap deleted file mode 100644 index 124bcea10e..0000000000 --- a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_2.py.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_executable/mod.rs ---- -EXE005_2.py:4:1: EXE005 Shebang should be at the beginning of the file - | -3 | # A python comment -4 | #!/usr/bin/python - | ^^^^^^^^^^^^^^^^^ EXE005 - | - - diff --git a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_3.py.snap b/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_3.py.snap deleted file mode 100644 index 44fadb275d..0000000000 --- a/crates/ruff/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE005_3.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_executable/mod.rs ---- -EXE005_3.py:6:1: EXE005 Shebang should be at the beginning of the file - | -4 | """ -5 | # A python comment -6 | #!/usr/bin/python - | ^^^^^^^^^^^^^^^^^ EXE005 - | - - diff --git a/crates/ruff/src/rules/flake8_fixme/snapshots/ruff__rules__flake8_fixme__tests__line-contains-fixme_T00.py.snap b/crates/ruff/src/rules/flake8_fixme/snapshots/ruff__rules__flake8_fixme__tests__line-contains-fixme_T00.py.snap deleted file mode 100644 index fd3b5650b6..0000000000 --- a/crates/ruff/src/rules/flake8_fixme/snapshots/ruff__rules__flake8_fixme__tests__line-contains-fixme_T00.py.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_fixme/mod.rs ---- -T00.py:7:3: FIX001 Line contains FIXME, consider resolving the issue - | -5 | # HACK: hack -6 | # hack: hack -7 | # FIXME: fixme - | ^^^^^ FIX001 -8 | # fixme: fixme - | - -T00.py:8:3: FIX001 Line contains FIXME, consider resolving the issue - | -6 | # hack: hack -7 | # FIXME: fixme -8 | # fixme: fixme - | ^^^^^ FIX001 - | - - diff --git a/crates/ruff/src/rules/flake8_fixme/snapshots/ruff__rules__flake8_fixme__tests__line-contains-hack_T00.py.snap b/crates/ruff/src/rules/flake8_fixme/snapshots/ruff__rules__flake8_fixme__tests__line-contains-hack_T00.py.snap deleted file mode 100644 index af6e776411..0000000000 --- a/crates/ruff/src/rules/flake8_fixme/snapshots/ruff__rules__flake8_fixme__tests__line-contains-hack_T00.py.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_fixme/mod.rs ---- -T00.py:5:3: FIX004 Line contains HACK, consider resolving the issue - | -3 | # XXX: xxx -4 | # xxx: xxx -5 | # HACK: hack - | ^^^^ FIX004 -6 | # hack: hack -7 | # FIXME: fixme - | - -T00.py:6:3: FIX004 Line contains HACK, consider resolving the issue - | -4 | # xxx: xxx -5 | # HACK: hack -6 | # hack: hack - | ^^^^ FIX004 -7 | # FIXME: fixme -8 | # fixme: fixme - | - - diff --git a/crates/ruff/src/rules/flake8_fixme/snapshots/ruff__rules__flake8_fixme__tests__line-contains-todo_T00.py.snap b/crates/ruff/src/rules/flake8_fixme/snapshots/ruff__rules__flake8_fixme__tests__line-contains-todo_T00.py.snap deleted file mode 100644 index 291305b5e5..0000000000 --- a/crates/ruff/src/rules/flake8_fixme/snapshots/ruff__rules__flake8_fixme__tests__line-contains-todo_T00.py.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_fixme/mod.rs ---- -T00.py:1:3: FIX002 Line contains TODO, consider resolving the issue - | -1 | # TODO: todo - | ^^^^ FIX002 -2 | # todo: todo -3 | # XXX: xxx - | - -T00.py:2:3: FIX002 Line contains TODO, consider resolving the issue - | -1 | # TODO: todo -2 | # todo: todo - | ^^^^ FIX002 -3 | # XXX: xxx -4 | # xxx: xxx - | - - diff --git a/crates/ruff/src/rules/flake8_fixme/snapshots/ruff__rules__flake8_fixme__tests__line-contains-xxx_T00.py.snap b/crates/ruff/src/rules/flake8_fixme/snapshots/ruff__rules__flake8_fixme__tests__line-contains-xxx_T00.py.snap deleted file mode 100644 index e1123d8b76..0000000000 --- a/crates/ruff/src/rules/flake8_fixme/snapshots/ruff__rules__flake8_fixme__tests__line-contains-xxx_T00.py.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_fixme/mod.rs ---- -T00.py:3:3: FIX003 Line contains XXX, consider resolving the issue - | -1 | # TODO: todo -2 | # todo: todo -3 | # XXX: xxx - | ^^^ FIX003 -4 | # xxx: xxx -5 | # HACK: hack - | - -T00.py:4:3: FIX003 Line contains XXX, consider resolving the issue - | -2 | # todo: todo -3 | # XXX: xxx -4 | # xxx: xxx - | ^^^ FIX003 -5 | # HACK: hack -6 | # hack: hack - | - - diff --git a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__edge_case.py.snap b/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__edge_case.py.snap deleted file mode 100644 index ed1dc0f3df..0000000000 --- a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__edge_case.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_future_annotations/mod.rs ---- -edge_case.py:5:13: FA100 Missing `from __future__ import annotations`, but uses `typing.List` - | -5 | def main(_: List[int]) -> None: - | ^^^^ FA100 -6 | a_list: t.List[str] = [] -7 | a_list.append("hello") - | - -edge_case.py:6:13: FA100 Missing `from __future__ import annotations`, but uses `typing.List` - | -5 | def main(_: List[int]) -> None: -6 | a_list: t.List[str] = [] - | ^^^^^^ FA100 -7 | a_list.append("hello") - | - - diff --git a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_lowercase.py.snap b/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_lowercase.py.snap deleted file mode 100644 index 14acba04f7..0000000000 --- a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_lowercase.py.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_future_annotations/mod.rs ---- -no_future_import_uses_lowercase.py:2:13: FA102 Missing `from __future__ import annotations`, but uses PEP 585 collection - | -1 | def main() -> None: -2 | a_list: list[str] = [] - | ^^^^^^^^^ FA102 -3 | a_list.append("hello") - | - -no_future_import_uses_lowercase.py:6:14: FA102 Missing `from __future__ import annotations`, but uses PEP 585 collection - | -6 | def hello(y: dict[str, int]) -> None: - | ^^^^^^^^^^^^^^ FA102 -7 | del y - | - - diff --git a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union.py.snap b/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union.py.snap deleted file mode 100644 index ad8c75c621..0000000000 --- a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union.py.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_future_annotations/mod.rs ---- -no_future_import_uses_union.py:2:13: FA102 Missing `from __future__ import annotations`, but uses PEP 585 collection - | -1 | def main() -> None: -2 | a_list: list[str] | None = [] - | ^^^^^^^^^ FA102 -3 | a_list.append("hello") - | - -no_future_import_uses_union.py:2:13: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union - | -1 | def main() -> None: -2 | a_list: list[str] | None = [] - | ^^^^^^^^^^^^^^^^ FA102 -3 | a_list.append("hello") - | - -no_future_import_uses_union.py:6:14: FA102 Missing `from __future__ import annotations`, but uses PEP 585 collection - | -6 | def hello(y: dict[str, int] | None) -> None: - | ^^^^^^^^^^^^^^ FA102 -7 | del y - | - -no_future_import_uses_union.py:6:14: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union - | -6 | def hello(y: dict[str, int] | None) -> None: - | ^^^^^^^^^^^^^^^^^^^^^ FA102 -7 | del y - | - - diff --git a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union_inner.py.snap b/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union_inner.py.snap deleted file mode 100644 index 7f5156463a..0000000000 --- a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union_inner.py.snap +++ /dev/null @@ -1,52 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_future_annotations/mod.rs ---- -no_future_import_uses_union_inner.py:2:13: FA102 Missing `from __future__ import annotations`, but uses PEP 585 collection - | -1 | def main() -> None: -2 | a_list: list[str | None] = [] - | ^^^^^^^^^^^^^^^^ FA102 -3 | a_list.append("hello") - | - -no_future_import_uses_union_inner.py:2:18: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union - | -1 | def main() -> None: -2 | a_list: list[str | None] = [] - | ^^^^^^^^^^ FA102 -3 | a_list.append("hello") - | - -no_future_import_uses_union_inner.py:6:14: FA102 Missing `from __future__ import annotations`, but uses PEP 585 collection - | -6 | def hello(y: dict[str | None, int]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^ FA102 -7 | z: tuple[str, str | None, str] = tuple(y) -8 | del z - | - -no_future_import_uses_union_inner.py:6:19: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union - | -6 | def hello(y: dict[str | None, int]) -> None: - | ^^^^^^^^^^ FA102 -7 | z: tuple[str, str | None, str] = tuple(y) -8 | del z - | - -no_future_import_uses_union_inner.py:7:8: FA102 Missing `from __future__ import annotations`, but uses PEP 585 collection - | -6 | def hello(y: dict[str | None, int]) -> None: -7 | z: tuple[str, str | None, str] = tuple(y) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FA102 -8 | del z - | - -no_future_import_uses_union_inner.py:7:19: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union - | -6 | def hello(y: dict[str | None, int]) -> None: -7 | z: tuple[str, str | None, str] = tuple(y) - | ^^^^^^^^^^ FA102 -8 | del z - | - - diff --git a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__fa102_ok_no_types.py.snap b/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__fa102_ok_no_types.py.snap deleted file mode 100644 index 681d4be5e5..0000000000 --- a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__fa102_ok_no_types.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_future_annotations/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__fa102_ok_uses_future.py.snap b/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__fa102_ok_uses_future.py.snap deleted file mode 100644 index 681d4be5e5..0000000000 --- a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__fa102_ok_uses_future.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_future_annotations/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__from_typing_import.py.snap b/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__from_typing_import.py.snap deleted file mode 100644 index 4ffbf6ba6a..0000000000 --- a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__from_typing_import.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_future_annotations/mod.rs ---- -from_typing_import.py:5:13: FA100 Missing `from __future__ import annotations`, but uses `typing.List` - | -4 | def main() -> None: -5 | a_list: List[str] = [] - | ^^^^ FA100 -6 | a_list.append("hello") - | - - diff --git a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__from_typing_import_many.py.snap b/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__from_typing_import_many.py.snap deleted file mode 100644 index 37017f7d78..0000000000 --- a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__from_typing_import_many.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_future_annotations/mod.rs ---- -from_typing_import_many.py:5:13: FA100 Missing `from __future__ import annotations`, but uses `typing.List` - | -4 | def main() -> None: -5 | a_list: List[Optional[str]] = [] - | ^^^^ FA100 -6 | a_list.append("hello") -7 | a_dict = cast(Dict[int | None, Union[int, Set[bool]]], {}) - | - -from_typing_import_many.py:5:18: FA100 Missing `from __future__ import annotations`, but uses `typing.Optional` - | -4 | def main() -> None: -5 | a_list: List[Optional[str]] = [] - | ^^^^^^^^ FA100 -6 | a_list.append("hello") -7 | a_dict = cast(Dict[int | None, Union[int, Set[bool]]], {}) - | - - diff --git a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__import_typing.py.snap b/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__import_typing.py.snap deleted file mode 100644 index 179e9aa72e..0000000000 --- a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__import_typing.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_future_annotations/mod.rs ---- -import_typing.py:5:13: FA100 Missing `from __future__ import annotations`, but uses `typing.List` - | -4 | def main() -> None: -5 | a_list: typing.List[str] = [] - | ^^^^^^^^^^^ FA100 -6 | a_list.append("hello") - | - - diff --git a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__import_typing_as.py.snap b/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__import_typing_as.py.snap deleted file mode 100644 index f8589d42e5..0000000000 --- a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__import_typing_as.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_future_annotations/mod.rs ---- -import_typing_as.py:5:13: FA100 Missing `from __future__ import annotations`, but uses `typing.List` - | -4 | def main() -> None: -5 | a_list: t.List[str] = [] - | ^^^^^^ FA100 -6 | a_list.append("hello") - | - - diff --git a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__no_future_import_uses_lowercase.py.snap b/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__no_future_import_uses_lowercase.py.snap deleted file mode 100644 index 681d4be5e5..0000000000 --- a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__no_future_import_uses_lowercase.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_future_annotations/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__no_future_import_uses_union.py.snap b/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__no_future_import_uses_union.py.snap deleted file mode 100644 index 681d4be5e5..0000000000 --- a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__no_future_import_uses_union.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_future_annotations/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__no_future_import_uses_union_inner.py.snap b/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__no_future_import_uses_union_inner.py.snap deleted file mode 100644 index 681d4be5e5..0000000000 --- a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__no_future_import_uses_union_inner.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_future_annotations/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__ok_no_types.py.snap b/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__ok_no_types.py.snap deleted file mode 100644 index 681d4be5e5..0000000000 --- a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__ok_no_types.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_future_annotations/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__ok_non_simplifiable_types.py.snap b/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__ok_non_simplifiable_types.py.snap deleted file mode 100644 index 681d4be5e5..0000000000 --- a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__ok_non_simplifiable_types.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_future_annotations/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__ok_uses_future.py.snap b/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__ok_uses_future.py.snap deleted file mode 100644 index 681d4be5e5..0000000000 --- a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__ok_uses_future.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_future_annotations/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__ok_variable_name.py.snap b/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__ok_variable_name.py.snap deleted file mode 100644 index 681d4be5e5..0000000000 --- a/crates/ruff/src/rules/flake8_future_annotations/snapshots/ruff__rules__flake8_future_annotations__tests__ok_variable_name.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_future_annotations/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_gettext/snapshots/ruff__rules__flake8_gettext__tests__f-string-in-get-text-func-call_INT001.py.snap b/crates/ruff/src/rules/flake8_gettext/snapshots/ruff__rules__flake8_gettext__tests__f-string-in-get-text-func-call_INT001.py.snap deleted file mode 100644 index 9a24a8c490..0000000000 --- a/crates/ruff/src/rules/flake8_gettext/snapshots/ruff__rules__flake8_gettext__tests__f-string-in-get-text-func-call_INT001.py.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_gettext/mod.rs ---- -INT001.py:1:3: INT001 f-string is resolved before function call; consider `_("string %s") % arg` - | -1 | _(f"{'value'}") - | ^^^^^^^^^^^^ INT001 - | - - diff --git a/crates/ruff/src/rules/flake8_gettext/snapshots/ruff__rules__flake8_gettext__tests__format-in-get-text-func-call_INT002.py.snap b/crates/ruff/src/rules/flake8_gettext/snapshots/ruff__rules__flake8_gettext__tests__format-in-get-text-func-call_INT002.py.snap deleted file mode 100644 index af74cf0ff1..0000000000 --- a/crates/ruff/src/rules/flake8_gettext/snapshots/ruff__rules__flake8_gettext__tests__format-in-get-text-func-call_INT002.py.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_gettext/mod.rs ---- -INT002.py:1:3: INT002 `format` method argument is resolved before function call; consider `_("string %s") % arg` - | -1 | _("{}".format("line")) - | ^^^^^^^^^^^^^^^^^^^ INT002 - | - - diff --git a/crates/ruff/src/rules/flake8_gettext/snapshots/ruff__rules__flake8_gettext__tests__printf-in-get-text-func-call_INT003.py.snap b/crates/ruff/src/rules/flake8_gettext/snapshots/ruff__rules__flake8_gettext__tests__printf-in-get-text-func-call_INT003.py.snap deleted file mode 100644 index aef3fd5f2b..0000000000 --- a/crates/ruff/src/rules/flake8_gettext/snapshots/ruff__rules__flake8_gettext__tests__printf-in-get-text-func-call_INT003.py.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_gettext/mod.rs ---- -INT003.py:1:3: INT003 printf-style format is resolved before function call; consider `_("string %s") % arg` - | -1 | _("%s" % "line") - | ^^^^^^^^^^^^^ INT003 - | - - diff --git a/crates/ruff/src/rules/flake8_implicit_str_concat/snapshots/ruff__rules__flake8_implicit_str_concat__tests__ISC001_ISC.py.snap b/crates/ruff/src/rules/flake8_implicit_str_concat/snapshots/ruff__rules__flake8_implicit_str_concat__tests__ISC001_ISC.py.snap deleted file mode 100644 index bd6f5f5aee..0000000000 --- a/crates/ruff/src/rules/flake8_implicit_str_concat/snapshots/ruff__rules__flake8_implicit_str_concat__tests__ISC001_ISC.py.snap +++ /dev/null @@ -1,156 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_implicit_str_concat/mod.rs ---- -ISC.py:1:5: ISC001 [*] Implicitly concatenated string literals on one line - | -1 | _ = "a" "b" "c" - | ^^^^^^^ ISC001 -2 | -3 | _ = "abc" + "def" - | - = help: Combine string literals - -ℹ Fix -1 |-_ = "a" "b" "c" - 1 |+_ = "ab" "c" -2 2 | -3 3 | _ = "abc" + "def" -4 4 | - -ISC.py:1:9: ISC001 [*] Implicitly concatenated string literals on one line - | -1 | _ = "a" "b" "c" - | ^^^^^^^ ISC001 -2 | -3 | _ = "abc" + "def" - | - = help: Combine string literals - -ℹ Fix -1 |-_ = "a" "b" "c" - 1 |+_ = "a" "bc" -2 2 | -3 3 | _ = "abc" + "def" -4 4 | - -ISC.py:38:5: ISC001 [*] Implicitly concatenated string literals on one line - | -36 | ) -37 | -38 | _ = """a""" """b""" - | ^^^^^^^^^^^^^^^ ISC001 -39 | -40 | _ = """a - | - = help: Combine string literals - -ℹ Fix -35 35 | b"def" -36 36 | ) -37 37 | -38 |-_ = """a""" """b""" - 38 |+_ = """ab""" -39 39 | -40 40 | _ = """a -41 41 | b""" """c - -ISC.py:40:5: ISC001 [*] Implicitly concatenated string literals on one line - | -38 | _ = """a""" """b""" -39 | -40 | _ = """a - | _____^ -41 | | b""" """c -42 | | d""" - | |____^ ISC001 -43 | -44 | _ = f"""a""" f"""b""" - | - = help: Combine string literals - -ℹ Fix -38 38 | _ = """a""" """b""" -39 39 | -40 40 | _ = """a -41 |-b""" """c - 41 |+bc -42 42 | d""" -43 43 | -44 44 | _ = f"""a""" f"""b""" - -ISC.py:44:5: ISC001 [*] Implicitly concatenated string literals on one line - | -42 | d""" -43 | -44 | _ = f"""a""" f"""b""" - | ^^^^^^^^^^^^^^^^^ ISC001 -45 | -46 | _ = f"a" "b" - | - = help: Combine string literals - -ℹ Fix -41 41 | b""" """c -42 42 | d""" -43 43 | -44 |-_ = f"""a""" f"""b""" - 44 |+_ = f"""ab""" -45 45 | -46 46 | _ = f"a" "b" -47 47 | - -ISC.py:46:5: ISC001 Implicitly concatenated string literals on one line - | -44 | _ = f"""a""" f"""b""" -45 | -46 | _ = f"a" "b" - | ^^^^^^^^ ISC001 -47 | -48 | _ = """a""" "b" - | - = help: Combine string literals - -ISC.py:48:5: ISC001 Implicitly concatenated string literals on one line - | -46 | _ = f"a" "b" -47 | -48 | _ = """a""" "b" - | ^^^^^^^^^^^ ISC001 -49 | -50 | _ = 'a' "b" - | - = help: Combine string literals - -ISC.py:50:5: ISC001 Implicitly concatenated string literals on one line - | -48 | _ = """a""" "b" -49 | -50 | _ = 'a' "b" - | ^^^^^^^ ISC001 -51 | -52 | _ = rf"a" rf"b" - | - = help: Combine string literals - -ISC.py:52:5: ISC001 [*] Implicitly concatenated string literals on one line - | -50 | _ = 'a' "b" -51 | -52 | _ = rf"a" rf"b" - | ^^^^^^^^^^^ ISC001 -53 | -54 | # Single-line explicit concatenation should be ignored. - | - = help: Combine string literals - -ℹ Fix -49 49 | -50 50 | _ = 'a' "b" -51 51 | -52 |-_ = rf"a" rf"b" - 52 |+_ = rf"ab" -53 53 | -54 54 | # Single-line explicit concatenation should be ignored. -55 55 | _ = "abc" + "def" + "ghi" - - diff --git a/crates/ruff/src/rules/flake8_implicit_str_concat/snapshots/ruff__rules__flake8_implicit_str_concat__tests__ISC002_ISC.py.snap b/crates/ruff/src/rules/flake8_implicit_str_concat/snapshots/ruff__rules__flake8_implicit_str_concat__tests__ISC002_ISC.py.snap deleted file mode 100644 index ce7e5fcb16..0000000000 --- a/crates/ruff/src/rules/flake8_implicit_str_concat/snapshots/ruff__rules__flake8_implicit_str_concat__tests__ISC002_ISC.py.snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_implicit_str_concat/mod.rs ---- -ISC.py:5:5: ISC002 Implicitly concatenated string literals over multiple lines - | -3 | _ = "abc" + "def" -4 | -5 | _ = "abc" \ - | _____^ -6 | | "def" - | |_________^ ISC002 -7 | -8 | _ = ( - | - - diff --git a/crates/ruff/src/rules/flake8_implicit_str_concat/snapshots/ruff__rules__flake8_implicit_str_concat__tests__ISC003_ISC.py.snap b/crates/ruff/src/rules/flake8_implicit_str_concat/snapshots/ruff__rules__flake8_implicit_str_concat__tests__ISC003_ISC.py.snap deleted file mode 100644 index f27c2bfd1b..0000000000 --- a/crates/ruff/src/rules/flake8_implicit_str_concat/snapshots/ruff__rules__flake8_implicit_str_concat__tests__ISC003_ISC.py.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_implicit_str_concat/mod.rs ---- -ISC.py:9:3: ISC003 Explicitly concatenated string should be implicitly concatenated - | - 8 | _ = ( - 9 | "abc" + - | ___^ -10 | | "def" - | |_______^ ISC003 -11 | ) - | - -ISC.py:14:3: ISC003 Explicitly concatenated string should be implicitly concatenated - | -13 | _ = ( -14 | f"abc" + - | ___^ -15 | | "def" - | |_______^ ISC003 -16 | ) - | - -ISC.py:19:3: ISC003 Explicitly concatenated string should be implicitly concatenated - | -18 | _ = ( -19 | b"abc" + - | ___^ -20 | | b"def" - | |________^ ISC003 -21 | ) - | - - diff --git a/crates/ruff/src/rules/flake8_implicit_str_concat/snapshots/ruff__rules__flake8_implicit_str_concat__tests__multiline_ISC001_ISC.py.snap b/crates/ruff/src/rules/flake8_implicit_str_concat/snapshots/ruff__rules__flake8_implicit_str_concat__tests__multiline_ISC001_ISC.py.snap deleted file mode 100644 index bd6f5f5aee..0000000000 --- a/crates/ruff/src/rules/flake8_implicit_str_concat/snapshots/ruff__rules__flake8_implicit_str_concat__tests__multiline_ISC001_ISC.py.snap +++ /dev/null @@ -1,156 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_implicit_str_concat/mod.rs ---- -ISC.py:1:5: ISC001 [*] Implicitly concatenated string literals on one line - | -1 | _ = "a" "b" "c" - | ^^^^^^^ ISC001 -2 | -3 | _ = "abc" + "def" - | - = help: Combine string literals - -ℹ Fix -1 |-_ = "a" "b" "c" - 1 |+_ = "ab" "c" -2 2 | -3 3 | _ = "abc" + "def" -4 4 | - -ISC.py:1:9: ISC001 [*] Implicitly concatenated string literals on one line - | -1 | _ = "a" "b" "c" - | ^^^^^^^ ISC001 -2 | -3 | _ = "abc" + "def" - | - = help: Combine string literals - -ℹ Fix -1 |-_ = "a" "b" "c" - 1 |+_ = "a" "bc" -2 2 | -3 3 | _ = "abc" + "def" -4 4 | - -ISC.py:38:5: ISC001 [*] Implicitly concatenated string literals on one line - | -36 | ) -37 | -38 | _ = """a""" """b""" - | ^^^^^^^^^^^^^^^ ISC001 -39 | -40 | _ = """a - | - = help: Combine string literals - -ℹ Fix -35 35 | b"def" -36 36 | ) -37 37 | -38 |-_ = """a""" """b""" - 38 |+_ = """ab""" -39 39 | -40 40 | _ = """a -41 41 | b""" """c - -ISC.py:40:5: ISC001 [*] Implicitly concatenated string literals on one line - | -38 | _ = """a""" """b""" -39 | -40 | _ = """a - | _____^ -41 | | b""" """c -42 | | d""" - | |____^ ISC001 -43 | -44 | _ = f"""a""" f"""b""" - | - = help: Combine string literals - -ℹ Fix -38 38 | _ = """a""" """b""" -39 39 | -40 40 | _ = """a -41 |-b""" """c - 41 |+bc -42 42 | d""" -43 43 | -44 44 | _ = f"""a""" f"""b""" - -ISC.py:44:5: ISC001 [*] Implicitly concatenated string literals on one line - | -42 | d""" -43 | -44 | _ = f"""a""" f"""b""" - | ^^^^^^^^^^^^^^^^^ ISC001 -45 | -46 | _ = f"a" "b" - | - = help: Combine string literals - -ℹ Fix -41 41 | b""" """c -42 42 | d""" -43 43 | -44 |-_ = f"""a""" f"""b""" - 44 |+_ = f"""ab""" -45 45 | -46 46 | _ = f"a" "b" -47 47 | - -ISC.py:46:5: ISC001 Implicitly concatenated string literals on one line - | -44 | _ = f"""a""" f"""b""" -45 | -46 | _ = f"a" "b" - | ^^^^^^^^ ISC001 -47 | -48 | _ = """a""" "b" - | - = help: Combine string literals - -ISC.py:48:5: ISC001 Implicitly concatenated string literals on one line - | -46 | _ = f"a" "b" -47 | -48 | _ = """a""" "b" - | ^^^^^^^^^^^ ISC001 -49 | -50 | _ = 'a' "b" - | - = help: Combine string literals - -ISC.py:50:5: ISC001 Implicitly concatenated string literals on one line - | -48 | _ = """a""" "b" -49 | -50 | _ = 'a' "b" - | ^^^^^^^ ISC001 -51 | -52 | _ = rf"a" rf"b" - | - = help: Combine string literals - -ISC.py:52:5: ISC001 [*] Implicitly concatenated string literals on one line - | -50 | _ = 'a' "b" -51 | -52 | _ = rf"a" rf"b" - | ^^^^^^^^^^^ ISC001 -53 | -54 | # Single-line explicit concatenation should be ignored. - | - = help: Combine string literals - -ℹ Fix -49 49 | -50 50 | _ = 'a' "b" -51 51 | -52 |-_ = rf"a" rf"b" - 52 |+_ = rf"ab" -53 53 | -54 54 | # Single-line explicit concatenation should be ignored. -55 55 | _ = "abc" + "def" + "ghi" - - diff --git a/crates/ruff/src/rules/flake8_implicit_str_concat/snapshots/ruff__rules__flake8_implicit_str_concat__tests__multiline_ISC002_ISC.py.snap b/crates/ruff/src/rules/flake8_implicit_str_concat/snapshots/ruff__rules__flake8_implicit_str_concat__tests__multiline_ISC002_ISC.py.snap deleted file mode 100644 index 7a107ca106..0000000000 --- a/crates/ruff/src/rules/flake8_implicit_str_concat/snapshots/ruff__rules__flake8_implicit_str_concat__tests__multiline_ISC002_ISC.py.snap +++ /dev/null @@ -1,46 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_implicit_str_concat/mod.rs ---- -ISC.py:5:5: ISC002 Implicitly concatenated string literals over multiple lines - | -3 | _ = "abc" + "def" -4 | -5 | _ = "abc" \ - | _____^ -6 | | "def" - | |_________^ ISC002 -7 | -8 | _ = ( - | - -ISC.py:24:3: ISC002 Implicitly concatenated string literals over multiple lines - | -23 | _ = ( -24 | "abc" - | ___^ -25 | | "def" - | |_______^ ISC002 -26 | ) - | - -ISC.py:29:3: ISC002 Implicitly concatenated string literals over multiple lines - | -28 | _ = ( -29 | f"abc" - | ___^ -30 | | "def" - | |_______^ ISC002 -31 | ) - | - -ISC.py:34:3: ISC002 Implicitly concatenated string literals over multiple lines - | -33 | _ = ( -34 | b"abc" - | ___^ -35 | | b"def" - | |________^ ISC002 -36 | ) - | - - diff --git a/crates/ruff/src/rules/flake8_implicit_str_concat/snapshots/ruff__rules__flake8_implicit_str_concat__tests__multiline_ISC003_ISC.py.snap b/crates/ruff/src/rules/flake8_implicit_str_concat/snapshots/ruff__rules__flake8_implicit_str_concat__tests__multiline_ISC003_ISC.py.snap deleted file mode 100644 index f27c2bfd1b..0000000000 --- a/crates/ruff/src/rules/flake8_implicit_str_concat/snapshots/ruff__rules__flake8_implicit_str_concat__tests__multiline_ISC003_ISC.py.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_implicit_str_concat/mod.rs ---- -ISC.py:9:3: ISC003 Explicitly concatenated string should be implicitly concatenated - | - 8 | _ = ( - 9 | "abc" + - | ___^ -10 | | "def" - | |_______^ ISC003 -11 | ) - | - -ISC.py:14:3: ISC003 Explicitly concatenated string should be implicitly concatenated - | -13 | _ = ( -14 | f"abc" + - | ___^ -15 | | "def" - | |_______^ ISC003 -16 | ) - | - -ISC.py:19:3: ISC003 Explicitly concatenated string should be implicitly concatenated - | -18 | _ = ( -19 | b"abc" + - | ___^ -20 | | b"def" - | |________^ ISC003 -21 | ) - | - - diff --git a/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__custom.snap b/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__custom.snap deleted file mode 100644 index 1b7779d90d..0000000000 --- a/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__custom.snap +++ /dev/null @@ -1,308 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_import_conventions/mod.rs ---- -custom.py:3:8: ICN001 `altair` should be imported as `alt` - | -1 | import math # not checked -2 | -3 | import altair # unconventional - | ^^^^^^ ICN001 -4 | import dask.array # unconventional -5 | import dask.dataframe # unconventional - | - = help: Alias `altair` to `alt` - -custom.py:4:8: ICN001 `dask.array` should be imported as `da` - | -3 | import altair # unconventional -4 | import dask.array # unconventional - | ^^^^^^^^^^ ICN001 -5 | import dask.dataframe # unconventional -6 | import matplotlib.pyplot # unconventional - | - = help: Alias `dask.array` to `da` - -custom.py:5:8: ICN001 `dask.dataframe` should be imported as `dd` - | -3 | import altair # unconventional -4 | import dask.array # unconventional -5 | import dask.dataframe # unconventional - | ^^^^^^^^^^^^^^ ICN001 -6 | import matplotlib.pyplot # unconventional -7 | import numpy # unconventional - | - = help: Alias `dask.dataframe` to `dd` - -custom.py:6:8: ICN001 `matplotlib.pyplot` should be imported as `plt` - | -4 | import dask.array # unconventional -5 | import dask.dataframe # unconventional -6 | import matplotlib.pyplot # unconventional - | ^^^^^^^^^^^^^^^^^ ICN001 -7 | import numpy # unconventional -8 | import pandas # unconventional - | - = help: Alias `matplotlib.pyplot` to `plt` - -custom.py:7:8: ICN001 `numpy` should be imported as `np` - | -5 | import dask.dataframe # unconventional -6 | import matplotlib.pyplot # unconventional -7 | import numpy # unconventional - | ^^^^^ ICN001 -8 | import pandas # unconventional -9 | import seaborn # unconventional - | - = help: Alias `numpy` to `np` - -custom.py:8:8: ICN001 `pandas` should be imported as `pd` - | - 6 | import matplotlib.pyplot # unconventional - 7 | import numpy # unconventional - 8 | import pandas # unconventional - | ^^^^^^ ICN001 - 9 | import seaborn # unconventional -10 | import tensorflow # unconventional - | - = help: Alias `pandas` to `pd` - -custom.py:9:8: ICN001 `seaborn` should be imported as `sns` - | - 7 | import numpy # unconventional - 8 | import pandas # unconventional - 9 | import seaborn # unconventional - | ^^^^^^^ ICN001 -10 | import tensorflow # unconventional -11 | import holoviews # unconventional - | - = help: Alias `seaborn` to `sns` - -custom.py:10:8: ICN001 `tensorflow` should be imported as `tf` - | - 8 | import pandas # unconventional - 9 | import seaborn # unconventional -10 | import tensorflow # unconventional - | ^^^^^^^^^^ ICN001 -11 | import holoviews # unconventional -12 | import panel # unconventional - | - = help: Alias `tensorflow` to `tf` - -custom.py:11:8: ICN001 `holoviews` should be imported as `hv` - | - 9 | import seaborn # unconventional -10 | import tensorflow # unconventional -11 | import holoviews # unconventional - | ^^^^^^^^^ ICN001 -12 | import panel # unconventional -13 | import plotly.express # unconventional - | - = help: Alias `holoviews` to `hv` - -custom.py:12:8: ICN001 `panel` should be imported as `pn` - | -10 | import tensorflow # unconventional -11 | import holoviews # unconventional -12 | import panel # unconventional - | ^^^^^ ICN001 -13 | import plotly.express # unconventional -14 | import matplotlib # unconventional - | - = help: Alias `panel` to `pn` - -custom.py:13:8: ICN001 `plotly.express` should be imported as `px` - | -11 | import holoviews # unconventional -12 | import panel # unconventional -13 | import plotly.express # unconventional - | ^^^^^^^^^^^^^^ ICN001 -14 | import matplotlib # unconventional -15 | import polars # unconventional - | - = help: Alias `plotly.express` to `px` - -custom.py:14:8: ICN001 `matplotlib` should be imported as `mpl` - | -12 | import panel # unconventional -13 | import plotly.express # unconventional -14 | import matplotlib # unconventional - | ^^^^^^^^^^ ICN001 -15 | import polars # unconventional -16 | import pyarrow # unconventional - | - = help: Alias `matplotlib` to `mpl` - -custom.py:15:8: ICN001 `polars` should be imported as `pl` - | -13 | import plotly.express # unconventional -14 | import matplotlib # unconventional -15 | import polars # unconventional - | ^^^^^^ ICN001 -16 | import pyarrow # unconventional - | - = help: Alias `polars` to `pl` - -custom.py:16:8: ICN001 `pyarrow` should be imported as `pa` - | -14 | import matplotlib # unconventional -15 | import polars # unconventional -16 | import pyarrow # unconventional - | ^^^^^^^ ICN001 -17 | -18 | import altair as altr # unconventional - | - = help: Alias `pyarrow` to `pa` - -custom.py:18:18: ICN001 `altair` should be imported as `alt` - | -16 | import pyarrow # unconventional -17 | -18 | import altair as altr # unconventional - | ^^^^ ICN001 -19 | import matplotlib.pyplot as plot # unconventional -20 | import dask.array as darray # unconventional - | - = help: Alias `altair` to `alt` - -custom.py:19:29: ICN001 `matplotlib.pyplot` should be imported as `plt` - | -18 | import altair as altr # unconventional -19 | import matplotlib.pyplot as plot # unconventional - | ^^^^ ICN001 -20 | import dask.array as darray # unconventional -21 | import dask.dataframe as ddf # unconventional - | - = help: Alias `matplotlib.pyplot` to `plt` - -custom.py:20:22: ICN001 `dask.array` should be imported as `da` - | -18 | import altair as altr # unconventional -19 | import matplotlib.pyplot as plot # unconventional -20 | import dask.array as darray # unconventional - | ^^^^^^ ICN001 -21 | import dask.dataframe as ddf # unconventional -22 | import numpy as nmp # unconventional - | - = help: Alias `dask.array` to `da` - -custom.py:21:26: ICN001 `dask.dataframe` should be imported as `dd` - | -19 | import matplotlib.pyplot as plot # unconventional -20 | import dask.array as darray # unconventional -21 | import dask.dataframe as ddf # unconventional - | ^^^ ICN001 -22 | import numpy as nmp # unconventional -23 | import pandas as pdas # unconventional - | - = help: Alias `dask.dataframe` to `dd` - -custom.py:22:17: ICN001 `numpy` should be imported as `np` - | -20 | import dask.array as darray # unconventional -21 | import dask.dataframe as ddf # unconventional -22 | import numpy as nmp # unconventional - | ^^^ ICN001 -23 | import pandas as pdas # unconventional -24 | import seaborn as sbrn # unconventional - | - = help: Alias `numpy` to `np` - -custom.py:23:18: ICN001 `pandas` should be imported as `pd` - | -21 | import dask.dataframe as ddf # unconventional -22 | import numpy as nmp # unconventional -23 | import pandas as pdas # unconventional - | ^^^^ ICN001 -24 | import seaborn as sbrn # unconventional -25 | import tensorflow as tfz # unconventional - | - = help: Alias `pandas` to `pd` - -custom.py:24:19: ICN001 `seaborn` should be imported as `sns` - | -22 | import numpy as nmp # unconventional -23 | import pandas as pdas # unconventional -24 | import seaborn as sbrn # unconventional - | ^^^^ ICN001 -25 | import tensorflow as tfz # unconventional -26 | import holoviews as hsv # unconventional - | - = help: Alias `seaborn` to `sns` - -custom.py:25:22: ICN001 `tensorflow` should be imported as `tf` - | -23 | import pandas as pdas # unconventional -24 | import seaborn as sbrn # unconventional -25 | import tensorflow as tfz # unconventional - | ^^^ ICN001 -26 | import holoviews as hsv # unconventional -27 | import panel as pns # unconventional - | - = help: Alias `tensorflow` to `tf` - -custom.py:26:21: ICN001 `holoviews` should be imported as `hv` - | -24 | import seaborn as sbrn # unconventional -25 | import tensorflow as tfz # unconventional -26 | import holoviews as hsv # unconventional - | ^^^ ICN001 -27 | import panel as pns # unconventional -28 | import plotly.express as pltx # unconventional - | - = help: Alias `holoviews` to `hv` - -custom.py:27:17: ICN001 `panel` should be imported as `pn` - | -25 | import tensorflow as tfz # unconventional -26 | import holoviews as hsv # unconventional -27 | import panel as pns # unconventional - | ^^^ ICN001 -28 | import plotly.express as pltx # unconventional -29 | import matplotlib as ml # unconventional - | - = help: Alias `panel` to `pn` - -custom.py:28:26: ICN001 `plotly.express` should be imported as `px` - | -26 | import holoviews as hsv # unconventional -27 | import panel as pns # unconventional -28 | import plotly.express as pltx # unconventional - | ^^^^ ICN001 -29 | import matplotlib as ml # unconventional -30 | import polars as ps # unconventional - | - = help: Alias `plotly.express` to `px` - -custom.py:29:22: ICN001 `matplotlib` should be imported as `mpl` - | -27 | import panel as pns # unconventional -28 | import plotly.express as pltx # unconventional -29 | import matplotlib as ml # unconventional - | ^^ ICN001 -30 | import polars as ps # unconventional -31 | import pyarrow as arr # unconventional - | - = help: Alias `matplotlib` to `mpl` - -custom.py:30:18: ICN001 `polars` should be imported as `pl` - | -28 | import plotly.express as pltx # unconventional -29 | import matplotlib as ml # unconventional -30 | import polars as ps # unconventional - | ^^ ICN001 -31 | import pyarrow as arr # unconventional - | - = help: Alias `polars` to `pl` - -custom.py:31:19: ICN001 `pyarrow` should be imported as `pa` - | -29 | import matplotlib as ml # unconventional -30 | import polars as ps # unconventional -31 | import pyarrow as arr # unconventional - | ^^^ ICN001 -32 | -33 | import altair as alt # conventional - | - = help: Alias `pyarrow` to `pa` - - diff --git a/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__custom_banned.snap b/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__custom_banned.snap deleted file mode 100644 index a12f8d5ea7..0000000000 --- a/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__custom_banned.snap +++ /dev/null @@ -1,78 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_import_conventions/mod.rs ---- -custom_banned.py:1:1: ICN002 `typing` should not be imported as `t` - | -1 | import typing as t # banned - | ^^^^^^^^^^^^^^^^^^ ICN002 -2 | import typing as ty # banned - | - -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 | -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 | -4 | import numpy as nmp # banned - | ^^^^^^^^^^^^^^^^^^^ ICN002 -5 | import numpy as npy # banned -6 | import tensorflow.keras.backend as K # banned - | - -custom_banned.py:5:1: ICN002 `numpy` should not be imported as `npy` - | -4 | import numpy as nmp # banned -5 | import numpy as npy # banned - | ^^^^^^^^^^^^^^^^^^^ ICN002 -6 | import tensorflow.keras.backend as K # banned -7 | import torch.nn.functional as F # banned - | - -custom_banned.py:6:1: ICN002 `tensorflow.keras.backend` should not be imported as `K` - | -4 | import numpy as nmp # banned -5 | import numpy as npy # banned -6 | import tensorflow.keras.backend as K # banned - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN002 -7 | import torch.nn.functional as F # banned -8 | from tensorflow.keras import backend as K # banned - | - -custom_banned.py:7:1: ICN002 `torch.nn.functional` should not be imported as `F` - | -5 | import numpy as npy # banned -6 | import tensorflow.keras.backend as K # banned -7 | import torch.nn.functional as F # banned - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN002 -8 | from tensorflow.keras import backend as K # banned -9 | from torch.nn import functional as F # banned - | - -custom_banned.py:8:1: ICN002 `tensorflow.keras.backend` should not be imported as `K` - | -6 | import tensorflow.keras.backend as K # banned -7 | import torch.nn.functional as F # banned -8 | from tensorflow.keras import backend as K # banned - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN002 -9 | from torch.nn import functional as F # banned - | - -custom_banned.py:9:1: ICN002 `torch.nn.functional` should not be imported as `F` - | - 7 | import torch.nn.functional as F # banned - 8 | from tensorflow.keras import backend as K # banned - 9 | from torch.nn import functional as F # banned - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN002 -10 | -11 | from typing import Any # ok - | - - diff --git a/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__custom_banned_from.snap b/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__custom_banned_from.snap deleted file mode 100644 index 0de367be7f..0000000000 --- a/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__custom_banned_from.snap +++ /dev/null @@ -1,48 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_import_conventions/mod.rs ---- -custom_banned_from.py:1:1: ICN003 Members of `logging.config` should not be imported explicitly - | -1 | from logging.config import BaseConfigurator # banned - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN003 -2 | from typing import Any, Dict # banned -3 | from typing import * # banned - | - -custom_banned_from.py:2:1: ICN003 Members of `typing` should not be imported explicitly - | -1 | from logging.config import BaseConfigurator # banned -2 | from typing import Any, Dict # banned - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN003 -3 | from typing import * # banned - | - -custom_banned_from.py:3:1: ICN003 Members of `typing` should not be imported explicitly - | -1 | from logging.config import BaseConfigurator # banned -2 | from typing import Any, Dict # banned -3 | from typing import * # banned - | ^^^^^^^^^^^^^^^^^^^^ ICN003 -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 | -5 | from pandas import DataFrame # banned - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN003 -6 | from pandas import * # banned - | - -custom_banned_from.py:6:1: ICN003 Members of `pandas` should not be imported explicitly - | -5 | from pandas import DataFrame # banned -6 | from pandas import * # banned - | ^^^^^^^^^^^^^^^^^^^^ ICN003 -7 | -8 | import logging.config # ok - | - - diff --git a/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__defaults.snap b/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__defaults.snap deleted file mode 100644 index 5cd38193f6..0000000000 --- a/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__defaults.snap +++ /dev/null @@ -1,282 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_import_conventions/mod.rs ---- -defaults.py:6:12: ICN001 [*] `altair` should be imported as `alt` - | -5 | def unconventional(): -6 | import altair - | ^^^^^^ ICN001 -7 | import matplotlib.pyplot -8 | import numpy - | - = help: Alias `altair` to `alt` - -ℹ Suggested fix -3 3 | -4 4 | -5 5 | def unconventional(): -6 |- import altair - 6 |+ import altair as alt -7 7 | import matplotlib.pyplot -8 8 | import numpy -9 9 | import pandas - -defaults.py:7:12: ICN001 `matplotlib.pyplot` should be imported as `plt` - | -5 | def unconventional(): -6 | import altair -7 | import matplotlib.pyplot - | ^^^^^^^^^^^^^^^^^ ICN001 -8 | import numpy -9 | import pandas - | - = help: Alias `matplotlib.pyplot` to `plt` - -defaults.py:8:12: ICN001 [*] `numpy` should be imported as `np` - | - 6 | import altair - 7 | import matplotlib.pyplot - 8 | import numpy - | ^^^^^ ICN001 - 9 | import pandas -10 | import seaborn - | - = help: Alias `numpy` to `np` - -ℹ Suggested fix -5 5 | def unconventional(): -6 6 | import altair -7 7 | import matplotlib.pyplot -8 |- import numpy - 8 |+ import numpy as np -9 9 | import pandas -10 10 | import seaborn -11 11 | import tkinter - -defaults.py:9:12: ICN001 [*] `pandas` should be imported as `pd` - | - 7 | import matplotlib.pyplot - 8 | import numpy - 9 | import pandas - | ^^^^^^ ICN001 -10 | import seaborn -11 | import tkinter - | - = help: Alias `pandas` to `pd` - -ℹ Suggested fix -6 6 | import altair -7 7 | import matplotlib.pyplot -8 8 | import numpy -9 |- import pandas - 9 |+ import pandas as pd -10 10 | import seaborn -11 11 | import tkinter -12 12 | import networkx - -defaults.py:10:12: ICN001 [*] `seaborn` should be imported as `sns` - | - 8 | import numpy - 9 | import pandas -10 | import seaborn - | ^^^^^^^ ICN001 -11 | import tkinter -12 | import networkx - | - = help: Alias `seaborn` to `sns` - -ℹ Suggested fix -7 7 | import matplotlib.pyplot -8 8 | import numpy -9 9 | import pandas -10 |- import seaborn - 10 |+ import seaborn as sns -11 11 | import tkinter -12 12 | import networkx -13 13 | - -defaults.py:11:12: ICN001 [*] `tkinter` should be imported as `tk` - | - 9 | import pandas -10 | import seaborn -11 | import tkinter - | ^^^^^^^ ICN001 -12 | import networkx - | - = help: Alias `tkinter` to `tk` - -ℹ Suggested fix -8 8 | import numpy -9 9 | import pandas -10 10 | import seaborn -11 |- import tkinter - 11 |+ import tkinter as tk -12 12 | import networkx -13 13 | -14 14 | - -defaults.py:12:12: ICN001 [*] `networkx` should be imported as `nx` - | -10 | import seaborn -11 | import tkinter -12 | import networkx - | ^^^^^^^^ ICN001 - | - = help: Alias `networkx` to `nx` - -ℹ Suggested fix -9 9 | import pandas -10 10 | import seaborn -11 11 | import tkinter -12 |- import networkx - 12 |+ import networkx as nx -13 13 | -14 14 | -15 15 | def unconventional_aliases(): - -defaults.py:16:22: ICN001 [*] `altair` should be imported as `alt` - | -15 | def unconventional_aliases(): -16 | import altair as altr - | ^^^^ ICN001 -17 | import matplotlib.pyplot as plot -18 | import numpy as nmp - | - = help: Alias `altair` to `alt` - -ℹ Suggested fix -13 13 | -14 14 | -15 15 | def unconventional_aliases(): -16 |- import altair as altr - 16 |+ import altair as alt -17 17 | import matplotlib.pyplot as plot -18 18 | import numpy as nmp -19 19 | import pandas as pdas - -defaults.py:17:33: ICN001 [*] `matplotlib.pyplot` should be imported as `plt` - | -15 | def unconventional_aliases(): -16 | import altair as altr -17 | import matplotlib.pyplot as plot - | ^^^^ ICN001 -18 | import numpy as nmp -19 | import pandas as pdas - | - = help: Alias `matplotlib.pyplot` to `plt` - -ℹ Suggested fix -14 14 | -15 15 | def unconventional_aliases(): -16 16 | import altair as altr -17 |- import matplotlib.pyplot as plot - 17 |+ import matplotlib.pyplot as plt -18 18 | import numpy as nmp -19 19 | import pandas as pdas -20 20 | import seaborn as sbrn - -defaults.py:18:21: ICN001 [*] `numpy` should be imported as `np` - | -16 | import altair as altr -17 | import matplotlib.pyplot as plot -18 | import numpy as nmp - | ^^^ ICN001 -19 | import pandas as pdas -20 | import seaborn as sbrn - | - = help: Alias `numpy` to `np` - -ℹ Suggested fix -15 15 | def unconventional_aliases(): -16 16 | import altair as altr -17 17 | import matplotlib.pyplot as plot -18 |- import numpy as nmp - 18 |+ import numpy as np -19 19 | import pandas as pdas -20 20 | import seaborn as sbrn -21 21 | import tkinter as tkr - -defaults.py:19:22: ICN001 [*] `pandas` should be imported as `pd` - | -17 | import matplotlib.pyplot as plot -18 | import numpy as nmp -19 | import pandas as pdas - | ^^^^ ICN001 -20 | import seaborn as sbrn -21 | import tkinter as tkr - | - = help: Alias `pandas` to `pd` - -ℹ Suggested fix -16 16 | import altair as altr -17 17 | import matplotlib.pyplot as plot -18 18 | import numpy as nmp -19 |- import pandas as pdas - 19 |+ import pandas as pd -20 20 | import seaborn as sbrn -21 21 | import tkinter as tkr -22 22 | import networkx as nxy - -defaults.py:20:23: ICN001 [*] `seaborn` should be imported as `sns` - | -18 | import numpy as nmp -19 | import pandas as pdas -20 | import seaborn as sbrn - | ^^^^ ICN001 -21 | import tkinter as tkr -22 | import networkx as nxy - | - = help: Alias `seaborn` to `sns` - -ℹ Suggested fix -17 17 | import matplotlib.pyplot as plot -18 18 | import numpy as nmp -19 19 | import pandas as pdas -20 |- import seaborn as sbrn - 20 |+ import seaborn as sns -21 21 | import tkinter as tkr -22 22 | import networkx as nxy -23 23 | - -defaults.py:21:23: ICN001 [*] `tkinter` should be imported as `tk` - | -19 | import pandas as pdas -20 | import seaborn as sbrn -21 | import tkinter as tkr - | ^^^ ICN001 -22 | import networkx as nxy - | - = help: Alias `tkinter` to `tk` - -ℹ Suggested fix -18 18 | import numpy as nmp -19 19 | import pandas as pdas -20 20 | import seaborn as sbrn -21 |- import tkinter as tkr - 21 |+ import tkinter as tk -22 22 | import networkx as nxy -23 23 | -24 24 | def conventional_aliases(): - -defaults.py:22:24: ICN001 [*] `networkx` should be imported as `nx` - | -20 | import seaborn as sbrn -21 | import tkinter as tkr -22 | import networkx as nxy - | ^^^ ICN001 -23 | -24 | def conventional_aliases(): - | - = help: Alias `networkx` to `nx` - -ℹ Suggested fix -19 19 | import pandas as pdas -20 20 | import seaborn as sbrn -21 21 | import tkinter as tkr -22 |- import networkx as nxy - 22 |+ import networkx as nx -23 23 | -24 24 | def conventional_aliases(): -25 25 | import altair as alt - - diff --git a/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__from_imports.snap b/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__from_imports.snap deleted file mode 100644 index bda73c8ac3..0000000000 --- a/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__from_imports.snap +++ /dev/null @@ -1,91 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_import_conventions/mod.rs ---- -from_imports.py:3:8: ICN001 `xml.dom.minidom` should be imported as `md` - | -1 | # Test absolute imports -2 | # Violation cases -3 | import xml.dom.minidom - | ^^^^^^^^^^^^^^^ ICN001 -4 | import xml.dom.minidom as wrong -5 | from xml.dom import minidom as wrong - | - = help: Alias `xml.dom.minidom` to `md` - -from_imports.py:4:27: ICN001 `xml.dom.minidom` should be imported as `md` - | -2 | # Violation cases -3 | import xml.dom.minidom -4 | import xml.dom.minidom as wrong - | ^^^^^ ICN001 -5 | from xml.dom import minidom as wrong -6 | from xml.dom import minidom - | - = help: Alias `xml.dom.minidom` to `md` - -from_imports.py:5:32: ICN001 `xml.dom.minidom` should be imported as `md` - | -3 | import xml.dom.minidom -4 | import xml.dom.minidom as wrong -5 | from xml.dom import minidom as wrong - | ^^^^^ ICN001 -6 | from xml.dom import minidom -7 | from xml.dom.minidom import parseString as wrong # Ensure ICN001 throws on function import. - | - = help: Alias `xml.dom.minidom` to `md` - -from_imports.py:6:21: ICN001 `xml.dom.minidom` should be imported as `md` - | -4 | import xml.dom.minidom as wrong -5 | from xml.dom import minidom as wrong -6 | from xml.dom import minidom - | ^^^^^^^ ICN001 -7 | from xml.dom.minidom import parseString as wrong # Ensure ICN001 throws on function import. -8 | from xml.dom.minidom import parseString - | - = help: Alias `xml.dom.minidom` to `md` - -from_imports.py:7:44: ICN001 `xml.dom.minidom.parseString` should be imported as `pstr` - | -5 | from xml.dom import minidom as wrong -6 | from xml.dom import minidom -7 | from xml.dom.minidom import parseString as wrong # Ensure ICN001 throws on function import. - | ^^^^^ ICN001 -8 | from xml.dom.minidom import parseString -9 | from xml.dom.minidom import parse, parseString - | - = help: Alias `xml.dom.minidom.parseString` to `pstr` - -from_imports.py:8:29: ICN001 `xml.dom.minidom.parseString` should be imported as `pstr` - | - 6 | from xml.dom import minidom - 7 | from xml.dom.minidom import parseString as wrong # Ensure ICN001 throws on function import. - 8 | from xml.dom.minidom import parseString - | ^^^^^^^^^^^ ICN001 - 9 | from xml.dom.minidom import parse, parseString -10 | from xml.dom.minidom import parse as ps, parseString as wrong - | - = help: Alias `xml.dom.minidom.parseString` to `pstr` - -from_imports.py:9:36: ICN001 `xml.dom.minidom.parseString` should be imported as `pstr` - | - 7 | from xml.dom.minidom import parseString as wrong # Ensure ICN001 throws on function import. - 8 | from xml.dom.minidom import parseString - 9 | from xml.dom.minidom import parse, parseString - | ^^^^^^^^^^^ ICN001 -10 | from xml.dom.minidom import parse as ps, parseString as wrong - | - = help: Alias `xml.dom.minidom.parseString` to `pstr` - -from_imports.py:10:57: ICN001 `xml.dom.minidom.parseString` should be imported as `pstr` - | - 8 | from xml.dom.minidom import parseString - 9 | from xml.dom.minidom import parse, parseString -10 | from xml.dom.minidom import parse as ps, parseString as wrong - | ^^^^^ ICN001 -11 | -12 | # No ICN001 violations - | - = help: Alias `xml.dom.minidom.parseString` to `pstr` - - diff --git a/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__override_defaults.snap b/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__override_defaults.snap deleted file mode 100644 index a0e6bef88c..0000000000 --- a/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__override_defaults.snap +++ /dev/null @@ -1,110 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_import_conventions/mod.rs ---- -override_default.py:3:8: ICN001 `altair` should be imported as `alt` - | -1 | import math # not checked -2 | -3 | import altair # unconventional - | ^^^^^^ ICN001 -4 | import matplotlib.pyplot # unconventional -5 | import numpy # unconventional - | - = help: Alias `altair` to `alt` - -override_default.py:4:8: ICN001 `matplotlib.pyplot` should be imported as `plt` - | -3 | import altair # unconventional -4 | import matplotlib.pyplot # unconventional - | ^^^^^^^^^^^^^^^^^ ICN001 -5 | import numpy # unconventional -6 | import pandas # unconventional - | - = help: Alias `matplotlib.pyplot` to `plt` - -override_default.py:5:8: ICN001 `numpy` should be imported as `nmp` - | -3 | import altair # unconventional -4 | import matplotlib.pyplot # unconventional -5 | import numpy # unconventional - | ^^^^^ ICN001 -6 | import pandas # unconventional -7 | import seaborn # unconventional - | - = help: Alias `numpy` to `nmp` - -override_default.py:6:8: ICN001 `pandas` should be imported as `pd` - | -4 | import matplotlib.pyplot # unconventional -5 | import numpy # unconventional -6 | import pandas # unconventional - | ^^^^^^ ICN001 -7 | import seaborn # unconventional - | - = help: Alias `pandas` to `pd` - -override_default.py:7:8: ICN001 `seaborn` should be imported as `sns` - | -5 | import numpy # unconventional -6 | import pandas # unconventional -7 | import seaborn # unconventional - | ^^^^^^^ ICN001 -8 | -9 | import altair as altr # unconventional - | - = help: Alias `seaborn` to `sns` - -override_default.py:9:18: ICN001 `altair` should be imported as `alt` - | - 7 | import seaborn # unconventional - 8 | - 9 | import altair as altr # unconventional - | ^^^^ ICN001 -10 | import matplotlib.pyplot as plot # unconventional -11 | import numpy as np # unconventional - | - = help: Alias `altair` to `alt` - -override_default.py:10:29: ICN001 `matplotlib.pyplot` should be imported as `plt` - | - 9 | import altair as altr # unconventional -10 | import matplotlib.pyplot as plot # unconventional - | ^^^^ ICN001 -11 | import numpy as np # unconventional -12 | import pandas as pdas # unconventional - | - = help: Alias `matplotlib.pyplot` to `plt` - -override_default.py:11:17: ICN001 `numpy` should be imported as `nmp` - | - 9 | import altair as altr # unconventional -10 | import matplotlib.pyplot as plot # unconventional -11 | import numpy as np # unconventional - | ^^ ICN001 -12 | import pandas as pdas # unconventional -13 | import seaborn as sbrn # unconventional - | - = help: Alias `numpy` to `nmp` - -override_default.py:12:18: ICN001 `pandas` should be imported as `pd` - | -10 | import matplotlib.pyplot as plot # unconventional -11 | import numpy as np # unconventional -12 | import pandas as pdas # unconventional - | ^^^^ ICN001 -13 | import seaborn as sbrn # unconventional - | - = help: Alias `pandas` to `pd` - -override_default.py:13:19: ICN001 `seaborn` should be imported as `sns` - | -11 | import numpy as np # unconventional -12 | import pandas as pdas # unconventional -13 | import seaborn as sbrn # unconventional - | ^^^^ ICN001 -14 | -15 | import altair as alt # conventional - | - = help: Alias `seaborn` to `sns` - - diff --git a/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__remove_defaults.snap b/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__remove_defaults.snap deleted file mode 100644 index b02135a6cb..0000000000 --- a/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__remove_defaults.snap +++ /dev/null @@ -1,88 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_import_conventions/mod.rs ---- -remove_default.py:3:8: ICN001 `altair` should be imported as `alt` - | -1 | import math # not checked -2 | -3 | import altair # unconventional - | ^^^^^^ ICN001 -4 | import matplotlib.pyplot # unconventional -5 | import numpy # not checked - | - = help: Alias `altair` to `alt` - -remove_default.py:4:8: ICN001 `matplotlib.pyplot` should be imported as `plt` - | -3 | import altair # unconventional -4 | import matplotlib.pyplot # unconventional - | ^^^^^^^^^^^^^^^^^ ICN001 -5 | import numpy # not checked -6 | import pandas # unconventional - | - = help: Alias `matplotlib.pyplot` to `plt` - -remove_default.py:6:8: ICN001 `pandas` should be imported as `pd` - | -4 | import matplotlib.pyplot # unconventional -5 | import numpy # not checked -6 | import pandas # unconventional - | ^^^^^^ ICN001 -7 | import seaborn # unconventional - | - = help: Alias `pandas` to `pd` - -remove_default.py:7:8: ICN001 `seaborn` should be imported as `sns` - | -5 | import numpy # not checked -6 | import pandas # unconventional -7 | import seaborn # unconventional - | ^^^^^^^ ICN001 -8 | -9 | import altair as altr # unconventional - | - = help: Alias `seaborn` to `sns` - -remove_default.py:9:18: ICN001 `altair` should be imported as `alt` - | - 7 | import seaborn # unconventional - 8 | - 9 | import altair as altr # unconventional - | ^^^^ ICN001 -10 | import matplotlib.pyplot as plot # unconventional -11 | import numpy as nmp # not checked - | - = help: Alias `altair` to `alt` - -remove_default.py:10:29: ICN001 `matplotlib.pyplot` should be imported as `plt` - | - 9 | import altair as altr # unconventional -10 | import matplotlib.pyplot as plot # unconventional - | ^^^^ ICN001 -11 | import numpy as nmp # not checked -12 | import pandas as pdas # unconventional - | - = help: Alias `matplotlib.pyplot` to `plt` - -remove_default.py:12:18: ICN001 `pandas` should be imported as `pd` - | -10 | import matplotlib.pyplot as plot # unconventional -11 | import numpy as nmp # not checked -12 | import pandas as pdas # unconventional - | ^^^^ ICN001 -13 | import seaborn as sbrn # unconventional - | - = help: Alias `pandas` to `pd` - -remove_default.py:13:19: ICN001 `seaborn` should be imported as `sns` - | -11 | import numpy as nmp # not checked -12 | import pandas as pdas # unconventional -13 | import seaborn as sbrn # unconventional - | ^^^^ ICN001 -14 | -15 | import altair as alt # conventional - | - = help: Alias `seaborn` to `sns` - - diff --git a/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__tricky.snap b/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__tricky.snap deleted file mode 100644 index 1d93608266..0000000000 --- a/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__tricky.snap +++ /dev/null @@ -1,26 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_import_conventions/mod.rs ---- -tricky.py:7:16: ICN001 [*] `pandas` should be imported as `pd` - | -5 | try: -6 | global pandas -7 | import pandas - | ^^^^^^ ICN001 -8 | except ImportError: -9 | return False - | - = help: Alias `pandas` to `pd` - -ℹ Suggested fix -3 3 | -4 4 | def rename_global(): -5 5 | try: -6 |- global pandas -7 |- import pandas - 6 |+ global pd - 7 |+ import pandas as pd -8 8 | except ImportError: -9 9 | return False - - diff --git a/crates/ruff/src/rules/flake8_logging/snapshots/ruff__rules__flake8_logging__tests__LOG001_LOG001.py.snap b/crates/ruff/src/rules/flake8_logging/snapshots/ruff__rules__flake8_logging__tests__LOG001_LOG001.py.snap deleted file mode 100644 index c94fed6a12..0000000000 --- a/crates/ruff/src/rules/flake8_logging/snapshots/ruff__rules__flake8_logging__tests__LOG001_LOG001.py.snap +++ /dev/null @@ -1,40 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_logging/mod.rs ---- -LOG001.py:3:1: LOG001 [*] Use `logging.getLogger()` to instantiate loggers - | -1 | import logging -2 | -3 | logging.Logger(__name__) - | ^^^^^^^^^^^^^^ LOG001 -4 | logging.Logger() -5 | logging.getLogger(__name__) - | - = help: Replace with `logging.getLogger()` - -ℹ Suggested fix -1 1 | import logging -2 2 | -3 |-logging.Logger(__name__) - 3 |+logging.getLogger(__name__) -4 4 | logging.Logger() -5 5 | logging.getLogger(__name__) - -LOG001.py:4:1: LOG001 [*] Use `logging.getLogger()` to instantiate loggers - | -3 | logging.Logger(__name__) -4 | logging.Logger() - | ^^^^^^^^^^^^^^ LOG001 -5 | logging.getLogger(__name__) - | - = help: Replace with `logging.getLogger()` - -ℹ Suggested fix -1 1 | import logging -2 2 | -3 3 | logging.Logger(__name__) -4 |-logging.Logger() - 4 |+logging.getLogger() -5 5 | logging.getLogger(__name__) - - diff --git a/crates/ruff/src/rules/flake8_logging/snapshots/ruff__rules__flake8_logging__tests__LOG002_LOG002.py.snap b/crates/ruff/src/rules/flake8_logging/snapshots/ruff__rules__flake8_logging__tests__LOG002_LOG002.py.snap deleted file mode 100644 index d59c381528..0000000000 --- a/crates/ruff/src/rules/flake8_logging/snapshots/ruff__rules__flake8_logging__tests__LOG002_LOG002.py.snap +++ /dev/null @@ -1,82 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_logging/mod.rs ---- -LOG002.py:11:11: LOG002 [*] Use `__name__` with `logging.getLogger()` - | -10 | # LOG002 -11 | getLogger(__file__) - | ^^^^^^^^ LOG002 -12 | logging.getLogger(name=__file__) - | - = help: Replace with `name` - -ℹ Suggested fix -8 8 | logging.getLogger(name="custom") -9 9 | -10 10 | # LOG002 -11 |-getLogger(__file__) - 11 |+getLogger(__name__) -12 12 | logging.getLogger(name=__file__) -13 13 | -14 14 | logging.getLogger(__cached__) - -LOG002.py:12:24: LOG002 [*] Use `__name__` with `logging.getLogger()` - | -10 | # LOG002 -11 | getLogger(__file__) -12 | logging.getLogger(name=__file__) - | ^^^^^^^^ LOG002 -13 | -14 | logging.getLogger(__cached__) - | - = help: Replace with `name` - -ℹ Suggested fix -9 9 | -10 10 | # LOG002 -11 11 | getLogger(__file__) -12 |-logging.getLogger(name=__file__) - 12 |+logging.getLogger(name=__name__) -13 13 | -14 14 | logging.getLogger(__cached__) -15 15 | getLogger(name=__cached__) - -LOG002.py:14:19: LOG002 [*] Use `__name__` with `logging.getLogger()` - | -12 | logging.getLogger(name=__file__) -13 | -14 | logging.getLogger(__cached__) - | ^^^^^^^^^^ LOG002 -15 | getLogger(name=__cached__) - | - = help: Replace with `name` - -ℹ Suggested fix -11 11 | getLogger(__file__) -12 12 | logging.getLogger(name=__file__) -13 13 | -14 |-logging.getLogger(__cached__) - 14 |+logging.getLogger(__name__) -15 15 | getLogger(name=__cached__) -16 16 | -17 17 | - -LOG002.py:15:16: LOG002 [*] Use `__name__` with `logging.getLogger()` - | -14 | logging.getLogger(__cached__) -15 | getLogger(name=__cached__) - | ^^^^^^^^^^ LOG002 - | - = help: Replace with `name` - -ℹ Suggested fix -12 12 | logging.getLogger(name=__file__) -13 13 | -14 14 | logging.getLogger(__cached__) -15 |-getLogger(name=__cached__) - 15 |+getLogger(name=__name__) -16 16 | -17 17 | -18 18 | # Override `logging.getLogger` - - diff --git a/crates/ruff/src/rules/flake8_logging/snapshots/ruff__rules__flake8_logging__tests__LOG007_LOG007.py.snap b/crates/ruff/src/rules/flake8_logging/snapshots/ruff__rules__flake8_logging__tests__LOG007_LOG007.py.snap deleted file mode 100644 index 25cdf811eb..0000000000 --- a/crates/ruff/src/rules/flake8_logging/snapshots/ruff__rules__flake8_logging__tests__LOG007_LOG007.py.snap +++ /dev/null @@ -1,43 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_logging/mod.rs ---- -LOG007.py:6:1: LOG007 Use of `logging.exception` with falsy `exc_info` - | -5 | logging.exception("foo") # OK -6 | logging.exception("foo", exc_info=False) # LOG007 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LOG007 -7 | logging.exception("foo", exc_info=[]) # LOG007 -8 | logger.exception("foo") # OK - | - -LOG007.py:7:1: LOG007 Use of `logging.exception` with falsy `exc_info` - | -5 | logging.exception("foo") # OK -6 | logging.exception("foo", exc_info=False) # LOG007 -7 | logging.exception("foo", exc_info=[]) # LOG007 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LOG007 -8 | logger.exception("foo") # OK -9 | logger.exception("foo", exc_info=False) # LOG007 - | - -LOG007.py:9:1: LOG007 Use of `logging.exception` with falsy `exc_info` - | - 7 | logging.exception("foo", exc_info=[]) # LOG007 - 8 | logger.exception("foo") # OK - 9 | logger.exception("foo", exc_info=False) # LOG007 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LOG007 -10 | logger.exception("foo", exc_info=[]) # LOG007 -11 | logger.error("foo", exc_info=False) # OK - | - -LOG007.py:10:1: LOG007 Use of `logging.exception` with falsy `exc_info` - | - 8 | logger.exception("foo") # OK - 9 | logger.exception("foo", exc_info=False) # LOG007 -10 | logger.exception("foo", exc_info=[]) # LOG007 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LOG007 -11 | logger.error("foo", exc_info=False) # OK -12 | logger.info("foo", exc_info=False) # OK - | - - diff --git a/crates/ruff/src/rules/flake8_logging/snapshots/ruff__rules__flake8_logging__tests__LOG009_LOG009.py.snap b/crates/ruff/src/rules/flake8_logging/snapshots/ruff__rules__flake8_logging__tests__LOG009_LOG009.py.snap deleted file mode 100644 index 3332f318d5..0000000000 --- a/crates/ruff/src/rules/flake8_logging/snapshots/ruff__rules__flake8_logging__tests__LOG009_LOG009.py.snap +++ /dev/null @@ -1,41 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_logging/mod.rs ---- -LOG009.py:3:1: LOG009 [*] Use of undocumented `logging.WARN` constant - | -1 | import logging -2 | -3 | logging.WARN # LOG009 - | ^^^^^^^^^^^^ LOG009 -4 | logging.WARNING # OK - | - = help: Replace `logging.WARN` with `logging.WARNING` - -ℹ Suggested fix -1 1 | import logging -2 2 | -3 |-logging.WARN # LOG009 - 3 |+logging.WARNING # LOG009 -4 4 | logging.WARNING # OK -5 5 | -6 6 | from logging import WARN, WARNING - -LOG009.py:8:1: LOG009 [*] Use of undocumented `logging.WARN` constant - | -6 | from logging import WARN, WARNING -7 | -8 | WARN # LOG009 - | ^^^^ LOG009 -9 | WARNING # OK - | - = help: Replace `logging.WARN` with `logging.WARNING` - -ℹ Suggested fix -5 5 | -6 6 | from logging import WARN, WARNING -7 7 | -8 |-WARN # LOG009 - 8 |+logging.WARNING # LOG009 -9 9 | WARNING # OK - - diff --git a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G001.py.snap b/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G001.py.snap deleted file mode 100644 index e1ed539d35..0000000000 --- a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G001.py.snap +++ /dev/null @@ -1,88 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_logging_format/mod.rs ---- -G001.py:4:14: G001 Logging statement uses `str.format` - | -2 | import logging as foo -3 | -4 | logging.info("Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 -5 | logging.log(logging.INFO, "Hello {}".format("World!")) -6 | foo.info("Hello {}".format("World!")) - | - -G001.py:5:27: G001 Logging statement uses `str.format` - | -4 | logging.info("Hello {}".format("World!")) -5 | logging.log(logging.INFO, "Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 -6 | foo.info("Hello {}".format("World!")) -7 | logging.log(logging.INFO, msg="Hello {}".format("World!")) - | - -G001.py:6:10: G001 Logging statement uses `str.format` - | -4 | logging.info("Hello {}".format("World!")) -5 | logging.log(logging.INFO, "Hello {}".format("World!")) -6 | foo.info("Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 -7 | logging.log(logging.INFO, msg="Hello {}".format("World!")) -8 | logging.log(level=logging.INFO, msg="Hello {}".format("World!")) - | - -G001.py:7:31: G001 Logging statement uses `str.format` - | -5 | logging.log(logging.INFO, "Hello {}".format("World!")) -6 | foo.info("Hello {}".format("World!")) -7 | logging.log(logging.INFO, msg="Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 -8 | logging.log(level=logging.INFO, msg="Hello {}".format("World!")) -9 | logging.log(msg="Hello {}".format("World!"), level=logging.INFO) - | - -G001.py:8:37: G001 Logging statement uses `str.format` - | -6 | foo.info("Hello {}".format("World!")) -7 | logging.log(logging.INFO, msg="Hello {}".format("World!")) -8 | logging.log(level=logging.INFO, msg="Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 -9 | logging.log(msg="Hello {}".format("World!"), level=logging.INFO) - | - -G001.py:9:17: G001 Logging statement uses `str.format` - | - 7 | logging.log(logging.INFO, msg="Hello {}".format("World!")) - 8 | logging.log(level=logging.INFO, msg="Hello {}".format("World!")) - 9 | logging.log(msg="Hello {}".format("World!"), level=logging.INFO) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 -10 | -11 | # Flask support - | - -G001.py:16:31: G001 Logging statement uses `str.format` - | -14 | from flask import current_app as app -15 | -16 | flask.current_app.logger.info("Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 -17 | current_app.logger.info("Hello {}".format("World!")) -18 | app.logger.log(logging.INFO, "Hello {}".format("World!")) - | - -G001.py:17:25: G001 Logging statement uses `str.format` - | -16 | flask.current_app.logger.info("Hello {}".format("World!")) -17 | current_app.logger.info("Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 -18 | app.logger.log(logging.INFO, "Hello {}".format("World!")) - | - -G001.py:18:30: G001 Logging statement uses `str.format` - | -16 | flask.current_app.logger.info("Hello {}".format("World!")) -17 | current_app.logger.info("Hello {}".format("World!")) -18 | app.logger.log(logging.INFO, "Hello {}".format("World!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 - | - - diff --git a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G002.py.snap b/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G002.py.snap deleted file mode 100644 index 207058ca05..0000000000 --- a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G002.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_logging_format/mod.rs ---- -G002.py:3:14: G002 Logging statement uses `%` - | -1 | import logging -2 | -3 | logging.info("Hello %s" % "World!") - | ^^^^^^^^^^^^^^^^^^^^^ G002 -4 | logging.log(logging.INFO, "Hello %s" % "World!") - | - -G002.py:4:27: G002 Logging statement uses `%` - | -3 | logging.info("Hello %s" % "World!") -4 | logging.log(logging.INFO, "Hello %s" % "World!") - | ^^^^^^^^^^^^^^^^^^^^^ G002 - | - - diff --git a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G003.py.snap b/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G003.py.snap deleted file mode 100644 index b038c333c8..0000000000 --- a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G003.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_logging_format/mod.rs ---- -G003.py:3:14: G003 Logging statement uses `+` - | -1 | import logging -2 | -3 | logging.info("Hello" + " " + "World!") - | ^^^^^^^^^^^^^^^^^^^^^^^^ G003 -4 | logging.log(logging.INFO, "Hello" + " " + "World!") - | - -G003.py:4:27: G003 Logging statement uses `+` - | -3 | logging.info("Hello" + " " + "World!") -4 | logging.log(logging.INFO, "Hello" + " " + "World!") - | ^^^^^^^^^^^^^^^^^^^^^^^^ G003 - | - - diff --git a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G004.py.snap b/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G004.py.snap deleted file mode 100644 index b54d2a4862..0000000000 --- a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G004.py.snap +++ /dev/null @@ -1,29 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_logging_format/mod.rs ---- -G004.py:4:14: G004 Logging statement uses f-string - | -3 | name = "world" -4 | logging.info(f"Hello {name}") - | ^^^^^^^^^^^^^^^ G004 -5 | logging.log(logging.INFO, f"Hello {name}") - | - -G004.py:5:27: G004 Logging statement uses f-string - | -3 | name = "world" -4 | logging.info(f"Hello {name}") -5 | logging.log(logging.INFO, f"Hello {name}") - | ^^^^^^^^^^^^^^^ G004 -6 | -7 | _LOGGER = logging.getLogger() - | - -G004.py:8:14: G004 Logging statement uses f-string - | -7 | _LOGGER = logging.getLogger() -8 | _LOGGER.info(f"{__name__}") - | ^^^^^^^^^^^^^ G004 - | - - diff --git a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G010.py.snap b/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G010.py.snap deleted file mode 100644 index faa3918fa1..0000000000 --- a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G010.py.snap +++ /dev/null @@ -1,61 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_logging_format/mod.rs ---- -G010.py:6:9: G010 [*] Logging statement uses `warn` instead of `warning` - | -4 | from logging_setup import logger -5 | -6 | logging.warn("Hello World!") - | ^^^^ G010 -7 | log.warn("Hello world!") # This shouldn't be considered as a logger candidate -8 | logger.warn("Hello world!") - | - = help: Convert to `warn` - -ℹ Fix -3 3 | -4 4 | from logging_setup import logger -5 5 | -6 |-logging.warn("Hello World!") - 6 |+logging.warning("Hello World!") -7 7 | log.warn("Hello world!") # This shouldn't be considered as a logger candidate -8 8 | logger.warn("Hello world!") -9 9 | - -G010.py:8:8: G010 [*] Logging statement uses `warn` instead of `warning` - | - 6 | logging.warn("Hello World!") - 7 | log.warn("Hello world!") # This shouldn't be considered as a logger candidate - 8 | logger.warn("Hello world!") - | ^^^^ G010 - 9 | -10 | logging . warn("Hello World!") - | - = help: Convert to `warn` - -ℹ Fix -5 5 | -6 6 | logging.warn("Hello World!") -7 7 | log.warn("Hello world!") # This shouldn't be considered as a logger candidate -8 |-logger.warn("Hello world!") - 8 |+logger.warning("Hello world!") -9 9 | -10 10 | logging . warn("Hello World!") - -G010.py:10:11: G010 [*] Logging statement uses `warn` instead of `warning` - | - 8 | logger.warn("Hello world!") - 9 | -10 | logging . warn("Hello World!") - | ^^^^ G010 - | - = help: Convert to `warn` - -ℹ Fix -7 7 | log.warn("Hello world!") # This shouldn't be considered as a logger candidate -8 8 | logger.warn("Hello world!") -9 9 | -10 |-logging . warn("Hello World!") - 10 |+logging . warning("Hello World!") - - diff --git a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G101_1.py.snap b/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G101_1.py.snap deleted file mode 100644 index ba7d9daa0d..0000000000 --- a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G101_1.py.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_logging_format/mod.rs ---- -G101_1.py:6:9: G101 Logging statement uses an `extra` field that clashes with a `LogRecord` field: `name` - | -4 | "Hello world!", -5 | extra={ -6 | "name": "foobar", - | ^^^^^^ G101 -7 | }, -8 | ) - | - - diff --git a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G101_2.py.snap b/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G101_2.py.snap deleted file mode 100644 index 0db9761fbc..0000000000 --- a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G101_2.py.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_logging_format/mod.rs ---- -G101_2.py:6:9: G101 Logging statement uses an `extra` field that clashes with a `LogRecord` field: `name` - | -4 | "Hello world!", -5 | extra=dict( -6 | name="foobar", - | ^^^^^^^^^^^^^ G101 -7 | ), -8 | ) - | - - diff --git a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G201.py.snap b/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G201.py.snap deleted file mode 100644 index 0ca80214d9..0000000000 --- a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G201.py.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_logging_format/mod.rs ---- -G201.py:8:13: G201 Logging `.exception(...)` should be used instead of `.error(..., exc_info=True)` - | - 6 | pass - 7 | except: - 8 | logging.error("Hello World", exc_info=True) - | ^^^^^ G201 - 9 | -10 | try: - | - -G201.py:13:13: G201 Logging `.exception(...)` should be used instead of `.error(..., exc_info=True)` - | -11 | pass -12 | except: -13 | logging.error("Hello World", exc_info=sys.exc_info()) - | ^^^^^ G201 -14 | -15 | # OK - | - - diff --git a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G202.py.snap b/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G202.py.snap deleted file mode 100644 index 2c61f2233d..0000000000 --- a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G202.py.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_logging_format/mod.rs ---- -G202.py:8:38: G202 Logging statement has redundant `exc_info` - | - 6 | pass - 7 | except: - 8 | logging.exception("Hello World", exc_info=True) - | ^^^^^^^^^^^^^ G202 - 9 | -10 | try: - | - -G202.py:13:38: G202 Logging statement has redundant `exc_info` - | -11 | pass -12 | except: -13 | logging.exception("Hello World", exc_info=sys.exc_info()) - | ^^^^^^^^^^^^^^^^^^^^^^^ G202 -14 | -15 | # OK - | - - diff --git a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G_argparse_parser_error_ok.py.snap b/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G_argparse_parser_error_ok.py.snap deleted file mode 100644 index 13978a7813..0000000000 --- a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G_argparse_parser_error_ok.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_logging_format/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G_extra_ok.py.snap b/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G_extra_ok.py.snap deleted file mode 100644 index 13978a7813..0000000000 --- a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G_extra_ok.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_logging_format/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G_extra_str_format_ok.py.snap b/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G_extra_str_format_ok.py.snap deleted file mode 100644 index 13978a7813..0000000000 --- a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G_extra_str_format_ok.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_logging_format/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G_simple_ok.py.snap b/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G_simple_ok.py.snap deleted file mode 100644 index 13978a7813..0000000000 --- a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G_simple_ok.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_logging_format/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G_warnings_ok.py.snap b/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G_warnings_ok.py.snap deleted file mode 100644 index 13978a7813..0000000000 --- a/crates/ruff/src/rules/flake8_logging_format/snapshots/ruff__rules__flake8_logging_format__tests__G_warnings_ok.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_logging_format/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_fail_empty.snap b/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_fail_empty.snap deleted file mode 100644 index b7e208fc6c..0000000000 --- a/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_fail_empty.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_no_pep420/mod.rs ---- -example.py:1:1: INP001 File `./resources/test/fixtures/flake8_no_pep420/test_fail_empty/example.py` is part of an implicit namespace package. Add an `__init__.py`. - | - | - - diff --git a/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_fail_nonempty.snap b/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_fail_nonempty.snap deleted file mode 100644 index a933366090..0000000000 --- a/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_fail_nonempty.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_no_pep420/mod.rs ---- -example.py:1:1: INP001 File `./resources/test/fixtures/flake8_no_pep420/test_fail_nonempty/example.py` is part of an implicit namespace package. Add an `__init__.py`. - | -1 | print('hi') - | INP001 - | - - diff --git a/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_fail_shebang.snap b/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_fail_shebang.snap deleted file mode 100644 index 49ef7c90a3..0000000000 --- a/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_fail_shebang.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_no_pep420/mod.rs ---- -example.py:1:1: INP001 File `./resources/test/fixtures/flake8_no_pep420/test_fail_shebang/example.py` is part of an implicit namespace package. Add an `__init__.py`. - | -1 | #!/bin/env/python - | INP001 -2 | print('hi') - | - - diff --git a/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_ignored.snap b/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_ignored.snap deleted file mode 100644 index a83bb58661..0000000000 --- a/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_ignored.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_no_pep420/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_pass_init.snap b/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_pass_init.snap deleted file mode 100644 index a83bb58661..0000000000 --- a/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_pass_init.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_no_pep420/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_pass_namespace_package.snap b/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_pass_namespace_package.snap deleted file mode 100644 index a83bb58661..0000000000 --- a/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_pass_namespace_package.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_no_pep420/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_pass_pyi.snap b/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_pass_pyi.snap deleted file mode 100644 index a83bb58661..0000000000 --- a/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_pass_pyi.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_no_pep420/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_pass_script.snap b/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_pass_script.snap deleted file mode 100644 index a83bb58661..0000000000 --- a/crates/ruff/src/rules/flake8_no_pep420/snapshots/ruff__rules__flake8_no_pep420__tests__test_pass_script.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_no_pep420/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE790_PIE790.py.snap b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE790_PIE790.py.snap deleted file mode 100644 index d3f8b3fa1f..0000000000 --- a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE790_PIE790.py.snap +++ /dev/null @@ -1,320 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pie/mod.rs ---- -PIE790.py:4:5: PIE790 [*] Unnecessary `pass` statement - | -2 | """buzz""" -3 | -4 | pass - | ^^^^ PIE790 - | - = help: Remove unnecessary `pass` - -ℹ Fix -1 1 | class Foo: -2 2 | """buzz""" -3 3 | -4 |- pass -5 4 | -6 5 | -7 6 | if foo: - -PIE790.py:9:5: PIE790 [*] Unnecessary `pass` statement - | -7 | if foo: -8 | """foo""" -9 | pass - | ^^^^ PIE790 - | - = help: Remove unnecessary `pass` - -ℹ Fix -6 6 | -7 7 | if foo: -8 8 | """foo""" -9 |- pass -10 9 | -11 10 | -12 11 | def multi_statement() -> None: - -PIE790.py:14:5: PIE790 [*] Unnecessary `pass` statement - | -12 | def multi_statement() -> None: -13 | """This is a function.""" -14 | pass; print("hello") - | ^^^^ PIE790 - | - = help: Remove unnecessary `pass` - -ℹ Fix -11 11 | -12 12 | def multi_statement() -> None: -13 13 | """This is a function.""" -14 |- pass; print("hello") - 14 |+ print("hello") -15 15 | -16 16 | -17 17 | if foo: - -PIE790.py:21:5: PIE790 [*] Unnecessary `pass` statement - | -19 | else: -20 | """bar""" -21 | pass - | ^^^^ PIE790 - | - = help: Remove unnecessary `pass` - -ℹ Fix -18 18 | pass -19 19 | else: -20 20 | """bar""" -21 |- pass -22 21 | -23 22 | -24 23 | while True: - -PIE790.py:28:5: PIE790 [*] Unnecessary `pass` statement - | -26 | else: -27 | """bar""" -28 | pass - | ^^^^ PIE790 - | - = help: Remove unnecessary `pass` - -ℹ Fix -25 25 | pass -26 26 | else: -27 27 | """bar""" -28 |- pass -29 28 | -30 29 | -31 30 | for _ in range(10): - -PIE790.py:35:5: PIE790 [*] Unnecessary `pass` statement - | -33 | else: -34 | """bar""" -35 | pass - | ^^^^ PIE790 - | - = help: Remove unnecessary `pass` - -ℹ Fix -32 32 | pass -33 33 | else: -34 34 | """bar""" -35 |- pass -36 35 | -37 36 | -38 37 | async for _ in range(10): - -PIE790.py:42:5: PIE790 [*] Unnecessary `pass` statement - | -40 | else: -41 | """bar""" -42 | pass - | ^^^^ PIE790 - | - = help: Remove unnecessary `pass` - -ℹ Fix -39 39 | pass -40 40 | else: -41 41 | """bar""" -42 |- pass -43 42 | -44 43 | -45 44 | def foo() -> None: - -PIE790.py:50:5: PIE790 [*] Unnecessary `pass` statement - | -48 | """ -49 | -50 | pass - | ^^^^ PIE790 - | - = help: Remove unnecessary `pass` - -ℹ Fix -47 47 | buzz -48 48 | """ -49 49 | -50 |- pass -51 50 | -52 51 | -53 52 | async def foo(): - -PIE790.py:58:5: PIE790 [*] Unnecessary `pass` statement - | -56 | """ -57 | -58 | pass - | ^^^^ PIE790 - | - = help: Remove unnecessary `pass` - -ℹ Fix -55 55 | buzz -56 56 | """ -57 57 | -58 |- pass -59 58 | -60 59 | -61 60 | try: - -PIE790.py:65:5: PIE790 [*] Unnecessary `pass` statement - | -63 | buzz -64 | """ -65 | pass - | ^^^^ PIE790 -66 | except ValueError: -67 | pass - | - = help: Remove unnecessary `pass` - -ℹ Fix -62 62 | """ -63 63 | buzz -64 64 | """ -65 |- pass -66 65 | except ValueError: -67 66 | pass -68 67 | - -PIE790.py:74:5: PIE790 [*] Unnecessary `pass` statement - | -72 | except ValueError: -73 | """bar""" -74 | pass - | ^^^^ PIE790 - | - = help: Remove unnecessary `pass` - -ℹ Fix -71 71 | bar() -72 72 | except ValueError: -73 73 | """bar""" -74 |- pass -75 74 | -76 75 | -77 76 | for _ in range(10): - -PIE790.py:79:5: PIE790 [*] Unnecessary `pass` statement - | -77 | for _ in range(10): -78 | """buzz""" -79 | pass - | ^^^^ PIE790 -80 | -81 | async for _ in range(10): - | - = help: Remove unnecessary `pass` - -ℹ Fix -76 76 | -77 77 | for _ in range(10): -78 78 | """buzz""" -79 |- pass -80 79 | -81 80 | async for _ in range(10): -82 81 | """buzz""" - -PIE790.py:83:5: PIE790 [*] Unnecessary `pass` statement - | -81 | async for _ in range(10): -82 | """buzz""" -83 | pass - | ^^^^ PIE790 -84 | -85 | while cond: - | - = help: Remove unnecessary `pass` - -ℹ Fix -80 80 | -81 81 | async for _ in range(10): -82 82 | """buzz""" -83 |- pass -84 83 | -85 84 | while cond: -86 85 | """buzz""" - -PIE790.py:87:5: PIE790 [*] Unnecessary `pass` statement - | -85 | while cond: -86 | """buzz""" -87 | pass - | ^^^^ PIE790 - | - = help: Remove unnecessary `pass` - -ℹ Fix -84 84 | -85 85 | while cond: -86 86 | """buzz""" -87 |- pass -88 87 | -89 88 | -90 89 | with bar: - -PIE790.py:92:5: PIE790 [*] Unnecessary `pass` statement - | -90 | with bar: -91 | """buzz""" -92 | pass - | ^^^^ PIE790 -93 | -94 | async with bar: - | - = help: Remove unnecessary `pass` - -ℹ Fix -89 89 | -90 90 | with bar: -91 91 | """buzz""" -92 |- pass -93 92 | -94 93 | async with bar: -95 94 | """buzz""" - -PIE790.py:96:5: PIE790 [*] Unnecessary `pass` statement - | -94 | async with bar: -95 | """buzz""" -96 | pass - | ^^^^ PIE790 - | - = help: Remove unnecessary `pass` - -ℹ Fix -93 93 | -94 94 | async with bar: -95 95 | """buzz""" -96 |- pass -97 96 | -98 97 | -99 98 | def foo() -> None: - -PIE790.py:101:5: PIE790 [*] Unnecessary `pass` statement - | - 99 | def foo() -> None: -100 | """buzz""" -101 | pass # bar - | ^^^^ PIE790 - | - = help: Remove unnecessary `pass` - -ℹ Fix -98 98 | -99 99 | def foo() -> None: -100 100 | """buzz""" -101 |- pass # bar - 101 |+ # bar -102 102 | -103 103 | -104 104 | class Foo: - - diff --git a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE794_PIE794.py.snap b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE794_PIE794.py.snap deleted file mode 100644 index 565f32d90c..0000000000 --- a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE794_PIE794.py.snap +++ /dev/null @@ -1,77 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pie/mod.rs ---- -PIE794.py:4:5: PIE794 [*] Class field `name` is defined multiple times - | -2 | name = StringField() -3 | # .... -4 | name = StringField() # PIE794 - | ^^^^^^^^^^^^^^^^^^^^ PIE794 -5 | -6 | def remove(self) -> None: - | - = help: Remove duplicate field definition for `name` - -ℹ Suggested fix -1 1 | class Foo(BaseModel): -2 2 | name = StringField() -3 3 | # .... -4 |- name = StringField() # PIE794 -5 4 | -6 5 | def remove(self) -> None: -7 6 | ... - -PIE794.py:13:5: PIE794 [*] Class field `name` is defined multiple times - | -11 | name: str = StringField() -12 | # .... -13 | name = StringField() # PIE794 - | ^^^^^^^^^^^^^^^^^^^^ PIE794 -14 | -15 | def foo(self) -> None: - | - = help: Remove duplicate field definition for `name` - -ℹ Suggested fix -10 10 | class Foo(BaseModel): -11 11 | name: str = StringField() -12 12 | # .... -13 |- name = StringField() # PIE794 -14 13 | -15 14 | def foo(self) -> None: -16 15 | ... - -PIE794.py:23:5: PIE794 [*] Class field `bar` is defined multiple times - | -21 | foo: bool = BooleanField() -22 | # ... -23 | bar = StringField() # PIE794 - | ^^^^^^^^^^^^^^^^^^^ PIE794 - | - = help: Remove duplicate field definition for `bar` - -ℹ Suggested fix -20 20 | bar: str = StringField() -21 21 | foo: bool = BooleanField() -22 22 | # ... -23 |- bar = StringField() # PIE794 -24 23 | -25 24 | -26 25 | class User(BaseModel): - -PIE794.py:40:5: PIE794 [*] Class field `bar` is defined multiple times - | -38 | foo: bool = BooleanField() -39 | # ... -40 | bar = StringField() # PIE794 - | ^^^^^^^^^^^^^^^^^^^ PIE794 - | - = help: Remove duplicate field definition for `bar` - -ℹ Suggested fix -37 37 | bar: str = StringField() -38 38 | foo: bool = BooleanField() -39 39 | # ... -40 |- bar = StringField() # PIE794 - - diff --git a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE796_PIE796.py.snap b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE796_PIE796.py.snap deleted file mode 100644 index b7ea29b907..0000000000 --- a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE796_PIE796.py.snap +++ /dev/null @@ -1,60 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pie/mod.rs ---- -PIE796.py:8:5: PIE796 Enum contains duplicate value: `"B"` - | -6 | A = "A" -7 | B = "B" -8 | C = "B" # PIE796 - | ^^^^^^^ PIE796 - | - -PIE796.py:14:5: PIE796 Enum contains duplicate value: `2` - | -12 | A = 1 -13 | B = 2 -14 | C = 2 # PIE796 - | ^^^^^ PIE796 - | - -PIE796.py:20:5: PIE796 Enum contains duplicate value: `"2"` - | -18 | A = "1" -19 | B = "2" -20 | C = "2" # PIE796 - | ^^^^^^^ PIE796 - | - -PIE796.py:26:5: PIE796 Enum contains duplicate value: `2.5` - | -24 | A = 1.0 -25 | B = 2.5 -26 | C = 2.5 # PIE796 - | ^^^^^^^ PIE796 - | - -PIE796.py:33:5: PIE796 Enum contains duplicate value: `False` - | -31 | B = True -32 | C = False -33 | D = False # PIE796 - | ^^^^^^^^^ PIE796 - | - -PIE796.py:40:5: PIE796 Enum contains duplicate value: `None` - | -38 | B = 2 -39 | C = None -40 | D = None # PIE796 - | ^^^^^^^^ PIE796 - | - -PIE796.py:54:5: PIE796 Enum contains duplicate value: `2` - | -52 | A = 1 -53 | B = 2 -54 | C = 2 # PIE796 - | ^^^^^ PIE796 - | - - diff --git a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE800_PIE800.py.snap b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE800_PIE800.py.snap deleted file mode 100644 index 9ad2ff5115..0000000000 --- a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE800_PIE800.py.snap +++ /dev/null @@ -1,42 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pie/mod.rs ---- -PIE800.py:1:14: PIE800 Unnecessary spread `**` - | -1 | {"foo": 1, **{"bar": 1}} # PIE800 - | ^^^^^^^^^^ PIE800 -2 | -3 | foo({**foo, **{"bar": True}}) # PIE800 - | - -PIE800.py:3:15: PIE800 Unnecessary spread `**` - | -1 | {"foo": 1, **{"bar": 1}} # PIE800 -2 | -3 | foo({**foo, **{"bar": True}}) # PIE800 - | ^^^^^^^^^^^^^ PIE800 -4 | -5 | {**foo, **{"bar": 10}} # PIE800 - | - -PIE800.py:5:11: PIE800 Unnecessary spread `**` - | -3 | foo({**foo, **{"bar": True}}) # PIE800 -4 | -5 | {**foo, **{"bar": 10}} # PIE800 - | ^^^^^^^^^^^ PIE800 -6 | -7 | {**foo, **buzz, **{bar: 10}} # PIE800 - | - -PIE800.py:7:19: PIE800 Unnecessary spread `**` - | -5 | {**foo, **{"bar": 10}} # PIE800 -6 | -7 | {**foo, **buzz, **{bar: 10}} # PIE800 - | ^^^^^^^^^ PIE800 -8 | -9 | {**foo, "bar": True } # OK - | - - diff --git a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE804_PIE804.py.snap b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE804_PIE804.py.snap deleted file mode 100644 index 799ff8468e..0000000000 --- a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE804_PIE804.py.snap +++ /dev/null @@ -1,50 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pie/mod.rs ---- -PIE804.py:1:1: PIE804 Unnecessary `dict` kwargs - | -1 | foo(**{"bar": True}) # PIE804 - | ^^^^^^^^^^^^^^^^^^^^ PIE804 -2 | -3 | foo(**{"r2d2": True}) # PIE804 - | - -PIE804.py:3:1: PIE804 Unnecessary `dict` kwargs - | -1 | foo(**{"bar": True}) # PIE804 -2 | -3 | foo(**{"r2d2": True}) # PIE804 - | ^^^^^^^^^^^^^^^^^^^^^ PIE804 -4 | -5 | Foo.objects.create(**{"bar": True}) # PIE804 - | - -PIE804.py:5:1: PIE804 Unnecessary `dict` kwargs - | -3 | foo(**{"r2d2": True}) # PIE804 -4 | -5 | Foo.objects.create(**{"bar": True}) # PIE804 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE804 -6 | -7 | Foo.objects.create(**{"_id": some_id}) # PIE804 - | - -PIE804.py:7:1: PIE804 Unnecessary `dict` kwargs - | -5 | Foo.objects.create(**{"bar": True}) # PIE804 -6 | -7 | Foo.objects.create(**{"_id": some_id}) # PIE804 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE804 -8 | -9 | Foo.objects.create(**{**bar}) # PIE804 - | - -PIE804.py:9:1: PIE804 Unnecessary `dict` kwargs - | -7 | Foo.objects.create(**{"_id": some_id}) # PIE804 -8 | -9 | Foo.objects.create(**{**bar}) # PIE804 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE804 - | - - diff --git a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE807_PIE807.py.snap b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE807_PIE807.py.snap deleted file mode 100644 index 41c220bad5..0000000000 --- a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE807_PIE807.py.snap +++ /dev/null @@ -1,58 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pie/mod.rs ---- -PIE807.py:3:44: PIE807 [*] Prefer `list` over useless lambda - | -1 | @dataclass -2 | class Foo: -3 | foo: List[str] = field(default_factory=lambda: []) # PIE807 - | ^^^^^^^^^^ PIE807 - | - = help: Replace with `list` - -ℹ Fix -1 1 | @dataclass -2 2 | class Foo: -3 |- foo: List[str] = field(default_factory=lambda: []) # PIE807 - 3 |+ foo: List[str] = field(default_factory=list) # PIE807 -4 4 | -5 5 | -6 6 | class FooTable(BaseTable): - -PIE807.py:7:36: PIE807 [*] Prefer `list` over useless lambda - | -6 | class FooTable(BaseTable): -7 | bar = fields.ListField(default=lambda: []) # PIE807 - | ^^^^^^^^^^ PIE807 - | - = help: Replace with `list` - -ℹ Fix -4 4 | -5 5 | -6 6 | class FooTable(BaseTable): -7 |- bar = fields.ListField(default=lambda: []) # PIE807 - 7 |+ bar = fields.ListField(default=list) # PIE807 -8 8 | -9 9 | -10 10 | class FooTable(BaseTable): - -PIE807.py:11:28: PIE807 [*] Prefer `list` over useless lambda - | -10 | class FooTable(BaseTable): -11 | bar = fields.ListField(lambda: []) # PIE807 - | ^^^^^^^^^^ PIE807 - | - = help: Replace with `list` - -ℹ Fix -8 8 | -9 9 | -10 10 | class FooTable(BaseTable): -11 |- bar = fields.ListField(lambda: []) # PIE807 - 11 |+ bar = fields.ListField(list) # PIE807 -12 12 | -13 13 | -14 14 | @dataclass - - diff --git a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE808_PIE808.py.snap b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE808_PIE808.py.snap deleted file mode 100644 index 0215ece47a..0000000000 --- a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE808_PIE808.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pie/mod.rs ---- -PIE808.py:2:7: PIE808 [*] Unnecessary `start` argument in `range` - | -1 | # PIE808 -2 | range(0, 10) - | ^ PIE808 -3 | -4 | # OK - | - = help: Remove `start` argument - -ℹ Fix -1 1 | # PIE808 -2 |-range(0, 10) - 2 |+range(10) -3 3 | -4 4 | # OK -5 5 | range(x, 10) - - diff --git a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE810_PIE810.py.snap b/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE810_PIE810.py.snap deleted file mode 100644 index cf5530d236..0000000000 --- a/crates/ruff/src/rules/flake8_pie/snapshots/ruff__rules__flake8_pie__tests__PIE810_PIE810.py.snap +++ /dev/null @@ -1,106 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pie/mod.rs ---- -PIE810.py:2:1: PIE810 [*] Call `startswith` once with a `tuple` - | -1 | # error -2 | obj.startswith("foo") or obj.startswith("bar") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 -3 | # error -4 | obj.endswith("foo") or obj.endswith("bar") - | - = help: Merge into a single `startswith` call - -ℹ Suggested fix -1 1 | # error -2 |-obj.startswith("foo") or obj.startswith("bar") - 2 |+obj.startswith(("foo", "bar")) -3 3 | # error -4 4 | obj.endswith("foo") or obj.endswith("bar") -5 5 | # error - -PIE810.py:4:1: PIE810 [*] Call `endswith` once with a `tuple` - | -2 | obj.startswith("foo") or obj.startswith("bar") -3 | # error -4 | obj.endswith("foo") or obj.endswith("bar") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 -5 | # error -6 | obj.startswith(foo) or obj.startswith(bar) - | - = help: Merge into a single `endswith` call - -ℹ Suggested fix -1 1 | # error -2 2 | obj.startswith("foo") or obj.startswith("bar") -3 3 | # error -4 |-obj.endswith("foo") or obj.endswith("bar") - 4 |+obj.endswith(("foo", "bar")) -5 5 | # error -6 6 | obj.startswith(foo) or obj.startswith(bar) -7 7 | # error - -PIE810.py:6:1: PIE810 [*] Call `startswith` once with a `tuple` - | -4 | obj.endswith("foo") or obj.endswith("bar") -5 | # error -6 | obj.startswith(foo) or obj.startswith(bar) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 -7 | # error -8 | obj.startswith(foo) or obj.startswith("foo") - | - = help: Merge into a single `startswith` call - -ℹ Suggested fix -3 3 | # error -4 4 | obj.endswith("foo") or obj.endswith("bar") -5 5 | # error -6 |-obj.startswith(foo) or obj.startswith(bar) - 6 |+obj.startswith((foo, bar)) -7 7 | # error -8 8 | obj.startswith(foo) or obj.startswith("foo") -9 9 | # error - -PIE810.py:8:1: PIE810 [*] Call `startswith` once with a `tuple` - | - 6 | obj.startswith(foo) or obj.startswith(bar) - 7 | # error - 8 | obj.startswith(foo) or obj.startswith("foo") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 - 9 | # error -10 | obj.endswith(foo) or obj.startswith(foo) or obj.startswith("foo") - | - = help: Merge into a single `startswith` call - -ℹ Suggested fix -5 5 | # error -6 6 | obj.startswith(foo) or obj.startswith(bar) -7 7 | # error -8 |-obj.startswith(foo) or obj.startswith("foo") - 8 |+obj.startswith((foo, "foo")) -9 9 | # error -10 10 | obj.endswith(foo) or obj.startswith(foo) or obj.startswith("foo") -11 11 | - -PIE810.py:10:1: PIE810 [*] Call `startswith` once with a `tuple` - | - 8 | obj.startswith(foo) or obj.startswith("foo") - 9 | # error -10 | obj.endswith(foo) or obj.startswith(foo) or obj.startswith("foo") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 -11 | -12 | # ok - | - = help: Merge into a single `startswith` call - -ℹ Suggested fix -7 7 | # error -8 8 | obj.startswith(foo) or obj.startswith("foo") -9 9 | # error -10 |-obj.endswith(foo) or obj.startswith(foo) or obj.startswith("foo") - 10 |+obj.endswith(foo) or obj.startswith((foo, "foo")) -11 11 | -12 12 | # ok -13 13 | obj.startswith(("foo", "bar")) - - diff --git a/crates/ruff/src/rules/flake8_print/snapshots/ruff__rules__flake8_print__tests__T201_T201.py.snap b/crates/ruff/src/rules/flake8_print/snapshots/ruff__rules__flake8_print__tests__T201_T201.py.snap deleted file mode 100644 index 909be25e28..0000000000 --- a/crates/ruff/src/rules/flake8_print/snapshots/ruff__rules__flake8_print__tests__T201_T201.py.snap +++ /dev/null @@ -1,42 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_print/mod.rs ---- -T201.py:4:1: T201 `print` found - | -2 | import tempfile -3 | -4 | print("Hello, world!") # T201 - | ^^^^^ T201 -5 | print("Hello, world!", file=None) # T201 -6 | print("Hello, world!", file=sys.stdout) # T201 - | - -T201.py:5:1: T201 `print` found - | -4 | print("Hello, world!") # T201 -5 | print("Hello, world!", file=None) # T201 - | ^^^^^ T201 -6 | print("Hello, world!", file=sys.stdout) # T201 -7 | print("Hello, world!", file=sys.stderr) # T201 - | - -T201.py:6:1: T201 `print` found - | -4 | print("Hello, world!") # T201 -5 | print("Hello, world!", file=None) # T201 -6 | print("Hello, world!", file=sys.stdout) # T201 - | ^^^^^ T201 -7 | print("Hello, world!", file=sys.stderr) # T201 - | - -T201.py:7:1: T201 `print` found - | -5 | print("Hello, world!", file=None) # T201 -6 | print("Hello, world!", file=sys.stdout) # T201 -7 | print("Hello, world!", file=sys.stderr) # T201 - | ^^^^^ T201 -8 | -9 | with tempfile.NamedTemporaryFile() as fp: - | - - diff --git a/crates/ruff/src/rules/flake8_print/snapshots/ruff__rules__flake8_print__tests__T203_T203.py.snap b/crates/ruff/src/rules/flake8_print/snapshots/ruff__rules__flake8_print__tests__T203_T203.py.snap deleted file mode 100644 index 80fe3da75f..0000000000 --- a/crates/ruff/src/rules/flake8_print/snapshots/ruff__rules__flake8_print__tests__T203_T203.py.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_print/mod.rs ---- -T203.py:3:1: T203 `pprint` found - | -1 | from pprint import pprint -2 | -3 | pprint("Hello, world!") # T203 - | ^^^^^^ T203 -4 | -5 | import pprint - | - -T203.py:7:1: T203 `pprint` found - | -5 | import pprint -6 | -7 | pprint.pprint("Hello, world!") # T203 - | ^^^^^^^^^^^^^ T203 -8 | -9 | pprint.pformat("Hello, world!") - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI001_PYI001.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI001_PYI001.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI001_PYI001.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI001_PYI001.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI001_PYI001.pyi.snap deleted file mode 100644 index 66c6c1809c..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI001_PYI001.pyi.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI001.pyi:3:5: PYI001 Name of private `TypeVar` must start with `_` - | -1 | from typing import ParamSpec, TypeVar, TypeVarTuple -2 | -3 | T = TypeVar("T") # Error: TypeVars in stubs must start with _ - | ^^^^^^^^^^^^ PYI001 -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 | -5 | TTuple = TypeVarTuple("TTuple") # Error: TypeVarTuples must also start with _ - | ^^^^^^^^^^^^^^^^^^^^^^ PYI001 -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 | -7 | P = ParamSpec("P") # Error: ParamSpecs must start with _ - | ^^^^^^^^^^^^^^ PYI001 -8 | -9 | _T = TypeVar("_T") # OK - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI002_PYI002.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI002_PYI002.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI002_PYI002.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI002_PYI002.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI002_PYI002.pyi.snap deleted file mode 100644 index d5de9a5682..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI002_PYI002.pyi.snap +++ /dev/null @@ -1,40 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI002.pyi:3:4: PYI002 `if` test must be a simple comparison against `sys.platform` or `sys.version_info` - | -1 | import sys -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 -5 | if hasattr(sys, 'maxint'): ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info - | - -PYI002.pyi:4:4: PYI002 `if` test must be a simple comparison against `sys.platform` or `sys.version_info` - | -3 | if sys.version == 'Python 2.7.10': ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info -4 | if 'linux' == sys.platform: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI002 -5 | if hasattr(sys, 'maxint'): ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info -6 | if sys.maxsize == 42: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info - | - -PYI002.pyi:5:4: PYI002 `if` test must be a simple comparison against `sys.platform` or `sys.version_info` - | -3 | if sys.version == 'Python 2.7.10': ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info -4 | if 'linux' == sys.platform: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info -5 | if hasattr(sys, 'maxint'): ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info - | ^^^^^^^^^^^^^^^^^^^^^^ PYI002 -6 | if sys.maxsize == 42: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info - | - -PYI002.pyi:6:4: PYI002 `if` test must be a simple comparison against `sys.platform` or `sys.version_info` - | -4 | if 'linux' == sys.platform: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info -5 | if hasattr(sys, 'maxint'): ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info -6 | if sys.maxsize == 42: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info - | ^^^^^^^^^^^^^^^^^ PYI002 - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI003_PYI003.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI003_PYI003.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI003_PYI003.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI003_PYI003.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI003_PYI003.pyi.snap deleted file mode 100644 index 2ce520c09b..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI003_PYI003.pyi.snap +++ /dev/null @@ -1,173 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -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:' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 - | - -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:' -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 -7 | if sys.version_info[0j] == 2: ... # Y003 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:' -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 -7 | if sys.version_info[0j] == 2: ... # Y003 Unrecognized sys.version_info check -8 | if sys.version_info[0] == (2, 7): ... # Y003 Unrecognized sys.version_info check - | - -PYI003.pyi:7:4: PYI003 Unrecognized `sys.version_info` check - | -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 -7 | if sys.version_info[0j] == 2: ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 -8 | if sys.version_info[0] == (2, 7): ... # Y003 Unrecognized sys.version_info check -9 | if sys.version_info[0] == '2': ... # Y003 Unrecognized sys.version_info check - | - -PYI003.pyi:8:4: PYI003 Unrecognized `sys.version_info` check - | - 6 | if sys.version_info[False] == 2: ... # Y003 Unrecognized sys.version_info check - 7 | if sys.version_info[0j] == 2: ... # Y003 Unrecognized sys.version_info check - 8 | if sys.version_info[0] == (2, 7): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 - 9 | if sys.version_info[0] == '2': ... # Y003 Unrecognized sys.version_info check -10 | if sys.version_info[1:] >= (7, 11): ... # Y003 Unrecognized sys.version_info check - | - -PYI003.pyi:9:4: PYI003 Unrecognized `sys.version_info` check - | - 7 | if sys.version_info[0j] == 2: ... # Y003 Unrecognized sys.version_info check - 8 | if sys.version_info[0] == (2, 7): ... # Y003 Unrecognized sys.version_info check - 9 | if sys.version_info[0] == '2': ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 -10 | if sys.version_info[1:] >= (7, 11): ... # Y003 Unrecognized sys.version_info check -11 | if sys.version_info[::-1] < (11, 7): ... # Y003 Unrecognized sys.version_info check - | - -PYI003.pyi:10:4: PYI003 Unrecognized `sys.version_info` check - | - 8 | if sys.version_info[0] == (2, 7): ... # Y003 Unrecognized sys.version_info check - 9 | if sys.version_info[0] == '2': ... # Y003 Unrecognized sys.version_info check -10 | if sys.version_info[1:] >= (7, 11): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 -11 | if sys.version_info[::-1] < (11, 7): ... # Y003 Unrecognized sys.version_info check -12 | if sys.version_info[:3] >= (2, 7): ... # Y003 Unrecognized sys.version_info check - | - -PYI003.pyi:11:4: PYI003 Unrecognized `sys.version_info` check - | - 9 | if sys.version_info[0] == '2': ... # Y003 Unrecognized sys.version_info check -10 | if sys.version_info[1:] >= (7, 11): ... # Y003 Unrecognized sys.version_info check -11 | if sys.version_info[::-1] < (11, 7): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 -12 | if sys.version_info[:3] >= (2, 7): ... # Y003 Unrecognized sys.version_info check -13 | if sys.version_info[:True] >= (2, 7): ... # Y003 Unrecognized sys.version_info check - | - -PYI003.pyi:12:4: PYI003 Unrecognized `sys.version_info` check - | -10 | if sys.version_info[1:] >= (7, 11): ... # Y003 Unrecognized sys.version_info check -11 | if sys.version_info[::-1] < (11, 7): ... # Y003 Unrecognized sys.version_info check -12 | if sys.version_info[:3] >= (2, 7): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 -13 | if sys.version_info[:True] >= (2, 7): ... # Y003 Unrecognized sys.version_info check -14 | if sys.version_info[:1] == (2,): ... - | - -PYI003.pyi:13:4: PYI003 Unrecognized `sys.version_info` check - | -11 | if sys.version_info[::-1] < (11, 7): ... # Y003 Unrecognized sys.version_info check -12 | if sys.version_info[:3] >= (2, 7): ... # Y003 Unrecognized sys.version_info check -13 | if sys.version_info[:True] >= (2, 7): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 -14 | if sys.version_info[:1] == (2,): ... -15 | if sys.version_info[:1] == (True,): ... # Y003 Unrecognized sys.version_info check - | - -PYI003.pyi:15:4: PYI003 Unrecognized `sys.version_info` check - | -13 | if sys.version_info[:True] >= (2, 7): ... # Y003 Unrecognized sys.version_info check -14 | if sys.version_info[:1] == (2,): ... -15 | if sys.version_info[:1] == (True,): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 -16 | if sys.version_info[:1] == (2, 7): ... # Y005 Version comparison must be against a length-1 tuple -17 | if sys.version_info[:2] == (2, 7): ... - | - -PYI003.pyi:19:4: PYI003 Unrecognized `sys.version_info` check - | -17 | if sys.version_info[:2] == (2, 7): ... -18 | if sys.version_info[:2] == (2,): ... # Y005 Version comparison must be against a length-2 tuple -19 | if sys.version_info[:2] == "lol": ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 -20 | if sys.version_info[:2.0] >= (3, 9): ... # Y003 Unrecognized sys.version_info check -21 | if sys.version_info[:2j] >= (3, 9): ... # Y003 Unrecognized sys.version_info check - | - -PYI003.pyi:20:4: PYI003 Unrecognized `sys.version_info` check - | -18 | if sys.version_info[:2] == (2,): ... # Y005 Version comparison must be against a length-2 tuple -19 | if sys.version_info[:2] == "lol": ... # Y003 Unrecognized sys.version_info check -20 | if sys.version_info[:2.0] >= (3, 9): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 -21 | if sys.version_info[:2j] >= (3, 9): ... # Y003 Unrecognized sys.version_info check -22 | if sys.version_info[:, :] >= (2, 7): ... # Y003 Unrecognized sys.version_info check - | - -PYI003.pyi:21:4: PYI003 Unrecognized `sys.version_info` check - | -19 | if sys.version_info[:2] == "lol": ... # Y003 Unrecognized sys.version_info check -20 | if sys.version_info[:2.0] >= (3, 9): ... # Y003 Unrecognized sys.version_info check -21 | if sys.version_info[:2j] >= (3, 9): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 -22 | if sys.version_info[:, :] >= (2, 7): ... # Y003 Unrecognized sys.version_info check -23 | if sys.version_info < [3, 0]: ... # Y003 Unrecognized sys.version_info check - | - -PYI003.pyi:22:4: PYI003 Unrecognized `sys.version_info` check - | -20 | if sys.version_info[:2.0] >= (3, 9): ... # Y003 Unrecognized sys.version_info check -21 | if sys.version_info[:2j] >= (3, 9): ... # Y003 Unrecognized sys.version_info check -22 | if sys.version_info[:, :] >= (2, 7): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 -23 | if sys.version_info < [3, 0]: ... # Y003 Unrecognized sys.version_info check -24 | if sys.version_info < ('3', '0'): ... # Y003 Unrecognized sys.version_info check - | - -PYI003.pyi:23:4: PYI003 Unrecognized `sys.version_info` check - | -21 | if sys.version_info[:2j] >= (3, 9): ... # Y003 Unrecognized sys.version_info check -22 | if sys.version_info[:, :] >= (2, 7): ... # Y003 Unrecognized sys.version_info check -23 | if sys.version_info < [3, 0]: ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 -24 | if sys.version_info < ('3', '0'): ... # Y003 Unrecognized sys.version_info check -25 | if sys.version_info >= (3, 4, 3): ... # Y004 Version comparison must use only major and minor version - | - -PYI003.pyi:24:4: PYI003 Unrecognized `sys.version_info` check - | -22 | if sys.version_info[:, :] >= (2, 7): ... # Y003 Unrecognized sys.version_info check -23 | if sys.version_info < [3, 0]: ... # Y003 Unrecognized sys.version_info check -24 | if sys.version_info < ('3', '0'): ... # Y003 Unrecognized sys.version_info check - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 -25 | if sys.version_info >= (3, 4, 3): ... # Y004 Version comparison must use only major and minor version -26 | if sys.version_info == (3, 4): ... # Y006 Use only < and >= for version comparisons - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI004_PYI004.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI004_PYI004.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI004_PYI004.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI004_PYI004.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI004_PYI004.pyi.snap deleted file mode 100644 index ddb37572e5..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI004_PYI004.pyi.snap +++ /dev/null @@ -1,42 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI004.pyi:4:4: PYI004 Version comparison must use only major and minor version - | -2 | from sys import version_info -3 | -4 | if sys.version_info >= (3, 4, 3): ... # PYI004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI004 -5 | if sys.version_info < (3, 4, 3): ... # PYI004 -6 | if sys.version_info == (3, 4, 3): ... # PYI004 - | - -PYI004.pyi:5:4: PYI004 Version comparison must use only major and minor version - | -4 | if sys.version_info >= (3, 4, 3): ... # PYI004 -5 | if sys.version_info < (3, 4, 3): ... # PYI004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI004 -6 | if sys.version_info == (3, 4, 3): ... # PYI004 -7 | if sys.version_info != (3, 4, 3): ... # PYI004 - | - -PYI004.pyi:6:4: PYI004 Version comparison must use only major and minor version - | -4 | if sys.version_info >= (3, 4, 3): ... # PYI004 -5 | if sys.version_info < (3, 4, 3): ... # PYI004 -6 | if sys.version_info == (3, 4, 3): ... # PYI004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI004 -7 | if sys.version_info != (3, 4, 3): ... # PYI004 - | - -PYI004.pyi:7:4: PYI004 Version comparison must use only major and minor version - | -5 | if sys.version_info < (3, 4, 3): ... # PYI004 -6 | if sys.version_info == (3, 4, 3): ... # PYI004 -7 | if sys.version_info != (3, 4, 3): ... # PYI004 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI004 -8 | -9 | if sys.version_info[0] == 2: ... - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI005_PYI005.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI005_PYI005.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI005_PYI005.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI005_PYI005.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI005_PYI005.pyi.snap deleted file mode 100644 index 1641bce44c..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI005_PYI005.pyi.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI005.pyi:4:4: PYI005 Version comparison must be against a length-1 tuple - | -2 | from sys import platform, version_info -3 | -4 | if sys.version_info[:1] == (2, 7): ... # Y005 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI005 -5 | if sys.version_info[:2] == (2,): ... # Y005 - | - -PYI005.pyi:5:4: PYI005 Version comparison must be against a length-2 tuple - | -4 | if sys.version_info[:1] == (2, 7): ... # Y005 -5 | if sys.version_info[:2] == (2,): ... # Y005 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI005 - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI006_PYI006.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI006_PYI006.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI006_PYI006.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI006_PYI006.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI006_PYI006.pyi.snap deleted file mode 100644 index 8dbd74304f..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI006_PYI006.pyi.snap +++ /dev/null @@ -1,62 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI006.pyi:8:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons - | - 6 | if sys.version_info >= (3, 9): ... # OK - 7 | - 8 | if sys.version_info == (3, 9): ... # OK - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 - 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 | -10 | if sys.version_info == (3, 9): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 -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 | -12 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 -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 | -14 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 -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 | -16 | if sys.version_info > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 -17 | -18 | if python_version > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | - -PYI006.pyi:18:4: 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 | -18 | if python_version > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons - | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI007_PYI007.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI007_PYI007.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI007_PYI007.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI007_PYI007.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI007_PYI007.pyi.snap deleted file mode 100644 index fda6f47ed1..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI007_PYI007.pyi.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI007.pyi:7:4: PYI007 Unrecognized `sys.platform` check - | -5 | if sys.platform != "platform_name_2": ... # OK -6 | -7 | if sys.platform in ["linux"]: ... # Error: PYI007 Unrecognized sys.platform check - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI007 -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 | - 9 | if sys.platform > 3: ... # Error: PYI007 Unrecognized sys.platform check - | ^^^^^^^^^^^^^^^^ PYI007 -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 | -11 | if sys.platform == 10.12: ... # Error: PYI007 Unrecognized sys.platform check - | ^^^^^^^^^^^^^^^^^^^^^ PYI007 - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI008_PYI008.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI008_PYI008.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI008_PYI008.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI008_PYI008.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI008_PYI008.pyi.snap deleted file mode 100644 index d31927fdc6..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI008_PYI008.pyi.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI008.pyi:3:20: PYI008 Unrecognized platform `linus` - | -1 | import sys -2 | -3 | if sys.platform == "linus": ... # Error: PYI008 Unrecognized platform `linus` - | ^^^^^^^ PYI008 -4 | -5 | if sys.platform != "linux": ... # OK - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI009_PYI009.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI009_PYI009.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI009_PYI009.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI009_PYI009.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI009_PYI009.pyi.snap deleted file mode 100644 index 94a71927a0..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI009_PYI009.pyi.snap +++ /dev/null @@ -1,39 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI009.pyi:3:5: PYI009 [*] Empty body should contain `...`, not `pass` - | -1 | def bar(): ... # OK -2 | def foo(): -3 | pass # ERROR PYI009, since we're in a stub file - | ^^^^ PYI009 -4 | -5 | class Bar: ... # OK - | - = help: Replace `pass` with `...` - -ℹ Fix -1 1 | def bar(): ... # OK -2 2 | def foo(): -3 |- pass # ERROR PYI009, since we're in a stub file - 3 |+ ... # ERROR PYI009, since we're in a stub file -4 4 | -5 5 | class Bar: ... # OK -6 6 | - -PYI009.pyi:8:5: PYI009 [*] Empty body should contain `...`, not `pass` - | -7 | class Foo: -8 | pass # ERROR PYI009, since we're in a stub file - | ^^^^ PYI009 - | - = help: Replace `pass` with `...` - -ℹ Fix -5 5 | class Bar: ... # OK -6 6 | -7 7 | class Foo: -8 |- pass # ERROR PYI009, since we're in a stub file - 8 |+ ... # ERROR PYI009, since we're in a stub file - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI010_PYI010.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI010_PYI010.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI010_PYI010.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap deleted file mode 100644 index 1e757d8872..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap +++ /dev/null @@ -1,64 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI010.pyi:6:5: PYI010 [*] Function body must contain only `...` - | -5 | def buzz(): -6 | print("buzz") # ERROR PYI010 - | ^^^^^^^^^^^^^ PYI010 -7 | -8 | def foo2(): - | - = help: Replace function body with `...` - -ℹ Suggested fix -3 3 | """foo""" # OK, docstrings are handled by another rule -4 4 | -5 5 | def buzz(): -6 |- print("buzz") # ERROR PYI010 - 6 |+ ... # ERROR PYI010 -7 7 | -8 8 | def foo2(): -9 9 | 123 # ERROR PYI010 - -PYI010.pyi:9:5: PYI010 [*] Function body must contain only `...` - | - 8 | def foo2(): - 9 | 123 # ERROR PYI010 - | ^^^ PYI010 -10 | -11 | def bizz(): - | - = help: Replace function body with `...` - -ℹ Suggested fix -6 6 | print("buzz") # ERROR PYI010 -7 7 | -8 8 | def foo2(): -9 |- 123 # ERROR PYI010 - 9 |+ ... # ERROR PYI010 -10 10 | -11 11 | def bizz(): -12 12 | x = 123 # ERROR PYI010 - -PYI010.pyi:12:5: PYI010 [*] Function body must contain only `...` - | -11 | def bizz(): -12 | x = 123 # ERROR PYI010 - | ^^^^^^^ PYI010 -13 | -14 | def foo3(): - | - = help: Replace function body with `...` - -ℹ Suggested fix -9 9 | 123 # ERROR PYI010 -10 10 | -11 11 | def bizz(): -12 |- x = 123 # ERROR PYI010 - 12 |+ ... # ERROR PYI010 -13 13 | -14 14 | def foo3(): -15 15 | pass # OK, pass is handled by another rule - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI011_PYI011.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI011_PYI011.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI011_PYI011.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI011_PYI011.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI011_PYI011.pyi.snap deleted file mode 100644 index b8e5942372..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI011_PYI011.pyi.snap +++ /dev/null @@ -1,457 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI011.pyi:10:14: PYI011 [*] Only simple default values allowed for typed arguments - | - 8 | def f12( - 9 | x, -10 | y: str = os.pathsep, # Error PYI011 Only simple default values allowed for typed arguments - | ^^^^^^^^^^ PYI011 -11 | ) -> None: ... -12 | def f11(*, x: str = "x") -> None: ... # OK - | - = help: Replace default value with `...` - -ℹ Suggested fix -7 7 | -8 8 | def f12( -9 9 | x, -10 |- y: str = os.pathsep, # Error PYI011 Only simple default values allowed for typed arguments - 10 |+ y: str = ..., # Error PYI011 Only simple default values allowed for typed arguments -11 11 | ) -> None: ... -12 12 | def f11(*, x: str = "x") -> None: ... # OK -13 13 | def f13( - -PYI011.pyi:38:9: PYI011 [*] Only simple default values allowed for typed arguments - | -36 | x: dict[ -37 | int, int -38 | ] = { # Error PYI011 Only simple default values allowed for typed arguments - | _________^ -39 | | 1: 2, -40 | | **{3: 4}, -41 | | } - | |_____^ PYI011 -42 | ) -> None: ... -43 | def f153( - | - = help: Replace default value with `...` - -ℹ Suggested fix -35 35 | def f152( -36 36 | x: dict[ -37 37 | int, int -38 |- ] = { # Error PYI011 Only simple default values allowed for typed arguments -39 |- 1: 2, -40 |- **{3: 4}, -41 |- } - 38 |+ ] = ... -42 39 | ) -> None: ... -43 40 | def f153( -44 41 | x: list[ - -PYI011.pyi:46:9: PYI011 [*] Only simple default values allowed for typed arguments - | -44 | x: list[ -45 | int -46 | ] = [ # Error PYI011 Only simple default values allowed for typed arguments - | _________^ -47 | | 1, -48 | | 2, -49 | | 3, -50 | | 4, -51 | | 5, -52 | | 6, -53 | | 7, -54 | | 8, -55 | | 9, -56 | | 10, -57 | | 11, -58 | | ] - | |_____^ PYI011 -59 | ) -> None: ... -60 | def f154( - | - = help: Replace default value with `...` - -ℹ Suggested fix -43 43 | def f153( -44 44 | x: list[ -45 45 | int -46 |- ] = [ # Error PYI011 Only simple default values allowed for typed arguments -47 |- 1, -48 |- 2, -49 |- 3, -50 |- 4, -51 |- 5, -52 |- 6, -53 |- 7, -54 |- 8, -55 |- 9, -56 |- 10, -57 |- 11, -58 |- ] - 46 |+ ] = ... -59 47 | ) -> None: ... -60 48 | def f154( -61 49 | x: tuple[ - -PYI011.pyi:63:9: PYI011 [*] Only simple default values allowed for typed arguments - | -61 | x: tuple[ -62 | str, tuple[str, ...] -63 | ] = ( # Error PYI011 Only simple default values allowed for typed arguments - | _________^ -64 | | "foo", -65 | | ("bar", "baz"), -66 | | ) - | |_____^ PYI011 -67 | ) -> None: ... -68 | def f141( - | - = help: Replace default value with `...` - -ℹ Suggested fix -60 60 | def f154( -61 61 | x: tuple[ -62 62 | str, tuple[str, ...] -63 |- ] = ( # Error PYI011 Only simple default values allowed for typed arguments -64 |- "foo", -65 |- ("bar", "baz"), -66 |- ) - 63 |+ ] = ... -67 64 | ) -> None: ... -68 65 | def f141( -69 66 | x: list[ - -PYI011.pyi:71:9: PYI011 [*] Only simple default values allowed for typed arguments - | -69 | x: list[ -70 | int -71 | ] = [ # Error PYI011 Only simple default values allowed for typed arguments - | _________^ -72 | | *range(10) -73 | | ], - | |_____^ PYI011 -74 | ) -> None: ... -75 | def f142( - | - = help: Replace default value with `...` - -ℹ Suggested fix -68 68 | def f141( -69 69 | x: list[ -70 70 | int -71 |- ] = [ # Error PYI011 Only simple default values allowed for typed arguments -72 |- *range(10) -73 |- ], - 71 |+ ] = ..., -74 72 | ) -> None: ... -75 73 | def f142( -76 74 | x: list[ - -PYI011.pyi:78:9: PYI011 [*] Only simple default values allowed for typed arguments - | -76 | x: list[ -77 | int -78 | ] = list( # Error PYI011 Only simple default values allowed for typed arguments - | _________^ -79 | | range(10) -80 | | ), - | |_____^ PYI011 -81 | ) -> None: ... -82 | def f16( - | - = help: Replace default value with `...` - -ℹ Suggested fix -75 75 | def f142( -76 76 | x: list[ -77 77 | int -78 |- ] = list( # Error PYI011 Only simple default values allowed for typed arguments -79 |- range(10) -80 |- ), - 78 |+ ] = ..., -81 79 | ) -> None: ... -82 80 | def f16( -83 81 | x: frozenset[ - -PYI011.pyi:85:9: PYI011 [*] Only simple default values allowed for typed arguments - | -83 | x: frozenset[ -84 | bytes -85 | ] = frozenset( # Error PYI011 Only simple default values allowed for typed arguments - | _________^ -86 | | {b"foo", b"bar", b"baz"} -87 | | ) - | |_____^ PYI011 -88 | ) -> None: ... -89 | def f17( - | - = help: Replace default value with `...` - -ℹ Suggested fix -82 82 | def f16( -83 83 | x: frozenset[ -84 84 | bytes -85 |- ] = frozenset( # Error PYI011 Only simple default values allowed for typed arguments -86 |- {b"foo", b"bar", b"baz"} -87 |- ) - 85 |+ ] = ... -88 86 | ) -> None: ... -89 87 | def f17( -90 88 | x: str = "foo" # Error PYI011 Only simple default values allowed for typed arguments - -PYI011.pyi:90:14: PYI011 [*] Only simple default values allowed for typed arguments - | -88 | ) -> None: ... -89 | def f17( -90 | x: str = "foo" # Error PYI011 Only simple default values allowed for typed arguments - | ______________^ -91 | | + "bar", - | |___________^ PYI011 -92 | ) -> None: ... -93 | def f18( - | - = help: Replace default value with `...` - -ℹ Suggested fix -87 87 | ) -88 88 | ) -> None: ... -89 89 | def f17( -90 |- x: str = "foo" # Error PYI011 Only simple default values allowed for typed arguments -91 |- + "bar", - 90 |+ x: str = ..., -92 91 | ) -> None: ... -93 92 | def f18( -94 93 | x: str = b"foo" # Error PYI011 Only simple default values allowed for typed arguments - -PYI011.pyi:94:14: PYI011 [*] Only simple default values allowed for typed arguments - | -92 | ) -> None: ... -93 | def f18( -94 | x: str = b"foo" # Error PYI011 Only simple default values allowed for typed arguments - | ______________^ -95 | | + b"bar", - | |____________^ PYI011 -96 | ) -> None: ... -97 | def f19( - | - = help: Replace default value with `...` - -ℹ Suggested fix -91 91 | + "bar", -92 92 | ) -> None: ... -93 93 | def f18( -94 |- x: str = b"foo" # Error PYI011 Only simple default values allowed for typed arguments -95 |- + b"bar", - 94 |+ x: str = ..., -96 95 | ) -> None: ... -97 96 | def f19( -98 97 | x: object = "foo" # Error PYI011 Only simple default values allowed for typed arguments - -PYI011.pyi:98:17: PYI011 [*] Only simple default values allowed for typed arguments - | - 96 | ) -> None: ... - 97 | def f19( - 98 | x: object = "foo" # Error PYI011 Only simple default values allowed for typed arguments - | _________________^ - 99 | | + 4, - | |_______^ PYI011 -100 | ) -> None: ... -101 | def f20( - | - = help: Replace default value with `...` - -ℹ Suggested fix -95 95 | + b"bar", -96 96 | ) -> None: ... -97 97 | def f19( -98 |- x: object = "foo" # Error PYI011 Only simple default values allowed for typed arguments -99 |- + 4, - 98 |+ x: object = ..., -100 99 | ) -> None: ... -101 100 | def f20( -102 101 | x: int = 5 - -PYI011.pyi:102:14: PYI011 [*] Only simple default values allowed for typed arguments - | -100 | ) -> None: ... -101 | def f20( -102 | x: int = 5 - | ______________^ -103 | | + 5, # Error PYI011 Only simple default values allowed for typed arguments - | |_______^ PYI011 -104 | ) -> None: ... -105 | def f21( - | - = help: Replace default value with `...` - -ℹ Suggested fix -99 99 | + 4, -100 100 | ) -> None: ... -101 101 | def f20( -102 |- x: int = 5 -103 |- + 5, # Error PYI011 Only simple default values allowed for typed arguments - 102 |+ x: int = ..., # Error PYI011 Only simple default values allowed for typed arguments -104 103 | ) -> None: ... -105 104 | def f21( -106 105 | x: complex = 3j - -PYI011.pyi:106:18: PYI011 [*] Only simple default values allowed for typed arguments - | -104 | ) -> None: ... -105 | def f21( -106 | x: complex = 3j - | __________________^ -107 | | - 3j, # Error PYI011 Only simple default values allowed for typed arguments - | |________^ PYI011 -108 | ) -> None: ... -109 | def f22( - | - = help: Replace default value with `...` - -ℹ Suggested fix -103 103 | + 5, # Error PYI011 Only simple default values allowed for typed arguments -104 104 | ) -> None: ... -105 105 | def f21( -106 |- x: complex = 3j -107 |- - 3j, # Error PYI011 Only simple default values allowed for typed arguments - 106 |+ x: complex = ..., # Error PYI011 Only simple default values allowed for typed arguments -108 107 | ) -> None: ... -109 108 | def f22( -110 109 | x: complex = -42.5j # Error PYI011 Only simple default values allowed for typed arguments - -PYI011.pyi:110:18: PYI011 [*] Only simple default values allowed for typed arguments - | -108 | ) -> None: ... -109 | def f22( -110 | x: complex = -42.5j # Error PYI011 Only simple default values allowed for typed arguments - | __________________^ -111 | | + 4.3j, - | |__________^ PYI011 -112 | ) -> None: ... -113 | def f23( - | - = help: Replace default value with `...` - -ℹ Suggested fix -107 107 | - 3j, # Error PYI011 Only simple default values allowed for typed arguments -108 108 | ) -> None: ... -109 109 | def f22( -110 |- x: complex = -42.5j # Error PYI011 Only simple default values allowed for typed arguments -111 |- + 4.3j, - 110 |+ x: complex = ..., -112 111 | ) -> None: ... -113 112 | def f23( -114 113 | x: bool = True, # OK - -PYI011.pyi:138:16: PYI011 [*] Only simple default values allowed for typed arguments - | -136 | ) -> None: ... -137 | def f31( -138 | x: float = inf, # Error PYI011 Only simple default values allowed for typed arguments - | ^^^ PYI011 -139 | ) -> None: ... -140 | def f32( - | - = help: Replace default value with `...` - -ℹ Suggested fix -135 135 | x: float = -math.inf, # OK -136 136 | ) -> None: ... -137 137 | def f31( -138 |- x: float = inf, # Error PYI011 Only simple default values allowed for typed arguments - 138 |+ x: float = ..., # Error PYI011 Only simple default values allowed for typed arguments -139 139 | ) -> None: ... -140 140 | def f32( -141 141 | x: float = np.inf, # Error PYI011 Only simple default values allowed for typed arguments - -PYI011.pyi:141:16: PYI011 [*] Only simple default values allowed for typed arguments - | -139 | ) -> None: ... -140 | def f32( -141 | x: float = np.inf, # Error PYI011 Only simple default values allowed for typed arguments - | ^^^^^^ PYI011 -142 | ) -> None: ... -143 | def f33( - | - = help: Replace default value with `...` - -ℹ Suggested fix -138 138 | x: float = inf, # Error PYI011 Only simple default values allowed for typed arguments -139 139 | ) -> None: ... -140 140 | def f32( -141 |- x: float = np.inf, # Error PYI011 Only simple default values allowed for typed arguments - 141 |+ x: float = ..., # Error PYI011 Only simple default values allowed for typed arguments -142 142 | ) -> None: ... -143 143 | def f33( -144 144 | x: float = math.nan, # OK - -PYI011.pyi:147:16: PYI011 [*] Only simple default values allowed for typed arguments - | -145 | ) -> None: ... -146 | def f34( -147 | x: float = -math.nan, # Error PYI011 Only simple default values allowed for typed arguments - | ^^^^^^^^^ PYI011 -148 | ) -> None: ... -149 | def f35( - | - = help: Replace default value with `...` - -ℹ Suggested fix -144 144 | x: float = math.nan, # OK -145 145 | ) -> None: ... -146 146 | def f34( -147 |- x: float = -math.nan, # Error PYI011 Only simple default values allowed for typed arguments - 147 |+ x: float = ..., # Error PYI011 Only simple default values allowed for typed arguments -148 148 | ) -> None: ... -149 149 | def f35( -150 150 | x: complex = math.inf # Error PYI011 Only simple default values allowed for typed arguments - -PYI011.pyi:150:18: PYI011 [*] Only simple default values allowed for typed arguments - | -148 | ) -> None: ... -149 | def f35( -150 | x: complex = math.inf # Error PYI011 Only simple default values allowed for typed arguments - | __________________^ -151 | | + 1j, - | |________^ PYI011 -152 | ) -> None: ... -153 | def f36( - | - = help: Replace default value with `...` - -ℹ Suggested fix -147 147 | x: float = -math.nan, # Error PYI011 Only simple default values allowed for typed arguments -148 148 | ) -> None: ... -149 149 | def f35( -150 |- x: complex = math.inf # Error PYI011 Only simple default values allowed for typed arguments -151 |- + 1j, - 150 |+ x: complex = ..., -152 151 | ) -> None: ... -153 152 | def f36( -154 153 | *, - -PYI011.pyi:159:14: PYI011 [*] Only simple default values allowed for typed arguments - | -157 | def f37( -158 | *, -159 | x: str = "" # Error PYI011 Only simple default values allowed for typed arguments - | ______________^ -160 | | + "", - | |________^ PYI011 -161 | ) -> None: ... - | - = help: Replace default value with `...` - -ℹ Suggested fix -156 156 | ) -> None: ... -157 157 | def f37( -158 158 | *, -159 |- x: str = "" # Error PYI011 Only simple default values allowed for typed arguments -160 |- + "", - 159 |+ x: str = ..., -161 160 | ) -> None: ... - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI012_PYI012.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI012_PYI012.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI012_PYI012.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI012_PYI012.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI012_PYI012.pyi.snap deleted file mode 100644 index 09fc8eec04..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI012_PYI012.pyi.snap +++ /dev/null @@ -1,120 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI012.pyi:5:5: PYI012 [*] Class body must not contain `pass` - | -3 | class OneAttributeClass: -4 | value: int -5 | pass # PYI012 Class body must not contain `pass` - | ^^^^ PYI012 -6 | -7 | class OneAttributeClassRev: - | - = help: Remove unnecessary `pass` - -ℹ Fix -2 2 | -3 3 | class OneAttributeClass: -4 4 | value: int -5 |- pass # PYI012 Class body must not contain `pass` -6 5 | -7 6 | class OneAttributeClassRev: -8 7 | pass # PYI012 Class body must not contain `pass` - -PYI012.pyi:8:5: PYI012 [*] Class body must not contain `pass` - | -7 | class OneAttributeClassRev: -8 | pass # PYI012 Class body must not contain `pass` - | ^^^^ PYI012 -9 | value: int - | - = help: Remove unnecessary `pass` - -ℹ Fix -5 5 | pass # PYI012 Class body must not contain `pass` -6 6 | -7 7 | class OneAttributeClassRev: -8 |- pass # PYI012 Class body must not contain `pass` -9 8 | value: int -10 9 | -11 10 | class DocstringClass: - -PYI012.pyi:16:5: PYI012 [*] Class body must not contain `pass` - | -14 | """ -15 | -16 | pass # PYI012 Class body must not contain `pass` - | ^^^^ PYI012 -17 | -18 | class NonEmptyChild(Exception): - | - = help: Remove unnecessary `pass` - -ℹ Fix -13 13 | My body only contains pass. -14 14 | """ -15 15 | -16 |- pass # PYI012 Class body must not contain `pass` -17 16 | -18 17 | class NonEmptyChild(Exception): -19 18 | value: int - -PYI012.pyi:20:5: PYI012 [*] Class body must not contain `pass` - | -18 | class NonEmptyChild(Exception): -19 | value: int -20 | pass # PYI012 Class body must not contain `pass` - | ^^^^ PYI012 -21 | -22 | class NonEmptyChild2(Exception): - | - = help: Remove unnecessary `pass` - -ℹ Fix -17 17 | -18 18 | class NonEmptyChild(Exception): -19 19 | value: int -20 |- pass # PYI012 Class body must not contain `pass` -21 20 | -22 21 | class NonEmptyChild2(Exception): -23 22 | pass # PYI012 Class body must not contain `pass` - -PYI012.pyi:23:5: PYI012 [*] Class body must not contain `pass` - | -22 | class NonEmptyChild2(Exception): -23 | pass # PYI012 Class body must not contain `pass` - | ^^^^ PYI012 -24 | value: int - | - = help: Remove unnecessary `pass` - -ℹ Fix -20 20 | pass # PYI012 Class body must not contain `pass` -21 21 | -22 22 | class NonEmptyChild2(Exception): -23 |- pass # PYI012 Class body must not contain `pass` -24 23 | value: int -25 24 | -26 25 | class NonEmptyWithInit: - -PYI012.pyi:28:5: PYI012 [*] Class body must not contain `pass` - | -26 | class NonEmptyWithInit: -27 | value: int -28 | pass # PYI012 Class body must not contain `pass` - | ^^^^ PYI012 -29 | -30 | def __init__(): - | - = help: Remove unnecessary `pass` - -ℹ Fix -25 25 | -26 26 | class NonEmptyWithInit: -27 27 | value: int -28 |- pass # PYI012 Class body must not contain `pass` -29 28 | -30 29 | def __init__(): -31 30 | pass - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI013_PYI013.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI013_PYI013.py.snap deleted file mode 100644 index 7e0954fb1c..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI013_PYI013.py.snap +++ /dev/null @@ -1,149 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI013.py:3:5: PYI013 [*] Non-empty class body must not contain `...` - | -1 | class OneAttributeClass: -2 | value: int -3 | ... - | ^^^ PYI013 - | - = help: Remove unnecessary `...` - -ℹ Fix -1 1 | class OneAttributeClass: -2 2 | value: int -3 |- ... -4 3 | -5 4 | -6 5 | class OneAttributeClass2: - -PYI013.py:7:5: PYI013 [*] Non-empty class body must not contain `...` - | -6 | class OneAttributeClass2: -7 | ... - | ^^^ PYI013 -8 | value: int - | - = help: Remove unnecessary `...` - -ℹ Fix -4 4 | -5 5 | -6 6 | class OneAttributeClass2: -7 |- ... -8 7 | value: int -9 8 | -10 9 | - -PYI013.py:12:5: PYI013 [*] Non-empty class body must not contain `...` - | -11 | class TwoEllipsesClass: -12 | ... - | ^^^ PYI013 -13 | ... - | - = help: Remove unnecessary `...` - -ℹ Fix -10 10 | -11 11 | class TwoEllipsesClass: -12 12 | ... -13 |- ... -14 13 | -15 14 | -16 15 | class DocstringClass: - -PYI013.py:13:5: PYI013 [*] Non-empty class body must not contain `...` - | -11 | class TwoEllipsesClass: -12 | ... -13 | ... - | ^^^ PYI013 - | - = help: Remove unnecessary `...` - -ℹ Fix -10 10 | -11 11 | class TwoEllipsesClass: -12 12 | ... -13 |- ... -14 13 | -15 14 | -16 15 | class DocstringClass: - -PYI013.py:21:5: PYI013 [*] Non-empty class body must not contain `...` - | -19 | """ -20 | -21 | ... - | ^^^ PYI013 - | - = help: Remove unnecessary `...` - -ℹ Fix -18 18 | My body only contains an ellipsis. -19 19 | """ -20 20 | -21 |- ... -22 21 | -23 22 | -24 23 | class NonEmptyChild(Exception): - -PYI013.py:26:5: PYI013 [*] Non-empty class body must not contain `...` - | -24 | class NonEmptyChild(Exception): -25 | value: int -26 | ... - | ^^^ PYI013 - | - = help: Remove unnecessary `...` - -ℹ Fix -23 23 | -24 24 | class NonEmptyChild(Exception): -25 25 | value: int -26 |- ... -27 26 | -28 27 | -29 28 | class NonEmptyChild2(Exception): - -PYI013.py:30:5: PYI013 [*] Non-empty class body must not contain `...` - | -29 | class NonEmptyChild2(Exception): -30 | ... - | ^^^ PYI013 -31 | value: int - | - = help: Remove unnecessary `...` - -ℹ Fix -27 27 | -28 28 | -29 29 | class NonEmptyChild2(Exception): -30 |- ... -31 30 | value: int -32 31 | -33 32 | - -PYI013.py:36:5: PYI013 [*] Non-empty class body must not contain `...` - | -34 | class NonEmptyWithInit: -35 | value: int -36 | ... - | ^^^ PYI013 -37 | -38 | def __init__(): - | - = help: Remove unnecessary `...` - -ℹ Fix -33 33 | -34 34 | class NonEmptyWithInit: -35 35 | value: int -36 |- ... -37 36 | -38 37 | def __init__(): -39 38 | pass - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI013_PYI013.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI013_PYI013.pyi.snap deleted file mode 100644 index bfdeaf25a4..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI013_PYI013.pyi.snap +++ /dev/null @@ -1,176 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI013.pyi:5:5: PYI013 [*] Non-empty class body must not contain `...` - | -3 | class OneAttributeClass: -4 | value: int -5 | ... # Error - | ^^^ PYI013 -6 | -7 | class OneAttributeClass2: - | - = help: Remove unnecessary `...` - -ℹ Fix -2 2 | -3 3 | class OneAttributeClass: -4 4 | value: int -5 |- ... # Error -6 5 | -7 6 | class OneAttributeClass2: -8 7 | ... # Error - -PYI013.pyi:8:5: PYI013 [*] Non-empty class body must not contain `...` - | -7 | class OneAttributeClass2: -8 | ... # Error - | ^^^ PYI013 -9 | value: int - | - = help: Remove unnecessary `...` - -ℹ Fix -5 5 | ... # Error -6 6 | -7 7 | class OneAttributeClass2: -8 |- ... # Error -9 8 | value: int -10 9 | -11 10 | class MyClass: - -PYI013.pyi:12:5: PYI013 [*] Non-empty class body must not contain `...` - | -11 | class MyClass: -12 | ... - | ^^^ PYI013 -13 | value: int - | - = help: Remove unnecessary `...` - -ℹ Fix -9 9 | value: int -10 10 | -11 11 | class MyClass: -12 |- ... -13 12 | value: int -14 13 | -15 14 | class TwoEllipsesClass: - -PYI013.pyi:16:5: PYI013 [*] Non-empty class body must not contain `...` - | -15 | class TwoEllipsesClass: -16 | ... - | ^^^ PYI013 -17 | ... # Error - | - = help: Remove unnecessary `...` - -ℹ Fix -13 13 | value: int -14 14 | -15 15 | class TwoEllipsesClass: -16 |- ... -17 16 | ... # Error -18 17 | -19 18 | class DocstringClass: - -PYI013.pyi:17:5: PYI013 [*] Non-empty class body must not contain `...` - | -15 | class TwoEllipsesClass: -16 | ... -17 | ... # Error - | ^^^ PYI013 -18 | -19 | class DocstringClass: - | - = help: Remove unnecessary `...` - -ℹ Fix -14 14 | -15 15 | class TwoEllipsesClass: -16 16 | ... -17 |- ... # Error -18 17 | -19 18 | class DocstringClass: -20 19 | """ - -PYI013.pyi:24:5: PYI013 [*] Non-empty class body must not contain `...` - | -22 | """ -23 | -24 | ... # Error - | ^^^ PYI013 -25 | -26 | class NonEmptyChild(Exception): - | - = help: Remove unnecessary `...` - -ℹ Fix -21 21 | My body only contains an ellipsis. -22 22 | """ -23 23 | -24 |- ... # Error -25 24 | -26 25 | class NonEmptyChild(Exception): -27 26 | value: int - -PYI013.pyi:28:5: PYI013 [*] Non-empty class body must not contain `...` - | -26 | class NonEmptyChild(Exception): -27 | value: int -28 | ... # Error - | ^^^ PYI013 -29 | -30 | class NonEmptyChild2(Exception): - | - = help: Remove unnecessary `...` - -ℹ Fix -25 25 | -26 26 | class NonEmptyChild(Exception): -27 27 | value: int -28 |- ... # Error -29 28 | -30 29 | class NonEmptyChild2(Exception): -31 30 | ... # Error - -PYI013.pyi:31:5: PYI013 [*] Non-empty class body must not contain `...` - | -30 | class NonEmptyChild2(Exception): -31 | ... # Error - | ^^^ PYI013 -32 | value: int - | - = help: Remove unnecessary `...` - -ℹ Fix -28 28 | ... # Error -29 29 | -30 30 | class NonEmptyChild2(Exception): -31 |- ... # Error -32 31 | value: int -33 32 | -34 33 | class NonEmptyWithInit: - -PYI013.pyi:36:5: PYI013 [*] Non-empty class body must not contain `...` - | -34 | class NonEmptyWithInit: -35 | value: int -36 | ... # Error - | ^^^ PYI013 -37 | -38 | def __init__(): - | - = help: Remove unnecessary `...` - -ℹ Fix -33 33 | -34 34 | class NonEmptyWithInit: -35 35 | value: int -36 |- ... # Error -37 36 | -38 37 | def __init__(): -39 38 | pass - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI014_PYI014.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI014_PYI014.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI014_PYI014.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI014_PYI014.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI014_PYI014.pyi.snap deleted file mode 100644 index 28247f283b..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI014_PYI014.pyi.snap +++ /dev/null @@ -1,315 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI014.pyi:3:7: PYI014 [*] Only simple default values allowed for arguments - | -1 | def f12( -2 | x, -3 | y=os.pathsep, # Error PYI014 - | ^^^^^^^^^^ PYI014 -4 | ) -> None: ... -5 | def f11(*, x="x") -> None: ... # OK - | - = help: Replace default value with `...` - -ℹ Suggested fix -1 1 | def f12( -2 2 | x, -3 |- y=os.pathsep, # Error PYI014 - 3 |+ y=..., # Error PYI014 -4 4 | ) -> None: ... -5 5 | def f11(*, x="x") -> None: ... # OK -6 6 | def f13( - -PYI014.pyi:29:7: PYI014 [*] Only simple default values allowed for arguments - | -27 | def f151(x={1: 2}) -> None: ... -28 | def f152( -29 | x={ # Error PYI014 - | _______^ -30 | | 1: 2, -31 | | **{3: 4}, -32 | | } - | |_____^ PYI014 -33 | ) -> None: ... -34 | def f153( - | - = help: Replace default value with `...` - -ℹ Suggested fix -26 26 | ) -> None: ... -27 27 | def f151(x={1: 2}) -> None: ... -28 28 | def f152( -29 |- x={ # Error PYI014 -30 |- 1: 2, -31 |- **{3: 4}, -32 |- } - 29 |+ x=... -33 30 | ) -> None: ... -34 31 | def f153( -35 32 | x=[ # Error PYI014 - -PYI014.pyi:35:7: PYI014 [*] Only simple default values allowed for arguments - | -33 | ) -> None: ... -34 | def f153( -35 | x=[ # Error PYI014 - | _______^ -36 | | 1, -37 | | 2, -38 | | 3, -39 | | 4, -40 | | 5, -41 | | 6, -42 | | 7, -43 | | 8, -44 | | 9, -45 | | 10, -46 | | 11, -47 | | ] - | |_____^ PYI014 -48 | ) -> None: ... -49 | def f154( - | - = help: Replace default value with `...` - -ℹ Suggested fix -32 32 | } -33 33 | ) -> None: ... -34 34 | def f153( -35 |- x=[ # Error PYI014 -36 |- 1, -37 |- 2, -38 |- 3, -39 |- 4, -40 |- 5, -41 |- 6, -42 |- 7, -43 |- 8, -44 |- 9, -45 |- 10, -46 |- 11, -47 |- ] - 35 |+ x=... -48 36 | ) -> None: ... -49 37 | def f154( -50 38 | x=( # Error PYI014 - -PYI014.pyi:50:7: PYI014 [*] Only simple default values allowed for arguments - | -48 | ) -> None: ... -49 | def f154( -50 | x=( # Error PYI014 - | _______^ -51 | | "foo", -52 | | ("bar", "baz"), -53 | | ) - | |_____^ PYI014 -54 | ) -> None: ... -55 | def f141( - | - = help: Replace default value with `...` - -ℹ Suggested fix -47 47 | ] -48 48 | ) -> None: ... -49 49 | def f154( -50 |- x=( # Error PYI014 -51 |- "foo", -52 |- ("bar", "baz"), -53 |- ) - 50 |+ x=... -54 51 | ) -> None: ... -55 52 | def f141( -56 53 | x=[*range(10)], # Error PYI014 - -PYI014.pyi:56:7: PYI014 [*] Only simple default values allowed for arguments - | -54 | ) -> None: ... -55 | def f141( -56 | x=[*range(10)], # Error PYI014 - | ^^^^^^^^^^^^ PYI014 -57 | ) -> None: ... -58 | def f142( - | - = help: Replace default value with `...` - -ℹ Suggested fix -53 53 | ) -54 54 | ) -> None: ... -55 55 | def f141( -56 |- x=[*range(10)], # Error PYI014 - 56 |+ x=..., # Error PYI014 -57 57 | ) -> None: ... -58 58 | def f142( -59 59 | x=list(range(10)), # Error PYI014 - -PYI014.pyi:59:7: PYI014 [*] Only simple default values allowed for arguments - | -57 | ) -> None: ... -58 | def f142( -59 | x=list(range(10)), # Error PYI014 - | ^^^^^^^^^^^^^^^ PYI014 -60 | ) -> None: ... -61 | def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: ... # Error PYI014 - | - = help: Replace default value with `...` - -ℹ Suggested fix -56 56 | x=[*range(10)], # Error PYI014 -57 57 | ) -> None: ... -58 58 | def f142( -59 |- x=list(range(10)), # Error PYI014 - 59 |+ x=..., # Error PYI014 -60 60 | ) -> None: ... -61 61 | def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: ... # Error PYI014 -62 62 | def f17( - -PYI014.pyi:61:11: PYI014 [*] Only simple default values allowed for arguments - | -59 | x=list(range(10)), # Error PYI014 -60 | ) -> None: ... -61 | def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: ... # Error PYI014 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI014 -62 | def f17( -63 | x="foo" + "bar", # Error PYI014 - | - = help: Replace default value with `...` - -ℹ Suggested fix -58 58 | def f142( -59 59 | x=list(range(10)), # Error PYI014 -60 60 | ) -> None: ... -61 |-def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: ... # Error PYI014 - 61 |+def f16(x=...) -> None: ... # Error PYI014 -62 62 | def f17( -63 63 | x="foo" + "bar", # Error PYI014 -64 64 | ) -> None: ... - -PYI014.pyi:63:7: PYI014 [*] Only simple default values allowed for arguments - | -61 | def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: ... # Error PYI014 -62 | def f17( -63 | x="foo" + "bar", # Error PYI014 - | ^^^^^^^^^^^^^ PYI014 -64 | ) -> None: ... -65 | def f18( - | - = help: Replace default value with `...` - -ℹ Suggested fix -60 60 | ) -> None: ... -61 61 | def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: ... # Error PYI014 -62 62 | def f17( -63 |- x="foo" + "bar", # Error PYI014 - 63 |+ x=..., # Error PYI014 -64 64 | ) -> None: ... -65 65 | def f18( -66 66 | x=b"foo" + b"bar", # Error PYI014 - -PYI014.pyi:66:7: PYI014 [*] Only simple default values allowed for arguments - | -64 | ) -> None: ... -65 | def f18( -66 | x=b"foo" + b"bar", # Error PYI014 - | ^^^^^^^^^^^^^^^ PYI014 -67 | ) -> None: ... -68 | def f19( - | - = help: Replace default value with `...` - -ℹ Suggested fix -63 63 | x="foo" + "bar", # Error PYI014 -64 64 | ) -> None: ... -65 65 | def f18( -66 |- x=b"foo" + b"bar", # Error PYI014 - 66 |+ x=..., # Error PYI014 -67 67 | ) -> None: ... -68 68 | def f19( -69 69 | x="foo" + 4, # Error PYI014 - -PYI014.pyi:69:7: PYI014 [*] Only simple default values allowed for arguments - | -67 | ) -> None: ... -68 | def f19( -69 | x="foo" + 4, # Error PYI014 - | ^^^^^^^^^ PYI014 -70 | ) -> None: ... -71 | def f20( - | - = help: Replace default value with `...` - -ℹ Suggested fix -66 66 | x=b"foo" + b"bar", # Error PYI014 -67 67 | ) -> None: ... -68 68 | def f19( -69 |- x="foo" + 4, # Error PYI014 - 69 |+ x=..., # Error PYI014 -70 70 | ) -> None: ... -71 71 | def f20( -72 72 | x=5 + 5, # Error PYI014 - -PYI014.pyi:72:7: PYI014 [*] Only simple default values allowed for arguments - | -70 | ) -> None: ... -71 | def f20( -72 | x=5 + 5, # Error PYI014 - | ^^^^^ PYI014 -73 | ) -> None: ... -74 | def f21( - | - = help: Replace default value with `...` - -ℹ Suggested fix -69 69 | x="foo" + 4, # Error PYI014 -70 70 | ) -> None: ... -71 71 | def f20( -72 |- x=5 + 5, # Error PYI014 - 72 |+ x=..., # Error PYI014 -73 73 | ) -> None: ... -74 74 | def f21( -75 75 | x=3j - 3j, # Error PYI014 - -PYI014.pyi:75:7: PYI014 [*] Only simple default values allowed for arguments - | -73 | ) -> None: ... -74 | def f21( -75 | x=3j - 3j, # Error PYI014 - | ^^^^^^^ PYI014 -76 | ) -> None: ... -77 | def f22( - | - = help: Replace default value with `...` - -ℹ Suggested fix -72 72 | x=5 + 5, # Error PYI014 -73 73 | ) -> None: ... -74 74 | def f21( -75 |- x=3j - 3j, # Error PYI014 - 75 |+ x=..., # Error PYI014 -76 76 | ) -> None: ... -77 77 | def f22( -78 78 | x=-42.5j + 4.3j, # Error PYI014 - -PYI014.pyi:78:7: PYI014 [*] Only simple default values allowed for arguments - | -76 | ) -> None: ... -77 | def f22( -78 | x=-42.5j + 4.3j, # Error PYI014 - | ^^^^^^^^^^^^^ PYI014 -79 | ) -> None: ... -80 | def f23( - | - = help: Replace default value with `...` - -ℹ Suggested fix -75 75 | x=3j - 3j, # Error PYI014 -76 76 | ) -> None: ... -77 77 | def f22( -78 |- x=-42.5j + 4.3j, # Error PYI014 - 78 |+ x=..., # Error PYI014 -79 79 | ) -> None: ... -80 80 | def f23( -81 81 | x=True, # OK - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI015_PYI015.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI015_PYI015.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI015_PYI015.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI015_PYI015.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI015_PYI015.pyi.snap deleted file mode 100644 index 021742b3b2..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI015_PYI015.pyi.snap +++ /dev/null @@ -1,233 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI015.pyi:44:23: PYI015 [*] Only simple default values allowed for assignments - | -43 | # We *should* emit Y015 for more complex default values -44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI015 -45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments -46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments - | - = help: Replace default value with `...` - -ℹ Suggested fix -41 41 | field22: Final = {"foo": 5} -42 42 | -43 43 | # We *should* emit Y015 for more complex default values -44 |-field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments - 44 |+field221: list[int] = ... # Y015 Only simple default values are allowed for assignments -45 45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments -46 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments -47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments - -PYI015.pyi:45:23: PYI015 [*] Only simple default values allowed for assignments - | -43 | # We *should* emit Y015 for more complex default values -44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments -45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^^^ PYI015 -46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments -47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments - | - = help: Replace default value with `...` - -ℹ Suggested fix -42 42 | -43 43 | # We *should* emit Y015 for more complex default values -44 44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments -45 |-field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments - 45 |+field223: list[int] = ... # Y015 Only simple default values are allowed for assignments -46 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments -47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments -48 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments - -PYI015.pyi:46:23: PYI015 [*] Only simple default values allowed for assignments - | -44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments -45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments -46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^^^^^^ PYI015 -47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments -48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments - | - = help: Replace default value with `...` - -ℹ Suggested fix -43 43 | # We *should* emit Y015 for more complex default values -44 44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments -45 45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments -46 |-field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments - 46 |+field224: list[int] = ... # Y015 Only simple default values are allowed for assignments -47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments -48 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments -49 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments - -PYI015.pyi:47:26: PYI015 [*] Only simple default values allowed for assignments - | -45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments -46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments -47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^ PYI015 -48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments -49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments - | - = help: Replace default value with `...` - -ℹ Suggested fix -44 44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments -45 45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments -46 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments -47 |-field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments - 47 |+field225: list[object] = ... # Y015 Only simple default values are allowed for assignments -48 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments -49 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments -50 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments - -PYI015.pyi:48:47: PYI015 [*] Only simple default values allowed for assignments - | -46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments -47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments -48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI015 -49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments -50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments - | - = help: Replace default value with `...` - -ℹ Suggested fix -45 45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments -46 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments -47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments -48 |-field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments - 48 |+field226: tuple[str | tuple[str, ...], ...] = ... # Y015 Only simple default values are allowed for assignments -49 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments -50 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments -51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node - -PYI015.pyi:49:31: PYI015 [*] Only simple default values allowed for assignments - | -47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments -48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments -49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI015 -50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments -51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node - | - = help: Replace default value with `...` - -ℹ Suggested fix -46 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments -47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments -48 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments -49 |-field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments - 49 |+field227: dict[str, object] = ... # Y015 Only simple default values are allowed for assignments -50 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments -51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node -52 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments - -PYI015.pyi:50:37: PYI015 [*] Only simple default values allowed for assignments - | -48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments -49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments -50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^^ PYI015 -51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node -52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments - | - = help: Replace default value with `...` - -ℹ Suggested fix -47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments -48 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments -49 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments -50 |-field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments - 50 |+field228: dict[str, list[object]] = ... # Y015 Only simple default values are allowed for assignments -51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node -52 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments -53 53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments - -PYI015.pyi:52:28: PYI015 [*] Only simple default values allowed for assignments - | -50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments -51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node -52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^^^^^^^ PYI015 -53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments -54 | field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments - | - = help: Replace default value with `...` - -ℹ Suggested fix -49 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments -50 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments -51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node -52 |-field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments - 52 |+field229: dict[int, int] = ... # Y015 Only simple default values are allowed for assignments -53 53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments -54 54 | field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments -55 55 | field25 = 5 * 5 # Y015 Only simple default values are allowed for assignments - -PYI015.pyi:53:11: PYI015 [*] Only simple default values allowed for assignments - | -51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node -52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments -53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^^^^ PYI015 -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 - | - = help: Replace default value with `...` - -ℹ Suggested fix -50 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments -51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node -52 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments -53 |-field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments - 53 |+field23 = ... # Y015 Only simple default values are allowed for assignments -54 54 | field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments -55 55 | field25 = 5 * 5 # Y015 Only simple default values are allowed for assignments -56 56 | - -PYI015.pyi:54:11: PYI015 [*] Only simple default values allowed for assignments - | -52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments -53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments -54 | field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments - | ^^^^^^^^^^^^^^^ PYI015 -55 | field25 = 5 * 5 # Y015 Only simple default values are allowed for assignments - | - = help: Replace default value with `...` - -ℹ Suggested fix -51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node -52 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments -53 53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments -54 |-field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments - 54 |+field24 = ... # Y015 Only simple default values are allowed for assignments -55 55 | field25 = 5 * 5 # Y015 Only simple default values are allowed for assignments -56 56 | -57 57 | # We shouldn't emit Y015 within functions - -PYI015.pyi:55:11: PYI015 [*] Only simple default values allowed for assignments - | -53 | field23 = "foo" + "bar" # Y015 Only simple default values are 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 | -57 | # We shouldn't emit Y015 within functions - | - = help: Replace default value with `...` - -ℹ Suggested fix -52 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments -53 53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments -54 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 - 55 |+field25 = ... # Y015 Only simple default values are allowed for assignments -56 56 | -57 57 | # We shouldn't emit Y015 within functions -58 58 | def f(): - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI016_PYI016.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI016_PYI016.py.snap deleted file mode 100644 index abc1d3226a..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI016_PYI016.py.snap +++ /dev/null @@ -1,543 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -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 | -9 | # Should emit for union types in arguments. - | - = help: Remove duplicate union member `str` - -ℹ Fix -4 4 | field1: str -5 5 | -6 6 | # Should emit for duplicate field types. -7 |-field2: str | str # PYI016: Duplicate union member `str` - 7 |+field2: str # PYI016: Duplicate union member `str` -8 8 | -9 9 | # Should emit for union types in arguments. -10 10 | def func1(arg1: int | int): # PYI016: Duplicate union member `int` - -PYI016.py:10:23: PYI016 [*] Duplicate union member `int` - | - 9 | # Should emit for union types in arguments. -10 | def func1(arg1: int | int): # PYI016: Duplicate union member `int` - | ^^^ PYI016 -11 | print(arg1) - | - = help: Remove duplicate union member `int` - -ℹ Fix -7 7 | field2: str | str # PYI016: Duplicate union member `str` -8 8 | -9 9 | # Should emit for union types in arguments. -10 |-def func1(arg1: int | int): # PYI016: Duplicate union member `int` - 10 |+def func1(arg1: int): # PYI016: Duplicate union member `int` -11 11 | print(arg1) -12 12 | -13 13 | # Should emit for unions in return types. - -PYI016.py:14:22: PYI016 [*] Duplicate union member `str` - | -13 | # Should emit for unions in return types. -14 | def func2() -> str | str: # PYI016: Duplicate union member `str` - | ^^^ PYI016 -15 | return "my string" - | - = help: Remove duplicate union member `str` - -ℹ Fix -11 11 | print(arg1) -12 12 | -13 13 | # Should emit for unions in return types. -14 |-def func2() -> str | str: # PYI016: Duplicate union member `str` - 14 |+def func2() -> str: # PYI016: Duplicate union member `str` -15 15 | return "my string" -16 16 | -17 17 | # Should emit in longer unions, even if not directly adjacent. - -PYI016.py:18:15: PYI016 [*] Duplicate union member `str` - | -17 | # Should emit in longer unions, even if not directly adjacent. -18 | field3: str | str | int # PYI016: Duplicate union member `str` - | ^^^ PYI016 -19 | field4: int | int | str # PYI016: Duplicate union member `int` -20 | field5: str | int | str # PYI016: Duplicate union member `str` - | - = help: Remove duplicate union member `str` - -ℹ Fix -15 15 | return "my string" -16 16 | -17 17 | # Should emit in longer unions, even if not directly adjacent. -18 |-field3: str | str | int # PYI016: Duplicate union member `str` - 18 |+field3: str | int # PYI016: Duplicate union member `str` -19 19 | field4: int | int | str # PYI016: Duplicate union member `int` -20 20 | field5: str | int | str # PYI016: Duplicate union member `str` -21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` - -PYI016.py:19:15: PYI016 [*] Duplicate union member `int` - | -17 | # Should emit in longer unions, even if not directly adjacent. -18 | field3: str | str | int # PYI016: Duplicate union member `str` -19 | field4: int | int | str # PYI016: Duplicate union member `int` - | ^^^ PYI016 -20 | field5: str | int | str # PYI016: Duplicate union member `str` -21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` - | - = help: Remove duplicate union member `int` - -ℹ Fix -16 16 | -17 17 | # Should emit in longer unions, even if not directly adjacent. -18 18 | field3: str | str | int # PYI016: Duplicate union member `str` -19 |-field4: int | int | str # PYI016: Duplicate union member `int` - 19 |+field4: int | str # PYI016: Duplicate union member `int` -20 20 | field5: str | int | str # PYI016: Duplicate union member `str` -21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` -22 22 | - -PYI016.py:20:21: PYI016 [*] Duplicate union member `str` - | -18 | field3: str | str | int # PYI016: Duplicate union member `str` -19 | field4: int | int | str # PYI016: Duplicate union member `int` -20 | field5: str | int | str # PYI016: Duplicate union member `str` - | ^^^ PYI016 -21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` - | - = help: Remove duplicate union member `str` - -ℹ Fix -17 17 | # Should emit in longer unions, even if not directly adjacent. -18 18 | field3: str | str | int # PYI016: Duplicate union member `str` -19 19 | field4: int | int | str # PYI016: Duplicate union member `int` -20 |-field5: str | int | str # PYI016: Duplicate union member `str` - 20 |+field5: str | int # PYI016: Duplicate union member `str` -21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` -22 22 | -23 23 | # Shouldn't emit for non-type unions. - -PYI016.py:21:28: PYI016 [*] Duplicate union member `int` - | -19 | field4: int | int | str # 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 | -23 | # Shouldn't emit for non-type unions. - | - = help: Remove duplicate union member `int` - -ℹ Fix -18 18 | field3: str | str | int # PYI016: Duplicate union member `str` -19 19 | field4: int | int | str # PYI016: Duplicate union member `int` -20 20 | field5: str | int | str # PYI016: Duplicate union member `str` -21 |-field6: int | bool | str | int # PYI016: Duplicate union member `int` - 21 |+field6: int | bool | str # PYI016: Duplicate union member `int` -22 22 | -23 23 | # Shouldn't emit for non-type unions. -24 24 | field7 = str | str - -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 | -29 | # Should handle user brackets when fixing. - | - = help: Remove duplicate union member `int` - -ℹ Fix -24 24 | field7 = str | str -25 25 | -26 26 | # Should emit for strangely-bracketed unions. -27 |-field8: int | (str | int) # PYI016: Duplicate union member `int` - 27 |+field8: int | (str) # PYI016: Duplicate union member `int` -28 28 | -29 29 | # Should handle user brackets when fixing. -30 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` - -PYI016.py:30:16: PYI016 [*] Duplicate union member `int` - | -29 | # Should handle user brackets when fixing. -30 | field9: int | (int | str) # PYI016: Duplicate union member `int` - | ^^^ PYI016 -31 | field10: (str | int) | str # PYI016: Duplicate union member `str` - | - = help: Remove duplicate union member `int` - -ℹ Fix -27 27 | field8: int | (str | int) # PYI016: Duplicate union member `int` -28 28 | -29 29 | # Should handle user brackets when fixing. -30 |-field9: int | (int | str) # PYI016: Duplicate union member `int` - 30 |+field9: int | (str) # PYI016: Duplicate union member `int` -31 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` -32 32 | -33 33 | # Should emit for nested unions. - -PYI016.py:31:24: PYI016 [*] Duplicate union member `str` - | -29 | # Should handle user brackets when fixing. -30 | field9: int | (int | str) # PYI016: Duplicate union member `int` -31 | field10: (str | int) | str # PYI016: Duplicate union member `str` - | ^^^ PYI016 -32 | -33 | # Should emit for nested unions. - | - = help: Remove duplicate union member `str` - -ℹ Fix -28 28 | -29 29 | # Should handle user brackets when fixing. -30 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` -31 |-field10: (str | int) | str # PYI016: Duplicate union member `str` - 31 |+field10: str | int # PYI016: Duplicate union member `str` -32 32 | -33 33 | # Should emit for nested unions. -34 34 | field11: dict[int | int, str] - -PYI016.py:34:21: PYI016 [*] Duplicate union member `int` - | -33 | # Should emit for nested unions. -34 | field11: dict[int | int, str] - | ^^^ PYI016 -35 | -36 | # Should emit for unions with more than two cases - | - = help: Remove duplicate union member `int` - -ℹ Fix -31 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` -32 32 | -33 33 | # Should emit for nested unions. -34 |-field11: dict[int | int, str] - 34 |+field11: dict[int, str] -35 35 | -36 36 | # Should emit for unions with more than two cases -37 37 | field12: int | int | int # Error - -PYI016.py:37:16: PYI016 [*] Duplicate union member `int` - | -36 | # Should emit for unions with more than two cases -37 | field12: int | int | int # Error - | ^^^ PYI016 -38 | field13: int | int | int | int # Error - | - = help: Remove duplicate union member `int` - -ℹ Fix -34 34 | field11: dict[int | int, str] -35 35 | -36 36 | # Should emit for unions with more than two cases -37 |-field12: int | int | int # Error - 37 |+field12: int | int # Error -38 38 | field13: int | int | int | int # Error -39 39 | -40 40 | # Should emit for unions with more than two cases, even if not directly adjacent - -PYI016.py:37:22: PYI016 [*] Duplicate union member `int` - | -36 | # Should emit for unions with more than two cases -37 | field12: int | int | int # Error - | ^^^ PYI016 -38 | field13: int | int | int | int # Error - | - = help: Remove duplicate union member `int` - -ℹ Fix -34 34 | field11: dict[int | int, str] -35 35 | -36 36 | # Should emit for unions with more than two cases -37 |-field12: int | int | int # Error - 37 |+field12: int | int # Error -38 38 | field13: int | int | int | int # Error -39 39 | -40 40 | # Should emit for unions with more than two cases, even if not directly adjacent - -PYI016.py:38:16: PYI016 [*] Duplicate union member `int` - | -36 | # Should emit for unions with more than two cases -37 | field12: int | int | int # Error -38 | field13: int | int | int | int # Error - | ^^^ PYI016 -39 | -40 | # Should emit for unions with more than two cases, even if not directly adjacent - | - = help: Remove duplicate union member `int` - -ℹ Fix -35 35 | -36 36 | # Should emit for unions with more than two cases -37 37 | field12: int | int | int # Error -38 |-field13: int | int | int | int # Error - 38 |+field13: int | int | int # Error -39 39 | -40 40 | # Should emit for unions with more than two cases, even if not directly adjacent -41 41 | field14: int | int | str | int # Error - -PYI016.py:38:22: PYI016 [*] Duplicate union member `int` - | -36 | # Should emit for unions with more than two cases -37 | field12: int | int | int # Error -38 | field13: int | int | int | int # Error - | ^^^ PYI016 -39 | -40 | # Should emit for unions with more than two cases, even if not directly adjacent - | - = help: Remove duplicate union member `int` - -ℹ Fix -35 35 | -36 36 | # Should emit for unions with more than two cases -37 37 | field12: int | int | int # Error -38 |-field13: int | int | int | int # Error - 38 |+field13: int | int | int # Error -39 39 | -40 40 | # Should emit for unions with more than two cases, even if not directly adjacent -41 41 | field14: int | int | str | int # Error - -PYI016.py:38:28: PYI016 [*] Duplicate union member `int` - | -36 | # Should emit for unions with more than two cases -37 | field12: int | int | int # Error -38 | field13: int | int | int | int # Error - | ^^^ PYI016 -39 | -40 | # Should emit for unions with more than two cases, even if not directly adjacent - | - = help: Remove duplicate union member `int` - -ℹ Fix -35 35 | -36 36 | # Should emit for unions with more than two cases -37 37 | field12: int | int | int # Error -38 |-field13: int | int | int | int # Error - 38 |+field13: int | int | int # Error -39 39 | -40 40 | # Should emit for unions with more than two cases, even if not directly adjacent -41 41 | field14: int | int | str | int # Error - -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 | -43 | # Should emit for duplicate literal types; also covered by PYI030 - | - = help: Remove duplicate union member `int` - -ℹ Fix -38 38 | field13: int | int | int | int # Error -39 39 | -40 40 | # Should emit for unions with more than two cases, even if not directly adjacent -41 |-field14: int | int | str | int # Error - 41 |+field14: int | str | int # Error -42 42 | -43 43 | # Should emit for duplicate literal types; also covered by PYI030 -44 44 | field15: typing.Literal[1] | typing.Literal[1] # Error - -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 | -43 | # Should emit for duplicate literal types; also covered by PYI030 - | - = help: Remove duplicate union member `int` - -ℹ Fix -38 38 | field13: int | int | int | int # Error -39 39 | -40 40 | # Should emit for unions with more than two cases, even if not directly adjacent -41 |-field14: int | int | str | int # Error - 41 |+field14: int | int | str # Error -42 42 | -43 43 | # Should emit for duplicate literal types; also covered by PYI030 -44 44 | field15: typing.Literal[1] | typing.Literal[1] # Error - -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 | -46 | # Shouldn't emit if in new parent type - | - = help: Remove duplicate union member `typing.Literal[1]` - -ℹ Fix -41 41 | field14: int | int | str | int # Error -42 42 | -43 43 | # Should emit for duplicate literal types; also covered by PYI030 -44 |-field15: typing.Literal[1] | typing.Literal[1] # Error - 44 |+field15: typing.Literal[1] # Error -45 45 | -46 46 | # Shouldn't emit if in new parent type -47 47 | field16: int | dict[int, str] # OK - -PYI016.py:57:5: PYI016 Duplicate union member `set[int]` - | -55 | int # foo -56 | ], -57 | set[ - | _____^ -58 | | int # bar -59 | | ], - | |_____^ PYI016 -60 | ] # Error, newline and comment will not be emitted in message - | - = help: Remove duplicate union member `set[int]` - -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 | -65 | # Should emit in cases with nested `typing.Union` - | - = help: Remove duplicate union member `int` - -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 | -68 | # Should emit in cases with mixed `typing.Union` and `|` - | - = help: Remove duplicate union member `int` - -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 | -71 | # Should emit only once in cases with multiple nested `typing.Union` - | - = help: Remove duplicate union member `int` - -ℹ Fix -66 66 | field20: typing.Union[int, typing.Union[int, str]] # Error -67 67 | -68 68 | # Should emit in cases with mixed `typing.Union` and `|` -69 |-field21: typing.Union[int, int | str] # Error - 69 |+field21: typing.Union[int, str] # Error -70 70 | -71 71 | # Should emit only once in cases with multiple nested `typing.Union` -72 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - -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 | -74 | # Should emit in cases with newlines - | - = help: Remove duplicate union member `int` - -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 | -74 | # Should emit in cases with newlines - | - = help: Remove duplicate union member `int` - -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 | -74 | # Should emit in cases with newlines - | - = help: Remove duplicate union member `int` - -PYI016.py:76:12: PYI016 [*] Duplicate union member `set[int]` - | -74 | # Should emit in cases with newlines -75 | field23: set[ # foo -76 | int] | set[int] - | ^^^^^^^^ PYI016 -77 | -78 | # Should emit twice (once for each `int` in the nested union, both of which are - | - = help: Remove duplicate union member `set[int]` - -ℹ Fix -73 73 | -74 74 | # Should emit in cases with newlines -75 75 | field23: set[ # foo -76 |- int] | set[int] - 76 |+ int] -77 77 | -78 78 | # Should emit twice (once for each `int` in the nested union, both of which are -79 79 | # duplicates of the outer `int`), but not three times (which would indicate that - -PYI016.py:81:41: PYI016 Duplicate union member `int` - | -79 | # duplicates of the outer `int`), but not three times (which would indicate that -80 | # we incorrectly re-checked the nested union). -81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 -82 | -83 | # Should emit twice (once for each `int` in the nested union, both of which are - | - = help: Remove duplicate union member `int` - -PYI016.py:81:46: PYI016 Duplicate union member `int` - | -79 | # duplicates of the outer `int`), but not three times (which would indicate that -80 | # we incorrectly re-checked the nested union). -81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 -82 | -83 | # Should emit twice (once for each `int` in the nested union, both of which are - | - = help: Remove duplicate union member `int` - -PYI016.py:86:28: PYI016 [*] Duplicate union member `int` - | -84 | # duplicates of the outer `int`), but not three times (which would indicate that -85 | # we incorrectly re-checked the nested union). -86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` - | ^^^ PYI016 - | - = help: Remove duplicate union member `int` - -ℹ Fix -83 83 | # Should emit twice (once for each `int` in the nested union, both of which are -84 84 | # duplicates of the outer `int`), but not three times (which would indicate that -85 85 | # we incorrectly re-checked the nested union). -86 |-field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` - 86 |+field25: typing.Union[int, int] # PYI016: Duplicate union member `int` - -PYI016.py:86:34: PYI016 [*] Duplicate union member `int` - | -84 | # duplicates of the outer `int`), but not three times (which would indicate that -85 | # we incorrectly re-checked the nested union). -86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` - | ^^^ PYI016 - | - = help: Remove duplicate union member `int` - -ℹ Fix -83 83 | # Should emit twice (once for each `int` in the nested union, both of which are -84 84 | # duplicates of the outer `int`), but not three times (which would indicate that -85 85 | # we incorrectly re-checked the nested union). -86 |-field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` - 86 |+field25: typing.Union[int, int] # PYI016: Duplicate union member `int` - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap deleted file mode 100644 index d29fea9901..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap +++ /dev/null @@ -1,543 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -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 | -9 | # Should emit for union types in arguments. - | - = help: Remove duplicate union member `str` - -ℹ Fix -4 4 | field1: str -5 5 | -6 6 | # Should emit for duplicate field types. -7 |-field2: str | str # PYI016: Duplicate union member `str` - 7 |+field2: str # PYI016: Duplicate union member `str` -8 8 | -9 9 | # Should emit for union types in arguments. -10 10 | def func1(arg1: int | int): # PYI016: Duplicate union member `int` - -PYI016.pyi:10:23: PYI016 [*] Duplicate union member `int` - | - 9 | # Should emit for union types in arguments. -10 | def func1(arg1: int | int): # PYI016: Duplicate union member `int` - | ^^^ PYI016 -11 | print(arg1) - | - = help: Remove duplicate union member `int` - -ℹ Fix -7 7 | field2: str | str # PYI016: Duplicate union member `str` -8 8 | -9 9 | # Should emit for union types in arguments. -10 |-def func1(arg1: int | int): # PYI016: Duplicate union member `int` - 10 |+def func1(arg1: int): # PYI016: Duplicate union member `int` -11 11 | print(arg1) -12 12 | -13 13 | # Should emit for unions in return types. - -PYI016.pyi:14:22: PYI016 [*] Duplicate union member `str` - | -13 | # Should emit for unions in return types. -14 | def func2() -> str | str: # PYI016: Duplicate union member `str` - | ^^^ PYI016 -15 | return "my string" - | - = help: Remove duplicate union member `str` - -ℹ Fix -11 11 | print(arg1) -12 12 | -13 13 | # Should emit for unions in return types. -14 |-def func2() -> str | str: # PYI016: Duplicate union member `str` - 14 |+def func2() -> str: # PYI016: Duplicate union member `str` -15 15 | return "my string" -16 16 | -17 17 | # Should emit in longer unions, even if not directly adjacent. - -PYI016.pyi:18:15: PYI016 [*] Duplicate union member `str` - | -17 | # Should emit in longer unions, even if not directly adjacent. -18 | field3: str | str | int # PYI016: Duplicate union member `str` - | ^^^ PYI016 -19 | field4: int | int | str # PYI016: Duplicate union member `int` -20 | field5: str | int | str # PYI016: Duplicate union member `str` - | - = help: Remove duplicate union member `str` - -ℹ Fix -15 15 | return "my string" -16 16 | -17 17 | # Should emit in longer unions, even if not directly adjacent. -18 |-field3: str | str | int # PYI016: Duplicate union member `str` - 18 |+field3: str | int # PYI016: Duplicate union member `str` -19 19 | field4: int | int | str # PYI016: Duplicate union member `int` -20 20 | field5: str | int | str # PYI016: Duplicate union member `str` -21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` - -PYI016.pyi:19:15: PYI016 [*] Duplicate union member `int` - | -17 | # Should emit in longer unions, even if not directly adjacent. -18 | field3: str | str | int # PYI016: Duplicate union member `str` -19 | field4: int | int | str # PYI016: Duplicate union member `int` - | ^^^ PYI016 -20 | field5: str | int | str # PYI016: Duplicate union member `str` -21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` - | - = help: Remove duplicate union member `int` - -ℹ Fix -16 16 | -17 17 | # Should emit in longer unions, even if not directly adjacent. -18 18 | field3: str | str | int # PYI016: Duplicate union member `str` -19 |-field4: int | int | str # PYI016: Duplicate union member `int` - 19 |+field4: int | str # PYI016: Duplicate union member `int` -20 20 | field5: str | int | str # PYI016: Duplicate union member `str` -21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` -22 22 | - -PYI016.pyi:20:21: PYI016 [*] Duplicate union member `str` - | -18 | field3: str | str | int # PYI016: Duplicate union member `str` -19 | field4: int | int | str # PYI016: Duplicate union member `int` -20 | field5: str | int | str # PYI016: Duplicate union member `str` - | ^^^ PYI016 -21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` - | - = help: Remove duplicate union member `str` - -ℹ Fix -17 17 | # Should emit in longer unions, even if not directly adjacent. -18 18 | field3: str | str | int # PYI016: Duplicate union member `str` -19 19 | field4: int | int | str # PYI016: Duplicate union member `int` -20 |-field5: str | int | str # PYI016: Duplicate union member `str` - 20 |+field5: str | int # PYI016: Duplicate union member `str` -21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` -22 22 | -23 23 | # Shouldn't emit for non-type unions. - -PYI016.pyi:21:28: PYI016 [*] Duplicate union member `int` - | -19 | field4: int | int | str # 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 | -23 | # Shouldn't emit for non-type unions. - | - = help: Remove duplicate union member `int` - -ℹ Fix -18 18 | field3: str | str | int # PYI016: Duplicate union member `str` -19 19 | field4: int | int | str # PYI016: Duplicate union member `int` -20 20 | field5: str | int | str # PYI016: Duplicate union member `str` -21 |-field6: int | bool | str | int # PYI016: Duplicate union member `int` - 21 |+field6: int | bool | str # PYI016: Duplicate union member `int` -22 22 | -23 23 | # Shouldn't emit for non-type unions. -24 24 | field7 = str | str - -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 | -29 | # Should handle user brackets when fixing. - | - = help: Remove duplicate union member `int` - -ℹ Fix -24 24 | field7 = str | str -25 25 | -26 26 | # Should emit for strangely-bracketed unions. -27 |-field8: int | (str | int) # PYI016: Duplicate union member `int` - 27 |+field8: int | (str) # PYI016: Duplicate union member `int` -28 28 | -29 29 | # Should handle user brackets when fixing. -30 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` - -PYI016.pyi:30:16: PYI016 [*] Duplicate union member `int` - | -29 | # Should handle user brackets when fixing. -30 | field9: int | (int | str) # PYI016: Duplicate union member `int` - | ^^^ PYI016 -31 | field10: (str | int) | str # PYI016: Duplicate union member `str` - | - = help: Remove duplicate union member `int` - -ℹ Fix -27 27 | field8: int | (str | int) # PYI016: Duplicate union member `int` -28 28 | -29 29 | # Should handle user brackets when fixing. -30 |-field9: int | (int | str) # PYI016: Duplicate union member `int` - 30 |+field9: int | (str) # PYI016: Duplicate union member `int` -31 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` -32 32 | -33 33 | # Should emit for nested unions. - -PYI016.pyi:31:24: PYI016 [*] Duplicate union member `str` - | -29 | # Should handle user brackets when fixing. -30 | field9: int | (int | str) # PYI016: Duplicate union member `int` -31 | field10: (str | int) | str # PYI016: Duplicate union member `str` - | ^^^ PYI016 -32 | -33 | # Should emit for nested unions. - | - = help: Remove duplicate union member `str` - -ℹ Fix -28 28 | -29 29 | # Should handle user brackets when fixing. -30 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` -31 |-field10: (str | int) | str # PYI016: Duplicate union member `str` - 31 |+field10: str | int # PYI016: Duplicate union member `str` -32 32 | -33 33 | # Should emit for nested unions. -34 34 | field11: dict[int | int, str] - -PYI016.pyi:34:21: PYI016 [*] Duplicate union member `int` - | -33 | # Should emit for nested unions. -34 | field11: dict[int | int, str] - | ^^^ PYI016 -35 | -36 | # Should emit for unions with more than two cases - | - = help: Remove duplicate union member `int` - -ℹ Fix -31 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` -32 32 | -33 33 | # Should emit for nested unions. -34 |-field11: dict[int | int, str] - 34 |+field11: dict[int, str] -35 35 | -36 36 | # Should emit for unions with more than two cases -37 37 | field12: int | int | int # Error - -PYI016.pyi:37:16: PYI016 [*] Duplicate union member `int` - | -36 | # Should emit for unions with more than two cases -37 | field12: int | int | int # Error - | ^^^ PYI016 -38 | field13: int | int | int | int # Error - | - = help: Remove duplicate union member `int` - -ℹ Fix -34 34 | field11: dict[int | int, str] -35 35 | -36 36 | # Should emit for unions with more than two cases -37 |-field12: int | int | int # Error - 37 |+field12: int | int # Error -38 38 | field13: int | int | int | int # Error -39 39 | -40 40 | # Should emit for unions with more than two cases, even if not directly adjacent - -PYI016.pyi:37:22: PYI016 [*] Duplicate union member `int` - | -36 | # Should emit for unions with more than two cases -37 | field12: int | int | int # Error - | ^^^ PYI016 -38 | field13: int | int | int | int # Error - | - = help: Remove duplicate union member `int` - -ℹ Fix -34 34 | field11: dict[int | int, str] -35 35 | -36 36 | # Should emit for unions with more than two cases -37 |-field12: int | int | int # Error - 37 |+field12: int | int # Error -38 38 | field13: int | int | int | int # Error -39 39 | -40 40 | # Should emit for unions with more than two cases, even if not directly adjacent - -PYI016.pyi:38:16: PYI016 [*] Duplicate union member `int` - | -36 | # Should emit for unions with more than two cases -37 | field12: int | int | int # Error -38 | field13: int | int | int | int # Error - | ^^^ PYI016 -39 | -40 | # Should emit for unions with more than two cases, even if not directly adjacent - | - = help: Remove duplicate union member `int` - -ℹ Fix -35 35 | -36 36 | # Should emit for unions with more than two cases -37 37 | field12: int | int | int # Error -38 |-field13: int | int | int | int # Error - 38 |+field13: int | int | int # Error -39 39 | -40 40 | # Should emit for unions with more than two cases, even if not directly adjacent -41 41 | field14: int | int | str | int # Error - -PYI016.pyi:38:22: PYI016 [*] Duplicate union member `int` - | -36 | # Should emit for unions with more than two cases -37 | field12: int | int | int # Error -38 | field13: int | int | int | int # Error - | ^^^ PYI016 -39 | -40 | # Should emit for unions with more than two cases, even if not directly adjacent - | - = help: Remove duplicate union member `int` - -ℹ Fix -35 35 | -36 36 | # Should emit for unions with more than two cases -37 37 | field12: int | int | int # Error -38 |-field13: int | int | int | int # Error - 38 |+field13: int | int | int # Error -39 39 | -40 40 | # Should emit for unions with more than two cases, even if not directly adjacent -41 41 | field14: int | int | str | int # Error - -PYI016.pyi:38:28: PYI016 [*] Duplicate union member `int` - | -36 | # Should emit for unions with more than two cases -37 | field12: int | int | int # Error -38 | field13: int | int | int | int # Error - | ^^^ PYI016 -39 | -40 | # Should emit for unions with more than two cases, even if not directly adjacent - | - = help: Remove duplicate union member `int` - -ℹ Fix -35 35 | -36 36 | # Should emit for unions with more than two cases -37 37 | field12: int | int | int # Error -38 |-field13: int | int | int | int # Error - 38 |+field13: int | int | int # Error -39 39 | -40 40 | # Should emit for unions with more than two cases, even if not directly adjacent -41 41 | field14: int | int | str | int # Error - -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 | -43 | # Should emit for duplicate literal types; also covered by PYI030 - | - = help: Remove duplicate union member `int` - -ℹ Fix -38 38 | field13: int | int | int | int # Error -39 39 | -40 40 | # Should emit for unions with more than two cases, even if not directly adjacent -41 |-field14: int | int | str | int # Error - 41 |+field14: int | str | int # Error -42 42 | -43 43 | # Should emit for duplicate literal types; also covered by PYI030 -44 44 | field15: typing.Literal[1] | typing.Literal[1] # Error - -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 | -43 | # Should emit for duplicate literal types; also covered by PYI030 - | - = help: Remove duplicate union member `int` - -ℹ Fix -38 38 | field13: int | int | int | int # Error -39 39 | -40 40 | # Should emit for unions with more than two cases, even if not directly adjacent -41 |-field14: int | int | str | int # Error - 41 |+field14: int | int | str # Error -42 42 | -43 43 | # Should emit for duplicate literal types; also covered by PYI030 -44 44 | field15: typing.Literal[1] | typing.Literal[1] # Error - -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 | -46 | # Shouldn't emit if in new parent type - | - = help: Remove duplicate union member `typing.Literal[1]` - -ℹ Fix -41 41 | field14: int | int | str | int # Error -42 42 | -43 43 | # Should emit for duplicate literal types; also covered by PYI030 -44 |-field15: typing.Literal[1] | typing.Literal[1] # Error - 44 |+field15: typing.Literal[1] # Error -45 45 | -46 46 | # Shouldn't emit if in new parent type -47 47 | field16: int | dict[int, str] # OK - -PYI016.pyi:57:5: PYI016 Duplicate union member `set[int]` - | -55 | int # foo -56 | ], -57 | set[ - | _____^ -58 | | int # bar -59 | | ], - | |_____^ PYI016 -60 | ] # Error, newline and comment will not be emitted in message - | - = help: Remove duplicate union member `set[int]` - -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 | -65 | # Should emit in cases with nested `typing.Union` - | - = help: Remove duplicate union member `int` - -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 | -68 | # Should emit in cases with mixed `typing.Union` and `|` - | - = help: Remove duplicate union member `int` - -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 | -71 | # Should emit only once in cases with multiple nested `typing.Union` - | - = help: Remove duplicate union member `int` - -ℹ Fix -66 66 | field20: typing.Union[int, typing.Union[int, str]] # Error -67 67 | -68 68 | # Should emit in cases with mixed `typing.Union` and `|` -69 |-field21: typing.Union[int, int | str] # Error - 69 |+field21: typing.Union[int, str] # Error -70 70 | -71 71 | # Should emit only once in cases with multiple nested `typing.Union` -72 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error - -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 | -74 | # Should emit in cases with newlines - | - = help: Remove duplicate union member `int` - -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 | -74 | # Should emit in cases with newlines - | - = help: Remove duplicate union member `int` - -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 | -74 | # Should emit in cases with newlines - | - = help: Remove duplicate union member `int` - -PYI016.pyi:76:12: PYI016 [*] Duplicate union member `set[int]` - | -74 | # Should emit in cases with newlines -75 | field23: set[ # foo -76 | int] | set[int] - | ^^^^^^^^ PYI016 -77 | -78 | # Should emit twice (once for each `int` in the nested union, both of which are - | - = help: Remove duplicate union member `set[int]` - -ℹ Fix -73 73 | -74 74 | # Should emit in cases with newlines -75 75 | field23: set[ # foo -76 |- int] | set[int] - 76 |+ int] -77 77 | -78 78 | # Should emit twice (once for each `int` in the nested union, both of which are -79 79 | # duplicates of the outer `int`), but not three times (which would indicate that - -PYI016.pyi:81:41: PYI016 Duplicate union member `int` - | -79 | # duplicates of the outer `int`), but not three times (which would indicate that -80 | # we incorrectly re-checked the nested union). -81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 -82 | -83 | # Should emit twice (once for each `int` in the nested union, both of which are - | - = help: Remove duplicate union member `int` - -PYI016.pyi:81:46: PYI016 Duplicate union member `int` - | -79 | # duplicates of the outer `int`), but not three times (which would indicate that -80 | # we incorrectly re-checked the nested union). -81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` - | ^^^ PYI016 -82 | -83 | # Should emit twice (once for each `int` in the nested union, both of which are - | - = help: Remove duplicate union member `int` - -PYI016.pyi:86:28: PYI016 [*] Duplicate union member `int` - | -84 | # duplicates of the outer `int`), but not three times (which would indicate that -85 | # we incorrectly re-checked the nested union). -86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` - | ^^^ PYI016 - | - = help: Remove duplicate union member `int` - -ℹ Fix -83 83 | # Should emit twice (once for each `int` in the nested union, both of which are -84 84 | # duplicates of the outer `int`), but not three times (which would indicate that -85 85 | # we incorrectly re-checked the nested union). -86 |-field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` - 86 |+field25: typing.Union[int, int] # PYI016: Duplicate union member `int` - -PYI016.pyi:86:34: PYI016 [*] Duplicate union member `int` - | -84 | # duplicates of the outer `int`), but not three times (which would indicate that -85 | # we incorrectly re-checked the nested union). -86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` - | ^^^ PYI016 - | - = help: Remove duplicate union member `int` - -ℹ Fix -83 83 | # Should emit twice (once for each `int` in the nested union, both of which are -84 84 | # duplicates of the outer `int`), but not three times (which would indicate that -85 85 | # we incorrectly re-checked the nested union). -86 |-field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` - 86 |+field25: typing.Union[int, int] # PYI016: Duplicate union member `int` - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI017_PYI017.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI017_PYI017.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI017_PYI017.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI017_PYI017.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI017_PYI017.pyi.snap deleted file mode 100644 index 6cb3e94f8c..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI017_PYI017.pyi.snap +++ /dev/null @@ -1,44 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI017.pyi:4:1: PYI017 Stubs should not contain assignments to attributes or multiple targets - | -2 | a = var # OK -3 | -4 | b = c = int # PYI017 - | ^^^^^^^^^^^ PYI017 -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 | -6 | a.b = int # PYI017 - | ^^^^^^^^^ PYI017 -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 | - 8 | d, e = int, str # PYI017 - | ^^^^^^^^^^^^^^^ PYI017 - 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 | -10 | f, g, h = int, str, TypeVar("T") # PYI017 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI017 -11 | -12 | i: TypeAlias = int | str # OK - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI018_PYI018.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI018_PYI018.py.snap deleted file mode 100644 index d61c7d9e11..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI018_PYI018.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI018.py:4:1: PYI018 Private TypeVar `_T` is never used - | -2 | from typing import TypeVar -3 | -4 | _T = typing.TypeVar("_T") - | ^^ PYI018 -5 | _P = TypeVar("_P") - | - -PYI018.py:5:1: PYI018 Private TypeVar `_P` is never used - | -4 | _T = typing.TypeVar("_T") -5 | _P = TypeVar("_P") - | ^^ PYI018 -6 | -7 | # OK - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI018_PYI018.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI018_PYI018.pyi.snap deleted file mode 100644 index b06ccc51bd..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI018_PYI018.pyi.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI018.pyi:4:1: PYI018 Private TypeVar `_T` is never used - | -2 | from typing import TypeVar -3 | -4 | _T = typing.TypeVar("_T") - | ^^ PYI018 -5 | _P = TypeVar("_P") - | - -PYI018.pyi:5:1: PYI018 Private TypeVar `_P` is never used - | -4 | _T = typing.TypeVar("_T") -5 | _P = TypeVar("_P") - | ^^ PYI018 -6 | -7 | # OK - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI019_PYI019.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI019_PYI019.py.snap deleted file mode 100644 index 7ead8194b9..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI019_PYI019.py.snap +++ /dev/null @@ -1,45 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI019.py:7:62: PYI019 Methods like `__new__` should return `typing.Self` instead of a custom `TypeVar` - | -6 | class BadClass: -7 | def __new__(cls: type[_S], *args: str, **kwargs: int) -> _S: ... # PYI019 - | ^^ PYI019 - | - -PYI019.py:10:54: PYI019 Methods like `bad_instance_method` should return `typing.Self` instead of a custom `TypeVar` - | -10 | def bad_instance_method(self: _S, arg: bytes) -> _S: ... # PYI019 - | ^^ PYI019 - | - -PYI019.py:14:54: PYI019 Methods like `bad_class_method` should return `typing.Self` instead of a custom `TypeVar` - | -13 | @classmethod -14 | def bad_class_method(cls: type[_S], arg: int) -> _S: ... # PYI019 - | ^^ PYI019 - | - -PYI019.py:18:55: PYI019 Methods like `bad_posonly_class_method` should return `typing.Self` instead of a custom `TypeVar` - | -17 | @classmethod -18 | def bad_posonly_class_method(cls: type[_S], /) -> _S: ... # PYI019 - | ^^ PYI019 - | - -PYI019.py:39:63: PYI019 Methods like `__new__` should return `typing.Self` instead of a custom `TypeVar` - | -37 | # Python > 3.12 -38 | class PEP695BadDunderNew[T]: -39 | def __new__[S](cls: type[S], *args: Any, ** kwargs: Any) -> S: ... # PYI019 - | ^ PYI019 - | - -PYI019.py:42:46: PYI019 Methods like `generic_instance_method` should return `typing.Self` instead of a custom `TypeVar` - | -42 | def generic_instance_method[S](self: S) -> S: ... # PYI019 - | ^ PYI019 - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI019_PYI019.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI019_PYI019.pyi.snap deleted file mode 100644 index 03c5bbb5be..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI019_PYI019.pyi.snap +++ /dev/null @@ -1,45 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI019.pyi:7:62: PYI019 Methods like `__new__` should return `typing.Self` instead of a custom `TypeVar` - | -6 | class BadClass: -7 | def __new__(cls: type[_S], *args: str, **kwargs: int) -> _S: ... # PYI019 - | ^^ PYI019 - | - -PYI019.pyi:10:54: PYI019 Methods like `bad_instance_method` should return `typing.Self` instead of a custom `TypeVar` - | -10 | def bad_instance_method(self: _S, arg: bytes) -> _S: ... # PYI019 - | ^^ PYI019 - | - -PYI019.pyi:14:54: PYI019 Methods like `bad_class_method` should return `typing.Self` instead of a custom `TypeVar` - | -13 | @classmethod -14 | def bad_class_method(cls: type[_S], arg: int) -> _S: ... # PYI019 - | ^^ PYI019 - | - -PYI019.pyi:18:55: PYI019 Methods like `bad_posonly_class_method` should return `typing.Self` instead of a custom `TypeVar` - | -17 | @classmethod -18 | def bad_posonly_class_method(cls: type[_S], /) -> _S: ... # PYI019 - | ^^ PYI019 - | - -PYI019.pyi:39:63: PYI019 Methods like `__new__` should return `typing.Self` instead of a custom `TypeVar` - | -37 | # Python > 3.12 -38 | class PEP695BadDunderNew[T]: -39 | def __new__[S](cls: type[S], *args: Any, ** kwargs: Any) -> S: ... # PYI019 - | ^ PYI019 - | - -PYI019.pyi:42:46: PYI019 Methods like `generic_instance_method` should return `typing.Self` instead of a custom `TypeVar` - | -42 | def generic_instance_method[S](self: S) -> S: ... # PYI019 - | ^ PYI019 - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI020_PYI020.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI020_PYI020.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI020_PYI020.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI020_PYI020.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI020_PYI020.pyi.snap deleted file mode 100644 index 09bd4a54d8..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI020_PYI020.pyi.snap +++ /dev/null @@ -1,187 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI020.pyi:7:10: PYI020 [*] Quoted annotations should not be included in stubs - | -5 | import typing_extensions -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 -9 | _T = TypeVar("_T", bound="int") # Y020 Quoted annotations should never be used in stubs - | - = help: Remove quotes - -ℹ Fix -4 4 | -5 5 | import typing_extensions -6 6 | -7 |-def f(x: "int"): ... # Y020 Quoted annotations should never be used in stubs - 7 |+def f(x: int): ... # Y020 Quoted annotations should never be used in stubs -8 8 | def g(x: list["int"]): ... # Y020 Quoted annotations should never be used in stubs -9 9 | _T = TypeVar("_T", bound="int") # Y020 Quoted annotations should never be used in stubs -10 10 | - -PYI020.pyi:8:15: PYI020 [*] Quoted annotations should not be included in stubs - | -7 | def f(x: "int"): ... # Y020 Quoted annotations should never be used in stubs -8 | def g(x: list["int"]): ... # Y020 Quoted annotations should never be used in stubs - | ^^^^^ PYI020 -9 | _T = TypeVar("_T", bound="int") # Y020 Quoted annotations should never be used in stubs - | - = help: Remove quotes - -ℹ Fix -5 5 | import typing_extensions -6 6 | -7 7 | def f(x: "int"): ... # Y020 Quoted annotations should never be used in stubs -8 |-def g(x: list["int"]): ... # Y020 Quoted annotations should never be used in stubs - 8 |+def g(x: list[int]): ... # Y020 Quoted annotations should never be used in stubs -9 9 | _T = TypeVar("_T", bound="int") # Y020 Quoted annotations should never be used in stubs -10 10 | -11 11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ... - -PYI020.pyi:9:26: PYI020 [*] Quoted annotations should not be included in stubs - | - 7 | def f(x: "int"): ... # Y020 Quoted annotations should never be used 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 | -11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ... - | - = help: Remove quotes - -ℹ Fix -6 6 | -7 7 | def f(x: "int"): ... # Y020 Quoted annotations should never be used in stubs -8 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 - 9 |+_T = TypeVar("_T", bound=int) # Y020 Quoted annotations should never be used in stubs -10 10 | -11 11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ... -12 12 | - -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 | -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 - | - = help: Remove quotes - -ℹ Fix -10 10 | -11 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 - 13 |+def j() -> int: ... # Y020 Quoted annotations should never be used in stubs -14 14 | Alias: TypeAlias = list["int"] # Y020 Quoted annotations should never be used in stubs -15 15 | -16 16 | class Child(list["int"]): # Y020 Quoted annotations should never be used in stubs - -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 | -16 | class Child(list["int"]): # Y020 Quoted annotations should never be used in stubs - | - = help: Remove quotes - -ℹ Fix -11 11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ... -12 12 | -13 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 - 14 |+Alias: TypeAlias = list[int] # Y020 Quoted annotations should never be used in stubs -15 15 | -16 16 | class Child(list["int"]): # Y020 Quoted annotations should never be used in stubs -17 17 | """Documented and guaranteed useful.""" # Y021 Docstrings 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 | -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 - | - = help: Remove quotes - -ℹ Fix -13 13 | def j() -> "int": ... # Y020 Quoted annotations should never be used in stubs -14 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 - 16 |+class Child(list[int]): # Y020 Quoted annotations should never be used in stubs -17 17 | """Documented and guaranteed useful.""" # Y021 Docstrings should not be included in stubs -18 18 | -19 19 | if sys.platform == "linux": - -PYI020.pyi:20:8: PYI020 [*] Quoted annotations should not be included in stubs - | -19 | if sys.platform == "linux": -20 | f: "int" # Y020 Quoted annotations should never be used in stubs - | ^^^^^ PYI020 -21 | elif sys.platform == "win32": -22 | f: "str" # Y020 Quoted annotations should never be used in stubs - | - = help: Remove quotes - -ℹ Fix -17 17 | """Documented and guaranteed useful.""" # Y021 Docstrings should not be included in stubs -18 18 | -19 19 | if sys.platform == "linux": -20 |- f: "int" # Y020 Quoted annotations should never be used in stubs - 20 |+ f: int # Y020 Quoted annotations should never be used in stubs -21 21 | elif sys.platform == "win32": -22 22 | f: "str" # Y020 Quoted annotations should never be used in stubs -23 23 | else: - -PYI020.pyi:22:8: PYI020 [*] Quoted annotations should not be included in stubs - | -20 | f: "int" # Y020 Quoted annotations should never be used in stubs -21 | elif sys.platform == "win32": -22 | f: "str" # Y020 Quoted annotations should never be used in stubs - | ^^^^^ PYI020 -23 | else: -24 | f: "bytes" # Y020 Quoted annotations should never be used in stubs - | - = help: Remove quotes - -ℹ Fix -19 19 | if sys.platform == "linux": -20 20 | f: "int" # Y020 Quoted annotations should never be used in stubs -21 21 | elif sys.platform == "win32": -22 |- f: "str" # Y020 Quoted annotations should never be used in stubs - 22 |+ f: str # Y020 Quoted annotations should never be used in stubs -23 23 | else: -24 24 | f: "bytes" # Y020 Quoted annotations should never be used in stubs -25 25 | - -PYI020.pyi:24:8: PYI020 [*] Quoted annotations should not be included in stubs - | -22 | f: "str" # Y020 Quoted annotations should never be used in stubs -23 | else: -24 | f: "bytes" # Y020 Quoted annotations should never be used in stubs - | ^^^^^^^ PYI020 -25 | -26 | # These two shouldn't trigger Y020 -- empty strings can't be "quoted annotations" - | - = help: Remove quotes - -ℹ Fix -21 21 | elif sys.platform == "win32": -22 22 | f: "str" # Y020 Quoted annotations should never be used in stubs -23 23 | else: -24 |- f: "bytes" # Y020 Quoted annotations should never be used in stubs - 24 |+ f: bytes # Y020 Quoted annotations should never be used in stubs -25 25 | -26 26 | # These two shouldn't trigger Y020 -- empty strings can't be "quoted annotations" -27 27 | k = "" # Y052 Need type annotation for "k" - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI021_PYI021.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI021_PYI021.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI021_PYI021.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI021_PYI021.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI021_PYI021.pyi.snap deleted file mode 100644 index 6e12d25532..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI021_PYI021.pyi.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI021.pyi:1:1: PYI021 Docstrings should not be included in stubs - | -1 | """foo""" # ERROR PYI021 - | ^^^^^^^^^ PYI021 -2 | -3 | def foo(): - | - -PYI021.pyi:4:5: PYI021 Docstrings should not be included in stubs - | -3 | def foo(): -4 | """foo""" # ERROR PYI021 - | ^^^^^^^^^ PYI021 -5 | -6 | class Bar: - | - -PYI021.pyi:7:5: PYI021 Docstrings should not be included in stubs - | -6 | class Bar: -7 | """bar""" # ERROR PYI021 - | ^^^^^^^^^ PYI021 -8 | -9 | def bar(): - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI024_PYI024.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI024_PYI024.py.snap deleted file mode 100644 index aacfa64984..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI024_PYI024.py.snap +++ /dev/null @@ -1,37 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI024.py:3:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` - | -1 | import collections -2 | -3 | person: collections.namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" - | ^^^^^^^^^^^^^^^^^^^^^^ PYI024 -4 | -5 | from collections import namedtuple - | - = help: Replace with `typing.NamedTuple` - -PYI024.py:7:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` - | -5 | from collections import namedtuple -6 | -7 | person: namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" - | ^^^^^^^^^^ PYI024 -8 | -9 | person = namedtuple( - | - = help: Replace with `typing.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 | - 9 | person = namedtuple( - | ^^^^^^^^^^ PYI024 -10 | "Person", ["name", "age"] -11 | ) # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" - | - = help: Replace with `typing.NamedTuple` - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI024_PYI024.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI024_PYI024.pyi.snap deleted file mode 100644 index b8ee29e220..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI024_PYI024.pyi.snap +++ /dev/null @@ -1,37 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI024.pyi:3:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` - | -1 | import collections -2 | -3 | person: collections.namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" - | ^^^^^^^^^^^^^^^^^^^^^^ PYI024 -4 | -5 | from collections import namedtuple - | - = help: Replace with `typing.NamedTuple` - -PYI024.pyi:7:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` - | -5 | from collections import namedtuple -6 | -7 | person: namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" - | ^^^^^^^^^^ PYI024 -8 | -9 | person = namedtuple( - | - = help: Replace with `typing.NamedTuple` - -PYI024.pyi:9:10: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` - | - 7 | person: namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" - 8 | - 9 | person = namedtuple( - | ^^^^^^^^^^ PYI024 -10 | "Person", ["name", "age"] -11 | ) # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" - | - = help: Replace with `typing.NamedTuple` - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI025_PYI025.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI025_PYI025.py.snap deleted file mode 100644 index 606cc41caf..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI025_PYI025.py.snap +++ /dev/null @@ -1,46 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI025.py:10:33: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin - | - 9 | def f(): -10 | from collections.abc import Set # PYI025 - | ^^^ PYI025 - | - = help: Alias `Set` to `AbstractSet` - -ℹ Suggested fix -7 7 | -8 8 | -9 9 | def f(): -10 |- from collections.abc import Set # PYI025 - 10 |+ from collections.abc import Set as AbstractSet # PYI025 -11 11 | -12 12 | -13 13 | def f(): - -PYI025.py:14:51: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin - | -13 | def f(): -14 | from collections.abc import Container, Sized, Set, ValuesView # PYI025 - | ^^^ PYI025 -15 | -16 | GLOBAL: Set[int] = set() - | - = help: Alias `Set` to `AbstractSet` - -ℹ Suggested fix -11 11 | -12 12 | -13 13 | def f(): -14 |- from collections.abc import Container, Sized, Set, ValuesView # PYI025 - 14 |+ from collections.abc import Container, Sized, Set as AbstractSet, ValuesView # PYI025 -15 15 | -16 |- GLOBAL: Set[int] = set() - 16 |+ GLOBAL: AbstractSet[int] = set() -17 17 | -18 18 | class Class: -19 |- member: Set[int] - 19 |+ member: AbstractSet[int] - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI025_PYI025.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI025_PYI025.pyi.snap deleted file mode 100644 index 6da7686105..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI025_PYI025.pyi.snap +++ /dev/null @@ -1,149 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI025.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 | -10 | def f(): - | - = help: Alias `Set` to `AbstractSet` - -ℹ Suggested fix -5 5 | from collections.abc import Container, Sized, Set as AbstractSet, ValuesView # Ok -6 6 | -7 7 | def f(): -8 |- from collections.abc import Set # PYI025 - 8 |+ from collections.abc import Set as AbstractSet # PYI025 -9 9 | -10 10 | def f(): -11 11 | from collections.abc import Container, Sized, Set, ValuesView # PYI025 - -PYI025.pyi:11:51: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin - | -10 | def f(): -11 | from collections.abc import Container, Sized, Set, ValuesView # PYI025 - | ^^^ PYI025 -12 | -13 | def f(): - | - = help: Alias `Set` to `AbstractSet` - -ℹ Suggested fix -8 8 | from collections.abc import Set # PYI025 -9 9 | -10 10 | def f(): -11 |- from collections.abc import Container, Sized, Set, ValuesView # PYI025 - 11 |+ from collections.abc import Container, Sized, Set as AbstractSet, ValuesView # PYI025 -12 12 | -13 13 | def f(): -14 14 | """Test: local symbol renaming.""" - -PYI025.pyi:16:37: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin - | -14 | """Test: local symbol renaming.""" -15 | if True: -16 | from collections.abc import Set - | ^^^ PYI025 -17 | else: -18 | Set = 1 - | - = help: Alias `Set` to `AbstractSet` - -ℹ Suggested fix -13 13 | def f(): -14 14 | """Test: local symbol renaming.""" -15 15 | if True: -16 |- from collections.abc import Set - 16 |+ from collections.abc import Set as AbstractSet -17 17 | else: -18 |- Set = 1 - 18 |+ AbstractSet = 1 -19 19 | -20 20 | x: Set = set() -21 21 | -22 22 | x: Set -23 23 | -24 |- del Set - 24 |+ del AbstractSet -25 25 | -26 26 | def f(): -27 |- print(Set) - 27 |+ print(AbstractSet) -28 28 | -29 29 | def Set(): -30 30 | pass - -PYI025.pyi:33:29: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin - | -31 | print(Set) -32 | -33 | from collections.abc import Set - | ^^^ PYI025 -34 | -35 | def f(): - | - = help: Alias `Set` to `AbstractSet` - -ℹ Suggested fix -17 17 | else: -18 18 | Set = 1 -19 19 | -20 |- x: Set = set() - 20 |+ x: AbstractSet = set() -21 21 | -22 |- x: Set - 22 |+ x: AbstractSet -23 23 | -24 24 | del Set -25 25 | --------------------------------------------------------------------------------- -30 30 | pass -31 31 | print(Set) -32 32 | -33 |-from collections.abc import Set - 33 |+from collections.abc import Set as AbstractSet -34 34 | -35 35 | def f(): -36 36 | """Test: global symbol renaming.""" -37 |- global Set - 37 |+ global AbstractSet -38 38 | -39 |- Set = 1 -40 |- print(Set) - 39 |+ AbstractSet = 1 - 40 |+ print(AbstractSet) -41 41 | -42 42 | def f(): -43 43 | """Test: nonlocal symbol renaming.""" - -PYI025.pyi:44:33: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin - | -42 | def f(): -43 | """Test: nonlocal symbol renaming.""" -44 | from collections.abc import Set - | ^^^ PYI025 -45 | -46 | def g(): - | - = help: Alias `Set` to `AbstractSet` - -ℹ Suggested fix -41 41 | -42 42 | def f(): -43 43 | """Test: nonlocal symbol renaming.""" -44 |- from collections.abc import Set - 44 |+ from collections.abc import Set as AbstractSet -45 45 | -46 46 | def g(): -47 |- nonlocal Set - 47 |+ nonlocal AbstractSet -48 48 | -49 |- Set = 1 -50 |- print(Set) - 49 |+ AbstractSet = 1 - 50 |+ print(AbstractSet) - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI026_PYI026.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI026_PYI026.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI026_PYI026.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI026_PYI026.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI026_PYI026.pyi.snap deleted file mode 100644 index b039953958..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI026_PYI026.pyi.snap +++ /dev/null @@ -1,117 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI026.pyi:3:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `NewAny: TypeAlias = Any` - | -1 | from typing import Literal, Any -2 | -3 | NewAny = Any - | ^^^^^^ PYI026 -4 | OptionalStr = typing.Optional[str] -5 | Foo = Literal["foo"] - | - = help: Add `TypeAlias` annotation - -ℹ Suggested fix -1 |-from typing import Literal, Any - 1 |+from typing import Literal, Any, TypeAlias -2 2 | -3 |-NewAny = Any - 3 |+NewAny: TypeAlias = Any -4 4 | OptionalStr = typing.Optional[str] -5 5 | Foo = Literal["foo"] -6 6 | IntOrStr = int | str - -PYI026.pyi:4:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `OptionalStr: TypeAlias = typing.Optional[str]` - | -3 | NewAny = Any -4 | OptionalStr = typing.Optional[str] - | ^^^^^^^^^^^ PYI026 -5 | Foo = Literal["foo"] -6 | IntOrStr = int | str - | - = help: Add `TypeAlias` annotation - -ℹ Suggested fix -1 |-from typing import Literal, Any - 1 |+from typing import Literal, Any, TypeAlias -2 2 | -3 3 | NewAny = Any -4 |-OptionalStr = typing.Optional[str] - 4 |+OptionalStr: TypeAlias = typing.Optional[str] -5 5 | Foo = Literal["foo"] -6 6 | IntOrStr = int | str -7 7 | AliasNone = None - -PYI026.pyi:5:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `Foo: TypeAlias = Literal["foo"]` - | -3 | NewAny = Any -4 | OptionalStr = typing.Optional[str] -5 | Foo = Literal["foo"] - | ^^^ PYI026 -6 | IntOrStr = int | str -7 | AliasNone = None - | - = help: Add `TypeAlias` annotation - -ℹ Suggested fix -1 |-from typing import Literal, Any - 1 |+from typing import Literal, Any, TypeAlias -2 2 | -3 3 | NewAny = Any -4 4 | OptionalStr = typing.Optional[str] -5 |-Foo = Literal["foo"] - 5 |+Foo: TypeAlias = Literal["foo"] -6 6 | IntOrStr = int | str -7 7 | AliasNone = None -8 8 | - -PYI026.pyi:6:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `IntOrStr: TypeAlias = int | str` - | -4 | OptionalStr = typing.Optional[str] -5 | Foo = Literal["foo"] -6 | IntOrStr = int | str - | ^^^^^^^^ PYI026 -7 | AliasNone = None - | - = help: Add `TypeAlias` annotation - -ℹ Suggested fix -1 |-from typing import Literal, Any - 1 |+from typing import Literal, Any, TypeAlias -2 2 | -3 3 | NewAny = Any -4 4 | OptionalStr = typing.Optional[str] -5 5 | Foo = Literal["foo"] -6 |-IntOrStr = int | str - 6 |+IntOrStr: TypeAlias = int | str -7 7 | AliasNone = None -8 8 | -9 9 | NewAny: typing.TypeAlias = Any - -PYI026.pyi:7:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `AliasNone: TypeAlias = None` - | -5 | Foo = Literal["foo"] -6 | IntOrStr = int | str -7 | AliasNone = None - | ^^^^^^^^^ PYI026 -8 | -9 | NewAny: typing.TypeAlias = Any - | - = help: Add `TypeAlias` annotation - -ℹ Suggested fix -1 |-from typing import Literal, Any - 1 |+from typing import Literal, Any, TypeAlias -2 2 | -3 3 | NewAny = Any -4 4 | OptionalStr = typing.Optional[str] -5 5 | Foo = Literal["foo"] -6 6 | IntOrStr = int | str -7 |-AliasNone = None - 7 |+AliasNone: TypeAlias = None -8 8 | -9 9 | NewAny: typing.TypeAlias = Any -10 10 | OptionalStr: TypeAlias = typing.Optional[str] - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI029_PYI029.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI029_PYI029.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI029_PYI029.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI029_PYI029.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI029_PYI029.pyi.snap deleted file mode 100644 index da345da4ff..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI029_PYI029.pyi.snap +++ /dev/null @@ -1,62 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -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 | -12 | class ShouldRemove: - | - = help: Remove definition of `str` - -ℹ Fix -7 7 | def __repr__(self, *, foo) -> str: ... -8 8 | -9 9 | class ShouldRemoveSingle: -10 |- def __str__(self) -> builtins.str: ... # Error: PYI029 - 10 |+ pass # Error: PYI029 -11 11 | -12 12 | class ShouldRemove: -13 13 | def __repr__(self) -> str: ... # Error: PYI029 - -PYI029.pyi:13:9: PYI029 [*] Defining `__repr__` in a stub is almost always redundant - | -12 | class ShouldRemove: -13 | def __repr__(self) -> str: ... # Error: PYI029 - | ^^^^^^^^ PYI029 -14 | def __str__(self) -> builtins.str: ... # Error: PYI029 - | - = help: Remove definition of `repr` - -ℹ Fix -10 10 | def __str__(self) -> builtins.str: ... # Error: PYI029 -11 11 | -12 12 | class ShouldRemove: -13 |- def __repr__(self) -> str: ... # Error: PYI029 -14 13 | def __str__(self) -> builtins.str: ... # Error: PYI029 -15 14 | -16 15 | class NoReturnSpecified: - -PYI029.pyi:14:9: PYI029 [*] Defining `__str__` in a stub is almost always redundant - | -12 | class ShouldRemove: -13 | def __repr__(self) -> str: ... # Error: PYI029 -14 | def __str__(self) -> builtins.str: ... # Error: PYI029 - | ^^^^^^^ PYI029 -15 | -16 | class NoReturnSpecified: - | - = help: Remove definition of `str` - -ℹ Fix -11 11 | -12 12 | class ShouldRemove: -13 13 | def __repr__(self) -> str: ... # Error: PYI029 -14 |- def __str__(self) -> builtins.str: ... # Error: PYI029 -15 14 | -16 15 | class NoReturnSpecified: -17 16 | def __str__(self): ... - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI030_PYI030.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI030_PYI030.py.snap deleted file mode 100644 index 204ae03602..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI030_PYI030.py.snap +++ /dev/null @@ -1,110 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -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 | -11 | # Should emit for union types in arguments. - | - -PYI030.py:12:17: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -11 | # Should emit for union types in arguments. -12 | def func1(arg1: Literal[1] | Literal[2]): # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -13 | print(arg1) - | - -PYI030.py:17:16: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -16 | # Should emit for unions in return types. -17 | def func2() -> Literal[1] | Literal[2]: # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -18 | return "my Literal[1]ing" - | - -PYI030.py:22:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -21 | # Should emit in longer unions, even if not directly adjacent. -22 | field3: Literal[1] | Literal[2] | str # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -23 | field4: str | Literal[1] | Literal[2] # Error -24 | field5: Literal[1] | str | Literal[2] # Error - | - -PYI030.py:23:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -21 | # Should emit in longer unions, even if not directly adjacent. -22 | field3: Literal[1] | Literal[2] | str # Error -23 | field4: str | Literal[1] | Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -24 | field5: Literal[1] | str | Literal[2] # Error -25 | field6: Literal[1] | bool | Literal[2] | str # Error - | - -PYI030.py:24:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -22 | field3: Literal[1] | Literal[2] | str # Error -23 | field4: str | Literal[1] | Literal[2] # Error -24 | field5: Literal[1] | str | Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -25 | field6: Literal[1] | bool | Literal[2] | str # Error - | - -PYI030.py:25:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -23 | field4: str | Literal[1] | Literal[2] # Error -24 | field5: Literal[1] | str | Literal[2] # Error -25 | field6: Literal[1] | bool | Literal[2] | str # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -26 | -27 | # Should emit for non-type unions. - | - -PYI030.py:28:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -27 | # Should emit for non-type unions. -28 | field7 = Literal[1] | Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -29 | -30 | # Should emit for parenthesized unions. - | - -PYI030.py:31:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -30 | # Should emit for parenthesized unions. -31 | field8: Literal[1] | (Literal[2] | str) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -32 | -33 | # Should handle user parentheses when fixing. - | - -PYI030.py:34:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -33 | # Should handle user parentheses when fixing. -34 | field9: Literal[1] | (Literal[2] | str) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -35 | field10: (Literal[1] | str) | Literal[2] # Error - | - -PYI030.py:35:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -33 | # Should handle user parentheses when fixing. -34 | field9: Literal[1] | (Literal[2] | str) # Error -35 | field10: (Literal[1] | str) | Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -36 | -37 | # Should emit for union in generic parent type. - | - -PYI030.py:38:15: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -37 | # Should emit for union in generic parent type. -38 | field11: dict[Literal[1] | Literal[2], str] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI030_PYI030.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI030_PYI030.pyi.snap deleted file mode 100644 index 42a1e51719..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI030_PYI030.pyi.snap +++ /dev/null @@ -1,233 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -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 | -11 | # Should emit for union types in arguments. - | - -PYI030.pyi:12:17: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -11 | # Should emit for union types in arguments. -12 | def func1(arg1: Literal[1] | Literal[2]): # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -13 | print(arg1) - | - -PYI030.pyi:17:16: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -16 | # Should emit for unions in return types. -17 | def func2() -> Literal[1] | Literal[2]: # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -18 | return "my Literal[1]ing" - | - -PYI030.pyi:22:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -21 | # Should emit in longer unions, even if not directly adjacent. -22 | field3: Literal[1] | Literal[2] | str # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -23 | field4: str | Literal[1] | Literal[2] # Error -24 | field5: Literal[1] | str | Literal[2] # Error - | - -PYI030.pyi:23:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -21 | # Should emit in longer unions, even if not directly adjacent. -22 | field3: Literal[1] | Literal[2] | str # Error -23 | field4: str | Literal[1] | Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -24 | field5: Literal[1] | str | Literal[2] # Error -25 | field6: Literal[1] | bool | Literal[2] | str # Error - | - -PYI030.pyi:24:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -22 | field3: Literal[1] | Literal[2] | str # Error -23 | field4: str | Literal[1] | Literal[2] # Error -24 | field5: Literal[1] | str | Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -25 | field6: Literal[1] | bool | Literal[2] | str # Error - | - -PYI030.pyi:25:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -23 | field4: str | Literal[1] | Literal[2] # Error -24 | field5: Literal[1] | str | Literal[2] # Error -25 | field6: Literal[1] | bool | Literal[2] | str # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -26 | -27 | # Should emit for non-type unions. - | - -PYI030.pyi:28:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -27 | # Should emit for non-type unions. -28 | field7 = Literal[1] | Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -29 | -30 | # Should emit for parenthesized unions. - | - -PYI030.pyi:31:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -30 | # Should emit for parenthesized unions. -31 | field8: Literal[1] | (Literal[2] | str) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -32 | -33 | # Should handle user parentheses when fixing. - | - -PYI030.pyi:34:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -33 | # Should handle user parentheses when fixing. -34 | field9: Literal[1] | (Literal[2] | str) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -35 | field10: (Literal[1] | str) | Literal[2] # Error - | - -PYI030.pyi:35:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -33 | # Should handle user parentheses when fixing. -34 | field9: Literal[1] | (Literal[2] | str) # Error -35 | field10: (Literal[1] | str) | Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -36 | -37 | # Should emit for union in generic parent type. - | - -PYI030.pyi:38:15: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -37 | # Should emit for union in generic parent type. -38 | field11: dict[Literal[1] | Literal[2], str] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -39 | -40 | # Should emit for unions with more than two cases - | - -PYI030.pyi:41:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3]` - | -40 | # Should emit for unions with more than two cases -41 | field12: Literal[1] | Literal[2] | Literal[3] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -42 | field13: Literal[1] | Literal[2] | Literal[3] | Literal[4] # Error - | - -PYI030.pyi:42:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` - | -40 | # Should emit for unions with more than two cases -41 | field12: Literal[1] | Literal[2] | Literal[3] # Error -42 | field13: Literal[1] | Literal[2] | Literal[3] | Literal[4] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -43 | -44 | # Should emit for unions with more than two cases, even if not directly adjacent - | - -PYI030.pyi:45:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3]` - | -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 | -47 | # Should emit for unions with mixed literal internal types - | - -PYI030.pyi:48:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, "foo", True]` - | -47 | # Should emit for unions with mixed literal internal types -48 | field15: Literal[1] | Literal["foo"] | Literal[True] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -49 | -50 | # Shouldn't emit for duplicate field types with same value; covered by Y016 - | - -PYI030.pyi:51:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 1]` - | -50 | # Shouldn't emit for duplicate field types with same value; covered by Y016 -51 | field16: Literal[1] | Literal[1] # OK - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -52 | -53 | # Shouldn't emit if in new parent type - | - -PYI030.pyi:60:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -59 | # Should respect name of literal type used -60 | field19: typing.Literal[1] | typing.Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -61 | -62 | # Should emit in cases with newlines - | - -PYI030.pyi:63:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -62 | # Should emit in cases with newlines -63 | field20: typing.Union[ - | __________^ -64 | | Literal[ -65 | | 1 # test -66 | | ], -67 | | Literal[2], -68 | | ] # Error, newline and comment will not be emitted in message - | |_^ PYI030 -69 | -70 | # Should handle multiple unions with multiple members - | - -PYI030.pyi:71:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` - | -70 | # Should handle multiple unions with multiple members -71 | field21: Literal[1, 2] | Literal[3, 4] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -72 | -73 | # Should emit in cases with `typing.Union` instead of `|` - | - -PYI030.pyi:74:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -73 | # Should emit in cases with `typing.Union` instead of `|` -74 | field22: typing.Union[Literal[1], Literal[2]] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -75 | -76 | # Should emit in cases with `typing_extensions.Literal` - | - -PYI030.pyi:77:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -76 | # Should emit in cases with `typing_extensions.Literal` -77 | field23: typing_extensions.Literal[1] | typing_extensions.Literal[2] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -78 | -79 | # Should emit in cases with nested `typing.Union` - | - -PYI030.pyi:80:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -79 | # Should emit in cases with nested `typing.Union` -80 | field24: typing.Union[Literal[1], typing.Union[Literal[2], str]] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -81 | -82 | # Should emit in cases with mixed `typing.Union` and `|` - | - -PYI030.pyi:83:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` - | -82 | # Should emit in cases with mixed `typing.Union` and `|` -83 | field25: typing.Union[Literal[1], Literal[2] | str] # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 -84 | -85 | # Should emit only once in cases with multiple nested `typing.Union` - | - -PYI030.pyi:86:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` - | -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 - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI032_PYI032.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI032_PYI032.py.snap deleted file mode 100644 index ddf2b4d458..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI032_PYI032.py.snap +++ /dev/null @@ -1,42 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI032.py:6:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to `__eq__` - | -5 | class Bad: -6 | def __eq__(self, other: Any) -> bool: ... # Y032 - | ^^^ PYI032 -7 | def __ne__(self, other: typing.Any) -> typing.Any: ... # Y032 - | - = help: Replace with `object` - -ℹ Fix -3 3 | -4 4 | -5 5 | class Bad: -6 |- def __eq__(self, other: Any) -> bool: ... # Y032 - 6 |+ def __eq__(self, other: object) -> bool: ... # Y032 -7 7 | def __ne__(self, other: typing.Any) -> typing.Any: ... # Y032 -8 8 | -9 9 | - -PYI032.py:7:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to `__ne__` - | -5 | class Bad: -6 | def __eq__(self, other: Any) -> bool: ... # Y032 -7 | def __ne__(self, other: typing.Any) -> typing.Any: ... # Y032 - | ^^^^^^^^^^ PYI032 - | - = help: Replace with `object` - -ℹ Fix -4 4 | -5 5 | class Bad: -6 6 | def __eq__(self, other: Any) -> bool: ... # Y032 -7 |- def __ne__(self, other: typing.Any) -> typing.Any: ... # Y032 - 7 |+ def __ne__(self, other: object) -> typing.Any: ... # Y032 -8 8 | -9 9 | -10 10 | class Good: - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI032_PYI032.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI032_PYI032.pyi.snap deleted file mode 100644 index 13bbbbe608..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI032_PYI032.pyi.snap +++ /dev/null @@ -1,42 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI032.pyi:6:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to `__eq__` - | -5 | class Bad: -6 | def __eq__(self, other: Any) -> bool: ... # Y032 - | ^^^ PYI032 -7 | def __ne__(self, other: typing.Any) -> typing.Any: ... # Y032 - | - = help: Replace with `object` - -ℹ Fix -3 3 | -4 4 | -5 5 | class Bad: -6 |- def __eq__(self, other: Any) -> bool: ... # Y032 - 6 |+ def __eq__(self, other: object) -> bool: ... # Y032 -7 7 | def __ne__(self, other: typing.Any) -> typing.Any: ... # Y032 -8 8 | -9 9 | - -PYI032.pyi:7:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to `__ne__` - | -5 | class Bad: -6 | def __eq__(self, other: Any) -> bool: ... # Y032 -7 | def __ne__(self, other: typing.Any) -> typing.Any: ... # Y032 - | ^^^^^^^^^^ PYI032 - | - = help: Replace with `object` - -ℹ Fix -4 4 | -5 5 | class Bad: -6 6 | def __eq__(self, other: Any) -> bool: ... # Y032 -7 |- def __ne__(self, other: typing.Any) -> typing.Any: ... # Y032 - 7 |+ def __ne__(self, other: object) -> typing.Any: ... # Y032 -8 8 | -9 9 | -10 10 | class Good: - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI033_PYI033.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI033_PYI033.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI033_PYI033.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI033_PYI033.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI033_PYI033.pyi.snap deleted file mode 100644 index e273f8a9fa..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI033_PYI033.pyi.snap +++ /dev/null @@ -1,106 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -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") - | - -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") - | - -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") - | - -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") - | - -PYI033.pyi:10:20: PYI033 Don't use type comments in stub file - | - 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") -10 | E: TypeAlias = None# type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 -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.pyi:11:20: PYI033 Don't use type comments in stub file - | - 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") -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 | -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 | ): ... - | - -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 | ): ... - | - -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 - | - -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 | -31 | class Bar: - | - -PYI033.pyi:32:26: PYI033 Don't use type comments in stub file - | -31 | class Bar: -32 | N: TypeAlias = None # type: can't parse me either! - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 -33 | # This whole line is commented out and indented # type: str - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI034_PYI034.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI034_PYI034.py.snap deleted file mode 100644 index a1f33f746f..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI034_PYI034.py.snap +++ /dev/null @@ -1,92 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI034.py:19:9: PYI034 `__new__` methods in classes like `Bad` usually return `self` at runtime - | -17 | object -18 | ): # Y040 Do not inherit from "object" explicitly, as it is redundant in Python 3 -19 | def __new__(cls, *args: Any, **kwargs: Any) -> Bad: - | ^^^^^^^ PYI034 -20 | ... # 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: ..." - | - = help: Consider using `typing_extensions.Self` as return type - -PYI034.py:34:9: PYI034 `__enter__` methods in classes like `Bad` usually return `self` at runtime - | -32 | ... # Y032 Prefer "object" to "Any" for the second parameter in "__ne__" methods -33 | -34 | def __enter__(self) -> Bad: - | ^^^^^^^^^ PYI034 -35 | ... # 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: ..." - | - = help: Consider using `typing_extensions.Self` as return type - -PYI034.py:37:15: PYI034 `__aenter__` methods in classes like `Bad` usually return `self` at runtime - | -35 | ... # 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: ..." -36 | -37 | async def __aenter__(self) -> Bad: - | ^^^^^^^^^^ PYI034 -38 | ... # 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: ..." - | - = help: Consider using `typing_extensions.Self` as return type - -PYI034.py:40:9: PYI034 `__iadd__` methods in classes like `Bad` usually return `self` at runtime - | -38 | ... # 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: ..." -39 | -40 | def __iadd__(self, other: Bad) -> Bad: - | ^^^^^^^^ PYI034 -41 | ... # 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: ..." - | - = help: Consider using `typing_extensions.Self` as return type - -PYI034.py:163:9: PYI034 `__iter__` methods in classes like `BadIterator1` usually return `self` at runtime - | -162 | class BadIterator1(Iterator[int]): -163 | def __iter__(self) -> Iterator[int]: - | ^^^^^^^^ PYI034 -164 | ... # 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: ..." - | - = help: Consider using `typing_extensions.Self` as return type - -PYI034.py:170:9: PYI034 `__iter__` methods in classes like `BadIterator2` usually return `self` at runtime - | -168 | typing.Iterator[int] -169 | ): # Y022 Use "collections.abc.Iterator[T]" instead of "typing.Iterator[T]" (PEP 585 syntax) -170 | def __iter__(self) -> Iterator[int]: - | ^^^^^^^^ PYI034 -171 | ... # 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: ..." - | - = help: Consider using `typing_extensions.Self` as return type - -PYI034.py:177:9: PYI034 `__iter__` methods in classes like `BadIterator3` usually return `self` at runtime - | -175 | typing.Iterator[int] -176 | ): # Y022 Use "collections.abc.Iterator[T]" instead of "typing.Iterator[T]" (PEP 585 syntax) -177 | def __iter__(self) -> collections.abc.Iterator[int]: - | ^^^^^^^^ PYI034 -178 | ... # 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: ..." - | - = help: Consider using `typing_extensions.Self` as return type - -PYI034.py:183:9: PYI034 `__iter__` methods in classes like `BadIterator4` usually return `self` at runtime - | -181 | class BadIterator4(Iterator[int]): -182 | # Note: *Iterable*, not *Iterator*, returned! -183 | def __iter__(self) -> Iterable[int]: - | ^^^^^^^^ PYI034 -184 | ... # 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: ..." - | - = help: Consider using `typing_extensions.Self` as return type - -PYI034.py:193:9: PYI034 `__aiter__` methods in classes like `BadAsyncIterator` usually return `self` at runtime - | -192 | class BadAsyncIterator(collections.abc.AsyncIterator[str]): -193 | def __aiter__(self) -> typing.AsyncIterator[str]: - | ^^^^^^^^^ PYI034 -194 | ... # 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) - | - = help: Consider using `typing_extensions.Self` as return type - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI034_PYI034.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI034_PYI034.pyi.snap deleted file mode 100644 index b06464af68..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI034_PYI034.pyi.snap +++ /dev/null @@ -1,101 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI034.pyi:18:9: PYI034 `__new__` methods in classes like `Bad` usually return `self` at runtime - | -16 | object -17 | ): # Y040 Do not inherit from "object" explicitly, as it is redundant in Python 3 -18 | def __new__( - | ^^^^^^^ PYI034 -19 | cls, *args: Any, **kwargs: Any -20 | ) -> 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: ..." - | - = help: Consider using `typing_extensions.Self` as return type - -PYI034.pyi:33:9: PYI034 `__enter__` methods in classes like `Bad` usually return `self` at runtime - | -31 | self, other: typing.Any -32 | ) -> typing.Any: ... # Y032 Prefer "object" to "Any" for the second parameter in "__ne__" methods -33 | def __enter__( - | ^^^^^^^^^ PYI034 -34 | self, -35 | ) -> 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: ..." - | - = help: Consider using `typing_extensions.Self` as return type - -PYI034.pyi:36:15: PYI034 `__aenter__` methods in classes like `Bad` usually return `self` at runtime - | -34 | self, -35 | ) -> 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: ..." -36 | async def __aenter__( - | ^^^^^^^^^^ PYI034 -37 | self, -38 | ) -> 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: ..." - | - = help: Consider using `typing_extensions.Self` as return type - -PYI034.pyi:39:9: PYI034 `__iadd__` methods in classes like `Bad` usually return `self` at runtime - | -37 | self, -38 | ) -> 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: ..." -39 | def __iadd__( - | ^^^^^^^^ PYI034 -40 | self, other: Bad -41 | ) -> 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: ..." - | - = help: Consider using `typing_extensions.Self` as return type - -PYI034.pyi:102:9: PYI034 `__iter__` methods in classes like `BadIterator1` usually return `self` at runtime - | -101 | class BadIterator1(Iterator[int]): -102 | def __iter__( - | ^^^^^^^^ PYI034 -103 | self, -104 | ) -> Iterator[ - | - = help: Consider using `typing_extensions.Self` as return type - -PYI034.pyi:111:9: PYI034 `__iter__` methods in classes like `BadIterator2` usually return `self` at runtime - | -109 | typing.Iterator[int] -110 | ): # Y022 Use "collections.abc.Iterator[T]" instead of "typing.Iterator[T]" (PEP 585 syntax) -111 | def __iter__( - | ^^^^^^^^ PYI034 -112 | self, -113 | ) -> Iterator[ - | - = help: Consider using `typing_extensions.Self` as return type - -PYI034.pyi:120:9: PYI034 `__iter__` methods in classes like `BadIterator3` usually return `self` at runtime - | -118 | typing.Iterator[int] -119 | ): # Y022 Use "collections.abc.Iterator[T]" instead of "typing.Iterator[T]" (PEP 585 syntax) -120 | def __iter__( - | ^^^^^^^^ PYI034 -121 | self, -122 | ) -> collections.abc.Iterator[ - | - = help: Consider using `typing_extensions.Self` as return type - -PYI034.pyi:128:9: PYI034 `__iter__` methods in classes like `BadIterator4` usually return `self` at runtime - | -126 | class BadIterator4(Iterator[int]): -127 | # Note: *Iterable*, not *Iterator*, returned! -128 | def __iter__( - | ^^^^^^^^ PYI034 -129 | self, -130 | ) -> Iterable[ - | - = help: Consider using `typing_extensions.Self` as return type - -PYI034.pyi:142:9: PYI034 `__aiter__` methods in classes like `BadAsyncIterator` usually return `self` at runtime - | -141 | class BadAsyncIterator(collections.abc.AsyncIterator[str]): -142 | def __aiter__( - | ^^^^^^^^^ PYI034 -143 | self, -144 | ) -> typing.AsyncIterator[ - | - = help: Consider using `typing_extensions.Self` as return type - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI035_PYI035.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI035_PYI035.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI035_PYI035.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI035_PYI035.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI035_PYI035.pyi.snap deleted file mode 100644 index 1129019f57..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI035_PYI035.pyi.snap +++ /dev/null @@ -1,31 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -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 | -3 | __all__: list[str] = ["foo"] - | - -PYI035.pyi:7:5: PYI035 `__match_args__` in a stub file must have a value, as it has the same semantics as `__match_args__` at runtime - | -5 | class Foo: -6 | __all__: list[str] -7 | __match_args__: tuple[str, ...] # Error: PYI035 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI035 -8 | __slots__: tuple[str, ...] # Error: PYI035 - | - -PYI035.pyi:8:5: PYI035 `__slots__` in a stub file must have a value, as it has the same semantics as `__slots__` at runtime - | - 6 | __all__: list[str] - 7 | __match_args__: tuple[str, ...] # Error: PYI035 - 8 | __slots__: tuple[str, ...] # Error: PYI035 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI035 - 9 | -10 | class Bar: - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI036_PYI036.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI036_PYI036.py.snap deleted file mode 100644 index e4a422090f..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI036_PYI036.py.snap +++ /dev/null @@ -1,161 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI036.py:54:31: PYI036 [*] Star-args in `__exit__` should be annotated with `object` - | -53 | class BadOne: -54 | def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation - | ^^^ PYI036 -55 | async def __aexit__(self) -> None: ... # PYI036: Missing args - | - = help: Annotate star-args with `object` - -ℹ Fix -51 51 | -52 52 | -53 53 | class BadOne: -54 |- def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation - 54 |+ def __exit__(self, *args: object) -> None: ... # PYI036: Bad star-args annotation -55 55 | async def __aexit__(self) -> None: ... # PYI036: Missing args -56 56 | -57 57 | class BadTwo: - -PYI036.py:55:24: PYI036 If there are no star-args, `__aexit__` should have at least 3 non-keyword-only args (excluding `self`) - | -53 | class BadOne: -54 | def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation -55 | async def __aexit__(self) -> None: ... # PYI036: Missing args - | ^^^^^^ PYI036 -56 | -57 | class BadTwo: - | - -PYI036.py:58:38: PYI036 All arguments after the first four in `__exit__` must have a default value - | -57 | class BadTwo: -58 | def __exit__(self, typ, exc, tb, weird_extra_arg) -> None: ... # PYI036: Extra arg must have default - | ^^^^^^^^^^^^^^^ PYI036 -59 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg) -> None: ...# PYI036: Extra arg must have default - | - -PYI036.py:59:48: PYI036 All keyword-only arguments in `__aexit__` must have a default value - | -57 | class BadTwo: -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 | -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 - | ^^^^^^^^^^^^^^^^^^^ PYI036 -63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI036: Second arg has bad annotation - | - -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 - | ^^^^^^^^^^^^^ PYI036 -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 - | ^^^^^^^^^^^^^ PYI036 -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 - | - -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: - | - -PYI036.py:70:29: PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` - | -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 - | - -PYI036.py:70:58: PYI036 [*] Star-args in `__exit__` should be annotated with `object` - | -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 - | - = help: Annotate star-args with `object` - -ℹ Fix -67 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 -68 68 | -69 69 | class BadFive: -70 |- def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation - 70 |+ def __exit__(self, typ: BaseException | None, *args: object) -> bool: ... # PYI036: Bad star-args annotation -71 71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotation -72 72 | -73 73 | class BadSix: - -PYI036.py:71:74: PYI036 [*] Star-args in `__aexit__` should be annotated with `object` - | -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 - | ^^^ PYI036 -72 | -73 | class BadSix: - | - = help: Annotate star-args with `object` - -ℹ Fix -68 68 | -69 69 | class BadFive: -70 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: object) -> Awaitable[None]: ... # PYI036: Bad star-args annotation -72 72 | -73 73 | class BadSix: -74 74 | def __exit__(self, typ, exc, tb, weird_extra_arg, extra_arg2 = None) -> None: ... # PYI036: Extra arg must have default - -PYI036.py:74:38: PYI036 All arguments after the first four in `__exit__` must have a default value - | -73 | class BadSix: -74 | def __exit__(self, typ, exc, tb, weird_extra_arg, extra_arg2 = None) -> None: ... # PYI036: Extra arg must have default - | ^^^^^^^^^^^^^^^ PYI036 -75 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg) -> None: ... # PYI036: kwargs must have default - | - -PYI036.py:75:48: PYI036 All keyword-only arguments in `__aexit__` must have a default value - | -73 | class BadSix: -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 - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI036_PYI036.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI036_PYI036.pyi.snap deleted file mode 100644 index 2c3a0dc7b6..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI036_PYI036.pyi.snap +++ /dev/null @@ -1,171 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI036.pyi:54:31: PYI036 [*] Star-args in `__exit__` should be annotated with `object` - | -53 | class BadOne: -54 | def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation - | ^^^ PYI036 -55 | async def __aexit__(self) -> None: ... # PYI036: Missing args - | - = help: Annotate star-args with `object` - -ℹ Fix -51 51 | -52 52 | -53 53 | class BadOne: -54 |- def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation - 54 |+ def __exit__(self, *args: object) -> None: ... # PYI036: Bad star-args annotation -55 55 | async def __aexit__(self) -> None: ... # PYI036: Missing args -56 56 | -57 57 | class BadTwo: - -PYI036.pyi:55:24: PYI036 If there are no star-args, `__aexit__` should have at least 3 non-keyword-only args (excluding `self`) - | -53 | class BadOne: -54 | def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation -55 | async def __aexit__(self) -> None: ... # PYI036: Missing args - | ^^^^^^ PYI036 -56 | -57 | class BadTwo: - | - -PYI036.pyi:58:38: PYI036 All arguments after the first four in `__exit__` must have a default value - | -57 | class BadTwo: -58 | def __exit__(self, typ, exc, tb, weird_extra_arg) -> None: ... # PYI036: Extra arg must have default - | ^^^^^^^^^^^^^^^ PYI036 -59 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg1, weird_extra_arg2) -> None: ...# PYI036: kwargs must have default - | - -PYI036.pyi:59:48: PYI036 All keyword-only arguments in `__aexit__` must have a default value - | -57 | class BadTwo: -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 | -61 | class BadThree: - | - -PYI036.pyi:59:66: PYI036 All keyword-only arguments in `__aexit__` must have a default value - | -57 | class BadTwo: -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 | -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 - | ^^^^^^^^^^^^^^^^^^^ PYI036 -63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI036: Second arg has bad annotation - | - -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 - | ^^^^^^^^^^^^^ PYI036 -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 - | ^^^^^^^^^^^^^ PYI036 -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 - | - -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: - | - -PYI036.pyi:70:29: PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` - | -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 - | - -PYI036.pyi:70:58: PYI036 [*] Star-args in `__exit__` should be annotated with `object` - | -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 - | - = help: Annotate star-args with `object` - -ℹ Fix -67 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 -68 68 | -69 69 | class BadFive: -70 |- def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation - 70 |+ def __exit__(self, typ: BaseException | None, *args: object) -> bool: ... # PYI036: Bad star-args annotation -71 71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotation -72 72 | -73 73 | class BadSix: - -PYI036.pyi:71:74: PYI036 [*] Star-args in `__aexit__` should be annotated with `object` - | -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 - | ^^^ PYI036 -72 | -73 | class BadSix: - | - = help: Annotate star-args with `object` - -ℹ Fix -68 68 | -69 69 | class BadFive: -70 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: object) -> Awaitable[None]: ... # PYI036: Bad star-args annotation -72 72 | -73 73 | class BadSix: -74 74 | def __exit__(self, typ, exc, tb, weird_extra_arg, extra_arg2 = None) -> None: ... # PYI036: Extra arg must have default - -PYI036.pyi:74:38: PYI036 All arguments after the first four in `__exit__` must have a default value - | -73 | class BadSix: -74 | def __exit__(self, typ, exc, tb, weird_extra_arg, extra_arg2 = None) -> None: ... # PYI036: Extra arg must have default - | ^^^^^^^^^^^^^^^ PYI036 -75 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg) -> None: ... # PYI036: kwargs must have default - | - -PYI036.pyi:75:48: PYI036 All keyword-only arguments in `__aexit__` must have a default value - | -73 | class BadSix: -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 - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI041_PYI041.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI041_PYI041.py.snap deleted file mode 100644 index de8a65f4b9..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI041_PYI041.py.snap +++ /dev/null @@ -1,50 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI041.py:22:14: PYI041 Use `float` instead of `int | float` - | -22 | def f0(arg1: float | int) -> None: - | ^^^^^^^^^^^ PYI041 -23 | ... - | - -PYI041.py:26:30: PYI041 Use `complex` instead of `float | complex` - | -26 | def f1(arg1: float, *, arg2: float | list[str] | type[bool] | complex) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 -27 | ... - | - -PYI041.py:30:28: PYI041 Use `float` instead of `int | float` - | -30 | def f2(arg1: int, /, arg2: int | int | float) -> None: - | ^^^^^^^^^^^^^^^^^ PYI041 -31 | ... - | - -PYI041.py:38:24: PYI041 Use `float` instead of `int | float` - | -38 | async def f4(**kwargs: int | int | float) -> None: - | ^^^^^^^^^^^^^^^^^ PYI041 -39 | ... - | - -PYI041.py:46:24: PYI041 Use `complex` instead of `float | complex` - | -44 | ... -45 | -46 | def bad(self, arg: int | float | complex) -> None: - | ^^^^^^^^^^^^^^^^^^^^^ PYI041 -47 | ... - | - -PYI041.py:46:24: PYI041 Use `complex` instead of `int | complex` - | -44 | ... -45 | -46 | def bad(self, arg: int | float | complex) -> None: - | ^^^^^^^^^^^^^^^^^^^^^ PYI041 -47 | ... - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI041_PYI041.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI041_PYI041.pyi.snap deleted file mode 100644 index f89a27a632..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI041_PYI041.pyi.snap +++ /dev/null @@ -1,44 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI041.pyi:21:14: PYI041 Use `float` instead of `int | float` - | -21 | def f0(arg1: float | int) -> None: ... # PYI041 - | ^^^^^^^^^^^ PYI041 - | - -PYI041.pyi:24:30: PYI041 Use `complex` instead of `float | complex` - | -24 | def f1(arg1: float, *, arg2: float | list[str] | type[bool] | complex) -> None: ... # PYI041 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 - | - -PYI041.pyi:27:28: PYI041 Use `float` instead of `int | float` - | -27 | def f2(arg1: int, /, arg2: int | int | float) -> None: ... # PYI041 - | ^^^^^^^^^^^^^^^^^ PYI041 - | - -PYI041.pyi:33:24: PYI041 Use `float` instead of `int | float` - | -33 | async def f4(**kwargs: int | int | float) -> None: ... # PYI041 - | ^^^^^^^^^^^^^^^^^ PYI041 - | - -PYI041.pyi:39:24: PYI041 Use `complex` instead of `float | complex` - | -37 | def good(self, arg: int) -> None: ... -38 | -39 | def bad(self, arg: int | float | complex) -> None: ... # PYI041 - | ^^^^^^^^^^^^^^^^^^^^^ PYI041 - | - -PYI041.pyi:39:24: PYI041 Use `complex` instead of `int | complex` - | -37 | def good(self, arg: int) -> None: ... -38 | -39 | def bad(self, arg: int | float | complex) -> None: ... # PYI041 - | ^^^^^^^^^^^^^^^^^^^^^ PYI041 - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI042_PYI042.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI042_PYI042.py.snap deleted file mode 100644 index e71725b775..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI042_PYI042.py.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI042.py:10:1: PYI042 Type alias `just_literals_pipe_union` should be CamelCase - | - 8 | ) - 9 | -10 | just_literals_pipe_union: TypeAlias = ( - | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI042 -11 | Literal[True] | Literal["idk"] -12 | ) # PYI042, since not camel case - | - -PYI042.py:19:1: PYI042 Type alias `snake_case_alias1` should be CamelCase - | -17 | _PrivateAliasS2: TypeAlias = Annotated[str, "also okay"] -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 -21 | Snake_case_alias: TypeAlias = int | float # PYI042, since not camel case - | - -PYI042.py:20:1: PYI042 Type alias `_snake_case_alias2` should be CamelCase - | -19 | snake_case_alias1: TypeAlias = str | int # PYI042, since not camel case -20 | _snake_case_alias2: TypeAlias = Literal["whatever"] # PYI042, since not camel case - | ^^^^^^^^^^^^^^^^^^ PYI042 -21 | Snake_case_alias: TypeAlias = int | float # PYI042, since not camel case - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI042_PYI042.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI042_PYI042.pyi.snap deleted file mode 100644 index e12793db7d..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI042_PYI042.pyi.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI042.pyi:10:1: PYI042 Type alias `just_literals_pipe_union` should be CamelCase - | - 8 | ) - 9 | -10 | just_literals_pipe_union: TypeAlias = ( - | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI042 -11 | Literal[True] | Literal["idk"] -12 | ) # PYI042, since not camel case - | - -PYI042.pyi:19:1: PYI042 Type alias `snake_case_alias1` should be CamelCase - | -17 | _PrivateAliasS2: TypeAlias = Annotated[str, "also okay"] -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 -21 | Snake_case_alias: TypeAlias = int | float # PYI042, since not camel case - | - -PYI042.pyi:20:1: PYI042 Type alias `_snake_case_alias2` should be CamelCase - | -19 | snake_case_alias1: TypeAlias = str | int # PYI042, since not camel case -20 | _snake_case_alias2: TypeAlias = Literal["whatever"] # PYI042, since not camel case - | ^^^^^^^^^^^^^^^^^^ PYI042 -21 | Snake_case_alias: TypeAlias = int | float # PYI042, since not camel case - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI043_PYI043.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI043_PYI043.py.snap deleted file mode 100644 index 84453cd4e7..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI043_PYI043.py.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -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 | -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 -12 | _PrivateAliasT3: TypeAlias = Literal[ - | - -PYI043.py:11:1: PYI043 Private type alias `_PrivateAliasT2` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) - | -10 | _PrivateAliasT: TypeAlias = str | int # PYI043, since this ends in a T -11 | _PrivateAliasT2: TypeAlias = typing.Any # PYI043, since this ends in a T - | ^^^^^^^^^^^^^^^ PYI043 -12 | _PrivateAliasT3: TypeAlias = Literal[ -13 | "not", "a", "chance" - | - -PYI043.py:12:1: PYI043 Private type alias `_PrivateAliasT3` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) - | -10 | _PrivateAliasT: TypeAlias = str | int # PYI043, since this ends in a T -11 | _PrivateAliasT2: TypeAlias = typing.Any # PYI043, since this ends in a T -12 | _PrivateAliasT3: TypeAlias = Literal[ - | ^^^^^^^^^^^^^^^ PYI043 -13 | "not", "a", "chance" -14 | ] # PYI043, since this ends in a T - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI043_PYI043.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI043_PYI043.pyi.snap deleted file mode 100644 index 65936531ad..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI043_PYI043.pyi.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -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 | -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 -12 | _PrivateAliasT3: TypeAlias = Literal[ - | - -PYI043.pyi:11:1: PYI043 Private type alias `_PrivateAliasT2` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) - | -10 | _PrivateAliasT: TypeAlias = str | int # PYI043, since this ends in a T -11 | _PrivateAliasT2: TypeAlias = typing.Any # PYI043, since this ends in a T - | ^^^^^^^^^^^^^^^ PYI043 -12 | _PrivateAliasT3: TypeAlias = Literal[ -13 | "not", "a", "chance" - | - -PYI043.pyi:12:1: PYI043 Private type alias `_PrivateAliasT3` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) - | -10 | _PrivateAliasT: TypeAlias = str | int # PYI043, since this ends in a T -11 | _PrivateAliasT2: TypeAlias = typing.Any # PYI043, since this ends in a T -12 | _PrivateAliasT3: TypeAlias = Literal[ - | ^^^^^^^^^^^^^^^ PYI043 -13 | "not", "a", "chance" -14 | ] # PYI043, since this ends in a T - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI044_PYI044.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI044_PYI044.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI044_PYI044.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI044_PYI044.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI044_PYI044.pyi.snap deleted file mode 100644 index 5e52d03969..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI044_PYI044.pyi.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -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 - | -1 | # Bad import. -2 | from __future__ import annotations # PYI044. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI044 -3 | -4 | # Good imports. - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI045_PYI045.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI045_PYI045.py.snap deleted file mode 100644 index cb8af8e42a..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI045_PYI045.py.snap +++ /dev/null @@ -1,60 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI045.py:12:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` - | -11 | class TypingIterableTReturn: -12 | def __iter__(self) -> typing.Iterable[int]: - | ^^^^^^^^^^^^^^^^^^^^ PYI045 -13 | ... - | - -PYI045.py:20:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` - | -19 | class TypingIterableReturn: -20 | def __iter__(self) -> typing.Iterable: - | ^^^^^^^^^^^^^^^ PYI045 -21 | ... - | - -PYI045.py:28:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` - | -27 | class CollectionsIterableTReturn: -28 | def __iter__(self) -> collections.abc.Iterable[int]: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI045 -29 | ... - | - -PYI045.py:36:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` - | -35 | class CollectionsIterableReturn: -36 | def __iter__(self) -> collections.abc.Iterable: - | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI045 -37 | ... - | - -PYI045.py:44:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` - | -43 | class IterableReturn: -44 | def __iter__(self) -> Iterable: - | ^^^^^^^^ PYI045 -45 | ... - | - -PYI045.py:79:28: PYI045 `__aiter__` methods should return an `AsyncIterator`, not an `AsyncIterable` - | -78 | class TypingAsyncIterableTReturn: -79 | def __aiter__(self) -> typing.AsyncIterable[int]: - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI045 -80 | ... - | - -PYI045.py:84:28: PYI045 `__aiter__` methods should return an `AsyncIterator`, not an `AsyncIterable` - | -83 | class TypingAsyncIterableReturn: -84 | def __aiter__(self) -> typing.AsyncIterable: - | ^^^^^^^^^^^^^^^^^^^^ PYI045 -85 | ... - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI045_PYI045.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI045_PYI045.pyi.snap deleted file mode 100644 index 06a39dc587..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI045_PYI045.pyi.snap +++ /dev/null @@ -1,61 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI045.pyi:9:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` - | - 8 | class TypingIterableTReturn: - 9 | def __iter__(self) -> typing.Iterable[int]: ... # Error: PYI045 - | ^^^^^^^^^^^^^^^^^^^^ PYI045 -10 | def not_iter(self) -> typing.Iterable[int]: ... - | - -PYI045.pyi:13:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` - | -12 | class TypingIterableReturn: -13 | def __iter__(self) -> typing.Iterable: ... # Error: PYI045 - | ^^^^^^^^^^^^^^^ PYI045 -14 | def not_iter(self) -> typing.Iterable: ... - | - -PYI045.pyi:17:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` - | -16 | class CollectionsIterableTReturn: -17 | def __iter__(self) -> collections.abc.Iterable[int]: ... # Error: PYI045 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI045 -18 | def not_iter(self) -> collections.abc.Iterable[int]: ... - | - -PYI045.pyi:21:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` - | -20 | class CollectionsIterableReturn: -21 | def __iter__(self) -> collections.abc.Iterable: ... # Error: PYI045 - | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI045 -22 | def not_iter(self) -> collections.abc.Iterable: ... - | - -PYI045.pyi:25:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` - | -24 | class IterableReturn: -25 | def __iter__(self) -> Iterable: ... # Error: PYI045 - | ^^^^^^^^ PYI045 -26 | -27 | class IteratorReturn: - | - -PYI045.pyi:46:28: PYI045 `__aiter__` methods should return an `AsyncIterator`, not an `AsyncIterable` - | -45 | class TypingAsyncIterableTReturn: -46 | def __aiter__(self) -> typing.AsyncIterable[int]: ... # Error: PYI045 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI045 -47 | -48 | class TypingAsyncIterableReturn: - | - -PYI045.pyi:49:28: PYI045 `__aiter__` methods should return an `AsyncIterator`, not an `AsyncIterable` - | -48 | class TypingAsyncIterableReturn: -49 | def __aiter__(self) -> typing.AsyncIterable: ... # Error: PYI045 - | ^^^^^^^^^^^^^^^^^^^^ PYI045 - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI046_PYI046.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI046_PYI046.py.snap deleted file mode 100644 index 463704b900..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI046_PYI046.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI046.py:5:7: PYI046 Private protocol `_Foo` is never used - | -5 | class _Foo(Protocol): - | ^^^^ PYI046 -6 | bar: int - | - -PYI046.py:9:7: PYI046 Private protocol `_Bar` is never used - | - 9 | class _Bar(typing.Protocol): - | ^^^^ PYI046 -10 | bar: int - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI046_PYI046.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI046_PYI046.pyi.snap deleted file mode 100644 index e21a217bdf..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI046_PYI046.pyi.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI046.pyi:5:7: PYI046 Private protocol `_Foo` is never used - | -5 | class _Foo(object, Protocol): - | ^^^^ PYI046 -6 | bar: int - | - -PYI046.pyi:9:7: PYI046 Private protocol `_Bar` is never used - | - 9 | class _Bar(typing.Protocol): - | ^^^^ PYI046 -10 | bar: int - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI047_PYI047.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI047_PYI047.py.snap deleted file mode 100644 index ced54687f1..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI047_PYI047.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI047.py:6:1: PYI047 Private TypeAlias `_UnusedPrivateTypeAlias` is never used - | -6 | _UnusedPrivateTypeAlias: TypeAlias = int | None - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI047 -7 | _T: typing.TypeAlias = str - | - -PYI047.py:7:1: PYI047 Private TypeAlias `_T` is never used - | -6 | _UnusedPrivateTypeAlias: TypeAlias = int | None -7 | _T: typing.TypeAlias = str - | ^^ PYI047 -8 | -9 | # OK - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI047_PYI047.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI047_PYI047.pyi.snap deleted file mode 100644 index 2d1f0275d7..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI047_PYI047.pyi.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI047.pyi:6:1: PYI047 Private TypeAlias `_UnusedPrivateTypeAlias` is never used - | -6 | _UnusedPrivateTypeAlias: TypeAlias = int | None - | ^^^^^^^^^^^^^^^^^^^^^^^ PYI047 -7 | _T: typing.TypeAlias = str - | - -PYI047.pyi:7:1: PYI047 Private TypeAlias `_T` is never used - | -6 | _UnusedPrivateTypeAlias: TypeAlias = int | None -7 | _T: typing.TypeAlias = str - | ^^ PYI047 -8 | -9 | # OK - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI048_PYI048.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI048_PYI048.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI048_PYI048.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI048_PYI048.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI048_PYI048.pyi.snap deleted file mode 100644 index d897255d5d..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI048_PYI048.pyi.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI048.pyi:8:5: PYI048 Function body must contain exactly one statement - | - 6 | """oof""" # OK - 7 | - 8 | def oof(): # ERROR PYI048 - | ^^^ PYI048 - 9 | """oof""" -10 | print("foo") - | - -PYI048.pyi:12:5: PYI048 Function body must contain exactly one statement - | -10 | print("foo") -11 | -12 | def foo(): # ERROR PYI048 - | ^^^ PYI048 -13 | """foo""" -14 | print("foo") - | - -PYI048.pyi:17:5: PYI048 Function body must contain exactly one statement - | -15 | print("foo") -16 | -17 | def buzz(): # ERROR PYI048 - | ^^^^ PYI048 -18 | print("fizz") -19 | print("buzz") - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI049_PYI049.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI049_PYI049.py.snap deleted file mode 100644 index 46c42efa8c..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI049_PYI049.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI049.py:5:7: PYI049 Private TypedDict `_UnusedTypedDict` is never used - | -5 | class _UnusedTypedDict(TypedDict): - | ^^^^^^^^^^^^^^^^ PYI049 -6 | foo: str - | - -PYI049.py:9:7: PYI049 Private TypedDict `_UnusedTypedDict2` is never used - | - 9 | class _UnusedTypedDict2(typing.TypedDict): - | ^^^^^^^^^^^^^^^^^ PYI049 -10 | bar: int - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI049_PYI049.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI049_PYI049.pyi.snap deleted file mode 100644 index f07884832c..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI049_PYI049.pyi.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI049.pyi:6:7: PYI049 Private TypedDict `_UnusedTypedDict` is never used - | -6 | class _UnusedTypedDict(TypedDict): - | ^^^^^^^^^^^^^^^^ PYI049 -7 | foo: str - | - -PYI049.pyi:10:7: PYI049 Private TypedDict `_UnusedTypedDict2` is never used - | -10 | class _UnusedTypedDict2(typing.TypedDict): - | ^^^^^^^^^^^^^^^^^ PYI049 -11 | bar: int - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI050_PYI050.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI050_PYI050.py.snap deleted file mode 100644 index 492243cf19..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI050_PYI050.py.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI050.py:13:24: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations - | -13 | def foo_no_return(arg: NoReturn): - | ^^^^^^^^ PYI050 -14 | ... - | - -PYI050.py:23:44: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations - | -23 | def foo_no_return_kwarg(arg: int, *, arg2: NoReturn): - | ^^^^^^^^ PYI050 -24 | ... - | - -PYI050.py:27:47: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations - | -27 | def foo_no_return_pos_only(arg: int, /, arg2: NoReturn): - | ^^^^^^^^ PYI050 -28 | ... - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI050_PYI050.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI050_PYI050.pyi.snap deleted file mode 100644 index 2eafac7805..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI050_PYI050.pyi.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI050.pyi:6:24: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations - | -4 | def foo(arg): ... -5 | def foo_int(arg: int): ... -6 | def foo_no_return(arg: NoReturn): ... # Error: PYI050 - | ^^^^^^^^ PYI050 -7 | def foo_no_return_typing_extensions( -8 | arg: typing_extensions.NoReturn, - | - -PYI050.pyi:10:44: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations - | - 8 | arg: typing_extensions.NoReturn, - 9 | ): ... # Error: PYI050 -10 | def foo_no_return_kwarg(arg: int, *, arg2: NoReturn): ... # Error: PYI050 - | ^^^^^^^^ PYI050 -11 | def foo_no_return_pos_only(arg: int, /, arg2: NoReturn): ... # Error: PYI050 -12 | def foo_never(arg: Never): ... - | - -PYI050.pyi:11:47: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations - | - 9 | ): ... # Error: PYI050 -10 | def foo_no_return_kwarg(arg: int, *, arg2: NoReturn): ... # Error: PYI050 -11 | def foo_no_return_pos_only(arg: int, /, arg2: NoReturn): ... # Error: PYI050 - | ^^^^^^^^ PYI050 -12 | def foo_never(arg: Never): ... - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI051_PYI051.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI051_PYI051.py.snap deleted file mode 100644 index 3c6c91602c..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI051_PYI051.py.snap +++ /dev/null @@ -1,90 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI051.py:4:18: PYI051 `Literal["foo"]` is redundant in a union with `str` - | -2 | from typing import Literal, TypeAlias, Union -3 | -4 | A: str | Literal["foo"] - | ^^^^^ PYI051 -5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] -6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] - | - -PYI051.py:5:37: PYI051 `Literal[b"bar"]` is redundant in a union with `bytes` - | -4 | A: str | Literal["foo"] -5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] - | ^^^^^^ PYI051 -6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] -7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - | - -PYI051.py:5:45: PYI051 `Literal[b"foo"]` is redundant in a union with `bytes` - | -4 | A: str | Literal["foo"] -5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] - | ^^^^^^ PYI051 -6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] -7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - | - -PYI051.py:6:37: PYI051 `Literal[5]` is redundant in a union with `int` - | -4 | A: str | Literal["foo"] -5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] -6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] - | ^ PYI051 -7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - | - -PYI051.py:6:67: PYI051 `Literal["foo"]` is redundant in a union with `str` - | -4 | A: str | Literal["foo"] -5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] -6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] - | ^^^^^ PYI051 -7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - | - -PYI051.py:7:37: PYI051 `Literal[b"str_bytes"]` is redundant in a union with `bytes` - | -5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] -6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] -7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - | ^^^^^^^^^^^^ PYI051 -8 | -9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... - | - -PYI051.py:7:51: PYI051 `Literal[42]` is redundant in a union with `int` - | -5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] -6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] -7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - | ^^ PYI051 -8 | -9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... - | - -PYI051.py:9:31: PYI051 `Literal[1J]` is redundant in a union with `complex` - | - 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - 8 | - 9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... - | ^^ PYI051 -10 | -11 | # OK - | - -PYI051.py:9:53: PYI051 `Literal[3.14]` is redundant in a union with `float` - | - 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - 8 | - 9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... - | ^^^^ PYI051 -10 | -11 | # OK - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI051_PYI051.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI051_PYI051.pyi.snap deleted file mode 100644 index 14b0115513..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI051_PYI051.pyi.snap +++ /dev/null @@ -1,90 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI051.pyi:4:18: PYI051 `Literal["foo"]` is redundant in a union with `str` - | -2 | from typing import Literal, TypeAlias, Union -3 | -4 | A: str | Literal["foo"] - | ^^^^^ PYI051 -5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] -6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] - | - -PYI051.pyi:5:37: PYI051 `Literal[b"bar"]` is redundant in a union with `bytes` - | -4 | A: str | Literal["foo"] -5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] - | ^^^^^^ PYI051 -6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] -7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - | - -PYI051.pyi:5:45: PYI051 `Literal[b"foo"]` is redundant in a union with `bytes` - | -4 | A: str | Literal["foo"] -5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] - | ^^^^^^ PYI051 -6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] -7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - | - -PYI051.pyi:6:37: PYI051 `Literal[5]` is redundant in a union with `int` - | -4 | A: str | Literal["foo"] -5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] -6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] - | ^ PYI051 -7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - | - -PYI051.pyi:6:67: PYI051 `Literal["foo"]` is redundant in a union with `str` - | -4 | A: str | Literal["foo"] -5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] -6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] - | ^^^^^ PYI051 -7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - | - -PYI051.pyi:7:37: PYI051 `Literal[b"str_bytes"]` is redundant in a union with `bytes` - | -5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] -6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] -7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - | ^^^^^^^^^^^^ PYI051 -8 | -9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... - | - -PYI051.pyi:7:51: PYI051 `Literal[42]` is redundant in a union with `int` - | -5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] -6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] -7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - | ^^ PYI051 -8 | -9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... - | - -PYI051.pyi:9:31: PYI051 `Literal[1J]` is redundant in a union with `complex` - | - 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - 8 | - 9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... - | ^^ PYI051 -10 | -11 | # OK - | - -PYI051.pyi:9:53: PYI051 `Literal[3.14]` is redundant in a union with `float` - | - 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] - 8 | - 9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... - | ^^^^ PYI051 -10 | -11 | # OK - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI052_PYI052.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI052_PYI052.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI052_PYI052.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI052_PYI052.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI052_PYI052.pyi.snap deleted file mode 100644 index 47d55f1499..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI052_PYI052.pyi.snap +++ /dev/null @@ -1,134 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -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" - | ^ PYI052 -15 | field6 = 0 # Y052 Need type annotation for "field6" -16 | field7 = b"" # Y052 Need type annotation for "field7" - | - -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" -15 | field6 = 0 # Y052 Need type annotation for "field6" - | ^ PYI052 -16 | field7 = b"" # Y052 Need type annotation for "field7" -17 | field71 = "foo" # Y052 Need type annotation for "field71" - | - -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" -15 | field6 = 0 # Y052 Need type annotation for "field6" -16 | field7 = b"" # Y052 Need type annotation for "field7" - | ^^^ PYI052 -17 | field71 = "foo" # Y052 Need type annotation for "field71" -18 | field72: str = "foo" - | - -PYI052.pyi:17:11: PYI052 Need type annotation for `field71` - | -15 | field6 = 0 # Y052 Need type annotation for "field6" -16 | field7 = b"" # Y052 Need type annotation for "field7" -17 | field71 = "foo" # Y052 Need type annotation for "field71" - | ^^^^^ PYI052 -18 | field72: str = "foo" -19 | field8 = False # Y052 Need type annotation for "field8" - | - -PYI052.pyi:19:10: PYI052 Need type annotation for `field8` - | -17 | field71 = "foo" # Y052 Need type annotation for "field71" -18 | field72: str = "foo" -19 | field8 = False # Y052 Need type annotation for "field8" - | ^^^^^ PYI052 -20 | field81 = -1 # Y052 Need type annotation for "field81" -21 | field82: float = -98.43 - | - -PYI052.pyi:20:11: PYI052 Need type annotation for `field81` - | -18 | field72: str = "foo" -19 | field8 = False # Y052 Need type annotation for "field8" -20 | field81 = -1 # Y052 Need type annotation for "field81" - | ^^ PYI052 -21 | field82: float = -98.43 -22 | field83 = -42j # Y052 Need type annotation for "field83" - | - -PYI052.pyi:22:11: PYI052 Need type annotation for `field83` - | -20 | field81 = -1 # Y052 Need type annotation for "field81" -21 | field82: float = -98.43 -22 | field83 = -42j # Y052 Need type annotation for "field83" - | ^^^^ PYI052 -23 | field84 = 5 + 42j # Y052 Need type annotation for "field84" -24 | field85 = -5 - 42j # Y052 Need type annotation for "field85" - | - -PYI052.pyi:23:11: PYI052 Need type annotation for `field84` - | -21 | field82: float = -98.43 -22 | field83 = -42j # Y052 Need type annotation for "field83" -23 | field84 = 5 + 42j # Y052 Need type annotation for "field84" - | ^^^^^^^ PYI052 -24 | field85 = -5 - 42j # Y052 Need type annotation for "field85" -25 | field9 = None # Y026 Use typing_extensions.TypeAlias for type aliases, e.g. "field9: TypeAlias = None" - | - -PYI052.pyi:24:11: PYI052 Need type annotation for `field85` - | -22 | field83 = -42j # Y052 Need type annotation for "field83" -23 | field84 = 5 + 42j # Y052 Need type annotation for "field84" -24 | field85 = -5 - 42j # Y052 Need type annotation for "field85" - | ^^^^^^^^ PYI052 -25 | field9 = None # Y026 Use typing_extensions.TypeAlias for type aliases, e.g. "field9: TypeAlias = None" -26 | Field95: TypeAlias = None - | - -PYI052.pyi:33:11: PYI052 Need type annotation for `field19` - | -31 | Field100 = TypeVarTuple('Field100') -32 | Field101 = ParamSpec('Field101') -33 | field19 = [1, 2, 3] # Y052 Need type annotation for "field19" - | ^^^^^^^^^ PYI052 -34 | field191: list[int] = [1, 2, 3] -35 | field20 = (1, 2, 3) # Y052 Need type annotation for "field20" - | - -PYI052.pyi:35:11: PYI052 Need type annotation for `field20` - | -33 | field19 = [1, 2, 3] # Y052 Need type annotation for "field19" -34 | field191: list[int] = [1, 2, 3] -35 | field20 = (1, 2, 3) # Y052 Need type annotation for "field20" - | ^^^^^^^^^ PYI052 -36 | field201: tuple[int, ...] = (1, 2, 3) -37 | field21 = {1, 2, 3} # Y052 Need type annotation for "field21" - | - -PYI052.pyi:37:11: PYI052 Need type annotation for `field21` - | -35 | field20 = (1, 2, 3) # Y052 Need type annotation for "field20" -36 | field201: tuple[int, ...] = (1, 2, 3) -37 | field21 = {1, 2, 3} # Y052 Need type annotation for "field21" - | ^^^^^^^^^ PYI052 -38 | field211: set[int] = {1, 2, 3} -39 | field212 = {"foo": "bar"} # Y052 Need type annotation for "field212" - | - -PYI052.pyi:39:12: PYI052 Need type annotation for `field212` - | -37 | field21 = {1, 2, 3} # Y052 Need type annotation for "field21" -38 | field211: set[int] = {1, 2, 3} -39 | field212 = {"foo": "bar"} # Y052 Need type annotation for "field212" - | ^^^^^^^^^^^^^^ PYI052 -40 | field213: dict[str, str] = {"foo": "bar"} -41 | field22: Final = {"foo": 5} - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI053_PYI053.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI053_PYI053.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI053_PYI053.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI053_PYI053.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI053_PYI053.pyi.snap deleted file mode 100644 index 951ca3acb1..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI053_PYI053.pyi.snap +++ /dev/null @@ -1,107 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI053.pyi:3:14: PYI053 [*] String and bytes literals longer than 50 characters are not permitted - | -1 | def f1(x: str = "50 character stringggggggggggggggggggggggggggggggg") -> None: ... # OK -2 | def f2( -3 | x: str = "51 character stringgggggggggggggggggggggggggggggggg", # Error: PYI053 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 -4 | ) -> None: ... -5 | def f3( - | - = help: Replace with `...` - -ℹ Suggested fix -1 1 | def f1(x: str = "50 character stringggggggggggggggggggggggggggggggg") -> None: ... # OK -2 2 | def f2( -3 |- x: str = "51 character stringgggggggggggggggggggggggggggggggg", # Error: PYI053 - 3 |+ x: str = ..., # Error: PYI053 -4 4 | ) -> None: ... -5 5 | def f3( -6 6 | x: str = "50 character stringgggggggggggggggggggggggggggggg\U0001f600", # OK - -PYI053.pyi:9:14: PYI053 [*] String and bytes literals longer than 50 characters are not permitted - | - 7 | ) -> None: ... - 8 | def f4( - 9 | x: str = "51 character stringggggggggggggggggggggggggggggggg\U0001f600", # Error: PYI053 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 -10 | ) -> None: ... -11 | def f5( - | - = help: Replace with `...` - -ℹ Suggested fix -6 6 | x: str = "50 character stringgggggggggggggggggggggggggggggg\U0001f600", # OK -7 7 | ) -> None: ... -8 8 | def f4( -9 |- x: str = "51 character stringggggggggggggggggggggggggggggggg\U0001f600", # Error: PYI053 - 9 |+ x: str = ..., # Error: PYI053 -10 10 | ) -> None: ... -11 11 | def f5( -12 12 | x: bytes = b"50 character byte stringgggggggggggggggggggggggggg", # OK - -PYI053.pyi:21:16: PYI053 [*] String and bytes literals longer than 50 characters are not permitted - | -19 | ) -> None: ... -20 | def f8( -21 | x: bytes = b"51 character byte stringgggggggggggggggggggggggggg\xff", # Error: PYI053 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 -22 | ) -> None: ... - | - = help: Replace with `...` - -ℹ Suggested fix -18 18 | x: bytes = b"50 character byte stringggggggggggggggggggggggggg\xff", # OK -19 19 | ) -> None: ... -20 20 | def f8( -21 |- x: bytes = b"51 character byte stringgggggggggggggggggggggggggg\xff", # Error: PYI053 - 21 |+ x: bytes = ..., # Error: PYI053 -22 22 | ) -> None: ... -23 23 | -24 24 | foo: str = "50 character stringggggggggggggggggggggggggggggggg" # OK - -PYI053.pyi:26:12: PYI053 [*] String and bytes literals longer than 50 characters are not permitted - | -24 | foo: str = "50 character stringggggggggggggggggggggggggggggggg" # OK -25 | -26 | bar: str = "51 character stringgggggggggggggggggggggggggggggggg" # Error: PYI053 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 -27 | -28 | baz: bytes = b"50 character byte stringgggggggggggggggggggggggggg" # OK - | - = help: Replace with `...` - -ℹ Suggested fix -23 23 | -24 24 | foo: str = "50 character stringggggggggggggggggggggggggggggggg" # OK -25 25 | -26 |-bar: str = "51 character stringgggggggggggggggggggggggggggggggg" # Error: PYI053 - 26 |+bar: str = ... # Error: PYI053 -27 27 | -28 28 | baz: bytes = b"50 character byte stringgggggggggggggggggggggggggg" # OK -29 29 | - -PYI053.pyi:30:14: PYI053 [*] String and bytes literals longer than 50 characters are not permitted - | -28 | baz: bytes = b"50 character byte stringgggggggggggggggggggggggggg" # OK -29 | -30 | qux: bytes = b"51 character byte stringggggggggggggggggggggggggggg\xff" # Error: PYI053 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 -31 | -32 | class Demo: - | - = help: Replace with `...` - -ℹ Suggested fix -27 27 | -28 28 | baz: bytes = b"50 character byte stringgggggggggggggggggggggggggg" # OK -29 29 | -30 |-qux: bytes = b"51 character byte stringggggggggggggggggggggggggggg\xff" # Error: PYI053 - 30 |+qux: bytes = ... # Error: PYI053 -31 31 | -32 32 | class Demo: -33 33 | """Docstrings are excluded from this rule. Some padding.""" # OK - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI054_PYI054.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI054_PYI054.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI054_PYI054.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI054_PYI054.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI054_PYI054.pyi.snap deleted file mode 100644 index 1e295c818d..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI054_PYI054.pyi.snap +++ /dev/null @@ -1,161 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI054.pyi:2:16: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted - | -1 | field01: int = 0xFFFFFFFF -2 | field02: int = 0xFFFFFFFFF # Error: PYI054 - | ^^^^^^^^^^^ PYI054 -3 | field03: int = -0xFFFFFFFF -4 | field04: int = -0xFFFFFFFFF # Error: PYI054 - | - = help: Replace with `...` - -ℹ Suggested fix -1 1 | field01: int = 0xFFFFFFFF -2 |-field02: int = 0xFFFFFFFFF # Error: PYI054 - 2 |+field02: int = ... # Error: PYI054 -3 3 | field03: int = -0xFFFFFFFF -4 4 | field04: int = -0xFFFFFFFFF # Error: PYI054 -5 5 | - -PYI054.pyi:4:17: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted - | -2 | field02: int = 0xFFFFFFFFF # Error: PYI054 -3 | field03: int = -0xFFFFFFFF -4 | field04: int = -0xFFFFFFFFF # Error: PYI054 - | ^^^^^^^^^^^ PYI054 -5 | -6 | field05: int = 1234567890 - | - = help: Replace with `...` - -ℹ Suggested fix -1 1 | field01: int = 0xFFFFFFFF -2 2 | field02: int = 0xFFFFFFFFF # Error: PYI054 -3 3 | field03: int = -0xFFFFFFFF -4 |-field04: int = -0xFFFFFFFFF # Error: PYI054 - 4 |+field04: int = -... # Error: PYI054 -5 5 | -6 6 | field05: int = 1234567890 -7 7 | field06: int = 12_456_890 - -PYI054.pyi:8:16: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted - | - 6 | field05: int = 1234567890 - 7 | field06: int = 12_456_890 - 8 | field07: int = 12345678901 # Error: PYI054 - | ^^^^^^^^^^^ PYI054 - 9 | field08: int = -1234567801 -10 | field09: int = -234_567_890 # Error: PYI054 - | - = help: Replace with `...` - -ℹ Suggested fix -5 5 | -6 6 | field05: int = 1234567890 -7 7 | field06: int = 12_456_890 -8 |-field07: int = 12345678901 # Error: PYI054 - 8 |+field07: int = ... # Error: PYI054 -9 9 | field08: int = -1234567801 -10 10 | field09: int = -234_567_890 # Error: PYI054 -11 11 | - -PYI054.pyi:10:17: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted - | - 8 | field07: int = 12345678901 # Error: PYI054 - 9 | field08: int = -1234567801 -10 | field09: int = -234_567_890 # Error: PYI054 - | ^^^^^^^^^^^ PYI054 -11 | -12 | field10: float = 123.456789 - | - = help: Replace with `...` - -ℹ Suggested fix -7 7 | field06: int = 12_456_890 -8 8 | field07: int = 12345678901 # Error: PYI054 -9 9 | field08: int = -1234567801 -10 |-field09: int = -234_567_890 # Error: PYI054 - 10 |+field09: int = -... # Error: PYI054 -11 11 | -12 12 | field10: float = 123.456789 -13 13 | field11: float = 123.4567890 # Error: PYI054 - -PYI054.pyi:13:18: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted - | -12 | field10: float = 123.456789 -13 | field11: float = 123.4567890 # Error: PYI054 - | ^^^^^^^^^^^ PYI054 -14 | field12: float = -123.456789 -15 | field13: float = -123.567_890 # Error: PYI054 - | - = help: Replace with `...` - -ℹ Suggested fix -10 10 | field09: int = -234_567_890 # Error: PYI054 -11 11 | -12 12 | field10: float = 123.456789 -13 |-field11: float = 123.4567890 # Error: PYI054 - 13 |+field11: float = ... # Error: PYI054 -14 14 | field12: float = -123.456789 -15 15 | field13: float = -123.567_890 # Error: PYI054 -16 16 | - -PYI054.pyi:15:19: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted - | -13 | field11: float = 123.4567890 # Error: PYI054 -14 | field12: float = -123.456789 -15 | field13: float = -123.567_890 # Error: PYI054 - | ^^^^^^^^^^^ PYI054 -16 | -17 | field14: complex = 1e1234567j - | - = help: Replace with `...` - -ℹ Suggested fix -12 12 | field10: float = 123.456789 -13 13 | field11: float = 123.4567890 # Error: PYI054 -14 14 | field12: float = -123.456789 -15 |-field13: float = -123.567_890 # Error: PYI054 - 15 |+field13: float = -... # Error: PYI054 -16 16 | -17 17 | field14: complex = 1e1234567j -18 18 | field15: complex = 1e12345678j # Error: PYI054 - -PYI054.pyi:18:20: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted - | -17 | field14: complex = 1e1234567j -18 | field15: complex = 1e12345678j # Error: PYI054 - | ^^^^^^^^^^^ PYI054 -19 | field16: complex = -1e1234567j -20 | field17: complex = 1e123456789j # Error: PYI054 - | - = help: Replace with `...` - -ℹ Suggested fix -15 15 | field13: float = -123.567_890 # Error: PYI054 -16 16 | -17 17 | field14: complex = 1e1234567j -18 |-field15: complex = 1e12345678j # Error: PYI054 - 18 |+field15: complex = ... # Error: PYI054 -19 19 | field16: complex = -1e1234567j -20 20 | field17: complex = 1e123456789j # Error: PYI054 - -PYI054.pyi:20:20: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted - | -18 | field15: complex = 1e12345678j # Error: PYI054 -19 | field16: complex = -1e1234567j -20 | field17: complex = 1e123456789j # Error: PYI054 - | ^^^^^^^^^^^^ PYI054 - | - = help: Replace with `...` - -ℹ Suggested fix -17 17 | field14: complex = 1e1234567j -18 18 | field15: complex = 1e12345678j # Error: PYI054 -19 19 | field16: complex = -1e1234567j -20 |-field17: complex = 1e123456789j # Error: PYI054 - 20 |+field17: complex = ... # Error: PYI054 - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI055_PYI055.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI055_PYI055.py.snap deleted file mode 100644 index 8f474e08d7..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI055_PYI055.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI055.py:31:11: PYI055 Multiple `type` members in a union. Combine them into one, e.g., `type[requests_mock.Mocker | httpretty]`. - | -29 | def func(): -30 | # PYI055 -31 | item: type[requests_mock.Mocker] | type[httpretty] = requests_mock.Mocker - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI055_PYI055.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI055_PYI055.pyi.snap deleted file mode 100644 index a8262366ed..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI055_PYI055.pyi.snap +++ /dev/null @@ -1,79 +0,0 @@ ---- -source: crates/ruff/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 | -4 | w: builtins.type[int] | builtins.type[str] | builtins.type[complex] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 -5 | x: type[int] | type[str] | type[float] -6 | y: builtins.type[int] | type[str] | builtins.type[complex] - | - -PYI055.pyi:5:4: PYI055 Multiple `type` members in a union. Combine them into one, e.g., `type[int | str | float]`. - | -4 | w: builtins.type[int] | builtins.type[str] | builtins.type[complex] -5 | x: type[int] | type[str] | type[float] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 -6 | y: builtins.type[int] | type[str] | builtins.type[complex] -7 | z: Union[type[float], type[complex]] - | - -PYI055.pyi:6:4: PYI055 Multiple `type` members in a union. Combine them into one, e.g., `type[int | str | complex]`. - | -4 | w: builtins.type[int] | builtins.type[str] | builtins.type[complex] -5 | x: type[int] | type[str] | type[float] -6 | y: builtins.type[int] | type[str] | builtins.type[complex] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 -7 | z: Union[type[float], type[complex]] -8 | z: Union[type[float, int], type[complex]] - | - -PYI055.pyi:7:4: PYI055 Multiple `type` members in a union. Combine them into one, e.g., `type[Union[float, complex]]`. - | -5 | x: type[int] | type[str] | type[float] -6 | y: builtins.type[int] | type[str] | builtins.type[complex] -7 | z: Union[type[float], type[complex]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 -8 | z: Union[type[float, int], type[complex]] - | - -PYI055.pyi:8:4: PYI055 Multiple `type` members in a union. Combine them into one, e.g., `type[Union[float, int, complex]]`. - | - 6 | y: builtins.type[int] | type[str] | builtins.type[complex] - 7 | z: Union[type[float], type[complex]] - 8 | z: Union[type[float, int], type[complex]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 - 9 | -10 | def func(arg: type[int] | str | type[float]) -> None: ... - | - -PYI055.pyi:10:15: PYI055 Multiple `type` members in a union. Combine them into one, e.g., `type[int | float]`. - | - 8 | z: Union[type[float, int], type[complex]] - 9 | -10 | def func(arg: type[int] | str | type[float]) -> None: ... - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 -11 | -12 | # OK - | - -PYI055.pyi:20:7: PYI055 Multiple `type` members in a union. Combine them into one, e.g., `type[requests_mock.Mocker | httpretty]`. - | -19 | # OK -20 | item: type[requests_mock.Mocker] | type[httpretty] = requests_mock.Mocker - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 -21 | -22 | def func(): - | - -PYI055.pyi:24:11: PYI055 Multiple `type` members in a union. Combine them into one, e.g., `type[requests_mock.Mocker | httpretty]`. - | -22 | def func(): -23 | # PYI055 -24 | item: type[requests_mock.Mocker] | type[httpretty] = requests_mock.Mocker - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI056_PYI056.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI056_PYI056.py.snap deleted file mode 100644 index 4c239c9c07..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI056_PYI056.py.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI056.py:4:1: PYI056 Calling `.append()` on `__all__` may not be supported by all type checkers (use `+=` instead) - | -3 | # Errors -4 | __all__.append("D") - | ^^^^^^^^^^^^^^ PYI056 -5 | __all__.extend(["E", "Foo"]) -6 | __all__.remove("A") - | - -PYI056.py:5:1: PYI056 Calling `.extend()` on `__all__` may not be supported by all type checkers (use `+=` instead) - | -3 | # Errors -4 | __all__.append("D") -5 | __all__.extend(["E", "Foo"]) - | ^^^^^^^^^^^^^^ PYI056 -6 | __all__.remove("A") - | - -PYI056.py:6:1: PYI056 Calling `.remove()` on `__all__` may not be supported by all type checkers (use `+=` instead) - | -4 | __all__.append("D") -5 | __all__.extend(["E", "Foo"]) -6 | __all__.remove("A") - | ^^^^^^^^^^^^^^ PYI056 -7 | -8 | # OK - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI056_PYI056.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI056_PYI056.pyi.snap deleted file mode 100644 index 79c5f952ec..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI056_PYI056.pyi.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI056.pyi:4:1: PYI056 Calling `.append()` on `__all__` may not be supported by all type checkers (use `+=` instead) - | -3 | # Errors -4 | __all__.append("D") - | ^^^^^^^^^^^^^^ PYI056 -5 | __all__.extend(["E", "Foo"]) -6 | __all__.remove("A") - | - -PYI056.pyi:5:1: PYI056 Calling `.extend()` on `__all__` may not be supported by all type checkers (use `+=` instead) - | -3 | # Errors -4 | __all__.append("D") -5 | __all__.extend(["E", "Foo"]) - | ^^^^^^^^^^^^^^ PYI056 -6 | __all__.remove("A") - | - -PYI056.pyi:6:1: PYI056 Calling `.remove()` on `__all__` may not be supported by all type checkers (use `+=` instead) - | -4 | __all__.append("D") -5 | __all__.extend(["E", "Foo"]) -6 | __all__.remove("A") - | ^^^^^^^^^^^^^^ PYI056 -7 | -8 | # OK - | - - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__py38_PYI026_PYI026.py.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__py38_PYI026_PYI026.py.snap deleted file mode 100644 index d1aa2e9116..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__py38_PYI026_PYI026.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__py38_PYI026_PYI026.pyi.snap b/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__py38_PYI026_PYI026.pyi.snap deleted file mode 100644 index a78ca465b9..0000000000 --- a/crates/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__py38_PYI026_PYI026.pyi.snap +++ /dev/null @@ -1,117 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pyi/mod.rs ---- -PYI026.pyi:3:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `NewAny: TypeAlias = Any` - | -1 | from typing import Literal, Any -2 | -3 | NewAny = Any - | ^^^^^^ PYI026 -4 | OptionalStr = typing.Optional[str] -5 | Foo = Literal["foo"] - | - = help: Add `TypeAlias` annotation - -ℹ Suggested fix -1 1 | from typing import Literal, Any - 2 |+import typing_extensions -2 3 | -3 |-NewAny = Any - 4 |+NewAny: typing_extensions.TypeAlias = Any -4 5 | OptionalStr = typing.Optional[str] -5 6 | Foo = Literal["foo"] -6 7 | IntOrStr = int | str - -PYI026.pyi:4:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `OptionalStr: TypeAlias = typing.Optional[str]` - | -3 | NewAny = Any -4 | OptionalStr = typing.Optional[str] - | ^^^^^^^^^^^ PYI026 -5 | Foo = Literal["foo"] -6 | IntOrStr = int | str - | - = help: Add `TypeAlias` annotation - -ℹ Suggested fix -1 1 | from typing import Literal, Any - 2 |+import typing_extensions -2 3 | -3 4 | NewAny = Any -4 |-OptionalStr = typing.Optional[str] - 5 |+OptionalStr: typing_extensions.TypeAlias = typing.Optional[str] -5 6 | Foo = Literal["foo"] -6 7 | IntOrStr = int | str -7 8 | AliasNone = None - -PYI026.pyi:5:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `Foo: TypeAlias = Literal["foo"]` - | -3 | NewAny = Any -4 | OptionalStr = typing.Optional[str] -5 | Foo = Literal["foo"] - | ^^^ PYI026 -6 | IntOrStr = int | str -7 | AliasNone = None - | - = help: Add `TypeAlias` annotation - -ℹ Suggested fix -1 1 | from typing import Literal, Any - 2 |+import typing_extensions -2 3 | -3 4 | NewAny = Any -4 5 | OptionalStr = typing.Optional[str] -5 |-Foo = Literal["foo"] - 6 |+Foo: typing_extensions.TypeAlias = Literal["foo"] -6 7 | IntOrStr = int | str -7 8 | AliasNone = None -8 9 | - -PYI026.pyi:6:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `IntOrStr: TypeAlias = int | str` - | -4 | OptionalStr = typing.Optional[str] -5 | Foo = Literal["foo"] -6 | IntOrStr = int | str - | ^^^^^^^^ PYI026 -7 | AliasNone = None - | - = help: Add `TypeAlias` annotation - -ℹ Suggested fix -1 1 | from typing import Literal, Any - 2 |+import typing_extensions -2 3 | -3 4 | NewAny = Any -4 5 | OptionalStr = typing.Optional[str] -5 6 | Foo = Literal["foo"] -6 |-IntOrStr = int | str - 7 |+IntOrStr: typing_extensions.TypeAlias = int | str -7 8 | AliasNone = None -8 9 | -9 10 | NewAny: typing.TypeAlias = Any - -PYI026.pyi:7:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `AliasNone: TypeAlias = None` - | -5 | Foo = Literal["foo"] -6 | IntOrStr = int | str -7 | AliasNone = None - | ^^^^^^^^^ PYI026 -8 | -9 | NewAny: typing.TypeAlias = Any - | - = help: Add `TypeAlias` annotation - -ℹ Suggested fix -1 1 | from typing import Literal, Any - 2 |+import typing_extensions -2 3 | -3 4 | NewAny = Any -4 5 | OptionalStr = typing.Optional[str] -5 6 | Foo = Literal["foo"] -6 7 | IntOrStr = int | str -7 |-AliasNone = None - 8 |+AliasNone: typing_extensions.TypeAlias = None -8 9 | -9 10 | NewAny: typing.TypeAlias = Any -10 11 | OptionalStr: TypeAlias = typing.Optional[str] - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT001_default.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT001_default.snap deleted file mode 100644 index ccfd30d007..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT001_default.snap +++ /dev/null @@ -1,61 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT001.py:9:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` - | - 9 | @pytest.fixture - | ^^^^^^^^^^^^^^^ PT001 -10 | def no_parentheses(): -11 | return 42 - | - = help: Add parentheses - -ℹ Fix -6 6 | # `import pytest` -7 7 | -8 8 | -9 |-@pytest.fixture - 9 |+@pytest.fixture() -10 10 | def no_parentheses(): -11 11 | return 42 -12 12 | - -PT001.py:34:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` - | -34 | @fixture - | ^^^^^^^^ PT001 -35 | def imported_from_no_parentheses(): -36 | return 42 - | - = help: Add parentheses - -ℹ Fix -31 31 | # `from pytest import fixture` -32 32 | -33 33 | -34 |-@fixture - 34 |+@fixture() -35 35 | def imported_from_no_parentheses(): -36 36 | return 42 -37 37 | - -PT001.py:59:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` - | -59 | @aliased - | ^^^^^^^^ PT001 -60 | def aliased_no_parentheses(): -61 | return 42 - | - = help: Add parentheses - -ℹ Fix -56 56 | # `from pytest import fixture as aliased` -57 57 | -58 58 | -59 |-@aliased - 59 |+@aliased() -60 60 | def aliased_no_parentheses(): -61 61 | return 42 -62 62 | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT001_no_parentheses.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT001_no_parentheses.snap deleted file mode 100644 index 408075a3cf..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT001_no_parentheses.snap +++ /dev/null @@ -1,129 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT001.py:14:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` - | -14 | @pytest.fixture() - | ^^^^^^^^^^^^^^^^^ PT001 -15 | def parentheses_no_params(): -16 | return 42 - | - = help: Remove parentheses - -ℹ Fix -11 11 | return 42 -12 12 | -13 13 | -14 |-@pytest.fixture() - 14 |+@pytest.fixture -15 15 | def parentheses_no_params(): -16 16 | return 42 -17 17 | - -PT001.py:24:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` - | -24 | / @pytest.fixture( -25 | | -26 | | ) - | |_^ PT001 -27 | def parentheses_no_params_multiline(): -28 | return 42 - | - = help: Remove parentheses - -ℹ Fix -21 21 | return 42 -22 22 | -23 23 | -24 |-@pytest.fixture( -25 |- -26 |-) - 24 |+@pytest.fixture -27 25 | def parentheses_no_params_multiline(): -28 26 | return 42 -29 27 | - -PT001.py:39:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` - | -39 | @fixture() - | ^^^^^^^^^^ PT001 -40 | def imported_from_parentheses_no_params(): -41 | return 42 - | - = help: Remove parentheses - -ℹ Fix -36 36 | return 42 -37 37 | -38 38 | -39 |-@fixture() - 39 |+@fixture -40 40 | def imported_from_parentheses_no_params(): -41 41 | return 42 -42 42 | - -PT001.py:49:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` - | -49 | / @fixture( -50 | | -51 | | ) - | |_^ PT001 -52 | def imported_from_parentheses_no_params_multiline(): -53 | return 42 - | - = help: Remove parentheses - -ℹ Fix -46 46 | return 42 -47 47 | -48 48 | -49 |-@fixture( -50 |- -51 |-) - 49 |+@fixture -52 50 | def imported_from_parentheses_no_params_multiline(): -53 51 | return 42 -54 52 | - -PT001.py:64:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` - | -64 | @aliased() - | ^^^^^^^^^^ PT001 -65 | def aliased_parentheses_no_params(): -66 | return 42 - | - = help: Remove parentheses - -ℹ Fix -61 61 | return 42 -62 62 | -63 63 | -64 |-@aliased() - 64 |+@aliased -65 65 | def aliased_parentheses_no_params(): -66 66 | return 42 -67 67 | - -PT001.py:74:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` - | -74 | / @aliased( -75 | | -76 | | ) - | |_^ PT001 -77 | def aliased_parentheses_no_params_multiline(): -78 | return 42 - | - = help: Remove parentheses - -ℹ Fix -71 71 | return 42 -72 72 | -73 73 | -74 |-@aliased( -75 |- -76 |-) - 74 |+@aliased -77 75 | def aliased_parentheses_no_params_multiline(): -78 76 | return 42 - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT002.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT002.snap deleted file mode 100644 index 2f5da96213..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT002.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT002.py:14:1: PT002 Configuration for fixture `my_fixture` specified via positional args, use kwargs - | -14 | @pytest.fixture("module") - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PT002 -15 | def my_fixture(): # Error only args -16 | return 0 - | - -PT002.py:19:1: PT002 Configuration for fixture `my_fixture` specified via positional args, use kwargs - | -19 | @pytest.fixture("module", autouse=True) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT002 -20 | def my_fixture(): # Error mixed -21 | return 0 - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT003.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT003.snap deleted file mode 100644 index 1db1884fda..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT003.snap +++ /dev/null @@ -1,164 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT003.py:14:17: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` - | -14 | @pytest.fixture(scope="function") - | ^^^^^^^^^^^^^^^^ PT003 -15 | def error(): -16 | ... - | - = help: Remove implied `scope` argument - -ℹ Suggested fix -11 11 | ... -12 12 | -13 13 | -14 |-@pytest.fixture(scope="function") - 14 |+@pytest.fixture() -15 15 | def error(): -16 16 | ... -17 17 | - -PT003.py:19:17: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` - | -19 | @pytest.fixture(scope="function", name="my_fixture") - | ^^^^^^^^^^^^^^^^ PT003 -20 | def error_multiple_args(): -21 | ... - | - = help: Remove implied `scope` argument - -ℹ Suggested fix -16 16 | ... -17 17 | -18 18 | -19 |-@pytest.fixture(scope="function", name="my_fixture") - 19 |+@pytest.fixture(name="my_fixture") -20 20 | def error_multiple_args(): -21 21 | ... -22 22 | - -PT003.py:24:36: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` - | -24 | @pytest.fixture(name="my_fixture", scope="function") - | ^^^^^^^^^^^^^^^^ PT003 -25 | def error_multiple_args(): -26 | ... - | - = help: Remove implied `scope` argument - -ℹ Suggested fix -21 21 | ... -22 22 | -23 23 | -24 |-@pytest.fixture(name="my_fixture", scope="function") - 24 |+@pytest.fixture(name="my_fixture") -25 25 | def error_multiple_args(): -26 26 | ... -27 27 | - -PT003.py:29:36: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` - | -29 | @pytest.fixture(name="my_fixture", scope="function", **kwargs) - | ^^^^^^^^^^^^^^^^ PT003 -30 | def error_second_arg(): -31 | ... - | - = help: Remove implied `scope` argument - -ℹ Suggested fix -26 26 | ... -27 27 | -28 28 | -29 |-@pytest.fixture(name="my_fixture", scope="function", **kwargs) - 29 |+@pytest.fixture(name="my_fixture", **kwargs) -30 30 | def error_second_arg(): -31 31 | ... -32 32 | - -PT003.py:37:31: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` - | -35 | # tests the general case as we use a helper function that should -36 | # work for all cases. -37 | @pytest.fixture("my_fixture", scope="function") - | ^^^^^^^^^^^^^^^^ PT003 -38 | def error_arg(): -39 | ... - | - = help: Remove implied `scope` argument - -ℹ Suggested fix -34 34 | # pytest.fixture does not take positional arguments, however this -35 35 | # tests the general case as we use a helper function that should -36 36 | # work for all cases. -37 |-@pytest.fixture("my_fixture", scope="function") - 37 |+@pytest.fixture("my_fixture") -38 38 | def error_arg(): -39 39 | ... -40 40 | - -PT003.py:43:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` - | -42 | @pytest.fixture( -43 | scope="function", - | ^^^^^^^^^^^^^^^^ PT003 -44 | name="my_fixture", -45 | ) - | - = help: Remove implied `scope` argument - -ℹ Suggested fix -40 40 | -41 41 | -42 42 | @pytest.fixture( -43 |- scope="function", -44 43 | name="my_fixture", -45 44 | ) -46 45 | def error_multiple_args(): - -PT003.py:52:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` - | -50 | @pytest.fixture( -51 | name="my_fixture", -52 | scope="function", - | ^^^^^^^^^^^^^^^^ PT003 -53 | ) -54 | def error_multiple_args(): - | - = help: Remove implied `scope` argument - -ℹ Suggested fix -49 49 | -50 50 | @pytest.fixture( -51 51 | name="my_fixture", -52 |- scope="function", -53 52 | ) -54 53 | def error_multiple_args(): -55 54 | ... - -PT003.py:66:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` - | -64 | # another comment ,) -65 | -66 | scope=\ - | _____^ -67 | | "function" # some comment ), - | |__________________^ PT003 -68 | , - | - = help: Remove implied `scope` argument - -ℹ Suggested fix -63 63 | -64 64 | # another comment ,) -65 65 | -66 |- scope=\ -67 |- "function" # some comment ), -68 |- , -69 |- -70 66 | name2=name, name3="my_fixture", **kwargs -71 67 | ) -72 68 | def error_multiple_args(): - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT004.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT004.snap deleted file mode 100644 index 64daa3babb..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT004.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT004.py:51:5: PT004 Fixture `patch_something` does not return anything, add leading underscore - | -50 | @pytest.fixture() -51 | def patch_something(mocker): # Error simple - | ^^^^^^^^^^^^^^^ PT004 -52 | mocker.patch("some.thing") - | - -PT004.py:56:5: PT004 Fixture `activate_context` does not return anything, add leading underscore - | -55 | @pytest.fixture() -56 | def activate_context(): # Error with yield - | ^^^^^^^^^^^^^^^^ PT004 -57 | with context: -58 | yield - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT005.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT005.snap deleted file mode 100644 index 6d13cf80b5..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT005.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT005.py:41:5: PT005 Fixture `_my_fixture` returns a value, remove leading underscore - | -40 | @pytest.fixture() -41 | def _my_fixture(mocker): # Error with return - | ^^^^^^^^^^^ PT005 -42 | return 0 - | - -PT005.py:46:5: PT005 Fixture `_activate_context` returns a value, remove leading underscore - | -45 | @pytest.fixture() -46 | def _activate_context(): # Error with yield - | ^^^^^^^^^^^^^^^^^ PT005 -47 | with get_context() as context: -48 | yield context - | - -PT005.py:52:5: PT005 Fixture `_activate_context` returns a value, remove leading underscore - | -51 | @pytest.fixture() -52 | def _activate_context(): # Error with conditional yield from - | ^^^^^^^^^^^^^^^^^ PT005 -53 | if some_condition: -54 | with get_context() as context: - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_csv.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_csv.snap deleted file mode 100644 index 47d6acb99c..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_csv.snap +++ /dev/null @@ -1,98 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT006.py:24:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` - | -24 | @pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^^^^ PT006 -25 | def test_tuple(param1, param2): -26 | ... - | - = help: Use a `csv` for parameter names - -ℹ Suggested fix -21 21 | ... -22 22 | -23 23 | -24 |-@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) - 24 |+@pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) -25 25 | def test_tuple(param1, param2): -26 26 | ... -27 27 | - -PT006.py:29:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` - | -29 | @pytest.mark.parametrize(("param1",), [1, 2, 3]) - | ^^^^^^^^^^^ PT006 -30 | def test_tuple_one_elem(param1, param2): -31 | ... - | - = help: Use a `csv` for parameter names - -ℹ Fix -26 26 | ... -27 27 | -28 28 | -29 |-@pytest.mark.parametrize(("param1",), [1, 2, 3]) - 29 |+@pytest.mark.parametrize("param1", [1, 2, 3]) -30 30 | def test_tuple_one_elem(param1, param2): -31 31 | ... -32 32 | - -PT006.py:34:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` - | -34 | @pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^^^^ PT006 -35 | def test_list(param1, param2): -36 | ... - | - = help: Use a `csv` for parameter names - -ℹ Suggested fix -31 31 | ... -32 32 | -33 33 | -34 |-@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) - 34 |+@pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) -35 35 | def test_list(param1, param2): -36 36 | ... -37 37 | - -PT006.py:39:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` - | -39 | @pytest.mark.parametrize(["param1"], [1, 2, 3]) - | ^^^^^^^^^^ PT006 -40 | def test_list_one_elem(param1, param2): -41 | ... - | - = help: Use a `csv` for parameter names - -ℹ Fix -36 36 | ... -37 37 | -38 38 | -39 |-@pytest.mark.parametrize(["param1"], [1, 2, 3]) - 39 |+@pytest.mark.parametrize("param1", [1, 2, 3]) -40 40 | def test_list_one_elem(param1, param2): -41 41 | ... -42 42 | - -PT006.py:44:26: PT006 Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` - | -44 | @pytest.mark.parametrize([some_expr, another_expr], [1, 2, 3]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 -45 | def test_list_expressions(param1, param2): -46 | ... - | - = help: Use a `csv` for parameter names - -PT006.py:49:26: PT006 Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` - | -49 | @pytest.mark.parametrize([some_expr, "param2"], [1, 2, 3]) - | ^^^^^^^^^^^^^^^^^^^^^ PT006 -50 | def test_list_mixed_expr_literal(param1, param2): -51 | ... - | - = help: Use a `csv` for parameter names - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_default.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_default.snap deleted file mode 100644 index 26ada2a795..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_default.snap +++ /dev/null @@ -1,231 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT006.py:9:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` - | - 9 | @pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^ PT006 -10 | def test_csv(param1, param2): -11 | ... - | - = help: Use a `tuple` for parameter names - -ℹ Suggested fix -6 6 | ... -7 7 | -8 8 | -9 |-@pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) - 9 |+@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) -10 10 | def test_csv(param1, param2): -11 11 | ... -12 12 | - -PT006.py:14:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` - | -14 | @pytest.mark.parametrize(" param1, , param2 , ", [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 -15 | def test_csv_with_whitespace(param1, param2): -16 | ... - | - = help: Use a `tuple` for parameter names - -ℹ Suggested fix -11 11 | ... -12 12 | -13 13 | -14 |-@pytest.mark.parametrize(" param1, , param2 , ", [(1, 2), (3, 4)]) - 14 |+@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) -15 15 | def test_csv_with_whitespace(param1, param2): -16 16 | ... -17 17 | - -PT006.py:19:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` - | -19 | @pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^ PT006 -20 | def test_csv_bad_quotes(param1, param2): -21 | ... - | - = help: Use a `tuple` for parameter names - -ℹ Suggested fix -16 16 | ... -17 17 | -18 18 | -19 |-@pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) - 19 |+@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) -20 20 | def test_csv_bad_quotes(param1, param2): -21 21 | ... -22 22 | - -PT006.py:29:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` - | -29 | @pytest.mark.parametrize(("param1",), [1, 2, 3]) - | ^^^^^^^^^^^ PT006 -30 | def test_tuple_one_elem(param1, param2): -31 | ... - | - = help: Use a `csv` for parameter names - -ℹ Fix -26 26 | ... -27 27 | -28 28 | -29 |-@pytest.mark.parametrize(("param1",), [1, 2, 3]) - 29 |+@pytest.mark.parametrize("param1", [1, 2, 3]) -30 30 | def test_tuple_one_elem(param1, param2): -31 31 | ... -32 32 | - -PT006.py:34:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` - | -34 | @pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^^^^ PT006 -35 | def test_list(param1, param2): -36 | ... - | - = help: Use a `tuple` for parameter names - -ℹ Suggested fix -31 31 | ... -32 32 | -33 33 | -34 |-@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) - 34 |+@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) -35 35 | def test_list(param1, param2): -36 36 | ... -37 37 | - -PT006.py:39:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` - | -39 | @pytest.mark.parametrize(["param1"], [1, 2, 3]) - | ^^^^^^^^^^ PT006 -40 | def test_list_one_elem(param1, param2): -41 | ... - | - = help: Use a `csv` for parameter names - -ℹ Fix -36 36 | ... -37 37 | -38 38 | -39 |-@pytest.mark.parametrize(["param1"], [1, 2, 3]) - 39 |+@pytest.mark.parametrize("param1", [1, 2, 3]) -40 40 | def test_list_one_elem(param1, param2): -41 41 | ... -42 42 | - -PT006.py:44:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` - | -44 | @pytest.mark.parametrize([some_expr, another_expr], [1, 2, 3]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 -45 | def test_list_expressions(param1, param2): -46 | ... - | - = help: Use a `tuple` for parameter names - -ℹ Suggested fix -41 41 | ... -42 42 | -43 43 | -44 |-@pytest.mark.parametrize([some_expr, another_expr], [1, 2, 3]) - 44 |+@pytest.mark.parametrize((some_expr, another_expr), [1, 2, 3]) -45 45 | def test_list_expressions(param1, param2): -46 46 | ... -47 47 | - -PT006.py:49:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` - | -49 | @pytest.mark.parametrize([some_expr, "param2"], [1, 2, 3]) - | ^^^^^^^^^^^^^^^^^^^^^ PT006 -50 | def test_list_mixed_expr_literal(param1, param2): -51 | ... - | - = help: Use a `tuple` for parameter names - -ℹ Suggested fix -46 46 | ... -47 47 | -48 48 | -49 |-@pytest.mark.parametrize([some_expr, "param2"], [1, 2, 3]) - 49 |+@pytest.mark.parametrize((some_expr, "param2"), [1, 2, 3]) -50 50 | def test_list_mixed_expr_literal(param1, param2): -51 51 | ... -52 52 | - -PT006.py:54:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` - | -54 | @pytest.mark.parametrize(("param1, " "param2, " "param3"), [(1, 2, 3), (4, 5, 6)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 -55 | def test_implicit_str_concat_with_parens(param1, param2, param3): -56 | ... - | - = help: Use a `tuple` for parameter names - -ℹ Suggested fix -51 51 | ... -52 52 | -53 53 | -54 |-@pytest.mark.parametrize(("param1, " "param2, " "param3"), [(1, 2, 3), (4, 5, 6)]) - 54 |+@pytest.mark.parametrize(("param1", "param2", "param3"), [(1, 2, 3), (4, 5, 6)]) -55 55 | def test_implicit_str_concat_with_parens(param1, param2, param3): -56 56 | ... -57 57 | - -PT006.py:59:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` - | -59 | @pytest.mark.parametrize("param1, " "param2, " "param3", [(1, 2, 3), (4, 5, 6)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 -60 | def test_implicit_str_concat_no_parens(param1, param2, param3): -61 | ... - | - = help: Use a `tuple` for parameter names - -ℹ Suggested fix -56 56 | ... -57 57 | -58 58 | -59 |-@pytest.mark.parametrize("param1, " "param2, " "param3", [(1, 2, 3), (4, 5, 6)]) - 59 |+@pytest.mark.parametrize(("param1", "param2", "param3"), [(1, 2, 3), (4, 5, 6)]) -60 60 | def test_implicit_str_concat_no_parens(param1, param2, param3): -61 61 | ... -62 62 | - -PT006.py:64:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` - | -64 | @pytest.mark.parametrize((("param1, " "param2, " "param3")), [(1, 2, 3), (4, 5, 6)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 -65 | def test_implicit_str_concat_with_multi_parens(param1, param2, param3): -66 | ... - | - = help: Use a `tuple` for parameter names - -ℹ Suggested fix -61 61 | ... -62 62 | -63 63 | -64 |-@pytest.mark.parametrize((("param1, " "param2, " "param3")), [(1, 2, 3), (4, 5, 6)]) - 64 |+@pytest.mark.parametrize(("param1", "param2", "param3"), [(1, 2, 3), (4, 5, 6)]) -65 65 | def test_implicit_str_concat_with_multi_parens(param1, param2, param3): -66 66 | ... -67 67 | - -PT006.py:69:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` - | -69 | @pytest.mark.parametrize(("param1,param2"), [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^ PT006 -70 | def test_csv_with_parens(param1, param2): -71 | ... - | - = help: Use a `tuple` for parameter names - -ℹ Suggested fix -66 66 | ... -67 67 | -68 68 | -69 |-@pytest.mark.parametrize(("param1,param2"), [(1, 2), (3, 4)]) - 69 |+@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) -70 70 | def test_csv_with_parens(param1, param2): -71 71 | ... - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_list.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_list.snap deleted file mode 100644 index 2d40708e94..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT006_list.snap +++ /dev/null @@ -1,193 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT006.py:9:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list` - | - 9 | @pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^ PT006 -10 | def test_csv(param1, param2): -11 | ... - | - = help: Use a `list` for parameter names - -ℹ Suggested fix -6 6 | ... -7 7 | -8 8 | -9 |-@pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) - 9 |+@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) -10 10 | def test_csv(param1, param2): -11 11 | ... -12 12 | - -PT006.py:14:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list` - | -14 | @pytest.mark.parametrize(" param1, , param2 , ", [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 -15 | def test_csv_with_whitespace(param1, param2): -16 | ... - | - = help: Use a `list` for parameter names - -ℹ Suggested fix -11 11 | ... -12 12 | -13 13 | -14 |-@pytest.mark.parametrize(" param1, , param2 , ", [(1, 2), (3, 4)]) - 14 |+@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) -15 15 | def test_csv_with_whitespace(param1, param2): -16 16 | ... -17 17 | - -PT006.py:19:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list` - | -19 | @pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^ PT006 -20 | def test_csv_bad_quotes(param1, param2): -21 | ... - | - = help: Use a `list` for parameter names - -ℹ Suggested fix -16 16 | ... -17 17 | -18 18 | -19 |-@pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) - 19 |+@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) -20 20 | def test_csv_bad_quotes(param1, param2): -21 21 | ... -22 22 | - -PT006.py:24:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list` - | -24 | @pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^^^^ PT006 -25 | def test_tuple(param1, param2): -26 | ... - | - = help: Use a `list` for parameter names - -ℹ Suggested fix -21 21 | ... -22 22 | -23 23 | -24 |-@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) - 24 |+@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) -25 25 | def test_tuple(param1, param2): -26 26 | ... -27 27 | - -PT006.py:29:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` - | -29 | @pytest.mark.parametrize(("param1",), [1, 2, 3]) - | ^^^^^^^^^^^ PT006 -30 | def test_tuple_one_elem(param1, param2): -31 | ... - | - = help: Use a `csv` for parameter names - -ℹ Fix -26 26 | ... -27 27 | -28 28 | -29 |-@pytest.mark.parametrize(("param1",), [1, 2, 3]) - 29 |+@pytest.mark.parametrize("param1", [1, 2, 3]) -30 30 | def test_tuple_one_elem(param1, param2): -31 31 | ... -32 32 | - -PT006.py:39:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` - | -39 | @pytest.mark.parametrize(["param1"], [1, 2, 3]) - | ^^^^^^^^^^ PT006 -40 | def test_list_one_elem(param1, param2): -41 | ... - | - = help: Use a `csv` for parameter names - -ℹ Fix -36 36 | ... -37 37 | -38 38 | -39 |-@pytest.mark.parametrize(["param1"], [1, 2, 3]) - 39 |+@pytest.mark.parametrize("param1", [1, 2, 3]) -40 40 | def test_list_one_elem(param1, param2): -41 41 | ... -42 42 | - -PT006.py:54:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list` - | -54 | @pytest.mark.parametrize(("param1, " "param2, " "param3"), [(1, 2, 3), (4, 5, 6)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 -55 | def test_implicit_str_concat_with_parens(param1, param2, param3): -56 | ... - | - = help: Use a `list` for parameter names - -ℹ Suggested fix -51 51 | ... -52 52 | -53 53 | -54 |-@pytest.mark.parametrize(("param1, " "param2, " "param3"), [(1, 2, 3), (4, 5, 6)]) - 54 |+@pytest.mark.parametrize(["param1", "param2", "param3"], [(1, 2, 3), (4, 5, 6)]) -55 55 | def test_implicit_str_concat_with_parens(param1, param2, param3): -56 56 | ... -57 57 | - -PT006.py:59:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list` - | -59 | @pytest.mark.parametrize("param1, " "param2, " "param3", [(1, 2, 3), (4, 5, 6)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 -60 | def test_implicit_str_concat_no_parens(param1, param2, param3): -61 | ... - | - = help: Use a `list` for parameter names - -ℹ Suggested fix -56 56 | ... -57 57 | -58 58 | -59 |-@pytest.mark.parametrize("param1, " "param2, " "param3", [(1, 2, 3), (4, 5, 6)]) - 59 |+@pytest.mark.parametrize(["param1", "param2", "param3"], [(1, 2, 3), (4, 5, 6)]) -60 60 | def test_implicit_str_concat_no_parens(param1, param2, param3): -61 61 | ... -62 62 | - -PT006.py:64:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list` - | -64 | @pytest.mark.parametrize((("param1, " "param2, " "param3")), [(1, 2, 3), (4, 5, 6)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 -65 | def test_implicit_str_concat_with_multi_parens(param1, param2, param3): -66 | ... - | - = help: Use a `list` for parameter names - -ℹ Suggested fix -61 61 | ... -62 62 | -63 63 | -64 |-@pytest.mark.parametrize((("param1, " "param2, " "param3")), [(1, 2, 3), (4, 5, 6)]) - 64 |+@pytest.mark.parametrize(["param1", "param2", "param3"], [(1, 2, 3), (4, 5, 6)]) -65 65 | def test_implicit_str_concat_with_multi_parens(param1, param2, param3): -66 66 | ... -67 67 | - -PT006.py:69:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list` - | -69 | @pytest.mark.parametrize(("param1,param2"), [(1, 2), (3, 4)]) - | ^^^^^^^^^^^^^^^^^ PT006 -70 | def test_csv_with_parens(param1, param2): -71 | ... - | - = help: Use a `list` for parameter names - -ℹ Suggested fix -66 66 | ... -67 67 | -68 68 | -69 |-@pytest.mark.parametrize(("param1,param2"), [(1, 2), (3, 4)]) - 69 |+@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) -70 70 | def test_csv_with_parens(param1, param2): -71 71 | ... - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap deleted file mode 100644 index 1386dad34e..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap +++ /dev/null @@ -1,107 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT007.py:4:35: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` - | -4 | @pytest.mark.parametrize("param", (1, 2)) - | ^^^^^^ PT007 -5 | def test_tuple(param): -6 | ... - | - -PT007.py:11:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` - | - 9 | @pytest.mark.parametrize( -10 | ("param1", "param2"), -11 | ( - | _____^ -12 | | (1, 2), -13 | | (3, 4), -14 | | ), - | |_____^ PT007 -15 | ) -16 | def test_tuple_of_tuples(param1, param2): - | - -PT007.py:12:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` - | -10 | ("param1", "param2"), -11 | ( -12 | (1, 2), - | ^^^^^^ PT007 -13 | (3, 4), -14 | ), - | - -PT007.py:13:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` - | -11 | ( -12 | (1, 2), -13 | (3, 4), - | ^^^^^^ PT007 -14 | ), -15 | ) - | - -PT007.py:22:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` - | -20 | @pytest.mark.parametrize( -21 | ("param1", "param2"), -22 | ( - | _____^ -23 | | [1, 2], -24 | | [3, 4], -25 | | ), - | |_____^ PT007 -26 | ) -27 | def test_tuple_of_lists(param1, param2): - | - -PT007.py:39:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` - | -37 | ("param1", "param2"), -38 | [ -39 | (1, 2), - | ^^^^^^ PT007 -40 | (3, 4), -41 | ], - | - -PT007.py:40:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` - | -38 | [ -39 | (1, 2), -40 | (3, 4), - | ^^^^^^ PT007 -41 | ], -42 | ) - | - -PT007.py:81:38: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` - | -80 | @pytest.mark.parametrize("a", [1, 2]) -81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) - | ^^^^^^^^^^^^^^^^ PT007 -82 | def test_multiple_decorators(a, b, c): -83 | pass - | - -PT007.py:81:39: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` - | -80 | @pytest.mark.parametrize("a", [1, 2]) -81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) - | ^^^^^^ PT007 -82 | def test_multiple_decorators(a, b, c): -83 | pass - | - -PT007.py:81:47: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` - | -80 | @pytest.mark.parametrize("a", [1, 2]) -81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) - | ^^^^^^ PT007 -82 | def test_multiple_decorators(a, b, c): -83 | pass - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap deleted file mode 100644 index 5b5c56d1ab..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap +++ /dev/null @@ -1,109 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT007.py:4:35: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` - | -4 | @pytest.mark.parametrize("param", (1, 2)) - | ^^^^^^ PT007 -5 | def test_tuple(param): -6 | ... - | - -PT007.py:11:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` - | - 9 | @pytest.mark.parametrize( -10 | ("param1", "param2"), -11 | ( - | _____^ -12 | | (1, 2), -13 | | (3, 4), -14 | | ), - | |_____^ PT007 -15 | ) -16 | def test_tuple_of_tuples(param1, param2): - | - -PT007.py:22:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` - | -20 | @pytest.mark.parametrize( -21 | ("param1", "param2"), -22 | ( - | _____^ -23 | | [1, 2], -24 | | [3, 4], -25 | | ), - | |_____^ PT007 -26 | ) -27 | def test_tuple_of_lists(param1, param2): - | - -PT007.py:23:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` - | -21 | ("param1", "param2"), -22 | ( -23 | [1, 2], - | ^^^^^^ PT007 -24 | [3, 4], -25 | ), - | - -PT007.py:24:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` - | -22 | ( -23 | [1, 2], -24 | [3, 4], - | ^^^^^^ PT007 -25 | ), -26 | ) - | - -PT007.py:50:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` - | -48 | ("param1", "param2"), -49 | [ -50 | [1, 2], - | ^^^^^^ PT007 -51 | [3, 4], -52 | ], - | - -PT007.py:51:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` - | -49 | [ -50 | [1, 2], -51 | [3, 4], - | ^^^^^^ PT007 -52 | ], -53 | ) - | - -PT007.py:61:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` - | -59 | "param1,param2", -60 | [ -61 | [1, 2], - | ^^^^^^ PT007 -62 | [3, 4], -63 | ], - | - -PT007.py:62:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` - | -60 | [ -61 | [1, 2], -62 | [3, 4], - | ^^^^^^ PT007 -63 | ], -64 | ) - | - -PT007.py:81:38: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` - | -80 | @pytest.mark.parametrize("a", [1, 2]) -81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) - | ^^^^^^^^^^^^^^^^ PT007 -82 | def test_multiple_decorators(a, b, c): -83 | pass - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap deleted file mode 100644 index 48f0d6b129..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap +++ /dev/null @@ -1,134 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT007.py:12:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` - | -10 | ("param1", "param2"), -11 | ( -12 | (1, 2), - | ^^^^^^ PT007 -13 | (3, 4), -14 | ), - | - -PT007.py:13:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` - | -11 | ( -12 | (1, 2), -13 | (3, 4), - | ^^^^^^ PT007 -14 | ), -15 | ) - | - -PT007.py:31:35: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` - | -31 | @pytest.mark.parametrize("param", [1, 2]) - | ^^^^^^ PT007 -32 | def test_list(param): -33 | ... - | - -PT007.py:38:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` - | -36 | @pytest.mark.parametrize( -37 | ("param1", "param2"), -38 | [ - | _____^ -39 | | (1, 2), -40 | | (3, 4), -41 | | ], - | |_____^ PT007 -42 | ) -43 | def test_list_of_tuples(param1, param2): - | - -PT007.py:39:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` - | -37 | ("param1", "param2"), -38 | [ -39 | (1, 2), - | ^^^^^^ PT007 -40 | (3, 4), -41 | ], - | - -PT007.py:40:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` - | -38 | [ -39 | (1, 2), -40 | (3, 4), - | ^^^^^^ PT007 -41 | ], -42 | ) - | - -PT007.py:49:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` - | -47 | @pytest.mark.parametrize( -48 | ("param1", "param2"), -49 | [ - | _____^ -50 | | [1, 2], -51 | | [3, 4], -52 | | ], - | |_____^ PT007 -53 | ) -54 | def test_list_of_lists(param1, param2): - | - -PT007.py:60:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` - | -58 | @pytest.mark.parametrize( -59 | "param1,param2", -60 | [ - | _____^ -61 | | [1, 2], -62 | | [3, 4], -63 | | ], - | |_____^ PT007 -64 | ) -65 | def test_csv_name_list_of_lists(param1, param2): - | - -PT007.py:71:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` - | -69 | @pytest.mark.parametrize( -70 | "param", -71 | [ - | _____^ -72 | | [1, 2], -73 | | [3, 4], -74 | | ], - | |_____^ PT007 -75 | ) -76 | def test_single_list_of_lists(param): - | - -PT007.py:80:31: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` - | -80 | @pytest.mark.parametrize("a", [1, 2]) - | ^^^^^^ PT007 -81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) -82 | def test_multiple_decorators(a, b, c): - | - -PT007.py:81:39: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` - | -80 | @pytest.mark.parametrize("a", [1, 2]) -81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) - | ^^^^^^ PT007 -82 | def test_multiple_decorators(a, b, c): -83 | pass - | - -PT007.py:81:47: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` - | -80 | @pytest.mark.parametrize("a", [1, 2]) -81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) - | ^^^^^^ PT007 -82 | def test_multiple_decorators(a, b, c): -83 | pass - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap deleted file mode 100644 index 124d8a23a3..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap +++ /dev/null @@ -1,136 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT007.py:23:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` - | -21 | ("param1", "param2"), -22 | ( -23 | [1, 2], - | ^^^^^^ PT007 -24 | [3, 4], -25 | ), - | - -PT007.py:24:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` - | -22 | ( -23 | [1, 2], -24 | [3, 4], - | ^^^^^^ PT007 -25 | ), -26 | ) - | - -PT007.py:31:35: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` - | -31 | @pytest.mark.parametrize("param", [1, 2]) - | ^^^^^^ PT007 -32 | def test_list(param): -33 | ... - | - -PT007.py:38:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` - | -36 | @pytest.mark.parametrize( -37 | ("param1", "param2"), -38 | [ - | _____^ -39 | | (1, 2), -40 | | (3, 4), -41 | | ], - | |_____^ PT007 -42 | ) -43 | def test_list_of_tuples(param1, param2): - | - -PT007.py:49:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` - | -47 | @pytest.mark.parametrize( -48 | ("param1", "param2"), -49 | [ - | _____^ -50 | | [1, 2], -51 | | [3, 4], -52 | | ], - | |_____^ PT007 -53 | ) -54 | def test_list_of_lists(param1, param2): - | - -PT007.py:50:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` - | -48 | ("param1", "param2"), -49 | [ -50 | [1, 2], - | ^^^^^^ PT007 -51 | [3, 4], -52 | ], - | - -PT007.py:51:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` - | -49 | [ -50 | [1, 2], -51 | [3, 4], - | ^^^^^^ PT007 -52 | ], -53 | ) - | - -PT007.py:60:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` - | -58 | @pytest.mark.parametrize( -59 | "param1,param2", -60 | [ - | _____^ -61 | | [1, 2], -62 | | [3, 4], -63 | | ], - | |_____^ PT007 -64 | ) -65 | def test_csv_name_list_of_lists(param1, param2): - | - -PT007.py:61:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` - | -59 | "param1,param2", -60 | [ -61 | [1, 2], - | ^^^^^^ PT007 -62 | [3, 4], -63 | ], - | - -PT007.py:62:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` - | -60 | [ -61 | [1, 2], -62 | [3, 4], - | ^^^^^^ PT007 -63 | ], -64 | ) - | - -PT007.py:71:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` - | -69 | @pytest.mark.parametrize( -70 | "param", -71 | [ - | _____^ -72 | | [1, 2], -73 | | [3, 4], -74 | | ], - | |_____^ PT007 -75 | ) -76 | def test_single_list_of_lists(param): - | - -PT007.py:80:31: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` - | -80 | @pytest.mark.parametrize("a", [1, 2]) - | ^^^^^^ PT007 -81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) -82 | def test_multiple_decorators(a, b, c): - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT008.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT008.snap deleted file mode 100644 index 56e9530e25..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT008.snap +++ /dev/null @@ -1,116 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT008.py:35:1: PT008 Use `return_value=` instead of patching with `lambda` - | -33 | # Error -34 | -35 | mocker.patch("module.name", lambda: None) - | ^^^^^^^^^^^^ PT008 -36 | module_mocker.patch("module.name", lambda: None) -37 | mocker.patch.object(obj, "attr", lambda: None) - | - -PT008.py:36:1: PT008 Use `return_value=` instead of patching with `lambda` - | -35 | mocker.patch("module.name", lambda: None) -36 | module_mocker.patch("module.name", lambda: None) - | ^^^^^^^^^^^^^^^^^^^ PT008 -37 | mocker.patch.object(obj, "attr", lambda: None) -38 | module_mocker.patch.object(obj, "attr", lambda: None) - | - -PT008.py:37:1: PT008 Use `return_value=` instead of patching with `lambda` - | -35 | mocker.patch("module.name", lambda: None) -36 | module_mocker.patch("module.name", lambda: None) -37 | mocker.patch.object(obj, "attr", lambda: None) - | ^^^^^^^^^^^^^^^^^^^ PT008 -38 | module_mocker.patch.object(obj, "attr", lambda: None) - | - -PT008.py:38:1: PT008 Use `return_value=` instead of patching with `lambda` - | -36 | module_mocker.patch("module.name", lambda: None) -37 | mocker.patch.object(obj, "attr", lambda: None) -38 | module_mocker.patch.object(obj, "attr", lambda: None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PT008 -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 | -40 | mocker.patch("module.name", lambda x, y: None) - | ^^^^^^^^^^^^ PT008 -41 | module_mocker.patch("module.name", lambda x, y: None) -42 | mocker.patch.object(obj, "attr", lambda x, y: None) - | - -PT008.py:41:1: PT008 Use `return_value=` instead of patching with `lambda` - | -40 | mocker.patch("module.name", lambda x, y: None) -41 | module_mocker.patch("module.name", lambda x, y: None) - | ^^^^^^^^^^^^^^^^^^^ PT008 -42 | mocker.patch.object(obj, "attr", lambda x, y: None) -43 | module_mocker.patch.object(obj, "attr", lambda x, y: None) - | - -PT008.py:42:1: PT008 Use `return_value=` instead of patching with `lambda` - | -40 | mocker.patch("module.name", lambda x, y: None) -41 | module_mocker.patch("module.name", lambda x, y: None) -42 | mocker.patch.object(obj, "attr", lambda x, y: None) - | ^^^^^^^^^^^^^^^^^^^ PT008 -43 | module_mocker.patch.object(obj, "attr", lambda x, y: None) - | - -PT008.py:43:1: PT008 Use `return_value=` instead of patching with `lambda` - | -41 | module_mocker.patch("module.name", lambda x, y: None) -42 | mocker.patch.object(obj, "attr", lambda x, y: None) -43 | module_mocker.patch.object(obj, "attr", lambda x, y: None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PT008 -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 | -45 | mocker.patch("module.name", lambda *args, **kwargs: None) - | ^^^^^^^^^^^^ PT008 -46 | module_mocker.patch("module.name", lambda *args, **kwargs: None) -47 | mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) - | - -PT008.py:46:1: PT008 Use `return_value=` instead of patching with `lambda` - | -45 | mocker.patch("module.name", lambda *args, **kwargs: None) -46 | module_mocker.patch("module.name", lambda *args, **kwargs: None) - | ^^^^^^^^^^^^^^^^^^^ PT008 -47 | mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) -48 | module_mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) - | - -PT008.py:47:1: PT008 Use `return_value=` instead of patching with `lambda` - | -45 | mocker.patch("module.name", lambda *args, **kwargs: None) -46 | module_mocker.patch("module.name", lambda *args, **kwargs: None) -47 | mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) - | ^^^^^^^^^^^^^^^^^^^ PT008 -48 | module_mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) - | - -PT008.py:48:1: PT008 Use `return_value=` instead of patching with `lambda` - | -46 | module_mocker.patch("module.name", lambda *args, **kwargs: None) -47 | mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) -48 | module_mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PT008 - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT009.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT009.snap deleted file mode 100644 index e3c46d173c..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT009.snap +++ /dev/null @@ -1,663 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT009.py:11:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` - | - 9 | expr = 1 -10 | msg = "Must be True" -11 | self.assertTrue(expr) # Error - | ^^^^^^^^^^^^^^^ PT009 -12 | self.assertTrue(expr=expr) # Error -13 | self.assertTrue(expr, msg) # Error - | - = help: Replace `assertTrue(...)` with `assert ...` - -ℹ Suggested fix -8 8 | def test_assert_true(self): -9 9 | expr = 1 -10 10 | msg = "Must be True" -11 |- self.assertTrue(expr) # Error - 11 |+ assert expr # Error -12 12 | self.assertTrue(expr=expr) # Error -13 13 | self.assertTrue(expr, msg) # Error -14 14 | self.assertTrue(expr=expr, msg=msg) # Error - -PT009.py:12:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` - | -10 | msg = "Must be True" -11 | self.assertTrue(expr) # Error -12 | self.assertTrue(expr=expr) # Error - | ^^^^^^^^^^^^^^^ PT009 -13 | self.assertTrue(expr, msg) # Error -14 | self.assertTrue(expr=expr, msg=msg) # Error - | - = help: Replace `assertTrue(...)` with `assert ...` - -ℹ Suggested fix -9 9 | expr = 1 -10 10 | msg = "Must be True" -11 11 | self.assertTrue(expr) # Error -12 |- self.assertTrue(expr=expr) # Error - 12 |+ assert expr # Error -13 13 | self.assertTrue(expr, msg) # Error -14 14 | self.assertTrue(expr=expr, msg=msg) # Error -15 15 | self.assertTrue(msg=msg, expr=expr) # Error - -PT009.py:13:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` - | -11 | self.assertTrue(expr) # Error -12 | self.assertTrue(expr=expr) # Error -13 | self.assertTrue(expr, msg) # Error - | ^^^^^^^^^^^^^^^ PT009 -14 | self.assertTrue(expr=expr, msg=msg) # Error -15 | self.assertTrue(msg=msg, expr=expr) # Error - | - = help: Replace `assertTrue(...)` with `assert ...` - -ℹ Suggested fix -10 10 | msg = "Must be True" -11 11 | self.assertTrue(expr) # Error -12 12 | self.assertTrue(expr=expr) # Error -13 |- self.assertTrue(expr, msg) # Error - 13 |+ assert expr, msg # Error -14 14 | self.assertTrue(expr=expr, msg=msg) # Error -15 15 | self.assertTrue(msg=msg, expr=expr) # Error -16 16 | self.assertTrue(*(expr, msg)) # Error, unfixable - -PT009.py:14:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` - | -12 | self.assertTrue(expr=expr) # Error -13 | self.assertTrue(expr, msg) # Error -14 | self.assertTrue(expr=expr, msg=msg) # Error - | ^^^^^^^^^^^^^^^ PT009 -15 | self.assertTrue(msg=msg, expr=expr) # Error -16 | self.assertTrue(*(expr, msg)) # Error, unfixable - | - = help: Replace `assertTrue(...)` with `assert ...` - -ℹ Suggested fix -11 11 | self.assertTrue(expr) # Error -12 12 | self.assertTrue(expr=expr) # Error -13 13 | self.assertTrue(expr, msg) # Error -14 |- self.assertTrue(expr=expr, msg=msg) # Error - 14 |+ assert expr, msg # Error -15 15 | self.assertTrue(msg=msg, expr=expr) # Error -16 16 | self.assertTrue(*(expr, msg)) # Error, unfixable -17 17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable - -PT009.py:15:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` - | -13 | self.assertTrue(expr, msg) # Error -14 | self.assertTrue(expr=expr, msg=msg) # Error -15 | self.assertTrue(msg=msg, expr=expr) # Error - | ^^^^^^^^^^^^^^^ PT009 -16 | self.assertTrue(*(expr, msg)) # Error, unfixable -17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable - | - = help: Replace `assertTrue(...)` with `assert ...` - -ℹ Suggested fix -12 12 | self.assertTrue(expr=expr) # Error -13 13 | self.assertTrue(expr, msg) # Error -14 14 | self.assertTrue(expr=expr, msg=msg) # Error -15 |- self.assertTrue(msg=msg, expr=expr) # Error - 15 |+ assert expr, msg # Error -16 16 | self.assertTrue(*(expr, msg)) # Error, unfixable -17 17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable -18 18 | self.assertTrue(msg=msg, expr=expr, unexpected_arg=False) # Error, unfixable - -PT009.py:16:9: PT009 Use a regular `assert` instead of unittest-style `assertTrue` - | -14 | self.assertTrue(expr=expr, msg=msg) # Error -15 | self.assertTrue(msg=msg, expr=expr) # Error -16 | self.assertTrue(*(expr, msg)) # Error, unfixable - | ^^^^^^^^^^^^^^^ PT009 -17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable -18 | self.assertTrue(msg=msg, expr=expr, unexpected_arg=False) # Error, unfixable - | - = help: Replace `assertTrue(...)` with `assert ...` - -PT009.py:17:9: PT009 Use a regular `assert` instead of unittest-style `assertTrue` - | -15 | self.assertTrue(msg=msg, expr=expr) # Error -16 | self.assertTrue(*(expr, msg)) # Error, unfixable -17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable - | ^^^^^^^^^^^^^^^ PT009 -18 | self.assertTrue(msg=msg, expr=expr, unexpected_arg=False) # Error, unfixable -19 | self.assertTrue(msg=msg) # Error, unfixable - | - = help: Replace `assertTrue(...)` with `assert ...` - -PT009.py:18:9: PT009 Use a regular `assert` instead of unittest-style `assertTrue` - | -16 | self.assertTrue(*(expr, msg)) # Error, unfixable -17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable -18 | self.assertTrue(msg=msg, expr=expr, unexpected_arg=False) # Error, unfixable - | ^^^^^^^^^^^^^^^ PT009 -19 | self.assertTrue(msg=msg) # Error, unfixable -20 | ( - | - = help: Replace `assertTrue(...)` with `assert ...` - -PT009.py:19:9: PT009 Use a regular `assert` instead of unittest-style `assertTrue` - | -17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable -18 | self.assertTrue(msg=msg, expr=expr, unexpected_arg=False) # Error, unfixable -19 | self.assertTrue(msg=msg) # Error, unfixable - | ^^^^^^^^^^^^^^^ PT009 -20 | ( -21 | self.assertIsNotNone(value) # Error, unfixable - | - = help: Replace `assertTrue(...)` with `assert ...` - -PT009.py:21:13: PT009 Use a regular `assert` instead of unittest-style `assertIsNotNone` - | -19 | self.assertTrue(msg=msg) # Error, unfixable -20 | ( -21 | self.assertIsNotNone(value) # Error, unfixable - | ^^^^^^^^^^^^^^^^^^^^ PT009 -22 | if expect_condition -23 | else self.assertIsNone(value) # Error, unfixable - | - = help: Replace `assertIsNotNone(...)` with `assert ...` - -PT009.py:23:18: PT009 Use a regular `assert` instead of unittest-style `assertIsNone` - | -21 | self.assertIsNotNone(value) # Error, unfixable -22 | if expect_condition -23 | else self.assertIsNone(value) # Error, unfixable - | ^^^^^^^^^^^^^^^^^ PT009 -24 | ) -25 | return self.assertEqual(True, False) # Error, unfixable - | - = help: Replace `assertIsNone(...)` with `assert ...` - -PT009.py:25:16: PT009 Use a regular `assert` instead of unittest-style `assertEqual` - | -23 | else self.assertIsNone(value) # Error, unfixable -24 | ) -25 | return self.assertEqual(True, False) # Error, unfixable - | ^^^^^^^^^^^^^^^^ PT009 -26 | -27 | def test_assert_false(self): - | - = help: Replace `assertEqual(...)` with `assert ...` - -PT009.py:28:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertFalse` - | -27 | def test_assert_false(self): -28 | self.assertFalse(True) # Error - | ^^^^^^^^^^^^^^^^ PT009 -29 | -30 | def test_assert_equal(self): - | - = help: Replace `assertFalse(...)` with `assert ...` - -ℹ Suggested fix -25 25 | return self.assertEqual(True, False) # Error, unfixable -26 26 | -27 27 | def test_assert_false(self): -28 |- self.assertFalse(True) # Error - 28 |+ assert not True # Error -29 29 | -30 30 | def test_assert_equal(self): -31 31 | self.assertEqual(1, 2) # Error - -PT009.py:31:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertEqual` - | -30 | def test_assert_equal(self): -31 | self.assertEqual(1, 2) # Error - | ^^^^^^^^^^^^^^^^ PT009 -32 | -33 | def test_assert_not_equal(self): - | - = help: Replace `assertEqual(...)` with `assert ...` - -ℹ Suggested fix -28 28 | self.assertFalse(True) # Error -29 29 | -30 30 | def test_assert_equal(self): -31 |- self.assertEqual(1, 2) # Error - 31 |+ assert 1 == 2 # Error -32 32 | -33 33 | def test_assert_not_equal(self): -34 34 | self.assertNotEqual(1, 1) # Error - -PT009.py:34:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotEqual` - | -33 | def test_assert_not_equal(self): -34 | self.assertNotEqual(1, 1) # Error - | ^^^^^^^^^^^^^^^^^^^ PT009 -35 | -36 | def test_assert_greater(self): - | - = help: Replace `assertNotEqual(...)` with `assert ...` - -ℹ Suggested fix -31 31 | self.assertEqual(1, 2) # Error -32 32 | -33 33 | def test_assert_not_equal(self): -34 |- self.assertNotEqual(1, 1) # Error - 34 |+ assert 1 != 1 # Error -35 35 | -36 36 | def test_assert_greater(self): -37 37 | self.assertGreater(1, 2) # Error - -PT009.py:37:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertGreater` - | -36 | def test_assert_greater(self): -37 | self.assertGreater(1, 2) # Error - | ^^^^^^^^^^^^^^^^^^ PT009 -38 | -39 | def test_assert_greater_equal(self): - | - = help: Replace `assertGreater(...)` with `assert ...` - -ℹ Suggested fix -34 34 | self.assertNotEqual(1, 1) # Error -35 35 | -36 36 | def test_assert_greater(self): -37 |- self.assertGreater(1, 2) # Error - 37 |+ assert 1 > 2 # Error -38 38 | -39 39 | def test_assert_greater_equal(self): -40 40 | self.assertGreaterEqual(1, 2) # Error - -PT009.py:40:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertGreaterEqual` - | -39 | def test_assert_greater_equal(self): -40 | self.assertGreaterEqual(1, 2) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^ PT009 -41 | -42 | def test_assert_less(self): - | - = help: Replace `assertGreaterEqual(...)` with `assert ...` - -ℹ Suggested fix -37 37 | self.assertGreater(1, 2) # Error -38 38 | -39 39 | def test_assert_greater_equal(self): -40 |- self.assertGreaterEqual(1, 2) # Error - 40 |+ assert 1 >= 2 # Error -41 41 | -42 42 | def test_assert_less(self): -43 43 | self.assertLess(2, 1) # Error - -PT009.py:43:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertLess` - | -42 | def test_assert_less(self): -43 | self.assertLess(2, 1) # Error - | ^^^^^^^^^^^^^^^ PT009 -44 | -45 | def test_assert_less_equal(self): - | - = help: Replace `assertLess(...)` with `assert ...` - -ℹ Suggested fix -40 40 | self.assertGreaterEqual(1, 2) # Error -41 41 | -42 42 | def test_assert_less(self): -43 |- self.assertLess(2, 1) # Error - 43 |+ assert 2 < 1 # Error -44 44 | -45 45 | def test_assert_less_equal(self): -46 46 | self.assertLessEqual(1, 2) # Error - -PT009.py:46:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertLessEqual` - | -45 | def test_assert_less_equal(self): -46 | self.assertLessEqual(1, 2) # Error - | ^^^^^^^^^^^^^^^^^^^^ PT009 -47 | -48 | def test_assert_in(self): - | - = help: Replace `assertLessEqual(...)` with `assert ...` - -ℹ Suggested fix -43 43 | self.assertLess(2, 1) # Error -44 44 | -45 45 | def test_assert_less_equal(self): -46 |- self.assertLessEqual(1, 2) # Error - 46 |+ assert 1 <= 2 # Error -47 47 | -48 48 | def test_assert_in(self): -49 49 | self.assertIn(1, [2, 3]) # Error - -PT009.py:49:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIn` - | -48 | def test_assert_in(self): -49 | self.assertIn(1, [2, 3]) # Error - | ^^^^^^^^^^^^^ PT009 -50 | -51 | def test_assert_not_in(self): - | - = help: Replace `assertIn(...)` with `assert ...` - -ℹ Suggested fix -46 46 | self.assertLessEqual(1, 2) # Error -47 47 | -48 48 | def test_assert_in(self): -49 |- self.assertIn(1, [2, 3]) # Error - 49 |+ assert 1 in [2, 3] # Error -50 50 | -51 51 | def test_assert_not_in(self): -52 52 | self.assertNotIn(2, [2, 3]) # Error - -PT009.py:52:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotIn` - | -51 | def test_assert_not_in(self): -52 | self.assertNotIn(2, [2, 3]) # Error - | ^^^^^^^^^^^^^^^^ PT009 -53 | -54 | def test_assert_is_none(self): - | - = help: Replace `assertNotIn(...)` with `assert ...` - -ℹ Suggested fix -49 49 | self.assertIn(1, [2, 3]) # Error -50 50 | -51 51 | def test_assert_not_in(self): -52 |- self.assertNotIn(2, [2, 3]) # Error - 52 |+ assert 2 not in [2, 3] # Error -53 53 | -54 54 | def test_assert_is_none(self): -55 55 | self.assertIsNone(0) # Error - -PT009.py:55:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIsNone` - | -54 | def test_assert_is_none(self): -55 | self.assertIsNone(0) # Error - | ^^^^^^^^^^^^^^^^^ PT009 -56 | -57 | def test_assert_is_not_none(self): - | - = help: Replace `assertIsNone(...)` with `assert ...` - -ℹ Suggested fix -52 52 | self.assertNotIn(2, [2, 3]) # Error -53 53 | -54 54 | def test_assert_is_none(self): -55 |- self.assertIsNone(0) # Error - 55 |+ assert 0 is None # Error -56 56 | -57 57 | def test_assert_is_not_none(self): -58 58 | self.assertIsNotNone(0) # Error - -PT009.py:58:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIsNotNone` - | -57 | def test_assert_is_not_none(self): -58 | self.assertIsNotNone(0) # Error - | ^^^^^^^^^^^^^^^^^^^^ PT009 -59 | -60 | def test_assert_is(self): - | - = help: Replace `assertIsNotNone(...)` with `assert ...` - -ℹ Suggested fix -55 55 | self.assertIsNone(0) # Error -56 56 | -57 57 | def test_assert_is_not_none(self): -58 |- self.assertIsNotNone(0) # Error - 58 |+ assert 0 is not None # Error -59 59 | -60 60 | def test_assert_is(self): -61 61 | self.assertIs([], []) # Error - -PT009.py:61:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIs` - | -60 | def test_assert_is(self): -61 | self.assertIs([], []) # Error - | ^^^^^^^^^^^^^ PT009 -62 | -63 | def test_assert_is_not(self): - | - = help: Replace `assertIs(...)` with `assert ...` - -ℹ Suggested fix -58 58 | self.assertIsNotNone(0) # Error -59 59 | -60 60 | def test_assert_is(self): -61 |- self.assertIs([], []) # Error - 61 |+ assert [] is [] # Error -62 62 | -63 63 | def test_assert_is_not(self): -64 64 | self.assertIsNot(1, 1) # Error - -PT009.py:64:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIsNot` - | -63 | def test_assert_is_not(self): -64 | self.assertIsNot(1, 1) # Error - | ^^^^^^^^^^^^^^^^ PT009 -65 | -66 | def test_assert_is_instance(self): - | - = help: Replace `assertIsNot(...)` with `assert ...` - -ℹ Suggested fix -61 61 | self.assertIs([], []) # Error -62 62 | -63 63 | def test_assert_is_not(self): -64 |- self.assertIsNot(1, 1) # Error - 64 |+ assert 1 is not 1 # Error -65 65 | -66 66 | def test_assert_is_instance(self): -67 67 | self.assertIsInstance(1, str) # Error - -PT009.py:67:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIsInstance` - | -66 | def test_assert_is_instance(self): -67 | self.assertIsInstance(1, str) # Error - | ^^^^^^^^^^^^^^^^^^^^^ PT009 -68 | -69 | def test_assert_is_not_instance(self): - | - = help: Replace `assertIsInstance(...)` with `assert ...` - -ℹ Suggested fix -64 64 | self.assertIsNot(1, 1) # Error -65 65 | -66 66 | def test_assert_is_instance(self): -67 |- self.assertIsInstance(1, str) # Error - 67 |+ assert isinstance(1, str) # Error -68 68 | -69 69 | def test_assert_is_not_instance(self): -70 70 | self.assertNotIsInstance(1, int) # Error - -PT009.py:70:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotIsInstance` - | -69 | def test_assert_is_not_instance(self): -70 | self.assertNotIsInstance(1, int) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^ PT009 -71 | -72 | def test_assert_regex(self): - | - = help: Replace `assertNotIsInstance(...)` with `assert ...` - -ℹ Suggested fix -67 67 | self.assertIsInstance(1, str) # Error -68 68 | -69 69 | def test_assert_is_not_instance(self): -70 |- self.assertNotIsInstance(1, int) # Error - 70 |+ assert not isinstance(1, int) # Error -71 71 | -72 72 | def test_assert_regex(self): -73 73 | self.assertRegex("abc", r"def") # Error - -PT009.py:73:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertRegex` - | -72 | def test_assert_regex(self): -73 | self.assertRegex("abc", r"def") # Error - | ^^^^^^^^^^^^^^^^ PT009 -74 | -75 | def test_assert_not_regex(self): - | - = help: Replace `assertRegex(...)` with `assert ...` - -ℹ Suggested fix -70 70 | self.assertNotIsInstance(1, int) # Error -71 71 | -72 72 | def test_assert_regex(self): -73 |- self.assertRegex("abc", r"def") # Error - 73 |+ assert re.search("def", "abc") # Error -74 74 | -75 75 | def test_assert_not_regex(self): -76 76 | self.assertNotRegex("abc", r"abc") # Error - -PT009.py:76:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotRegex` - | -75 | def test_assert_not_regex(self): -76 | self.assertNotRegex("abc", r"abc") # Error - | ^^^^^^^^^^^^^^^^^^^ PT009 -77 | -78 | def test_assert_regexp_matches(self): - | - = help: Replace `assertNotRegex(...)` with `assert ...` - -ℹ Suggested fix -73 73 | self.assertRegex("abc", r"def") # Error -74 74 | -75 75 | def test_assert_not_regex(self): -76 |- self.assertNotRegex("abc", r"abc") # Error - 76 |+ assert not re.search("abc", "abc") # Error -77 77 | -78 78 | def test_assert_regexp_matches(self): -79 79 | self.assertRegexpMatches("abc", r"def") # Error - -PT009.py:79:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertRegexpMatches` - | -78 | def test_assert_regexp_matches(self): -79 | self.assertRegexpMatches("abc", r"def") # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^ PT009 -80 | -81 | def test_assert_not_regexp_matches(self): - | - = help: Replace `assertRegexpMatches(...)` with `assert ...` - -ℹ Suggested fix -76 76 | self.assertNotRegex("abc", r"abc") # Error -77 77 | -78 78 | def test_assert_regexp_matches(self): -79 |- self.assertRegexpMatches("abc", r"def") # Error - 79 |+ assert re.search("def", "abc") # Error -80 80 | -81 81 | def test_assert_not_regexp_matches(self): -82 82 | self.assertNotRegex("abc", r"abc") # Error - -PT009.py:82:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotRegex` - | -81 | def test_assert_not_regexp_matches(self): -82 | self.assertNotRegex("abc", r"abc") # Error - | ^^^^^^^^^^^^^^^^^^^ PT009 -83 | -84 | def test_fail_if(self): - | - = help: Replace `assertNotRegex(...)` with `assert ...` - -ℹ Suggested fix -79 79 | self.assertRegexpMatches("abc", r"def") # Error -80 80 | -81 81 | def test_assert_not_regexp_matches(self): -82 |- self.assertNotRegex("abc", r"abc") # Error - 82 |+ assert not re.search("abc", "abc") # Error -83 83 | -84 84 | def test_fail_if(self): -85 85 | self.failIf("abc") # Error - -PT009.py:85:9: PT009 [*] Use a regular `assert` instead of unittest-style `failIf` - | -84 | def test_fail_if(self): -85 | self.failIf("abc") # Error - | ^^^^^^^^^^^ PT009 -86 | -87 | def test_fail_unless(self): - | - = help: Replace `failIf(...)` with `assert ...` - -ℹ Suggested fix -82 82 | self.assertNotRegex("abc", r"abc") # Error -83 83 | -84 84 | def test_fail_if(self): -85 |- self.failIf("abc") # Error - 85 |+ assert not "abc" # Error -86 86 | -87 87 | def test_fail_unless(self): -88 88 | self.failUnless("abc") # Error - -PT009.py:88:9: PT009 [*] Use a regular `assert` instead of unittest-style `failUnless` - | -87 | def test_fail_unless(self): -88 | self.failUnless("abc") # Error - | ^^^^^^^^^^^^^^^ PT009 -89 | -90 | def test_fail_unless_equal(self): - | - = help: Replace `failUnless(...)` with `assert ...` - -ℹ Suggested fix -85 85 | self.failIf("abc") # Error -86 86 | -87 87 | def test_fail_unless(self): -88 |- self.failUnless("abc") # Error - 88 |+ assert "abc" # Error -89 89 | -90 90 | def test_fail_unless_equal(self): -91 91 | self.failUnlessEqual(1, 2) # Error - -PT009.py:91:9: PT009 [*] Use a regular `assert` instead of unittest-style `failUnlessEqual` - | -90 | def test_fail_unless_equal(self): -91 | self.failUnlessEqual(1, 2) # Error - | ^^^^^^^^^^^^^^^^^^^^ PT009 -92 | -93 | def test_fail_if_equal(self): - | - = help: Replace `failUnlessEqual(...)` with `assert ...` - -ℹ Suggested fix -88 88 | self.failUnless("abc") # Error -89 89 | -90 90 | def test_fail_unless_equal(self): -91 |- self.failUnlessEqual(1, 2) # Error - 91 |+ assert 1 == 2 # Error -92 92 | -93 93 | def test_fail_if_equal(self): -94 94 | self.failIfEqual(1, 2) # Error - -PT009.py:94:9: PT009 [*] Use a regular `assert` instead of unittest-style `failIfEqual` - | -93 | def test_fail_if_equal(self): -94 | self.failIfEqual(1, 2) # Error - | ^^^^^^^^^^^^^^^^ PT009 - | - = help: Replace `failIfEqual(...)` with `assert ...` - -ℹ Suggested fix -91 91 | self.failUnlessEqual(1, 2) # Error -92 92 | -93 93 | def test_fail_if_equal(self): -94 |- self.failIfEqual(1, 2) # Error - 94 |+ assert 1 != 2 # Error -95 95 | -96 96 | -97 97 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459517 - -PT009.py:98:2: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` - | - 97 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459517 - 98 | (self.assertTrue( - | ^^^^^^^^^^^^^^^ PT009 - 99 | "piAx_piAy_beta[r][x][y] = {17}".format( -100 | self.model.piAx_piAy_beta[r][x][y]))) - | - = help: Replace `assertTrue(...)` with `assert ...` - -ℹ Suggested fix -95 95 | -96 96 | -97 97 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459517 -98 |-(self.assertTrue( -99 |- "piAx_piAy_beta[r][x][y] = {17}".format( -100 |- self.model.piAx_piAy_beta[r][x][y]))) - 98 |+assert "piAx_piAy_beta[r][x][y] = {17}".format(self.model.piAx_piAy_beta[r][x][y]) - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT010.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT010.snap deleted file mode 100644 index 65316534d4..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT010.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT010.py:5:10: PT010 set the expected exception in `pytest.raises()` - | -4 | def test_ok(): -5 | with pytest.raises(): - | ^^^^^^^^^^^^^ PT010 -6 | pass - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_default.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_default.snap deleted file mode 100644 index ca94e0c212..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_default.snap +++ /dev/null @@ -1,47 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT011.py:18:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception - | -17 | def test_error_no_argument_given(): -18 | with pytest.raises(ValueError): - | ^^^^^^^^^^ PT011 -19 | raise ValueError("Can't divide 1 by 0") - | - -PT011.py:21:24: PT011 `pytest.raises(socket.error)` is too broad, set the `match` parameter or use a more specific exception - | -19 | raise ValueError("Can't divide 1 by 0") -20 | -21 | with pytest.raises(socket.error): - | ^^^^^^^^^^^^ PT011 -22 | raise ValueError("Can't divide 1 by 0") - | - -PT011.py:32:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception - | -31 | def test_error_match_is_empty(): -32 | with pytest.raises(ValueError, match=None): - | ^^^^^^^^^^ PT011 -33 | raise ValueError("Can't divide 1 by 0") - | - -PT011.py:35:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception - | -33 | raise ValueError("Can't divide 1 by 0") -34 | -35 | with pytest.raises(ValueError, match=""): - | ^^^^^^^^^^ PT011 -36 | raise ValueError("Can't divide 1 by 0") - | - -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 | -38 | with pytest.raises(ValueError, match=f""): - | ^^^^^^^^^^ PT011 -39 | raise ValueError("Can't divide 1 by 0") - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_extend_broad_exceptions.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_extend_broad_exceptions.snap deleted file mode 100644 index 023618c278..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_extend_broad_exceptions.snap +++ /dev/null @@ -1,55 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT011.py:13:24: PT011 `pytest.raises(ZeroDivisionError)` is too broad, set the `match` parameter or use a more specific exception - | -12 | def test_ok_different_error_from_config(): -13 | with pytest.raises(ZeroDivisionError): - | ^^^^^^^^^^^^^^^^^ PT011 -14 | raise ZeroDivisionError("Can't divide by 0") - | - -PT011.py:18:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception - | -17 | def test_error_no_argument_given(): -18 | with pytest.raises(ValueError): - | ^^^^^^^^^^ PT011 -19 | raise ValueError("Can't divide 1 by 0") - | - -PT011.py:21:24: PT011 `pytest.raises(socket.error)` is too broad, set the `match` parameter or use a more specific exception - | -19 | raise ValueError("Can't divide 1 by 0") -20 | -21 | with pytest.raises(socket.error): - | ^^^^^^^^^^^^ PT011 -22 | raise ValueError("Can't divide 1 by 0") - | - -PT011.py:32:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception - | -31 | def test_error_match_is_empty(): -32 | with pytest.raises(ValueError, match=None): - | ^^^^^^^^^^ PT011 -33 | raise ValueError("Can't divide 1 by 0") - | - -PT011.py:35:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception - | -33 | raise ValueError("Can't divide 1 by 0") -34 | -35 | with pytest.raises(ValueError, match=""): - | ^^^^^^^^^^ PT011 -36 | raise ValueError("Can't divide 1 by 0") - | - -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 | -38 | with pytest.raises(ValueError, match=f""): - | ^^^^^^^^^^ PT011 -39 | raise ValueError("Can't divide 1 by 0") - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_glob_all.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_glob_all.snap deleted file mode 100644 index f10518091d..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_glob_all.snap +++ /dev/null @@ -1,73 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT011.py:13:24: PT011 `pytest.raises(ZeroDivisionError)` is too broad, set the `match` parameter or use a more specific exception - | -12 | def test_ok_different_error_from_config(): -13 | with pytest.raises(ZeroDivisionError): - | ^^^^^^^^^^^^^^^^^ PT011 -14 | raise ZeroDivisionError("Can't divide by 0") - | - -PT011.py:18:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception - | -17 | def test_error_no_argument_given(): -18 | with pytest.raises(ValueError): - | ^^^^^^^^^^ PT011 -19 | raise ValueError("Can't divide 1 by 0") - | - -PT011.py:21:24: PT011 `pytest.raises(socket.error)` is too broad, set the `match` parameter or use a more specific exception - | -19 | raise ValueError("Can't divide 1 by 0") -20 | -21 | with pytest.raises(socket.error): - | ^^^^^^^^^^^^ PT011 -22 | raise ValueError("Can't divide 1 by 0") - | - -PT011.py:24:24: PT011 `pytest.raises(pickle.PicklingError)` is too broad, set the `match` parameter or use a more specific exception - | -22 | raise ValueError("Can't divide 1 by 0") -23 | -24 | with pytest.raises(PicklingError): - | ^^^^^^^^^^^^^ PT011 -25 | raise PicklingError("Can't pickle") - | - -PT011.py:27:24: PT011 `pytest.raises(pickle.UnpicklingError)` is too broad, set the `match` parameter or use a more specific exception - | -25 | raise PicklingError("Can't pickle") -26 | -27 | with pytest.raises(UnpicklingError): - | ^^^^^^^^^^^^^^^ PT011 -28 | raise UnpicklingError("Can't unpickle") - | - -PT011.py:32:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception - | -31 | def test_error_match_is_empty(): -32 | with pytest.raises(ValueError, match=None): - | ^^^^^^^^^^ PT011 -33 | raise ValueError("Can't divide 1 by 0") - | - -PT011.py:35:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception - | -33 | raise ValueError("Can't divide 1 by 0") -34 | -35 | with pytest.raises(ValueError, match=""): - | ^^^^^^^^^^ PT011 -36 | raise ValueError("Can't divide 1 by 0") - | - -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 | -38 | with pytest.raises(ValueError, match=f""): - | ^^^^^^^^^^ PT011 -39 | raise ValueError("Can't divide 1 by 0") - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_glob_prefix.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_glob_prefix.snap deleted file mode 100644 index 53d44920d6..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_glob_prefix.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT011.py:24:24: PT011 `pytest.raises(pickle.PicklingError)` is too broad, set the `match` parameter or use a more specific exception - | -22 | raise ValueError("Can't divide 1 by 0") -23 | -24 | with pytest.raises(PicklingError): - | ^^^^^^^^^^^^^ PT011 -25 | raise PicklingError("Can't pickle") - | - -PT011.py:27:24: PT011 `pytest.raises(pickle.UnpicklingError)` is too broad, set the `match` parameter or use a more specific exception - | -25 | raise PicklingError("Can't pickle") -26 | -27 | with pytest.raises(UnpicklingError): - | ^^^^^^^^^^^^^^^ PT011 -28 | raise UnpicklingError("Can't unpickle") - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_replace_broad_exceptions.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_replace_broad_exceptions.snap deleted file mode 100644 index 9e4a8533c9..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT011_replace_broad_exceptions.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT011.py:13:24: PT011 `pytest.raises(ZeroDivisionError)` is too broad, set the `match` parameter or use a more specific exception - | -12 | def test_ok_different_error_from_config(): -13 | with pytest.raises(ZeroDivisionError): - | ^^^^^^^^^^^^^^^^^ PT011 -14 | raise ZeroDivisionError("Can't divide by 0") - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT012.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT012.snap deleted file mode 100644 index d96e181a2e..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT012.snap +++ /dev/null @@ -1,89 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -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): - | _____^ -43 | | len([]) -44 | | [].size - | |_______________^ PT012 - | - -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): - | _____^ -49 | | if True: -50 | | [].size - | |___________________^ PT012 -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): - | _____^ -53 | | for i in []: -54 | | [].size - | |___________________^ PT012 -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): - | _____^ -57 | | async for i in []: -58 | | [].size - | |___________________^ PT012 -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): - | _____^ -61 | | while True: -62 | | [].size - | |___________________^ PT012 -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): - | _____^ -65 | | async with context_manager_under_test(): -66 | | if True: -67 | | raise Exception - | |_______________________________^ PT012 - | - -PT012.py:71:5: PT012 `pytest.raises()` block should contain a single simple statement - | -70 | def test_error_try(): -71 | with pytest.raises(AttributeError): - | _____^ -72 | | try: -73 | | [].size -74 | | except: -75 | | raise - | |_________________^ PT012 - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT013.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT013.snap deleted file mode 100644 index 965ca83695..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT013.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT013.py:11:1: PT013 Found incorrect import of pytest, use simple `import pytest` instead - | - 9 | # Error -10 | -11 | import pytest as other_name - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT013 -12 | from pytest import fixture -13 | from pytest import fixture as other_name - | - -PT013.py:12:1: PT013 Found incorrect import of pytest, use simple `import pytest` instead - | -11 | import pytest as other_name -12 | from pytest import fixture - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PT013 -13 | from pytest import fixture as other_name - | - -PT013.py:13:1: PT013 Found incorrect import of pytest, use simple `import pytest` instead - | -11 | import pytest as other_name -12 | from pytest import fixture -13 | from pytest import fixture as other_name - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT013 - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT014.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT014.snap deleted file mode 100644 index 091cc25bc4..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT014.snap +++ /dev/null @@ -1,169 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT014.py:4:35: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.parametrize` - | -4 | @pytest.mark.parametrize("x", [1, 1, 2]) - | ^ PT014 -5 | def test_error_literal(x): -6 | ... - | - = help: Remove duplicate test case - -ℹ Suggested fix -1 1 | import pytest -2 2 | -3 3 | -4 |-@pytest.mark.parametrize("x", [1, 1, 2]) - 4 |+@pytest.mark.parametrize("x", [1, 2]) -5 5 | def test_error_literal(x): -6 6 | ... -7 7 | - -PT014.py:14:35: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.parametrize` - | -14 | @pytest.mark.parametrize("x", [a, a, b, b, b, c]) - | ^ PT014 -15 | def test_error_expr_simple(x): -16 | ... - | - = help: Remove duplicate test case - -ℹ Suggested fix -11 11 | c = 3 -12 12 | -13 13 | -14 |-@pytest.mark.parametrize("x", [a, a, b, b, b, c]) - 14 |+@pytest.mark.parametrize("x", [a, b, b, b, c]) -15 15 | def test_error_expr_simple(x): -16 16 | ... -17 17 | - -PT014.py:14:41: PT014 [*] Duplicate of test case at index 2 in `@pytest_mark.parametrize` - | -14 | @pytest.mark.parametrize("x", [a, a, b, b, b, c]) - | ^ PT014 -15 | def test_error_expr_simple(x): -16 | ... - | - = help: Remove duplicate test case - -ℹ Suggested fix -11 11 | c = 3 -12 12 | -13 13 | -14 |-@pytest.mark.parametrize("x", [a, a, b, b, b, c]) - 14 |+@pytest.mark.parametrize("x", [a, a, b, b, c]) -15 15 | def test_error_expr_simple(x): -16 16 | ... -17 17 | - -PT014.py:14:44: PT014 [*] Duplicate of test case at index 2 in `@pytest_mark.parametrize` - | -14 | @pytest.mark.parametrize("x", [a, a, b, b, b, c]) - | ^ PT014 -15 | def test_error_expr_simple(x): -16 | ... - | - = help: Remove duplicate test case - -ℹ Suggested fix -11 11 | c = 3 -12 12 | -13 13 | -14 |-@pytest.mark.parametrize("x", [a, a, b, b, b, c]) - 14 |+@pytest.mark.parametrize("x", [a, a, b, b, c]) -15 15 | def test_error_expr_simple(x): -16 16 | ... -17 17 | - -PT014.py:24:9: PT014 Duplicate of test case at index 0 in `@pytest_mark.parametrize` - | -22 | (a, b), -23 | # comment -24 | (a, b), - | ^^^^^^ PT014 -25 | (b, c), -26 | ], - | - = help: Remove duplicate test case - -PT014.py:32:39: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.parametrize` - | -32 | @pytest.mark.parametrize("x", [a, b, (a), c, ((a))]) - | ^ PT014 -33 | def test_error_parentheses(x): -34 | ... - | - = help: Remove duplicate test case - -ℹ Suggested fix -29 29 | ... -30 30 | -31 31 | -32 |-@pytest.mark.parametrize("x", [a, b, (a), c, ((a))]) - 32 |+@pytest.mark.parametrize("x", [a, b, c, ((a))]) -33 33 | def test_error_parentheses(x): -34 34 | ... -35 35 | - -PT014.py:32:48: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.parametrize` - | -32 | @pytest.mark.parametrize("x", [a, b, (a), c, ((a))]) - | ^ PT014 -33 | def test_error_parentheses(x): -34 | ... - | - = help: Remove duplicate test case - -ℹ Suggested fix -29 29 | ... -30 30 | -31 31 | -32 |-@pytest.mark.parametrize("x", [a, b, (a), c, ((a))]) - 32 |+@pytest.mark.parametrize("x", [a, b, (a), c]) -33 33 | def test_error_parentheses(x): -34 34 | ... -35 35 | - -PT014.py:42:10: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.parametrize` - | -40 | a, -41 | b, -42 | (a), - | ^ PT014 -43 | c, -44 | ((a)), - | - = help: Remove duplicate test case - -ℹ Suggested fix -39 39 | [ -40 40 | a, -41 41 | b, -42 |- (a), -43 42 | c, -44 43 | ((a)), -45 44 | ], - -PT014.py:44:11: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.parametrize` - | -42 | (a), -43 | c, -44 | ((a)), - | ^ PT014 -45 | ], -46 | ) - | - = help: Remove duplicate test case - -ℹ Suggested fix -41 41 | b, -42 42 | (a), -43 43 | c, -44 |- ((a)), -45 44 | ], -46 45 | ) -47 46 | def test_error_parentheses_trailing_comma(x): - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT015.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT015.snap deleted file mode 100644 index 3e5a3f7771..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT015.snap +++ /dev/null @@ -1,170 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT015.py:9:5: PT015 Assertion always fails, replace with `pytest.fail()` - | - 8 | def test_error(): - 9 | assert None - | ^^^^^^^^^^^ PT015 -10 | assert False -11 | assert 0 - | - -PT015.py:10:5: PT015 Assertion always fails, replace with `pytest.fail()` - | - 8 | def test_error(): - 9 | assert None -10 | assert False - | ^^^^^^^^^^^^ PT015 -11 | assert 0 -12 | assert 0.0 - | - -PT015.py:11:5: PT015 Assertion always fails, replace with `pytest.fail()` - | - 9 | assert None -10 | assert False -11 | assert 0 - | ^^^^^^^^ PT015 -12 | assert 0.0 -13 | assert "" - | - -PT015.py:12:5: PT015 Assertion always fails, replace with `pytest.fail()` - | -10 | assert False -11 | assert 0 -12 | assert 0.0 - | ^^^^^^^^^^ PT015 -13 | assert "" -14 | assert f"" - | - -PT015.py:13:5: PT015 Assertion always fails, replace with `pytest.fail()` - | -11 | assert 0 -12 | assert 0.0 -13 | assert "" - | ^^^^^^^^^ PT015 -14 | assert f"" -15 | assert [] - | - -PT015.py:14:5: PT015 Assertion always fails, replace with `pytest.fail()` - | -12 | assert 0.0 -13 | assert "" -14 | assert f"" - | ^^^^^^^^^^ PT015 -15 | assert [] -16 | assert () - | - -PT015.py:15:5: PT015 Assertion always fails, replace with `pytest.fail()` - | -13 | assert "" -14 | assert f"" -15 | assert [] - | ^^^^^^^^^ PT015 -16 | assert () -17 | assert {} - | - -PT015.py:16:5: PT015 Assertion always fails, replace with `pytest.fail()` - | -14 | assert f"" -15 | assert [] -16 | assert () - | ^^^^^^^^^ PT015 -17 | assert {} -18 | assert list() - | - -PT015.py:17:5: PT015 Assertion always fails, replace with `pytest.fail()` - | -15 | assert [] -16 | assert () -17 | assert {} - | ^^^^^^^^^ PT015 -18 | assert list() -19 | assert set() - | - -PT015.py:18:5: PT015 Assertion always fails, replace with `pytest.fail()` - | -16 | assert () -17 | assert {} -18 | assert list() - | ^^^^^^^^^^^^^ PT015 -19 | assert set() -20 | assert tuple() - | - -PT015.py:19:5: PT015 Assertion always fails, replace with `pytest.fail()` - | -17 | assert {} -18 | assert list() -19 | assert set() - | ^^^^^^^^^^^^ PT015 -20 | assert tuple() -21 | assert dict() - | - -PT015.py:20:5: PT015 Assertion always fails, replace with `pytest.fail()` - | -18 | assert list() -19 | assert set() -20 | assert tuple() - | ^^^^^^^^^^^^^^ PT015 -21 | assert dict() -22 | assert frozenset() - | - -PT015.py:21:5: PT015 Assertion always fails, replace with `pytest.fail()` - | -19 | assert set() -20 | assert tuple() -21 | assert dict() - | ^^^^^^^^^^^^^ PT015 -22 | assert frozenset() -23 | assert list([]) - | - -PT015.py:22:5: PT015 Assertion always fails, replace with `pytest.fail()` - | -20 | assert tuple() -21 | assert dict() -22 | assert frozenset() - | ^^^^^^^^^^^^^^^^^^ PT015 -23 | assert list([]) -24 | assert set(set()) - | - -PT015.py:23:5: PT015 Assertion always fails, replace with `pytest.fail()` - | -21 | assert dict() -22 | assert frozenset() -23 | assert list([]) - | ^^^^^^^^^^^^^^^ PT015 -24 | assert set(set()) -25 | assert tuple("") - | - -PT015.py:24:5: PT015 Assertion always fails, replace with `pytest.fail()` - | -22 | assert frozenset() -23 | assert list([]) -24 | assert set(set()) - | ^^^^^^^^^^^^^^^^^ PT015 -25 | assert tuple("") - | - -PT015.py:25:5: PT015 Assertion always fails, replace with `pytest.fail()` - | -23 | assert list([]) -24 | assert set(set()) -25 | assert tuple("") - | ^^^^^^^^^^^^^^^^ PT015 - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT016.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT016.snap deleted file mode 100644 index 945f989567..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT016.snap +++ /dev/null @@ -1,71 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT016.py:19:5: PT016 No message passed to `pytest.fail()` - | -17 | # Errors -18 | def f(): -19 | pytest.fail() - | ^^^^^^^^^^^ PT016 -20 | pytest.fail("") -21 | pytest.fail(f"") - | - -PT016.py:20:5: PT016 No message passed to `pytest.fail()` - | -18 | def f(): -19 | pytest.fail() -20 | pytest.fail("") - | ^^^^^^^^^^^ PT016 -21 | pytest.fail(f"") -22 | pytest.fail(msg="") - | - -PT016.py:21:5: PT016 No message passed to `pytest.fail()` - | -19 | pytest.fail() -20 | pytest.fail("") -21 | pytest.fail(f"") - | ^^^^^^^^^^^ PT016 -22 | pytest.fail(msg="") -23 | pytest.fail(msg=f"") - | - -PT016.py:22:5: PT016 No message passed to `pytest.fail()` - | -20 | pytest.fail("") -21 | pytest.fail(f"") -22 | pytest.fail(msg="") - | ^^^^^^^^^^^ PT016 -23 | pytest.fail(msg=f"") -24 | pytest.fail(reason="") - | - -PT016.py:23:5: PT016 No message passed to `pytest.fail()` - | -21 | pytest.fail(f"") -22 | pytest.fail(msg="") -23 | pytest.fail(msg=f"") - | ^^^^^^^^^^^ PT016 -24 | pytest.fail(reason="") -25 | pytest.fail(reason=f"") - | - -PT016.py:24:5: PT016 No message passed to `pytest.fail()` - | -22 | pytest.fail(msg="") -23 | pytest.fail(msg=f"") -24 | pytest.fail(reason="") - | ^^^^^^^^^^^ PT016 -25 | pytest.fail(reason=f"") - | - -PT016.py:25:5: PT016 No message passed to `pytest.fail()` - | -23 | pytest.fail(msg=f"") -24 | pytest.fail(reason="") -25 | pytest.fail(reason=f"") - | ^^^^^^^^^^^ PT016 - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT017.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT017.snap deleted file mode 100644 index 9cb417a2b4..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT017.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT017.py:19:9: PT017 Found assertion on exception `e` in `except` block, use `pytest.raises()` instead - | -17 | something() -18 | except Exception as e: -19 | assert e.message, "blah blah" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT017 - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT018.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT018.snap deleted file mode 100644 index 1d24f27b3a..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT018.snap +++ /dev/null @@ -1,417 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT018.py:14:5: PT018 [*] Assertion should be broken down into multiple parts - | -13 | def test_error(): -14 | assert something and something_else - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 -15 | assert something and something_else and something_third -16 | assert something and not something_else - | - = help: Break down assertion into multiple parts - -ℹ Suggested fix -11 11 | -12 12 | -13 13 | def test_error(): -14 |- assert something and something_else - 14 |+ assert something - 15 |+ assert something_else -15 16 | assert something and something_else and something_third -16 17 | assert something and not something_else -17 18 | assert something and (something_else or something_third) - -PT018.py:15:5: PT018 [*] Assertion should be broken down into multiple parts - | -13 | def test_error(): -14 | assert something and something_else -15 | assert something and something_else and something_third - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 -16 | assert something and not something_else -17 | assert something and (something_else or something_third) - | - = help: Break down assertion into multiple parts - -ℹ Suggested fix -12 12 | -13 13 | def test_error(): -14 14 | assert something and something_else -15 |- assert something and something_else and something_third - 15 |+ assert something and something_else - 16 |+ assert something_third -16 17 | assert something and not something_else -17 18 | assert something and (something_else or something_third) -18 19 | assert not something and something_else - -PT018.py:16:5: PT018 [*] Assertion should be broken down into multiple parts - | -14 | assert something and something_else -15 | assert something and something_else and something_third -16 | assert something and not something_else - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 -17 | assert something and (something_else or something_third) -18 | assert not something and something_else - | - = help: Break down assertion into multiple parts - -ℹ Suggested fix -13 13 | def test_error(): -14 14 | assert something and something_else -15 15 | assert something and something_else and something_third -16 |- assert something and not something_else - 16 |+ assert something - 17 |+ assert not something_else -17 18 | assert something and (something_else or something_third) -18 19 | assert not something and something_else -19 20 | assert not (something or something_else) - -PT018.py:17:5: PT018 [*] Assertion should be broken down into multiple parts - | -15 | assert something and something_else and something_third -16 | assert something and not something_else -17 | assert something and (something_else or something_third) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 -18 | assert not something and something_else -19 | assert not (something or something_else) - | - = help: Break down assertion into multiple parts - -ℹ Suggested fix -14 14 | assert something and something_else -15 15 | assert something and something_else and something_third -16 16 | assert something and not something_else -17 |- assert something and (something_else or something_third) - 17 |+ assert something - 18 |+ assert (something_else or something_third) -18 19 | assert not something and something_else -19 20 | assert not (something or something_else) -20 21 | assert not (something or something_else or something_third) - -PT018.py:18:5: PT018 [*] Assertion should be broken down into multiple parts - | -16 | assert something and not something_else -17 | assert something and (something_else or something_third) -18 | assert not something and something_else - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 -19 | assert not (something or something_else) -20 | assert not (something or something_else or something_third) - | - = help: Break down assertion into multiple parts - -ℹ Suggested fix -15 15 | assert something and something_else and something_third -16 16 | assert something and not something_else -17 17 | assert something and (something_else or something_third) -18 |- assert not something and something_else - 18 |+ assert not something - 19 |+ assert something_else -19 20 | assert not (something or something_else) -20 21 | assert not (something or something_else or something_third) -21 22 | assert something and something_else == """error - -PT018.py:19:5: PT018 [*] Assertion should be broken down into multiple parts - | -17 | assert something and (something_else or something_third) -18 | assert not something and something_else -19 | assert not (something or something_else) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 -20 | assert not (something or something_else or something_third) -21 | assert something and something_else == """error - | - = help: Break down assertion into multiple parts - -ℹ Suggested fix -16 16 | assert something and not something_else -17 17 | assert something and (something_else or something_third) -18 18 | assert not something and something_else -19 |- assert not (something or something_else) - 19 |+ assert not something - 20 |+ assert not something_else -20 21 | assert not (something or something_else or something_third) -21 22 | assert something and something_else == """error -22 23 | message - -PT018.py:20:5: PT018 [*] Assertion should be broken down into multiple parts - | -18 | assert not something and something_else -19 | assert not (something or something_else) -20 | assert not (something or something_else or something_third) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 -21 | assert something and something_else == """error -22 | message - | - = help: Break down assertion into multiple parts - -ℹ Suggested fix -17 17 | assert something and (something_else or something_third) -18 18 | assert not something and something_else -19 19 | assert not (something or something_else) -20 |- assert not (something or something_else or something_third) - 20 |+ assert not (something or something_else) - 21 |+ assert not something_third -21 22 | assert something and something_else == """error -22 23 | message -23 24 | """ - -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 - | _____^ -22 | | message -23 | | """ - | |_______^ PT018 -24 | assert ( -25 | something - | - = help: Break down assertion into multiple parts - -ℹ Suggested fix -18 18 | assert not something and something_else -19 19 | assert not (something or something_else) -20 20 | assert not (something or something_else or something_third) -21 |- assert something and something_else == """error - 21 |+ assert something - 22 |+ assert something_else == """error -22 23 | message -23 24 | """ -24 25 | assert ( - -PT018.py:24:5: PT018 [*] Assertion should be broken down into multiple parts - | -22 | message -23 | """ -24 | assert ( - | _____^ -25 | | something -26 | | and something_else -27 | | == """error -28 | | message -29 | | """ -30 | | ) - | |_____^ PT018 -31 | -32 | # recursive case - | - = help: Break down assertion into multiple parts - -ℹ Suggested fix -21 21 | assert something and something_else == """error -22 22 | message -23 23 | """ - 24 |+ assert something -24 25 | assert ( -25 |- something -26 |- and something_else - 26 |+ something_else -27 27 | == """error -28 28 | message -29 29 | """ - -PT018.py:33:5: PT018 [*] Assertion should be broken down into multiple parts - | -32 | # recursive case -33 | assert not (a or not (b or c)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 -34 | assert not (a or not (b and c)) - | - = help: Break down assertion into multiple parts - -ℹ Suggested fix -30 30 | ) -31 31 | -32 32 | # recursive case -33 |- assert not (a or not (b or c)) - 33 |+ assert not a - 34 |+ assert (b or c) -34 35 | assert not (a or not (b and c)) -35 36 | -36 37 | # detected, but no autofix for messages - -PT018.py:34:5: PT018 [*] Assertion should be broken down into multiple parts - | -32 | # recursive case -33 | assert not (a or not (b or c)) -34 | assert not (a or not (b and c)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 -35 | -36 | # detected, but no autofix for messages - | - = help: Break down assertion into multiple parts - -ℹ Suggested fix -31 31 | -32 32 | # recursive case -33 33 | assert not (a or not (b or c)) -34 |- assert not (a or not (b and c)) - 34 |+ assert not a - 35 |+ assert (b and c) -35 36 | -36 37 | # detected, but no autofix for messages -37 38 | assert something and something_else, "error message" - -PT018.py:37:5: PT018 Assertion should be broken down into multiple parts - | -36 | # detected, but no autofix for messages -37 | assert something and something_else, "error message" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 -38 | assert not (something or something_else and something_third), "with message" -39 | # detected, but no autofix for mixed conditions (e.g. `a or b and c`) - | - = help: Break down assertion into multiple parts - -PT018.py:38:5: PT018 Assertion should be broken down into multiple parts - | -36 | # detected, but no autofix for messages -37 | assert something and something_else, "error message" -38 | assert not (something or something_else and something_third), "with message" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 -39 | # detected, but no autofix for mixed conditions (e.g. `a or b and c`) -40 | assert not (something or something_else and something_third) - | - = help: Break down assertion into multiple parts - -PT018.py:40:5: PT018 Assertion should be broken down into multiple parts - | -38 | assert not (something or something_else and something_third), "with message" -39 | # detected, but no autofix for mixed conditions (e.g. `a or b and c`) -40 | assert not (something or something_else and something_third) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 - | - = help: Break down assertion into multiple parts - -PT018.py:44:1: PT018 [*] Assertion should be broken down into multiple parts - | -43 | assert something # OK -44 | assert something and something_else # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 -45 | assert something and something_else and something_third # Error - | - = help: Break down assertion into multiple parts - -ℹ Suggested fix -41 41 | -42 42 | -43 43 | assert something # OK -44 |-assert something and something_else # Error - 44 |+assert something - 45 |+assert something_else -45 46 | assert something and something_else and something_third # Error -46 47 | -47 48 | - -PT018.py:45:1: PT018 [*] Assertion should be broken down into multiple parts - | -43 | assert something # OK -44 | assert something and something_else # Error -45 | assert something and something_else and something_third # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 - | - = help: Break down assertion into multiple parts - -ℹ Suggested fix -42 42 | -43 43 | assert something # OK -44 44 | assert something and something_else # Error -45 |-assert something and something_else and something_third # Error - 45 |+assert something and something_else - 46 |+assert something_third -46 47 | -47 48 | -48 49 | def test_multiline(): - -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 | -51 | x = 1; assert something and something_else - | - = help: Break down assertion 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 | -51 | x = 1; assert something and something_else - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 -52 | -53 | x = 1; \ - | - = help: Break down assertion into multiple parts - -PT018.py:54:9: PT018 Assertion should be broken down into multiple parts - | -53 | x = 1; \ -54 | assert something and something_else - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 - | - = help: Break down assertion into multiple parts - -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 ( - | _____^ -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 | -65 | assert (not ( - | - = help: Break down assertion into multiple parts - -ℹ Suggested fix -59 59 | assert not ( -60 60 | self.find_graph_output(node.output[0]) -61 61 | or self.find_graph_input(node.input[0]) -62 |- or self.find_graph_output(node.input[0]) -63 62 | ) - 63 |+ assert not ( - 64 |+ self.find_graph_output(node.input[0]) - 65 |+ ) -64 66 | -65 67 | assert (not ( -66 68 | self.find_graph_output(node.output[0]) - -PT018.py:65:5: PT018 [*] Assertion should be broken down into multiple parts - | -63 | ) -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 | -71 | assert (not self.find_graph_output(node.output[0]) or - | - = help: Break down assertion into multiple parts - -ℹ Suggested fix -62 62 | or self.find_graph_output(node.input[0]) -63 63 | ) -64 64 | -65 |- assert (not ( - 65 |+ assert not ( -66 66 | self.find_graph_output(node.output[0]) -67 67 | or self.find_graph_input(node.input[0]) -68 |- or self.find_graph_output(node.input[0]) -69 |- )) - 68 |+ ) - 69 |+ assert not ( - 70 |+ self.find_graph_output(node.input[0]) - 71 |+ ) -70 72 | -71 73 | assert (not self.find_graph_output(node.output[0]) or -72 74 | self.find_graph_input(node.input[0])) - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT019.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT019.snap deleted file mode 100644 index aac6a03e52..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT019.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT019.py:9:14: PT019 Fixture `_fixture` without value is injected as parameter, use `@pytest.mark.usefixtures` instead - | - 9 | def test_xxx(_fixture): # Error arg - | ^^^^^^^^ PT019 -10 | pass - | - -PT019.py:13:17: PT019 Fixture `_fixture` without value is injected as parameter, use `@pytest.mark.usefixtures` instead - | -13 | def test_xxx(*, _fixture): # Error kwonly - | ^^^^^^^^ PT019 -14 | pass - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT020.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT020.snap deleted file mode 100644 index 258108b551..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT020.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT020.py:14:1: PT020 `@pytest.yield_fixture` is deprecated, use `@pytest.fixture` - | -14 | @pytest.yield_fixture() - | ^^^^^^^^^^^^^^^^^^^^^^^ PT020 -15 | def error_without_parens(): -16 | return 0 - | - -PT020.py:19:1: PT020 `@pytest.yield_fixture` is deprecated, use `@pytest.fixture` - | -19 | @pytest.yield_fixture - | ^^^^^^^^^^^^^^^^^^^^^ PT020 -20 | def error_with_parens(): -21 | return 0 - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT021.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT021.snap deleted file mode 100644 index f8ccf4b84c..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT021.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT021.py:49:5: PT021 Use `yield` instead of `request.addfinalizer` - | -47 | def my_fixture(request): # Error return -48 | resource = acquire_resource() -49 | request.addfinalizer(resource.release) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT021 -50 | return resource - | - -PT021.py:56:5: PT021 Use `yield` instead of `request.addfinalizer` - | -54 | def my_fixture(request): # Error yield -55 | resource = acquire_resource() -56 | request.addfinalizer(resource.release) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT021 -57 | yield resource -58 | resource # prevent PT022 - | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT022.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT022.snap deleted file mode 100644 index 96594ee97c..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT022.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT022.py:17:5: PT022 [*] No teardown in fixture `error`, use `return` instead of `yield` - | -15 | def error(): -16 | resource = acquire_resource() -17 | yield resource - | ^^^^^^^^^^^^^^ PT022 - | - = help: Replace `yield` with `return` - -ℹ Fix -14 14 | @pytest.fixture() -15 15 | def error(): -16 16 | resource = acquire_resource() -17 |- yield resource - 17 |+ return resource - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT023_default.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT023_default.snap deleted file mode 100644 index 03d769bf5a..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT023_default.snap +++ /dev/null @@ -1,103 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT023.py:12:1: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` - | -12 | @pytest.mark.foo - | ^^^^^^^^^^^^^^^^ PT023 -13 | def test_something(): -14 | pass - | - = help: Add/remove parentheses - -ℹ Fix -9 9 | # Without parentheses -10 10 | -11 11 | -12 |-@pytest.mark.foo - 12 |+@pytest.mark.foo() -13 13 | def test_something(): -14 14 | pass -15 15 | - -PT023.py:17:1: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` - | -17 | @pytest.mark.foo - | ^^^^^^^^^^^^^^^^ PT023 -18 | class TestClass: -19 | def test_something(): - | - = help: Add/remove parentheses - -ℹ Fix -14 14 | pass -15 15 | -16 16 | -17 |-@pytest.mark.foo - 17 |+@pytest.mark.foo() -18 18 | class TestClass: -19 19 | def test_something(): -20 20 | pass - -PT023.py:24:5: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` - | -23 | class TestClass: -24 | @pytest.mark.foo - | ^^^^^^^^^^^^^^^^ PT023 -25 | def test_something(): -26 | pass - | - = help: Add/remove parentheses - -ℹ Fix -21 21 | -22 22 | -23 23 | class TestClass: -24 |- @pytest.mark.foo - 24 |+ @pytest.mark.foo() -25 25 | def test_something(): -26 26 | pass -27 27 | - -PT023.py:30:5: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` - | -29 | class TestClass: -30 | @pytest.mark.foo - | ^^^^^^^^^^^^^^^^ PT023 -31 | class TestNestedClass: -32 | def test_something(): - | - = help: Add/remove parentheses - -ℹ Fix -27 27 | -28 28 | -29 29 | class TestClass: -30 |- @pytest.mark.foo - 30 |+ @pytest.mark.foo() -31 31 | class TestNestedClass: -32 32 | def test_something(): -33 33 | pass - -PT023.py:38:9: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` - | -36 | class TestClass: -37 | class TestNestedClass: -38 | @pytest.mark.foo - | ^^^^^^^^^^^^^^^^ PT023 -39 | def test_something(): -40 | pass - | - = help: Add/remove parentheses - -ℹ Fix -35 35 | -36 36 | class TestClass: -37 37 | class TestNestedClass: -38 |- @pytest.mark.foo - 38 |+ @pytest.mark.foo() -39 39 | def test_something(): -40 40 | pass -41 41 | - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT023_no_parentheses.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT023_no_parentheses.snap deleted file mode 100644 index 8a049d4f70..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT023_no_parentheses.snap +++ /dev/null @@ -1,102 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT023.py:46:1: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` - | -46 | @pytest.mark.foo() - | ^^^^^^^^^^^^^^^^^^ PT023 -47 | def test_something(): -48 | pass - | - = help: Add/remove parentheses - -ℹ Fix -43 43 | # With parentheses -44 44 | -45 45 | -46 |-@pytest.mark.foo() - 46 |+@pytest.mark.foo -47 47 | def test_something(): -48 48 | pass -49 49 | - -PT023.py:51:1: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` - | -51 | @pytest.mark.foo() - | ^^^^^^^^^^^^^^^^^^ PT023 -52 | class TestClass: -53 | def test_something(): - | - = help: Add/remove parentheses - -ℹ Fix -48 48 | pass -49 49 | -50 50 | -51 |-@pytest.mark.foo() - 51 |+@pytest.mark.foo -52 52 | class TestClass: -53 53 | def test_something(): -54 54 | pass - -PT023.py:58:5: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` - | -57 | class TestClass: -58 | @pytest.mark.foo() - | ^^^^^^^^^^^^^^^^^^ PT023 -59 | def test_something(): -60 | pass - | - = help: Add/remove parentheses - -ℹ Fix -55 55 | -56 56 | -57 57 | class TestClass: -58 |- @pytest.mark.foo() - 58 |+ @pytest.mark.foo -59 59 | def test_something(): -60 60 | pass -61 61 | - -PT023.py:64:5: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` - | -63 | class TestClass: -64 | @pytest.mark.foo() - | ^^^^^^^^^^^^^^^^^^ PT023 -65 | class TestNestedClass: -66 | def test_something(): - | - = help: Add/remove parentheses - -ℹ Fix -61 61 | -62 62 | -63 63 | class TestClass: -64 |- @pytest.mark.foo() - 64 |+ @pytest.mark.foo -65 65 | class TestNestedClass: -66 66 | def test_something(): -67 67 | pass - -PT023.py:72:9: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` - | -70 | class TestClass: -71 | class TestNestedClass: -72 | @pytest.mark.foo() - | ^^^^^^^^^^^^^^^^^^ PT023 -73 | def test_something(): -74 | pass - | - = help: Add/remove parentheses - -ℹ Fix -69 69 | -70 70 | class TestClass: -71 71 | class TestNestedClass: -72 |- @pytest.mark.foo() - 72 |+ @pytest.mark.foo -73 73 | def test_something(): -74 74 | pass - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT024.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT024.snap deleted file mode 100644 index 14fd58d9d6..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT024.snap +++ /dev/null @@ -1,77 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT024.py:14:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures - | -14 | @pytest.mark.asyncio() - | ^^^^^^^^^^^^^^^^^^^^^^ PT024 -15 | @pytest.fixture() -16 | async def my_fixture(): # Error before - | - = help: Remove `pytest.mark.asyncio` - -ℹ Fix -11 11 | pass -12 12 | -13 13 | -14 |-@pytest.mark.asyncio() -15 14 | @pytest.fixture() -16 15 | async def my_fixture(): # Error before -17 16 | return 0 - -PT024.py:20:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures - | -20 | @pytest.mark.asyncio - | ^^^^^^^^^^^^^^^^^^^^ PT024 -21 | @pytest.fixture() -22 | async def my_fixture(): # Error before no parens - | - = help: Remove `pytest.mark.asyncio` - -ℹ Fix -17 17 | return 0 -18 18 | -19 19 | -20 |-@pytest.mark.asyncio -21 20 | @pytest.fixture() -22 21 | async def my_fixture(): # Error before no parens -23 22 | return 0 - -PT024.py:27:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures - | -26 | @pytest.fixture() -27 | @pytest.mark.asyncio() - | ^^^^^^^^^^^^^^^^^^^^^^ PT024 -28 | async def my_fixture(): # Error after -29 | return 0 - | - = help: Remove `pytest.mark.asyncio` - -ℹ Fix -24 24 | -25 25 | -26 26 | @pytest.fixture() -27 |-@pytest.mark.asyncio() -28 27 | async def my_fixture(): # Error after -29 28 | return 0 -30 29 | - -PT024.py:33:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures - | -32 | @pytest.fixture() -33 | @pytest.mark.asyncio - | ^^^^^^^^^^^^^^^^^^^^ PT024 -34 | async def my_fixture(): # Error after no parens -35 | return 0 - | - = help: Remove `pytest.mark.asyncio` - -ℹ Fix -30 30 | -31 31 | -32 32 | @pytest.fixture() -33 |-@pytest.mark.asyncio -34 33 | async def my_fixture(): # Error after no parens -35 34 | return 0 - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT025.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT025.snap deleted file mode 100644 index 181945326c..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT025.snap +++ /dev/null @@ -1,40 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT025.py:9:1: PT025 [*] `pytest.mark.usefixtures` has no effect on fixtures - | - 9 | @pytest.mark.usefixtures("a") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT025 -10 | @pytest.fixture() -11 | def my_fixture(): # Error before - | - = help: Remove `pytest.mark.usefixtures` - -ℹ Fix -6 6 | pass -7 7 | -8 8 | -9 |-@pytest.mark.usefixtures("a") -10 9 | @pytest.fixture() -11 10 | def my_fixture(): # Error before -12 11 | return 0 - -PT025.py:16:1: PT025 [*] `pytest.mark.usefixtures` has no effect on fixtures - | -15 | @pytest.fixture() -16 | @pytest.mark.usefixtures("a") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT025 -17 | def my_fixture(): # Error after -18 | return 0 - | - = help: Remove `pytest.mark.usefixtures` - -ℹ Fix -13 13 | -14 14 | -15 15 | @pytest.fixture() -16 |-@pytest.mark.usefixtures("a") -17 16 | def my_fixture(): # Error after -18 17 | return 0 - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT026.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT026.snap deleted file mode 100644 index 1b22f5b2c9..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT026.snap +++ /dev/null @@ -1,41 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT026.py:19:1: PT026 [*] Useless `pytest.mark.usefixtures` without parameters - | -19 | @pytest.mark.usefixtures() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PT026 -20 | def test_error_with_parens(): -21 | pass - | - = help: Remove `usefixtures` decorator or pass parameters - -ℹ Suggested fix -16 16 | pass -17 17 | -18 18 | -19 |-@pytest.mark.usefixtures() - 19 |+ -20 20 | def test_error_with_parens(): -21 21 | pass -22 22 | - -PT026.py:24:1: PT026 [*] Useless `pytest.mark.usefixtures` without parameters - | -24 | @pytest.mark.usefixtures - | ^^^^^^^^^^^^^^^^^^^^^^^^ PT026 -25 | def test_error_no_parens(): -26 | pass - | - = help: Remove `usefixtures` decorator or pass parameters - -ℹ Suggested fix -21 21 | pass -22 22 | -23 23 | -24 |-@pytest.mark.usefixtures - 24 |+ -25 25 | def test_error_no_parens(): -26 26 | pass - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT027_0.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT027_0.snap deleted file mode 100644 index 8ac1da881c..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT027_0.snap +++ /dev/null @@ -1,248 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT027_0.py:6:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` - | -4 | class Test(unittest.TestCase): -5 | def test_errors(self): -6 | with self.assertRaises(ValueError): - | ^^^^^^^^^^^^^^^^^ PT027 -7 | raise ValueError -8 | with self.assertRaises(expected_exception=ValueError): - | - = help: Replace `assertRaises` with `pytest.raises` - -ℹ Suggested fix -1 1 | import unittest - 2 |+import pytest -2 3 | -3 4 | -4 5 | class Test(unittest.TestCase): -5 6 | def test_errors(self): -6 |- with self.assertRaises(ValueError): - 7 |+ with pytest.raises(ValueError): -7 8 | raise ValueError -8 9 | with self.assertRaises(expected_exception=ValueError): -9 10 | raise ValueError - -PT027_0.py:8:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` - | -6 | with self.assertRaises(ValueError): -7 | raise ValueError -8 | with self.assertRaises(expected_exception=ValueError): - | ^^^^^^^^^^^^^^^^^ PT027 -9 | raise ValueError - | - = help: Replace `assertRaises` with `pytest.raises` - -ℹ Suggested fix -1 1 | import unittest - 2 |+import pytest -2 3 | -3 4 | -4 5 | class Test(unittest.TestCase): -5 6 | def test_errors(self): -6 7 | with self.assertRaises(ValueError): -7 8 | raise ValueError -8 |- with self.assertRaises(expected_exception=ValueError): - 9 |+ with pytest.raises(ValueError): -9 10 | raise ValueError -10 11 | -11 12 | with self.failUnlessRaises(ValueError): - -PT027_0.py:11:14: PT027 [*] Use `pytest.raises` instead of unittest-style `failUnlessRaises` - | - 9 | raise ValueError -10 | -11 | with self.failUnlessRaises(ValueError): - | ^^^^^^^^^^^^^^^^^^^^^ PT027 -12 | raise ValueError - | - = help: Replace `failUnlessRaises` with `pytest.raises` - -ℹ Suggested fix -1 1 | import unittest - 2 |+import pytest -2 3 | -3 4 | -4 5 | class Test(unittest.TestCase): --------------------------------------------------------------------------------- -8 9 | with self.assertRaises(expected_exception=ValueError): -9 10 | raise ValueError -10 11 | -11 |- with self.failUnlessRaises(ValueError): - 12 |+ with pytest.raises(ValueError): -12 13 | raise ValueError -13 14 | -14 15 | with self.assertRaisesRegex(ValueError, "test"): - -PT027_0.py:14:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` - | -12 | raise ValueError -13 | -14 | with self.assertRaisesRegex(ValueError, "test"): - | ^^^^^^^^^^^^^^^^^^^^^^ PT027 -15 | raise ValueError("test") - | - = help: Replace `assertRaisesRegex` with `pytest.raises` - -ℹ Suggested fix -1 1 | import unittest - 2 |+import pytest -2 3 | -3 4 | -4 5 | class Test(unittest.TestCase): --------------------------------------------------------------------------------- -11 12 | with self.failUnlessRaises(ValueError): -12 13 | raise ValueError -13 14 | -14 |- with self.assertRaisesRegex(ValueError, "test"): - 15 |+ with pytest.raises(ValueError, match="test"): -15 16 | raise ValueError("test") -16 17 | -17 18 | with self.assertRaisesRegex(ValueError, expected_regex="test"): - -PT027_0.py:17:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` - | -15 | raise ValueError("test") -16 | -17 | with self.assertRaisesRegex(ValueError, expected_regex="test"): - | ^^^^^^^^^^^^^^^^^^^^^^ PT027 -18 | raise ValueError("test") - | - = help: Replace `assertRaisesRegex` with `pytest.raises` - -ℹ Suggested fix -1 1 | import unittest - 2 |+import pytest -2 3 | -3 4 | -4 5 | class Test(unittest.TestCase): --------------------------------------------------------------------------------- -14 15 | with self.assertRaisesRegex(ValueError, "test"): -15 16 | raise ValueError("test") -16 17 | -17 |- with self.assertRaisesRegex(ValueError, expected_regex="test"): - 18 |+ with pytest.raises(ValueError, match="test"): -18 19 | raise ValueError("test") -19 20 | -20 21 | with self.assertRaisesRegex( - -PT027_0.py:20:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` - | -18 | raise ValueError("test") -19 | -20 | with self.assertRaisesRegex( - | ^^^^^^^^^^^^^^^^^^^^^^ PT027 -21 | expected_exception=ValueError, expected_regex="test" -22 | ): - | - = help: Replace `assertRaisesRegex` with `pytest.raises` - -ℹ Suggested fix -1 1 | import unittest - 2 |+import pytest -2 3 | -3 4 | -4 5 | class Test(unittest.TestCase): --------------------------------------------------------------------------------- -17 18 | with self.assertRaisesRegex(ValueError, expected_regex="test"): -18 19 | raise ValueError("test") -19 20 | -20 |- with self.assertRaisesRegex( -21 |- expected_exception=ValueError, expected_regex="test" -22 |- ): - 21 |+ with pytest.raises(ValueError, match="test"): -23 22 | raise ValueError("test") -24 23 | -25 24 | with self.assertRaisesRegex( - -PT027_0.py:25:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` - | -23 | raise ValueError("test") -24 | -25 | with self.assertRaisesRegex( - | ^^^^^^^^^^^^^^^^^^^^^^ PT027 -26 | expected_regex="test", expected_exception=ValueError -27 | ): - | - = help: Replace `assertRaisesRegex` with `pytest.raises` - -ℹ Suggested fix -1 1 | import unittest - 2 |+import pytest -2 3 | -3 4 | -4 5 | class Test(unittest.TestCase): --------------------------------------------------------------------------------- -22 23 | ): -23 24 | raise ValueError("test") -24 25 | -25 |- with self.assertRaisesRegex( -26 |- expected_regex="test", expected_exception=ValueError -27 |- ): - 26 |+ with pytest.raises(ValueError, match="test"): -28 27 | raise ValueError("test") -29 28 | -30 29 | with self.assertRaisesRegexp(ValueError, "test"): - -PT027_0.py:30:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegexp` - | -28 | raise ValueError("test") -29 | -30 | with self.assertRaisesRegexp(ValueError, "test"): - | ^^^^^^^^^^^^^^^^^^^^^^^ PT027 -31 | raise ValueError("test") - | - = help: Replace `assertRaisesRegexp` with `pytest.raises` - -ℹ Suggested fix -1 1 | import unittest - 2 |+import pytest -2 3 | -3 4 | -4 5 | class Test(unittest.TestCase): --------------------------------------------------------------------------------- -27 28 | ): -28 29 | raise ValueError("test") -29 30 | -30 |- with self.assertRaisesRegexp(ValueError, "test"): - 31 |+ with pytest.raises(ValueError, match="test"): -31 32 | raise ValueError("test") -32 33 | -33 34 | def test_unfixable_errors(self): - -PT027_0.py:34:14: PT027 Use `pytest.raises` instead of unittest-style `assertRaises` - | -33 | def test_unfixable_errors(self): -34 | with self.assertRaises(ValueError, msg="msg"): - | ^^^^^^^^^^^^^^^^^ PT027 -35 | raise ValueError - | - = help: Replace `assertRaises` with `pytest.raises` - -PT027_0.py:37:14: PT027 Use `pytest.raises` instead of unittest-style `assertRaises` - | -35 | raise ValueError -36 | -37 | with self.assertRaises( - | ^^^^^^^^^^^^^^^^^ PT027 -38 | # comment -39 | ValueError - | - = help: Replace `assertRaises` with `pytest.raises` - -PT027_0.py:44:13: PT027 Use `pytest.raises` instead of unittest-style `assertRaises` - | -43 | with ( -44 | self - | _____________^ -45 | | # comment -46 | | .assertRaises(ValueError) - | |_________________________^ PT027 -47 | ): -48 | raise ValueError - | - = help: Replace `assertRaises` with `pytest.raises` - - diff --git a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT027_1.snap b/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT027_1.snap deleted file mode 100644 index 7656398481..0000000000 --- a/crates/ruff/src/rules/flake8_pytest_style/snapshots/ruff__rules__flake8_pytest_style__tests__PT027_1.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_pytest_style/mod.rs ---- -PT027_1.py:11:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` - | -10 | def test_errors(self): -11 | with self.assertRaises(ValueError): - | ^^^^^^^^^^^^^^^^^ PT027 -12 | raise ValueError - | - = help: Replace `assertRaises` with `pytest.raises` - -ℹ Suggested fix -8 8 | raise ValueError -9 9 | -10 10 | def test_errors(self): -11 |- with self.assertRaises(ValueError): - 11 |+ with pytest.raises(ValueError): -12 12 | raise ValueError - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles.py.snap deleted file mode 100644 index 00664f2737..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles.py.snap +++ /dev/null @@ -1,131 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -docstring_doubles.py:5:1: Q001 [*] Double quote multiline found but single quotes preferred - | -3 | """ -4 | -5 | / """ -6 | | this is not a docstring -7 | | """ - | |___^ Q001 -8 | -9 | l = [] - | - = help: Replace double multiline quotes with single quotes - -ℹ Fix -2 2 | Double quotes multiline module docstring -3 3 | """ -4 4 | -5 |-""" - 5 |+''' -6 6 | this is not a docstring -7 |-""" - 7 |+''' -8 8 | -9 9 | l = [] -10 10 | - -docstring_doubles.py:16:5: Q001 [*] Double quote multiline found but single quotes preferred - | -14 | """ -15 | -16 | """ - | _____^ -17 | | this is not a docstring -18 | | """ - | |_______^ Q001 -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 - -ℹ Fix -13 13 | Double quotes multiline class docstring -14 14 | """ -15 15 | -16 |- """ - 16 |+ ''' -17 17 | this is not a docstring -18 |- """ - 18 |+ ''' -19 19 | -20 20 | # The colon in the list indexing below is an edge case for the docstring scanner -21 21 | def f(self, bar=""" - -docstring_doubles.py:21:21: Q001 [*] Double quote multiline found but single quotes preferred - | -20 | # The colon in the list indexing below is an edge case for the docstring scanner -21 | def f(self, bar=""" - | _____________________^ -22 | | definitely not a docstring""", - | |_____________________________________^ Q001 -23 | val=l[Cls():3]): -24 | """ - | - = help: Replace double multiline quotes with single quotes - -ℹ Fix -18 18 | """ -19 19 | -20 20 | # The colon in the list indexing below is an edge case for the docstring scanner -21 |- def f(self, bar=""" -22 |- definitely not a docstring""", - 21 |+ def f(self, bar=''' - 22 |+ definitely not a docstring''', -23 23 | val=l[Cls():3]): -24 24 | """ -25 25 | Double quotes multiline function docstring - -docstring_doubles.py:30:9: Q001 [*] Double quote multiline found but single quotes preferred - | -28 | some_expression = 'hello world' -29 | -30 | """ - | _________^ -31 | | this is not a docstring -32 | | """ - | |___________^ Q001 -33 | -34 | if l: - | - = help: Replace double multiline quotes with single quotes - -ℹ Fix -27 27 | -28 28 | some_expression = 'hello world' -29 29 | -30 |- """ - 30 |+ ''' -31 31 | this is not a docstring -32 |- """ - 32 |+ ''' -33 33 | -34 34 | if l: -35 35 | """ - -docstring_doubles.py:35:13: Q001 [*] Double quote multiline found but single quotes preferred - | -34 | if l: -35 | """ - | _____________^ -36 | | Looks like a docstring, but in reality it isn't - only modules, classes and functions -37 | | """ - | |_______________^ Q001 -38 | pass - | - = help: Replace double multiline quotes with single quotes - -ℹ Fix -32 32 | """ -33 33 | -34 34 | if l: -35 |- """ - 35 |+ ''' -36 36 | Looks like a docstring, but in reality it isn't - only modules, classes and functions -37 |- """ - 37 |+ ''' -38 38 | pass - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_class.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_class.py.snap deleted file mode 100644 index 1cac8d3b14..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_class.py.snap +++ /dev/null @@ -1,45 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -docstring_doubles_class.py:3:5: Q001 [*] Double quote multiline found but single quotes preferred - | -1 | class SingleLineDocstrings(): -2 | """ Double quotes single line class docstring """ -3 | """ Not a docstring """ - | ^^^^^^^^^^^^^^^^^^^^^^^ Q001 -4 | -5 | def foo(self, bar="""not a docstring"""): - | - = help: Replace double multiline quotes with single quotes - -ℹ Fix -1 1 | class SingleLineDocstrings(): -2 2 | """ Double quotes single line class docstring """ -3 |- """ Not a docstring """ - 3 |+ ''' Not a docstring ''' -4 4 | -5 5 | def foo(self, bar="""not a docstring"""): -6 6 | """ Double quotes single line method docstring""" - -docstring_doubles_class.py:5:23: Q001 [*] Double quote multiline found but single quotes preferred - | -3 | """ Not a docstring """ -4 | -5 | def foo(self, bar="""not a docstring"""): - | ^^^^^^^^^^^^^^^^^^^^^ Q001 -6 | """ Double quotes single line method docstring""" -7 | pass - | - = help: Replace double multiline quotes with single quotes - -ℹ Fix -2 2 | """ Double quotes single line class docstring """ -3 3 | """ Not a docstring """ -4 4 | -5 |- def foo(self, bar="""not a docstring"""): - 5 |+ def foo(self, bar='''not a docstring'''): -6 6 | """ Double quotes single line method docstring""" -7 7 | pass -8 8 | - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_function.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_function.py.snap deleted file mode 100644 index 561aba67da..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_function.py.snap +++ /dev/null @@ -1,106 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -docstring_doubles_function.py:3:5: Q001 [*] Double quote multiline found but single quotes preferred - | -1 | def foo(): -2 | """function without params, single line docstring""" -3 | """ not a docstring""" - | ^^^^^^^^^^^^^^^^^^^^^^ Q001 -4 | return - | - = help: Replace double multiline quotes with single quotes - -ℹ Fix -1 1 | def foo(): -2 2 | """function without params, single line docstring""" -3 |- """ not a docstring""" - 3 |+ ''' not a docstring''' -4 4 | return -5 5 | -6 6 | - -docstring_doubles_function.py:11:5: Q001 [*] Double quote multiline found but single quotes preferred - | - 9 | function without params, multiline docstring -10 | """ -11 | """ not a docstring""" - | ^^^^^^^^^^^^^^^^^^^^^^ Q001 -12 | return - | - = help: Replace double multiline quotes with single quotes - -ℹ Fix -8 8 | """ -9 9 | function without params, multiline docstring -10 10 | """ -11 |- """ not a docstring""" - 11 |+ ''' not a docstring''' -12 12 | return -13 13 | -14 14 | - -docstring_doubles_function.py:15:39: Q001 [*] Double quote multiline found but single quotes preferred - | -15 | def fun_with_params_no_docstring(a, b=""" - | _______________________________________^ -16 | | not a -17 | | """ """docstring"""): - | |___^ Q001 -18 | pass - | - = help: Replace double multiline quotes with single quotes - -ℹ Fix -12 12 | return -13 13 | -14 14 | -15 |-def fun_with_params_no_docstring(a, b=""" - 15 |+def fun_with_params_no_docstring(a, b=''' -16 16 | not a -17 |-""" """docstring"""): - 17 |+''' """docstring"""): -18 18 | pass -19 19 | -20 20 | - -docstring_doubles_function.py:17:5: Q001 [*] Double quote multiline found but single quotes preferred - | -15 | def fun_with_params_no_docstring(a, b=""" -16 | not a -17 | """ """docstring"""): - | ^^^^^^^^^^^^^^^ Q001 -18 | pass - | - = help: Replace double multiline quotes with single quotes - -ℹ Fix -14 14 | -15 15 | def fun_with_params_no_docstring(a, b=""" -16 16 | not a -17 |-""" """docstring"""): - 17 |+""" '''docstring'''): -18 18 | pass -19 19 | -20 20 | - -docstring_doubles_function.py:22:5: Q001 [*] Double quote multiline found but single quotes preferred - | -21 | def fun_with_params_no_docstring2(a, b=c[foo():], c=\ -22 | """ not a docstring """): - | ^^^^^^^^^^^^^^^^^^^^^^^ Q001 -23 | pass - | - = help: Replace double multiline quotes with single quotes - -ℹ Fix -19 19 | -20 20 | -21 21 | def fun_with_params_no_docstring2(a, b=c[foo():], c=\ -22 |- """ not a docstring """): - 22 |+ ''' not a docstring '''): -23 23 | pass -24 24 | -25 25 | - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_multiline.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_multiline.py.snap deleted file mode 100644 index dc6f5236d4..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_multiline.py.snap +++ /dev/null @@ -1,51 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -docstring_doubles_module_multiline.py:4:1: Q001 [*] Double quote multiline found but single quotes preferred - | -2 | Double quotes multiline module docstring -3 | """ -4 | / """ -5 | | this is not a docstring -6 | | """ - | |___^ Q001 -7 | def foo(): -8 | pass - | - = help: Replace double multiline quotes with single quotes - -ℹ Fix -1 1 | """ -2 2 | Double quotes multiline module docstring -3 3 | """ -4 |-""" - 4 |+''' -5 5 | this is not a docstring -6 |-""" - 6 |+''' -7 7 | def foo(): -8 8 | pass -9 9 | """ - -docstring_doubles_module_multiline.py:9:1: Q001 [*] Double quote multiline found but single quotes preferred - | - 7 | def foo(): - 8 | pass - 9 | / """ -10 | | this is not a docstring -11 | | """ - | |___^ Q001 - | - = help: Replace double multiline quotes with single quotes - -ℹ Fix -6 6 | """ -7 7 | def foo(): -8 8 | pass -9 |-""" - 9 |+''' -10 10 | this is not a docstring -11 |-""" - 11 |+''' - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_singleline.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_singleline.py.snap deleted file mode 100644 index 86ca4127b2..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_singleline.py.snap +++ /dev/null @@ -1,38 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -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 | -4 | def foo(): - | - = help: Replace double multiline quotes with single quotes - -ℹ Fix -1 1 | """ Double quotes singleline module docstring """ -2 |-""" this is not a docstring """ - 2 |+''' this is not a docstring ''' -3 3 | -4 4 | def foo(): -5 5 | pass - -docstring_doubles_module_singleline.py:6:1: Q001 [*] Double quote multiline found but single quotes preferred - | -4 | def foo(): -5 | pass -6 | """ this is not a docstring """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q001 - | - = help: Replace double multiline quotes with single quotes - -ℹ Fix -3 3 | -4 4 | def foo(): -5 5 | pass -6 |-""" this is not a docstring """ - 6 |+''' this is not a docstring ''' - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles.py.snap deleted file mode 100644 index 2315b0b9f0..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles.py.snap +++ /dev/null @@ -1,79 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -docstring_singles.py:1:1: Q002 [*] Single quote docstring found but double quotes preferred - | -1 | / ''' -2 | | Single quotes multiline module docstring -3 | | ''' - | |___^ Q002 -4 | -5 | ''' - | - = help: Replace single quotes docstring with double quotes - -ℹ Fix -1 |-''' - 1 |+""" -2 2 | Single quotes multiline module docstring -3 |-''' - 3 |+""" -4 4 | -5 5 | ''' -6 6 | this is not a docstring - -docstring_singles.py:14:5: Q002 [*] Single quote docstring found but double quotes preferred - | -12 | class params \t not a docstring -13 | ''')): -14 | ''' - | _____^ -15 | | Single quotes multiline class docstring -16 | | ''' - | |_______^ Q002 -17 | -18 | ''' - | - = help: Replace single quotes docstring with double quotes - -ℹ Fix -11 11 | class Cls(MakeKlass(''' -12 12 | class params \t not a docstring -13 13 | ''')): -14 |- ''' - 14 |+ """ -15 15 | Single quotes multiline class docstring -16 |- ''' - 16 |+ """ -17 17 | -18 18 | ''' -19 19 | this is not a docstring - -docstring_singles.py:26:9: Q002 [*] Single quote docstring found but double quotes preferred - | -24 | definitely not a docstring''', -25 | val=l[Cls():3]): -26 | ''' - | _________^ -27 | | Single quotes multiline function docstring -28 | | ''' - | |___________^ Q002 -29 | -30 | some_expression = 'hello world' - | - = help: Replace single quotes docstring with double quotes - -ℹ Fix -23 23 | def f(self, bar=''' -24 24 | definitely not a docstring''', -25 25 | val=l[Cls():3]): -26 |- ''' - 26 |+ """ -27 27 | Single quotes multiline function docstring -28 |- ''' - 28 |+ """ -29 29 | -30 30 | some_expression = 'hello world' -31 31 | - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_class.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_class.py.snap deleted file mode 100644 index 2c822e35c8..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_class.py.snap +++ /dev/null @@ -1,56 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -docstring_singles_class.py:2:5: Q002 [*] Single quote docstring found but double quotes preferred - | -1 | class SingleLineDocstrings(): -2 | ''' Double quotes single line class docstring ''' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 -3 | ''' Not a docstring ''' - | - = help: Replace single quotes docstring with double quotes - -ℹ Fix -1 1 | class SingleLineDocstrings(): -2 |- ''' Double quotes single line class docstring ''' - 2 |+ """ Double quotes single line class docstring """ -3 3 | ''' Not a docstring ''' -4 4 | -5 5 | def foo(self, bar='''not a docstring'''): - -docstring_singles_class.py:6:9: Q002 [*] Single quote docstring found but double quotes preferred - | -5 | def foo(self, bar='''not a docstring'''): -6 | ''' Double quotes single line method docstring''' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 -7 | pass - | - = help: Replace single quotes docstring with double quotes - -ℹ Fix -3 3 | ''' Not a docstring ''' -4 4 | -5 5 | def foo(self, bar='''not a docstring'''): -6 |- ''' Double quotes single line method docstring''' - 6 |+ """ Double quotes single line method docstring""" -7 7 | pass -8 8 | -9 9 | class Nested(foo()[:]): ''' inline docstring '''; pass - -docstring_singles_class.py:9:29: Q002 [*] Single quote docstring found but double quotes preferred - | -7 | pass -8 | -9 | class Nested(foo()[:]): ''' inline docstring '''; pass - | ^^^^^^^^^^^^^^^^^^^^^^^^ Q002 - | - = help: Replace single quotes docstring with double quotes - -ℹ Fix -6 6 | ''' Double quotes single line method docstring''' -7 7 | pass -8 8 | -9 |- class Nested(foo()[:]): ''' inline docstring '''; pass - 9 |+ class Nested(foo()[:]): """ inline docstring """; pass - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_function.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_function.py.snap deleted file mode 100644 index 6d878507ce..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_function.py.snap +++ /dev/null @@ -1,66 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -docstring_singles_function.py:2:5: Q002 [*] Single quote docstring found but double quotes preferred - | -1 | def foo(): -2 | '''function without params, single line docstring''' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 -3 | ''' not a docstring''' -4 | return - | - = help: Replace single quotes docstring with double quotes - -ℹ Fix -1 1 | def foo(): -2 |- '''function without params, single line docstring''' - 2 |+ """function without params, single line docstring""" -3 3 | ''' not a docstring''' -4 4 | return -5 5 | - -docstring_singles_function.py:8:5: Q002 [*] Single quote docstring found but double quotes preferred - | - 7 | def foo2(): - 8 | ''' - | _____^ - 9 | | function without params, multiline docstring -10 | | ''' - | |_______^ Q002 -11 | ''' not a docstring''' -12 | return - | - = help: Replace single quotes docstring with double quotes - -ℹ Fix -5 5 | -6 6 | -7 7 | def foo2(): -8 |- ''' - 8 |+ """ -9 9 | function without params, multiline docstring -10 |- ''' - 10 |+ """ -11 11 | ''' not a docstring''' -12 12 | return -13 13 | - -docstring_singles_function.py:27:5: Q002 [*] Single quote docstring found but double quotes preferred - | -26 | def function_with_single_docstring(a): -27 | 'Single line docstring' - | ^^^^^^^^^^^^^^^^^^^^^^^ Q002 - | - = help: Replace single quotes docstring with double quotes - -ℹ Fix -24 24 | -25 25 | -26 26 | def function_with_single_docstring(a): -27 |- 'Single line docstring' - 27 |+ "Single line docstring" -28 28 | -29 29 | -30 30 | def double_inside_single(a): - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_multiline.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_multiline.py.snap deleted file mode 100644 index 3ec2a92e01..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_multiline.py.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -docstring_singles_module_multiline.py:1:1: Q002 [*] Single quote docstring found but double quotes preferred - | -1 | / ''' -2 | | Double quotes multiline module docstring -3 | | ''' - | |___^ Q002 -4 | ''' -5 | this is not a docstring - | - = help: Replace single quotes docstring with double quotes - -ℹ Fix -1 |-''' - 1 |+""" -2 2 | Double quotes multiline module docstring -3 |-''' - 3 |+""" -4 4 | ''' -5 5 | this is not a docstring -6 6 | ''' - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_singleline.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_singleline.py.snap deleted file mode 100644 index 75b12d38c6..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_singleline.py.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -docstring_singles_module_singleline.py:1:1: Q002 [*] Single quote docstring found but double quotes preferred - | -1 | ''' Double quotes singleline module docstring ''' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 -2 | ''' this is not a docstring ''' - | - = help: Replace single quotes docstring with double quotes - -ℹ Fix -1 |-''' Double quotes singleline module docstring ''' - 1 |+""" Double quotes singleline module docstring """ -2 2 | ''' this is not a docstring ''' -3 3 | -4 4 | def foo(): - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles.py.snap deleted file mode 100644 index 3e4aff52d5..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles.py.snap +++ /dev/null @@ -1,78 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -docstring_doubles.py:1:1: Q002 [*] Double quote docstring found but single quotes preferred - | -1 | / """ -2 | | Double quotes multiline module docstring -3 | | """ - | |___^ Q002 -4 | -5 | """ - | - = help: Replace double quotes docstring with single quotes - -ℹ Fix -1 |-""" - 1 |+''' -2 2 | Double quotes multiline module docstring -3 |-""" - 3 |+''' -4 4 | -5 5 | """ -6 6 | this is not a docstring - -docstring_doubles.py:12:5: Q002 [*] Double quote docstring found but single quotes preferred - | -11 | class Cls: -12 | """ - | _____^ -13 | | Double quotes multiline class docstring -14 | | """ - | |_______^ Q002 -15 | -16 | """ - | - = help: Replace double quotes docstring with single quotes - -ℹ Fix -9 9 | l = [] -10 10 | -11 11 | class Cls: -12 |- """ - 12 |+ ''' -13 13 | Double quotes multiline class docstring -14 |- """ - 14 |+ ''' -15 15 | -16 16 | """ -17 17 | this is not a docstring - -docstring_doubles.py:24:9: Q002 [*] Double quote docstring found but single quotes preferred - | -22 | definitely not a docstring""", -23 | val=l[Cls():3]): -24 | """ - | _________^ -25 | | Double quotes multiline function docstring -26 | | """ - | |___________^ Q002 -27 | -28 | some_expression = 'hello world' - | - = help: Replace double quotes docstring with single quotes - -ℹ Fix -21 21 | def f(self, bar=""" -22 22 | definitely not a docstring""", -23 23 | val=l[Cls():3]): -24 |- """ - 24 |+ ''' -25 25 | Double quotes multiline function docstring -26 |- """ - 26 |+ ''' -27 27 | -28 28 | some_expression = 'hello world' -29 29 | - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_class.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_class.py.snap deleted file mode 100644 index 4f1be427c9..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_class.py.snap +++ /dev/null @@ -1,56 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -docstring_doubles_class.py:2:5: Q002 [*] Double quote docstring found but single quotes preferred - | -1 | class SingleLineDocstrings(): -2 | """ Double quotes single line class docstring """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 -3 | """ Not a docstring """ - | - = help: Replace double quotes docstring with single quotes - -ℹ Fix -1 1 | class SingleLineDocstrings(): -2 |- """ Double quotes single line class docstring """ - 2 |+ ''' Double quotes single line class docstring ''' -3 3 | """ Not a docstring """ -4 4 | -5 5 | def foo(self, bar="""not a docstring"""): - -docstring_doubles_class.py:6:9: Q002 [*] Double quote docstring found but single quotes preferred - | -5 | def foo(self, bar="""not a docstring"""): -6 | """ Double quotes single line method docstring""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 -7 | pass - | - = help: Replace double quotes docstring with single quotes - -ℹ Fix -3 3 | """ Not a docstring """ -4 4 | -5 5 | def foo(self, bar="""not a docstring"""): -6 |- """ Double quotes single line method docstring""" - 6 |+ ''' Double quotes single line method docstring''' -7 7 | pass -8 8 | -9 9 | class Nested(foo()[:]): """ inline docstring """; pass - -docstring_doubles_class.py:9:29: Q002 [*] Double quote docstring found but single quotes preferred - | -7 | pass -8 | -9 | class Nested(foo()[:]): """ inline docstring """; pass - | ^^^^^^^^^^^^^^^^^^^^^^^^ Q002 - | - = help: Replace double quotes docstring with single quotes - -ℹ Fix -6 6 | """ Double quotes single line method docstring""" -7 7 | pass -8 8 | -9 |- class Nested(foo()[:]): """ inline docstring """; pass - 9 |+ class Nested(foo()[:]): ''' inline docstring '''; pass - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_function.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_function.py.snap deleted file mode 100644 index 013f064e86..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_function.py.snap +++ /dev/null @@ -1,66 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -docstring_doubles_function.py:2:5: Q002 [*] Double quote docstring found but single quotes preferred - | -1 | def foo(): -2 | """function without params, single line docstring""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 -3 | """ not a docstring""" -4 | return - | - = help: Replace double quotes docstring with single quotes - -ℹ Fix -1 1 | def foo(): -2 |- """function without params, single line docstring""" - 2 |+ '''function without params, single line docstring''' -3 3 | """ not a docstring""" -4 4 | return -5 5 | - -docstring_doubles_function.py:8:5: Q002 [*] Double quote docstring found but single quotes preferred - | - 7 | def foo2(): - 8 | """ - | _____^ - 9 | | function without params, multiline docstring -10 | | """ - | |_______^ Q002 -11 | """ not a docstring""" -12 | return - | - = help: Replace double quotes docstring with single quotes - -ℹ Fix -5 5 | -6 6 | -7 7 | def foo2(): -8 |- """ - 8 |+ ''' -9 9 | function without params, multiline docstring -10 |- """ - 10 |+ ''' -11 11 | """ not a docstring""" -12 12 | return -13 13 | - -docstring_doubles_function.py:27:5: Q002 [*] Double quote docstring found but single quotes preferred - | -26 | def function_with_single_docstring(a): -27 | "Single line docstring" - | ^^^^^^^^^^^^^^^^^^^^^^^ Q002 - | - = help: Replace double quotes docstring with single quotes - -ℹ Fix -24 24 | -25 25 | -26 26 | def function_with_single_docstring(a): -27 |- "Single line docstring" - 27 |+ 'Single line docstring' -28 28 | -29 29 | -30 30 | def double_inside_single(a): - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_multiline.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_multiline.py.snap deleted file mode 100644 index e2c5e024af..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_multiline.py.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -docstring_doubles_module_multiline.py:1:1: Q002 [*] Double quote docstring found but single quotes preferred - | -1 | / """ -2 | | Double quotes multiline module docstring -3 | | """ - | |___^ Q002 -4 | """ -5 | this is not a docstring - | - = help: Replace double quotes docstring with single quotes - -ℹ Fix -1 |-""" - 1 |+''' -2 2 | Double quotes multiline module docstring -3 |-""" - 3 |+''' -4 4 | """ -5 5 | this is not a docstring -6 6 | """ - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_singleline.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_singleline.py.snap deleted file mode 100644 index c6332e463f..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_singleline.py.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -docstring_doubles_module_singleline.py:1:1: Q002 [*] Double quote docstring found but single quotes preferred - | -1 | """ Double quotes singleline module docstring """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 -2 | """ this is not a docstring """ - | - = help: Replace double quotes docstring with single quotes - -ℹ Fix -1 |-""" Double quotes singleline module docstring """ - 1 |+''' Double quotes singleline module docstring ''' -2 2 | """ this is not a docstring """ -3 3 | -4 4 | def foo(): - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles.py.snap deleted file mode 100644 index 90eb8de9cc..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles.py.snap +++ /dev/null @@ -1,158 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -docstring_singles.py:5:1: Q001 [*] Single quote multiline found but double quotes preferred - | -3 | ''' -4 | -5 | / ''' -6 | | this is not a docstring -7 | | ''' - | |___^ Q001 -8 | -9 | l = [] - | - = help: Replace single multiline quotes with double quotes - -ℹ Fix -2 2 | Single quotes multiline module docstring -3 3 | ''' -4 4 | -5 |-''' - 5 |+""" -6 6 | this is not a docstring -7 |-''' - 7 |+""" -8 8 | -9 9 | l = [] -10 10 | - -docstring_singles.py:11:21: Q001 [*] Single quote multiline found but double quotes preferred - | - 9 | l = [] -10 | -11 | class Cls(MakeKlass(''' - | _____________________^ -12 | | class params \t not a docstring -13 | | ''')): - | |___^ Q001 -14 | ''' -15 | Single quotes multiline class docstring - | - = help: Replace single multiline quotes with double quotes - -ℹ Fix -8 8 | -9 9 | l = [] -10 10 | -11 |-class Cls(MakeKlass(''' - 11 |+class Cls(MakeKlass(""" -12 12 | class params \t not a docstring -13 |-''')): - 13 |+""")): -14 14 | ''' -15 15 | Single quotes multiline class docstring -16 16 | ''' - -docstring_singles.py:18:5: Q001 [*] Single quote multiline found but double quotes preferred - | -16 | ''' -17 | -18 | ''' - | _____^ -19 | | this is not a docstring -20 | | ''' - | |_______^ Q001 -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 - -ℹ Fix -15 15 | Single quotes multiline class docstring -16 16 | ''' -17 17 | -18 |- ''' - 18 |+ """ -19 19 | this is not a docstring -20 |- ''' - 20 |+ """ -21 21 | -22 22 | # The colon in the list indexing below is an edge case for the docstring scanner -23 23 | def f(self, bar=''' - -docstring_singles.py:23:21: Q001 [*] Single quote multiline found but double quotes preferred - | -22 | # The colon in the list indexing below is an edge case for the docstring scanner -23 | def f(self, bar=''' - | _____________________^ -24 | | definitely not a docstring''', - | |_____________________________________^ Q001 -25 | val=l[Cls():3]): -26 | ''' - | - = help: Replace single multiline quotes with double quotes - -ℹ Fix -20 20 | ''' -21 21 | -22 22 | # The colon in the list indexing below is an edge case for the docstring scanner -23 |- def f(self, bar=''' -24 |- definitely not a docstring''', - 23 |+ def f(self, bar=""" - 24 |+ definitely not a docstring""", -25 25 | val=l[Cls():3]): -26 26 | ''' -27 27 | Single quotes multiline function docstring - -docstring_singles.py:32:9: Q001 [*] Single quote multiline found but double quotes preferred - | -30 | some_expression = 'hello world' -31 | -32 | ''' - | _________^ -33 | | this is not a docstring -34 | | ''' - | |___________^ Q001 -35 | -36 | if l: - | - = help: Replace single multiline quotes with double quotes - -ℹ Fix -29 29 | -30 30 | some_expression = 'hello world' -31 31 | -32 |- ''' - 32 |+ """ -33 33 | this is not a docstring -34 |- ''' - 34 |+ """ -35 35 | -36 36 | if l: -37 37 | ''' - -docstring_singles.py:37:13: Q001 [*] Single quote multiline found but double quotes preferred - | -36 | if l: -37 | ''' - | _____________^ -38 | | Looks like a docstring, but in reality it isn't - only modules, classes and functions -39 | | ''' - | |_______________^ Q001 -40 | pass - | - = help: Replace single multiline quotes with double quotes - -ℹ Fix -34 34 | ''' -35 35 | -36 36 | if l: -37 |- ''' - 37 |+ """ -38 38 | Looks like a docstring, but in reality it isn't - only modules, classes and functions -39 |- ''' - 39 |+ """ -40 40 | pass - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_class.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_class.py.snap deleted file mode 100644 index 323f502a22..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_class.py.snap +++ /dev/null @@ -1,45 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -docstring_singles_class.py:3:5: Q001 [*] Single quote multiline found but double quotes preferred - | -1 | class SingleLineDocstrings(): -2 | ''' Double quotes single line class docstring ''' -3 | ''' Not a docstring ''' - | ^^^^^^^^^^^^^^^^^^^^^^^ Q001 -4 | -5 | def foo(self, bar='''not a docstring'''): - | - = help: Replace single multiline quotes with double quotes - -ℹ Fix -1 1 | class SingleLineDocstrings(): -2 2 | ''' Double quotes single line class docstring ''' -3 |- ''' Not a docstring ''' - 3 |+ """ Not a docstring """ -4 4 | -5 5 | def foo(self, bar='''not a docstring'''): -6 6 | ''' Double quotes single line method docstring''' - -docstring_singles_class.py:5:23: Q001 [*] Single quote multiline found but double quotes preferred - | -3 | ''' Not a docstring ''' -4 | -5 | def foo(self, bar='''not a docstring'''): - | ^^^^^^^^^^^^^^^^^^^^^ Q001 -6 | ''' Double quotes single line method docstring''' -7 | pass - | - = help: Replace single multiline quotes with double quotes - -ℹ Fix -2 2 | ''' Double quotes single line class docstring ''' -3 3 | ''' Not a docstring ''' -4 4 | -5 |- def foo(self, bar='''not a docstring'''): - 5 |+ def foo(self, bar="""not a docstring"""): -6 6 | ''' Double quotes single line method docstring''' -7 7 | pass -8 8 | - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_function.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_function.py.snap deleted file mode 100644 index fe7371af8f..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_function.py.snap +++ /dev/null @@ -1,106 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -docstring_singles_function.py:3:5: Q001 [*] Single quote multiline found but double quotes preferred - | -1 | def foo(): -2 | '''function without params, single line docstring''' -3 | ''' not a docstring''' - | ^^^^^^^^^^^^^^^^^^^^^^ Q001 -4 | return - | - = help: Replace single multiline quotes with double quotes - -ℹ Fix -1 1 | def foo(): -2 2 | '''function without params, single line docstring''' -3 |- ''' not a docstring''' - 3 |+ """ not a docstring""" -4 4 | return -5 5 | -6 6 | - -docstring_singles_function.py:11:5: Q001 [*] Single quote multiline found but double quotes preferred - | - 9 | function without params, multiline docstring -10 | ''' -11 | ''' not a docstring''' - | ^^^^^^^^^^^^^^^^^^^^^^ Q001 -12 | return - | - = help: Replace single multiline quotes with double quotes - -ℹ Fix -8 8 | ''' -9 9 | function without params, multiline docstring -10 10 | ''' -11 |- ''' not a docstring''' - 11 |+ """ not a docstring""" -12 12 | return -13 13 | -14 14 | - -docstring_singles_function.py:15:39: Q001 [*] Single quote multiline found but double quotes preferred - | -15 | def fun_with_params_no_docstring(a, b=''' - | _______________________________________^ -16 | | not a -17 | | ''' '''docstring'''): - | |___^ Q001 -18 | pass - | - = help: Replace single multiline quotes with double quotes - -ℹ Fix -12 12 | return -13 13 | -14 14 | -15 |-def fun_with_params_no_docstring(a, b=''' - 15 |+def fun_with_params_no_docstring(a, b=""" -16 16 | not a -17 |-''' '''docstring'''): - 17 |+""" '''docstring'''): -18 18 | pass -19 19 | -20 20 | - -docstring_singles_function.py:17:5: Q001 [*] Single quote multiline found but double quotes preferred - | -15 | def fun_with_params_no_docstring(a, b=''' -16 | not a -17 | ''' '''docstring'''): - | ^^^^^^^^^^^^^^^ Q001 -18 | pass - | - = help: Replace single multiline quotes with double quotes - -ℹ Fix -14 14 | -15 15 | def fun_with_params_no_docstring(a, b=''' -16 16 | not a -17 |-''' '''docstring'''): - 17 |+''' """docstring"""): -18 18 | pass -19 19 | -20 20 | - -docstring_singles_function.py:22:5: Q001 [*] Single quote multiline found but double quotes preferred - | -21 | def fun_with_params_no_docstring2(a, b=c[foo():], c=\ -22 | ''' not a docstring '''): - | ^^^^^^^^^^^^^^^^^^^^^^^ Q001 -23 | pass - | - = help: Replace single multiline quotes with double quotes - -ℹ Fix -19 19 | -20 20 | -21 21 | def fun_with_params_no_docstring2(a, b=c[foo():], c=\ -22 |- ''' not a docstring '''): - 22 |+ """ not a docstring """): -23 23 | pass -24 24 | -25 25 | - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_multiline.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_multiline.py.snap deleted file mode 100644 index ca3d7d259d..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_multiline.py.snap +++ /dev/null @@ -1,51 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -docstring_singles_module_multiline.py:4:1: Q001 [*] Single quote multiline found but double quotes preferred - | -2 | Double quotes multiline module docstring -3 | ''' -4 | / ''' -5 | | this is not a docstring -6 | | ''' - | |___^ Q001 -7 | def foo(): -8 | pass - | - = help: Replace single multiline quotes with double quotes - -ℹ Fix -1 1 | ''' -2 2 | Double quotes multiline module docstring -3 3 | ''' -4 |-''' - 4 |+""" -5 5 | this is not a docstring -6 |-''' - 6 |+""" -7 7 | def foo(): -8 8 | pass -9 9 | ''' - -docstring_singles_module_multiline.py:9:1: Q001 [*] Single quote multiline found but double quotes preferred - | - 7 | def foo(): - 8 | pass - 9 | / ''' -10 | | this is not a docstring -11 | | ''' - | |___^ Q001 - | - = help: Replace single multiline quotes with double quotes - -ℹ Fix -6 6 | ''' -7 7 | def foo(): -8 8 | pass -9 |-''' - 9 |+""" -10 10 | this is not a docstring -11 |-''' - 11 |+""" - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_singleline.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_singleline.py.snap deleted file mode 100644 index 3d9926a1e6..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_singleline.py.snap +++ /dev/null @@ -1,38 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -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 | -4 | def foo(): - | - = help: Replace single multiline quotes with double quotes - -ℹ Fix -1 1 | ''' Double quotes singleline module docstring ''' -2 |-''' this is not a docstring ''' - 2 |+""" this is not a docstring """ -3 3 | -4 4 | def foo(): -5 5 | pass - -docstring_singles_module_singleline.py:6:1: Q001 [*] Single quote multiline found but double quotes preferred - | -4 | def foo(): -5 | pass -6 | ''' this is not a docstring ''' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q001 - | - = help: Replace single multiline quotes with double quotes - -ℹ Fix -3 3 | -4 4 | def foo(): -5 5 | pass -6 |-''' this is not a docstring ''' - 6 |+""" this is not a docstring """ - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_doubles_over_singles.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_doubles_over_singles.py.snap deleted file mode 100644 index 83354230b3..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_doubles_over_singles.py.snap +++ /dev/null @@ -1,54 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -singles.py:1:25: Q000 [*] Single quotes found but double quotes preferred - | -1 | this_should_be_linted = 'single quote string' - | ^^^^^^^^^^^^^^^^^^^^^ Q000 -2 | this_should_be_linted = u'double quote string' -3 | this_should_be_linted = f'double quote string' - | - = help: Replace single quotes with double quotes - -ℹ Fix -1 |-this_should_be_linted = 'single quote string' - 1 |+this_should_be_linted = "single quote string" -2 2 | this_should_be_linted = u'double quote string' -3 3 | this_should_be_linted = f'double quote string' -4 4 | this_should_be_linted = f'double {"quote"} string' - -singles.py:2:25: Q000 [*] Single quotes found but double quotes preferred - | -1 | this_should_be_linted = 'single quote string' -2 | this_should_be_linted = u'double quote string' - | ^^^^^^^^^^^^^^^^^^^^^^ Q000 -3 | this_should_be_linted = f'double quote string' -4 | this_should_be_linted = f'double {"quote"} string' - | - = help: Replace single quotes with double quotes - -ℹ Fix -1 1 | this_should_be_linted = 'single quote string' -2 |-this_should_be_linted = u'double quote string' - 2 |+this_should_be_linted = u"double quote string" -3 3 | this_should_be_linted = f'double quote string' -4 4 | this_should_be_linted = f'double {"quote"} string' - -singles.py:3:25: Q000 [*] Single quotes found but double quotes preferred - | -1 | this_should_be_linted = 'single quote string' -2 | this_should_be_linted = u'double quote string' -3 | this_should_be_linted = f'double quote string' - | ^^^^^^^^^^^^^^^^^^^^^^ Q000 -4 | this_should_be_linted = f'double {"quote"} string' - | - = help: Replace single quotes with double quotes - -ℹ Fix -1 1 | this_should_be_linted = 'single quote string' -2 2 | this_should_be_linted = u'double quote string' -3 |-this_should_be_linted = f'double quote string' - 3 |+this_should_be_linted = f"double quote string" -4 4 | this_should_be_linted = f'double {"quote"} string' - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_doubles_over_singles_escaped.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_doubles_over_singles_escaped.py.snap deleted file mode 100644 index 6dd7d7e8f6..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_doubles_over_singles_escaped.py.snap +++ /dev/null @@ -1,38 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -singles_escaped.py:1:26: Q003 [*] Change outer quotes to avoid escaping inner quotes - | -1 | this_should_raise_Q003 = "This is a \"string\"" - | ^^^^^^^^^^^^^^^^^^^^^^ Q003 -2 | this_is_fine = "'This' is a \"string\"" -3 | this_is_fine = 'This is a "string"' - | - = help: Change outer quotes to avoid escaping inner quotes - -ℹ Fix -1 |-this_should_raise_Q003 = "This is a \"string\"" - 1 |+this_should_raise_Q003 = 'This is a "string"' -2 2 | this_is_fine = "'This' is a \"string\"" -3 3 | this_is_fine = 'This is a "string"' -4 4 | this_is_fine = '\'This\' is a "string"' - -singles_escaped.py:9:5: Q003 [*] Change outer quotes to avoid escaping inner quotes - | - 7 | this_should_raise = ( - 8 | "This is a" - 9 | "\"string\"" - | ^^^^^^^^^^^^ Q003 -10 | ) - | - = help: Change outer quotes to avoid escaping inner quotes - -ℹ Fix -6 6 | this_is_fine = R"This is a \"string\"" -7 7 | this_should_raise = ( -8 8 | "This is a" -9 |- "\"string\"" - 9 |+ '"string"' -10 10 | ) - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_doubles_over_singles_implicit.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_doubles_over_singles_implicit.py.snap deleted file mode 100644 index 24ebd5c6f3..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_doubles_over_singles_implicit.py.snap +++ /dev/null @@ -1,139 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -singles_implicit.py:2:5: Q000 [*] Single quotes found but double quotes preferred - | -1 | x = ( -2 | 'This' - | ^^^^^^ Q000 -3 | 'is' -4 | 'not' - | - = help: Replace single quotes with double quotes - -ℹ Fix -1 1 | x = ( -2 |- 'This' - 2 |+ "This" -3 3 | 'is' -4 4 | 'not' -5 5 | ) - -singles_implicit.py:3:5: Q000 [*] Single quotes found but double quotes preferred - | -1 | x = ( -2 | 'This' -3 | 'is' - | ^^^^ Q000 -4 | 'not' -5 | ) - | - = help: Replace single quotes with double quotes - -ℹ Fix -1 1 | x = ( -2 2 | 'This' -3 |- 'is' - 3 |+ "is" -4 4 | 'not' -5 5 | ) -6 6 | - -singles_implicit.py:4:5: Q000 [*] Single quotes found but double quotes preferred - | -2 | 'This' -3 | 'is' -4 | 'not' - | ^^^^^ Q000 -5 | ) - | - = help: Replace single quotes with double quotes - -ℹ Fix -1 1 | x = ( -2 2 | 'This' -3 3 | 'is' -4 |- 'not' - 4 |+ "not" -5 5 | ) -6 6 | -7 7 | x = ( - -singles_implicit.py:8:5: Q000 [*] Single quotes found but double quotes preferred - | - 7 | x = ( - 8 | 'This' \ - | ^^^^^^ Q000 - 9 | 'is' \ -10 | 'not' - | - = help: Replace single quotes with double quotes - -ℹ Fix -5 5 | ) -6 6 | -7 7 | x = ( -8 |- 'This' \ - 8 |+ "This" \ -9 9 | 'is' \ -10 10 | 'not' -11 11 | ) - -singles_implicit.py:9:5: Q000 [*] Single quotes found but double quotes preferred - | - 7 | x = ( - 8 | 'This' \ - 9 | 'is' \ - | ^^^^ Q000 -10 | 'not' -11 | ) - | - = help: Replace single quotes with double quotes - -ℹ Fix -6 6 | -7 7 | x = ( -8 8 | 'This' \ -9 |- 'is' \ - 9 |+ "is" \ -10 10 | 'not' -11 11 | ) -12 12 | - -singles_implicit.py:10:5: Q000 [*] Single quotes found but double quotes preferred - | - 8 | 'This' \ - 9 | 'is' \ -10 | 'not' - | ^^^^^ Q000 -11 | ) - | - = help: Replace single quotes with double quotes - -ℹ Fix -7 7 | x = ( -8 8 | 'This' \ -9 9 | 'is' \ -10 |- 'not' - 10 |+ "not" -11 11 | ) -12 12 | -13 13 | x = ( - -singles_implicit.py:27:1: Q000 [*] Single quotes found but double quotes preferred - | -25 | if True: -26 | 'This can use "single" quotes' -27 | 'But this needs to be changed' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q000 - | - = help: Replace single quotes with double quotes - -ℹ Fix -24 24 | -25 25 | if True: -26 26 | 'This can use "single" quotes' -27 |-'But this needs to be changed' - 27 |+"But this needs to be changed" - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_doubles_over_singles_multiline_string.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_doubles_over_singles_multiline_string.py.snap deleted file mode 100644 index 20cd5ce322..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_doubles_over_singles_multiline_string.py.snap +++ /dev/null @@ -1,26 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -singles_multiline_string.py:1:5: Q001 [*] Single quote multiline found but double quotes preferred - | -1 | s = ''' This 'should' - | _____^ -2 | | be -3 | | 'linted' ''' - | |____________^ Q001 -4 | -5 | s = """ This 'should' - | - = help: Replace single multiline quotes with double quotes - -ℹ Fix -1 |-s = ''' This 'should' - 1 |+s = """ This 'should' -2 2 | be -3 |-'linted' ''' - 3 |+'linted' """ -4 4 | -5 5 | s = """ This 'should' -6 6 | 'not' be - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_doubles_over_singles_noqa.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_doubles_over_singles_noqa.py.snap deleted file mode 100644 index 6703f6be3e..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_doubles_over_singles_noqa.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_doubles_over_singles_wrapped.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_doubles_over_singles_wrapped.py.snap deleted file mode 100644 index 6703f6be3e..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_doubles_over_singles_wrapped.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_singles_over_doubles.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_singles_over_doubles.py.snap deleted file mode 100644 index 0550913c80..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_singles_over_doubles.py.snap +++ /dev/null @@ -1,54 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -doubles.py:1:25: Q000 [*] Double quotes found but single quotes preferred - | -1 | this_should_be_linted = "double quote string" - | ^^^^^^^^^^^^^^^^^^^^^ Q000 -2 | this_should_be_linted = u"double quote string" -3 | this_should_be_linted = f"double quote string" - | - = help: Replace double quotes with single quotes - -ℹ Fix -1 |-this_should_be_linted = "double quote string" - 1 |+this_should_be_linted = 'double quote string' -2 2 | this_should_be_linted = u"double quote string" -3 3 | this_should_be_linted = f"double quote string" -4 4 | this_should_be_linted = f"double {'quote'} string" - -doubles.py:2:25: Q000 [*] Double quotes found but single quotes preferred - | -1 | this_should_be_linted = "double quote string" -2 | this_should_be_linted = u"double quote string" - | ^^^^^^^^^^^^^^^^^^^^^^ Q000 -3 | this_should_be_linted = f"double quote string" -4 | this_should_be_linted = f"double {'quote'} string" - | - = help: Replace double quotes with single quotes - -ℹ Fix -1 1 | this_should_be_linted = "double quote string" -2 |-this_should_be_linted = u"double quote string" - 2 |+this_should_be_linted = u'double quote string' -3 3 | this_should_be_linted = f"double quote string" -4 4 | this_should_be_linted = f"double {'quote'} string" - -doubles.py:3:25: Q000 [*] Double quotes found but single quotes preferred - | -1 | this_should_be_linted = "double quote string" -2 | this_should_be_linted = u"double quote string" -3 | this_should_be_linted = f"double quote string" - | ^^^^^^^^^^^^^^^^^^^^^^ Q000 -4 | this_should_be_linted = f"double {'quote'} string" - | - = help: Replace double quotes with single quotes - -ℹ Fix -1 1 | this_should_be_linted = "double quote string" -2 2 | this_should_be_linted = u"double quote string" -3 |-this_should_be_linted = f"double quote string" - 3 |+this_should_be_linted = f'double quote string' -4 4 | this_should_be_linted = f"double {'quote'} string" - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_singles_over_doubles_escaped.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_singles_over_doubles_escaped.py.snap deleted file mode 100644 index 6a31d7a11f..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_singles_over_doubles_escaped.py.snap +++ /dev/null @@ -1,56 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -doubles_escaped.py:1:26: Q003 [*] Change outer quotes to avoid escaping inner quotes - | -1 | this_should_raise_Q003 = 'This is a \'string\'' - | ^^^^^^^^^^^^^^^^^^^^^^ Q003 -2 | this_should_raise_Q003 = 'This is \\ a \\\'string\'' -3 | this_is_fine = '"This" is a \'string\'' - | - = help: Change outer quotes to avoid escaping inner quotes - -ℹ Fix -1 |-this_should_raise_Q003 = 'This is a \'string\'' - 1 |+this_should_raise_Q003 = "This is a 'string'" -2 2 | this_should_raise_Q003 = 'This is \\ a \\\'string\'' -3 3 | this_is_fine = '"This" is a \'string\'' -4 4 | this_is_fine = "This is a 'string'" - -doubles_escaped.py:2:26: Q003 [*] Change outer quotes to avoid escaping inner quotes - | -1 | this_should_raise_Q003 = 'This is a \'string\'' -2 | this_should_raise_Q003 = 'This is \\ a \\\'string\'' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 -3 | this_is_fine = '"This" is a \'string\'' -4 | this_is_fine = "This is a 'string'" - | - = help: Change outer quotes to avoid escaping inner quotes - -ℹ Fix -1 1 | this_should_raise_Q003 = 'This is a \'string\'' -2 |-this_should_raise_Q003 = 'This is \\ a \\\'string\'' - 2 |+this_should_raise_Q003 = "This is \\ a \\'string'" -3 3 | this_is_fine = '"This" is a \'string\'' -4 4 | this_is_fine = "This is a 'string'" -5 5 | this_is_fine = "\"This\" is a 'string'" - -doubles_escaped.py:10:5: Q003 [*] Change outer quotes to avoid escaping inner quotes - | - 8 | this_should_raise = ( - 9 | 'This is a' -10 | '\'string\'' - | ^^^^^^^^^^^^ Q003 -11 | ) - | - = help: Change outer quotes to avoid escaping inner quotes - -ℹ Fix -7 7 | this_is_fine = R'This is a \'string\'' -8 8 | this_should_raise = ( -9 9 | 'This is a' -10 |- '\'string\'' - 10 |+ "'string'" -11 11 | ) - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_singles_over_doubles_implicit.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_singles_over_doubles_implicit.py.snap deleted file mode 100644 index dcd5cd4f75..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_singles_over_doubles_implicit.py.snap +++ /dev/null @@ -1,139 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -doubles_implicit.py:2:5: Q000 [*] Double quotes found but single quotes preferred - | -1 | x = ( -2 | "This" - | ^^^^^^ Q000 -3 | "is" -4 | "not" - | - = help: Replace double quotes with single quotes - -ℹ Fix -1 1 | x = ( -2 |- "This" - 2 |+ 'This' -3 3 | "is" -4 4 | "not" -5 5 | ) - -doubles_implicit.py:3:5: Q000 [*] Double quotes found but single quotes preferred - | -1 | x = ( -2 | "This" -3 | "is" - | ^^^^ Q000 -4 | "not" -5 | ) - | - = help: Replace double quotes with single quotes - -ℹ Fix -1 1 | x = ( -2 2 | "This" -3 |- "is" - 3 |+ 'is' -4 4 | "not" -5 5 | ) -6 6 | - -doubles_implicit.py:4:5: Q000 [*] Double quotes found but single quotes preferred - | -2 | "This" -3 | "is" -4 | "not" - | ^^^^^ Q000 -5 | ) - | - = help: Replace double quotes with single quotes - -ℹ Fix -1 1 | x = ( -2 2 | "This" -3 3 | "is" -4 |- "not" - 4 |+ 'not' -5 5 | ) -6 6 | -7 7 | x = ( - -doubles_implicit.py:8:5: Q000 [*] Double quotes found but single quotes preferred - | - 7 | x = ( - 8 | "This" \ - | ^^^^^^ Q000 - 9 | "is" \ -10 | "not" - | - = help: Replace double quotes with single quotes - -ℹ Fix -5 5 | ) -6 6 | -7 7 | x = ( -8 |- "This" \ - 8 |+ 'This' \ -9 9 | "is" \ -10 10 | "not" -11 11 | ) - -doubles_implicit.py:9:5: Q000 [*] Double quotes found but single quotes preferred - | - 7 | x = ( - 8 | "This" \ - 9 | "is" \ - | ^^^^ Q000 -10 | "not" -11 | ) - | - = help: Replace double quotes with single quotes - -ℹ Fix -6 6 | -7 7 | x = ( -8 8 | "This" \ -9 |- "is" \ - 9 |+ 'is' \ -10 10 | "not" -11 11 | ) -12 12 | - -doubles_implicit.py:10:5: Q000 [*] Double quotes found but single quotes preferred - | - 8 | "This" \ - 9 | "is" \ -10 | "not" - | ^^^^^ Q000 -11 | ) - | - = help: Replace double quotes with single quotes - -ℹ Fix -7 7 | x = ( -8 8 | "This" \ -9 9 | "is" \ -10 |- "not" - 10 |+ 'not' -11 11 | ) -12 12 | -13 13 | x = ( - -doubles_implicit.py:27:1: Q000 [*] Double quotes found but single quotes preferred - | -25 | if True: -26 | "This can use 'double' quotes" -27 | "But this needs to be changed" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q000 - | - = help: Replace double quotes with single quotes - -ℹ Fix -24 24 | -25 25 | if True: -26 26 | "This can use 'double' quotes" -27 |-"But this needs to be changed" - 27 |+'But this needs to be changed' - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_singles_over_doubles_multiline_string.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_singles_over_doubles_multiline_string.py.snap deleted file mode 100644 index 07ee108c25..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_singles_over_doubles_multiline_string.py.snap +++ /dev/null @@ -1,26 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- -doubles_multiline_string.py:1:5: Q001 [*] Double quote multiline found but single quotes preferred - | -1 | s = """ This "should" - | _____^ -2 | | be -3 | | "linted" """ - | |____________^ Q001 -4 | -5 | s = ''' This "should" - | - = help: Replace double multiline quotes with single quotes - -ℹ Fix -1 |-s = """ This "should" - 1 |+s = ''' This "should" -2 2 | be -3 |-"linted" """ - 3 |+"linted" ''' -4 4 | -5 5 | s = ''' This "should" -6 6 | "not" be - - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_singles_over_doubles_noqa.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_singles_over_doubles_noqa.py.snap deleted file mode 100644 index 6703f6be3e..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_singles_over_doubles_noqa.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_singles_over_doubles_wrapped.py.snap b/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_singles_over_doubles_wrapped.py.snap deleted file mode 100644 index 6703f6be3e..0000000000 --- a/crates/ruff/src/rules/flake8_quotes/snapshots/ruff__rules__flake8_quotes__tests__require_singles_over_doubles_wrapped.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_quotes/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_raise/snapshots/ruff__rules__flake8_raise__tests__unnecessary-paren-on-raise-exception_RSE102.py.snap b/crates/ruff/src/rules/flake8_raise/snapshots/ruff__rules__flake8_raise__tests__unnecessary-paren-on-raise-exception_RSE102.py.snap deleted file mode 100644 index c759a28002..0000000000 --- a/crates/ruff/src/rules/flake8_raise/snapshots/ruff__rules__flake8_raise__tests__unnecessary-paren-on-raise-exception_RSE102.py.snap +++ /dev/null @@ -1,258 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_raise/mod.rs ---- -RSE102.py:5:21: RSE102 [*] Unnecessary parentheses on raised exception - | -3 | except TypeError: -4 | # RSE102 -5 | raise ValueError() - | ^^ RSE102 -6 | -7 | try: - | - = help: Remove unnecessary parentheses - -ℹ Fix -2 2 | y = 6 + "7" -3 3 | except TypeError: -4 4 | # RSE102 -5 |- raise ValueError() - 5 |+ raise ValueError -6 6 | -7 7 | try: -8 8 | x = 1 / 0 - -RSE102.py:13:16: RSE102 [*] Unnecessary parentheses on raised exception - | -12 | # RSE102 -13 | raise TypeError() - | ^^ RSE102 -14 | -15 | # RSE102 - | - = help: Remove unnecessary parentheses - -ℹ Fix -10 10 | raise -11 11 | -12 12 | # RSE102 -13 |-raise TypeError() - 13 |+raise TypeError -14 14 | -15 15 | # RSE102 -16 16 | raise TypeError () - -RSE102.py:16:17: RSE102 [*] Unnecessary parentheses on raised exception - | -15 | # RSE102 -16 | raise TypeError () - | ^^ RSE102 -17 | -18 | # RSE102 - | - = help: Remove unnecessary parentheses - -ℹ Fix -13 13 | raise TypeError() -14 14 | -15 15 | # RSE102 -16 |-raise TypeError () - 16 |+raise TypeError -17 17 | -18 18 | # RSE102 -19 19 | raise TypeError \ - -RSE102.py:20:5: RSE102 [*] Unnecessary parentheses on raised exception - | -18 | # RSE102 -19 | raise TypeError \ -20 | () - | ^^ RSE102 -21 | -22 | # RSE102 - | - = help: Remove unnecessary parentheses - -ℹ Fix -17 17 | -18 18 | # RSE102 -19 19 | raise TypeError \ -20 |- () - 20 |+ -21 21 | -22 22 | # RSE102 -23 23 | raise TypeError \ - -RSE102.py:24:5: RSE102 [*] Unnecessary parentheses on raised exception - | -22 | # RSE102 -23 | raise TypeError \ -24 | (); - | ^^ RSE102 -25 | -26 | # RSE102 - | - = help: Remove unnecessary parentheses - -ℹ Fix -21 21 | -22 22 | # RSE102 -23 23 | raise TypeError \ -24 |- (); - 24 |+ ; -25 25 | -26 26 | # RSE102 -27 27 | raise TypeError( - -RSE102.py:27:16: RSE102 [*] Unnecessary parentheses on raised exception - | -26 | # RSE102 -27 | raise TypeError( - | ________________^ -28 | | -29 | | ) - | |_^ RSE102 -30 | -31 | # RSE102 - | - = help: Remove unnecessary parentheses - -ℹ Fix -24 24 | (); -25 25 | -26 26 | # RSE102 -27 |-raise TypeError( -28 |- -29 |-) - 27 |+raise TypeError -30 28 | -31 29 | # RSE102 -32 30 | raise (TypeError) ( - -RSE102.py:32:19: RSE102 [*] Unnecessary parentheses on raised exception - | -31 | # RSE102 -32 | raise (TypeError) ( - | ___________________^ -33 | | -34 | | ) - | |_^ RSE102 -35 | -36 | # RSE102 - | - = help: Remove unnecessary parentheses - -ℹ Fix -29 29 | ) -30 30 | -31 31 | # RSE102 -32 |-raise (TypeError) ( -33 |- -34 |-) - 32 |+raise (TypeError) -35 33 | -36 34 | # RSE102 -37 35 | raise TypeError( - -RSE102.py:37:16: RSE102 [*] Unnecessary parentheses on raised exception - | -36 | # RSE102 -37 | raise TypeError( - | ________________^ -38 | | # Hello, world! -39 | | ) - | |_^ RSE102 -40 | -41 | # OK - | - = help: Remove unnecessary parentheses - -ℹ Fix -34 34 | ) -35 35 | -36 36 | # RSE102 -37 |-raise TypeError( -38 |- # Hello, world! -39 |-) - 37 |+raise TypeError -40 38 | -41 39 | # OK -42 40 | raise AssertionError - -RSE102.py:74:17: RSE102 [*] Unnecessary parentheses on raised exception - | -73 | # RSE102 -74 | raise IndexError()from ZeroDivisionError - | ^^ RSE102 -75 | -76 | raise IndexError()\ - | - = help: Remove unnecessary parentheses - -ℹ Fix -71 71 | -72 72 | -73 73 | # RSE102 -74 |-raise IndexError()from ZeroDivisionError - 74 |+raise IndexError from ZeroDivisionError -75 75 | -76 76 | raise IndexError()\ -77 77 | from ZeroDivisionError - -RSE102.py:76:17: RSE102 [*] Unnecessary parentheses on raised exception - | -74 | raise IndexError()from ZeroDivisionError -75 | -76 | raise IndexError()\ - | ^^ RSE102 -77 | from ZeroDivisionError - | - = help: Remove unnecessary parentheses - -ℹ Fix -73 73 | # RSE102 -74 74 | raise IndexError()from ZeroDivisionError -75 75 | -76 |-raise IndexError()\ - 76 |+raise IndexError\ -77 77 | from ZeroDivisionError -78 78 | -79 79 | raise IndexError() from ZeroDivisionError - -RSE102.py:79:17: RSE102 [*] Unnecessary parentheses on raised exception - | -77 | from ZeroDivisionError -78 | -79 | raise IndexError() from ZeroDivisionError - | ^^ RSE102 -80 | -81 | raise IndexError(); - | - = help: Remove unnecessary parentheses - -ℹ Fix -76 76 | raise IndexError()\ -77 77 | from ZeroDivisionError -78 78 | -79 |-raise IndexError() from ZeroDivisionError - 79 |+raise IndexError from ZeroDivisionError -80 80 | -81 81 | raise IndexError(); - -RSE102.py:81:17: RSE102 [*] Unnecessary parentheses on raised exception - | -79 | raise IndexError() from ZeroDivisionError -80 | -81 | raise IndexError(); - | ^^ RSE102 - | - = help: Remove unnecessary parentheses - -ℹ Fix -78 78 | -79 79 | raise IndexError() from ZeroDivisionError -80 80 | -81 |-raise IndexError(); - 81 |+raise IndexError; - - diff --git a/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET501_RET501.py.snap b/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET501_RET501.py.snap deleted file mode 100644 index d0eeb67af0..0000000000 --- a/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET501_RET501.py.snap +++ /dev/null @@ -1,39 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_return/mod.rs ---- -RET501.py:4:5: RET501 [*] Do not explicitly `return None` in function if it is the only possible return value - | -2 | if not y: -3 | return -4 | return None # error - | ^^^^^^^^^^^ RET501 - | - = help: Remove explicit `return None` - -ℹ Fix -1 1 | def x(y): -2 2 | if not y: -3 3 | return -4 |- return None # error - 4 |+ return # error -5 5 | -6 6 | -7 7 | class BaseCache: - -RET501.py:14:9: RET501 [*] Do not explicitly `return None` in function if it is the only possible return value - | -12 | def get(self, key: str) -> None: -13 | print(f"{key} not found") -14 | return None - | ^^^^^^^^^^^ RET501 - | - = help: Remove explicit `return None` - -ℹ Fix -11 11 | -12 12 | def get(self, key: str) -> None: -13 13 | print(f"{key} not found") -14 |- return None - 14 |+ return - - diff --git a/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET502_RET502.py.snap b/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET502_RET502.py.snap deleted file mode 100644 index 6cc2760a27..0000000000 --- a/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET502_RET502.py.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_return/mod.rs ---- -RET502.py:3:9: RET502 [*] Do not implicitly `return None` in function able to return non-`None` value - | -1 | def x(y): -2 | if not y: -3 | return # error - | ^^^^^^ RET502 -4 | return 1 - | - = help: Add explicit `None` return value - -ℹ Fix -1 1 | def x(y): -2 2 | if not y: -3 |- return # error - 3 |+ return None # error -4 4 | return 1 -5 5 | -6 6 | - - diff --git a/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET503_RET503.py.snap b/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET503_RET503.py.snap deleted file mode 100644 index 9627ff3dca..0000000000 --- a/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET503_RET503.py.snap +++ /dev/null @@ -1,403 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_return/mod.rs ---- -RET503.py:20:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -18 | # if/elif/else -19 | def x(y): -20 | if not y: - | _____^ -21 | | return 1 - | |________________^ RET503 -22 | # error - | - = help: Add explicit `return` statement - -ℹ Suggested fix -19 19 | def x(y): -20 20 | if not y: -21 21 | return 1 - 22 |+ return None -22 23 | # error -23 24 | -24 25 | - -RET503.py:27:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -25 | def x(y): -26 | if not y: -27 | print() # error - | ^^^^^^^ RET503 -28 | else: -29 | return 2 - | - = help: Add explicit `return` statement - -ℹ Suggested fix -25 25 | def x(y): -26 26 | if not y: -27 27 | print() # error - 28 |+ return None -28 29 | else: -29 30 | return 2 -30 31 | - -RET503.py:36:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -34 | return 1 -35 | -36 | print() # error - | ^^^^^^^ RET503 - | - = help: Add explicit `return` statement - -ℹ Suggested fix -34 34 | return 1 -35 35 | -36 36 | print() # error - 37 |+ return None -37 38 | -38 39 | -39 40 | # for - -RET503.py:41:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -39 | # for -40 | def x(y): -41 | for i in range(10): - | _____^ -42 | | if i > 10: -43 | | return i - | |____________________^ RET503 -44 | # error - | - = help: Add explicit `return` statement - -ℹ Suggested fix -41 41 | for i in range(10): -42 42 | if i > 10: -43 43 | return i - 44 |+ return None -44 45 | # error -45 46 | -46 47 | - -RET503.py:52:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -50 | return i -51 | else: -52 | print() # error - | ^^^^^^^ RET503 - | - = help: Add explicit `return` statement - -ℹ Suggested fix -50 50 | return i -51 51 | else: -52 52 | print() # error - 53 |+ return None -53 54 | -54 55 | -55 56 | # A nonexistent function - -RET503.py:59:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -57 | if x > 0: -58 | return False -59 | no_such_function() # error - | ^^^^^^^^^^^^^^^^^^ RET503 - | - = help: Add explicit `return` statement - -ℹ Suggested fix -57 57 | if x > 0: -58 58 | return False -59 59 | no_such_function() # error - 60 |+ return None -60 61 | -61 62 | -62 63 | # A function that does return the control - -RET503.py:66:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -64 | if x > 0: -65 | return False -66 | print("", end="") # error - | ^^^^^^^^^^^^^^^^^ RET503 - | - = help: Add explicit `return` statement - -ℹ Suggested fix -64 64 | if x > 0: -65 65 | return False -66 66 | print("", end="") # error - 67 |+ return None -67 68 | -68 69 | -69 70 | ### - -RET503.py:82:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -80 | # last line in while loop -81 | def x(y): -82 | while i > 0: - | _____^ -83 | | if y > 0: -84 | | return 1 -85 | | y += 1 - | |______________^ RET503 - | - = help: Add explicit `return` statement - -ℹ Suggested fix -83 83 | if y > 0: -84 84 | return 1 -85 85 | y += 1 - 86 |+ return None -86 87 | -87 88 | -88 89 | # exclude empty functions - -RET503.py:113:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -111 | # return value within loop -112 | def bar1(x, y, z): -113 | for i in x: - | _____^ -114 | | if i > y: -115 | | break -116 | | return z - | |________________^ RET503 - | - = help: Add explicit `return` statement - -ℹ Suggested fix -114 114 | if i > y: -115 115 | break -116 116 | return z - 117 |+ return None -117 118 | -118 119 | -119 120 | def bar3(x, y, z): - -RET503.py:120:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -119 | def bar3(x, y, z): -120 | for i in x: - | _____^ -121 | | if i > y: -122 | | if z: -123 | | break -124 | | else: -125 | | return z -126 | | return None - | |___________________^ RET503 - | - = help: Add explicit `return` statement - -ℹ Suggested fix -124 124 | else: -125 125 | return z -126 126 | return None - 127 |+ return None -127 128 | -128 129 | -129 130 | def bar1(x, y, z): - -RET503.py:130:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -129 | def bar1(x, y, z): -130 | for i in x: - | _____^ -131 | | if i < y: -132 | | continue -133 | | return z - | |________________^ RET503 - | - = help: Add explicit `return` statement - -ℹ Suggested fix -131 131 | if i < y: -132 132 | continue -133 133 | return z - 134 |+ return None -134 135 | -135 136 | -136 137 | def bar3(x, y, z): - -RET503.py:137:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -136 | def bar3(x, y, z): -137 | for i in x: - | _____^ -138 | | if i < y: -139 | | if z: -140 | | continue -141 | | else: -142 | | return z -143 | | return None - | |___________________^ RET503 - | - = help: Add explicit `return` statement - -ℹ Suggested fix -141 141 | else: -142 142 | return z -143 143 | return None - 144 |+ return None -144 145 | -145 146 | -146 147 | def prompts(self, foo): - -RET503.py:274:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -272 | return False -273 | -274 | for value in values: - | _____^ -275 | | print(value) - | |____________________^ RET503 - | - = help: Add explicit `return` statement - -ℹ Suggested fix -273 273 | -274 274 | for value in values: -275 275 | print(value) - 276 |+ return None -276 277 | -277 278 | -278 279 | def while_true(): - -RET503.py:291:13: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -289 | return 1 -290 | case 1: -291 | print() # error - | ^^^^^^^ RET503 - | - = help: Add explicit `return` statement - -ℹ Suggested fix -289 289 | return 1 -290 290 | case 1: -291 291 | print() # error - 292 |+ return None -292 293 | -293 294 | -294 295 | def foo(baz: str) -> str: - -RET503.py:300:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -298 | def end_of_statement(): -299 | def example(): -300 | if True: - | _________^ -301 | | return "" - | |_____________________^ RET503 - | - = help: Add explicit `return` statement - -ℹ Suggested fix -299 299 | def example(): -300 300 | if True: -301 301 | return "" - 302 |+ return None -302 303 | -303 304 | -304 305 | def example(): - -RET503.py:305:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -304 | def example(): -305 | if True: - | _________^ -306 | | return "" - | |_____________________^ RET503 - | - = help: Add explicit `return` statement - -ℹ Suggested fix -304 304 | def example(): -305 305 | if True: -306 306 | return "" - 307 |+ return None -307 308 | -308 309 | -309 310 | def example(): - -RET503.py:310:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -309 | def example(): -310 | if True: - | _________^ -311 | | return "" # type: ignore - | |_____________________^ RET503 - | - = help: Add explicit `return` statement - -ℹ Suggested fix -309 309 | def example(): -310 310 | if True: -311 311 | return "" # type: ignore - 312 |+ return None -312 313 | -313 314 | -314 315 | def example(): - -RET503.py:315:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -314 | def example(): -315 | if True: - | _________^ -316 | | return "" ; - | |_____________________^ RET503 - | - = help: Add explicit `return` statement - -ℹ Suggested fix -314 314 | def example(): -315 315 | if True: -316 316 | return "" ; - 317 |+ return None -317 318 | -318 319 | -319 320 | def example(): - -RET503.py:320:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -319 | def example(): -320 | if True: - | _________^ -321 | | return "" \ - | |_____________________^ RET503 -322 | ; # type: ignore - | - = help: Add explicit `return` statement - -ℹ Suggested fix -320 320 | if True: -321 321 | return "" \ -322 322 | ; # type: ignore - 323 |+ return None -323 324 | -324 325 | -325 326 | def end_of_file(): - -RET503.py:328:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value - | -326 | if False: -327 | return 1 -328 | x = 2 \ - | ^^^^^ RET503 - | - = help: Add explicit `return` statement - -ℹ Suggested fix -326 326 | if False: -327 327 | return 1 -328 328 | x = 2 \ - 329 |+ - 330 |+ return None - - diff --git a/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET504_RET504.py.snap b/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET504_RET504.py.snap deleted file mode 100644 index 33608dd533..0000000000 --- a/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET504_RET504.py.snap +++ /dev/null @@ -1,221 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_return/mod.rs ---- -RET504.py:6:12: RET504 [*] Unnecessary assignment to `a` before `return` statement - | -4 | def x(): -5 | a = 1 -6 | return a # RET504 - | ^ RET504 - | - = help: Remove unnecessary assignment - -ℹ Suggested fix -2 2 | # Errors -3 3 | ### -4 4 | def x(): -5 |- a = 1 -6 |- return a # RET504 - 5 |+ return 1 -7 6 | -8 7 | -9 8 | # Can be refactored false positives - -RET504.py:23:12: RET504 [*] Unnecessary assignment to `formatted` before `return` statement - | -21 | # clean up after any blank components -22 | formatted = formatted.replace("()", "").replace(" ", " ").strip() -23 | return formatted - | ^^^^^^^^^ RET504 - | - = help: Remove unnecessary assignment - -ℹ Suggested fix -19 19 | def x(): -20 20 | formatted = _USER_AGENT_FORMATTER.format(format_string, **values) -21 21 | # clean up after any blank components -22 |- formatted = formatted.replace("()", "").replace(" ", " ").strip() -23 |- return formatted - 22 |+ return formatted.replace("()", "").replace(" ", " ").strip() -24 23 | -25 24 | -26 25 | # https://github.com/afonasev/flake8-return/issues/47#issue-641117366 - -RET504.py:246:12: RET504 [*] Unnecessary assignment to `queryset` before `return` statement - | -244 | queryset = Model.filter(a=1) -245 | queryset = queryset.filter(c=3) -246 | return queryset - | ^^^^^^^^ RET504 - | - = help: Remove unnecessary assignment - -ℹ Suggested fix -242 242 | -243 243 | def get_queryset(): -244 244 | queryset = Model.filter(a=1) -245 |- queryset = queryset.filter(c=3) -246 |- return queryset - 245 |+ return queryset.filter(c=3) -247 246 | -248 247 | -249 248 | def get_queryset(): - -RET504.py:251:12: RET504 [*] Unnecessary assignment to `queryset` before `return` statement - | -249 | def get_queryset(): -250 | queryset = Model.filter(a=1) -251 | return queryset # RET504 - | ^^^^^^^^ RET504 - | - = help: Remove unnecessary assignment - -ℹ Suggested fix -247 247 | -248 248 | -249 249 | def get_queryset(): -250 |- queryset = Model.filter(a=1) -251 |- return queryset # RET504 - 250 |+ return Model.filter(a=1) -252 251 | -253 252 | -254 253 | # Function arguments - -RET504.py:269:12: RET504 [*] Unnecessary assignment to `val` before `return` statement - | -267 | return val -268 | val = 1 -269 | return val # RET504 - | ^^^ RET504 - | - = help: Remove unnecessary assignment - -ℹ Suggested fix -265 265 | def str_to_bool(val): -266 266 | if isinstance(val, bool): -267 267 | return val -268 |- val = 1 -269 |- return val # RET504 - 268 |+ return 1 -270 269 | -271 270 | -272 271 | def str_to_bool(val): - -RET504.py:321:12: RET504 [*] Unnecessary assignment to `x` before `return` statement - | -319 | with open("foo.txt", "r") as f: -320 | x = f.read() -321 | return x # RET504 - | ^ RET504 - | - = help: Remove unnecessary assignment - -ℹ Suggested fix -317 317 | # `with` statements -318 318 | def foo(): -319 319 | with open("foo.txt", "r") as f: -320 |- x = f.read() -321 |- return x # RET504 - 320 |+ return f.read() -322 321 | -323 322 | -324 323 | def foo(): - -RET504.py:342:12: RET504 [*] Unnecessary assignment to `b` before `return` statement - | -340 | a = 1 -341 | b=a -342 | return b # RET504 - | ^ RET504 - | - = help: Remove unnecessary assignment - -ℹ Suggested fix -338 338 | # Autofix cases -339 339 | def foo(): -340 340 | a = 1 -341 |- b=a -342 |- return b # RET504 - 341 |+ return a -343 342 | -344 343 | -345 344 | def foo(): - -RET504.py:348:12: RET504 [*] Unnecessary assignment to `b` before `return` statement - | -346 | a = 1 -347 | b =a -348 | return b # RET504 - | ^ RET504 - | - = help: Remove unnecessary assignment - -ℹ Suggested fix -344 344 | -345 345 | def foo(): -346 346 | a = 1 -347 |- b =a -348 |- return b # RET504 - 347 |+ return a -349 348 | -350 349 | -351 350 | def foo(): - -RET504.py:354:12: RET504 [*] Unnecessary assignment to `b` before `return` statement - | -352 | a = 1 -353 | b= a -354 | return b # RET504 - | ^ RET504 - | - = help: Remove unnecessary assignment - -ℹ Suggested fix -350 350 | -351 351 | def foo(): -352 352 | a = 1 -353 |- b= a -354 |- return b # RET504 - 353 |+ return a -355 354 | -356 355 | -357 356 | def foo(): - -RET504.py:359:12: RET504 [*] Unnecessary assignment to `a` before `return` statement - | -357 | def foo(): -358 | a = 1 # Comment -359 | return a - | ^ RET504 - | - = help: Remove unnecessary assignment - -ℹ Suggested fix -355 355 | -356 356 | -357 357 | def foo(): -358 |- a = 1 # Comment -359 |- return a - 358 |+ return 1 # Comment -360 359 | -361 360 | -362 361 | # Regression test for: https://github.com/astral-sh/ruff/issues/7098 - -RET504.py:365:12: RET504 [*] Unnecessary assignment to `D` before `return` statement - | -363 | def mavko_debari(P_kbar): -364 | D=0.4853881 + 3.6006116*P - 0.0117368*(P-1.3822)**2 -365 | return D - | ^ RET504 - | - = help: Remove unnecessary assignment - -ℹ Suggested fix -361 361 | -362 362 | # Regression test for: https://github.com/astral-sh/ruff/issues/7098 -363 363 | def mavko_debari(P_kbar): -364 |- D=0.4853881 + 3.6006116*P - 0.0117368*(P-1.3822)**2 -365 |- return D - 364 |+ return 0.4853881 + 3.6006116*P - 0.0117368*(P-1.3822)**2 - - diff --git a/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET505_RET505.py.snap b/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET505_RET505.py.snap deleted file mode 100644 index c04e5370d9..0000000000 --- a/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET505_RET505.py.snap +++ /dev/null @@ -1,84 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_return/mod.rs ---- -RET505.py:8:5: RET505 Unnecessary `elif` after `return` statement - | - 6 | a = 1 - 7 | return y - 8 | elif z: - | ^^^^ RET505 - 9 | b = 2 -10 | return w - | - -RET505.py:23:5: RET505 Unnecessary `elif` after `return` statement - | -21 | b = 2 -22 | return -23 | elif z: - | ^^^^ RET505 -24 | c = 2 -25 | else: - | - -RET505.py:41:5: RET505 Unnecessary `elif` after `return` statement - | -39 | a = 1 -40 | return y -41 | elif z: - | ^^^^ RET505 -42 | b = 2 -43 | return w - | - -RET505.py:53:5: RET505 Unnecessary `else` after `return` statement - | -51 | a = 1 -52 | return y -53 | else: - | ^^^^ RET505 -54 | b = 2 -55 | return z - | - -RET505.py:64:9: RET505 Unnecessary `else` after `return` statement - | -62 | b = 2 -63 | return y -64 | else: - | ^^^^ RET505 -65 | c = 3 -66 | return x - | - -RET505.py:79:5: RET505 Unnecessary `else` after `return` statement - | -77 | b = 2 -78 | return -79 | else: - | ^^^^ RET505 -80 | c = 3 -81 | return - | - -RET505.py:89:9: RET505 Unnecessary `else` after `return` statement - | -87 | a = 4 -88 | return -89 | else: - | ^^^^ RET505 -90 | b = 2 -91 | else: - | - -RET505.py:99:5: RET505 Unnecessary `else` after `return` statement - | - 97 | if x: # [no-else-return] - 98 | return True - 99 | else: - | ^^^^ RET505 -100 | try: -101 | return False - | - - diff --git a/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET506_RET506.py.snap b/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET506_RET506.py.snap deleted file mode 100644 index 3a28f79042..0000000000 --- a/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET506_RET506.py.snap +++ /dev/null @@ -1,74 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_return/mod.rs ---- -RET506.py:8:5: RET506 Unnecessary `elif` after `raise` statement - | - 6 | a = 1 - 7 | raise Exception(y) - 8 | elif z: - | ^^^^ RET506 - 9 | b = 2 -10 | raise Exception(w) - | - -RET506.py:23:5: RET506 Unnecessary `elif` after `raise` statement - | -21 | b = 2 -22 | raise Exception(x) -23 | elif z: - | ^^^^ RET506 -24 | raise Exception(y) -25 | else: - | - -RET506.py:34:5: RET506 Unnecessary `else` after `raise` statement - | -32 | a = 1 -33 | raise Exception(y) -34 | else: - | ^^^^ RET506 -35 | b = 2 -36 | raise Exception(z) - | - -RET506.py:45:9: RET506 Unnecessary `else` after `raise` statement - | -43 | b = 2 -44 | raise Exception(y) -45 | else: - | ^^^^ RET506 -46 | c = 3 -47 | raise Exception(x) - | - -RET506.py:60:5: RET506 Unnecessary `else` after `raise` statement - | -58 | b = 2 -59 | raise Exception(x) -60 | else: - | ^^^^ RET506 -61 | c = 3 -62 | raise Exception(y) - | - -RET506.py:70:9: RET506 Unnecessary `else` after `raise` statement - | -68 | a = 4 -69 | raise Exception(x) -70 | else: - | ^^^^ RET506 -71 | b = 2 -72 | else: - | - -RET506.py:80:5: RET506 Unnecessary `else` after `raise` statement - | -78 | if x: # [no-else-raise] -79 | raise Exception(True) -80 | else: - | ^^^^ RET506 -81 | try: -82 | raise Exception(False) - | - - diff --git a/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET507_RET507.py.snap b/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET507_RET507.py.snap deleted file mode 100644 index f91c20d897..0000000000 --- a/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET507_RET507.py.snap +++ /dev/null @@ -1,73 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_return/mod.rs ---- -RET507.py:8:9: RET507 Unnecessary `elif` after `continue` statement - | - 6 | if i < y: # [no-else-continue] - 7 | continue - 8 | elif i < w: - | ^^^^ RET507 - 9 | continue -10 | else: - | - -RET507.py:22:9: RET507 Unnecessary `elif` after `continue` statement - | -20 | b = 2 -21 | continue -22 | elif z: - | ^^^^ RET507 -23 | c = 2 -24 | else: - | - -RET507.py:36:9: RET507 Unnecessary `else` after `continue` statement - | -34 | if i < y: # [no-else-continue] -35 | continue -36 | else: - | ^^^^ RET507 -37 | a = z - | - -RET507.py:47:13: RET507 Unnecessary `else` after `continue` statement - | -45 | b = 2 -46 | continue -47 | else: - | ^^^^ RET507 -48 | c = 3 -49 | continue - | - -RET507.py:63:9: RET507 Unnecessary `else` after `continue` statement - | -61 | b = 2 -62 | continue -63 | else: - | ^^^^ RET507 -64 | c = 3 -65 | continue - | - -RET507.py:74:13: RET507 Unnecessary `else` after `continue` statement - | -72 | a = 4 -73 | continue -74 | else: - | ^^^^ RET507 -75 | b = 2 -76 | else: - | - -RET507.py:85:9: RET507 Unnecessary `else` after `continue` statement - | -83 | if x: # [no-else-continue] -84 | continue -85 | else: - | ^^^^ RET507 -86 | try: -87 | return - | - - diff --git a/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET508_RET508.py.snap b/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET508_RET508.py.snap deleted file mode 100644 index 5154b39429..0000000000 --- a/crates/ruff/src/rules/flake8_return/snapshots/ruff__rules__flake8_return__tests__RET508_RET508.py.snap +++ /dev/null @@ -1,82 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_return/mod.rs ---- -RET508.py:8:9: RET508 Unnecessary `elif` after `break` statement - | - 6 | if i > y: # [no-else-break] - 7 | break - 8 | elif i > w: - | ^^^^ RET508 - 9 | break -10 | else: - | - -RET508.py:22:9: RET508 Unnecessary `elif` after `break` statement - | -20 | b = 2 -21 | break -22 | elif z: - | ^^^^ RET508 -23 | c = 2 -24 | else: - | - -RET508.py:33:9: RET508 Unnecessary `else` after `break` statement - | -31 | if i > y: # [no-else-break] -32 | break -33 | else: - | ^^^^ RET508 -34 | a = z - | - -RET508.py:44:13: RET508 Unnecessary `else` after `break` statement - | -42 | b = 2 -43 | break -44 | else: - | ^^^^ RET508 -45 | c = 3 -46 | break - | - -RET508.py:60:9: RET508 Unnecessary `else` after `break` statement - | -58 | b = 2 -59 | break -60 | else: - | ^^^^ RET508 -61 | c = 3 -62 | break - | - -RET508.py:71:13: RET508 Unnecessary `else` after `break` statement - | -69 | a = 4 -70 | break -71 | else: - | ^^^^ RET508 -72 | b = 2 -73 | else: - | - -RET508.py:82:9: RET508 Unnecessary `else` after `break` statement - | -80 | if x: # [no-else-break] -81 | break -82 | else: - | ^^^^ RET508 -83 | try: -84 | return - | - -RET508.py:158:13: RET508 Unnecessary `else` after `break` statement - | -156 | if i > w: -157 | break -158 | else: - | ^^^^ RET508 -159 | a = z - | - - diff --git a/crates/ruff/src/rules/flake8_self/snapshots/ruff__rules__flake8_self__tests__ignore_names.snap b/crates/ruff/src/rules/flake8_self/snapshots/ruff__rules__flake8_self__tests__ignore_names.snap deleted file mode 100644 index 6d3072d4e8..0000000000 --- a/crates/ruff/src/rules/flake8_self/snapshots/ruff__rules__flake8_self__tests__ignore_names.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_self/mod.rs ---- -SLF001_extended.py:6:5: SLF001 Private member accessed: `_asdict` - | -5 | def foo(obj): -6 | obj._asdict # SLF001 - | ^^^^^^^^^^^ SLF001 - | - -SLF001_extended.py:10:5: SLF001 Private member accessed: `_bar` - | - 9 | def foo(obj): -10 | obj._bar # SLF001 - | ^^^^^^^^ SLF001 - | - - diff --git a/crates/ruff/src/rules/flake8_self/snapshots/ruff__rules__flake8_self__tests__private-member-access_SLF001.py.snap b/crates/ruff/src/rules/flake8_self/snapshots/ruff__rules__flake8_self__tests__private-member-access_SLF001.py.snap deleted file mode 100644 index 67940211f2..0000000000 --- a/crates/ruff/src/rules/flake8_self/snapshots/ruff__rules__flake8_self__tests__private-member-access_SLF001.py.snap +++ /dev/null @@ -1,111 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_self/mod.rs ---- -SLF001.py:34:12: SLF001 Private member accessed: `_private` - | -33 | def get_bar(): -34 | if self.bar._private: # SLF001 - | ^^^^^^^^^^^^^^^^^ SLF001 -35 | return None -36 | if self.bar()._private: # SLF001 - | - -SLF001.py:36:12: SLF001 Private member accessed: `_private` - | -34 | if self.bar._private: # SLF001 -35 | return None -36 | if self.bar()._private: # SLF001 - | ^^^^^^^^^^^^^^^^^^^ SLF001 -37 | return None -38 | if Bar._private_thing: # SLF001 - | - -SLF001.py:38:12: SLF001 Private member accessed: `_private_thing` - | -36 | if self.bar()._private: # SLF001 -37 | return None -38 | if Bar._private_thing: # SLF001 - | ^^^^^^^^^^^^^^^^^^ SLF001 -39 | return None -40 | if Foo._private_thing: - | - -SLF001.py:43:12: SLF001 Private member accessed: `_private_thing` - | -41 | return None -42 | Foo = Bar() -43 | if Foo._private_thing: # SLF001 - | ^^^^^^^^^^^^^^^^^^ SLF001 -44 | return None -45 | return self.bar - | - -SLF001.py:62:7: SLF001 Private member accessed: `_private_thing` - | -60 | foo = Foo() -61 | -62 | print(foo._private_thing) # SLF001 - | ^^^^^^^^^^^^^^^^^^ SLF001 -63 | print(foo.__really_private_thing) # SLF001 -64 | print(foo._private_func()) # SLF001 - | - -SLF001.py:63:7: SLF001 Private member accessed: `__really_private_thing` - | -62 | print(foo._private_thing) # SLF001 -63 | print(foo.__really_private_thing) # SLF001 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ SLF001 -64 | print(foo._private_func()) # SLF001 -65 | print(foo.__really_private_func(1)) # SLF001 - | - -SLF001.py:64:7: SLF001 Private member accessed: `_private_func` - | -62 | print(foo._private_thing) # SLF001 -63 | print(foo.__really_private_thing) # SLF001 -64 | print(foo._private_func()) # SLF001 - | ^^^^^^^^^^^^^^^^^ SLF001 -65 | print(foo.__really_private_func(1)) # SLF001 -66 | print(foo.bar._private) # SLF001 - | - -SLF001.py:65:7: SLF001 Private member accessed: `__really_private_func` - | -63 | print(foo.__really_private_thing) # SLF001 -64 | print(foo._private_func()) # SLF001 -65 | print(foo.__really_private_func(1)) # SLF001 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SLF001 -66 | print(foo.bar._private) # SLF001 -67 | print(foo()._private_thing) # SLF001 - | - -SLF001.py:66:7: SLF001 Private member accessed: `_private` - | -64 | print(foo._private_func()) # SLF001 -65 | print(foo.__really_private_func(1)) # SLF001 -66 | print(foo.bar._private) # SLF001 - | ^^^^^^^^^^^^^^^^ SLF001 -67 | print(foo()._private_thing) # SLF001 -68 | print(foo()._private_thing__) # SLF001 - | - -SLF001.py:67:7: SLF001 Private member accessed: `_private_thing` - | -65 | print(foo.__really_private_func(1)) # SLF001 -66 | print(foo.bar._private) # SLF001 -67 | print(foo()._private_thing) # SLF001 - | ^^^^^^^^^^^^^^^^^^^^ SLF001 -68 | print(foo()._private_thing__) # SLF001 - | - -SLF001.py:68:7: SLF001 Private member accessed: `_private_thing__` - | -66 | print(foo.bar._private) # SLF001 -67 | print(foo()._private_thing) # SLF001 -68 | print(foo()._private_thing__) # SLF001 - | ^^^^^^^^^^^^^^^^^^^^^^ SLF001 -69 | -70 | print(foo.public_thing) - | - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM101_SIM101.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM101_SIM101.py.snap deleted file mode 100644 index deff303a82..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM101_SIM101.py.snap +++ /dev/null @@ -1,149 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM101.py:1:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call - | -1 | if isinstance(a, int) or isinstance(a, float): # SIM101 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 -2 | pass - | - = help: Merge `isinstance` calls for `a` - -ℹ Suggested fix -1 |-if isinstance(a, int) or isinstance(a, float): # SIM101 - 1 |+if isinstance(a, (int, float)): # SIM101 -2 2 | pass -3 3 | -4 4 | if isinstance(a, (int, float)) or isinstance(a, bool): # SIM101 - -SIM101.py:4:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call - | -2 | pass -3 | -4 | if isinstance(a, (int, float)) or isinstance(a, bool): # SIM101 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 -5 | pass - | - = help: Merge `isinstance` calls for `a` - -ℹ Suggested fix -1 1 | if isinstance(a, int) or isinstance(a, float): # SIM101 -2 2 | pass -3 3 | -4 |-if isinstance(a, (int, float)) or isinstance(a, bool): # SIM101 - 4 |+if isinstance(a, (int, float, bool)): # SIM101 -5 5 | pass -6 6 | -7 7 | if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool): # SIM101 - -SIM101.py:7:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call - | -5 | pass -6 | -7 | if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool): # SIM101 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 -8 | pass - | - = help: Merge `isinstance` calls for `a` - -ℹ Suggested fix -4 4 | if isinstance(a, (int, float)) or isinstance(a, bool): # SIM101 -5 5 | pass -6 6 | -7 |-if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool): # SIM101 - 7 |+if isinstance(a, (int, float)) or isinstance(b, bool): # SIM101 -8 8 | pass -9 9 | -10 10 | if isinstance(b, bool) or isinstance(a, int) or isinstance(a, float): # SIM101 - -SIM101.py:10:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call - | - 8 | pass - 9 | -10 | if isinstance(b, bool) or isinstance(a, int) or isinstance(a, float): # SIM101 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 -11 | pass - | - = help: Merge `isinstance` calls for `a` - -ℹ Suggested fix -7 7 | if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool): # SIM101 -8 8 | pass -9 9 | -10 |-if isinstance(b, bool) or isinstance(a, int) or isinstance(a, float): # SIM101 - 10 |+if isinstance(a, (int, float)) or isinstance(b, bool): # SIM101 -11 11 | pass -12 12 | -13 13 | if isinstance(a, int) or isinstance(b, bool) or isinstance(a, float): # SIM101 - -SIM101.py:13:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call - | -11 | pass -12 | -13 | if isinstance(a, int) or isinstance(b, bool) or isinstance(a, float): # SIM101 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 -14 | pass - | - = help: Merge `isinstance` calls for `a` - -ℹ Suggested fix -10 10 | if isinstance(b, bool) or isinstance(a, int) or isinstance(a, float): # SIM101 -11 11 | pass -12 12 | -13 |-if isinstance(a, int) or isinstance(b, bool) or isinstance(a, float): # SIM101 - 13 |+if isinstance(a, (int, float)) or isinstance(b, bool): # SIM101 -14 14 | pass -15 15 | -16 16 | if (isinstance(a, int) or isinstance(a, float)) and isinstance(b, bool): # SIM101 - -SIM101.py:16:5: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call - | -14 | pass -15 | -16 | if (isinstance(a, int) or isinstance(a, float)) and isinstance(b, bool): # SIM101 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 -17 | pass - | - = help: Merge `isinstance` calls for `a` - -ℹ Suggested fix -13 13 | if isinstance(a, int) or isinstance(b, bool) or isinstance(a, float): # SIM101 -14 14 | pass -15 15 | -16 |-if (isinstance(a, int) or isinstance(a, float)) and isinstance(b, bool): # SIM101 - 16 |+if (isinstance(a, (int, float))) and isinstance(b, bool): # SIM101 -17 17 | pass -18 18 | -19 19 | if isinstance(a.b, int) or isinstance(a.b, float): # SIM101 - -SIM101.py:19:4: SIM101 [*] Multiple `isinstance` calls for expression, merge into a single call - | -17 | pass -18 | -19 | if isinstance(a.b, int) or isinstance(a.b, float): # SIM101 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 -20 | pass - | - = help: Merge `isinstance` calls - -ℹ Suggested fix -16 16 | if (isinstance(a, int) or isinstance(a, float)) and isinstance(b, bool): # SIM101 -17 17 | pass -18 18 | -19 |-if isinstance(a.b, int) or isinstance(a.b, float): # SIM101 - 19 |+if isinstance(a.b, (int, float)): # SIM101 -20 20 | pass -21 21 | -22 22 | if isinstance(a(), int) or isinstance(a(), float): # SIM101 - -SIM101.py:22:4: SIM101 Multiple `isinstance` calls for expression, merge into a single call - | -20 | pass -21 | -22 | if isinstance(a(), int) or isinstance(a(), float): # SIM101 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 -23 | pass - | - = help: Merge `isinstance` calls - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM102_SIM102.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM102_SIM102.py.snap deleted file mode 100644 index ea461e39cc..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM102_SIM102.py.snap +++ /dev/null @@ -1,357 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM102.py:2:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements - | -1 | # SIM102 -2 | / if a: -3 | | if b: - | |_________^ SIM102 -4 | c - | - = help: Combine `if` statements using `and` - -ℹ Suggested fix -1 1 | # SIM102 -2 |-if a: -3 |- if b: -4 |- c - 2 |+if a and b: - 3 |+ c -5 4 | -6 5 | # SIM102 -7 6 | if a: - -SIM102.py:7:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements - | - 6 | # SIM102 - 7 | / if a: - 8 | | if b: - 9 | | if c: - | |_____________^ SIM102 -10 | d - | - = help: Combine `if` statements using `and` - -ℹ Suggested fix -4 4 | c -5 5 | -6 6 | # SIM102 -7 |-if a: -8 |- if b: -9 |- if c: -10 |- d - 7 |+if a and b: - 8 |+ if c: - 9 |+ d -11 10 | -12 11 | # SIM102 -13 12 | if a: - -SIM102.py:8:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements - | - 6 | # SIM102 - 7 | if a: - 8 | if b: - | _____^ - 9 | | if c: - | |_____________^ SIM102 -10 | d - | - = help: Combine `if` statements using `and` - -ℹ Suggested fix -5 5 | -6 6 | # SIM102 -7 7 | if a: -8 |- if b: -9 |- if c: -10 |- d - 8 |+ if b and c: - 9 |+ d -11 10 | -12 11 | # SIM102 -13 12 | if a: - -SIM102.py:15:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements - | -13 | if a: -14 | pass -15 | / elif b: -16 | | if c: - | |_________^ SIM102 -17 | d - | - = help: Combine `if` statements using `and` - -ℹ Suggested fix -12 12 | # SIM102 -13 13 | if a: -14 14 | pass -15 |-elif b: -16 |- if c: -17 |- d - 15 |+elif b and c: - 16 |+ d -18 17 | -19 18 | # SIM102 -20 19 | if a: - -SIM102.py:20:1: SIM102 Use a single `if` statement instead of nested `if` statements - | -19 | # SIM102 -20 | / if a: -21 | | # Unfixable due to placement of this comment. -22 | | if b: - | |_________^ SIM102 -23 | c - | - = help: Combine `if` statements using `and` - -SIM102.py:26:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements - | -25 | # SIM102 -26 | / if a: -27 | | if b: - | |_________^ SIM102 -28 | # Fixable due to placement of this comment. -29 | c - | - = help: Combine `if` statements using `and` - -ℹ Suggested fix -23 23 | c -24 24 | -25 25 | # SIM102 -26 |-if a: -27 |- if b: -28 |- # Fixable due to placement of this comment. -29 |- c - 26 |+if a and b: - 27 |+ # Fixable due to placement of this comment. - 28 |+ c -30 29 | -31 30 | # OK -32 31 | if a: - -SIM102.py:51:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements - | -49 | while x > 0: -50 | # SIM102 -51 | if y > 0: - | _____^ -52 | | if z > 0: - | |_________________^ SIM102 -53 | """this -54 | is valid""" - | - = help: Combine `if` statements using `and` - -ℹ Suggested fix -48 48 | -49 49 | while x > 0: -50 50 | # SIM102 -51 |- if y > 0: -52 |- if z > 0: -53 |- """this - 51 |+ if y > 0 and z > 0: - 52 |+ """this -54 53 | is valid""" -55 54 | -56 |- """the indentation on - 55 |+ """the indentation on -57 56 | this line is significant""" -58 57 | -59 |- "this is" \ - 58 |+ "this is" \ -60 59 | "allowed too" -61 60 | -62 |- ("so is" - 61 |+ ("so is" -63 62 | "this for some reason") -64 63 | -65 64 | - -SIM102.py:67:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements - | -66 | # SIM102 -67 | / if x > 0: -68 | | if y > 0: - | |_____________^ SIM102 -69 | """this -70 | is valid""" - | - = help: Combine `if` statements using `and` - -ℹ Suggested fix -64 64 | -65 65 | -66 66 | # SIM102 -67 |-if x > 0: -68 |- if y > 0: -69 |- """this - 67 |+if x > 0 and y > 0: - 68 |+ """this -70 69 | is valid""" -71 70 | -72 |- """the indentation on - 71 |+ """the indentation on -73 72 | this line is significant""" -74 73 | -75 |- "this is" \ - 74 |+ "this is" \ -76 75 | "allowed too" -77 76 | -78 |- ("so is" - 77 |+ ("so is" -79 78 | "this for some reason") -80 79 | -81 80 | while x > 0: - -SIM102.py:83:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements - | -81 | while x > 0: -82 | # SIM102 -83 | if node.module: - | _____^ -84 | | if node.module == "multiprocessing" or node.module.startswith( -85 | | "multiprocessing." -86 | | ): - | |__________^ SIM102 -87 | print("Bad module!") - | - = help: Combine `if` statements using `and` - -ℹ Suggested fix -80 80 | -81 81 | while x > 0: -82 82 | # SIM102 -83 |- if node.module: -84 |- if node.module == "multiprocessing" or node.module.startswith( -85 |- "multiprocessing." -86 |- ): -87 |- print("Bad module!") - 83 |+ if node.module and (node.module == "multiprocessing" or node.module.startswith( - 84 |+ "multiprocessing." - 85 |+ )): - 86 |+ print("Bad module!") -88 87 | -89 88 | # SIM102 (auto-fixable) -90 89 | if node.module012345678: - -SIM102.py:90:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements - | -89 | # SIM102 (auto-fixable) -90 | / if node.module012345678: -91 | | if node.module == "multiprocß9💣2ℝ" or node.module.startswith( -92 | | "multiprocessing." -93 | | ): - | |______^ SIM102 -94 | print("Bad module!") - | - = help: Combine `if` statements using `and` - -ℹ Suggested fix -87 87 | print("Bad module!") -88 88 | -89 89 | # SIM102 (auto-fixable) -90 |-if node.module012345678: -91 |- if node.module == "multiprocß9💣2ℝ" or node.module.startswith( -92 |- "multiprocessing." -93 |- ): -94 |- print("Bad module!") - 90 |+if node.module012345678 and (node.module == "multiprocß9💣2ℝ" or node.module.startswith( - 91 |+ "multiprocessing." - 92 |+)): - 93 |+ print("Bad module!") -95 94 | -96 95 | # SIM102 (not auto-fixable) -97 96 | if node.module0123456789: - -SIM102.py:97:1: SIM102 Use a single `if` statement instead of nested `if` statements - | - 96 | # SIM102 (not auto-fixable) - 97 | / if node.module0123456789: - 98 | | if node.module == "multiprocß9💣2ℝ" or node.module.startswith( - 99 | | "multiprocessing." -100 | | ): - | |______^ SIM102 -101 | print("Bad module!") - | - = help: Combine `if` statements using `and` - -SIM102.py:106:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements - | -104 | # Regression test for https://github.com/apache/airflow/blob/145b16caaa43f0c42bffd97344df916c602cddde/airflow/configuration.py#L1161 -105 | if a: -106 | if b: - | _____^ -107 | | if c: - | |_____________^ SIM102 -108 | print("if") -109 | elif d: - | - = help: Combine `if` statements using `and` - -ℹ Suggested fix -103 103 | # SIM102 -104 104 | # Regression test for https://github.com/apache/airflow/blob/145b16caaa43f0c42bffd97344df916c602cddde/airflow/configuration.py#L1161 -105 105 | if a: -106 |- if b: -107 |- if c: -108 |- print("if") - 106 |+ if b and c: - 107 |+ print("if") -109 108 | elif d: -110 109 | print("elif") -111 110 | - -SIM102.py:132:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements - | -130 | if a: -131 | # SIM 102 -132 | if b: - | _____^ -133 | | if c: - | |_____________^ SIM102 -134 | print("foo") -135 | else: - | - = help: Combine `if` statements using `and` - -ℹ Suggested fix -129 129 | # OK -130 130 | if a: -131 131 | # SIM 102 -132 |- if b: -133 |- if c: -134 |- print("foo") - 132 |+ if b and c: - 133 |+ print("foo") -135 134 | else: -136 135 | print("bar") -137 136 | - -SIM102.py:165:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements - | -163 | if a: -164 | pass -165 | elif b: - | _____^ -166 | | if c: - | |_____________^ SIM102 -167 | d - | - = help: Combine `if` statements using `and` - -ℹ Suggested fix -162 162 | def f(): -163 163 | if a: -164 164 | pass -165 |- elif b: -166 |- if c: -167 |- d - 165 |+ elif b and c: - 166 |+ d - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM103_SIM103.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM103_SIM103.py.snap deleted file mode 100644 index c33eb07ce9..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM103_SIM103.py.snap +++ /dev/null @@ -1,133 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM103.py:3:5: SIM103 [*] Return the condition `a` directly - | -1 | def f(): -2 | # SIM103 -3 | if a: - | _____^ -4 | | return True -5 | | else: -6 | | return False - | |____________________^ SIM103 - | - = help: Replace with `return a` - -ℹ Suggested fix -1 1 | def f(): -2 2 | # SIM103 -3 |- if a: -4 |- return True -5 |- else: -6 |- return False - 3 |+ return bool(a) -7 4 | -8 5 | -9 6 | def f(): - -SIM103.py:11:5: SIM103 [*] Return the condition `a == b` directly - | - 9 | def f(): -10 | # SIM103 -11 | if a == b: - | _____^ -12 | | return True -13 | | else: -14 | | return False - | |____________________^ SIM103 - | - = help: Replace with `return a == b` - -ℹ Suggested fix -8 8 | -9 9 | def f(): -10 10 | # SIM103 -11 |- if a == b: -12 |- return True -13 |- else: -14 |- return False - 11 |+ return a == b -15 12 | -16 13 | -17 14 | def f(): - -SIM103.py:21:5: SIM103 [*] Return the condition `b` directly - | -19 | if a: -20 | return 1 -21 | elif b: - | _____^ -22 | | return True -23 | | else: -24 | | return False - | |____________________^ SIM103 - | - = help: Replace with `return b` - -ℹ Suggested fix -18 18 | # SIM103 -19 19 | if a: -20 20 | return 1 -21 |- elif b: -22 |- return True -23 |- else: -24 |- return False - 21 |+ return bool(b) -25 22 | -26 23 | -27 24 | def f(): - -SIM103.py:32:9: SIM103 [*] Return the condition `b` directly - | -30 | return 1 -31 | else: -32 | if b: - | _________^ -33 | | return True -34 | | else: -35 | | return False - | |________________________^ SIM103 - | - = help: Replace with `return b` - -ℹ Suggested fix -29 29 | if a: -30 30 | return 1 -31 31 | else: -32 |- if b: -33 |- return True -34 |- else: -35 |- return False - 32 |+ return bool(b) -36 33 | -37 34 | -38 35 | def f(): - -SIM103.py:57:5: SIM103 Return the condition `a` directly - | -55 | def f(): -56 | # SIM103 (but not fixable) -57 | if a: - | _____^ -58 | | return False -59 | | else: -60 | | return True - | |___________________^ SIM103 - | - = help: Replace with `return a` - -SIM103.py:83:5: SIM103 Return the condition `a` directly - | -81 | def bool(): -82 | return False -83 | if a: - | _____^ -84 | | return True -85 | | else: -86 | | return False - | |____________________^ SIM103 - | - = help: Replace with `return a` - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap deleted file mode 100644 index f11cb66d1d..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap +++ /dev/null @@ -1,294 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM105_0.py:6:1: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` - | -5 | # SIM105 -6 | / try: -7 | | foo() -8 | | except ValueError: -9 | | pass - | |________^ SIM105 - | - = help: Replace with `contextlib.suppress(ValueError)` - -ℹ Suggested fix - 1 |+import contextlib -1 2 | def foo(): -2 3 | pass -3 4 | -4 5 | -5 6 | # SIM105 -6 |-try: - 7 |+with contextlib.suppress(ValueError): -7 8 | foo() -8 |-except ValueError: -9 |- pass -10 9 | -11 10 | -12 11 | # SIM105 - -SIM105_0.py:13:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` - | -12 | # SIM105 -13 | / try: -14 | | foo() -15 | | except (ValueError, OSError): -16 | | pass - | |________^ SIM105 -17 | -18 | # SIM105 - | - = help: Replace with `contextlib.suppress(ValueError, OSError)` - -ℹ Suggested fix - 1 |+import contextlib -1 2 | def foo(): -2 3 | pass -3 4 | --------------------------------------------------------------------------------- -10 11 | -11 12 | -12 13 | # SIM105 -13 |-try: - 14 |+with contextlib.suppress(ValueError, OSError): -14 15 | foo() -15 |-except (ValueError, OSError): -16 |- pass -17 16 | -18 17 | # SIM105 -19 18 | try: - -SIM105_0.py:19:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` - | -18 | # SIM105 -19 | / try: -20 | | foo() -21 | | except (ValueError, OSError) as e: -22 | | pass - | |________^ SIM105 -23 | -24 | # SIM105 - | - = help: Replace with `contextlib.suppress(ValueError, OSError)` - -ℹ Suggested fix - 1 |+import contextlib -1 2 | def foo(): -2 3 | pass -3 4 | --------------------------------------------------------------------------------- -16 17 | pass -17 18 | -18 19 | # SIM105 -19 |-try: - 20 |+with contextlib.suppress(ValueError, OSError): -20 21 | foo() -21 |-except (ValueError, OSError) as e: -22 |- pass -23 22 | -24 23 | # SIM105 -25 24 | try: - -SIM105_0.py:25:1: SIM105 [*] Use `contextlib.suppress(Exception)` instead of `try`-`except`-`pass` - | -24 | # SIM105 -25 | / try: -26 | | foo() -27 | | except: -28 | | pass - | |________^ SIM105 -29 | -30 | # SIM105 - | - = help: Replace with `contextlib.suppress(Exception)` - -ℹ Suggested fix - 1 |+import contextlib -1 2 | def foo(): -2 3 | pass -3 4 | --------------------------------------------------------------------------------- -22 23 | pass -23 24 | -24 25 | # SIM105 -25 |-try: - 26 |+with contextlib.suppress(Exception): -26 27 | foo() -27 |-except: -28 |- pass -29 28 | -30 29 | # SIM105 -31 30 | try: - -SIM105_0.py:31:1: SIM105 [*] Use `contextlib.suppress(a.Error, b.Error)` instead of `try`-`except`-`pass` - | -30 | # SIM105 -31 | / try: -32 | | foo() -33 | | except (a.Error, b.Error): -34 | | pass - | |________^ SIM105 -35 | -36 | # OK - | - = help: Replace with `contextlib.suppress(a.Error, b.Error)` - -ℹ Suggested fix - 1 |+import contextlib -1 2 | def foo(): -2 3 | pass -3 4 | --------------------------------------------------------------------------------- -28 29 | pass -29 30 | -30 31 | # SIM105 -31 |-try: - 32 |+with contextlib.suppress(a.Error, b.Error): -32 33 | foo() -33 |-except (a.Error, b.Error): -34 |- pass -35 34 | -36 35 | # OK -37 36 | try: - -SIM105_0.py:85:5: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` - | -83 | def with_ellipsis(): -84 | # OK -85 | try: - | _____^ -86 | | foo() -87 | | except ValueError: -88 | | ... - | |___________^ SIM105 - | - = help: Replace with `contextlib.suppress(ValueError)` - -ℹ Suggested fix - 1 |+import contextlib -1 2 | def foo(): -2 3 | pass -3 4 | --------------------------------------------------------------------------------- -82 83 | -83 84 | def with_ellipsis(): -84 85 | # OK -85 |- try: - 86 |+ with contextlib.suppress(ValueError): -86 87 | foo() -87 |- except ValueError: -88 |- ... -89 88 | -90 89 | -91 90 | def with_ellipsis_and_return(): - -SIM105_0.py:100:5: SIM105 Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` - | - 99 | def with_comment(): -100 | try: - | _____^ -101 | | foo() -102 | | except (ValueError, OSError): -103 | | pass # Trailing comment. - | |____________^ SIM105 -104 | -105 | try: - | - = help: Replace with `contextlib.suppress(ValueError, OSError)` - -SIM105_0.py:117:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass` - | -115 | # Regression test for: https://github.com/astral-sh/ruff/issues/7123 -116 | def write_models(directory, Models): -117 | try: - | _____^ -118 | | os.makedirs(model_dir); -119 | | except OSError: -120 | | pass; - | |____________^ SIM105 -121 | -122 | try: os.makedirs(model_dir); - | - = help: Replace with `contextlib.suppress(OSError)` - -ℹ Suggested fix - 1 |+import contextlib -1 2 | def foo(): -2 3 | pass -3 4 | --------------------------------------------------------------------------------- -114 115 | -115 116 | # Regression test for: https://github.com/astral-sh/ruff/issues/7123 -116 117 | def write_models(directory, Models): -117 |- try: - 118 |+ with contextlib.suppress(OSError): -118 119 | os.makedirs(model_dir); -119 |- except OSError: -120 |- pass; -121 120 | -122 121 | try: os.makedirs(model_dir); -123 122 | except OSError: - -SIM105_0.py:122:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass` - | -120 | pass; -121 | -122 | try: os.makedirs(model_dir); - | _____^ -123 | | except OSError: -124 | | pass; - | |____________^ SIM105 -125 | -126 | try: os.makedirs(model_dir); - | - = help: Replace with `contextlib.suppress(OSError)` - -ℹ Suggested fix - 1 |+import contextlib -1 2 | def foo(): -2 3 | pass -3 4 | --------------------------------------------------------------------------------- -119 120 | except OSError: -120 121 | pass; -121 122 | -122 |- try: os.makedirs(model_dir); -123 |- except OSError: -124 |- pass; - 123 |+ with contextlib.suppress(OSError): os.makedirs(model_dir); -125 124 | -126 125 | try: os.makedirs(model_dir); -127 126 | except OSError: - -SIM105_0.py:126:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass` - | -124 | pass; -125 | -126 | try: os.makedirs(model_dir); - | _____^ -127 | | except OSError: -128 | | pass; \ - | |____________^ SIM105 -129 | \ -130 | # - | - = help: Replace with `contextlib.suppress(OSError)` - -ℹ Suggested fix - 1 |+import contextlib -1 2 | def foo(): -2 3 | pass -3 4 | --------------------------------------------------------------------------------- -123 124 | except OSError: -124 125 | pass; -125 126 | -126 |- try: os.makedirs(model_dir); -127 |- except OSError: -128 |- pass; \ - 127 |+ with contextlib.suppress(OSError): os.makedirs(model_dir); -129 128 | \ -130 129 | # - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_1.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_1.py.snap deleted file mode 100644 index 2d8426b90e..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_1.py.snap +++ /dev/null @@ -1,27 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM105_1.py:5:1: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` - | -4 | # SIM105 -5 | / try: -6 | | math.sqrt(-1) -7 | | except ValueError: -8 | | pass - | |________^ SIM105 - | - = help: Replace with `contextlib.suppress(ValueError)` - -ℹ Suggested fix -1 1 | """Case: There's a random import, so it should add `contextlib` after it.""" -2 2 | import math - 3 |+import contextlib -3 4 | -4 5 | # SIM105 -5 |-try: - 6 |+with contextlib.suppress(ValueError): -6 7 | math.sqrt(-1) -7 |-except ValueError: -8 |- pass - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_2.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_2.py.snap deleted file mode 100644 index 6a41bb27e1..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_2.py.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM105_2.py:10:1: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` - | - 9 | # SIM105 -10 | / try: -11 | | foo() -12 | | except ValueError: -13 | | pass - | |________^ SIM105 - | - = help: Replace with `contextlib.suppress(ValueError)` - -ℹ Suggested fix -7 7 | -8 8 | -9 9 | # SIM105 -10 |-try: - 10 |+with contextlib.suppress(ValueError): -11 11 | foo() -12 |-except ValueError: -13 |- pass - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_3.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_3.py.snap deleted file mode 100644 index 18413a2f74..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM105_SIM105_3.py.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM105_3.py:10:5: SIM105 Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` - | - 8 | def bar(): - 9 | # SIM105 -10 | try: - | _____^ -11 | | foo() -12 | | except ValueError: -13 | | pass - | |____________^ SIM105 - | - = help: Replace with `contextlib.suppress(ValueError)` - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM107_SIM107.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM107_SIM107.py.snap deleted file mode 100644 index d552d7b9c5..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM107_SIM107.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM107.py:9:9: SIM107 Don't use `return` in `try`-`except` and `finally` - | -7 | return "2" -8 | finally: -9 | return "3" - | ^^^^^^^^^^ SIM107 - | - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM108_SIM108.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM108_SIM108.py.snap deleted file mode 100644 index 7d361835a6..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM108_SIM108.py.snap +++ /dev/null @@ -1,122 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM108.py:2:1: SIM108 [*] Use ternary operator `b = c if a else d` instead of `if`-`else`-block - | -1 | # SIM108 -2 | / if a: -3 | | b = c -4 | | else: -5 | | b = d - | |_________^ SIM108 -6 | -7 | # OK - | - = help: Replace `if`-`else`-block with `b = c if a else d` - -ℹ Suggested fix -1 1 | # SIM108 -2 |-if a: -3 |- b = c -4 |-else: -5 |- b = d - 2 |+b = c if a else d -6 3 | -7 4 | # OK -8 5 | b = c if a else d - -SIM108.py:30:5: SIM108 [*] Use ternary operator `b = 1 if a else 2` instead of `if`-`else`-block - | -28 | pass -29 | else: -30 | if a: - | _____^ -31 | | b = 1 -32 | | else: -33 | | b = 2 - | |_____________^ SIM108 - | - = help: Replace `if`-`else`-block with `b = 1 if a else 2` - -ℹ Suggested fix -27 27 | if True: -28 28 | pass -29 29 | else: -30 |- if a: -31 |- b = 1 -32 |- else: -33 |- b = 2 - 30 |+ b = 1 if a else 2 -34 31 | -35 32 | -36 33 | import sys - -SIM108.py:58:1: SIM108 Use ternary operator `abc = x if x > 0 else -x` instead of `if`-`else`-block - | -57 | # SIM108 (without fix due to comments) -58 | / if x > 0: -59 | | # test test -60 | | abc = x -61 | | else: -62 | | # test test test -63 | | abc = -x - | |____________^ SIM108 - | - = help: Replace `if`-`else`-block with `abc = x if x > 0 else -x` - -SIM108.py:82:1: SIM108 [*] Use ternary operator `b = "cccccccccccccccccccccccccccccccccß" if a else "ddddddddddddddddddddddddddddddddd💣"` instead of `if`-`else`-block - | -81 | # SIM108 -82 | / if a: -83 | | b = "cccccccccccccccccccccccccccccccccß" -84 | | else: -85 | | b = "ddddddddddddddddddddddddddddddddd💣" - | |_____________________________________________^ SIM108 - | - = help: Replace `if`-`else`-block with `b = "cccccccccccccccccccccccccccccccccß" if a else "ddddddddddddddddddddddddddddddddd💣"` - -ℹ Suggested fix -79 79 | -80 80 | -81 81 | # SIM108 -82 |-if a: -83 |- b = "cccccccccccccccccccccccccccccccccß" -84 |-else: -85 |- b = "ddddddddddddddddddddddddddddddddd💣" - 82 |+b = "cccccccccccccccccccccccccccccccccß" if a else "ddddddddddddddddddddddddddddddddd💣" -86 83 | -87 84 | -88 85 | # OK (too long) - -SIM108.py:105:1: SIM108 Use ternary operator `exitcode = 0 if True else 1` instead of `if`-`else`-block - | -104 | # SIM108 (without fix due to trailing comment) -105 | / if True: -106 | | exitcode = 0 -107 | | else: -108 | | exitcode = 1 # Trailing comment - | |________________^ SIM108 - | - = help: Replace `if`-`else`-block with `exitcode = 0 if True else 1` - -SIM108.py:112:1: SIM108 Use ternary operator `x = 3 if True else 5` instead of `if`-`else`-block - | -111 | # SIM108 -112 | / if True: x = 3 # Foo -113 | | else: x = 5 - | |___________^ SIM108 - | - = help: Replace `if`-`else`-block with `x = 3 if True else 5` - -SIM108.py:117:1: SIM108 Use ternary operator `x = 3 if True else 5` instead of `if`-`else`-block - | -116 | # SIM108 -117 | / if True: # Foo -118 | | x = 3 -119 | | else: -120 | | x = 5 - | |_________^ SIM108 - | - = help: Replace `if`-`else`-block with `x = 3 if True else 5` - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM109_SIM109.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM109_SIM109.py.snap deleted file mode 100644 index e9e7686139..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM109_SIM109.py.snap +++ /dev/null @@ -1,78 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM109.py:2:4: SIM109 [*] Use `a in (b, c)` instead of multiple equality comparisons - | -1 | # SIM109 -2 | if a == b or a == c: - | ^^^^^^^^^^^^^^^^ SIM109 -3 | d - | - = help: Replace with `a in (b, c)` - -ℹ Suggested fix -1 1 | # SIM109 -2 |-if a == b or a == c: - 2 |+if a in (b, c): -3 3 | d -4 4 | -5 5 | # SIM109 - -SIM109.py:6:5: SIM109 [*] Use `a in (b, c)` instead of multiple equality comparisons - | -5 | # SIM109 -6 | if (a == b or a == c) and None: - | ^^^^^^^^^^^^^^^^ SIM109 -7 | d - | - = help: Replace with `a in (b, c)` - -ℹ Suggested fix -3 3 | d -4 4 | -5 5 | # SIM109 -6 |-if (a == b or a == c) and None: - 6 |+if (a in (b, c)) and None: -7 7 | d -8 8 | -9 9 | # SIM109 - -SIM109.py:10:4: SIM109 [*] Use `a in (b, c)` instead of multiple equality comparisons - | - 9 | # SIM109 -10 | if a == b or a == c or None: - | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM109 -11 | d - | - = help: Replace with `a in (b, c)` - -ℹ Suggested fix -7 7 | d -8 8 | -9 9 | # SIM109 -10 |-if a == b or a == c or None: - 10 |+if a in (b, c) or None: -11 11 | d -12 12 | -13 13 | # SIM109 - -SIM109.py:14:4: SIM109 [*] Use `a in (b, c)` instead of multiple equality comparisons - | -13 | # SIM109 -14 | if a == b or None or a == c: - | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM109 -15 | d - | - = help: Replace with `a in (b, c)` - -ℹ Suggested fix -11 11 | d -12 12 | -13 13 | # SIM109 -14 |-if a == b or None or a == c: - 14 |+if a in (b, c) or None: -15 15 | d -16 16 | -17 17 | # OK - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM110.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM110.py.snap deleted file mode 100644 index 1a815035bd..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM110.py.snap +++ /dev/null @@ -1,320 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -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: - | _____^ -4 | | if check(x): -5 | | return True -6 | | return False - | |________________^ SIM110 - | - = help: Replace with `return any(check(x) for x in iterable)` - -ℹ Suggested fix -1 1 | def f(): -2 2 | # SIM110 -3 |- for x in iterable: -4 |- if check(x): -5 |- return True -6 |- return False - 3 |+ return any(check(x) for x in iterable) -7 4 | -8 5 | -9 6 | def f(): - -SIM110.py:25:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop - | -23 | def f(): -24 | # SIM111 -25 | for x in iterable: - | _____^ -26 | | if check(x): -27 | | return False -28 | | return True - | |_______________^ SIM110 - | - = help: Replace with `return all(not check(x) for x in iterable)` - -ℹ Suggested fix -22 22 | -23 23 | def f(): -24 24 | # SIM111 -25 |- for x in iterable: -26 |- if check(x): -27 |- return False -28 |- return True - 25 |+ return all(not check(x) for x in iterable) -29 26 | -30 27 | -31 28 | def f(): - -SIM110.py:33:5: SIM110 [*] Use `return all(x.is_empty() for x in iterable)` instead of `for` loop - | -31 | def f(): -32 | # SIM111 -33 | for x in iterable: - | _____^ -34 | | if not x.is_empty(): -35 | | return False -36 | | return True - | |_______________^ SIM110 - | - = help: Replace with `return all(x.is_empty() for x in iterable)` - -ℹ Suggested fix -30 30 | -31 31 | def f(): -32 32 | # SIM111 -33 |- for x in iterable: -34 |- if not x.is_empty(): -35 |- return False -36 |- return True - 33 |+ return all(x.is_empty() for x in iterable) -37 34 | -38 35 | -39 36 | def f(): - -SIM110.py:55:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop - | -53 | def f(): -54 | # SIM110 -55 | for x in iterable: - | _____^ -56 | | if check(x): -57 | | return True -58 | | else: -59 | | return False - | |____________________^ SIM110 - | - = help: Replace with `return any(check(x) for x in iterable)` - -ℹ Suggested fix -52 52 | -53 53 | def f(): -54 54 | # SIM110 -55 |- for x in iterable: -56 |- if check(x): -57 |- return True -58 |- else: -59 |- return False - 55 |+ return any(check(x) for x in iterable) -60 56 | -61 57 | -62 58 | def f(): - -SIM110.py:64:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop - | -62 | def f(): -63 | # SIM111 -64 | for x in iterable: - | _____^ -65 | | if check(x): -66 | | return False -67 | | else: -68 | | return True - | |___________________^ SIM110 - | - = help: Replace with `return all(not check(x) for x in iterable)` - -ℹ Suggested fix -61 61 | -62 62 | def f(): -63 63 | # SIM111 -64 |- for x in iterable: -65 |- if check(x): -66 |- return False -67 |- else: -68 |- return True - 64 |+ return all(not check(x) for x in iterable) -69 65 | -70 66 | -71 67 | def f(): - -SIM110.py:73:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop - | -71 | def f(): -72 | # SIM110 -73 | for x in iterable: - | _____^ -74 | | if check(x): -75 | | return True -76 | | else: -77 | | return False - | |____________________^ SIM110 -78 | return True - | - = help: Replace with `return any(check(x) for x in iterable)` - -ℹ Suggested fix -70 70 | -71 71 | def f(): -72 72 | # SIM110 -73 |- for x in iterable: -74 |- if check(x): -75 |- return True -76 |- else: -77 |- return False - 73 |+ return any(check(x) for x in iterable) -78 74 | return True -79 75 | -80 76 | - -SIM110.py:83:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop - | -81 | def f(): -82 | # SIM111 -83 | for x in iterable: - | _____^ -84 | | if check(x): -85 | | return False -86 | | else: -87 | | return True - | |___________________^ SIM110 -88 | return False - | - = help: Replace with `return all(not check(x) for x in iterable)` - -ℹ Suggested fix -80 80 | -81 81 | def f(): -82 82 | # SIM111 -83 |- for x in iterable: -84 |- if check(x): -85 |- return False -86 |- else: -87 |- return True - 83 |+ return all(not check(x) for x in iterable) -88 84 | return False -89 85 | -90 86 | - -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: - | _____^ -125 | | if check(x): -126 | | return True -127 | | return False - | |________________^ SIM110 - | - = help: Replace with `return any(check(x) for x in iterable)` - -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: - | _____^ -135 | | if check(x): -136 | | return False -137 | | return True - | |_______________^ SIM110 - | - = help: Replace with `return all(not check(x) for x in iterable)` - -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: - | _____^ -145 | | if check(x): -146 | | return True -147 | | return False - | |________________^ SIM110 - | - = help: Replace with `return any(check(x) for x in iterable)` - -ℹ Suggested fix -141 141 | x = 1 -142 142 | -143 143 | # SIM110 -144 |- for x in iterable: -145 |- if check(x): -146 |- return True -147 |- return False - 144 |+ return any(check(x) for x in iterable) -148 145 | -149 146 | -150 147 | def f(): - -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: - | _____^ -155 | | if check(x): -156 | | return False -157 | | return True - | |_______________^ SIM110 - | - = help: Replace with `return all(not check(x) for x in iterable)` - -ℹ Suggested fix -151 151 | x = 1 -152 152 | -153 153 | # SIM111 -154 |- for x in iterable: -155 |- if check(x): -156 |- return False -157 |- return True - 154 |+ return all(not check(x) for x in iterable) -158 155 | -159 156 | -160 157 | def f(): - -SIM110.py:162:5: SIM110 [*] Use `return any(x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ")` instead of `for` loop - | -160 | def f(): -161 | # SIM110 -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 - | |________________^ SIM110 - | - = help: Replace with `return any(x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ")` - -ℹ Suggested fix -159 159 | -160 160 | def f(): -161 161 | # SIM110 -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 - 162 |+ return any(x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ") -166 163 | -167 164 | -168 165 | def f(): - -SIM110.py:184:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop - | -182 | async def f(): -183 | # SIM110 -184 | for x in iterable: - | _____^ -185 | | if check(x): -186 | | return True -187 | | return False - | |________________^ SIM110 - | - = help: Replace with `return any(check(x) for x in iterable)` - -ℹ Suggested fix -181 181 | -182 182 | async def f(): -183 183 | # SIM110 -184 |- for x in iterable: -185 |- if check(x): -186 |- return True -187 |- return False - 184 |+ return any(check(x) for x in iterable) - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM111.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM111.py.snap deleted file mode 100644 index 22f8cd884a..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM110_SIM111.py.snap +++ /dev/null @@ -1,349 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -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: - | _____^ -4 | | if check(x): -5 | | return True -6 | | return False - | |________________^ SIM110 - | - = help: Replace with `return any(check(x) for x in iterable)` - -ℹ Suggested fix -1 1 | def f(): -2 2 | # SIM110 -3 |- for x in iterable: -4 |- if check(x): -5 |- return True -6 |- return False - 3 |+ return any(check(x) for x in iterable) -7 4 | -8 5 | -9 6 | def f(): - -SIM111.py:25:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop - | -23 | def f(): -24 | # SIM111 -25 | for x in iterable: - | _____^ -26 | | if check(x): -27 | | return False -28 | | return True - | |_______________^ SIM110 - | - = help: Replace with `return all(not check(x) for x in iterable)` - -ℹ Suggested fix -22 22 | -23 23 | def f(): -24 24 | # SIM111 -25 |- for x in iterable: -26 |- if check(x): -27 |- return False -28 |- return True - 25 |+ return all(not check(x) for x in iterable) -29 26 | -30 27 | -31 28 | def f(): - -SIM111.py:33:5: SIM110 [*] Use `return all(x.is_empty() for x in iterable)` instead of `for` loop - | -31 | def f(): -32 | # SIM111 -33 | for x in iterable: - | _____^ -34 | | if not x.is_empty(): -35 | | return False -36 | | return True - | |_______________^ SIM110 - | - = help: Replace with `return all(x.is_empty() for x in iterable)` - -ℹ Suggested fix -30 30 | -31 31 | def f(): -32 32 | # SIM111 -33 |- for x in iterable: -34 |- if not x.is_empty(): -35 |- return False -36 |- return True - 33 |+ return all(x.is_empty() for x in iterable) -37 34 | -38 35 | -39 36 | def f(): - -SIM111.py:55:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop - | -53 | def f(): -54 | # SIM110 -55 | for x in iterable: - | _____^ -56 | | if check(x): -57 | | return True -58 | | else: -59 | | return False - | |____________________^ SIM110 - | - = help: Replace with `return any(check(x) for x in iterable)` - -ℹ Suggested fix -52 52 | -53 53 | def f(): -54 54 | # SIM110 -55 |- for x in iterable: -56 |- if check(x): -57 |- return True -58 |- else: -59 |- return False - 55 |+ return any(check(x) for x in iterable) -60 56 | -61 57 | -62 58 | def f(): - -SIM111.py:64:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop - | -62 | def f(): -63 | # SIM111 -64 | for x in iterable: - | _____^ -65 | | if check(x): -66 | | return False -67 | | else: -68 | | return True - | |___________________^ SIM110 - | - = help: Replace with `return all(not check(x) for x in iterable)` - -ℹ Suggested fix -61 61 | -62 62 | def f(): -63 63 | # SIM111 -64 |- for x in iterable: -65 |- if check(x): -66 |- return False -67 |- else: -68 |- return True - 64 |+ return all(not check(x) for x in iterable) -69 65 | -70 66 | -71 67 | def f(): - -SIM111.py:73:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop - | -71 | def f(): -72 | # SIM110 -73 | for x in iterable: - | _____^ -74 | | if check(x): -75 | | return True -76 | | else: -77 | | return False - | |____________________^ SIM110 -78 | return True - | - = help: Replace with `return any(check(x) for x in iterable)` - -ℹ Suggested fix -70 70 | -71 71 | def f(): -72 72 | # SIM110 -73 |- for x in iterable: -74 |- if check(x): -75 |- return True -76 |- else: -77 |- return False - 73 |+ return any(check(x) for x in iterable) -78 74 | return True -79 75 | -80 76 | - -SIM111.py:83:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop - | -81 | def f(): -82 | # SIM111 -83 | for x in iterable: - | _____^ -84 | | if check(x): -85 | | return False -86 | | else: -87 | | return True - | |___________________^ SIM110 -88 | return False - | - = help: Replace with `return all(not check(x) for x in iterable)` - -ℹ Suggested fix -80 80 | -81 81 | def f(): -82 82 | # SIM111 -83 |- for x in iterable: -84 |- if check(x): -85 |- return False -86 |- else: -87 |- return True - 83 |+ return all(not check(x) for x in iterable) -88 84 | return False -89 85 | -90 86 | - -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: - | _____^ -125 | | if check(x): -126 | | return True -127 | | return False - | |________________^ SIM110 - | - = help: Replace with `return any(check(x) for x in iterable)` - -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: - | _____^ -135 | | if check(x): -136 | | return False -137 | | return True - | |_______________^ SIM110 - | - = help: Replace with `return all(not check(x) for x in iterable)` - -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: - | _____^ -145 | | if check(x): -146 | | return True -147 | | return False - | |________________^ SIM110 - | - = help: Replace with `return any(check(x) for x in iterable)` - -ℹ Suggested fix -141 141 | x = 1 -142 142 | -143 143 | # SIM110 -144 |- for x in iterable: -145 |- if check(x): -146 |- return True -147 |- return False - 144 |+ return any(check(x) for x in iterable) -148 145 | -149 146 | -150 147 | def f(): - -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: - | _____^ -155 | | if check(x): -156 | | return False -157 | | return True - | |_______________^ SIM110 - | - = help: Replace with `return all(not check(x) for x in iterable)` - -ℹ Suggested fix -151 151 | x = 1 -152 152 | -153 153 | # SIM111 -154 |- for x in iterable: -155 |- if check(x): -156 |- return False -157 |- return True - 154 |+ return all(not check(x) for x in iterable) -158 155 | -159 156 | -160 157 | def f(): - -SIM111.py:162:5: SIM110 [*] Use `return all(x in y for x in iterable)` instead of `for` loop - | -160 | def f(): -161 | # SIM111 -162 | for x in iterable: - | _____^ -163 | | if x not in y: -164 | | return False -165 | | return True - | |_______________^ SIM110 - | - = help: Replace with `return all(x in y for x in iterable)` - -ℹ Suggested fix -159 159 | -160 160 | def f(): -161 161 | # SIM111 -162 |- for x in iterable: -163 |- if x not in y: -164 |- return False -165 |- return True - 162 |+ return all(x in y for x in iterable) -166 163 | -167 164 | -168 165 | def f(): - -SIM111.py:170:5: SIM110 [*] Use `return all(x <= y for x in iterable)` instead of `for` loop - | -168 | def f(): -169 | # SIM111 -170 | for x in iterable: - | _____^ -171 | | if x > y: -172 | | return False -173 | | return True - | |_______________^ SIM110 - | - = help: Replace with `return all(x <= y for x in iterable)` - -ℹ Suggested fix -167 167 | -168 168 | def f(): -169 169 | # SIM111 -170 |- for x in iterable: -171 |- if x > y: -172 |- return False -173 |- return True - 170 |+ return all(x <= y for x in iterable) -174 171 | -175 172 | -176 173 | def f(): - -SIM111.py:178:5: SIM110 [*] Use `return all(not x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9")` instead of `for` loop - | -176 | def f(): -177 | # SIM111 -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 - | |_______________^ SIM110 - | - = help: Replace with `return all(not x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9")` - -ℹ Suggested fix -175 175 | -176 176 | def f(): -177 177 | # SIM111 -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 - 178 |+ return all(not x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9") -182 179 | -183 180 | -184 181 | def f(): - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM112_SIM112.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM112_SIM112.py.snap deleted file mode 100644 index 747db79ee1..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM112_SIM112.py.snap +++ /dev/null @@ -1,119 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM112.py:4:12: SIM112 [*] Use capitalized environment variable `FOO` instead of `foo` - | -3 | # Bad -4 | os.environ['foo'] - | ^^^^^ SIM112 -5 | -6 | os.environ.get('foo') - | - = help: Replace `foo` with `FOO` - -ℹ Suggested fix -1 1 | import os -2 2 | -3 3 | # Bad -4 |-os.environ['foo'] - 4 |+os.environ['FOO'] -5 5 | -6 6 | os.environ.get('foo') -7 7 | - -SIM112.py:6:16: SIM112 Use capitalized environment variable `FOO` instead of `foo` - | -4 | os.environ['foo'] -5 | -6 | os.environ.get('foo') - | ^^^^^ SIM112 -7 | -8 | os.environ.get('foo', 'bar') - | - = help: Replace `foo` with `FOO` - -SIM112.py:8:16: SIM112 Use capitalized environment variable `FOO` instead of `foo` - | - 6 | os.environ.get('foo') - 7 | - 8 | os.environ.get('foo', 'bar') - | ^^^^^ SIM112 - 9 | -10 | os.getenv('foo') - | - = help: Replace `foo` with `FOO` - -SIM112.py:10:11: SIM112 Use capitalized environment variable `FOO` instead of `foo` - | - 8 | os.environ.get('foo', 'bar') - 9 | -10 | os.getenv('foo') - | ^^^^^ SIM112 -11 | -12 | env = os.environ.get('foo') - | - = help: Replace `foo` with `FOO` - -SIM112.py:12:22: SIM112 Use capitalized environment variable `FOO` instead of `foo` - | -10 | os.getenv('foo') -11 | -12 | env = os.environ.get('foo') - | ^^^^^ SIM112 -13 | -14 | env = os.environ['foo'] - | - = help: Replace `foo` with `FOO` - -SIM112.py:14:18: SIM112 [*] Use capitalized environment variable `FOO` instead of `foo` - | -12 | env = os.environ.get('foo') -13 | -14 | env = os.environ['foo'] - | ^^^^^ SIM112 -15 | -16 | if env := os.environ.get('foo'): - | - = help: Replace `foo` with `FOO` - -ℹ Suggested fix -11 11 | -12 12 | env = os.environ.get('foo') -13 13 | -14 |-env = os.environ['foo'] - 14 |+env = os.environ['FOO'] -15 15 | -16 16 | if env := os.environ.get('foo'): -17 17 | pass - -SIM112.py:16:26: SIM112 Use capitalized environment variable `FOO` instead of `foo` - | -14 | env = os.environ['foo'] -15 | -16 | if env := os.environ.get('foo'): - | ^^^^^ SIM112 -17 | pass - | - = help: Replace `foo` with `FOO` - -SIM112.py:19:22: SIM112 [*] Use capitalized environment variable `FOO` instead of `foo` - | -17 | pass -18 | -19 | if env := os.environ['foo']: - | ^^^^^ SIM112 -20 | pass - | - = help: Replace `foo` with `FOO` - -ℹ Suggested fix -16 16 | if env := os.environ.get('foo'): -17 17 | pass -18 18 | -19 |-if env := os.environ['foo']: - 19 |+if env := os.environ['FOO']: -20 20 | pass -21 21 | -22 22 | - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM114_SIM114.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM114_SIM114.py.snap deleted file mode 100644 index a578730457..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM114_SIM114.py.snap +++ /dev/null @@ -1,167 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM114.py:2:1: SIM114 Combine `if` branches using logical `or` operator - | -1 | # Errors -2 | / if a: -3 | | b -4 | | elif c: -5 | | b - | |_____^ SIM114 -6 | -7 | if x == 1: - | - -SIM114.py:7:1: SIM114 Combine `if` branches using logical `or` operator - | - 5 | b - 6 | - 7 | / if x == 1: - 8 | | for _ in range(20): - 9 | | print("hello") -10 | | elif x == 2: -11 | | for _ in range(20): -12 | | print("hello") - | |______________________^ SIM114 -13 | -14 | if x == 1: - | - -SIM114.py:14:1: SIM114 Combine `if` branches using logical `or` operator - | -12 | print("hello") -13 | -14 | / if x == 1: -15 | | if True: -16 | | for _ in range(20): -17 | | print("hello") -18 | | elif x == 2: -19 | | if True: -20 | | for _ in range(20): -21 | | print("hello") - | |__________________________^ SIM114 -22 | -23 | if x == 1: - | - -SIM114.py:23:1: SIM114 Combine `if` branches using logical `or` operator - | -21 | print("hello") -22 | -23 | / if x == 1: -24 | | if True: -25 | | for _ in range(20): -26 | | print("hello") -27 | | elif False: -28 | | for _ in range(20): -29 | | print("hello") -30 | | elif x == 2: -31 | | if True: -32 | | for _ in range(20): -33 | | print("hello") -34 | | elif False: -35 | | for _ in range(20): -36 | | print("hello") - | |__________________________^ SIM114 -37 | -38 | if ( - | - -SIM114.py:24:5: SIM114 Combine `if` branches using logical `or` operator - | -23 | if x == 1: -24 | if True: - | _____^ -25 | | for _ in range(20): -26 | | print("hello") -27 | | elif False: -28 | | for _ in range(20): -29 | | print("hello") - | |__________________________^ SIM114 -30 | elif x == 2: -31 | if True: - | - -SIM114.py:31:5: SIM114 Combine `if` branches using logical `or` operator - | -29 | print("hello") -30 | elif x == 2: -31 | if True: - | _____^ -32 | | for _ in range(20): -33 | | print("hello") -34 | | elif False: -35 | | for _ in range(20): -36 | | print("hello") - | |__________________________^ SIM114 -37 | -38 | if ( - | - -SIM114.py:38:1: SIM114 Combine `if` branches using logical `or` operator - | -36 | print("hello") -37 | -38 | / if ( -39 | | x == 1 -40 | | and y == 2 -41 | | and z == 3 -42 | | and a == 4 -43 | | and b == 5 -44 | | and c == 6 -45 | | and d == 7 -46 | | and e == 8 -47 | | and f == 9 -48 | | and g == 10 -49 | | and h == 11 -50 | | and i == 12 -51 | | and j == 13 -52 | | and k == 14 -53 | | ): -54 | | pass -55 | | elif 1 == 2: -56 | | pass - | |________^ SIM114 -57 | -58 | if result.eofs == "O": - | - -SIM114.py:62:1: SIM114 Combine `if` branches using logical `or` operator - | -60 | elif result.eofs == "S": -61 | skipped = 1 -62 | / elif result.eofs == "F": -63 | | errors = 1 -64 | | elif result.eofs == "E": -65 | | errors = 1 - | |______________^ SIM114 - | - -SIM114.py:109:5: SIM114 Combine `if` branches using logical `or` operator - | -107 | a = True -108 | b = False -109 | if a > b: # end-of-line - | _____^ -110 | | return 3 -111 | | elif a == b: -112 | | return 3 - | |________________^ SIM114 -113 | elif a < b: # end-of-line -114 | return 4 - | - -SIM114.py:113:5: SIM114 Combine `if` branches using logical `or` operator - | -111 | elif a == b: -112 | return 3 -113 | elif a < b: # end-of-line - | _____^ -114 | | return 4 -115 | | elif b is None: -116 | | return 4 - | |________________^ SIM114 - | - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM115_SIM115.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM115_SIM115.py.snap deleted file mode 100644 index f27ff64857..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM115_SIM115.py.snap +++ /dev/null @@ -1,63 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM115.py:8:5: SIM115 Use context handler for opening files - | - 7 | # SIM115 - 8 | f = open("foo.txt") - | ^^^^ SIM115 - 9 | f = Path("foo.txt").open() -10 | f = pathlib.Path("foo.txt").open() - | - -SIM115.py:9:5: SIM115 Use context handler for opening files - | - 7 | # SIM115 - 8 | f = open("foo.txt") - 9 | f = Path("foo.txt").open() - | ^^^^^^^^^^^^^^^^^^^^ SIM115 -10 | f = pathlib.Path("foo.txt").open() -11 | f = pl.Path("foo.txt").open() - | - -SIM115.py:10:5: SIM115 Use context handler for opening files - | - 8 | f = open("foo.txt") - 9 | f = Path("foo.txt").open() -10 | f = pathlib.Path("foo.txt").open() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM115 -11 | f = pl.Path("foo.txt").open() -12 | f = P("foo.txt").open() - | - -SIM115.py:11:5: SIM115 Use context handler for opening files - | - 9 | f = Path("foo.txt").open() -10 | f = pathlib.Path("foo.txt").open() -11 | f = pl.Path("foo.txt").open() - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM115 -12 | f = P("foo.txt").open() -13 | data = f.read() - | - -SIM115.py:12:5: SIM115 Use context handler for opening files - | -10 | f = pathlib.Path("foo.txt").open() -11 | f = pl.Path("foo.txt").open() -12 | f = P("foo.txt").open() - | ^^^^^^^^^^^^^^^^^ SIM115 -13 | data = f.read() -14 | f.close() - | - -SIM115.py:39:9: SIM115 Use context handler for opening files - | -37 | # SIM115 -38 | with contextlib.ExitStack(): -39 | f = open("filename") - | ^^^^ SIM115 -40 | -41 | # OK - | - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM116_SIM116.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM116_SIM116.py.snap deleted file mode 100644 index d2ef5ee577..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM116_SIM116.py.snap +++ /dev/null @@ -1,112 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM116.py:5:1: SIM116 Use a dictionary instead of consecutive `if` statements - | - 4 | # SIM116 - 5 | / if a == "foo": - 6 | | return "bar" - 7 | | elif a == "bar": - 8 | | return "baz" - 9 | | elif a == "boo": -10 | | return "ooh" -11 | | else: -12 | | return 42 - | |_____________^ SIM116 -13 | -14 | # SIM116 - | - -SIM116.py:15:1: SIM116 Use a dictionary instead of consecutive `if` statements - | -14 | # SIM116 -15 | / if a == 1: -16 | | return (1, 2, 3) -17 | | elif a == 2: -18 | | return (4, 5, 6) -19 | | elif a == 3: -20 | | return (7, 8, 9) -21 | | else: -22 | | return (10, 11, 12) - | |_______________________^ SIM116 -23 | -24 | # SIM116 - | - -SIM116.py:25:1: SIM116 Use a dictionary instead of consecutive `if` statements - | -24 | # SIM116 -25 | / if a == 1: -26 | | return (1, 2, 3) -27 | | elif a == 2: -28 | | return (4, 5, 6) -29 | | elif a == 3: -30 | | return (7, 8, 9) - | |____________________^ SIM116 -31 | -32 | # SIM116 - | - -SIM116.py:33:1: SIM116 Use a dictionary instead of consecutive `if` statements - | -32 | # SIM116 -33 | / if a == "hello 'sir'": -34 | | return (1, 2, 3) -35 | | elif a == 'goodbye "mam"': -36 | | return (4, 5, 6) -37 | | elif a == """Fairwell 'mister'""": -38 | | return (7, 8, 9) -39 | | else: -40 | | return (10, 11, 12) - | |_______________________^ SIM116 -41 | -42 | # SIM116 - | - -SIM116.py:43:1: SIM116 Use a dictionary instead of consecutive `if` statements - | -42 | # SIM116 -43 | / if a == b"one": -44 | | return 1 -45 | | elif a == b"two": -46 | | return 2 -47 | | elif a == b"three": -48 | | return 3 - | |____________^ SIM116 -49 | -50 | # SIM116 - | - -SIM116.py:51:1: SIM116 Use a dictionary instead of consecutive `if` statements - | -50 | # SIM116 -51 | / if a == "hello 'sir'": -52 | | return ("hello'", 'hi"', 3) -53 | | elif a == 'goodbye "mam"': -54 | | return (4, 5, 6) -55 | | elif a == """Fairwell 'mister'""": -56 | | return (7, 8, 9) -57 | | else: -58 | | return (10, 11, 12) - | |_______________________^ SIM116 -59 | -60 | # OK - | - -SIM116.py:79:1: SIM116 Use a dictionary instead of consecutive `if` statements - | -78 | # SIM116 -79 | / if func_name == "create": -80 | | return "A" -81 | | elif func_name == "modify": -82 | | return "M" -83 | | elif func_name == "remove": -84 | | return "D" -85 | | elif func_name == "move": -86 | | return "MV" - | |_______________^ SIM116 -87 | -88 | # OK - | - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM117_SIM117.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM117_SIM117.py.snap deleted file mode 100644 index ceb934c7e9..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM117_SIM117.py.snap +++ /dev/null @@ -1,287 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM117.py:2:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements - | -1 | # SIM117 -2 | / with A() as a: -3 | | with B() as b: - | |__________________^ SIM117 -4 | print("hello") - | - = help: Combine `with` statements - -ℹ Suggested fix -1 1 | # SIM117 -2 |-with A() as a: -3 |- with B() as b: -4 |- print("hello") - 2 |+with A() as a, B() as b: - 3 |+ print("hello") -5 4 | -6 5 | # SIM117 -7 6 | with A(): - -SIM117.py:7:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements - | - 6 | # SIM117 - 7 | / with A(): - 8 | | with B(): - | |_____________^ SIM117 - 9 | with C(): -10 | print("hello") - | - = help: Combine `with` statements - -ℹ Suggested fix -4 4 | print("hello") -5 5 | -6 6 | # SIM117 -7 |-with A(): -8 |- with B(): -9 |- with C(): -10 |- print("hello") - 7 |+with A(), B(): - 8 |+ with C(): - 9 |+ print("hello") -11 10 | -12 11 | # SIM117 -13 12 | with A() as a: - -SIM117.py:13:1: SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements - | -12 | # SIM117 -13 | / with A() as a: -14 | | # Unfixable due to placement of this comment. -15 | | with B() as b: - | |__________________^ SIM117 -16 | print("hello") - | - = help: Combine `with` statements - -SIM117.py:19:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements - | -18 | # SIM117 -19 | / with A() as a: -20 | | with B() as b: - | |__________________^ SIM117 -21 | # Fixable due to placement of this comment. -22 | print("hello") - | - = help: Combine `with` statements - -ℹ Suggested fix -16 16 | print("hello") -17 17 | -18 18 | # SIM117 -19 |-with A() as a: -20 |- with B() as b: -21 |- # Fixable due to placement of this comment. -22 |- print("hello") - 19 |+with A() as a, B() as b: - 20 |+ # Fixable due to placement of this comment. - 21 |+ print("hello") -23 22 | -24 23 | # OK -25 24 | with A() as a: - -SIM117.py:47:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements - | -46 | # SIM117 -47 | / async with A() as a: -48 | | async with B() as b: - | |________________________^ SIM117 -49 | print("hello") - | - = help: Combine `with` statements - -ℹ Suggested fix -44 44 | print("hello") -45 45 | -46 46 | # SIM117 -47 |-async with A() as a: -48 |- async with B() as b: -49 |- print("hello") - 47 |+async with A() as a, B() as b: - 48 |+ print("hello") -50 49 | -51 50 | while True: -52 51 | # SIM117 - -SIM117.py:53:5: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements - | -51 | while True: -52 | # SIM117 -53 | with A() as a: - | _____^ -54 | | with B() as b: - | |______________________^ SIM117 -55 | """this -56 | is valid""" - | - = help: Combine `with` statements - -ℹ Suggested fix -50 50 | -51 51 | while True: -52 52 | # SIM117 -53 |- with A() as a: -54 |- with B() as b: -55 |- """this - 53 |+ with A() as a, B() as b: - 54 |+ """this -56 55 | is valid""" -57 56 | -58 |- """the indentation on - 57 |+ """the indentation on -59 58 | this line is significant""" -60 59 | -61 |- "this is" \ - 60 |+ "this is" \ -62 61 | "allowed too" -63 62 | -64 |- ("so is" - 63 |+ ("so is" -65 64 | "this for some reason") -66 65 | -67 66 | # SIM117 - -SIM117.py:68:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements - | -67 | # SIM117 -68 | / with ( -69 | | A() as a, -70 | | B() as b, -71 | | ): -72 | | with C() as c: - | |__________________^ SIM117 -73 | print("hello") - | - = help: Combine `with` statements - -ℹ Suggested fix -67 67 | # SIM117 -68 68 | with ( -69 69 | A() as a, -70 |- B() as b, - 70 |+ B() as b,C() as c -71 71 | ): -72 |- with C() as c: -73 |- print("hello") - 72 |+ print("hello") -74 73 | -75 74 | # SIM117 -76 75 | with A() as a: - -SIM117.py:76:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements - | -75 | # SIM117 -76 | / with A() as a: -77 | | with ( -78 | | B() as b, -79 | | C() as c, -80 | | ): - | |______^ SIM117 -81 | print("hello") - | - = help: Combine `with` statements - -ℹ Suggested fix -73 73 | print("hello") -74 74 | -75 75 | # SIM117 -76 |-with A() as a: -77 |- with ( -78 |- B() as b, -79 |- C() as c, -80 |- ): -81 |- print("hello") - 76 |+with ( - 77 |+ A() as a, B() as b, - 78 |+ C() as c, - 79 |+): - 80 |+ print("hello") -82 81 | -83 82 | # SIM117 -84 83 | with ( - -SIM117.py:84:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements - | -83 | # SIM117 -84 | / with ( -85 | | A() as a, -86 | | B() as b, -87 | | ): -88 | | with ( -89 | | C() as c, -90 | | D() as d, -91 | | ): - | |______^ SIM117 -92 | print("hello") - | - = help: Combine `with` statements - -ℹ Suggested fix -83 83 | # SIM117 -84 84 | with ( -85 85 | A() as a, -86 |- B() as b, - 86 |+ B() as b,C() as c, - 87 |+ D() as d, -87 88 | ): -88 |- with ( -89 |- C() as c, -90 |- D() as d, -91 |- ): -92 |- print("hello") - 89 |+ print("hello") -93 90 | -94 91 | # SIM117 (auto-fixable) -95 92 | with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as a: - -SIM117.py:95:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements - | -94 | # SIM117 (auto-fixable) -95 | / with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as a: -96 | | with B("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as b: - | |__________________________________________________^ SIM117 -97 | print("hello") - | - = help: Combine `with` statements - -ℹ Suggested fix -92 92 | print("hello") -93 93 | -94 94 | # SIM117 (auto-fixable) -95 |-with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as a: -96 |- with B("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as b: -97 |- print("hello") - 95 |+with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as a, B("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as b: - 96 |+ print("hello") -98 97 | -99 98 | # SIM117 (not auto-fixable too long) -100 99 | with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ890") as a: - -SIM117.py:100:1: SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements - | - 99 | # SIM117 (not auto-fixable too long) -100 | / with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ890") as a: -101 | | with B("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as b: - | |__________________________________________________^ SIM117 -102 | print("hello") - | - = help: Combine `with` statements - -SIM117.py:106:5: SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements - | -104 | # From issue #3025. -105 | async def main(): -106 | async with A() as a: # SIM117. - | _____^ -107 | | async with B() as b: - | |____________________________^ SIM117 -108 | print("async-inside!") - | - = help: Combine `with` statements - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM118_SIM118.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM118_SIM118.py.snap deleted file mode 100644 index 59b0d3558c..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM118_SIM118.py.snap +++ /dev/null @@ -1,396 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM118.py:1:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` - | -1 | key in obj.keys() # SIM118 - | ^^^^^^^^^^^^^^^^^ SIM118 -2 | -3 | key not in obj.keys() # SIM118 - | - = help: Remove `.keys()` - -ℹ Suggested fix -1 |-key in obj.keys() # SIM118 - 1 |+key in obj # SIM118 -2 2 | -3 3 | key not in obj.keys() # SIM118 -4 4 | - -SIM118.py:3:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` - | -1 | key in obj.keys() # SIM118 -2 | -3 | key not in obj.keys() # SIM118 - | ^^^^^^^^^^^^^^^^^^^^^ SIM118 -4 | -5 | foo["bar"] in obj.keys() # SIM118 - | - = help: Remove `.keys()` - -ℹ Suggested fix -1 1 | key in obj.keys() # SIM118 -2 2 | -3 |-key not in obj.keys() # SIM118 - 3 |+key not in obj # SIM118 -4 4 | -5 5 | foo["bar"] in obj.keys() # SIM118 -6 6 | - -SIM118.py:5:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` - | -3 | key not in obj.keys() # SIM118 -4 | -5 | foo["bar"] in obj.keys() # SIM118 - | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 -6 | -7 | foo["bar"] not in obj.keys() # SIM118 - | - = help: Remove `.keys()` - -ℹ Suggested fix -2 2 | -3 3 | key not in obj.keys() # SIM118 -4 4 | -5 |-foo["bar"] in obj.keys() # SIM118 - 5 |+foo["bar"] in obj # SIM118 -6 6 | -7 7 | foo["bar"] not in obj.keys() # SIM118 -8 8 | - -SIM118.py:7:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` - | -5 | foo["bar"] in obj.keys() # SIM118 -6 | -7 | foo["bar"] not in obj.keys() # SIM118 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 -8 | -9 | foo['bar'] in obj.keys() # SIM118 - | - = help: Remove `.keys()` - -ℹ Suggested fix -4 4 | -5 5 | foo["bar"] in obj.keys() # SIM118 -6 6 | -7 |-foo["bar"] not in obj.keys() # SIM118 - 7 |+foo["bar"] not in obj # SIM118 -8 8 | -9 9 | foo['bar'] in obj.keys() # SIM118 -10 10 | - -SIM118.py:9:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` - | - 7 | foo["bar"] not in obj.keys() # SIM118 - 8 | - 9 | foo['bar'] in obj.keys() # SIM118 - | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 -10 | -11 | foo['bar'] not in obj.keys() # SIM118 - | - = help: Remove `.keys()` - -ℹ Suggested fix -6 6 | -7 7 | foo["bar"] not in obj.keys() # SIM118 -8 8 | -9 |-foo['bar'] in obj.keys() # SIM118 - 9 |+foo['bar'] in obj # SIM118 -10 10 | -11 11 | foo['bar'] not in obj.keys() # SIM118 -12 12 | - -SIM118.py:11:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` - | - 9 | foo['bar'] in obj.keys() # SIM118 -10 | -11 | foo['bar'] not in obj.keys() # SIM118 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 -12 | -13 | foo() in obj.keys() # SIM118 - | - = help: Remove `.keys()` - -ℹ Suggested fix -8 8 | -9 9 | foo['bar'] in obj.keys() # SIM118 -10 10 | -11 |-foo['bar'] not in obj.keys() # SIM118 - 11 |+foo['bar'] not in obj # SIM118 -12 12 | -13 13 | foo() in obj.keys() # SIM118 -14 14 | - -SIM118.py:13:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` - | -11 | foo['bar'] not in obj.keys() # SIM118 -12 | -13 | foo() in obj.keys() # SIM118 - | ^^^^^^^^^^^^^^^^^^^ SIM118 -14 | -15 | foo() not in obj.keys() # SIM118 - | - = help: Remove `.keys()` - -ℹ Suggested fix -10 10 | -11 11 | foo['bar'] not in obj.keys() # SIM118 -12 12 | -13 |-foo() in obj.keys() # SIM118 - 13 |+foo() in obj # SIM118 -14 14 | -15 15 | foo() not in obj.keys() # SIM118 -16 16 | - -SIM118.py:15:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` - | -13 | foo() in obj.keys() # SIM118 -14 | -15 | foo() not in obj.keys() # SIM118 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM118 -16 | -17 | for key in obj.keys(): # SIM118 - | - = help: Remove `.keys()` - -ℹ Suggested fix -12 12 | -13 13 | foo() in obj.keys() # SIM118 -14 14 | -15 |-foo() not in obj.keys() # SIM118 - 15 |+foo() not in obj # SIM118 -16 16 | -17 17 | for key in obj.keys(): # SIM118 -18 18 | pass - -SIM118.py:17:5: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` - | -15 | foo() not in obj.keys() # SIM118 -16 | -17 | for key in obj.keys(): # SIM118 - | ^^^^^^^^^^^^^^^^^ SIM118 -18 | pass - | - = help: Remove `.keys()` - -ℹ Suggested fix -14 14 | -15 15 | foo() not in obj.keys() # SIM118 -16 16 | -17 |-for key in obj.keys(): # SIM118 - 17 |+for key in obj: # SIM118 -18 18 | pass -19 19 | -20 20 | for key in list(obj.keys()): - -SIM118.py:24:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` - | -22 | del obj[key] -23 | -24 | [k for k in obj.keys()] # SIM118 - | ^^^^^^^^^^^^^^^ SIM118 -25 | -26 | {k for k in obj.keys()} # SIM118 - | - = help: Remove `.keys()` - -ℹ Suggested fix -21 21 | if some_property(key): -22 22 | del obj[key] -23 23 | -24 |-[k for k in obj.keys()] # SIM118 - 24 |+[k for k in obj] # SIM118 -25 25 | -26 26 | {k for k in obj.keys()} # SIM118 -27 27 | - -SIM118.py:26:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` - | -24 | [k for k in obj.keys()] # SIM118 -25 | -26 | {k for k in obj.keys()} # SIM118 - | ^^^^^^^^^^^^^^^ SIM118 -27 | -28 | {k: k for k in obj.keys()} # SIM118 - | - = help: Remove `.keys()` - -ℹ Suggested fix -23 23 | -24 24 | [k for k in obj.keys()] # SIM118 -25 25 | -26 |-{k for k in obj.keys()} # SIM118 - 26 |+{k for k in obj} # SIM118 -27 27 | -28 28 | {k: k for k in obj.keys()} # SIM118 -29 29 | - -SIM118.py:28:11: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` - | -26 | {k for k in obj.keys()} # SIM118 -27 | -28 | {k: k for k in obj.keys()} # SIM118 - | ^^^^^^^^^^^^^^^ SIM118 -29 | -30 | (k for k in obj.keys()) # SIM118 - | - = help: Remove `.keys()` - -ℹ Suggested fix -25 25 | -26 26 | {k for k in obj.keys()} # SIM118 -27 27 | -28 |-{k: k for k in obj.keys()} # SIM118 - 28 |+{k: k for k in obj} # SIM118 -29 29 | -30 30 | (k for k in obj.keys()) # SIM118 -31 31 | - -SIM118.py:30:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` - | -28 | {k: k for k in obj.keys()} # SIM118 -29 | -30 | (k for k in obj.keys()) # SIM118 - | ^^^^^^^^^^^^^^^ SIM118 -31 | -32 | key in (obj or {}).keys() # SIM118 - | - = help: Remove `.keys()` - -ℹ Suggested fix -27 27 | -28 28 | {k: k for k in obj.keys()} # SIM118 -29 29 | -30 |-(k for k in obj.keys()) # SIM118 - 30 |+(k for k in obj) # SIM118 -31 31 | -32 32 | key in (obj or {}).keys() # SIM118 -33 33 | - -SIM118.py:32:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` - | -30 | (k for k in obj.keys()) # SIM118 -31 | -32 | key in (obj or {}).keys() # SIM118 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 -33 | -34 | (key) in (obj or {}).keys() # SIM118 - | - = help: Remove `.keys()` - -ℹ Suggested fix -29 29 | -30 30 | (k for k in obj.keys()) # SIM118 -31 31 | -32 |-key in (obj or {}).keys() # SIM118 - 32 |+key in (obj or {}) # SIM118 -33 33 | -34 34 | (key) in (obj or {}).keys() # SIM118 -35 35 | - -SIM118.py:34:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` - | -32 | key in (obj or {}).keys() # SIM118 -33 | -34 | (key) in (obj or {}).keys() # SIM118 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 -35 | -36 | from typing import KeysView - | - = help: Remove `.keys()` - -ℹ Suggested fix -31 31 | -32 32 | key in (obj or {}).keys() # SIM118 -33 33 | -34 |-(key) in (obj or {}).keys() # SIM118 - 34 |+(key) in (obj or {}) # SIM118 -35 35 | -36 36 | from typing import KeysView -37 37 | - -SIM118.py:48:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` - | -47 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 -48 | key in obj.keys()and foo - | ^^^^^^^^^^^^^^^^^ SIM118 -49 | (key in obj.keys())and foo -50 | key in (obj.keys())and foo - | - = help: Remove `.keys()` - -ℹ Suggested fix -45 45 | -46 46 | -47 47 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 -48 |-key in obj.keys()and foo - 48 |+key in obj and foo -49 49 | (key in obj.keys())and foo -50 50 | key in (obj.keys())and foo -51 51 | - -SIM118.py:49:2: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` - | -47 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 -48 | key in obj.keys()and foo -49 | (key in obj.keys())and foo - | ^^^^^^^^^^^^^^^^^ SIM118 -50 | key in (obj.keys())and foo - | - = help: Remove `.keys()` - -ℹ Suggested fix -46 46 | -47 47 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 -48 48 | key in obj.keys()and foo -49 |-(key in obj.keys())and foo - 49 |+(key in obj)and foo -50 50 | key in (obj.keys())and foo -51 51 | -52 52 | # Regression test for: https://github.com/astral-sh/ruff/issues/7200 - -SIM118.py:50:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` - | -48 | key in obj.keys()and foo -49 | (key in obj.keys())and foo -50 | key in (obj.keys())and foo - | ^^^^^^^^^^^^^^^^^^^ SIM118 -51 | -52 | # Regression test for: https://github.com/astral-sh/ruff/issues/7200 - | - = help: Remove `.keys()` - -ℹ Suggested fix -47 47 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 -48 48 | key in obj.keys()and foo -49 49 | (key in obj.keys())and foo -50 |-key in (obj.keys())and foo - 50 |+key in (obj)and foo -51 51 | -52 52 | # Regression test for: https://github.com/astral-sh/ruff/issues/7200 -53 53 | for key in ( - -SIM118.py:53:5: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` - | -52 | # Regression test for: https://github.com/astral-sh/ruff/issues/7200 -53 | for key in ( - | _____^ -54 | | self.experiment.surveys[0] -55 | | .stations[0] -56 | | .keys() -57 | | ): - | |_^ SIM118 -58 | continue - | - = help: Remove `.keys()` - -ℹ Suggested fix -53 53 | for key in ( -54 54 | self.experiment.surveys[0] -55 55 | .stations[0] -56 |- .keys() - 56 |+ -57 57 | ): -58 58 | continue - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM201_SIM201.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM201_SIM201.py.snap deleted file mode 100644 index cff98673a5..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM201_SIM201.py.snap +++ /dev/null @@ -1,59 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM201.py:2:4: SIM201 [*] Use `a != b` instead of `not a == b` - | -1 | # SIM201 -2 | if not a == b: - | ^^^^^^^^^^ SIM201 -3 | pass - | - = help: Replace with `!=` operator - -ℹ Fix -1 1 | # SIM201 -2 |-if not a == b: - 2 |+if a != b: -3 3 | pass -4 4 | -5 5 | # SIM201 - -SIM201.py:6:4: SIM201 [*] Use `a != b + c` instead of `not a == b + c` - | -5 | # SIM201 -6 | if not a == (b + c): - | ^^^^^^^^^^^^^^^^ SIM201 -7 | pass - | - = help: Replace with `!=` operator - -ℹ Fix -3 3 | pass -4 4 | -5 5 | # SIM201 -6 |-if not a == (b + c): - 6 |+if a != b + c: -7 7 | pass -8 8 | -9 9 | # SIM201 - -SIM201.py:10:4: SIM201 [*] Use `a + b != c` instead of `not a + b == c` - | - 9 | # SIM201 -10 | if not (a + b) == c: - | ^^^^^^^^^^^^^^^^ SIM201 -11 | pass - | - = help: Replace with `!=` operator - -ℹ Fix -7 7 | pass -8 8 | -9 9 | # SIM201 -10 |-if not (a + b) == c: - 10 |+if a + b != c: -11 11 | pass -12 12 | -13 13 | # OK - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM202_SIM202.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM202_SIM202.py.snap deleted file mode 100644 index db24c7b052..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM202_SIM202.py.snap +++ /dev/null @@ -1,59 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM202.py:2:4: SIM202 [*] Use `a == b` instead of `not a != b` - | -1 | # SIM202 -2 | if not a != b: - | ^^^^^^^^^^ SIM202 -3 | pass - | - = help: Replace with `==` operator - -ℹ Suggested fix -1 1 | # SIM202 -2 |-if not a != b: - 2 |+if a == b: -3 3 | pass -4 4 | -5 5 | # SIM202 - -SIM202.py:6:4: SIM202 [*] Use `a == b + c` instead of `not a != b + c` - | -5 | # SIM202 -6 | if not a != (b + c): - | ^^^^^^^^^^^^^^^^ SIM202 -7 | pass - | - = help: Replace with `==` operator - -ℹ Suggested fix -3 3 | pass -4 4 | -5 5 | # SIM202 -6 |-if not a != (b + c): - 6 |+if a == b + c: -7 7 | pass -8 8 | -9 9 | # SIM202 - -SIM202.py:10:4: SIM202 [*] Use `a + b == c` instead of `not a + b != c` - | - 9 | # SIM202 -10 | if not (a + b) != c: - | ^^^^^^^^^^^^^^^^ SIM202 -11 | pass - | - = help: Replace with `==` operator - -ℹ Suggested fix -7 7 | pass -8 8 | -9 9 | # SIM202 -10 |-if not (a + b) != c: - 10 |+if a + b == c: -11 11 | pass -12 12 | -13 13 | # OK - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM208_SIM208.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM208_SIM208.py.snap deleted file mode 100644 index e23694aa4c..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM208_SIM208.py.snap +++ /dev/null @@ -1,99 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM208.py:1:4: SIM208 [*] Use `a` instead of `not (not a)` - | -1 | if not (not a): # SIM208 - | ^^^^^^^^^^^ SIM208 -2 | pass - | - = help: Replace with `a` - -ℹ Suggested fix -1 |-if not (not a): # SIM208 - 1 |+if a: # SIM208 -2 2 | pass -3 3 | -4 4 | if not (not (a == b)): # SIM208 - -SIM208.py:4:4: SIM208 [*] Use `a == b` instead of `not (not a == b)` - | -2 | pass -3 | -4 | if not (not (a == b)): # SIM208 - | ^^^^^^^^^^^^^^^^^^ SIM208 -5 | pass - | - = help: Replace with `a == b` - -ℹ Suggested fix -1 1 | if not (not a): # SIM208 -2 2 | pass -3 3 | -4 |-if not (not (a == b)): # SIM208 - 4 |+if a == b: # SIM208 -5 5 | pass -6 6 | -7 7 | if not a: # OK - -SIM208.py:16:5: SIM208 [*] Use `b` instead of `not (not b)` - | -14 | pass -15 | -16 | a = not not b # SIM208 - | ^^^^^^^^^ SIM208 -17 | -18 | f(not not a) # SIM208 - | - = help: Replace with `b` - -ℹ Suggested fix -13 13 | if not a != b: # OK -14 14 | pass -15 15 | -16 |-a = not not b # SIM208 - 16 |+a = bool(b) # SIM208 -17 17 | -18 18 | f(not not a) # SIM208 -19 19 | - -SIM208.py:18:3: SIM208 [*] Use `a` instead of `not (not a)` - | -16 | a = not not b # SIM208 -17 | -18 | f(not not a) # SIM208 - | ^^^^^^^^^ SIM208 -19 | -20 | if 1 + (not (not a)): # SIM208 - | - = help: Replace with `a` - -ℹ Suggested fix -15 15 | -16 16 | a = not not b # SIM208 -17 17 | -18 |-f(not not a) # SIM208 - 18 |+f(bool(a)) # SIM208 -19 19 | -20 20 | if 1 + (not (not a)): # SIM208 -21 21 | pass - -SIM208.py:20:9: SIM208 [*] Use `a` instead of `not (not a)` - | -18 | f(not not a) # SIM208 -19 | -20 | if 1 + (not (not a)): # SIM208 - | ^^^^^^^^^^^ SIM208 -21 | pass - | - = help: Replace with `a` - -ℹ Suggested fix -17 17 | -18 18 | f(not not a) # SIM208 -19 19 | -20 |-if 1 + (not (not a)): # SIM208 - 20 |+if 1 + (bool(a)): # SIM208 -21 21 | pass - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM210_SIM210.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM210_SIM210.py.snap deleted file mode 100644 index 66f2e91bcf..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM210_SIM210.py.snap +++ /dev/null @@ -1,89 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM210.py:1:5: SIM210 [*] Use `bool(...)` instead of `True if ... else False` - | -1 | a = True if b else False # SIM210 - | ^^^^^^^^^^^^^^^^^^^^ SIM210 -2 | -3 | a = True if b != c else False # SIM210 - | - = help: Replace with `bool(...) - -ℹ Suggested fix -1 |-a = True if b else False # SIM210 - 1 |+a = bool(b) # SIM210 -2 2 | -3 3 | a = True if b != c else False # SIM210 -4 4 | - -SIM210.py:3:5: SIM210 [*] Remove unnecessary `True if ... else False` - | -1 | a = True if b else False # SIM210 -2 | -3 | a = True if b != c else False # SIM210 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM210 -4 | -5 | a = True if b + c else False # SIM210 - | - = help: Remove unnecessary `True if ... else False` - -ℹ Suggested fix -1 1 | a = True if b else False # SIM210 -2 2 | -3 |-a = True if b != c else False # SIM210 - 3 |+a = b != c # SIM210 -4 4 | -5 5 | a = True if b + c else False # SIM210 -6 6 | - -SIM210.py:5:5: SIM210 [*] Use `bool(...)` instead of `True if ... else False` - | -3 | a = True if b != c else False # SIM210 -4 | -5 | a = True if b + c else False # SIM210 - | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM210 -6 | -7 | a = False if b else True # OK - | - = help: Replace with `bool(...) - -ℹ Suggested fix -2 2 | -3 3 | a = True if b != c else False # SIM210 -4 4 | -5 |-a = True if b + c else False # SIM210 - 5 |+a = bool(b + c) # SIM210 -6 6 | -7 7 | a = False if b else True # OK -8 8 | - -SIM210.py:15:9: SIM210 Use `bool(...)` instead of `True if ... else False` - | -13 | return False -14 | -15 | a = True if b else False - | ^^^^^^^^^^^^^^^^^^^^ SIM210 - | - = help: Replace with `bool(...) - -SIM210.py:19:11: SIM210 [*] Remove unnecessary `True if ... else False` - | -18 | # Regression test for: https://github.com/astral-sh/ruff/issues/7076 -19 | samesld = True if (psl.privatesuffix(urlparse(response.url).netloc) == - | ___________^ -20 | | psl.privatesuffix(src.netloc)) else False - | |____________________________________________________________________________^ SIM210 - | - = help: Remove unnecessary `True if ... else False` - -ℹ Suggested fix -16 16 | -17 17 | -18 18 | # Regression test for: https://github.com/astral-sh/ruff/issues/7076 -19 |-samesld = True if (psl.privatesuffix(urlparse(response.url).netloc) == -20 |- psl.privatesuffix(src.netloc)) else False - 19 |+samesld = (psl.privatesuffix(urlparse(response.url).netloc) == - 20 |+ psl.privatesuffix(src.netloc)) - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM211_SIM211.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM211_SIM211.py.snap deleted file mode 100644 index b6d6d2570f..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM211_SIM211.py.snap +++ /dev/null @@ -1,60 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM211.py:1:5: SIM211 [*] Use `not ...` instead of `False if ... else True` - | -1 | a = False if b else True # SIM211 - | ^^^^^^^^^^^^^^^^^^^^ SIM211 -2 | -3 | a = False if b != c else True # SIM211 - | - = help: Replace with `not ...` - -ℹ Suggested fix -1 |-a = False if b else True # SIM211 - 1 |+a = not b # SIM211 -2 2 | -3 3 | a = False if b != c else True # SIM211 -4 4 | - -SIM211.py:3:5: SIM211 [*] Use `not ...` instead of `False if ... else True` - | -1 | a = False if b else True # SIM211 -2 | -3 | a = False if b != c else True # SIM211 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM211 -4 | -5 | a = False if b + c else True # SIM211 - | - = help: Replace with `not ...` - -ℹ Suggested fix -1 1 | a = False if b else True # SIM211 -2 2 | -3 |-a = False if b != c else True # SIM211 - 3 |+a = not b != c # SIM211 -4 4 | -5 5 | a = False if b + c else True # SIM211 -6 6 | - -SIM211.py:5:5: SIM211 [*] Use `not ...` instead of `False if ... else True` - | -3 | a = False if b != c else True # SIM211 -4 | -5 | a = False if b + c else True # SIM211 - | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM211 -6 | -7 | a = True if b else False # OK - | - = help: Replace with `not ...` - -ℹ Suggested fix -2 2 | -3 3 | a = False if b != c else True # SIM211 -4 4 | -5 |-a = False if b + c else True # SIM211 - 5 |+a = not b + c # SIM211 -6 6 | -7 7 | a = True if b else False # OK - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM212_SIM212.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM212_SIM212.py.snap deleted file mode 100644 index 750464d62b..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM212_SIM212.py.snap +++ /dev/null @@ -1,40 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -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 | -3 | c = b + c if not a else a # SIM212 - | - = help: Replace with `a if a else b` - -ℹ Suggested fix -1 |-c = b if not a else a # SIM212 - 1 |+c = a if a else b # SIM212 -2 2 | -3 3 | c = b + c if not a else a # SIM212 -4 4 | - -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 | -3 | c = b + c if not a else a # SIM212 - | ^^^^^^^^^^^^^^^^^^^^^ SIM212 -4 | -5 | c = b if not x else a # OK - | - = help: Replace with `a if a else b + c` - -ℹ Suggested fix -1 1 | c = b if not a else a # SIM212 -2 2 | -3 |-c = b + c if not a else a # SIM212 - 3 |+c = a if a else b + c # SIM212 -4 4 | -5 5 | c = b if not x else a # OK -6 6 | - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM220_SIM220.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM220_SIM220.py.snap deleted file mode 100644 index 6e8645c0ed..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM220_SIM220.py.snap +++ /dev/null @@ -1,59 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM220.py:1:4: SIM220 [*] Use `False` instead of `a and not a` - | -1 | if a and not a: - | ^^^^^^^^^^^ SIM220 -2 | pass - | - = help: Replace with `False` - -ℹ Suggested fix -1 |-if a and not a: - 1 |+if False: -2 2 | pass -3 3 | -4 4 | if (a and not a) and b: - -SIM220.py:4:5: SIM220 [*] Use `False` instead of `a and not a` - | -2 | pass -3 | -4 | if (a and not a) and b: - | ^^^^^^^^^^^ SIM220 -5 | pass - | - = help: Replace with `False` - -ℹ Suggested fix -1 1 | if a and not a: -2 2 | pass -3 3 | -4 |-if (a and not a) and b: - 4 |+if (False) and b: -5 5 | pass -6 6 | -7 7 | if (a and not a) or b: - -SIM220.py:7:5: SIM220 [*] Use `False` instead of `a and not a` - | -5 | pass -6 | -7 | if (a and not a) or b: - | ^^^^^^^^^^^ SIM220 -8 | pass - | - = help: Replace with `False` - -ℹ Suggested fix -4 4 | if (a and not a) and b: -5 5 | pass -6 6 | -7 |-if (a and not a) or b: - 7 |+if (False) or b: -8 8 | pass -9 9 | -10 10 | if a: - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM221_SIM221.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM221_SIM221.py.snap deleted file mode 100644 index 006ff6ef39..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM221_SIM221.py.snap +++ /dev/null @@ -1,59 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM221.py:1:4: SIM221 [*] Use `True` instead of `a or not a` - | -1 | if a or not a: - | ^^^^^^^^^^ SIM221 -2 | pass - | - = help: Replace with `True` - -ℹ Suggested fix -1 |-if a or not a: - 1 |+if True: -2 2 | pass -3 3 | -4 4 | if (a or not a) or b: - -SIM221.py:4:5: SIM221 [*] Use `True` instead of `a or not a` - | -2 | pass -3 | -4 | if (a or not a) or b: - | ^^^^^^^^^^ SIM221 -5 | pass - | - = help: Replace with `True` - -ℹ Suggested fix -1 1 | if a or not a: -2 2 | pass -3 3 | -4 |-if (a or not a) or b: - 4 |+if (True) or b: -5 5 | pass -6 6 | -7 7 | if (a or not a) and b: - -SIM221.py:7:5: SIM221 [*] Use `True` instead of `a or not a` - | -5 | pass -6 | -7 | if (a or not a) and b: - | ^^^^^^^^^^ SIM221 -8 | pass - | - = help: Replace with `True` - -ℹ Suggested fix -4 4 | if (a or not a) or b: -5 5 | pass -6 6 | -7 |-if (a or not a) and b: - 7 |+if (True) and b: -8 8 | pass -9 9 | -10 10 | if a: - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM222_SIM222.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM222_SIM222.py.snap deleted file mode 100644 index a4bf8aa027..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM222_SIM222.py.snap +++ /dev/null @@ -1,1044 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM222.py:1:4: SIM222 [*] Use `True` instead of `... or True` - | -1 | if a or True: # SIM222 - | ^^^^^^^^^ SIM222 -2 | pass - | - = help: Replace with `True` - -ℹ Suggested fix -1 |-if a or True: # SIM222 - 1 |+if True: # SIM222 -2 2 | pass -3 3 | -4 4 | if (a or b) or True: # SIM222 - -SIM222.py:4:4: SIM222 [*] Use `True` instead of `... or True` - | -2 | pass -3 | -4 | if (a or b) or True: # SIM222 - | ^^^^^^^^^^^^^^^^ SIM222 -5 | pass - | - = help: Replace with `True` - -ℹ Suggested fix -1 1 | if a or True: # SIM222 -2 2 | pass -3 3 | -4 |-if (a or b) or True: # SIM222 - 4 |+if True: # SIM222 -5 5 | pass -6 6 | -7 7 | if a or (b or True): # SIM222 - -SIM222.py:7:10: SIM222 [*] Use `True` instead of `... or True` - | -5 | pass -6 | -7 | if a or (b or True): # SIM222 - | ^^^^^^^^^ SIM222 -8 | pass - | - = help: Replace with `True` - -ℹ Suggested fix -4 4 | if (a or b) or True: # SIM222 -5 5 | pass -6 6 | -7 |-if a or (b or True): # SIM222 - 7 |+if a or (True): # SIM222 -8 8 | pass -9 9 | -10 10 | if a and True: # OK - -SIM222.py:24:16: SIM222 [*] Use `True` instead of `True or ...` - | -22 | pass -23 | -24 | if a or f() or True or g() or b: # SIM222 - | ^^^^^^^^^^^^^^^^ SIM222 -25 | pass - | - = help: Replace with `True` - -ℹ Suggested fix -21 21 | if a or f() or b or g() or True: # OK -22 22 | pass -23 23 | -24 |-if a or f() or True or g() or b: # SIM222 - 24 |+if a or f() or True: # SIM222 -25 25 | pass -26 26 | -27 27 | if True or f() or a or g() or b: # SIM222 - -SIM222.py:27:4: SIM222 [*] Use `True` instead of `True or ...` - | -25 | pass -26 | -27 | if True or f() or a or g() or b: # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -28 | pass - | - = help: Replace with `True` - -ℹ Suggested fix -24 24 | if a or f() or True or g() or b: # SIM222 -25 25 | pass -26 26 | -27 |-if True or f() or a or g() or b: # SIM222 - 27 |+if True: # SIM222 -28 28 | pass -29 29 | -30 30 | if a or True or f() or b or g(): # SIM222 - -SIM222.py:30:4: SIM222 [*] Use `True` instead of `... or True or ...` - | -28 | pass -29 | -30 | if a or True or f() or b or g(): # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -31 | pass - | - = help: Replace with `True` - -ℹ Suggested fix -27 27 | if True or f() or a or g() or b: # SIM222 -28 28 | pass -29 29 | -30 |-if a or True or f() or b or g(): # SIM222 - 30 |+if True: # SIM222 -31 31 | pass -32 32 | -33 33 | - -SIM222.py:47:6: SIM222 [*] Use `True` instead of `... or True` - | -47 | a or "" or True # SIM222 - | ^^^^^^^^^^ SIM222 -48 | -49 | a or "foo" or True or "bar" # SIM222 - | - = help: Replace with `True` - -ℹ Suggested fix -44 44 | pass -45 45 | -46 46 | -47 |-a or "" or True # SIM222 - 47 |+a or True # SIM222 -48 48 | -49 49 | a or "foo" or True or "bar" # SIM222 -50 50 | - -SIM222.py:49:6: SIM222 [*] Use `"foo"` instead of `"foo" or ...` - | -47 | a or "" or True # SIM222 -48 | -49 | a or "foo" or True or "bar" # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^ SIM222 -50 | -51 | a or 0 or True # SIM222 - | - = help: Replace with `"foo"` - -ℹ Suggested fix -46 46 | -47 47 | a or "" or True # SIM222 -48 48 | -49 |-a or "foo" or True or "bar" # SIM222 - 49 |+a or "foo" # SIM222 -50 50 | -51 51 | a or 0 or True # SIM222 -52 52 | - -SIM222.py:51:6: SIM222 [*] Use `True` instead of `... or True` - | -49 | a or "foo" or True or "bar" # SIM222 -50 | -51 | a or 0 or True # SIM222 - | ^^^^^^^^^ SIM222 -52 | -53 | a or 1 or True or 2 # SIM222 - | - = help: Replace with `True` - -ℹ Suggested fix -48 48 | -49 49 | a or "foo" or True or "bar" # SIM222 -50 50 | -51 |-a or 0 or True # SIM222 - 51 |+a or True # SIM222 -52 52 | -53 53 | a or 1 or True or 2 # SIM222 -54 54 | - -SIM222.py:53:6: SIM222 [*] Use `1` instead of `1 or ...` - | -51 | a or 0 or True # SIM222 -52 | -53 | a or 1 or True or 2 # SIM222 - | ^^^^^^^^^^^^^^ SIM222 -54 | -55 | a or 0.0 or True # SIM222 - | - = help: Replace with `1` - -ℹ Suggested fix -50 50 | -51 51 | a or 0 or True # SIM222 -52 52 | -53 |-a or 1 or True or 2 # SIM222 - 53 |+a or 1 # SIM222 -54 54 | -55 55 | a or 0.0 or True # SIM222 -56 56 | - -SIM222.py:55:6: SIM222 [*] Use `True` instead of `... or True` - | -53 | a or 1 or True or 2 # SIM222 -54 | -55 | a or 0.0 or True # SIM222 - | ^^^^^^^^^^^ SIM222 -56 | -57 | a or 0.1 or True or 0.2 # SIM222 - | - = help: Replace with `True` - -ℹ Suggested fix -52 52 | -53 53 | a or 1 or True or 2 # SIM222 -54 54 | -55 |-a or 0.0 or True # SIM222 - 55 |+a or True # SIM222 -56 56 | -57 57 | a or 0.1 or True or 0.2 # SIM222 -58 58 | - -SIM222.py:57:6: SIM222 [*] Use `0.1` instead of `0.1 or ...` - | -55 | a or 0.0 or True # SIM222 -56 | -57 | a or 0.1 or True or 0.2 # SIM222 - | ^^^^^^^^^^^^^^^^^^ SIM222 -58 | -59 | a or [] or True # SIM222 - | - = help: Replace with `0.1` - -ℹ Suggested fix -54 54 | -55 55 | a or 0.0 or True # SIM222 -56 56 | -57 |-a or 0.1 or True or 0.2 # SIM222 - 57 |+a or 0.1 # SIM222 -58 58 | -59 59 | a or [] or True # SIM222 -60 60 | - -SIM222.py:59:6: SIM222 [*] Use `True` instead of `... or True` - | -57 | a or 0.1 or True or 0.2 # SIM222 -58 | -59 | a or [] or True # SIM222 - | ^^^^^^^^^^ SIM222 -60 | -61 | a or list([]) or True # SIM222 - | - = help: Replace with `True` - -ℹ Suggested fix -56 56 | -57 57 | a or 0.1 or True or 0.2 # SIM222 -58 58 | -59 |-a or [] or True # SIM222 - 59 |+a or True # SIM222 -60 60 | -61 61 | a or list([]) or True # SIM222 -62 62 | - -SIM222.py:61:6: SIM222 [*] Use `True` instead of `... or True` - | -59 | a or [] or True # SIM222 -60 | -61 | a or list([]) or True # SIM222 - | ^^^^^^^^^^^^^^^^ SIM222 -62 | -63 | a or [1] or True or [2] # SIM222 - | - = help: Replace with `True` - -ℹ Suggested fix -58 58 | -59 59 | a or [] or True # SIM222 -60 60 | -61 |-a or list([]) or True # SIM222 - 61 |+a or True # SIM222 -62 62 | -63 63 | a or [1] or True or [2] # SIM222 -64 64 | - -SIM222.py:63:6: SIM222 [*] Use `[1]` instead of `[1] or ...` - | -61 | a or list([]) or True # SIM222 -62 | -63 | a or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^ SIM222 -64 | -65 | a or list([1]) or True or list([2]) # SIM222 - | - = help: Replace with `[1]` - -ℹ Suggested fix -60 60 | -61 61 | a or list([]) or True # SIM222 -62 62 | -63 |-a or [1] or True or [2] # SIM222 - 63 |+a or [1] # SIM222 -64 64 | -65 65 | a or list([1]) or True or list([2]) # SIM222 -66 66 | - -SIM222.py:65:6: SIM222 [*] Use `list([1])` instead of `list([1]) or ...` - | -63 | a or [1] or True or [2] # SIM222 -64 | -65 | a or list([1]) or True or list([2]) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -66 | -67 | a or {} or True # SIM222 - | - = help: Replace with `list([1])` - -ℹ Suggested fix -62 62 | -63 63 | a or [1] or True or [2] # SIM222 -64 64 | -65 |-a or list([1]) or True or list([2]) # SIM222 - 65 |+a or list([1]) # SIM222 -66 66 | -67 67 | a or {} or True # SIM222 -68 68 | - -SIM222.py:67:6: SIM222 [*] Use `True` instead of `... or True` - | -65 | a or list([1]) or True or list([2]) # SIM222 -66 | -67 | a or {} or True # SIM222 - | ^^^^^^^^^^ SIM222 -68 | -69 | a or dict() or True # SIM222 - | - = help: Replace with `True` - -ℹ Suggested fix -64 64 | -65 65 | a or list([1]) or True or list([2]) # SIM222 -66 66 | -67 |-a or {} or True # SIM222 - 67 |+a or True # SIM222 -68 68 | -69 69 | a or dict() or True # SIM222 -70 70 | - -SIM222.py:69:6: SIM222 [*] Use `True` instead of `... or True` - | -67 | a or {} or True # SIM222 -68 | -69 | a or dict() or True # SIM222 - | ^^^^^^^^^^^^^^ SIM222 -70 | -71 | a or {1: 1} or True or {2: 2} # SIM222 - | - = help: Replace with `True` - -ℹ Suggested fix -66 66 | -67 67 | a or {} or True # SIM222 -68 68 | -69 |-a or dict() or True # SIM222 - 69 |+a or True # SIM222 -70 70 | -71 71 | a or {1: 1} or True or {2: 2} # SIM222 -72 72 | - -SIM222.py:71:6: SIM222 [*] Use `{1: 1}` instead of `{1: 1} or ...` - | -69 | a or dict() or True # SIM222 -70 | -71 | a or {1: 1} or True or {2: 2} # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -72 | -73 | a or dict({1: 1}) or True or dict({2: 2}) # SIM222 - | - = help: Replace with `{1: 1}` - -ℹ Suggested fix -68 68 | -69 69 | a or dict() or True # SIM222 -70 70 | -71 |-a or {1: 1} or True or {2: 2} # SIM222 - 71 |+a or {1: 1} # SIM222 -72 72 | -73 73 | a or dict({1: 1}) or True or dict({2: 2}) # SIM222 -74 74 | - -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 | -73 | a or dict({1: 1}) or True or dict({2: 2}) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -74 | -75 | a or set() or True # SIM222 - | - = help: Replace with `dict({1: 1})` - -ℹ Suggested fix -70 70 | -71 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 - 73 |+a or dict({1: 1}) # SIM222 -74 74 | -75 75 | a or set() or True # SIM222 -76 76 | - -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 | -75 | a or set() or True # SIM222 - | ^^^^^^^^^^^^^ SIM222 -76 | -77 | a or set(set()) or True # SIM222 - | - = help: Replace with `True` - -ℹ Suggested fix -72 72 | -73 73 | a or dict({1: 1}) or True or dict({2: 2}) # SIM222 -74 74 | -75 |-a or set() or True # SIM222 - 75 |+a or True # SIM222 -76 76 | -77 77 | a or set(set()) or True # SIM222 -78 78 | - -SIM222.py:77:6: SIM222 [*] Use `True` instead of `... or True` - | -75 | a or set() or True # SIM222 -76 | -77 | a or set(set()) or True # SIM222 - | ^^^^^^^^^^^^^^^^^^ SIM222 -78 | -79 | a or {1} or True or {2} # SIM222 - | - = help: Replace with `True` - -ℹ Suggested fix -74 74 | -75 75 | a or set() or True # SIM222 -76 76 | -77 |-a or set(set()) or True # SIM222 - 77 |+a or True # SIM222 -78 78 | -79 79 | a or {1} or True or {2} # SIM222 -80 80 | - -SIM222.py:79:6: SIM222 [*] Use `{1}` instead of `{1} or ...` - | -77 | a or set(set()) or True # SIM222 -78 | -79 | a or {1} or True or {2} # SIM222 - | ^^^^^^^^^^^^^^^^^^ SIM222 -80 | -81 | a or set({1}) or True or set({2}) # SIM222 - | - = help: Replace with `{1}` - -ℹ Suggested fix -76 76 | -77 77 | a or set(set()) or True # SIM222 -78 78 | -79 |-a or {1} or True or {2} # SIM222 - 79 |+a or {1} # SIM222 -80 80 | -81 81 | a or set({1}) or True or set({2}) # SIM222 -82 82 | - -SIM222.py:81:6: SIM222 [*] Use `set({1})` instead of `set({1}) or ...` - | -79 | a or {1} or True or {2} # SIM222 -80 | -81 | a or set({1}) or True or set({2}) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -82 | -83 | a or () or True # SIM222 - | - = help: Replace with `set({1})` - -ℹ Suggested fix -78 78 | -79 79 | a or {1} or True or {2} # SIM222 -80 80 | -81 |-a or set({1}) or True or set({2}) # SIM222 - 81 |+a or set({1}) # SIM222 -82 82 | -83 83 | a or () or True # SIM222 -84 84 | - -SIM222.py:83:6: SIM222 [*] Use `True` instead of `... or True` - | -81 | a or set({1}) or True or set({2}) # SIM222 -82 | -83 | a or () or True # SIM222 - | ^^^^^^^^^^ SIM222 -84 | -85 | a or tuple(()) or True # SIM222 - | - = help: Replace with `True` - -ℹ Suggested fix -80 80 | -81 81 | a or set({1}) or True or set({2}) # SIM222 -82 82 | -83 |-a or () or True # SIM222 - 83 |+a or True # SIM222 -84 84 | -85 85 | a or tuple(()) or True # SIM222 -86 86 | - -SIM222.py:85:6: SIM222 [*] Use `True` instead of `... or True` - | -83 | a or () or True # SIM222 -84 | -85 | a or tuple(()) or True # SIM222 - | ^^^^^^^^^^^^^^^^^ SIM222 -86 | -87 | a or (1,) or True or (2,) # SIM222 - | - = help: Replace with `True` - -ℹ Suggested fix -82 82 | -83 83 | a or () or True # SIM222 -84 84 | -85 |-a or tuple(()) or True # SIM222 - 85 |+a or True # SIM222 -86 86 | -87 87 | a or (1,) or True or (2,) # SIM222 -88 88 | - -SIM222.py:87:6: SIM222 [*] Use `(1,)` instead of `(1,) or ...` - | -85 | a or tuple(()) or True # SIM222 -86 | -87 | a or (1,) or True or (2,) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^ SIM222 -88 | -89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 - | - = help: Replace with `(1,)` - -ℹ Suggested fix -84 84 | -85 85 | a or tuple(()) or True # SIM222 -86 86 | -87 |-a or (1,) or True or (2,) # SIM222 - 87 |+a or (1,) # SIM222 -88 88 | -89 89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 -90 90 | - -SIM222.py:89:6: SIM222 [*] Use `tuple((1,))` instead of `tuple((1,)) or ...` - | -87 | a or (1,) or True or (2,) # SIM222 -88 | -89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -90 | -91 | a or frozenset() or True # SIM222 - | - = help: Replace with `tuple((1,))` - -ℹ Suggested fix -86 86 | -87 87 | a or (1,) or True or (2,) # SIM222 -88 88 | -89 |-a or tuple((1,)) or True or tuple((2,)) # SIM222 - 89 |+a or tuple((1,)) # SIM222 -90 90 | -91 91 | a or frozenset() or True # SIM222 -92 92 | - -SIM222.py:91:6: SIM222 [*] Use `True` instead of `... or True` - | -89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 -90 | -91 | a or frozenset() or True # SIM222 - | ^^^^^^^^^^^^^^^^^^^ SIM222 -92 | -93 | a or frozenset(frozenset()) or True # SIM222 - | - = help: Replace with `True` - -ℹ Suggested fix -88 88 | -89 89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 -90 90 | -91 |-a or frozenset() or True # SIM222 - 91 |+a or True # SIM222 -92 92 | -93 93 | a or frozenset(frozenset()) or True # SIM222 -94 94 | - -SIM222.py:93:6: SIM222 [*] Use `True` instead of `... or True` - | -91 | a or frozenset() or True # SIM222 -92 | -93 | a or frozenset(frozenset()) or True # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -94 | -95 | a or frozenset({1}) or True or frozenset({2}) # SIM222 - | - = help: Replace with `True` - -ℹ Suggested fix -90 90 | -91 91 | a or frozenset() or True # SIM222 -92 92 | -93 |-a or frozenset(frozenset()) or True # SIM222 - 93 |+a or True # SIM222 -94 94 | -95 95 | a or frozenset({1}) or True or frozenset({2}) # SIM222 -96 96 | - -SIM222.py:95:6: SIM222 [*] Use `frozenset({1})` instead of `frozenset({1}) or ...` - | -93 | a or frozenset(frozenset()) or True # SIM222 -94 | -95 | a or frozenset({1}) or True or frozenset({2}) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -96 | -97 | a or frozenset(frozenset({1})) or True or frozenset(frozenset({2})) # SIM222 - | - = help: Replace with `frozenset({1})` - -ℹ Suggested fix -92 92 | -93 93 | a or frozenset(frozenset()) or True # SIM222 -94 94 | -95 |-a or frozenset({1}) or True or frozenset({2}) # SIM222 - 95 |+a or frozenset({1}) # SIM222 -96 96 | -97 97 | a or frozenset(frozenset({1})) or True or frozenset(frozenset({2})) # SIM222 -98 98 | - -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 | -97 | a or frozenset(frozenset({1})) or True or frozenset(frozenset({2})) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 - | - = help: Replace with `frozenset(frozenset({1}))` - -ℹ Suggested fix -94 94 | -95 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 - 97 |+a or frozenset(frozenset({1})) # SIM222 -98 98 | -99 99 | -100 100 | # Inside test `a` is simplified. - -SIM222.py:102:6: SIM222 [*] Use `True` instead of `... or True or ...` - | -100 | # Inside test `a` is simplified. -101 | -102 | bool(a or [1] or True or [2]) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -103 | -104 | assert a or [1] or True or [2] # SIM222 - | - = help: Replace with `True` - -ℹ Suggested fix -99 99 | -100 100 | # Inside test `a` is simplified. -101 101 | -102 |-bool(a or [1] or True or [2]) # SIM222 - 102 |+bool(True) # SIM222 -103 103 | -104 104 | assert a or [1] or True or [2] # SIM222 -105 105 | - -SIM222.py:104:8: SIM222 [*] Use `True` instead of `... or True or ...` - | -102 | bool(a or [1] or True or [2]) # SIM222 -103 | -104 | assert a or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -105 | -106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 - | - = help: Replace with `True` - -ℹ Suggested fix -101 101 | -102 102 | bool(a or [1] or True or [2]) # SIM222 -103 103 | -104 |-assert a or [1] or True or [2] # SIM222 - 104 |+assert True # SIM222 -105 105 | -106 106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 -107 107 | pass - -SIM222.py:106:5: SIM222 [*] Use `True` instead of `... or True or ...` - | -104 | assert a or [1] or True or [2] # SIM222 -105 | -106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -107 | pass - | - = help: Replace with `True` - -ℹ Suggested fix -103 103 | -104 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 - 106 |+if (True) and (a or [1] or True or [2]): # SIM222 -107 107 | pass -108 108 | -109 109 | 0 if a or [1] or True or [2] else 1 # SIM222 - -SIM222.py:106:35: SIM222 [*] Use `True` instead of `... or True or ...` - | -104 | assert a or [1] or True or [2] # SIM222 -105 | -106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -107 | pass - | - = help: Replace with `True` - -ℹ Suggested fix -103 103 | -104 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 - 106 |+if (a or [1] or True or [2]) and (True): # SIM222 -107 107 | pass -108 108 | -109 109 | 0 if a or [1] or True or [2] else 1 # SIM222 - -SIM222.py:109:6: SIM222 [*] Use `True` instead of `... or True or ...` - | -107 | pass -108 | -109 | 0 if a or [1] or True or [2] else 1 # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -110 | -111 | while a or [1] or True or [2]: # SIM222 - | - = help: Replace with `True` - -ℹ Suggested fix -106 106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 -107 107 | pass -108 108 | -109 |-0 if a or [1] or True or [2] else 1 # SIM222 - 109 |+0 if True else 1 # SIM222 -110 110 | -111 111 | while a or [1] or True or [2]: # SIM222 -112 112 | pass - -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 | -111 | while a or [1] or True or [2]: # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -112 | pass - | - = help: Replace with `True` - -ℹ Suggested fix -108 108 | -109 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 - 111 |+while True: # SIM222 -112 112 | pass -113 113 | -114 114 | [ - -SIM222.py:118:8: SIM222 [*] Use `True` instead of `... or True or ...` - | -116 | for a in range(10) -117 | for b in range(10) -118 | if a or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -119 | if b or [1] or True or [2] # SIM222 -120 | ] - | - = help: Replace with `True` - -ℹ Suggested fix -115 115 | 0 -116 116 | for a in range(10) -117 117 | for b in range(10) -118 |- if a or [1] or True or [2] # SIM222 - 118 |+ if True # SIM222 -119 119 | if b or [1] or True or [2] # SIM222 -120 120 | ] -121 121 | - -SIM222.py:119:8: SIM222 [*] Use `True` instead of `... or True or ...` - | -117 | for b in range(10) -118 | if a or [1] or True or [2] # SIM222 -119 | if b or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -120 | ] - | - = help: Replace with `True` - -ℹ Suggested fix -116 116 | for a in range(10) -117 117 | for b in range(10) -118 118 | if a or [1] or True or [2] # SIM222 -119 |- if b or [1] or True or [2] # SIM222 - 119 |+ if True # SIM222 -120 120 | ] -121 121 | -122 122 | { - -SIM222.py:126:8: SIM222 [*] Use `True` instead of `... or True or ...` - | -124 | for a in range(10) -125 | for b in range(10) -126 | if a or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -127 | if b or [1] or True or [2] # SIM222 -128 | } - | - = help: Replace with `True` - -ℹ Suggested fix -123 123 | 0 -124 124 | for a in range(10) -125 125 | for b in range(10) -126 |- if a or [1] or True or [2] # SIM222 - 126 |+ if True # SIM222 -127 127 | if b or [1] or True or [2] # SIM222 -128 128 | } -129 129 | - -SIM222.py:127:8: SIM222 [*] Use `True` instead of `... or True or ...` - | -125 | for b in range(10) -126 | if a or [1] or True or [2] # SIM222 -127 | if b or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -128 | } - | - = help: Replace with `True` - -ℹ Suggested fix -124 124 | for a in range(10) -125 125 | for b in range(10) -126 126 | if a or [1] or True or [2] # SIM222 -127 |- if b or [1] or True or [2] # SIM222 - 127 |+ if True # SIM222 -128 128 | } -129 129 | -130 130 | { - -SIM222.py:134:8: SIM222 [*] Use `True` instead of `... or True or ...` - | -132 | for a in range(10) -133 | for b in range(10) -134 | if a or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -135 | if b or [1] or True or [2] # SIM222 -136 | } - | - = help: Replace with `True` - -ℹ Suggested fix -131 131 | 0: 0 -132 132 | for a in range(10) -133 133 | for b in range(10) -134 |- if a or [1] or True or [2] # SIM222 - 134 |+ if True # SIM222 -135 135 | if b or [1] or True or [2] # SIM222 -136 136 | } -137 137 | - -SIM222.py:135:8: SIM222 [*] Use `True` instead of `... or True or ...` - | -133 | for b in range(10) -134 | if a or [1] or True or [2] # SIM222 -135 | if b or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -136 | } - | - = help: Replace with `True` - -ℹ Suggested fix -132 132 | for a in range(10) -133 133 | for b in range(10) -134 134 | if a or [1] or True or [2] # SIM222 -135 |- if b or [1] or True or [2] # SIM222 - 135 |+ if True # SIM222 -136 136 | } -137 137 | -138 138 | ( - -SIM222.py:142:8: SIM222 [*] Use `True` instead of `... or True or ...` - | -140 | for a in range(10) -141 | for b in range(10) -142 | if a or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -143 | if b or [1] or True or [2] # SIM222 -144 | ) - | - = help: Replace with `True` - -ℹ Suggested fix -139 139 | 0 -140 140 | for a in range(10) -141 141 | for b in range(10) -142 |- if a or [1] or True or [2] # SIM222 - 142 |+ if True # SIM222 -143 143 | if b or [1] or True or [2] # SIM222 -144 144 | ) -145 145 | - -SIM222.py:143:8: SIM222 [*] Use `True` instead of `... or True or ...` - | -141 | for b in range(10) -142 | if a or [1] or True or [2] # SIM222 -143 | if b or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 -144 | ) - | - = help: Replace with `True` - -ℹ Suggested fix -140 140 | for a in range(10) -141 141 | for b in range(10) -142 142 | if a or [1] or True or [2] # SIM222 -143 |- if b or [1] or True or [2] # SIM222 - 143 |+ if True # SIM222 -144 144 | ) -145 145 | -146 146 | # Outside test `a` is not simplified. - -SIM222.py:148:6: SIM222 [*] Use `[1]` instead of `[1] or ...` - | -146 | # Outside test `a` is not simplified. -147 | -148 | a or [1] or True or [2] # SIM222 - | ^^^^^^^^^^^^^^^^^^ SIM222 -149 | -150 | if (a or [1] or True or [2]) == (a or [1]): # SIM222 - | - = help: Replace with `[1]` - -ℹ Suggested fix -145 145 | -146 146 | # Outside test `a` is not simplified. -147 147 | -148 |-a or [1] or True or [2] # SIM222 - 148 |+a or [1] # SIM222 -149 149 | -150 150 | if (a or [1] or True or [2]) == (a or [1]): # SIM222 -151 151 | pass - -SIM222.py:150:10: SIM222 [*] Use `[1]` instead of `[1] or ...` - | -148 | a or [1] or True or [2] # SIM222 -149 | -150 | if (a or [1] or True or [2]) == (a or [1]): # SIM222 - | ^^^^^^^^^^^^^^^^^^ SIM222 -151 | pass - | - = help: Replace with `[1]` - -ℹ Suggested fix -147 147 | -148 148 | a or [1] or True or [2] # SIM222 -149 149 | -150 |-if (a or [1] or True or [2]) == (a or [1]): # SIM222 - 150 |+if (a or [1]) == (a or [1]): # SIM222 -151 151 | pass -152 152 | -153 153 | if f(a or [1] or True or [2]): # SIM222 - -SIM222.py:153:11: SIM222 [*] Use `[1]` instead of `[1] or ...` - | -151 | pass -152 | -153 | if f(a or [1] or True or [2]): # SIM222 - | ^^^^^^^^^^^^^^^^^^ SIM222 -154 | pass - | - = help: Replace with `[1]` - -ℹ Suggested fix -150 150 | if (a or [1] or True or [2]) == (a or [1]): # SIM222 -151 151 | pass -152 152 | -153 |-if f(a or [1] or True or [2]): # SIM222 - 153 |+if f(a or [1]): # SIM222 -154 154 | pass -155 155 | -156 156 | # Regression test for: https://github.com/astral-sh/ruff/issues/7099 - -SIM222.py:157:30: SIM222 [*] Use `(int, int, int)` instead of `(int, int, int) or ...` - | -156 | # Regression test for: https://github.com/astral-sh/ruff/issues/7099 -157 | def secondToTime(s0: int) -> (int, int, int) or str: - | ^^^^^^^^^^^^^^^^^^^^^^ SIM222 -158 | m, s = divmod(s0, 60) - | - = help: Replace with `(int, int, int)` - -ℹ Suggested fix -154 154 | pass -155 155 | -156 156 | # Regression test for: https://github.com/astral-sh/ruff/issues/7099 -157 |-def secondToTime(s0: int) -> (int, int, int) or str: - 157 |+def secondToTime(s0: int) -> (int, int, int): -158 158 | m, s = divmod(s0, 60) -159 159 | -160 160 | - -SIM222.py:161:31: SIM222 [*] Use `(int, int, int)` instead of `(int, int, int) or ...` - | -161 | def secondToTime(s0: int) -> ((int, int, int) or str): - | ^^^^^^^^^^^^^^^^^^^^^^ SIM222 -162 | m, s = divmod(s0, 60) - | - = help: Replace with `(int, int, int)` - -ℹ Suggested fix -158 158 | m, s = divmod(s0, 60) -159 159 | -160 160 | -161 |-def secondToTime(s0: int) -> ((int, int, int) or str): - 161 |+def secondToTime(s0: int) -> ((int, int, int)): -162 162 | m, s = divmod(s0, 60) - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM223_SIM223.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM223_SIM223.py.snap deleted file mode 100644 index 88976dd7f3..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM223_SIM223.py.snap +++ /dev/null @@ -1,1007 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM223.py:1:4: SIM223 [*] Use `False` instead of `... and False` - | -1 | if a and False: # SIM223 - | ^^^^^^^^^^^ SIM223 -2 | pass - | - = help: Replace with `False` - -ℹ Suggested fix -1 |-if a and False: # SIM223 - 1 |+if False: # SIM223 -2 2 | pass -3 3 | -4 4 | if (a or b) and False: # SIM223 - -SIM223.py:4:4: SIM223 [*] Use `False` instead of `... and False` - | -2 | pass -3 | -4 | if (a or b) and False: # SIM223 - | ^^^^^^^^^^^^^^^^^^ SIM223 -5 | pass - | - = help: Replace with `False` - -ℹ Suggested fix -1 1 | if a and False: # SIM223 -2 2 | pass -3 3 | -4 |-if (a or b) and False: # SIM223 - 4 |+if False: # SIM223 -5 5 | pass -6 6 | -7 7 | if a or (b and False): # SIM223 - -SIM223.py:7:10: SIM223 [*] Use `False` instead of `... and False` - | -5 | pass -6 | -7 | if a or (b and False): # SIM223 - | ^^^^^^^^^^^ SIM223 -8 | pass - | - = help: Replace with `False` - -ℹ Suggested fix -4 4 | if (a or b) and False: # SIM223 -5 5 | pass -6 6 | -7 |-if a or (b and False): # SIM223 - 7 |+if a or (False): # SIM223 -8 8 | pass -9 9 | -10 10 | if a or False: - -SIM223.py:19:18: SIM223 [*] Use `False` instead of `False and ...` - | -17 | pass -18 | -19 | if a and f() and False and g() and b: # SIM223 - | ^^^^^^^^^^^^^^^^^^^ SIM223 -20 | pass - | - = help: Replace with `False` - -ℹ Suggested fix -16 16 | if a and f() and b and g() and False: # OK -17 17 | pass -18 18 | -19 |-if a and f() and False and g() and b: # SIM223 - 19 |+if a and f() and False: # SIM223 -20 20 | pass -21 21 | -22 22 | if False and f() and a and g() and b: # SIM223 - -SIM223.py:22:4: SIM223 [*] Use `False` instead of `False and ...` - | -20 | pass -21 | -22 | if False and f() and a and g() and b: # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -23 | pass - | - = help: Replace with `False` - -ℹ Suggested fix -19 19 | if a and f() and False and g() and b: # SIM223 -20 20 | pass -21 21 | -22 |-if False and f() and a and g() and b: # SIM223 - 22 |+if False: # SIM223 -23 23 | pass -24 24 | -25 25 | if a and False and f() and b and g(): # SIM223 - -SIM223.py:25:4: SIM223 [*] Use `False` instead of `... and False and ...` - | -23 | pass -24 | -25 | if a and False and f() and b and g(): # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -26 | pass - | - = help: Replace with `False` - -ℹ Suggested fix -22 22 | if False and f() and a and g() and b: # SIM223 -23 23 | pass -24 24 | -25 |-if a and False and f() and b and g(): # SIM223 - 25 |+if False: # SIM223 -26 26 | pass -27 27 | -28 28 | - -SIM223.py:42:7: SIM223 [*] Use `""` instead of `"" and ...` - | -42 | a and "" and False # SIM223 - | ^^^^^^^^^^^^ SIM223 -43 | -44 | a and "foo" and False and "bar" # SIM223 - | - = help: Replace with `""` - -ℹ Suggested fix -39 39 | pass -40 40 | -41 41 | -42 |-a and "" and False # SIM223 - 42 |+a and "" # SIM223 -43 43 | -44 44 | a and "foo" and False and "bar" # SIM223 -45 45 | - -SIM223.py:44:7: SIM223 [*] Use `False` instead of `... and False and ...` - | -42 | a and "" and False # SIM223 -43 | -44 | a and "foo" and False and "bar" # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -45 | -46 | a and 0 and False # SIM223 - | - = help: Replace with `False` - -ℹ Suggested fix -41 41 | -42 42 | a and "" and False # SIM223 -43 43 | -44 |-a and "foo" and False and "bar" # SIM223 - 44 |+a and False # SIM223 -45 45 | -46 46 | a and 0 and False # SIM223 -47 47 | - -SIM223.py:46:7: SIM223 [*] Use `0` instead of `0 and ...` - | -44 | a and "foo" and False and "bar" # SIM223 -45 | -46 | a and 0 and False # SIM223 - | ^^^^^^^^^^^ SIM223 -47 | -48 | a and 1 and False and 2 # SIM223 - | - = help: Replace with `0` - -ℹ Suggested fix -43 43 | -44 44 | a and "foo" and False and "bar" # SIM223 -45 45 | -46 |-a and 0 and False # SIM223 - 46 |+a and 0 # SIM223 -47 47 | -48 48 | a and 1 and False and 2 # SIM223 -49 49 | - -SIM223.py:48:7: SIM223 [*] Use `False` instead of `... and False and ...` - | -46 | a and 0 and False # SIM223 -47 | -48 | a and 1 and False and 2 # SIM223 - | ^^^^^^^^^^^^^^^^^ SIM223 -49 | -50 | a and 0.0 and False # SIM223 - | - = help: Replace with `False` - -ℹ Suggested fix -45 45 | -46 46 | a and 0 and False # SIM223 -47 47 | -48 |-a and 1 and False and 2 # SIM223 - 48 |+a and False # SIM223 -49 49 | -50 50 | a and 0.0 and False # SIM223 -51 51 | - -SIM223.py:50:7: SIM223 [*] Use `0.0` instead of `0.0 and ...` - | -48 | a and 1 and False and 2 # SIM223 -49 | -50 | a and 0.0 and False # SIM223 - | ^^^^^^^^^^^^^ SIM223 -51 | -52 | a and 0.1 and False and 0.2 # SIM223 - | - = help: Replace with `0.0` - -ℹ Suggested fix -47 47 | -48 48 | a and 1 and False and 2 # SIM223 -49 49 | -50 |-a and 0.0 and False # SIM223 - 50 |+a and 0.0 # SIM223 -51 51 | -52 52 | a and 0.1 and False and 0.2 # SIM223 -53 53 | - -SIM223.py:52:7: SIM223 [*] Use `False` instead of `... and False and ...` - | -50 | a and 0.0 and False # SIM223 -51 | -52 | a and 0.1 and False and 0.2 # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^ SIM223 -53 | -54 | a and [] and False # SIM223 - | - = help: Replace with `False` - -ℹ Suggested fix -49 49 | -50 50 | a and 0.0 and False # SIM223 -51 51 | -52 |-a and 0.1 and False and 0.2 # SIM223 - 52 |+a and False # SIM223 -53 53 | -54 54 | a and [] and False # SIM223 -55 55 | - -SIM223.py:54:7: SIM223 [*] Use `[]` instead of `[] and ...` - | -52 | a and 0.1 and False and 0.2 # SIM223 -53 | -54 | a and [] and False # SIM223 - | ^^^^^^^^^^^^ SIM223 -55 | -56 | a and list([]) and False # SIM223 - | - = help: Replace with `[]` - -ℹ Suggested fix -51 51 | -52 52 | a and 0.1 and False and 0.2 # SIM223 -53 53 | -54 |-a and [] and False # SIM223 - 54 |+a and [] # SIM223 -55 55 | -56 56 | a and list([]) and False # SIM223 -57 57 | - -SIM223.py:56:7: SIM223 [*] Use `list([])` instead of `list([]) and ...` - | -54 | a and [] and False # SIM223 -55 | -56 | a and list([]) and False # SIM223 - | ^^^^^^^^^^^^^^^^^^ SIM223 -57 | -58 | a and [1] and False and [2] # SIM223 - | - = help: Replace with `list([])` - -ℹ Suggested fix -53 53 | -54 54 | a and [] and False # SIM223 -55 55 | -56 |-a and list([]) and False # SIM223 - 56 |+a and list([]) # SIM223 -57 57 | -58 58 | a and [1] and False and [2] # SIM223 -59 59 | - -SIM223.py:58:7: SIM223 [*] Use `False` instead of `... and False and ...` - | -56 | a and list([]) and False # SIM223 -57 | -58 | a and [1] and False and [2] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^ SIM223 -59 | -60 | a and list([1]) and False and list([2]) # SIM223 - | - = help: Replace with `False` - -ℹ Suggested fix -55 55 | -56 56 | a and list([]) and False # SIM223 -57 57 | -58 |-a and [1] and False and [2] # SIM223 - 58 |+a and False # SIM223 -59 59 | -60 60 | a and list([1]) and False and list([2]) # SIM223 -61 61 | - -SIM223.py:60:7: SIM223 [*] Use `False` instead of `... and False and ...` - | -58 | a and [1] and False and [2] # SIM223 -59 | -60 | a and list([1]) and False and list([2]) # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -61 | -62 | a and {} and False # SIM223 - | - = help: Replace with `False` - -ℹ Suggested fix -57 57 | -58 58 | a and [1] and False and [2] # SIM223 -59 59 | -60 |-a and list([1]) and False and list([2]) # SIM223 - 60 |+a and False # SIM223 -61 61 | -62 62 | a and {} and False # SIM223 -63 63 | - -SIM223.py:62:7: SIM223 [*] Use `{}` instead of `{} and ...` - | -60 | a and list([1]) and False and list([2]) # SIM223 -61 | -62 | a and {} and False # SIM223 - | ^^^^^^^^^^^^ SIM223 -63 | -64 | a and dict() and False # SIM223 - | - = help: Replace with `{}` - -ℹ Suggested fix -59 59 | -60 60 | a and list([1]) and False and list([2]) # SIM223 -61 61 | -62 |-a and {} and False # SIM223 - 62 |+a and {} # SIM223 -63 63 | -64 64 | a and dict() and False # SIM223 -65 65 | - -SIM223.py:64:7: SIM223 [*] Use `dict()` instead of `dict() and ...` - | -62 | a and {} and False # SIM223 -63 | -64 | a and dict() and False # SIM223 - | ^^^^^^^^^^^^^^^^ SIM223 -65 | -66 | a and {1: 1} and False and {2: 2} # SIM223 - | - = help: Replace with `dict()` - -ℹ Suggested fix -61 61 | -62 62 | a and {} and False # SIM223 -63 63 | -64 |-a and dict() and False # SIM223 - 64 |+a and dict() # SIM223 -65 65 | -66 66 | a and {1: 1} and False and {2: 2} # SIM223 -67 67 | - -SIM223.py:66:7: SIM223 [*] Use `False` instead of `... and False and ...` - | -64 | a and dict() and False # SIM223 -65 | -66 | a and {1: 1} and False and {2: 2} # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -67 | -68 | a and dict({1: 1}) and False and dict({2: 2}) # SIM223 - | - = help: Replace with `False` - -ℹ Suggested fix -63 63 | -64 64 | a and dict() and False # SIM223 -65 65 | -66 |-a and {1: 1} and False and {2: 2} # SIM223 - 66 |+a and False # SIM223 -67 67 | -68 68 | a and dict({1: 1}) and False and dict({2: 2}) # SIM223 -69 69 | - -SIM223.py:68:7: SIM223 [*] Use `False` instead of `... and False and ...` - | -66 | a and {1: 1} and False and {2: 2} # SIM223 -67 | -68 | a and dict({1: 1}) and False and dict({2: 2}) # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -69 | -70 | a and set() and False # SIM223 - | - = help: Replace with `False` - -ℹ Suggested fix -65 65 | -66 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 - 68 |+a and False # SIM223 -69 69 | -70 70 | a and set() and False # SIM223 -71 71 | - -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 | -70 | a and set() and False # SIM223 - | ^^^^^^^^^^^^^^^ SIM223 -71 | -72 | a and set(set()) and False # SIM223 - | - = help: Replace with `set()` - -ℹ Suggested fix -67 67 | -68 68 | a and dict({1: 1}) and False and dict({2: 2}) # SIM223 -69 69 | -70 |-a and set() and False # SIM223 - 70 |+a and set() # SIM223 -71 71 | -72 72 | a and set(set()) and False # SIM223 -73 73 | - -SIM223.py:72:7: SIM223 [*] Use `set(set())` instead of `set(set()) and ...` - | -70 | a and set() and False # SIM223 -71 | -72 | a and set(set()) and False # SIM223 - | ^^^^^^^^^^^^^^^^^^^^ SIM223 -73 | -74 | a and {1} and False and {2} # SIM223 - | - = help: Replace with `set(set())` - -ℹ Suggested fix -69 69 | -70 70 | a and set() and False # SIM223 -71 71 | -72 |-a and set(set()) and False # SIM223 - 72 |+a and set(set()) # SIM223 -73 73 | -74 74 | a and {1} and False and {2} # SIM223 -75 75 | - -SIM223.py:74:7: SIM223 [*] Use `False` instead of `... and False and ...` - | -72 | a and set(set()) and False # SIM223 -73 | -74 | a and {1} and False and {2} # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^ SIM223 -75 | -76 | a and set({1}) and False and set({2}) # SIM223 - | - = help: Replace with `False` - -ℹ Suggested fix -71 71 | -72 72 | a and set(set()) and False # SIM223 -73 73 | -74 |-a and {1} and False and {2} # SIM223 - 74 |+a and False # SIM223 -75 75 | -76 76 | a and set({1}) and False and set({2}) # SIM223 -77 77 | - -SIM223.py:76:7: SIM223 [*] Use `False` instead of `... and False and ...` - | -74 | a and {1} and False and {2} # SIM223 -75 | -76 | a and set({1}) and False and set({2}) # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -77 | -78 | a and () and False # SIM222 - | - = help: Replace with `False` - -ℹ Suggested fix -73 73 | -74 74 | a and {1} and False and {2} # SIM223 -75 75 | -76 |-a and set({1}) and False and set({2}) # SIM223 - 76 |+a and False # SIM223 -77 77 | -78 78 | a and () and False # SIM222 -79 79 | - -SIM223.py:78:7: SIM223 [*] Use `()` instead of `() and ...` - | -76 | a and set({1}) and False and set({2}) # SIM223 -77 | -78 | a and () and False # SIM222 - | ^^^^^^^^^^^^ SIM223 -79 | -80 | a and tuple(()) and False # SIM222 - | - = help: Replace with `()` - -ℹ Suggested fix -75 75 | -76 76 | a and set({1}) and False and set({2}) # SIM223 -77 77 | -78 |-a and () and False # SIM222 - 78 |+a and () # SIM222 -79 79 | -80 80 | a and tuple(()) and False # SIM222 -81 81 | - -SIM223.py:80:7: SIM223 [*] Use `tuple(())` instead of `tuple(()) and ...` - | -78 | a and () and False # SIM222 -79 | -80 | a and tuple(()) and False # SIM222 - | ^^^^^^^^^^^^^^^^^^^ SIM223 -81 | -82 | a and (1,) and False and (2,) # SIM222 - | - = help: Replace with `tuple(())` - -ℹ Suggested fix -77 77 | -78 78 | a and () and False # SIM222 -79 79 | -80 |-a and tuple(()) and False # SIM222 - 80 |+a and tuple(()) # SIM222 -81 81 | -82 82 | a and (1,) and False and (2,) # SIM222 -83 83 | - -SIM223.py:82:7: SIM223 [*] Use `False` instead of `... and False and ...` - | -80 | a and tuple(()) and False # SIM222 -81 | -82 | a and (1,) and False and (2,) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -83 | -84 | a and tuple((1,)) and False and tuple((2,)) # SIM222 - | - = help: Replace with `False` - -ℹ Suggested fix -79 79 | -80 80 | a and tuple(()) and False # SIM222 -81 81 | -82 |-a and (1,) and False and (2,) # SIM222 - 82 |+a and False # SIM222 -83 83 | -84 84 | a and tuple((1,)) and False and tuple((2,)) # SIM222 -85 85 | - -SIM223.py:84:7: SIM223 [*] Use `False` instead of `... and False and ...` - | -82 | a and (1,) and False and (2,) # SIM222 -83 | -84 | a and tuple((1,)) and False and tuple((2,)) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -85 | -86 | a and frozenset() and False # SIM222 - | - = help: Replace with `False` - -ℹ Suggested fix -81 81 | -82 82 | a and (1,) and False and (2,) # SIM222 -83 83 | -84 |-a and tuple((1,)) and False and tuple((2,)) # SIM222 - 84 |+a and False # SIM222 -85 85 | -86 86 | a and frozenset() and False # SIM222 -87 87 | - -SIM223.py:86:7: SIM223 [*] Use `frozenset()` instead of `frozenset() and ...` - | -84 | a and tuple((1,)) and False and tuple((2,)) # SIM222 -85 | -86 | a and frozenset() and False # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^ SIM223 -87 | -88 | a and frozenset(frozenset()) and False # SIM222 - | - = help: Replace with `frozenset()` - -ℹ Suggested fix -83 83 | -84 84 | a and tuple((1,)) and False and tuple((2,)) # SIM222 -85 85 | -86 |-a and frozenset() and False # SIM222 - 86 |+a and frozenset() # SIM222 -87 87 | -88 88 | a and frozenset(frozenset()) and False # SIM222 -89 89 | - -SIM223.py:88:7: SIM223 [*] Use `frozenset(frozenset())` instead of `frozenset(frozenset()) and ...` - | -86 | a and frozenset() and False # SIM222 -87 | -88 | a and frozenset(frozenset()) and False # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -89 | -90 | a and frozenset({1}) and False and frozenset({2}) # SIM222 - | - = help: Replace with `frozenset(frozenset())` - -ℹ Suggested fix -85 85 | -86 86 | a and frozenset() and False # SIM222 -87 87 | -88 |-a and frozenset(frozenset()) and False # SIM222 - 88 |+a and frozenset(frozenset()) # SIM222 -89 89 | -90 90 | a and frozenset({1}) and False and frozenset({2}) # SIM222 -91 91 | - -SIM223.py:90:7: SIM223 [*] Use `False` instead of `... and False and ...` - | -88 | a and frozenset(frozenset()) and False # SIM222 -89 | -90 | a and frozenset({1}) and False and frozenset({2}) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -91 | -92 | a and frozenset(frozenset({1})) and False and frozenset(frozenset({2})) # SIM222 - | - = help: Replace with `False` - -ℹ Suggested fix -87 87 | -88 88 | a and frozenset(frozenset()) and False # SIM222 -89 89 | -90 |-a and frozenset({1}) and False and frozenset({2}) # SIM222 - 90 |+a and False # SIM222 -91 91 | -92 92 | a and frozenset(frozenset({1})) and False and frozenset(frozenset({2})) # SIM222 -93 93 | - -SIM223.py:92:7: SIM223 [*] Use `False` instead of `... and False and ...` - | -90 | a and frozenset({1}) and False and frozenset({2}) # SIM222 -91 | -92 | a and frozenset(frozenset({1})) and False and frozenset(frozenset({2})) # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 - | - = help: Replace with `False` - -ℹ Suggested fix -89 89 | -90 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 - 92 |+a and False # SIM222 -93 93 | -94 94 | -95 95 | # Inside test `a` is simplified. - -SIM223.py:97:6: SIM223 [*] Use `False` instead of `... and False and ...` - | -95 | # Inside test `a` is simplified. -96 | -97 | bool(a and [] and False and []) # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -98 | -99 | assert a and [] and False and [] # SIM223 - | - = help: Replace with `False` - -ℹ Suggested fix -94 94 | -95 95 | # Inside test `a` is simplified. -96 96 | -97 |-bool(a and [] and False and []) # SIM223 - 97 |+bool(False) # SIM223 -98 98 | -99 99 | assert a and [] and False and [] # SIM223 -100 100 | - -SIM223.py:99:8: SIM223 [*] Use `False` instead of `... and False and ...` - | - 97 | bool(a and [] and False and []) # SIM223 - 98 | - 99 | assert a and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -100 | -101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 - | - = help: Replace with `False` - -ℹ Suggested fix -96 96 | -97 97 | bool(a and [] and False and []) # SIM223 -98 98 | -99 |-assert a and [] and False and [] # SIM223 - 99 |+assert False # SIM223 -100 100 | -101 101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 -102 102 | pass - -SIM223.py:101:5: SIM223 [*] Use `False` instead of `... and False and ...` - | - 99 | assert a and [] and False and [] # SIM223 -100 | -101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -102 | pass - | - = help: Replace with `False` - -ℹ Suggested fix -98 98 | -99 99 | assert a and [] and False and [] # SIM223 -100 100 | -101 |-if (a and [] and False and []) or (a and [] and False and []): # SIM223 - 101 |+if (False) or (a and [] and False and []): # SIM223 -102 102 | pass -103 103 | -104 104 | 0 if a and [] and False and [] else 1 # SIM222 - -SIM223.py:101:36: SIM223 [*] Use `False` instead of `... and False and ...` - | - 99 | assert a and [] and False and [] # SIM223 -100 | -101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -102 | pass - | - = help: Replace with `False` - -ℹ Suggested fix -98 98 | -99 99 | assert a and [] and False and [] # SIM223 -100 100 | -101 |-if (a and [] and False and []) or (a and [] and False and []): # SIM223 - 101 |+if (a and [] and False and []) or (False): # SIM223 -102 102 | pass -103 103 | -104 104 | 0 if a and [] and False and [] else 1 # SIM222 - -SIM223.py:104:6: SIM223 [*] Use `False` instead of `... and False and ...` - | -102 | pass -103 | -104 | 0 if a and [] and False and [] else 1 # SIM222 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -105 | -106 | while a and [] and False and []: # SIM223 - | - = help: Replace with `False` - -ℹ Suggested fix -101 101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 -102 102 | pass -103 103 | -104 |-0 if a and [] and False and [] else 1 # SIM222 - 104 |+0 if False else 1 # SIM222 -105 105 | -106 106 | while a and [] and False and []: # SIM223 -107 107 | pass - -SIM223.py:106:7: SIM223 [*] Use `False` instead of `... and False and ...` - | -104 | 0 if a and [] and False and [] else 1 # SIM222 -105 | -106 | while a and [] and False and []: # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -107 | pass - | - = help: Replace with `False` - -ℹ Suggested fix -103 103 | -104 104 | 0 if a and [] and False and [] else 1 # SIM222 -105 105 | -106 |-while a and [] and False and []: # SIM223 - 106 |+while False: # SIM223 -107 107 | pass -108 108 | -109 109 | [ - -SIM223.py:113:8: SIM223 [*] Use `False` instead of `... and False and ...` - | -111 | for a in range(10) -112 | for b in range(10) -113 | if a and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -114 | if b and [] and False and [] # SIM223 -115 | ] - | - = help: Replace with `False` - -ℹ Suggested fix -110 110 | 0 -111 111 | for a in range(10) -112 112 | for b in range(10) -113 |- if a and [] and False and [] # SIM223 - 113 |+ if False # SIM223 -114 114 | if b and [] and False and [] # SIM223 -115 115 | ] -116 116 | - -SIM223.py:114:8: SIM223 [*] Use `False` instead of `... and False and ...` - | -112 | for b in range(10) -113 | if a and [] and False and [] # SIM223 -114 | if b and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -115 | ] - | - = help: Replace with `False` - -ℹ Suggested fix -111 111 | for a in range(10) -112 112 | for b in range(10) -113 113 | if a and [] and False and [] # SIM223 -114 |- if b and [] and False and [] # SIM223 - 114 |+ if False # SIM223 -115 115 | ] -116 116 | -117 117 | { - -SIM223.py:121:8: SIM223 [*] Use `False` instead of `... and False and ...` - | -119 | for a in range(10) -120 | for b in range(10) -121 | if a and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -122 | if b and [] and False and [] # SIM223 -123 | } - | - = help: Replace with `False` - -ℹ Suggested fix -118 118 | 0 -119 119 | for a in range(10) -120 120 | for b in range(10) -121 |- if a and [] and False and [] # SIM223 - 121 |+ if False # SIM223 -122 122 | if b and [] and False and [] # SIM223 -123 123 | } -124 124 | - -SIM223.py:122:8: SIM223 [*] Use `False` instead of `... and False and ...` - | -120 | for b in range(10) -121 | if a and [] and False and [] # SIM223 -122 | if b and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -123 | } - | - = help: Replace with `False` - -ℹ Suggested fix -119 119 | for a in range(10) -120 120 | for b in range(10) -121 121 | if a and [] and False and [] # SIM223 -122 |- if b and [] and False and [] # SIM223 - 122 |+ if False # SIM223 -123 123 | } -124 124 | -125 125 | { - -SIM223.py:129:8: SIM223 [*] Use `False` instead of `... and False and ...` - | -127 | for a in range(10) -128 | for b in range(10) -129 | if a and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -130 | if b and [] and False and [] # SIM223 -131 | } - | - = help: Replace with `False` - -ℹ Suggested fix -126 126 | 0: 0 -127 127 | for a in range(10) -128 128 | for b in range(10) -129 |- if a and [] and False and [] # SIM223 - 129 |+ if False # SIM223 -130 130 | if b and [] and False and [] # SIM223 -131 131 | } -132 132 | - -SIM223.py:130:8: SIM223 [*] Use `False` instead of `... and False and ...` - | -128 | for b in range(10) -129 | if a and [] and False and [] # SIM223 -130 | if b and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -131 | } - | - = help: Replace with `False` - -ℹ Suggested fix -127 127 | for a in range(10) -128 128 | for b in range(10) -129 129 | if a and [] and False and [] # SIM223 -130 |- if b and [] and False and [] # SIM223 - 130 |+ if False # SIM223 -131 131 | } -132 132 | -133 133 | ( - -SIM223.py:137:8: SIM223 [*] Use `False` instead of `... and False and ...` - | -135 | for a in range(10) -136 | for b in range(10) -137 | if a and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -138 | if b and [] and False and [] # SIM223 -139 | ) - | - = help: Replace with `False` - -ℹ Suggested fix -134 134 | 0 -135 135 | for a in range(10) -136 136 | for b in range(10) -137 |- if a and [] and False and [] # SIM223 - 137 |+ if False # SIM223 -138 138 | if b and [] and False and [] # SIM223 -139 139 | ) -140 140 | - -SIM223.py:138:8: SIM223 [*] Use `False` instead of `... and False and ...` - | -136 | for b in range(10) -137 | if a and [] and False and [] # SIM223 -138 | if b and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 -139 | ) - | - = help: Replace with `False` - -ℹ Suggested fix -135 135 | for a in range(10) -136 136 | for b in range(10) -137 137 | if a and [] and False and [] # SIM223 -138 |- if b and [] and False and [] # SIM223 - 138 |+ if False # SIM223 -139 139 | ) -140 140 | -141 141 | # Outside test `a` is not simplified. - -SIM223.py:143:7: SIM223 [*] Use `[]` instead of `[] and ...` - | -141 | # Outside test `a` is not simplified. -142 | -143 | a and [] and False and [] # SIM223 - | ^^^^^^^^^^^^^^^^^^^ SIM223 -144 | -145 | if (a and [] and False and []) == (a and []): # SIM223 - | - = help: Replace with `[]` - -ℹ Suggested fix -140 140 | -141 141 | # Outside test `a` is not simplified. -142 142 | -143 |-a and [] and False and [] # SIM223 - 143 |+a and [] # SIM223 -144 144 | -145 145 | if (a and [] and False and []) == (a and []): # SIM223 -146 146 | pass - -SIM223.py:145:11: SIM223 [*] Use `[]` instead of `[] and ...` - | -143 | a and [] and False and [] # SIM223 -144 | -145 | if (a and [] and False and []) == (a and []): # SIM223 - | ^^^^^^^^^^^^^^^^^^^ SIM223 -146 | pass - | - = help: Replace with `[]` - -ℹ Suggested fix -142 142 | -143 143 | a and [] and False and [] # SIM223 -144 144 | -145 |-if (a and [] and False and []) == (a and []): # SIM223 - 145 |+if (a and []) == (a and []): # SIM223 -146 146 | pass -147 147 | -148 148 | if f(a and [] and False and []): # SIM223 - -SIM223.py:148:12: SIM223 [*] Use `[]` instead of `[] and ...` - | -146 | pass -147 | -148 | if f(a and [] and False and []): # SIM223 - | ^^^^^^^^^^^^^^^^^^^ SIM223 -149 | pass - | - = help: Replace with `[]` - -ℹ Suggested fix -145 145 | if (a and [] and False and []) == (a and []): # SIM223 -146 146 | pass -147 147 | -148 |-if f(a and [] and False and []): # SIM223 - 148 |+if f(a and []): # SIM223 -149 149 | pass - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM300_SIM300.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM300_SIM300.py.snap deleted file mode 100644 index 997f098472..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM300_SIM300.py.snap +++ /dev/null @@ -1,356 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM300.py:2:1: SIM300 [*] Yoda conditions are discouraged, use `compare == "yoda"` instead - | -1 | # Errors -2 | "yoda" == compare # SIM300 - | ^^^^^^^^^^^^^^^^^ SIM300 -3 | "yoda" == compare # SIM300 -4 | 42 == age # SIM300 - | - = help: Replace Yoda condition with `compare == "yoda"` - -ℹ Fix -1 1 | # Errors -2 |-"yoda" == compare # SIM300 - 2 |+compare == "yoda" # SIM300 -3 3 | "yoda" == compare # SIM300 -4 4 | 42 == age # SIM300 -5 5 | ("a", "b") == compare # SIM300 - -SIM300.py:3:1: SIM300 [*] Yoda conditions are discouraged, use `compare == "yoda"` instead - | -1 | # Errors -2 | "yoda" == compare # SIM300 -3 | "yoda" == compare # SIM300 - | ^^^^^^^^^^^^^^^^^ SIM300 -4 | 42 == age # SIM300 -5 | ("a", "b") == compare # SIM300 - | - = help: Replace Yoda condition with `compare == "yoda"` - -ℹ Fix -1 1 | # Errors -2 2 | "yoda" == compare # SIM300 -3 |-"yoda" == compare # SIM300 - 3 |+compare == "yoda" # SIM300 -4 4 | 42 == age # SIM300 -5 5 | ("a", "b") == compare # SIM300 -6 6 | "yoda" <= compare # SIM300 - -SIM300.py:4:1: SIM300 [*] Yoda conditions are discouraged, use `age == 42` instead - | -2 | "yoda" == compare # SIM300 -3 | "yoda" == compare # SIM300 -4 | 42 == age # SIM300 - | ^^^^^^^^^ SIM300 -5 | ("a", "b") == compare # SIM300 -6 | "yoda" <= compare # SIM300 - | - = help: Replace Yoda condition with `age == 42` - -ℹ Fix -1 1 | # Errors -2 2 | "yoda" == compare # SIM300 -3 3 | "yoda" == compare # SIM300 -4 |-42 == age # SIM300 - 4 |+age == 42 # SIM300 -5 5 | ("a", "b") == compare # SIM300 -6 6 | "yoda" <= compare # SIM300 -7 7 | "yoda" < compare # SIM300 - -SIM300.py:5:1: SIM300 [*] Yoda conditions are discouraged, use `compare == ("a", "b")` instead - | -3 | "yoda" == compare # SIM300 -4 | 42 == age # SIM300 -5 | ("a", "b") == compare # SIM300 - | ^^^^^^^^^^^^^^^^^^^^^ SIM300 -6 | "yoda" <= compare # SIM300 -7 | "yoda" < compare # SIM300 - | - = help: Replace Yoda condition with `compare == ("a", "b")` - -ℹ Fix -2 2 | "yoda" == compare # SIM300 -3 3 | "yoda" == compare # SIM300 -4 4 | 42 == age # SIM300 -5 |-("a", "b") == compare # SIM300 - 5 |+compare == ("a", "b") # SIM300 -6 6 | "yoda" <= compare # SIM300 -7 7 | "yoda" < compare # SIM300 -8 8 | 42 > age # SIM300 - -SIM300.py:6:1: SIM300 [*] Yoda conditions are discouraged, use `compare >= "yoda"` instead - | -4 | 42 == age # SIM300 -5 | ("a", "b") == compare # SIM300 -6 | "yoda" <= compare # SIM300 - | ^^^^^^^^^^^^^^^^^ SIM300 -7 | "yoda" < compare # SIM300 -8 | 42 > age # SIM300 - | - = help: Replace Yoda condition with `compare >= "yoda"` - -ℹ Fix -3 3 | "yoda" == compare # SIM300 -4 4 | 42 == age # SIM300 -5 5 | ("a", "b") == compare # SIM300 -6 |-"yoda" <= compare # SIM300 - 6 |+compare >= "yoda" # SIM300 -7 7 | "yoda" < compare # SIM300 -8 8 | 42 > age # SIM300 -9 9 | -42 > age # SIM300 - -SIM300.py:7:1: SIM300 [*] Yoda conditions are discouraged, use `compare > "yoda"` instead - | -5 | ("a", "b") == compare # SIM300 -6 | "yoda" <= compare # SIM300 -7 | "yoda" < compare # SIM300 - | ^^^^^^^^^^^^^^^^ SIM300 -8 | 42 > age # SIM300 -9 | -42 > age # SIM300 - | - = help: Replace Yoda condition with `compare > "yoda"` - -ℹ Fix -4 4 | 42 == age # SIM300 -5 5 | ("a", "b") == compare # SIM300 -6 6 | "yoda" <= compare # SIM300 -7 |-"yoda" < compare # SIM300 - 7 |+compare > "yoda" # SIM300 -8 8 | 42 > age # SIM300 -9 9 | -42 > age # SIM300 -10 10 | +42 > age # SIM300 - -SIM300.py:8:1: SIM300 [*] Yoda conditions are discouraged, use `age < 42` instead - | - 6 | "yoda" <= compare # SIM300 - 7 | "yoda" < compare # SIM300 - 8 | 42 > age # SIM300 - | ^^^^^^^^ SIM300 - 9 | -42 > age # SIM300 -10 | +42 > age # SIM300 - | - = help: Replace Yoda condition with `age < 42` - -ℹ Fix -5 5 | ("a", "b") == compare # SIM300 -6 6 | "yoda" <= compare # SIM300 -7 7 | "yoda" < compare # SIM300 -8 |-42 > age # SIM300 - 8 |+age < 42 # SIM300 -9 9 | -42 > age # SIM300 -10 10 | +42 > age # SIM300 -11 11 | YODA == age # SIM300 - -SIM300.py:9:1: SIM300 [*] Yoda conditions are discouraged, use `age < -42` instead - | - 7 | "yoda" < compare # SIM300 - 8 | 42 > age # SIM300 - 9 | -42 > age # SIM300 - | ^^^^^^^^^ SIM300 -10 | +42 > age # SIM300 -11 | YODA == age # SIM300 - | - = help: Replace Yoda condition with `age < -42` - -ℹ Fix -6 6 | "yoda" <= compare # SIM300 -7 7 | "yoda" < compare # SIM300 -8 8 | 42 > age # SIM300 -9 |--42 > age # SIM300 - 9 |+age < -42 # SIM300 -10 10 | +42 > age # SIM300 -11 11 | YODA == age # SIM300 -12 12 | YODA > age # SIM300 - -SIM300.py:10:1: SIM300 [*] Yoda conditions are discouraged, use `age < +42` instead - | - 8 | 42 > age # SIM300 - 9 | -42 > age # SIM300 -10 | +42 > age # SIM300 - | ^^^^^^^^^ SIM300 -11 | YODA == age # SIM300 -12 | YODA > age # SIM300 - | - = help: Replace Yoda condition with `age < +42` - -ℹ Fix -7 7 | "yoda" < compare # SIM300 -8 8 | 42 > age # SIM300 -9 9 | -42 > age # SIM300 -10 |-+42 > age # SIM300 - 10 |+age < +42 # SIM300 -11 11 | YODA == age # SIM300 -12 12 | YODA > age # SIM300 -13 13 | YODA >= age # SIM300 - -SIM300.py:11:1: SIM300 [*] Yoda conditions are discouraged, use `age == YODA` instead - | - 9 | -42 > age # SIM300 -10 | +42 > age # SIM300 -11 | YODA == age # SIM300 - | ^^^^^^^^^^^ SIM300 -12 | YODA > age # SIM300 -13 | YODA >= age # SIM300 - | - = help: Replace Yoda condition with `age == YODA` - -ℹ Fix -8 8 | 42 > age # SIM300 -9 9 | -42 > age # SIM300 -10 10 | +42 > age # SIM300 -11 |-YODA == age # SIM300 - 11 |+age == YODA # SIM300 -12 12 | YODA > age # SIM300 -13 13 | YODA >= age # SIM300 -14 14 | JediOrder.YODA == age # SIM300 - -SIM300.py:12:1: SIM300 [*] Yoda conditions are discouraged, use `age < YODA` instead - | -10 | +42 > age # SIM300 -11 | YODA == age # SIM300 -12 | YODA > age # SIM300 - | ^^^^^^^^^^ SIM300 -13 | YODA >= age # SIM300 -14 | JediOrder.YODA == age # SIM300 - | - = help: Replace Yoda condition with `age < YODA` - -ℹ Fix -9 9 | -42 > age # SIM300 -10 10 | +42 > age # SIM300 -11 11 | YODA == age # SIM300 -12 |-YODA > age # SIM300 - 12 |+age < YODA # SIM300 -13 13 | YODA >= age # SIM300 -14 14 | JediOrder.YODA == age # SIM300 -15 15 | 0 < (number - 100) # SIM300 - -SIM300.py:13:1: SIM300 [*] Yoda conditions are discouraged, use `age <= YODA` instead - | -11 | YODA == age # SIM300 -12 | YODA > age # SIM300 -13 | YODA >= age # SIM300 - | ^^^^^^^^^^^ SIM300 -14 | JediOrder.YODA == age # SIM300 -15 | 0 < (number - 100) # SIM300 - | - = help: Replace Yoda condition with `age <= YODA` - -ℹ Fix -10 10 | +42 > age # SIM300 -11 11 | YODA == age # SIM300 -12 12 | YODA > age # SIM300 -13 |-YODA >= age # SIM300 - 13 |+age <= YODA # SIM300 -14 14 | JediOrder.YODA == age # SIM300 -15 15 | 0 < (number - 100) # SIM300 -16 16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 - -SIM300.py:14:1: SIM300 [*] Yoda conditions are discouraged, use `age == JediOrder.YODA` instead - | -12 | YODA > age # SIM300 -13 | YODA >= age # SIM300 -14 | JediOrder.YODA == age # SIM300 - | ^^^^^^^^^^^^^^^^^^^^^ SIM300 -15 | 0 < (number - 100) # SIM300 -16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 - | - = help: Replace Yoda condition with `age == JediOrder.YODA` - -ℹ Fix -11 11 | YODA == age # SIM300 -12 12 | YODA > age # SIM300 -13 13 | YODA >= age # SIM300 -14 |-JediOrder.YODA == age # SIM300 - 14 |+age == JediOrder.YODA # SIM300 -15 15 | 0 < (number - 100) # SIM300 -16 16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 -17 17 | B 0` instead - | -13 | YODA >= age # SIM300 -14 | JediOrder.YODA == age # SIM300 -15 | 0 < (number - 100) # SIM300 - | ^^^^^^^^^^^^^^^^^^ SIM300 -16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 -17 | B 0` - -ℹ Fix -12 12 | YODA > age # SIM300 -13 13 | YODA >= age # SIM300 -14 14 | JediOrder.YODA == age # SIM300 -15 |-0 < (number - 100) # SIM300 - 15 |+(number - 100) > 0 # SIM300 -16 16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 -17 17 | B (60 * 60) # SIM300 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM300 -17 | B= age # SIM300 -14 14 | JediOrder.YODA == age # SIM300 -15 15 | 0 < (number - 100) # SIM300 -16 |-SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 - 16 |+(60 * 60) < SomeClass().settings.SOME_CONSTANT_VALUE # SIM300 -17 17 | B B` instead - | -15 | 0 < (number - 100) # SIM300 -16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 -17 | B B` - -ℹ Fix -14 14 | JediOrder.YODA == age # SIM300 -15 15 | 0 < (number - 100) # SIM300 -16 16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 -17 |-B B or B -18 18 | B or(B) (B)` instead - | -16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 -17 | B (B)` - -ℹ Fix -15 15 | 0 < (number - 100) # SIM300 -16 16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 -17 17 | B (B) -19 19 | -20 20 | # OK -21 21 | compare == "yoda" - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM401_SIM401.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM401_SIM401.py.snap deleted file mode 100644 index 9408fda39e..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM401_SIM401.py.snap +++ /dev/null @@ -1,162 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM401.py:6:1: SIM401 [*] Use `var = a_dict.get(key, "default1")` instead of an `if` block - | - 5 | # SIM401 (pattern-1) - 6 | / if key in a_dict: - 7 | | var = a_dict[key] - 8 | | else: - 9 | | var = "default1" - | |____________________^ SIM401 -10 | -11 | # SIM401 (pattern-2) - | - = help: Replace with `var = a_dict.get(key, "default1")` - -ℹ Suggested fix -3 3 | ### -4 4 | -5 5 | # SIM401 (pattern-1) -6 |-if key in a_dict: -7 |- var = a_dict[key] -8 |-else: -9 |- var = "default1" - 6 |+var = a_dict.get(key, "default1") -10 7 | -11 8 | # SIM401 (pattern-2) -12 9 | if key not in a_dict: - -SIM401.py:12:1: SIM401 [*] Use `var = a_dict.get(key, "default2")` instead of an `if` block - | -11 | # SIM401 (pattern-2) -12 | / if key not in a_dict: -13 | | var = "default2" -14 | | else: -15 | | var = a_dict[key] - | |_____________________^ SIM401 -16 | -17 | # OK (default contains effect) - | - = help: Replace with `var = a_dict.get(key, "default2")` - -ℹ Suggested fix -9 9 | var = "default1" -10 10 | -11 11 | # SIM401 (pattern-2) -12 |-if key not in a_dict: -13 |- var = "default2" -14 |-else: -15 |- var = a_dict[key] - 12 |+var = a_dict.get(key, "default2") -16 13 | -17 14 | # OK (default contains effect) -18 15 | if key in a_dict: - -SIM401.py:24:1: SIM401 [*] Use `var = a_dict.get(keys[idx], "default")` instead of an `if` block - | -23 | # SIM401 (complex expression in key) -24 | / if keys[idx] in a_dict: -25 | | var = a_dict[keys[idx]] -26 | | else: -27 | | var = "default" - | |___________________^ SIM401 -28 | -29 | # SIM401 (complex expression in dict) - | - = help: Replace with `var = a_dict.get(keys[idx], "default")` - -ℹ Suggested fix -21 21 | var = val1 + val2 -22 22 | -23 23 | # SIM401 (complex expression in key) -24 |-if keys[idx] in a_dict: -25 |- var = a_dict[keys[idx]] -26 |-else: -27 |- var = "default" - 24 |+var = a_dict.get(keys[idx], "default") -28 25 | -29 26 | # SIM401 (complex expression in dict) -30 27 | if key in dicts[idx]: - -SIM401.py:30:1: SIM401 [*] Use `var = dicts[idx].get(key, "default")` instead of an `if` block - | -29 | # SIM401 (complex expression in dict) -30 | / if key in dicts[idx]: -31 | | var = dicts[idx][key] -32 | | else: -33 | | var = "default" - | |___________________^ SIM401 -34 | -35 | # SIM401 (complex expression in var) - | - = help: Replace with `var = dicts[idx].get(key, "default")` - -ℹ Suggested fix -27 27 | var = "default" -28 28 | -29 29 | # SIM401 (complex expression in dict) -30 |-if key in dicts[idx]: -31 |- var = dicts[idx][key] -32 |-else: -33 |- var = "default" - 30 |+var = dicts[idx].get(key, "default") -34 31 | -35 32 | # SIM401 (complex expression in var) -36 33 | if key in a_dict: - -SIM401.py:36:1: SIM401 [*] Use `vars[idx] = a_dict.get(key, "defaultß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789")` instead of an `if` block - | -35 | # SIM401 (complex expression in var) -36 | / if key in a_dict: -37 | | vars[idx] = a_dict[key] -38 | | else: -39 | | vars[idx] = "defaultß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789" - | |___________________________________________________________________________^ SIM401 -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")` - -ℹ Suggested fix -33 33 | var = "default" -34 34 | -35 35 | # SIM401 (complex expression in var) -36 |-if key in a_dict: -37 |- vars[idx] = a_dict[key] -38 |-else: -39 |- vars[idx] = "defaultß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789" - 36 |+vars[idx] = a_dict.get(key, "defaultß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789") -40 37 | -41 38 | # SIM401 -42 39 | if foo(): - -SIM401.py:45:5: SIM401 [*] Use `vars[idx] = a_dict.get(key, "default")` instead of an `if` block - | -43 | pass -44 | else: -45 | if key in a_dict: - | _____^ -46 | | vars[idx] = a_dict[key] -47 | | else: -48 | | vars[idx] = "default" - | |_____________________________^ SIM401 -49 | -50 | ### - | - = help: Replace with `vars[idx] = a_dict.get(key, "default")` - -ℹ Suggested fix -42 42 | if foo(): -43 43 | pass -44 44 | else: -45 |- if key in a_dict: -46 |- vars[idx] = a_dict[key] -47 |- else: -48 |- vars[idx] = "default" - 45 |+ vars[idx] = a_dict.get(key, "default") -49 46 | -50 47 | ### -51 48 | # Negative cases - - diff --git a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM910_SIM910.py.snap b/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM910_SIM910.py.snap deleted file mode 100644 index ec96791486..0000000000 --- a/crates/ruff/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM910_SIM910.py.snap +++ /dev/null @@ -1,96 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_simplify/mod.rs ---- -SIM910.py:2:1: SIM910 [*] Use `{}.get(key)` instead of `{}.get(key, None)` - | -1 | # SIM910 -2 | {}.get(key, None) - | ^^^^^^^^^^^^^^^^^ SIM910 -3 | -4 | # SIM910 - | - = help: Replace `{}.get(key, None)` with `{}.get(key)` - -ℹ Fix -1 1 | # SIM910 -2 |-{}.get(key, None) - 2 |+{}.get(key) -3 3 | -4 4 | # SIM910 -5 5 | {}.get("key", None) - -SIM910.py:5:1: SIM910 [*] Use `{}.get("key")` instead of `{}.get("key", None)` - | -4 | # SIM910 -5 | {}.get("key", None) - | ^^^^^^^^^^^^^^^^^^^ SIM910 -6 | -7 | # OK - | - = help: Replace `{}.get("key", None)` with `{}.get("key")` - -ℹ Fix -2 2 | {}.get(key, None) -3 3 | -4 4 | # SIM910 -5 |-{}.get("key", None) - 5 |+{}.get("key") -6 6 | -7 7 | # OK -8 8 | {}.get(key) - -SIM910.py:20:9: SIM910 [*] Use `{}.get(key)` instead of `{}.get(key, None)` - | -19 | # SIM910 -20 | if a := {}.get(key, None): - | ^^^^^^^^^^^^^^^^^ SIM910 -21 | pass - | - = help: Replace `{}.get(key, None)` with `{}.get(key)` - -ℹ Fix -17 17 | {}.get("key", False) -18 18 | -19 19 | # SIM910 -20 |-if a := {}.get(key, None): - 20 |+if a := {}.get(key): -21 21 | pass -22 22 | -23 23 | # SIM910 - -SIM910.py:24:5: SIM910 [*] Use `{}.get(key)` instead of `{}.get(key, None)` - | -23 | # SIM910 -24 | a = {}.get(key, None) - | ^^^^^^^^^^^^^^^^^ SIM910 -25 | -26 | # SIM910 - | - = help: Replace `{}.get(key, None)` with `{}.get(key)` - -ℹ Fix -21 21 | pass -22 22 | -23 23 | # SIM910 -24 |-a = {}.get(key, None) - 24 |+a = {}.get(key) -25 25 | -26 26 | # SIM910 -27 27 | ({}).get(key, None) - -SIM910.py:27:1: SIM910 [*] Use `({}).get(key)` instead of `({}).get(key, None)` - | -26 | # SIM910 -27 | ({}).get(key, None) - | ^^^^^^^^^^^^^^^^^^^ SIM910 - | - = help: Replace `({}).get(key, None)` with `({}).get(key)` - -ℹ Fix -24 24 | a = {}.get(key, None) -25 25 | -26 26 | # SIM910 -27 |-({}).get(key, None) - 27 |+({}).get(key) - - diff --git a/crates/ruff/src/rules/flake8_slots/snapshots/ruff__rules__flake8_slots__tests__SLOT000_SLOT000.py.snap b/crates/ruff/src/rules/flake8_slots/snapshots/ruff__rules__flake8_slots__tests__SLOT000_SLOT000.py.snap deleted file mode 100644 index 70807294d3..0000000000 --- a/crates/ruff/src/rules/flake8_slots/snapshots/ruff__rules__flake8_slots__tests__SLOT000_SLOT000.py.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_slots/mod.rs ---- -SLOT000.py:1:7: SLOT000 Subclasses of `str` should define `__slots__` - | -1 | class Bad(str): # SLOT000 - | ^^^ SLOT000 -2 | pass - | - - diff --git a/crates/ruff/src/rules/flake8_slots/snapshots/ruff__rules__flake8_slots__tests__SLOT001_SLOT001.py.snap b/crates/ruff/src/rules/flake8_slots/snapshots/ruff__rules__flake8_slots__tests__SLOT001_SLOT001.py.snap deleted file mode 100644 index f0a8c0f9e8..0000000000 --- a/crates/ruff/src/rules/flake8_slots/snapshots/ruff__rules__flake8_slots__tests__SLOT001_SLOT001.py.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_slots/mod.rs ---- -SLOT001.py:1:7: SLOT001 Subclasses of `tuple` should define `__slots__` - | -1 | class Bad(tuple): # SLOT001 - | ^^^ SLOT001 -2 | pass - | - -SLOT001.py:12:7: SLOT001 Subclasses of `tuple` should define `__slots__` - | -12 | class Bad(Tuple): # SLOT001 - | ^^^ SLOT001 -13 | pass - | - -SLOT001.py:16:7: SLOT001 Subclasses of `tuple` should define `__slots__` - | -16 | class Bad(Tuple[str, int, float]): # SLOT001 - | ^^^ SLOT001 -17 | pass - | - - diff --git a/crates/ruff/src/rules/flake8_slots/snapshots/ruff__rules__flake8_slots__tests__SLOT002_SLOT002.py.snap b/crates/ruff/src/rules/flake8_slots/snapshots/ruff__rules__flake8_slots__tests__SLOT002_SLOT002.py.snap deleted file mode 100644 index 56ed809c2a..0000000000 --- a/crates/ruff/src/rules/flake8_slots/snapshots/ruff__rules__flake8_slots__tests__SLOT002_SLOT002.py.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_slots/mod.rs ---- -SLOT002.py:5:7: SLOT002 Subclasses of `collections.namedtuple()` should define `__slots__` - | -5 | class Bad(namedtuple("foo", ["str", "int"])): # SLOT002 - | ^^^ SLOT002 -6 | pass - | - - diff --git a/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__tests__ban_all_imports.snap b/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__tests__ban_all_imports.snap deleted file mode 100644 index d0c77373b8..0000000000 --- a/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__tests__ban_all_imports.snap +++ /dev/null @@ -1,192 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_tidy_imports/mod.rs ---- -TID252.py:7:1: TID252 Relative imports are banned - | -6 | # TID252 -7 | from . import sibling - | ^^^^^^^^^^^^^^^^^^^^^ TID252 -8 | from .sibling import example -9 | from .. import parent - | - = help: Replace relative imports with absolute imports - -TID252.py:8:1: TID252 Relative imports are banned - | - 6 | # TID252 - 7 | from . import sibling - 8 | from .sibling import example - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 - 9 | from .. import parent -10 | from ..parent import example - | - = help: Replace relative imports with absolute imports - -TID252.py:9:1: TID252 Relative imports are banned - | - 7 | from . import sibling - 8 | from .sibling import example - 9 | from .. import parent - | ^^^^^^^^^^^^^^^^^^^^^ TID252 -10 | from ..parent import example -11 | from ... import grandparent - | - = help: Replace relative imports with absolute imports - -TID252.py:10:1: TID252 Relative imports are banned - | - 8 | from .sibling import example - 9 | from .. import parent -10 | from ..parent import example - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -11 | from ... import grandparent -12 | from ...grandparent import example - | - = help: Replace relative imports with absolute imports - -TID252.py:11:1: TID252 Relative imports are banned - | - 9 | from .. import parent -10 | from ..parent import example -11 | from ... import grandparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -12 | from ...grandparent import example -13 | from .parent import hello - | - = help: Replace relative imports with absolute imports - -TID252.py:12:1: TID252 Relative imports are banned - | -10 | from ..parent import example -11 | from ... import grandparent -12 | from ...grandparent import example - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -13 | from .parent import hello -14 | from .\ - | - = help: Replace relative imports with absolute imports - -TID252.py:13:1: TID252 Relative imports are banned - | -11 | from ... import grandparent -12 | from ...grandparent import example -13 | from .parent import hello - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -14 | from .\ -15 | parent import \ - | - = help: Replace relative imports with absolute imports - -TID252.py:14:1: TID252 Relative imports are banned - | -12 | from ...grandparent import example -13 | from .parent import hello -14 | / from .\ -15 | | parent import \ -16 | | hello_world - | |___________________^ TID252 -17 | from \ -18 | ..parent\ - | - = help: Replace relative imports with absolute imports - -TID252.py:17:1: TID252 Relative imports are banned - | -15 | parent import \ -16 | hello_world -17 | / from \ -18 | | ..parent\ -19 | | import \ -20 | | world_hello - | |_______________^ TID252 -21 | from ..... import ultragrantparent -22 | from ...... import ultragrantparent - | - = help: Replace relative imports with absolute imports - -TID252.py:21:1: TID252 Relative imports are banned - | -19 | import \ -20 | world_hello -21 | from ..... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -22 | from ...... import ultragrantparent -23 | from ....... import ultragrantparent - | - = help: Replace relative imports with absolute imports - -TID252.py:22:1: TID252 Relative imports are banned - | -20 | world_hello -21 | from ..... import ultragrantparent -22 | from ...... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -23 | from ....... import ultragrantparent -24 | from ......... import ultragrantparent - | - = help: Replace relative imports with absolute imports - -TID252.py:23:1: TID252 Relative imports are banned - | -21 | from ..... import ultragrantparent -22 | from ...... import ultragrantparent -23 | from ....... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -24 | from ......... import ultragrantparent -25 | from ........................... import ultragrantparent - | - = help: Replace relative imports with absolute imports - -TID252.py:24:1: TID252 Relative imports are banned - | -22 | from ...... import ultragrantparent -23 | from ....... import ultragrantparent -24 | from ......... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -25 | from ........................... import ultragrantparent -26 | from .....parent import ultragrantparent - | - = help: Replace relative imports with absolute imports - -TID252.py:25:1: TID252 Relative imports are banned - | -23 | from ....... import ultragrantparent -24 | from ......... import ultragrantparent -25 | from ........................... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -26 | from .....parent import ultragrantparent -27 | from .........parent import ultragrantparent - | - = help: Replace relative imports with absolute imports - -TID252.py:26:1: TID252 Relative imports are banned - | -24 | from ......... import ultragrantparent -25 | from ........................... import ultragrantparent -26 | from .....parent import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -27 | from .........parent import ultragrantparent -28 | from ...........................parent import ultragrantparent - | - = help: Replace relative imports with absolute imports - -TID252.py:27:1: TID252 Relative imports are banned - | -25 | from ........................... import ultragrantparent -26 | from .....parent import ultragrantparent -27 | from .........parent import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -28 | from ...........................parent import ultragrantparent - | - = help: Replace relative imports with absolute imports - -TID252.py:28:1: TID252 Relative imports are banned - | -26 | from .....parent import ultragrantparent -27 | from .........parent import ultragrantparent -28 | from ...........................parent import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 - | - = help: Replace relative imports with absolute imports - - diff --git a/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__tests__ban_parent_imports.snap b/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__tests__ban_parent_imports.snap deleted file mode 100644 index 21d1448fbc..0000000000 --- a/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__tests__ban_parent_imports.snap +++ /dev/null @@ -1,147 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_tidy_imports/mod.rs ---- -TID252.py:9:1: TID252 Relative imports from parent modules are banned - | - 7 | from . import sibling - 8 | from .sibling import example - 9 | from .. import parent - | ^^^^^^^^^^^^^^^^^^^^^ TID252 -10 | from ..parent import example -11 | from ... import grandparent - | - = help: Replace relative imports from parent modules with absolute imports - -TID252.py:10:1: TID252 Relative imports from parent modules are banned - | - 8 | from .sibling import example - 9 | from .. import parent -10 | from ..parent import example - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -11 | from ... import grandparent -12 | from ...grandparent import example - | - = help: Replace relative imports from parent modules with absolute imports - -TID252.py:11:1: TID252 Relative imports from parent modules are banned - | - 9 | from .. import parent -10 | from ..parent import example -11 | from ... import grandparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -12 | from ...grandparent import example -13 | from .parent import hello - | - = help: Replace relative imports from parent modules with absolute imports - -TID252.py:12:1: TID252 Relative imports from parent modules are banned - | -10 | from ..parent import example -11 | from ... import grandparent -12 | from ...grandparent import example - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -13 | from .parent import hello -14 | from .\ - | - = help: Replace relative imports from parent modules with absolute imports - -TID252.py:17:1: TID252 Relative imports from parent modules are banned - | -15 | parent import \ -16 | hello_world -17 | / from \ -18 | | ..parent\ -19 | | import \ -20 | | world_hello - | |_______________^ TID252 -21 | from ..... import ultragrantparent -22 | from ...... import ultragrantparent - | - = help: Replace relative imports from parent modules with absolute imports - -TID252.py:21:1: TID252 Relative imports from parent modules are banned - | -19 | import \ -20 | world_hello -21 | from ..... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -22 | from ...... import ultragrantparent -23 | from ....... import ultragrantparent - | - = help: Replace relative imports from parent modules with absolute imports - -TID252.py:22:1: TID252 Relative imports from parent modules are banned - | -20 | world_hello -21 | from ..... import ultragrantparent -22 | from ...... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -23 | from ....... import ultragrantparent -24 | from ......... import ultragrantparent - | - = help: Replace relative imports from parent modules with absolute imports - -TID252.py:23:1: TID252 Relative imports from parent modules are banned - | -21 | from ..... import ultragrantparent -22 | from ...... import ultragrantparent -23 | from ....... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -24 | from ......... import ultragrantparent -25 | from ........................... import ultragrantparent - | - = help: Replace relative imports from parent modules with absolute imports - -TID252.py:24:1: TID252 Relative imports from parent modules are banned - | -22 | from ...... import ultragrantparent -23 | from ....... import ultragrantparent -24 | from ......... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -25 | from ........................... import ultragrantparent -26 | from .....parent import ultragrantparent - | - = help: Replace relative imports from parent modules with absolute imports - -TID252.py:25:1: TID252 Relative imports from parent modules are banned - | -23 | from ....... import ultragrantparent -24 | from ......... import ultragrantparent -25 | from ........................... import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -26 | from .....parent import ultragrantparent -27 | from .........parent import ultragrantparent - | - = help: Replace relative imports from parent modules with absolute imports - -TID252.py:26:1: TID252 Relative imports from parent modules are banned - | -24 | from ......... import ultragrantparent -25 | from ........................... import ultragrantparent -26 | from .....parent import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -27 | from .........parent import ultragrantparent -28 | from ...........................parent import ultragrantparent - | - = help: Replace relative imports from parent modules with absolute imports - -TID252.py:27:1: TID252 Relative imports from parent modules are banned - | -25 | from ........................... import ultragrantparent -26 | from .....parent import ultragrantparent -27 | from .........parent import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -28 | from ...........................parent import ultragrantparent - | - = help: Replace relative imports from parent modules with absolute imports - -TID252.py:28:1: TID252 Relative imports from parent modules are banned - | -26 | from .....parent import ultragrantparent -27 | from .........parent import ultragrantparent -28 | from ...........................parent import ultragrantparent - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 - | - = help: Replace relative imports from parent modules with absolute imports - - diff --git a/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__tests__ban_parent_imports_package.snap b/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__tests__ban_parent_imports_package.snap deleted file mode 100644 index 8f273255d8..0000000000 --- a/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__tests__ban_parent_imports_package.snap +++ /dev/null @@ -1,132 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_tidy_imports/mod.rs ---- -application.py:5:1: TID252 Relative imports from parent modules are banned - | -3 | import attrs -4 | -5 | from ....import unknown - | ^^^^^^^^^^^^^^^^^^^^^^^ TID252 -6 | from ..protocol import commands, definitions, responses -7 | from ..server import example - | - = help: Replace relative imports from parent modules with absolute imports - -application.py:6:1: TID252 [*] Relative imports from parent modules are banned - | -5 | from ....import unknown -6 | from ..protocol import commands, definitions, responses - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -7 | from ..server import example -8 | from .. import server - | - = help: Replace relative imports from parent modules with absolute imports - -ℹ Suggested fix -3 3 | import attrs -4 4 | -5 5 | from ....import unknown -6 |-from ..protocol import commands, definitions, responses - 6 |+from my_package.sublib.protocol import commands, definitions, responses -7 7 | from ..server import example -8 8 | from .. import server -9 9 | from . import logger, models - -application.py:6:1: TID252 [*] Relative imports from parent modules are banned - | -5 | from ....import unknown -6 | from ..protocol import commands, definitions, responses - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -7 | from ..server import example -8 | from .. import server - | - = help: Replace relative imports from parent modules with absolute imports - -ℹ Suggested fix -3 3 | import attrs -4 4 | -5 5 | from ....import unknown -6 |-from ..protocol import commands, definitions, responses - 6 |+from my_package.sublib.protocol import commands, definitions, responses -7 7 | from ..server import example -8 8 | from .. import server -9 9 | from . import logger, models - -application.py:6:1: TID252 [*] Relative imports from parent modules are banned - | -5 | from ....import unknown -6 | from ..protocol import commands, definitions, responses - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -7 | from ..server import example -8 | from .. import server - | - = help: Replace relative imports from parent modules with absolute imports - -ℹ Suggested fix -3 3 | import attrs -4 4 | -5 5 | from ....import unknown -6 |-from ..protocol import commands, definitions, responses - 6 |+from my_package.sublib.protocol import commands, definitions, responses -7 7 | from ..server import example -8 8 | from .. import server -9 9 | from . import logger, models - -application.py:7:1: TID252 [*] Relative imports from parent modules are banned - | -5 | from ....import unknown -6 | from ..protocol import commands, definitions, responses -7 | from ..server import example - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 -8 | from .. import server -9 | from . import logger, models - | - = help: Replace relative imports from parent modules with absolute imports - -ℹ Suggested fix -4 4 | -5 5 | from ....import unknown -6 6 | from ..protocol import commands, definitions, responses -7 |-from ..server import example - 7 |+from my_package.sublib.server import example -8 8 | from .. import server -9 9 | from . import logger, models -10 10 | from ..protocol.UpperCaseModule import some_function - -application.py:8:1: TID252 [*] Relative imports from parent modules are banned - | - 6 | from ..protocol import commands, definitions, responses - 7 | from ..server import example - 8 | from .. import server - | ^^^^^^^^^^^^^^^^^^^^^ TID252 - 9 | from . import logger, models -10 | from ..protocol.UpperCaseModule import some_function - | - = help: Replace relative imports from parent modules with absolute imports - -ℹ Suggested fix -5 5 | from ....import unknown -6 6 | from ..protocol import commands, definitions, responses -7 7 | from ..server import example -8 |-from .. import server - 8 |+from my_package.sublib import server -9 9 | from . import logger, models -10 10 | from ..protocol.UpperCaseModule import some_function - -application.py:10:1: TID252 [*] Relative imports from parent modules are banned - | - 8 | from .. import server - 9 | from . import logger, models -10 | from ..protocol.UpperCaseModule import some_function - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 - | - = help: Replace relative imports from parent modules with absolute imports - -ℹ Suggested fix -7 7 | from ..server import example -8 8 | from .. import server -9 9 | from . import logger, models -10 |-from ..protocol.UpperCaseModule import some_function - 10 |+from my_package.sublib.protocol.UpperCaseModule import some_function - - diff --git a/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__tests__banned_api.snap b/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__tests__banned_api.snap deleted file mode 100644 index 616f6dfbf8..0000000000 --- a/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__tests__banned_api.snap +++ /dev/null @@ -1,120 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_tidy_imports/mod.rs ---- -TID251.py:2:8: TID251 `cgi` is banned: The cgi module is deprecated. - | -1 | ## Banned modules ## -2 | import cgi - | ^^^ TID251 -3 | -4 | from cgi import * - | - -TID251.py:4:1: TID251 `cgi` is banned: The cgi module is deprecated. - | -2 | import cgi -3 | -4 | from cgi import * - | ^^^^^^^^^^^^^^^^^ TID251 -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 | -6 | from cgi import a, b, c - | ^^^^^^^^^^^^^^^^^^^^^^^ TID251 -7 | -8 | # banning a module also bans any submodules - | - -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 | -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 | -11 | from cgi.foo import bar - | ^^^^^^^^^^^^^^^^^^^^^^^ TID251 -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 | -13 | from cgi.foo.bar import * - | ^^^^^^^^^^^^^^^^^^^^^^^^^ TID251 -14 | -15 | ## Banned module members ## - | - -TID251.py:17:20: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. - | -15 | ## Banned module members ## -16 | -17 | from typing import TypedDict - | ^^^^^^^^^ TID251 -18 | -19 | import typing - | - -TID251.py:22:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. - | -21 | # attribute access is checked -22 | typing.TypedDict - | ^^^^^^^^^^^^^^^^ TID251 -23 | -24 | typing.TypedDict.anything - | - -TID251.py:24:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. - | -22 | typing.TypedDict -23 | -24 | typing.TypedDict.anything - | ^^^^^^^^^^^^^^^^ TID251 -25 | -26 | # function calls are checked - | - -TID251.py:27:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. - | -26 | # function calls are checked -27 | typing.TypedDict() - | ^^^^^^^^^^^^^^^^ TID251 -28 | -29 | typing.TypedDict.anything() - | - -TID251.py:29:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. - | -27 | typing.TypedDict() -28 | -29 | typing.TypedDict.anything() - | ^^^^^^^^^^^^^^^^ TID251 -30 | -31 | # import aliases are resolved - | - -TID251.py:33:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. - | -31 | # import aliases are resolved -32 | import typing as totally_not_typing -33 | totally_not_typing.TypedDict - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID251 -34 | -35 | # relative imports are respected - | - - diff --git a/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__tests__banned_api_package.snap b/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__tests__banned_api_package.snap deleted file mode 100644 index 5ab9b80996..0000000000 --- a/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__tests__banned_api_package.snap +++ /dev/null @@ -1,31 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_tidy_imports/mod.rs ---- -application.py:3:8: TID251 `attrs` is banned: The attrs module is deprecated. - | -1 | from typing import TYPE_CHECKING, Any, ClassVar -2 | -3 | import attrs - | ^^^^^ TID251 -4 | -5 | from ....import unknown - | - -application.py:6:1: TID251 `my_package.sublib.protocol` is banned: The protocol module is deprecated. - | -5 | from ....import unknown -6 | from ..protocol import commands, definitions, responses - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID251 -7 | from ..server import example -8 | from .. import server - | - -application.py:10:1: TID251 `my_package.sublib.protocol` is banned: The protocol module is deprecated. - | - 8 | from .. import server - 9 | from . import logger, models -10 | from ..protocol.UpperCaseModule import some_function - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID251 - | - - diff --git a/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__tests__banned_module_level_imports.snap b/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__tests__banned_module_level_imports.snap deleted file mode 100644 index 40bb5c9f58..0000000000 --- a/crates/ruff/src/rules/flake8_tidy_imports/snapshots/ruff__rules__flake8_tidy_imports__tests__banned_module_level_imports.snap +++ /dev/null @@ -1,81 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_tidy_imports/mod.rs ---- -TID253.py:2:8: TID253 `torch` is banned at the module level - | -1 | ## Banned modules ## -2 | import torch - | ^^^^^ TID253 -3 | -4 | from torch import * - | - -TID253.py:4:1: TID253 `torch` is banned at the module level - | -2 | import torch -3 | -4 | from torch import * - | ^^^^^^^^^^^^^^^^^^^ TID253 -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 | -6 | from tensorflow import a, b, c - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID253 -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 | - 8 | import torch as torch_wearing_a_trenchcoat - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID253 - 9 | -10 | # this should count as module level - | - -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 | -13 | # banning a module also bans any submodules - | - -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 | -16 | from tensorflow.foo import bar - | - -TID253.py:16:1: TID253 `tensorflow` is banned at the module level - | -14 | import torch.foo.bar -15 | -16 | from tensorflow.foo import bar - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID253 -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 | -18 | from torch.foo.bar import * - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID253 -19 | -20 | # unlike TID251, inline imports are *not* banned - | - - diff --git a/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__invalid-todo-capitalization_TD006.py.snap b/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__invalid-todo-capitalization_TD006.py.snap deleted file mode 100644 index e99b35d40b..0000000000 --- a/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__invalid-todo-capitalization_TD006.py.snap +++ /dev/null @@ -1,58 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_todos/mod.rs ---- -TD006.py:4:3: TD006 [*] Invalid TODO capitalization: `ToDo` should be `TODO` - | -2 | # TODO (evanrittenhouse): this is a valid TODO -3 | # TDO006 - error -4 | # ToDo (evanrittenhouse): invalid capitalization - | ^^^^ TD006 -5 | # todo (evanrittenhouse): another invalid capitalization -6 | # foo # todo: invalid capitalization - | - = help: Replace `ToDo` with `TODO` - -ℹ Fix -1 1 | # TDO006 - accepted -2 2 | # TODO (evanrittenhouse): this is a valid TODO -3 3 | # TDO006 - error -4 |-# ToDo (evanrittenhouse): invalid capitalization - 4 |+# TODO (evanrittenhouse): invalid capitalization -5 5 | # todo (evanrittenhouse): another invalid capitalization -6 6 | # foo # todo: invalid capitalization - -TD006.py:5:3: TD006 [*] Invalid TODO capitalization: `todo` should be `TODO` - | -3 | # TDO006 - error -4 | # ToDo (evanrittenhouse): invalid capitalization -5 | # todo (evanrittenhouse): another invalid capitalization - | ^^^^ TD006 -6 | # foo # todo: invalid capitalization - | - = help: Replace `todo` with `TODO` - -ℹ Fix -2 2 | # TODO (evanrittenhouse): this is a valid TODO -3 3 | # TDO006 - error -4 4 | # ToDo (evanrittenhouse): invalid capitalization -5 |-# todo (evanrittenhouse): another invalid capitalization - 5 |+# TODO (evanrittenhouse): another invalid capitalization -6 6 | # foo # todo: invalid capitalization - -TD006.py:6:9: TD006 [*] Invalid TODO capitalization: `todo` should be `TODO` - | -4 | # ToDo (evanrittenhouse): invalid capitalization -5 | # todo (evanrittenhouse): another invalid capitalization -6 | # foo # todo: invalid capitalization - | ^^^^ TD006 - | - = help: Replace `todo` with `TODO` - -ℹ Fix -3 3 | # TDO006 - error -4 4 | # ToDo (evanrittenhouse): invalid capitalization -5 5 | # todo (evanrittenhouse): another invalid capitalization -6 |-# foo # todo: invalid capitalization - 6 |+# foo # TODO: invalid capitalization - - diff --git a/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__invalid-todo-tag_TD001.py.snap b/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__invalid-todo-tag_TD001.py.snap deleted file mode 100644 index efbb2c4e6b..0000000000 --- a/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__invalid-todo-tag_TD001.py.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_todos/mod.rs ---- -TD001.py:7:3: TD001 Invalid TODO tag: `XXX` - | -6 | # T001 - errors -7 | # XXX (evanrittenhouse): this is not fine - | ^^^ TD001 -8 | # FIXME (evanrittenhouse): this is not fine -9 | # foo # XXX: this isn't fine either - | - -TD001.py:8:3: TD001 Invalid TODO tag: `FIXME` - | -6 | # T001 - errors -7 | # XXX (evanrittenhouse): this is not fine -8 | # FIXME (evanrittenhouse): this is not fine - | ^^^^^ TD001 -9 | # foo # XXX: this isn't fine either - | - -TD001.py:9:9: TD001 Invalid TODO tag: `XXX` - | -7 | # XXX (evanrittenhouse): this is not fine -8 | # FIXME (evanrittenhouse): this is not fine -9 | # foo # XXX: this isn't fine either - | ^^^ TD001 - | - - diff --git a/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__missing-space-after-todo-colon_TD007.py.snap b/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__missing-space-after-todo-colon_TD007.py.snap deleted file mode 100644 index ea62bdbd83..0000000000 --- a/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__missing-space-after-todo-colon_TD007.py.snap +++ /dev/null @@ -1,53 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_todos/mod.rs ---- -TD007.py:5:3: TD007 Missing space after colon in TODO - | -3 | # TODO: so does this -4 | # T007 - errors -5 | # TODO(evanrittenhouse):this has no space after a colon - | ^^^^ TD007 -6 | # TODO (evanrittenhouse):this doesn't either -7 | # TODO:neither does this - | - -TD007.py:6:3: TD007 Missing space after colon in TODO - | -4 | # T007 - errors -5 | # TODO(evanrittenhouse):this has no space after a colon -6 | # TODO (evanrittenhouse):this doesn't either - | ^^^^ TD007 -7 | # TODO:neither does this -8 | # FIXME:and lastly neither does this - | - -TD007.py:7:3: TD007 Missing space after colon in TODO - | -5 | # TODO(evanrittenhouse):this has no space after a colon -6 | # TODO (evanrittenhouse):this doesn't either -7 | # TODO:neither does this - | ^^^^ TD007 -8 | # FIXME:and lastly neither does this -9 | # foo # TODO:this is really the last one - | - -TD007.py:8:3: TD007 Missing space after colon in TODO - | - 6 | # TODO (evanrittenhouse):this doesn't either - 7 | # TODO:neither does this - 8 | # FIXME:and lastly neither does this - | ^^^^^ TD007 - 9 | # foo # TODO:this is really the last one -10 | # TODO this colon doesn't terminate the tag, so don't check it. https://www.google.com - | - -TD007.py:9:9: TD007 Missing space after colon in TODO - | - 7 | # TODO:neither does this - 8 | # FIXME:and lastly neither does this - 9 | # foo # TODO:this is really the last one - | ^^^^ TD007 -10 | # TODO this colon doesn't terminate the tag, so don't check it. https://www.google.com - | - - diff --git a/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__missing-todo-author_TD002.py.snap b/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__missing-todo-author_TD002.py.snap deleted file mode 100644 index f14a00cd5f..0000000000 --- a/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__missing-todo-author_TD002.py.snap +++ /dev/null @@ -1,41 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_todos/mod.rs ---- -TD002.py:11:3: TD002 Missing author in TODO; try: `# TODO(): ...` or `# TODO @: ...` - | - 9 | # TODO @mayrholu and more: this has an author -10 | # T002 - errors -11 | # TODO: this has no author - | ^^^^ TD002 -12 | # FIXME: neither does this -13 | # TODO : and neither does this - | - -TD002.py:12:3: TD002 Missing author in TODO; try: `# TODO(): ...` or `# TODO @: ...` - | -10 | # T002 - errors -11 | # TODO: this has no author -12 | # FIXME: neither does this - | ^^^^^ TD002 -13 | # TODO : and neither does this -14 | # foo # TODO: this doesn't either - | - -TD002.py:13:3: TD002 Missing author in TODO; try: `# TODO(): ...` or `# TODO @: ...` - | -11 | # TODO: this has no author -12 | # FIXME: neither does this -13 | # TODO : and neither does this - | ^^^^ TD002 -14 | # foo # TODO: this doesn't either - | - -TD002.py:14:9: TD002 Missing author in TODO; try: `# TODO(): ...` or `# TODO @: ...` - | -12 | # FIXME: neither does this -13 | # TODO : and neither does this -14 | # foo # TODO: this doesn't either - | ^^^^ TD002 - | - - diff --git a/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__missing-todo-colon_TD004.py.snap b/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__missing-todo-colon_TD004.py.snap deleted file mode 100644 index 539d7dd7dd..0000000000 --- a/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__missing-todo-colon_TD004.py.snap +++ /dev/null @@ -1,51 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_todos/mod.rs ---- -TD004.py:4:3: TD004 Missing colon in TODO - | -2 | # TODO(evanrittenhouse): this has a colon -3 | # T004 - errors -4 | # TODO this has no colon - | ^^^^ TD004 -5 | # TODO(evanrittenhouse 😀) this has no colon -6 | # FIXME add a colon - | - -TD004.py:5:3: TD004 Missing colon in TODO - | -3 | # T004 - errors -4 | # TODO this has no colon -5 | # TODO(evanrittenhouse 😀) this has no colon - | ^^^^ TD004 -6 | # FIXME add a colon -7 | # foo # TODO add a colon - | - -TD004.py:6:3: TD004 Missing colon in TODO - | -4 | # TODO this has no colon -5 | # TODO(evanrittenhouse 😀) this has no colon -6 | # FIXME add a colon - | ^^^^^ TD004 -7 | # foo # TODO add a colon -8 | # TODO this has a colon but it doesn't terminate the tag, so this should throw. https://www.google.com - | - -TD004.py:7:9: TD004 Missing colon in TODO - | -5 | # TODO(evanrittenhouse 😀) this has no colon -6 | # FIXME add a colon -7 | # foo # TODO add a colon - | ^^^^ TD004 -8 | # TODO this has a colon but it doesn't terminate the tag, so this should throw. https://www.google.com - | - -TD004.py:8:3: TD004 Missing colon in TODO - | -6 | # FIXME add a colon -7 | # foo # TODO add a colon -8 | # TODO this has a colon but it doesn't terminate the tag, so this should throw. https://www.google.com - | ^^^^ TD004 - | - - diff --git a/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__missing-todo-description_TD005.py.snap b/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__missing-todo-description_TD005.py.snap deleted file mode 100644 index 5fe476e021..0000000000 --- a/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__missing-todo-description_TD005.py.snap +++ /dev/null @@ -1,41 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_todos/mod.rs ---- -TD005.py:4:3: TD005 Missing issue description after `TODO` - | -2 | # TODO(evanrittenhouse): this has text, while the errors do not -3 | # T005 - errors -4 | # TODO(evanrittenhouse): - | ^^^^ TD005 -5 | # TODO(evanrittenhouse) -6 | # FIXME - | - -TD005.py:5:3: TD005 Missing issue description after `TODO` - | -3 | # T005 - errors -4 | # TODO(evanrittenhouse): -5 | # TODO(evanrittenhouse) - | ^^^^ TD005 -6 | # FIXME -7 | # foo # TODO - | - -TD005.py:6:3: TD005 Missing issue description after `TODO` - | -4 | # TODO(evanrittenhouse): -5 | # TODO(evanrittenhouse) -6 | # FIXME - | ^^^^^ TD005 -7 | # foo # TODO - | - -TD005.py:7:9: TD005 Missing issue description after `TODO` - | -5 | # TODO(evanrittenhouse) -6 | # FIXME -7 | # foo # TODO - | ^^^^ TD005 - | - - diff --git a/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__missing-todo-link_TD003.py.snap b/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__missing-todo-link_TD003.py.snap deleted file mode 100644 index 10f1a23b46..0000000000 --- a/crates/ruff/src/rules/flake8_todos/snapshots/ruff__rules__flake8_todos__tests__missing-todo-link_TD003.py.snap +++ /dev/null @@ -1,50 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_todos/mod.rs ---- -TD003.py:9:3: TD003 Missing issue link on the line following this TODO - | - 8 | # TDO003 - errors - 9 | # TODO: this comment has no - | ^^^^ TD003 -10 | # link after it - | - -TD003.py:12:3: TD003 Missing issue link on the line following this TODO - | -10 | # link after it -11 | -12 | # TODO: here's a TODO with no link after it - | ^^^^ TD003 -13 | def foo(x): -14 | return x - | - -TD003.py:25:3: TD003 Missing issue link on the line following this TODO - | -23 | # TDO-3870 -24 | -25 | # TODO: here's a TODO without an issue link - | ^^^^ TD003 -26 | # TODO: followed by a new TODO with an issue link -27 | # TDO-3870 - | - -TD003.py:29:9: TD003 Missing issue link on the line following this TODO - | -27 | # TDO-3870 -28 | -29 | # foo # TODO: no link! - | ^^^^ TD003 -30 | -31 | # TODO: here's a TODO on the last line with no link - | - -TD003.py:31:3: TD003 Missing issue link on the line following this TODO - | -29 | # foo # TODO: no link! -30 | -31 | # TODO: here's a TODO on the last line with no link - | ^^^^ TD003 - | - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__empty-type-checking-block_TCH005.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__empty-type-checking-block_TCH005.py.snap deleted file mode 100644 index 4d3f7db421..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__empty-type-checking-block_TCH005.py.snap +++ /dev/null @@ -1,99 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -TCH005.py:4:5: TCH005 [*] Found empty type-checking block - | -3 | if TYPE_CHECKING: -4 | pass # TCH005 - | ^^^^ TCH005 - | - = help: Delete empty type-checking block - -ℹ Fix -1 1 | from typing import TYPE_CHECKING, List -2 2 | -3 |-if TYPE_CHECKING: -4 |- pass # TCH005 -5 3 | -6 4 | -7 5 | if False: - -TCH005.py:8:5: TCH005 [*] Found empty type-checking block - | - 7 | if False: - 8 | pass # TCH005 - | ^^^^ TCH005 - 9 | -10 | if 0: - | - = help: Delete empty type-checking block - -ℹ Fix -4 4 | pass # TCH005 -5 5 | -6 6 | -7 |-if False: -8 |- pass # TCH005 -9 7 | -10 8 | if 0: -11 9 | pass # TCH005 - -TCH005.py:11:5: TCH005 [*] Found empty type-checking block - | -10 | if 0: -11 | pass # TCH005 - | ^^^^ TCH005 - | - = help: Delete empty type-checking block - -ℹ Fix -7 7 | if False: -8 8 | pass # TCH005 -9 9 | -10 |-if 0: -11 |- pass # TCH005 -12 10 | -13 11 | -14 12 | def example(): - -TCH005.py:16:9: TCH005 [*] Found empty type-checking block - | -14 | def example(): -15 | if TYPE_CHECKING: -16 | pass # TCH005 - | ^^^^ TCH005 -17 | return - | - = help: Delete empty type-checking block - -ℹ Fix -12 12 | -13 13 | -14 14 | def example(): -15 |- if TYPE_CHECKING: -16 |- pass # TCH005 -17 15 | return -18 16 | -19 17 | - -TCH005.py:22:9: TCH005 [*] Found empty type-checking block - | -20 | class Test: -21 | if TYPE_CHECKING: -22 | pass # TCH005 - | ^^^^ TCH005 -23 | x = 2 - | - = help: Delete empty type-checking block - -ℹ Fix -18 18 | -19 19 | -20 20 | class Test: -21 |- if TYPE_CHECKING: -22 |- pass # TCH005 -23 21 | x = 2 -24 22 | -25 23 | - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__exempt_modules.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__exempt_modules.snap deleted file mode 100644 index b2be893e98..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__exempt_modules.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -exempt_modules.py:14:12: TCH002 [*] Move third-party import `flask` into a type-checking block - | -13 | def f(): -14 | import flask - | ^^^^^ TCH002 -15 | -16 | x: flask - | - = help: Move into type-checking block - -ℹ Suggested fix - 1 |+from typing import TYPE_CHECKING - 2 |+ - 3 |+if TYPE_CHECKING: - 4 |+ import flask -1 5 | def f(): -2 6 | import pandas as pd -3 7 | --------------------------------------------------------------------------------- -11 15 | -12 16 | -13 17 | def f(): -14 |- import flask -15 18 | -16 19 | x: flask - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__import_from.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__import_from.snap deleted file mode 100644 index c4108f63e8..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__import_from.snap +++ /dev/null @@ -1,31 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -:5:5: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block - | -4 | from pandas import ( -5 | DataFrame, # DataFrame - | ^^^^^^^^^ TCH002 -6 | Series, # Series -7 | ) - | - = help: Move into type-checking block - -ℹ Suggested fix -2 2 | from __future__ import annotations -3 3 | -4 4 | from pandas import ( -5 |- DataFrame, # DataFrame -6 5 | Series, # Series -7 6 | ) - 7 |+from typing import TYPE_CHECKING - 8 |+ - 9 |+if TYPE_CHECKING: - 10 |+ from pandas import ( - 11 |+ DataFrame, # DataFrame - 12 |+ ) -8 13 | -9 14 | def f(x: DataFrame): -10 15 | pass - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__import_from_type_checking_block.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__import_from_type_checking_block.snap deleted file mode 100644 index e25e00301c..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__import_from_type_checking_block.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -:7:5: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block - | -6 | from pandas import ( -7 | DataFrame, # DataFrame - | ^^^^^^^^^ TCH002 -8 | Series, # Series -9 | ) - | - = help: Move into type-checking block - -ℹ Suggested fix -4 4 | from typing import TYPE_CHECKING -5 5 | -6 6 | from pandas import ( -7 |- DataFrame, # DataFrame -8 7 | Series, # Series -9 8 | ) -10 9 | -11 10 | if TYPE_CHECKING: - 11 |+ from pandas import ( - 12 |+ DataFrame, # DataFrame - 13 |+ ) -12 14 | import os -13 15 | -14 16 | def f(x: DataFrame): - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__multiple_members.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__multiple_members.snap deleted file mode 100644 index 964a13b9a0..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__multiple_members.snap +++ /dev/null @@ -1,60 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -:7:5: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block - | -6 | from pandas import ( -7 | DataFrame, # DataFrame - | ^^^^^^^^^ TCH002 -8 | Series, # Series -9 | ) - | - = help: Move into type-checking block - -ℹ Suggested fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-from pandas import ( -7 |- DataFrame, # DataFrame -8 |- Series, # Series -9 |-) -10 6 | - 7 |+if TYPE_CHECKING: - 8 |+ from pandas import ( - 9 |+ DataFrame, # DataFrame - 10 |+ Series, # Series - 11 |+ ) - 12 |+ -11 13 | def f(x: DataFrame, y: Series): -12 14 | pass - -:8:5: TCH002 [*] Move third-party import `pandas.Series` into a type-checking block - | -6 | from pandas import ( -7 | DataFrame, # DataFrame -8 | Series, # Series - | ^^^^^^ TCH002 -9 | ) - | - = help: Move into type-checking block - -ℹ Suggested fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-from pandas import ( -7 |- DataFrame, # DataFrame -8 |- Series, # Series -9 |-) -10 6 | - 7 |+if TYPE_CHECKING: - 8 |+ from pandas import ( - 9 |+ DataFrame, # DataFrame - 10 |+ Series, # Series - 11 |+ ) - 12 |+ -11 13 | def f(x: DataFrame, y: Series): -12 14 | pass - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__multiple_modules_different_types.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__multiple_modules_different_types.snap deleted file mode 100644 index c8b5366a61..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__multiple_modules_different_types.snap +++ /dev/null @@ -1,52 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -:6:8: TCH003 [*] Move standard library import `os` into a type-checking block - | -4 | from typing import TYPE_CHECKING -5 | -6 | import os, pandas - | ^^ TCH003 -7 | -8 | def f(x: os, y: pandas): - | - = help: Move into type-checking block - -ℹ Suggested fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-import os, pandas - 6 |+import pandas - 7 |+ - 8 |+if TYPE_CHECKING: - 9 |+ import os -7 10 | -8 11 | def f(x: os, y: pandas): -9 12 | pass - -:6:12: TCH002 [*] Move third-party import `pandas` into a type-checking block - | -4 | from typing import TYPE_CHECKING -5 | -6 | import os, pandas - | ^^^^^^ TCH002 -7 | -8 | def f(x: os, y: pandas): - | - = help: Move into type-checking block - -ℹ Suggested fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-import os, pandas - 6 |+import os - 7 |+ - 8 |+if TYPE_CHECKING: - 9 |+ import pandas -7 10 | -8 11 | def f(x: os, y: pandas): -9 12 | pass - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__multiple_modules_same_type.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__multiple_modules_same_type.snap deleted file mode 100644 index 113e734c65..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__multiple_modules_same_type.snap +++ /dev/null @@ -1,50 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -:6:8: TCH003 [*] Move standard library import `os` into a type-checking block - | -4 | from typing import TYPE_CHECKING -5 | -6 | import os, sys - | ^^ TCH003 -7 | -8 | def f(x: os, y: sys): - | - = help: Move into type-checking block - -ℹ Suggested fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-import os, sys -7 6 | - 7 |+if TYPE_CHECKING: - 8 |+ import os, sys - 9 |+ -8 10 | def f(x: os, y: sys): -9 11 | pass - -:6:12: TCH003 [*] Move standard library import `sys` into a type-checking block - | -4 | from typing import TYPE_CHECKING -5 | -6 | import os, sys - | ^^^ TCH003 -7 | -8 | def f(x: os, y: sys): - | - = help: Move into type-checking block - -ℹ Suggested fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-import os, sys -7 6 | - 7 |+if TYPE_CHECKING: - 8 |+ import os, sys - 9 |+ -8 10 | def f(x: os, y: sys): -9 11 | pass - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__no_typing_import.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__no_typing_import.snap deleted file mode 100644 index 51e4ecc7c4..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__no_typing_import.snap +++ /dev/null @@ -1,28 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -:4:18: TCH002 [*] Move third-party import `pandas` into a type-checking block - | -2 | from __future__ import annotations -3 | -4 | import pandas as pd - | ^^ TCH002 -5 | -6 | def f(x: pd.DataFrame): - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | -2 2 | from __future__ import annotations -3 3 | -4 |-import pandas as pd - 4 |+from typing import TYPE_CHECKING - 5 |+ - 6 |+if TYPE_CHECKING: - 7 |+ import pandas as pd -5 8 | -6 9 | def f(x: pd.DataFrame): -7 10 | pass - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_1.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_1.py.snap deleted file mode 100644 index e2122ee3b2..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_1.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -TCH004_1.py:4:26: TCH004 [*] Move import `datetime.datetime` out of type-checking block. Import is used for more than type hinting. - | -3 | if TYPE_CHECKING: -4 | from datetime import datetime - | ^^^^^^^^ TCH004 -5 | x = datetime - | - = help: Move out of type-checking block - -ℹ Suggested fix -1 1 | from typing import TYPE_CHECKING - 2 |+from datetime import datetime -2 3 | -3 4 | if TYPE_CHECKING: -4 |- from datetime import datetime - 5 |+ pass -5 6 | x = datetime - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_10.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_10.py.snap deleted file mode 100644 index abbbb06448..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_10.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_11.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_11.py.snap deleted file mode 100644 index ad9d9f099d..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_11.py.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -TCH004_11.py:4:24: TCH004 [*] 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 - | ^^^^ TCH004 -5 | -6 | __all__ = ("List",) - | - = help: Move out of type-checking block - -ℹ Suggested fix -1 1 | from typing import TYPE_CHECKING - 2 |+from typing import List -2 3 | -3 4 | if TYPE_CHECKING: -4 |- from typing import List - 5 |+ pass -5 6 | -6 7 | __all__ = ("List",) - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_12.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_12.py.snap deleted file mode 100644 index 78e4f36491..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_12.py.snap +++ /dev/null @@ -1,26 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -TCH004_12.py:6:33: TCH004 [*] 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 - | ^^^^^^^^ TCH004 -7 | -8 | AnyCallable: TypeAlias = Callable[..., Any] - | - = help: Move out of type-checking block - -ℹ Suggested fix -1 1 | from __future__ import annotations -2 2 | -3 3 | from typing import Any, TYPE_CHECKING, TypeAlias - 4 |+from collections.abc import Callable -4 5 | -5 6 | if TYPE_CHECKING: -6 |- from collections.abc import Callable - 7 |+ pass -7 8 | -8 9 | AnyCallable: TypeAlias = Callable[..., Any] - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_13.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_13.py.snap deleted file mode 100644 index abbbb06448..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_13.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_14.pyi.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_14.pyi.snap deleted file mode 100644 index abbbb06448..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_14.pyi.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_2.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_2.py.snap deleted file mode 100644 index c8a4f0c035..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_2.py.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -TCH004_2.py:4:26: TCH004 [*] Move import `datetime.date` out of type-checking block. Import is used for more than type hinting. - | -3 | if TYPE_CHECKING: -4 | from datetime import date - | ^^^^ TCH004 - | - = help: Move out of type-checking block - -ℹ Suggested fix -1 1 | from typing import TYPE_CHECKING - 2 |+from datetime import date -2 3 | -3 4 | if TYPE_CHECKING: -4 |- from datetime import date - 5 |+ pass -5 6 | -6 7 | -7 8 | def example(): - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_3.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_3.py.snap deleted file mode 100644 index abbbb06448..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_3.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_4.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_4.py.snap deleted file mode 100644 index e16a269d3a..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_4.py.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -TCH004_4.py:4:24: TCH004 [*] Move import `typing.Any` out of type-checking block. Import is used for more than type hinting. - | -3 | if TYPE_CHECKING: -4 | from typing import Any - | ^^^ TCH004 - | - = help: Move out of type-checking block - -ℹ Suggested fix -1 1 | from typing import TYPE_CHECKING, Type - 2 |+from typing import Any -2 3 | -3 4 | if TYPE_CHECKING: -4 |- from typing import Any - 5 |+ pass -5 6 | -6 7 | -7 8 | def example(*args: Any, **kwargs: Any): - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_5.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_5.py.snap deleted file mode 100644 index dc83a618b7..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_5.py.snap +++ /dev/null @@ -1,61 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -TCH004_5.py:4:24: TCH004 [*] 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, Sequence, Set - | ^^^^ TCH004 - | - = help: Move out of type-checking block - -ℹ Suggested fix -1 1 | from typing import TYPE_CHECKING - 2 |+from typing import List, Sequence, Set -2 3 | -3 4 | if TYPE_CHECKING: -4 |- from typing import List, Sequence, Set - 5 |+ pass -5 6 | -6 7 | -7 8 | def example(a: List[int], /, b: Sequence[int], *, c: Set[int]): - -TCH004_5.py:4:30: TCH004 [*] Move import `typing.Sequence` out of type-checking block. Import is used for more than type hinting. - | -3 | if TYPE_CHECKING: -4 | from typing import List, Sequence, Set - | ^^^^^^^^ TCH004 - | - = help: Move out of type-checking block - -ℹ Suggested fix -1 1 | from typing import TYPE_CHECKING - 2 |+from typing import List, Sequence, Set -2 3 | -3 4 | if TYPE_CHECKING: -4 |- from typing import List, Sequence, Set - 5 |+ pass -5 6 | -6 7 | -7 8 | def example(a: List[int], /, b: Sequence[int], *, c: Set[int]): - -TCH004_5.py:4:40: TCH004 [*] Move import `typing.Set` out of type-checking block. Import is used for more than type hinting. - | -3 | if TYPE_CHECKING: -4 | from typing import List, Sequence, Set - | ^^^ TCH004 - | - = help: Move out of type-checking block - -ℹ Suggested fix -1 1 | from typing import TYPE_CHECKING - 2 |+from typing import List, Sequence, Set -2 3 | -3 4 | if TYPE_CHECKING: -4 |- from typing import List, Sequence, Set - 5 |+ pass -5 6 | -6 7 | -7 8 | def example(a: List[int], /, b: Sequence[int], *, c: Set[int]): - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_6.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_6.py.snap deleted file mode 100644 index abbbb06448..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_6.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_7.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_7.py.snap deleted file mode 100644 index abbbb06448..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_7.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_8.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_8.py.snap deleted file mode 100644 index abbbb06448..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_8.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_9.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_9.py.snap deleted file mode 100644 index 87149f0c5d..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_9.py.snap +++ /dev/null @@ -1,46 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -TCH004_9.py:4:24: TCH004 [*] 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 - | ^^^^^ TCH004 -5 | -6 | x: Tuple - | - = help: Move out of type-checking block - -ℹ Suggested fix -1 1 | from typing import TYPE_CHECKING - 2 |+from typing import Tuple, List -2 3 | -3 4 | if TYPE_CHECKING: -4 |- from typing import Tuple, List, Dict - 5 |+ from typing import Dict -5 6 | -6 7 | x: Tuple -7 8 | - -TCH004_9.py:4:31: TCH004 [*] 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 Tuple, List, Dict - | ^^^^ TCH004 -5 | -6 | x: Tuple - | - = help: Move out of type-checking block - -ℹ Suggested fix -1 1 | from typing import TYPE_CHECKING - 2 |+from typing import Tuple, List -2 3 | -3 4 | if TYPE_CHECKING: -4 |- from typing import Tuple, List, Dict - 5 |+ from typing import Dict -5 6 | -6 7 | x: Tuple -7 8 | - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_base_classes_1.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_base_classes_1.py.snap deleted file mode 100644 index c90269a7ef..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_base_classes_1.py.snap +++ /dev/null @@ -1,74 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -runtime_evaluated_base_classes_1.py:10:12: TCH004 [*] Move import `datetime` out of type-checking block. Import is used for more than type hinting. - | - 9 | if TYPE_CHECKING: -10 | import datetime # TCH004 - | ^^^^^^^^ TCH004 -11 | from array import array # TCH004 - | - = help: Move out of type-checking block - -ℹ Suggested fix -5 5 | -6 6 | import pydantic -7 7 | from pydantic import BaseModel - 8 |+import datetime -8 9 | -9 10 | if TYPE_CHECKING: -10 |- import datetime # TCH004 -11 11 | from array import array # TCH004 -12 12 | -13 13 | import pandas # TCH004 - -runtime_evaluated_base_classes_1.py:11:23: TCH004 [*] Move import `array.array` out of type-checking block. Import is used for more than type hinting. - | - 9 | if TYPE_CHECKING: -10 | import datetime # TCH004 -11 | from array import array # TCH004 - | ^^^^^ TCH004 -12 | -13 | import pandas # TCH004 - | - = help: Move out of type-checking block - -ℹ Suggested fix -5 5 | -6 6 | import pydantic -7 7 | from pydantic import BaseModel - 8 |+from array import array -8 9 | -9 10 | if TYPE_CHECKING: -10 11 | import datetime # TCH004 -11 |- from array import array # TCH004 -12 12 | -13 13 | import pandas # TCH004 -14 14 | import pyproj - -runtime_evaluated_base_classes_1.py:13:12: TCH004 [*] Move import `pandas` out of type-checking block. Import is used for more than type hinting. - | -11 | from array import array # TCH004 -12 | -13 | import pandas # TCH004 - | ^^^^^^ TCH004 -14 | import pyproj - | - = help: Move out of type-checking block - -ℹ Suggested fix -5 5 | -6 6 | import pydantic -7 7 | from pydantic import BaseModel - 8 |+import pandas -8 9 | -9 10 | if TYPE_CHECKING: -10 11 | import datetime # TCH004 -11 12 | from array import array # TCH004 -12 13 | -13 |- import pandas # TCH004 -14 14 | import pyproj -15 15 | -16 16 | - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_decorators_1.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_decorators_1.py.snap deleted file mode 100644 index 004da0e492..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_runtime_evaluated_decorators_1.py.snap +++ /dev/null @@ -1,74 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -runtime_evaluated_decorators_1.py:12:12: TCH004 [*] Move import `datetime` out of type-checking block. Import is used for more than type hinting. - | -11 | if TYPE_CHECKING: -12 | import datetime # TCH004 - | ^^^^^^^^ TCH004 -13 | from array import array # TCH004 - | - = help: Move out of type-checking block - -ℹ Suggested fix -7 7 | from attrs import frozen -8 8 | -9 9 | import numpy - 10 |+import datetime -10 11 | -11 12 | if TYPE_CHECKING: -12 |- import datetime # TCH004 -13 13 | from array import array # TCH004 -14 14 | -15 15 | import pandas # TCH004 - -runtime_evaluated_decorators_1.py:13:23: TCH004 [*] Move import `array.array` out of type-checking block. Import is used for more than type hinting. - | -11 | if TYPE_CHECKING: -12 | import datetime # TCH004 -13 | from array import array # TCH004 - | ^^^^^ TCH004 -14 | -15 | import pandas # TCH004 - | - = help: Move out of type-checking block - -ℹ Suggested fix -7 7 | from attrs import frozen -8 8 | -9 9 | import numpy - 10 |+from array import array -10 11 | -11 12 | if TYPE_CHECKING: -12 13 | import datetime # TCH004 -13 |- from array import array # TCH004 -14 14 | -15 15 | import pandas # TCH004 -16 16 | import pyproj - -runtime_evaluated_decorators_1.py:15:12: TCH004 [*] Move import `pandas` out of type-checking block. Import is used for more than type hinting. - | -13 | from array import array # TCH004 -14 | -15 | import pandas # TCH004 - | ^^^^^^ TCH004 -16 | import pyproj - | - = help: Move out of type-checking block - -ℹ Suggested fix -7 7 | from attrs import frozen -8 8 | -9 9 | import numpy - 10 |+import pandas -10 11 | -11 12 | if TYPE_CHECKING: -12 13 | import datetime # TCH004 -13 14 | from array import array # TCH004 -14 15 | -15 |- import pandas # TCH004 -16 16 | import pyproj -17 17 | -18 18 | - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__strict.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__strict.snap deleted file mode 100644 index 9ef1a60a95..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__strict.snap +++ /dev/null @@ -1,233 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -strict.py:27:21: TCH002 [*] Move third-party import `pkg.A` into a type-checking block - | -25 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime. -26 | import pkg -27 | from pkg import A - | ^ TCH002 -28 | -29 | def test(value: A): - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ from pkg import A -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -24 28 | def f(): -25 29 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime. -26 30 | import pkg -27 |- from pkg import A -28 31 | -29 32 | def test(value: A): -30 33 | return pkg.B() - -strict.py:35:21: TCH002 [*] Move third-party import `pkg.A` into a type-checking block - | -33 | def f(): -34 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime. -35 | from pkg import A, B - | ^ TCH002 -36 | -37 | def test(value: A): - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ from pkg import A -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -32 36 | -33 37 | def f(): -34 38 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime. -35 |- from pkg import A, B - 39 |+ from pkg import B -36 40 | -37 41 | def test(value: A): -38 42 | return B() - -strict.py:54:25: TCH002 [*] Move third-party import `pkg.bar.A` into a type-checking block - | -52 | # In un-strict mode, this _should_ raise an error, since `pkg.bar` isn't used at runtime -53 | import pkg -54 | from pkg.bar import A - | ^ TCH002 -55 | -56 | def test(value: A): - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ from pkg.bar import A -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -51 55 | def f(): -52 56 | # In un-strict mode, this _should_ raise an error, since `pkg.bar` isn't used at runtime -53 57 | import pkg -54 |- from pkg.bar import A -55 58 | -56 59 | def test(value: A): -57 60 | return pkg.B() - -strict.py:62:12: TCH002 [*] Move third-party import `pkg` into a type-checking block - | -60 | def f(): -61 | # In un-strict mode, this shouldn't raise an error, since `pkg.bar` is used at runtime. -62 | import pkg - | ^^^ TCH002 -63 | import pkg.bar as B - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pkg -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -59 63 | -60 64 | def f(): -61 65 | # In un-strict mode, this shouldn't raise an error, since `pkg.bar` is used at runtime. -62 |- import pkg -63 66 | import pkg.bar as B -64 67 | -65 68 | def test(value: pkg.A): - -strict.py:71:23: TCH002 [*] Move third-party import `pkg.foo` into a type-checking block - | -69 | def f(): -70 | # In un-strict mode, this shouldn't raise an error, since `pkg.foo.bar` is used at runtime. -71 | import pkg.foo as F - | ^ TCH002 -72 | import pkg.foo.bar as B - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pkg.foo as F -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -68 72 | -69 73 | def f(): -70 74 | # In un-strict mode, this shouldn't raise an error, since `pkg.foo.bar` is used at runtime. -71 |- import pkg.foo as F -72 75 | import pkg.foo.bar as B -73 76 | -74 77 | def test(value: F.Foo): - -strict.py:80:12: TCH002 [*] Move third-party import `pkg` into a type-checking block - | -78 | def f(): -79 | # In un-strict mode, this shouldn't raise an error, since `pkg.foo.bar` is used at runtime. -80 | import pkg - | ^^^ TCH002 -81 | import pkg.foo.bar as B - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pkg -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -77 81 | -78 82 | def f(): -79 83 | # In un-strict mode, this shouldn't raise an error, since `pkg.foo.bar` is used at runtime. -80 |- import pkg -81 84 | import pkg.foo.bar as B -82 85 | -83 86 | def test(value: pkg.A): - -strict.py:91:12: TCH002 [*] Move third-party import `pkg` into a type-checking block - | -89 | # Note that `pkg` is a prefix of `pkgfoo` which are both different modules. This is -90 | # testing the implementation. -91 | import pkg - | ^^^ TCH002 -92 | import pkgfoo.bar as B - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pkg -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -88 92 | # In un-strict mode, this _should_ raise an error, since `pkg` isn't used at runtime. -89 93 | # Note that `pkg` is a prefix of `pkgfoo` which are both different modules. This is -90 94 | # testing the implementation. -91 |- import pkg -92 95 | import pkgfoo.bar as B -93 96 | -94 97 | def test(value: pkg.A): - -strict.py:101:23: TCH002 [*] Move third-party import `pkg.foo` into a type-checking block - | - 99 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime. -100 | import pkg.bar as B -101 | import pkg.foo as F - | ^ TCH002 -102 | -103 | def test(value: F.Foo): - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pkg.foo as F -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -98 102 | def f(): -99 103 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime. -100 104 | import pkg.bar as B -101 |- import pkg.foo as F -102 105 | -103 106 | def test(value: F.Foo): -104 107 | return B.Bar() - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__type_checking_block_after_usage.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__type_checking_block_after_usage.snap deleted file mode 100644 index 8eb591e7db..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__type_checking_block_after_usage.snap +++ /dev/null @@ -1,28 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -:6:18: TCH002 [*] Move third-party import `pandas` into a type-checking block - | -4 | from typing import TYPE_CHECKING -5 | -6 | import pandas as pd - | ^^ TCH002 -7 | -8 | def f(x: pd.DataFrame): - | - = help: Move into type-checking block - -ℹ Suggested fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-import pandas as pd -7 6 | - 7 |+if TYPE_CHECKING: - 8 |+ import pandas as pd - 9 |+ -8 10 | def f(x: pd.DataFrame): -9 11 | pass -10 12 | - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__type_checking_block_comment.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__type_checking_block_comment.snap deleted file mode 100644 index 43ed4cbe88..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__type_checking_block_comment.snap +++ /dev/null @@ -1,28 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -:6:18: TCH002 [*] Move third-party import `pandas` into a type-checking block - | -4 | from typing import TYPE_CHECKING -5 | -6 | import pandas as pd - | ^^ TCH002 -7 | -8 | if TYPE_CHECKING: - | - = help: Move into type-checking block - -ℹ Suggested fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-import pandas as pd -7 6 | -8 7 | if TYPE_CHECKING: -9 8 | # This is a comment. - 9 |+ import pandas as pd -10 10 | import os -11 11 | -12 12 | def f(x: pd.DataFrame): - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__type_checking_block_inline.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__type_checking_block_inline.snap deleted file mode 100644 index 983345aae9..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__type_checking_block_inline.snap +++ /dev/null @@ -1,27 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -:6:18: TCH002 [*] Move third-party import `pandas` into a type-checking block - | -4 | from typing import TYPE_CHECKING -5 | -6 | import pandas as pd - | ^^ TCH002 -7 | -8 | if TYPE_CHECKING: import os - | - = help: Move into type-checking block - -ℹ Suggested fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-import pandas as pd -7 6 | -8 |-if TYPE_CHECKING: import os - 7 |+if TYPE_CHECKING: import pandas as pd; import os -9 8 | -10 9 | def f(x: pd.DataFrame): -11 10 | pass - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__type_checking_block_own_line.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__type_checking_block_own_line.snap deleted file mode 100644 index 4246c582dc..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__type_checking_block_own_line.snap +++ /dev/null @@ -1,27 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -:6:18: TCH002 [*] Move third-party import `pandas` into a type-checking block - | -4 | from typing import TYPE_CHECKING -5 | -6 | import pandas as pd - | ^^ TCH002 -7 | -8 | if TYPE_CHECKING: - | - = help: Move into type-checking block - -ℹ Suggested fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-import pandas as pd -7 6 | -8 7 | if TYPE_CHECKING: - 8 |+ import pandas as pd -9 9 | import os -10 10 | -11 11 | def f(x: pd.DataFrame): - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-first-party-import_TCH001.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-first-party-import_TCH001.py.snap deleted file mode 100644 index f4e212bced..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-first-party-import_TCH001.py.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -TCH001.py:20:19: TCH001 [*] Move application import `.TYP001` into a type-checking block - | -19 | def f(): -20 | from . import TYP001 - | ^^^^^^ TCH001 -21 | -22 | x: TYP001 - | - = help: Move into type-checking block - -ℹ Suggested fix -2 2 | -3 3 | For typing-only import detection tests, see `TCH002.py`. -4 4 | """ - 5 |+from typing import TYPE_CHECKING - 6 |+ - 7 |+if TYPE_CHECKING: - 8 |+ from . import TYP001 -5 9 | -6 10 | -7 11 | def f(): --------------------------------------------------------------------------------- -17 21 | -18 22 | -19 23 | def f(): -20 |- from . import TYP001 -21 24 | -22 25 | x: TYP001 -23 26 | - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-standard-library-import_TCH003.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-standard-library-import_TCH003.py.snap deleted file mode 100644 index ed9d200e33..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-standard-library-import_TCH003.py.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -TCH003.py:8:12: TCH003 [*] Move standard library import `os` into a type-checking block - | - 7 | def f(): - 8 | import os - | ^^ TCH003 - 9 | -10 | x: os - | - = help: Move into type-checking block - -ℹ Suggested fix -2 2 | -3 3 | For typing-only import detection tests, see `TCH002.py`. -4 4 | """ - 5 |+from typing import TYPE_CHECKING - 6 |+ - 7 |+if TYPE_CHECKING: - 8 |+ import os -5 9 | -6 10 | -7 11 | def f(): -8 |- import os -9 12 | -10 13 | x: os -11 14 | - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_base_classes_3.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_base_classes_3.py.snap deleted file mode 100644 index 1a60cf77ae..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_base_classes_3.py.snap +++ /dev/null @@ -1,31 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -runtime_evaluated_base_classes_3.py:5:18: TCH003 [*] Move standard library import `uuid.UUID` into a type-checking block - | -3 | import datetime -4 | import pathlib -5 | from uuid import UUID # TCH003 - | ^^^^ TCH003 -6 | -7 | import pydantic - | - = help: Move into type-checking block - -ℹ Suggested fix -2 2 | -3 3 | import datetime -4 4 | import pathlib -5 |-from uuid import UUID # TCH003 -6 5 | -7 6 | import pydantic -8 7 | from pydantic import BaseModel - 8 |+from typing import TYPE_CHECKING - 9 |+ - 10 |+if TYPE_CHECKING: - 11 |+ from uuid import UUID -9 12 | -10 13 | -11 14 | class A(pydantic.BaseModel): - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_base_classes_4.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_base_classes_4.py.snap deleted file mode 100644 index abbbb06448..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_base_classes_4.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_decorators_3.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_decorators_3.py.snap deleted file mode 100644 index 3765967f99..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_decorators_3.py.snap +++ /dev/null @@ -1,31 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -runtime_evaluated_decorators_3.py:6:18: TCH003 [*] Move standard library import `uuid.UUID` into a type-checking block - | -4 | from array import array -5 | from dataclasses import dataclass -6 | from uuid import UUID # TCH003 - | ^^^^ TCH003 -7 | -8 | import attrs - | - = help: Move into type-checking block - -ℹ Suggested fix -3 3 | import datetime -4 4 | from array import array -5 5 | from dataclasses import dataclass -6 |-from uuid import UUID # TCH003 -7 6 | -8 7 | import attrs -9 8 | from attrs import frozen - 9 |+from typing import TYPE_CHECKING - 10 |+ - 11 |+if TYPE_CHECKING: - 12 |+ from uuid import UUID -10 13 | -11 14 | -12 15 | @attrs.define(auto_attribs=True) - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-standard-library-import_snapshot.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-standard-library-import_snapshot.py.snap deleted file mode 100644 index abbbb06448..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-standard-library-import_snapshot.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-third-party-import_TCH002.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-third-party-import_TCH002.py.snap deleted file mode 100644 index ab4ed38714..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-third-party-import_TCH002.py.snap +++ /dev/null @@ -1,252 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -TCH002.py:5:22: TCH002 [*] Move third-party import `pandas` into a type-checking block - | -4 | def f(): -5 | import pandas as pd # TCH002 - | ^^ TCH002 -6 | -7 | x: pd.DataFrame - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | """Tests to determine accurate detection of typing-only imports.""" - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pandas as pd -2 6 | -3 7 | -4 8 | def f(): -5 |- import pandas as pd # TCH002 -6 9 | -7 10 | x: pd.DataFrame -8 11 | - -TCH002.py:11:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block - | -10 | def f(): -11 | from pandas import DataFrame # TCH002 - | ^^^^^^^^^ TCH002 -12 | -13 | x: DataFrame - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | """Tests to determine accurate detection of typing-only imports.""" - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ from pandas import DataFrame -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -8 12 | -9 13 | -10 14 | def f(): -11 |- from pandas import DataFrame # TCH002 -12 15 | -13 16 | x: DataFrame -14 17 | - -TCH002.py:17:37: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block - | -16 | def f(): -17 | from pandas import DataFrame as df # TCH002 - | ^^ TCH002 -18 | -19 | x: df - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | """Tests to determine accurate detection of typing-only imports.""" - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ from pandas import DataFrame as df -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -14 18 | -15 19 | -16 20 | def f(): -17 |- from pandas import DataFrame as df # TCH002 -18 21 | -19 22 | x: df -20 23 | - -TCH002.py:23:22: TCH002 [*] Move third-party import `pandas` into a type-checking block - | -22 | def f(): -23 | import pandas as pd # TCH002 - | ^^ TCH002 -24 | -25 | x: pd.DataFrame = 1 - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | """Tests to determine accurate detection of typing-only imports.""" - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pandas as pd -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -20 24 | -21 25 | -22 26 | def f(): -23 |- import pandas as pd # TCH002 -24 27 | -25 28 | x: pd.DataFrame = 1 -26 29 | - -TCH002.py:29:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block - | -28 | def f(): -29 | from pandas import DataFrame # TCH002 - | ^^^^^^^^^ TCH002 -30 | -31 | x: DataFrame = 2 - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | """Tests to determine accurate detection of typing-only imports.""" - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ from pandas import DataFrame -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -26 30 | -27 31 | -28 32 | def f(): -29 |- from pandas import DataFrame # TCH002 -30 33 | -31 34 | x: DataFrame = 2 -32 35 | - -TCH002.py:35:37: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block - | -34 | def f(): -35 | from pandas import DataFrame as df # TCH002 - | ^^ TCH002 -36 | -37 | x: df = 3 - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | """Tests to determine accurate detection of typing-only imports.""" - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ from pandas import DataFrame as df -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -32 36 | -33 37 | -34 38 | def f(): -35 |- from pandas import DataFrame as df # TCH002 -36 39 | -37 40 | x: df = 3 -38 41 | - -TCH002.py:41:22: TCH002 [*] Move third-party import `pandas` into a type-checking block - | -40 | def f(): -41 | import pandas as pd # TCH002 - | ^^ TCH002 -42 | -43 | x: "pd.DataFrame" = 1 - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | """Tests to determine accurate detection of typing-only imports.""" - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pandas as pd -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -38 42 | -39 43 | -40 44 | def f(): -41 |- import pandas as pd # TCH002 -42 45 | -43 46 | x: "pd.DataFrame" = 1 -44 47 | - -TCH002.py:47:22: TCH002 [*] Move third-party import `pandas` into a type-checking block - | -46 | def f(): -47 | import pandas as pd # TCH002 - | ^^ TCH002 -48 | -49 | x = dict["pd.DataFrame", "pd.DataFrame"] - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | """Tests to determine accurate detection of typing-only imports.""" - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pandas as pd -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -44 48 | -45 49 | -46 50 | def f(): -47 |- import pandas as pd # TCH002 -48 51 | -49 52 | x = dict["pd.DataFrame", "pd.DataFrame"] -50 53 | - -TCH002.py:172:24: TCH002 [*] Move third-party import `module.Member` into a type-checking block - | -170 | global Member -171 | -172 | from module import Member - | ^^^^^^ TCH002 -173 | -174 | x: Member = 1 - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | """Tests to determine accurate detection of typing-only imports.""" - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ from module import Member -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -169 173 | def f(): -170 174 | global Member -171 175 | -172 |- from module import Member -173 176 | -174 177 | x: Member = 1 - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_base_classes_2.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_base_classes_2.py.snap deleted file mode 100644 index c90b345fe7..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_base_classes_2.py.snap +++ /dev/null @@ -1,58 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -runtime_evaluated_base_classes_2.py:3:21: TCH002 [*] Move third-party import `geopandas` into a type-checking block - | -1 | from __future__ import annotations -2 | -3 | import geopandas as gpd # TCH002 - | ^^^ TCH002 -4 | import pydantic -5 | import pyproj # TCH002 - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | from __future__ import annotations -2 2 | -3 |-import geopandas as gpd # TCH002 -4 3 | import pydantic -5 4 | import pyproj # TCH002 -6 5 | from pydantic import BaseModel -7 6 | -8 7 | import numpy - 8 |+from typing import TYPE_CHECKING - 9 |+ - 10 |+if TYPE_CHECKING: - 11 |+ import geopandas as gpd -9 12 | -10 13 | -11 14 | class A(BaseModel): - -runtime_evaluated_base_classes_2.py:5:8: TCH002 [*] Move third-party import `pyproj` into a type-checking block - | -3 | import geopandas as gpd # TCH002 -4 | import pydantic -5 | import pyproj # TCH002 - | ^^^^^^ TCH002 -6 | from pydantic import BaseModel - | - = help: Move into type-checking block - -ℹ Suggested fix -2 2 | -3 3 | import geopandas as gpd # TCH002 -4 4 | import pydantic -5 |-import pyproj # TCH002 -6 5 | from pydantic import BaseModel -7 6 | -8 7 | import numpy - 8 |+from typing import TYPE_CHECKING - 9 |+ - 10 |+if TYPE_CHECKING: - 11 |+ import pyproj -9 12 | -10 13 | -11 14 | class A(BaseModel): - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_decorators_2.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_decorators_2.py.snap deleted file mode 100644 index b25c1d1ab9..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-third-party-import_runtime_evaluated_decorators_2.py.snap +++ /dev/null @@ -1,26 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -runtime_evaluated_decorators_2.py:10:8: TCH002 [*] Move third-party import `numpy` into a type-checking block - | - 8 | from attrs import frozen - 9 | -10 | import numpy # TCH002 - | ^^^^^ TCH002 - | - = help: Move into type-checking block - -ℹ Suggested fix -7 7 | import pyproj -8 8 | from attrs import frozen -9 9 | -10 |-import numpy # TCH002 - 10 |+from typing import TYPE_CHECKING - 11 |+ - 12 |+if TYPE_CHECKING: - 13 |+ import numpy -11 14 | -12 15 | -13 16 | @attrs.define(auto_attribs=True) - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-third-party-import_strict.py.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-third-party-import_strict.py.snap deleted file mode 100644 index fd487eaaaf..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing-only-third-party-import_strict.py.snap +++ /dev/null @@ -1,61 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -strict.py:54:25: TCH002 [*] Move third-party import `pkg.bar.A` into a type-checking block - | -52 | # In un-strict mode, this _should_ raise an error, since `pkg.bar` isn't used at runtime -53 | import pkg -54 | from pkg.bar import A - | ^ TCH002 -55 | -56 | def test(value: A): - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ from pkg.bar import A -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -51 55 | def f(): -52 56 | # In un-strict mode, this _should_ raise an error, since `pkg.bar` isn't used at runtime -53 57 | import pkg -54 |- from pkg.bar import A -55 58 | -56 59 | def test(value: A): -57 60 | return pkg.B() - -strict.py:91:12: TCH002 [*] Move third-party import `pkg` into a type-checking block - | -89 | # Note that `pkg` is a prefix of `pkgfoo` which are both different modules. This is -90 | # testing the implementation. -91 | import pkg - | ^^^ TCH002 -92 | import pkgfoo.bar as B - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | from __future__ import annotations - 2 |+from typing import TYPE_CHECKING - 3 |+ - 4 |+if TYPE_CHECKING: - 5 |+ import pkg -2 6 | -3 7 | -4 8 | def f(): --------------------------------------------------------------------------------- -88 92 | # In un-strict mode, this _should_ raise an error, since `pkg` isn't used at runtime. -89 93 | # Note that `pkg` is a prefix of `pkgfoo` which are both different modules. This is -90 94 | # testing the implementation. -91 |- import pkg -92 95 | import pkgfoo.bar as B -93 96 | -94 97 | def test(value: pkg.A): - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing_import_after_package_import.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing_import_after_package_import.snap deleted file mode 100644 index 41b6a8f207..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing_import_after_package_import.snap +++ /dev/null @@ -1,29 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -:4:18: TCH002 [*] Move third-party import `pandas` into a type-checking block - | -2 | from __future__ import annotations -3 | -4 | import pandas as pd - | ^^ TCH002 -5 | -6 | from typing import TYPE_CHECKING - | - = help: Move into type-checking block - -ℹ Suggested fix -1 1 | -2 2 | from __future__ import annotations -3 3 | -4 |-import pandas as pd -5 4 | -6 5 | from typing import TYPE_CHECKING -7 6 | - 7 |+if TYPE_CHECKING: - 8 |+ import pandas as pd - 9 |+ -8 10 | def f(x: pd.DataFrame): -9 11 | pass - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing_import_after_usage.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing_import_after_usage.snap deleted file mode 100644 index 271f52f2df..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing_import_after_usage.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -:4:18: TCH002 Move third-party import `pandas` into a type-checking block - | -2 | from __future__ import annotations -3 | -4 | import pandas as pd - | ^^ TCH002 -5 | -6 | def f(x: pd.DataFrame): - | - = help: Move into type-checking block - - diff --git a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing_import_before_package_import.snap b/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing_import_before_package_import.snap deleted file mode 100644 index 06752d7221..0000000000 --- a/crates/ruff/src/rules/flake8_type_checking/snapshots/ruff__rules__flake8_type_checking__tests__typing_import_before_package_import.snap +++ /dev/null @@ -1,27 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_type_checking/mod.rs ---- -:6:18: TCH002 [*] Move third-party import `pandas` into a type-checking block - | -4 | from typing import TYPE_CHECKING -5 | -6 | import pandas as pd - | ^^ TCH002 -7 | -8 | def f(x: pd.DataFrame): - | - = help: Move into type-checking block - -ℹ Suggested fix -3 3 | -4 4 | from typing import TYPE_CHECKING -5 5 | -6 |-import pandas as pd -7 6 | - 7 |+if TYPE_CHECKING: - 8 |+ import pandas as pd - 9 |+ -8 10 | def f(x: pd.DataFrame): -9 11 | pass - - diff --git a/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__ARG001_ARG.py.snap b/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__ARG001_ARG.py.snap deleted file mode 100644 index 9e80060621..0000000000 --- a/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__ARG001_ARG.py.snap +++ /dev/null @@ -1,64 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_unused_arguments/mod.rs ---- -ARG.py:9:7: ARG001 Unused function argument: `self` - | - 7 | # Unused arguments on functions. - 8 | ### - 9 | def f(self, x): - | ^^^^ ARG001 -10 | print("Hello, world!") - | - -ARG.py:9:13: ARG001 Unused function argument: `x` - | - 7 | # Unused arguments on functions. - 8 | ### - 9 | def f(self, x): - | ^ ARG001 -10 | print("Hello, world!") - | - -ARG.py:13:7: ARG001 Unused function argument: `cls` - | -13 | def f(cls, x): - | ^^^ ARG001 -14 | print("Hello, world!") - | - -ARG.py:13:12: ARG001 Unused function argument: `x` - | -13 | def f(cls, x): - | ^ ARG001 -14 | print("Hello, world!") - | - -ARG.py:17:7: ARG001 Unused function argument: `self` - | -17 | def f(self, x): - | ^^^^ ARG001 -18 | ... - | - -ARG.py:17:13: ARG001 Unused function argument: `x` - | -17 | def f(self, x): - | ^ ARG001 -18 | ... - | - -ARG.py:21:7: ARG001 Unused function argument: `cls` - | -21 | def f(cls, x): - | ^^^ ARG001 -22 | ... - | - -ARG.py:21:12: ARG001 Unused function argument: `x` - | -21 | def f(cls, x): - | ^ ARG001 -22 | ... - | - - diff --git a/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__ARG002_ARG.py.snap b/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__ARG002_ARG.py.snap deleted file mode 100644 index bacd069607..0000000000 --- a/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__ARG002_ARG.py.snap +++ /dev/null @@ -1,40 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_unused_arguments/mod.rs ---- -ARG.py:37:17: ARG002 Unused method argument: `x` - | -35 | # Unused arguments. -36 | ### -37 | def f(self, x): - | ^ ARG002 -38 | print("Hello, world!") - | - -ARG.py:40:20: ARG002 Unused method argument: `x` - | -38 | print("Hello, world!") -39 | -40 | def f(self, /, x): - | ^ ARG002 -41 | print("Hello, world!") - | - -ARG.py:43:16: ARG002 Unused method argument: `x` - | -41 | print("Hello, world!") -42 | -43 | def f(cls, x): - | ^ ARG002 -44 | print("Hello, world!") - | - -ARG.py:192:24: ARG002 Unused method argument: `x` - | -190 | ### -191 | class C: -192 | def __init__(self, x) -> None: - | ^ ARG002 -193 | print("Hello, world!") - | - - diff --git a/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__ARG003_ARG.py.snap b/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__ARG003_ARG.py.snap deleted file mode 100644 index 131b8c6303..0000000000 --- a/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__ARG003_ARG.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_unused_arguments/mod.rs ---- -ARG.py:47:16: ARG003 Unused class method argument: `x` - | -46 | @classmethod -47 | def f(cls, x): - | ^ ARG003 -48 | print("Hello, world!") - | - - diff --git a/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__ARG004_ARG.py.snap b/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__ARG004_ARG.py.snap deleted file mode 100644 index 0b28d1c4e3..0000000000 --- a/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__ARG004_ARG.py.snap +++ /dev/null @@ -1,28 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_unused_arguments/mod.rs ---- -ARG.py:51:11: ARG004 Unused static method argument: `cls` - | -50 | @staticmethod -51 | def f(cls, x): - | ^^^ ARG004 -52 | print("Hello, world!") - | - -ARG.py:51:16: ARG004 Unused static method argument: `x` - | -50 | @staticmethod -51 | def f(cls, x): - | ^ ARG004 -52 | print("Hello, world!") - | - -ARG.py:55:11: ARG004 Unused static method argument: `x` - | -54 | @staticmethod -55 | def f(x): - | ^ ARG004 -56 | print("Hello, world!") - | - - diff --git a/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__ARG005_ARG.py.snap b/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__ARG005_ARG.py.snap deleted file mode 100644 index 13c992c382..0000000000 --- a/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__ARG005_ARG.py.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_unused_arguments/mod.rs ---- -ARG.py:28:8: ARG005 Unused lambda argument: `x` - | -26 | # Unused arguments on lambdas. -27 | ### -28 | lambda x: print("Hello, world!") - | ^ ARG005 -29 | -30 | lambda: print("Hello, world!") - | - - diff --git a/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__enforce_variadic_names.snap b/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__enforce_variadic_names.snap deleted file mode 100644 index 75f6e3017c..0000000000 --- a/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__enforce_variadic_names.snap +++ /dev/null @@ -1,98 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_unused_arguments/mod.rs ---- -ignore_variadic_names.py:1:7: ARG001 Unused function argument: `a` - | -1 | def f(a, b): - | ^ ARG001 -2 | print("Hello, world!") - | - -ignore_variadic_names.py:1:10: ARG001 Unused function argument: `b` - | -1 | def f(a, b): - | ^ ARG001 -2 | print("Hello, world!") - | - -ignore_variadic_names.py:5:7: ARG001 Unused function argument: `a` - | -5 | def f(a, b, *args, **kwargs): - | ^ ARG001 -6 | print("Hello, world!") - | - -ignore_variadic_names.py:5:10: ARG001 Unused function argument: `b` - | -5 | def f(a, b, *args, **kwargs): - | ^ ARG001 -6 | print("Hello, world!") - | - -ignore_variadic_names.py:5:14: ARG001 Unused function argument: `args` - | -5 | def f(a, b, *args, **kwargs): - | ^^^^ ARG001 -6 | print("Hello, world!") - | - -ignore_variadic_names.py:5:22: ARG001 Unused function argument: `kwargs` - | -5 | def f(a, b, *args, **kwargs): - | ^^^^^^ ARG001 -6 | print("Hello, world!") - | - -ignore_variadic_names.py:10:17: ARG002 Unused method argument: `a` - | - 9 | class C: -10 | def f(self, a, b): - | ^ ARG002 -11 | print("Hello, world!") - | - -ignore_variadic_names.py:10:20: ARG002 Unused method argument: `b` - | - 9 | class C: -10 | def f(self, a, b): - | ^ ARG002 -11 | print("Hello, world!") - | - -ignore_variadic_names.py:13:17: ARG002 Unused method argument: `a` - | -11 | print("Hello, world!") -12 | -13 | def f(self, a, b, *args, **kwargs): - | ^ ARG002 -14 | print("Hello, world!") - | - -ignore_variadic_names.py:13:20: ARG002 Unused method argument: `b` - | -11 | print("Hello, world!") -12 | -13 | def f(self, a, b, *args, **kwargs): - | ^ ARG002 -14 | print("Hello, world!") - | - -ignore_variadic_names.py:13:24: ARG002 Unused method argument: `args` - | -11 | print("Hello, world!") -12 | -13 | def f(self, a, b, *args, **kwargs): - | ^^^^ ARG002 -14 | print("Hello, world!") - | - -ignore_variadic_names.py:13:32: ARG002 Unused method argument: `kwargs` - | -11 | print("Hello, world!") -12 | -13 | def f(self, a, b, *args, **kwargs): - | ^^^^^^ ARG002 -14 | print("Hello, world!") - | - - diff --git a/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__ignore_variadic_names.snap b/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__ignore_variadic_names.snap deleted file mode 100644 index 0556b96b41..0000000000 --- a/crates/ruff/src/rules/flake8_unused_arguments/snapshots/ruff__rules__flake8_unused_arguments__tests__ignore_variadic_names.snap +++ /dev/null @@ -1,66 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_unused_arguments/mod.rs ---- -ignore_variadic_names.py:1:7: ARG001 Unused function argument: `a` - | -1 | def f(a, b): - | ^ ARG001 -2 | print("Hello, world!") - | - -ignore_variadic_names.py:1:10: ARG001 Unused function argument: `b` - | -1 | def f(a, b): - | ^ ARG001 -2 | print("Hello, world!") - | - -ignore_variadic_names.py:5:7: ARG001 Unused function argument: `a` - | -5 | def f(a, b, *args, **kwargs): - | ^ ARG001 -6 | print("Hello, world!") - | - -ignore_variadic_names.py:5:10: ARG001 Unused function argument: `b` - | -5 | def f(a, b, *args, **kwargs): - | ^ ARG001 -6 | print("Hello, world!") - | - -ignore_variadic_names.py:10:17: ARG002 Unused method argument: `a` - | - 9 | class C: -10 | def f(self, a, b): - | ^ ARG002 -11 | print("Hello, world!") - | - -ignore_variadic_names.py:10:20: ARG002 Unused method argument: `b` - | - 9 | class C: -10 | def f(self, a, b): - | ^ ARG002 -11 | print("Hello, world!") - | - -ignore_variadic_names.py:13:17: ARG002 Unused method argument: `a` - | -11 | print("Hello, world!") -12 | -13 | def f(self, a, b, *args, **kwargs): - | ^ ARG002 -14 | print("Hello, world!") - | - -ignore_variadic_names.py:13:20: ARG002 Unused method argument: `b` - | -11 | print("Hello, world!") -12 | -13 | def f(self, a, b, *args, **kwargs): - | ^ ARG002 -14 | print("Hello, world!") - | - - diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH124_py_path_1.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH124_py_path_1.py.snap deleted file mode 100644 index e61f19d701..0000000000 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH124_py_path_1.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs ---- -py_path_1.py:3:5: PTH124 `py.path` is in maintenance mode, use `pathlib` instead - | -1 | import py -2 | -3 | p = py.path.local("../foo") - | ^^^^^^^^^^^^^ PTH124 - | - - diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH124_py_path_2.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH124_py_path_2.py.snap deleted file mode 100644 index 031d163e1e..0000000000 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH124_py_path_2.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs ---- -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 | -3 | p = path("/foo") - | ^^^^ PTH124 - | - - diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH201_PTH201.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH201_PTH201.py.snap deleted file mode 100644 index 10d9a60ae4..0000000000 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH201_PTH201.py.snap +++ /dev/null @@ -1,86 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs ---- -PTH201.py:5:10: PTH201 [*] Do not pass the current directory explicitly to `Path` - | -4 | # match -5 | _ = Path(".") - | ^^^ PTH201 -6 | _ = pth(".") -7 | _ = PurePath(".") - | - = help: Remove the current directory argument - -ℹ Fix -2 2 | from pathlib import Path as pth -3 3 | -4 4 | # match -5 |-_ = Path(".") - 5 |+_ = Path() -6 6 | _ = pth(".") -7 7 | _ = PurePath(".") -8 8 | _ = Path("") - -PTH201.py:6:9: PTH201 [*] Do not pass the current directory explicitly to `Path` - | -4 | # match -5 | _ = Path(".") -6 | _ = pth(".") - | ^^^ PTH201 -7 | _ = PurePath(".") -8 | _ = Path("") - | - = help: Remove the current directory argument - -ℹ Fix -3 3 | -4 4 | # match -5 5 | _ = Path(".") -6 |-_ = pth(".") - 6 |+_ = pth() -7 7 | _ = PurePath(".") -8 8 | _ = Path("") -9 9 | - -PTH201.py:7:14: PTH201 [*] Do not pass the current directory explicitly to `Path` - | -5 | _ = Path(".") -6 | _ = pth(".") -7 | _ = PurePath(".") - | ^^^ PTH201 -8 | _ = Path("") - | - = help: Remove the current directory argument - -ℹ Fix -4 4 | # match -5 5 | _ = Path(".") -6 6 | _ = pth(".") -7 |-_ = PurePath(".") - 7 |+_ = PurePath() -8 8 | _ = Path("") -9 9 | -10 10 | # no match - -PTH201.py:8:10: PTH201 [*] Do not pass the current directory explicitly to `Path` - | - 6 | _ = pth(".") - 7 | _ = PurePath(".") - 8 | _ = Path("") - | ^^ PTH201 - 9 | -10 | # no match - | - = help: Remove the current directory argument - -ℹ Fix -5 5 | _ = Path(".") -6 6 | _ = pth(".") -7 7 | _ = PurePath(".") -8 |-_ = Path("") - 8 |+_ = Path() -9 9 | -10 10 | # no match -11 11 | _ = Path() - - diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH202_PTH202.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH202_PTH202.py.snap deleted file mode 100644 index 078f5fd3b0..0000000000 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH202_PTH202.py.snap +++ /dev/null @@ -1,76 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs ---- -PTH202.py:6:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` - | -6 | os.path.getsize("filename") - | ^^^^^^^^^^^^^^^ PTH202 -7 | os.path.getsize(b"filename") -8 | os.path.getsize(Path("filename")) - | - -PTH202.py:7:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` - | -6 | os.path.getsize("filename") -7 | os.path.getsize(b"filename") - | ^^^^^^^^^^^^^^^ PTH202 -8 | os.path.getsize(Path("filename")) -9 | os.path.getsize(__file__) - | - -PTH202.py:8:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` - | -6 | os.path.getsize("filename") -7 | os.path.getsize(b"filename") -8 | os.path.getsize(Path("filename")) - | ^^^^^^^^^^^^^^^ PTH202 -9 | os.path.getsize(__file__) - | - -PTH202.py:9:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` - | - 7 | os.path.getsize(b"filename") - 8 | os.path.getsize(Path("filename")) - 9 | os.path.getsize(__file__) - | ^^^^^^^^^^^^^^^ PTH202 -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 | -11 | getsize("filename") - | ^^^^^^^ PTH202 -12 | getsize(b"filename") -13 | getsize(Path("filename")) - | - -PTH202.py:12:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` - | -11 | getsize("filename") -12 | getsize(b"filename") - | ^^^^^^^ PTH202 -13 | getsize(Path("filename")) -14 | getsize(__file__) - | - -PTH202.py:13:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` - | -11 | getsize("filename") -12 | getsize(b"filename") -13 | getsize(Path("filename")) - | ^^^^^^^ PTH202 -14 | getsize(__file__) - | - -PTH202.py:14:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` - | -12 | getsize(b"filename") -13 | getsize(Path("filename")) -14 | getsize(__file__) - | ^^^^^^^ PTH202 - | - - diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH203_PTH203.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH203_PTH203.py.snap deleted file mode 100644 index e67bd06aff..0000000000 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH203_PTH203.py.snap +++ /dev/null @@ -1,54 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs ---- -PTH203.py:5:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` - | -3 | from os.path import getatime -4 | -5 | os.path.getatime("filename") - | ^^^^^^^^^^^^^^^^ PTH203 -6 | os.path.getatime(b"filename") -7 | os.path.getatime(Path("filename")) - | - -PTH203.py:6:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` - | -5 | os.path.getatime("filename") -6 | os.path.getatime(b"filename") - | ^^^^^^^^^^^^^^^^ PTH203 -7 | os.path.getatime(Path("filename")) - | - -PTH203.py:7:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` - | -5 | os.path.getatime("filename") -6 | os.path.getatime(b"filename") -7 | os.path.getatime(Path("filename")) - | ^^^^^^^^^^^^^^^^ PTH203 - | - -PTH203.py:10:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` - | -10 | getatime("filename") - | ^^^^^^^^ PTH203 -11 | getatime(b"filename") -12 | getatime(Path("filename")) - | - -PTH203.py:11:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` - | -10 | getatime("filename") -11 | getatime(b"filename") - | ^^^^^^^^ PTH203 -12 | getatime(Path("filename")) - | - -PTH203.py:12:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` - | -10 | getatime("filename") -11 | getatime(b"filename") -12 | getatime(Path("filename")) - | ^^^^^^^^ PTH203 - | - - diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH204_PTH204.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH204_PTH204.py.snap deleted file mode 100644 index 9260022b09..0000000000 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH204_PTH204.py.snap +++ /dev/null @@ -1,52 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs ---- -PTH204.py:6:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` - | -6 | os.path.getmtime("filename") - | ^^^^^^^^^^^^^^^^ PTH204 -7 | os.path.getmtime(b"filename") -8 | os.path.getmtime(Path("filename")) - | - -PTH204.py:7:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` - | -6 | os.path.getmtime("filename") -7 | os.path.getmtime(b"filename") - | ^^^^^^^^^^^^^^^^ PTH204 -8 | os.path.getmtime(Path("filename")) - | - -PTH204.py:8:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` - | -6 | os.path.getmtime("filename") -7 | os.path.getmtime(b"filename") -8 | os.path.getmtime(Path("filename")) - | ^^^^^^^^^^^^^^^^ PTH204 - | - -PTH204.py:11:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` - | -11 | getmtime("filename") - | ^^^^^^^^ PTH204 -12 | getmtime(b"filename") -13 | getmtime(Path("filename")) - | - -PTH204.py:12:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` - | -11 | getmtime("filename") -12 | getmtime(b"filename") - | ^^^^^^^^ PTH204 -13 | getmtime(Path("filename")) - | - -PTH204.py:13:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` - | -11 | getmtime("filename") -12 | getmtime(b"filename") -13 | getmtime(Path("filename")) - | ^^^^^^^^ PTH204 - | - - diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH205_PTH205.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH205_PTH205.py.snap deleted file mode 100644 index e776a429b1..0000000000 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH205_PTH205.py.snap +++ /dev/null @@ -1,56 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs ---- -PTH205.py:6:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` - | -6 | os.path.getctime("filename") - | ^^^^^^^^^^^^^^^^ PTH205 -7 | os.path.getctime(b"filename") -8 | os.path.getctime(Path("filename")) - | - -PTH205.py:7:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` - | -6 | os.path.getctime("filename") -7 | os.path.getctime(b"filename") - | ^^^^^^^^^^^^^^^^ PTH205 -8 | os.path.getctime(Path("filename")) - | - -PTH205.py:8:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` - | - 6 | os.path.getctime("filename") - 7 | os.path.getctime(b"filename") - 8 | os.path.getctime(Path("filename")) - | ^^^^^^^^^^^^^^^^ PTH205 - 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 | -10 | getctime("filename") - | ^^^^^^^^ PTH205 -11 | getctime(b"filename") -12 | getctime(Path("filename")) - | - -PTH205.py:11:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` - | -10 | getctime("filename") -11 | getctime(b"filename") - | ^^^^^^^^ PTH205 -12 | getctime(Path("filename")) - | - -PTH205.py:12:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` - | -10 | getctime("filename") -11 | getctime(b"filename") -12 | getctime(Path("filename")) - | ^^^^^^^^ PTH205 - | - - diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH206_PTH206.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH206_PTH206.py.snap deleted file mode 100644 index cd41c2038a..0000000000 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH206_PTH206.py.snap +++ /dev/null @@ -1,102 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs ---- -PTH206.py:8:12: PTH206 Replace `.split(os.sep)` with `Path.parts` - | - 7 | # PTH206 - 8 | "foo/bar/".split(os.sep) - | ^^^^^ PTH206 - 9 | "foo/bar/".split(sep=os.sep) -10 | "foo/bar/".split(os.sep)[-1] - | - -PTH206.py:9:12: PTH206 Replace `.split(os.sep)` with `Path.parts` - | - 7 | # PTH206 - 8 | "foo/bar/".split(os.sep) - 9 | "foo/bar/".split(sep=os.sep) - | ^^^^^ PTH206 -10 | "foo/bar/".split(os.sep)[-1] -11 | "foo/bar/".split(os.sep)[-2] - | - -PTH206.py:10:12: PTH206 Replace `.split(os.sep)` with `Path.parts` - | - 8 | "foo/bar/".split(os.sep) - 9 | "foo/bar/".split(sep=os.sep) -10 | "foo/bar/".split(os.sep)[-1] - | ^^^^^ PTH206 -11 | "foo/bar/".split(os.sep)[-2] -12 | "foo/bar/".split(os.sep)[-2:] - | - -PTH206.py:11:12: PTH206 Replace `.split(os.sep)` with `Path.parts` - | - 9 | "foo/bar/".split(sep=os.sep) -10 | "foo/bar/".split(os.sep)[-1] -11 | "foo/bar/".split(os.sep)[-2] - | ^^^^^ PTH206 -12 | "foo/bar/".split(os.sep)[-2:] -13 | "fizz/buzz".split(sep) - | - -PTH206.py:12:12: PTH206 Replace `.split(os.sep)` with `Path.parts` - | -10 | "foo/bar/".split(os.sep)[-1] -11 | "foo/bar/".split(os.sep)[-2] -12 | "foo/bar/".split(os.sep)[-2:] - | ^^^^^ PTH206 -13 | "fizz/buzz".split(sep) -14 | "fizz/buzz".split(sep)[-1] - | - -PTH206.py:13:13: PTH206 Replace `.split(os.sep)` with `Path.parts` - | -11 | "foo/bar/".split(os.sep)[-2] -12 | "foo/bar/".split(os.sep)[-2:] -13 | "fizz/buzz".split(sep) - | ^^^^^ PTH206 -14 | "fizz/buzz".split(sep)[-1] -15 | os.path.splitext("path/to/hello_world.py")[0].split(os.sep)[-1] - | - -PTH206.py:14:13: PTH206 Replace `.split(os.sep)` with `Path.parts` - | -12 | "foo/bar/".split(os.sep)[-2:] -13 | "fizz/buzz".split(sep) -14 | "fizz/buzz".split(sep)[-1] - | ^^^^^ PTH206 -15 | os.path.splitext("path/to/hello_world.py")[0].split(os.sep)[-1] -16 | file_name.split(os.sep) - | - -PTH206.py:15:47: PTH206 Replace `.split(os.sep)` with `Path.parts` - | -13 | "fizz/buzz".split(sep) -14 | "fizz/buzz".split(sep)[-1] -15 | os.path.splitext("path/to/hello_world.py")[0].split(os.sep)[-1] - | ^^^^^ PTH206 -16 | file_name.split(os.sep) -17 | (os.path.abspath(file_name)).split(os.sep) - | - -PTH206.py:16:11: PTH206 Replace `.split(os.sep)` with `Path.parts` - | -14 | "fizz/buzz".split(sep)[-1] -15 | os.path.splitext("path/to/hello_world.py")[0].split(os.sep)[-1] -16 | file_name.split(os.sep) - | ^^^^^ PTH206 -17 | (os.path.abspath(file_name)).split(os.sep) - | - -PTH206.py:17:30: PTH206 Replace `.split(os.sep)` with `Path.parts` - | -15 | os.path.splitext("path/to/hello_world.py")[0].split(os.sep)[-1] -16 | file_name.split(os.sep) -17 | (os.path.abspath(file_name)).split(os.sep) - | ^^^^^ PTH206 -18 | -19 | # OK - | - - diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH207_PTH207.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH207_PTH207.py.snap deleted file mode 100644 index 99cebbcb70..0000000000 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__PTH207_PTH207.py.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs ---- -PTH207.py:9:1: PTH207 Replace `glob` with `Path.glob` or `Path.rglob` - | - 8 | # PTH207 - 9 | glob.glob(os.path.join(extensions_dir, "ops", "autograd", "*.cpp")) - | ^^^^^^^^^ PTH207 -10 | list(glob.iglob(os.path.join(extensions_dir, "ops", "autograd", "*.cpp"))) -11 | search("*.png") - | - -PTH207.py:10:6: PTH207 Replace `iglob` with `Path.glob` or `Path.rglob` - | - 8 | # PTH207 - 9 | glob.glob(os.path.join(extensions_dir, "ops", "autograd", "*.cpp")) -10 | list(glob.iglob(os.path.join(extensions_dir, "ops", "autograd", "*.cpp"))) - | ^^^^^^^^^^ PTH207 -11 | search("*.png") - | - -PTH207.py:11:1: PTH207 Replace `glob` with `Path.glob` or `Path.rglob` - | - 9 | glob.glob(os.path.join(extensions_dir, "ops", "autograd", "*.cpp")) -10 | list(glob.iglob(os.path.join(extensions_dir, "ops", "autograd", "*.cpp"))) -11 | search("*.png") - | ^^^^^^ PTH207 - | - - diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__full_name.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__full_name.py.snap deleted file mode 100644 index 40a313d086..0000000000 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__full_name.py.snap +++ /dev/null @@ -1,280 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs ---- -full_name.py:7:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` - | -5 | q = "bar" -6 | -7 | a = os.path.abspath(p) - | ^^^^^^^^^^^^^^^ PTH100 -8 | aa = os.chmod(p) -9 | aaa = os.mkdir(p) - | - -full_name.py:8:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()` - | - 7 | a = os.path.abspath(p) - 8 | aa = os.chmod(p) - | ^^^^^^^^ PTH101 - 9 | aaa = os.mkdir(p) -10 | os.makedirs(p) - | - -full_name.py:9:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` - | - 7 | a = os.path.abspath(p) - 8 | aa = os.chmod(p) - 9 | aaa = os.mkdir(p) - | ^^^^^^^^ PTH102 -10 | os.makedirs(p) -11 | os.rename(p) - | - -full_name.py:10:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` - | - 8 | aa = os.chmod(p) - 9 | aaa = os.mkdir(p) -10 | os.makedirs(p) - | ^^^^^^^^^^^ PTH103 -11 | os.rename(p) -12 | os.replace(p) - | - -full_name.py:11:1: PTH104 `os.rename()` should be replaced by `Path.rename()` - | - 9 | aaa = os.mkdir(p) -10 | os.makedirs(p) -11 | os.rename(p) - | ^^^^^^^^^ PTH104 -12 | os.replace(p) -13 | os.rmdir(p) - | - -full_name.py:12:1: PTH105 `os.replace()` should be replaced by `Path.replace()` - | -10 | os.makedirs(p) -11 | os.rename(p) -12 | os.replace(p) - | ^^^^^^^^^^ PTH105 -13 | os.rmdir(p) -14 | os.remove(p) - | - -full_name.py:13:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()` - | -11 | os.rename(p) -12 | os.replace(p) -13 | os.rmdir(p) - | ^^^^^^^^ PTH106 -14 | os.remove(p) -15 | os.unlink(p) - | - -full_name.py:14:1: PTH107 `os.remove()` should be replaced by `Path.unlink()` - | -12 | os.replace(p) -13 | os.rmdir(p) -14 | os.remove(p) - | ^^^^^^^^^ PTH107 -15 | os.unlink(p) -16 | os.getcwd(p) - | - -full_name.py:15:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()` - | -13 | os.rmdir(p) -14 | os.remove(p) -15 | os.unlink(p) - | ^^^^^^^^^ PTH108 -16 | os.getcwd(p) -17 | b = os.path.exists(p) - | - -full_name.py:16:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` - | -14 | os.remove(p) -15 | os.unlink(p) -16 | os.getcwd(p) - | ^^^^^^^^^ PTH109 -17 | b = os.path.exists(p) -18 | bb = os.path.expanduser(p) - | - -full_name.py:17:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()` - | -15 | os.unlink(p) -16 | os.getcwd(p) -17 | b = os.path.exists(p) - | ^^^^^^^^^^^^^^ PTH110 -18 | bb = os.path.expanduser(p) -19 | bbb = os.path.isdir(p) - | - -full_name.py:18:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()` - | -16 | os.getcwd(p) -17 | b = os.path.exists(p) -18 | bb = os.path.expanduser(p) - | ^^^^^^^^^^^^^^^^^^ PTH111 -19 | bbb = os.path.isdir(p) -20 | bbbb = os.path.isfile(p) - | - -full_name.py:19:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()` - | -17 | b = os.path.exists(p) -18 | bb = os.path.expanduser(p) -19 | bbb = os.path.isdir(p) - | ^^^^^^^^^^^^^ PTH112 -20 | bbbb = os.path.isfile(p) -21 | bbbbb = os.path.islink(p) - | - -full_name.py:20:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()` - | -18 | bb = os.path.expanduser(p) -19 | bbb = os.path.isdir(p) -20 | bbbb = os.path.isfile(p) - | ^^^^^^^^^^^^^^ PTH113 -21 | bbbbb = os.path.islink(p) -22 | os.readlink(p) - | - -full_name.py:21:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()` - | -19 | bbb = os.path.isdir(p) -20 | bbbb = os.path.isfile(p) -21 | bbbbb = os.path.islink(p) - | ^^^^^^^^^^^^^^ PTH114 -22 | os.readlink(p) -23 | os.stat(p) - | - -full_name.py:22:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()` - | -20 | bbbb = os.path.isfile(p) -21 | bbbbb = os.path.islink(p) -22 | os.readlink(p) - | ^^^^^^^^^^^ PTH115 -23 | os.stat(p) -24 | os.path.isabs(p) - | - -full_name.py:23:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` - | -21 | bbbbb = os.path.islink(p) -22 | os.readlink(p) -23 | os.stat(p) - | ^^^^^^^ PTH116 -24 | os.path.isabs(p) -25 | os.path.join(p, q) - | - -full_name.py:24:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()` - | -22 | os.readlink(p) -23 | os.stat(p) -24 | os.path.isabs(p) - | ^^^^^^^^^^^^^ PTH117 -25 | os.path.join(p, q) -26 | os.sep.join([p, q]) - | - -full_name.py:25:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator - | -23 | os.stat(p) -24 | os.path.isabs(p) -25 | os.path.join(p, q) - | ^^^^^^^^^^^^ PTH118 -26 | os.sep.join([p, q]) -27 | os.sep.join((p, q)) - | - -full_name.py:26:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator - | -24 | os.path.isabs(p) -25 | os.path.join(p, q) -26 | os.sep.join([p, q]) - | ^^^^^^^^^^^ PTH118 -27 | os.sep.join((p, q)) -28 | os.path.basename(p) - | - -full_name.py:27:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator - | -25 | os.path.join(p, q) -26 | os.sep.join([p, q]) -27 | os.sep.join((p, q)) - | ^^^^^^^^^^^ PTH118 -28 | os.path.basename(p) -29 | os.path.dirname(p) - | - -full_name.py:28:1: PTH119 `os.path.basename()` should be replaced by `Path.name` - | -26 | os.sep.join([p, q]) -27 | os.sep.join((p, q)) -28 | os.path.basename(p) - | ^^^^^^^^^^^^^^^^ PTH119 -29 | os.path.dirname(p) -30 | os.path.samefile(p) - | - -full_name.py:29:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent` - | -27 | os.sep.join((p, q)) -28 | os.path.basename(p) -29 | os.path.dirname(p) - | ^^^^^^^^^^^^^^^ PTH120 -30 | os.path.samefile(p) -31 | os.path.splitext(p) - | - -full_name.py:30:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` - | -28 | os.path.basename(p) -29 | os.path.dirname(p) -30 | os.path.samefile(p) - | ^^^^^^^^^^^^^^^^ PTH121 -31 | os.path.splitext(p) -32 | with open(p) as fp: - | - -full_name.py:31:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` - | -29 | os.path.dirname(p) -30 | os.path.samefile(p) -31 | os.path.splitext(p) - | ^^^^^^^^^^^^^^^^ PTH122 -32 | with open(p) as fp: -33 | fp.read() - | - -full_name.py:32:6: PTH123 `open()` should be replaced by `Path.open()` - | -30 | os.path.samefile(p) -31 | os.path.splitext(p) -32 | with open(p) as fp: - | ^^^^ PTH123 -33 | fp.read() -34 | open(p).close() - | - -full_name.py:34:1: PTH123 `open()` should be replaced by `Path.open()` - | -32 | with open(p) as fp: -33 | fp.read() -34 | open(p).close() - | ^^^^ PTH123 -35 | os.getcwdb(p) - | - -full_name.py:35:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` - | -33 | fp.read() -34 | open(p).close() -35 | os.getcwdb(p) - | ^^^^^^^^^^ PTH109 - | - - diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_as.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_as.py.snap deleted file mode 100644 index 117cb496d6..0000000000 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_as.py.snap +++ /dev/null @@ -1,250 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs ---- -import_as.py:7:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` - | -5 | q = "bar" -6 | -7 | a = foo_p.abspath(p) - | ^^^^^^^^^^^^^ PTH100 -8 | aa = foo.chmod(p) -9 | aaa = foo.mkdir(p) - | - -import_as.py:8:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()` - | - 7 | a = foo_p.abspath(p) - 8 | aa = foo.chmod(p) - | ^^^^^^^^^ PTH101 - 9 | aaa = foo.mkdir(p) -10 | foo.makedirs(p) - | - -import_as.py:9:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` - | - 7 | a = foo_p.abspath(p) - 8 | aa = foo.chmod(p) - 9 | aaa = foo.mkdir(p) - | ^^^^^^^^^ PTH102 -10 | foo.makedirs(p) -11 | foo.rename(p) - | - -import_as.py:10:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` - | - 8 | aa = foo.chmod(p) - 9 | aaa = foo.mkdir(p) -10 | foo.makedirs(p) - | ^^^^^^^^^^^^ PTH103 -11 | foo.rename(p) -12 | foo.replace(p) - | - -import_as.py:11:1: PTH104 `os.rename()` should be replaced by `Path.rename()` - | - 9 | aaa = foo.mkdir(p) -10 | foo.makedirs(p) -11 | foo.rename(p) - | ^^^^^^^^^^ PTH104 -12 | foo.replace(p) -13 | foo.rmdir(p) - | - -import_as.py:12:1: PTH105 `os.replace()` should be replaced by `Path.replace()` - | -10 | foo.makedirs(p) -11 | foo.rename(p) -12 | foo.replace(p) - | ^^^^^^^^^^^ PTH105 -13 | foo.rmdir(p) -14 | foo.remove(p) - | - -import_as.py:13:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()` - | -11 | foo.rename(p) -12 | foo.replace(p) -13 | foo.rmdir(p) - | ^^^^^^^^^ PTH106 -14 | foo.remove(p) -15 | foo.unlink(p) - | - -import_as.py:14:1: PTH107 `os.remove()` should be replaced by `Path.unlink()` - | -12 | foo.replace(p) -13 | foo.rmdir(p) -14 | foo.remove(p) - | ^^^^^^^^^^ PTH107 -15 | foo.unlink(p) -16 | foo.getcwd(p) - | - -import_as.py:15:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()` - | -13 | foo.rmdir(p) -14 | foo.remove(p) -15 | foo.unlink(p) - | ^^^^^^^^^^ PTH108 -16 | foo.getcwd(p) -17 | b = foo_p.exists(p) - | - -import_as.py:16:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` - | -14 | foo.remove(p) -15 | foo.unlink(p) -16 | foo.getcwd(p) - | ^^^^^^^^^^ PTH109 -17 | b = foo_p.exists(p) -18 | bb = foo_p.expanduser(p) - | - -import_as.py:17:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()` - | -15 | foo.unlink(p) -16 | foo.getcwd(p) -17 | b = foo_p.exists(p) - | ^^^^^^^^^^^^ PTH110 -18 | bb = foo_p.expanduser(p) -19 | bbb = foo_p.isdir(p) - | - -import_as.py:18:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()` - | -16 | foo.getcwd(p) -17 | b = foo_p.exists(p) -18 | bb = foo_p.expanduser(p) - | ^^^^^^^^^^^^^^^^ PTH111 -19 | bbb = foo_p.isdir(p) -20 | bbbb = foo_p.isfile(p) - | - -import_as.py:19:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()` - | -17 | b = foo_p.exists(p) -18 | bb = foo_p.expanduser(p) -19 | bbb = foo_p.isdir(p) - | ^^^^^^^^^^^ PTH112 -20 | bbbb = foo_p.isfile(p) -21 | bbbbb = foo_p.islink(p) - | - -import_as.py:20:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()` - | -18 | bb = foo_p.expanduser(p) -19 | bbb = foo_p.isdir(p) -20 | bbbb = foo_p.isfile(p) - | ^^^^^^^^^^^^ PTH113 -21 | bbbbb = foo_p.islink(p) -22 | foo.readlink(p) - | - -import_as.py:21:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()` - | -19 | bbb = foo_p.isdir(p) -20 | bbbb = foo_p.isfile(p) -21 | bbbbb = foo_p.islink(p) - | ^^^^^^^^^^^^ PTH114 -22 | foo.readlink(p) -23 | foo.stat(p) - | - -import_as.py:22:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()` - | -20 | bbbb = foo_p.isfile(p) -21 | bbbbb = foo_p.islink(p) -22 | foo.readlink(p) - | ^^^^^^^^^^^^ PTH115 -23 | foo.stat(p) -24 | foo_p.isabs(p) - | - -import_as.py:23:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` - | -21 | bbbbb = foo_p.islink(p) -22 | foo.readlink(p) -23 | foo.stat(p) - | ^^^^^^^^ PTH116 -24 | foo_p.isabs(p) -25 | foo_p.join(p, q) - | - -import_as.py:24:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()` - | -22 | foo.readlink(p) -23 | foo.stat(p) -24 | foo_p.isabs(p) - | ^^^^^^^^^^^ PTH117 -25 | foo_p.join(p, q) -26 | foo.sep.join([p, q]) - | - -import_as.py:25:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator - | -23 | foo.stat(p) -24 | foo_p.isabs(p) -25 | foo_p.join(p, q) - | ^^^^^^^^^^ PTH118 -26 | foo.sep.join([p, q]) -27 | foo.sep.join((p, q)) - | - -import_as.py:26:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator - | -24 | foo_p.isabs(p) -25 | foo_p.join(p, q) -26 | foo.sep.join([p, q]) - | ^^^^^^^^^^^^ PTH118 -27 | foo.sep.join((p, q)) -28 | foo_p.basename(p) - | - -import_as.py:27:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator - | -25 | foo_p.join(p, q) -26 | foo.sep.join([p, q]) -27 | foo.sep.join((p, q)) - | ^^^^^^^^^^^^ PTH118 -28 | foo_p.basename(p) -29 | foo_p.dirname(p) - | - -import_as.py:28:1: PTH119 `os.path.basename()` should be replaced by `Path.name` - | -26 | foo.sep.join([p, q]) -27 | foo.sep.join((p, q)) -28 | foo_p.basename(p) - | ^^^^^^^^^^^^^^ PTH119 -29 | foo_p.dirname(p) -30 | foo_p.samefile(p) - | - -import_as.py:29:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent` - | -27 | foo.sep.join((p, q)) -28 | foo_p.basename(p) -29 | foo_p.dirname(p) - | ^^^^^^^^^^^^^ PTH120 -30 | foo_p.samefile(p) -31 | foo_p.splitext(p) - | - -import_as.py:30:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` - | -28 | foo_p.basename(p) -29 | foo_p.dirname(p) -30 | foo_p.samefile(p) - | ^^^^^^^^^^^^^^ PTH121 -31 | foo_p.splitext(p) - | - -import_as.py:31:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` - | -29 | foo_p.dirname(p) -30 | foo_p.samefile(p) -31 | foo_p.splitext(p) - | ^^^^^^^^^^^^^^ PTH122 - | - - diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_from.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_from.py.snap deleted file mode 100644 index f2ec0ff9b1..0000000000 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_from.py.snap +++ /dev/null @@ -1,271 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs ---- -import_from.py:9:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` - | - 7 | q = "bar" - 8 | - 9 | a = abspath(p) - | ^^^^^^^ PTH100 -10 | aa = chmod(p) -11 | aaa = mkdir(p) - | - -import_from.py:10:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()` - | - 9 | a = abspath(p) -10 | aa = chmod(p) - | ^^^^^ PTH101 -11 | aaa = mkdir(p) -12 | makedirs(p) - | - -import_from.py:11:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` - | - 9 | a = abspath(p) -10 | aa = chmod(p) -11 | aaa = mkdir(p) - | ^^^^^ PTH102 -12 | makedirs(p) -13 | rename(p) - | - -import_from.py:12:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` - | -10 | aa = chmod(p) -11 | aaa = mkdir(p) -12 | makedirs(p) - | ^^^^^^^^ PTH103 -13 | rename(p) -14 | replace(p) - | - -import_from.py:13:1: PTH104 `os.rename()` should be replaced by `Path.rename()` - | -11 | aaa = mkdir(p) -12 | makedirs(p) -13 | rename(p) - | ^^^^^^ PTH104 -14 | replace(p) -15 | rmdir(p) - | - -import_from.py:14:1: PTH105 `os.replace()` should be replaced by `Path.replace()` - | -12 | makedirs(p) -13 | rename(p) -14 | replace(p) - | ^^^^^^^ PTH105 -15 | rmdir(p) -16 | remove(p) - | - -import_from.py:15:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()` - | -13 | rename(p) -14 | replace(p) -15 | rmdir(p) - | ^^^^^ PTH106 -16 | remove(p) -17 | unlink(p) - | - -import_from.py:16:1: PTH107 `os.remove()` should be replaced by `Path.unlink()` - | -14 | replace(p) -15 | rmdir(p) -16 | remove(p) - | ^^^^^^ PTH107 -17 | unlink(p) -18 | getcwd(p) - | - -import_from.py:17:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()` - | -15 | rmdir(p) -16 | remove(p) -17 | unlink(p) - | ^^^^^^ PTH108 -18 | getcwd(p) -19 | b = exists(p) - | - -import_from.py:18:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` - | -16 | remove(p) -17 | unlink(p) -18 | getcwd(p) - | ^^^^^^ PTH109 -19 | b = exists(p) -20 | bb = expanduser(p) - | - -import_from.py:19:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()` - | -17 | unlink(p) -18 | getcwd(p) -19 | b = exists(p) - | ^^^^^^ PTH110 -20 | bb = expanduser(p) -21 | bbb = isdir(p) - | - -import_from.py:20:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()` - | -18 | getcwd(p) -19 | b = exists(p) -20 | bb = expanduser(p) - | ^^^^^^^^^^ PTH111 -21 | bbb = isdir(p) -22 | bbbb = isfile(p) - | - -import_from.py:21:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()` - | -19 | b = exists(p) -20 | bb = expanduser(p) -21 | bbb = isdir(p) - | ^^^^^ PTH112 -22 | bbbb = isfile(p) -23 | bbbbb = islink(p) - | - -import_from.py:22:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()` - | -20 | bb = expanduser(p) -21 | bbb = isdir(p) -22 | bbbb = isfile(p) - | ^^^^^^ PTH113 -23 | bbbbb = islink(p) -24 | readlink(p) - | - -import_from.py:23:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()` - | -21 | bbb = isdir(p) -22 | bbbb = isfile(p) -23 | bbbbb = islink(p) - | ^^^^^^ PTH114 -24 | readlink(p) -25 | stat(p) - | - -import_from.py:24:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()` - | -22 | bbbb = isfile(p) -23 | bbbbb = islink(p) -24 | readlink(p) - | ^^^^^^^^ PTH115 -25 | stat(p) -26 | isabs(p) - | - -import_from.py:25:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` - | -23 | bbbbb = islink(p) -24 | readlink(p) -25 | stat(p) - | ^^^^ PTH116 -26 | isabs(p) -27 | join(p, q) - | - -import_from.py:26:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()` - | -24 | readlink(p) -25 | stat(p) -26 | isabs(p) - | ^^^^^ PTH117 -27 | join(p, q) -28 | sep.join((p, q)) - | - -import_from.py:27:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator - | -25 | stat(p) -26 | isabs(p) -27 | join(p, q) - | ^^^^ PTH118 -28 | sep.join((p, q)) -29 | sep.join([p, q]) - | - -import_from.py:28:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator - | -26 | isabs(p) -27 | join(p, q) -28 | sep.join((p, q)) - | ^^^^^^^^ PTH118 -29 | sep.join([p, q]) -30 | basename(p) - | - -import_from.py:29:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator - | -27 | join(p, q) -28 | sep.join((p, q)) -29 | sep.join([p, q]) - | ^^^^^^^^ PTH118 -30 | basename(p) -31 | dirname(p) - | - -import_from.py:30:1: PTH119 `os.path.basename()` should be replaced by `Path.name` - | -28 | sep.join((p, q)) -29 | sep.join([p, q]) -30 | basename(p) - | ^^^^^^^^ PTH119 -31 | dirname(p) -32 | samefile(p) - | - -import_from.py:31:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent` - | -29 | sep.join([p, q]) -30 | basename(p) -31 | dirname(p) - | ^^^^^^^ PTH120 -32 | samefile(p) -33 | splitext(p) - | - -import_from.py:32:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` - | -30 | basename(p) -31 | dirname(p) -32 | samefile(p) - | ^^^^^^^^ PTH121 -33 | splitext(p) -34 | with open(p) as fp: - | - -import_from.py:33:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` - | -31 | dirname(p) -32 | samefile(p) -33 | splitext(p) - | ^^^^^^^^ PTH122 -34 | with open(p) as fp: -35 | fp.read() - | - -import_from.py:34:6: PTH123 `open()` should be replaced by `Path.open()` - | -32 | samefile(p) -33 | splitext(p) -34 | with open(p) as fp: - | ^^^^ PTH123 -35 | fp.read() -36 | open(p).close() - | - -import_from.py:36:1: PTH123 `open()` should be replaced by `Path.open()` - | -34 | with open(p) as fp: -35 | fp.read() -36 | open(p).close() - | ^^^^ PTH123 - | - - diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_from_as.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_from_as.py.snap deleted file mode 100644 index fc8ac1544b..0000000000 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__import_from_as.py.snap +++ /dev/null @@ -1,250 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs ---- -import_from_as.py:14:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` - | -12 | q = "bar" -13 | -14 | a = xabspath(p) - | ^^^^^^^^ PTH100 -15 | aa = xchmod(p) -16 | aaa = xmkdir(p) - | - -import_from_as.py:15:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()` - | -14 | a = xabspath(p) -15 | aa = xchmod(p) - | ^^^^^^ PTH101 -16 | aaa = xmkdir(p) -17 | xmakedirs(p) - | - -import_from_as.py:16:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` - | -14 | a = xabspath(p) -15 | aa = xchmod(p) -16 | aaa = xmkdir(p) - | ^^^^^^ PTH102 -17 | xmakedirs(p) -18 | xrename(p) - | - -import_from_as.py:17:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` - | -15 | aa = xchmod(p) -16 | aaa = xmkdir(p) -17 | xmakedirs(p) - | ^^^^^^^^^ PTH103 -18 | xrename(p) -19 | xreplace(p) - | - -import_from_as.py:18:1: PTH104 `os.rename()` should be replaced by `Path.rename()` - | -16 | aaa = xmkdir(p) -17 | xmakedirs(p) -18 | xrename(p) - | ^^^^^^^ PTH104 -19 | xreplace(p) -20 | xrmdir(p) - | - -import_from_as.py:19:1: PTH105 `os.replace()` should be replaced by `Path.replace()` - | -17 | xmakedirs(p) -18 | xrename(p) -19 | xreplace(p) - | ^^^^^^^^ PTH105 -20 | xrmdir(p) -21 | xremove(p) - | - -import_from_as.py:20:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()` - | -18 | xrename(p) -19 | xreplace(p) -20 | xrmdir(p) - | ^^^^^^ PTH106 -21 | xremove(p) -22 | xunlink(p) - | - -import_from_as.py:21:1: PTH107 `os.remove()` should be replaced by `Path.unlink()` - | -19 | xreplace(p) -20 | xrmdir(p) -21 | xremove(p) - | ^^^^^^^ PTH107 -22 | xunlink(p) -23 | xgetcwd(p) - | - -import_from_as.py:22:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()` - | -20 | xrmdir(p) -21 | xremove(p) -22 | xunlink(p) - | ^^^^^^^ PTH108 -23 | xgetcwd(p) -24 | b = xexists(p) - | - -import_from_as.py:23:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` - | -21 | xremove(p) -22 | xunlink(p) -23 | xgetcwd(p) - | ^^^^^^^ PTH109 -24 | b = xexists(p) -25 | bb = xexpanduser(p) - | - -import_from_as.py:24:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()` - | -22 | xunlink(p) -23 | xgetcwd(p) -24 | b = xexists(p) - | ^^^^^^^ PTH110 -25 | bb = xexpanduser(p) -26 | bbb = xisdir(p) - | - -import_from_as.py:25:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()` - | -23 | xgetcwd(p) -24 | b = xexists(p) -25 | bb = xexpanduser(p) - | ^^^^^^^^^^^ PTH111 -26 | bbb = xisdir(p) -27 | bbbb = xisfile(p) - | - -import_from_as.py:26:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()` - | -24 | b = xexists(p) -25 | bb = xexpanduser(p) -26 | bbb = xisdir(p) - | ^^^^^^ PTH112 -27 | bbbb = xisfile(p) -28 | bbbbb = xislink(p) - | - -import_from_as.py:27:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()` - | -25 | bb = xexpanduser(p) -26 | bbb = xisdir(p) -27 | bbbb = xisfile(p) - | ^^^^^^^ PTH113 -28 | bbbbb = xislink(p) -29 | xreadlink(p) - | - -import_from_as.py:28:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()` - | -26 | bbb = xisdir(p) -27 | bbbb = xisfile(p) -28 | bbbbb = xislink(p) - | ^^^^^^^ PTH114 -29 | xreadlink(p) -30 | xstat(p) - | - -import_from_as.py:29:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()` - | -27 | bbbb = xisfile(p) -28 | bbbbb = xislink(p) -29 | xreadlink(p) - | ^^^^^^^^^ PTH115 -30 | xstat(p) -31 | xisabs(p) - | - -import_from_as.py:30:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` - | -28 | bbbbb = xislink(p) -29 | xreadlink(p) -30 | xstat(p) - | ^^^^^ PTH116 -31 | xisabs(p) -32 | xjoin(p, q) - | - -import_from_as.py:31:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()` - | -29 | xreadlink(p) -30 | xstat(p) -31 | xisabs(p) - | ^^^^^^ PTH117 -32 | xjoin(p, q) -33 | s.join((p, q)) - | - -import_from_as.py:32:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator - | -30 | xstat(p) -31 | xisabs(p) -32 | xjoin(p, q) - | ^^^^^ PTH118 -33 | s.join((p, q)) -34 | s.join([p, q]) - | - -import_from_as.py:33:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator - | -31 | xisabs(p) -32 | xjoin(p, q) -33 | s.join((p, q)) - | ^^^^^^ PTH118 -34 | s.join([p, q]) -35 | xbasename(p) - | - -import_from_as.py:34:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator - | -32 | xjoin(p, q) -33 | s.join((p, q)) -34 | s.join([p, q]) - | ^^^^^^ PTH118 -35 | xbasename(p) -36 | xdirname(p) - | - -import_from_as.py:35:1: PTH119 `os.path.basename()` should be replaced by `Path.name` - | -33 | s.join((p, q)) -34 | s.join([p, q]) -35 | xbasename(p) - | ^^^^^^^^^ PTH119 -36 | xdirname(p) -37 | xsamefile(p) - | - -import_from_as.py:36:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent` - | -34 | s.join([p, q]) -35 | xbasename(p) -36 | xdirname(p) - | ^^^^^^^^ PTH120 -37 | xsamefile(p) -38 | xsplitext(p) - | - -import_from_as.py:37:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` - | -35 | xbasename(p) -36 | xdirname(p) -37 | xsamefile(p) - | ^^^^^^^^^ PTH121 -38 | xsplitext(p) - | - -import_from_as.py:38:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` - | -36 | xdirname(p) -37 | xsamefile(p) -38 | xsplitext(p) - | ^^^^^^^^^ PTH122 - | - - diff --git a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__use_pathlib.py.snap b/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__use_pathlib.py.snap deleted file mode 100644 index 1bea340c06..0000000000 --- a/crates/ruff/src/rules/flake8_use_pathlib/snapshots/ruff__rules__flake8_use_pathlib__tests__use_pathlib.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/flake8_use_pathlib/mod.rs ---- - diff --git a/crates/ruff/src/rules/flynt/snapshots/ruff__rules__flynt__tests__FLY002_FLY002.py.snap b/crates/ruff/src/rules/flynt/snapshots/ruff__rules__flynt__tests__FLY002_FLY002.py.snap deleted file mode 100644 index aff724b257..0000000000 --- a/crates/ruff/src/rules/flynt/snapshots/ruff__rules__flynt__tests__FLY002_FLY002.py.snap +++ /dev/null @@ -1,144 +0,0 @@ ---- -source: crates/ruff/src/rules/flynt/mod.rs ---- -FLY002.py:5:7: FLY002 [*] Consider `f"{a} World"` instead of string join - | -4 | a = "Hello" -5 | ok1 = " ".join([a, " World"]) # OK - | ^^^^^^^^^^^^^^^^^^^^^^^ FLY002 -6 | ok2 = "".join(["Finally, ", a, " World"]) # OK -7 | ok3 = "x".join(("1", "2", "3")) # OK - | - = help: Replace with `f"{a} World"` - -ℹ Suggested fix -2 2 | from random import random, choice -3 3 | -4 4 | a = "Hello" -5 |-ok1 = " ".join([a, " World"]) # OK - 5 |+ok1 = f"{a} World" # OK -6 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK -7 7 | ok3 = "x".join(("1", "2", "3")) # OK -8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally - -FLY002.py:6:7: FLY002 [*] Consider `f"Finally, {a} World"` instead of string join - | -4 | a = "Hello" -5 | ok1 = " ".join([a, " World"]) # OK -6 | ok2 = "".join(["Finally, ", a, " World"]) # OK - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 -7 | ok3 = "x".join(("1", "2", "3")) # OK -8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally - | - = help: Replace with `f"Finally, {a} World"` - -ℹ Suggested fix -3 3 | -4 4 | a = "Hello" -5 5 | ok1 = " ".join([a, " World"]) # OK -6 |-ok2 = "".join(["Finally, ", a, " World"]) # OK - 6 |+ok2 = f"Finally, {a} World" # OK -7 7 | ok3 = "x".join(("1", "2", "3")) # OK -8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally -9 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) - -FLY002.py:7:7: FLY002 [*] Consider `"1x2x3"` instead of string join - | -5 | ok1 = " ".join([a, " World"]) # OK -6 | ok2 = "".join(["Finally, ", a, " World"]) # OK -7 | ok3 = "x".join(("1", "2", "3")) # OK - | ^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 -8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally -9 | ok5 = "a".join([random(), random()]) # OK (simple calls) - | - = help: Replace with `"1x2x3"` - -ℹ Suggested fix -4 4 | a = "Hello" -5 5 | ok1 = " ".join([a, " World"]) # OK -6 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK -7 |-ok3 = "x".join(("1", "2", "3")) # OK - 7 |+ok3 = "1x2x3" # OK -8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally -9 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) -10 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) - -FLY002.py:8:7: FLY002 [*] Consider `f"{1}y{2}y{3}"` instead of string join - | - 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK - 7 | ok3 = "x".join(("1", "2", "3")) # OK - 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally - | ^^^^^^^^^^^^^^^^^^^ FLY002 - 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) -10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) - | - = help: Replace with `f"{1}y{2}y{3}"` - -ℹ Suggested fix -5 5 | ok1 = " ".join([a, " World"]) # OK -6 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK -7 7 | ok3 = "x".join(("1", "2", "3")) # OK -8 |-ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally - 8 |+ok4 = f"{1}y{2}y{3}" # Technically OK, though would've been an error originally -9 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) -10 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) -11 11 | - -FLY002.py:9:7: FLY002 [*] Consider `f"{random()}a{random()}"` instead of string join - | - 7 | ok3 = "x".join(("1", "2", "3")) # OK - 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally - 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 -10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) - | - = help: Replace with `f"{random()}a{random()}"` - -ℹ Suggested fix -6 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK -7 7 | ok3 = "x".join(("1", "2", "3")) # OK -8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally -9 |-ok5 = "a".join([random(), random()]) # OK (simple calls) - 9 |+ok5 = f"{random()}a{random()}" # OK (simple calls) -10 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) -11 11 | -12 12 | nok1 = "x".join({"4", "5", "yee"}) # Not OK (set) - -FLY002.py:10:7: FLY002 [*] Consider `f"{secrets.token_urlsafe()}a{secrets.token_hex()}"` instead of string join - | - 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally - 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) -10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 -11 | -12 | nok1 = "x".join({"4", "5", "yee"}) # Not OK (set) - | - = help: Replace with `f"{secrets.token_urlsafe()}a{secrets.token_hex()}"` - -ℹ Suggested fix -7 7 | ok3 = "x".join(("1", "2", "3")) # OK -8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally -9 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) -10 |-ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) - 10 |+ok6 = f"{secrets.token_urlsafe()}a{secrets.token_hex()}" # OK (attr calls) -11 11 | -12 12 | nok1 = "x".join({"4", "5", "yee"}) # Not OK (set) -13 13 | nok2 = a.join(["1", "2", "3"]) # Not OK (not a static joiner) - -FLY002.py:23:11: FLY002 [*] Consider `f"{url}{filename}"` instead of string join - | -21 | # Regression test for: https://github.com/astral-sh/ruff/issues/7197 -22 | def create_file_public_url(url, filename): -23 | return''.join([url, filename]) - | ^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 - | - = help: Replace with `f"{url}{filename}"` - -ℹ Suggested fix -20 20 | -21 21 | # Regression test for: https://github.com/astral-sh/ruff/issues/7197 -22 22 | def create_file_public_url(url, filename): -23 |- return''.join([url, filename]) - 23 |+ return f"{url}{filename}" - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__1_separate_subpackage_first_and_third_party_imports.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__1_separate_subpackage_first_and_third_party_imports.py.snap deleted file mode 100644 index 41e6eb47f6..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__1_separate_subpackage_first_and_third_party_imports.py.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / import sys -2 | | import baz -3 | | from foo import bar, baz -4 | | from foo.bar import blah, blub -5 | | from foo.bar.baz import something -6 | | import foo -7 | | import foo.bar -8 | | import foo.bar.baz - | - = help: Organize imports - -ℹ Fix -1 1 | import sys - 2 |+ - 3 |+import foo - 4 |+from foo import bar, baz - 5 |+ -2 6 | import baz -3 |-from foo import bar, baz - 7 |+import foo.bar - 8 |+import foo.bar.baz -4 9 | from foo.bar import blah, blub -5 10 | from foo.bar.baz import something -6 |-import foo -7 |-import foo.bar -8 |-import foo.bar.baz - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__2_separate_subpackage_first_and_third_party_imports.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__2_separate_subpackage_first_and_third_party_imports.py.snap deleted file mode 100644 index fbf2a1df8d..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__2_separate_subpackage_first_and_third_party_imports.py.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / import sys -2 | | import baz -3 | | from foo import bar, baz -4 | | from foo.bar import blah, blub -5 | | from foo.bar.baz import something -6 | | import foo -7 | | import foo.bar -8 | | import foo.bar.baz - | - = help: Organize imports - -ℹ Fix -1 1 | import sys - 2 |+ -2 3 | import baz -3 |-from foo import bar, baz - 4 |+import foo.bar - 5 |+import foo.bar.baz -4 6 | from foo.bar import blah, blub -5 7 | from foo.bar.baz import something - 8 |+ -6 9 | import foo -7 |-import foo.bar -8 |-import foo.bar.baz - 10 |+from foo import bar, baz - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__add_newline_before_comments.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__add_newline_before_comments.py.snap deleted file mode 100644 index 8089cce5f5..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__add_newline_before_comments.py.snap +++ /dev/null @@ -1,28 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -add_newline_before_comments.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / import os -2 | | # This is a comment in the same section, so we need to add one newline. -3 | | import sys -4 | | import numpy as np -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 - | - = help: Organize imports - -ℹ Fix -1 1 | import os - 2 |+ -2 3 | # This is a comment in the same section, so we need to add one newline. -3 4 | import sys - 5 |+ -4 6 | import numpy as np - 7 |+ -5 8 | # This is a comment, but it starts a new section, so we don't need to add a newline -6 9 | # before it. -7 10 | import leading_prefix - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__as_imports_comments.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__as_imports_comments.py.snap deleted file mode 100644 index 572fada48a..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__as_imports_comments.py.snap +++ /dev/null @@ -1,45 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -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 | | - 5 | | from bar import ( # Comment on `bar` - 6 | | Member, # Comment on `Member` - 7 | | ) - 8 | | - 9 | | from baz import ( # Comment on `baz` -10 | | Member as Alias # Comment on `Alias` -11 | | ) -12 | | -13 | | from bop import ( # Comment on `bop` -14 | | Member # Comment on `Member` -15 | | ) - | - = help: Organize imports - -ℹ Fix -1 |-from foo import ( # Comment on `foo` -2 |- Member as Alias, # Comment on `Alias` -3 |-) -4 |- -5 1 | from bar import ( # Comment on `bar` -6 2 | Member, # Comment on `Member` -7 |-) -8 |- -9 |-from baz import ( # Comment on `baz` -10 |- Member as Alias # Comment on `Alias` -11 3 | ) -12 |- -13 |-from bop import ( # Comment on `bop` -14 |- Member # Comment on `Member` - 4 |+from baz import Member as Alias # Comment on `Alias` # Comment on `baz` - 5 |+from bop import Member # Comment on `Member` # Comment on `bop` - 6 |+from foo import ( # Comment on `foo` - 7 |+ Member as Alias, # Comment on `Alias` -15 8 | ) - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__bom_sorted.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__bom_sorted.py.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__bom_sorted.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__bom_unsorted.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__bom_unsorted.py.snap deleted file mode 100644 index ac86dda07b..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__bom_unsorted.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -bom_unsorted.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | import foo - | _^ -2 | | import bar - | - = help: Organize imports - -ℹ Fix -1 |-import foo -2 |-import bar - 1 |+import bar - 2 |+import foo - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__case_sensitive_case_sensitive.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__case_sensitive_case_sensitive.py.snap deleted file mode 100644 index c6fe266802..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__case_sensitive_case_sensitive.py.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -case_sensitive.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / import A -2 | | import B -3 | | import b -4 | | import C -5 | | import d -6 | | import E -7 | | import f -8 | | from g import a, B, c -9 | | from h import A, b, C - | - = help: Organize imports - -ℹ Fix -1 1 | import A -2 2 | import B - 3 |+import C - 4 |+import E -3 5 | import b -4 |-import C -5 6 | import d -6 |-import E -7 7 | import f -8 |-from g import a, B, c -9 |-from h import A, b, C - 8 |+from g import B, a, c - 9 |+from h import A, C, b - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__closest_to_furthest_relative_imports_order.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__closest_to_furthest_relative_imports_order.py.snap deleted file mode 100644 index 920a8da11a..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__closest_to_furthest_relative_imports_order.py.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -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 - | - = help: Organize imports - -ℹ Fix - 1 |+from . import c - 2 |+from .. import b -1 3 | from ... import a -2 |-from .. import b -3 |-from . import c - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combine_as_imports.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combine_as_imports.py.snap deleted file mode 100644 index ae83cbda38..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combine_as_imports.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -combine_as_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / from module import Class as C -2 | | from module import CONSTANT -3 | | from module import function -4 | | from module import function as f - | - = help: Organize imports - -ℹ Fix - 1 |+from module import CONSTANT, function -1 2 | from module import Class as C -2 |-from module import CONSTANT -3 |-from module import function -4 3 | from module import function as f - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combine_as_imports_combine_as_imports.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combine_as_imports_combine_as_imports.py.snap deleted file mode 100644 index 7460bca867..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combine_as_imports_combine_as_imports.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -combine_as_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / from module import Class as C -2 | | from module import CONSTANT -3 | | from module import function -4 | | from module import function as f - | - = help: Organize imports - -ℹ Fix -1 |-from module import Class as C -2 |-from module import CONSTANT -3 |-from module import function -4 |-from module import function as f - 1 |+from module import CONSTANT, Class as C, function, function as f - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combine_import_from.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combine_import_from.py.snap deleted file mode 100644 index 998a4bb3d8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combine_import_from.py.snap +++ /dev/null @@ -1,29 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -combine_import_from.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / from collections import Awaitable -2 | | from collections import AsyncIterable -3 | | from collections import Collection -4 | | from collections import ChainMap -5 | | from collections import MutableSequence, MutableMapping - | - = help: Organize imports - -ℹ Fix -1 |-from collections import Awaitable -2 |-from collections import AsyncIterable -3 |-from collections import Collection -4 |-from collections import ChainMap -5 |-from collections import MutableSequence, MutableMapping - 1 |+from collections import ( - 2 |+ AsyncIterable, - 3 |+ Awaitable, - 4 |+ ChainMap, - 5 |+ Collection, - 6 |+ MutableMapping, - 7 |+ MutableSequence, - 8 |+) - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combined_required_imports_docstring.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combined_required_imports_docstring.py.snap deleted file mode 100644 index c5a0bd69f0..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combined_required_imports_docstring.py.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` - | -1 | """Hello, world!""" - | I002 -2 | -3 | x = 1 - | - = help: Insert required import: `from future import annotations` - -ℹ Fix -1 1 | """Hello, world!""" - 2 |+from __future__ import annotations -2 3 | -3 4 | x = 1 - -docstring.py:1:1: I002 [*] Missing required import: `from __future__ import generator_stop` - | -1 | """Hello, world!""" - | I002 -2 | -3 | x = 1 - | - = help: Insert required import: `from future import generator_stop` - -ℹ Fix -1 1 | """Hello, world!""" - 2 |+from __future__ import generator_stop -2 3 | -3 4 | x = 1 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combined_required_imports_docstring.pyi.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combined_required_imports_docstring.pyi.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combined_required_imports_docstring.pyi.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combined_required_imports_docstring_only.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combined_required_imports_docstring_only.py.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combined_required_imports_docstring_only.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combined_required_imports_empty.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combined_required_imports_empty.py.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__combined_required_imports_empty.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__comments.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__comments.py.snap deleted file mode 100644 index b93620b594..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__comments.py.snap +++ /dev/null @@ -1,89 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -comments.py:3:1: I001 [*] Import block is un-sorted or un-formatted - | - 1 | # Comment 1 - 2 | # Comment 2 - 3 | / import D - 4 | | - 5 | | # Comment 3a - 6 | | import C - 7 | | - 8 | | # Comment 3b - 9 | | import C -10 | | -11 | | import B # Comment 4 -12 | | -13 | | # Comment 5 -14 | | -15 | | # Comment 6 -16 | | from A import ( -17 | | a, # Comment 7 -18 | | b, -19 | | c, # Comment 8 -20 | | ) -21 | | from A import ( -22 | | a, # Comment 9 -23 | | b, # Comment 10 -24 | | c, # Comment 11 -25 | | ) -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 | | -30 | | from E import a # Comment 1 -31 | | -32 | | from F import a # Comment 1 -33 | | from F import b - | - = help: Organize imports - -ℹ Fix -1 1 | # Comment 1 -2 2 | # Comment 2 -3 |-import D - 3 |+import B # Comment 4 -4 4 | -5 5 | # Comment 3a -6 |-import C -7 |- -8 6 | # Comment 3b -9 7 | import C -10 |- -11 |-import B # Comment 4 - 8 |+import D -12 9 | -13 10 | # Comment 5 -14 |- -15 11 | # Comment 6 -16 12 | from A import ( -17 |- a, # Comment 7 -18 |- b, -19 |- c, # Comment 8 - 13 |+ a, # Comment 7 # Comment 9 - 14 |+ b, # Comment 10 - 15 |+ c, # Comment 8 # Comment 11 -20 16 | ) -21 |-from A import ( -22 |- a, # Comment 9 -23 |- b, # Comment 10 -24 |- c, # Comment 11 - 17 |+from D import ( - 18 |+ a_long_name_to_force_multiple_lines, # Comment 12 - 19 |+ another_long_name_to_force_multiple_lines, # Comment 13 -25 20 | ) -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 |- -30 21 | from E import a # Comment 1 -31 |- -32 |-from F import a # Comment 1 -33 |-from F import b - 22 |+from F import ( - 23 |+ a, # Comment 1 - 24 |+ b, - 25 |+) - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__deduplicate_imports.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__deduplicate_imports.py.snap deleted file mode 100644 index 04805215be..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__deduplicate_imports.py.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -deduplicate_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / import os -2 | | import os -3 | | import os as os1 -4 | | import os as os2 - | - = help: Organize imports - -ℹ Fix -1 1 | import os -2 |-import os -3 2 | import os as os1 -4 3 | import os as os2 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__detect_same_package.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__detect_same_package.snap deleted file mode 100644 index 4b75e7ede6..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__detect_same_package.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -bar.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / import os -2 | | import pandas -3 | | import foo.baz - | - = help: Organize imports - -ℹ Fix -1 1 | import os - 2 |+ -2 3 | import pandas - 4 |+ -3 5 | import foo.baz - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__fit_line_length.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__fit_line_length.py.snap deleted file mode 100644 index 6c32ed23b6..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__fit_line_length.py.snap +++ /dev/null @@ -1,42 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -fit_line_length.py:7:1: I001 [*] Import block is un-sorted or un-formatted - | - 6 | if indented: - 7 | / from line_with_88 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - 8 | | from line_with_89 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - 9 | | from line_with_90 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -10 | | from line_with_91 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -11 | | from line_with_92 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -12 | | from line_with_93 import ( -13 | | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, -14 | | ) - | - = help: Organize imports - -ℹ Fix -5 5 | -6 6 | if indented: -7 7 | from line_with_88 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -8 |- from line_with_89 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -9 |- from line_with_90 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -10 |- from line_with_91 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -11 |- from line_with_92 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - 8 |+ from line_with_89 import ( - 9 |+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, - 10 |+ ) - 11 |+ from line_with_90 import ( - 12 |+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, - 13 |+ ) - 14 |+ from line_with_91 import ( - 15 |+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, - 16 |+ ) - 17 |+ from line_with_92 import ( - 18 |+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, - 19 |+ ) -12 20 | from line_with_93 import ( -13 21 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, -14 22 | ) - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__fit_line_length_comment.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__fit_line_length_comment.py.snap deleted file mode 100644 index 9b4bae938a..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__fit_line_length_comment.py.snap +++ /dev/null @@ -1,36 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -fit_line_length_comment.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / import a -2 | | # Don't take this comment into account when determining whether the next import can fit on one line. -3 | | from b import c -4 | | from d import e # Do take this comment into account when determining whether the next import can fit on one line. -5 | | # The next import fits on one line. -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 - | - = help: Organize imports - -ℹ Fix -1 1 | import a - 2 |+ -2 3 | # Don't take this comment into account when determining whether the next import can fit on one line. -3 4 | from b import c -4 |-from d import e # Do take this comment into account when determining whether the next import can fit on one line. - 5 |+from d import ( - 6 |+ e, # Do take this comment into account when determining whether the next import can fit on one line. - 7 |+) - 8 |+ -5 9 | # The next import fits on one line. -6 10 | 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ℝ - 11 |+ -7 12 | # 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 - 13 |+from h import ( - 14 |+ i, # 012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9 - 15 |+) - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_single_line_force_single_line.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_single_line_force_single_line.py.snap deleted file mode 100644 index c7247981b9..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_single_line_force_single_line.py.snap +++ /dev/null @@ -1,85 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -force_single_line.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | - 1 | / import sys, math - 2 | | from os import path, uname - 3 | | from json import detect_encoding - 4 | | from json import dump - 5 | | from json import dumps as json_dumps - 6 | | from json import load - 7 | | from json import loads as json_loads - 8 | | from logging.handlers import StreamHandler, FileHandler - 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 | | -16 | | from foo import bar # comment 3 -17 | | from foo2 import bar2 # comment 4 -18 | | from foo3 import bar3, baz3 # comment 5 -19 | | -20 | | # comment 6 -21 | | from bar import ( -22 | | a, # comment 7 -23 | | b, # comment 8 -24 | | ) -25 | | -26 | | # comment 9 -27 | | from baz import * # comment 10 - | - = help: Organize imports - -ℹ Fix -1 |-import sys, math -2 |-from os import path, uname - 1 |+import math - 2 |+import sys -3 3 | from json import detect_encoding -4 4 | from json import dump -5 5 | from json import dumps as json_dumps -6 6 | from json import load -7 7 | from json import loads as json_loads -8 |-from logging.handlers import StreamHandler, FileHandler - 8 |+from logging.handlers import FileHandler, StreamHandler - 9 |+from os import path, uname -9 10 | -10 |-# comment 1 -11 |-from third_party import lib1, lib2, \ -12 |- lib3, lib7, lib5, lib6 -13 |-# comment 2 -14 |-from third_party import lib4 - 11 |+# comment 6 - 12 |+from bar import a # comment 7 - 13 |+from bar import b # comment 8 -15 14 | - 15 |+# comment 9 - 16 |+from baz import * # comment 10 -16 17 | from foo import bar # comment 3 -17 18 | from foo2 import bar2 # comment 4 -18 |-from foo3 import bar3, baz3 # comment 5 - 19 |+from foo3 import bar3 # comment 5 - 20 |+from foo3 import baz3 # comment 5 -19 21 | -20 |-# comment 6 -21 |-from bar import ( -22 |- a, # comment 7 -23 |- b, # comment 8 -24 |-) - 22 |+# comment 1 - 23 |+from third_party import lib1 - 24 |+from third_party import lib2 - 25 |+from third_party import lib3 -25 26 | -26 |-# comment 9 -27 |-from baz import * # comment 10 - 27 |+# comment 2 - 28 |+from third_party import lib4 - 29 |+from third_party import lib5 - 30 |+from third_party import lib6 - 31 |+from third_party import lib7 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_sort_within_sections.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_sort_within_sections.py.snap deleted file mode 100644 index 6d018eb2e3..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_sort_within_sections.py.snap +++ /dev/null @@ -1,43 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -force_sort_within_sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | - 1 | / from a import a1 # import_from - 2 | | from c import * # import_from_star - 3 | | import a # import - 4 | | import c.d - 5 | | from z import z1 - 6 | | import b as b1 # import_as - 7 | | import z - 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 - | - = help: Organize imports - -ℹ Fix -1 |-from a import a1 # import_from -2 |-from c import * # import_from_star -3 1 | import a # import - 2 |+import b as b1 # import_as -4 3 | import c.d - 4 |+import z - 5 |+from a import a1 # import_from - 6 |+from c import * # import_from_star -5 7 | from z import z1 -6 |-import b as b1 # import_as -7 |-import z -8 8 | - 9 |+from ...grandparent import fn3 -9 10 | from ..parent import * - 11 |+from . import my -10 12 | from .my import fn -11 |-from . import my -12 13 | from .my.nested import fn2 -13 |-from ...grandparent import fn3 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_sort_within_sections_force_sort_within_sections.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_sort_within_sections_force_sort_within_sections.py.snap deleted file mode 100644 index a306bd2cf2..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_sort_within_sections_force_sort_within_sections.py.snap +++ /dev/null @@ -1,44 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -force_sort_within_sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | - 1 | / from a import a1 # import_from - 2 | | from c import * # import_from_star - 3 | | import a # import - 4 | | import c.d - 5 | | from z import z1 - 6 | | import b as b1 # import_as - 7 | | import z - 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 - | - = help: Organize imports - -ℹ Fix -1 |-from a import a1 # import_from -2 |-from c import * # import_from_star - 1 |+import z - 2 |+from z import z1 -3 3 | import a # import - 4 |+from a import a1 # import_from - 5 |+import b as b1 # import_as - 6 |+from c import * # import_from_star -4 7 | import c.d -5 |-from z import z1 -6 |-import b as b1 # import_as -7 |-import z -8 8 | - 9 |+from ...grandparent import fn3 -9 10 | from ..parent import * - 11 |+from . import my -10 12 | from .my import fn -11 |-from . import my -12 13 | from .my.nested import fn2 -13 |-from ...grandparent import fn3 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_to_top.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_to_top.py.snap deleted file mode 100644 index 26418b34ad..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_to_top.py.snap +++ /dev/null @@ -1,67 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | - 1 | / import lib6 - 2 | | import lib2 - 3 | | import lib5 - 4 | | import lib1 - 5 | | import lib3 - 6 | | import lib4 - 7 | | - 8 | | import foo - 9 | | import z -10 | | from foo import bar -11 | | from lib1 import foo -12 | | from lib2 import foo -13 | | from lib1.lib2 import foo -14 | | from foo.lib1.bar import baz -15 | | from lib4 import lib1 -16 | | from lib5 import lib2 -17 | | from lib4 import lib2 -18 | | from lib5 import lib1 -19 | | -20 | | import lib3.lib4 -21 | | import lib3.lib4.lib5 -22 | | from lib3.lib4 import foo -23 | | from lib3.lib4.lib5 import foo - | - = help: Organize imports - -ℹ Fix -1 |-import lib6 - 1 |+import foo - 2 |+import lib1 -2 3 | import lib2 -3 |-import lib5 -4 |-import lib1 -5 4 | import lib3 - 5 |+import lib3.lib4 - 6 |+import lib3.lib4.lib5 -6 7 | import lib4 -7 |- -8 |-import foo - 8 |+import lib5 - 9 |+import lib6 -9 10 | import z -10 11 | from foo import bar - 12 |+from foo.lib1.bar import baz -11 13 | from lib1 import foo -12 |-from lib2 import foo -13 14 | from lib1.lib2 import foo -14 |-from foo.lib1.bar import baz -15 |-from lib4 import lib1 -16 |-from lib5 import lib2 -17 |-from lib4 import lib2 -18 |-from lib5 import lib1 -19 |- -20 |-import lib3.lib4 -21 |-import lib3.lib4.lib5 - 15 |+from lib2 import foo -22 16 | from lib3.lib4 import foo -23 17 | from lib3.lib4.lib5 import foo - 18 |+from lib4 import lib1, lib2 - 19 |+from lib5 import lib1, lib2 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_to_top_force_to_top.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_to_top_force_to_top.py.snap deleted file mode 100644 index 229aef46ee..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_to_top_force_to_top.py.snap +++ /dev/null @@ -1,70 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | - 1 | / import lib6 - 2 | | import lib2 - 3 | | import lib5 - 4 | | import lib1 - 5 | | import lib3 - 6 | | import lib4 - 7 | | - 8 | | import foo - 9 | | import z -10 | | from foo import bar -11 | | from lib1 import foo -12 | | from lib2 import foo -13 | | from lib1.lib2 import foo -14 | | from foo.lib1.bar import baz -15 | | from lib4 import lib1 -16 | | from lib5 import lib2 -17 | | from lib4 import lib2 -18 | | from lib5 import lib1 -19 | | -20 | | import lib3.lib4 -21 | | import lib3.lib4.lib5 -22 | | from lib3.lib4 import foo -23 | | from lib3.lib4.lib5 import foo - | - = help: Organize imports - -ℹ Fix -1 |-import lib6 -2 |-import lib2 -3 |-import lib5 -4 1 | import lib1 -5 2 | import lib3 -6 |-import lib4 -7 |- - 3 |+import lib3.lib4 - 4 |+import lib5 - 5 |+import z -8 6 | import foo -9 |-import z - 7 |+import lib2 - 8 |+import lib3.lib4.lib5 - 9 |+import lib4 - 10 |+import lib6 - 11 |+from lib1 import foo - 12 |+from lib3.lib4 import foo - 13 |+from lib5 import lib1, lib2 -10 14 | from foo import bar -11 |-from lib1 import foo -12 |-from lib2 import foo -13 |-from lib1.lib2 import foo -14 15 | from foo.lib1.bar import baz -15 |-from lib4 import lib1 -16 |-from lib5 import lib2 -17 |-from lib4 import lib2 -18 |-from lib5 import lib1 -19 |- -20 |-import lib3.lib4 -21 |-import lib3.lib4.lib5 -22 |-from lib3.lib4 import foo - 16 |+from lib1.lib2 import foo - 17 |+from lib2 import foo -23 18 | from lib3.lib4.lib5 import foo - 19 |+from lib4 import lib1, lib2 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_wrap_aliases.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_wrap_aliases.py.snap deleted file mode 100644 index 7c1ab3dfdf..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_wrap_aliases.py.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -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 - | - = help: Organize imports - -ℹ Fix -1 |-from .a import a1 as a1, a2 as a2 - 1 |+from .a import a1 as a1 - 2 |+from .a import a2 as a2 -2 3 | from .b import b1 as b1 -3 4 | from .c import c1 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_wrap_aliases_force_wrap_aliases.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_wrap_aliases_force_wrap_aliases.py.snap deleted file mode 100644 index e2bef255ce..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__force_wrap_aliases_force_wrap_aliases.py.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -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 - | - = help: Organize imports - -ℹ Fix -1 |-from .a import a1 as a1, a2 as a2 - 1 |+from .a import ( - 2 |+ a1 as a1, - 3 |+ a2 as a2, - 4 |+) -2 5 | from .b import b1 as b1 -3 6 | from .c import c1 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__forced_separate.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__forced_separate.py.snap deleted file mode 100644 index 1e9308ae31..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__forced_separate.py.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -forced_separate.py:3:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | # office_helper and tests are both first-party, -2 | # but we want tests and experiments to be separated, in that order -3 | / from office_helper.core import CoreState -4 | | import tests.common.foo as tcf -5 | | from tests.common import async_mock_service -6 | | from experiments.starry import * -7 | | from experiments.weird import varieties -8 | | from office_helper.assistants import entity_registry as er - | - = help: Organize imports - -ℹ Fix -1 1 | # office_helper and tests are both first-party, -2 2 | # but we want tests and experiments to be separated, in that order - 3 |+from office_helper.assistants import entity_registry as er -3 4 | from office_helper.core import CoreState - 5 |+ -4 6 | import tests.common.foo as tcf -5 7 | from tests.common import async_mock_service - 8 |+ -6 9 | from experiments.starry import * -7 10 | from experiments.weird import varieties -8 |-from office_helper.assistants import entity_registry as er - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__glob_1_separate_subpackage_first_and_third_party_imports.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__glob_1_separate_subpackage_first_and_third_party_imports.py.snap deleted file mode 100644 index 41e6eb47f6..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__glob_1_separate_subpackage_first_and_third_party_imports.py.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / import sys -2 | | import baz -3 | | from foo import bar, baz -4 | | from foo.bar import blah, blub -5 | | from foo.bar.baz import something -6 | | import foo -7 | | import foo.bar -8 | | import foo.bar.baz - | - = help: Organize imports - -ℹ Fix -1 1 | import sys - 2 |+ - 3 |+import foo - 4 |+from foo import bar, baz - 5 |+ -2 6 | import baz -3 |-from foo import bar, baz - 7 |+import foo.bar - 8 |+import foo.bar.baz -4 9 | from foo.bar import blah, blub -5 10 | from foo.bar.baz import something -6 |-import foo -7 |-import foo.bar -8 |-import foo.bar.baz - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__if_elif_else.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__if_elif_else.py.snap deleted file mode 100644 index 4a9a844881..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__if_elif_else.py.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -if_elif_else.py:6:1: I001 [*] Import block is un-sorted or un-formatted - | -4 | from setuptools.command.sdist import sdist as _sdist -5 | else: -6 | / from setuptools.command.sdist import sdist as _sdist -7 | | from distutils.command.sdist import sdist as _sdist - | - = help: Organize imports - -ℹ Fix -3 3 | elif "setuptools" in sys.modules: -4 4 | from setuptools.command.sdist import sdist as _sdist -5 5 | else: - 6 |+ from distutils.command.sdist import sdist as _sdist -6 7 | from setuptools.command.sdist import sdist as _sdist -7 |- from distutils.command.sdist import sdist as _sdist - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__import_from_after_import.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__import_from_after_import.py.snap deleted file mode 100644 index 53a884c3e5..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__import_from_after_import.py.snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -import_from_after_import.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / from collections import Collection -2 | | import os - | - = help: Organize imports - -ℹ Fix - 1 |+import os -1 2 | from collections import Collection -2 |-import os - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__inline_comments.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__inline_comments.py.snap deleted file mode 100644 index 5e7526984b..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__inline_comments.py.snap +++ /dev/null @@ -1,40 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -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 | | - 5 | | from b.prometheus.metrics import ( - 6 | | TERMINAL_CURRENTLY_RUNNING_TOTAL, # type:ignore[attr-defined] - 7 | | ) - 8 | | - 9 | | from c.prometheus.metrics import TERMINAL_CURRENTLY_RUNNING_TOTAL # type:ignore[attr-defined] -10 | | -11 | | from d.prometheus.metrics import TERMINAL_CURRENTLY_RUNNING_TOTAL, OTHER_RUNNING_TOTAL # type:ignore[attr-defined] - | - = help: Organize imports - -ℹ Fix -1 1 | from a.prometheus.metrics import ( # type:ignore[attr-defined] -2 2 | TERMINAL_CURRENTLY_RUNNING_TOTAL, -3 3 | ) -4 |- -5 4 | from b.prometheus.metrics import ( -6 5 | TERMINAL_CURRENTLY_RUNNING_TOTAL, # type:ignore[attr-defined] -7 6 | ) -8 |- -9 |-from c.prometheus.metrics import TERMINAL_CURRENTLY_RUNNING_TOTAL # type:ignore[attr-defined] -10 |- -11 |-from d.prometheus.metrics import TERMINAL_CURRENTLY_RUNNING_TOTAL, OTHER_RUNNING_TOTAL # type:ignore[attr-defined] - 7 |+from c.prometheus.metrics import ( - 8 |+ TERMINAL_CURRENTLY_RUNNING_TOTAL, # type:ignore[attr-defined] - 9 |+) - 10 |+from d.prometheus.metrics import ( # type:ignore[attr-defined] - 11 |+ OTHER_RUNNING_TOTAL, - 12 |+ TERMINAL_CURRENTLY_RUNNING_TOTAL, - 13 |+) - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__insert_empty_lines.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__insert_empty_lines.py.snap deleted file mode 100644 index a287c38ba2..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__insert_empty_lines.py.snap +++ /dev/null @@ -1,88 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -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 -4 | import os -5 | import sys - | - = help: Organize imports - -ℹ Fix -1 1 | import a -2 2 | import b - 3 |+ -3 4 | x = 1 -4 5 | import os -5 6 | import sys - -insert_empty_lines.py:4:1: I001 [*] Import block is un-sorted or un-formatted - | -2 | import b -3 | x = 1 -4 | / import os -5 | | import sys -6 | | def f(): - | |_^ I001 -7 | pass -8 | if True: - | - = help: Organize imports - -ℹ Fix -3 3 | x = 1 -4 4 | import os -5 5 | import sys - 6 |+ - 7 |+ -6 8 | def f(): -7 9 | pass -8 10 | if True: - -insert_empty_lines.py:14:1: I001 [*] Import block is un-sorted or un-formatted - | -12 | class X: pass -13 | y = 1 -14 | / import os -15 | | import sys -16 | | """Docstring""" - | |_^ I001 -17 | -18 | if True: - | - = help: Organize imports - -ℹ Fix -13 13 | y = 1 -14 14 | import os -15 15 | import sys - 16 |+ -16 17 | """Docstring""" -17 18 | -18 19 | if True: - -insert_empty_lines.py:52:1: I001 [*] Import block is un-sorted or un-formatted - | -52 | / import os -53 | | -54 | | # Comment goes here. - | |_^ I001 -55 | def f(): -56 | pass - | - = help: Organize imports - -ℹ Fix -51 51 | -52 52 | import os -53 53 | - 54 |+ -54 55 | # Comment goes here. -55 56 | def f(): -56 57 | pass - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__insert_empty_lines.pyi.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__insert_empty_lines.pyi.snap deleted file mode 100644 index 2a85d8bfcf..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__insert_empty_lines.pyi.snap +++ /dev/null @@ -1,67 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -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 -4 | import os -5 | import sys - | - = help: Organize imports - -ℹ Fix -1 1 | import a -2 2 | import b - 3 |+ -3 4 | x = 1 -4 5 | import os -5 6 | import sys - -insert_empty_lines.pyi:4:1: I001 [*] Import block is un-sorted or un-formatted - | -2 | import b -3 | x = 1 -4 | / import os -5 | | import sys -6 | | def f(): - | |_^ I001 -7 | pass -8 | if True: - | - = help: Organize imports - -ℹ Fix -3 3 | x = 1 -4 4 | import os -5 5 | import sys - 6 |+ -6 7 | def f(): -7 8 | pass -8 9 | if True: - -insert_empty_lines.pyi:14:1: I001 [*] Import block is un-sorted or un-formatted - | -12 | class X: pass -13 | y = 1 -14 | / import os -15 | | import sys -16 | | """Docstring""" - | |_^ I001 -17 | -18 | if True: - | - = help: Organize imports - -ℹ Fix -13 13 | y = 1 -14 14 | import os -15 15 | import sys - 16 |+ -16 17 | """Docstring""" -17 18 | -18 19 | if True: - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__isort_skip_file.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__isort_skip_file.py.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__isort_skip_file.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__known_local_folder_separate_local_folder_imports.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__known_local_folder_separate_local_folder_imports.py.snap deleted file mode 100644 index c46c4efd56..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__known_local_folder_separate_local_folder_imports.py.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / import sys -2 | | import ruff -3 | | import leading_prefix -4 | | import os -5 | | from . import leading_prefix - | - = help: Organize imports - -ℹ Fix - 1 |+import os -1 2 | import sys - 3 |+ - 4 |+import leading_prefix - 5 |+ -2 6 | import ruff -3 |-import leading_prefix -4 |-import os -5 7 | from . import leading_prefix - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__leading_prefix.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__leading_prefix.py.snap deleted file mode 100644 index c7ae53662f..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__leading_prefix.py.snap +++ /dev/null @@ -1,46 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -leading_prefix.py:1:8: I001 Import block is un-sorted or un-formatted - | -1 | x = 1; import sys - | ________^ -2 | | import os - | |_________^ I001 -3 | -4 | if True: - | - = help: Organize imports - -leading_prefix.py:5:12: I001 Import block is un-sorted or un-formatted - | -4 | if True: -5 | x = 1; import sys - | ____________^ -6 | | import os - | |_____________^ I001 -7 | -8 | if True: - | - = help: Organize imports - -leading_prefix.py:10:9: I001 Import block is un-sorted or un-formatted - | - 8 | if True: - 9 | x = 1; \ -10 | import os - | ^^^^^^^^^ I001 -11 | -12 | x = 1; \ - | - = help: Organize imports - -leading_prefix.py:13:1: I001 Import block is un-sorted or un-formatted - | -12 | x = 1; \ -13 | import os - | ^^^^^^^^^ I001 - | - = help: Organize imports - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__lines_after_imports_lines_after_imports_class_after.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__lines_after_imports_lines_after_imports_class_after.py.snap deleted file mode 100644 index d49496d35a..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__lines_after_imports_lines_after_imports_class_after.py.snap +++ /dev/null @@ -1,39 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -lines_after_imports_class_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | - 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 | | class Thing(object): - | |_^ I001 -11 | name: str -12 | def __init__(self, name: str): - | - = help: Organize imports - -ℹ Fix -2 2 | -3 3 | from typing import Any -4 4 | - 5 |+from my_first_party import my_first_party_object -5 6 | from requests import Session -6 7 | -7 |-from my_first_party import my_first_party_object - 8 |+from . import my_local_folder_object - 9 |+ - 10 |+ -8 11 | -9 |-from . import my_local_folder_object -10 12 | class Thing(object): -11 13 | name: str -12 14 | def __init__(self, name: str): - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__lines_after_imports_lines_after_imports_func_after.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__lines_after_imports_lines_after_imports_func_after.py.snap deleted file mode 100644 index dc6bc6c11f..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__lines_after_imports_lines_after_imports_func_after.py.snap +++ /dev/null @@ -1,54 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -lines_after_imports_func_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | - 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 | | -14 | | -15 | | -16 | | -17 | | -18 | | -19 | | -20 | | -21 | | def main(): - | |_^ I001 -22 | my_local_folder_object.get() - | - = help: Organize imports - -ℹ Fix -2 2 | -3 3 | from typing import Any -4 4 | -5 |-from requests import Session -6 |- -7 5 | from my_first_party import my_first_party_object - 6 |+from requests import Session -8 7 | -9 8 | from . import my_local_folder_object -10 |- -11 |- -12 |- -13 |- -14 |- -15 |- -16 |- -17 |- -18 9 | -19 10 | -20 11 | - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__lines_after_imports_lines_after_imports_nothing_after.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__lines_after_imports_lines_after_imports_nothing_after.py.snap deleted file mode 100644 index aa2fbb6995..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__lines_after_imports_lines_after_imports_nothing_after.py.snap +++ /dev/null @@ -1,29 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -lines_after_imports_nothing_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -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 - | - = help: Organize imports - -ℹ Fix -2 2 | -3 3 | from typing import Any -4 4 | -5 |-from requests import Session -6 |- -7 5 | from my_first_party import my_first_party_object - 6 |+from requests import Session -8 7 | -9 8 | from . import my_local_folder_object - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__lines_between_typeslines_between_types.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__lines_between_typeslines_between_types.py.snap deleted file mode 100644 index 500a265589..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__lines_between_typeslines_between_types.py.snap +++ /dev/null @@ -1,36 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -lines_between_types.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | - 1 | / from __future__ import annotations - 2 | | - 3 | | import datetime - 4 | | import json - 5 | | - 6 | | - 7 | | from binascii import hexlify - 8 | | - 9 | | import requests -10 | | -11 | | -12 | | from sanic import Sanic -13 | | from loguru import Logger -14 | | -15 | | from . import config -16 | | from .data import Data - | - = help: Organize imports - -ℹ Fix -9 9 | import requests -10 10 | -11 11 | - 12 |+from loguru import Logger -12 13 | from sanic import Sanic -13 |-from loguru import Logger -14 14 | -15 15 | from . import config -16 16 | from .data import Data - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__magic_trailing_comma.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__magic_trailing_comma.py.snap deleted file mode 100644 index adcda14481..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__magic_trailing_comma.py.snap +++ /dev/null @@ -1,101 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted - | - 1 | # This has a magic trailing comma, will be sorted, but not rolled into one line - 2 | / from sys import ( - 3 | | stderr, - 4 | | argv, - 5 | | stdout, - 6 | | exit, - 7 | | ) - 8 | | - 9 | | # No magic comma, this will be rolled into one line. -10 | | from os import ( -11 | | path, -12 | | environ, -13 | | execl, -14 | | execv -15 | | ) -16 | | -17 | | from glob import ( -18 | | glob, -19 | | iglob, -20 | | escape, # Ends with a comment, should still treat as magic trailing comma. -21 | | ) -22 | | -23 | | # These will be combined, but without a trailing comma. -24 | | from foo import bar -25 | | from foo import baz -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 | | -34 | | # These will be combined, _with_ a trailing comma. -35 | | from module2 import member1, member2 -36 | | from module2 import ( -37 | | member3, -38 | | ) - | - = help: Organize imports - -ℹ Fix -1 1 | # This has a magic trailing comma, will be sorted, but not rolled into one line -2 |-from sys import ( -3 |- stderr, -4 |- argv, -5 |- stdout, -6 |- exit, - 2 |+from glob import ( - 3 |+ escape, # Ends with a comment, should still treat as magic trailing comma. - 4 |+ glob, - 5 |+ iglob, -7 6 | ) -8 7 | -9 8 | # No magic comma, this will be rolled into one line. -10 |-from os import ( -11 |- path, -12 |- environ, -13 |- execl, -14 |- execv -15 |-) -16 |- -17 |-from glob import ( -18 |- glob, -19 |- iglob, -20 |- escape, # Ends with a comment, should still treat as magic trailing comma. - 9 |+from os import environ, execl, execv, path - 10 |+from sys import ( - 11 |+ argv, - 12 |+ exit, - 13 |+ stderr, - 14 |+ stdout, -21 15 | ) -22 16 | -23 17 | # These will be combined, but without a trailing comma. -24 |-from foo import bar -25 |-from foo import baz - 18 |+from foo import bar, baz -26 19 | -27 20 | # These will be combined, _with_ a trailing comma. -28 |-from module1 import member1 -29 21 | from module1 import ( - 22 |+ member1, -30 23 | member2, -31 24 | member3, -32 25 | ) -33 26 | -34 27 | # These will be combined, _with_ a trailing comma. -35 |-from module2 import member1, member2 -36 28 | from module2 import ( - 29 |+ member1, - 30 |+ member2, -37 31 | member3, -38 32 | ) - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__match_case.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__match_case.py.snap deleted file mode 100644 index 7df72260f7..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__match_case.py.snap +++ /dev/null @@ -1,44 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -match_case.py:3:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | match 1: -2 | case 1: -3 | / import sys -4 | | import os -5 | | case 2: - | |_^ I001 -6 | import collections -7 | import abc - | - = help: Organize imports - -ℹ Fix -1 1 | match 1: -2 2 | case 1: - 3 |+ import os -3 4 | import sys -4 |- import os -5 5 | case 2: -6 6 | import collections -7 7 | import abc - -match_case.py:6:1: I001 [*] Import block is un-sorted or un-formatted - | -4 | import os -5 | case 2: -6 | / import collections -7 | | import abc - | - = help: Organize imports - -ℹ Fix -3 3 | import sys -4 4 | import os -5 5 | case 2: - 6 |+ import abc -6 7 | import collections -7 |- import abc - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__natural_order.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__natural_order.py.snap deleted file mode 100644 index b7d3150fa1..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__natural_order.py.snap +++ /dev/null @@ -1,46 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -natural_order.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | - 1 | / import numpy1 - 2 | | import numpy10 - 3 | | import numpy2 - 4 | | from numpy import ( - 5 | | cos, - 6 | | int8, - 7 | | sin, - 8 | | int32, - 9 | | int64, -10 | | tan, -11 | | uint8, -12 | | uint16, -13 | | int16, -14 | | uint32, -15 | | uint64, -16 | | ) - | - = help: Organize imports - -ℹ Fix -1 1 | import numpy1 - 2 |+import numpy2 -2 3 | import numpy10 -3 |-import numpy2 -4 4 | from numpy import ( -5 5 | cos, -6 6 | int8, -7 |- sin, - 7 |+ int16, -8 8 | int32, -9 9 | int64, - 10 |+ sin, -10 11 | tan, -11 12 | uint8, -12 13 | uint16, -13 |- int16, -14 14 | uint32, -15 15 | uint64, -16 16 | ) - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__no_detect_same_package.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__no_detect_same_package.snap deleted file mode 100644 index 2036ce6762..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__no_detect_same_package.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -bar.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / import os -2 | | import pandas -3 | | import foo.baz - | - = help: Organize imports - -ℹ Fix -1 1 | import os -2 |-import pandas - 2 |+ -3 3 | import foo.baz - 4 |+import pandas - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__no_lines_before.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__no_lines_before.py.snap deleted file mode 100644 index f7ff0486df..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__no_lines_before.py.snap +++ /dev/null @@ -1,29 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -no_lines_before.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -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 - | - = help: Organize imports - -ℹ Fix -2 2 | -3 3 | from typing import Any -4 4 | -5 |-from requests import Session -6 |- -7 5 | from my_first_party import my_first_party_object - 6 |+from requests import Session -8 7 | -9 8 | from . import my_local_folder_object - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__no_lines_before.py_no_lines_before.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__no_lines_before.py_no_lines_before.py.snap deleted file mode 100644 index 635fcda159..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__no_lines_before.py_no_lines_before.py.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -no_lines_before.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -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 - | - = help: Organize imports - -ℹ Fix -1 1 | from __future__ import annotations -2 |- -3 2 | from typing import Any -4 |- - 3 |+from my_first_party import my_first_party_object -5 4 | from requests import Session -6 |- -7 |-from my_first_party import my_first_party_object -8 |- -9 5 | from . import my_local_folder_object - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__no_lines_before_with_empty_sections.py_no_lines_before_with_empty_sections.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__no_lines_before_with_empty_sections.py_no_lines_before_with_empty_sections.py.snap deleted file mode 100644 index bcc68488ee..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__no_lines_before_with_empty_sections.py_no_lines_before_with_empty_sections.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -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 - | - = help: Organize imports - -ℹ Fix -1 1 | from __future__ import annotations -2 2 | from typing import Any - 3 |+ -3 4 | from . import my_local_folder_object - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__no_reorder_within_section.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__no_reorder_within_section.py.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__no_reorder_within_section.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__no_wrap_star.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__no_wrap_star.py.snap deleted file mode 100644 index 2eb7630eb8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__no_wrap_star.py.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -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 - | - = help: Organize imports - -ℹ Fix -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 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type.py.snap deleted file mode 100644 index 76e6484c72..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type.py.snap +++ /dev/null @@ -1,41 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -order_by_type.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | - 1 | / import StringIO - 2 | | import glob - 3 | | import os - 4 | | import shutil - 5 | | import tempfile - 6 | | import time - 7 | | from subprocess import PIPE, Popen, STDOUT - 8 | | from module import Class, CONSTANT, function, BASIC, Apple - 9 | | import foo -10 | | import FOO -11 | | import BAR -12 | | import bar - | - = help: Organize imports - -ℹ Fix -1 |-import StringIO -2 1 | import glob -3 2 | import os -4 3 | import shutil -5 4 | import tempfile -6 5 | import time -7 |-from subprocess import PIPE, Popen, STDOUT -8 |-from module import Class, CONSTANT, function, BASIC, Apple -9 |-import foo -10 |-import FOO - 6 |+from subprocess import PIPE, STDOUT, Popen - 7 |+ -11 8 | import BAR -12 9 | import bar - 10 |+import FOO - 11 |+import foo - 12 |+import StringIO - 13 |+from module import BASIC, CONSTANT, Apple, Class, function - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_false_order_by_type.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_false_order_by_type.py.snap deleted file mode 100644 index 4f2c173898..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_false_order_by_type.py.snap +++ /dev/null @@ -1,40 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -order_by_type.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | - 1 | / import StringIO - 2 | | import glob - 3 | | import os - 4 | | import shutil - 5 | | import tempfile - 6 | | import time - 7 | | from subprocess import PIPE, Popen, STDOUT - 8 | | from module import Class, CONSTANT, function, BASIC, Apple - 9 | | import foo -10 | | import FOO -11 | | import BAR -12 | | import bar - | - = help: Organize imports - -ℹ Fix -1 |-import StringIO -2 1 | import glob -3 2 | import os -4 3 | import shutil -5 4 | import tempfile -6 5 | import time -7 6 | from subprocess import PIPE, Popen, STDOUT -8 |-from module import Class, CONSTANT, function, BASIC, Apple -9 |-import foo -10 |-import FOO - 7 |+ -11 8 | import BAR -12 9 | import bar - 10 |+import FOO - 11 |+import foo - 12 |+import StringIO - 13 |+from module import Apple, BASIC, Class, CONSTANT, function - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_with_custom_classes.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_with_custom_classes.py.snap deleted file mode 100644 index 902db7014b..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_with_custom_classes.py.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -order_by_type_with_custom_classes.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / from sklearn.svm import func, SVC, CONST, Klass -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 - | - = help: Organize imports - -ℹ Fix -1 |-from sklearn.svm import func, SVC, CONST, Klass -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 - 1 |+from subprocess import N_CLASS, PIPE, STDOUT, Popen - 2 |+ - 3 |+from module import BASIC, CLASS, CONSTANT, Apple, Class, function - 4 |+from sklearn.svm import CONST, SVC, Klass, func - 5 |+from torch.nn import A_CONSTANT, SELU, AClass - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_with_custom_classes_order_by_type_with_custom_classes.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_with_custom_classes_order_by_type_with_custom_classes.py.snap deleted file mode 100644 index 7147189148..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_with_custom_classes_order_by_type_with_custom_classes.py.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -order_by_type_with_custom_classes.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / from sklearn.svm import func, SVC, CONST, Klass -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 - | - = help: Organize imports - -ℹ Fix -1 |-from sklearn.svm import func, SVC, CONST, Klass -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 - 1 |+from subprocess import PIPE, STDOUT, N_CLASS, Popen - 2 |+ - 3 |+from module import BASIC, CONSTANT, Apple, CLASS, Class, function - 4 |+from sklearn.svm import CONST, Klass, SVC, func - 5 |+from torch.nn import A_CONSTANT, AClass, SELU - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_with_custom_constants.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_with_custom_constants.py.snap deleted file mode 100644 index 0a616fa8a1..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_with_custom_constants.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -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 - | - = help: Organize imports - -ℹ Fix -1 |-from sklearn.svm import XYZ, func, variable, Const, Klass, constant -2 |-from subprocess import First, var, func, Class, konst, A_constant, Last, STDOUT - 1 |+from subprocess import STDOUT, A_constant, Class, First, Last, func, konst, var - 2 |+ - 3 |+from sklearn.svm import XYZ, Const, Klass, constant, func, variable - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_with_custom_constants_order_by_type_with_custom_constants.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_with_custom_constants_order_by_type_with_custom_constants.py.snap deleted file mode 100644 index aade3e18a2..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_with_custom_constants_order_by_type_with_custom_constants.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -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 - | - = help: Organize imports - -ℹ Fix -1 |-from sklearn.svm import XYZ, func, variable, Const, Klass, constant -2 |-from subprocess import First, var, func, Class, konst, A_constant, Last, STDOUT - 1 |+from subprocess import A_constant, First, konst, Last, STDOUT, Class, func, var - 2 |+ - 3 |+from sklearn.svm import Const, constant, XYZ, Klass, func, variable - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_with_custom_variables.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_with_custom_variables.py.snap deleted file mode 100644 index 4ac3df49ca..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_with_custom_variables.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -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 - | - = help: Organize imports - -ℹ Fix -1 |-from sklearn.svm import VAR, Class, MyVar, CONST, abc -2 |-from subprocess import utils, var_ABC, Variable, Klass, CONSTANT, exe - 1 |+from subprocess import CONSTANT, Klass, Variable, exe, utils, var_ABC - 2 |+ - 3 |+from sklearn.svm import CONST, VAR, Class, MyVar, abc - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_with_custom_variables_order_by_type_with_custom_variables.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_with_custom_variables_order_by_type_with_custom_variables.py.snap deleted file mode 100644 index 002a187b45..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_by_type_with_custom_variables_order_by_type_with_custom_variables.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -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 - | - = help: Organize imports - -ℹ Fix -1 |-from sklearn.svm import VAR, Class, MyVar, CONST, abc -2 |-from subprocess import utils, var_ABC, Variable, Klass, CONSTANT, exe - 1 |+from subprocess import CONSTANT, Klass, exe, utils, var_ABC, Variable - 2 |+ - 3 |+from sklearn.svm import CONST, Class, abc, MyVar, VAR - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_relative_imports_by_level.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_relative_imports_by_level.py.snap deleted file mode 100644 index 75940c7d49..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__order_relative_imports_by_level.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -order_relative_imports_by_level.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / from .a import a -2 | | from ..a import a -3 | | from ..b import a -4 | | from .b import a - | - = help: Organize imports - -ℹ Fix -1 |-from .a import a -2 1 | from ..a import a -3 2 | from ..b import a - 3 |+from .a import a -4 4 | from .b import a - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__preserve_comment_order.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__preserve_comment_order.py.snap deleted file mode 100644 index 0a8c62f4b3..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__preserve_comment_order.py.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -preserve_comment_order.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | - 1 | / import io - 2 | | # Old MacDonald had a farm, - 3 | | # EIEIO - 4 | | # And on his farm he had a cow, - 5 | | # EIEIO - 6 | | # With a moo-moo here and a moo-moo there - 7 | | # Here a moo, there a moo, everywhere moo-moo - 8 | | # Old MacDonald had a farm, - 9 | | # EIEIO -10 | | from errno import EIO -11 | | import abc - | - = help: Organize imports - -ℹ Fix - 1 |+import abc -1 2 | import io - 3 |+ -2 4 | # Old MacDonald had a farm, -3 5 | # EIEIO -4 6 | # And on his farm he had a cow, --------------------------------------------------------------------------------- -8 10 | # Old MacDonald had a farm, -9 11 | # EIEIO -10 12 | from errno import EIO -11 |-import abc - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__preserve_import_star.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__preserve_import_star.py.snap deleted file mode 100644 index d640a69905..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__preserve_import_star.py.snap +++ /dev/null @@ -1,28 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -preserve_import_star.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / from some_other_module import some_class -2 | | from some_other_module import * -3 | | # Above -4 | | from some_module import some_class # Aside -5 | | # Above -6 | | from some_module import * # Aside - | - = help: Organize imports - -ℹ Fix -1 |-from some_other_module import some_class -2 |-from some_other_module import * -3 1 | # Above -4 |-from some_module import some_class # Aside -5 |-# Above -6 2 | from some_module import * # Aside - 3 |+ - 4 |+# Above - 5 |+from some_module import some_class # Aside - 6 |+from some_other_module import * - 7 |+from some_other_module import some_class - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__preserve_indentation.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__preserve_indentation.py.snap deleted file mode 100644 index 78341bacce..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__preserve_indentation.py.snap +++ /dev/null @@ -1,42 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -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 -5 | import sys -6 | import os - | - = help: Organize imports - -ℹ Fix -1 1 | if True: - 2 |+ import os -2 3 | import sys -3 |- import os -4 4 | else: -5 5 | import sys -6 6 | import os - -preserve_indentation.py:5:1: I001 [*] Import block is un-sorted or un-formatted - | -3 | import os -4 | else: -5 | / import sys -6 | | import os - | - = help: Organize imports - -ℹ Fix -2 2 | import sys -3 3 | import os -4 4 | else: - 5 |+ import os -5 6 | import sys -6 |- import os - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__preserve_tabs.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__preserve_tabs.py.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__preserve_tabs.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__preserve_tabs_2.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__preserve_tabs_2.py.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__preserve_tabs_2.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__propagate_inline_comments_propagate_inline_comments.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__propagate_inline_comments_propagate_inline_comments.py.snap deleted file mode 100644 index 154e06dbc9..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__propagate_inline_comments_propagate_inline_comments.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -propagate_inline_comments.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / from mypackage.subpackage import ( # long comment that seems to be a problem -2 | | a_long_variable_name_that_causes_problems, -3 | | items, -4 | | ) - | - = help: Organize imports - -ℹ Fix -1 1 | from mypackage.subpackage import ( # long comment that seems to be a problem -2 2 | a_long_variable_name_that_causes_problems, -3 |- items, -4 3 | ) - 4 |+from mypackage.subpackage import items # long comment that seems to be a problem - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__relative_imports_order.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__relative_imports_order.py.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__relative_imports_order.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__reorder_within_section.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__reorder_within_section.py.snap deleted file mode 100644 index c8b39c3378..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__reorder_within_section.py.snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -reorder_within_section.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / import sys -2 | | import os - | - = help: Organize imports - -ℹ Fix - 1 |+import os -1 2 | import sys -2 |-import os - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_comment.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_comment.py.snap deleted file mode 100644 index ad5b85c1d1..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_comment.py.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -comment.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` - | -1 | #!/usr/bin/env python3 - | I002 -2 | -3 | x = 1 - | - = help: Insert required import: `from future import annotations` - -ℹ Fix -1 1 | #!/usr/bin/env python3 - 2 |+from __future__ import annotations -2 3 | -3 4 | x = 1 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_comments_and_newlines.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_comments_and_newlines.py.snap deleted file mode 100644 index 107c3ef147..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_comments_and_newlines.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -comments_and_newlines.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` - | -1 | #!/usr/bin/env python3 - | I002 -2 | # A copyright notice could go here - | - = help: Insert required import: `from future import annotations` - -ℹ Fix -2 2 | # A copyright notice could go here -3 3 | -4 4 | # A linter directive could go here - 5 |+from __future__ import annotations -5 6 | -6 7 | x = 1 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_docstring.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_docstring.py.snap deleted file mode 100644 index ae57622574..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_docstring.py.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` - | -1 | """Hello, world!""" - | I002 -2 | -3 | x = 1 - | - = help: Insert required import: `from future import annotations` - -ℹ Fix -1 1 | """Hello, world!""" - 2 |+from __future__ import annotations -2 3 | -3 4 | x = 1 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_docstring.pyi.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_docstring.pyi.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_docstring.pyi.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_docstring_only.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_docstring_only.py.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_docstring_only.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_docstring_with_continuation.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_docstring_with_continuation.py.snap deleted file mode 100644 index 47eff34dad..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_docstring_with_continuation.py.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -docstring_with_continuation.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` - | -1 | """Hello, world!"""; x = \ - | I002 -2 | 1; y = 2 - | - = help: Insert required import: `from future import annotations` - -ℹ Fix -1 |-"""Hello, world!"""; x = \ - 1 |+"""Hello, world!"""; from __future__ import annotations; x = \ -2 2 | 1; y = 2 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_docstring_with_semicolon.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_docstring_with_semicolon.py.snap deleted file mode 100644 index 4e43866591..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_docstring_with_semicolon.py.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -docstring_with_semicolon.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` - | -1 | """Hello, world!"""; x = 1 - | I002 - | - = help: Insert required import: `from future import annotations` - -ℹ Fix -1 |-"""Hello, world!"""; x = 1 - 1 |+"""Hello, world!"""; from __future__ import annotations; x = 1 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_empty.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_empty.py.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_empty.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_existing_import.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_existing_import.py.snap deleted file mode 100644 index 39faabae25..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_existing_import.py.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -existing_import.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` - | -1 | from __future__ import generator_stop - | I002 -2 | import os - | - = help: Insert required import: `from future import annotations` - -ℹ Fix - 1 |+from __future__ import annotations -1 2 | from __future__ import generator_stop -2 3 | import os - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_multiline_docstring.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_multiline_docstring.py.snap deleted file mode 100644 index c5c8bf78df..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_multiline_docstring.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -multiline_docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` - | -1 | """a - | I002 -2 | b""" -3 | # b - | - = help: Insert required import: `from future import annotations` - -ℹ Fix -1 1 | """a -2 2 | b""" -3 3 | # b - 4 |+from __future__ import annotations -4 5 | import os - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_off.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_off.py.snap deleted file mode 100644 index ada290ffd3..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_off.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -off.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` - | -1 | # isort: off - | I002 -2 | -3 | x = 1 - | - = help: Insert required import: `from future import annotations` - -ℹ Fix -1 1 | # isort: off - 2 |+from __future__ import annotations -2 3 | -3 4 | x = 1 -4 5 | # isort: on - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_comment.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_comment.py.snap deleted file mode 100644 index 98c8abf237..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_comment.py.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -comment.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` - | -1 | #!/usr/bin/env python3 - | I002 -2 | -3 | x = 1 - | - = help: Insert required import: `from future import annotations as _annotations` - -ℹ Fix -1 1 | #!/usr/bin/env python3 - 2 |+from __future__ import annotations as _annotations -2 3 | -3 4 | x = 1 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_comments_and_newlines.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_comments_and_newlines.py.snap deleted file mode 100644 index a9ea7adf2e..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_comments_and_newlines.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -comments_and_newlines.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` - | -1 | #!/usr/bin/env python3 - | I002 -2 | # A copyright notice could go here - | - = help: Insert required import: `from future import annotations as _annotations` - -ℹ Fix -2 2 | # A copyright notice could go here -3 3 | -4 4 | # A linter directive could go here - 5 |+from __future__ import annotations as _annotations -5 6 | -6 7 | x = 1 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_docstring.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_docstring.py.snap deleted file mode 100644 index 3937d80bed..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_docstring.py.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` - | -1 | """Hello, world!""" - | I002 -2 | -3 | x = 1 - | - = help: Insert required import: `from future import annotations as _annotations` - -ℹ Fix -1 1 | """Hello, world!""" - 2 |+from __future__ import annotations as _annotations -2 3 | -3 4 | x = 1 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_docstring.pyi.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_docstring.pyi.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_docstring.pyi.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_docstring_only.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_docstring_only.py.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_docstring_only.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_docstring_with_continuation.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_docstring_with_continuation.py.snap deleted file mode 100644 index 2d0057caa7..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_docstring_with_continuation.py.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -docstring_with_continuation.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` - | -1 | """Hello, world!"""; x = \ - | I002 -2 | 1; y = 2 - | - = help: Insert required import: `from future import annotations as _annotations` - -ℹ Fix -1 |-"""Hello, world!"""; x = \ - 1 |+"""Hello, world!"""; from __future__ import annotations as _annotations; x = \ -2 2 | 1; y = 2 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_docstring_with_semicolon.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_docstring_with_semicolon.py.snap deleted file mode 100644 index 610a7d7c62..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_docstring_with_semicolon.py.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -docstring_with_semicolon.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` - | -1 | """Hello, world!"""; x = 1 - | I002 - | - = help: Insert required import: `from future import annotations as _annotations` - -ℹ Fix -1 |-"""Hello, world!"""; x = 1 - 1 |+"""Hello, world!"""; from __future__ import annotations as _annotations; x = 1 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_empty.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_empty.py.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_empty.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_existing_import.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_existing_import.py.snap deleted file mode 100644 index 345ff07159..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_existing_import.py.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -existing_import.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` - | -1 | from __future__ import generator_stop - | I002 -2 | import os - | - = help: Insert required import: `from future import annotations as _annotations` - -ℹ Fix - 1 |+from __future__ import annotations as _annotations -1 2 | from __future__ import generator_stop -2 3 | import os - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_multiline_docstring.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_multiline_docstring.py.snap deleted file mode 100644 index 5289840be4..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_multiline_docstring.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -multiline_docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` - | -1 | """a - | I002 -2 | b""" -3 | # b - | - = help: Insert required import: `from future import annotations as _annotations` - -ℹ Fix -1 1 | """a -2 2 | b""" -3 3 | # b - 4 |+from __future__ import annotations as _annotations -4 5 | import os - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_off.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_off.py.snap deleted file mode 100644 index 617305a4be..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_import_with_alias_off.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -off.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` - | -1 | # isort: off - | I002 -2 | -3 | x = 1 - | - = help: Insert required import: `from future import annotations as _annotations` - -ℹ Fix -1 1 | # isort: off - 2 |+from __future__ import annotations as _annotations -2 3 | -3 4 | x = 1 -4 5 | # isort: on - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_imports_docstring.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_imports_docstring.py.snap deleted file mode 100644 index c5a0bd69f0..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_imports_docstring.py.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` - | -1 | """Hello, world!""" - | I002 -2 | -3 | x = 1 - | - = help: Insert required import: `from future import annotations` - -ℹ Fix -1 1 | """Hello, world!""" - 2 |+from __future__ import annotations -2 3 | -3 4 | x = 1 - -docstring.py:1:1: I002 [*] Missing required import: `from __future__ import generator_stop` - | -1 | """Hello, world!""" - | I002 -2 | -3 | x = 1 - | - = help: Insert required import: `from future import generator_stop` - -ℹ Fix -1 1 | """Hello, world!""" - 2 |+from __future__ import generator_stop -2 3 | -3 4 | x = 1 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_imports_docstring.pyi.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_imports_docstring.pyi.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_imports_docstring.pyi.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_imports_docstring_only.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_imports_docstring_only.py.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_imports_docstring_only.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_imports_empty.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_imports_empty.py.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__required_imports_empty.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__ruff_skip_file.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__ruff_skip_file.py.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__ruff_skip_file.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__section_order_sections.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__section_order_sections.py.snap deleted file mode 100644 index accc2bec47..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__section_order_sections.py.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / from __future__ import annotations -2 | | import os -3 | | import sys -4 | | import pytz -5 | | import django.settings -6 | | from library import foo -7 | | from . import local - | - = help: Organize imports - -ℹ Fix -1 1 | from __future__ import annotations - 2 |+ -2 3 | import os -3 4 | import sys - 5 |+ -4 6 | import pytz - 7 |+ -5 8 | import django.settings - 9 |+ -6 10 | from library import foo - 11 |+ -7 12 | from . import local - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__sections_sections.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__sections_sections.py.snap deleted file mode 100644 index 44a174f26b..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__sections_sections.py.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / from __future__ import annotations -2 | | import os -3 | | import sys -4 | | import pytz -5 | | import django.settings -6 | | from library import foo -7 | | from . import local - | - = help: Organize imports - -ℹ Fix -1 1 | from __future__ import annotations - 2 |+ -2 3 | import os -3 4 | import sys - 5 |+ -4 6 | import pytz -5 |-import django.settings -6 7 | from library import foo - 8 |+ -7 9 | from . import local - 10 |+ - 11 |+import django.settings - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__separate_first_party_imports.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__separate_first_party_imports.py.snap deleted file mode 100644 index 4152577a2b..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__separate_first_party_imports.py.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -separate_first_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / import sys -2 | | import leading_prefix -3 | | import numpy as np -4 | | import os -5 | | from leading_prefix import Class - | - = help: Organize imports - -ℹ Fix - 1 |+import os -1 2 | import sys - 3 |+ - 4 |+import numpy as np - 5 |+ -2 6 | import leading_prefix -3 |-import numpy as np -4 |-import os -5 7 | from leading_prefix import Class - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__separate_future_imports.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__separate_future_imports.py.snap deleted file mode 100644 index 35071c595f..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__separate_future_imports.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -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 - | - = help: Organize imports - -ℹ Fix -1 |-import sys -2 |-import os -3 1 | from __future__ import annotations - 2 |+ - 3 |+import os - 4 |+import sys - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__separate_local_folder_imports.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__separate_local_folder_imports.py.snap deleted file mode 100644 index 50a99dc995..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__separate_local_folder_imports.py.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / import sys -2 | | import ruff -3 | | import leading_prefix -4 | | import os -5 | | from . import leading_prefix - | - = help: Organize imports - -ℹ Fix - 1 |+import os -1 2 | import sys - 3 |+ -2 4 | import ruff - 5 |+ -3 6 | import leading_prefix -4 |-import os - 7 |+ -5 8 | from . import leading_prefix - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__separate_third_party_imports.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__separate_third_party_imports.py.snap deleted file mode 100644 index 93364da9d2..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__separate_third_party_imports.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -separate_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | -1 | / import pandas as pd -2 | | import sys -3 | | import numpy as np -4 | | import os - | - = help: Organize imports - -ℹ Fix -1 |-import pandas as pd - 1 |+import os -2 2 | import sys - 3 |+ -3 4 | import numpy as np -4 |-import os - 5 |+import pandas as pd - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__skip.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__skip.py.snap deleted file mode 100644 index 498421b65b..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__skip.py.snap +++ /dev/null @@ -1,68 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -skip.py:20:1: I001 [*] Import block is un-sorted or un-formatted - | -18 | import sys -19 | import os # isort: skip -20 | / import collections -21 | | import abc -22 | | - | |_^ I001 -23 | -24 | def f(): - | - = help: Organize imports - -ℹ Fix -17 17 | def f(): -18 18 | import sys -19 19 | import os # isort: skip - 20 |+ import abc -20 21 | import collections -21 |- import abc -22 22 | -23 23 | -24 24 | def f(): - -skip.py:27:1: I001 [*] Import block is un-sorted or un-formatted - | -25 | import sys -26 | import os # isort:skip -27 | / import collections -28 | | import abc -29 | | - | |_^ I001 -30 | -31 | def f(): - | - = help: Organize imports - -ℹ Fix -24 24 | def f(): -25 25 | import sys -26 26 | import os # isort:skip - 27 |+ import abc -27 28 | import collections -28 |- import abc -29 29 | -30 30 | -31 31 | def f(): - -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 - -ℹ Fix -31 31 | def f(): -32 32 | import sys; import os # isort:skip -33 33 | import sys; import os # isort:skip # isort:skip -34 |- import sys; import os - 34 |+ import os - 35 |+ import sys - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__sort_similar_imports.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__sort_similar_imports.py.snap deleted file mode 100644 index 7de30d7bc5..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__sort_similar_imports.py.snap +++ /dev/null @@ -1,77 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -sort_similar_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted - | - 1 | / from a import b - 2 | | from a import BAD as DEF - 3 | | from a import B - 4 | | from a import Boo as DEF - 5 | | from a import B as Abc - 6 | | from a import B as A - 7 | | from a import B as DEF - 8 | | from a import b as a - 9 | | from a import b as x -10 | | from a import b as c -11 | | from b import c -12 | | from a import b as d -13 | | from a import b as y -14 | | from b import C -15 | | from b import c as d -16 | | -17 | | import A -18 | | import a -19 | | import b -20 | | import B -21 | | -22 | | import x as y -23 | | import x as A -24 | | import x as Y -25 | | import x -26 | | import x as a - | - = help: Organize imports - -ℹ Fix -1 |-from a import b - 1 |+import A - 2 |+import a - 3 |+import B - 4 |+import b - 5 |+import x - 6 |+import x as A - 7 |+import x as Y - 8 |+import x as a - 9 |+import x as y -2 10 | from a import BAD as DEF -3 |-from a import B -4 |-from a import Boo as DEF - 11 |+from a import B, b - 12 |+from a import B as A -5 13 | from a import B as Abc -6 |-from a import B as A -7 14 | from a import B as DEF - 15 |+from a import Boo as DEF -8 16 | from a import b as a -9 |-from a import b as x -10 17 | from a import b as c -11 |-from b import c -12 18 | from a import b as d - 19 |+from a import b as x -13 20 | from a import b as y -14 |-from b import C - 21 |+from b import C, c -15 22 | from b import c as d -16 |- -17 |-import A -18 |-import a -19 |-import b -20 |-import B -21 |- -22 |-import x as y -23 |-import x as A -24 |-import x as Y -25 |-import x -26 |-import x as a - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__split.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__split.py.snap deleted file mode 100644 index 7556899b60..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__split.py.snap +++ /dev/null @@ -1,67 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -split.py:15:1: I001 [*] Import block is un-sorted or un-formatted - | -14 | if True: -15 | / import C -16 | | import A -17 | | - | |_^ I001 -18 | # isort: split - | - = help: Organize imports - -ℹ Fix -12 12 | import b -13 13 | -14 14 | if True: - 15 |+ import A -15 16 | import C -16 |- import A -17 17 | -18 18 | # isort: split -19 19 | - -split.py:20:1: I001 [*] Import block is un-sorted or un-formatted - | -18 | # isort: split -19 | -20 | / import D -21 | | import B -22 | | - | |_^ I001 -23 | -24 | import e - | - = help: Organize imports - -ℹ Fix -17 17 | -18 18 | # isort: split -19 19 | - 20 |+ import B -20 21 | import D -21 |- import B -22 22 | -23 23 | -24 24 | import e - -split.py:30:1: I001 [*] Import block is un-sorted or un-formatted - | -28 | # isort: split -29 | -30 | / import d -31 | | import c - | - = help: Organize imports - -ℹ Fix -27 27 | # isort: split -28 28 | # isort: split -29 29 | - 30 |+import c -30 31 | import d -31 |-import c - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__split_on_trailing_comma_magic_trailing_comma.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__split_on_trailing_comma_magic_trailing_comma.py.snap deleted file mode 100644 index f1413b2e21..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__split_on_trailing_comma_magic_trailing_comma.py.snap +++ /dev/null @@ -1,95 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted - | - 1 | # This has a magic trailing comma, will be sorted, but not rolled into one line - 2 | / from sys import ( - 3 | | stderr, - 4 | | argv, - 5 | | stdout, - 6 | | exit, - 7 | | ) - 8 | | - 9 | | # No magic comma, this will be rolled into one line. -10 | | from os import ( -11 | | path, -12 | | environ, -13 | | execl, -14 | | execv -15 | | ) -16 | | -17 | | from glob import ( -18 | | glob, -19 | | iglob, -20 | | escape, # Ends with a comment, should still treat as magic trailing comma. -21 | | ) -22 | | -23 | | # These will be combined, but without a trailing comma. -24 | | from foo import bar -25 | | from foo import baz -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 | | -34 | | # These will be combined, _with_ a trailing comma. -35 | | from module2 import member1, member2 -36 | | from module2 import ( -37 | | member3, -38 | | ) - | - = help: Organize imports - -ℹ Fix -1 1 | # This has a magic trailing comma, will be sorted, but not rolled into one line -2 |-from sys import ( -3 |- stderr, -4 |- argv, -5 |- stdout, -6 |- exit, -7 |-) -8 |- -9 |-# No magic comma, this will be rolled into one line. -10 |-from os import ( -11 |- path, -12 |- environ, -13 |- execl, -14 |- execv -15 |-) -16 |- -17 2 | from glob import ( - 3 |+ escape, # Ends with a comment, should still treat as magic trailing comma. -18 4 | glob, -19 5 | iglob, -20 |- escape, # Ends with a comment, should still treat as magic trailing comma. -21 6 | ) -22 7 | - 8 |+# No magic comma, this will be rolled into one line. - 9 |+from os import environ, execl, execv, path - 10 |+from sys import argv, exit, stderr, stdout - 11 |+ -23 12 | # These will be combined, but without a trailing comma. -24 |-from foo import bar -25 |-from foo import baz - 13 |+from foo import bar, baz -26 14 | -27 15 | # These will be combined, _with_ a trailing comma. -28 |-from module1 import member1 -29 |-from module1 import ( -30 |- member2, -31 |- member3, -32 |-) - 16 |+from module1 import member1, member2, member3 -33 17 | -34 18 | # These will be combined, _with_ a trailing comma. -35 |-from module2 import member1, member2 -36 |-from module2 import ( -37 |- member3, -38 |-) - 19 |+from module2 import member1, member2, member3 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__star_before_others.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__star_before_others.py.snap deleted file mode 100644 index fc46ab5b8d..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__star_before_others.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -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 * - | - = help: Organize imports - -ℹ Fix -1 1 | from .logging import config_logging - 2 |+from .settings import * -2 3 | from .settings import ENV -3 |-from .settings import * - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__straight_required_import_docstring.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__straight_required_import_docstring.py.snap deleted file mode 100644 index a03f5f7702..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__straight_required_import_docstring.py.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -docstring.py:1:1: I002 [*] Missing required import: `import os` - | -1 | """Hello, world!""" - | I002 -2 | -3 | x = 1 - | - = help: Insert required import: `import os` - -ℹ Fix -1 1 | """Hello, world!""" - 2 |+import os -2 3 | -3 4 | x = 1 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__straight_required_import_docstring.pyi.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__straight_required_import_docstring.pyi.snap deleted file mode 100644 index 41b00e0ee3..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__straight_required_import_docstring.pyi.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -docstring.pyi:1:1: I002 [*] Missing required import: `import os` - | -1 | """Hello, world!""" - | I002 -2 | -3 | x = 1 - | - = help: Insert required import: `import os` - -ℹ Fix -1 1 | """Hello, world!""" - 2 |+import os -2 3 | -3 4 | x = 1 - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__straight_required_import_docstring_only.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__straight_required_import_docstring_only.py.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__straight_required_import_docstring_only.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__straight_required_import_empty.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__straight_required_import_empty.py.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__straight_required_import_empty.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__trailing_suffix.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__trailing_suffix.py.snap deleted file mode 100644 index 07e27eb12c..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__trailing_suffix.py.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- -trailing_suffix.py:1:1: I001 Import block is un-sorted or un-formatted - | -1 | / import sys -2 | | import os; x = 1 - | |_________^ I001 -3 | -4 | if True: - | - = help: Organize imports - -trailing_suffix.py:5:5: I001 Import block is un-sorted or un-formatted - | -4 | if True: -5 | import sys - | _____^ -6 | | import os; x = 1 - | |_____________^ I001 - | - = help: Organize imports - - diff --git a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__type_comments.py.snap b/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__type_comments.py.snap deleted file mode 100644 index 94aa1559b8..0000000000 --- a/crates/ruff/src/rules/isort/snapshots/ruff__rules__isort__tests__type_comments.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/isort/mod.rs ---- - diff --git a/crates/ruff/src/rules/mccabe/snapshots/ruff__rules__mccabe__tests__max_complexity_0.snap b/crates/ruff/src/rules/mccabe/snapshots/ruff__rules__mccabe__tests__max_complexity_0.snap deleted file mode 100644 index 1f9f1c3d75..0000000000 --- a/crates/ruff/src/rules/mccabe/snapshots/ruff__rules__mccabe__tests__max_complexity_0.snap +++ /dev/null @@ -1,200 +0,0 @@ ---- -source: crates/ruff/src/rules/mccabe/mod.rs ---- -C901.py:2:5: C901 `trivial` is too complex (1 > 0) - | -1 | # Complexity = 1 -2 | def trivial(): - | ^^^^^^^ C901 -3 | pass - | - -C901.py:7:5: C901 `expr_as_statement` is too complex (1 > 0) - | -6 | # Complexity = 1 -7 | def expr_as_statement(): - | ^^^^^^^^^^^^^^^^^ C901 -8 | 0xF00D - | - -C901.py:12:5: C901 `sequential` is too complex (1 > 0) - | -11 | # Complexity = 1 -12 | def sequential(n): - | ^^^^^^^^^^ C901 -13 | k = n + 4 -14 | s = k + n - | - -C901.py:19:5: C901 `if_elif_else_dead_path` is too complex (3 > 0) - | -18 | # Complexity = 3 -19 | def if_elif_else_dead_path(n): - | ^^^^^^^^^^^^^^^^^^^^^^ C901 -20 | if n > 3: -21 | return "bigger than three" - | - -C901.py:29:5: C901 `nested_ifs` is too complex (3 > 0) - | -28 | # Complexity = 3 -29 | def nested_ifs(): - | ^^^^^^^^^^ C901 -30 | if n > 3: -31 | if n > 4: - | - -C901.py:40:5: C901 `for_loop` is too complex (2 > 0) - | -39 | # Complexity = 2 -40 | def for_loop(): - | ^^^^^^^^ C901 -41 | for i in range(10): -42 | print(i) - | - -C901.py:46:5: C901 `for_else` is too complex (2 > 0) - | -45 | # Complexity = 2 -46 | def for_else(mylist): - | ^^^^^^^^ C901 -47 | for i in mylist: -48 | print(i) - | - -C901.py:54:5: C901 `recursive` is too complex (2 > 0) - | -53 | # Complexity = 2 -54 | def recursive(n): - | ^^^^^^^^^ C901 -55 | if n > 4: -56 | return f(n - 1) - | - -C901.py:62:5: C901 `nested_functions` is too complex (3 > 0) - | -61 | # Complexity = 3 -62 | def nested_functions(): - | ^^^^^^^^^^^^^^^^ C901 -63 | def a(): -64 | def b(): - | - -C901.py:63:9: C901 `a` is too complex (2 > 0) - | -61 | # Complexity = 3 -62 | def nested_functions(): -63 | def a(): - | ^ C901 -64 | def b(): -65 | pass - | - -C901.py:64:13: C901 `b` is too complex (1 > 0) - | -62 | def nested_functions(): -63 | def a(): -64 | def b(): - | ^ C901 -65 | pass - | - -C901.py:73:5: C901 `try_else` is too complex (4 > 0) - | -72 | # Complexity = 4 -73 | def try_else(): - | ^^^^^^^^ C901 -74 | try: -75 | print(1) - | - -C901.py:85:5: C901 `nested_try_finally` is too complex (1 > 0) - | -84 | # Complexity = 3 -85 | def nested_try_finally(): - | ^^^^^^^^^^^^^^^^^^ C901 -86 | try: -87 | try: - | - -C901.py:96:11: C901 `foobar` is too complex (3 > 0) - | -95 | # Complexity = 3 -96 | async def foobar(a, b, c): - | ^^^^^^ C901 -97 | await whatever(a, b, c) -98 | if await b: - | - -C901.py:107:5: C901 `annotated_assign` is too complex (1 > 0) - | -106 | # Complexity = 1 -107 | def annotated_assign(): - | ^^^^^^^^^^^^^^^^ C901 -108 | x: Any = None - | - -C901.py:113:9: C901 `handle` is too complex (9 > 0) - | -111 | # Complexity = 9 -112 | class Class: -113 | def handle(self, *args, **options): - | ^^^^^^ C901 -114 | if args: -115 | return - | - -C901.py:118:17: C901 `a` is too complex (1 > 0) - | -117 | class ServiceProvider: -118 | def a(self): - | ^ C901 -119 | pass - | - -C901.py:121:17: C901 `b` is too complex (2 > 0) - | -119 | pass -120 | -121 | def b(self, data): - | ^ C901 -122 | if not args: -123 | pass - | - -C901.py:126:17: C901 `c` is too complex (1 > 0) - | -125 | class Logger: -126 | def c(*args, **kwargs): - | ^ C901 -127 | pass - | - -C901.py:129:17: C901 `error` is too complex (1 > 0) - | -127 | pass -128 | -129 | def error(self, message): - | ^^^^^ C901 -130 | pass - | - -C901.py:132:17: C901 `info` is too complex (1 > 0) - | -130 | pass -131 | -132 | def info(self, message): - | ^^^^ C901 -133 | pass - | - -C901.py:135:17: C901 `exception` is too complex (1 > 0) - | -133 | pass -134 | -135 | def exception(self): - | ^^^^^^^^^ C901 -136 | pass - | - - diff --git a/crates/ruff/src/rules/mccabe/snapshots/ruff__rules__mccabe__tests__max_complexity_10.snap b/crates/ruff/src/rules/mccabe/snapshots/ruff__rules__mccabe__tests__max_complexity_10.snap deleted file mode 100644 index f51e6be38f..0000000000 --- a/crates/ruff/src/rules/mccabe/snapshots/ruff__rules__mccabe__tests__max_complexity_10.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/mccabe/mod.rs ---- - diff --git a/crates/ruff/src/rules/mccabe/snapshots/ruff__rules__mccabe__tests__max_complexity_3.snap b/crates/ruff/src/rules/mccabe/snapshots/ruff__rules__mccabe__tests__max_complexity_3.snap deleted file mode 100644 index ca9d7373d7..0000000000 --- a/crates/ruff/src/rules/mccabe/snapshots/ruff__rules__mccabe__tests__max_complexity_3.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: crates/ruff/src/rules/mccabe/mod.rs ---- -C901.py:73:5: C901 `try_else` is too complex (4 > 3) - | -72 | # Complexity = 4 -73 | def try_else(): - | ^^^^^^^^ C901 -74 | try: -75 | print(1) - | - -C901.py:113:9: C901 `handle` is too complex (9 > 3) - | -111 | # Complexity = 9 -112 | class Class: -113 | def handle(self, *args, **options): - | ^^^^^^ C901 -114 | if args: -115 | return - | - - diff --git a/crates/ruff/src/rules/numpy/snapshots/ruff__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap b/crates/ruff/src/rules/numpy/snapshots/ruff__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap deleted file mode 100644 index a1593e920e..0000000000 --- a/crates/ruff/src/rules/numpy/snapshots/ruff__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap +++ /dev/null @@ -1,225 +0,0 @@ ---- -source: crates/ruff/src/rules/numpy/mod.rs ---- -NPY003.py:4:5: NPY003 [*] `np.round_` is deprecated; use `np.round` instead - | -2 | import numpy as np -3 | -4 | np.round_(np.random.rand(5, 5), 2) - | ^^^^^^^^^ NPY003 -5 | np.product(np.random.rand(5, 5)) -6 | np.cumproduct(np.random.rand(5, 5)) - | - = help: Replace with `np.round` - -ℹ Suggested fix -1 1 | def func(): -2 2 | import numpy as np -3 3 | -4 |- np.round_(np.random.rand(5, 5), 2) - 4 |+ np.round(np.random.rand(5, 5), 2) -5 5 | np.product(np.random.rand(5, 5)) -6 6 | np.cumproduct(np.random.rand(5, 5)) -7 7 | np.sometrue(np.random.rand(5, 5)) - -NPY003.py:5:5: NPY003 [*] `np.product` is deprecated; use `np.prod` instead - | -4 | np.round_(np.random.rand(5, 5), 2) -5 | np.product(np.random.rand(5, 5)) - | ^^^^^^^^^^ NPY003 -6 | np.cumproduct(np.random.rand(5, 5)) -7 | np.sometrue(np.random.rand(5, 5)) - | - = help: Replace with `np.prod` - -ℹ Suggested fix -2 2 | import numpy as np -3 3 | -4 4 | np.round_(np.random.rand(5, 5), 2) -5 |- np.product(np.random.rand(5, 5)) - 5 |+ np.prod(np.random.rand(5, 5)) -6 6 | np.cumproduct(np.random.rand(5, 5)) -7 7 | np.sometrue(np.random.rand(5, 5)) -8 8 | np.alltrue(np.random.rand(5, 5)) - -NPY003.py:6:5: NPY003 [*] `np.cumproduct` is deprecated; use `np.cumprod` instead - | -4 | np.round_(np.random.rand(5, 5), 2) -5 | np.product(np.random.rand(5, 5)) -6 | np.cumproduct(np.random.rand(5, 5)) - | ^^^^^^^^^^^^^ NPY003 -7 | np.sometrue(np.random.rand(5, 5)) -8 | np.alltrue(np.random.rand(5, 5)) - | - = help: Replace with `np.cumprod` - -ℹ Suggested fix -3 3 | -4 4 | np.round_(np.random.rand(5, 5), 2) -5 5 | np.product(np.random.rand(5, 5)) -6 |- np.cumproduct(np.random.rand(5, 5)) - 6 |+ np.cumprod(np.random.rand(5, 5)) -7 7 | np.sometrue(np.random.rand(5, 5)) -8 8 | np.alltrue(np.random.rand(5, 5)) -9 9 | - -NPY003.py:7:5: NPY003 [*] `np.sometrue` is deprecated; use `np.any` instead - | -5 | np.product(np.random.rand(5, 5)) -6 | np.cumproduct(np.random.rand(5, 5)) -7 | np.sometrue(np.random.rand(5, 5)) - | ^^^^^^^^^^^ NPY003 -8 | np.alltrue(np.random.rand(5, 5)) - | - = help: Replace with `np.any` - -ℹ Suggested fix -4 4 | np.round_(np.random.rand(5, 5), 2) -5 5 | np.product(np.random.rand(5, 5)) -6 6 | np.cumproduct(np.random.rand(5, 5)) -7 |- np.sometrue(np.random.rand(5, 5)) - 7 |+ np.any(np.random.rand(5, 5)) -8 8 | np.alltrue(np.random.rand(5, 5)) -9 9 | -10 10 | - -NPY003.py:8:5: NPY003 [*] `np.alltrue` is deprecated; use `np.all` instead - | -6 | np.cumproduct(np.random.rand(5, 5)) -7 | np.sometrue(np.random.rand(5, 5)) -8 | np.alltrue(np.random.rand(5, 5)) - | ^^^^^^^^^^ NPY003 - | - = help: Replace with `np.all` - -ℹ Suggested fix -5 5 | np.product(np.random.rand(5, 5)) -6 6 | np.cumproduct(np.random.rand(5, 5)) -7 7 | np.sometrue(np.random.rand(5, 5)) -8 |- np.alltrue(np.random.rand(5, 5)) - 8 |+ np.all(np.random.rand(5, 5)) -9 9 | -10 10 | -11 11 | def func(): - -NPY003.py:14:5: NPY003 [*] `np.round_` is deprecated; use `np.round` instead - | -12 | from numpy import round_, product, cumproduct, sometrue, alltrue -13 | -14 | round_(np.random.rand(5, 5), 2) - | ^^^^^^ NPY003 -15 | product(np.random.rand(5, 5)) -16 | cumproduct(np.random.rand(5, 5)) - | - = help: Replace with `np.round` - -ℹ Suggested fix - 1 |+from numpy import round -1 2 | def func(): -2 3 | import numpy as np -3 4 | --------------------------------------------------------------------------------- -11 12 | def func(): -12 13 | from numpy import round_, product, cumproduct, sometrue, alltrue -13 14 | -14 |- round_(np.random.rand(5, 5), 2) - 15 |+ round(np.random.rand(5, 5), 2) -15 16 | product(np.random.rand(5, 5)) -16 17 | cumproduct(np.random.rand(5, 5)) -17 18 | sometrue(np.random.rand(5, 5)) - -NPY003.py:15:5: NPY003 [*] `np.product` is deprecated; use `np.prod` instead - | -14 | round_(np.random.rand(5, 5), 2) -15 | product(np.random.rand(5, 5)) - | ^^^^^^^ NPY003 -16 | cumproduct(np.random.rand(5, 5)) -17 | sometrue(np.random.rand(5, 5)) - | - = help: Replace with `np.prod` - -ℹ Suggested fix - 1 |+from numpy import prod -1 2 | def func(): -2 3 | import numpy as np -3 4 | --------------------------------------------------------------------------------- -12 13 | from numpy import round_, product, cumproduct, sometrue, alltrue -13 14 | -14 15 | round_(np.random.rand(5, 5), 2) -15 |- product(np.random.rand(5, 5)) - 16 |+ prod(np.random.rand(5, 5)) -16 17 | cumproduct(np.random.rand(5, 5)) -17 18 | sometrue(np.random.rand(5, 5)) -18 19 | alltrue(np.random.rand(5, 5)) - -NPY003.py:16:5: NPY003 [*] `np.cumproduct` is deprecated; use `np.cumprod` instead - | -14 | round_(np.random.rand(5, 5), 2) -15 | product(np.random.rand(5, 5)) -16 | cumproduct(np.random.rand(5, 5)) - | ^^^^^^^^^^ NPY003 -17 | sometrue(np.random.rand(5, 5)) -18 | alltrue(np.random.rand(5, 5)) - | - = help: Replace with `np.cumprod` - -ℹ Suggested fix - 1 |+from numpy import cumprod -1 2 | def func(): -2 3 | import numpy as np -3 4 | --------------------------------------------------------------------------------- -13 14 | -14 15 | round_(np.random.rand(5, 5), 2) -15 16 | product(np.random.rand(5, 5)) -16 |- cumproduct(np.random.rand(5, 5)) - 17 |+ cumprod(np.random.rand(5, 5)) -17 18 | sometrue(np.random.rand(5, 5)) -18 19 | alltrue(np.random.rand(5, 5)) - -NPY003.py:17:5: NPY003 [*] `np.sometrue` is deprecated; use `np.any` instead - | -15 | product(np.random.rand(5, 5)) -16 | cumproduct(np.random.rand(5, 5)) -17 | sometrue(np.random.rand(5, 5)) - | ^^^^^^^^ NPY003 -18 | alltrue(np.random.rand(5, 5)) - | - = help: Replace with `np.any` - -ℹ Suggested fix - 1 |+from numpy import any -1 2 | def func(): -2 3 | import numpy as np -3 4 | --------------------------------------------------------------------------------- -14 15 | round_(np.random.rand(5, 5), 2) -15 16 | product(np.random.rand(5, 5)) -16 17 | cumproduct(np.random.rand(5, 5)) -17 |- sometrue(np.random.rand(5, 5)) - 18 |+ any(np.random.rand(5, 5)) -18 19 | alltrue(np.random.rand(5, 5)) - -NPY003.py:18:5: NPY003 [*] `np.alltrue` is deprecated; use `np.all` instead - | -16 | cumproduct(np.random.rand(5, 5)) -17 | sometrue(np.random.rand(5, 5)) -18 | alltrue(np.random.rand(5, 5)) - | ^^^^^^^ NPY003 - | - = help: Replace with `np.all` - -ℹ Suggested fix - 1 |+from numpy import all -1 2 | def func(): -2 3 | import numpy as np -3 4 | --------------------------------------------------------------------------------- -15 16 | product(np.random.rand(5, 5)) -16 17 | cumproduct(np.random.rand(5, 5)) -17 18 | sometrue(np.random.rand(5, 5)) -18 |- alltrue(np.random.rand(5, 5)) - 19 |+ all(np.random.rand(5, 5)) - - diff --git a/crates/ruff/src/rules/numpy/snapshots/ruff__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap b/crates/ruff/src/rules/numpy/snapshots/ruff__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap deleted file mode 100644 index 6326a97859..0000000000 --- a/crates/ruff/src/rules/numpy/snapshots/ruff__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap +++ /dev/null @@ -1,156 +0,0 @@ ---- -source: crates/ruff/src/rules/numpy/mod.rs ---- -NPY001.py:6:1: NPY001 [*] Type alias `np.bool` is deprecated, replace with builtin type - | -5 | # Error -6 | npy.bool - | ^^^^^^^^ NPY001 -7 | npy.int - | - = help: Replace `np.bool` with builtin type - -ℹ Suggested fix -3 3 | import numpy -4 4 | -5 5 | # Error -6 |-npy.bool - 6 |+bool -7 7 | npy.int -8 8 | -9 9 | if dtype == np.object: - -NPY001.py:7:1: NPY001 [*] Type alias `np.int` is deprecated, replace with builtin type - | -5 | # Error -6 | npy.bool -7 | npy.int - | ^^^^^^^ NPY001 -8 | -9 | if dtype == np.object: - | - = help: Replace `np.int` with builtin type - -ℹ Suggested fix -4 4 | -5 5 | # Error -6 6 | npy.bool -7 |-npy.int - 7 |+int -8 8 | -9 9 | if dtype == np.object: -10 10 | ... - -NPY001.py:9:13: NPY001 [*] Type alias `np.object` is deprecated, replace with builtin type - | - 7 | npy.int - 8 | - 9 | if dtype == np.object: - | ^^^^^^^^^ NPY001 -10 | ... - | - = help: Replace `np.object` with builtin type - -ℹ Suggested fix -6 6 | npy.bool -7 7 | npy.int -8 8 | -9 |-if dtype == np.object: - 9 |+if dtype == object: -10 10 | ... -11 11 | -12 12 | result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.long]) - -NPY001.py:12:72: NPY001 [*] Type alias `np.int` is deprecated, replace with builtin type - | -10 | ... -11 | -12 | result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.long]) - | ^^^^^^ NPY001 -13 | -14 | pdf = pd.DataFrame( - | - = help: Replace `np.int` with builtin type - -ℹ Suggested fix -9 9 | if dtype == np.object: -10 10 | ... -11 11 | -12 |-result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.long]) - 12 |+result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, int, np.long]) -13 13 | -14 14 | pdf = pd.DataFrame( -15 15 | data=[[1, 2, 3]], - -NPY001.py:12:80: NPY001 [*] Type alias `np.long` is deprecated, replace with builtin type - | -10 | ... -11 | -12 | result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.long]) - | ^^^^^^^ NPY001 -13 | -14 | pdf = pd.DataFrame( - | - = help: Replace `np.long` with builtin type - -ℹ Suggested fix -9 9 | if dtype == np.object: -10 10 | ... -11 11 | -12 |-result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.long]) - 12 |+result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, int]) -13 13 | -14 14 | pdf = pd.DataFrame( -15 15 | data=[[1, 2, 3]], - -NPY001.py:17:11: NPY001 [*] Type alias `np.object` is deprecated, replace with builtin type - | -15 | data=[[1, 2, 3]], -16 | columns=["a", "b", "c"], -17 | dtype=numpy.object, - | ^^^^^^^^^^^^ NPY001 -18 | ) - | - = help: Replace `np.object` with builtin type - -ℹ Suggested fix -14 14 | pdf = pd.DataFrame( -15 15 | data=[[1, 2, 3]], -16 16 | columns=["a", "b", "c"], -17 |- dtype=numpy.object, - 17 |+ dtype=object, -18 18 | ) -19 19 | -20 20 | _ = arr.astype(np.int) - -NPY001.py:20:16: NPY001 [*] Type alias `np.int` is deprecated, replace with builtin type - | -18 | ) -19 | -20 | _ = arr.astype(np.int) - | ^^^^^^ NPY001 -21 | -22 | # Regression test for: https://github.com/astral-sh/ruff/issues/6952 - | - = help: Replace `np.int` with builtin type - -ℹ Suggested fix -17 17 | dtype=numpy.object, -18 18 | ) -19 19 | -20 |-_ = arr.astype(np.int) - 20 |+_ = arr.astype(int) -21 21 | -22 22 | # Regression test for: https://github.com/astral-sh/ruff/issues/6952 -23 23 | from numpy import float - -NPY001.py:25:1: NPY001 Type alias `np.float` is deprecated, replace with builtin type - | -23 | from numpy import float -24 | -25 | float(1) - | ^^^^^ NPY001 - | - = help: Replace `np.float` with builtin type - - diff --git a/crates/ruff/src/rules/numpy/snapshots/ruff__rules__numpy__tests__numpy-legacy-random_NPY002.py.snap b/crates/ruff/src/rules/numpy/snapshots/ruff__rules__numpy__tests__numpy-legacy-random_NPY002.py.snap deleted file mode 100644 index c06c12bee6..0000000000 --- a/crates/ruff/src/rules/numpy/snapshots/ruff__rules__numpy__tests__numpy-legacy-random_NPY002.py.snap +++ /dev/null @@ -1,498 +0,0 @@ ---- -source: crates/ruff/src/rules/numpy/mod.rs ---- -NPY002.py:12:8: NPY002 Replace legacy `np.random.standard_normal` call with `np.random.Generator` - | -10 | from numpy import random -11 | -12 | vals = random.standard_normal(10) - | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 -13 | more_vals = random.standard_normal(10) -14 | numbers = random.integers(high, size=5) - | - -NPY002.py:13:13: NPY002 Replace legacy `np.random.standard_normal` call with `np.random.Generator` - | -12 | vals = random.standard_normal(10) -13 | more_vals = random.standard_normal(10) - | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 -14 | numbers = random.integers(high, size=5) - | - -NPY002.py:18:1: NPY002 Replace legacy `np.random.seed` call with `np.random.Generator` - | -16 | import numpy -17 | -18 | numpy.random.seed() - | ^^^^^^^^^^^^^^^^^ NPY002 -19 | numpy.random.get_state() -20 | numpy.random.set_state() - | - -NPY002.py:19:1: NPY002 Replace legacy `np.random.get_state` call with `np.random.Generator` - | -18 | numpy.random.seed() -19 | numpy.random.get_state() - | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 -20 | numpy.random.set_state() -21 | numpy.random.rand() - | - -NPY002.py:20:1: NPY002 Replace legacy `np.random.set_state` call with `np.random.Generator` - | -18 | numpy.random.seed() -19 | numpy.random.get_state() -20 | numpy.random.set_state() - | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 -21 | numpy.random.rand() -22 | numpy.random.randn() - | - -NPY002.py:21:1: NPY002 Replace legacy `np.random.rand` call with `np.random.Generator` - | -19 | numpy.random.get_state() -20 | numpy.random.set_state() -21 | numpy.random.rand() - | ^^^^^^^^^^^^^^^^^ NPY002 -22 | numpy.random.randn() -23 | numpy.random.randint() - | - -NPY002.py:22:1: NPY002 Replace legacy `np.random.randn` call with `np.random.Generator` - | -20 | numpy.random.set_state() -21 | numpy.random.rand() -22 | numpy.random.randn() - | ^^^^^^^^^^^^^^^^^^ NPY002 -23 | numpy.random.randint() -24 | numpy.random.random_integers() - | - -NPY002.py:23:1: NPY002 Replace legacy `np.random.randint` call with `np.random.Generator` - | -21 | numpy.random.rand() -22 | numpy.random.randn() -23 | numpy.random.randint() - | ^^^^^^^^^^^^^^^^^^^^ NPY002 -24 | numpy.random.random_integers() -25 | numpy.random.random_sample() - | - -NPY002.py:24:1: NPY002 Replace legacy `np.random.random_integers` call with `np.random.Generator` - | -22 | numpy.random.randn() -23 | numpy.random.randint() -24 | numpy.random.random_integers() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 -25 | numpy.random.random_sample() -26 | numpy.random.choice() - | - -NPY002.py:25:1: NPY002 Replace legacy `np.random.random_sample` call with `np.random.Generator` - | -23 | numpy.random.randint() -24 | numpy.random.random_integers() -25 | numpy.random.random_sample() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 -26 | numpy.random.choice() -27 | numpy.random.bytes() - | - -NPY002.py:26:1: NPY002 Replace legacy `np.random.choice` call with `np.random.Generator` - | -24 | numpy.random.random_integers() -25 | numpy.random.random_sample() -26 | numpy.random.choice() - | ^^^^^^^^^^^^^^^^^^^ NPY002 -27 | numpy.random.bytes() -28 | numpy.random.shuffle() - | - -NPY002.py:27:1: NPY002 Replace legacy `np.random.bytes` call with `np.random.Generator` - | -25 | numpy.random.random_sample() -26 | numpy.random.choice() -27 | numpy.random.bytes() - | ^^^^^^^^^^^^^^^^^^ NPY002 -28 | numpy.random.shuffle() -29 | numpy.random.permutation() - | - -NPY002.py:28:1: NPY002 Replace legacy `np.random.shuffle` call with `np.random.Generator` - | -26 | numpy.random.choice() -27 | numpy.random.bytes() -28 | numpy.random.shuffle() - | ^^^^^^^^^^^^^^^^^^^^ NPY002 -29 | numpy.random.permutation() -30 | numpy.random.beta() - | - -NPY002.py:29:1: NPY002 Replace legacy `np.random.permutation` call with `np.random.Generator` - | -27 | numpy.random.bytes() -28 | numpy.random.shuffle() -29 | numpy.random.permutation() - | ^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 -30 | numpy.random.beta() -31 | numpy.random.binomial() - | - -NPY002.py:30:1: NPY002 Replace legacy `np.random.beta` call with `np.random.Generator` - | -28 | numpy.random.shuffle() -29 | numpy.random.permutation() -30 | numpy.random.beta() - | ^^^^^^^^^^^^^^^^^ NPY002 -31 | numpy.random.binomial() -32 | numpy.random.chisquare() - | - -NPY002.py:31:1: NPY002 Replace legacy `np.random.binomial` call with `np.random.Generator` - | -29 | numpy.random.permutation() -30 | numpy.random.beta() -31 | numpy.random.binomial() - | ^^^^^^^^^^^^^^^^^^^^^ NPY002 -32 | numpy.random.chisquare() -33 | numpy.random.dirichlet() - | - -NPY002.py:32:1: NPY002 Replace legacy `np.random.chisquare` call with `np.random.Generator` - | -30 | numpy.random.beta() -31 | numpy.random.binomial() -32 | numpy.random.chisquare() - | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 -33 | numpy.random.dirichlet() -34 | numpy.random.exponential() - | - -NPY002.py:33:1: NPY002 Replace legacy `np.random.dirichlet` call with `np.random.Generator` - | -31 | numpy.random.binomial() -32 | numpy.random.chisquare() -33 | numpy.random.dirichlet() - | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 -34 | numpy.random.exponential() -35 | numpy.random.f() - | - -NPY002.py:34:1: NPY002 Replace legacy `np.random.exponential` call with `np.random.Generator` - | -32 | numpy.random.chisquare() -33 | numpy.random.dirichlet() -34 | numpy.random.exponential() - | ^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 -35 | numpy.random.f() -36 | numpy.random.gamma() - | - -NPY002.py:35:1: NPY002 Replace legacy `np.random.f` call with `np.random.Generator` - | -33 | numpy.random.dirichlet() -34 | numpy.random.exponential() -35 | numpy.random.f() - | ^^^^^^^^^^^^^^ NPY002 -36 | numpy.random.gamma() -37 | numpy.random.geometric() - | - -NPY002.py:36:1: NPY002 Replace legacy `np.random.gamma` call with `np.random.Generator` - | -34 | numpy.random.exponential() -35 | numpy.random.f() -36 | numpy.random.gamma() - | ^^^^^^^^^^^^^^^^^^ NPY002 -37 | numpy.random.geometric() -38 | numpy.random.get_state() - | - -NPY002.py:37:1: NPY002 Replace legacy `np.random.geometric` call with `np.random.Generator` - | -35 | numpy.random.f() -36 | numpy.random.gamma() -37 | numpy.random.geometric() - | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 -38 | numpy.random.get_state() -39 | numpy.random.gumbel() - | - -NPY002.py:38:1: NPY002 Replace legacy `np.random.get_state` call with `np.random.Generator` - | -36 | numpy.random.gamma() -37 | numpy.random.geometric() -38 | numpy.random.get_state() - | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 -39 | numpy.random.gumbel() -40 | numpy.random.hypergeometric() - | - -NPY002.py:39:1: NPY002 Replace legacy `np.random.gumbel` call with `np.random.Generator` - | -37 | numpy.random.geometric() -38 | numpy.random.get_state() -39 | numpy.random.gumbel() - | ^^^^^^^^^^^^^^^^^^^ NPY002 -40 | numpy.random.hypergeometric() -41 | numpy.random.laplace() - | - -NPY002.py:40:1: NPY002 Replace legacy `np.random.hypergeometric` call with `np.random.Generator` - | -38 | numpy.random.get_state() -39 | numpy.random.gumbel() -40 | numpy.random.hypergeometric() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 -41 | numpy.random.laplace() -42 | numpy.random.logistic() - | - -NPY002.py:41:1: NPY002 Replace legacy `np.random.laplace` call with `np.random.Generator` - | -39 | numpy.random.gumbel() -40 | numpy.random.hypergeometric() -41 | numpy.random.laplace() - | ^^^^^^^^^^^^^^^^^^^^ NPY002 -42 | numpy.random.logistic() -43 | numpy.random.lognormal() - | - -NPY002.py:42:1: NPY002 Replace legacy `np.random.logistic` call with `np.random.Generator` - | -40 | numpy.random.hypergeometric() -41 | numpy.random.laplace() -42 | numpy.random.logistic() - | ^^^^^^^^^^^^^^^^^^^^^ NPY002 -43 | numpy.random.lognormal() -44 | numpy.random.logseries() - | - -NPY002.py:43:1: NPY002 Replace legacy `np.random.lognormal` call with `np.random.Generator` - | -41 | numpy.random.laplace() -42 | numpy.random.logistic() -43 | numpy.random.lognormal() - | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 -44 | numpy.random.logseries() -45 | numpy.random.multinomial() - | - -NPY002.py:44:1: NPY002 Replace legacy `np.random.logseries` call with `np.random.Generator` - | -42 | numpy.random.logistic() -43 | numpy.random.lognormal() -44 | numpy.random.logseries() - | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 -45 | numpy.random.multinomial() -46 | numpy.random.multivariate_normal() - | - -NPY002.py:45:1: NPY002 Replace legacy `np.random.multinomial` call with `np.random.Generator` - | -43 | numpy.random.lognormal() -44 | numpy.random.logseries() -45 | numpy.random.multinomial() - | ^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 -46 | numpy.random.multivariate_normal() -47 | numpy.random.negative_binomial() - | - -NPY002.py:46:1: NPY002 Replace legacy `np.random.multivariate_normal` call with `np.random.Generator` - | -44 | numpy.random.logseries() -45 | numpy.random.multinomial() -46 | numpy.random.multivariate_normal() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 -47 | numpy.random.negative_binomial() -48 | numpy.random.noncentral_chisquare() - | - -NPY002.py:47:1: NPY002 Replace legacy `np.random.negative_binomial` call with `np.random.Generator` - | -45 | numpy.random.multinomial() -46 | numpy.random.multivariate_normal() -47 | numpy.random.negative_binomial() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 -48 | numpy.random.noncentral_chisquare() -49 | numpy.random.noncentral_f() - | - -NPY002.py:48:1: NPY002 Replace legacy `np.random.noncentral_chisquare` call with `np.random.Generator` - | -46 | numpy.random.multivariate_normal() -47 | numpy.random.negative_binomial() -48 | numpy.random.noncentral_chisquare() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 -49 | numpy.random.noncentral_f() -50 | numpy.random.normal() - | - -NPY002.py:49:1: NPY002 Replace legacy `np.random.noncentral_f` call with `np.random.Generator` - | -47 | numpy.random.negative_binomial() -48 | numpy.random.noncentral_chisquare() -49 | numpy.random.noncentral_f() - | ^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 -50 | numpy.random.normal() -51 | numpy.random.pareto() - | - -NPY002.py:50:1: NPY002 Replace legacy `np.random.normal` call with `np.random.Generator` - | -48 | numpy.random.noncentral_chisquare() -49 | numpy.random.noncentral_f() -50 | numpy.random.normal() - | ^^^^^^^^^^^^^^^^^^^ NPY002 -51 | numpy.random.pareto() -52 | numpy.random.poisson() - | - -NPY002.py:51:1: NPY002 Replace legacy `np.random.pareto` call with `np.random.Generator` - | -49 | numpy.random.noncentral_f() -50 | numpy.random.normal() -51 | numpy.random.pareto() - | ^^^^^^^^^^^^^^^^^^^ NPY002 -52 | numpy.random.poisson() -53 | numpy.random.power() - | - -NPY002.py:52:1: NPY002 Replace legacy `np.random.poisson` call with `np.random.Generator` - | -50 | numpy.random.normal() -51 | numpy.random.pareto() -52 | numpy.random.poisson() - | ^^^^^^^^^^^^^^^^^^^^ NPY002 -53 | numpy.random.power() -54 | numpy.random.rayleigh() - | - -NPY002.py:53:1: NPY002 Replace legacy `np.random.power` call with `np.random.Generator` - | -51 | numpy.random.pareto() -52 | numpy.random.poisson() -53 | numpy.random.power() - | ^^^^^^^^^^^^^^^^^^ NPY002 -54 | numpy.random.rayleigh() -55 | numpy.random.standard_cauchy() - | - -NPY002.py:54:1: NPY002 Replace legacy `np.random.rayleigh` call with `np.random.Generator` - | -52 | numpy.random.poisson() -53 | numpy.random.power() -54 | numpy.random.rayleigh() - | ^^^^^^^^^^^^^^^^^^^^^ NPY002 -55 | numpy.random.standard_cauchy() -56 | numpy.random.standard_exponential() - | - -NPY002.py:55:1: NPY002 Replace legacy `np.random.standard_cauchy` call with `np.random.Generator` - | -53 | numpy.random.power() -54 | numpy.random.rayleigh() -55 | numpy.random.standard_cauchy() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 -56 | numpy.random.standard_exponential() -57 | numpy.random.standard_gamma() - | - -NPY002.py:56:1: NPY002 Replace legacy `np.random.standard_exponential` call with `np.random.Generator` - | -54 | numpy.random.rayleigh() -55 | numpy.random.standard_cauchy() -56 | numpy.random.standard_exponential() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 -57 | numpy.random.standard_gamma() -58 | numpy.random.standard_normal() - | - -NPY002.py:57:1: NPY002 Replace legacy `np.random.standard_gamma` call with `np.random.Generator` - | -55 | numpy.random.standard_cauchy() -56 | numpy.random.standard_exponential() -57 | numpy.random.standard_gamma() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 -58 | numpy.random.standard_normal() -59 | numpy.random.standard_t() - | - -NPY002.py:58:1: NPY002 Replace legacy `np.random.standard_normal` call with `np.random.Generator` - | -56 | numpy.random.standard_exponential() -57 | numpy.random.standard_gamma() -58 | numpy.random.standard_normal() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 -59 | numpy.random.standard_t() -60 | numpy.random.triangular() - | - -NPY002.py:59:1: NPY002 Replace legacy `np.random.standard_t` call with `np.random.Generator` - | -57 | numpy.random.standard_gamma() -58 | numpy.random.standard_normal() -59 | numpy.random.standard_t() - | ^^^^^^^^^^^^^^^^^^^^^^^ NPY002 -60 | numpy.random.triangular() -61 | numpy.random.uniform() - | - -NPY002.py:60:1: NPY002 Replace legacy `np.random.triangular` call with `np.random.Generator` - | -58 | numpy.random.standard_normal() -59 | numpy.random.standard_t() -60 | numpy.random.triangular() - | ^^^^^^^^^^^^^^^^^^^^^^^ NPY002 -61 | numpy.random.uniform() -62 | numpy.random.vonmises() - | - -NPY002.py:61:1: NPY002 Replace legacy `np.random.uniform` call with `np.random.Generator` - | -59 | numpy.random.standard_t() -60 | numpy.random.triangular() -61 | numpy.random.uniform() - | ^^^^^^^^^^^^^^^^^^^^ NPY002 -62 | numpy.random.vonmises() -63 | numpy.random.wald() - | - -NPY002.py:62:1: NPY002 Replace legacy `np.random.vonmises` call with `np.random.Generator` - | -60 | numpy.random.triangular() -61 | numpy.random.uniform() -62 | numpy.random.vonmises() - | ^^^^^^^^^^^^^^^^^^^^^ NPY002 -63 | numpy.random.wald() -64 | numpy.random.weibull() - | - -NPY002.py:63:1: NPY002 Replace legacy `np.random.wald` call with `np.random.Generator` - | -61 | numpy.random.uniform() -62 | numpy.random.vonmises() -63 | numpy.random.wald() - | ^^^^^^^^^^^^^^^^^ NPY002 -64 | numpy.random.weibull() -65 | numpy.random.zipf() - | - -NPY002.py:64:1: NPY002 Replace legacy `np.random.weibull` call with `np.random.Generator` - | -62 | numpy.random.vonmises() -63 | numpy.random.wald() -64 | numpy.random.weibull() - | ^^^^^^^^^^^^^^^^^^^^ NPY002 -65 | numpy.random.zipf() - | - -NPY002.py:65:1: NPY002 Replace legacy `np.random.zipf` call with `np.random.Generator` - | -63 | numpy.random.wald() -64 | numpy.random.weibull() -65 | numpy.random.zipf() - | ^^^^^^^^^^^^^^^^^ NPY002 - | - - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_PD002.py.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_PD002.py.snap deleted file mode 100644 index a57280c4ba..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_PD002.py.snap +++ /dev/null @@ -1,177 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- -PD002.py:5:23: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior - | -3 | x = pd.DataFrame() -4 | -5 | x.drop(["a"], axis=1, inplace=True) - | ^^^^^^^^^^^^ PD002 -6 | -7 | x.y.drop(["a"], axis=1, inplace=True) - | - = help: Assign to variable; remove `inplace` arg - -ℹ Suggested fix -2 2 | -3 3 | x = pd.DataFrame() -4 4 | -5 |-x.drop(["a"], axis=1, inplace=True) - 5 |+x = x.drop(["a"], axis=1) -6 6 | -7 7 | x.y.drop(["a"], axis=1, inplace=True) -8 8 | - -PD002.py:7:25: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior - | -5 | x.drop(["a"], axis=1, inplace=True) -6 | -7 | x.y.drop(["a"], axis=1, inplace=True) - | ^^^^^^^^^^^^ PD002 -8 | -9 | x["y"].drop(["a"], axis=1, inplace=True) - | - = help: Assign to variable; remove `inplace` arg - -ℹ Suggested fix -4 4 | -5 5 | x.drop(["a"], axis=1, inplace=True) -6 6 | -7 |-x.y.drop(["a"], axis=1, inplace=True) - 7 |+x.y = x.y.drop(["a"], axis=1) -8 8 | -9 9 | x["y"].drop(["a"], axis=1, inplace=True) -10 10 | - -PD002.py:9:28: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior - | - 7 | x.y.drop(["a"], axis=1, inplace=True) - 8 | - 9 | x["y"].drop(["a"], axis=1, inplace=True) - | ^^^^^^^^^^^^ PD002 -10 | -11 | x.drop( - | - = help: Assign to variable; remove `inplace` arg - -ℹ Suggested fix -6 6 | -7 7 | x.y.drop(["a"], axis=1, inplace=True) -8 8 | -9 |-x["y"].drop(["a"], axis=1, inplace=True) - 9 |+x["y"] = x["y"].drop(["a"], axis=1) -10 10 | -11 11 | x.drop( -12 12 | inplace=True, - -PD002.py:12:5: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior - | -11 | x.drop( -12 | inplace=True, - | ^^^^^^^^^^^^ PD002 -13 | columns=["a"], -14 | axis=1, - | - = help: Assign to variable; remove `inplace` arg - -ℹ Suggested fix -8 8 | -9 9 | x["y"].drop(["a"], axis=1, inplace=True) -10 10 | -11 |-x.drop( -12 |- inplace=True, - 11 |+x = x.drop( -13 12 | columns=["a"], -14 13 | axis=1, -15 14 | ) - -PD002.py:19:9: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior - | -17 | if True: -18 | x.drop( -19 | inplace=True, - | ^^^^^^^^^^^^ PD002 -20 | columns=["a"], -21 | axis=1, - | - = help: Assign to variable; remove `inplace` arg - -ℹ Suggested fix -15 15 | ) -16 16 | -17 17 | if True: -18 |- x.drop( -19 |- inplace=True, - 18 |+ x = x.drop( -20 19 | columns=["a"], -21 20 | axis=1, -22 21 | ) - -PD002.py:24:33: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior - | -22 | ) -23 | -24 | x.drop(["a"], axis=1, **kwargs, inplace=True) - | ^^^^^^^^^^^^ PD002 -25 | x.drop(["a"], axis=1, inplace=True, **kwargs) -26 | f(x.drop(["a"], axis=1, inplace=True)) - | - = help: Assign to variable; remove `inplace` arg - -ℹ Suggested fix -21 21 | axis=1, -22 22 | ) -23 23 | -24 |-x.drop(["a"], axis=1, **kwargs, inplace=True) - 24 |+x = x.drop(["a"], axis=1, **kwargs) -25 25 | x.drop(["a"], axis=1, inplace=True, **kwargs) -26 26 | f(x.drop(["a"], axis=1, inplace=True)) -27 27 | - -PD002.py:25:23: PD002 `inplace=True` should be avoided; it has inconsistent behavior - | -24 | x.drop(["a"], axis=1, **kwargs, inplace=True) -25 | x.drop(["a"], axis=1, inplace=True, **kwargs) - | ^^^^^^^^^^^^ PD002 -26 | f(x.drop(["a"], axis=1, inplace=True)) - | - = help: Assign to variable; remove `inplace` arg - -PD002.py:26:25: PD002 `inplace=True` should be avoided; it has inconsistent behavior - | -24 | x.drop(["a"], axis=1, **kwargs, inplace=True) -25 | x.drop(["a"], axis=1, inplace=True, **kwargs) -26 | f(x.drop(["a"], axis=1, inplace=True)) - | ^^^^^^^^^^^^ PD002 -27 | -28 | x.apply(lambda x: x.sort_values("a", inplace=True)) - | - = help: Assign to variable; remove `inplace` arg - -PD002.py:28:38: PD002 `inplace=True` should be avoided; it has inconsistent behavior - | -26 | f(x.drop(["a"], axis=1, inplace=True)) -27 | -28 | x.apply(lambda x: x.sort_values("a", inplace=True)) - | ^^^^^^^^^^^^ PD002 -29 | import torch - | - = help: Assign to variable; remove `inplace` arg - -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 | -33 | (x.drop(["a"], axis=1, inplace=True)) - | ^^^^^^^^^^^^ PD002 - | - = help: Assign to variable; remove `inplace` arg - -ℹ Suggested fix -30 30 | -31 31 | torch.m.ReLU(inplace=True) # safe because this isn't a pandas call -32 32 | -33 |-(x.drop(["a"], axis=1, inplace=True)) - 33 |+x = (x.drop(["a"], axis=1)) - - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_fail.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_fail.snap deleted file mode 100644 index 0a60b7ba2d..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_fail.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- -:4:23: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior - | -2 | import pandas as pd -3 | x = pd.DataFrame() -4 | x.drop(["a"], axis=1, inplace=True) - | ^^^^^^^^^^^^ PD002 - | - = help: Assign to variable; remove `inplace` arg - -ℹ Suggested fix -1 1 | -2 2 | import pandas as pd -3 3 | x = pd.DataFrame() -4 |-x.drop(["a"], axis=1, inplace=True) - 4 |+x = x.drop(["a"], axis=1) - - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_pass.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_pass.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD002_pass.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD003_allows_other_calls.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD003_allows_other_calls.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD003_allows_other_calls.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD003_fail.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD003_fail.snap deleted file mode 100644 index 8dcf28166e..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD003_fail.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- -:3:9: PD003 `.isna` is preferred to `.isnull`; functionality is equivalent - | -2 | import pandas as pd -3 | nulls = pd.isnull(val) - | ^^^^^^^^^ PD003 - | - - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD003_pass.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD003_pass.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD003_pass.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD004_fail.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD004_fail.snap deleted file mode 100644 index 4fb7b42afe..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD004_fail.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- -:3:13: PD004 `.notna` is preferred to `.notnull`; functionality is equivalent - | -2 | import pandas as pd -3 | not_nulls = pd.notnull(val) - | ^^^^^^^^^^ PD004 - | - - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD004_pass.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD004_pass.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD004_pass.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD007_fail.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD007_fail.snap deleted file mode 100644 index 50e601131f..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD007_fail.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- -:4:5: PD007 `.ix` is deprecated; use more explicit `.loc` or `.iloc` - | -2 | import pandas as pd -3 | x = pd.DataFrame() -4 | y = x.ix[[0, 2], "A"] - | ^^^^^^^^^^^^^^^^^ PD007 - | - - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD007_pass_iloc.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD007_pass_iloc.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD007_pass_iloc.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD007_pass_loc.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD007_pass_loc.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD007_pass_loc.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD008_fail.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD008_fail.snap deleted file mode 100644 index f36ff0557a..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD008_fail.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- -:4:9: PD008 Use `.loc` instead of `.at`. If speed is important, use NumPy. - | -2 | import pandas as pd -3 | x = pd.DataFrame() -4 | index = x.at[:, ["B", "A"]] - | ^^^^^^^^^^^^^^^^^^^ PD008 - | - - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD008_pass.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD008_pass.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD008_pass.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD008_pass_on_attr.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD008_pass_on_attr.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD008_pass_on_attr.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD009_fail.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD009_fail.snap deleted file mode 100644 index cfb9533b81..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD009_fail.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- -:4:9: PD009 Use `.iloc` instead of `.iat`. If speed is important, use NumPy. - | -2 | import pandas as pd -3 | x = pd.DataFrame() -4 | index = x.iat[:, 1:3] - | ^^^^^^^^^^^^^ PD009 - | - - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD009_pass.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD009_pass.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD009_pass.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD010_fail_pivot.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD010_fail_pivot.snap deleted file mode 100644 index 92686007fb..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD010_fail_pivot.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- -:4:9: PD010 `.pivot_table` is preferred to `.pivot` or `.unstack`; provides same functionality - | -2 | import pandas as pd -3 | x = pd.DataFrame() -4 | table = pd.pivot( - | ^^^^^^^^ PD010 -5 | x, -6 | index="foo", - | - - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD010_pass.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD010_pass.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD010_pass.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_fail_values.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_fail_values.snap deleted file mode 100644 index 4c8e1611e7..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_fail_values.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- -:4:10: PD011 Use `.to_numpy()` instead of `.values` - | -2 | import pandas as pd -3 | x = pd.DataFrame() -4 | result = x.values - | ^^^^^^^^ PD011 - | - - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_array.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_array.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_array.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_node_name.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_node_name.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_node_name.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_to_array.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_to_array.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_to_array.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_values_call.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_values_call.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_values_call.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_values_dict.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_values_dict.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_values_dict.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_values_import.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_values_import.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_values_import.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_values_instance.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_values_instance.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_values_instance.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_values_store.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_values_store.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_values_store.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_values_unbound.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_values_unbound.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD011_pass_values_unbound.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD012_pandas_use_of_dot_read_table.py.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD012_pandas_use_of_dot_read_table.py.snap deleted file mode 100644 index 06fcb65b1e..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD012_pandas_use_of_dot_read_table.py.snap +++ /dev/null @@ -1,42 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- -pandas_use_of_dot_read_table.py:4:6: PD012 Use `.read_csv` instead of `.read_table` to read CSV files - | -3 | # Errors. -4 | df = pd.read_table("data.csv", sep=",") - | ^^^^^^^^^^^^^ PD012 -5 | df = pd.read_table("data.csv", sep=",", header=0) -6 | filename = "data.csv" - | - -pandas_use_of_dot_read_table.py:5:6: PD012 Use `.read_csv` instead of `.read_table` to read CSV files - | -3 | # Errors. -4 | df = pd.read_table("data.csv", sep=",") -5 | df = pd.read_table("data.csv", sep=",", header=0) - | ^^^^^^^^^^^^^ PD012 -6 | filename = "data.csv" -7 | df = pd.read_table(filename, sep=",") - | - -pandas_use_of_dot_read_table.py:7:6: PD012 Use `.read_csv` instead of `.read_table` to read CSV files - | -5 | df = pd.read_table("data.csv", sep=",", header=0) -6 | filename = "data.csv" -7 | df = pd.read_table(filename, sep=",") - | ^^^^^^^^^^^^^ PD012 -8 | df = pd.read_table(filename, sep=",", header=0) - | - -pandas_use_of_dot_read_table.py:8:6: PD012 Use `.read_csv` instead of `.read_table` to read CSV files - | - 6 | filename = "data.csv" - 7 | df = pd.read_table(filename, sep=",") - 8 | df = pd.read_table(filename, sep=",", header=0) - | ^^^^^^^^^^^^^ PD012 - 9 | -10 | # Non-errors. - | - - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD013_fail_stack.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD013_fail_stack.snap deleted file mode 100644 index f19ad540ba..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD013_fail_stack.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- -:4:5: PD013 `.melt` is preferred to `.stack`; provides same functionality - | -2 | import pandas as pd -3 | x = pd.DataFrame() -4 | y = x.stack(level=-1, dropna=True) - | ^^^^^^^ PD013 - | - - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD013_pass.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD013_pass.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD013_pass.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD013_pass_numpy.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD013_pass_numpy.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD013_pass_numpy.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD013_pass_unbound.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD013_pass_unbound.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD013_pass_unbound.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD015_fail_merge_on_pandas_object.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD015_fail_merge_on_pandas_object.snap deleted file mode 100644 index 1b206b7a55..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD015_fail_merge_on_pandas_object.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- -:5:1: PD015 Use `.merge` method instead of `pd.merge` function. They have equivalent functionality. - | -3 | x = pd.DataFrame() -4 | y = pd.DataFrame() -5 | pd.merge(x, y) - | ^^^^^^^^ PD015 - | - - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD015_pass_merge_on_dataframe.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD015_pass_merge_on_dataframe.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD015_pass_merge_on_dataframe.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD015_pass_merge_on_dataframe_with_multiple_args.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD015_pass_merge_on_dataframe_with_multiple_args.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD015_pass_merge_on_dataframe_with_multiple_args.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD015_pass_other_pd_function.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD015_pass_other_pd_function.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD015_pass_other_pd_function.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD101_PD101.py.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD101_PD101.py.snap deleted file mode 100644 index ddfdd060ba..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD101_PD101.py.snap +++ /dev/null @@ -1,122 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- -PD101.py:7:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient - | -6 | # PD101 -7 | data.nunique() <= 1 - | ^^^^^^^^^^^^^^^^^^^ PD101 -8 | data.nunique(dropna=True) <= 1 -9 | data.nunique(dropna=False) <= 1 - | - -PD101.py:8:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient - | - 6 | # PD101 - 7 | data.nunique() <= 1 - 8 | data.nunique(dropna=True) <= 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 - 9 | data.nunique(dropna=False) <= 1 -10 | data.nunique() == 1 - | - -PD101.py:9:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient - | - 7 | data.nunique() <= 1 - 8 | data.nunique(dropna=True) <= 1 - 9 | data.nunique(dropna=False) <= 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 -10 | data.nunique() == 1 -11 | data.nunique(dropna=True) == 1 - | - -PD101.py:10:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient - | - 8 | data.nunique(dropna=True) <= 1 - 9 | data.nunique(dropna=False) <= 1 -10 | data.nunique() == 1 - | ^^^^^^^^^^^^^^^^^^^ PD101 -11 | data.nunique(dropna=True) == 1 -12 | data.nunique(dropna=False) == 1 - | - -PD101.py:11:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient - | - 9 | data.nunique(dropna=False) <= 1 -10 | data.nunique() == 1 -11 | data.nunique(dropna=True) == 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 -12 | data.nunique(dropna=False) == 1 -13 | data.nunique() != 1 - | - -PD101.py:12:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient - | -10 | data.nunique() == 1 -11 | data.nunique(dropna=True) == 1 -12 | data.nunique(dropna=False) == 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 -13 | data.nunique() != 1 -14 | data.nunique(dropna=True) != 1 - | - -PD101.py:13:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient - | -11 | data.nunique(dropna=True) == 1 -12 | data.nunique(dropna=False) == 1 -13 | data.nunique() != 1 - | ^^^^^^^^^^^^^^^^^^^ PD101 -14 | data.nunique(dropna=True) != 1 -15 | data.nunique(dropna=False) != 1 - | - -PD101.py:14:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient - | -12 | data.nunique(dropna=False) == 1 -13 | data.nunique() != 1 -14 | data.nunique(dropna=True) != 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 -15 | data.nunique(dropna=False) != 1 -16 | data.nunique() > 1 - | - -PD101.py:15:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient - | -13 | data.nunique() != 1 -14 | data.nunique(dropna=True) != 1 -15 | data.nunique(dropna=False) != 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 -16 | data.nunique() > 1 -17 | data.dropna().nunique() == 1 - | - -PD101.py:16:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient - | -14 | data.nunique(dropna=True) != 1 -15 | data.nunique(dropna=False) != 1 -16 | data.nunique() > 1 - | ^^^^^^^^^^^^^^^^^^ PD101 -17 | data.dropna().nunique() == 1 -18 | data[data.notnull()].nunique() == 1 - | - -PD101.py:17:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient - | -15 | data.nunique(dropna=False) != 1 -16 | data.nunique() > 1 -17 | data.dropna().nunique() == 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 -18 | data[data.notnull()].nunique() == 1 - | - -PD101.py:18:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient - | -16 | data.nunique() > 1 -17 | data.dropna().nunique() == 1 -18 | data[data.notnull()].nunique() == 1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 -19 | -20 | # No violation of this rule - | - - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD901_fail_df_var.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD901_fail_df_var.snap deleted file mode 100644 index 61f786e762..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD901_fail_df_var.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- -:3:1: PD901 `df` is a bad variable name. Be kinder to your future self. - | -2 | import pandas as pd -3 | df = pd.DataFrame() - | ^^ PD901 - | - - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD901_pass_df_param.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD901_pass_df_param.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD901_pass_df_param.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD901_pass_non_df.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD901_pass_non_df.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD901_pass_non_df.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD901_pass_part_df.snap b/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD901_pass_part_df.snap deleted file mode 100644 index cee5b2f842..0000000000 --- a/crates/ruff/src/rules/pandas_vet/snapshots/ruff__rules__pandas_vet__tests__PD901_pass_part_df.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pandas_vet/mod.rs ---- - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N801_N801.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N801_N801.py.snap deleted file mode 100644 index 1756c047ab..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N801_N801.py.snap +++ /dev/null @@ -1,39 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N801.py:1:7: N801 Class name `bad` should use CapWords convention - | -1 | class bad: - | ^^^ N801 -2 | pass - | - -N801.py:5:7: N801 Class name `_bad` should use CapWords convention - | -5 | class _bad: - | ^^^^ N801 -6 | pass - | - -N801.py:9:7: N801 Class name `bad_class` should use CapWords convention - | - 9 | class bad_class: - | ^^^^^^^^^ N801 -10 | pass - | - -N801.py:13:7: N801 Class name `Bad_Class` should use CapWords convention - | -13 | class Bad_Class: - | ^^^^^^^^^ N801 -14 | pass - | - -N801.py:17:7: N801 Class name `BAD_CLASS` should use CapWords convention - | -17 | class BAD_CLASS: - | ^^^^^^^^^ N801 -18 | pass - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N802_N802.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N802_N802.py.snap deleted file mode 100644 index 6446a68ad5..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N802_N802.py.snap +++ /dev/null @@ -1,41 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N802.py:4:5: N802 Function name `Bad` should be lowercase - | -4 | def Bad(): - | ^^^ N802 -5 | pass - | - -N802.py:8:5: N802 Function name `_Bad` should be lowercase - | -8 | def _Bad(): - | ^^^^ N802 -9 | pass - | - -N802.py:12:5: N802 Function name `BAD` should be lowercase - | -12 | def BAD(): - | ^^^ N802 -13 | pass - | - -N802.py:16:5: N802 Function name `BAD_FUNC` should be lowercase - | -16 | def BAD_FUNC(): - | ^^^^^^^^ N802 -17 | pass - | - -N802.py:40:9: N802 Function name `testTest` should be lowercase - | -38 | return super().tearDown() -39 | -40 | def testTest(self): - | ^^^^^^^^ N802 -41 | assert True - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N803_N803.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N803_N803.py.snap deleted file mode 100644 index 90094e305b..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N803_N803.py.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N803.py:1:16: N803 Argument name `A` should be lowercase - | -1 | def func(_, a, A): - | ^ N803 -2 | return _, a, A - | - -N803.py:6:28: N803 Argument name `A` should be lowercase - | -5 | class Class: -6 | def method(self, _, a, A): - | ^ N803 -7 | return _, a, A - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N804_N804.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N804_N804.py.snap deleted file mode 100644 index 583e124692..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N804_N804.py.snap +++ /dev/null @@ -1,29 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N804.py:30:27: N804 First argument of a class method should be named `cls` - | -28 | ... -29 | -30 | def __init_subclass__(self, default_name, **kwargs): - | ^^^^ N804 -31 | ... - | - -N804.py:38:56: N804 First argument of a class method should be named `cls` - | -37 | @classmethod -38 | def bad_class_method_with_positional_only_argument(self, x, /, other): - | ^^^^ N804 -39 | ... - | - -N804.py:43:20: N804 First argument of a class method should be named `cls` - | -42 | class MetaClass(ABCMeta): -43 | def bad_method(self): - | ^^^^ N804 -44 | pass - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N805_N805.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N805_N805.py.snap deleted file mode 100644 index 714a639ab7..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N805_N805.py.snap +++ /dev/null @@ -1,46 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N805.py:7:20: N805 First argument of a method should be named `self` - | -6 | class Class: -7 | def bad_method(this): - | ^^^^ N805 -8 | pass - | - -N805.py:12:30: N805 First argument of a method should be named `self` - | -10 | if False: -11 | -12 | def extra_bad_method(this): - | ^^^^ N805 -13 | pass - | - -N805.py:31:15: N805 First argument of a method should be named `self` - | -30 | @pydantic.validator -31 | def lower(cls, my_field: str) -> str: - | ^^^ N805 -32 | pass - | - -N805.py:35:15: N805 First argument of a method should be named `self` - | -34 | @pydantic.validator("my_field") -35 | def lower(cls, my_field: str) -> str: - | ^^^ N805 -36 | pass - | - -N805.py:64:29: N805 First argument of a method should be named `self` - | -62 | pass -63 | -64 | def bad_method_pos_only(this, blah, /, self, something: str): - | ^^^^ N805 -65 | pass - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N806_N806.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N806_N806.py.snap deleted file mode 100644 index f2a3d321b4..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N806_N806.py.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N806.py:12:5: N806 Variable `Camel` in function should be lowercase - | -10 | GLOBAL = "bar" -11 | lower = 0 -12 | Camel = 0 - | ^^^^^ N806 -13 | CONSTANT = 0 -14 | _ = 0 - | - -N806.py:13:5: N806 Variable `CONSTANT` in function should be lowercase - | -11 | lower = 0 -12 | Camel = 0 -13 | CONSTANT = 0 - | ^^^^^^^^ N806 -14 | _ = 0 - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N807_N807.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N807_N807.py.snap deleted file mode 100644 index 400e893261..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N807_N807.py.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N807.py:1:5: N807 Function name should not start and end with `__` - | -1 | def __bad__(): - | ^^^^^^^ N807 -2 | pass - | - -N807.py:14:9: N807 Function name should not start and end with `__` - | -13 | def nested(): -14 | def __bad__(): - | ^^^^^^^ N807 -15 | pass - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N811_N811.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N811_N811.py.snap deleted file mode 100644 index 797bd557a5..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N811_N811.py.snap +++ /dev/null @@ -1,28 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N811.py:1:8: N811 Constant `CONST` imported as non-constant `const` - | -1 | import mod.CONST as const - | ^^^^^^^^^^^^^^^^^^ N811 -2 | from mod import CONSTANT as constant -3 | from mod import ANOTHER_CONSTANT as another_constant - | - -N811.py:2:17: N811 Constant `CONSTANT` imported as non-constant `constant` - | -1 | import mod.CONST as const -2 | from mod import CONSTANT as constant - | ^^^^^^^^^^^^^^^^^^^^ N811 -3 | from mod import ANOTHER_CONSTANT as another_constant - | - -N811.py:3:17: N811 Constant `ANOTHER_CONSTANT` imported as non-constant `another_constant` - | -1 | import mod.CONST as const -2 | from mod import CONSTANT as constant -3 | from mod import ANOTHER_CONSTANT as another_constant - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ N811 - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N812_N812.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N812_N812.py.snap deleted file mode 100644 index 5a7efcbe36..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N812_N812.py.snap +++ /dev/null @@ -1,28 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N812.py:1:8: N812 Lowercase `lowercase` imported as non-lowercase `Lower` - | -1 | import modl.lowercase as Lower - | ^^^^^^^^^^^^^^^^^^^^^^^ N812 -2 | from mod import lowercase as Lowercase -3 | from mod import another_lowercase as AnotherLowercase - | - -N812.py:2:17: N812 Lowercase `lowercase` imported as non-lowercase `Lowercase` - | -1 | import modl.lowercase as Lower -2 | from mod import lowercase as Lowercase - | ^^^^^^^^^^^^^^^^^^^^^^ N812 -3 | from mod import another_lowercase as AnotherLowercase - | - -N812.py:3:17: N812 Lowercase `another_lowercase` imported as non-lowercase `AnotherLowercase` - | -1 | import modl.lowercase as Lower -2 | from mod import lowercase as Lowercase -3 | from mod import another_lowercase as AnotherLowercase - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ N812 - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N813_N813.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N813_N813.py.snap deleted file mode 100644 index 0b067b1278..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N813_N813.py.snap +++ /dev/null @@ -1,28 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N813.py:1:8: N813 Camelcase `Camel` imported as lowercase `camel` - | -1 | import mod.Camel as camel - | ^^^^^^^^^^^^^^^^^^ N813 -2 | from mod import CamelCase as camelcase -3 | from mod import AnotherCamelCase as another_camelcase - | - -N813.py:2:17: N813 Camelcase `CamelCase` imported as lowercase `camelcase` - | -1 | import mod.Camel as camel -2 | from mod import CamelCase as camelcase - | ^^^^^^^^^^^^^^^^^^^^^^ N813 -3 | from mod import AnotherCamelCase as another_camelcase - | - -N813.py:3:17: N813 Camelcase `AnotherCamelCase` imported as lowercase `another_camelcase` - | -1 | import mod.Camel as camel -2 | from mod import CamelCase as camelcase -3 | from mod import AnotherCamelCase as another_camelcase - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ N813 - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N814_N814.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N814_N814.py.snap deleted file mode 100644 index f859bdd13a..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N814_N814.py.snap +++ /dev/null @@ -1,28 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N814.py:1:8: N814 Camelcase `Camel` imported as constant `CAMEL` - | -1 | import mod.Camel as CAMEL - | ^^^^^^^^^^^^^^^^^^ N814 -2 | from mod import CamelCase as CAMELCASE -3 | from mod import AnotherCamelCase as ANOTHER_CAMELCASE - | - -N814.py:2:17: N814 Camelcase `CamelCase` imported as constant `CAMELCASE` - | -1 | import mod.Camel as CAMEL -2 | from mod import CamelCase as CAMELCASE - | ^^^^^^^^^^^^^^^^^^^^^^ N814 -3 | from mod import AnotherCamelCase as ANOTHER_CAMELCASE - | - -N814.py:3:17: N814 Camelcase `AnotherCamelCase` imported as constant `ANOTHER_CAMELCASE` - | -1 | import mod.Camel as CAMEL -2 | from mod import CamelCase as CAMELCASE -3 | from mod import AnotherCamelCase as ANOTHER_CAMELCASE - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ N814 - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N815_N815.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N815_N815.py.snap deleted file mode 100644 index 4c5afe5a28..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N815_N815.py.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N815.py:9:5: N815 Variable `mixedCase` in class scope should not be mixedCase - | - 7 | lower = 0 - 8 | CONSTANT = 0 - 9 | mixedCase = 0 - | ^^^^^^^^^ N815 -10 | _mixedCase = 0 -11 | mixed_Case = 0 - | - -N815.py:10:5: N815 Variable `_mixedCase` in class scope should not be mixedCase - | - 8 | CONSTANT = 0 - 9 | mixedCase = 0 -10 | _mixedCase = 0 - | ^^^^^^^^^^ N815 -11 | mixed_Case = 0 -12 | myObj1 = collections.namedtuple("MyObj1", ["a", "b"]) - | - -N815.py:11:5: N815 Variable `mixed_Case` in class scope should not be mixedCase - | - 9 | mixedCase = 0 -10 | _mixedCase = 0 -11 | mixed_Case = 0 - | ^^^^^^^^^^ N815 -12 | myObj1 = collections.namedtuple("MyObj1", ["a", "b"]) -13 | myObj2 = namedtuple("MyObj2", ["a", "b"]) - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N816_N816.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N816_N816.py.snap deleted file mode 100644 index 72e997bd99..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N816_N816.py.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N816.py:7:1: N816 Variable `mixedCase` in global scope should not be mixedCase - | -5 | lower = 0 -6 | CONSTANT = 0 -7 | mixedCase = 0 - | ^^^^^^^^^ N816 -8 | _mixedCase = 0 -9 | mixed_Case = 0 - | - -N816.py:8:1: N816 Variable `_mixedCase` in global scope should not be mixedCase - | - 6 | CONSTANT = 0 - 7 | mixedCase = 0 - 8 | _mixedCase = 0 - | ^^^^^^^^^^ N816 - 9 | mixed_Case = 0 -10 | myObj1 = collections.namedtuple("MyObj1", ["a", "b"]) - | - -N816.py:9:1: N816 Variable `mixed_Case` in global scope should not be mixedCase - | - 7 | mixedCase = 0 - 8 | _mixedCase = 0 - 9 | mixed_Case = 0 - | ^^^^^^^^^^ N816 -10 | myObj1 = collections.namedtuple("MyObj1", ["a", "b"]) -11 | myObj2 = namedtuple("MyObj2", ["a", "b"]) - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N817_N817.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N817_N817.py.snap deleted file mode 100644 index fb627ebef3..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N817_N817.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N817.py:1:8: N817 CamelCase `CaMel` imported as acronym `CM` - | -1 | import mod.CaMel as CM - | ^^^^^^^^^^^^^^^ N817 -2 | from mod import CamelCase as CC - | - -N817.py:2:17: N817 CamelCase `CamelCase` imported as acronym `CC` - | -1 | import mod.CaMel as CM -2 | from mod import CamelCase as CC - | ^^^^^^^^^^^^^^^ N817 - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N818_N818.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N818_N818.py.snap deleted file mode 100644 index 9acf3b6bcc..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N818_N818.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N818.py:9:7: N818 Exception name `C` should be named with an Error suffix - | - 9 | class C(Exception): - | ^ N818 -10 | pass - | - -N818.py:17:7: N818 Exception name `E` should be named with an Error suffix - | -17 | class E(AnotherError): - | ^ N818 -18 | pass - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__MODULE____init__.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__MODULE____init__.py.snap deleted file mode 100644 index 2167171d58..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__MODULE____init__.py.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -__init__.py:1:1: N999 Invalid module name: 'MODULE' - | - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__MODULE__file.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__MODULE__file.py.snap deleted file mode 100644 index eb9fd7a59b..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__MODULE__file.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__flake9____init__.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__flake9____init__.py.snap deleted file mode 100644 index eb9fd7a59b..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__flake9____init__.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__invalid_name__0001_initial.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__invalid_name__0001_initial.py.snap deleted file mode 100644 index f5d2a97e9a..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__invalid_name__0001_initial.py.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -0001_initial.py:1:1: N999 Invalid module name: '0001_initial' - | - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__invalid_name__import.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__invalid_name__import.py.snap deleted file mode 100644 index b57d684ac9..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__invalid_name__import.py.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -import.py:1:1: N999 Invalid module name: 'import' - | - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__mod with spaces____init__.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__mod with spaces____init__.py.snap deleted file mode 100644 index 16357a2fa0..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__mod with spaces____init__.py.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -__init__.py:1:1: N999 Invalid module name: 'mod with spaces' - | - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__mod with spaces__file.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__mod with spaces__file.py.snap deleted file mode 100644 index eb9fd7a59b..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__mod with spaces__file.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__mod-with-dashes____init__.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__mod-with-dashes____init__.py.snap deleted file mode 100644 index 75c4e4aacb..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__mod-with-dashes____init__.py.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -__init__.py:1:1: N999 Invalid module name: 'mod-with-dashes' - | - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__no_module__test.txt.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__no_module__test.txt.snap deleted file mode 100644 index eb9fd7a59b..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__no_module__test.txt.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__valid_name____init__.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__valid_name____init__.py.snap deleted file mode 100644 index eb9fd7a59b..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__valid_name____init__.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__valid_name____main__.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__valid_name____main__.py.snap deleted file mode 100644 index eb9fd7a59b..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__valid_name____main__.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__valid_name____setup__.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__valid_name____setup__.py.snap deleted file mode 100644 index eb9fd7a59b..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__valid_name____setup__.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__valid_name__file-with-dashes.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__valid_name__file-with-dashes.py.snap deleted file mode 100644 index c95f6877f7..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__valid_name__file-with-dashes.py.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -file-with-dashes.py:1:1: N999 Invalid module name: 'file-with-dashes' - | - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__valid_name__file-with-dashes.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__valid_name__file-with-dashes.snap deleted file mode 100644 index eb9fd7a59b..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__N999_N999__module__valid_name__file-with-dashes.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__classmethod_decorators.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__classmethod_decorators.snap deleted file mode 100644 index 06c9407f28..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__classmethod_decorators.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N805.py:7:20: N805 First argument of a method should be named `self` - | -6 | class Class: -7 | def bad_method(this): - | ^^^^ N805 -8 | pass - | - -N805.py:12:30: N805 First argument of a method should be named `self` - | -10 | if False: -11 | -12 | def extra_bad_method(this): - | ^^^^ N805 -13 | pass - | - -N805.py:64:29: N805 First argument of a method should be named `self` - | -62 | pass -63 | -64 | def bad_method_pos_only(this, blah, /, self, something: str): - | ^^^^ N805 -65 | pass - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N801_N801.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N801_N801.py.snap deleted file mode 100644 index cbe43359c0..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N801_N801.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N801.py:4:7: N801 Class name `stillBad` should use CapWords convention - | -2 | pass -3 | -4 | class stillBad: - | ^^^^^^^^ N801 -5 | pass - | - -N801.py:10:7: N801 Class name `STILL_BAD` should use CapWords convention - | - 8 | pass - 9 | -10 | class STILL_BAD: - | ^^^^^^^^^ N801 -11 | pass - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N802_N802.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N802_N802.py.snap deleted file mode 100644 index 9b33e0be3e..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N802_N802.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N802.py:6:5: N802 Function name `stillBad` should be lowercase - | -4 | pass -5 | -6 | def stillBad(): - | ^^^^^^^^ N802 -7 | pass - | - -N802.py:13:9: N802 Function name `stillBad` should be lowercase - | -11 | return super().tearDown() -12 | -13 | def stillBad(self): - | ^^^^^^^^ N802 -14 | return super().tearDown() - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N803_N803.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N803_N803.py.snap deleted file mode 100644 index 92918cc420..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N803_N803.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N803.py:4:16: N803 Argument name `stillBad` should be lowercase - | -2 | return _, a, badAllowed -3 | -4 | def func(_, a, stillBad): - | ^^^^^^^^ N803 -5 | return _, a, stillBad - | - -N803.py:11:28: N803 Argument name `stillBad` should be lowercase - | - 9 | return _, a, badAllowed -10 | -11 | def method(self, _, a, stillBad): - | ^^^^^^^^ N803 -12 | return _, a, stillBad - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N804_N804.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N804_N804.py.snap deleted file mode 100644 index c308109147..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N804_N804.py.snap +++ /dev/null @@ -1,29 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N804.py:5:27: N804 First argument of a class method should be named `cls` - | -4 | class Class: -5 | def __init_subclass__(self, default_name, **kwargs): - | ^^^^ N804 -6 | ... - | - -N804.py:13:18: N804 First argument of a class method should be named `cls` - | -12 | @classmethod -13 | def stillBad(self, x, /, other): - | ^^^^ N804 -14 | ... - | - -N804.py:21:18: N804 First argument of a class method should be named `cls` - | -19 | pass -20 | -21 | def stillBad(self): - | ^^^^ N804 -22 | pass - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N805_N805.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N805_N805.py.snap deleted file mode 100644 index fee3fee254..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N805_N805.py.snap +++ /dev/null @@ -1,47 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N805.py:10:18: N805 First argument of a method should be named `self` - | - 8 | pass - 9 | -10 | def stillBad(this): - | ^^^^ N805 -11 | pass - | - -N805.py:18:22: N805 First argument of a method should be named `self` - | -16 | pass -17 | -18 | def stillBad(this): - | ^^^^ N805 -19 | pass - | - -N805.py:26:18: N805 First argument of a method should be named `self` - | -25 | @pydantic.validator -26 | def stillBad(cls, my_field: str) -> str: - | ^^^ N805 -27 | pass - | - -N805.py:34:18: N805 First argument of a method should be named `self` - | -33 | @pydantic.validator("my_field") -34 | def stillBad(cls, my_field: str) -> str: - | ^^^ N805 -35 | pass - | - -N805.py:58:18: N805 First argument of a method should be named `self` - | -56 | pass -57 | -58 | def stillBad(this, blah, /, self, something: str): - | ^^^^ N805 -59 | pass - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N806_N806.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N806_N806.py.snap deleted file mode 100644 index eff8113cce..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N806_N806.py.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N806.py:3:5: N806 Variable `stillBad` in function should be lowercase - | -1 | def assign(): -2 | badAllowed = 0 -3 | stillBad = 0 - | ^^^^^^^^ N806 -4 | -5 | BAD_ALLOWED = 0 - | - -N806.py:6:5: N806 Variable `STILL_BAD` in function should be lowercase - | -5 | BAD_ALLOWED = 0 -6 | STILL_BAD = 0 - | ^^^^^^^^^ N806 - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N807_N807.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N807_N807.py.snap deleted file mode 100644 index b3ba02329b..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N807_N807.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N807.py:4:5: N807 Function name should not start and end with `__` - | -2 | pass -3 | -4 | def __stillBad__(): - | ^^^^^^^^^^^^ N807 -5 | pass - | - -N807.py:12:9: N807 Function name should not start and end with `__` - | -10 | pass -11 | -12 | def __stillBad__(): - | ^^^^^^^^^^^^ N807 -13 | pass - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N811_N811.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N811_N811.py.snap deleted file mode 100644 index 099823a45b..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N811_N811.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -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 | -4 | from mod import BAD_ALLOWED as badAllowed - | - -N811.py:5:17: N811 Constant `STILL_BAD` imported as non-constant `stillBad` - | -4 | from mod import BAD_ALLOWED as badAllowed -5 | from mod import STILL_BAD as stillBad - | ^^^^^^^^^^^^^^^^^^^^^ N811 - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N812_N812.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N812_N812.py.snap deleted file mode 100644 index 3f5caafe57..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N812_N812.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -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 | -4 | from mod import badallowed as BadAllowed - | - -N812.py:5:17: N812 Lowercase `stillbad` imported as non-lowercase `StillBad` - | -4 | from mod import badallowed as BadAllowed -5 | from mod import stillbad as StillBad - | ^^^^^^^^^^^^^^^^^^^^ N812 - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N813_N813.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N813_N813.py.snap deleted file mode 100644 index 814fb4c88d..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N813_N813.py.snap +++ /dev/null @@ -1,29 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -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 | -4 | from mod import BadAllowed as badallowed - | - -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 | -7 | from mod import BadAllowed as bad_allowed - | - -N813.py:8:17: N813 Camelcase `StillBad` imported as lowercase `still_bad` - | -7 | from mod import BadAllowed as bad_allowed -8 | from mod import StillBad as still_bad - | ^^^^^^^^^^^^^^^^^^^^^ N813 - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N814_N814.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N814_N814.py.snap deleted file mode 100644 index cd367bfe6a..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N814_N814.py.snap +++ /dev/null @@ -1,29 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -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 | -4 | from mod import BadAllowed as BADALLOWED - | - -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 | -7 | from mod import BadAllowed as BAD_ALLOWED - | - -N814.py:8:17: N814 Camelcase `StillBad` imported as constant `STILL_BAD` - | -7 | from mod import BadAllowed as BAD_ALLOWED -8 | from mod import StillBad as STILL_BAD - | ^^^^^^^^^^^^^^^^^^^^^ N814 - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N815_N815.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N815_N815.py.snap deleted file mode 100644 index 90cdc67709..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N815_N815.py.snap +++ /dev/null @@ -1,58 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N815.py:3:5: N815 Variable `stillBad` in class scope should not be mixedCase - | -1 | class C: -2 | badAllowed = 0 -3 | stillBad = 0 - | ^^^^^^^^ N815 -4 | -5 | _badAllowed = 0 - | - -N815.py:6:5: N815 Variable `_stillBad` in class scope should not be mixedCase - | -5 | _badAllowed = 0 -6 | _stillBad = 0 - | ^^^^^^^^^ N815 -7 | -8 | bad_Allowed = 0 - | - -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 | -11 | class D(TypedDict): - | - -N815.py:13:5: N815 Variable `stillBad` in class scope should not be mixedCase - | -11 | class D(TypedDict): -12 | badAllowed: bool -13 | stillBad: bool - | ^^^^^^^^ N815 -14 | -15 | _badAllowed: list - | - -N815.py:16:5: N815 Variable `_stillBad` in class scope should not be mixedCase - | -15 | _badAllowed: list -16 | _stillBad: list - | ^^^^^^^^^ N815 -17 | -18 | bad_Allowed: set - | - -N815.py:19:5: N815 Variable `still_Bad` in class scope should not be mixedCase - | -18 | bad_Allowed: set -19 | still_Bad: set - | ^^^^^^^^^ N815 - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N816_N816.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N816_N816.py.snap deleted file mode 100644 index 9535fc1ba6..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N816_N816.py.snap +++ /dev/null @@ -1,29 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N816.py:2:1: N816 Variable `stillBad` in global scope should not be mixedCase - | -1 | badAllowed = 0 -2 | stillBad = 0 - | ^^^^^^^^ N816 -3 | -4 | _badAllowed = 0 - | - -N816.py:5:1: N816 Variable `_stillBad` in global scope should not be mixedCase - | -4 | _badAllowed = 0 -5 | _stillBad = 0 - | ^^^^^^^^^ N816 -6 | -7 | bad_Allowed = 0 - | - -N816.py:8:1: N816 Variable `still_Bad` in global scope should not be mixedCase - | -7 | bad_Allowed = 0 -8 | still_Bad = 0 - | ^^^^^^^^^ N816 - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N817_N817.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N817_N817.py.snap deleted file mode 100644 index e67415d87a..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N817_N817.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -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 | -4 | from mod import BadAllowed as BA - | - -N817.py:5:17: N817 CamelCase `StillBad` imported as acronym `SB` - | -4 | from mod import BadAllowed as BA -5 | from mod import StillBad as SB - | ^^^^^^^^^^^^^^ N817 - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N818_N818.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N818_N818.py.snap deleted file mode 100644 index b2df749de6..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N818_N818.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- -N818.py:4:7: N818 Exception name `StillBad` should be named with an Error suffix - | -2 | pass -3 | -4 | class StillBad(Exception): - | ^^^^^^^^ N818 -5 | pass - | - -N818.py:10:7: N818 Exception name `StillBad` should be named with an Error suffix - | - 8 | pass - 9 | -10 | class StillBad(AnotherError): - | ^^^^^^^^ N818 -11 | pass - | - - diff --git a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N999_N999__badAllowed____init__.py.snap b/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N999_N999__badAllowed____init__.py.snap deleted file mode 100644 index eb9fd7a59b..0000000000 --- a/crates/ruff/src/rules/pep8_naming/snapshots/ruff__rules__pep8_naming__tests__ignore_names_N999_N999__badAllowed____init__.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pep8_naming/mod.rs ---- - diff --git a/crates/ruff/src/rules/perflint/snapshots/ruff__rules__perflint__tests__PERF101_PERF101.py.snap b/crates/ruff/src/rules/perflint/snapshots/ruff__rules__perflint__tests__PERF101_PERF101.py.snap deleted file mode 100644 index 54a17b4c4f..0000000000 --- a/crates/ruff/src/rules/perflint/snapshots/ruff__rules__perflint__tests__PERF101_PERF101.py.snap +++ /dev/null @@ -1,183 +0,0 @@ ---- -source: crates/ruff/src/rules/perflint/mod.rs ---- -PERF101.py:7:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it - | -5 | foo_int = 123 -6 | -7 | for i in list(foo_tuple): # PERF101 - | ^^^^^^^^^^^^^^^ PERF101 -8 | pass - | - = help: Remove `list()` cast - -ℹ Fix -4 4 | foo_dict = {1: 2, 3: 4} -5 5 | foo_int = 123 -6 6 | -7 |-for i in list(foo_tuple): # PERF101 - 7 |+for i in foo_tuple: # PERF101 -8 8 | pass -9 9 | -10 10 | for i in list(foo_list): # PERF101 - -PERF101.py:10:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it - | - 8 | pass - 9 | -10 | for i in list(foo_list): # PERF101 - | ^^^^^^^^^^^^^^ PERF101 -11 | pass - | - = help: Remove `list()` cast - -ℹ Fix -7 7 | for i in list(foo_tuple): # PERF101 -8 8 | pass -9 9 | -10 |-for i in list(foo_list): # PERF101 - 10 |+for i in foo_list: # PERF101 -11 11 | pass -12 12 | -13 13 | for i in list(foo_set): # PERF101 - -PERF101.py:13:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it - | -11 | pass -12 | -13 | for i in list(foo_set): # PERF101 - | ^^^^^^^^^^^^^ PERF101 -14 | pass - | - = help: Remove `list()` cast - -ℹ Fix -10 10 | for i in list(foo_list): # PERF101 -11 11 | pass -12 12 | -13 |-for i in list(foo_set): # PERF101 - 13 |+for i in foo_set: # PERF101 -14 14 | pass -15 15 | -16 16 | for i in list((1, 2, 3)): # PERF101 - -PERF101.py:16:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it - | -14 | pass -15 | -16 | for i in list((1, 2, 3)): # PERF101 - | ^^^^^^^^^^^^^^^ PERF101 -17 | pass - | - = help: Remove `list()` cast - -ℹ Fix -13 13 | for i in list(foo_set): # PERF101 -14 14 | pass -15 15 | -16 |-for i in list((1, 2, 3)): # PERF101 - 16 |+for i in (1, 2, 3): # PERF101 -17 17 | pass -18 18 | -19 19 | for i in list([1, 2, 3]): # PERF101 - -PERF101.py:19:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it - | -17 | pass -18 | -19 | for i in list([1, 2, 3]): # PERF101 - | ^^^^^^^^^^^^^^^ PERF101 -20 | pass - | - = help: Remove `list()` cast - -ℹ Fix -16 16 | for i in list((1, 2, 3)): # PERF101 -17 17 | pass -18 18 | -19 |-for i in list([1, 2, 3]): # PERF101 - 19 |+for i in [1, 2, 3]: # PERF101 -20 20 | pass -21 21 | -22 22 | for i in list({1, 2, 3}): # PERF101 - -PERF101.py:22:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it - | -20 | pass -21 | -22 | for i in list({1, 2, 3}): # PERF101 - | ^^^^^^^^^^^^^^^ PERF101 -23 | pass - | - = help: Remove `list()` cast - -ℹ Fix -19 19 | for i in list([1, 2, 3]): # PERF101 -20 20 | pass -21 21 | -22 |-for i in list({1, 2, 3}): # PERF101 - 22 |+for i in {1, 2, 3}: # PERF101 -23 23 | pass -24 24 | -25 25 | for i in list( - -PERF101.py:25:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it - | -23 | pass -24 | -25 | for i in list( - | __________^ -26 | | { -27 | | 1, -28 | | 2, -29 | | 3, -30 | | } -31 | | ): - | |_^ PERF101 -32 | pass - | - = help: Remove `list()` cast - -ℹ Fix -22 22 | for i in list({1, 2, 3}): # PERF101 -23 23 | pass -24 24 | -25 |-for i in list( -26 |- { - 25 |+for i in { -27 26 | 1, -28 27 | 2, -29 28 | 3, -30 |- } -31 |-): - 29 |+ }: -32 30 | pass -33 31 | -34 32 | for i in list( # Comment - -PERF101.py:34:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it - | -32 | pass -33 | -34 | for i in list( # Comment - | __________^ -35 | | {1, 2, 3} -36 | | ): # PERF101 - | |_^ PERF101 -37 | pass - | - = help: Remove `list()` cast - -ℹ Fix -31 31 | ): -32 32 | pass -33 33 | -34 |-for i in list( # Comment -35 |- {1, 2, 3} -36 |-): # PERF101 - 34 |+for i in {1, 2, 3}: # PERF101 -37 35 | pass -38 36 | -39 37 | for i in list(foo_dict): # Ok - - diff --git a/crates/ruff/src/rules/perflint/snapshots/ruff__rules__perflint__tests__PERF102_PERF102.py.snap b/crates/ruff/src/rules/perflint/snapshots/ruff__rules__perflint__tests__PERF102_PERF102.py.snap deleted file mode 100644 index 2e1092b666..0000000000 --- a/crates/ruff/src/rules/perflint/snapshots/ruff__rules__perflint__tests__PERF102_PERF102.py.snap +++ /dev/null @@ -1,211 +0,0 @@ ---- -source: crates/ruff/src/rules/perflint/mod.rs ---- -PERF102.py:5:21: PERF102 [*] When using only the values of a dict use the `values()` method - | -4 | def f(): -5 | for _, value in some_dict.items(): # PERF102 - | ^^^^^^^^^^^^^^^ PERF102 -6 | print(value) - | - = help: Replace `.items()` with `.values()` - -ℹ Suggested fix -2 2 | -3 3 | -4 4 | def f(): -5 |- for _, value in some_dict.items(): # PERF102 - 5 |+ for value in some_dict.values(): # PERF102 -6 6 | print(value) -7 7 | -8 8 | - -PERF102.py:10:19: PERF102 [*] When using only the keys of a dict use the `keys()` method - | - 9 | def f(): -10 | for key, _ in some_dict.items(): # PERF102 - | ^^^^^^^^^^^^^^^ PERF102 -11 | print(key) - | - = help: Replace `.items()` with `.keys()` - -ℹ Suggested fix -7 7 | -8 8 | -9 9 | def f(): -10 |- for key, _ in some_dict.items(): # PERF102 - 10 |+ for key in some_dict.keys(): # PERF102 -11 11 | print(key) -12 12 | -13 13 | - -PERF102.py:15:30: PERF102 [*] When using only the keys of a dict use the `keys()` method - | -14 | def f(): -15 | for weird_arg_name, _ in some_dict.items(): # PERF102 - | ^^^^^^^^^^^^^^^ PERF102 -16 | print(weird_arg_name) - | - = help: Replace `.items()` with `.keys()` - -ℹ Suggested fix -12 12 | -13 13 | -14 14 | def f(): -15 |- for weird_arg_name, _ in some_dict.items(): # PERF102 - 15 |+ for weird_arg_name in some_dict.keys(): # PERF102 -16 16 | print(weird_arg_name) -17 17 | -18 18 | - -PERF102.py:20:25: PERF102 [*] When using only the keys of a dict use the `keys()` method - | -19 | def f(): -20 | for name, (_, _) in some_dict.items(): # PERF102 - | ^^^^^^^^^^^^^^^ PERF102 -21 | print(name) - | - = help: Replace `.items()` with `.keys()` - -ℹ Suggested fix -17 17 | -18 18 | -19 19 | def f(): -20 |- for name, (_, _) in some_dict.items(): # PERF102 - 20 |+ for name in some_dict.keys(): # PERF102 -21 21 | print(name) -22 22 | -23 23 | - -PERF102.py:30:30: PERF102 [*] When using only the keys of a dict use the `keys()` method - | -29 | def f(): -30 | for (key1, _), (_, _) in some_dict.items(): # PERF102 - | ^^^^^^^^^^^^^^^ PERF102 -31 | print(key1) - | - = help: Replace `.items()` with `.keys()` - -ℹ Suggested fix -27 27 | -28 28 | -29 29 | def f(): -30 |- for (key1, _), (_, _) in some_dict.items(): # PERF102 - 30 |+ for (key1, _) in some_dict.keys(): # PERF102 -31 31 | print(key1) -32 32 | -33 33 | - -PERF102.py:35:36: PERF102 [*] When using only the values of a dict use the `values()` method - | -34 | def f(): -35 | for (_, (_, _)), (value, _) in some_dict.items(): # PERF102 - | ^^^^^^^^^^^^^^^ PERF102 -36 | print(value) - | - = help: Replace `.items()` with `.values()` - -ℹ Suggested fix -32 32 | -33 33 | -34 34 | def f(): -35 |- for (_, (_, _)), (value, _) in some_dict.items(): # PERF102 - 35 |+ for (value, _) in some_dict.values(): # PERF102 -36 36 | print(value) -37 37 | -38 38 | - -PERF102.py:50:32: PERF102 [*] When using only the keys of a dict use the `keys()` method - | -49 | def f(): -50 | for ((_, key2), (_, _)) in some_dict.items(): # PERF102 - | ^^^^^^^^^^^^^^^ PERF102 -51 | print(key2) - | - = help: Replace `.items()` with `.keys()` - -ℹ Suggested fix -47 47 | -48 48 | -49 49 | def f(): -50 |- for ((_, key2), (_, _)) in some_dict.items(): # PERF102 - 50 |+ for (_, key2) in some_dict.keys(): # PERF102 -51 51 | print(key2) -52 52 | -53 53 | - -PERF102.py:85:25: PERF102 [*] When using only the keys of a dict use the `keys()` method - | -84 | def f(): -85 | for name, (_, _) in (some_function()).items(): # PERF102 - | ^^^^^^^^^^^^^^^^^^^^^^^ PERF102 -86 | print(name) - | - = help: Replace `.items()` with `.keys()` - -ℹ Suggested fix -82 82 | -83 83 | -84 84 | def f(): -85 |- for name, (_, _) in (some_function()).items(): # PERF102 - 85 |+ for name in (some_function()).keys(): # PERF102 -86 86 | print(name) -87 87 | -88 88 | - -PERF102.py:90:25: PERF102 [*] When using only the keys of a dict use the `keys()` method - | -89 | def f(): -90 | for name, (_, _) in (some_function().some_attribute).items(): # PERF102 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PERF102 -91 | print(name) - | - = help: Replace `.items()` with `.keys()` - -ℹ Suggested fix -87 87 | -88 88 | -89 89 | def f(): -90 |- for name, (_, _) in (some_function().some_attribute).items(): # PERF102 - 90 |+ for name in (some_function().some_attribute).keys(): # PERF102 -91 91 | print(name) -92 92 | -93 93 | - -PERF102.py:95:31: PERF102 [*] When using only the keys of a dict use the `keys()` method - | -94 | def f(): -95 | for name, unused_value in some_dict.items(): # PERF102 - | ^^^^^^^^^^^^^^^ PERF102 -96 | print(name) - | - = help: Replace `.items()` with `.keys()` - -ℹ Suggested fix -92 92 | -93 93 | -94 94 | def f(): -95 |- for name, unused_value in some_dict.items(): # PERF102 - 95 |+ for name in some_dict.keys(): # PERF102 -96 96 | print(name) -97 97 | -98 98 | - -PERF102.py:100:31: PERF102 [*] When using only the values of a dict use the `values()` method - | - 99 | def f(): -100 | for unused_name, value in some_dict.items(): # PERF102 - | ^^^^^^^^^^^^^^^ PERF102 -101 | print(value) - | - = help: Replace `.items()` with `.values()` - -ℹ Suggested fix -97 97 | -98 98 | -99 99 | def f(): -100 |- for unused_name, value in some_dict.items(): # PERF102 - 100 |+ for value in some_dict.values(): # PERF102 -101 101 | print(value) - - diff --git a/crates/ruff/src/rules/perflint/snapshots/ruff__rules__perflint__tests__PERF203_PERF203.py.snap b/crates/ruff/src/rules/perflint/snapshots/ruff__rules__perflint__tests__PERF203_PERF203.py.snap deleted file mode 100644 index d74621c223..0000000000 --- a/crates/ruff/src/rules/perflint/snapshots/ruff__rules__perflint__tests__PERF203_PERF203.py.snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: crates/ruff/src/rules/perflint/mod.rs ---- -PERF203.py:5:5: PERF203 `try`-`except` within a loop incurs performance overhead - | -3 | try: -4 | print(f"{i}") -5 | except: - | _____^ -6 | | print("error") - | |______________________^ PERF203 -7 | -8 | # OK - | - - diff --git a/crates/ruff/src/rules/perflint/snapshots/ruff__rules__perflint__tests__PERF401_PERF401.py.snap b/crates/ruff/src/rules/perflint/snapshots/ruff__rules__perflint__tests__PERF401_PERF401.py.snap deleted file mode 100644 index cf2e2677c5..0000000000 --- a/crates/ruff/src/rules/perflint/snapshots/ruff__rules__perflint__tests__PERF401_PERF401.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/perflint/mod.rs ---- -PERF401.py:6:13: PERF401 Use a list comprehension to create a transformed list - | -4 | for i in items: -5 | if i % 2: -6 | result.append(i) # PERF401 - | ^^^^^^^^^^^^^^^^ PERF401 - | - -PERF401.py:13:9: PERF401 Use a list comprehension to create a transformed list - | -11 | result = [] -12 | for i in items: -13 | result.append(i * i) # PERF401 - | ^^^^^^^^^^^^^^^^^^^^ PERF401 - | - - diff --git a/crates/ruff/src/rules/perflint/snapshots/ruff__rules__perflint__tests__PERF402_PERF402.py.snap b/crates/ruff/src/rules/perflint/snapshots/ruff__rules__perflint__tests__PERF402_PERF402.py.snap deleted file mode 100644 index e56584c95e..0000000000 --- a/crates/ruff/src/rules/perflint/snapshots/ruff__rules__perflint__tests__PERF402_PERF402.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/perflint/mod.rs ---- -PERF402.py:5:9: PERF402 Use `list` or `list.copy` to create a copy of a list - | -3 | result = [] -4 | for i in items: -5 | result.append(i) # PERF402 - | ^^^^^^^^^^^^^^^^ PERF402 - | - - diff --git a/crates/ruff/src/rules/perflint/snapshots/ruff__rules__perflint__tests__PERF403_PERF403.py.snap b/crates/ruff/src/rules/perflint/snapshots/ruff__rules__perflint__tests__PERF403_PERF403.py.snap deleted file mode 100644 index 461e20a438..0000000000 --- a/crates/ruff/src/rules/perflint/snapshots/ruff__rules__perflint__tests__PERF403_PERF403.py.snap +++ /dev/null @@ -1,52 +0,0 @@ ---- -source: crates/ruff/src/rules/perflint/mod.rs ---- -PERF403.py:5:9: PERF403 Use a dictionary comprehension instead of a for-loop - | -3 | result = {} -4 | for idx, name in enumerate(fruit): -5 | result[idx] = name # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 - | - -PERF403.py:13:13: PERF403 Use a dictionary comprehension instead of a for-loop - | -11 | for idx, name in enumerate(fruit): -12 | if idx % 2: -13 | result[idx] = name # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 - | - -PERF403.py:31:13: PERF403 Use a dictionary comprehension instead of a for-loop - | -29 | for idx, name in enumerate(fruit): -30 | if idx % 2: -31 | result[idx] = name # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 - | - -PERF403.py:61:13: PERF403 Use a dictionary comprehension instead of a for-loop - | -59 | for idx, name in enumerate(fruit): -60 | if idx % 2: -61 | result[idx] = name # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 - | - -PERF403.py:76:9: PERF403 Use a dictionary comprehension instead of a for-loop - | -74 | result = {} -75 | for name in fruit: -76 | result[name] = name # PERF403 - | ^^^^^^^^^^^^^^^^^^^ PERF403 - | - -PERF403.py:83:9: PERF403 Use a dictionary comprehension instead of a for-loop - | -81 | result = {} -82 | for idx, name in enumerate(fruit): -83 | result[name] = idx # PERF403 - | ^^^^^^^^^^^^^^^^^^ PERF403 - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E101_E101.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E101_E101.py.snap deleted file mode 100644 index 6526e38586..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E101_E101.py.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E101.py:11:1: E101 Indentation contains mixed spaces and tabs - | - 9 | def func_mixed_start_with_tab(): -10 | # E101 -11 | print("mixed starts with tab") - | ^^^^^^ E101 -12 | -13 | def func_mixed_start_with_space(): - | - -E101.py:15:1: E101 Indentation contains mixed spaces and tabs - | -13 | def func_mixed_start_with_space(): -14 | # E101 -15 | print("mixed starts with space") - | ^^^^^^^^^^^^^^^ E101 -16 | -17 | def xyz(): - | - -E101.py:19:1: E101 Indentation contains mixed spaces and tabs - | -17 | def xyz(): -18 | # E101 -19 | print("xyz"); - | ^^^^ E101 - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E111_E11.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E111_E11.py.snap deleted file mode 100644 index e036c94c84..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E111_E11.py.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E11.py:3:1: E111 Indentation is not a multiple of 4 - | -1 | #: E111 -2 | if x > 2: -3 | print(x) - | ^^ E111 -4 | #: E111 E117 -5 | if True: - | - -E11.py:6:1: E111 Indentation is not a multiple of 4 - | -4 | #: E111 E117 -5 | if True: -6 | print() - | ^^^^^ E111 -7 | #: E112 -8 | if False: - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E112_E11.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E112_E11.py.snap deleted file mode 100644 index 5c938fcdc5..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E112_E11.py.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E11.py:9:1: E112 Expected an indented block - | - 7 | #: E112 - 8 | if False: - 9 | print() - | E112 -10 | #: E113 -11 | print() - | - -E11.py:45:1: E112 Expected an indented block - | -43 | #: E112 -44 | if False: # -45 | print() - | E112 -46 | #: -47 | if False: - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E113_E11.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E113_E11.py.snap deleted file mode 100644 index f792e53ca7..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E113_E11.py.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E11.py:12:1: E113 Unexpected indentation - | -10 | #: E113 -11 | print() -12 | print() - | ^^^^ E113 -13 | #: E114 E116 -14 | mimetype = 'application/x-directory' - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E114_E11.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E114_E11.py.snap deleted file mode 100644 index e347082688..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E114_E11.py.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E11.py:15:1: E114 Indentation is not a multiple of 4 (comment) - | -13 | #: E114 E116 -14 | mimetype = 'application/x-directory' -15 | # 'httpd/unix-directory' - | ^^^^^ E114 -16 | create_date = False -17 | #: E116 E116 E116 - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E115_E11.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E115_E11.py.snap deleted file mode 100644 index 38cb54a995..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E115_E11.py.snap +++ /dev/null @@ -1,64 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E11.py:30:1: E115 Expected an indented block (comment) - | -28 | def start(self): -29 | if True: -30 | # try: - | E115 -31 | # self.master.start() -32 | # except MasterExit: - | - -E11.py:31:1: E115 Expected an indented block (comment) - | -29 | if True: -30 | # try: -31 | # self.master.start() - | E115 -32 | # except MasterExit: -33 | # self.shutdown() - | - -E11.py:32:1: E115 Expected an indented block (comment) - | -30 | # try: -31 | # self.master.start() -32 | # except MasterExit: - | E115 -33 | # self.shutdown() -34 | # finally: - | - -E11.py:33:1: E115 Expected an indented block (comment) - | -31 | # self.master.start() -32 | # except MasterExit: -33 | # self.shutdown() - | E115 -34 | # finally: -35 | # sys.exit() - | - -E11.py:34:1: E115 Expected an indented block (comment) - | -32 | # except MasterExit: -33 | # self.shutdown() -34 | # finally: - | E115 -35 | # sys.exit() -36 | self.master.start() - | - -E11.py:35:1: E115 Expected an indented block (comment) - | -33 | # self.shutdown() -34 | # finally: -35 | # sys.exit() - | E115 -36 | self.master.start() -37 | #: E117 - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E116_E11.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E116_E11.py.snap deleted file mode 100644 index f881047cd7..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E116_E11.py.snap +++ /dev/null @@ -1,44 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E11.py:15:1: E116 Unexpected indentation (comment) - | -13 | #: E114 E116 -14 | mimetype = 'application/x-directory' -15 | # 'httpd/unix-directory' - | ^^^^^ E116 -16 | create_date = False -17 | #: E116 E116 E116 - | - -E11.py:22:1: E116 Unexpected indentation (comment) - | -20 | self.master.start() -21 | # try: -22 | # self.master.start() - | ^^^^^^^^^^^^ E116 -23 | # except MasterExit: -24 | # self.shutdown() - | - -E11.py:24:1: E116 Unexpected indentation (comment) - | -22 | # self.master.start() -23 | # except MasterExit: -24 | # self.shutdown() - | ^^^^^^^^^^^^ E116 -25 | # finally: -26 | # sys.exit() - | - -E11.py:26:1: E116 Unexpected indentation (comment) - | -24 | # self.shutdown() -25 | # finally: -26 | # sys.exit() - | ^^^^^^^^^^^^ E116 -27 | #: E115 E115 E115 E115 E115 E115 -28 | def start(self): - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E117_E11.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E117_E11.py.snap deleted file mode 100644 index 65888f0b62..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E117_E11.py.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E11.py:6:1: E117 Over-indented - | -4 | #: E111 E117 -5 | if True: -6 | print() - | ^^^^^ E117 -7 | #: E112 -8 | if False: - | - -E11.py:39:1: E117 Over-indented - | -37 | #: E117 -38 | def start(): -39 | print() - | ^^^^^^^^ E117 -40 | #: E117 W191 -41 | def start(): - | - -E11.py:42:1: E117 Over-indented - | -40 | #: E117 W191 -41 | def start(): -42 | print() - | ^^^^^^^^ E117 -43 | #: E112 -44 | if False: # - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E201_E20.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E201_E20.py.snap deleted file mode 100644 index 53239f38be..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E201_E20.py.snap +++ /dev/null @@ -1,147 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E20.py:2:6: E201 [*] Whitespace after '(' - | -1 | #: E201:1:6 -2 | spam( ham[1], {eggs: 2}) - | ^ E201 -3 | #: E201:1:10 -4 | spam(ham[ 1], {eggs: 2}) - | - = help: Remove whitespace before '(' - -ℹ Fix -1 1 | #: E201:1:6 -2 |-spam( ham[1], {eggs: 2}) - 2 |+spam(ham[1], {eggs: 2}) -3 3 | #: E201:1:10 -4 4 | spam(ham[ 1], {eggs: 2}) -5 5 | #: E201:1:15 - -E20.py:4:10: E201 [*] Whitespace after '[' - | -2 | spam( ham[1], {eggs: 2}) -3 | #: E201:1:10 -4 | spam(ham[ 1], {eggs: 2}) - | ^ E201 -5 | #: E201:1:15 -6 | spam(ham[1], { eggs: 2}) - | - = help: Remove whitespace before '[' - -ℹ Fix -1 1 | #: E201:1:6 -2 2 | spam( ham[1], {eggs: 2}) -3 3 | #: E201:1:10 -4 |-spam(ham[ 1], {eggs: 2}) - 4 |+spam(ham[1], {eggs: 2}) -5 5 | #: E201:1:15 -6 6 | spam(ham[1], { eggs: 2}) -7 7 | #: E201:1:6 - -E20.py:6:15: E201 [*] Whitespace after '{' - | -4 | spam(ham[ 1], {eggs: 2}) -5 | #: E201:1:15 -6 | spam(ham[1], { eggs: 2}) - | ^ E201 -7 | #: E201:1:6 -8 | spam( ham[1], {eggs: 2}) - | - = help: Remove whitespace before '{' - -ℹ Fix -3 3 | #: E201:1:10 -4 4 | spam(ham[ 1], {eggs: 2}) -5 5 | #: E201:1:15 -6 |-spam(ham[1], { eggs: 2}) - 6 |+spam(ham[1], {eggs: 2}) -7 7 | #: E201:1:6 -8 8 | spam( ham[1], {eggs: 2}) -9 9 | #: E201:1:10 - -E20.py:8:6: E201 [*] Whitespace after '(' - | - 6 | spam(ham[1], { eggs: 2}) - 7 | #: E201:1:6 - 8 | spam( ham[1], {eggs: 2}) - | ^^^ E201 - 9 | #: E201:1:10 -10 | spam(ham[ 1], {eggs: 2}) - | - = help: Remove whitespace before '(' - -ℹ Fix -5 5 | #: E201:1:15 -6 6 | spam(ham[1], { eggs: 2}) -7 7 | #: E201:1:6 -8 |-spam( ham[1], {eggs: 2}) - 8 |+spam(ham[1], {eggs: 2}) -9 9 | #: E201:1:10 -10 10 | spam(ham[ 1], {eggs: 2}) -11 11 | #: E201:1:15 - -E20.py:10:10: E201 [*] Whitespace after '[' - | - 8 | spam( ham[1], {eggs: 2}) - 9 | #: E201:1:10 -10 | spam(ham[ 1], {eggs: 2}) - | ^^^ E201 -11 | #: E201:1:15 -12 | spam(ham[1], { eggs: 2}) - | - = help: Remove whitespace before '[' - -ℹ Fix -7 7 | #: E201:1:6 -8 8 | spam( ham[1], {eggs: 2}) -9 9 | #: E201:1:10 -10 |-spam(ham[ 1], {eggs: 2}) - 10 |+spam(ham[1], {eggs: 2}) -11 11 | #: E201:1:15 -12 12 | spam(ham[1], { eggs: 2}) -13 13 | #: Okay - -E20.py:12:15: E201 [*] Whitespace after '{' - | -10 | spam(ham[ 1], {eggs: 2}) -11 | #: E201:1:15 -12 | spam(ham[1], { eggs: 2}) - | ^^ E201 -13 | #: Okay -14 | spam(ham[1], {eggs: 2}) - | - = help: Remove whitespace before '{' - -ℹ Fix -9 9 | #: E201:1:10 -10 10 | spam(ham[ 1], {eggs: 2}) -11 11 | #: E201:1:15 -12 |-spam(ham[1], { eggs: 2}) - 12 |+spam(ham[1], {eggs: 2}) -13 13 | #: Okay -14 14 | spam(ham[1], {eggs: 2}) -15 15 | #: - -E20.py:81:6: E201 [*] Whitespace after '[' - | -80 | #: E201:1:6 -81 | spam[ ~ham] - | ^ E201 -82 | -83 | #: Okay - | - = help: Remove whitespace before '[' - -ℹ Fix -78 78 | #: -79 79 | -80 80 | #: E201:1:6 -81 |-spam[ ~ham] - 81 |+spam[~ham] -82 82 | -83 83 | #: Okay -84 84 | x = [ # - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E202_E20.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E202_E20.py.snap deleted file mode 100644 index 39f0b0f22a..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E202_E20.py.snap +++ /dev/null @@ -1,129 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E20.py:19:23: E202 [*] Whitespace before ')' - | -18 | #: E202:1:23 -19 | spam(ham[1], {eggs: 2} ) - | ^ E202 -20 | #: E202:1:22 -21 | spam(ham[1], {eggs: 2 }) - | - = help: Remove whitespace before ')' - -ℹ Fix -16 16 | -17 17 | -18 18 | #: E202:1:23 -19 |-spam(ham[1], {eggs: 2} ) - 19 |+spam(ham[1], {eggs: 2}) -20 20 | #: E202:1:22 -21 21 | spam(ham[1], {eggs: 2 }) -22 22 | #: E202:1:11 - -E20.py:21:22: E202 [*] Whitespace before '}' - | -19 | spam(ham[1], {eggs: 2} ) -20 | #: E202:1:22 -21 | spam(ham[1], {eggs: 2 }) - | ^ E202 -22 | #: E202:1:11 -23 | spam(ham[1 ], {eggs: 2}) - | - = help: Remove whitespace before '}' - -ℹ Fix -18 18 | #: E202:1:23 -19 19 | spam(ham[1], {eggs: 2} ) -20 20 | #: E202:1:22 -21 |-spam(ham[1], {eggs: 2 }) - 21 |+spam(ham[1], {eggs: 2}) -22 22 | #: E202:1:11 -23 23 | spam(ham[1 ], {eggs: 2}) -24 24 | #: E202:1:23 - -E20.py:23:11: E202 [*] Whitespace before ']' - | -21 | spam(ham[1], {eggs: 2 }) -22 | #: E202:1:11 -23 | spam(ham[1 ], {eggs: 2}) - | ^ E202 -24 | #: E202:1:23 -25 | spam(ham[1], {eggs: 2} ) - | - = help: Remove whitespace before ']' - -ℹ Fix -20 20 | #: E202:1:22 -21 21 | spam(ham[1], {eggs: 2 }) -22 22 | #: E202:1:11 -23 |-spam(ham[1 ], {eggs: 2}) - 23 |+spam(ham[1], {eggs: 2}) -24 24 | #: E202:1:23 -25 25 | spam(ham[1], {eggs: 2} ) -26 26 | #: E202:1:22 - -E20.py:25:23: E202 [*] Whitespace before ')' - | -23 | spam(ham[1 ], {eggs: 2}) -24 | #: E202:1:23 -25 | spam(ham[1], {eggs: 2} ) - | ^^ E202 -26 | #: E202:1:22 -27 | spam(ham[1], {eggs: 2 }) - | - = help: Remove whitespace before ')' - -ℹ Fix -22 22 | #: E202:1:11 -23 23 | spam(ham[1 ], {eggs: 2}) -24 24 | #: E202:1:23 -25 |-spam(ham[1], {eggs: 2} ) - 25 |+spam(ham[1], {eggs: 2}) -26 26 | #: E202:1:22 -27 27 | spam(ham[1], {eggs: 2 }) -28 28 | #: E202:1:11 - -E20.py:27:22: E202 [*] Whitespace before '}' - | -25 | spam(ham[1], {eggs: 2} ) -26 | #: E202:1:22 -27 | spam(ham[1], {eggs: 2 }) - | ^^^ E202 -28 | #: E202:1:11 -29 | spam(ham[1 ], {eggs: 2}) - | - = help: Remove whitespace before '}' - -ℹ Fix -24 24 | #: E202:1:23 -25 25 | spam(ham[1], {eggs: 2} ) -26 26 | #: E202:1:22 -27 |-spam(ham[1], {eggs: 2 }) - 27 |+spam(ham[1], {eggs: 2}) -28 28 | #: E202:1:11 -29 29 | spam(ham[1 ], {eggs: 2}) -30 30 | #: Okay - -E20.py:29:11: E202 [*] Whitespace before ']' - | -27 | spam(ham[1], {eggs: 2 }) -28 | #: E202:1:11 -29 | spam(ham[1 ], {eggs: 2}) - | ^^ E202 -30 | #: Okay -31 | spam(ham[1], {eggs: 2}) - | - = help: Remove whitespace before ']' - -ℹ Fix -26 26 | #: E202:1:22 -27 27 | spam(ham[1], {eggs: 2 }) -28 28 | #: E202:1:11 -29 |-spam(ham[1 ], {eggs: 2}) - 29 |+spam(ham[1], {eggs: 2}) -30 30 | #: Okay -31 31 | spam(ham[1], {eggs: 2}) -32 32 | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E203_E20.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E203_E20.py.snap deleted file mode 100644 index 933d7eb3a3..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E203_E20.py.snap +++ /dev/null @@ -1,129 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E20.py:51:10: E203 [*] Whitespace before ':' - | -50 | #: E203:1:10 -51 | if x == 4 : - | ^ E203 -52 | print x, y -53 | x, y = y, x - | - = help: Remove whitespace before ':' - -ℹ Fix -48 48 | -49 49 | -50 50 | #: E203:1:10 -51 |-if x == 4 : - 51 |+if x == 4: -52 52 | print x, y -53 53 | x, y = y, x -54 54 | #: E203:1:10 - -E20.py:55:10: E203 [*] Whitespace before ':' - | -53 | x, y = y, x -54 | #: E203:1:10 -55 | if x == 4 : - | ^^^ E203 -56 | print x, y -57 | x, y = y, x - | - = help: Remove whitespace before ':' - -ℹ Fix -52 52 | print x, y -53 53 | x, y = y, x -54 54 | #: E203:1:10 -55 |-if x == 4 : - 55 |+if x == 4: -56 56 | print x, y -57 57 | x, y = y, x -58 58 | #: E203:2:15 E702:2:16 - -E20.py:60:15: E203 [*] Whitespace before ';' - | -58 | #: E203:2:15 E702:2:16 -59 | if x == 4: -60 | print x, y ; x, y = y, x - | ^ E203 -61 | #: E203:2:15 E702:2:16 -62 | if x == 4: - | - = help: Remove whitespace before ';' - -ℹ Fix -57 57 | x, y = y, x -58 58 | #: E203:2:15 E702:2:16 -59 59 | if x == 4: -60 |- print x, y ; x, y = y, x - 60 |+ print x, y; x, y = y, x -61 61 | #: E203:2:15 E702:2:16 -62 62 | if x == 4: -63 63 | print x, y ; x, y = y, x - -E20.py:63:15: E203 [*] Whitespace before ';' - | -61 | #: E203:2:15 E702:2:16 -62 | if x == 4: -63 | print x, y ; x, y = y, x - | ^^ E203 -64 | #: E203:3:13 -65 | if x == 4: - | - = help: Remove whitespace before ';' - -ℹ Fix -60 60 | print x, y ; x, y = y, x -61 61 | #: E203:2:15 E702:2:16 -62 62 | if x == 4: -63 |- print x, y ; x, y = y, x - 63 |+ print x, y; x, y = y, x -64 64 | #: E203:3:13 -65 65 | if x == 4: -66 66 | print x, y - -E20.py:67:13: E203 [*] Whitespace before ',' - | -65 | if x == 4: -66 | print x, y -67 | x, y = y , x - | ^ E203 -68 | #: E203:3:13 -69 | if x == 4: - | - = help: Remove whitespace before ',' - -ℹ Fix -64 64 | #: E203:3:13 -65 65 | if x == 4: -66 66 | print x, y -67 |- x, y = y , x - 67 |+ x, y = y, x -68 68 | #: E203:3:13 -69 69 | if x == 4: -70 70 | print x, y - -E20.py:71:13: E203 [*] Whitespace before ',' - | -69 | if x == 4: -70 | print x, y -71 | x, y = y , x - | ^^^^ E203 -72 | #: Okay -73 | if x == 4: - | - = help: Remove whitespace before ',' - -ℹ Fix -68 68 | #: E203:3:13 -69 69 | if x == 4: -70 70 | print x, y -71 |- x, y = y , x - 71 |+ x, y = y, x -72 72 | #: Okay -73 73 | if x == 4: -74 74 | print x, y - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E211_E21.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E211_E21.py.snap deleted file mode 100644 index 594efa073b..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E211_E21.py.snap +++ /dev/null @@ -1,85 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E21.py:2:5: E211 [*] Whitespace before '(' - | -1 | #: E211 -2 | spam (1) - | ^ E211 -3 | #: E211 E211 -4 | dict ['key'] = list [index] - | - = help: Removed whitespace before '(' - -ℹ Fix -1 1 | #: E211 -2 |-spam (1) - 2 |+spam(1) -3 3 | #: E211 E211 -4 4 | dict ['key'] = list [index] -5 5 | #: E211 - -E21.py:4:5: E211 [*] Whitespace before '[' - | -2 | spam (1) -3 | #: E211 E211 -4 | dict ['key'] = list [index] - | ^ E211 -5 | #: E211 -6 | dict['key'] ['subkey'] = list[index] - | - = help: Removed whitespace before '[' - -ℹ Fix -1 1 | #: E211 -2 2 | spam (1) -3 3 | #: E211 E211 -4 |-dict ['key'] = list [index] - 4 |+dict['key'] = list [index] -5 5 | #: E211 -6 6 | dict['key'] ['subkey'] = list[index] -7 7 | #: Okay - -E21.py:4:20: E211 [*] Whitespace before '[' - | -2 | spam (1) -3 | #: E211 E211 -4 | dict ['key'] = list [index] - | ^ E211 -5 | #: E211 -6 | dict['key'] ['subkey'] = list[index] - | - = help: Removed whitespace before '[' - -ℹ Fix -1 1 | #: E211 -2 2 | spam (1) -3 3 | #: E211 E211 -4 |-dict ['key'] = list [index] - 4 |+dict ['key'] = list[index] -5 5 | #: E211 -6 6 | dict['key'] ['subkey'] = list[index] -7 7 | #: Okay - -E21.py:6:12: E211 [*] Whitespace before '[' - | -4 | dict ['key'] = list [index] -5 | #: E211 -6 | dict['key'] ['subkey'] = list[index] - | ^ E211 -7 | #: Okay -8 | spam(1) - | - = help: Removed whitespace before '[' - -ℹ Fix -3 3 | #: E211 E211 -4 4 | dict ['key'] = list [index] -5 5 | #: E211 -6 |-dict['key'] ['subkey'] = list[index] - 6 |+dict['key']['subkey'] = list[index] -7 7 | #: Okay -8 8 | spam(1) -9 9 | dict['key'] = list[index] - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E221_E22.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E221_E22.py.snap deleted file mode 100644 index 954df9957f..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E221_E22.py.snap +++ /dev/null @@ -1,84 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E22.py:3:6: E221 Multiple spaces before operator - | -1 | #: E221 -2 | a = 12 + 3 -3 | b = 4 + 5 - | ^^ E221 -4 | #: E221 E221 -5 | x = 1 - | - -E22.py:5:2: E221 Multiple spaces before operator - | -3 | b = 4 + 5 -4 | #: E221 E221 -5 | x = 1 - | ^^^^^^^^^^^^^ E221 -6 | y = 2 -7 | long_variable = 3 - | - -E22.py:6:2: E221 Multiple spaces before operator - | -4 | #: E221 E221 -5 | x = 1 -6 | y = 2 - | ^^^^^^^^^^^^^ E221 -7 | long_variable = 3 -8 | #: E221 E221 - | - -E22.py:9:5: E221 Multiple spaces before operator - | - 7 | long_variable = 3 - 8 | #: E221 E221 - 9 | x[0] = 1 - | ^^^^^^^^^^ E221 -10 | x[1] = 2 -11 | long_variable = 3 - | - -E22.py:10:5: E221 Multiple spaces before operator - | - 8 | #: E221 E221 - 9 | x[0] = 1 -10 | x[1] = 2 - | ^^^^^^^^^^ E221 -11 | long_variable = 3 -12 | #: E221 E221 - | - -E22.py:13:9: E221 Multiple spaces before operator - | -11 | long_variable = 3 -12 | #: E221 E221 -13 | x = f(x) + 1 - | ^^^^^^^^^^ E221 -14 | y = long_variable + 2 -15 | z = x[0] + 3 - | - -E22.py:15:9: E221 Multiple spaces before operator - | -13 | x = f(x) + 1 -14 | y = long_variable + 2 -15 | z = x[0] + 3 - | ^^^^^^^^^^ E221 -16 | #: E221:3:14 -17 | text = """ - | - -E22.py:19:14: E221 Multiple spaces before operator - | -17 | text = """ -18 | bar -19 | foo %s""" % rofl - | ^^ E221 -20 | #: Okay -21 | x = 1 - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E222_E22.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E222_E22.py.snap deleted file mode 100644 index eff96ac2fe..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E222_E22.py.snap +++ /dev/null @@ -1,53 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E22.py:28:8: E222 Multiple spaces after operator - | -27 | #: E222 -28 | a = a + 1 - | ^^ E222 -29 | b = b + 10 -30 | #: E222 E222 - | - -E22.py:31:4: E222 Multiple spaces after operator - | -29 | b = b + 10 -30 | #: E222 E222 -31 | x = -1 - | ^^^^^^^^^^^^ E222 -32 | y = -2 -33 | long_variable = 3 - | - -E22.py:32:4: E222 Multiple spaces after operator - | -30 | #: E222 E222 -31 | x = -1 -32 | y = -2 - | ^^^^^^^^^^^^ E222 -33 | long_variable = 3 -34 | #: E222 E222 - | - -E22.py:35:7: E222 Multiple spaces after operator - | -33 | long_variable = 3 -34 | #: E222 E222 -35 | x[0] = 1 - | ^^^^^^^^^^ E222 -36 | x[1] = 2 -37 | long_variable = 3 - | - -E22.py:36:7: E222 Multiple spaces after operator - | -34 | #: E222 E222 -35 | x[0] = 1 -36 | x[1] = 2 - | ^^^^^^^^^^ E222 -37 | long_variable = 3 -38 | #: - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E223_E22.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E223_E22.py.snap deleted file mode 100644 index 06e72f4a4b..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E223_E22.py.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E22.py:43:2: E223 Tab before operator - | -41 | #: E223 -42 | foobart = 4 -43 | a = 3 # aligned with tab - | ^^^ E223 -44 | #: - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E224_E22.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E224_E22.py.snap deleted file mode 100644 index e8ee9b11d3..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E224_E22.py.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E22.py:48:5: E224 Tab after operator - | -47 | #: E224 -48 | a += 1 - | ^^^^ E224 -49 | b += 1000 -50 | #: - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E225_E22.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E225_E22.py.snap deleted file mode 100644 index b293ab2b2a..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E225_E22.py.snap +++ /dev/null @@ -1,272 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E22.py:54:11: E225 Missing whitespace around operator - | -53 | #: E225 -54 | submitted +=1 - | ^^ E225 -55 | #: E225 -56 | submitted+= 1 - | - -E22.py:56:10: E225 Missing whitespace around operator - | -54 | submitted +=1 -55 | #: E225 -56 | submitted+= 1 - | ^^ E225 -57 | #: E225 -58 | c =-1 - | - -E22.py:58:3: E225 Missing whitespace around operator - | -56 | submitted+= 1 -57 | #: E225 -58 | c =-1 - | ^ E225 -59 | #: E225 -60 | x = x /2 - 1 - | - -E22.py:60:7: E225 Missing whitespace around operator - | -58 | c =-1 -59 | #: E225 -60 | x = x /2 - 1 - | ^ E225 -61 | #: E225 -62 | c = alpha -4 - | - -E22.py:62:11: E225 Missing whitespace around operator - | -60 | x = x /2 - 1 -61 | #: E225 -62 | c = alpha -4 - | ^ E225 -63 | #: E225 -64 | c = alpha- 4 - | - -E22.py:64:10: E225 Missing whitespace around operator - | -62 | c = alpha -4 -63 | #: E225 -64 | c = alpha- 4 - | ^ E225 -65 | #: E225 -66 | z = x **y - | - -E22.py:66:7: E225 Missing whitespace around operator - | -64 | c = alpha- 4 -65 | #: E225 -66 | z = x **y - | ^^ E225 -67 | #: E225 -68 | z = (x + 1) **y - | - -E22.py:68:13: E225 Missing whitespace around operator - | -66 | z = x **y -67 | #: E225 -68 | z = (x + 1) **y - | ^^ E225 -69 | #: E225 -70 | z = (x + 1)** y - | - -E22.py:70:12: E225 Missing whitespace around operator - | -68 | z = (x + 1) **y -69 | #: E225 -70 | z = (x + 1)** y - | ^^ E225 -71 | #: E225 -72 | _1kB = _1MB >>10 - | - -E22.py:72:13: E225 Missing whitespace around operator - | -70 | z = (x + 1)** y -71 | #: E225 -72 | _1kB = _1MB >>10 - | ^^ E225 -73 | #: E225 -74 | _1kB = _1MB>> 10 - | - -E22.py:74:12: E225 Missing whitespace around operator - | -72 | _1kB = _1MB >>10 -73 | #: E225 -74 | _1kB = _1MB>> 10 - | ^^ E225 -75 | #: E225 E225 -76 | i=i+ 1 - | - -E22.py:76:2: E225 Missing whitespace around operator - | -74 | _1kB = _1MB>> 10 -75 | #: E225 E225 -76 | i=i+ 1 - | ^ E225 -77 | #: E225 E225 -78 | i=i +1 - | - -E22.py:76:4: E225 Missing whitespace around operator - | -74 | _1kB = _1MB>> 10 -75 | #: E225 E225 -76 | i=i+ 1 - | ^ E225 -77 | #: E225 E225 -78 | i=i +1 - | - -E22.py:78:2: E225 Missing whitespace around operator - | -76 | i=i+ 1 -77 | #: E225 E225 -78 | i=i +1 - | ^ E225 -79 | #: E225 -80 | i = 1and 1 - | - -E22.py:78:5: E225 Missing whitespace around operator - | -76 | i=i+ 1 -77 | #: E225 E225 -78 | i=i +1 - | ^ E225 -79 | #: E225 -80 | i = 1and 1 - | - -E22.py:80:6: E225 Missing whitespace around operator - | -78 | i=i +1 -79 | #: E225 -80 | i = 1and 1 - | ^^^ E225 -81 | #: E225 -82 | i = 1or 0 - | - -E22.py:82:6: E225 Missing whitespace around operator - | -80 | i = 1and 1 -81 | #: E225 -82 | i = 1or 0 - | ^^ E225 -83 | #: E225 -84 | 1is 1 - | - -E22.py:84:2: E225 Missing whitespace around operator - | -82 | i = 1or 0 -83 | #: E225 -84 | 1is 1 - | ^^ E225 -85 | #: E225 -86 | 1in [] - | - -E22.py:86:2: E225 Missing whitespace around operator - | -84 | 1is 1 -85 | #: E225 -86 | 1in [] - | ^^ E225 -87 | #: E225 -88 | i = 1 @2 - | - -E22.py:88:7: E225 Missing whitespace around operator - | -86 | 1in [] -87 | #: E225 -88 | i = 1 @2 - | ^ E225 -89 | #: E225 -90 | i = 1@ 2 - | - -E22.py:90:6: E225 Missing whitespace around operator - | -88 | i = 1 @2 -89 | #: E225 -90 | i = 1@ 2 - | ^ E225 -91 | #: E225 E226 -92 | i=i+1 - | - -E22.py:92:2: E225 Missing whitespace around operator - | -90 | i = 1@ 2 -91 | #: E225 E226 -92 | i=i+1 - | ^ E225 -93 | #: E225 E226 -94 | i =i+1 - | - -E22.py:94:3: E225 Missing whitespace around operator - | -92 | i=i+1 -93 | #: E225 E226 -94 | i =i+1 - | ^ E225 -95 | #: E225 E226 -96 | i= i+1 - | - -E22.py:96:2: E225 Missing whitespace around operator - | -94 | i =i+1 -95 | #: E225 E226 -96 | i= i+1 - | ^ E225 -97 | #: E225 E226 -98 | c = (a +b)*(a - b) - | - -E22.py:98:8: E225 Missing whitespace around operator - | - 96 | i= i+1 - 97 | #: E225 E226 - 98 | c = (a +b)*(a - b) - | ^ E225 - 99 | #: E225 E226 -100 | c = (a+ b)*(a - b) - | - -E22.py:100:7: E225 Missing whitespace around operator - | - 98 | c = (a +b)*(a - b) - 99 | #: E225 E226 -100 | c = (a+ b)*(a - b) - | ^ E225 -101 | #: - | - -E22.py:154:11: E225 Missing whitespace around operator - | -152 | func2(lambda a, b=h[:], c=0: (a, b, c)) -153 | if not -5 < x < +5: -154 | print >>sys.stderr, "x is out of range." - | ^^ E225 -155 | print >> sys.stdout, "x is an integer." -156 | x = x / 2 - 1 - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E226_E22.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E226_E22.py.snap deleted file mode 100644 index c323c51053..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E226_E22.py.snap +++ /dev/null @@ -1,142 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E22.py:92:4: E226 Missing whitespace around arithmetic operator - | -90 | i = 1@ 2 -91 | #: E225 E226 -92 | i=i+1 - | ^ E226 -93 | #: E225 E226 -94 | i =i+1 - | - -E22.py:94:5: E226 Missing whitespace around arithmetic operator - | -92 | i=i+1 -93 | #: E225 E226 -94 | i =i+1 - | ^ E226 -95 | #: E225 E226 -96 | i= i+1 - | - -E22.py:96:5: E226 Missing whitespace around arithmetic operator - | -94 | i =i+1 -95 | #: E225 E226 -96 | i= i+1 - | ^ E226 -97 | #: E225 E226 -98 | c = (a +b)*(a - b) - | - -E22.py:98:11: E226 Missing whitespace around arithmetic operator - | - 96 | i= i+1 - 97 | #: E225 E226 - 98 | c = (a +b)*(a - b) - | ^ E226 - 99 | #: E225 E226 -100 | c = (a+ b)*(a - b) - | - -E22.py:100:11: E226 Missing whitespace around arithmetic operator - | - 98 | c = (a +b)*(a - b) - 99 | #: E225 E226 -100 | c = (a+ b)*(a - b) - | ^ E226 -101 | #: - | - -E22.py:104:6: E226 Missing whitespace around arithmetic operator - | -103 | #: E226 -104 | z = 2//30 - | ^^ E226 -105 | #: E226 E226 -106 | c = (a+b) * (a-b) - | - -E22.py:106:7: E226 Missing whitespace around arithmetic operator - | -104 | z = 2//30 -105 | #: E226 E226 -106 | c = (a+b) * (a-b) - | ^ E226 -107 | #: E226 -108 | norman = True+False - | - -E22.py:106:15: E226 Missing whitespace around arithmetic operator - | -104 | z = 2//30 -105 | #: E226 E226 -106 | c = (a+b) * (a-b) - | ^ E226 -107 | #: E226 -108 | norman = True+False - | - -E22.py:110:6: E226 Missing whitespace around arithmetic operator - | -108 | norman = True+False -109 | #: E226 -110 | x = x*2 - 1 - | ^ E226 -111 | #: E226 -112 | x = x/2 - 1 - | - -E22.py:112:6: E226 Missing whitespace around arithmetic operator - | -110 | x = x*2 - 1 -111 | #: E226 -112 | x = x/2 - 1 - | ^ E226 -113 | #: E226 E226 -114 | hypot2 = x*x + y*y - | - -E22.py:114:11: E226 Missing whitespace around arithmetic operator - | -112 | x = x/2 - 1 -113 | #: E226 E226 -114 | hypot2 = x*x + y*y - | ^ E226 -115 | #: E226 -116 | c = (a + b)*(a - b) - | - -E22.py:114:17: E226 Missing whitespace around arithmetic operator - | -112 | x = x/2 - 1 -113 | #: E226 E226 -114 | hypot2 = x*x + y*y - | ^ E226 -115 | #: E226 -116 | c = (a + b)*(a - b) - | - -E22.py:116:12: E226 Missing whitespace around arithmetic operator - | -114 | hypot2 = x*x + y*y -115 | #: E226 -116 | c = (a + b)*(a - b) - | ^ E226 -117 | #: E226 -118 | def halves(n): - | - -E22.py:119:14: E226 Missing whitespace around arithmetic operator - | -117 | #: E226 -118 | def halves(n): -119 | return (i//2 for i in range(n)) - | ^^ E226 -120 | #: E227 -121 | _1kB = _1MB>>10 - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E227_E22.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E227_E22.py.snap deleted file mode 100644 index b1b7e5077a..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E227_E22.py.snap +++ /dev/null @@ -1,54 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E22.py:121:12: E227 Missing whitespace around bitwise or shift operator - | -119 | return (i//2 for i in range(n)) -120 | #: E227 -121 | _1kB = _1MB>>10 - | ^^ E227 -122 | #: E227 -123 | _1MB = _1kB<<10 - | - -E22.py:123:12: E227 Missing whitespace around bitwise or shift operator - | -121 | _1kB = _1MB>>10 -122 | #: E227 -123 | _1MB = _1kB<<10 - | ^^ E227 -124 | #: E227 -125 | a = b|c - | - -E22.py:125:6: E227 Missing whitespace around bitwise or shift operator - | -123 | _1MB = _1kB<<10 -124 | #: E227 -125 | a = b|c - | ^ E227 -126 | #: E227 -127 | b = c&a - | - -E22.py:127:6: E227 Missing whitespace around bitwise or shift operator - | -125 | a = b|c -126 | #: E227 -127 | b = c&a - | ^ E227 -128 | #: E227 -129 | c = b^a - | - -E22.py:129:6: E227 Missing whitespace around bitwise or shift operator - | -127 | b = c&a -128 | #: E227 -129 | c = b^a - | ^ E227 -130 | #: E228 -131 | a = b%c - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E228_E22.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E228_E22.py.snap deleted file mode 100644 index 80f207b442..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E228_E22.py.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E22.py:131:6: E228 Missing whitespace around modulo operator - | -129 | c = b^a -130 | #: E228 -131 | a = b%c - | ^ E228 -132 | #: E228 -133 | msg = fmt%(errno, errmsg) - | - -E22.py:133:10: E228 Missing whitespace around modulo operator - | -131 | a = b%c -132 | #: E228 -133 | msg = fmt%(errno, errmsg) - | ^ E228 -134 | #: E228 -135 | msg = "Error %d occurred"%errno - | - -E22.py:135:26: E228 Missing whitespace around modulo operator - | -133 | msg = fmt%(errno, errmsg) -134 | #: E228 -135 | msg = "Error %d occurred"%errno - | ^ E228 -136 | #: - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E231_E23.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E231_E23.py.snap deleted file mode 100644 index 7a197e5247..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E231_E23.py.snap +++ /dev/null @@ -1,104 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E23.py:2:7: E231 [*] Missing whitespace after ',' - | -1 | #: E231 -2 | a = (1,2) - | ^ E231 -3 | #: E231 -4 | a[b1,:] - | - = help: Added missing whitespace after ',' - -ℹ Fix -1 1 | #: E231 -2 |-a = (1,2) - 2 |+a = (1, 2) -3 3 | #: E231 -4 4 | a[b1,:] -5 5 | #: E231 - -E23.py:4:5: E231 [*] Missing whitespace after ',' - | -2 | a = (1,2) -3 | #: E231 -4 | a[b1,:] - | ^ E231 -5 | #: E231 -6 | a = [{'a':''}] - | - = help: Added missing whitespace after ',' - -ℹ Fix -1 1 | #: E231 -2 2 | a = (1,2) -3 3 | #: E231 -4 |-a[b1,:] - 4 |+a[b1, :] -5 5 | #: E231 -6 6 | a = [{'a':''}] -7 7 | #: Okay - -E23.py:6:10: E231 [*] Missing whitespace after ':' - | -4 | a[b1,:] -5 | #: E231 -6 | a = [{'a':''}] - | ^ E231 -7 | #: Okay -8 | a = (4,) - | - = help: Added missing whitespace after ':' - -ℹ Fix -3 3 | #: E231 -4 4 | a[b1,:] -5 5 | #: E231 -6 |-a = [{'a':''}] - 6 |+a = [{'a': ''}] -7 7 | #: Okay -8 8 | a = (4,) -9 9 | b = (5, ) - -E23.py:19:10: E231 [*] Missing whitespace after ',' - | -17 | def foo() -> None: -18 | #: E231 -19 | if (1,2): - | ^ E231 -20 | pass - | - = help: Added missing whitespace after ',' - -ℹ Fix -16 16 | -17 17 | def foo() -> None: -18 18 | #: E231 -19 |- if (1,2): - 19 |+ if (1, 2): -20 20 | pass -21 21 | -22 22 | #: Okay - -E23.py:29:20: E231 [*] Missing whitespace after ':' - | -27 | mdtypes_template = { -28 | 'tag_full': [('mdtype', 'u4'), ('byte_count', 'u4')], -29 | 'tag_smalldata':[('byte_count_mdtype', 'u4'), ('data', 'S4')], - | ^ E231 -30 | } - | - = help: Added missing whitespace after ':' - -ℹ Fix -26 26 | #: E231:2:20 -27 27 | mdtypes_template = { -28 28 | 'tag_full': [('mdtype', 'u4'), ('byte_count', 'u4')], -29 |- 'tag_smalldata':[('byte_count_mdtype', 'u4'), ('data', 'S4')], - 29 |+ 'tag_smalldata': [('byte_count_mdtype', 'u4'), ('data', 'S4')], -30 30 | } -31 31 | -32 32 | #: Okay - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E241_E24.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E241_E24.py.snap deleted file mode 100644 index db80143017..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E241_E24.py.snap +++ /dev/null @@ -1,40 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E24.py:2:8: E241 Multiple spaces after comma - | -1 | #: E241 -2 | a = (1, 2) - | ^^ E241 -3 | #: Okay -4 | b = (1, 20) - | - -E24.py:11:18: E241 Multiple spaces after comma - | - 9 | #: E241 E241 E241 -10 | # issue 135 -11 | more_spaces = [a, b, - | ^^^^ E241 -12 | ef, +h, -13 | c, -d] - | - -E24.py:12:19: E241 Multiple spaces after comma - | -10 | # issue 135 -11 | more_spaces = [a, b, -12 | ef, +h, - | ^^ E241 -13 | c, -d] - | - -E24.py:13:18: E241 Multiple spaces after comma - | -11 | more_spaces = [a, b, -12 | ef, +h, -13 | c, -d] - | ^^^ E241 - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E242_E24.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E242_E24.py.snap deleted file mode 100644 index 63298792db..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E242_E24.py.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E24.py:6:8: E242 Tab after comma - | -4 | b = (1, 20) -5 | #: E242 -6 | a = (1, 2) # tab before 2 - | ^ E242 -7 | #: Okay -8 | b = (1, 20) # space before 20 - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E251_E25.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E251_E25.py.snap deleted file mode 100644 index 14e31b83a8..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E251_E25.py.snap +++ /dev/null @@ -1,116 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E25.py:2:12: E251 Unexpected spaces around keyword / parameter equals - | -1 | #: E251 E251 -2 | def foo(bar = False): - | ^ E251 -3 | '''Test function with an error in declaration''' -4 | pass - | - -E25.py:2:14: E251 Unexpected spaces around keyword / parameter equals - | -1 | #: E251 E251 -2 | def foo(bar = False): - | ^ E251 -3 | '''Test function with an error in declaration''' -4 | pass - | - -E25.py:6:9: E251 Unexpected spaces around keyword / parameter equals - | -4 | pass -5 | #: E251 -6 | foo(bar= True) - | ^ E251 -7 | #: E251 -8 | foo(bar =True) - | - -E25.py:8:8: E251 Unexpected spaces around keyword / parameter equals - | - 6 | foo(bar= True) - 7 | #: E251 - 8 | foo(bar =True) - | ^ E251 - 9 | #: E251 E251 -10 | foo(bar = True) - | - -E25.py:10:8: E251 Unexpected spaces around keyword / parameter equals - | - 8 | foo(bar =True) - 9 | #: E251 E251 -10 | foo(bar = True) - | ^ E251 -11 | #: E251 -12 | y = bar(root= "sdasd") - | - -E25.py:10:10: E251 Unexpected spaces around keyword / parameter equals - | - 8 | foo(bar =True) - 9 | #: E251 E251 -10 | foo(bar = True) - | ^ E251 -11 | #: E251 -12 | y = bar(root= "sdasd") - | - -E25.py:12:14: E251 Unexpected spaces around keyword / parameter equals - | -10 | foo(bar = True) -11 | #: E251 -12 | y = bar(root= "sdasd") - | ^ E251 -13 | #: E251:2:29 -14 | parser.add_argument('--long-option', - | - -E25.py:15:29: E251 Unexpected spaces around keyword / parameter equals - | -13 | #: E251:2:29 -14 | parser.add_argument('--long-option', -15 | default= - | _____________________________^ -16 | | "/rather/long/filesystem/path/here/blah/blah/blah") - | |____________________^ E251 -17 | #: E251:1:45 -18 | parser.add_argument('--long-option', default - | - -E25.py:18:45: E251 Unexpected spaces around keyword / parameter equals - | -16 | "/rather/long/filesystem/path/here/blah/blah/blah") -17 | #: E251:1:45 -18 | parser.add_argument('--long-option', default - | _____________________________________________^ -19 | | ="/rather/long/filesystem/path/here/blah/blah/blah") - | |____________________^ E251 -20 | #: E251:3:8 E251:3:10 -21 | foo(True, - | - -E25.py:23:8: E251 Unexpected spaces around keyword / parameter equals - | -21 | foo(True, -22 | baz=(1, 2), -23 | biz = 'foo' - | ^ E251 -24 | ) -25 | #: Okay - | - -E25.py:23:10: E251 Unexpected spaces around keyword / parameter equals - | -21 | foo(True, -22 | baz=(1, 2), -23 | biz = 'foo' - | ^ E251 -24 | ) -25 | #: Okay - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E252_E25.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E252_E25.py.snap deleted file mode 100644 index a1d763598c..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E252_E25.py.snap +++ /dev/null @@ -1,44 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E25.py:46:15: E252 Missing whitespace around parameter equals - | -44 | return a + b -45 | #: E252:1:15 E252:1:16 E252:1:27 E252:1:36 -46 | def add(a: int=0, b: int =0, c: int= 0) -> int: - | ^ E252 -47 | return a + b + c -48 | #: Okay - | - -E25.py:46:15: E252 Missing whitespace around parameter equals - | -44 | return a + b -45 | #: E252:1:15 E252:1:16 E252:1:27 E252:1:36 -46 | def add(a: int=0, b: int =0, c: int= 0) -> int: - | ^ E252 -47 | return a + b + c -48 | #: Okay - | - -E25.py:46:26: E252 Missing whitespace around parameter equals - | -44 | return a + b -45 | #: E252:1:15 E252:1:16 E252:1:27 E252:1:36 -46 | def add(a: int=0, b: int =0, c: int= 0) -> int: - | ^ E252 -47 | return a + b + c -48 | #: Okay - | - -E25.py:46:36: E252 Missing whitespace around parameter equals - | -44 | return a + b -45 | #: E252:1:15 E252:1:16 E252:1:27 E252:1:36 -46 | def add(a: int=0, b: int =0, c: int= 0) -> int: - | ^ E252 -47 | return a + b + c -48 | #: Okay - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E261_E26.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E261_E26.py.snap deleted file mode 100644 index 731fc71c8a..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E261_E26.py.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E26.py:2:5: E261 Insert at least two spaces before an inline comment - | -1 | #: E261:1:5 -2 | pass # an inline comment - | ^ E261 -3 | #: E262:1:12 -4 | x = x + 1 #Increment x - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E262_E26.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E262_E26.py.snap deleted file mode 100644 index a7469f47a9..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E262_E26.py.snap +++ /dev/null @@ -1,54 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E26.py:4:12: E262 Inline comment should start with `# ` - | -2 | pass # an inline comment -3 | #: E262:1:12 -4 | x = x + 1 #Increment x - | ^^^^^^^^^^^^ E262 -5 | #: E262:1:12 -6 | x = x + 1 # Increment x - | - -E26.py:6:12: E262 Inline comment should start with `# ` - | -4 | x = x + 1 #Increment x -5 | #: E262:1:12 -6 | x = x + 1 # Increment x - | ^^^^^^^^^^^^^^ E262 -7 | #: E262:1:12 -8 | x = y + 1 #: Increment x - | - -E26.py:8:12: E262 Inline comment should start with `# ` - | - 6 | x = x + 1 # Increment x - 7 | #: E262:1:12 - 8 | x = y + 1 #: Increment x - | ^^^^^^^^^^^^^^^ E262 - 9 | #: E265:1:1 -10 | #Block comment - | - -E26.py:63:9: E262 Inline comment should start with `# ` - | -61 | # -*- coding: utf8 -*- -62 | #  (One space one NBSP) Ok for block comment -63 | a = 42 #  (One space one NBSP) - | ^^^^^^^^^^^^^^^^^^^^^^^ E262 -64 | #: E262:2:9 -65 | # (Two spaces) Ok for block comment - | - -E26.py:66:9: E262 Inline comment should start with `# ` - | -64 | #: E262:2:9 -65 | # (Two spaces) Ok for block comment -66 | a = 42 # (Two spaces) - | ^^^^^^^^^^^^^^^ E262 -67 | -68 | #: E265:5:1 - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E265_E26.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E265_E26.py.snap deleted file mode 100644 index c353a81922..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E265_E26.py.snap +++ /dev/null @@ -1,52 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E26.py:10:1: E265 Block comment should start with `# ` - | - 8 | x = y + 1 #: Increment x - 9 | #: E265:1:1 -10 | #Block comment - | ^^^^^^^^^^^^^^ E265 -11 | a = 1 -12 | #: E265:2:1 - | - -E26.py:14:1: E265 Block comment should start with `# ` - | -12 | #: E265:2:1 -13 | m = 42 -14 | #! This is important - | ^^^^^^^^^^^^^^^^^^^^ E265 -15 | mx = 42 - 42 -16 | #: E266:3:5 E266:6:5 - | - -E26.py:25:1: E265 Block comment should start with `# ` - | -23 | return -24 | #: E265:1:1 E266:2:1 -25 | ##if DEBUG: - | ^^^^^^^^^^^ E265 -26 | ## logging.error() -27 | #: W291:1:42 - | - -E26.py:32:1: E265 Block comment should start with `# ` - | -31 | #: Okay -32 | #!/usr/bin/env python - | ^^^^^^^^^^^^^^^^^^^^^ E265 -33 | -34 | pass # an inline comment - | - -E26.py:73:1: E265 Block comment should start with `# ` - | -71 | # F Means test is failing (F) -72 | # EF Means test is giving error and Failing -73 | #! Means test is segfaulting - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E265 -74 | # 8 Means test runs forever - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E266_E26.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E266_E26.py.snap deleted file mode 100644 index a317993b31..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E266_E26.py.snap +++ /dev/null @@ -1,42 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E26.py:19:5: E266 Too many leading `#` before block comment - | -17 | def how_it_feel(r): -18 | -19 | ### This is a variable ### - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E266 -20 | a = 42 - | - -E26.py:22:5: E266 Too many leading `#` before block comment - | -20 | a = 42 -21 | -22 | ### Of course it is unused - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E266 -23 | return -24 | #: E265:1:1 E266:2:1 - | - -E26.py:26:1: E266 Too many leading `#` before block comment - | -24 | #: E265:1:1 E266:2:1 -25 | ##if DEBUG: -26 | ## logging.error() - | ^^^^^^^^^^^^^^^^^^^^^ E266 -27 | #: W291:1:42 -28 | ######################################### - | - -E26.py:69:1: E266 Too many leading `#` before block comment - | -68 | #: E265:5:1 -69 | ### Means test is not done yet - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E266 -70 | # E Means test is giving error (E) -71 | # F Means test is failing (F) - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E271_E27.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E271_E27.py.snap deleted file mode 100644 index e17f1f89b2..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E271_E27.py.snap +++ /dev/null @@ -1,94 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E27.py:4:9: E271 Multiple spaces after keyword - | -2 | True and False -3 | #: E271 -4 | True and False - | ^^ E271 -5 | #: E272 -6 | True and False - | - -E27.py:6:5: E271 Multiple spaces after keyword - | -4 | True and False -5 | #: E272 -6 | True and False - | ^^ E271 -7 | #: E271 -8 | if 1: - | - -E27.py:8:3: E271 Multiple spaces after keyword - | - 6 | True and False - 7 | #: E271 - 8 | if 1: - | ^^^ E271 - 9 | #: E273 -10 | True and False - | - -E27.py:14:6: E271 Multiple spaces after keyword - | -12 | True and False -13 | #: E271 -14 | a and b - | ^^ E271 -15 | #: E271 -16 | 1 and b - | - -E27.py:16:6: E271 Multiple spaces after keyword - | -14 | a and b -15 | #: E271 -16 | 1 and b - | ^^ E271 -17 | #: E271 -18 | a and 2 - | - -E27.py:18:6: E271 Multiple spaces after keyword - | -16 | 1 and b -17 | #: E271 -18 | a and 2 - | ^^ E271 -19 | #: E271 E272 -20 | 1 and b - | - -E27.py:20:7: E271 Multiple spaces after keyword - | -18 | a and 2 -19 | #: E271 E272 -20 | 1 and b - | ^^ E271 -21 | #: E271 E272 -22 | a and 2 - | - -E27.py:22:7: E271 Multiple spaces after keyword - | -20 | 1 and b -21 | #: E271 E272 -22 | a and 2 - | ^^ E271 -23 | #: E272 -24 | this and False - | - -E27.py:35:14: E271 Multiple spaces after keyword - | -33 | from v import c, d -34 | #: E271 -35 | from w import (e, f) - | ^^ E271 -36 | #: E275 -37 | from w import(e, f) - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E272_E27.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E272_E27.py.snap deleted file mode 100644 index f6a003c36d..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E272_E27.py.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E27.py:20:2: E272 Multiple spaces before keyword - | -18 | a and 2 -19 | #: E271 E272 -20 | 1 and b - | ^^ E272 -21 | #: E271 E272 -22 | a and 2 - | - -E27.py:22:2: E272 Multiple spaces before keyword - | -20 | 1 and b -21 | #: E271 E272 -22 | a and 2 - | ^^ E272 -23 | #: E272 -24 | this and False - | - -E27.py:24:5: E272 Multiple spaces before keyword - | -22 | a and 2 -23 | #: E272 -24 | this and False - | ^^ E272 -25 | #: E273 -26 | a and b - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E273_E27.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E273_E27.py.snap deleted file mode 100644 index 7456a0a624..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E273_E27.py.snap +++ /dev/null @@ -1,54 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E27.py:10:9: E273 Tab after keyword - | - 8 | if 1: - 9 | #: E273 -10 | True and False - | ^^^^^^^^ E273 -11 | #: E273 E274 -12 | True and False - | - -E27.py:12:5: E273 Tab after keyword - | -10 | True and False -11 | #: E273 E274 -12 | True and False - | ^^^^^^^^ E273 -13 | #: E271 -14 | a and b - | - -E27.py:12:10: E273 Tab after keyword - | -10 | True and False -11 | #: E273 E274 -12 | True and False - | ^ E273 -13 | #: E271 -14 | a and b - | - -E27.py:26:6: E273 Tab after keyword - | -24 | this and False -25 | #: E273 -26 | a and b - | ^^^ E273 -27 | #: E274 -28 | a and b - | - -E27.py:30:10: E273 Tab after keyword - | -28 | a and b -29 | #: E273 E274 -30 | this and False - | ^ E273 -31 | #: Okay -32 | from u import (a, b) - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E274_E27.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E274_E27.py.snap deleted file mode 100644 index fe00460dea..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E274_E27.py.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E27.py:28:2: E274 Tab before keyword - | -26 | a and b -27 | #: E274 -28 | a and b - | ^^^^^^^ E274 -29 | #: E273 E274 -30 | this and False - | - -E27.py:30:5: E274 Tab before keyword - | -28 | a and b -29 | #: E273 E274 -30 | this and False - | ^^^^^^^^ E274 -31 | #: Okay -32 | from u import (a, b) - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E275_E27.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E275_E27.py.snap deleted file mode 100644 index 1ab10b75ea..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E275_E27.py.snap +++ /dev/null @@ -1,54 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E27.py:37:8: E275 Missing whitespace after keyword - | -35 | from w import (e, f) -36 | #: E275 -37 | from w import(e, f) - | ^^^^^^ E275 -38 | #: E275 -39 | from importable.module import(e, f) - | - -E27.py:39:24: E275 Missing whitespace after keyword - | -37 | from w import(e, f) -38 | #: E275 -39 | from importable.module import(e, f) - | ^^^^^^ E275 -40 | #: E275 -41 | try: - | - -E27.py:42:28: E275 Missing whitespace after keyword - | -40 | #: E275 -41 | try: -42 | from importable.module import(e, f) - | ^^^^^^ E275 -43 | except ImportError: -44 | pass - | - -E27.py:46:1: E275 Missing whitespace after keyword - | -44 | pass -45 | #: E275 -46 | if(foo): - | ^^ E275 -47 | pass -48 | else: - | - -E27.py:54:5: E275 Missing whitespace after keyword - | -52 | #: E275:2:11 -53 | if True: -54 | assert(1) - | ^^^^^^ E275 -55 | #: Okay -56 | def f(): - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E401_E40.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E401_E40.py.snap deleted file mode 100644 index fb4d57fd9f..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E401_E40.py.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E40.py:2:1: E401 Multiple imports on one line - | -1 | #: E401 -2 | import os, sys - | ^^^^^^^^^^^^^^ E401 -3 | #: Okay -4 | import os - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E402_E40.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E402_E40.py.snap deleted file mode 100644 index 19c044b3e0..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E402_E40.py.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E40.py:55:1: E402 Module level import not at top of file - | -53 | VERSION = '1.2.3' -54 | -55 | import foo - | ^^^^^^^^^^ E402 -56 | #: E402 -57 | import foo - | - -E40.py:57:1: E402 Module level import not at top of file - | -55 | import foo -56 | #: E402 -57 | import foo - | ^^^^^^^^^^ E402 -58 | -59 | a = 1 - | - -E40.py:61:1: E402 Module level import not at top of file - | -59 | a = 1 -60 | -61 | import bar - | ^^^^^^^^^^ E402 - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E402_E402.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E402_E402.py.snap deleted file mode 100644 index a0518e1437..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E402_E402.py.snap +++ /dev/null @@ -1,28 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E402.py:24:1: E402 Module level import not at top of file - | -22 | __some__magic = 1 -23 | -24 | import f - | ^^^^^^^^ E402 - | - -E402.py:34:1: E402 Module level import not at top of file - | -32 | import g -33 | -34 | import h; import i - | ^^^^^^^^ E402 - | - -E402.py:34:11: E402 Module level import not at top of file - | -32 | import g -33 | -34 | import h; import i - | ^^^^^^^^ E402 - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E501_E501.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E501_E501.py.snap deleted file mode 100644 index 65c355a014..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E501_E501.py.snap +++ /dev/null @@ -1,59 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E501.py:5:89: E501 Line too long (123 > 88 characters) - | -3 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 -4 | -5 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 -6 | """ - | - -E501.py:16:85: E501 Line too long (95 > 88 characters) - | -15 | _ = "---------------------------------------------------------------------------AAAAAAA" -16 | _ = "---------------------------------------------------------------------------亜亜亜亜亜亜亜" - | ^^^^^^^ E501 - | - -E501.py:25:89: E501 Line too long (127 > 88 characters) - | -23 | caller( -24 | """ -25 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 -26 | """, -27 | ) - | - -E501.py:40:89: E501 Line too long (132 > 88 characters) - | -38 | "Lorem ipsum dolor": "sit amet", -39 | # E501 Line too long -40 | "Lorem ipsum dolor": "sit amet consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 -41 | # E501 Line too long -42 | "Lorem ipsum dolor": """ - | - -E501.py:43:89: E501 Line too long (105 > 88 characters) - | -41 | # E501 Line too long -42 | "Lorem ipsum dolor": """ -43 | sit amet consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. - | ^^^^^^^^^^^^^^^^^ E501 -44 | """, -45 | # OK - | - -E501.py:83:89: E501 Line too long (147 > 88 characters) - | -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 | """ - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E701_E70.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E701_E70.py.snap deleted file mode 100644 index 9d4472d4fb..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E701_E70.py.snap +++ /dev/null @@ -1,143 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E70.py:2:5: E701 Multiple statements on one line (colon) - | -1 | #: E701:1:5 -2 | if a: a = False - | ^ E701 -3 | #: E701:1:40 -4 | if not header or header[:6] != 'bytes=': return - | - -E70.py:4:40: E701 Multiple statements on one line (colon) - | -2 | if a: a = False -3 | #: E701:1:40 -4 | if not header or header[:6] != 'bytes=': return - | ^ E701 -5 | #: E702:1:10 -6 | a = False; b = True - | - -E70.py:25:8: E701 Multiple statements on one line (colon) - | -23 | def f(x): return 2*x -24 | #: E704:1:8 E702:1:11 E703:1:14 -25 | if True: x; y; - | ^ E701 -26 | #: E701:1:8 -27 | if True: lambda a: b - | - -E70.py:27:8: E701 Multiple statements on one line (colon) - | -25 | if True: x; y; -26 | #: E701:1:8 -27 | if True: lambda a: b - | ^ E701 -28 | #: E701:1:10 -29 | if a := 1: pass - | - -E70.py:29:10: E701 Multiple statements on one line (colon) - | -27 | if True: lambda a: b -28 | #: E701:1:10 -29 | if a := 1: pass - | ^ E701 -30 | # E701:1:4 E701:2:18 E701:3:8 -31 | try: lambda foo: bar - | - -E70.py:31:4: E701 Multiple statements on one line (colon) - | -29 | if a := 1: pass -30 | # E701:1:4 E701:2:18 E701:3:8 -31 | try: lambda foo: bar - | ^ E701 -32 | except ValueError: pass -33 | finally: pass - | - -E70.py:32:18: E701 Multiple statements on one line (colon) - | -30 | # E701:1:4 E701:2:18 E701:3:8 -31 | try: lambda foo: bar -32 | except ValueError: pass - | ^ E701 -33 | finally: pass -34 | # E701:1:7 - | - -E70.py:33:8: E701 Multiple statements on one line (colon) - | -31 | try: lambda foo: bar -32 | except ValueError: pass -33 | finally: pass - | ^ E701 -34 | # E701:1:7 -35 | class C: pass - | - -E70.py:35:8: E701 Multiple statements on one line (colon) - | -33 | finally: pass -34 | # E701:1:7 -35 | class C: pass - | ^ E701 -36 | # E701:1:7 -37 | with C(): pass - | - -E70.py:37:9: E701 Multiple statements on one line (colon) - | -35 | class C: pass -36 | # E701:1:7 -37 | with C(): pass - | ^ E701 -38 | # E701:1:14 -39 | async with C(): pass - | - -E70.py:39:15: E701 Multiple statements on one line (colon) - | -37 | with C(): pass -38 | # E701:1:14 -39 | async with C(): pass - | ^ E701 -40 | #: -41 | lambda a: b - | - -E70.py:54:8: E701 Multiple statements on one line (colon) - | -52 | def f(): ... -53 | #: E701:1:8 E702:1:13 -54 | class C: ...; x = 1 - | ^ E701 -55 | #: E701:1:8 E702:1:13 -56 | class C: ...; ... - | - -E70.py:56:8: E701 Multiple statements on one line (colon) - | -54 | class C: ...; x = 1 -55 | #: E701:1:8 E702:1:13 -56 | class C: ...; ... - | ^ E701 -57 | #: E701:2:12 -58 | match *0, 1, *2: - | - -E70.py:59:12: E701 Multiple statements on one line (colon) - | -57 | #: E701:2:12 -58 | match *0, 1, *2: -59 | case 0,: y = 0 - | ^ E701 -60 | #: -61 | class Foo: - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E702_E70.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E702_E70.py.snap deleted file mode 100644 index a0e09543c1..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E702_E70.py.snap +++ /dev/null @@ -1,74 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E70.py:6:10: E702 Multiple statements on one line (semicolon) - | -4 | if not header or header[:6] != 'bytes=': return -5 | #: E702:1:10 -6 | a = False; b = True - | ^ E702 -7 | #: E702:1:17 -8 | import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe) - | - -E70.py:8:17: E702 Multiple statements on one line (semicolon) - | - 6 | a = False; b = True - 7 | #: E702:1:17 - 8 | import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe) - | ^ E702 - 9 | #: E703:1:13 -10 | import shlex; - | - -E70.py:12:9: E702 Multiple statements on one line (semicolon) - | -10 | import shlex; -11 | #: E702:1:9 E703:1:23 -12 | del a[:]; a.append(42); - | ^ E702 -13 | #: E704:1:1 -14 | def f(x): return 2 - | - -E70.py:25:11: E702 Multiple statements on one line (semicolon) - | -23 | def f(x): return 2*x -24 | #: E704:1:8 E702:1:11 E703:1:14 -25 | if True: x; y; - | ^ E702 -26 | #: E701:1:8 -27 | if True: lambda a: b - | - -E70.py:54:13: E702 Multiple statements on one line (semicolon) - | -52 | def f(): ... -53 | #: E701:1:8 E702:1:13 -54 | class C: ...; x = 1 - | ^ E702 -55 | #: E701:1:8 E702:1:13 -56 | class C: ...; ... - | - -E70.py:56:13: E702 Multiple statements on one line (semicolon) - | -54 | class C: ...; x = 1 -55 | #: E701:1:8 E702:1:13 -56 | class C: ...; ... - | ^ E702 -57 | #: E701:2:12 -58 | match *0, 1, *2: - | - -E70.py:65:4: E702 Multiple statements on one line (semicolon) - | -63 | #: E702:2:4 -64 | while 1: -65 | 1;... - | ^ E702 -66 | #: E703:2:1 -67 | 0\ - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E703_E70.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E703_E70.py.snap deleted file mode 100644 index f3bc1f206a..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E703_E70.py.snap +++ /dev/null @@ -1,105 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E70.py:10:13: E703 [*] Statement ends with an unnecessary semicolon - | - 8 | import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe) - 9 | #: E703:1:13 -10 | import shlex; - | ^ E703 -11 | #: E702:1:9 E703:1:23 -12 | del a[:]; a.append(42); - | - = help: Remove unnecessary semicolon - -ℹ Fix -7 7 | #: E702:1:17 -8 8 | import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe) -9 9 | #: E703:1:13 -10 |-import shlex; - 10 |+import shlex -11 11 | #: E702:1:9 E703:1:23 -12 12 | del a[:]; a.append(42); -13 13 | #: E704:1:1 - -E70.py:12:23: E703 [*] Statement ends with an unnecessary semicolon - | -10 | import shlex; -11 | #: E702:1:9 E703:1:23 -12 | del a[:]; a.append(42); - | ^ E703 -13 | #: E704:1:1 -14 | def f(x): return 2 - | - = help: Remove unnecessary semicolon - -ℹ Fix -9 9 | #: E703:1:13 -10 10 | import shlex; -11 11 | #: E702:1:9 E703:1:23 -12 |-del a[:]; a.append(42); - 12 |+del a[:]; a.append(42) -13 13 | #: E704:1:1 -14 14 | def f(x): return 2 -15 15 | #: E704:1:1 - -E70.py:25:14: E703 [*] Statement ends with an unnecessary semicolon - | -23 | def f(x): return 2*x -24 | #: E704:1:8 E702:1:11 E703:1:14 -25 | if True: x; y; - | ^ E703 -26 | #: E701:1:8 -27 | if True: lambda a: b - | - = help: Remove unnecessary semicolon - -ℹ Fix -22 22 | while all is round: -23 23 | def f(x): return 2*x -24 24 | #: E704:1:8 E702:1:11 E703:1:14 -25 |-if True: x; y; - 25 |+if True: x; y -26 26 | #: E701:1:8 -27 27 | if True: lambda a: b -28 28 | #: E701:1:10 - -E70.py:68:1: E703 [*] Statement ends with an unnecessary semicolon - | -66 | #: E703:2:1 -67 | 0\ -68 | ; - | ^ E703 -69 | #: E701:2:3 -70 | a = \ - | - = help: Remove unnecessary semicolon - -ℹ Fix -64 64 | while 1: -65 65 | 1;... -66 66 | #: E703:2:1 -67 |-0\ -68 |-; - 67 |+0 -69 68 | #: E701:2:3 -70 69 | a = \ -71 70 | 5; - -E70.py:71:4: E703 [*] Statement ends with an unnecessary semicolon - | -69 | #: E701:2:3 -70 | a = \ -71 | 5; - | ^ E703 - | - = help: Remove unnecessary semicolon - -ℹ Fix -68 68 | ; -69 69 | #: E701:2:3 -70 70 | a = \ -71 |- 5; - 71 |+ 5 - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E711_E711.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E711_E711.py.snap deleted file mode 100644 index 6ebd5e2be6..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E711_E711.py.snap +++ /dev/null @@ -1,208 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E711.py:2:11: E711 [*] Comparison to `None` should be `cond is None` - | -1 | #: E711 -2 | if res == None: - | ^^^^ E711 -3 | pass -4 | #: E711 - | - = help: Replace with `cond is None` - -ℹ Suggested fix -1 1 | #: E711 -2 |-if res == None: - 2 |+if res is None: -3 3 | pass -4 4 | #: E711 -5 5 | if res != None: - -E711.py:5:11: E711 [*] Comparison to `None` should be `cond is not None` - | -3 | pass -4 | #: E711 -5 | if res != None: - | ^^^^ E711 -6 | pass -7 | #: E711 - | - = help: Replace with `cond is not None` - -ℹ Suggested fix -2 2 | if res == None: -3 3 | pass -4 4 | #: E711 -5 |-if res != None: - 5 |+if res is not None: -6 6 | pass -7 7 | #: E711 -8 8 | if None == res: - -E711.py:8:4: E711 [*] Comparison to `None` should be `cond is None` - | - 6 | pass - 7 | #: E711 - 8 | if None == res: - | ^^^^ E711 - 9 | pass -10 | #: E711 - | - = help: Replace with `cond is None` - -ℹ Suggested fix -5 5 | if res != None: -6 6 | pass -7 7 | #: E711 -8 |-if None == res: - 8 |+if None is res: -9 9 | pass -10 10 | #: E711 -11 11 | if None != res: - -E711.py:11:4: E711 [*] Comparison to `None` should be `cond is not None` - | - 9 | pass -10 | #: E711 -11 | if None != res: - | ^^^^ E711 -12 | pass -13 | #: E711 - | - = help: Replace with `cond is not None` - -ℹ Suggested fix -8 8 | if None == res: -9 9 | pass -10 10 | #: E711 -11 |-if None != res: - 11 |+if None is not res: -12 12 | pass -13 13 | #: E711 -14 14 | if res[1] == None: - -E711.py:14:14: E711 [*] Comparison to `None` should be `cond is None` - | -12 | pass -13 | #: E711 -14 | if res[1] == None: - | ^^^^ E711 -15 | pass -16 | #: E711 - | - = help: Replace with `cond is None` - -ℹ Suggested fix -11 11 | if None != res: -12 12 | pass -13 13 | #: E711 -14 |-if res[1] == None: - 14 |+if res[1] is None: -15 15 | pass -16 16 | #: E711 -17 17 | if res[1] != None: - -E711.py:17:14: E711 [*] Comparison to `None` should be `cond is not None` - | -15 | pass -16 | #: E711 -17 | if res[1] != None: - | ^^^^ E711 -18 | pass -19 | #: E711 - | - = help: Replace with `cond is not None` - -ℹ Suggested fix -14 14 | if res[1] == None: -15 15 | pass -16 16 | #: E711 -17 |-if res[1] != None: - 17 |+if res[1] is not None: -18 18 | pass -19 19 | #: E711 -20 20 | if None != res[1]: - -E711.py:20:4: E711 [*] Comparison to `None` should be `cond is not None` - | -18 | pass -19 | #: E711 -20 | if None != res[1]: - | ^^^^ E711 -21 | pass -22 | #: E711 - | - = help: Replace with `cond is not None` - -ℹ Suggested fix -17 17 | if res[1] != None: -18 18 | pass -19 19 | #: E711 -20 |-if None != res[1]: - 20 |+if None is not res[1]: -21 21 | pass -22 22 | #: E711 -23 23 | if None == res[1]: - -E711.py:23:4: E711 [*] Comparison to `None` should be `cond is None` - | -21 | pass -22 | #: E711 -23 | if None == res[1]: - | ^^^^ E711 -24 | pass - | - = help: Replace with `cond is None` - -ℹ Suggested fix -20 20 | if None != res[1]: -21 21 | pass -22 22 | #: E711 -23 |-if None == res[1]: - 23 |+if None is res[1]: -24 24 | pass -25 25 | -26 26 | if x == None != None: - -E711.py:26:9: E711 [*] Comparison to `None` should be `cond is None` - | -24 | pass -25 | -26 | if x == None != None: - | ^^^^ E711 -27 | pass - | - = help: Replace with `cond is None` - -ℹ Suggested fix -23 23 | if None == res[1]: -24 24 | pass -25 25 | -26 |-if x == None != None: - 26 |+if x is None is not None: -27 27 | pass -28 28 | -29 29 | #: Okay - -E711.py:26:17: E711 [*] Comparison to `None` should be `cond is not None` - | -24 | pass -25 | -26 | if x == None != None: - | ^^^^ E711 -27 | pass - | - = help: Replace with `cond is not None` - -ℹ Suggested fix -23 23 | if None == res[1]: -24 24 | pass -25 25 | -26 |-if x == None != None: - 26 |+if x is None is not None: -27 27 | pass -28 28 | -29 29 | #: Okay - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E712_E712.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E712_E712.py.snap deleted file mode 100644 index ba3f1143bd..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E712_E712.py.snap +++ /dev/null @@ -1,269 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E712.py:2:11: E712 [*] Comparison to `True` should be `cond is True` or `if cond:` - | -1 | #: E712 -2 | if res == True: - | ^^^^ E712 -3 | pass -4 | #: E712 - | - = help: Replace with `cond is True` - -ℹ Suggested fix -1 1 | #: E712 -2 |-if res == True: - 2 |+if res is True: -3 3 | pass -4 4 | #: E712 -5 5 | if res != False: - -E712.py:5:11: E712 [*] Comparison to `False` should be `cond is not False` or `if cond:` - | -3 | pass -4 | #: E712 -5 | if res != False: - | ^^^^^ E712 -6 | pass -7 | #: E712 - | - = help: Replace with `cond is not False` - -ℹ Suggested fix -2 2 | if res == True: -3 3 | pass -4 4 | #: E712 -5 |-if res != False: - 5 |+if res is not False: -6 6 | pass -7 7 | #: E712 -8 8 | if True != res: - -E712.py:8:4: E712 [*] Comparison to `True` should be `cond is not True` or `if not cond:` - | - 6 | pass - 7 | #: E712 - 8 | if True != res: - | ^^^^ E712 - 9 | pass -10 | #: E712 - | - = help: Replace with `cond is not True` - -ℹ Suggested fix -5 5 | if res != False: -6 6 | pass -7 7 | #: E712 -8 |-if True != res: - 8 |+if True is not res: -9 9 | pass -10 10 | #: E712 -11 11 | if False == res: - -E712.py:11:4: E712 [*] Comparison to `False` should be `cond is False` or `if not cond:` - | - 9 | pass -10 | #: E712 -11 | if False == res: - | ^^^^^ E712 -12 | pass -13 | #: E712 - | - = help: Replace with `cond is False` - -ℹ Suggested fix -8 8 | if True != res: -9 9 | pass -10 10 | #: E712 -11 |-if False == res: - 11 |+if False is res: -12 12 | pass -13 13 | #: E712 -14 14 | if res[1] == True: - -E712.py:14:14: E712 [*] Comparison to `True` should be `cond is True` or `if cond:` - | -12 | pass -13 | #: E712 -14 | if res[1] == True: - | ^^^^ E712 -15 | pass -16 | #: E712 - | - = help: Replace with `cond is True` - -ℹ Suggested fix -11 11 | if False == res: -12 12 | pass -13 13 | #: E712 -14 |-if res[1] == True: - 14 |+if res[1] is True: -15 15 | pass -16 16 | #: E712 -17 17 | if res[1] != False: - -E712.py:17:14: E712 [*] Comparison to `False` should be `cond is not False` or `if cond:` - | -15 | pass -16 | #: E712 -17 | if res[1] != False: - | ^^^^^ E712 -18 | pass -19 | #: E712 - | - = help: Replace with `cond is not False` - -ℹ Suggested fix -14 14 | if res[1] == True: -15 15 | pass -16 16 | #: E712 -17 |-if res[1] != False: - 17 |+if res[1] is not False: -18 18 | pass -19 19 | #: E712 -20 20 | var = 1 if cond == True else -1 if cond == False else cond - -E712.py:20:20: E712 [*] Comparison to `True` should be `cond is True` or `if cond:` - | -18 | pass -19 | #: E712 -20 | var = 1 if cond == True else -1 if cond == False else cond - | ^^^^ E712 -21 | #: E712 -22 | if (True) == TrueElement or x == TrueElement: - | - = help: Replace with `cond is True` - -ℹ Suggested fix -17 17 | if res[1] != False: -18 18 | pass -19 19 | #: E712 -20 |-var = 1 if cond == True else -1 if cond == False else cond - 20 |+var = 1 if cond is True else -1 if cond == False else cond -21 21 | #: E712 -22 22 | if (True) == TrueElement or x == TrueElement: -23 23 | pass - -E712.py:20:44: E712 [*] Comparison to `False` should be `cond is False` or `if not cond:` - | -18 | pass -19 | #: E712 -20 | var = 1 if cond == True else -1 if cond == False else cond - | ^^^^^ E712 -21 | #: E712 -22 | if (True) == TrueElement or x == TrueElement: - | - = help: Replace with `cond is False` - -ℹ Suggested fix -17 17 | if res[1] != False: -18 18 | pass -19 19 | #: E712 -20 |-var = 1 if cond == True else -1 if cond == False else cond - 20 |+var = 1 if cond == True else -1 if cond is False else cond -21 21 | #: E712 -22 22 | if (True) == TrueElement or x == TrueElement: -23 23 | pass - -E712.py:22:5: E712 [*] Comparison to `True` should be `cond is True` or `if cond:` - | -20 | var = 1 if cond == True else -1 if cond == False else cond -21 | #: E712 -22 | if (True) == TrueElement or x == TrueElement: - | ^^^^ E712 -23 | pass - | - = help: Replace with `cond is True` - -ℹ Suggested fix -19 19 | #: E712 -20 20 | var = 1 if cond == True else -1 if cond == False else cond -21 21 | #: E712 -22 |-if (True) == TrueElement or x == TrueElement: - 22 |+if (True) is TrueElement or x == TrueElement: -23 23 | pass -24 24 | -25 25 | if res == True != False: - -E712.py:25:11: E712 [*] Comparison to `True` should be `cond is True` or `if cond:` - | -23 | pass -24 | -25 | if res == True != False: - | ^^^^ E712 -26 | pass - | - = help: Replace with `cond is True` - -ℹ Suggested fix -22 22 | if (True) == TrueElement or x == TrueElement: -23 23 | pass -24 24 | -25 |-if res == True != False: - 25 |+if res is True is not False: -26 26 | pass -27 27 | -28 28 | if(True) == TrueElement or x == TrueElement: - -E712.py:25:19: E712 [*] Comparison to `False` should be `cond is not False` or `if cond:` - | -23 | pass -24 | -25 | if res == True != False: - | ^^^^^ E712 -26 | pass - | - = help: Replace with `cond is not False` - -ℹ Suggested fix -22 22 | if (True) == TrueElement or x == TrueElement: -23 23 | pass -24 24 | -25 |-if res == True != False: - 25 |+if res is True is not False: -26 26 | pass -27 27 | -28 28 | if(True) == TrueElement or x == TrueElement: - -E712.py:28:4: E712 [*] Comparison to `True` should be `cond is True` or `if cond:` - | -26 | pass -27 | -28 | if(True) == TrueElement or x == TrueElement: - | ^^^^ E712 -29 | pass - | - = help: Replace with `cond is True` - -ℹ Suggested fix -25 25 | if res == True != False: -26 26 | pass -27 27 | -28 |-if(True) == TrueElement or x == TrueElement: - 28 |+if(True) is TrueElement or x == TrueElement: -29 29 | pass -30 30 | -31 31 | if (yield i) == True: - -E712.py:31:17: E712 [*] Comparison to `True` should be `cond is True` or `if cond:` - | -29 | pass -30 | -31 | if (yield i) == True: - | ^^^^ E712 -32 | print("even") - | - = help: Replace with `cond is True` - -ℹ Suggested fix -28 28 | if(True) == TrueElement or x == TrueElement: -29 29 | pass -30 30 | -31 |-if (yield i) == True: - 31 |+if (yield i) is True: -32 32 | print("even") -33 33 | -34 34 | #: Okay - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E713_E713.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E713_E713.py.snap deleted file mode 100644 index 51dbe6d081..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E713_E713.py.snap +++ /dev/null @@ -1,121 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E713.py:2:8: E713 [*] Test for membership should be `not in` - | -1 | #: E713 -2 | if not X in Y: - | ^^^^^^ E713 -3 | pass -4 | #: E713 - | - = help: Convert to `not in` - -ℹ Fix -1 1 | #: E713 -2 |-if not X in Y: - 2 |+if X not in Y: -3 3 | pass -4 4 | #: E713 -5 5 | if not X.B in Y: - -E713.py:5:8: E713 [*] Test for membership should be `not in` - | -3 | pass -4 | #: E713 -5 | if not X.B in Y: - | ^^^^^^^^ E713 -6 | pass -7 | #: E713 - | - = help: Convert to `not in` - -ℹ Fix -2 2 | if not X in Y: -3 3 | pass -4 4 | #: E713 -5 |-if not X.B in Y: - 5 |+if X.B not in Y: -6 6 | pass -7 7 | #: E713 -8 8 | if not X in Y and Z == "zero": - -E713.py:8:8: E713 [*] Test for membership should be `not in` - | - 6 | pass - 7 | #: E713 - 8 | if not X in Y and Z == "zero": - | ^^^^^^ E713 - 9 | pass -10 | #: E713 - | - = help: Convert to `not in` - -ℹ Fix -5 5 | if not X.B in Y: -6 6 | pass -7 7 | #: E713 -8 |-if not X in Y and Z == "zero": - 8 |+if X not in Y and Z == "zero": -9 9 | pass -10 10 | #: E713 -11 11 | if X == "zero" or not Y in Z: - -E713.py:11:23: E713 [*] Test for membership should be `not in` - | - 9 | pass -10 | #: E713 -11 | if X == "zero" or not Y in Z: - | ^^^^^^ E713 -12 | pass -13 | #: E713 - | - = help: Convert to `not in` - -ℹ Fix -8 8 | if not X in Y and Z == "zero": -9 9 | pass -10 10 | #: E713 -11 |-if X == "zero" or not Y in Z: - 11 |+if X == "zero" or Y not in Z: -12 12 | pass -13 13 | #: E713 -14 14 | if not (X in Y): - -E713.py:14:9: E713 [*] Test for membership should be `not in` - | -12 | pass -13 | #: E713 -14 | if not (X in Y): - | ^^^^^^ E713 -15 | pass - | - = help: Convert to `not in` - -ℹ Fix -11 11 | if X == "zero" or not Y in Z: -12 12 | pass -13 13 | #: E713 -14 |-if not (X in Y): - 14 |+if X not in Y: -15 15 | pass -16 16 | -17 17 | #: Okay - -E713.py:40:12: E713 [*] Test for membership should be `not in` - | -38 | assert [42, not foo] in bar -39 | assert not (re.search(r"^.:\\Users\\[^\\]*\\Downloads\\.*") is None) -40 | assert not('name' in request)or not request['name'] - | ^^^^^^^^^^^^^^^^^ E713 - | - = help: Convert to `not in` - -ℹ Fix -37 37 | assert {"x": not foo} in bar -38 38 | assert [42, not foo] in bar -39 39 | assert not (re.search(r"^.:\\Users\\[^\\]*\\Downloads\\.*") is None) -40 |-assert not('name' in request)or not request['name'] - 40 |+assert 'name' not in request or not request['name'] - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E714_E714.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E714_E714.py.snap deleted file mode 100644 index 37f9a2cc63..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E714_E714.py.snap +++ /dev/null @@ -1,58 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E714.py:2:8: E714 [*] Test for object identity should be `is not` - | -1 | #: E714 -2 | if not X is Y: - | ^^^^^^ E714 -3 | pass -4 | #: E714 - | - = help: Convert to `is not` - -ℹ Fix -1 1 | #: E714 -2 |-if not X is Y: - 2 |+if X is not Y: -3 3 | pass -4 4 | #: E714 -5 5 | if not X.B is Y: - -E714.py:5:8: E714 [*] Test for object identity should be `is not` - | -3 | pass -4 | #: E714 -5 | if not X.B is Y: - | ^^^^^^^^ E714 -6 | pass - | - = help: Convert to `is not` - -ℹ Fix -2 2 | if not X is Y: -3 3 | pass -4 4 | #: E714 -5 |-if not X.B is Y: - 5 |+if X.B is not Y: -6 6 | pass -7 7 | -8 8 | #: Okay - -E714.py:39:13: E714 [*] Test for object identity should be `is not` - | -37 | assert {"x": not foo} in bar -38 | assert [42, not foo] in bar -39 | assert not (re.search(r"^.:\\Users\\[^\\]*\\Downloads\\.*") is None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E714 - | - = help: Convert to `is not` - -ℹ Fix -36 36 | assert (not foo) in bar -37 37 | assert {"x": not foo} in bar -38 38 | assert [42, not foo] in bar -39 |-assert not (re.search(r"^.:\\Users\\[^\\]*\\Downloads\\.*") is None) - 39 |+assert re.search(r"^.:\\Users\\[^\\]*\\Downloads\\.*") is not None - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E721_E721.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E721_E721.py.snap deleted file mode 100644 index 50476a5090..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E721_E721.py.snap +++ /dev/null @@ -1,173 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E721.py:2:4: E721 Do not compare types, use `isinstance()` - | -1 | #: E721 -2 | if type(res) == type(42): - | ^^^^^^^^^^^^^^^^^^^^^ E721 -3 | pass -4 | #: E721 - | - -E721.py:5:4: E721 Do not compare types, use `isinstance()` - | -3 | pass -4 | #: E721 -5 | if type(res) != type(""): - | ^^^^^^^^^^^^^^^^^^^^^ E721 -6 | pass -7 | #: E721 - | - -E721.py:15:4: E721 Do not compare types, use `isinstance()` - | -13 | import types -14 | -15 | if type(res) is not types.ListType: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E721 -16 | pass -17 | #: E721 - | - -E721.py:18:8: E721 Do not compare types, use `isinstance()` - | -16 | pass -17 | #: E721 -18 | assert type(res) == type(False) - | ^^^^^^^^^^^^^^^^^^^^^^^^ E721 -19 | #: E721 -20 | assert type(res) == type([]) - | - -E721.py:20:8: E721 Do not compare types, use `isinstance()` - | -18 | assert type(res) == type(False) -19 | #: E721 -20 | assert type(res) == type([]) - | ^^^^^^^^^^^^^^^^^^^^^ E721 -21 | #: E721 -22 | assert type(res) == type(()) - | - -E721.py:22:8: E721 Do not compare types, use `isinstance()` - | -20 | assert type(res) == type([]) -21 | #: E721 -22 | assert type(res) == type(()) - | ^^^^^^^^^^^^^^^^^^^^^ E721 -23 | #: E721 -24 | assert type(res) == type((0,)) - | - -E721.py:24:8: E721 Do not compare types, use `isinstance()` - | -22 | assert type(res) == type(()) -23 | #: E721 -24 | assert type(res) == type((0,)) - | ^^^^^^^^^^^^^^^^^^^^^^^ E721 -25 | #: E721 -26 | assert type(res) == type((0)) - | - -E721.py:26:8: E721 Do not compare types, use `isinstance()` - | -24 | assert type(res) == type((0,)) -25 | #: E721 -26 | assert type(res) == type((0)) - | ^^^^^^^^^^^^^^^^^^^^^^ E721 -27 | #: E721 -28 | assert type(res) != type((1,)) - | - -E721.py:28:8: E721 Do not compare types, use `isinstance()` - | -26 | assert type(res) == type((0)) -27 | #: E721 -28 | assert type(res) != type((1,)) - | ^^^^^^^^^^^^^^^^^^^^^^^ E721 -29 | #: E721 -30 | assert type(res) is type((1,)) - | - -E721.py:30:8: E721 Do not compare types, use `isinstance()` - | -28 | assert type(res) != type((1,)) -29 | #: E721 -30 | assert type(res) is type((1,)) - | ^^^^^^^^^^^^^^^^^^^^^^^ E721 -31 | #: E721 -32 | assert type(res) is not type((1,)) - | - -E721.py:32:8: E721 Do not compare types, use `isinstance()` - | -30 | assert type(res) is type((1,)) -31 | #: E721 -32 | assert type(res) is not type((1,)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E721 -33 | #: E211 E721 -34 | assert type(res) == type( - | - -E721.py:34:8: E721 Do not compare types, use `isinstance()` - | -32 | assert type(res) is not type((1,)) -33 | #: E211 E721 -34 | assert type(res) == type( - | ________^ -35 | | [ -36 | | 2, -37 | | ] -38 | | ) - | |_^ E721 -39 | #: E201 E201 E202 E721 -40 | assert type(res) == type(()) - | - -E721.py:40:8: E721 Do not compare types, use `isinstance()` - | -38 | ) -39 | #: E201 E201 E202 E721 -40 | assert type(res) == type(()) - | ^^^^^^^^^^^^^^^^^^^^^ E721 -41 | #: E201 E202 E721 -42 | assert type(res) == type((0,)) - | - -E721.py:42:8: E721 Do not compare types, use `isinstance()` - | -40 | assert type(res) == type(()) -41 | #: E201 E202 E721 -42 | assert type(res) == type((0,)) - | ^^^^^^^^^^^^^^^^^^^^^^^ E721 -43 | -44 | #: Okay - | - -E721.py:63:8: E721 Do not compare types, use `isinstance()` - | -62 | #: E721 -63 | assert type(res) is int - | ^^^^^^^^^^^^^^^^ E721 - | - -E721.py:69:12: E721 Do not compare types, use `isinstance()` - | -67 | def asdf(self, value: str | None): -68 | #: E721 -69 | if type(value) is str: - | ^^^^^^^^^^^^^^^^^^ E721 -70 | ... - | - -E721.py:79:12: E721 Do not compare types, use `isinstance()` - | -77 | def asdf(self, value: str | None): -78 | #: E721 -79 | if type(value) is str: - | ^^^^^^^^^^^^^^^^^^ E721 -80 | ... - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E722_E722.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E722_E722.py.snap deleted file mode 100644 index de79a0a65c..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E722_E722.py.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E722.py:4:1: E722 Do not use bare `except` - | -2 | try: -3 | pass -4 | except: - | ^^^^^^ E722 -5 | pass -6 | #: E722 - | - -E722.py:11:1: E722 Do not use bare `except` - | - 9 | except Exception: -10 | pass -11 | except: - | ^^^^^^ E722 -12 | pass -13 | #: E722 - | - -E722.py:16:1: E722 Do not use bare `except` - | -14 | try: -15 | pass -16 | except: - | ^^^^^^ E722 -17 | pass -18 | #: Okay - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E731_E731.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E731_E731.py.snap deleted file mode 100644 index 976423061a..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E731_E731.py.snap +++ /dev/null @@ -1,387 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E731.py:3:5: E731 [*] Do not assign a `lambda` expression, use a `def` - | -1 | def scope(): -2 | # E731 -3 | f = lambda x: 2 * x - | ^^^^^^^^^^^^^^^^^^^ E731 - | - = help: Rewrite `f` as a `def` - -ℹ Suggested fix -1 1 | def scope(): -2 2 | # E731 -3 |- f = lambda x: 2 * x - 3 |+ def f(x): - 4 |+ return 2 * x -4 5 | -5 6 | -6 7 | def scope(): - -E731.py:8:5: E731 [*] Do not assign a `lambda` expression, use a `def` - | -6 | def scope(): -7 | # E731 -8 | f = lambda x: 2 * x - | ^^^^^^^^^^^^^^^^^^^ E731 - | - = help: Rewrite `f` as a `def` - -ℹ Suggested fix -5 5 | -6 6 | def scope(): -7 7 | # E731 -8 |- f = lambda x: 2 * x - 8 |+ def f(x): - 9 |+ return 2 * x -9 10 | -10 11 | -11 12 | def scope(): - -E731.py:14:9: E731 [*] Do not assign a `lambda` expression, use a `def` - | -12 | # E731 -13 | while False: -14 | this = lambda y, z: 2 * x - | ^^^^^^^^^^^^^^^^^^^^^^^^^ E731 - | - = help: Rewrite `this` as a `def` - -ℹ Suggested fix -11 11 | def scope(): -12 12 | # E731 -13 13 | while False: -14 |- this = lambda y, z: 2 * x - 14 |+ def this(y, z): - 15 |+ return 2 * x -15 16 | -16 17 | -17 18 | def scope(): - -E731.py:19:5: E731 [*] Do not assign a `lambda` expression, use a `def` - | -17 | def scope(): -18 | # E731 -19 | f = lambda: (yield 1) - | ^^^^^^^^^^^^^^^^^^^^^ E731 - | - = help: Rewrite `f` as a `def` - -ℹ Suggested fix -16 16 | -17 17 | def scope(): -18 18 | # E731 -19 |- f = lambda: (yield 1) - 19 |+ def f(): - 20 |+ return (yield 1) -20 21 | -21 22 | -22 23 | def scope(): - -E731.py:24:5: E731 [*] Do not assign a `lambda` expression, use a `def` - | -22 | def scope(): -23 | # E731 -24 | f = lambda: (yield from g()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 - | - = help: Rewrite `f` as a `def` - -ℹ Suggested fix -21 21 | -22 22 | def scope(): -23 23 | # E731 -24 |- f = lambda: (yield from g()) - 24 |+ def f(): - 25 |+ return (yield from g()) -25 26 | -26 27 | -27 28 | def scope(): - -E731.py:57:5: E731 [*] Do not assign a `lambda` expression, use a `def` - | -55 | class Scope: -56 | # E731 -57 | f = lambda x: 2 * x - | ^^^^^^^^^^^^^^^^^^^ E731 - | - = help: Rewrite `f` as a `def` - -ℹ Possible fix -54 54 | -55 55 | class Scope: -56 56 | # E731 -57 |- f = lambda x: 2 * x - 57 |+ def f(x): - 58 |+ return 2 * x -58 59 | -59 60 | -60 61 | class Scope: - -E731.py:64:5: E731 [*] Do not assign a `lambda` expression, use a `def` - | -63 | # E731 -64 | f: Callable[[int], int] = lambda x: 2 * x - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 - | - = help: Rewrite `f` as a `def` - -ℹ Possible fix -61 61 | from typing import Callable -62 62 | -63 63 | # E731 -64 |- f: Callable[[int], int] = lambda x: 2 * x - 64 |+ def f(x: int) -> int: - 65 |+ return 2 * x -65 66 | -66 67 | -67 68 | def scope(): - -E731.py:73:9: E731 [*] Do not assign a `lambda` expression, use a `def` - | -71 | x: Callable[[int], int] -72 | if True: -73 | x = lambda: 1 - | ^^^^^^^^^^^^^ E731 -74 | else: -75 | x = lambda: 2 - | - = help: Rewrite `x` as a `def` - -ℹ Possible fix -70 70 | -71 71 | x: Callable[[int], int] -72 72 | if True: -73 |- x = lambda: 1 - 73 |+ def x(): - 74 |+ return 1 -74 75 | else: -75 76 | x = lambda: 2 -76 77 | return x - -E731.py:75:9: E731 [*] Do not assign a `lambda` expression, use a `def` - | -73 | x = lambda: 1 -74 | else: -75 | x = lambda: 2 - | ^^^^^^^^^^^^^ E731 -76 | return x - | - = help: Rewrite `x` as a `def` - -ℹ Possible fix -72 72 | if True: -73 73 | x = lambda: 1 -74 74 | else: -75 |- x = lambda: 2 - 75 |+ def x(): - 76 |+ return 2 -76 77 | return x -77 78 | -78 79 | - -E731.py:86:5: E731 [*] Do not assign a `lambda` expression, use a `def` - | -84 | # ParamSpec cannot be used in this context, so do not preserve the annotation. -85 | P = ParamSpec("P") -86 | f: Callable[P, int] = lambda *args: len(args) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 - | - = help: Rewrite `f` as a `def` - -ℹ Suggested fix -83 83 | -84 84 | # ParamSpec cannot be used in this context, so do not preserve the annotation. -85 85 | P = ParamSpec("P") -86 |- f: Callable[P, int] = lambda *args: len(args) - 86 |+ def f(*args): - 87 |+ return len(args) -87 88 | -88 89 | -89 90 | def scope(): - -E731.py:94:5: E731 [*] Do not assign a `lambda` expression, use a `def` - | -92 | from typing import Callable -93 | -94 | f: Callable[[], None] = lambda: None - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 - | - = help: Rewrite `f` as a `def` - -ℹ Suggested fix -91 91 | -92 92 | from typing import Callable -93 93 | -94 |- f: Callable[[], None] = lambda: None - 94 |+ def f() -> None: - 95 |+ return None -95 96 | -96 97 | -97 98 | def scope(): - -E731.py:102:5: E731 [*] Do not assign a `lambda` expression, use a `def` - | -100 | from typing import Callable -101 | -102 | f: Callable[..., None] = lambda a, b: None - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 - | - = help: Rewrite `f` as a `def` - -ℹ Suggested fix -99 99 | -100 100 | from typing import Callable -101 101 | -102 |- f: Callable[..., None] = lambda a, b: None - 102 |+ def f(a, b) -> None: - 103 |+ return None -103 104 | -104 105 | -105 106 | def scope(): - -E731.py:110:5: E731 [*] Do not assign a `lambda` expression, use a `def` - | -108 | from typing import Callable -109 | -110 | f: Callable[[int], int] = lambda x: 2 * x - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 - | - = help: Rewrite `f` as a `def` - -ℹ Suggested fix -107 107 | -108 108 | from typing import Callable -109 109 | -110 |- f: Callable[[int], int] = lambda x: 2 * x - 110 |+ def f(x: int) -> int: - 111 |+ return 2 * x -111 112 | -112 113 | -113 114 | # Let's use the `Callable` type from `collections.abc` instead. - -E731.py:119:5: E731 [*] Do not assign a `lambda` expression, use a `def` - | -117 | from collections.abc import Callable -118 | -119 | f: Callable[[str, int], str] = lambda a, b: a * b - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 - | - = help: Rewrite `f` as a `def` - -ℹ Suggested fix -116 116 | -117 117 | from collections.abc import Callable -118 118 | -119 |- f: Callable[[str, int], str] = lambda a, b: a * b - 119 |+ def f(a: str, b: int) -> str: - 120 |+ return a * b -120 121 | -121 122 | -122 123 | def scope(): - -E731.py:127:5: E731 [*] Do not assign a `lambda` expression, use a `def` - | -125 | from collections.abc import Callable -126 | -127 | f: Callable[[str, int], tuple[str, int]] = lambda a, b: (a, b) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 - | - = help: Rewrite `f` as a `def` - -ℹ Suggested fix -124 124 | -125 125 | from collections.abc import Callable -126 126 | -127 |- f: Callable[[str, int], tuple[str, int]] = lambda a, b: (a, b) - 127 |+ def f(a: str, b: int) -> tuple[str, int]: - 128 |+ return a, b -128 129 | -129 130 | -130 131 | def scope(): - -E731.py:135:5: E731 [*] Do not assign a `lambda` expression, use a `def` - | -133 | from collections.abc import Callable -134 | -135 | f: Callable[[str, int, list[str]], list[str]] = lambda a, b, /, c: [*c, a * b] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 - | - = help: Rewrite `f` as a `def` - -ℹ Suggested fix -132 132 | -133 133 | from collections.abc import Callable -134 134 | -135 |- f: Callable[[str, int, list[str]], list[str]] = lambda a, b, /, c: [*c, a * b] - 135 |+ def f(a: str, b: int, /, c: list[str]) -> list[str]: - 136 |+ return [*c, a * b] -136 137 | -137 138 | -138 139 | class TemperatureScales(Enum): - -E731.py:139:5: E731 [*] Do not assign a `lambda` expression, use a `def` - | -138 | class TemperatureScales(Enum): -139 | CELSIUS = (lambda deg_c: deg_c) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 -140 | FAHRENHEIT = (lambda deg_c: deg_c * 9 / 5 + 32) - | - = help: Rewrite `CELSIUS` as a `def` - -ℹ Possible fix -136 136 | -137 137 | -138 138 | class TemperatureScales(Enum): -139 |- CELSIUS = (lambda deg_c: deg_c) - 139 |+ def CELSIUS(deg_c): - 140 |+ return deg_c -140 141 | FAHRENHEIT = (lambda deg_c: deg_c * 9 / 5 + 32) -141 142 | -142 143 | - -E731.py:140:5: E731 [*] Do not assign a `lambda` expression, use a `def` - | -138 | class TemperatureScales(Enum): -139 | CELSIUS = (lambda deg_c: deg_c) -140 | FAHRENHEIT = (lambda deg_c: deg_c * 9 / 5 + 32) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 - | - = help: Rewrite `FAHRENHEIT` as a `def` - -ℹ Possible fix -137 137 | -138 138 | class TemperatureScales(Enum): -139 139 | CELSIUS = (lambda deg_c: deg_c) -140 |- FAHRENHEIT = (lambda deg_c: deg_c * 9 / 5 + 32) - 140 |+ def FAHRENHEIT(deg_c): - 141 |+ return deg_c * 9 / 5 + 32 -141 142 | -142 143 | -143 144 | # Regression test for: https://github.com/astral-sh/ruff/issues/7141 - -E731.py:147:5: E731 [*] Do not assign a `lambda` expression, use a `def` - | -145 | # E731 -146 | -147 | f = lambda: ( - | _____^ -148 | | i := 1, -149 | | ) - | |_____^ E731 - | - = help: Rewrite `f` as a `def` - -ℹ Suggested fix -144 144 | def scope(): -145 145 | # E731 -146 146 | -147 |- f = lambda: ( -148 |- i := 1, -149 |- ) - 147 |+ def f(): - 148 |+ return (i := 1), - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E741_E741.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E741_E741.py.snap deleted file mode 100644 index 80fffde95f..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E741_E741.py.snap +++ /dev/null @@ -1,213 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E741.py:3:1: E741 Ambiguous variable name: `l` - | -1 | from contextlib import contextmanager -2 | -3 | l = 0 - | ^ E741 -4 | I = 0 -5 | O = 0 - | - -E741.py:4:1: E741 Ambiguous variable name: `I` - | -3 | l = 0 -4 | I = 0 - | ^ E741 -5 | O = 0 -6 | l: int = 0 - | - -E741.py:5:1: E741 Ambiguous variable name: `O` - | -3 | l = 0 -4 | I = 0 -5 | O = 0 - | ^ E741 -6 | l: int = 0 - | - -E741.py:6:1: E741 Ambiguous variable name: `l` - | -4 | I = 0 -5 | O = 0 -6 | l: int = 0 - | ^ E741 -7 | -8 | a, l = 0, 1 - | - -E741.py:8:4: E741 Ambiguous variable name: `l` - | - 6 | l: int = 0 - 7 | - 8 | a, l = 0, 1 - | ^ E741 - 9 | [a, l] = 0, 1 -10 | a, *l = 0, 1, 2 - | - -E741.py:9:5: E741 Ambiguous variable name: `l` - | - 8 | a, l = 0, 1 - 9 | [a, l] = 0, 1 - | ^ E741 -10 | a, *l = 0, 1, 2 -11 | a = l = 0 - | - -E741.py:10:5: E741 Ambiguous variable name: `l` - | - 8 | a, l = 0, 1 - 9 | [a, l] = 0, 1 -10 | a, *l = 0, 1, 2 - | ^ E741 -11 | a = l = 0 - | - -E741.py:11:5: E741 Ambiguous variable name: `l` - | - 9 | [a, l] = 0, 1 -10 | a, *l = 0, 1, 2 -11 | a = l = 0 - | ^ E741 -12 | -13 | o = 0 - | - -E741.py:16:5: E741 Ambiguous variable name: `l` - | -14 | i = 0 -15 | -16 | for l in range(3): - | ^ E741 -17 | pass - | - -E741.py:20:8: E741 Ambiguous variable name: `l` - | -20 | for a, l in zip(range(3), range(3)): - | ^ E741 -21 | pass - | - -E741.py:25:12: E741 Ambiguous variable name: `l` - | -24 | def f1(): -25 | global l - | ^ E741 -26 | l = 0 - | - -E741.py:26:5: E741 Ambiguous variable name: `l` - | -24 | def f1(): -25 | global l -26 | l = 0 - | ^ E741 - | - -E741.py:30:5: E741 Ambiguous variable name: `l` - | -29 | def f2(): -30 | l = 0 - | ^ E741 -31 | -32 | def f3(): - | - -E741.py:33:18: E741 Ambiguous variable name: `l` - | -32 | def f3(): -33 | nonlocal l - | ^ E741 -34 | l = 1 - | - -E741.py:34:9: E741 Ambiguous variable name: `l` - | -32 | def f3(): -33 | nonlocal l -34 | l = 1 - | ^ E741 -35 | -36 | f3() - | - -E741.py:40:8: E741 Ambiguous variable name: `l` - | -40 | def f4(l, /, I): - | ^ E741 -41 | return l, I, O - | - -E741.py:40:14: E741 Ambiguous variable name: `I` - | -40 | def f4(l, /, I): - | ^ E741 -41 | return l, I, O - | - -E741.py:44:8: E741 Ambiguous variable name: `l` - | -44 | def f5(l=0, *, I=1): - | ^ E741 -45 | return l, I - | - -E741.py:44:16: E741 Ambiguous variable name: `I` - | -44 | def f5(l=0, *, I=1): - | ^ E741 -45 | return l, I - | - -E741.py:48:9: E741 Ambiguous variable name: `l` - | -48 | def f6(*l, **I): - | ^ E741 -49 | return l, I - | - -E741.py:48:14: E741 Ambiguous variable name: `I` - | -48 | def f6(*l, **I): - | ^ E741 -49 | return l, I - | - -E741.py:57:16: E741 Ambiguous variable name: `l` - | -57 | with ctx1() as l: - | ^ E741 -58 | pass - | - -E741.py:66:20: E741 Ambiguous variable name: `l` - | -66 | with ctx2() as (a, l): - | ^ E741 -67 | pass - | - -E741.py:71:22: E741 Ambiguous variable name: `l` - | -69 | try: -70 | pass -71 | except ValueError as l: - | ^ E741 -72 | pass - | - -E741.py:74:5: E741 Ambiguous variable name: `l` - | -72 | pass -73 | -74 | if (l := 5) > 0: - | ^ E741 -75 | pass - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E742_E742.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E742_E742.py.snap deleted file mode 100644 index 7031549d65..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E742_E742.py.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E742.py:1:7: E742 Ambiguous class name: `l` - | -1 | class l: - | ^ E742 -2 | pass - | - -E742.py:5:7: E742 Ambiguous class name: `I` - | -5 | class I: - | ^ E742 -6 | pass - | - -E742.py:9:7: E742 Ambiguous class name: `O` - | - 9 | class O: - | ^ E742 -10 | pass - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E743_E743.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E743_E743.py.snap deleted file mode 100644 index 88a107f756..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E743_E743.py.snap +++ /dev/null @@ -1,26 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E743.py:1:5: E743 Ambiguous function name: `l` - | -1 | def l(): - | ^ E743 -2 | pass - | - -E743.py:5:5: E743 Ambiguous function name: `I` - | -5 | def I(): - | ^ E743 -6 | pass - | - -E743.py:10:9: E743 Ambiguous function name: `O` - | - 9 | class X: -10 | def O(self): - | ^ E743 -11 | pass - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E999_E999.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E999_E999.py.snap deleted file mode 100644 index 4e22fd7e9c..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E999_E999.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E999.py:3:1: E999 SyntaxError: unindent does not match any outer indentation level - | -2 | def x(): -3 | - | ^ E999 -4 | - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W191_W19.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W191_W19.py.snap deleted file mode 100644 index 8fc58243f1..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W191_W19.py.snap +++ /dev/null @@ -1,352 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -W19.py:1:1: W191 Indentation contains tabs - | -1 | '''File starts with a tab - | ^^^^ W191 -2 | multiline string with tab in it''' - | - -W19.py:6:1: W191 Indentation contains tabs - | -4 | #: W191 -5 | if False: -6 | print # indented with 1 tab - | ^^^^ W191 -7 | #: - | - -W19.py:12:1: W191 Indentation contains tabs - | -10 | #: W191 -11 | y = x == 2 \ -12 | or x == 3 - | ^^^^ W191 -13 | #: E101 W191 W504 -14 | if ( - | - -W19.py:19:1: W191 Indentation contains tabs - | -17 | ) or -18 | y == 4): -19 | pass - | ^^^^ W191 -20 | #: E101 W191 -21 | if x == 2 \ - | - -W19.py:24:1: W191 Indentation contains tabs - | -22 | or y > 1 \ -23 | or x == 3: -24 | pass - | ^^^^ W191 -25 | #: E101 W191 -26 | if x == 2 \ - | - -W19.py:29:1: W191 Indentation contains tabs - | -27 | or y > 1 \ -28 | or x == 3: -29 | pass - | ^^^^ W191 -30 | #: - | - -W19.py:35:1: W191 Indentation contains tabs - | -33 | if (foo == bar and -34 | baz == bop): -35 | pass - | ^^^^ W191 -36 | #: E101 W191 W504 -37 | if ( - | - -W19.py:41:1: W191 Indentation contains tabs - | -39 | baz == bop -40 | ): -41 | pass - | ^^^^ W191 -42 | #: - | - -W19.py:47:1: W191 Indentation contains tabs - | -45 | if start[1] > end_col and not ( -46 | over_indent == 4 and indent_next): -47 | return (0, "E121 continuation line over-" - | ^^^^ W191 -48 | "indented for visual indent") -49 | #: - | - -W19.py:48:1: W191 Indentation contains tabs - | -46 | over_indent == 4 and indent_next): -47 | return (0, "E121 continuation line over-" -48 | "indented for visual indent") - | ^^^^^^^^^^^^ W191 -49 | #: - | - -W19.py:57:1: W191 Indentation contains tabs - | -55 | var_one, var_two, var_three, -56 | var_four): -57 | print(var_one) - | ^^^^ W191 -58 | #: E101 W191 W504 -59 | if ((row < 0 or self.moduleCount <= row or - | - -W19.py:61:1: W191 Indentation contains tabs - | -59 | if ((row < 0 or self.moduleCount <= row or -60 | col < 0 or self.moduleCount <= col)): -61 | raise Exception("%s,%s - %s" % (row, col, self.moduleCount)) - | ^^^^ W191 -62 | #: E101 E101 E101 E101 W191 W191 W191 W191 W191 W191 -63 | if bar: - | - -W19.py:64:1: W191 Indentation contains tabs - | -62 | #: E101 E101 E101 E101 W191 W191 W191 W191 W191 W191 -63 | if bar: -64 | return ( - | ^^^^ W191 -65 | start, 'E121 lines starting with a ' -66 | 'closing bracket should be indented ' - | - -W19.py:65:1: W191 Indentation contains tabs - | -63 | if bar: -64 | return ( -65 | start, 'E121 lines starting with a ' - | ^^^^^^^^ W191 -66 | 'closing bracket should be indented ' -67 | "to match that of the opening " - | - -W19.py:66:1: W191 Indentation contains tabs - | -64 | return ( -65 | start, 'E121 lines starting with a ' -66 | 'closing bracket should be indented ' - | ^^^^^^^^ W191 -67 | "to match that of the opening " -68 | "bracket's line" - | - -W19.py:67:1: W191 Indentation contains tabs - | -65 | start, 'E121 lines starting with a ' -66 | 'closing bracket should be indented ' -67 | "to match that of the opening " - | ^^^^^^^^ W191 -68 | "bracket's line" -69 | ) - | - -W19.py:68:1: W191 Indentation contains tabs - | -66 | 'closing bracket should be indented ' -67 | "to match that of the opening " -68 | "bracket's line" - | ^^^^^^^^ W191 -69 | ) -70 | # - | - -W19.py:69:1: W191 Indentation contains tabs - | -67 | "to match that of the opening " -68 | "bracket's line" -69 | ) - | ^^^^ W191 -70 | # -71 | #: E101 W191 W504 - | - -W19.py:76:1: W191 Indentation contains tabs - | -74 | foo.bar("bop") -75 | )): -76 | print "yes" - | ^^^^ W191 -77 | #: E101 W191 W504 -78 | # also ok, but starting to look like LISP - | - -W19.py:81:1: W191 Indentation contains tabs - | -79 | if ((foo.bar("baz") and -80 | foo.bar("bop"))): -81 | print "yes" - | ^^^^ W191 -82 | #: E101 W191 W504 -83 | if (a == 2 or - | - -W19.py:86:1: W191 Indentation contains tabs - | -84 | b == "abc def ghi" -85 | "jkl mno"): -86 | return True - | ^^^^ W191 -87 | #: E101 W191 W504 -88 | if (a == 2 or - | - -W19.py:91:1: W191 Indentation contains tabs - | -89 | b == """abc def ghi -90 | jkl mno"""): -91 | return True - | ^^^^ W191 -92 | #: W191:2:1 W191:3:1 E101:3:2 -93 | if length > options.max_line_length: - | - -W19.py:94:1: W191 Indentation contains tabs - | -92 | #: W191:2:1 W191:3:1 E101:3:2 -93 | if length > options.max_line_length: -94 | return options.max_line_length, \ - | ^^^^ W191 -95 | "E501 line too long (%d characters)" % length - | - -W19.py:95:1: W191 Indentation contains tabs - | -93 | if length > options.max_line_length: -94 | return options.max_line_length, \ -95 | "E501 line too long (%d characters)" % length - | ^^^^^^^^ W191 - | - -W19.py:101:1: W191 Indentation contains tabs - | - 99 | #: E101 W191 W191 W504 -100 | if os.path.exists(os.path.join(path, PEP8_BIN)): -101 | cmd = ([os.path.join(path, PEP8_BIN)] + - | ^^^^ W191 -102 | self._pep8_options(targetfile)) -103 | #: W191 - okay - | - -W19.py:102:1: W191 Indentation contains tabs - | -100 | if os.path.exists(os.path.join(path, PEP8_BIN)): -101 | cmd = ([os.path.join(path, PEP8_BIN)] + -102 | self._pep8_options(targetfile)) - | ^^^^^^^^^^^ W191 -103 | #: W191 - okay -104 | ''' - | - -W19.py:128:1: W191 Indentation contains tabs - | -126 | if foo is None and bar is "bop" and \ -127 | blah == 'yeah': -128 | blah = 'yeahnah' - | ^^^^ W191 - | - -W19.py:134:1: W191 Indentation contains tabs - | -132 | #: W191 W191 W191 -133 | if True: -134 | foo( - | ^^^^ W191 -135 | 1, -136 | 2) - | - -W19.py:135:1: W191 Indentation contains tabs - | -133 | if True: -134 | foo( -135 | 1, - | ^^^^^^^^ W191 -136 | 2) -137 | #: W191 W191 W191 W191 W191 - | - -W19.py:136:1: W191 Indentation contains tabs - | -134 | foo( -135 | 1, -136 | 2) - | ^^^^^^^^ W191 -137 | #: W191 W191 W191 W191 W191 -138 | def test_keys(self): - | - -W19.py:139:1: W191 Indentation contains tabs - | -137 | #: W191 W191 W191 W191 W191 -138 | def test_keys(self): -139 | """areas.json - All regions are accounted for.""" - | ^^^^ W191 -140 | expected = set([ -141 | u'Norrbotten', - | - -W19.py:140:1: W191 Indentation contains tabs - | -138 | def test_keys(self): -139 | """areas.json - All regions are accounted for.""" -140 | expected = set([ - | ^^^^ W191 -141 | u'Norrbotten', -142 | u'V\xe4sterbotten', - | - -W19.py:141:1: W191 Indentation contains tabs - | -139 | """areas.json - All regions are accounted for.""" -140 | expected = set([ -141 | u'Norrbotten', - | ^^^^^^^^ W191 -142 | u'V\xe4sterbotten', -143 | ]) - | - -W19.py:142:1: W191 Indentation contains tabs - | -140 | expected = set([ -141 | u'Norrbotten', -142 | u'V\xe4sterbotten', - | ^^^^^^^^ W191 -143 | ]) -144 | #: W191 - | - -W19.py:143:1: W191 Indentation contains tabs - | -141 | u'Norrbotten', -142 | u'V\xe4sterbotten', -143 | ]) - | ^^^^ W191 -144 | #: W191 -145 | x = [ - | - -W19.py:146:1: W191 Indentation contains tabs - | -144 | #: W191 -145 | x = [ -146 | 'abc' - | ^^^^ W191 -147 | ] -148 | #: W191 - okay - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W291_W29.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W291_W29.py.snap deleted file mode 100644 index e6e4ed42aa..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W291_W29.py.snap +++ /dev/null @@ -1,67 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -W29.py:4:6: W291 [*] Trailing whitespace - | -2 | # 情 -3 | #: W291:1:6 -4 | print - | ^ W291 -5 | #: W293:2:1 -6 | class Foo(object): - | - = help: Remove trailing whitespace - -ℹ Fix -1 1 | #: Okay -2 2 | # 情 -3 3 | #: W291:1:6 -4 |-print - 4 |+print -5 5 | #: W293:2:1 -6 6 | class Foo(object): -7 7 | - -W29.py:11:35: W291 [*] Trailing whitespace - | - 9 | #: W291:2:35 -10 | '''multiline -11 | string with trailing whitespace''' - | ^^^ W291 -12 | #: W291 W292 noeol -13 | x = 1 - | - = help: Remove trailing whitespace - -ℹ Fix -8 8 | bang = 12 -9 9 | #: W291:2:35 -10 10 | '''multiline -11 |-string with trailing whitespace''' - 11 |+string with trailing whitespace''' -12 12 | #: W291 W292 noeol -13 13 | x = 1 -14 14 | #: W191 W292 noeol - -W29.py:13:6: W291 [*] Trailing whitespace - | -11 | string with trailing whitespace''' -12 | #: W291 W292 noeol -13 | x = 1 - | ^^^ W291 -14 | #: W191 W292 noeol -15 | if False: - | - = help: Remove trailing whitespace - -ℹ Fix -10 10 | '''multiline -11 11 | string with trailing whitespace''' -12 12 | #: W291 W292 noeol -13 |-x = 1 - 13 |+x = 1 -14 14 | #: W191 W292 noeol -15 15 | if False: -16 16 | pass # indented with tabs - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_0.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_0.py.snap deleted file mode 100644 index 7b67a4f6a1..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_0.py.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -W292_0.py:2:9: W292 [*] No newline at end of file - | -1 | def fn() -> None: -2 | pass - | W292 - | - = help: Add trailing newline - -ℹ Fix -1 1 | def fn() -> None: -2 |- pass - 2 |+ pass - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_1.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_1.py.snap deleted file mode 100644 index 47288f5b43..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_1.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_2.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_2.py.snap deleted file mode 100644 index 47288f5b43..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_2.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_3.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_3.py.snap deleted file mode 100644 index 47288f5b43..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_3.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W293_W29.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W293_W29.py.snap deleted file mode 100644 index 14f67ce27f..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W293_W29.py.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -W29.py:7:1: W293 [*] Blank line contains whitespace - | -5 | #: W293:2:1 -6 | class Foo(object): -7 | - | ^^^^ W293 -8 | bang = 12 -9 | #: W291:2:35 - | - = help: Remove whitespace from blank line - -ℹ Fix -4 4 | print -5 5 | #: W293:2:1 -6 6 | class Foo(object): -7 |- - 7 |+ -8 8 | bang = 12 -9 9 | #: W291:2:35 -10 10 | '''multiline - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W605_W605_0.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W605_W605_0.py.snap deleted file mode 100644 index 8e4c0ad0c5..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W605_W605_0.py.snap +++ /dev/null @@ -1,138 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -W605_0.py:2:10: W605 [*] Invalid escape sequence: `\.` - | -1 | #: W605:1:10 -2 | regex = '\.png$' - | ^^ W605 -3 | -4 | #: W605:2:1 - | - = help: Add backslash to escape sequence - -ℹ Fix -1 1 | #: W605:1:10 -2 |-regex = '\.png$' - 2 |+regex = r'\.png$' -3 3 | -4 4 | #: W605:2:1 -5 5 | regex = ''' - -W605_0.py:6:1: W605 [*] Invalid escape sequence: `\.` - | -4 | #: W605:2:1 -5 | regex = ''' -6 | \.png$ - | ^^ W605 -7 | ''' - | - = help: Add backslash to escape sequence - -ℹ Fix -2 2 | regex = '\.png$' -3 3 | -4 4 | #: W605:2:1 -5 |-regex = ''' - 5 |+regex = r''' -6 6 | \.png$ -7 7 | ''' -8 8 | - -W605_0.py:11:6: W605 [*] Invalid escape sequence: `\_` - | - 9 | #: W605:2:6 -10 | f( -11 | '\_' - | ^^ W605 -12 | ) - | - = help: Add backslash to escape sequence - -ℹ Fix -8 8 | -9 9 | #: W605:2:6 -10 10 | f( -11 |- '\_' - 11 |+ r'\_' -12 12 | ) -13 13 | -14 14 | #: W605:4:6 - -W605_0.py:18:6: W605 [*] Invalid escape sequence: `\_` - | -16 | multi-line -17 | literal -18 | with \_ somewhere - | ^^ W605 -19 | in the middle -20 | """ - | - = help: Add backslash to escape sequence - -ℹ Fix -12 12 | ) -13 13 | -14 14 | #: W605:4:6 -15 |-""" - 15 |+r""" -16 16 | multi-line -17 17 | literal -18 18 | with \_ somewhere - -W605_0.py:23:39: W605 [*] Invalid escape sequence: `\_` - | -22 | #: W605:1:38 -23 | value = 'new line\nand invalid escape \_ here' - | ^^ W605 - | - = help: Add backslash to escape sequence - -ℹ Fix -20 20 | """ -21 21 | -22 22 | #: W605:1:38 -23 |-value = 'new line\nand invalid escape \_ here' - 23 |+value = 'new line\nand invalid escape \\_ here' -24 24 | -25 25 | -26 26 | def f(): - -W605_0.py:28:12: W605 [*] Invalid escape sequence: `\.` - | -26 | def f(): -27 | #: W605:1:11 -28 | return'\.png$' - | ^^ W605 -29 | -30 | #: Okay - | - = help: Add backslash to escape sequence - -ℹ Fix -25 25 | -26 26 | def f(): -27 27 | #: W605:1:11 -28 |- return'\.png$' - 28 |+ return r'\.png$' -29 29 | -30 30 | #: Okay -31 31 | regex = r'\.png$' - -W605_0.py:45:12: W605 [*] Invalid escape sequence: `\_` - | -43 | ''' # noqa -44 | -45 | regex = '\\\_' - | ^^ W605 - | - = help: Add backslash to escape sequence - -ℹ Fix -42 42 | \w -43 43 | ''' # noqa -44 44 | -45 |-regex = '\\\_' - 45 |+regex = '\\\\_' - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W605_W605_1.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W605_W605_1.py.snap deleted file mode 100644 index 6b6f5939fb..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W605_W605_1.py.snap +++ /dev/null @@ -1,104 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -W605_1.py:2:10: W605 [*] Invalid escape sequence: `\.` - | -1 | #: W605:1:10 -2 | regex = '\.png$' - | ^^ W605 -3 | -4 | #: W605:2:1 - | - = help: Add backslash to escape sequence - -ℹ Fix -1 1 | #: W605:1:10 -2 |-regex = '\.png$' - 2 |+regex = r'\.png$' -3 3 | -4 4 | #: W605:2:1 -5 5 | regex = ''' - -W605_1.py:6:1: W605 [*] Invalid escape sequence: `\.` - | -4 | #: W605:2:1 -5 | regex = ''' -6 | \.png$ - | ^^ W605 -7 | ''' - | - = help: Add backslash to escape sequence - -ℹ Fix -2 2 | regex = '\.png$' -3 3 | -4 4 | #: W605:2:1 -5 |-regex = ''' - 5 |+regex = r''' -6 6 | \.png$ -7 7 | ''' -8 8 | - -W605_1.py:11:6: W605 [*] Invalid escape sequence: `\_` - | - 9 | #: W605:2:6 -10 | f( -11 | '\_' - | ^^ W605 -12 | ) - | - = help: Add backslash to escape sequence - -ℹ Fix -8 8 | -9 9 | #: W605:2:6 -10 10 | f( -11 |- '\_' - 11 |+ r'\_' -12 12 | ) -13 13 | -14 14 | #: W605:4:6 - -W605_1.py:18:6: W605 [*] Invalid escape sequence: `\_` - | -16 | multi-line -17 | literal -18 | with \_ somewhere - | ^^ W605 -19 | in the middle -20 | """ - | - = help: Add backslash to escape sequence - -ℹ Fix -12 12 | ) -13 13 | -14 14 | #: W605:4:6 -15 |-""" - 15 |+r""" -16 16 | multi-line -17 17 | literal -18 18 | with \_ somewhere - -W605_1.py:25:12: W605 [*] Invalid escape sequence: `\.` - | -23 | def f(): -24 | #: W605:1:11 -25 | return'\.png$' - | ^^ W605 -26 | -27 | #: Okay - | - = help: Add backslash to escape sequence - -ℹ Fix -22 22 | -23 23 | def f(): -24 24 | #: W605:1:11 -25 |- return'\.png$' - 25 |+ return r'\.png$' -26 26 | -27 27 | #: Okay -28 28 | regex = r'\.png$' - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__constant_literals.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__constant_literals.snap deleted file mode 100644 index b6ae2e3549..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__constant_literals.snap +++ /dev/null @@ -1,191 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -constant_literals.py:4:4: F632 [*] Use `==` to compare constant literals - | -2 | # Errors -3 | ### -4 | if "abc" is "def": # F632 (fix) - | ^^^^^^^^^^^^^^ F632 -5 | pass -6 | if "abc" is None: # F632 (fix, but leaves behind unfixable E711) - | - = help: Replace `is` with `==` - -ℹ Fix -1 1 | ### -2 2 | # Errors -3 3 | ### -4 |-if "abc" is "def": # F632 (fix) - 4 |+if "abc" == "def": # F632 (fix) -5 5 | pass -6 6 | if "abc" is None: # F632 (fix, but leaves behind unfixable E711) -7 7 | pass - -constant_literals.py:6:4: F632 [*] Use `==` to compare constant literals - | -4 | if "abc" is "def": # F632 (fix) -5 | pass -6 | if "abc" is None: # F632 (fix, but leaves behind unfixable E711) - | ^^^^^^^^^^^^^ F632 -7 | pass -8 | if None is "abc": # F632 (fix, but leaves behind unfixable E711) - | - = help: Replace `is` with `==` - -ℹ Fix -3 3 | ### -4 4 | if "abc" is "def": # F632 (fix) -5 5 | pass -6 |-if "abc" is None: # F632 (fix, but leaves behind unfixable E711) - 6 |+if "abc" == None: # F632 (fix, but leaves behind unfixable E711) -7 7 | pass -8 8 | if None is "abc": # F632 (fix, but leaves behind unfixable E711) -9 9 | pass - -constant_literals.py:8:4: F632 [*] Use `==` to compare constant literals - | - 6 | if "abc" is None: # F632 (fix, but leaves behind unfixable E711) - 7 | pass - 8 | if None is "abc": # F632 (fix, but leaves behind unfixable E711) - | ^^^^^^^^^^^^^ F632 - 9 | pass -10 | if "abc" is False: # F632 (fix, but leaves behind unfixable E712) - | - = help: Replace `is` with `==` - -ℹ Fix -5 5 | pass -6 6 | if "abc" is None: # F632 (fix, but leaves behind unfixable E711) -7 7 | pass -8 |-if None is "abc": # F632 (fix, but leaves behind unfixable E711) - 8 |+if None == "abc": # F632 (fix, but leaves behind unfixable E711) -9 9 | pass -10 10 | if "abc" is False: # F632 (fix, but leaves behind unfixable E712) -11 11 | pass - -constant_literals.py:10:4: F632 [*] Use `==` to compare constant literals - | - 8 | if None is "abc": # F632 (fix, but leaves behind unfixable E711) - 9 | pass -10 | if "abc" is False: # F632 (fix, but leaves behind unfixable E712) - | ^^^^^^^^^^^^^^ F632 -11 | pass -12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) - | - = help: Replace `is` with `==` - -ℹ Fix -7 7 | pass -8 8 | if None is "abc": # F632 (fix, but leaves behind unfixable E711) -9 9 | pass -10 |-if "abc" is False: # F632 (fix, but leaves behind unfixable E712) - 10 |+if "abc" == False: # F632 (fix, but leaves behind unfixable E712) -11 11 | pass -12 12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) -13 13 | pass - -constant_literals.py:12:4: F632 [*] Use `==` to compare constant literals - | -10 | if "abc" is False: # F632 (fix, but leaves behind unfixable E712) -11 | pass -12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) - | ^^^^^^^^^^^^^^ F632 -13 | pass -14 | if False == None: # E711, E712 (fix) - | - = help: Replace `is` with `==` - -ℹ Fix -9 9 | pass -10 10 | if "abc" is False: # F632 (fix, but leaves behind unfixable E712) -11 11 | pass -12 |-if False is "abc": # F632 (fix, but leaves behind unfixable E712) - 12 |+if False == "abc": # F632 (fix, but leaves behind unfixable E712) -13 13 | pass -14 14 | if False == None: # E711, E712 (fix) -15 15 | pass - -constant_literals.py:14:4: E712 [*] Comparison to `False` should be `cond is False` or `if not cond:` - | -12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) -13 | pass -14 | if False == None: # E711, E712 (fix) - | ^^^^^ E712 -15 | pass -16 | if None == False: # E711, E712 (fix) - | - = help: Replace with `cond is False` - -ℹ Suggested fix -11 11 | pass -12 12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) -13 13 | pass -14 |-if False == None: # E711, E712 (fix) - 14 |+if False is None: # E711, E712 (fix) -15 15 | pass -16 16 | if None == False: # E711, E712 (fix) -17 17 | pass - -constant_literals.py:14:13: E711 [*] Comparison to `None` should be `cond is None` - | -12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) -13 | pass -14 | if False == None: # E711, E712 (fix) - | ^^^^ E711 -15 | pass -16 | if None == False: # E711, E712 (fix) - | - = help: Replace with `cond is None` - -ℹ Suggested fix -11 11 | pass -12 12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) -13 13 | pass -14 |-if False == None: # E711, E712 (fix) - 14 |+if False is None: # E711, E712 (fix) -15 15 | pass -16 16 | if None == False: # E711, E712 (fix) -17 17 | pass - -constant_literals.py:16:4: E711 [*] Comparison to `None` should be `cond is None` - | -14 | if False == None: # E711, E712 (fix) -15 | pass -16 | if None == False: # E711, E712 (fix) - | ^^^^ E711 -17 | pass - | - = help: Replace with `cond is None` - -ℹ Suggested fix -13 13 | pass -14 14 | if False == None: # E711, E712 (fix) -15 15 | pass -16 |-if None == False: # E711, E712 (fix) - 16 |+if None is False: # E711, E712 (fix) -17 17 | pass -18 18 | -19 19 | ### - -constant_literals.py:16:12: E712 [*] Comparison to `False` should be `cond is False` or `if not cond:` - | -14 | if False == None: # E711, E712 (fix) -15 | pass -16 | if None == False: # E711, E712 (fix) - | ^^^^^ E712 -17 | pass - | - = help: Replace with `cond is False` - -ℹ Suggested fix -13 13 | pass -14 14 | if False == None: # E711, E712 (fix) -15 15 | pass -16 |-if None == False: # E711, E712 (fix) - 16 |+if None is False: # E711, E712 (fix) -17 17 | pass -18 18 | -19 19 | ### - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__max_doc_length.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__max_doc_length.snap deleted file mode 100644 index d9291c9f2e..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__max_doc_length.snap +++ /dev/null @@ -1,62 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -W505.py:2:51: W505 Doc line too long (57 > 50 characters) - | -1 | #!/usr/bin/env python3 -2 | """Here's a top-level docstring that's over the limit.""" - | ^^^^^^^ W505 - | - -W505.py:6:51: W505 Doc line too long (56 > 50 characters) - | -5 | def f1(): -6 | """Here's a docstring that's also over the limit.""" - | ^^^^^^ W505 -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 characters) - | - 8 | x = 1 # Here's a comment that's over the limit, but it's not standalone. - 9 | -10 | # Here's a standalone comment that's over the limit. - | ^^^^^^ W505 -11 | -12 | x = 2 - | - -W505.py:13:51: W505 Doc line too long (93 > 50 characters) - | -12 | x = 2 -13 | # Another standalone that is preceded by a newline and indent toke and is over the limit. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 -14 | -15 | print("Here's a string that's over the limit, but it's not a docstring.") - | - -W505.py:18:51: W505 Doc line too long (61 > 50 characters) - | -18 | "This is also considered a docstring, and is over the limit." - | ^^^^^^^^^^^ W505 - | - -W505.py:24:51: W505 Doc line too long (82 > 50 characters) - | -22 | """Here's a multi-line docstring. -23 | -24 | It's over the limit on this line, which isn't the first line in the docstring. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 -25 | """ - | - -W505.py:31:51: W505 Doc line too long (85 > 50 characters) - | -29 | """Here's a multi-line docstring. -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/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__max_doc_length_with_utf_8.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__max_doc_length_with_utf_8.snap deleted file mode 100644 index d76c188d97..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__max_doc_length_with_utf_8.snap +++ /dev/null @@ -1,62 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -W505_utf_8.py:2:50: W505 Doc line too long (57 > 50 characters) - | -1 | #!/usr/bin/env python3 -2 | """Here's a top-level ß9💣2ℝing that's over theß9💣2ℝ.""" - | ^^^^^^ W505 - | - -W505_utf_8.py:6:49: W505 Doc line too long (56 > 50 characters) - | -5 | def f1(): -6 | """Here's a ß9💣2ℝing that's also over theß9💣2ℝ.""" - | ^^^^^^ W505 -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 characters) - | - 8 | x = 1 # Here's a comment that's over theß9💣2ℝ, but it's not standalone. - 9 | -10 | # Here's a standalone comment that's over theß9💣2ℝ. - | ^^^^^^ W505 -11 | -12 | x = 2 - | - -W505_utf_8.py:13:51: W505 Doc line too long (93 > 50 characters) - | -12 | x = 2 -13 | # Another standalone that is preceded by a newline and indent toke and is over theß9💣2ℝ. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 -14 | -15 | print("Here's a string that's over theß9💣2ℝ, but it's not a ß9💣2ℝing.") - | - -W505_utf_8.py:18:50: W505 Doc line too long (61 > 50 characters) - | -18 | "This is also considered a ß9💣2ℝing, and is over theß9💣2ℝ." - | ^^^^^^^^^^^ W505 - | - -W505_utf_8.py:24:50: W505 Doc line too long (82 > 50 characters) - | -22 | """Here's a multi-line ß9💣2ℝing. -23 | -24 | It's over theß9💣2ℝ on this line, which isn't the first line in the ß9💣2ℝing. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 -25 | """ - | - -W505_utf_8.py:31:50: W505 Doc line too long (85 > 50 characters) - | -29 | """Here's a multi-line ß9💣2ℝing. -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/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__shebang.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__shebang.snap deleted file mode 100644 index aec7237fed..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__shebang.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -shebang.py:3:1: E265 Block comment should start with `# ` - | -1 | #!/usr/bin/python -2 | # -3 | #! - | ^^ E265 -4 | #: - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__tab_size_1.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__tab_size_1.snap deleted file mode 100644 index b20cb9ecbf..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__tab_size_1.snap +++ /dev/null @@ -1,51 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E501_2.py:2:7: E501 Line too long (7 > 6 characters) - | -1 | # aaaa -2 | # aaaaa - | ^ E501 -3 | # a -4 | # a - | - -E501_2.py:3:7: E501 Line too long (7 > 6 characters) - | -1 | # aaaa -2 | # aaaaa -3 | # a - | ^ E501 -4 | # a -5 | # aa - | - -E501_2.py:7:7: E501 Line too long (7 > 6 characters) - | -5 | # aa -6 | # aaa -7 | # aaaa - | ^ E501 -8 | # a -9 | # aa - | - -E501_2.py:10:7: E501 Line too long (7 > 6 characters) - | - 8 | # a - 9 | # aa -10 | # aaa - | ^ E501 -11 | -12 | if True: # noqa: E501 - | - -E501_2.py:16:7: E501 Line too long (7 > 6 characters) - | -14 | [12 ] -15 | [1,2] -16 | [1, 2] - | ^ E501 - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__tab_size_2.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__tab_size_2.snap deleted file mode 100644 index e2f7159f9c..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__tab_size_2.snap +++ /dev/null @@ -1,90 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E501_2.py:2:7: E501 Line too long (7 > 6 characters) - | -1 | # aaaa -2 | # aaaaa - | ^ E501 -3 | # a -4 | # a - | - -E501_2.py:3:7: E501 Line too long (7 > 6 characters) - | -1 | # aaaa -2 | # aaaaa -3 | # a - | ^ E501 -4 | # a -5 | # aa - | - -E501_2.py:6:6: E501 Line too long (7 > 6 characters) - | -4 | # a -5 | # aa -6 | # aaa - | ^ E501 -7 | # aaaa -8 | # a - | - -E501_2.py:7:6: E501 Line too long (8 > 6 characters) - | -5 | # aa -6 | # aaa -7 | # aaaa - | ^^ E501 -8 | # a -9 | # aa - | - -E501_2.py:8:5: E501 Line too long (7 > 6 characters) - | - 6 | # aaa - 7 | # aaaa - 8 | # a - | ^ E501 - 9 | # aa -10 | # aaa - | - -E501_2.py:9:5: E501 Line too long (8 > 6 characters) - | - 7 | # aaaa - 8 | # a - 9 | # aa - | ^^ E501 -10 | # aaa - | - -E501_2.py:10:5: E501 Line too long (9 > 6 characters) - | - 8 | # a - 9 | # aa -10 | # aaa - | ^^^ E501 -11 | -12 | if True: # noqa: E501 - | - -E501_2.py:14:6: E501 Line too long (7 > 6 characters) - | -12 | if True: # noqa: E501 -13 | [12] -14 | [12 ] - | ^ E501 -15 | [1,2] -16 | [1, 2] - | - -E501_2.py:16:6: E501 Line too long (8 > 6 characters) - | -14 | [12 ] -15 | [1,2] -16 | [1, 2] - | ^^ E501 - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__tab_size_4.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__tab_size_4.snap deleted file mode 100644 index 3fd272e5d0..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__tab_size_4.snap +++ /dev/null @@ -1,110 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E501_2.py:2:7: E501 Line too long (7 > 6 characters) - | -1 | # aaaa -2 | # aaaaa - | ^ E501 -3 | # a -4 | # a - | - -E501_2.py:3:7: E501 Line too long (7 > 6 characters) - | -1 | # aaaa -2 | # aaaaa -3 | # a - | ^ E501 -4 | # a -5 | # aa - | - -E501_2.py:4:4: E501 Line too long (7 > 6 characters) - | -2 | # aaaaa -3 | # a -4 | # a - | ^ E501 -5 | # aa -6 | # aaa - | - -E501_2.py:5:4: E501 Line too long (8 > 6 characters) - | -3 | # a -4 | # a -5 | # aa - | ^^ E501 -6 | # aaa -7 | # aaaa - | - -E501_2.py:6:4: E501 Line too long (9 > 6 characters) - | -4 | # a -5 | # aa -6 | # aaa - | ^^^ E501 -7 | # aaaa -8 | # a - | - -E501_2.py:7:4: E501 Line too long (10 > 6 characters) - | -5 | # aa -6 | # aaa -7 | # aaaa - | ^^^^ E501 -8 | # a -9 | # aa - | - -E501_2.py:8:3: E501 Line too long (11 > 6 characters) - | - 6 | # aaa - 7 | # aaaa - 8 | # a - | ^^^ E501 - 9 | # aa -10 | # aaa - | - -E501_2.py:9:3: E501 Line too long (12 > 6 characters) - | - 7 | # aaaa - 8 | # a - 9 | # aa - | ^^^^ E501 -10 | # aaa - | - -E501_2.py:10:3: E501 Line too long (13 > 6 characters) - | - 8 | # a - 9 | # aa -10 | # aaa - | ^^^^^ E501 -11 | -12 | if True: # noqa: E501 - | - -E501_2.py:14:4: E501 Line too long (9 > 6 characters) - | -12 | if True: # noqa: E501 -13 | [12] -14 | [12 ] - | ^^^ E501 -15 | [1,2] -16 | [1, 2] - | - -E501_2.py:16:4: E501 Line too long (10 > 6 characters) - | -14 | [12 ] -15 | [1,2] -16 | [1, 2] - | ^^^^ E501 - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__tab_size_8.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__tab_size_8.snap deleted file mode 100644 index 7b2dd3f8f9..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__tab_size_8.snap +++ /dev/null @@ -1,110 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E501_2.py:2:7: E501 Line too long (7 > 6 characters) - | -1 | # aaaa -2 | # aaaaa - | ^ E501 -3 | # a -4 | # a - | - -E501_2.py:3:7: E501 Line too long (7 > 6 characters) - | -1 | # aaaa -2 | # aaaaa -3 | # a - | ^ E501 -4 | # a -5 | # aa - | - -E501_2.py:4:2: E501 Line too long (11 > 6 characters) - | -2 | # aaaaa -3 | # a -4 | # a - | ^^^ E501 -5 | # aa -6 | # aaa - | - -E501_2.py:5:2: E501 Line too long (12 > 6 characters) - | -3 | # a -4 | # a -5 | # aa - | ^^^^ E501 -6 | # aaa -7 | # aaaa - | - -E501_2.py:6:2: E501 Line too long (13 > 6 characters) - | -4 | # a -5 | # aa -6 | # aaa - | ^^^^^ E501 -7 | # aaaa -8 | # a - | - -E501_2.py:7:2: E501 Line too long (14 > 6 characters) - | -5 | # aa -6 | # aaa -7 | # aaaa - | ^^^^^^ E501 -8 | # a -9 | # aa - | - -E501_2.py:8:2: E501 Line too long (19 > 6 characters) - | - 6 | # aaa - 7 | # aaaa - 8 | # a - | ^^^^^^^ E501 - 9 | # aa -10 | # aaa - | - -E501_2.py:9:2: E501 Line too long (20 > 6 characters) - | - 7 | # aaaa - 8 | # a - 9 | # aa - | ^^^^^^^^ E501 -10 | # aaa - | - -E501_2.py:10:2: E501 Line too long (21 > 6 characters) - | - 8 | # a - 9 | # aa -10 | # aaa - | ^^^^^^^^^ E501 -11 | -12 | if True: # noqa: E501 - | - -E501_2.py:14:2: E501 Line too long (13 > 6 characters) - | -12 | if True: # noqa: E501 -13 | [12] -14 | [12 ] - | ^^^^^ E501 -15 | [1,2] -16 | [1, 2] - | - -E501_2.py:16:2: E501 Line too long (14 > 6 characters) - | -14 | [12 ] -15 | [1,2] -16 | [1, 2] - | ^^^^^^ E501 - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__task_tags_false.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__task_tags_false.snap deleted file mode 100644 index f4fe618901..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__task_tags_false.snap +++ /dev/null @@ -1,58 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -E501_1.py:1:89: E501 Line too long (149 > 88 characters) - | -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 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_1.py:2:89: E501 Line too long (148 > 88 characters) - | -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 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 | # 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_1.py:3:89: E501 Line too long (155 > 88 characters) - | -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 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 | # 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` -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_1.py:4:89: E501 Line too long (150 > 88 characters) - | -2 | # 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` -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 | # 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 -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_1.py:5:89: E501 Line too long (149 > 88 characters) - | -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 | # 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` -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` - | - -E501_1.py:6:89: E501 Line too long (156 > 88 characters) - | -4 | # 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` -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 - | - - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__task_tags_true.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__task_tags_true.snap deleted file mode 100644 index 47288f5b43..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__task_tags_true.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- - diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__w292_4.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__w292_4.snap deleted file mode 100644 index 68d23e984d..0000000000 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__w292_4.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/ruff/src/rules/pycodestyle/mod.rs ---- -W292_4.py:1:2: W292 [*] No newline at end of file - | -1 | - | W292 - | - = help: Add trailing newline - -ℹ Fix -1 |- - 1 |+ - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D100_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D100_D.py.snap deleted file mode 100644 index 1d8675730c..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D100_D.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:1:1: D100 Missing docstring in public module - | -1 | # No docstring, so we can test D100 - | D100 -2 | from functools import wraps -3 | import os - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D100__unrelated___no_pkg_priv.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D100__unrelated___no_pkg_priv.py.snap deleted file mode 100644 index 89dabd861c..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D100__unrelated___no_pkg_priv.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D100__unrelated__pkg__D100_pub.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D100__unrelated__pkg__D100_pub.py.snap deleted file mode 100644 index 4432d7ac1c..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D100__unrelated__pkg__D100_pub.py.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D100_pub.py:1:1: D100 Missing docstring in public module - | - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D100__unrelated__pkg___priv__no_D100_priv.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D100__unrelated__pkg___priv__no_D100_priv.py.snap deleted file mode 100644 index 89dabd861c..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D100__unrelated__pkg___priv__no_D100_priv.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D101_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D101_D.py.snap deleted file mode 100644 index 3120356f61..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D101_D.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:15:7: D101 Missing docstring in public class - | -15 | class class_: - | ^^^^^^ D101 -16 | -17 | expect('meta', 'D419: Docstring is empty') - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D102_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D102_D.py.snap deleted file mode 100644 index 557a1a840c..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D102_D.py.snap +++ /dev/null @@ -1,46 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:23:9: D102 Missing docstring in public method - | -22 | @expect('D102: Missing docstring in public method') -23 | def method(self=None): - | ^^^^^^ D102 -24 | pass - | - -D.py:56:9: D102 Missing docstring in public method - | -55 | @expect('D102: Missing docstring in public method') -56 | def __new__(self=None): - | ^^^^^^^ D102 -57 | pass - | - -D.py:68:9: D102 Missing docstring in public method - | -67 | @expect('D102: Missing docstring in public method') -68 | def __call__(self=None, x=None, y=None, z=None): - | ^^^^^^^^ D102 -69 | pass - | - -D.py:650:9: D102 Missing docstring in public method - | -648 | class StatementOnSameLineAsDocstring: -649 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 -650 | def sort_services(self): - | ^^^^^^^^^^^^^ D102 -651 | pass - | - -D.py:659:9: D102 Missing docstring in public method - | -657 | class CommentAfterDocstring: -658 | "After this docstring there's a comment." # priorities=1 -659 | def sort_services(self): - | ^^^^^^^^^^^^^ D102 -660 | pass - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D102_setter.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D102_setter.py.snap deleted file mode 100644 index 5523fa2ba1..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D102_setter.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -setter.py:16:9: D102 Missing docstring in public method - | -15 | @foo -16 | def foo(self, value: str) -> None: - | ^^^ D102 -17 | pass - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D103_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D103_D.py.snap deleted file mode 100644 index d5ba6d72fc..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D103_D.py.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:400:5: D103 Missing docstring in public function - | -399 | @expect("D103: Missing docstring in public function") -400 | def oneliner_d102(): return - | ^^^^^^^^^^^^^ D103 - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D104_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D104_D.py.snap deleted file mode 100644 index 89dabd861c..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D104_D.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D104_D104____init__.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D104_D104____init__.py.snap deleted file mode 100644 index 6db44d1079..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D104_D104____init__.py.snap +++ /dev/null @@ -1,8 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -__init__.py:1:1: D104 Missing docstring in public package - | - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D105_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D105_D.py.snap deleted file mode 100644 index ed3366103f..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D105_D.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:64:9: D105 Missing docstring in magic method - | -63 | @expect('D105: Missing docstring in magic method') -64 | def __str__(self=None): - | ^^^^^^^ D105 -65 | pass - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D106_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D106_D.py.snap deleted file mode 100644 index 89dabd861c..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D106_D.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D107_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D107_D.py.snap deleted file mode 100644 index cdd964439e..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D107_D.py.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:60:9: D107 Missing docstring in `__init__` - | -59 | @expect('D107: Missing docstring in __init__') -60 | def __init__(self=None): - | ^^^^^^^^ D107 -61 | pass - | - -D.py:534:9: D107 Missing docstring in `__init__` - | -532 | """ -533 | -534 | def __init__(self, x): - | ^^^^^^^^ D107 -535 | pass - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D200_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D200_D.py.snap deleted file mode 100644 index 0d1feaafc6..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D200_D.py.snap +++ /dev/null @@ -1,112 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -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 | """ - | _____^ -130 | | Wrong. -131 | | """ - | |_______^ D200 - | - = help: Reformat to one line - -ℹ Suggested fix -126 126 | '(found 3)') -127 127 | @expect('D212: Multi-line docstring summary should start at the first line') -128 128 | def asdlkfasd(): -129 |- """ -130 |- Wrong. -131 |- """ - 129 |+ """Wrong.""" -132 130 | -133 131 | -134 132 | @expect('D201: No blank lines allowed before function docstring (found 1)') - -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 | | -599 | | Wrong.""" - | |_____________^ D200 - | - = help: Reformat to one line - -ℹ Suggested fix -594 594 | '(found 3)') -595 595 | @expect('D212: Multi-line docstring summary should start at the first line') -596 596 | def one_liner(): -597 |- """ -598 |- -599 |- Wrong.""" - 597 |+ """Wrong.""" -600 598 | -601 599 | -602 600 | @expect('D200: One-line docstring should fit on one line with quotes ' - -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 | | -608 | | """ - | |_______^ D200 - | - = help: Reformat to one line - -ℹ Suggested fix -603 603 | '(found 3)') -604 604 | @expect('D212: Multi-line docstring summary should start at the first line') -605 605 | def one_liner(): -606 |- r"""Wrong. -607 |- -608 |- """ - 606 |+ r"""Wrong.""" -609 607 | -610 608 | -611 609 | @expect('D200: One-line docstring should fit on one line with quotes ' - -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 | | -617 | | """ - | |_______^ D200 - | - = help: Reformat to one line - -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 | | -626 | | "Wrong.""" - | |______________^ D200 - | - = help: Reformat to 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 | "\ - | _____^ -646 | | " - | |_____^ D200 -647 | -648 | class StatementOnSameLineAsDocstring: - | - = help: Reformat to one line - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D200_D200.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D200_D200.py.snap deleted file mode 100644 index d810136599..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D200_D200.py.snap +++ /dev/null @@ -1,45 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D200.py:2:5: D200 One-line docstring should fit on one line - | -1 | def func(): -2 | """\ - | _____^ -3 | | """ - | |_______^ D200 - | - = help: Reformat to one line - -D200.py:7:5: D200 [*] One-line docstring should fit on one line - | -6 | def func(): -7 | """\\ - | _____^ -8 | | """ - | |_______^ D200 - | - = help: Reformat to one line - -ℹ Suggested fix -4 4 | -5 5 | -6 6 | def func(): -7 |- """\\ -8 |- """ - 7 |+ """\\""" -9 8 | -10 9 | -11 10 | def func(): - -D200.py:12:5: D200 One-line docstring should fit on one line - | -11 | def func(): -12 | """\ \ - | _____^ -13 | | """ - | |_______^ D200 - | - = help: Reformat to one line - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D201_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D201_D.py.snap deleted file mode 100644 index 9f8287aa46..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D201_D.py.snap +++ /dev/null @@ -1,88 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:137:5: D201 [*] No blank lines allowed before function docstring (found 1) - | -135 | def leading_space(): -136 | -137 | """Leading space.""" - | ^^^^^^^^^^^^^^^^^^^^ D201 - | - = help: Remove blank line(s) before function docstring - -ℹ Fix -133 133 | -134 134 | @expect('D201: No blank lines allowed before function docstring (found 1)') -135 135 | def leading_space(): -136 |- -137 136 | """Leading space.""" -138 137 | -139 138 | - -D.py:151:5: D201 [*] No blank lines allowed before function docstring (found 1) - | -149 | def trailing_and_leading_space(): -150 | -151 | """Trailing and leading space.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D201 -152 | -153 | pass - | - = help: Remove blank line(s) before function docstring - -ℹ Fix -147 147 | @expect('D201: No blank lines allowed before function docstring (found 1)') -148 148 | @expect('D202: No blank lines allowed after function docstring (found 1)') -149 149 | def trailing_and_leading_space(): -150 |- -151 150 | """Trailing and leading space.""" -152 151 | -153 152 | pass - -D.py:546:5: D201 [*] No blank lines allowed before function docstring (found 1) - | -544 | def multiline_leading_space(): -545 | -546 | """Leading space. - | _____^ -547 | | -548 | | More content. -549 | | """ - | |_______^ D201 - | - = help: Remove blank line(s) before function docstring - -ℹ Fix -542 542 | @expect('D201: No blank lines allowed before function docstring (found 1)') -543 543 | @expect('D213: Multi-line docstring summary should start at the second line') -544 544 | def multiline_leading_space(): -545 |- -546 545 | """Leading space. -547 546 | -548 547 | More content. - -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 | | -570 | | More content. -571 | | """ - | |_______^ D201 -572 | -573 | pass - | - = help: Remove blank line(s) before function docstring - -ℹ Fix -564 564 | @expect('D202: No blank lines allowed after function docstring (found 1)') -565 565 | @expect('D213: Multi-line docstring summary should start at the second line') -566 566 | def multiline_trailing_and_leading_space(): -567 |- -568 567 | """Trailing and leading space. -569 568 | -570 569 | More content. - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D202_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D202_D.py.snap deleted file mode 100644 index e620ddc640..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D202_D.py.snap +++ /dev/null @@ -1,92 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:142:5: D202 [*] No blank lines allowed after function docstring (found 1) - | -140 | @expect('D202: No blank lines allowed after function docstring (found 1)') -141 | def trailing_space(): -142 | """Leading space.""" - | ^^^^^^^^^^^^^^^^^^^^ D202 -143 | -144 | pass - | - = help: Remove blank line(s) after function docstring - -ℹ Fix -140 140 | @expect('D202: No blank lines allowed after function docstring (found 1)') -141 141 | def trailing_space(): -142 142 | """Leading space.""" -143 |- -144 143 | pass -145 144 | -146 145 | - -D.py:151:5: D202 [*] No blank lines allowed after function docstring (found 1) - | -149 | def trailing_and_leading_space(): -150 | -151 | """Trailing and leading space.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D202 -152 | -153 | pass - | - = help: Remove blank line(s) after function docstring - -ℹ Fix -149 149 | def trailing_and_leading_space(): -150 150 | -151 151 | """Trailing and leading space.""" -152 |- -153 152 | pass -154 153 | -155 154 | - -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 | | -557 | | More content. -558 | | """ - | |_______^ D202 -559 | -560 | pass - | - = help: Remove blank line(s) after function docstring - -ℹ Fix -556 556 | -557 557 | More content. -558 558 | """ -559 |- -560 559 | pass -561 560 | -562 561 | - -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 | | -570 | | More content. -571 | | """ - | |_______^ D202 -572 | -573 | pass - | - = help: Remove blank line(s) after function docstring - -ℹ Fix -569 569 | -570 570 | More content. -571 571 | """ -572 |- -573 572 | pass -574 573 | -575 574 | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D202_D202.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D202_D202.py.snap deleted file mode 100644 index b05850ca5c..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D202_D202.py.snap +++ /dev/null @@ -1,62 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D202.py:57:5: D202 [*] No blank lines allowed after function docstring (found 2) - | -55 | # D202 -56 | def outer(): -57 | """This is a docstring.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ D202 - | - = help: Remove blank line(s) after function docstring - -ℹ Fix -55 55 | # D202 -56 56 | def outer(): -57 57 | """This is a docstring.""" -58 |- -59 |- -60 58 | def inner(): -61 59 | return -62 60 | - -D202.py:68:5: D202 [*] No blank lines allowed after function docstring (found 2) - | -66 | # D202 -67 | def outer(): -68 | """This is a docstring.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ D202 - | - = help: Remove blank line(s) after function docstring - -ℹ Fix -66 66 | # D202 -67 67 | def outer(): -68 68 | """This is a docstring.""" -69 |- -70 |- -71 69 | # This is a comment. -72 70 | def inner(): -73 71 | return - -D202.py:80:5: D202 [*] No blank lines allowed after function docstring (found 1) - | -78 | # D202 -79 | def outer(): -80 | """This is a docstring.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ D202 -81 | -82 | # This is a comment. - | - = help: Remove blank line(s) after function docstring - -ℹ Fix -78 78 | # D202 -79 79 | def outer(): -80 80 | """This is a docstring.""" -81 |- -82 81 | # This is a comment. -83 82 | -84 83 | def inner(): - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D203_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D203_D.py.snap deleted file mode 100644 index 214a5f0424..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D203_D.py.snap +++ /dev/null @@ -1,121 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:161:5: D203 [*] 1 blank line required before class docstring - | -160 | class LeadingSpaceMissing: -161 | """Leading space missing.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D203 - | - = help: Insert 1 blank line before class docstring - -ℹ Fix -158 158 | -159 159 | -160 160 | class LeadingSpaceMissing: - 161 |+ -161 162 | """Leading space missing.""" -162 163 | -163 164 | - -D.py:192:5: D203 [*] 1 blank line required before class docstring - | -191 | class LeadingAndTrailingSpaceMissing: -192 | """Leading and trailing space missing.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D203 -193 | pass - | - = help: Insert 1 blank line before class docstring - -ℹ Fix -189 189 | -190 190 | -191 191 | class LeadingAndTrailingSpaceMissing: - 192 |+ -192 193 | """Leading and trailing space missing.""" -193 194 | pass -194 195 | - -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 | | -528 | | Parameters -529 | | ---------- -530 | | x : int -531 | | -532 | | """ - | |_______^ D203 -533 | -534 | def __init__(self, x): - | - = help: Insert 1 blank line before class docstring - -ℹ Fix -523 523 | # This is reproducing a bug where AttributeError is raised when parsing class -524 524 | # parameters as functions for Google / Numpy conventions. -525 525 | class Blah: # noqa: D203,D213 - 526 |+ -526 527 | """A Blah. -527 528 | -528 529 | Parameters - -D.py:649:5: D203 [*] 1 blank line required before class docstring - | -648 | class StatementOnSameLineAsDocstring: -649 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D203 -650 | def sort_services(self): -651 | pass - | - = help: Insert 1 blank line before class docstring - -ℹ Fix -646 646 | " -647 647 | -648 648 | class StatementOnSameLineAsDocstring: - 649 |+ -649 650 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 -650 651 | def sort_services(self): -651 652 | pass - -D.py:654:5: D203 [*] 1 blank line required before class docstring - | -653 | class StatementOnSameLineAsDocstring: -654 | "After this docstring there's another statement on the same line separated by a semicolon."; priorities=1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D203 - | - = help: Insert 1 blank line before class docstring - -ℹ Fix -651 651 | pass -652 652 | -653 653 | class StatementOnSameLineAsDocstring: - 654 |+ -654 655 | "After this docstring there's another statement on the same line separated by a semicolon."; priorities=1 -655 656 | -656 657 | - -D.py:658:5: D203 [*] 1 blank line required before class docstring - | -657 | class CommentAfterDocstring: -658 | "After this docstring there's a comment." # priorities=1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D203 -659 | def sort_services(self): -660 | pass - | - = help: Insert 1 blank line before class docstring - -ℹ Fix -655 655 | -656 656 | -657 657 | class CommentAfterDocstring: - 658 |+ -658 659 | "After this docstring there's a comment." # priorities=1 -659 660 | def sort_services(self): -660 661 | pass - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D204_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D204_D.py.snap deleted file mode 100644 index a2db13ef2a..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D204_D.py.snap +++ /dev/null @@ -1,102 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:181:5: D204 [*] 1 blank line required after class docstring - | -179 | class TrailingSpace: -180 | -181 | """TrailingSpace.""" - | ^^^^^^^^^^^^^^^^^^^^ D204 -182 | pass - | - = help: Insert 1 blank line after class docstring - -ℹ Fix -179 179 | class TrailingSpace: -180 180 | -181 181 | """TrailingSpace.""" - 182 |+ -182 183 | pass -183 184 | -184 185 | - -D.py:192:5: D204 [*] 1 blank line required after class docstring - | -191 | class LeadingAndTrailingSpaceMissing: -192 | """Leading and trailing space missing.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D204 -193 | pass - | - = help: Insert 1 blank line after class docstring - -ℹ Fix -190 190 | -191 191 | class LeadingAndTrailingSpaceMissing: -192 192 | """Leading and trailing space missing.""" - 193 |+ -193 194 | pass -194 195 | -195 196 | - -D.py:649:5: D204 [*] 1 blank line required after class docstring - | -648 | class StatementOnSameLineAsDocstring: -649 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D204 -650 | def sort_services(self): -651 | pass - | - = help: Insert 1 blank line after class docstring - -ℹ Fix -646 646 | " -647 647 | -648 648 | class StatementOnSameLineAsDocstring: -649 |- "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 - 649 |+ "After this docstring there's another statement on the same line separated by a semicolon." - 650 |+ - 651 |+ priorities=1 -650 652 | def sort_services(self): -651 653 | pass -652 654 | - -D.py:654:5: D204 [*] 1 blank line required after class docstring - | -653 | class StatementOnSameLineAsDocstring: -654 | "After this docstring there's another statement on the same line separated by a semicolon."; priorities=1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D204 - | - = help: Insert 1 blank line after class docstring - -ℹ Fix -651 651 | pass -652 652 | -653 653 | class StatementOnSameLineAsDocstring: -654 |- "After this docstring there's another statement on the same line separated by a semicolon."; priorities=1 - 654 |+ "After this docstring there's another statement on the same line separated by a semicolon." - 655 |+ - 656 |+ priorities=1 -655 657 | -656 658 | -657 659 | class CommentAfterDocstring: - -D.py:658:5: D204 [*] 1 blank line required after class docstring - | -657 | class CommentAfterDocstring: -658 | "After this docstring there's a comment." # priorities=1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D204 -659 | def sort_services(self): -660 | pass - | - = help: Insert 1 blank line after class docstring - -ℹ Fix -656 656 | -657 657 | class CommentAfterDocstring: -658 658 | "After this docstring there's a comment." # priorities=1 - 659 |+ -659 660 | def sort_services(self): -660 661 | pass -661 662 | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D205_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D205_D.py.snap deleted file mode 100644 index 266342bb41..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D205_D.py.snap +++ /dev/null @@ -1,41 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -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. - | _____^ -201 | | Description. -202 | | -203 | | """ - | |_______^ D205 - | - = help: Insert single blank line - -D.py:210:5: D205 [*] 1 blank line required between summary line and description (found 2) - | -208 | @expect('D213: Multi-line docstring summary should start at the second line') -209 | def multi_line_two_separating_blanks(): -210 | """Summary. - | _____^ -211 | | -212 | | -213 | | Description. -214 | | -215 | | """ - | |_______^ D205 - | - = help: Insert single blank line - -ℹ Fix -209 209 | def multi_line_two_separating_blanks(): -210 210 | """Summary. -211 211 | -212 |- -213 212 | Description. -214 213 | -215 214 | """ - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D206_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D206_D.py.snap deleted file mode 100644 index 89dabd861c..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D206_D.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D207_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D207_D.py.snap deleted file mode 100644 index 9c86c51d99..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D207_D.py.snap +++ /dev/null @@ -1,82 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:232:1: D207 [*] Docstring is under-indented - | -230 | """Summary. -231 | -232 | Description. - | D207 -233 | -234 | """ - | - = help: Increase indentation - -ℹ Fix -229 229 | def asdfsdf(): -230 230 | """Summary. -231 231 | -232 |-Description. - 232 |+ Description. -233 233 | -234 234 | """ -235 235 | - -D.py:244:1: D207 [*] Docstring is under-indented - | -242 | Description. -243 | -244 | """ - | D207 - | - = help: Increase indentation - -ℹ Fix -241 241 | -242 242 | Description. -243 243 | -244 |-""" - 244 |+ """ -245 245 | -246 246 | -247 247 | @expect('D208: Docstring is over-indented') - -D.py:440:1: D207 [*] Docstring is under-indented - | -438 | def docstring_start_in_same_line(): """First Line. -439 | -440 | Second Line - | D207 -441 | """ - | - = help: Increase indentation - -ℹ Fix -437 437 | @expect('D213: Multi-line docstring summary should start at the second line') -438 438 | def docstring_start_in_same_line(): """First Line. -439 439 | -440 |- Second Line - 440 |+ Second Line -441 441 | """ -442 442 | -443 443 | - -D.py:441:1: D207 [*] Docstring is under-indented - | -440 | Second Line -441 | """ - | D207 - | - = help: Increase indentation - -ℹ Fix -438 438 | def docstring_start_in_same_line(): """First Line. -439 439 | -440 440 | Second Line -441 |- """ - 441 |+ """ -442 442 | -443 443 | -444 444 | def function_with_lambda_arg(x=lambda y: y): - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D208_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D208_D.py.snap deleted file mode 100644 index 7fe7b24f84..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D208_D.py.snap +++ /dev/null @@ -1,65 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:252:1: D208 [*] Docstring is over-indented - | -250 | """Summary. -251 | -252 | Description. - | D208 -253 | -254 | """ - | - = help: Remove over-indentation - -ℹ Fix -249 249 | def asdfsdsdf24(): -250 250 | """Summary. -251 251 | -252 |- Description. - 252 |+ Description. -253 253 | -254 254 | """ -255 255 | - -D.py:264:1: D208 [*] Docstring is over-indented - | -262 | Description. -263 | -264 | """ - | D208 - | - = help: Remove over-indentation - -ℹ Fix -261 261 | -262 262 | Description. -263 263 | -264 |- """ - 264 |+ """ -265 265 | -266 266 | -267 267 | @expect('D208: Docstring is over-indented') - -D.py:272:1: D208 [*] Docstring is over-indented - | -270 | """Summary. -271 | -272 | Description. - | D208 -273 | -274 | """ - | - = help: Remove over-indentation - -ℹ Fix -269 269 | def asdfsdfsdsdsdfsdf24(): -270 270 | """Summary. -271 271 | -272 |- Description. - 272 |+ Description. -273 273 | -274 274 | """ -275 275 | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D209_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D209_D.py.snap deleted file mode 100644 index 01e3838be0..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D209_D.py.snap +++ /dev/null @@ -1,50 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -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 | | -283 | | Description.""" - | |___________________^ D209 - | - = help: Move closing quotes to new line - -ℹ Fix -280 280 | def asdfljdf24(): -281 281 | """Summary. -282 282 | -283 |- Description.""" - 283 |+ Description. - 284 |+ """ -284 285 | -285 286 | -286 287 | @expect('D210: No whitespaces allowed surrounding docstring text') - -D.py:588:5: D209 [*] Multi-line docstring closing quotes should be on a separate line - | -586 | @expect('D213: Multi-line docstring summary should start at the second line') -587 | def asdfljdjgf24(): -588 | """Summary. - | _____^ -589 | | -590 | | Description. """ - | |_____________________^ D209 - | - = help: Move closing quotes to new line - -ℹ Fix -587 587 | def asdfljdjgf24(): -588 588 | """Summary. -589 589 | -590 |- Description. """ - 590 |+ Description. - 591 |+ """ -591 592 | -592 593 | -593 594 | @expect('D200: One-line docstring should fit on one line with quotes ' - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D210_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D210_D.py.snap deleted file mode 100644 index 8e3a805a4d..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D210_D.py.snap +++ /dev/null @@ -1,74 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:288:5: D210 [*] No whitespaces allowed surrounding docstring text - | -286 | @expect('D210: No whitespaces allowed surrounding docstring text') -287 | def endswith(): -288 | """Whitespace at the end. """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D210 - | - = help: Trim surrounding whitespace - -ℹ Fix -285 285 | -286 286 | @expect('D210: No whitespaces allowed surrounding docstring text') -287 287 | def endswith(): -288 |- """Whitespace at the end. """ - 288 |+ """Whitespace at the end.""" -289 289 | -290 290 | -291 291 | @expect('D210: No whitespaces allowed surrounding docstring text') - -D.py:293:5: D210 [*] No whitespaces allowed surrounding docstring text - | -291 | @expect('D210: No whitespaces allowed surrounding docstring text') -292 | def around(): -293 | """ Whitespace at everywhere. """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D210 - | - = help: Trim surrounding whitespace - -ℹ Fix -290 290 | -291 291 | @expect('D210: No whitespaces allowed surrounding docstring text') -292 292 | def around(): -293 |- """ Whitespace at everywhere. """ - 293 |+ """Whitespace at everywhere.""" -294 294 | -295 295 | -296 296 | @expect('D210: No whitespaces allowed surrounding docstring text') - -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 | | -301 | | This is the end. -302 | | """ - | |_______^ D210 - | - = help: Trim surrounding whitespace - -ℹ Fix -296 296 | @expect('D210: No whitespaces allowed surrounding docstring text') -297 297 | @expect('D213: Multi-line docstring summary should start at the second line') -298 298 | def multiline(): -299 |- """ Whitespace at the beginning. - 299 |+ """Whitespace at the beginning. -300 300 | -301 301 | This is the end. -302 302 | """ - -D.py:581:5: D210 No whitespaces allowed surrounding docstring text - | -579 | "or exclamation point (not '\"')") -580 | def endswith_quote(): -581 | """Whitespace at the end, but also a quote" """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D210 - | - = help: Trim surrounding whitespace - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D211_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D211_D.py.snap deleted file mode 100644 index 729ea91914..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D211_D.py.snap +++ /dev/null @@ -1,41 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:170:5: D211 [*] No blank lines allowed before class docstring - | -168 | class WithLeadingSpace: -169 | -170 | """With leading space.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^ D211 - | - = help: Remove blank line(s) before class docstring - -ℹ Fix -166 166 | -167 167 | -168 168 | class WithLeadingSpace: -169 |- -170 169 | """With leading space.""" -171 170 | -172 171 | - -D.py:181:5: D211 [*] No blank lines allowed before class docstring - | -179 | class TrailingSpace: -180 | -181 | """TrailingSpace.""" - | ^^^^^^^^^^^^^^^^^^^^ D211 -182 | pass - | - = help: Remove blank line(s) before class docstring - -ℹ Fix -177 177 | -178 178 | -179 179 | class TrailingSpace: -180 |- -181 180 | """TrailingSpace.""" -182 181 | pass -183 182 | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D212_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D212_D.py.snap deleted file mode 100644 index 5d2ea74fd8..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D212_D.py.snap +++ /dev/null @@ -1,75 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -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 | """ - | _____^ -130 | | Wrong. -131 | | """ - | |_______^ D212 - | - = help: Remove whitespace after opening quotes - -ℹ Fix -126 126 | '(found 3)') -127 127 | @expect('D212: Multi-line docstring summary should start at the first line') -128 128 | def asdlkfasd(): -129 |- """ -130 |- Wrong. - 129 |+ """Wrong. -131 130 | """ -132 131 | -133 132 | - -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 | | -599 | | Wrong.""" - | |_____________^ D212 - | - = help: Remove whitespace after opening quotes - -ℹ Fix -594 594 | '(found 3)') -595 595 | @expect('D212: Multi-line docstring summary should start at the first line') -596 596 | def one_liner(): -597 |- """ -598 |- -599 |- Wrong.""" - 597 |+ """Wrong.""" -600 598 | -601 599 | -602 600 | @expect('D200: One-line docstring should fit on one line with quotes ' - -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 | | -626 | | "Wrong.""" - | |______________^ D212 - | - = help: Remove whitespace after opening quotes - -ℹ Fix -621 621 | '(found 3)') -622 622 | @expect('D212: Multi-line docstring summary should start at the first line') -623 623 | def one_liner(): -624 |- """ -625 |- -626 |- "Wrong.""" - 624 |+ """"Wrong.""" -627 625 | -628 626 | -629 627 | @expect('D404: First word of the docstring should not be "This"') - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D213_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D213_D.py.snap deleted file mode 100644 index 070f70b2c8..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D213_D.py.snap +++ /dev/null @@ -1,550 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -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. - | _____^ -201 | | Description. -202 | | -203 | | """ - | |_______^ D213 - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -197 197 | '(found 0)') -198 198 | @expect('D213: Multi-line docstring summary should start at the second line') -199 199 | def multi_line_zero_separating_blanks(): -200 |- """Summary. - 200 |+ """ - 201 |+ Summary. -201 202 | Description. -202 203 | -203 204 | """ - -D.py:210:5: D213 [*] Multi-line docstring summary should start at the second line - | -208 | @expect('D213: Multi-line docstring summary should start at the second line') -209 | def multi_line_two_separating_blanks(): -210 | """Summary. - | _____^ -211 | | -212 | | -213 | | Description. -214 | | -215 | | """ - | |_______^ D213 - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -207 207 | '(found 2)') -208 208 | @expect('D213: Multi-line docstring summary should start at the second line') -209 209 | def multi_line_two_separating_blanks(): -210 |- """Summary. - 210 |+ """ - 211 |+ Summary. -211 212 | -212 213 | -213 214 | Description. - -D.py:220:5: D213 [*] Multi-line docstring summary should start at the second line - | -218 | @expect('D213: Multi-line docstring summary should start at the second line') -219 | def multi_line_one_separating_blanks(): -220 | """Summary. - | _____^ -221 | | -222 | | Description. -223 | | -224 | | """ - | |_______^ D213 - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -217 217 | -218 218 | @expect('D213: Multi-line docstring summary should start at the second line') -219 219 | def multi_line_one_separating_blanks(): -220 |- """Summary. - 220 |+ """ - 221 |+ Summary. -221 222 | -222 223 | Description. -223 224 | - -D.py:230:5: D213 [*] Multi-line docstring summary should start at the second line - | -228 | @expect('D213: Multi-line docstring summary should start at the second line') -229 | def asdfsdf(): -230 | """Summary. - | _____^ -231 | | -232 | | Description. -233 | | -234 | | """ - | |_______^ D213 - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -227 227 | @expect('D207: Docstring is under-indented') -228 228 | @expect('D213: Multi-line docstring summary should start at the second line') -229 229 | def asdfsdf(): -230 |- """Summary. - 230 |+ """ - 231 |+ Summary. -231 232 | -232 233 | Description. -233 234 | - -D.py:240:5: D213 [*] Multi-line docstring summary should start at the second line - | -238 | @expect('D213: Multi-line docstring summary should start at the second line') -239 | def asdsdfsdffsdf(): -240 | """Summary. - | _____^ -241 | | -242 | | Description. -243 | | -244 | | """ - | |___^ D213 - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -237 237 | @expect('D207: Docstring is under-indented') -238 238 | @expect('D213: Multi-line docstring summary should start at the second line') -239 239 | def asdsdfsdffsdf(): -240 |- """Summary. - 240 |+ """ - 241 |+ Summary. -241 242 | -242 243 | Description. -243 244 | - -D.py:250:5: D213 [*] Multi-line docstring summary should start at the second line - | -248 | @expect('D213: Multi-line docstring summary should start at the second line') -249 | def asdfsdsdf24(): -250 | """Summary. - | _____^ -251 | | -252 | | Description. -253 | | -254 | | """ - | |_______^ D213 - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -247 247 | @expect('D208: Docstring is over-indented') -248 248 | @expect('D213: Multi-line docstring summary should start at the second line') -249 249 | def asdfsdsdf24(): -250 |- """Summary. - 250 |+ """ - 251 |+ Summary. -251 252 | -252 253 | Description. -253 254 | - -D.py:260:5: D213 [*] Multi-line docstring summary should start at the second line - | -258 | @expect('D213: Multi-line docstring summary should start at the second line') -259 | def asdfsdsdfsdf24(): -260 | """Summary. - | _____^ -261 | | -262 | | Description. -263 | | -264 | | """ - | |___________^ D213 - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -257 257 | @expect('D208: Docstring is over-indented') -258 258 | @expect('D213: Multi-line docstring summary should start at the second line') -259 259 | def asdfsdsdfsdf24(): -260 |- """Summary. - 260 |+ """ - 261 |+ Summary. -261 262 | -262 263 | Description. -263 264 | - -D.py:270:5: D213 [*] Multi-line docstring summary should start at the second line - | -268 | @expect('D213: Multi-line docstring summary should start at the second line') -269 | def asdfsdfsdsdsdfsdf24(): -270 | """Summary. - | _____^ -271 | | -272 | | Description. -273 | | -274 | | """ - | |_______^ D213 - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -267 267 | @expect('D208: Docstring is over-indented') -268 268 | @expect('D213: Multi-line docstring summary should start at the second line') -269 269 | def asdfsdfsdsdsdfsdf24(): -270 |- """Summary. - 270 |+ """ - 271 |+ Summary. -271 272 | -272 273 | Description. -273 274 | - -D.py:281:5: D213 [*] Multi-line docstring summary should start at the second line - | -279 | @expect('D213: Multi-line docstring summary should start at the second line') -280 | def asdfljdf24(): -281 | """Summary. - | _____^ -282 | | -283 | | Description.""" - | |___________________^ D213 - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -278 278 | 'line') -279 279 | @expect('D213: Multi-line docstring summary should start at the second line') -280 280 | def asdfljdf24(): -281 |- """Summary. - 281 |+ """ - 282 |+ Summary. -282 283 | -283 284 | Description.""" -284 285 | - -D.py:299:5: D213 [*] Multi-line docstring summary should start at the second line - | -297 | @expect('D213: Multi-line docstring summary should start at the second line') -298 | def multiline(): -299 | """ Whitespace at the beginning. - | _____^ -300 | | -301 | | This is the end. -302 | | """ - | |_______^ D213 - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -296 296 | @expect('D210: No whitespaces allowed surrounding docstring text') -297 297 | @expect('D213: Multi-line docstring summary should start at the second line') -298 298 | def multiline(): -299 |- """ Whitespace at the beginning. - 299 |+ """ - 300 |+ Whitespace at the beginning. -300 301 | -301 302 | This is the end. -302 303 | """ - -D.py:343:5: D213 [*] Multi-line docstring summary should start at the second line - | -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 | | -345 | | In particular, line continuations \ -346 | | and unicode literals \u0394 and \N{GREEK CAPITAL LETTER DELTA}. -347 | | They are considered to be intentionally unescaped. -348 | | """ - | |_______^ D213 - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -340 340 | -341 341 | @expect('D213: Multi-line docstring summary should start at the second line') -342 342 | def exceptions_of_D301(): -343 |- """Exclude some backslashes from D301. - 343 |+ """ - 344 |+ Exclude some backslashes from D301. -344 345 | -345 346 | In particular, line continuations \ -346 347 | and unicode literals \u0394 and \N{GREEK CAPITAL LETTER DELTA}. - -D.py:383:5: D213 [*] Multi-line docstring summary should start at the second line - | -381 | @expect('D213: Multi-line docstring summary should start at the second line') -382 | def new_209(): -383 | """First line. - | _____^ -384 | | -385 | | More lines. -386 | | """ - | |_______^ D213 -387 | pass - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -380 380 | -381 381 | @expect('D213: Multi-line docstring summary should start at the second line') -382 382 | def new_209(): -383 |- """First line. - 383 |+ """ - 384 |+ First line. -384 385 | -385 386 | More lines. -386 387 | """ - -D.py:392:5: D213 [*] Multi-line docstring summary should start at the second line - | -390 | @expect('D213: Multi-line docstring summary should start at the second line') -391 | def old_209(): -392 | """One liner. - | _____^ -393 | | -394 | | Multi-line comments. OK to have extra blank line -395 | | -396 | | """ - | |_______^ D213 - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -389 389 | -390 390 | @expect('D213: Multi-line docstring summary should start at the second line') -391 391 | def old_209(): -392 |- """One liner. - 392 |+ """ - 393 |+ One liner. -393 394 | -394 395 | Multi-line comments. OK to have extra blank line -395 396 | - -D.py:438:37: D213 [*] Multi-line docstring summary should start at the second line - | -436 | @expect("D207: Docstring is under-indented") -437 | @expect('D213: Multi-line docstring summary should start at the second line') -438 | def docstring_start_in_same_line(): """First Line. - | _____________________________________^ -439 | | -440 | | Second Line -441 | | """ - | |_______^ D213 - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -435 435 | -436 436 | @expect("D207: Docstring is under-indented") -437 437 | @expect('D213: Multi-line docstring summary should start at the second line') -438 |-def docstring_start_in_same_line(): """First Line. - 438 |+def docstring_start_in_same_line(): """ - 439 |+ First Line. -439 440 | -440 441 | Second Line -441 442 | """ - -D.py:450:5: D213 [*] Multi-line docstring summary should start at the second line - | -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 | | -452 | | The assertion was caused in the next function, so this one is necessary. -453 | | -454 | | """ - | |_______^ D213 - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -447 447 | -448 448 | @expect('D213: Multi-line docstring summary should start at the second line') -449 449 | def a_following_valid_function(x=None): -450 |- """Check for a bug where the previous function caused an assertion. - 450 |+ """ - 451 |+ Check for a bug where the previous function caused an assertion. -451 452 | -452 453 | The assertion was caused in the next function, so this one is necessary. -453 454 | - -D.py:526:5: D213 [*] Multi-line docstring summary should start at the second line - | -524 | # parameters as functions for Google / Numpy conventions. -525 | class Blah: # noqa: D203,D213 -526 | """A Blah. - | _____^ -527 | | -528 | | Parameters -529 | | ---------- -530 | | x : int -531 | | -532 | | """ - | |_______^ D213 -533 | -534 | def __init__(self, x): - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -523 523 | # This is reproducing a bug where AttributeError is raised when parsing class -524 524 | # parameters as functions for Google / Numpy conventions. -525 525 | class Blah: # noqa: D203,D213 -526 |- """A Blah. - 526 |+ """ - 527 |+ A Blah. -527 528 | -528 529 | Parameters -529 530 | ---------- - -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 | | -548 | | More content. -549 | | """ - | |_______^ D213 - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -543 543 | @expect('D213: Multi-line docstring summary should start at the second line') -544 544 | def multiline_leading_space(): -545 545 | -546 |- """Leading space. - 546 |+ """ - 547 |+ Leading space. -547 548 | -548 549 | More content. -549 550 | """ - -D.py:555:5: D213 [*] Multi-line docstring summary should start at the second line - | -553 | @expect('D213: Multi-line docstring summary should start at the second line') -554 | def multiline_trailing_space(): -555 | """Leading space. - | _____^ -556 | | -557 | | More content. -558 | | """ - | |_______^ D213 -559 | -560 | pass - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -552 552 | @expect('D202: No blank lines allowed after function docstring (found 1)') -553 553 | @expect('D213: Multi-line docstring summary should start at the second line') -554 554 | def multiline_trailing_space(): -555 |- """Leading space. - 555 |+ """ - 556 |+ Leading space. -556 557 | -557 558 | More content. -558 559 | """ - -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 | | -570 | | More content. -571 | | """ - | |_______^ D213 -572 | -573 | pass - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -565 565 | @expect('D213: Multi-line docstring summary should start at the second line') -566 566 | def multiline_trailing_and_leading_space(): -567 567 | -568 |- """Trailing and leading space. - 568 |+ """ - 569 |+ Trailing and leading space. -569 570 | -570 571 | More content. -571 572 | """ - -D.py:588:5: D213 [*] Multi-line docstring summary should start at the second line - | -586 | @expect('D213: Multi-line docstring summary should start at the second line') -587 | def asdfljdjgf24(): -588 | """Summary. - | _____^ -589 | | -590 | | Description. """ - | |_____________________^ D213 - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -585 585 | 'line') -586 586 | @expect('D213: Multi-line docstring summary should start at the second line') -587 587 | def asdfljdjgf24(): -588 |- """Summary. - 588 |+ """ - 589 |+ Summary. -589 590 | -590 591 | Description. """ -591 592 | - -D.py:606:5: D213 [*] Multi-line docstring summary should start at the second line - | -604 | @expect('D212: Multi-line docstring summary should start at the first line') -605 | def one_liner(): -606 | r"""Wrong. - | _____^ -607 | | -608 | | """ - | |_______^ D213 - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -603 603 | '(found 3)') -604 604 | @expect('D212: Multi-line docstring summary should start at the first line') -605 605 | def one_liner(): -606 |- r"""Wrong. - 606 |+ r""" - 607 |+ Wrong. -607 608 | -608 609 | """ -609 610 | - -D.py:615:5: D213 [*] Multi-line docstring summary should start at the second line - | -613 | @expect('D212: Multi-line docstring summary should start at the first line') -614 | def one_liner(): -615 | """Wrong." - | _____^ -616 | | -617 | | """ - | |_______^ D213 - | - = help: Insert line break and indentation after opening quotes - -ℹ Fix -612 612 | '(found 3)') -613 613 | @expect('D212: Multi-line docstring summary should start at the first line') -614 614 | def one_liner(): -615 |- """Wrong." - 615 |+ """ - 616 |+ Wrong." -616 617 | -617 618 | """ -618 619 | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D214_D214_module.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D214_D214_module.py.snap deleted file mode 100644 index be8ef02628..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D214_D214_module.py.snap +++ /dev/null @@ -1,59 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D214_module.py:1:1: D214 [*] Section is over-indented ("Returns") - | - 1 | / """A module docstring with D214 violations - 2 | | - 3 | | Returns - 4 | | ----- - 5 | | valid returns - 6 | | - 7 | | Args - 8 | | ----- - 9 | | valid args -10 | | """ - | |___^ D214 -11 | -12 | import os - | - = help: Remove over-indentation from "Returns" - -ℹ Fix -1 1 | """A module docstring with D214 violations -2 2 | -3 |- Returns - 3 |+Returns -4 4 | ----- -5 5 | valid returns -6 6 | - -D214_module.py:1:1: D214 [*] Section is over-indented ("Args") - | - 1 | / """A module docstring with D214 violations - 2 | | - 3 | | Returns - 4 | | ----- - 5 | | valid returns - 6 | | - 7 | | Args - 8 | | ----- - 9 | | valid args -10 | | """ - | |___^ D214 -11 | -12 | import os - | - = help: Remove over-indentation from "Args" - -ℹ Fix -4 4 | ----- -5 5 | valid returns -6 6 | -7 |- Args - 7 |+Args -8 8 | ----- -9 9 | valid args -10 10 | """ - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D214_sections.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D214_sections.py.snap deleted file mode 100644 index a1395220a6..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D214_sections.py.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -sections.py:144:5: D214 [*] Section is over-indented ("Returns") - | -142 | @expect("D214: Section is over-indented ('Returns')") -143 | def section_overindented(): # noqa: D416 -144 | """Toggle the gizmo. - | _____^ -145 | | -146 | | Returns -147 | | ------- -148 | | A value of some sort. -149 | | -150 | | """ - | |_______^ D214 - | - = help: Remove over-indentation from "Returns" - -ℹ Fix -143 143 | def section_overindented(): # noqa: D416 -144 144 | """Toggle the gizmo. -145 145 | -146 |- Returns - 146 |+ Returns -147 147 | ------- -148 148 | A value of some sort. -149 149 | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D215_sections.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D215_sections.py.snap deleted file mode 100644 index 4c99c69a03..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D215_sections.py.snap +++ /dev/null @@ -1,54 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -sections.py:156:5: D215 [*] Section underline is over-indented ("Returns") - | -154 | @expect("D215: Section underline is over-indented (in section 'Returns')") -155 | def section_underline_overindented(): # noqa: D416 -156 | """Toggle the gizmo. - | _____^ -157 | | -158 | | Returns -159 | | ------- -160 | | A value of some sort. -161 | | -162 | | """ - | |_______^ D215 - | - = help: Remove over-indentation from "Returns" underline - -ℹ Fix -156 156 | """Toggle the gizmo. -157 157 | -158 158 | Returns -159 |- ------- - 159 |+ ------ -160 160 | A value of some sort. -161 161 | -162 162 | """ - -sections.py:170:5: D215 [*] Section underline is over-indented ("Returns") - | -168 | @expect("D414: Section has no content ('Returns')") -169 | def section_underline_overindented_and_contentless(): # noqa: D416 -170 | """Toggle the gizmo. - | _____^ -171 | | -172 | | Returns -173 | | ------- -174 | | """ - | |_______^ D215 - | - = help: Remove over-indentation from "Returns" underline - -ℹ Fix -170 170 | """Toggle the gizmo. -171 171 | -172 172 | Returns -173 |- ------- - 173 |+ ------ -174 174 | """ -175 175 | -176 176 | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D300_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D300_D.py.snap deleted file mode 100644 index 502ad6d435..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D300_D.py.snap +++ /dev/null @@ -1,89 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:307:5: D300 Use triple double quotes `"""` - | -305 | @expect('D300: Use """triple double quotes""" (found \'\'\'-quotes)') -306 | def triple_single_quotes_raw(): -307 | r'''Summary.''' - | ^^^^^^^^^^^^^^^ D300 - | - -D.py:312:5: D300 Use triple double quotes `"""` - | -310 | @expect('D300: Use """triple double quotes""" (found \'\'\'-quotes)') -311 | def triple_single_quotes_raw_uppercase(): -312 | R'''Summary.''' - | ^^^^^^^^^^^^^^^ D300 - | - -D.py:317:5: D300 Use triple double quotes `"""` - | -315 | @expect('D300: Use """triple double quotes""" (found \'-quotes)') -316 | def single_quotes_raw(): -317 | r'Summary.' - | ^^^^^^^^^^^ D300 - | - -D.py:322:5: D300 Use triple double quotes `"""` - | -320 | @expect('D300: Use """triple double quotes""" (found \'-quotes)') -321 | def single_quotes_raw_uppercase(): -322 | R'Summary.' - | ^^^^^^^^^^^ D300 - | - -D.py:328:5: D300 Use triple double quotes `"""` - | -326 | @expect('D301: Use r""" if any backslashes in a docstring') -327 | def single_quotes_raw_uppercase_backslash(): -328 | R'Sum\mary.' - | ^^^^^^^^^^^^ D300 - | - -D.py:645:5: D300 Use triple double quotes `"""` - | -644 | def single_line_docstring_with_an_escaped_backslash(): -645 | "\ - | _____^ -646 | | " - | |_____^ D300 -647 | -648 | class StatementOnSameLineAsDocstring: - | - -D.py:649:5: D300 Use triple double quotes `"""` - | -648 | class StatementOnSameLineAsDocstring: -649 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D300 -650 | def sort_services(self): -651 | pass - | - -D.py:654:5: D300 Use triple double quotes `"""` - | -653 | class StatementOnSameLineAsDocstring: -654 | "After this docstring there's another statement on the same line separated by a semicolon."; priorities=1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D300 - | - -D.py:658:5: D300 Use triple double quotes `"""` - | -657 | class CommentAfterDocstring: -658 | "After this docstring there's a comment." # priorities=1 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D300 -659 | def sort_services(self): -660 | pass - | - -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 \ - | _____^ -665 | | but continuations shouldn't be considered multi-line" - | |_________________________________________________________^ D300 - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D301_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D301_D.py.snap deleted file mode 100644 index 2a018924e6..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D301_D.py.snap +++ /dev/null @@ -1,28 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:328:5: D301 Use `r"""` if any backslashes in a docstring - | -326 | @expect('D301: Use r""" if any backslashes in a docstring') -327 | def single_quotes_raw_uppercase_backslash(): -328 | R'Sum\mary.' - | ^^^^^^^^^^^^ D301 - | - -D.py:333:5: D301 Use `r"""` if any backslashes in a docstring - | -331 | @expect('D301: Use r""" if any backslashes in a docstring') -332 | def double_quotes_backslash(): -333 | """Sum\\mary.""" - | ^^^^^^^^^^^^^^^^ D301 - | - -D.py:338:5: D301 Use `r"""` if any backslashes in a docstring - | -336 | @expect('D301: Use r""" if any backslashes in a docstring') -337 | def double_quotes_backslash_uppercase(): -338 | R"""Sum\\mary.""" - | ^^^^^^^^^^^^^^^^^ D301 - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D301_D301.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D301_D301.py.snap deleted file mode 100644 index 9f8919505c..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D301_D301.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D301.py:2:5: D301 Use `r"""` if any backslashes in a docstring - | -1 | def double_quotes_backslash(): -2 | """Sum\\mary.""" - | ^^^^^^^^^^^^^^^^ D301 - | - -D301.py:10:5: D301 Use `r"""` if any backslashes in a docstring - | - 9 | def double_quotes_backslash_uppercase(): -10 | R"""Sum\\mary.""" - | ^^^^^^^^^^^^^^^^^ D301 - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D400_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D400_D.py.snap deleted file mode 100644 index 6c9ba058cb..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D400_D.py.snap +++ /dev/null @@ -1,330 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:355:5: D400 [*] First line should end with a period - | -353 | "or exclamation point (not 'y')") -354 | def lwnlkjl(): -355 | """Summary""" - | ^^^^^^^^^^^^^ D400 - | - = help: Add period - -ℹ Suggested fix -352 352 | @expect("D415: First line should end with a period, question mark, " -353 353 | "or exclamation point (not 'y')") -354 354 | def lwnlkjl(): -355 |- """Summary""" - 355 |+ """Summary.""" -356 356 | -357 357 | -358 358 | @expect("D401: First line should be in imperative mood " - -D.py:406:25: D400 [*] First line should end with a period - | -404 | @expect("D415: First line should end with a period, question mark," -405 | " or exclamation point (not 'r')") -406 | def oneliner_withdoc(): """One liner""" - | ^^^^^^^^^^^^^^^ D400 - | - = help: Add period - -ℹ Suggested fix -403 403 | @expect("D400: First line should end with a period (not 'r')") -404 404 | @expect("D415: First line should end with a period, question mark," -405 405 | " or exclamation point (not 'r')") -406 |-def oneliner_withdoc(): """One liner""" - 406 |+def oneliner_withdoc(): """One liner.""" -407 407 | -408 408 | -409 409 | def ignored_decorator(func): # noqa: D400,D401,D415 - -D.py:410:5: D400 [*] First line should end with a period - | -409 | def ignored_decorator(func): # noqa: D400,D401,D415 -410 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D400 -411 | func() -412 | pass - | - = help: Add period - -ℹ Suggested fix -407 407 | -408 408 | -409 409 | def ignored_decorator(func): # noqa: D400,D401,D415 -410 |- """Runs something""" - 410 |+ """Runs something.""" -411 411 | func() -412 412 | pass -413 413 | - -D.py:416:5: D400 [*] First line should end with a period - | -415 | def decorator_for_test(func): # noqa: D400,D401,D415 -416 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D400 -417 | func() -418 | pass - | - = help: Add period - -ℹ Suggested fix -413 413 | -414 414 | -415 415 | def decorator_for_test(func): # noqa: D400,D401,D415 -416 |- """Runs something""" - 416 |+ """Runs something.""" -417 417 | func() -418 418 | pass -419 419 | - -D.py:422:35: D400 [*] First line should end with a period - | -421 | @ignored_decorator -422 | def oneliner_ignored_decorator(): """One liner""" - | ^^^^^^^^^^^^^^^ D400 - | - = help: Add period - -ℹ Suggested fix -419 419 | -420 420 | -421 421 | @ignored_decorator -422 |-def oneliner_ignored_decorator(): """One liner""" - 422 |+def oneliner_ignored_decorator(): """One liner.""" -423 423 | -424 424 | -425 425 | @decorator_for_test - -D.py:429:49: D400 [*] First line should end with a period - | -427 | @expect("D415: First line should end with a period, question mark," -428 | " or exclamation point (not 'r')") -429 | def oneliner_with_decorator_expecting_errors(): """One liner""" - | ^^^^^^^^^^^^^^^ D400 - | - = help: Add period - -ℹ Suggested fix -426 426 | @expect("D400: First line should end with a period (not 'r')") -427 427 | @expect("D415: First line should end with a period, question mark," -428 428 | " or exclamation point (not 'r')") -429 |-def oneliner_with_decorator_expecting_errors(): """One liner""" - 429 |+def oneliner_with_decorator_expecting_errors(): """One liner.""" -430 430 | -431 431 | -432 432 | @decorator_for_test - -D.py:470:5: D400 [*] First line should end with a period - | -468 | "or exclamation point (not 'g')") -469 | def docstring_bad(): -470 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D400 -471 | pass - | - = help: Add period - -ℹ Suggested fix -467 467 | @expect("D415: First line should end with a period, question mark, " -468 468 | "or exclamation point (not 'g')") -469 469 | def docstring_bad(): -470 |- """Runs something""" - 470 |+ """Runs something.""" -471 471 | pass -472 472 | -473 473 | - -D.py:475:5: D400 [*] First line should end with a period - | -474 | def docstring_bad_ignore_all(): # noqa -475 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D400 -476 | pass - | - = help: Add period - -ℹ Suggested fix -472 472 | -473 473 | -474 474 | def docstring_bad_ignore_all(): # noqa -475 |- """Runs something""" - 475 |+ """Runs something.""" -476 476 | pass -477 477 | -478 478 | - -D.py:480:5: D400 [*] First line should end with a period - | -479 | def docstring_bad_ignore_one(): # noqa: D400,D401,D415 -480 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D400 -481 | pass - | - = help: Add period - -ℹ Suggested fix -477 477 | -478 478 | -479 479 | def docstring_bad_ignore_one(): # noqa: D400,D401,D415 -480 |- """Runs something""" - 480 |+ """Runs something.""" -481 481 | pass -482 482 | -483 483 | - -D.py:487:5: D400 [*] First line should end with a period - | -485 | "(perhaps 'Run', not 'Runs')") -486 | def docstring_ignore_some_violations_but_catch_D401(): # noqa: E501,D400,D415 -487 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D400 -488 | pass - | - = help: Add period - -ℹ Suggested fix -484 484 | @expect("D401: First line should be in imperative mood " -485 485 | "(perhaps 'Run', not 'Runs')") -486 486 | def docstring_ignore_some_violations_but_catch_D401(): # noqa: E501,D400,D415 -487 |- """Runs something""" - 487 |+ """Runs something.""" -488 488 | pass -489 489 | -490 490 | - -D.py:514:5: D400 [*] First line should end with a period - | -513 | def valid_google_string(): # noqa: D400 -514 | """Test a valid something!""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 - | - = help: Add period - -ℹ Suggested fix -511 511 | -512 512 | -513 513 | def valid_google_string(): # noqa: D400 -514 |- """Test a valid something!""" - 514 |+ """Test a valid something!.""" -515 515 | -516 516 | -517 517 | @expect("D415: First line should end with a period, question mark, " - -D.py:520:5: D400 [*] First line should end with a period - | -518 | "or exclamation point (not 'g')") -519 | def bad_google_string(): # noqa: D400 -520 | """Test a valid something""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 - | - = help: Add period - -ℹ Suggested fix -517 517 | @expect("D415: First line should end with a period, question mark, " -518 518 | "or exclamation point (not 'g')") -519 519 | def bad_google_string(): # noqa: D400 -520 |- """Test a valid something""" - 520 |+ """Test a valid something.""" -521 521 | -522 522 | -523 523 | # This is reproducing a bug where AttributeError is raised when parsing class - -D.py:581:5: D400 [*] First line should end with a period - | -579 | "or exclamation point (not '\"')") -580 | def endswith_quote(): -581 | """Whitespace at the end, but also a quote" """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 - | - = help: Add period - -ℹ Suggested fix -578 578 | @expect("D415: First line should end with a period, question mark, " -579 579 | "or exclamation point (not '\"')") -580 580 | def endswith_quote(): -581 |- """Whitespace at the end, but also a quote" """ - 581 |+ """Whitespace at the end, but also a quote". """ -582 582 | -583 583 | -584 584 | @expect('D209: Multi-line docstring closing quotes should be on a separate ' - -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 | | -617 | | """ - | |_______^ D400 - | - = help: Add period - -ℹ Suggested fix -612 612 | '(found 3)') -613 613 | @expect('D212: Multi-line docstring summary should start at the first line') -614 614 | def one_liner(): -615 |- """Wrong." - 615 |+ """Wrong.". -616 616 | -617 617 | """ -618 618 | - -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 | -641 | def same_line(): """This is a docstring on the same line""" - | - = help: Add period - -ℹ Suggested fix -636 636 | """ This is a docstring that starts with a space.""" # noqa: D210 -637 637 | -638 638 | -639 |-class SameLine: """This is a docstring on the same line""" - 639 |+class SameLine: """This is a docstring on the same line.""" -640 640 | -641 641 | def same_line(): """This is a docstring on the same line""" -642 642 | - -D.py:641:18: D400 [*] First line should end with a period - | -639 | class SameLine: """This is a docstring on the same line""" -640 | -641 | def same_line(): """This is a docstring on the same line""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 - | - = help: Add period - -ℹ Suggested fix -638 638 | -639 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""" - 641 |+def same_line(): """This is a docstring on the same line.""" -642 642 | -643 643 | -644 644 | def single_line_docstring_with_an_escaped_backslash(): - -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 \ - | _____^ -665 | | but continuations shouldn't be considered multi-line" - | |_________________________________________________________^ D400 - | - = help: Add period - -ℹ Suggested fix -662 662 | -663 663 | def newline_after_closing_quote(self): -664 664 | "We enforce a newline after the closing quote for a multi-line docstring \ -665 |- but continuations shouldn't be considered multi-line" - 665 |+ but continuations shouldn't be considered multi-line." - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D400_D400.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D400_D400.py.snap deleted file mode 100644 index 6d88a6bb27..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D400_D400.py.snap +++ /dev/null @@ -1,250 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D400.py:2:5: D400 [*] First line should end with a period - | -1 | def f(): -2 | "Here's a line without a period" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 -3 | ... - | - = help: Add period - -ℹ Suggested fix -1 1 | def f(): -2 |- "Here's a line without a period" - 2 |+ "Here's a line without a period." -3 3 | ... -4 4 | -5 5 | - -D400.py:7:5: D400 [*] First line should end with a period - | -6 | def f(): -7 | """Here's a line without a period""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 -8 | ... - | - = help: Add period - -ℹ Suggested fix -4 4 | -5 5 | -6 6 | def f(): -7 |- """Here's a line without a period""" - 7 |+ """Here's a line without a period.""" -8 8 | ... -9 9 | -10 10 | - -D400.py:12:5: D400 [*] First line should end with a period - | -11 | def f(): -12 | """ - | _____^ -13 | | Here's a line without a period, -14 | | but here's the next line -15 | | """ - | |_______^ D400 -16 | ... - | - = help: Add period - -ℹ Suggested fix -11 11 | def f(): -12 12 | """ -13 13 | Here's a line without a period, -14 |- but here's the next line - 14 |+ but here's the next line. -15 15 | """ -16 16 | ... -17 17 | - -D400.py:20:5: D400 [*] First line should end with a period - | -19 | def f(): -20 | """Here's a line without a period""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 -21 | ... - | - = help: Add period - -ℹ Suggested fix -17 17 | -18 18 | -19 19 | def f(): -20 |- """Here's a line without a period""" - 20 |+ """Here's a line without a period.""" -21 21 | ... -22 22 | -23 23 | - -D400.py:25:5: D400 [*] First line should end with a period - | -24 | def f(): -25 | """ - | _____^ -26 | | Here's a line without a period, -27 | | but here's the next line""" - | |_______________________________^ D400 -28 | ... - | - = help: Add period - -ℹ Suggested fix -24 24 | def f(): -25 25 | """ -26 26 | Here's a line without a period, -27 |- but here's the next line""" - 27 |+ but here's the next line.""" -28 28 | ... -29 29 | -30 30 | - -D400.py:32:5: D400 [*] First line should end with a period - | -31 | def f(): -32 | """ - | _____^ -33 | | Here's a line without a period, -34 | | but here's the next line with trailing space """ - | |____________________________________________________^ D400 -35 | ... - | - = help: Add period - -ℹ Suggested fix -31 31 | def f(): -32 32 | """ -33 33 | Here's a line without a period, -34 |- but here's the next line with trailing space """ - 34 |+ but here's the next line with trailing space. """ -35 35 | ... -36 36 | -37 37 | - -D400.py:39:5: D400 [*] First line should end with a period - | -38 | def f(): -39 | r"Here's a line without a period" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 -40 | ... - | - = help: Add period - -ℹ Suggested fix -36 36 | -37 37 | -38 38 | def f(): -39 |- r"Here's a line without a period" - 39 |+ r"Here's a line without a period." -40 40 | ... -41 41 | -42 42 | - -D400.py:44:5: D400 [*] First line should end with a period - | -43 | def f(): -44 | r"""Here's a line without a period""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 -45 | ... - | - = help: Add period - -ℹ Suggested fix -41 41 | -42 42 | -43 43 | def f(): -44 |- r"""Here's a line without a period""" - 44 |+ r"""Here's a line without a period.""" -45 45 | ... -46 46 | -47 47 | - -D400.py:49:5: D400 [*] First line should end with a period - | -48 | def f(): -49 | r""" - | _____^ -50 | | Here's a line without a period, -51 | | but here's the next line -52 | | """ - | |_______^ D400 -53 | ... - | - = help: Add period - -ℹ Suggested fix -48 48 | def f(): -49 49 | r""" -50 50 | Here's a line without a period, -51 |- but here's the next line - 51 |+ but here's the next line. -52 52 | """ -53 53 | ... -54 54 | - -D400.py:57:5: D400 [*] First line should end with a period - | -56 | def f(): -57 | r"""Here's a line without a period""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 -58 | ... - | - = help: Add period - -ℹ Suggested fix -54 54 | -55 55 | -56 56 | def f(): -57 |- r"""Here's a line without a period""" - 57 |+ r"""Here's a line without a period.""" -58 58 | ... -59 59 | -60 60 | - -D400.py:62:5: D400 [*] First line should end with a period - | -61 | def f(): -62 | r""" - | _____^ -63 | | Here's a line without a period, -64 | | but here's the next line""" - | |_______________________________^ D400 -65 | ... - | - = help: Add period - -ℹ Suggested fix -61 61 | def f(): -62 62 | r""" -63 63 | Here's a line without a period, -64 |- but here's the next line""" - 64 |+ but here's the next line.""" -65 65 | ... -66 66 | -67 67 | - -D400.py:69:5: D400 [*] First line should end with a period - | -68 | def f(): -69 | r""" - | _____^ -70 | | Here's a line without a period, -71 | | but here's the next line with trailing space """ - | |____________________________________________________^ D400 -72 | ... - | - = help: Add period - -ℹ Suggested fix -68 68 | def f(): -69 69 | r""" -70 70 | Here's a line without a period, -71 |- but here's the next line with trailing space """ - 71 |+ but here's the next line with trailing space. """ -72 72 | ... -73 73 | -74 74 | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D401_D401.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D401_D401.py.snap deleted file mode 100644 index 69bae1f4ac..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D401_D401.py.snap +++ /dev/null @@ -1,67 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D401.py:10:5: D401 First line of docstring should be in imperative mood: "Returns foo." - | - 9 | def bad_liouiwnlkjl(): -10 | """Returns foo.""" - | ^^^^^^^^^^^^^^^^^^ D401 - | - -D401.py:14:5: D401 First line of docstring should be in imperative mood: "Constructor for a foo." - | -13 | def bad_sdgfsdg23245(): -14 | """Constructor for a foo.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D401 - | - -D401.py:18:5: D401 First line of docstring should be in imperative mood: "Constructor for a boa." - | -17 | def bad_sdgfsdg23245777(): -18 | """ - | _____^ -19 | | -20 | | Constructor for a boa. -21 | | -22 | | """ - | |_______^ D401 - | - -D401.py:26:5: D401 First line of docstring should be in imperative mood: "Runs something" - | -25 | def bad_run_something(): -26 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D401 -27 | -28 | def bad_nested(): - | - -D401.py:29:9: D401 First line of docstring should be in imperative mood: "Runs other things, nested" - | -28 | def bad_nested(): -29 | """Runs other things, nested""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D401 -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 - | _____^ -36 | | extends to two physical lines. -37 | | """ - | |_______^ D401 - | - -D401.py:74:9: D401 First line of docstring should be in imperative mood: "This method docstring should be written in imperative mood." - | -73 | def bad_method(self): -74 | """This method docstring should be written in imperative mood.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D401 -75 | -76 | @property - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D402_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D402_D.py.snap deleted file mode 100644 index f2ddc0888c..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D402_D.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:378:5: D402 First line should not be the function's signature - | -376 | @expect('D402: First line should not be the function\'s "signature"') -377 | def foobar(): -378 | """Signature: foobar().""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ D402 - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D403_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D403_D.py.snap deleted file mode 100644 index 89dabd861c..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D403_D.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D403_D403.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D403_D403.py.snap deleted file mode 100644 index 79e1522fd3..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D403_D403.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D403.py:2:5: D403 [*] First word of the first line should be capitalized: `this` -> `This` - | -1 | def bad_function(): -2 | """this docstring is not capitalized""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D403 -3 | -4 | def good_function(): - | - = help: Capitalize `this` to `This` - -ℹ Fix -1 1 | def bad_function(): -2 |- """this docstring is not capitalized""" - 2 |+ """This docstring is not capitalized""" -3 3 | -4 4 | def good_function(): -5 5 | """This docstring is capitalized.""" - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D404_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D404_D.py.snap deleted file mode 100644 index d372af4445..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D404_D.py.snap +++ /dev/null @@ -1,36 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:631:5: D404 First word of the docstring should not be "This" - | -629 | @expect('D404: First word of the docstring should not be "This"') -630 | def starts_with_this(): -631 | """This is a docstring.""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ D404 - | - -D.py:636:5: D404 First word of the docstring should not be "This" - | -634 | @expect('D404: First word of the docstring should not be "This"') -635 | def starts_with_space_then_this(): -636 | """ This is a docstring that starts with a space.""" # noqa: D210 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D404 - | - -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 | -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 | -641 | def same_line(): """This is a docstring on the same line""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D404 - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D405_sections.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D405_sections.py.snap deleted file mode 100644 index 3b3ec3f1df..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D405_sections.py.snap +++ /dev/null @@ -1,64 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -sections.py:17:5: D405 [*] Section name should be properly capitalized ("returns") - | -15 | "('Returns', not 'returns')") -16 | def not_capitalized(): # noqa: D416 -17 | """Toggle the gizmo. - | _____^ -18 | | -19 | | returns -20 | | ------- -21 | | A value of some sort. -22 | | -23 | | """ - | |_______^ D405 - | - = help: Capitalize "returns" - -ℹ Fix -16 16 | def not_capitalized(): # noqa: D416 -17 17 | """Toggle the gizmo. -18 18 | -19 |- returns - 19 |+ Returns -20 20 | ------- -21 21 | A value of some sort. -22 22 | - -sections.py:216:5: D405 [*] Section name should be properly capitalized ("Short summary") - | -214 | @expect("D407: Missing dashed underline after section ('Raises')") -215 | def multiple_sections(): # noqa: D416 -216 | """Toggle the gizmo. - | _____^ -217 | | -218 | | Short summary -219 | | ------------- -220 | | -221 | | This is the function's description, which will also specify what it -222 | | returns. -223 | | -224 | | Returns -225 | | ------ -226 | | Many many wonderful things. -227 | | Raises: -228 | | My attention. -229 | | -230 | | """ - | |_______^ D405 - | - = help: Capitalize "Short summary" - -ℹ Fix -215 215 | def multiple_sections(): # noqa: D416 -216 216 | """Toggle the gizmo. -217 217 | -218 |- Short summary - 218 |+ Short Summary -219 219 | ------------- -220 220 | -221 221 | This is the function's description, which will also specify what it - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D406_sections.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D406_sections.py.snap deleted file mode 100644 index b87c43b472..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D406_sections.py.snap +++ /dev/null @@ -1,64 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -sections.py:30:5: D406 [*] Section name should end with a newline ("Returns") - | -28 | "('Returns', not 'Returns:')") -29 | def superfluous_suffix(): # noqa: D416 -30 | """Toggle the gizmo. - | _____^ -31 | | -32 | | Returns: -33 | | ------- -34 | | A value of some sort. -35 | | -36 | | """ - | |_______^ D406 - | - = help: Add newline after "Returns" - -ℹ Fix -29 29 | def superfluous_suffix(): # noqa: D416 -30 30 | """Toggle the gizmo. -31 31 | -32 |- Returns: - 32 |+ Returns -33 33 | ------- -34 34 | A value of some sort. -35 35 | - -sections.py:216:5: D406 [*] Section name should end with a newline ("Raises") - | -214 | @expect("D407: Missing dashed underline after section ('Raises')") -215 | def multiple_sections(): # noqa: D416 -216 | """Toggle the gizmo. - | _____^ -217 | | -218 | | Short summary -219 | | ------------- -220 | | -221 | | This is the function's description, which will also specify what it -222 | | returns. -223 | | -224 | | Returns -225 | | ------ -226 | | Many many wonderful things. -227 | | Raises: -228 | | My attention. -229 | | -230 | | """ - | |_______^ D406 - | - = help: Add newline after "Raises" - -ℹ Fix -224 224 | Returns -225 225 | ------ -226 226 | Many many wonderful things. -227 |- Raises: - 227 |+ Raises -228 228 | My attention. -229 229 | -230 230 | """ - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D407_sections.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D407_sections.py.snap deleted file mode 100644 index 6c296e9ca0..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D407_sections.py.snap +++ /dev/null @@ -1,501 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -sections.py:42:5: D407 [*] Missing dashed underline after section ("Returns") - | -40 | @expect("D407: Missing dashed underline after section ('Returns')") -41 | def no_underline(): # noqa: D416 -42 | """Toggle the gizmo. - | _____^ -43 | | -44 | | Returns -45 | | A value of some sort. -46 | | -47 | | """ - | |_______^ D407 - | - = help: Add dashed line under "Returns" - -ℹ Fix -42 42 | """Toggle the gizmo. -43 43 | -44 44 | Returns - 45 |+ ------- -45 46 | A value of some sort. -46 47 | -47 48 | """ - -sections.py:54:5: D407 [*] Missing dashed underline after section ("Returns") - | -52 | @expect("D414: Section has no content ('Returns')") -53 | def no_underline_and_no_description(): # noqa: D416 -54 | """Toggle the gizmo. - | _____^ -55 | | -56 | | Returns -57 | | -58 | | """ - | |_______^ D407 - | - = help: Add dashed line under "Returns" - -ℹ Fix -54 54 | """Toggle the gizmo. -55 55 | -56 56 | Returns - 57 |+ ------- -57 58 | -58 59 | """ -59 60 | - -sections.py:65:5: D407 [*] Missing dashed underline after section ("Returns") - | -63 | @expect("D414: Section has no content ('Returns')") -64 | def no_underline_and_no_newline(): # noqa: D416 -65 | """Toggle the gizmo. - | _____^ -66 | | -67 | | Returns""" - | |______________^ D407 - | - = help: Add dashed line under "Returns" - -ℹ Fix -64 64 | def no_underline_and_no_newline(): # noqa: D416 -65 65 | """Toggle the gizmo. -66 66 | -67 |- Returns""" - 67 |+ Returns - 68 |+ -------""" -68 69 | -69 70 | -70 71 | @expect(_D213) - -sections.py:216:5: D407 [*] Missing dashed underline after section ("Raises") - | -214 | @expect("D407: Missing dashed underline after section ('Raises')") -215 | def multiple_sections(): # noqa: D416 -216 | """Toggle the gizmo. - | _____^ -217 | | -218 | | Short summary -219 | | ------------- -220 | | -221 | | This is the function's description, which will also specify what it -222 | | returns. -223 | | -224 | | Returns -225 | | ------ -226 | | Many many wonderful things. -227 | | Raises: -228 | | My attention. -229 | | -230 | | """ - | |_______^ D407 - | - = help: Add dashed line under "Raises" - -ℹ Fix -225 225 | ------ -226 226 | Many many wonderful things. -227 227 | Raises: - 228 |+ ------ -228 229 | My attention. -229 230 | -230 231 | """ - -sections.py:261:5: D407 [*] Missing dashed underline after section ("Args") - | -259 | @expect("D414: Section has no content ('Returns')") -260 | def valid_google_style_section(): # noqa: D406, D407 -261 | """Toggle the gizmo. - | _____^ -262 | | -263 | | Args: -264 | | note: A random string. -265 | | -266 | | Returns: -267 | | -268 | | Raises: -269 | | RandomError: A random error that occurs randomly. -270 | | -271 | | """ - | |_______^ D407 - | - = help: Add dashed line under "Args" - -ℹ Fix -261 261 | """Toggle the gizmo. -262 262 | -263 263 | Args: - 264 |+ ---- -264 265 | note: A random string. -265 266 | -266 267 | Returns: - -sections.py:261:5: D407 [*] Missing dashed underline after section ("Returns") - | -259 | @expect("D414: Section has no content ('Returns')") -260 | def valid_google_style_section(): # noqa: D406, D407 -261 | """Toggle the gizmo. - | _____^ -262 | | -263 | | Args: -264 | | note: A random string. -265 | | -266 | | Returns: -267 | | -268 | | Raises: -269 | | RandomError: A random error that occurs randomly. -270 | | -271 | | """ - | |_______^ D407 - | - = help: Add dashed line under "Returns" - -ℹ Fix -264 264 | note: A random string. -265 265 | -266 266 | Returns: - 267 |+ ------- -267 268 | -268 269 | Raises: -269 270 | RandomError: A random error that occurs randomly. - -sections.py:261:5: D407 [*] Missing dashed underline after section ("Raises") - | -259 | @expect("D414: Section has no content ('Returns')") -260 | def valid_google_style_section(): # noqa: D406, D407 -261 | """Toggle the gizmo. - | _____^ -262 | | -263 | | Args: -264 | | note: A random string. -265 | | -266 | | Returns: -267 | | -268 | | Raises: -269 | | RandomError: A random error that occurs randomly. -270 | | -271 | | """ - | |_______^ D407 - | - = help: Add dashed line under "Raises" - -ℹ Fix -266 266 | Returns: -267 267 | -268 268 | Raises: - 269 |+ ------ -269 270 | RandomError: A random error that occurs randomly. -270 271 | -271 272 | """ - -sections.py:278:5: D407 [*] Missing dashed underline after section ("Args") - | -276 | "('Args:', not 'Args')") -277 | def missing_colon_google_style_section(): # noqa: D406, D407 -278 | """Toggle the gizmo. - | _____^ -279 | | -280 | | Args -281 | | note: A random string. -282 | | -283 | | """ - | |_______^ D407 - | - = help: Add dashed line under "Args" - -ℹ Fix -278 278 | """Toggle the gizmo. -279 279 | -280 280 | Args - 281 |+ ---- -281 282 | note: A random string. -282 283 | -283 284 | """ - -sections.py:293:9: D407 [*] Missing dashed underline after section ("Args") - | -292 | def bar(y=2): # noqa: D207, D213, D406, D407 -293 | """Nested function test for docstrings. - | _________^ -294 | | -295 | | Will this work when referencing x? -296 | | -297 | | Args: -298 | | x: Test something -299 | | that is broken. -300 | | -301 | | """ - | |___________^ D407 -302 | print(x) - | - = help: Add dashed line under "Args" - -ℹ Fix -295 295 | Will this work when referencing x? -296 296 | -297 297 | Args: - 298 |+ ---- -298 299 | x: Test something -299 300 | that is broken. -300 301 | - -sections.py:310:5: D407 [*] Missing dashed underline after section ("Args") - | -308 | "'test_missing_google_args' docstring)") -309 | def test_missing_google_args(x=1, y=2, _private=3): # noqa: D406, D407 -310 | """Toggle the gizmo. - | _____^ -311 | | -312 | | Args: -313 | | x (int): The greatest integer. -314 | | -315 | | """ - | |_______^ D407 - | - = help: Add dashed line under "Args" - -ℹ Fix -310 310 | """Toggle the gizmo. -311 311 | -312 312 | Args: - 313 |+ ---- -313 314 | x (int): The greatest integer. -314 315 | -315 316 | """ - -sections.py:322:9: D407 [*] Missing dashed underline after section ("Args") - | -321 | def test_method(self, test, another_test, _): # noqa: D213, D407 -322 | """Test a valid args section. - | _________^ -323 | | -324 | | Args: -325 | | test: A parameter. -326 | | another_test: Another parameter. -327 | | -328 | | """ - | |___________^ D407 -329 | -330 | @expect("D417: Missing argument descriptions in the docstring " - | - = help: Add dashed line under "Args" - -ℹ Fix -322 322 | """Test a valid args section. -323 323 | -324 324 | Args: - 325 |+ ---- -325 326 | test: A parameter. -326 327 | another_test: Another parameter. -327 328 | - -sections.py:334:9: D407 [*] Missing dashed underline after section ("Args") - | -332 | "'test_missing_args' docstring)", arg_count=5) -333 | def test_missing_args(self, test, x, y, z=3, _private_arg=3): # noqa: D213, D407 -334 | """Test a valid args section. - | _________^ -335 | | -336 | | Args: -337 | | x: Another parameter. -338 | | -339 | | """ - | |___________^ D407 -340 | -341 | @classmethod - | - = help: Add dashed line under "Args" - -ℹ Fix -334 334 | """Test a valid args section. -335 335 | -336 336 | Args: - 337 |+ ---- -337 338 | x: Another parameter. -338 339 | -339 340 | """ - -sections.py:346:9: D407 [*] Missing dashed underline after section ("Args") - | -344 | "'test_missing_args_class_method' docstring)", arg_count=5) -345 | def test_missing_args_class_method(cls, test, x, y, _, z=3): # noqa: D213, D407 -346 | """Test a valid args section. - | _________^ -347 | | -348 | | Args: -349 | | x: Another parameter. The parameter below is missing description. -350 | | y: -351 | | -352 | | """ - | |___________^ D407 -353 | -354 | @staticmethod - | - = help: Add dashed line under "Args" - -ℹ Fix -346 346 | """Test a valid args section. -347 347 | -348 348 | Args: - 349 |+ ---- -349 350 | x: Another parameter. The parameter below is missing description. -350 351 | y: -351 352 | - -sections.py:359:9: D407 [*] Missing dashed underline after section ("Args") - | -357 | "'test_missing_args_static_method' docstring)", arg_count=4) -358 | def test_missing_args_static_method(a, x, y, _test, z=3): # noqa: D213, D407 -359 | """Test a valid args section. - | _________^ -360 | | -361 | | Args: -362 | | x: Another parameter. -363 | | -364 | | """ - | |___________^ D407 -365 | -366 | @staticmethod - | - = help: Add dashed line under "Args" - -ℹ Fix -359 359 | """Test a valid args section. -360 360 | -361 361 | Args: - 362 |+ ---- -362 363 | x: Another parameter. -363 364 | -364 365 | """ - -sections.py:371:9: D407 [*] Missing dashed underline after section ("Args") - | -369 | "'test_missing_docstring' docstring)", arg_count=2) -370 | def test_missing_docstring(a, b): # noqa: D213, D407 -371 | """Test a valid args section. - | _________^ -372 | | -373 | | Args: -374 | | a: -375 | | -376 | | """ - | |___________^ D407 -377 | -378 | @staticmethod - | - = help: Add dashed line under "Args" - -ℹ Fix -371 371 | """Test a valid args section. -372 372 | -373 373 | Args: - 374 |+ ---- -374 375 | a: -375 376 | -376 377 | """ - -sections.py:380:9: D407 [*] Missing dashed underline after section ("Args") - | -378 | @staticmethod -379 | def test_hanging_indent(skip, verbose): # noqa: D213, D407 -380 | """Do stuff. - | _________^ -381 | | -382 | | Args: -383 | | skip (:attr:`.Skip`): -384 | | Lorem ipsum dolor sit amet, consectetur adipiscing elit. -385 | | Etiam at tellus a tellus faucibus maximus. Curabitur tellus -386 | | mauris, semper id vehicula ac, feugiat ut tortor. -387 | | verbose (bool): -388 | | If True, print out as much information as possible. -389 | | If False, print out concise "one-liner" information. -390 | | -391 | | """ - | |___________^ D407 - | - = help: Add dashed line under "Args" - -ℹ Fix -380 380 | """Do stuff. -381 381 | -382 382 | Args: - 383 |+ ---- -383 384 | skip (:attr:`.Skip`): -384 385 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. -385 386 | Etiam at tellus a tellus faucibus maximus. Curabitur tellus - -sections.py:499:9: D407 [*] Missing dashed underline after section ("Args") - | -497 | "'test_incorrect_indent' docstring)", arg_count=3) -498 | def test_incorrect_indent(self, x=1, y=2): # noqa: D207, D213, D407 -499 | """Reproducing issue #437. - | _________^ -500 | | -501 | | Testing this incorrectly indented docstring. -502 | | -503 | | Args: -504 | | x: Test argument. -505 | | -506 | | """ - | |___________^ D407 - | - = help: Add dashed line under "Args" - -ℹ Fix -501 501 | Testing this incorrectly indented docstring. -502 502 | -503 503 | Args: - 504 |+ ---- -504 505 | x: Test argument. -505 506 | -506 507 | """ - -sections.py:519:5: D407 [*] Missing dashed underline after section ("Parameters") - | -518 | def replace_equals_with_dash(): -519 | """Equal length equals should be replaced with dashes. - | _____^ -520 | | -521 | | Parameters -522 | | ========== -523 | | """ - | |_______^ D407 - | - = help: Add dashed line under "Parameters" - -ℹ Fix -519 519 | """Equal length equals should be replaced with dashes. -520 520 | -521 521 | Parameters -522 |- ========== - 522 |+ ---------- -523 523 | """ -524 524 | -525 525 | - -sections.py:527:5: D407 [*] Missing dashed underline after section ("Parameters") - | -526 | def replace_equals_with_dash2(): -527 | """Here, the length of equals is not the same. - | _____^ -528 | | -529 | | Parameters -530 | | =========== -531 | | """ - | |_______^ D407 - | - = help: Add dashed line under "Parameters" - -ℹ Fix -527 527 | """Here, the length of equals is not the same. -528 528 | -529 529 | Parameters - 530 |+ ---------- -530 531 | =========== -531 532 | """ -532 533 | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D408_sections.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D408_sections.py.snap deleted file mode 100644 index 4550efa25b..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D408_sections.py.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -sections.py:94:5: D408 [*] Section underline should be in the line following the section's name ("Returns") - | - 92 | "section's name ('Returns')") - 93 | def blank_line_before_underline(): # noqa: D416 - 94 | """Toggle the gizmo. - | _____^ - 95 | | - 96 | | Returns - 97 | | - 98 | | ------- - 99 | | A value of some sort. -100 | | -101 | | """ - | |_______^ D408 - | - = help: Add underline to "Returns" - -ℹ Fix -94 94 | """Toggle the gizmo. -95 95 | -96 96 | Returns -97 |- -98 97 | ------- -99 98 | A value of some sort. -100 99 | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D409_sections.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D409_sections.py.snap deleted file mode 100644 index db7d4e96b3..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D409_sections.py.snap +++ /dev/null @@ -1,64 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -sections.py:108:5: D409 [*] Section underline should match the length of its name ("Returns") - | -106 | "(Expected 7 dashes in section 'Returns', got 2)") -107 | def bad_underline_length(): # noqa: D416 -108 | """Toggle the gizmo. - | _____^ -109 | | -110 | | Returns -111 | | -- -112 | | A value of some sort. -113 | | -114 | | """ - | |_______^ D409 - | - = help: Adjust underline length to match "Returns" - -ℹ Fix -108 108 | """Toggle the gizmo. -109 109 | -110 110 | Returns -111 |- -- - 111 |+ ------- -112 112 | A value of some sort. -113 113 | -114 114 | """ - -sections.py:216:5: D409 [*] Section underline should match the length of its name ("Returns") - | -214 | @expect("D407: Missing dashed underline after section ('Raises')") -215 | def multiple_sections(): # noqa: D416 -216 | """Toggle the gizmo. - | _____^ -217 | | -218 | | Short summary -219 | | ------------- -220 | | -221 | | This is the function's description, which will also specify what it -222 | | returns. -223 | | -224 | | Returns -225 | | ------ -226 | | Many many wonderful things. -227 | | Raises: -228 | | My attention. -229 | | -230 | | """ - | |_______^ D409 - | - = help: Adjust underline length to match "Returns" - -ℹ Fix -222 222 | returns. -223 223 | -224 224 | Returns -225 |- ------ - 225 |+ ------- -226 226 | Many many wonderful things. -227 227 | Raises: -228 228 | My attention. - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D410_D410.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D410_D410.py.snap deleted file mode 100644 index 0ce1725147..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D410_D410.py.snap +++ /dev/null @@ -1,59 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D410.py:2:5: D410 [*] Missing blank line after section ("Parameters") - | - 1 | def f(a: int, b: int) -> int: - 2 | """Showcase function. - | _____^ - 3 | | - 4 | | Parameters - 5 | | ---------- - 6 | | a : int - 7 | | _description_ - 8 | | b : int - 9 | | _description_ -10 | | Returns -11 | | ------- -12 | | int -13 | | _description -14 | | """ - | |_______^ D410 -15 | return b - a - | - = help: Add blank line after "Parameters" - -ℹ Fix -7 7 | _description_ -8 8 | b : int -9 9 | _description_ - 10 |+ -10 11 | Returns -11 12 | ------- -12 13 | int - -D410.py:19:5: D410 [*] Missing blank line after section ("Parameters") - | -18 | def f() -> int: -19 | """Showcase function. - | _____^ -20 | | -21 | | Parameters -22 | | ---------- -23 | | Returns -24 | | ------- -25 | | """ - | |_______^ D410 - | - = help: Add blank line after "Parameters" - -ℹ Fix -20 20 | -21 21 | Parameters -22 22 | ---------- - 23 |+ -23 24 | Returns -24 25 | ------- -25 26 | """ - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D410_sections.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D410_sections.py.snap deleted file mode 100644 index e2cda946d5..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D410_sections.py.snap +++ /dev/null @@ -1,67 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -sections.py:76:5: D410 [*] Missing blank line after section ("Returns") - | -74 | @expect("D414: Section has no content ('Yields')") -75 | def consecutive_sections(): # noqa: D416 -76 | """Toggle the gizmo. - | _____^ -77 | | -78 | | Returns -79 | | ------- -80 | | Yields -81 | | ------ -82 | | -83 | | Raises -84 | | ------ -85 | | Questions. -86 | | -87 | | """ - | |_______^ D410 - | - = help: Add blank line after "Returns" - -ℹ Fix -77 77 | -78 78 | Returns -79 79 | ------- - 80 |+ -80 81 | Yields -81 82 | ------ -82 83 | - -sections.py:216:5: D410 [*] Missing blank line after section ("Returns") - | -214 | @expect("D407: Missing dashed underline after section ('Raises')") -215 | def multiple_sections(): # noqa: D416 -216 | """Toggle the gizmo. - | _____^ -217 | | -218 | | Short summary -219 | | ------------- -220 | | -221 | | This is the function's description, which will also specify what it -222 | | returns. -223 | | -224 | | Returns -225 | | ------ -226 | | Many many wonderful things. -227 | | Raises: -228 | | My attention. -229 | | -230 | | """ - | |_______^ D410 - | - = help: Add blank line after "Returns" - -ℹ Fix -224 224 | Returns -225 225 | ------ -226 226 | Many many wonderful things. - 227 |+ -227 228 | Raises: -228 229 | My attention. -229 230 | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D411_sections.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D411_sections.py.snap deleted file mode 100644 index 1e7cad7261..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D411_sections.py.snap +++ /dev/null @@ -1,93 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -sections.py:76:5: D411 [*] Missing blank line before section ("Yields") - | -74 | @expect("D414: Section has no content ('Yields')") -75 | def consecutive_sections(): # noqa: D416 -76 | """Toggle the gizmo. - | _____^ -77 | | -78 | | Returns -79 | | ------- -80 | | Yields -81 | | ------ -82 | | -83 | | Raises -84 | | ------ -85 | | Questions. -86 | | -87 | | """ - | |_______^ D411 - | - = help: Add blank line before "Yields" - -ℹ Fix -77 77 | -78 78 | Returns -79 79 | ------- - 80 |+ -80 81 | Yields -81 82 | ------ -82 83 | - -sections.py:131:5: D411 [*] Missing blank line before section ("Returns") - | -129 | @expect("D411: Missing blank line before section ('Returns')") -130 | def no_blank_line_before_section(): # noqa: D416 -131 | """Toggle the gizmo. - | _____^ -132 | | -133 | | The function's description. -134 | | Returns -135 | | ------- -136 | | A value of some sort. -137 | | -138 | | """ - | |_______^ D411 - | - = help: Add blank line before "Returns" - -ℹ Fix -131 131 | """Toggle the gizmo. -132 132 | -133 133 | The function's description. - 134 |+ -134 135 | Returns -135 136 | ------- -136 137 | A value of some sort. - -sections.py:216:5: D411 [*] Missing blank line before section ("Raises") - | -214 | @expect("D407: Missing dashed underline after section ('Raises')") -215 | def multiple_sections(): # noqa: D416 -216 | """Toggle the gizmo. - | _____^ -217 | | -218 | | Short summary -219 | | ------------- -220 | | -221 | | This is the function's description, which will also specify what it -222 | | returns. -223 | | -224 | | Returns -225 | | ------ -226 | | Many many wonderful things. -227 | | Raises: -228 | | My attention. -229 | | -230 | | """ - | |_______^ D411 - | - = help: Add blank line before "Raises" - -ℹ Fix -224 224 | Returns -225 225 | ------ -226 226 | Many many wonderful things. - 227 |+ -227 228 | Raises: -228 229 | My attention. -229 230 | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D412_sections.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D412_sections.py.snap deleted file mode 100644 index 2d32ab4dcc..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D412_sections.py.snap +++ /dev/null @@ -1,37 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -sections.py:216:5: D412 [*] No blank lines allowed between a section header and its content ("Short summary") - | -214 | @expect("D407: Missing dashed underline after section ('Raises')") -215 | def multiple_sections(): # noqa: D416 -216 | """Toggle the gizmo. - | _____^ -217 | | -218 | | Short summary -219 | | ------------- -220 | | -221 | | This is the function's description, which will also specify what it -222 | | returns. -223 | | -224 | | Returns -225 | | ------ -226 | | Many many wonderful things. -227 | | Raises: -228 | | My attention. -229 | | -230 | | """ - | |_______^ D412 - | - = help: Remove blank line(s) - -ℹ Fix -217 217 | -218 218 | Short summary -219 219 | ------------- -220 |- -221 220 | This is the function's description, which will also specify what it -222 221 | returns. -223 222 | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D413_sections.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D413_sections.py.snap deleted file mode 100644 index 05ae181bc0..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D413_sections.py.snap +++ /dev/null @@ -1,27 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -sections.py:65:5: D413 [*] Missing blank line after last section ("Returns") - | -63 | @expect("D414: Section has no content ('Returns')") -64 | def no_underline_and_no_newline(): # noqa: D416 -65 | """Toggle the gizmo. - | _____^ -66 | | -67 | | Returns""" - | |______________^ D413 - | - = help: Add blank line after "Returns" - -ℹ Fix -64 64 | def no_underline_and_no_newline(): # noqa: D416 -65 65 | """Toggle the gizmo. -66 66 | -67 |- Returns""" - 67 |+ Returns - 68 |+ """ -68 69 | -69 70 | -70 71 | @expect(_D213) - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D414_sections.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D414_sections.py.snap deleted file mode 100644 index 102e5c262e..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D414_sections.py.snap +++ /dev/null @@ -1,100 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -sections.py:54:5: D414 Section has no content ("Returns") - | -52 | @expect("D414: Section has no content ('Returns')") -53 | def no_underline_and_no_description(): # noqa: D416 -54 | """Toggle the gizmo. - | _____^ -55 | | -56 | | Returns -57 | | -58 | | """ - | |_______^ D414 - | - -sections.py:65:5: D414 Section has no content ("Returns") - | -63 | @expect("D414: Section has no content ('Returns')") -64 | def no_underline_and_no_newline(): # noqa: D416 -65 | """Toggle the gizmo. - | _____^ -66 | | -67 | | Returns""" - | |______________^ D414 - | - -sections.py:76:5: D414 Section has no content ("Returns") - | -74 | @expect("D414: Section has no content ('Yields')") -75 | def consecutive_sections(): # noqa: D416 -76 | """Toggle the gizmo. - | _____^ -77 | | -78 | | Returns -79 | | ------- -80 | | Yields -81 | | ------ -82 | | -83 | | Raises -84 | | ------ -85 | | Questions. -86 | | -87 | | """ - | |_______^ D414 - | - -sections.py:76:5: D414 Section has no content ("Yields") - | -74 | @expect("D414: Section has no content ('Yields')") -75 | def consecutive_sections(): # noqa: D416 -76 | """Toggle the gizmo. - | _____^ -77 | | -78 | | Returns -79 | | ------- -80 | | Yields -81 | | ------ -82 | | -83 | | Raises -84 | | ------ -85 | | Questions. -86 | | -87 | | """ - | |_______^ D414 - | - -sections.py:170:5: D414 Section has no content ("Returns") - | -168 | @expect("D414: Section has no content ('Returns')") -169 | def section_underline_overindented_and_contentless(): # noqa: D416 -170 | """Toggle the gizmo. - | _____^ -171 | | -172 | | Returns -173 | | ------- -174 | | """ - | |_______^ D414 - | - -sections.py:261:5: D414 Section has no content ("Returns") - | -259 | @expect("D414: Section has no content ('Returns')") -260 | def valid_google_style_section(): # noqa: D406, D407 -261 | """Toggle the gizmo. - | _____^ -262 | | -263 | | Args: -264 | | note: A random string. -265 | | -266 | | Returns: -267 | | -268 | | Raises: -269 | | RandomError: A random error that occurs randomly. -270 | | -271 | | """ - | |_______^ D414 - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D415_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D415_D.py.snap deleted file mode 100644 index 0c3aa113e7..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D415_D.py.snap +++ /dev/null @@ -1,312 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:355:5: D415 [*] First line should end with a period, question mark, or exclamation point - | -353 | "or exclamation point (not 'y')") -354 | def lwnlkjl(): -355 | """Summary""" - | ^^^^^^^^^^^^^ D415 - | - = help: Add closing punctuation - -ℹ Suggested fix -352 352 | @expect("D415: First line should end with a period, question mark, " -353 353 | "or exclamation point (not 'y')") -354 354 | def lwnlkjl(): -355 |- """Summary""" - 355 |+ """Summary.""" -356 356 | -357 357 | -358 358 | @expect("D401: First line should be in imperative mood " - -D.py:406:25: D415 [*] First line should end with a period, question mark, or exclamation point - | -404 | @expect("D415: First line should end with a period, question mark," -405 | " or exclamation point (not 'r')") -406 | def oneliner_withdoc(): """One liner""" - | ^^^^^^^^^^^^^^^ D415 - | - = help: Add closing punctuation - -ℹ Suggested fix -403 403 | @expect("D400: First line should end with a period (not 'r')") -404 404 | @expect("D415: First line should end with a period, question mark," -405 405 | " or exclamation point (not 'r')") -406 |-def oneliner_withdoc(): """One liner""" - 406 |+def oneliner_withdoc(): """One liner.""" -407 407 | -408 408 | -409 409 | def ignored_decorator(func): # noqa: D400,D401,D415 - -D.py:410:5: D415 [*] First line should end with a period, question mark, or exclamation point - | -409 | def ignored_decorator(func): # noqa: D400,D401,D415 -410 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D415 -411 | func() -412 | pass - | - = help: Add closing punctuation - -ℹ Suggested fix -407 407 | -408 408 | -409 409 | def ignored_decorator(func): # noqa: D400,D401,D415 -410 |- """Runs something""" - 410 |+ """Runs something.""" -411 411 | func() -412 412 | pass -413 413 | - -D.py:416:5: D415 [*] First line should end with a period, question mark, or exclamation point - | -415 | def decorator_for_test(func): # noqa: D400,D401,D415 -416 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D415 -417 | func() -418 | pass - | - = help: Add closing punctuation - -ℹ Suggested fix -413 413 | -414 414 | -415 415 | def decorator_for_test(func): # noqa: D400,D401,D415 -416 |- """Runs something""" - 416 |+ """Runs something.""" -417 417 | func() -418 418 | pass -419 419 | - -D.py:422:35: D415 [*] First line should end with a period, question mark, or exclamation point - | -421 | @ignored_decorator -422 | def oneliner_ignored_decorator(): """One liner""" - | ^^^^^^^^^^^^^^^ D415 - | - = help: Add closing punctuation - -ℹ Suggested fix -419 419 | -420 420 | -421 421 | @ignored_decorator -422 |-def oneliner_ignored_decorator(): """One liner""" - 422 |+def oneliner_ignored_decorator(): """One liner.""" -423 423 | -424 424 | -425 425 | @decorator_for_test - -D.py:429:49: D415 [*] First line should end with a period, question mark, or exclamation point - | -427 | @expect("D415: First line should end with a period, question mark," -428 | " or exclamation point (not 'r')") -429 | def oneliner_with_decorator_expecting_errors(): """One liner""" - | ^^^^^^^^^^^^^^^ D415 - | - = help: Add closing punctuation - -ℹ Suggested fix -426 426 | @expect("D400: First line should end with a period (not 'r')") -427 427 | @expect("D415: First line should end with a period, question mark," -428 428 | " or exclamation point (not 'r')") -429 |-def oneliner_with_decorator_expecting_errors(): """One liner""" - 429 |+def oneliner_with_decorator_expecting_errors(): """One liner.""" -430 430 | -431 431 | -432 432 | @decorator_for_test - -D.py:470:5: D415 [*] First line should end with a period, question mark, or exclamation point - | -468 | "or exclamation point (not 'g')") -469 | def docstring_bad(): -470 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D415 -471 | pass - | - = help: Add closing punctuation - -ℹ Suggested fix -467 467 | @expect("D415: First line should end with a period, question mark, " -468 468 | "or exclamation point (not 'g')") -469 469 | def docstring_bad(): -470 |- """Runs something""" - 470 |+ """Runs something.""" -471 471 | pass -472 472 | -473 473 | - -D.py:475:5: D415 [*] First line should end with a period, question mark, or exclamation point - | -474 | def docstring_bad_ignore_all(): # noqa -475 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D415 -476 | pass - | - = help: Add closing punctuation - -ℹ Suggested fix -472 472 | -473 473 | -474 474 | def docstring_bad_ignore_all(): # noqa -475 |- """Runs something""" - 475 |+ """Runs something.""" -476 476 | pass -477 477 | -478 478 | - -D.py:480:5: D415 [*] First line should end with a period, question mark, or exclamation point - | -479 | def docstring_bad_ignore_one(): # noqa: D400,D401,D415 -480 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D415 -481 | pass - | - = help: Add closing punctuation - -ℹ Suggested fix -477 477 | -478 478 | -479 479 | def docstring_bad_ignore_one(): # noqa: D400,D401,D415 -480 |- """Runs something""" - 480 |+ """Runs something.""" -481 481 | pass -482 482 | -483 483 | - -D.py:487:5: D415 [*] First line should end with a period, question mark, or exclamation point - | -485 | "(perhaps 'Run', not 'Runs')") -486 | def docstring_ignore_some_violations_but_catch_D401(): # noqa: E501,D400,D415 -487 | """Runs something""" - | ^^^^^^^^^^^^^^^^^^^^ D415 -488 | pass - | - = help: Add closing punctuation - -ℹ Suggested fix -484 484 | @expect("D401: First line should be in imperative mood " -485 485 | "(perhaps 'Run', not 'Runs')") -486 486 | def docstring_ignore_some_violations_but_catch_D401(): # noqa: E501,D400,D415 -487 |- """Runs something""" - 487 |+ """Runs something.""" -488 488 | pass -489 489 | -490 490 | - -D.py:520:5: D415 [*] First line should end with a period, question mark, or exclamation point - | -518 | "or exclamation point (not 'g')") -519 | def bad_google_string(): # noqa: D400 -520 | """Test a valid something""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D415 - | - = help: Add closing punctuation - -ℹ Suggested fix -517 517 | @expect("D415: First line should end with a period, question mark, " -518 518 | "or exclamation point (not 'g')") -519 519 | def bad_google_string(): # noqa: D400 -520 |- """Test a valid something""" - 520 |+ """Test a valid something.""" -521 521 | -522 522 | -523 523 | # This is reproducing a bug where AttributeError is raised when parsing class - -D.py:581:5: D415 [*] First line should end with a period, question mark, or exclamation point - | -579 | "or exclamation point (not '\"')") -580 | def endswith_quote(): -581 | """Whitespace at the end, but also a quote" """ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D415 - | - = help: Add closing punctuation - -ℹ Suggested fix -578 578 | @expect("D415: First line should end with a period, question mark, " -579 579 | "or exclamation point (not '\"')") -580 580 | def endswith_quote(): -581 |- """Whitespace at the end, but also a quote" """ - 581 |+ """Whitespace at the end, but also a quote". """ -582 582 | -583 583 | -584 584 | @expect('D209: Multi-line docstring closing quotes should be on a separate ' - -D.py:615:5: D415 [*] First line should end with a period, question mark, or exclamation point - | -613 | @expect('D212: Multi-line docstring summary should start at the first line') -614 | def one_liner(): -615 | """Wrong." - | _____^ -616 | | -617 | | """ - | |_______^ D415 - | - = help: Add closing punctuation - -ℹ Suggested fix -612 612 | '(found 3)') -613 613 | @expect('D212: Multi-line docstring summary should start at the first line') -614 614 | def one_liner(): -615 |- """Wrong." - 615 |+ """Wrong.". -616 616 | -617 617 | """ -618 618 | - -D.py:639:17: D415 [*] First line should end with a period, question mark, or exclamation point - | -639 | class SameLine: """This is a docstring on the same line""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D415 -640 | -641 | def same_line(): """This is a docstring on the same line""" - | - = help: Add closing punctuation - -ℹ Suggested fix -636 636 | """ This is a docstring that starts with a space.""" # noqa: D210 -637 637 | -638 638 | -639 |-class SameLine: """This is a docstring on the same line""" - 639 |+class SameLine: """This is a docstring on the same line.""" -640 640 | -641 641 | def same_line(): """This is a docstring on the same line""" -642 642 | - -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 | -641 | def same_line(): """This is a docstring on the same line""" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D415 - | - = help: Add closing punctuation - -ℹ Suggested fix -638 638 | -639 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""" - 641 |+def same_line(): """This is a docstring on the same line.""" -642 642 | -643 643 | -644 644 | def single_line_docstring_with_an_escaped_backslash(): - -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 \ - | _____^ -665 | | but continuations shouldn't be considered multi-line" - | |_________________________________________________________^ D415 - | - = help: Add closing punctuation - -ℹ Suggested fix -662 662 | -663 663 | def newline_after_closing_quote(self): -664 664 | "We enforce a newline after the closing quote for a multi-line docstring \ -665 |- but continuations shouldn't be considered multi-line" - 665 |+ but continuations shouldn't be considered multi-line." - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D416_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D416_D.py.snap deleted file mode 100644 index 89dabd861c..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D416_D.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D417_canonical_google_examples.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D417_canonical_google_examples.py.snap deleted file mode 100644 index 89dabd861c..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D417_canonical_google_examples.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D417_canonical_numpy_examples.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D417_canonical_numpy_examples.py.snap deleted file mode 100644 index 89dabd861c..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D417_canonical_numpy_examples.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D417_sections.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D417_sections.py.snap deleted file mode 100644 index 10c20472ba..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D417_sections.py.snap +++ /dev/null @@ -1,103 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -sections.py:292:9: D417 Missing argument description in the docstring for `bar`: `y` - | -290 | x = 1 -291 | -292 | def bar(y=2): # noqa: D207, D213, D406, D407 - | ^^^ D417 -293 | """Nested function test for docstrings. - | - -sections.py:309:5: D417 Missing argument description in the docstring for `test_missing_google_args`: `y` - | -307 | "(argument(s) y are missing descriptions in " -308 | "'test_missing_google_args' docstring)") -309 | def test_missing_google_args(x=1, y=2, _private=3): # noqa: D406, D407 - | ^^^^^^^^^^^^^^^^^^^^^^^^ D417 -310 | """Toggle the gizmo. - | - -sections.py:333:9: D417 Missing argument descriptions in the docstring for `test_missing_args`: `test`, `y`, `z` - | -331 | "(argument(s) test, y, z are missing descriptions in " -332 | "'test_missing_args' docstring)", arg_count=5) -333 | def test_missing_args(self, test, x, y, z=3, _private_arg=3): # noqa: D213, D407 - | ^^^^^^^^^^^^^^^^^ D417 -334 | """Test a valid args section. - | - -sections.py:345:9: D417 Missing argument descriptions in the docstring for `test_missing_args_class_method`: `test`, `y`, `z` - | -343 | "(argument(s) test, y, z are missing descriptions in " -344 | "'test_missing_args_class_method' docstring)", arg_count=5) -345 | def test_missing_args_class_method(cls, test, x, y, _, z=3): # noqa: D213, D407 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D417 -346 | """Test a valid args section. - | - -sections.py:358:9: D417 Missing argument descriptions in the docstring for `test_missing_args_static_method`: `a`, `y`, `z` - | -356 | "(argument(s) a, y, z are missing descriptions in " -357 | "'test_missing_args_static_method' docstring)", arg_count=4) -358 | def test_missing_args_static_method(a, x, y, _test, z=3): # noqa: D213, D407 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D417 -359 | """Test a valid args section. - | - -sections.py:370:9: D417 Missing argument descriptions in the docstring for `test_missing_docstring`: `a`, `b` - | -368 | "(argument(s) a, b are missing descriptions in " -369 | "'test_missing_docstring' docstring)", arg_count=2) -370 | def test_missing_docstring(a, b): # noqa: D213, D407 - | ^^^^^^^^^^^^^^^^^^^^^^ D417 -371 | """Test a valid args section. - | - -sections.py:398:5: D417 Missing argument description in the docstring for `test_missing_numpy_args`: `y` - | -396 | "(argument(s) y are missing descriptions in " -397 | "'test_missing_numpy_args' docstring)") -398 | def test_missing_numpy_args(_private_arg=0, x=1, y=2): # noqa: D406, D407 - | ^^^^^^^^^^^^^^^^^^^^^^^ D417 -399 | """Toggle the gizmo. - | - -sections.py:434:9: D417 Missing argument descriptions in the docstring for `test_missing_args`: `test`, `y`, `z` - | -432 | "(argument(s) test, y, z are missing descriptions in " -433 | "'test_missing_args' docstring)", arg_count=5) -434 | def test_missing_args(self, test, x, y, z=3, t=1, _private=0): # noqa: D213, D407 - | ^^^^^^^^^^^^^^^^^ D417 -435 | """Test a valid args section. - | - -sections.py:449:9: D417 Missing argument descriptions in the docstring for `test_missing_args_class_method`: `test`, `y`, `z` - | -447 | "(argument(s) test, y, z are missing descriptions in " -448 | "'test_missing_args_class_method' docstring)", arg_count=4) -449 | def test_missing_args_class_method(cls, test, x, y, z=3): # noqa: D213, D407 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D417 -450 | """Test a valid args section. - | - -sections.py:468:9: D417 Missing argument descriptions in the docstring for `test_missing_args_static_method`: `a`, `z` - | -466 | "(argument(s) a, z are missing descriptions in " -467 | "'test_missing_args_static_method' docstring)", arg_count=3) -468 | def test_missing_args_static_method(a, x, y, z=3, t=1): # noqa: D213, D407 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D417 -469 | """Test a valid args section. - | - -sections.py:498:9: D417 Missing argument description in the docstring for `test_incorrect_indent`: `y` - | -496 | "(argument(s) y are missing descriptions in " -497 | "'test_incorrect_indent' docstring)", arg_count=3) -498 | def test_incorrect_indent(self, x=1, y=2): # noqa: D207, D213, D407 - | ^^^^^^^^^^^^^^^^^^^^^ D417 -499 | """Reproducing issue #437. - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D418_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D418_D.py.snap deleted file mode 100644 index e73a606662..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D418_D.py.snap +++ /dev/null @@ -1,31 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:34:9: D418 Function decorated with `@overload` shouldn't contain a docstring - | -33 | @overload -34 | def overloaded_method(self, a: str) -> str: - | ^^^^^^^^^^^^^^^^^ D418 -35 | """Foo bar documentation.""" -36 | ... - | - -D.py:90:9: D418 Function decorated with `@overload` shouldn't contain a docstring - | -89 | @overload -90 | def nested_overloaded_func(a: str) -> str: - | ^^^^^^^^^^^^^^^^^^^^^^ D418 -91 | """Foo bar documentation.""" -92 | ... - | - -D.py:110:5: D418 Function decorated with `@overload` shouldn't contain a docstring - | -109 | @overload -110 | def overloaded_func(a: str) -> str: - | ^^^^^^^^^^^^^^^ D418 -111 | """Foo bar documentation.""" -112 | ... - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D419_D.py.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D419_D.py.snap deleted file mode 100644 index d4fd7d8427..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__D419_D.py.snap +++ /dev/null @@ -1,31 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D.py:20:9: D419 Docstring is empty - | -19 | class meta: -20 | """""" - | ^^^^^^ D419 -21 | -22 | @expect('D102: Missing docstring in public method') - | - -D.py:74:5: D419 Docstring is empty - | -72 | @expect('D419: Docstring is empty') -73 | def function(): -74 | """ """ - | ^^^^^^^ D419 -75 | def ok_since_nested(): -76 | pass - | - -D.py:80:9: D419 Docstring is empty - | -78 | @expect('D419: Docstring is empty') -79 | def nested(): -80 | '' - | ^^ D419 - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__all.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__all.snap deleted file mode 100644 index a2d8d2dd8f..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__all.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -all.py:1:1: D100 Missing docstring in public module - | -1 | def public_func(): - | D100 -2 | pass - | - -all.py:1:5: D103 Missing docstring in public function - | -1 | def public_func(): - | ^^^^^^^^^^^ D103 -2 | pass - | - -all.py:9:7: D101 Missing docstring in public class - | - 9 | class PublicClass: - | ^^^^^^^^^^^ D101 -10 | class PublicNestedClass: -11 | pass - | - -all.py:10:11: D106 Missing docstring in public nested class - | - 9 | class PublicClass: -10 | class PublicNestedClass: - | ^^^^^^^^^^^^^^^^^ D106 -11 | pass - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__bom.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__bom.snap deleted file mode 100644 index 6cbf9fcdd6..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__bom.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -bom.py:1:1: D300 Use triple double quotes `"""` - | -1 | ''' SAM macro definitions ''' - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D300 - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__d209_d400.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__d209_d400.snap deleted file mode 100644 index 4b0e26c0d5..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__d209_d400.snap +++ /dev/null @@ -1,37 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -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 - | _____^ -3 | | sed do eiusmod tempor incididunt ut labore et dolore magna aliqua""" - | |________________________________________________________________________^ D209 - | - = help: Move closing quotes to new line - -ℹ Fix -1 1 | def lorem(): -2 2 | """lorem ipsum dolor sit amet consectetur adipiscing elit -3 |- sed do eiusmod tempor incididunt ut labore et dolore magna aliqua""" - 3 |+ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua - 4 |+ """ - -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 - | _____^ -3 | | sed do eiusmod tempor incididunt ut labore et dolore magna aliqua""" - | |________________________________________________________________________^ D400 - | - = help: Add period - -ℹ Suggested fix -1 1 | def lorem(): -2 2 | """lorem ipsum dolor sit amet consectetur adipiscing elit -3 |- sed do eiusmod tempor incididunt ut labore et dolore magna aliqua""" - 3 |+ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.""" - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__d417_google.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__d417_google.snap deleted file mode 100644 index 184e5947bd..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__d417_google.snap +++ /dev/null @@ -1,67 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D417.py:1:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` - | -1 | def f(x, y, z): - | ^ D417 -2 | """Do something. - | - -D417.py:14:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` - | -14 | def f(x, y, z): - | ^ D417 -15 | """Do something. - | - -D417.py:27:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` - | -27 | def f(x, y, z): - | ^ D417 -28 | """Do something. - | - -D417.py:39:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` - | -39 | def f(x, y, z): - | ^ D417 -40 | """Do something. - | - -D417.py:52:5: D417 Missing argument description in the docstring for `f`: `y` - | -52 | def f(x, y, z): - | ^ D417 -53 | """Do something. - | - -D417.py:65:5: D417 Missing argument description in the docstring for `f`: `y` - | -65 | def f(x, y, z): - | ^ D417 -66 | """Do something. - | - -D417.py:77:5: D417 Missing argument description in the docstring for `f`: `y` - | -77 | def f(x, y, z): - | ^ D417 -78 | """Do something. - | - -D417.py:98:5: D417 Missing argument description in the docstring for `f`: `x` - | -98 | def f(x, *args, **kwargs): - | ^ D417 -99 | """Do something. - | - -D417.py:108:5: D417 Missing argument description in the docstring for `f`: `*args` - | -108 | def f(x, *args, **kwargs): - | ^ D417 -109 | """Do something. - | - - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__d417_numpy.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__d417_numpy.snap deleted file mode 100644 index 89dabd861c..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__d417_numpy.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- - diff --git a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__d417_unspecified.snap b/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__d417_unspecified.snap deleted file mode 100644 index 184e5947bd..0000000000 --- a/crates/ruff/src/rules/pydocstyle/snapshots/ruff__rules__pydocstyle__tests__d417_unspecified.snap +++ /dev/null @@ -1,67 +0,0 @@ ---- -source: crates/ruff/src/rules/pydocstyle/mod.rs ---- -D417.py:1:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` - | -1 | def f(x, y, z): - | ^ D417 -2 | """Do something. - | - -D417.py:14:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` - | -14 | def f(x, y, z): - | ^ D417 -15 | """Do something. - | - -D417.py:27:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` - | -27 | def f(x, y, z): - | ^ D417 -28 | """Do something. - | - -D417.py:39:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` - | -39 | def f(x, y, z): - | ^ D417 -40 | """Do something. - | - -D417.py:52:5: D417 Missing argument description in the docstring for `f`: `y` - | -52 | def f(x, y, z): - | ^ D417 -53 | """Do something. - | - -D417.py:65:5: D417 Missing argument description in the docstring for `f`: `y` - | -65 | def f(x, y, z): - | ^ D417 -66 | """Do something. - | - -D417.py:77:5: D417 Missing argument description in the docstring for `f`: `y` - | -77 | def f(x, y, z): - | ^ D417 -78 | """Do something. - | - -D417.py:98:5: D417 Missing argument description in the docstring for `f`: `x` - | -98 | def f(x, *args, **kwargs): - | ^ D417 -99 | """Do something. - | - -D417.py:108:5: D417 Missing argument description in the docstring for `f`: `*args` - | -108 | def f(x, *args, **kwargs): - | ^ D417 -109 | """Do something. - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_0.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_0.py.snap deleted file mode 100644 index 4968fd1616..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_0.py.snap +++ /dev/null @@ -1,286 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F401_0.py:2:8: F401 [*] `functools` imported but unused - | -1 | from __future__ import all_feature_names -2 | import functools, os - | ^^^^^^^^^ F401 -3 | from datetime import datetime -4 | from collections import ( - | - = help: Remove unused import: `functools` - -ℹ Fix -1 1 | from __future__ import all_feature_names -2 |-import functools, os - 2 |+import os -3 3 | from datetime import datetime -4 4 | from collections import ( -5 5 | Counter, - -F401_0.py:6:5: F401 [*] `collections.OrderedDict` imported but unused - | -4 | from collections import ( -5 | Counter, -6 | OrderedDict, - | ^^^^^^^^^^^ F401 -7 | namedtuple, -8 | ) - | - = help: Remove unused import: `collections.OrderedDict` - -ℹ Fix -3 3 | from datetime import datetime -4 4 | from collections import ( -5 5 | Counter, -6 |- OrderedDict, -7 6 | namedtuple, -8 7 | ) -9 8 | import multiprocessing.pool - -F401_0.py:12:8: F401 [*] `logging.handlers` imported but unused - | -10 | import multiprocessing.process -11 | import logging.config -12 | import logging.handlers - | ^^^^^^^^^^^^^^^^ F401 -13 | from typing import ( -14 | TYPE_CHECKING, - | - = help: Remove unused import: `logging.handlers` - -ℹ Fix -9 9 | import multiprocessing.pool -10 10 | import multiprocessing.process -11 11 | import logging.config -12 |-import logging.handlers -13 12 | from typing import ( -14 13 | TYPE_CHECKING, -15 14 | NamedTuple, - -F401_0.py:32:12: F401 [*] `shelve` imported but unused - | -31 | if TYPE_CHECKING: -32 | import shelve - | ^^^^^^ F401 -33 | import importlib - | - = help: Remove unused import: `shelve` - -ℹ Fix -29 29 | from models import Fruit, Nut, Vegetable -30 30 | -31 31 | if TYPE_CHECKING: -32 |- import shelve -33 32 | import importlib -34 33 | -35 34 | if TYPE_CHECKING: - -F401_0.py:33:12: F401 [*] `importlib` imported but unused - | -31 | if TYPE_CHECKING: -32 | import shelve -33 | import importlib - | ^^^^^^^^^ F401 -34 | -35 | if TYPE_CHECKING: - | - = help: Remove unused import: `importlib` - -ℹ Fix -30 30 | -31 31 | if TYPE_CHECKING: -32 32 | import shelve -33 |- import importlib -34 33 | -35 34 | if TYPE_CHECKING: -36 35 | """Hello, world!""" - -F401_0.py:37:12: F401 [*] `pathlib` imported but unused - | -35 | if TYPE_CHECKING: -36 | """Hello, world!""" -37 | import pathlib - | ^^^^^^^ F401 -38 | -39 | z = 1 - | - = help: Remove unused import: `pathlib` - -ℹ Fix -34 34 | -35 35 | if TYPE_CHECKING: -36 36 | """Hello, world!""" -37 |- import pathlib -38 37 | -39 38 | z = 1 -40 39 | - -F401_0.py:52:16: F401 [*] `pickle` imported but unused - | -51 | def b(self) -> None: -52 | import pickle - | ^^^^^^ F401 - | - = help: Remove unused import: `pickle` - -ℹ Fix -49 49 | z = multiprocessing.pool.ThreadPool() -50 50 | -51 51 | def b(self) -> None: -52 |- import pickle - 52 |+ pass -53 53 | -54 54 | -55 55 | __all__ = ["ClassA"] + ["ClassB"] - -F401_0.py:93:16: F401 [*] `x` imported but unused - | -91 | match *0, 1, *2: -92 | case 0,: -93 | import x - | ^ F401 -94 | import y - | - = help: Remove unused import: `x` - -ℹ Fix -90 90 | # Test: match statements. -91 91 | match *0, 1, *2: -92 92 | case 0,: -93 |- import x -94 93 | import y -95 94 | -96 95 | - -F401_0.py:94:16: F401 [*] `y` imported but unused - | -92 | case 0,: -93 | import x -94 | import y - | ^ F401 - | - = help: Remove unused import: `y` - -ℹ Fix -91 91 | match *0, 1, *2: -92 92 | case 0,: -93 93 | import x -94 |- import y -95 94 | -96 95 | -97 96 | # Test: access a sub-importation via an alias. - -F401_0.py:99:8: F401 [*] `foo.bar.baz` imported but unused - | - 97 | # Test: access a sub-importation via an alias. - 98 | import foo.bar as bop - 99 | import foo.bar.baz - | ^^^^^^^^^^^ F401 -100 | -101 | print(bop.baz.read_csv("test.csv")) - | - = help: Remove unused import: `foo.bar.baz` - -ℹ Fix -96 96 | -97 97 | # Test: access a sub-importation via an alias. -98 98 | import foo.bar as bop -99 |-import foo.bar.baz -100 99 | -101 100 | print(bop.baz.read_csv("test.csv")) -102 101 | - -F401_0.py:105:12: F401 [*] `a1` imported but unused - | -103 | # Test: isolated deletions. -104 | if TYPE_CHECKING: -105 | import a1 - | ^^ F401 -106 | -107 | import a2 - | - = help: Remove unused import: `a1` - -ℹ Fix -102 102 | -103 103 | # Test: isolated deletions. -104 104 | if TYPE_CHECKING: -105 |- import a1 -106 105 | -107 106 | import a2 -108 107 | - -F401_0.py:107:12: F401 [*] `a2` imported but unused - | -105 | import a1 -106 | -107 | import a2 - | ^^ F401 - | - = help: Remove unused import: `a2` - -ℹ Fix -104 104 | if TYPE_CHECKING: -105 105 | import a1 -106 106 | -107 |- import a2 -108 107 | -109 108 | -110 109 | match *0, 1, *2: - -F401_0.py:112:16: F401 [*] `b1` imported but unused - | -110 | match *0, 1, *2: -111 | case 0,: -112 | import b1 - | ^^ F401 -113 | -114 | import b2 - | - = help: Remove unused import: `b1` - -ℹ Fix -109 109 | -110 110 | match *0, 1, *2: -111 111 | case 0,: -112 |- import b1 -113 112 | -114 113 | import b2 -115 114 | - -F401_0.py:114:16: F401 [*] `b2` imported but unused - | -112 | import b1 -113 | -114 | import b2 - | ^^ F401 - | - = help: Remove unused import: `b2` - -ℹ Fix -111 111 | case 0,: -112 112 | import b1 -113 113 | -114 |- import b2 -115 114 | -116 115 | -117 116 | # Regression test for: https://github.com/astral-sh/ruff/issues/7244 - -F401_0.py:122:1: F401 [*] `datameta_client_lib.model_helpers.noqa` imported but unused - | -121 | from datameta_client_lib.model_helpers import ( -122 | noqa ) - | ^^^^ F401 - | - = help: Remove unused import: `datameta_client_lib.model_helpers.noqa` - -ℹ Fix -118 118 | from datameta_client_lib.model_utils import ( # noqa: F401 -119 119 | noqa ) -120 120 | -121 |-from datameta_client_lib.model_helpers import ( -122 |-noqa ) - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_1.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_1.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_1.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_10.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_10.py.snap deleted file mode 100644 index 3e73b2a878..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_10.py.snap +++ /dev/null @@ -1,26 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F401_10.py:6:16: F401 `orjson` imported but unused; consider using `importlib.util.find_spec` to test for availability - | -4 | def module_not_found_error(): -5 | try: -6 | import orjson - | ^^^^^^ F401 -7 | -8 | return True - | - = help: Remove unused import: `orjson` - -F401_10.py:15:16: F401 `orjson` imported but unused; consider using `importlib.util.find_spec` to test for availability - | -13 | def import_error(): -14 | try: -15 | import orjson - | ^^^^^^ F401 -16 | -17 | return True - | - = help: Remove unused import: `orjson` - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_11.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_11.py.snap deleted file mode 100644 index 760c989c0f..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_11.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F401_11.py:4:27: F401 [*] `pathlib.PurePath` imported but unused - | -3 | from typing import List -4 | from pathlib import Path, PurePath - | ^^^^^^^^ F401 - | - = help: Remove unused import: `pathlib.PurePath` - -ℹ Fix -1 1 | """Test: parsing of nested string annotations.""" -2 2 | -3 3 | from typing import List -4 |-from pathlib import Path, PurePath - 4 |+from pathlib import Path -5 5 | -6 6 | -7 7 | x: """List['Path']""" = [] - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_12.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_12.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_12.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_13.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_13.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_13.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_14.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_14.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_14.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_15.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_15.py.snap deleted file mode 100644 index 93cf621c5d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_15.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F401_15.py:5:25: F401 [*] `pathlib.Path` imported but unused - | -4 | if TYPE_CHECKING: -5 | from pathlib import Path - | ^^^^ F401 - | - = help: Remove unused import: `pathlib.Path` - -ℹ Fix -2 2 | from django.db.models import ForeignKey -3 3 | -4 4 | if TYPE_CHECKING: -5 |- from pathlib import Path - 5 |+ pass -6 6 | -7 7 | -8 8 | class Foo: - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_16.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_16.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_16.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_17.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_17.py.snap deleted file mode 100644 index ca6046706b..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_17.py.snap +++ /dev/null @@ -1,42 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F401_17.py:12:27: F401 [*] `threading.Thread` imported but unused - | -11 | def fn(thread: Thread): -12 | from threading import Thread - | ^^^^^^ F401 -13 | -14 | # The `Thread` on the left-hand side should resolve to the `Thread` imported at the - | - = help: Remove unused import: `threading.Thread` - -ℹ Fix -9 9 | -10 10 | -11 11 | def fn(thread: Thread): -12 |- from threading import Thread -13 12 | -14 13 | # The `Thread` on the left-hand side should resolve to the `Thread` imported at the -15 14 | # top level. - -F401_17.py:20:27: F401 [*] `threading.Thread` imported but unused - | -19 | def fn(thread: Thread): -20 | from threading import Thread - | ^^^^^^ F401 -21 | -22 | # The `Thread` on the left-hand side should resolve to the `Thread` imported at the - | - = help: Remove unused import: `threading.Thread` - -ℹ Fix -17 17 | -18 18 | -19 19 | def fn(thread: Thread): -20 |- from threading import Thread -21 20 | -22 21 | # The `Thread` on the left-hand side should resolve to the `Thread` imported at the -23 22 | # top level. - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_18.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_18.py.snap deleted file mode 100644 index d49e67f268..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_18.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F401_18.py:5:12: F401 [*] `__future__` imported but unused - | -4 | def f(): -5 | import __future__ - | ^^^^^^^^^^ F401 - | - = help: Remove unused import: `future` - -ℹ Fix -2 2 | -3 3 | -4 4 | def f(): -5 |- import __future__ - 5 |+ pass -6 6 | -7 7 | -8 8 | def f(): - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_2.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_2.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_2.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_3.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_3.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_3.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_4.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_4.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_4.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_5.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_5.py.snap deleted file mode 100644 index 7be6dbbe89..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_5.py.snap +++ /dev/null @@ -1,71 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F401_5.py:2:17: F401 [*] `a.b.c` imported but unused - | -1 | """Test: removal of multi-segment and aliases imports.""" -2 | from a.b import c - | ^ F401 -3 | from d.e import f as g -4 | import h.i - | - = help: Remove unused import: `a.b.c` - -ℹ Fix -1 1 | """Test: removal of multi-segment and aliases imports.""" -2 |-from a.b import c -3 2 | from d.e import f as g -4 3 | import h.i -5 4 | import j.k as l - -F401_5.py:3:22: F401 [*] `d.e.f` imported but unused - | -1 | """Test: removal of multi-segment and aliases imports.""" -2 | from a.b import c -3 | from d.e import f as g - | ^ F401 -4 | import h.i -5 | import j.k as l - | - = help: Remove unused import: `d.e.f` - -ℹ Fix -1 1 | """Test: removal of multi-segment and aliases imports.""" -2 2 | from a.b import c -3 |-from d.e import f as g -4 3 | import h.i -5 4 | import j.k as l - -F401_5.py:4:8: F401 [*] `h.i` imported but unused - | -2 | from a.b import c -3 | from d.e import f as g -4 | import h.i - | ^^^ F401 -5 | import j.k as l - | - = help: Remove unused import: `h.i` - -ℹ Fix -1 1 | """Test: removal of multi-segment and aliases imports.""" -2 2 | from a.b import c -3 3 | from d.e import f as g -4 |-import h.i -5 4 | import j.k as l - -F401_5.py:5:15: F401 [*] `j.k` imported but unused - | -3 | from d.e import f as g -4 | import h.i -5 | import j.k as l - | ^ F401 - | - = help: Remove unused import: `j.k` - -ℹ Fix -2 2 | from a.b import c -3 3 | from d.e import f as g -4 4 | import h.i -5 |-import j.k as l - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_6.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_6.py.snap deleted file mode 100644 index a6b21228c3..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_6.py.snap +++ /dev/null @@ -1,75 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -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 | -9 | # F401 `datastructures.UploadFile` imported but unused - | - = help: Remove unused import: `.background.BackgroundTasks` - -ℹ Fix -4 4 | from .applications import FastAPI as FastAPI -5 5 | -6 6 | # F401 `background.BackgroundTasks` imported but unused -7 |-from .background import BackgroundTasks -8 7 | -9 8 | # F401 `datastructures.UploadFile` imported but unused -10 9 | from .datastructures import UploadFile as FileUpload - -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 | -12 | # OK - | - = help: Remove unused import: `.datastructures.UploadFile` - -ℹ Fix -7 7 | from .background import BackgroundTasks -8 8 | -9 9 | # F401 `datastructures.UploadFile` imported but unused -10 |-from .datastructures import UploadFile as FileUpload -11 10 | -12 11 | # OK -13 12 | import applications as applications - -F401_6.py:16:8: F401 [*] `background` imported but unused - | -15 | # F401 `background` imported but unused -16 | import background - | ^^^^^^^^^^ F401 -17 | -18 | # F401 `datastructures` imported but unused - | - = help: Remove unused import: `background` - -ℹ Fix -13 13 | import applications as applications -14 14 | -15 15 | # F401 `background` imported but unused -16 |-import background -17 16 | -18 17 | # F401 `datastructures` imported but unused -19 18 | import datastructures as structures - -F401_6.py:19:26: F401 [*] `datastructures` imported but unused - | -18 | # F401 `datastructures` imported but unused -19 | import datastructures as structures - | ^^^^^^^^^^ F401 - | - = help: Remove unused import: `datastructures` - -ℹ Fix -16 16 | import background -17 17 | -18 18 | # F401 `datastructures` imported but unused -19 |-import datastructures as structures - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_7.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_7.py.snap deleted file mode 100644 index 264b94f6ba..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_7.py.snap +++ /dev/null @@ -1,53 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F401_7.py:30:5: F401 [*] `typing.Union` imported but unused - | -28 | from typing import ( -29 | Mapping, # noqa: F401 -30 | Union, - | ^^^^^ F401 -31 | ) - | - = help: Remove unused import: `typing.Union` - -ℹ Fix -27 27 | # This should ignore the first error. -28 28 | from typing import ( -29 29 | Mapping, # noqa: F401 -30 |- Union, -31 |-) - 30 |+ ) -32 31 | -33 32 | # This should ignore both errors. -34 33 | from typing import ( # noqa - -F401_7.py:66:20: F401 [*] `typing.Awaitable` imported but unused - | -65 | # This should mark F501 as unused. -66 | from typing import Awaitable, AwaitableGenerator # noqa: F501 - | ^^^^^^^^^ F401 - | - = help: Remove unused import - -ℹ Fix -63 63 | from typing import AsyncIterable, AsyncGenerator # noqa -64 64 | -65 65 | # This should mark F501 as unused. -66 |-from typing import Awaitable, AwaitableGenerator # noqa: F501 - -F401_7.py:66:31: F401 [*] `typing.AwaitableGenerator` imported but unused - | -65 | # This should mark F501 as unused. -66 | from typing import Awaitable, AwaitableGenerator # noqa: F501 - | ^^^^^^^^^^^^^^^^^^ F401 - | - = help: Remove unused import - -ℹ Fix -63 63 | from typing import AsyncIterable, AsyncGenerator # noqa -64 64 | -65 65 | # This should mark F501 as unused. -66 |-from typing import Awaitable, AwaitableGenerator # noqa: F501 - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_8.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_8.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_8.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_9.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_9.py.snap deleted file mode 100644 index bd6be4b40d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F401_F401_9.py.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F401_9.py:4:22: F401 [*] `foo.baz` imported but unused - | -3 | __all__ = ("bar",) -4 | from foo import bar, baz - | ^^^ F401 - | - = help: Remove unused import: `foo.baz` - -ℹ Fix -1 1 | """Test: late-binding of `__all__`.""" -2 2 | -3 3 | __all__ = ("bar",) -4 |-from foo import bar, baz - 4 |+from foo import bar - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F402_F402.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F402_F402.py.snap deleted file mode 100644 index 2ef7eab91b..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F402_F402.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F402.py:5:5: F402 Import `os` from line 1 shadowed by loop variable - | -5 | for os in range(3): - | ^^ F402 -6 | pass - | - -F402.py:8:5: F402 Import `path` from line 2 shadowed by loop variable - | -6 | pass -7 | -8 | for path in range(3): - | ^^^^ F402 -9 | pass - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F403_F403.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F403_F403.py.snap deleted file mode 100644 index 4c6ce9d319..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F403_F403.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F403.py:1:1: F403 `from F634 import *` used; unable to detect undefined names - | -1 | from F634 import * - | ^^^^^^^^^^^^^^^^^^ F403 -2 | from F634 import * # noqa: E501 - | - -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 | -4 | from F634 import * # noqa - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F404_F404.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F404_F404.py.snap deleted file mode 100644 index feba0f8d20..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F404_F404.py.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F404.py:6:1: F404 `from __future__` imports must occur at the beginning of the file - | -4 | from collections import namedtuple -5 | -6 | from __future__ import print_function - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F404 -7 | -8 | import __future__ - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F405_F405.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F405_F405.py.snap deleted file mode 100644 index 218b8dc5e2..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F405_F405.py.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F405.py:5:11: F405 `name` may be undefined, or defined from star imports - | -4 | def print_name(): -5 | print(name) - | ^^^^ F405 - | - -F405.py:11:1: F405 `a` may be undefined, or defined from star imports - | - 9 | print(name) -10 | -11 | __all__ = ['a'] - | ^^^^^^^ F405 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F406_F406.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F406_F406.py.snap deleted file mode 100644 index d4ef894cc6..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F406_F406.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F406.py:5:5: F406 `from F634 import *` only allowed at module level - | -4 | def f(): -5 | from F634 import * - | ^^^^^^^^^^^^^^^^^^ F406 - | - -F406.py:9:5: F406 `from F634 import *` only allowed at module level - | -8 | class F: -9 | from F634 import * - | ^^^^^^^^^^^^^^^^^^ F406 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F407_F407.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F407_F407.py.snap deleted file mode 100644 index 79345c97d4..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F407_F407.py.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F407.py:2:24: F407 Future feature `non_existent_feature` is not defined - | -1 | from __future__ import print_function -2 | from __future__ import non_existent_feature - | ^^^^^^^^^^^^^^^^^^^^ F407 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F501_F50x.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F501_F50x.py.snap deleted file mode 100644 index 013a8d5a4b..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F501_F50x.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F50x.py:1:1: F501 `%`-format string has invalid format string: incomplete format - | -1 | '%(foo)' % {'foo': 'bar'} # F501 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ F501 -2 | '%s %(foo)s' % {'foo': 'bar'} # F506 -3 | '%(foo)s %s' % {'foo': 'bar'} # F506 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F502_F502.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F502_F502.py.snap deleted file mode 100644 index 9803d28696..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F502_F502.py.snap +++ /dev/null @@ -1,71 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F502.py:6:1: F502 `%`-format string expected mapping but got sequence - | -4 | "%(bob)s" % {"bob": "bob"} -5 | "%(bob)s" % {**{"bob": "bob"}} -6 | "%(bob)s" % ["bob"] # F202 - | ^^^^^^^^^^^^^^^^^^^ F502 -7 | "%(bob)s" % ("bob",) # F202 -8 | "%(bob)s" % {"bob"} # F202 - | - -F502.py:7:1: F502 `%`-format string expected mapping but got sequence - | -5 | "%(bob)s" % {**{"bob": "bob"}} -6 | "%(bob)s" % ["bob"] # F202 -7 | "%(bob)s" % ("bob",) # F202 - | ^^^^^^^^^^^^^^^^^^^^ F502 -8 | "%(bob)s" % {"bob"} # F202 -9 | "%(bob)s" % [*["bob"]] # F202 - | - -F502.py:8:1: F502 `%`-format string expected mapping but got sequence - | - 6 | "%(bob)s" % ["bob"] # F202 - 7 | "%(bob)s" % ("bob",) # F202 - 8 | "%(bob)s" % {"bob"} # F202 - | ^^^^^^^^^^^^^^^^^^^ F502 - 9 | "%(bob)s" % [*["bob"]] # F202 -10 | "%(bob)s" % {"bob": "bob" for _ in range(1)} - | - -F502.py:9:1: F502 `%`-format string expected mapping but got sequence - | - 7 | "%(bob)s" % ("bob",) # F202 - 8 | "%(bob)s" % {"bob"} # F202 - 9 | "%(bob)s" % [*["bob"]] # F202 - | ^^^^^^^^^^^^^^^^^^^^^^ F502 -10 | "%(bob)s" % {"bob": "bob" for _ in range(1)} -11 | "%(bob)s" % ["bob" for _ in range(1)] # F202 - | - -F502.py:11:1: F502 `%`-format string expected mapping but got sequence - | - 9 | "%(bob)s" % [*["bob"]] # F202 -10 | "%(bob)s" % {"bob": "bob" for _ in range(1)} -11 | "%(bob)s" % ["bob" for _ in range(1)] # F202 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F502 -12 | "%(bob)s" % ("bob" for _ in range(1)) # F202 -13 | "%(bob)s" % {"bob" for _ in range(1)} # F202 - | - -F502.py:12:1: F502 `%`-format string expected mapping but got sequence - | -10 | "%(bob)s" % {"bob": "bob" for _ in range(1)} -11 | "%(bob)s" % ["bob" for _ in range(1)] # F202 -12 | "%(bob)s" % ("bob" for _ in range(1)) # F202 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F502 -13 | "%(bob)s" % {"bob" for _ in range(1)} # F202 - | - -F502.py:13:1: F502 `%`-format string expected mapping but got sequence - | -11 | "%(bob)s" % ["bob" for _ in range(1)] # F202 -12 | "%(bob)s" % ("bob" for _ in range(1)) # F202 -13 | "%(bob)s" % {"bob" for _ in range(1)} # F202 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F502 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F502_F50x.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F502_F50x.py.snap deleted file mode 100644 index 411e3e1fce..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F502_F50x.py.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F50x.py:9:1: F502 `%`-format string expected mapping but got sequence - | - 7 | '%(bar)s' % {} # F505 - 8 | '%(bar)s' % {'bar': 1, 'baz': 2} # F504 - 9 | '%(bar)s' % (1, 2, 3) # F502 - | ^^^^^^^^^^^^^^^^^^^^^ F502 -10 | '%s %s' % {'k': 'v'} # F503 -11 | '%(bar)*s' % {'bar': 'baz'} # F506, F508 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F503_F503.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F503_F503.py.snap deleted file mode 100644 index 00340ae913..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F503_F503.py.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F503.py:17:1: F503 `%`-format string expected sequence but got mapping - | -15 | # Multiple placeholders -16 | "%s %s" % dog -17 | "%s %s" % {"bob": "bob"} # F503 - | ^^^^^^^^^^^^^^^^^^^^^^^^ F503 -18 | "%s %s" % {**{"bob": "bob"}} # F503 -19 | "%s %s" % ["bob"] - | - -F503.py:18:1: F503 `%`-format string expected sequence but got mapping - | -16 | "%s %s" % dog -17 | "%s %s" % {"bob": "bob"} # F503 -18 | "%s %s" % {**{"bob": "bob"}} # F503 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F503 -19 | "%s %s" % ["bob"] -20 | "%s %s" % ("bob",) - | - -F503.py:23:1: F503 `%`-format string expected sequence but got mapping - | -21 | "%s %s" % {"bob"} -22 | "%s %s" % [*["bob"]] -23 | "%s %s" % {"bob": "bob" for _ in range(1)} # F503 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F503 -24 | "%s %s" % ["bob" for _ in range(1)] -25 | "%s %s" % ("bob" for _ in range(1)) - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F503_F50x.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F503_F50x.py.snap deleted file mode 100644 index 49a38e7183..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F503_F50x.py.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F50x.py:10:1: F503 `%`-format string expected sequence but got mapping - | - 8 | '%(bar)s' % {'bar': 1, 'baz': 2} # F504 - 9 | '%(bar)s' % (1, 2, 3) # F502 -10 | '%s %s' % {'k': 'v'} # F503 - | ^^^^^^^^^^^^^^^^^^^^ F503 -11 | '%(bar)*s' % {'bar': 'baz'} # F506, F508 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F504_F504.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F504_F504.py.snap deleted file mode 100644 index c9035cd3c4..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F504_F504.py.snap +++ /dev/null @@ -1,103 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F504.py:3:1: F504 [*] `%`-format string has unused named argument(s): b - | -1 | # Ruff has no way of knowing if the following are F505s -2 | a = "wrong" -3 | "%(a)s %(c)s" % {a: "?", "b": "!"} # F504 ("b" not used) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F504 -4 | -5 | hidden = {"a": "!"} - | - = help: Remove extra named arguments: b - -ℹ Fix -1 1 | # Ruff has no way of knowing if the following are F505s -2 2 | a = "wrong" -3 |-"%(a)s %(c)s" % {a: "?", "b": "!"} # F504 ("b" not used) - 3 |+"%(a)s %(c)s" % {a: "?", } # F504 ("b" not used) -4 4 | -5 5 | hidden = {"a": "!"} -6 6 | "%(a)s %(c)s" % {"x": 1, **hidden} # Ok (cannot see through splat) - -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 | -8 | "%(a)s" % {"a": 1, r"b": "!"} # F504 ("b" not used) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F504 -9 | "%(a)s" % {'a': 1, u"b": "!"} # F504 ("b" not used) - | - = help: Remove extra named arguments: b - -ℹ Fix -5 5 | hidden = {"a": "!"} -6 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) - 8 |+"%(a)s" % {"a": 1, } # F504 ("b" not used) -9 9 | "%(a)s" % {'a': 1, u"b": "!"} # F504 ("b" not used) -10 10 | -11 11 | '' % {'a''b' : ''} # F504 ("ab" not used) - -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 | -11 | '' % {'a''b' : ''} # F504 ("ab" not used) - | - = help: Remove extra named arguments: b - -ℹ Fix -6 6 | "%(a)s %(c)s" % {"x": 1, **hidden} # Ok (cannot see through splat) -7 7 | -8 8 | "%(a)s" % {"a": 1, r"b": "!"} # F504 ("b" not used) -9 |-"%(a)s" % {'a': 1, u"b": "!"} # F504 ("b" not used) - 9 |+"%(a)s" % {'a': 1, } # F504 ("b" not used) -10 10 | -11 11 | '' % {'a''b' : ''} # F504 ("ab" not used) -12 12 | - -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 | -11 | '' % {'a''b' : ''} # F504 ("ab" not used) - | ^^^^^^^^^^^^^^^^^^ F504 -12 | -13 | # https://github.com/astral-sh/ruff/issues/4899 - | - = help: Remove extra named arguments: ab - -ℹ Fix -8 8 | "%(a)s" % {"a": 1, r"b": "!"} # F504 ("b" not used) -9 9 | "%(a)s" % {'a': 1, u"b": "!"} # F504 ("b" not used) -10 10 | -11 |-'' % {'a''b' : ''} # F504 ("ab" not used) - 11 |+'' % {} # F504 ("ab" not used) -12 12 | -13 13 | # https://github.com/astral-sh/ruff/issues/4899 -14 14 | "" % { - -F504.py:14:1: F504 [*] `%`-format string has unused named argument(s): test1, test2 - | -13 | # https://github.com/astral-sh/ruff/issues/4899 -14 | / "" % { -15 | | 'test1': '', 'test2': '', -16 | | } - | |_^ F504 - | - = help: Remove extra named arguments: test1, test2 - -ℹ Fix -12 12 | -13 13 | # https://github.com/astral-sh/ruff/issues/4899 -14 14 | "" % { -15 |- 'test1': '', 16 |- 'test2': '', - 15 |+ -17 16 | } - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F504_F50x.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F504_F50x.py.snap deleted file mode 100644 index c8b2c5e78a..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F504_F50x.py.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F50x.py:8:1: F504 [*] `%`-format string has unused named argument(s): baz - | - 6 | '%s %s' % (1, 2, 3) # F507 - 7 | '%(bar)s' % {} # F505 - 8 | '%(bar)s' % {'bar': 1, 'baz': 2} # F504 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F504 - 9 | '%(bar)s' % (1, 2, 3) # F502 -10 | '%s %s' % {'k': 'v'} # F503 - | - = help: Remove extra named arguments: baz - -ℹ Fix -5 5 | '%s %s' % (1,) # F507 -6 6 | '%s %s' % (1, 2, 3) # F507 -7 7 | '%(bar)s' % {} # F505 -8 |-'%(bar)s' % {'bar': 1, 'baz': 2} # F504 - 8 |+'%(bar)s' % {'bar': 1, } # F504 -9 9 | '%(bar)s' % (1, 2, 3) # F502 -10 10 | '%s %s' % {'k': 'v'} # F503 -11 11 | '%(bar)*s' % {'bar': 'baz'} # F506, F508 - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F505_F504.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F505_F504.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F505_F504.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F505_F50x.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F505_F50x.py.snap deleted file mode 100644 index f756f01c29..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F505_F50x.py.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F50x.py:7:1: F505 `%`-format string is missing argument(s) for placeholder(s): bar - | -5 | '%s %s' % (1,) # F507 -6 | '%s %s' % (1, 2, 3) # F507 -7 | '%(bar)s' % {} # F505 - | ^^^^^^^^^^^^^^ F505 -8 | '%(bar)s' % {'bar': 1, 'baz': 2} # F504 -9 | '%(bar)s' % (1, 2, 3) # F502 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F506_F50x.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F506_F50x.py.snap deleted file mode 100644 index f19322c73b..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F506_F50x.py.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F50x.py:2:1: F506 `%`-format string has mixed positional and named placeholders - | -1 | '%(foo)' % {'foo': 'bar'} # F501 -2 | '%s %(foo)s' % {'foo': 'bar'} # F506 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F506 -3 | '%(foo)s %s' % {'foo': 'bar'} # F506 -4 | '%j' % (1,) # F509 - | - -F50x.py:3:1: F506 `%`-format string has mixed positional and named placeholders - | -1 | '%(foo)' % {'foo': 'bar'} # F501 -2 | '%s %(foo)s' % {'foo': 'bar'} # F506 -3 | '%(foo)s %s' % {'foo': 'bar'} # F506 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F506 -4 | '%j' % (1,) # F509 -5 | '%s %s' % (1,) # F507 - | - -F50x.py:11:1: F506 `%`-format string has mixed positional and named placeholders - | - 9 | '%(bar)s' % (1, 2, 3) # F502 -10 | '%s %s' % {'k': 'v'} # F503 -11 | '%(bar)*s' % {'bar': 'baz'} # F506, F508 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ F506 -12 | -13 | # ok: single %s with mapping - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F507_F50x.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F507_F50x.py.snap deleted file mode 100644 index 86e095046e..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F507_F50x.py.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F50x.py:5:1: F507 `%`-format string has 2 placeholder(s) but 1 substitution(s) - | -3 | '%(foo)s %s' % {'foo': 'bar'} # F506 -4 | '%j' % (1,) # F509 -5 | '%s %s' % (1,) # F507 - | ^^^^^^^^^^^^^^ F507 -6 | '%s %s' % (1, 2, 3) # F507 -7 | '%(bar)s' % {} # F505 - | - -F50x.py:6:1: F507 `%`-format string has 2 placeholder(s) but 3 substitution(s) - | -4 | '%j' % (1,) # F509 -5 | '%s %s' % (1,) # F507 -6 | '%s %s' % (1, 2, 3) # F507 - | ^^^^^^^^^^^^^^^^^^^ F507 -7 | '%(bar)s' % {} # F505 -8 | '%(bar)s' % {'bar': 1, 'baz': 2} # F504 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F508_F50x.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F508_F50x.py.snap deleted file mode 100644 index 85a718379a..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F508_F50x.py.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F50x.py:11:1: F508 `%`-format string `*` specifier requires sequence - | - 9 | '%(bar)s' % (1, 2, 3) # F502 -10 | '%s %s' % {'k': 'v'} # F503 -11 | '%(bar)*s' % {'bar': 'baz'} # F506, F508 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ F508 -12 | -13 | # ok: single %s with mapping - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F509_F50x.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F509_F50x.py.snap deleted file mode 100644 index 7ec0627419..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F509_F50x.py.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F50x.py:4:1: F509 `%`-format string has unsupported format character `j` - | -2 | '%s %(foo)s' % {'foo': 'bar'} # F506 -3 | '%(foo)s %s' % {'foo': 'bar'} # F506 -4 | '%j' % (1,) # F509 - | ^^^^^^^^^^^ F509 -5 | '%s %s' % (1,) # F507 -6 | '%s %s' % (1, 2, 3) # F507 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F521_F521.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F521_F521.py.snap deleted file mode 100644 index 7e5cb863c7..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F521_F521.py.snap +++ /dev/null @@ -1,70 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F521.py:1:1: F521 `.format` call has invalid format string: Single '{' encountered in format string - | -1 | "{".format(1) - | ^^^^^^^^^^^^^ F521 -2 | "}".format(1) -3 | "{foo[}".format(foo=1) - | - -F521.py:2:1: F521 `.format` call has invalid format string: Single '}' encountered in format string - | -1 | "{".format(1) -2 | "}".format(1) - | ^^^^^^^^^^^^^ F521 -3 | "{foo[}".format(foo=1) -4 | # too much string recursion (placeholder-in-placeholder) - | - -F521.py:3:1: F521 `.format` call has invalid format string: Expected '}' before end of string - | -1 | "{".format(1) -2 | "}".format(1) -3 | "{foo[}".format(foo=1) - | ^^^^^^^^^^^^^^^^^^^^^^ F521 -4 | # too much string recursion (placeholder-in-placeholder) -5 | "{:{:{}}}".format(1, 2, 3) - | - -F521.py:5:1: F521 `.format` call has invalid format string: Max format placeholder recursion exceeded - | -3 | "{foo[}".format(foo=1) -4 | # too much string recursion (placeholder-in-placeholder) -5 | "{:{:{}}}".format(1, 2, 3) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ F521 -6 | # ruff picks these issues up, but flake8 doesn't -7 | "{foo[]}".format(foo={"": 1}) - | - -F521.py:7:1: F521 `.format` call has invalid format string: Empty attribute in format string - | -5 | "{:{:{}}}".format(1, 2, 3) -6 | # ruff picks these issues up, but flake8 doesn't -7 | "{foo[]}".format(foo={"": 1}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F521 -8 | "{foo..}".format(foo=1) -9 | "{foo..bar}".format(foo=1) - | - -F521.py:8:1: F521 `.format` call has invalid format string: Empty attribute in format string - | -6 | # ruff picks these issues up, but flake8 doesn't -7 | "{foo[]}".format(foo={"": 1}) -8 | "{foo..}".format(foo=1) - | ^^^^^^^^^^^^^^^^^^^^^^^ F521 -9 | "{foo..bar}".format(foo=1) - | - -F521.py:9:1: F521 `.format` call has invalid format string: Empty attribute in format string - | - 7 | "{foo[]}".format(foo={"": 1}) - 8 | "{foo..}".format(foo=1) - 9 | "{foo..bar}".format(foo=1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ F521 -10 | -11 | # The following are all "good" uses of .format - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F522_F522.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F522_F522.py.snap deleted file mode 100644 index 8581e62d0b..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F522_F522.py.snap +++ /dev/null @@ -1,76 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F522.py:1:1: F522 [*] `.format` call has unused named argument(s): bar - | -1 | "{}".format(1, bar=2) # F522 - | ^^^^^^^^^^^^^^^^^^^^^ F522 -2 | "{bar}{}".format(1, bar=2, spam=3) # F522 -3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues - | - = help: Remove extra named arguments: bar - -ℹ Fix -1 |-"{}".format(1, bar=2) # F522 - 1 |+"{}".format(1, ) # F522 -2 2 | "{bar}{}".format(1, bar=2, spam=3) # F522 -3 3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues -4 4 | "{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 - -F522.py:2:1: F522 [*] `.format` call has unused named argument(s): spam - | -1 | "{}".format(1, bar=2) # F522 -2 | "{bar}{}".format(1, bar=2, spam=3) # F522 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F522 -3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues -4 | "{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 - | - = help: Remove extra named arguments: spam - -ℹ Fix -1 1 | "{}".format(1, bar=2) # F522 -2 |-"{bar}{}".format(1, bar=2, spam=3) # F522 - 2 |+"{bar}{}".format(1, bar=2, ) # F522 -3 3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues -4 4 | "{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 -5 5 | ('' - -F522.py:4:1: F522 [*] `.format` call has unused named argument(s): eggs, ham - | -2 | "{bar}{}".format(1, bar=2, spam=3) # F522 -3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues -4 | "{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F522 -5 | ('' -6 | .format(x=2)) # F522 - | - = help: Remove extra named arguments: eggs, ham - -ℹ Fix -1 1 | "{}".format(1, bar=2) # F522 -2 2 | "{bar}{}".format(1, bar=2, spam=3) # F522 -3 3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues -4 |-"{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 - 4 |+"{bar:{spam}}".format(bar=2, spam=3, ) # F522 -5 5 | ('' -6 6 | .format(x=2)) # F522 - -F522.py:5:2: F522 [*] `.format` call has unused named argument(s): x - | -3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues -4 | "{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 -5 | ('' - | __^ -6 | | .format(x=2)) # F522 - | |_____________^ F522 - | - = help: Remove extra named arguments: x - -ℹ Fix -3 3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues -4 4 | "{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 -5 5 | ('' -6 |- .format(x=2)) # F522 - 6 |+ .format()) # F522 - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F523_F523.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F523_F523.py.snap deleted file mode 100644 index f84189c4be..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F523_F523.py.snap +++ /dev/null @@ -1,267 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F523.py:2:1: F523 [*] `.format` call has unused arguments at position(s): 1 - | -1 | # With indexes -2 | "{0}".format(1, 2) # F523 - | ^^^^^^^^^^^^^^^^^^ F523 -3 | "{1}".format(1, 2, 3) # F523 -4 | "{1:{0}}".format(1, 2) # No issues - | - = help: Remove extra positional arguments at position(s): 1 - -ℹ Fix -1 1 | # With indexes -2 |-"{0}".format(1, 2) # F523 - 2 |+"{0}".format(1, ) # F523 -3 3 | "{1}".format(1, 2, 3) # F523 -4 4 | "{1:{0}}".format(1, 2) # No issues -5 5 | "{1:{0}}".format(1, 2, 3) # F523 - -F523.py:3:1: F523 `.format` call has unused arguments at position(s): 0, 2 - | -1 | # With indexes -2 | "{0}".format(1, 2) # F523 -3 | "{1}".format(1, 2, 3) # F523 - | ^^^^^^^^^^^^^^^^^^^^^ F523 -4 | "{1:{0}}".format(1, 2) # No issues -5 | "{1:{0}}".format(1, 2, 3) # F523 - | - = help: Remove extra positional arguments at position(s): 0, 2 - -F523.py:5:1: F523 [*] `.format` call has unused arguments at position(s): 2 - | -3 | "{1}".format(1, 2, 3) # F523 -4 | "{1:{0}}".format(1, 2) # No issues -5 | "{1:{0}}".format(1, 2, 3) # F523 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ F523 -6 | "{0}{2}".format(1, 2) # F523, # F524 -7 | "{1.arg[1]!r:0{2['arg']}{1}}".format(1, 2, 3, 4) # F523 - | - = help: Remove extra positional arguments at position(s): 2 - -ℹ Fix -2 2 | "{0}".format(1, 2) # F523 -3 3 | "{1}".format(1, 2, 3) # F523 -4 4 | "{1:{0}}".format(1, 2) # No issues -5 |-"{1:{0}}".format(1, 2, 3) # F523 - 5 |+"{1:{0}}".format(1, 2, ) # F523 -6 6 | "{0}{2}".format(1, 2) # F523, # F524 -7 7 | "{1.arg[1]!r:0{2['arg']}{1}}".format(1, 2, 3, 4) # F523 -8 8 | - -F523.py:6:1: F523 [*] `.format` call has unused arguments at position(s): 1 - | -4 | "{1:{0}}".format(1, 2) # No issues -5 | "{1:{0}}".format(1, 2, 3) # F523 -6 | "{0}{2}".format(1, 2) # F523, # F524 - | ^^^^^^^^^^^^^^^^^^^^^ F523 -7 | "{1.arg[1]!r:0{2['arg']}{1}}".format(1, 2, 3, 4) # F523 - | - = help: Remove extra positional arguments at position(s): 1 - -ℹ Fix -3 3 | "{1}".format(1, 2, 3) # F523 -4 4 | "{1:{0}}".format(1, 2) # No issues -5 5 | "{1:{0}}".format(1, 2, 3) # F523 -6 |-"{0}{2}".format(1, 2) # F523, # F524 - 6 |+"{0}{2}".format(1, ) # F523, # F524 -7 7 | "{1.arg[1]!r:0{2['arg']}{1}}".format(1, 2, 3, 4) # F523 -8 8 | -9 9 | # With no indexes - -F523.py:7:1: F523 `.format` call has unused arguments at position(s): 0, 3 - | -5 | "{1:{0}}".format(1, 2, 3) # F523 -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 | -9 | # With no indexes - | - = help: Remove extra positional arguments at position(s): 0, 3 - -F523.py:10:1: F523 [*] `.format` call has unused arguments at position(s): 1 - | - 9 | # With no indexes -10 | "{}".format(1, 2) # F523 - | ^^^^^^^^^^^^^^^^^ F523 -11 | "{}".format(1, 2, 3) # F523 -12 | "{:{}}".format(1, 2) # No issues - | - = help: Remove extra positional arguments at position(s): 1 - -ℹ Fix -7 7 | "{1.arg[1]!r:0{2['arg']}{1}}".format(1, 2, 3, 4) # F523 -8 8 | -9 9 | # With no indexes -10 |-"{}".format(1, 2) # F523 - 10 |+"{}".format(1, ) # F523 -11 11 | "{}".format(1, 2, 3) # F523 -12 12 | "{:{}}".format(1, 2) # No issues -13 13 | "{:{}}".format(1, 2, 3) # F523 - -F523.py:11:1: F523 [*] `.format` call has unused arguments at position(s): 1, 2 - | - 9 | # With no indexes -10 | "{}".format(1, 2) # F523 -11 | "{}".format(1, 2, 3) # F523 - | ^^^^^^^^^^^^^^^^^^^^ F523 -12 | "{:{}}".format(1, 2) # No issues -13 | "{:{}}".format(1, 2, 3) # F523 - | - = help: Remove extra positional arguments at position(s): 1, 2 - -ℹ Fix -8 8 | -9 9 | # With no indexes -10 10 | "{}".format(1, 2) # F523 -11 |-"{}".format(1, 2, 3) # F523 - 11 |+"{}".format(1, ) # F523 -12 12 | "{:{}}".format(1, 2) # No issues -13 13 | "{:{}}".format(1, 2, 3) # F523 -14 14 | - -F523.py:13:1: F523 [*] `.format` call has unused arguments at position(s): 2 - | -11 | "{}".format(1, 2, 3) # F523 -12 | "{:{}}".format(1, 2) # No issues -13 | "{:{}}".format(1, 2, 3) # F523 - | ^^^^^^^^^^^^^^^^^^^^^^^ F523 -14 | -15 | # With *args - | - = help: Remove extra positional arguments at position(s): 2 - -ℹ Fix -10 10 | "{}".format(1, 2) # F523 -11 11 | "{}".format(1, 2, 3) # F523 -12 12 | "{:{}}".format(1, 2) # No issues -13 |-"{:{}}".format(1, 2, 3) # F523 - 13 |+"{:{}}".format(1, 2, ) # F523 -14 14 | -15 15 | # With *args -16 16 | "{0}{1}".format(*args) # No issues - -F523.py:19:1: F523 `.format` call has unused arguments at position(s): 2 - | -17 | "{0}{1}".format(1, *args) # No issues -18 | "{0}{1}".format(1, 2, *args) # No issues -19 | "{0}{1}".format(1, 2, 3, *args) # F523 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F523 -20 | -21 | # With nested quotes - | - = help: Remove extra positional arguments at position(s): 2 - -F523.py:22:1: F523 [*] `.format` call has unused arguments at position(s): 1, 2 - | -21 | # With nested quotes -22 | "''1{0}".format(1, 2, 3) # F523 - | ^^^^^^^^^^^^^^^^^^^^^^^^ F523 -23 | "\"\"{1}{0}".format(1, 2, 3) # F523 -24 | '""{1}{0}'.format(1, 2, 3) # F523 - | - = help: Remove extra positional arguments at position(s): 1, 2 - -ℹ Fix -19 19 | "{0}{1}".format(1, 2, 3, *args) # F523 -20 20 | -21 21 | # With nested quotes -22 |-"''1{0}".format(1, 2, 3) # F523 - 22 |+"''1{0}".format(1, ) # F523 -23 23 | "\"\"{1}{0}".format(1, 2, 3) # F523 -24 24 | '""{1}{0}'.format(1, 2, 3) # F523 -25 25 | - -F523.py:23:1: F523 [*] `.format` call has unused arguments at position(s): 2 - | -21 | # With nested quotes -22 | "''1{0}".format(1, 2, 3) # F523 -23 | "\"\"{1}{0}".format(1, 2, 3) # F523 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F523 -24 | '""{1}{0}'.format(1, 2, 3) # F523 - | - = help: Remove extra positional arguments at position(s): 2 - -ℹ Fix -20 20 | -21 21 | # With nested quotes -22 22 | "''1{0}".format(1, 2, 3) # F523 -23 |-"\"\"{1}{0}".format(1, 2, 3) # F523 - 23 |+"\"\"{1}{0}".format(1, 2, ) # F523 -24 24 | '""{1}{0}'.format(1, 2, 3) # F523 -25 25 | -26 26 | # With modified indexes - -F523.py:24:1: F523 [*] `.format` call has unused arguments at position(s): 2 - | -22 | "''1{0}".format(1, 2, 3) # F523 -23 | "\"\"{1}{0}".format(1, 2, 3) # F523 -24 | '""{1}{0}'.format(1, 2, 3) # F523 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ F523 -25 | -26 | # With modified indexes - | - = help: Remove extra positional arguments at position(s): 2 - -ℹ Fix -21 21 | # With nested quotes -22 22 | "''1{0}".format(1, 2, 3) # F523 -23 23 | "\"\"{1}{0}".format(1, 2, 3) # F523 -24 |-'""{1}{0}'.format(1, 2, 3) # F523 - 24 |+'""{1}{0}'.format(1, 2, ) # F523 -25 25 | -26 26 | # With modified indexes -27 27 | "{1}{2}".format(1, 2, 3) # F523, # F524 - -F523.py:27:1: F523 `.format` call has unused arguments at position(s): 0 - | -26 | # With modified indexes -27 | "{1}{2}".format(1, 2, 3) # F523, # F524 - | ^^^^^^^^^^^^^^^^^^^^^^^^ F523 -28 | "{1}{3}".format(1, 2, 3, 4) # F523, # F524 -29 | "{1} {8}".format(0, 1) # F523, # F524 - | - = help: Remove extra positional arguments at position(s): 0 - -F523.py:28:1: F523 `.format` call has unused arguments at position(s): 0, 2 - | -26 | # With modified indexes -27 | "{1}{2}".format(1, 2, 3) # F523, # F524 -28 | "{1}{3}".format(1, 2, 3, 4) # F523, # F524 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ F523 -29 | "{1} {8}".format(0, 1) # F523, # F524 - | - = help: Remove extra positional arguments at position(s): 0, 2 - -F523.py:29:1: F523 `.format` call has unused arguments at position(s): 0 - | -27 | "{1}{2}".format(1, 2, 3) # F523, # F524 -28 | "{1}{3}".format(1, 2, 3, 4) # F523, # F524 -29 | "{1} {8}".format(0, 1) # F523, # F524 - | ^^^^^^^^^^^^^^^^^^^^^^ F523 -30 | -31 | # Multiline - | - = help: Remove extra positional arguments at position(s): 0 - -F523.py:32:2: F523 [*] `.format` call has unused arguments at position(s): 0 - | -31 | # Multiline -32 | ('' - | __^ -33 | | .format(2)) - | |__________^ F523 - | - = help: Remove extra positional arguments at position(s): 0 - -ℹ Fix -30 30 | -31 31 | # Multiline -32 32 | ('' -33 |-.format(2)) - 33 |+.format()) - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F524_F524.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F524_F524.py.snap deleted file mode 100644 index 1596f82f10..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F524_F524.py.snap +++ /dev/null @@ -1,68 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F524.py:1:1: F524 `.format` call is missing argument(s) for placeholder(s): 1 - | -1 | "{} {}".format(1) # F524 - | ^^^^^^^^^^^^^^^^^ F524 -2 | "{2}".format() # F524 -3 | "{bar}".format() # F524 - | - -F524.py:2:1: F524 `.format` call is missing argument(s) for placeholder(s): 2 - | -1 | "{} {}".format(1) # F524 -2 | "{2}".format() # F524 - | ^^^^^^^^^^^^^^ F524 -3 | "{bar}".format() # F524 -4 | "{0} {bar}".format(1) # F524 - | - -F524.py:3:1: F524 `.format` call is missing argument(s) for placeholder(s): bar - | -1 | "{} {}".format(1) # F524 -2 | "{2}".format() # F524 -3 | "{bar}".format() # F524 - | ^^^^^^^^^^^^^^^^ F524 -4 | "{0} {bar}".format(1) # F524 -5 | "{0} {bar}".format() # F524 - | - -F524.py:4:1: F524 `.format` call is missing argument(s) for placeholder(s): bar - | -2 | "{2}".format() # F524 -3 | "{bar}".format() # F524 -4 | "{0} {bar}".format(1) # F524 - | ^^^^^^^^^^^^^^^^^^^^^ F524 -5 | "{0} {bar}".format() # F524 -6 | "{bar} {0}".format() # F524 - | - -F524.py:5:1: F524 `.format` call is missing argument(s) for placeholder(s): 0, bar - | -3 | "{bar}".format() # F524 -4 | "{0} {bar}".format(1) # F524 -5 | "{0} {bar}".format() # F524 - | ^^^^^^^^^^^^^^^^^^^^ F524 -6 | "{bar} {0}".format() # F524 -7 | "{1} {8}".format(0, 1) - | - -F524.py:6:1: F524 `.format` call is missing argument(s) for placeholder(s): 0, bar - | -4 | "{0} {bar}".format(1) # F524 -5 | "{0} {bar}".format() # F524 -6 | "{bar} {0}".format() # F524 - | ^^^^^^^^^^^^^^^^^^^^ F524 -7 | "{1} {8}".format(0, 1) - | - -F524.py:7:1: F524 `.format` call is missing argument(s) for placeholder(s): 8 - | -5 | "{0} {bar}".format() # F524 -6 | "{bar} {0}".format() # F524 -7 | "{1} {8}".format(0, 1) - | ^^^^^^^^^^^^^^^^^^^^^^ F524 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F525_F525.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F525_F525.py.snap deleted file mode 100644 index 00cc74e258..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F525_F525.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F525.py:1:1: F525 `.format` string mixes automatic and manual numbering - | -1 | "{} {1}".format(1, 2) # F525 - | ^^^^^^^^^^^^^^^^^^^^^ F525 -2 | "{0} {}".format(1, 2) # F523, F525 - | - -F525.py:2:1: F525 `.format` string mixes automatic and manual numbering - | -1 | "{} {1}".format(1, 2) # F525 -2 | "{0} {}".format(1, 2) # F523, F525 - | ^^^^^^^^^^^^^^^^^^^^^ F525 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F541_F541.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F541_F541.py.snap deleted file mode 100644 index 7ca008c27e..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F541_F541.py.snap +++ /dev/null @@ -1,378 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F541.py:6:5: F541 [*] f-string without any placeholders - | -5 | # Errors -6 | c = f"def" - | ^^^^^^ F541 -7 | d = f"def" + "ghi" -8 | e = ( - | - = help: Remove extraneous `f` prefix - -ℹ Fix -3 3 | b = f"ghi{'jkl'}" -4 4 | -5 5 | # Errors -6 |-c = f"def" - 6 |+c = "def" -7 7 | d = f"def" + "ghi" -8 8 | e = ( -9 9 | f"def" + - -F541.py:7:5: F541 [*] f-string without any placeholders - | -5 | # Errors -6 | c = f"def" -7 | d = f"def" + "ghi" - | ^^^^^^ F541 -8 | e = ( -9 | f"def" + - | - = help: Remove extraneous `f` prefix - -ℹ Fix -4 4 | -5 5 | # Errors -6 6 | c = f"def" -7 |-d = f"def" + "ghi" - 7 |+d = "def" + "ghi" -8 8 | e = ( -9 9 | f"def" + -10 10 | "ghi" - -F541.py:9:5: F541 [*] f-string without any placeholders - | - 7 | d = f"def" + "ghi" - 8 | e = ( - 9 | f"def" + - | ^^^^^^ F541 -10 | "ghi" -11 | ) - | - = help: Remove extraneous `f` prefix - -ℹ Fix -6 6 | c = f"def" -7 7 | d = f"def" + "ghi" -8 8 | e = ( -9 |- f"def" + - 9 |+ "def" + -10 10 | "ghi" -11 11 | ) -12 12 | f = ( - -F541.py:13:5: F541 [*] f-string without any placeholders - | -11 | ) -12 | f = ( -13 | f"a" - | ^^^^ F541 -14 | F"b" -15 | "c" - | - = help: Remove extraneous `f` prefix - -ℹ Fix -10 10 | "ghi" -11 11 | ) -12 12 | f = ( -13 |- f"a" - 13 |+ "a" -14 14 | F"b" -15 15 | "c" -16 16 | rf"d" - -F541.py:14:5: F541 [*] f-string without any placeholders - | -12 | f = ( -13 | f"a" -14 | F"b" - | ^^^^ F541 -15 | "c" -16 | rf"d" - | - = help: Remove extraneous `f` prefix - -ℹ Fix -11 11 | ) -12 12 | f = ( -13 13 | f"a" -14 |- F"b" - 14 |+ "b" -15 15 | "c" -16 16 | rf"d" -17 17 | fr"e" - -F541.py:16:5: F541 [*] f-string without any placeholders - | -14 | F"b" -15 | "c" -16 | rf"d" - | ^^^^^ F541 -17 | fr"e" -18 | ) - | - = help: Remove extraneous `f` prefix - -ℹ Fix -13 13 | f"a" -14 14 | F"b" -15 15 | "c" -16 |- rf"d" - 16 |+ r"d" -17 17 | fr"e" -18 18 | ) -19 19 | g = f"" - -F541.py:17:5: F541 [*] f-string without any placeholders - | -15 | "c" -16 | rf"d" -17 | fr"e" - | ^^^^^ F541 -18 | ) -19 | g = f"" - | - = help: Remove extraneous `f` prefix - -ℹ Fix -14 14 | F"b" -15 15 | "c" -16 16 | rf"d" -17 |- fr"e" - 17 |+ r"e" -18 18 | ) -19 19 | g = f"" -20 20 | - -F541.py:19:5: F541 [*] f-string without any placeholders - | -17 | fr"e" -18 | ) -19 | g = f"" - | ^^^ F541 -20 | -21 | # OK - | - = help: Remove extraneous `f` prefix - -ℹ Fix -16 16 | rf"d" -17 17 | fr"e" -18 18 | ) -19 |-g = f"" - 19 |+g = "" -20 20 | -21 21 | # OK -22 22 | g = f"ghi{123:{45}}" - -F541.py:25:13: F541 [*] f-string without any placeholders - | -24 | # Error -25 | h = "x" "y" f"z" - | ^^^^ F541 -26 | -27 | v = 23.234234 - | - = help: Remove extraneous `f` prefix - -ℹ Fix -22 22 | g = f"ghi{123:{45}}" -23 23 | -24 24 | # Error -25 |-h = "x" "y" f"z" - 25 |+h = "x" "y" "z" -26 26 | -27 27 | v = 23.234234 -28 28 | - -F541.py:34:7: F541 [*] f-string without any placeholders - | -33 | # Errors -34 | f"{v:{f'0.2f'}}" - | ^^^^^^^ F541 -35 | f"{f''}" -36 | f"{{test}}" - | - = help: Remove extraneous `f` prefix - -ℹ Fix -31 31 | f"{f'{v:0.2f}'}" -32 32 | -33 33 | # Errors -34 |-f"{v:{f'0.2f'}}" - 34 |+f"{v:{'0.2f'}}" -35 35 | f"{f''}" -36 36 | f"{{test}}" -37 37 | f'{{ 40 }}' - -F541.py:35:4: F541 [*] f-string without any placeholders - | -33 | # Errors -34 | f"{v:{f'0.2f'}}" -35 | f"{f''}" - | ^^^ F541 -36 | f"{{test}}" -37 | f'{{ 40 }}' - | - = help: Remove extraneous `f` prefix - -ℹ Fix -32 32 | -33 33 | # Errors -34 34 | f"{v:{f'0.2f'}}" -35 |-f"{f''}" - 35 |+f"{''}" -36 36 | f"{{test}}" -37 37 | f'{{ 40 }}' -38 38 | f"{{a {{x}}" - -F541.py:36:1: F541 [*] f-string without any placeholders - | -34 | f"{v:{f'0.2f'}}" -35 | f"{f''}" -36 | f"{{test}}" - | ^^^^^^^^^^^ F541 -37 | f'{{ 40 }}' -38 | f"{{a {{x}}" - | - = help: Remove extraneous `f` prefix - -ℹ Fix -33 33 | # Errors -34 34 | f"{v:{f'0.2f'}}" -35 35 | f"{f''}" -36 |-f"{{test}}" - 36 |+"{test}" -37 37 | f'{{ 40 }}' -38 38 | f"{{a {{x}}" -39 39 | f"{{{{x}}}}" - -F541.py:37:1: F541 [*] f-string without any placeholders - | -35 | f"{f''}" -36 | f"{{test}}" -37 | f'{{ 40 }}' - | ^^^^^^^^^^^ F541 -38 | f"{{a {{x}}" -39 | f"{{{{x}}}}" - | - = help: Remove extraneous `f` prefix - -ℹ Fix -34 34 | f"{v:{f'0.2f'}}" -35 35 | f"{f''}" -36 36 | f"{{test}}" -37 |-f'{{ 40 }}' - 37 |+'{ 40 }' -38 38 | f"{{a {{x}}" -39 39 | f"{{{{x}}}}" -40 40 | ""f"" - -F541.py:38:1: F541 [*] f-string without any placeholders - | -36 | f"{{test}}" -37 | f'{{ 40 }}' -38 | f"{{a {{x}}" - | ^^^^^^^^^^^^ F541 -39 | f"{{{{x}}}}" -40 | ""f"" - | - = help: Remove extraneous `f` prefix - -ℹ Fix -35 35 | f"{f''}" -36 36 | f"{{test}}" -37 37 | f'{{ 40 }}' -38 |-f"{{a {{x}}" - 38 |+"{a {x}" -39 39 | f"{{{{x}}}}" -40 40 | ""f"" -41 41 | ''f"" - -F541.py:39:1: F541 [*] f-string without any placeholders - | -37 | f'{{ 40 }}' -38 | f"{{a {{x}}" -39 | f"{{{{x}}}}" - | ^^^^^^^^^^^^ F541 -40 | ""f"" -41 | ''f"" - | - = help: Remove extraneous `f` prefix - -ℹ Fix -36 36 | f"{{test}}" -37 37 | f'{{ 40 }}' -38 38 | f"{{a {{x}}" -39 |-f"{{{{x}}}}" - 39 |+"{{x}}" -40 40 | ""f"" -41 41 | ''f"" -42 42 | (""f""r"") - -F541.py:40:3: F541 [*] f-string without any placeholders - | -38 | f"{{a {{x}}" -39 | f"{{{{x}}}}" -40 | ""f"" - | ^^^ F541 -41 | ''f"" -42 | (""f""r"") - | - = help: Remove extraneous `f` prefix - -ℹ Fix -37 37 | f'{{ 40 }}' -38 38 | f"{{a {{x}}" -39 39 | f"{{{{x}}}}" -40 |-""f"" - 40 |+"" "" -41 41 | ''f"" -42 42 | (""f""r"") -43 43 | - -F541.py:41:3: F541 [*] f-string without any placeholders - | -39 | f"{{{{x}}}}" -40 | ""f"" -41 | ''f"" - | ^^^ F541 -42 | (""f""r"") - | - = help: Remove extraneous `f` prefix - -ℹ Fix -38 38 | f"{{a {{x}}" -39 39 | f"{{{{x}}}}" -40 40 | ""f"" -41 |-''f"" - 41 |+''"" -42 42 | (""f""r"") -43 43 | -44 44 | # To be fixed - -F541.py:42:4: F541 [*] f-string without any placeholders - | -40 | ""f"" -41 | ''f"" -42 | (""f""r"") - | ^^^ F541 -43 | -44 | # To be fixed - | - = help: Remove extraneous `f` prefix - -ℹ Fix -39 39 | f"{{{{x}}}}" -40 40 | ""f"" -41 41 | ''f"" -42 |-(""f""r"") - 42 |+("" ""r"") -43 43 | -44 44 | # To be fixed -45 45 | # Error: f-string: single '}' is not allowed at line 41 column 8 - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F601_F601.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F601_F601.py.snap deleted file mode 100644 index 1a5b94a092..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F601_F601.py.snap +++ /dev/null @@ -1,284 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F601.py:3:5: F601 Dictionary key literal `"a"` repeated - | -1 | x = { -2 | "a": 1, -3 | "a": 2, - | ^^^ F601 -4 | "b": 3, -5 | ("a", "b"): 3, - | - = help: Remove repeated key literal `"a"` - -F601.py:6:5: F601 Dictionary key literal `("a", "b")` repeated - | -4 | "b": 3, -5 | ("a", "b"): 3, -6 | ("a", "b"): 4, - | ^^^^^^^^^^ F601 -7 | 1.0: 2, -8 | 1: 0, - | - = help: Remove repeated key literal `("a", "b")` - -F601.py:9:5: F601 Dictionary key literal `1` repeated - | - 7 | 1.0: 2, - 8 | 1: 0, - 9 | 1: 3, - | ^ F601 -10 | b"123": 1, -11 | b"123": 4, - | - = help: Remove repeated key literal `1` - -F601.py:11:5: F601 Dictionary key literal `b"123"` repeated - | - 9 | 1: 3, -10 | b"123": 1, -11 | b"123": 4, - | ^^^^^^ F601 -12 | } - | - = help: Remove repeated key literal `b"123"` - -F601.py:16:5: F601 Dictionary key literal `"a"` repeated - | -14 | x = { -15 | "a": 1, -16 | "a": 2, - | ^^^ F601 -17 | "a": 3, -18 | "a": 3, - | - = help: Remove repeated key literal `"a"` - -F601.py:17:5: F601 Dictionary key literal `"a"` repeated - | -15 | "a": 1, -16 | "a": 2, -17 | "a": 3, - | ^^^ F601 -18 | "a": 3, -19 | } - | - = help: Remove repeated key literal `"a"` - -F601.py:18:5: F601 [*] Dictionary key literal `"a"` repeated - | -16 | "a": 2, -17 | "a": 3, -18 | "a": 3, - | ^^^ F601 -19 | } - | - = help: Remove repeated key literal `"a"` - -ℹ Suggested fix -15 15 | "a": 1, -16 16 | "a": 2, -17 17 | "a": 3, -18 |- "a": 3, -19 18 | } -20 19 | -21 20 | x = { - -F601.py:23:5: F601 Dictionary key literal `"a"` repeated - | -21 | x = { -22 | "a": 1, -23 | "a": 2, - | ^^^ F601 -24 | "a": 3, -25 | "a": 3, - | - = help: Remove repeated key literal `"a"` - -F601.py:24:5: F601 Dictionary key literal `"a"` repeated - | -22 | "a": 1, -23 | "a": 2, -24 | "a": 3, - | ^^^ F601 -25 | "a": 3, -26 | "a": 4, - | - = help: Remove repeated key literal `"a"` - -F601.py:25:5: F601 [*] Dictionary key literal `"a"` repeated - | -23 | "a": 2, -24 | "a": 3, -25 | "a": 3, - | ^^^ F601 -26 | "a": 4, -27 | } - | - = help: Remove repeated key literal `"a"` - -ℹ Suggested fix -22 22 | "a": 1, -23 23 | "a": 2, -24 24 | "a": 3, -25 |- "a": 3, -26 25 | "a": 4, -27 26 | } -28 27 | - -F601.py:26:5: F601 Dictionary key literal `"a"` repeated - | -24 | "a": 3, -25 | "a": 3, -26 | "a": 4, - | ^^^ F601 -27 | } - | - = help: Remove repeated key literal `"a"` - -F601.py:31:5: F601 [*] Dictionary key literal `"a"` repeated - | -29 | x = { -30 | "a": 1, -31 | "a": 1, - | ^^^ F601 -32 | "a": 2, -33 | "a": 3, - | - = help: Remove repeated key literal `"a"` - -ℹ Suggested fix -28 28 | -29 29 | x = { -30 30 | "a": 1, -31 |- "a": 1, -32 31 | "a": 2, -33 32 | "a": 3, -34 33 | "a": 4, - -F601.py:32:5: F601 Dictionary key literal `"a"` repeated - | -30 | "a": 1, -31 | "a": 1, -32 | "a": 2, - | ^^^ F601 -33 | "a": 3, -34 | "a": 4, - | - = help: Remove repeated key literal `"a"` - -F601.py:33:5: F601 Dictionary key literal `"a"` repeated - | -31 | "a": 1, -32 | "a": 2, -33 | "a": 3, - | ^^^ F601 -34 | "a": 4, -35 | } - | - = help: Remove repeated key literal `"a"` - -F601.py:34:5: F601 Dictionary key literal `"a"` repeated - | -32 | "a": 2, -33 | "a": 3, -34 | "a": 4, - | ^^^ F601 -35 | } - | - = help: Remove repeated key literal `"a"` - -F601.py:41:5: F601 Dictionary key literal `"a"` repeated - | -39 | "a": 1, -40 | a: 1, -41 | "a": 2, - | ^^^ F601 -42 | a: 2, -43 | "a": 3, - | - = help: Remove repeated key literal `"a"` - -F601.py:43:5: F601 Dictionary key literal `"a"` repeated - | -41 | "a": 2, -42 | a: 2, -43 | "a": 3, - | ^^^ F601 -44 | a: 3, -45 | "a": 3, - | - = help: Remove repeated key literal `"a"` - -F601.py:45:5: F601 [*] Dictionary key literal `"a"` repeated - | -43 | "a": 3, -44 | a: 3, -45 | "a": 3, - | ^^^ F601 -46 | a: 4, -47 | } - | - = help: Remove repeated key literal `"a"` - -ℹ Suggested fix -42 42 | a: 2, -43 43 | "a": 3, -44 44 | a: 3, -45 |- "a": 3, -46 45 | a: 4, -47 46 | } -48 47 | - -F601.py:49:14: F601 [*] Dictionary key literal `"a"` repeated - | -47 | } -48 | -49 | x = {"a": 1, "a": 1} - | ^^^ F601 -50 | x = {"a": 1, "b": 2, "a": 1} - | - = help: Remove repeated key literal `"a"` - -ℹ Suggested fix -46 46 | a: 4, -47 47 | } -48 48 | -49 |-x = {"a": 1, "a": 1} - 49 |+x = {"a": 1} -50 50 | x = {"a": 1, "b": 2, "a": 1} -51 51 | -52 52 | x = { - -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 | -52 | x = { - | - = help: Remove repeated key literal `"a"` - -ℹ Suggested fix -47 47 | } -48 48 | -49 49 | x = {"a": 1, "a": 1} -50 |-x = {"a": 1, "b": 2, "a": 1} - 50 |+x = {"a": 1, "b": 2} -51 51 | -52 52 | x = { -53 53 | ('a', 'b'): 'asdf', - -F601.py:54:5: F601 Dictionary key literal `('a', 'b')` repeated - | -52 | x = { -53 | ('a', 'b'): 'asdf', -54 | ('a', 'b'): 'qwer', - | ^^^^^^^^^^ F601 -55 | } - | - = help: Remove repeated key literal `('a', 'b')` - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F602_F602.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F602_F602.py.snap deleted file mode 100644 index c29e85b114..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F602_F602.py.snap +++ /dev/null @@ -1,245 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F602.py:5:5: F602 Dictionary key `a` repeated - | -3 | x = { -4 | a: 1, -5 | a: 2, - | ^ F602 -6 | b: 3, -7 | } - | - = help: Remove repeated key `a` - -F602.py:11:5: F602 Dictionary key `a` repeated - | - 9 | x = { -10 | a: 1, -11 | a: 2, - | ^ F602 -12 | a: 3, -13 | a: 3, - | - = help: Remove repeated key `a` - -F602.py:12:5: F602 Dictionary key `a` repeated - | -10 | a: 1, -11 | a: 2, -12 | a: 3, - | ^ F602 -13 | a: 3, -14 | } - | - = help: Remove repeated key `a` - -F602.py:13:5: F602 [*] Dictionary key `a` repeated - | -11 | a: 2, -12 | a: 3, -13 | a: 3, - | ^ F602 -14 | } - | - = help: Remove repeated key `a` - -ℹ Suggested fix -10 10 | a: 1, -11 11 | a: 2, -12 12 | a: 3, -13 |- a: 3, -14 13 | } -15 14 | -16 15 | x = { - -F602.py:18:5: F602 Dictionary key `a` repeated - | -16 | x = { -17 | a: 1, -18 | a: 2, - | ^ F602 -19 | a: 3, -20 | a: 3, - | - = help: Remove repeated key `a` - -F602.py:19:5: F602 Dictionary key `a` repeated - | -17 | a: 1, -18 | a: 2, -19 | a: 3, - | ^ F602 -20 | a: 3, -21 | a: 4, - | - = help: Remove repeated key `a` - -F602.py:20:5: F602 [*] Dictionary key `a` repeated - | -18 | a: 2, -19 | a: 3, -20 | a: 3, - | ^ F602 -21 | a: 4, -22 | } - | - = help: Remove repeated key `a` - -ℹ Suggested fix -17 17 | a: 1, -18 18 | a: 2, -19 19 | a: 3, -20 |- a: 3, -21 20 | a: 4, -22 21 | } -23 22 | - -F602.py:21:5: F602 Dictionary key `a` repeated - | -19 | a: 3, -20 | a: 3, -21 | a: 4, - | ^ F602 -22 | } - | - = help: Remove repeated key `a` - -F602.py:26:5: F602 [*] Dictionary key `a` repeated - | -24 | x = { -25 | a: 1, -26 | a: 1, - | ^ F602 -27 | a: 2, -28 | a: 3, - | - = help: Remove repeated key `a` - -ℹ Suggested fix -23 23 | -24 24 | x = { -25 25 | a: 1, -26 |- a: 1, -27 26 | a: 2, -28 27 | a: 3, -29 28 | a: 4, - -F602.py:27:5: F602 Dictionary key `a` repeated - | -25 | a: 1, -26 | a: 1, -27 | a: 2, - | ^ F602 -28 | a: 3, -29 | a: 4, - | - = help: Remove repeated key `a` - -F602.py:28:5: F602 Dictionary key `a` repeated - | -26 | a: 1, -27 | a: 2, -28 | a: 3, - | ^ F602 -29 | a: 4, -30 | } - | - = help: Remove repeated key `a` - -F602.py:29:5: F602 Dictionary key `a` repeated - | -27 | a: 2, -28 | a: 3, -29 | a: 4, - | ^ F602 -30 | } - | - = help: Remove repeated key `a` - -F602.py:35:5: F602 [*] Dictionary key `a` repeated - | -33 | a: 1, -34 | "a": 1, -35 | a: 1, - | ^ F602 -36 | "a": 2, -37 | a: 2, - | - = help: Remove repeated key `a` - -ℹ Suggested fix -32 32 | x = { -33 33 | a: 1, -34 34 | "a": 1, -35 |- a: 1, -36 35 | "a": 2, -37 36 | a: 2, -38 37 | "a": 3, - -F602.py:37:5: F602 Dictionary key `a` repeated - | -35 | a: 1, -36 | "a": 2, -37 | a: 2, - | ^ F602 -38 | "a": 3, -39 | a: 3, - | - = help: Remove repeated key `a` - -F602.py:39:5: F602 Dictionary key `a` repeated - | -37 | a: 2, -38 | "a": 3, -39 | a: 3, - | ^ F602 -40 | "a": 3, -41 | a: 4, - | - = help: Remove repeated key `a` - -F602.py:41:5: F602 Dictionary key `a` repeated - | -39 | a: 3, -40 | "a": 3, -41 | a: 4, - | ^ F602 -42 | } - | - = help: Remove repeated key `a` - -F602.py:44:12: F602 [*] Dictionary key `a` repeated - | -42 | } -43 | -44 | x = {a: 1, a: 1} - | ^ F602 -45 | x = {a: 1, b: 2, a: 1} - | - = help: Remove repeated key `a` - -ℹ Suggested fix -41 41 | a: 4, -42 42 | } -43 43 | -44 |-x = {a: 1, a: 1} - 44 |+x = {a: 1} -45 45 | x = {a: 1, b: 2, a: 1} - -F602.py:45:18: F602 [*] Dictionary key `a` repeated - | -44 | x = {a: 1, a: 1} -45 | x = {a: 1, b: 2, a: 1} - | ^ F602 - | - = help: Remove repeated key `a` - -ℹ Suggested fix -42 42 | } -43 43 | -44 44 | x = {a: 1, a: 1} -45 |-x = {a: 1, b: 2, a: 1} - 45 |+x = {a: 1, b: 2} - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F622_F622.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F622_F622.py.snap deleted file mode 100644 index 4c1e3173b8..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F622_F622.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F622.py:1:1: F622 Two starred expressions in assignment - | -1 | *a, *b, c = (1, 2, 3) - | ^^^^^^^^^ F622 -2 | *a, b, c = (1, 2, 3) -3 | a, b, *c = (1, 2, 3) - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F631_F631.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F631_F631.py.snap deleted file mode 100644 index c5d6812833..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F631_F631.py.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F631.py:1:1: F631 Assert test is a non-empty tuple, which is always `True` - | -1 | assert (False, "x") - | ^^^^^^^^^^^^^^^^^^^ F631 -2 | assert (False,) -3 | assert () - | - -F631.py:2:1: F631 Assert test is a non-empty tuple, which is always `True` - | -1 | assert (False, "x") -2 | assert (False,) - | ^^^^^^^^^^^^^^^ F631 -3 | assert () -4 | assert True - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F632_F632.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F632_F632.py.snap deleted file mode 100644 index fe6785eab5..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F632_F632.py.snap +++ /dev/null @@ -1,185 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F632.py:1:4: F632 [*] Use `==` to compare constant literals - | -1 | if x is "abc": - | ^^^^^^^^^^ F632 -2 | pass - | - = help: Replace `is` with `==` - -ℹ Fix -1 |-if x is "abc": - 1 |+if x == "abc": -2 2 | pass -3 3 | -4 4 | if 123 is not y: - -F632.py:4:4: F632 [*] Use `!=` to compare constant literals - | -2 | pass -3 | -4 | if 123 is not y: - | ^^^^^^^^^^^^ F632 -5 | pass - | - = help: Replace `is not` with `!=` - -ℹ Fix -1 1 | if x is "abc": -2 2 | pass -3 3 | -4 |-if 123 is not y: - 4 |+if 123 != y: -5 5 | pass -6 6 | -7 7 | if 123 is \ - -F632.py:7:4: F632 [*] Use `!=` to compare constant literals - | -5 | pass -6 | -7 | if 123 is \ - | ____^ -8 | | not y: - | |_____________^ F632 -9 | pass - | - = help: Replace `is not` with `!=` - -ℹ Fix -4 4 | if 123 is not y: -5 5 | pass -6 6 | -7 |-if 123 is \ -8 |- not y: - 7 |+if 123 != y: -9 8 | pass -10 9 | -11 10 | if "123" is x < 3: - -F632.py:11:4: F632 [*] Use `==` to compare constant literals - | - 9 | pass -10 | -11 | if "123" is x < 3: - | ^^^^^^^^^^^^^^ F632 -12 | pass - | - = help: Replace `is` with `==` - -ℹ Fix -8 8 | not y: -9 9 | pass -10 10 | -11 |-if "123" is x < 3: - 11 |+if "123" == x < 3: -12 12 | pass -13 13 | -14 14 | if "123" != x is 3: - -F632.py:14:4: F632 [*] Use `==` to compare constant literals - | -12 | pass -13 | -14 | if "123" != x is 3: - | ^^^^^^^^^^^^^^^ F632 -15 | pass - | - = help: Replace `is` with `==` - -ℹ Fix -11 11 | if "123" is x < 3: -12 12 | pass -13 13 | -14 |-if "123" != x is 3: - 14 |+if "123" != x == 3: -15 15 | pass -16 16 | -17 17 | if ("123" != x) is 3: - -F632.py:17:4: F632 [*] Use `==` to compare constant literals - | -15 | pass -16 | -17 | if ("123" != x) is 3: - | ^^^^^^^^^^^^^^^^^ F632 -18 | pass - | - = help: Replace `is` with `==` - -ℹ Fix -14 14 | if "123" != x is 3: -15 15 | pass -16 16 | -17 |-if ("123" != x) is 3: - 17 |+if ("123" != x) == 3: -18 18 | pass -19 19 | -20 20 | if "123" != (x is 3): - -F632.py:20:14: F632 [*] Use `==` to compare constant literals - | -18 | pass -19 | -20 | if "123" != (x is 3): - | ^^^^^^ F632 -21 | pass - | - = help: Replace `is` with `==` - -ℹ Fix -17 17 | if ("123" != x) is 3: -18 18 | pass -19 19 | -20 |-if "123" != (x is 3): - 20 |+if "123" != (x == 3): -21 21 | pass -22 22 | -23 23 | {2 is - -F632.py:23:2: F632 [*] Use `!=` to compare constant literals - | -21 | pass -22 | -23 | {2 is - | __^ -24 | | not ''} - | |______^ F632 -25 | -26 | {2 is - | - = help: Replace `is not` with `!=` - -ℹ Fix -20 20 | if "123" != (x is 3): -21 21 | pass -22 22 | -23 |-{2 is -24 |-not ''} - 23 |+{2 != ''} -25 24 | -26 25 | {2 is -27 26 | not ''} - -F632.py:26:2: F632 [*] Use `!=` to compare constant literals - | -24 | not ''} -25 | -26 | {2 is - | __^ -27 | | not ''} - | |_______^ F632 - | - = help: Replace `is not` with `!=` - -ℹ Fix -23 23 | {2 is -24 24 | not ''} -25 25 | -26 |-{2 is -27 |- not ''} - 26 |+{2 != ''} - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F633_F633.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F633_F633.py.snap deleted file mode 100644 index 2d667b6de9..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F633_F633.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F633.py:4:1: F633 Use of `>>` is invalid with `print` function - | -2 | import sys -3 | -4 | print >> sys.stderr, "Hello" - | ^^^^^ F633 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F634_F634.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F634_F634.py.snap deleted file mode 100644 index d753d6d96e..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F634_F634.py.snap +++ /dev/null @@ -1,31 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F634.py:1:4: F634 If test is a tuple, which is always `True` - | -1 | if (1, 2): - | ^^^^^^ F634 -2 | pass - | - -F634.py:4:4: F634 If test is a tuple, which is always `True` - | -2 | pass -3 | -4 | if (3, 4): - | ^^^^^^ F634 -5 | pass -6 | elif foo: - | - -F634.py:12:10: F634 If test is a tuple, which is always `True` - | -10 | if True: -11 | pass -12 | elif (3, 4): - | ^^^^^^ F634 -13 | pass -14 | elif (): - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F701_F701.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F701_F701.py.snap deleted file mode 100644 index 3418a661fd..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F701_F701.py.snap +++ /dev/null @@ -1,35 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F701.py:4:5: F701 `break` outside loop - | -2 | break -3 | else: -4 | break - | ^^^^^ F701 -5 | -6 | i = 0 - | - -F701.py:16:5: F701 `break` outside loop - | -14 | break -15 | -16 | break - | ^^^^^ F701 - | - -F701.py:20:5: F701 `break` outside loop - | -19 | class Foo: -20 | break - | ^^^^^ F701 - | - -F701.py:23:1: F701 `break` outside loop - | -23 | break - | ^^^^^ F701 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F702_F702.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F702_F702.py.snap deleted file mode 100644 index bef1b7a235..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F702_F702.py.snap +++ /dev/null @@ -1,35 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F702.py:4:5: F702 `continue` not properly in loop - | -2 | continue -3 | else: -4 | continue - | ^^^^^^^^ F702 -5 | -6 | i = 0 - | - -F702.py:16:5: F702 `continue` not properly in loop - | -14 | continue -15 | -16 | continue - | ^^^^^^^^ F702 - | - -F702.py:20:5: F702 `continue` not properly in loop - | -19 | class Foo: -20 | continue - | ^^^^^^^^ F702 - | - -F702.py:23:1: F702 `continue` not properly in loop - | -23 | continue - | ^^^^^^^^ F702 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F704_F704.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F704_F704.py.snap deleted file mode 100644 index b929c5ac43..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F704_F704.py.snap +++ /dev/null @@ -1,35 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F704.py:6:5: F704 `yield` statement outside of a function - | -5 | class Foo: -6 | yield 2 - | ^^^^^^^ F704 - | - -F704.py:9:1: F704 `yield` statement outside of a function - | - 9 | yield 3 - | ^^^^^^^ F704 -10 | yield from 3 -11 | await f() - | - -F704.py:10:1: F704 `yield from` statement outside of a function - | - 9 | yield 3 -10 | yield from 3 - | ^^^^^^^^^^^^ F704 -11 | await f() - | - -F704.py:11:1: F704 `await` statement outside of a function - | - 9 | yield 3 -10 | yield from 3 -11 | await f() - | ^^^^^^^^^ F704 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F706_F706.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F706_F706.py.snap deleted file mode 100644 index afefad51d8..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F706_F706.py.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F706.py:6:5: F706 `return` statement outside of a function/method - | -5 | class Foo: -6 | return 2 - | ^^^^^^^^ F706 - | - -F706.py:9:1: F706 `return` statement outside of a function/method - | -9 | return 3 - | ^^^^^^^^ F706 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F707_F707.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F707_F707.py.snap deleted file mode 100644 index bf899d037d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F707_F707.py.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F707.py:3:1: F707 An `except` block as not the last exception handler - | -1 | try: -2 | pass -3 | except: - | ^^^^^^ F707 -4 | pass -5 | except ValueError: - | - -F707.py:10:1: F707 An `except` block as not the last exception handler - | - 8 | try: - 9 | pass -10 | except: - | ^^^^^^ F707 -11 | pass -12 | except ValueError: - | - -F707.py:19:1: F707 An `except` block as not the last exception handler - | -17 | try: -18 | pass -19 | except: - | ^^^^^^ F707 -20 | pass -21 | except ValueError: - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F722_F722.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F722_F722.py.snap deleted file mode 100644 index adfe2caae0..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F722_F722.py.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F722.py:9:12: F722 Syntax error in forward annotation: `///` - | - 9 | def g() -> "///": - | ^^^^^ F722 -10 | pass - | - -F722.py:13:4: F722 Syntax error in forward annotation: `List[int]☃` - | -13 | X: """List[int]"""'☃' = [] - | ^^^^^^^^^^^^^^^^^^ F722 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_0.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_0.py.snap deleted file mode 100644 index c4665ab15a..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_0.py.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F811_0.py:10:5: F811 Redefinition of unused `bar` from line 6 - | -10 | def bar(): - | ^^^ F811 -11 | pass - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_1.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_1.py.snap deleted file mode 100644 index 365bef1c04..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_1.py.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F811_1.py:1:25: F811 Redefinition of unused `FU` from line 1 - | -1 | import fu as FU, bar as FU - | ^^ F811 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_10.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_10.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_10.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_11.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_11.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_11.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_12.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_12.py.snap deleted file mode 100644 index 456a8dcde9..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_12.py.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F811_12.py:6:20: F811 Redefinition of unused `mixer` from line 2 - | -4 | pass -5 | else: -6 | from bb import mixer - | ^^^^^ F811 -7 | mixer(123) - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_13.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_13.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_13.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_14.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_14.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_14.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_15.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_15.py.snap deleted file mode 100644 index 90a61472ce..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_15.py.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F811_15.py:4:5: F811 Redefinition of unused `fu` from line 1 - | -4 | def fu(): - | ^^ F811 -5 | pass - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_16.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_16.py.snap deleted file mode 100644 index dfbc7ced7f..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_16.py.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F811_16.py:8:13: F811 Redefinition of unused `fu` from line 3 - | -6 | def bar(): -7 | def baz(): -8 | def fu(): - | ^^ F811 -9 | pass - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_17.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_17.py.snap deleted file mode 100644 index 4e96533476..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_17.py.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F811_17.py:6:12: F811 Redefinition of unused `fu` from line 2 - | -5 | def bar(): -6 | import fu - | ^^ F811 -7 | -8 | def baz(): - | - -F811_17.py:9:13: F811 Redefinition of unused `fu` from line 6 - | - 8 | def baz(): - 9 | def fu(): - | ^^ F811 -10 | pass - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_18.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_18.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_18.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_19.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_19.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_19.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_2.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_2.py.snap deleted file mode 100644 index bf0275f23e..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_2.py.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F811_2.py:1:34: F811 Redefinition of unused `FU` from line 1 - | -1 | from moo import fu as FU, bar as FU - | ^^ F811 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_20.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_20.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_20.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_21.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_21.py.snap deleted file mode 100644 index 40e91e5156..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_21.py.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F811_21.py:32:5: F811 Redefinition of unused `Sequence` from line 26 - | -30 | from typing import ( -31 | List, # noqa: F811 -32 | Sequence, - | ^^^^^^^^ F811 -33 | ) - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_22.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_22.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_22.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_23.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_23.py.snap deleted file mode 100644 index 6f9198fc9d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_23.py.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F811_23.py:4:15: F811 Redefinition of unused `foo` from line 3 - | -3 | import foo as foo -4 | import bar as foo - | ^^^ F811 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_24.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_24.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_24.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_25.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_25.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_25.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_26.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_26.py.snap deleted file mode 100644 index f61e59fc0e..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_26.py.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F811_26.py:5:9: F811 Redefinition of unused `func` from line 2 - | -3 | pass -4 | -5 | def func(self): - | ^^^^ F811 -6 | pass - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_3.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_3.py.snap deleted file mode 100644 index 3f65d958a5..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_3.py.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F811_3.py:1:12: F811 Redefinition of unused `fu` from line 1 - | -1 | import fu; fu = 3 - | ^^ F811 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_4.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_4.py.snap deleted file mode 100644 index 015e0ff8d3..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_4.py.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F811_4.py:1:12: F811 Redefinition of unused `fu` from line 1 - | -1 | import fu; fu, bar = 3 - | ^^ F811 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_5.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_5.py.snap deleted file mode 100644 index ce7897f921..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_5.py.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F811_5.py:1:13: F811 Redefinition of unused `fu` from line 1 - | -1 | import fu; [fu, bar] = 3 - | ^^ F811 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_6.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_6.py.snap deleted file mode 100644 index 26789d845c..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_6.py.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F811_6.py:6:12: F811 Redefinition of unused `os` from line 5 - | -4 | if i == 1: -5 | import os -6 | import os - | ^^ F811 -7 | os.path - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_7.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_7.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_7.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_8.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_8.py.snap deleted file mode 100644 index 291cfe352a..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_8.py.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F811_8.py:5:12: F811 Redefinition of unused `os` from line 4 - | -3 | try: -4 | import os -5 | import os - | ^^ F811 -6 | except: -7 | pass - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_9.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_9.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F811_F811_9.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_0.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_0.py.snap deleted file mode 100644 index 8a0b34df52..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_0.py.snap +++ /dev/null @@ -1,117 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F821_0.py:2:12: F821 Undefined name `self` - | -1 | def get_name(): -2 | return self.name - | ^^^^ F821 - | - -F821_0.py:6:13: F821 Undefined name `self` - | -5 | def get_name(): -6 | return (self.name,) - | ^^^^ F821 - | - -F821_0.py:10:9: F821 Undefined name `self` - | - 9 | def get_name(): -10 | del self.name - | ^^^^ F821 - | - -F821_0.py:21:12: F821 Undefined name `numeric_string` - | -20 | def randdec(maxprec, maxexp): -21 | return numeric_string(maxprec, maxexp) - | ^^^^^^^^^^^^^^ F821 - | - -F821_0.py:58:5: F821 Undefined name `Bar` - | -56 | y: int = 1 -57 | -58 | x: "Bar" = 1 - | ^^^ F821 -59 | -60 | [first] = ["yup"] - | - -F821_0.py:83:11: F821 Undefined name `TOMATO` - | -82 | def update_tomato(): -83 | print(TOMATO) - | ^^^^^^ F821 -84 | TOMATO = "cherry tomato" - | - -F821_0.py:87:8: F821 Undefined name `B` - | -87 | A = f'{B}' - | ^ F821 -88 | A = ( -89 | f'B' - | - -F821_0.py:90:8: F821 Undefined name `B` - | -88 | A = ( -89 | f'B' -90 | f'{B}' - | ^ F821 -91 | ) -92 | C = f'{A:{B}}' - | - -F821_0.py:92:11: F821 Undefined name `B` - | -90 | f'{B}' -91 | ) -92 | C = f'{A:{B}}' - | ^ F821 -93 | C = f'{A:{f"{B}"}}' - | - -F821_0.py:93:14: F821 Undefined name `B` - | -91 | ) -92 | C = f'{A:{B}}' -93 | C = f'{A:{f"{B}"}}' - | ^ F821 -94 | -95 | from typing import Annotated, Literal - | - -F821_0.py:115:10: F821 Undefined name `PEP593Test123` - | -113 | ] -114 | field_with_undefined_stringified_type: Annotated[ -115 | "PEP593Test123", - | ^^^^^^^^^^^^^ F821 -116 | 123, -117 | ] - | - -F821_0.py:123:15: F821 Undefined name `foo` - | -121 | ] -122 | field_with_undefined_nested_subscript: Annotated[ -123 | dict["foo", "bar"], # Expected to fail as undefined. - | ^^^ F821 -124 | 123, -125 | ] - | - -F821_0.py:123:22: F821 Undefined name `bar` - | -121 | ] -122 | field_with_undefined_nested_subscript: Annotated[ -123 | dict["foo", "bar"], # Expected to fail as undefined. - | ^^^ F821 -124 | 123, -125 | ] - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_1.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_1.py.snap deleted file mode 100644 index f7bfe7eef5..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_1.py.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F821_1.py:11:11: F821 Undefined name `Model` - | -10 | # F821 Undefined name `Model` -11 | x = cast("Model", x) - | ^^^^^ F821 - | - -F821_1.py:18:18: F821 Undefined name `Model` - | -17 | # F821 Undefined name `Model` -18 | x = typing.cast("Model", x) - | ^^^^^ F821 - | - -F821_1.py:24:14: F821 Undefined name `Model` - | -23 | # F821 Undefined name `Model` -24 | x = Pattern["Model"] - | ^^^^^ F821 - | - -F821_1.py:30:12: F821 Undefined name `Model` - | -29 | # F821 Undefined name `Model` -30 | x = Match["Model"] - | ^^^^^ F821 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_10.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_10.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_10.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_11.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_11.py.snap deleted file mode 100644 index 4c3951b27b..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_11.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F821_11.py:18:28: F821 Undefined name `os` - | -18 | def f(x: Callable[[VarArg("os")], None]): # F821 - | ^^ F821 -19 | pass - | - -F821_11.py:23:14: F821 Undefined name `Baz` - | -22 | f(Callable[["Bar"], None]) -23 | f(Callable[["Baz"], None]) - | ^^^ F821 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_12.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_12.py.snap deleted file mode 100644 index 4c60b42d52..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_12.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F821_12.py:20:28: F821 Undefined name `os` - | -20 | def f(x: Callable[[VarArg("os")], None]): # F821 - | ^^ F821 -21 | pass - | - -F821_12.py:25:14: F821 Undefined name `Baz` - | -24 | f(Callable[["Bar"], None]) -25 | f(Callable[["Baz"], None]) - | ^^^ F821 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_13.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_13.py.snap deleted file mode 100644 index add8537eba..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_13.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F821_13.py:8:19: F821 Undefined name `List` - | -6 | Y: ForwardRef("List[int]") -7 | -8 | Z = TypeVar("X", "List[int]", "int") - | ^^^^ F821 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_14.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_14.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_14.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_15.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_15.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_15.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_16.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_16.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_16.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_17.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_17.py.snap deleted file mode 100644 index 1cec326ee5..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_17.py.snap +++ /dev/null @@ -1,178 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F821_17.py:16:12: F821 Undefined name `DoesNotExist` - | -14 | # Types used in aliased assignment must exist -15 | -16 | type Foo = DoesNotExist # F821: Undefined name `DoesNotExist` - | ^^^^^^^^^^^^ F821 -17 | type Foo = list[DoesNotExist] # F821: Undefined name `DoesNotExist` - | - -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 | -19 | # Type parameters do not escape alias scopes - | - -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 | -24 | # Type parameters in functions - | - -F821_17.py:39:17: F821 Undefined name `T` - | -37 | from some_library import some_decorator -38 | -39 | @some_decorator(T) # F821: Undefined name `T` - not accessible in decorators - | ^ F821 -40 | -41 | def foo[T](t: T) -> None: ... - | - -F821_17.py:42:1: F821 Undefined name `T` - | -41 | def foo[T](t: T) -> None: ... -42 | T # F821: Undefined name `T` - not accessible afterward function scope - | ^ F821 - | - -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 | -66 | class Foo[T](list[T]): ... - | - -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 | -69 | # Types specified in bounds should exist - | - -F821_17.py:71:13: F821 Undefined name `DoesNotExist` - | -69 | # Types specified in bounds should exist -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` -73 | class Foo[T: DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` - | - -F821_17.py:72:12: F821 Undefined name `DoesNotExist` - | -71 | type Foo[T: DoesNotExist] = T # F821: Undefined name `DoesNotExist` -72 | def foo[T: DoesNotExist](t: T) -> T: return t # F821: Undefined name `DoesNotExist` - | ^^^^^^^^^^^^ F821 -73 | class Foo[T: DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` - | - -F821_17.py:73:14: F821 Undefined name `DoesNotExist` - | -71 | type Foo[T: DoesNotExist] = T # 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 | -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 | -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` -77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` - | - -F821_17.py:75:29: F821 Undefined name `DoesNotExist2` - | -73 | class Foo[T: DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` -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` -77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` - | - -F821_17.py:76:13: F821 Undefined name `DoesNotExist1` - | -75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` -76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` - | ^^^^^^^^^^^^^ F821 -77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` - | - -F821_17.py:76:28: F821 Undefined name `DoesNotExist2` - | -75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` -76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` - | ^^^^^^^^^^^^^ F821 -77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` - | - -F821_17.py:77:15: F821 Undefined name `DoesNotExist1` - | -75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, 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 | -79 | # Type parameters in nested classes - | - -F821_17.py:77:30: F821 Undefined name `DoesNotExist2` - | -75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, 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 | -79 | # Type parameters in nested classes - | - -F821_17.py:92:52: F821 Undefined name `t` - | -90 | return x -91 | -92 | def cannot_access_parent_variable(self, x: t) -> t: # F821: Undefined name `T` - | ^ F821 -93 | t # F821: Undefined name `t` -94 | return x - | - -F821_17.py:92:58: F821 Undefined name `t` - | -90 | return x -91 | -92 | def cannot_access_parent_variable(self, x: t) -> t: # F821: Undefined name `T` - | ^ F821 -93 | t # F821: Undefined name `t` -94 | return x - | - -F821_17.py:93:17: F821 Undefined name `t` - | -92 | def cannot_access_parent_variable(self, x: t) -> t: # F821: Undefined name `T` -93 | t # F821: Undefined name `t` - | ^ F821 -94 | return x - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_2.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_2.py.snap deleted file mode 100644 index a6c4129d93..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_2.py.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F821_2.py:5:13: F821 Undefined name `Model` - | -4 | # F821 Undefined name `Model` -5 | x: Literal["Model"] - | ^^^^^ F821 -6 | -7 | from typing_extensions import Literal - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_3.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_3.py.snap deleted file mode 100644 index 38cf1234a4..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_3.py.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F821_3.py:11:10: F821 Undefined name `key` - | - 9 | # F821 Undefined name `key` -10 | # F821 Undefined name `value` -11 | x: dict["key", "value"] - | ^^^ F821 -12 | -13 | # OK - | - -F821_3.py:11:17: F821 Undefined name `value` - | - 9 | # F821 Undefined name `key` -10 | # F821 Undefined name `value` -11 | x: dict["key", "value"] - | ^^^^^ F821 -12 | -13 | # OK - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_4.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_4.py.snap deleted file mode 100644 index 12c934891a..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_4.py.snap +++ /dev/null @@ -1,44 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F821_4.py:4:11: F821 Undefined name `Model` - | -2 | from typing import List -3 | -4 | _ = List["Model"] - | ^^^^^ F821 - | - -F821_4.py:9:12: F821 Undefined name `Model` - | -7 | from typing import List as IList -8 | -9 | _ = IList["Model"] - | ^^^^^ F821 - | - -F821_4.py:14:16: F821 Undefined name `Model` - | -12 | from collections.abc import ItemsView -13 | -14 | _ = ItemsView["Model"] - | ^^^^^ F821 - | - -F821_4.py:19:32: F821 Undefined name `Model` - | -17 | import collections.abc -18 | -19 | _ = collections.abc.ItemsView["Model"] - | ^^^^^ F821 - | - -F821_4.py:24:20: F821 Undefined name `Model` - | -22 | from collections import abc -23 | -24 | _ = abc.ItemsView["Model"] - | ^^^^^ F821 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_5.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_5.py.snap deleted file mode 100644 index 97f255ff0f..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_5.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F821_5.py:5:31: F821 Undefined name `InnerClass` - | -4 | class RandomClass: -5 | def random_func(self) -> "InnerClass": - | ^^^^^^^^^^ F821 -6 | pass - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_6.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_6.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_6.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_7.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_7.py.snap deleted file mode 100644 index da88eb6403..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_7.py.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F821_7.py:11:22: F821 Undefined name `Undefined` - | -10 | # Not OK -11 | _ = DefaultNamedArg("Undefined", name="some_prop_name") - | ^^^^^^^^^ F821 -12 | _ = DefaultNamedArg(type="Undefined", name="some_prop_name") -13 | _ = DefaultNamedArg("Undefined", "some_prop_name") - | - -F821_7.py:12:27: F821 Undefined name `Undefined` - | -10 | # Not OK -11 | _ = DefaultNamedArg("Undefined", name="some_prop_name") -12 | _ = DefaultNamedArg(type="Undefined", name="some_prop_name") - | ^^^^^^^^^ F821 -13 | _ = DefaultNamedArg("Undefined", "some_prop_name") - | - -F821_7.py:13:22: F821 Undefined name `Undefined` - | -11 | _ = DefaultNamedArg("Undefined", name="some_prop_name") -12 | _ = DefaultNamedArg(type="Undefined", name="some_prop_name") -13 | _ = DefaultNamedArg("Undefined", "some_prop_name") - | ^^^^^^^^^ F821 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_8.pyi.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_8.pyi.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_8.pyi.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_9.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_9.py.snap deleted file mode 100644 index 01db81f47c..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F821_F821_9.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F821_9.py:22:20: F821 Undefined name `captured` - | -20 | match provided: -21 | case True: -22 | return captured # F821 - | ^^^^^^^^ F821 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F822_F822_0.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F822_F822_0.py.snap deleted file mode 100644 index b5972c45fa..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F822_F822_0.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F822_0.py:3:1: F822 Undefined name `b` in `__all__` - | -1 | a = 1 -2 | -3 | __all__ = ["a", "b"] - | ^^^^^^^ F822 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F822_F822_1.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F822_F822_1.py.snap deleted file mode 100644 index ff3bd3079e..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F822_F822_1.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F822_1.py:3:1: F822 Undefined name `b` in `__all__` - | -1 | a = 1 -2 | -3 | __all__ = list(["a", "b"]) - | ^^^^^^^ F822 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F822_F822_2.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F822_F822_2.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F822_F822_2.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F823_F823.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F823_F823.py.snap deleted file mode 100644 index 8139a06590..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F823_F823.py.snap +++ /dev/null @@ -1,46 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F823.py:6:5: F823 Local variable `my_var` referenced before assignment - | -5 | def foo(): -6 | my_var += 1 - | ^^^^^^ F823 - | - -F823.py:32:15: F823 Local variable `my_var` referenced before assignment - | -30 | class Class: -31 | def f(self): -32 | print(my_var) - | ^^^^^^ F823 -33 | my_var = 1 - | - -F823.py:40:15: F823 Local variable `my_var` referenced before assignment - | -39 | def f(self): -40 | print(my_var) - | ^^^^^^ F823 -41 | my_var = 1 - | - -F823.py:48:11: F823 Local variable `sys` referenced before assignment - | -47 | def main(): -48 | print(sys.argv) - | ^^^ F823 -49 | -50 | try: - | - -F823.py:62:11: F823 Local variable `sys` referenced before assignment - | -61 | def main(): -62 | print(sys.argv) - | ^^^ F823 -63 | -64 | for sys in range(5): - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_0.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_0.py.snap deleted file mode 100644 index d6ecba5159..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_0.py.snap +++ /dev/null @@ -1,222 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F841_0.py:3:22: F841 [*] Local variable `e` is assigned to but never used - | -1 | try: -2 | 1 / 0 -3 | except ValueError as e: - | ^ F841 -4 | pass - | - = help: Remove assignment to unused variable `e` - -ℹ Fix -1 1 | try: -2 2 | 1 / 0 -3 |-except ValueError as e: - 3 |+except ValueError: -4 4 | pass -5 5 | -6 6 | - -F841_0.py:16:5: F841 [*] Local variable `z` is assigned to but never used - | -14 | x = 1 -15 | y = 2 -16 | z = x + y - | ^ F841 - | - = help: Remove assignment to unused variable `z` - -ℹ Suggested fix -13 13 | def f(): -14 14 | x = 1 -15 15 | y = 2 -16 |- z = x + y - 16 |+ x + y -17 17 | -18 18 | -19 19 | def f(): - -F841_0.py:20:5: F841 [*] Local variable `foo` is assigned to but never used - | -19 | def f(): -20 | foo = (1, 2) - | ^^^ F841 -21 | (a, b) = (1, 2) - | - = help: Remove assignment to unused variable `foo` - -ℹ Suggested fix -17 17 | -18 18 | -19 19 | def f(): -20 |- foo = (1, 2) -21 20 | (a, b) = (1, 2) -22 21 | -23 22 | bar = (1, 2) - -F841_0.py:21:6: F841 Local variable `a` is assigned to but never used - | -19 | def f(): -20 | foo = (1, 2) -21 | (a, b) = (1, 2) - | ^ F841 -22 | -23 | bar = (1, 2) - | - = help: Remove assignment to unused variable `a` - -F841_0.py:21:9: F841 Local variable `b` is assigned to but never used - | -19 | def f(): -20 | foo = (1, 2) -21 | (a, b) = (1, 2) - | ^ F841 -22 | -23 | bar = (1, 2) - | - = help: Remove assignment to unused variable `b` - -F841_0.py:26:14: F841 [*] Local variable `baz` is assigned to but never used - | -24 | (c, d) = bar -25 | -26 | (x, y) = baz = bar - | ^^^ F841 - | - = help: Remove assignment to unused variable `baz` - -ℹ Suggested fix -23 23 | bar = (1, 2) -24 24 | (c, d) = bar -25 25 | -26 |- (x, y) = baz = bar - 26 |+ (x, y) = bar -27 27 | -28 28 | -29 29 | def f(): - -F841_0.py:51:9: F841 [*] Local variable `b` is assigned to but never used - | -49 | def c(): -50 | # F841 -51 | b = 1 - | ^ F841 -52 | -53 | def d(): - | - = help: Remove assignment to unused variable `b` - -ℹ Suggested fix -48 48 | -49 49 | def c(): -50 50 | # F841 -51 |- b = 1 - 51 |+ pass -52 52 | -53 53 | def d(): -54 54 | nonlocal b - -F841_0.py:79:26: F841 [*] Local variable `my_file` is assigned to but never used - | -78 | def f(): -79 | with open("file") as my_file, open("") as ((this, that)): - | ^^^^^^^ F841 -80 | print("hello") - | - = help: Remove assignment to unused variable `my_file` - -ℹ Suggested fix -76 76 | -77 77 | -78 78 | def f(): -79 |- with open("file") as my_file, open("") as ((this, that)): - 79 |+ with open("file"), open("") as ((this, that)): -80 80 | print("hello") -81 81 | -82 82 | - -F841_0.py:85:25: F841 [*] Local variable `my_file` is assigned to but never used - | -83 | def f(): -84 | with ( -85 | open("file") as my_file, - | ^^^^^^^ F841 -86 | open("") as ((this, that)), -87 | ): - | - = help: Remove assignment to unused variable `my_file` - -ℹ Suggested fix -82 82 | -83 83 | def f(): -84 84 | with ( -85 |- open("file") as my_file, - 85 |+ open("file"), -86 86 | open("") as ((this, that)), -87 87 | ): -88 88 | print("hello") - -F841_0.py:102:5: F841 [*] Local variable `msg3` is assigned to but never used - | -100 | msg1 = "Hello, world!" -101 | msg2 = "Hello, world!" -102 | msg3 = "Hello, world!" - | ^^^^ F841 -103 | match x: -104 | case 1: - | - = help: Remove assignment to unused variable `msg3` - -ℹ Suggested fix -99 99 | def f(x: int): -100 100 | msg1 = "Hello, world!" -101 101 | msg2 = "Hello, world!" -102 |- msg3 = "Hello, world!" -103 102 | match x: -104 103 | case 1: -105 104 | print(msg1) - -F841_0.py:115:5: F841 [*] Local variable `Baz` is assigned to but never used - | -113 | Foo = enum.Enum("Foo", "A B") -114 | Bar = enum.Enum("Bar", "A B") -115 | Baz = enum.Enum("Baz", "A B") - | ^^^ F841 -116 | -117 | match x: - | - = help: Remove assignment to unused variable `Baz` - -ℹ Suggested fix -112 112 | -113 113 | Foo = enum.Enum("Foo", "A B") -114 114 | Bar = enum.Enum("Bar", "A B") -115 |- Baz = enum.Enum("Baz", "A B") - 115 |+ enum.Enum("Baz", "A B") -116 116 | -117 117 | match x: -118 118 | case (Foo.A): - -F841_0.py:122:14: F841 Local variable `y` is assigned to but never used - | -120 | case [Bar.A, *_]: -121 | print("A") -122 | case y: - | ^ F841 -123 | pass - | - = help: Remove assignment to unused variable `y` - -F841_0.py:127:21: F841 Local variable `value` is assigned to but never used - | -126 | def f(): -127 | if any((key := (value := x)) for x in ["ok"]): - | ^^^^^ F841 -128 | print(key) - | - = help: Remove assignment to unused variable `value` - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_1.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_1.py.snap deleted file mode 100644 index c273807b0a..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_1.py.snap +++ /dev/null @@ -1,88 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F841_1.py:6:5: F841 Local variable `x` is assigned to but never used - | -5 | def f(): -6 | x, y = 1, 2 # this triggers F841 as it's just a simple assignment where unpacking isn't needed - | ^ F841 - | - = help: Remove assignment to unused variable `x` - -F841_1.py:6:8: F841 Local variable `y` is assigned to but never used - | -5 | def f(): -6 | x, y = 1, 2 # this triggers F841 as it's just a simple assignment where unpacking isn't needed - | ^ F841 - | - = help: Remove assignment to unused variable `y` - -F841_1.py:16:14: F841 [*] Local variable `coords` is assigned to but never used - | -15 | def f(): -16 | (x, y) = coords = 1, 2 # this triggers F841 on coords - | ^^^^^^ F841 - | - = help: Remove assignment to unused variable `coords` - -ℹ Suggested fix -13 13 | -14 14 | -15 15 | def f(): -16 |- (x, y) = coords = 1, 2 # this triggers F841 on coords - 16 |+ (x, y) = 1, 2 # this triggers F841 on coords -17 17 | -18 18 | -19 19 | def f(): - -F841_1.py:20:5: F841 [*] Local variable `coords` is assigned to but never used - | -19 | def f(): -20 | coords = (x, y) = 1, 2 # this triggers F841 on coords - | ^^^^^^ F841 - | - = help: Remove assignment to unused variable `coords` - -ℹ Suggested fix -17 17 | -18 18 | -19 19 | def f(): -20 |- coords = (x, y) = 1, 2 # this triggers F841 on coords - 20 |+ (x, y) = 1, 2 # this triggers F841 on coords -21 21 | -22 22 | -23 23 | def f(): - -F841_1.py:24:6: F841 Local variable `a` is assigned to but never used - | -23 | def f(): -24 | (a, b) = (x, y) = 1, 2 # this triggers F841 on everything - | ^ F841 - | - = help: Remove assignment to unused variable `a` - -F841_1.py:24:9: F841 Local variable `b` is assigned to but never used - | -23 | def f(): -24 | (a, b) = (x, y) = 1, 2 # this triggers F841 on everything - | ^ F841 - | - = help: Remove assignment to unused variable `b` - -F841_1.py:24:15: F841 Local variable `x` is assigned to but never used - | -23 | def f(): -24 | (a, b) = (x, y) = 1, 2 # this triggers F841 on everything - | ^ F841 - | - = help: Remove assignment to unused variable `x` - -F841_1.py:24:18: F841 Local variable `y` is assigned to but never used - | -23 | def f(): -24 | (a, b) = (x, y) = 1, 2 # this triggers F841 on everything - | ^ F841 - | - = help: Remove assignment to unused variable `y` - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_2.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_2.py.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_2.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_3.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_3.py.snap deleted file mode 100644 index c428d3b5ec..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F841_F841_3.py.snap +++ /dev/null @@ -1,696 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F841_3.py:5:5: F841 [*] Local variable `x` is assigned to but never used - | -4 | def f(): -5 | x = 1 - | ^ F841 -6 | y = 2 - | - = help: Remove assignment to unused variable `x` - -ℹ Suggested fix -2 2 | -3 3 | -4 4 | def f(): -5 |- x = 1 -6 5 | y = 2 -7 6 | -8 7 | z = 3 - -F841_3.py:6:5: F841 [*] Local variable `y` is assigned to but never used - | -4 | def f(): -5 | x = 1 -6 | y = 2 - | ^ F841 -7 | -8 | z = 3 - | - = help: Remove assignment to unused variable `y` - -ℹ Suggested fix -3 3 | -4 4 | def f(): -5 5 | x = 1 -6 |- y = 2 -7 6 | -8 7 | z = 3 -9 8 | print(z) - -F841_3.py:13:5: F841 [*] Local variable `x` is assigned to but never used - | -12 | def f(): -13 | x: int = 1 - | ^ F841 -14 | y: int = 2 - | - = help: Remove assignment to unused variable `x` - -ℹ Suggested fix -10 10 | -11 11 | -12 12 | def f(): -13 |- x: int = 1 -14 13 | y: int = 2 -15 14 | -16 15 | z: int = 3 - -F841_3.py:14:5: F841 [*] Local variable `y` is assigned to but never used - | -12 | def f(): -13 | x: int = 1 -14 | y: int = 2 - | ^ F841 -15 | -16 | z: int = 3 - | - = help: Remove assignment to unused variable `y` - -ℹ Suggested fix -11 11 | -12 12 | def f(): -13 13 | x: int = 1 -14 |- y: int = 2 -15 14 | -16 15 | z: int = 3 -17 16 | print(z) - -F841_3.py:21:19: F841 [*] Local variable `x1` is assigned to but never used - | -20 | def f(): -21 | with foo() as x1: - | ^^ F841 -22 | pass - | - = help: Remove assignment to unused variable `x1` - -ℹ Suggested fix -18 18 | -19 19 | -20 20 | def f(): -21 |- with foo() as x1: - 21 |+ with foo(): -22 22 | pass -23 23 | -24 24 | with foo() as (x2, y2): - -F841_3.py:27:20: F841 [*] Local variable `x3` is assigned to but never used - | -25 | pass -26 | -27 | with (foo() as x3, foo() as y3, foo() as z3): - | ^^ F841 -28 | pass - | - = help: Remove assignment to unused variable `x3` - -ℹ Suggested fix -24 24 | with foo() as (x2, y2): -25 25 | pass -26 26 | -27 |- with (foo() as x3, foo() as y3, foo() as z3): - 27 |+ with (foo(), foo() as y3, foo() as z3): -28 28 | pass -29 29 | -30 30 | - -F841_3.py:27:33: F841 [*] Local variable `y3` is assigned to but never used - | -25 | pass -26 | -27 | with (foo() as x3, foo() as y3, foo() as z3): - | ^^ F841 -28 | pass - | - = help: Remove assignment to unused variable `y3` - -ℹ Suggested fix -24 24 | with foo() as (x2, y2): -25 25 | pass -26 26 | -27 |- with (foo() as x3, foo() as y3, foo() as z3): - 27 |+ with (foo() as x3, foo(), foo() as z3): -28 28 | pass -29 29 | -30 30 | - -F841_3.py:27:46: F841 [*] Local variable `z3` is assigned to but never used - | -25 | pass -26 | -27 | with (foo() as x3, foo() as y3, foo() as z3): - | ^^ F841 -28 | pass - | - = help: Remove assignment to unused variable `z3` - -ℹ Suggested fix -24 24 | with foo() as (x2, y2): -25 25 | pass -26 26 | -27 |- with (foo() as x3, foo() as y3, foo() as z3): - 27 |+ with (foo() as x3, foo() as y3, foo()): -28 28 | pass -29 29 | -30 30 | - -F841_3.py:32:6: F841 Local variable `x1` is assigned to but never used - | -31 | def f(): -32 | (x1, y1) = (1, 2) - | ^^ F841 -33 | (x2, y2) = coords2 = (1, 2) -34 | coords3 = (x3, y3) = (1, 2) - | - = help: Remove assignment to unused variable `x1` - -F841_3.py:32:10: F841 Local variable `y1` is assigned to but never used - | -31 | def f(): -32 | (x1, y1) = (1, 2) - | ^^ F841 -33 | (x2, y2) = coords2 = (1, 2) -34 | coords3 = (x3, y3) = (1, 2) - | - = help: Remove assignment to unused variable `y1` - -F841_3.py:33:16: F841 [*] Local variable `coords2` is assigned to but never used - | -31 | def f(): -32 | (x1, y1) = (1, 2) -33 | (x2, y2) = coords2 = (1, 2) - | ^^^^^^^ F841 -34 | coords3 = (x3, y3) = (1, 2) - | - = help: Remove assignment to unused variable `coords2` - -ℹ Suggested fix -30 30 | -31 31 | def f(): -32 32 | (x1, y1) = (1, 2) -33 |- (x2, y2) = coords2 = (1, 2) - 33 |+ (x2, y2) = (1, 2) -34 34 | coords3 = (x3, y3) = (1, 2) -35 35 | -36 36 | - -F841_3.py:34:5: F841 [*] Local variable `coords3` is assigned to but never used - | -32 | (x1, y1) = (1, 2) -33 | (x2, y2) = coords2 = (1, 2) -34 | coords3 = (x3, y3) = (1, 2) - | ^^^^^^^ F841 - | - = help: Remove assignment to unused variable `coords3` - -ℹ Suggested fix -31 31 | def f(): -32 32 | (x1, y1) = (1, 2) -33 33 | (x2, y2) = coords2 = (1, 2) -34 |- coords3 = (x3, y3) = (1, 2) - 34 |+ (x3, y3) = (1, 2) -35 35 | -36 36 | -37 37 | def f(): - -F841_3.py:40:26: F841 [*] Local variable `x1` is assigned to but never used - | -38 | try: -39 | 1 / 0 -40 | except ValueError as x1: - | ^^ F841 -41 | pass - | - = help: Remove assignment to unused variable `x1` - -ℹ Fix -37 37 | def f(): -38 38 | try: -39 39 | 1 / 0 -40 |- except ValueError as x1: - 40 |+ except ValueError: -41 41 | pass -42 42 | -43 43 | try: - -F841_3.py:45:47: F841 [*] Local variable `x2` is assigned to but never used - | -43 | try: -44 | 1 / 0 -45 | except (ValueError, ZeroDivisionError) as x2: - | ^^ F841 -46 | pass - | - = help: Remove assignment to unused variable `x2` - -ℹ Fix -42 42 | -43 43 | try: -44 44 | 1 / 0 -45 |- except (ValueError, ZeroDivisionError) as x2: - 45 |+ except (ValueError, ZeroDivisionError): -46 46 | pass -47 47 | -48 48 | - -F841_3.py:50:5: F841 [*] Local variable `x` is assigned to but never used - | -49 | def f(a, b): -50 | x = ( - | ^ F841 -51 | a() -52 | if a is not None - | - = help: Remove assignment to unused variable `x` - -ℹ Suggested fix -47 47 | -48 48 | -49 49 | def f(a, b): -50 |- x = ( - 50 |+ ( -51 51 | a() -52 52 | if a is not None -53 53 | else b - -F841_3.py:56:5: F841 [*] Local variable `y` is assigned to but never used - | -54 | ) -55 | -56 | y = \ - | ^ F841 -57 | a() if a is not None else b - | - = help: Remove assignment to unused variable `y` - -ℹ Suggested fix -53 53 | else b -54 54 | ) -55 55 | -56 |- y = \ -57 |- a() if a is not None else b - 56 |+ a() if a is not None else b -58 57 | -59 58 | -60 59 | def f(a, b): - -F841_3.py:61:5: F841 [*] Local variable `x` is assigned to but never used - | -60 | def f(a, b): -61 | x = ( - | ^ F841 -62 | a -63 | if a is not None - | - = help: Remove assignment to unused variable `x` - -ℹ Suggested fix -58 58 | -59 59 | -60 60 | def f(a, b): -61 |- x = ( -62 |- a -63 |- if a is not None -64 |- else b -65 |- ) -66 61 | -67 62 | y = \ -68 63 | a if a is not None else b - -F841_3.py:67:5: F841 [*] Local variable `y` is assigned to but never used - | -65 | ) -66 | -67 | y = \ - | ^ F841 -68 | a if a is not None else b - | - = help: Remove assignment to unused variable `y` - -ℹ Suggested fix -64 64 | else b -65 65 | ) -66 66 | -67 |- y = \ -68 |- a if a is not None else b -69 67 | -70 68 | -71 69 | def f(): - -F841_3.py:72:24: F841 [*] Local variable `cm` is assigned to but never used - | -71 | def f(): -72 | with Nested(m) as (cm): - | ^^ F841 -73 | pass - | - = help: Remove assignment to unused variable `cm` - -ℹ Suggested fix -69 69 | -70 70 | -71 71 | def f(): -72 |- with Nested(m) as (cm): - 72 |+ with Nested(m): -73 73 | pass -74 74 | -75 75 | - -F841_3.py:77:25: F841 [*] Local variable `cm` is assigned to but never used - | -76 | def f(): -77 | with (Nested(m) as (cm),): - | ^^ F841 -78 | pass - | - = help: Remove assignment to unused variable `cm` - -ℹ Suggested fix -74 74 | -75 75 | -76 76 | def f(): -77 |- with (Nested(m) as (cm),): - 77 |+ with (Nested(m),): -78 78 | pass -79 79 | -80 80 | - -F841_3.py:87:26: F841 [*] Local variable `cm` is assigned to but never used - | -86 | def f(): -87 | with (Nested(m)) as (cm): - | ^^ F841 -88 | pass - | - = help: Remove assignment to unused variable `cm` - -ℹ Suggested fix -84 84 | -85 85 | -86 86 | def f(): -87 |- with (Nested(m)) as (cm): - 87 |+ with (Nested(m)): -88 88 | pass -89 89 | -90 90 | - -F841_3.py:92:5: F841 [*] Local variable `toplevel` is assigned to but never used - | -91 | def f(): -92 | toplevel = tt = lexer.get_token() - | ^^^^^^^^ F841 -93 | if not tt: -94 | break - | - = help: Remove assignment to unused variable `toplevel` - -ℹ Suggested fix -89 89 | -90 90 | -91 91 | def f(): -92 |- toplevel = tt = lexer.get_token() - 92 |+ tt = lexer.get_token() -93 93 | if not tt: -94 94 | break -95 95 | - -F841_3.py:98:5: F841 [*] Local variable `toplevel` is assigned to but never used - | -97 | def f(): -98 | toplevel = tt = lexer.get_token() - | ^^^^^^^^ F841 - | - = help: Remove assignment to unused variable `toplevel` - -ℹ Suggested fix -95 95 | -96 96 | -97 97 | def f(): -98 |- toplevel = tt = lexer.get_token() - 98 |+ tt = lexer.get_token() -99 99 | -100 100 | -101 101 | def f(): - -F841_3.py:98:16: F841 [*] Local variable `tt` is assigned to but never used - | -97 | def f(): -98 | toplevel = tt = lexer.get_token() - | ^^ F841 - | - = help: Remove assignment to unused variable `tt` - -ℹ Suggested fix -95 95 | -96 96 | -97 97 | def f(): -98 |- toplevel = tt = lexer.get_token() - 98 |+ toplevel = lexer.get_token() -99 99 | -100 100 | -101 101 | def f(): - -F841_3.py:102:5: F841 [*] Local variable `toplevel` is assigned to but never used - | -101 | def f(): -102 | toplevel = (a, b) = lexer.get_token() - | ^^^^^^^^ F841 - | - = help: Remove assignment to unused variable `toplevel` - -ℹ Suggested fix -99 99 | -100 100 | -101 101 | def f(): -102 |- toplevel = (a, b) = lexer.get_token() - 102 |+ (a, b) = lexer.get_token() -103 103 | -104 104 | -105 105 | def f(): - -F841_3.py:106:14: F841 [*] Local variable `toplevel` is assigned to but never used - | -105 | def f(): -106 | (a, b) = toplevel = lexer.get_token() - | ^^^^^^^^ F841 - | - = help: Remove assignment to unused variable `toplevel` - -ℹ Suggested fix -103 103 | -104 104 | -105 105 | def f(): -106 |- (a, b) = toplevel = lexer.get_token() - 106 |+ (a, b) = lexer.get_token() -107 107 | -108 108 | -109 109 | def f(): - -F841_3.py:110:5: F841 [*] Local variable `toplevel` is assigned to but never used - | -109 | def f(): -110 | toplevel = tt = 1 - | ^^^^^^^^ F841 - | - = help: Remove assignment to unused variable `toplevel` - -ℹ Suggested fix -107 107 | -108 108 | -109 109 | def f(): -110 |- toplevel = tt = 1 - 110 |+ tt = 1 -111 111 | -112 112 | -113 113 | def f(provided: int) -> int: - -F841_3.py:110:16: F841 [*] Local variable `tt` is assigned to but never used - | -109 | def f(): -110 | toplevel = tt = 1 - | ^^ F841 - | - = help: Remove assignment to unused variable `tt` - -ℹ Suggested fix -107 107 | -108 108 | -109 109 | def f(): -110 |- toplevel = tt = 1 - 110 |+ toplevel = 1 -111 111 | -112 112 | -113 113 | def f(provided: int) -> int: - -F841_3.py:115:19: F841 Local variable `x` is assigned to but never used - | -113 | def f(provided: int) -> int: -114 | match provided: -115 | case [_, *x]: - | ^ F841 -116 | pass - | - = help: Remove assignment to unused variable `x` - -F841_3.py:121:14: F841 Local variable `x` is assigned to but never used - | -119 | def f(provided: int) -> int: -120 | match provided: -121 | case x: - | ^ F841 -122 | pass - | - = help: Remove assignment to unused variable `x` - -F841_3.py:127:18: F841 Local variable `bar` is assigned to but never used - | -125 | def f(provided: int) -> int: -126 | match provided: -127 | case Foo(bar) as x: - | ^^^ F841 -128 | pass - | - = help: Remove assignment to unused variable `bar` - -F841_3.py:127:26: F841 Local variable `x` is assigned to but never used - | -125 | def f(provided: int) -> int: -126 | match provided: -127 | case Foo(bar) as x: - | ^ F841 -128 | pass - | - = help: Remove assignment to unused variable `x` - -F841_3.py:133:27: F841 Local variable `x` is assigned to but never used - | -131 | def f(provided: int) -> int: -132 | match provided: -133 | case {"foo": 0, **x}: - | ^ F841 -134 | pass - | - = help: Remove assignment to unused variable `x` - -F841_3.py:139:17: F841 Local variable `x` is assigned to but never used - | -137 | def f(provided: int) -> int: -138 | match provided: -139 | case {**x}: - | ^ F841 -140 | pass - | - = help: Remove assignment to unused variable `x` - -F841_3.py:155:17: F841 [*] Local variable `e` is assigned to but never used - | -153 | try: -154 | print("hello") -155 | except A as e : - | ^ F841 -156 | print("oh no!") - | - = help: Remove assignment to unused variable `e` - -ℹ Fix -152 152 | def f() -> None: -153 153 | try: -154 154 | print("hello") -155 |- except A as e : - 155 |+ except A: -156 156 | print("oh no!") -157 157 | -158 158 | - -F841_3.py:160:5: F841 [*] Local variable `x` is assigned to but never used - | -159 | def f(): -160 | x = 1 - | ^ F841 -161 | y = 2 - | - = help: Remove assignment to unused variable `x` - -ℹ Suggested fix -157 157 | -158 158 | -159 159 | def f(): -160 |- x = 1 -161 160 | y = 2 -162 161 | -163 162 | - -F841_3.py:161:5: F841 [*] Local variable `y` is assigned to but never used - | -159 | def f(): -160 | x = 1 -161 | y = 2 - | ^ F841 - | - = help: Remove assignment to unused variable `y` - -ℹ Suggested fix -158 158 | -159 159 | def f(): -160 160 | x = 1 -161 |- y = 2 -162 161 | -163 162 | -164 163 | def f(): - -F841_3.py:165:5: F841 [*] Local variable `x` is assigned to but never used - | -164 | def f(): -165 | x = 1 - | ^ F841 -166 | -167 | y = 2 - | - = help: Remove assignment to unused variable `x` - -ℹ Suggested fix -162 162 | -163 163 | -164 164 | def f(): -165 |- x = 1 -166 165 | -167 166 | y = 2 -168 167 | - -F841_3.py:167:5: F841 [*] Local variable `y` is assigned to but never used - | -165 | x = 1 -166 | -167 | y = 2 - | ^ F841 - | - = help: Remove assignment to unused variable `y` - -ℹ Suggested fix -164 164 | def f(): -165 165 | x = 1 -166 166 | -167 |- y = 2 -168 167 | -169 168 | -170 169 | def f(): - -F841_3.py:173:6: F841 [*] Local variable `x` is assigned to but never used - | -171 | (x) = foo() -172 | ((x)) = foo() -173 | (x) = (y.z) = foo() - | ^ F841 - | - = help: Remove assignment to unused variable `x` - -ℹ Suggested fix -170 170 | def f(): -171 171 | (x) = foo() -172 172 | ((x)) = foo() -173 |- (x) = (y.z) = foo() - 173 |+ (y.z) = foo() - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F842_F842.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F842_F842.py.snap deleted file mode 100644 index cf6131dbea..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F842_F842.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F842.py:2:5: F842 Local variable `name` is annotated but never used - | -1 | def f(): -2 | name: str - | ^^^^ F842 -3 | age: int - | - -F842.py:3:5: F842 Local variable `age` is annotated but never used - | -1 | def f(): -2 | name: str -3 | age: int - | ^^^ F842 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F901_F901.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F901_F901.py.snap deleted file mode 100644 index a5cac50d13..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F901_F901.py.snap +++ /dev/null @@ -1,35 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F901.py:2:11: F901 [*] `raise NotImplemented` should be `raise NotImplementedError` - | -1 | def f() -> None: -2 | raise NotImplemented() - | ^^^^^^^^^^^^^^ F901 - | - = help: Use `raise NotImplementedError` - -ℹ Fix -1 1 | def f() -> None: -2 |- raise NotImplemented() - 2 |+ raise NotImplementedError() -3 3 | -4 4 | -5 5 | def g() -> None: - -F901.py:6:11: F901 [*] `raise NotImplemented` should be `raise NotImplementedError` - | -5 | def g() -> None: -6 | raise NotImplemented - | ^^^^^^^^^^^^^^ F901 - | - = help: Use `raise NotImplementedError` - -ℹ Fix -3 3 | -4 4 | -5 5 | def g() -> None: -6 |- raise NotImplemented - 6 |+ raise NotImplementedError - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__augmented_assignment_after_del.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__augmented_assignment_after_del.snap deleted file mode 100644 index 57a88f04c4..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__augmented_assignment_after_del.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -:10:5: F821 Undefined name `x` - | - 8 | # entirely after the `del` statement. However, it should be an F821 - 9 | # error, because the name is defined in the scope, but unbound. -10 | x += 1 - | ^ F821 - | - -:10:5: F841 Local variable `x` is assigned to but never used - | - 8 | # entirely after the `del` statement. However, it should be an F821 - 9 | # error, because the name is defined in the scope, but unbound. -10 | x += 1 - | ^ F841 - | - = help: Remove assignment to unused variable `x` - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__default_builtins.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__default_builtins.snap deleted file mode 100644 index 0ba1ffc048..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__default_builtins.snap +++ /dev/null @@ -1,10 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -builtins.py:1:1: F821 Undefined name `_` - | -1 | _("Translations") - | ^ F821 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__default_typing_modules.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__default_typing_modules.snap deleted file mode 100644 index 71270c7714..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__default_typing_modules.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -typing_modules.py:6:36: F821 Undefined name `db` - | -6 | X = Union[Literal[False], Literal["db"]] - | ^^ F821 -7 | y = Optional["Class"] - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__del_shadowed_global_import_in_global_scope.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__del_shadowed_global_import_in_global_scope.snap deleted file mode 100644 index b54efa2244..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__del_shadowed_global_import_in_global_scope.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -:5:12: F401 [*] `os` imported but unused - | -4 | def f(): -5 | import os - | ^^ F401 -6 | -7 | # Despite this `del`, `import os` in `f` should still be flagged as shadowing an unused - | - = help: Remove unused import: `os` - -ℹ Fix -2 2 | import os -3 3 | -4 4 | def f(): -5 |- import os - 5 |+ pass -6 6 | -7 7 | # Despite this `del`, `import os` in `f` should still be flagged as shadowing an unused -8 8 | # import. (This is a false negative, but is consistent with Pyflakes.) - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap deleted file mode 100644 index b2b02e92a7..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap +++ /dev/null @@ -1,29 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -:2:8: F401 [*] `os` imported but unused - | -2 | import os - | ^^ F401 -3 | -4 | def f(): - | - = help: Remove unused import: `os` - -ℹ Fix -1 1 | -2 |-import os -3 2 | -4 3 | def f(): -5 4 | import os - -:5:12: F811 Redefinition of unused `os` from line 2 - | -4 | def f(): -5 | import os - | ^^ F811 -6 | -7 | # Despite this `del`, `import os` in `f` should still be flagged as shadowing an unused - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap deleted file mode 100644 index 747002c934..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap +++ /dev/null @@ -1,28 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -:2:8: F401 [*] `os` imported but unused - | -2 | import os - | ^^ F401 -3 | -4 | def f(): - | - = help: Remove unused import: `os` - -ℹ Fix -1 1 | -2 |-import os -3 2 | -4 3 | def f(): -5 4 | os = 1 - -:5:5: F811 Redefinition of unused `os` from line 2 - | -4 | def f(): -5 | os = 1 - | ^^ F811 -6 | print(os) - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap deleted file mode 100644 index ddd7869ba0..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -:4:12: F811 Redefinition of unused `os` from line 3 - | -2 | def f(): -3 | import os -4 | import os - | ^^ F811 -5 | -6 | # Despite this `del`, `import os` should still be flagged as shadowing an unused - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__double_del.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__double_del.snap deleted file mode 100644 index ef01e14323..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__double_del.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -:5:9: F821 Undefined name `x` - | -3 | x = 1 -4 | del x -5 | del x - | ^ F821 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__extend_immutable_calls.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__extend_immutable_calls.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__extend_immutable_calls.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__extra_builtins.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__extra_builtins.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__extra_builtins.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__extra_typing_modules.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__extra_typing_modules.snap deleted file mode 100644 index dbc711712f..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__extra_typing_modules.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -typing_modules.py:7:15: F821 Undefined name `Class` - | -6 | X = Union[Literal[False], Literal["db"]] -7 | y = Optional["Class"] - | ^^^^^ F821 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__f841_dummy_variable_rgx.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__f841_dummy_variable_rgx.snap deleted file mode 100644 index 5197e53959..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__f841_dummy_variable_rgx.snap +++ /dev/null @@ -1,277 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -F841_0.py:3:22: F841 [*] Local variable `e` is assigned to but never used - | -1 | try: -2 | 1 / 0 -3 | except ValueError as e: - | ^ F841 -4 | pass - | - = help: Remove assignment to unused variable `e` - -ℹ Fix -1 1 | try: -2 2 | 1 / 0 -3 |-except ValueError as e: - 3 |+except ValueError: -4 4 | pass -5 5 | -6 6 | - -F841_0.py:20:5: F841 [*] Local variable `foo` is assigned to but never used - | -19 | def f(): -20 | foo = (1, 2) - | ^^^ F841 -21 | (a, b) = (1, 2) - | - = help: Remove assignment to unused variable `foo` - -ℹ Suggested fix -17 17 | -18 18 | -19 19 | def f(): -20 |- foo = (1, 2) -21 20 | (a, b) = (1, 2) -22 21 | -23 22 | bar = (1, 2) - -F841_0.py:21:6: F841 Local variable `a` is assigned to but never used - | -19 | def f(): -20 | foo = (1, 2) -21 | (a, b) = (1, 2) - | ^ F841 -22 | -23 | bar = (1, 2) - | - = help: Remove assignment to unused variable `a` - -F841_0.py:21:9: F841 Local variable `b` is assigned to but never used - | -19 | def f(): -20 | foo = (1, 2) -21 | (a, b) = (1, 2) - | ^ F841 -22 | -23 | bar = (1, 2) - | - = help: Remove assignment to unused variable `b` - -F841_0.py:26:14: F841 [*] Local variable `baz` is assigned to but never used - | -24 | (c, d) = bar -25 | -26 | (x, y) = baz = bar - | ^^^ F841 - | - = help: Remove assignment to unused variable `baz` - -ℹ Suggested fix -23 23 | bar = (1, 2) -24 24 | (c, d) = bar -25 25 | -26 |- (x, y) = baz = bar - 26 |+ (x, y) = bar -27 27 | -28 28 | -29 29 | def f(): - -F841_0.py:35:5: F841 [*] Local variable `_` is assigned to but never used - | -34 | def f(): -35 | _ = 1 - | ^ F841 -36 | __ = 1 -37 | _discarded = 1 - | - = help: Remove assignment to unused variable `_` - -ℹ Suggested fix -32 32 | -33 33 | -34 34 | def f(): -35 |- _ = 1 -36 35 | __ = 1 -37 36 | _discarded = 1 -38 37 | - -F841_0.py:36:5: F841 [*] Local variable `__` is assigned to but never used - | -34 | def f(): -35 | _ = 1 -36 | __ = 1 - | ^^ F841 -37 | _discarded = 1 - | - = help: Remove assignment to unused variable `` - -ℹ Suggested fix -33 33 | -34 34 | def f(): -35 35 | _ = 1 -36 |- __ = 1 -37 36 | _discarded = 1 -38 37 | -39 38 | - -F841_0.py:37:5: F841 [*] Local variable `_discarded` is assigned to but never used - | -35 | _ = 1 -36 | __ = 1 -37 | _discarded = 1 - | ^^^^^^^^^^ F841 - | - = help: Remove assignment to unused variable `_discarded` - -ℹ Suggested fix -34 34 | def f(): -35 35 | _ = 1 -36 36 | __ = 1 -37 |- _discarded = 1 -38 37 | -39 38 | -40 39 | a = 1 - -F841_0.py:51:9: F841 [*] Local variable `b` is assigned to but never used - | -49 | def c(): -50 | # F841 -51 | b = 1 - | ^ F841 -52 | -53 | def d(): - | - = help: Remove assignment to unused variable `b` - -ℹ Suggested fix -48 48 | -49 49 | def c(): -50 50 | # F841 -51 |- b = 1 - 51 |+ pass -52 52 | -53 53 | def d(): -54 54 | nonlocal b - -F841_0.py:79:26: F841 [*] Local variable `my_file` is assigned to but never used - | -78 | def f(): -79 | with open("file") as my_file, open("") as ((this, that)): - | ^^^^^^^ F841 -80 | print("hello") - | - = help: Remove assignment to unused variable `my_file` - -ℹ Suggested fix -76 76 | -77 77 | -78 78 | def f(): -79 |- with open("file") as my_file, open("") as ((this, that)): - 79 |+ with open("file"), open("") as ((this, that)): -80 80 | print("hello") -81 81 | -82 82 | - -F841_0.py:85:25: F841 [*] Local variable `my_file` is assigned to but never used - | -83 | def f(): -84 | with ( -85 | open("file") as my_file, - | ^^^^^^^ F841 -86 | open("") as ((this, that)), -87 | ): - | - = help: Remove assignment to unused variable `my_file` - -ℹ Suggested fix -82 82 | -83 83 | def f(): -84 84 | with ( -85 |- open("file") as my_file, - 85 |+ open("file"), -86 86 | open("") as ((this, that)), -87 87 | ): -88 88 | print("hello") - -F841_0.py:102:5: F841 [*] Local variable `msg3` is assigned to but never used - | -100 | msg1 = "Hello, world!" -101 | msg2 = "Hello, world!" -102 | msg3 = "Hello, world!" - | ^^^^ F841 -103 | match x: -104 | case 1: - | - = help: Remove assignment to unused variable `msg3` - -ℹ Suggested fix -99 99 | def f(x: int): -100 100 | msg1 = "Hello, world!" -101 101 | msg2 = "Hello, world!" -102 |- msg3 = "Hello, world!" -103 102 | match x: -104 103 | case 1: -105 104 | print(msg1) - -F841_0.py:115:5: F841 [*] Local variable `Baz` is assigned to but never used - | -113 | Foo = enum.Enum("Foo", "A B") -114 | Bar = enum.Enum("Bar", "A B") -115 | Baz = enum.Enum("Baz", "A B") - | ^^^ F841 -116 | -117 | match x: - | - = help: Remove assignment to unused variable `Baz` - -ℹ Suggested fix -112 112 | -113 113 | Foo = enum.Enum("Foo", "A B") -114 114 | Bar = enum.Enum("Bar", "A B") -115 |- Baz = enum.Enum("Baz", "A B") - 115 |+ enum.Enum("Baz", "A B") -116 116 | -117 117 | match x: -118 118 | case (Foo.A): - -F841_0.py:122:14: F841 Local variable `y` is assigned to but never used - | -120 | case [Bar.A, *_]: -121 | print("A") -122 | case y: - | ^ F841 -123 | pass - | - = help: Remove assignment to unused variable `y` - -F841_0.py:127:21: F841 Local variable `value` is assigned to but never used - | -126 | def f(): -127 | if any((key := (value := x)) for x in ["ok"]): - | ^^^^^ F841 -128 | print(key) - | - = help: Remove assignment to unused variable `value` - -F841_0.py:152:25: F841 [*] Local variable `_` is assigned to but never used - | -150 | try: -151 | pass -152 | except Exception as _: - | ^ F841 -153 | pass - | - = help: Remove assignment to unused variable `_` - -ℹ Fix -149 149 | def f(): -150 150 | try: -151 151 | pass -152 |- except Exception as _: - 152 |+ except Exception: -153 153 | pass - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__future_annotations.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__future_annotations.snap deleted file mode 100644 index f2a0e521f1..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__future_annotations.snap +++ /dev/null @@ -1,31 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -future_annotations.py:8:5: F401 [*] `models.Nut` imported but unused - | -6 | from models import ( -7 | Fruit, -8 | Nut, - | ^^^ F401 -9 | ) - | - = help: Remove unused import: `models.Nut` - -ℹ Fix -5 5 | -6 6 | from models import ( -7 7 | Fruit, -8 |- Nut, -9 8 | ) -10 9 | -11 10 | - -future_annotations.py:26:19: F821 Undefined name `Bar` - | -25 | @classmethod -26 | def c(cls) -> Bar: - | ^^^ F821 -27 | return cls(x=0, y=0) - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__init.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__init.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__init.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__load_after_multiple_unbinds_from_module_scope.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__load_after_multiple_unbinds_from_module_scope.snap deleted file mode 100644 index 32d31a0137..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__load_after_multiple_unbinds_from_module_scope.snap +++ /dev/null @@ -1,44 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -:7:26: F841 [*] Local variable `x` is assigned to but never used - | -5 | try: -6 | pass -7 | except ValueError as x: - | ^ F841 -8 | pass - | - = help: Remove assignment to unused variable `x` - -ℹ Fix -4 4 | def f(): -5 5 | try: -6 6 | pass -7 |- except ValueError as x: - 7 |+ except ValueError: -8 8 | pass -9 9 | -10 10 | try: - -:12:26: F841 [*] Local variable `x` is assigned to but never used - | -10 | try: -11 | pass -12 | except ValueError as x: - | ^ F841 -13 | pass - | - = help: Remove assignment to unused variable `x` - -ℹ Fix -9 9 | -10 10 | try: -11 11 | pass -12 |- except ValueError as x: - 12 |+ except ValueError: -13 13 | pass -14 14 | -15 15 | # This should resolve to the `x` in `x = 1`. - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__load_after_unbind_from_class_scope.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__load_after_unbind_from_class_scope.snap deleted file mode 100644 index 058a92ae6f..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__load_after_unbind_from_class_scope.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -:8:30: F841 [*] Local variable `x` is assigned to but never used - | -6 | try: -7 | pass -8 | except ValueError as x: - | ^ F841 -9 | pass - | - = help: Remove assignment to unused variable `x` - -ℹ Fix -5 5 | def f(): -6 6 | try: -7 7 | pass -8 |- except ValueError as x: - 8 |+ except ValueError: -9 9 | pass -10 10 | -11 11 | # This should raise an F821 error, rather than resolving to the - -:13:15: F821 Undefined name `x` - | -11 | # This should raise an F821 error, rather than resolving to the -12 | # `x` in `x = 1`. -13 | print(x) - | ^ F821 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__load_after_unbind_from_module_scope.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__load_after_unbind_from_module_scope.snap deleted file mode 100644 index 2f25f19aeb..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__load_after_unbind_from_module_scope.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -:7:26: F841 [*] Local variable `x` is assigned to but never used - | -5 | try: -6 | pass -7 | except ValueError as x: - | ^ F841 -8 | pass - | - = help: Remove assignment to unused variable `x` - -ℹ Fix -4 4 | def f(): -5 5 | try: -6 6 | pass -7 |- except ValueError as x: - 7 |+ except ValueError: -8 8 | pass -9 9 | -10 10 | # This should resolve to the `x` in `x = 1`. - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__load_after_unbind_from_nested_module_scope.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__load_after_unbind_from_nested_module_scope.snap deleted file mode 100644 index 7ab30bf910..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__load_after_unbind_from_nested_module_scope.snap +++ /dev/null @@ -1,44 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -:7:26: F841 [*] Local variable `x` is assigned to but never used - | -5 | try: -6 | pass -7 | except ValueError as x: - | ^ F841 -8 | pass - | - = help: Remove assignment to unused variable `x` - -ℹ Fix -4 4 | def f(): -5 5 | try: -6 6 | pass -7 |- except ValueError as x: - 7 |+ except ValueError: -8 8 | pass -9 9 | -10 10 | def g(): - -:13:30: F841 [*] Local variable `x` is assigned to but never used - | -11 | try: -12 | pass -13 | except ValueError as x: - | ^ F841 -14 | pass - | - = help: Remove assignment to unused variable `x` - -ℹ Fix -10 10 | def g(): -11 11 | try: -12 12 | pass -13 |- except ValueError as x: - 13 |+ except ValueError: -14 14 | pass -15 15 | -16 16 | # This should resolve to the `x` in `x = 1`. - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__multi_statement_lines.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__multi_statement_lines.snap deleted file mode 100644 index f384bf81ca..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__multi_statement_lines.snap +++ /dev/null @@ -1,325 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -multi_statement_lines.py:2:12: F401 [*] `foo1` imported but unused - | -1 | if True: -2 | import foo1; x = 1 - | ^^^^ F401 -3 | import foo2; x = 1 - | - = help: Remove unused import: `foo1` - -ℹ Fix -1 1 | if True: -2 |- import foo1; x = 1 - 2 |+ x = 1 -3 3 | import foo2; x = 1 -4 4 | -5 5 | if True: - -multi_statement_lines.py:3:12: F401 [*] `foo2` imported but unused - | -1 | if True: -2 | import foo1; x = 1 -3 | import foo2; x = 1 - | ^^^^ F401 -4 | -5 | if True: - | - = help: Remove unused import: `foo2` - -ℹ Fix -1 1 | if True: -2 2 | import foo1; x = 1 -3 |- import foo2; x = 1 - 3 |+ x = 1 -4 4 | -5 5 | if True: -6 6 | import foo3; \ - -multi_statement_lines.py:6:12: F401 [*] `foo3` imported but unused - | -5 | if True: -6 | import foo3; \ - | ^^^^ F401 -7 | x = 1 - | - = help: Remove unused import: `foo3` - -ℹ Fix -3 3 | import foo2; x = 1 -4 4 | -5 5 | if True: -6 |- import foo3; \ -7 |-x = 1 - 6 |+ x = 1 -8 7 | -9 8 | if True: -10 9 | import foo4 \ - -multi_statement_lines.py:10:12: F401 [*] `foo4` imported but unused - | - 9 | if True: -10 | import foo4 \ - | ^^^^ F401 -11 | ; x = 1 - | - = help: Remove unused import: `foo4` - -ℹ Fix -7 7 | x = 1 -8 8 | -9 9 | if True: -10 |- import foo4 \ -11 |- ; x = 1 - 10 |+ x = 1 -12 11 | -13 12 | if True: -14 13 | x = 1; import foo5 - -multi_statement_lines.py:14:19: F401 [*] `foo5` imported but unused - | -13 | if True: -14 | x = 1; import foo5 - | ^^^^ F401 - | - = help: Remove unused import: `foo5` - -ℹ Fix -11 11 | ; x = 1 -12 12 | -13 13 | if True: -14 |- x = 1; import foo5 - 14 |+ x = 1; -15 15 | -16 16 | -17 17 | if True: - -multi_statement_lines.py:19:17: F401 [*] `foo6` imported but unused - | -17 | if True: -18 | x = 1; \ -19 | import foo6 - | ^^^^ F401 -20 | -21 | if True: - | - = help: Remove unused import: `foo6` - -ℹ Fix -15 15 | -16 16 | -17 17 | if True: -18 |- x = 1; \ -19 |- import foo6 - 18 |+ x = 1; -20 19 | -21 20 | if True: -22 21 | x = 1 \ - -multi_statement_lines.py:23:18: F401 [*] `foo7` imported but unused - | -21 | if True: -22 | x = 1 \ -23 | ; import foo7 - | ^^^^ F401 -24 | -25 | if True: - | - = help: Remove unused import: `foo7` - -ℹ Fix -20 20 | -21 21 | if True: -22 22 | x = 1 \ -23 |- ; import foo7 - 23 |+ ; -24 24 | -25 25 | if True: -26 26 | x = 1; import foo8; x = 1 - -multi_statement_lines.py:26:19: F401 [*] `foo8` imported but unused - | -25 | if True: -26 | x = 1; import foo8; x = 1 - | ^^^^ F401 -27 | x = 1; import foo9; x = 1 - | - = help: Remove unused import: `foo8` - -ℹ Fix -23 23 | ; import foo7 -24 24 | -25 25 | if True: -26 |- x = 1; import foo8; x = 1 - 26 |+ x = 1; x = 1 -27 27 | x = 1; import foo9; x = 1 -28 28 | -29 29 | if True: - -multi_statement_lines.py:27:23: F401 [*] `foo9` imported but unused - | -25 | if True: -26 | x = 1; import foo8; x = 1 -27 | x = 1; import foo9; x = 1 - | ^^^^ F401 -28 | -29 | if True: - | - = help: Remove unused import: `foo9` - -ℹ Fix -24 24 | -25 25 | if True: -26 26 | x = 1; import foo8; x = 1 -27 |- x = 1; import foo9; x = 1 - 27 |+ x = 1; x = 1 -28 28 | -29 29 | if True: -30 30 | x = 1; \ - -multi_statement_lines.py:31:16: F401 [*] `foo10` imported but unused - | -29 | if True: -30 | x = 1; \ -31 | import foo10; \ - | ^^^^^ F401 -32 | x = 1 - | - = help: Remove unused import: `foo10` - -ℹ Fix -28 28 | -29 29 | if True: -30 30 | x = 1; \ -31 |- import foo10; \ -32 |- x = 1 - 31 |+ x = 1 -33 32 | -34 33 | if True: -35 34 | x = 1 \ - -multi_statement_lines.py:36:17: F401 [*] `foo11` imported but unused - | -34 | if True: -35 | x = 1 \ -36 | ;import foo11 \ - | ^^^^^ F401 -37 | ;x = 1 - | - = help: Remove unused import: `foo11` - -ℹ Fix -33 33 | -34 34 | if True: -35 35 | x = 1 \ -36 |- ;import foo11 \ -37 36 | ;x = 1 -38 37 | -39 38 | if True: - -multi_statement_lines.py:42:16: F401 [*] `foo12` imported but unused - | -40 | x = 1; \ -41 | \ -42 | import foo12 - | ^^^^^ F401 -43 | -44 | if True: - | - = help: Remove unused import: `foo12` - -ℹ Fix -37 37 | ;x = 1 -38 38 | -39 39 | if True: -40 |- x = 1; \ -41 |- \ -42 |- import foo12 - 40 |+ x = 1; -43 41 | -44 42 | if True: -45 43 | x = 1; \ - -multi_statement_lines.py:47:12: F401 [*] `foo13` imported but unused - | -45 | x = 1; \ -46 | \ -47 | import foo13 - | ^^^^^ F401 - | - = help: Remove unused import: `foo13` - -ℹ Fix -42 42 | import foo12 -43 43 | -44 44 | if True: -45 |- x = 1; \ -46 |-\ -47 |- import foo13 - 45 |+ x = 1; -48 46 | -49 47 | -50 48 | if True: - -multi_statement_lines.py:53:12: F401 [*] `foo14` imported but unused - | -51 | x = 1; \ -52 | # \ -53 | import foo14 - | ^^^^^ F401 -54 | -55 | # Continuation, but not as the last content in the file. - | - = help: Remove unused import: `foo14` - -ℹ Fix -50 50 | if True: -51 51 | x = 1; \ -52 52 | # \ -53 |- import foo14 -54 53 | -55 54 | # Continuation, but not as the last content in the file. -56 55 | x = 1; \ - -multi_statement_lines.py:57:8: F401 [*] `foo15` imported but unused - | -55 | # Continuation, but not as the last content in the file. -56 | x = 1; \ -57 | import foo15 - | ^^^^^ F401 -58 | -59 | # Continuation, followed by end-of-file. (Removing `import foo` would cause a syntax - | - = help: Remove unused import: `foo15` - -ℹ Fix -53 53 | import foo14 -54 54 | -55 55 | # Continuation, but not as the last content in the file. -56 |-x = 1; \ -57 |-import foo15 - 56 |+x = 1; -58 57 | -59 58 | # Continuation, followed by end-of-file. (Removing `import foo` would cause a syntax -60 59 | # error.) - -multi_statement_lines.py:62:8: F401 [*] `foo16` imported but unused - | -60 | # error.) -61 | x = 1; \ -62 | import foo16 - | ^^^^^ F401 - | - = help: Remove unused import: `foo16` - -ℹ Fix -58 58 | -59 59 | # Continuation, followed by end-of-file. (Removing `import foo` would cause a syntax -60 60 | # error.) -61 |-x = 1; \ -62 |-import foo16 - 61 |+x = 1; - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__nested_relative_typing_module.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__nested_relative_typing_module.snap deleted file mode 100644 index 6bba36837d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__nested_relative_typing_module.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -baz.py:26:17: F821 Undefined name `foo` - | -25 | # F821 -26 | x: Literal["foo"] - | ^^^ F821 - | - -baz.py:33:17: F821 Undefined name `foo` - | -32 | # F821 -33 | x: Literal["foo"] - | ^^^ F821 - | - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__print_in_body_after_double_shadowing_except.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__print_in_body_after_double_shadowing_except.snap deleted file mode 100644 index 616577852c..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__print_in_body_after_double_shadowing_except.snap +++ /dev/null @@ -1,45 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -:7:26: F841 [*] Local variable `x` is assigned to but never used - | -5 | try: -6 | 1 / 0 -7 | except ValueError as x: - | ^ F841 -8 | pass -9 | except ImportError as x: - | - = help: Remove assignment to unused variable `x` - -ℹ Fix -4 4 | -5 5 | try: -6 6 | 1 / 0 -7 |- except ValueError as x: - 7 |+ except ValueError: -8 8 | pass -9 9 | except ImportError as x: -10 10 | pass - -:9:27: F841 [*] Local variable `x` is assigned to but never used - | - 7 | except ValueError as x: - 8 | pass - 9 | except ImportError as x: - | ^ F841 -10 | pass - | - = help: Remove assignment to unused variable `x` - -ℹ Fix -6 6 | 1 / 0 -7 7 | except ValueError as x: -8 8 | pass -9 |- except ImportError as x: - 9 |+ except ImportError: -10 10 | pass -11 11 | -12 12 | # No error here, though it should arguably be an F821 error. `x` will - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__print_in_body_after_shadowing_except.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__print_in_body_after_shadowing_except.snap deleted file mode 100644 index 085cb7c453..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__print_in_body_after_shadowing_except.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -:7:25: F841 [*] Local variable `x` is assigned to but never used - | -5 | try: -6 | 1 / 0 -7 | except Exception as x: - | ^ F841 -8 | pass - | - = help: Remove assignment to unused variable `x` - -ℹ Fix -4 4 | -5 5 | try: -6 6 | 1 / 0 -7 |- except Exception as x: - 7 |+ except Exception: -8 8 | pass -9 9 | -10 10 | # No error here, though it should arguably be an F821 error. `x` will - - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__print_in_if_else_after_shadowing_except.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__print_in_if_else_after_shadowing_except.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__print_in_if_else_after_shadowing_except.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__print_in_try_else_after_shadowing_except.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__print_in_try_else_after_shadowing_except.snap deleted file mode 100644 index 1976c4331d..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__print_in_try_else_after_shadowing_except.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__relative_typing_module.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__relative_typing_module.snap deleted file mode 100644 index 4b04960a44..0000000000 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__relative_typing_module.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/pyflakes/mod.rs ---- -bar.py:26:17: F821 Undefined name `foo` - | -25 | # F821 -26 | x: Literal["foo"] - | ^^^ F821 - | - - diff --git a/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH001_PGH001_0.py.snap b/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH001_PGH001_0.py.snap deleted file mode 100644 index 61d1024fec..0000000000 --- a/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH001_PGH001_0.py.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: crates/ruff/src/rules/pygrep_hooks/mod.rs ---- -PGH001_0.py:3:1: PGH001 No builtin `eval()` allowed - | -1 | from ast import literal_eval -2 | -3 | eval("3 + 4") - | ^^^^ PGH001 -4 | -5 | literal_eval({1: 2}) - | - -PGH001_0.py:9:5: PGH001 No builtin `eval()` allowed - | -8 | def fn() -> None: -9 | eval("3 + 4") - | ^^^^ PGH001 - | - - diff --git a/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH001_PGH001_1.py.snap b/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH001_PGH001_1.py.snap deleted file mode 100644 index 73d713dc73..0000000000 --- a/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH001_PGH001_1.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pygrep_hooks/mod.rs ---- - diff --git a/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH002_PGH002_0.py.snap b/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH002_PGH002_0.py.snap deleted file mode 100644 index 73d713dc73..0000000000 --- a/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH002_PGH002_0.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pygrep_hooks/mod.rs ---- - diff --git a/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH002_PGH002_1.py.snap b/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH002_PGH002_1.py.snap deleted file mode 100644 index 917e9356ca..0000000000 --- a/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH002_PGH002_1.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/pygrep_hooks/mod.rs ---- -PGH002_1.py:4:1: PGH002 `warn` is deprecated in favor of `warning` - | -2 | from logging import warn -3 | -4 | logging.warn("this is not ok") - | ^^^^^^^^^^^^ PGH002 -5 | warn("not ok") - | - -PGH002_1.py:5:1: PGH002 `warn` is deprecated in favor of `warning` - | -4 | logging.warn("this is not ok") -5 | warn("not ok") - | ^^^^ PGH002 - | - - diff --git a/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH003_PGH003_0.py.snap b/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH003_PGH003_0.py.snap deleted file mode 100644 index 57861ca1bf..0000000000 --- a/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH003_PGH003_0.py.snap +++ /dev/null @@ -1,40 +0,0 @@ ---- -source: crates/ruff/src/rules/pygrep_hooks/mod.rs ---- -PGH003_0.py:1:8: PGH003 Use specific rule codes when ignoring type issues - | -1 | x = 1 # type: ignore - | ^^^^^^^^^^^^^^ PGH003 -2 | x = 1 # type:ignore -3 | x = 1 # type: ignore[attr-defined] # type: ignore - | - -PGH003_0.py:2:8: PGH003 Use specific rule codes when ignoring type issues - | -1 | x = 1 # type: ignore -2 | x = 1 # type:ignore - | ^^^^^^^^^^^^^ PGH003 -3 | x = 1 # type: ignore[attr-defined] # type: ignore -4 | x = 1 # type: ignoreme # type: ignore - | - -PGH003_0.py:3:38: PGH003 Use specific rule codes when ignoring type issues - | -1 | x = 1 # type: ignore -2 | x = 1 # type:ignore -3 | x = 1 # type: ignore[attr-defined] # type: ignore - | ^^^^^^^^^^^^^^ PGH003 -4 | x = 1 # type: ignoreme # type: ignore - | - -PGH003_0.py:4:25: PGH003 Use specific rule codes when ignoring type issues - | -2 | x = 1 # type:ignore -3 | x = 1 # type: ignore[attr-defined] # type: ignore -4 | x = 1 # type: ignoreme # type: ignore - | ^^^^^^^^^^^^^^ PGH003 -5 | -6 | x = 1 - | - - diff --git a/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH003_PGH003_1.py.snap b/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH003_PGH003_1.py.snap deleted file mode 100644 index 2af53a31e8..0000000000 --- a/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH003_PGH003_1.py.snap +++ /dev/null @@ -1,30 +0,0 @@ ---- -source: crates/ruff/src/rules/pygrep_hooks/mod.rs ---- -PGH003_1.py:1:8: PGH003 Use specific rule codes when ignoring type issues - | -1 | x = 1 # pyright: ignore - | ^^^^^^^^^^^^^^^^^ PGH003 -2 | x = 1 # pyright:ignore -3 | x = 1 # pyright: ignore[attr-defined] # pyright: ignore - | - -PGH003_1.py:2:8: PGH003 Use specific rule codes when ignoring type issues - | -1 | x = 1 # pyright: ignore -2 | x = 1 # pyright:ignore - | ^^^^^^^^^^^^^^^^ PGH003 -3 | x = 1 # pyright: ignore[attr-defined] # pyright: ignore - | - -PGH003_1.py:3:41: PGH003 Use specific rule codes when ignoring type issues - | -1 | x = 1 # pyright: ignore -2 | x = 1 # pyright:ignore -3 | x = 1 # pyright: ignore[attr-defined] # pyright: ignore - | ^^^^^^^^^^^^^^^^^ PGH003 -4 | -5 | x = 1 - | - - diff --git a/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH004_PGH004_0.py.snap b/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH004_PGH004_0.py.snap deleted file mode 100644 index c198ff858c..0000000000 --- a/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH004_PGH004_0.py.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: crates/ruff/src/rules/pygrep_hooks/mod.rs ---- -PGH004_0.py:1:8: PGH004 Use specific rule codes when using `noqa` - | -1 | x = 1 # noqa - | ^^^^^^ PGH004 -2 | x = 1 # NOQA:F401,W203 -3 | # noqa - | - -PGH004_0.py:3:1: PGH004 Use specific rule codes when using `noqa` - | -1 | x = 1 # noqa -2 | x = 1 # NOQA:F401,W203 -3 | # noqa - | ^^^^^^ PGH004 -4 | # NOQA -5 | # noqa:F401 - | - -PGH004_0.py:4:1: PGH004 Use specific rule codes when using `noqa` - | -2 | x = 1 # NOQA:F401,W203 -3 | # noqa -4 | # NOQA - | ^^^^^^ PGH004 -5 | # noqa:F401 -6 | # noqa:F401,W203 - | - - diff --git a/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH005_PGH005_0.py.snap b/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH005_PGH005_0.py.snap deleted file mode 100644 index 85a46cae82..0000000000 --- a/crates/ruff/src/rules/pygrep_hooks/snapshots/ruff__rules__pygrep_hooks__tests__PGH005_PGH005_0.py.snap +++ /dev/null @@ -1,92 +0,0 @@ ---- -source: crates/ruff/src/rules/pygrep_hooks/mod.rs ---- -PGH005_0.py:2:8: PGH005 Non-existent mock method: `not_called` - | -1 | # Errors -2 | assert my_mock.not_called() - | ^^^^^^^^^^^^^^^^^^^^ PGH005 -3 | assert my_mock.called_once_with() -4 | assert my_mock.not_called - | - -PGH005_0.py:3:8: PGH005 Non-existent mock method: `called_once_with` - | -1 | # Errors -2 | assert my_mock.not_called() -3 | assert my_mock.called_once_with() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 -4 | assert my_mock.not_called -5 | assert my_mock.called_once_with - | - -PGH005_0.py:4:8: PGH005 Non-existent mock method: `not_called` - | -2 | assert my_mock.not_called() -3 | assert my_mock.called_once_with() -4 | assert my_mock.not_called - | ^^^^^^^^^^^^^^^^^^ PGH005 -5 | assert my_mock.called_once_with -6 | my_mock.assert_not_called - | - -PGH005_0.py:5:8: PGH005 Non-existent mock method: `called_once_with` - | -3 | assert my_mock.called_once_with() -4 | assert my_mock.not_called -5 | assert my_mock.called_once_with - | ^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 -6 | my_mock.assert_not_called -7 | my_mock.assert_called - | - -PGH005_0.py:6:1: PGH005 Mock method should be called: `assert_not_called` - | -4 | assert my_mock.not_called -5 | assert my_mock.called_once_with -6 | my_mock.assert_not_called - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 -7 | my_mock.assert_called -8 | my_mock.assert_called_once_with - | - -PGH005_0.py:7:1: PGH005 Mock method should be called: `assert_called` - | -5 | assert my_mock.called_once_with -6 | my_mock.assert_not_called -7 | my_mock.assert_called - | ^^^^^^^^^^^^^^^^^^^^^ PGH005 -8 | my_mock.assert_called_once_with -9 | my_mock.assert_called_once_with - | - -PGH005_0.py:8:1: PGH005 Mock method should be called: `assert_called_once_with` - | - 6 | my_mock.assert_not_called - 7 | my_mock.assert_called - 8 | my_mock.assert_called_once_with - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 - 9 | my_mock.assert_called_once_with -10 | MyMock.assert_called_once_with - | - -PGH005_0.py:9:1: PGH005 Mock method should be called: `assert_called_once_with` - | - 7 | my_mock.assert_called - 8 | my_mock.assert_called_once_with - 9 | my_mock.assert_called_once_with - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 -10 | MyMock.assert_called_once_with - | - -PGH005_0.py:10:1: PGH005 Mock method should be called: `assert_called_once_with` - | - 8 | my_mock.assert_called_once_with - 9 | my_mock.assert_called_once_with -10 | MyMock.assert_called_once_with - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 -11 | -12 | # OK - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0105_type_name_incorrect_variance.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0105_type_name_incorrect_variance.py.snap deleted file mode 100644 index 675130c6ea..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0105_type_name_incorrect_variance.py.snap +++ /dev/null @@ -1,318 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -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 | -5 | T = TypeVar("T", covariant=True) - | ^^^^^^^ PLC0105 -6 | T = TypeVar("T", covariant=True, contravariant=False) -7 | T = TypeVar("T", contravariant=True) - | - -type_name_incorrect_variance.py:6:5: PLC0105 `TypeVar` name "T" does not reflect its covariance; consider renaming it to "T_co" - | -5 | T = TypeVar("T", covariant=True) -6 | T = TypeVar("T", covariant=True, contravariant=False) - | ^^^^^^^ PLC0105 -7 | T = TypeVar("T", contravariant=True) -8 | T = TypeVar("T", covariant=False, contravariant=True) - | - -type_name_incorrect_variance.py:7:5: PLC0105 `TypeVar` name "T" does not reflect its contravariance; consider renaming it to "T_contra" - | -5 | T = TypeVar("T", covariant=True) -6 | T = TypeVar("T", covariant=True, contravariant=False) -7 | T = TypeVar("T", contravariant=True) - | ^^^^^^^ PLC0105 -8 | T = TypeVar("T", covariant=False, contravariant=True) -9 | P = ParamSpec("P", covariant=True) - | - -type_name_incorrect_variance.py:8:5: PLC0105 `TypeVar` name "T" does not reflect its contravariance; consider renaming it to "T_contra" - | - 6 | T = TypeVar("T", covariant=True, contravariant=False) - 7 | T = TypeVar("T", contravariant=True) - 8 | T = TypeVar("T", covariant=False, contravariant=True) - | ^^^^^^^ PLC0105 - 9 | P = ParamSpec("P", covariant=True) -10 | P = ParamSpec("P", covariant=True, contravariant=False) - | - -type_name_incorrect_variance.py:9:5: PLC0105 `ParamSpec` name "P" does not reflect its covariance; consider renaming it to "P_co" - | - 7 | T = TypeVar("T", contravariant=True) - 8 | T = TypeVar("T", covariant=False, contravariant=True) - 9 | P = ParamSpec("P", covariant=True) - | ^^^^^^^^^ PLC0105 -10 | P = ParamSpec("P", covariant=True, contravariant=False) -11 | P = ParamSpec("P", contravariant=True) - | - -type_name_incorrect_variance.py:10:5: PLC0105 `ParamSpec` name "P" does not reflect its covariance; consider renaming it to "P_co" - | - 8 | T = TypeVar("T", covariant=False, contravariant=True) - 9 | P = ParamSpec("P", covariant=True) -10 | P = ParamSpec("P", covariant=True, contravariant=False) - | ^^^^^^^^^ PLC0105 -11 | P = ParamSpec("P", contravariant=True) -12 | P = ParamSpec("P", covariant=False, contravariant=True) - | - -type_name_incorrect_variance.py:11:5: PLC0105 `ParamSpec` name "P" does not reflect its contravariance; consider renaming it to "P_contra" - | - 9 | P = ParamSpec("P", covariant=True) -10 | P = ParamSpec("P", covariant=True, contravariant=False) -11 | P = ParamSpec("P", contravariant=True) - | ^^^^^^^^^ PLC0105 -12 | P = ParamSpec("P", covariant=False, contravariant=True) - | - -type_name_incorrect_variance.py:12:5: PLC0105 `ParamSpec` name "P" does not reflect its contravariance; consider renaming it to "P_contra" - | -10 | P = ParamSpec("P", covariant=True, contravariant=False) -11 | P = ParamSpec("P", contravariant=True) -12 | P = ParamSpec("P", covariant=False, contravariant=True) - | ^^^^^^^^^ PLC0105 -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 | -14 | T_co = TypeVar("T_co") - | ^^^^^^^ PLC0105 -15 | T_co = TypeVar("T_co", covariant=False) -16 | T_co = TypeVar("T_co", contravariant=False) - | - -type_name_incorrect_variance.py:15:8: PLC0105 `TypeVar` name "T_co" does not reflect its invariance; consider renaming it to "T" - | -14 | T_co = TypeVar("T_co") -15 | T_co = TypeVar("T_co", covariant=False) - | ^^^^^^^ PLC0105 -16 | T_co = TypeVar("T_co", contravariant=False) -17 | T_co = TypeVar("T_co", covariant=False, contravariant=False) - | - -type_name_incorrect_variance.py:16:8: PLC0105 `TypeVar` name "T_co" does not reflect its invariance; consider renaming it to "T" - | -14 | T_co = TypeVar("T_co") -15 | T_co = TypeVar("T_co", covariant=False) -16 | T_co = TypeVar("T_co", contravariant=False) - | ^^^^^^^ PLC0105 -17 | T_co = TypeVar("T_co", covariant=False, contravariant=False) -18 | T_co = TypeVar("T_co", contravariant=True) - | - -type_name_incorrect_variance.py:17:8: PLC0105 `TypeVar` name "T_co" does not reflect its invariance; consider renaming it to "T" - | -15 | T_co = TypeVar("T_co", covariant=False) -16 | T_co = TypeVar("T_co", contravariant=False) -17 | T_co = TypeVar("T_co", covariant=False, contravariant=False) - | ^^^^^^^ PLC0105 -18 | T_co = TypeVar("T_co", contravariant=True) -19 | T_co = TypeVar("T_co", covariant=False, contravariant=True) - | - -type_name_incorrect_variance.py:18:8: PLC0105 `TypeVar` name "T_co" does not reflect its contravariance; consider renaming it to "T_contra" - | -16 | T_co = TypeVar("T_co", contravariant=False) -17 | T_co = TypeVar("T_co", covariant=False, contravariant=False) -18 | T_co = TypeVar("T_co", contravariant=True) - | ^^^^^^^ PLC0105 -19 | T_co = TypeVar("T_co", covariant=False, contravariant=True) -20 | P_co = ParamSpec("P_co") - | - -type_name_incorrect_variance.py:19:8: PLC0105 `TypeVar` name "T_co" does not reflect its contravariance; consider renaming it to "T_contra" - | -17 | T_co = TypeVar("T_co", covariant=False, contravariant=False) -18 | T_co = TypeVar("T_co", contravariant=True) -19 | T_co = TypeVar("T_co", covariant=False, contravariant=True) - | ^^^^^^^ PLC0105 -20 | P_co = ParamSpec("P_co") -21 | P_co = ParamSpec("P_co", covariant=False) - | - -type_name_incorrect_variance.py:20:8: PLC0105 `ParamSpec` name "P_co" does not reflect its invariance; consider renaming it to "P" - | -18 | T_co = TypeVar("T_co", contravariant=True) -19 | T_co = TypeVar("T_co", covariant=False, contravariant=True) -20 | P_co = ParamSpec("P_co") - | ^^^^^^^^^ PLC0105 -21 | P_co = ParamSpec("P_co", covariant=False) -22 | P_co = ParamSpec("P_co", contravariant=False) - | - -type_name_incorrect_variance.py:21:8: PLC0105 `ParamSpec` name "P_co" does not reflect its invariance; consider renaming it to "P" - | -19 | T_co = TypeVar("T_co", covariant=False, contravariant=True) -20 | P_co = ParamSpec("P_co") -21 | P_co = ParamSpec("P_co", covariant=False) - | ^^^^^^^^^ PLC0105 -22 | P_co = ParamSpec("P_co", contravariant=False) -23 | P_co = ParamSpec("P_co", covariant=False, contravariant=False) - | - -type_name_incorrect_variance.py:22:8: PLC0105 `ParamSpec` name "P_co" does not reflect its invariance; consider renaming it to "P" - | -20 | P_co = ParamSpec("P_co") -21 | P_co = ParamSpec("P_co", covariant=False) -22 | P_co = ParamSpec("P_co", contravariant=False) - | ^^^^^^^^^ PLC0105 -23 | P_co = ParamSpec("P_co", covariant=False, contravariant=False) -24 | P_co = ParamSpec("P_co", contravariant=True) - | - -type_name_incorrect_variance.py:23:8: PLC0105 `ParamSpec` name "P_co" does not reflect its invariance; consider renaming it to "P" - | -21 | P_co = ParamSpec("P_co", covariant=False) -22 | P_co = ParamSpec("P_co", contravariant=False) -23 | P_co = ParamSpec("P_co", covariant=False, contravariant=False) - | ^^^^^^^^^ PLC0105 -24 | P_co = ParamSpec("P_co", contravariant=True) -25 | P_co = ParamSpec("P_co", covariant=False, contravariant=True) - | - -type_name_incorrect_variance.py:24:8: PLC0105 `ParamSpec` name "P_co" does not reflect its contravariance; consider renaming it to "P_contra" - | -22 | P_co = ParamSpec("P_co", contravariant=False) -23 | P_co = ParamSpec("P_co", covariant=False, contravariant=False) -24 | P_co = ParamSpec("P_co", contravariant=True) - | ^^^^^^^^^ PLC0105 -25 | P_co = ParamSpec("P_co", covariant=False, contravariant=True) - | - -type_name_incorrect_variance.py:25:8: PLC0105 `ParamSpec` name "P_co" does not reflect its contravariance; consider renaming it to "P_contra" - | -23 | P_co = ParamSpec("P_co", covariant=False, contravariant=False) -24 | P_co = ParamSpec("P_co", contravariant=True) -25 | P_co = ParamSpec("P_co", covariant=False, contravariant=True) - | ^^^^^^^^^ PLC0105 -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 | -27 | T_contra = TypeVar("T_contra") - | ^^^^^^^ PLC0105 -28 | T_contra = TypeVar("T_contra", covariant=False) -29 | T_contra = TypeVar("T_contra", contravariant=False) - | - -type_name_incorrect_variance.py:28:12: PLC0105 `TypeVar` name "T_contra" does not reflect its invariance; consider renaming it to "T" - | -27 | T_contra = TypeVar("T_contra") -28 | T_contra = TypeVar("T_contra", covariant=False) - | ^^^^^^^ PLC0105 -29 | T_contra = TypeVar("T_contra", contravariant=False) -30 | T_contra = TypeVar("T_contra", covariant=False, contravariant=False) - | - -type_name_incorrect_variance.py:29:12: PLC0105 `TypeVar` name "T_contra" does not reflect its invariance; consider renaming it to "T" - | -27 | T_contra = TypeVar("T_contra") -28 | T_contra = TypeVar("T_contra", covariant=False) -29 | T_contra = TypeVar("T_contra", contravariant=False) - | ^^^^^^^ PLC0105 -30 | T_contra = TypeVar("T_contra", covariant=False, contravariant=False) -31 | T_contra = TypeVar("T_contra", covariant=True) - | - -type_name_incorrect_variance.py:30:12: PLC0105 `TypeVar` name "T_contra" does not reflect its invariance; consider renaming it to "T" - | -28 | T_contra = TypeVar("T_contra", covariant=False) -29 | T_contra = TypeVar("T_contra", contravariant=False) -30 | T_contra = TypeVar("T_contra", covariant=False, contravariant=False) - | ^^^^^^^ PLC0105 -31 | T_contra = TypeVar("T_contra", covariant=True) -32 | T_contra = TypeVar("T_contra", covariant=True, contravariant=False) - | - -type_name_incorrect_variance.py:31:12: PLC0105 `TypeVar` name "T_contra" does not reflect its covariance; consider renaming it to "T_co" - | -29 | T_contra = TypeVar("T_contra", contravariant=False) -30 | T_contra = TypeVar("T_contra", covariant=False, contravariant=False) -31 | T_contra = TypeVar("T_contra", covariant=True) - | ^^^^^^^ PLC0105 -32 | T_contra = TypeVar("T_contra", covariant=True, contravariant=False) -33 | P_contra = ParamSpec("P_contra") - | - -type_name_incorrect_variance.py:32:12: PLC0105 `TypeVar` name "T_contra" does not reflect its covariance; consider renaming it to "T_co" - | -30 | T_contra = TypeVar("T_contra", covariant=False, contravariant=False) -31 | T_contra = TypeVar("T_contra", covariant=True) -32 | T_contra = TypeVar("T_contra", covariant=True, contravariant=False) - | ^^^^^^^ PLC0105 -33 | P_contra = ParamSpec("P_contra") -34 | P_contra = ParamSpec("P_contra", covariant=False) - | - -type_name_incorrect_variance.py:33:12: PLC0105 `ParamSpec` name "P_contra" does not reflect its invariance; consider renaming it to "P" - | -31 | T_contra = TypeVar("T_contra", covariant=True) -32 | T_contra = TypeVar("T_contra", covariant=True, contravariant=False) -33 | P_contra = ParamSpec("P_contra") - | ^^^^^^^^^ PLC0105 -34 | P_contra = ParamSpec("P_contra", covariant=False) -35 | P_contra = ParamSpec("P_contra", contravariant=False) - | - -type_name_incorrect_variance.py:34:12: PLC0105 `ParamSpec` name "P_contra" does not reflect its invariance; consider renaming it to "P" - | -32 | T_contra = TypeVar("T_contra", covariant=True, contravariant=False) -33 | P_contra = ParamSpec("P_contra") -34 | P_contra = ParamSpec("P_contra", covariant=False) - | ^^^^^^^^^ PLC0105 -35 | P_contra = ParamSpec("P_contra", contravariant=False) -36 | P_contra = ParamSpec("P_contra", covariant=False, contravariant=False) - | - -type_name_incorrect_variance.py:35:12: PLC0105 `ParamSpec` name "P_contra" does not reflect its invariance; consider renaming it to "P" - | -33 | P_contra = ParamSpec("P_contra") -34 | P_contra = ParamSpec("P_contra", covariant=False) -35 | P_contra = ParamSpec("P_contra", contravariant=False) - | ^^^^^^^^^ PLC0105 -36 | P_contra = ParamSpec("P_contra", covariant=False, contravariant=False) -37 | P_contra = ParamSpec("P_contra", covariant=True) - | - -type_name_incorrect_variance.py:36:12: PLC0105 `ParamSpec` name "P_contra" does not reflect its invariance; consider renaming it to "P" - | -34 | P_contra = ParamSpec("P_contra", covariant=False) -35 | P_contra = ParamSpec("P_contra", contravariant=False) -36 | P_contra = ParamSpec("P_contra", covariant=False, contravariant=False) - | ^^^^^^^^^ PLC0105 -37 | P_contra = ParamSpec("P_contra", covariant=True) -38 | P_contra = ParamSpec("P_contra", covariant=True, contravariant=False) - | - -type_name_incorrect_variance.py:37:12: PLC0105 `ParamSpec` name "P_contra" does not reflect its covariance; consider renaming it to "P_co" - | -35 | P_contra = ParamSpec("P_contra", contravariant=False) -36 | P_contra = ParamSpec("P_contra", covariant=False, contravariant=False) -37 | P_contra = ParamSpec("P_contra", covariant=True) - | ^^^^^^^^^ PLC0105 -38 | P_contra = ParamSpec("P_contra", covariant=True, contravariant=False) - | - -type_name_incorrect_variance.py:38:12: PLC0105 `ParamSpec` name "P_contra" does not reflect its covariance; consider renaming it to "P_co" - | -36 | P_contra = ParamSpec("P_contra", covariant=False, contravariant=False) -37 | P_contra = ParamSpec("P_contra", covariant=True) -38 | P_contra = ParamSpec("P_contra", covariant=True, contravariant=False) - | ^^^^^^^^^ PLC0105 -39 | -40 | # Non-errors. - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0131_type_bivariance.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0131_type_bivariance.py.snap deleted file mode 100644 index 01107aac91..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0131_type_bivariance.py.snap +++ /dev/null @@ -1,40 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -type_bivariance.py:5:5: PLC0131 `TypeVar` "T" cannot be both covariant and contravariant - | -3 | # Errors. -4 | -5 | T = TypeVar("T", covariant=True, contravariant=True) - | ^^^^^^^ PLC0131 -6 | T = TypeVar(name="T", covariant=True, contravariant=True) - | - -type_bivariance.py:6:5: PLC0131 `TypeVar` "T" cannot be both covariant and contravariant - | -5 | T = TypeVar("T", covariant=True, contravariant=True) -6 | T = TypeVar(name="T", covariant=True, contravariant=True) - | ^^^^^^^ PLC0131 -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 | -8 | T = ParamSpec("T", covariant=True, contravariant=True) - | ^^^^^^^^^ PLC0131 -9 | T = ParamSpec(name="T", covariant=True, contravariant=True) - | - -type_bivariance.py:9:5: PLC0131 `ParamSpec` "T" cannot be both covariant and contravariant - | - 8 | T = ParamSpec("T", covariant=True, contravariant=True) - 9 | T = ParamSpec(name="T", covariant=True, contravariant=True) - | ^^^^^^^^^ PLC0131 -10 | -11 | # Non-errors. - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0132_type_param_name_mismatch.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0132_type_param_name_mismatch.py.snap deleted file mode 100644 index 44084245c2..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0132_type_param_name_mismatch.py.snap +++ /dev/null @@ -1,76 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -type_param_name_mismatch.py:5:5: PLC0132 `TypeVar` name `T` does not match assigned variable name `X` - | -3 | # Errors. -4 | -5 | X = TypeVar("T") - | ^^^^^^^^^^^^ PLC0132 -6 | X = TypeVar(name="T") - | - -type_param_name_mismatch.py:6:5: PLC0132 `TypeVar` name `T` does not match assigned variable name `X` - | -5 | X = TypeVar("T") -6 | X = TypeVar(name="T") - | ^^^^^^^^^^^^^^^^^ PLC0132 -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 | -8 | Y = ParamSpec("T") - | ^^^^^^^^^^^^^^ PLC0132 -9 | Y = ParamSpec(name="T") - | - -type_param_name_mismatch.py:9:5: PLC0132 `ParamSpec` name `T` does not match assigned variable name `Y` - | - 8 | Y = ParamSpec("T") - 9 | Y = ParamSpec(name="T") - | ^^^^^^^^^^^^^^^^^^^ PLC0132 -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 | -11 | Z = NewType("T", int) - | ^^^^^^^^^^^^^^^^^ PLC0132 -12 | Z = NewType(name="T", tp=int) - | - -type_param_name_mismatch.py:12:5: PLC0132 `NewType` name `T` does not match assigned variable name `Z` - | -11 | Z = NewType("T", int) -12 | Z = NewType(name="T", tp=int) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0132 -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 | -14 | Ws = TypeVarTuple("Ts") - | ^^^^^^^^^^^^^^^^^^ PLC0132 -15 | Ws = TypeVarTuple(name="Ts") - | - -type_param_name_mismatch.py:15:6: PLC0132 `TypeVarTuple` name `Ts` does not match assigned variable name `Ws` - | -14 | Ws = TypeVarTuple("Ts") -15 | Ws = TypeVarTuple(name="Ts") - | ^^^^^^^^^^^^^^^^^^^^^^^ PLC0132 -16 | -17 | # Non-errors. - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0205_single_string_slots.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0205_single_string_slots.py.snap deleted file mode 100644 index b378d106c9..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0205_single_string_slots.py.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -single_string_slots.py:3:5: PLC0205 Class `__slots__` should be a non-string iterable - | -1 | # Errors. -2 | class Foo: -3 | __slots__ = "bar" - | ^^^^^^^^^^^^^^^^^ PLC0205 -4 | -5 | def __init__(self, bar): - | - -single_string_slots.py:10:5: PLC0205 Class `__slots__` should be a non-string iterable - | - 9 | class Foo: -10 | __slots__: str = "bar" - | ^^^^^^^^^^^^^^^^^^^^^^ PLC0205 -11 | -12 | def __init__(self, bar): - | - -single_string_slots.py:17:5: PLC0205 Class `__slots__` should be a non-string iterable - | -16 | class Foo: -17 | __slots__: str = f"bar" - | ^^^^^^^^^^^^^^^^^^^^^^^ PLC0205 -18 | -19 | def __init__(self, bar): - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0208_iteration_over_set.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0208_iteration_over_set.py.snap deleted file mode 100644 index 2fdcd20f16..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0208_iteration_over_set.py.snap +++ /dev/null @@ -1,53 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -iteration_over_set.py:3:13: PLC0208 Use a sequence type instead of a `set` when iterating over values - | -1 | # Errors -2 | -3 | for item in {"apples", "lemons", "water"}: # flags in-line set literals - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0208 -4 | print(f"I like {item}.") - | - -iteration_over_set.py:6:28: PLC0208 Use a sequence type instead of a `set` when iterating over values - | -4 | print(f"I like {item}.") -5 | -6 | numbers_list = [i for i in {1, 2, 3}] # flags sets in list comprehensions - | ^^^^^^^^^ PLC0208 -7 | -8 | numbers_set = {i for i in {1, 2, 3}} # flags sets in set comprehensions - | - -iteration_over_set.py:8:27: PLC0208 Use a sequence type instead of a `set` when iterating over values - | - 6 | numbers_list = [i for i in {1, 2, 3}] # flags sets in list comprehensions - 7 | - 8 | numbers_set = {i for i in {1, 2, 3}} # flags sets in set comprehensions - | ^^^^^^^^^ PLC0208 - 9 | -10 | numbers_dict = {str(i): i for i in {1, 2, 3}} # flags sets in dict comprehensions - | - -iteration_over_set.py:10:36: PLC0208 Use a sequence type instead of a `set` when iterating over values - | - 8 | numbers_set = {i for i in {1, 2, 3}} # flags sets in set comprehensions - 9 | -10 | numbers_dict = {str(i): i for i in {1, 2, 3}} # flags sets in dict comprehensions - | ^^^^^^^^^ PLC0208 -11 | -12 | numbers_gen = (i for i in {1, 2, 3}) # flags sets in generator expressions - | - -iteration_over_set.py:12:27: PLC0208 Use a sequence type instead of a `set` when iterating over values - | -10 | numbers_dict = {str(i): i for i in {1, 2, 3}} # flags sets in dict comprehensions -11 | -12 | numbers_gen = (i for i in {1, 2, 3}) # flags sets in generator expressions - | ^^^^^^^^^ PLC0208 -13 | -14 | # Non-errors - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0414_import_aliasing.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0414_import_aliasing.py.snap deleted file mode 100644 index a46cd982e0..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0414_import_aliasing.py.snap +++ /dev/null @@ -1,171 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -import_aliasing.py:6:8: PLC0414 [*] Import alias does not rename original package - | -4 | # 2. consider-using-from-import -5 | -6 | import collections as collections # [useless-import-alias] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0414 -7 | from collections import OrderedDict as OrderedDict # [useless-import-alias] -8 | from collections import OrderedDict as o_dict - | - = help: Remove import alias - -ℹ Suggested fix -3 3 | # 1. useless-import-alias -4 4 | # 2. consider-using-from-import -5 5 | -6 |-import collections as collections # [useless-import-alias] - 6 |+import collections # [useless-import-alias] -7 7 | from collections import OrderedDict as OrderedDict # [useless-import-alias] -8 8 | from collections import OrderedDict as o_dict -9 9 | import os.path as path # [consider-using-from-import] - -import_aliasing.py:7:25: PLC0414 [*] Import alias does not rename original package - | -6 | import collections as collections # [useless-import-alias] -7 | from collections import OrderedDict as OrderedDict # [useless-import-alias] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0414 -8 | from collections import OrderedDict as o_dict -9 | import os.path as path # [consider-using-from-import] - | - = help: Remove import alias - -ℹ Suggested fix -4 4 | # 2. consider-using-from-import -5 5 | -6 6 | import collections as collections # [useless-import-alias] -7 |-from collections import OrderedDict as OrderedDict # [useless-import-alias] - 7 |+from collections import OrderedDict # [useless-import-alias] -8 8 | from collections import OrderedDict as o_dict -9 9 | import os.path as path # [consider-using-from-import] -10 10 | import os.path as p - -import_aliasing.py:16:15: PLC0414 [*] Import alias does not rename original package - | -14 | import os as OS -15 | from sys import version -16 | from . import bar as bar # [useless-import-alias] - | ^^^^^^^^^^ PLC0414 -17 | from . import bar as Bar -18 | from . import bar - | - = help: Remove import alias - -ℹ Suggested fix -13 13 | import os -14 14 | import os as OS -15 15 | from sys import version -16 |-from . import bar as bar # [useless-import-alias] - 16 |+from . import bar # [useless-import-alias] -17 17 | from . import bar as Bar -18 18 | from . import bar -19 19 | from ..foo import bar as bar # [useless-import-alias] - -import_aliasing.py:19:19: PLC0414 [*] Import alias does not rename original package - | -17 | from . import bar as Bar -18 | from . import bar -19 | from ..foo import bar as bar # [useless-import-alias] - | ^^^^^^^^^^ PLC0414 -20 | from ..foo.bar import foobar as foobar # [useless-import-alias] -21 | from ..foo.bar import foobar as anotherfoobar - | - = help: Remove import alias - -ℹ Suggested fix -16 16 | from . import bar as bar # [useless-import-alias] -17 17 | from . import bar as Bar -18 18 | from . import bar -19 |-from ..foo import bar as bar # [useless-import-alias] - 19 |+from ..foo import bar # [useless-import-alias] -20 20 | from ..foo.bar import foobar as foobar # [useless-import-alias] -21 21 | from ..foo.bar import foobar as anotherfoobar -22 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] - -import_aliasing.py:20:23: PLC0414 [*] Import alias does not rename original package - | -18 | from . import bar -19 | from ..foo import bar as bar # [useless-import-alias] -20 | from ..foo.bar import foobar as foobar # [useless-import-alias] - | ^^^^^^^^^^^^^^^^ PLC0414 -21 | from ..foo.bar import foobar as anotherfoobar -22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] - | - = help: Remove import alias - -ℹ Suggested fix -17 17 | from . import bar as Bar -18 18 | from . import bar -19 19 | from ..foo import bar as bar # [useless-import-alias] -20 |-from ..foo.bar import foobar as foobar # [useless-import-alias] - 20 |+from ..foo.bar import foobar # [useless-import-alias] -21 21 | from ..foo.bar import foobar as anotherfoobar -22 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] -23 23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] - -import_aliasing.py:22:15: PLC0414 [*] Import alias does not rename original package - | -20 | from ..foo.bar import foobar as foobar # [useless-import-alias] -21 | from ..foo.bar import foobar as anotherfoobar -22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] - | ^^^^^^^^^^ PLC0414 -23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] -24 | from . import foo as bar, foo2 as bar2 - | - = help: Remove import alias - -ℹ Suggested fix -19 19 | from ..foo import bar as bar # [useless-import-alias] -20 20 | from ..foo.bar import foobar as foobar # [useless-import-alias] -21 21 | from ..foo.bar import foobar as anotherfoobar -22 |-from . import foo as foo, foo2 as bar2 # [useless-import-alias] - 22 |+from . import foo, foo2 as bar2 # [useless-import-alias] -23 23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] -24 24 | from . import foo as bar, foo2 as bar2 -25 25 | from foo.bar import foobar as foobar # [useless-import-alias] - -import_aliasing.py:23:27: PLC0414 [*] Import alias does not rename original package - | -21 | from ..foo.bar import foobar as anotherfoobar -22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] -23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] - | ^^^^^^^^^^^^ PLC0414 -24 | from . import foo as bar, foo2 as bar2 -25 | from foo.bar import foobar as foobar # [useless-import-alias] - | - = help: Remove import alias - -ℹ Suggested fix -20 20 | from ..foo.bar import foobar as foobar # [useless-import-alias] -21 21 | from ..foo.bar import foobar as anotherfoobar -22 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] -23 |-from . import foo as bar, foo2 as foo2 # [useless-import-alias] - 23 |+from . import foo as bar, foo2 # [useless-import-alias] -24 24 | from . import foo as bar, foo2 as bar2 -25 25 | from foo.bar import foobar as foobar # [useless-import-alias] -26 26 | from foo.bar import foobar as foo - -import_aliasing.py:25:21: PLC0414 [*] Import alias does not rename original package - | -23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] -24 | from . import foo as bar, foo2 as bar2 -25 | from foo.bar import foobar as foobar # [useless-import-alias] - | ^^^^^^^^^^^^^^^^ PLC0414 -26 | from foo.bar import foobar as foo -27 | from .foo.bar import f as foobar - | - = help: Remove import alias - -ℹ Suggested fix -22 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] -23 23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] -24 24 | from . import foo as bar, foo2 as bar2 -25 |-from foo.bar import foobar as foobar # [useless-import-alias] - 25 |+from foo.bar import foobar # [useless-import-alias] -26 26 | from foo.bar import foobar as foo -27 27 | from .foo.bar import f as foobar -28 28 | from ............a import b # [relative-beyond-top-level] - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC1901_compare_to_empty_string.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC1901_compare_to_empty_string.py.snap deleted file mode 100644 index 19209890fd..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC1901_compare_to_empty_string.py.snap +++ /dev/null @@ -1,47 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -compare_to_empty_string.py:7:13: PLC1901 `x is ""` can be simplified to `not x` as an empty string is falsey - | -6 | def errors(): -7 | if x is "" or x == "": - | ^^ PLC1901 -8 | print("x is an empty string") - | - -compare_to_empty_string.py:7:24: PLC1901 `x == ""` can be simplified to `not x` as an empty string is falsey - | -6 | def errors(): -7 | if x is "" or x == "": - | ^^ PLC1901 -8 | print("x is an empty string") - | - -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 | -10 | if y is not "" or y != "": - | ^^ PLC1901 -11 | print("y is not an empty string") - | - -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 | -10 | if y is not "" or y != "": - | ^^ PLC1901 -11 | print("y is not an empty string") - | - -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 | -13 | if "" != z: - | ^^ PLC1901 -14 | print("z is an empty string") - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC3002_unnecessary_direct_lambda_call.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC3002_unnecessary_direct_lambda_call.py.snap deleted file mode 100644 index 1be8b842ca..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC3002_unnecessary_direct_lambda_call.py.snap +++ /dev/null @@ -1,27 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -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 | -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] - | - -unnecessary_direct_lambda_call.py:5:9: PLC3002 Lambda expression called directly. Execute the expression inline instead. - | -4 | y = (lambda x: x**2 + 2*x + 1)(a) # [unnecessary-direct-lambda-call] -5 | y = max((lambda x: x**2)(a), (lambda x: x+1)(a)) # [unnecessary-direct-lambda-call,unnecessary-direct-lambda-call] - | ^^^^^^^^^^^^^^^^^^^ PLC3002 - | - -unnecessary_direct_lambda_call.py:5:30: PLC3002 Lambda expression called directly. Execute the expression inline instead. - | -4 | y = (lambda x: x**2 + 2*x + 1)(a) # [unnecessary-direct-lambda-call] -5 | y = max((lambda x: x**2)(a), (lambda x: x+1)(a)) # [unnecessary-direct-lambda-call,unnecessary-direct-lambda-call] - | ^^^^^^^^^^^^^^^^^^ PLC3002 - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0100_yield_in_init.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0100_yield_in_init.py.snap deleted file mode 100644 index 77699330ba..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0100_yield_in_init.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -yield_in_init.py:9:9: PLE0100 `__init__` method is a generator - | -7 | class A: -8 | def __init__(self): -9 | yield - | ^^^^^ PLE0100 - | - -yield_in_init.py:14:9: PLE0100 `__init__` method is a generator - | -12 | class B: -13 | def __init__(self): -14 | yield from self.gen() - | ^^^^^^^^^^^^^^^^^^^^^ PLE0100 -15 | -16 | def gen(self): - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0101_return_in_init.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0101_return_in_init.py.snap deleted file mode 100644 index 47f19e6214..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0101_return_in_init.py.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -return_in_init.py:14:9: PLE0101 Explicit return in `__init__` - | -12 | class B: -13 | def __init__(self): -14 | return 3 - | ^^^^^^^^ PLE0101 -15 | -16 | def gen(self): - | - -return_in_init.py:22:9: PLE0101 Explicit return in `__init__` - | -21 | def __init__(self): -22 | return 1 - | ^^^^^^^^ PLE0101 -23 | -24 | class MyClass2: - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0116_continue_in_finally.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0116_continue_in_finally.py.snap deleted file mode 100644 index e4c72d6658..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0116_continue_in_finally.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0117_nonlocal_without_binding.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0117_nonlocal_without_binding.py.snap deleted file mode 100644 index 50bd5bf0ac..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0117_nonlocal_without_binding.py.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -nonlocal_without_binding.py:5:14: PLE0117 Nonlocal name `x` found without binding - | -4 | def f(): -5 | nonlocal x - | ^ PLE0117 - | - -nonlocal_without_binding.py:9:14: PLE0117 Nonlocal name `y` found without binding - | -8 | def f(): -9 | nonlocal y - | ^ PLE0117 - | - -nonlocal_without_binding.py:19:18: PLE0117 Nonlocal name `y` found without binding - | -18 | def f(): -19 | nonlocal y - | ^ PLE0117 - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0118_load_before_global_declaration.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0118_load_before_global_declaration.py.snap deleted file mode 100644 index af3d849793..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0118_load_before_global_declaration.py.snap +++ /dev/null @@ -1,127 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -load_before_global_declaration.py:5:11: PLE0118 Name `x` is used prior to global declaration on line 7 - | -3 | ### -4 | def f(): -5 | print(x) - | ^ PLE0118 -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 | -15 | print(x) - | ^ PLE0118 -16 | -17 | global x - | - -load_before_global_declaration.py:23:11: PLE0118 Name `x` is used prior to global declaration on line 25 - | -22 | def f(): -23 | print(x) - | ^ PLE0118 -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 | -33 | print(x) - | ^ PLE0118 -34 | -35 | global x, y - | - -load_before_global_declaration.py:41:5: PLE0118 Name `x` is used prior to global declaration on line 43 - | -40 | def f(): -41 | x = 1 - | ^ PLE0118 -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 | -51 | x = 1 - | ^ PLE0118 -52 | -53 | global x - | - -load_before_global_declaration.py:59:9: PLE0118 Name `x` is used prior to global declaration on line 61 - | -58 | def f(): -59 | del x - | ^ PLE0118 -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 | -69 | del x - | ^ PLE0118 -70 | -71 | global x, y - | - -load_before_global_declaration.py:77:9: PLE0118 Name `x` is used prior to global declaration on line 79 - | -76 | def f(): -77 | del x - | ^ PLE0118 -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 | -87 | del x - | ^ PLE0118 -88 | -89 | global x - | - -load_before_global_declaration.py:95:9: PLE0118 Name `x` is used prior to global declaration on line 97 - | -94 | def f(): -95 | del x - | ^ PLE0118 -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 | -105 | del x - | ^ PLE0118 -106 | -107 | global x, y - | - -load_before_global_declaration.py:113:14: PLE0118 Name `x` is used prior to global declaration on line 114 - | -112 | def f(): -113 | print(f"{x=}") - | ^ PLE0118 -114 | global x - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0241_duplicate_bases.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0241_duplicate_bases.py.snap deleted file mode 100644 index 60b9ce981b..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0241_duplicate_bases.py.snap +++ /dev/null @@ -1,11 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -duplicate_bases.py:8:12: PLE0241 Duplicate base `A` for class `B` - | -8 | class B(A, A): - | ^ PLE0241 -9 | ... - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0302_unexpected_special_method_signature.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0302_unexpected_special_method_signature.py.snap deleted file mode 100644 index 512a8b27d3..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0302_unexpected_special_method_signature.py.snap +++ /dev/null @@ -1,75 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -unexpected_special_method_signature.py:5:9: PLE0302 The special method `__bool__` expects 1 parameter, 2 were given - | -3 | ... -4 | -5 | def __bool__(self, x): # too many mandatory args - | ^^^^^^^^ PLE0302 -6 | ... - | - -unexpected_special_method_signature.py:19:9: PLE0302 The special method `__bool__` expects 0 parameters, 1 was given - | -18 | @staticmethod -19 | def __bool__(x): # too many mandatory args - | ^^^^^^^^ PLE0302 -20 | ... - | - -unexpected_special_method_signature.py:32:9: PLE0302 The special method `__eq__` expects 2 parameters, 1 was given - | -30 | ... -31 | -32 | def __eq__(self): # too few mandatory args - | ^^^^^^ PLE0302 -33 | ... - | - -unexpected_special_method_signature.py:35:9: PLE0302 The special method `__eq__` expects 2 parameters, 3 were given - | -33 | ... -34 | -35 | def __eq__(self, other, other_other): # too many mandatory args - | ^^^^^^ PLE0302 -36 | ... - | - -unexpected_special_method_signature.py:44:9: PLE0302 The special method `__round__` expects between 1 and 2 parameters, 3 were given - | -42 | ... -43 | -44 | def __round__(self, x, y): # disallow 2 args - | ^^^^^^^^^ PLE0302 -45 | ... - | - -unexpected_special_method_signature.py:47:9: PLE0302 The special method `__round__` expects between 1 and 2 parameters, 4 were given - | -45 | ... -46 | -47 | def __round__(self, x, y, z=2): # disallow 3 args even when one is optional - | ^^^^^^^^^ PLE0302 -48 | ... - | - -unexpected_special_method_signature.py:56:9: PLE0302 The special method `__eq__` expects 2 parameters, 3 were given - | -54 | ... -55 | -56 | def __eq__(self, x, y, *args): # too many args with *args - | ^^^^^^ PLE0302 -57 | ... - | - -unexpected_special_method_signature.py:65:9: PLE0302 The special method `__round__` expects between 1 and 2 parameters, 3 were given - | -63 | ... -64 | -65 | def __round__(self, x, y, *args): # disallow 2 args - | ^^^^^^^^^ PLE0302 -66 | ... - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0307_invalid_return_type_str.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0307_invalid_return_type_str.py.snap deleted file mode 100644 index cec902bbf7..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0307_invalid_return_type_str.py.snap +++ /dev/null @@ -1,44 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -invalid_return_type_str.py:3:16: PLE0307 `__str__` does not return `str` - | -1 | class Str: -2 | def __str__(self): -3 | return 1 - | ^ PLE0307 -4 | -5 | class Float: - | - -invalid_return_type_str.py:7:16: PLE0307 `__str__` does not return `str` - | -5 | class Float: -6 | def __str__(self): -7 | return 3.05 - | ^^^^ PLE0307 -8 | -9 | class Int: - | - -invalid_return_type_str.py:11:16: PLE0307 `__str__` does not return `str` - | - 9 | class Int: -10 | def __str__(self): -11 | return 0 - | ^ PLE0307 -12 | -13 | class Bool: - | - -invalid_return_type_str.py:15:16: PLE0307 `__str__` does not return `str` - | -13 | class Bool: -14 | def __str__(self): -15 | return False - | ^^^^^ PLE0307 -16 | -17 | class Str2: - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0604_invalid_all_object.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0604_invalid_all_object.py.snap deleted file mode 100644 index b6a2057d6a..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0604_invalid_all_object.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -invalid_all_object.py:1:1: PLE0604 Invalid object in `__all__`, must contain only strings - | -1 | __all__ = ( - | ^^^^^^^ PLE0604 -2 | None, # [invalid-all-object] -3 | Fruit, - | - -invalid_all_object.py:7:1: PLE0604 Invalid object in `__all__`, must contain only strings - | -5 | ) -6 | -7 | __all__ = list([None, "Fruit", "Worm"]) # [invalid-all-object] - | ^^^^^^^ PLE0604 - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0605_invalid_all_format.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0605_invalid_all_format.py.snap deleted file mode 100644 index 44550c82a6..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE0605_invalid_all_format.py.snap +++ /dev/null @@ -1,112 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -invalid_all_format.py:1:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` - | -1 | __all__ = "CONST" # [invalid-all-format] - | ^^^^^^^ PLE0605 -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 | -3 | __all__ = ["Hello"] + {"world"} # [invalid-all-format] - | ^^^^^^^ PLE0605 -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 | -5 | __all__ += {"world"} # [invalid-all-format] - | ^^^^^^^ PLE0605 -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 | -7 | __all__ = {"world"} + ["Hello"] # [invalid-all-format] - | ^^^^^^^ PLE0605 -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 | - 9 | __all__ = {"world"} + list(["Hello"]) # [invalid-all-format] - | ^^^^^^^ PLE0605 -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 | -11 | __all__ = list(["Hello"]) + {"world"} # [invalid-all-format] - | ^^^^^^^ PLE0605 -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 | -13 | __all__ = (x for x in ["Hello", "world"]) # [invalid-all-format] - | ^^^^^^^ PLE0605 -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 | -15 | __all__ = {x for x in ["Hello", "world"]} # [invalid-all-format] - | ^^^^^^^ PLE0605 -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 | -17 | __all__ = foo # [invalid-all-format] - | ^^^^^^^ PLE0605 -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 | -19 | __all__ = foo.bar # [invalid-all-format] - | ^^^^^^^ PLE0605 -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 | -21 | __all__ = foo["bar"] # [invalid-all-format] - | ^^^^^^^ PLE0605 -22 | -23 | __all__ = ["Hello"] - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1142_await_outside_async.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1142_await_outside_async.py.snap deleted file mode 100644 index f811eb6497..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1142_await_outside_async.py.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -await_outside_async.py:12:11: PLE1142 `await` should be used within an async function - | -11 | def not_async(): -12 | print(await nested()) # [await-outside-async] - | ^^^^^^^^^^^^^^ PLE1142 - | - -await_outside_async.py:25:9: PLE1142 `await` should be used within an async function - | -23 | async def func2(): -24 | def inner_func(): -25 | await asyncio.sleep(1) # [await-outside-async] - | ^^^^^^^^^^^^^^^^^^^^^^ PLE1142 - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1205_logging_too_many_args.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1205_logging_too_many_args.py.snap deleted file mode 100644 index 9c07b31eb2..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1205_logging_too_many_args.py.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -logging_too_many_args.py:3:1: PLE1205 Too many arguments for `logging` format string - | -1 | import logging -2 | -3 | logging.warning("Hello %s", "World!", "again") # [logging-too-many-args] - | ^^^^^^^^^^^^^^^ PLE1205 -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 | -5 | logging.warning("Hello %s", "World!", "again", something="else") - | ^^^^^^^^^^^^^^^ PLE1205 -6 | -7 | logging.warning("Hello %s", "World!") - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1206_logging_too_few_args.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1206_logging_too_few_args.py.snap deleted file mode 100644 index 6a9ca89cec..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1206_logging_too_few_args.py.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -logging_too_few_args.py:3:1: PLE1206 Not enough arguments for `logging` format string - | -1 | import logging -2 | -3 | logging.warning("Hello %s %s", "World!") # [logging-too-few-args] - | ^^^^^^^^^^^^^^^ PLE1206 -4 | -5 | # do not handle calls with kwargs (like pylint) - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1300_bad_string_format_character.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1300_bad_string_format_character.py.snap deleted file mode 100644 index 709c8ec814..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1300_bad_string_format_character.py.snap +++ /dev/null @@ -1,64 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -bad_string_format_character.py:5:1: PLE1300 Unsupported format character 'z' - | -3 | ## Old style formatting -4 | -5 | "%s %z" % ("hello", "world") # [bad-format-character] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 -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 | -7 | "%s" "%z" % ("hello", "world") # [bad-format-character] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 -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 | - 9 | """%s %z""" % ("hello", "world") # [bad-format-character] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 -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 | -11 | """%s""" """%z""" % ("hello", "world") # [bad-format-character] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 -12 | -13 | ## New style formatting - | - -bad_string_format_character.py:15:1: PLE1300 Unsupported format character 'y' - | -13 | ## New style formatting -14 | -15 | "{:s} {:y}".format("hello", "world") # [bad-format-character] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 -16 | -17 | "{:*^30s}".format("centered") # OK - | - -bad_string_format_character.py:19:1: PLE1300 Unsupported format character 'y' - | -17 | "{:*^30s}".format("centered") # OK -18 | "{:{s}}".format("hello", s="s") # OK (nested placeholder value not checked) -19 | "{:{s:y}}".format("hello", s="s") # [bad-format-character] (nested placeholder format spec checked) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 -20 | "{0:.{prec}g}".format(1.23, prec=15) # OK (cannot validate after nested placeholder) -21 | "{0:.{foo}{bar}{foobar}y}".format(...) # OK (cannot validate after nested placeholders) - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1307_bad_string_format_type.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1307_bad_string_format_type.py.snap deleted file mode 100644 index e50006d763..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1307_bad_string_format_type.py.snap +++ /dev/null @@ -1,131 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -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 | -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 | -4 | "foo %e bar %s" % ("1", 2) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 -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 | -6 | "%d" % "1" - | ^^^^^^^^^^ PLE1307 -7 | "%o" % "1" -8 | "%(key)d" % {"key": "1"} - | - -bad_string_format_type.py:7:1: PLE1307 Format type does not match argument type - | -6 | "%d" % "1" -7 | "%o" % "1" - | ^^^^^^^^^^ PLE1307 -8 | "%(key)d" % {"key": "1"} -9 | "%x" % 1.1 - | - -bad_string_format_type.py:8:1: PLE1307 Format type does not match argument type - | - 6 | "%d" % "1" - 7 | "%o" % "1" - 8 | "%(key)d" % {"key": "1"} - | ^^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 - 9 | "%x" % 1.1 -10 | "%(key)x" % {"key": 1.1} - | - -bad_string_format_type.py:9:1: PLE1307 Format type does not match argument type - | - 7 | "%o" % "1" - 8 | "%(key)d" % {"key": "1"} - 9 | "%x" % 1.1 - | ^^^^^^^^^^ PLE1307 -10 | "%(key)x" % {"key": 1.1} -11 | "%d" % [] - | - -bad_string_format_type.py:10:1: PLE1307 Format type does not match argument type - | - 8 | "%(key)d" % {"key": "1"} - 9 | "%x" % 1.1 -10 | "%(key)x" % {"key": 1.1} - | ^^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 -11 | "%d" % [] -12 | "%d" % ([],) - | - -bad_string_format_type.py:11:1: PLE1307 Format type does not match argument type - | - 9 | "%x" % 1.1 -10 | "%(key)x" % {"key": 1.1} -11 | "%d" % [] - | ^^^^^^^^^ PLE1307 -12 | "%d" % ([],) -13 | "%(key)d" % {"key": []} - | - -bad_string_format_type.py:12:1: PLE1307 Format type does not match argument type - | -10 | "%(key)x" % {"key": 1.1} -11 | "%d" % [] -12 | "%d" % ([],) - | ^^^^^^^^^^^^ PLE1307 -13 | "%(key)d" % {"key": []} -14 | print("%d" % ("%s" % ("nested",),)) - | - -bad_string_format_type.py:13:1: PLE1307 Format type does not match argument type - | -11 | "%d" % [] -12 | "%d" % ([],) -13 | "%(key)d" % {"key": []} - | ^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 -14 | print("%d" % ("%s" % ("nested",),)) -15 | "%d" % ((1, 2, 3),) - | - -bad_string_format_type.py:14:7: PLE1307 Format type does not match argument type - | -12 | "%d" % ([],) -13 | "%(key)d" % {"key": []} -14 | print("%d" % ("%s" % ("nested",),)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 -15 | "%d" % ((1, 2, 3),) -16 | "%d" % (1 if x > 0 else []) - | - -bad_string_format_type.py:15:1: PLE1307 Format type does not match argument type - | -13 | "%(key)d" % {"key": []} -14 | print("%d" % ("%s" % ("nested",),)) -15 | "%d" % ((1, 2, 3),) - | ^^^^^^^^^^^^^^^^^^^ PLE1307 -16 | "%d" % (1 if x > 0 else []) - | - -bad_string_format_type.py:16:1: PLE1307 Format type does not match argument type - | -14 | print("%d" % ("%s" % ("nested",),)) -15 | "%d" % ((1, 2, 3),) -16 | "%d" % (1 if x > 0 else []) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 -17 | -18 | # False negatives - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1310_bad_str_strip_call.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1310_bad_str_strip_call.py.snap deleted file mode 100644 index 10ea225240..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1310_bad_str_strip_call.py.snap +++ /dev/null @@ -1,160 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -bad_str_strip_call.py:2:21: PLE1310 String `strip` call contains duplicate characters - | -1 | # PLE1310 -2 | "Hello World".strip("Hello") - | ^^^^^^^ PLE1310 -3 | -4 | # PLE1310 - | - -bad_str_strip_call.py:5:21: PLE1310 String `strip` call contains duplicate characters - | -4 | # PLE1310 -5 | "Hello World".strip("Hello") - | ^^^^^^^ PLE1310 -6 | -7 | # PLE1310 - | - -bad_str_strip_call.py:8:21: PLE1310 String `strip` call contains duplicate characters - | - 7 | # PLE1310 - 8 | "Hello World".strip(u"Hello") - | ^^^^^^^^ PLE1310 - 9 | -10 | # PLE1310 - | - -bad_str_strip_call.py:11:21: PLE1310 String `strip` call contains duplicate characters - | -10 | # PLE1310 -11 | "Hello World".strip(r"Hello") - | ^^^^^^^^ PLE1310 -12 | -13 | # PLE1310 - | - -bad_str_strip_call.py:14:21: PLE1310 String `strip` call contains duplicate characters - | -13 | # PLE1310 -14 | "Hello World".strip("Hello\t") - | ^^^^^^^^^ PLE1310 -15 | -16 | # PLE1310 - | - -bad_str_strip_call.py:17:21: PLE1310 String `strip` call contains duplicate characters - | -16 | # PLE1310 -17 | "Hello World".strip(r"Hello\t") - | ^^^^^^^^^^ PLE1310 -18 | -19 | # PLE1310 - | - -bad_str_strip_call.py:20:21: PLE1310 String `strip` call contains duplicate characters - | -19 | # PLE1310 -20 | "Hello World".strip("Hello\\") - | ^^^^^^^^^ PLE1310 -21 | -22 | # PLE1310 - | - -bad_str_strip_call.py:23:21: PLE1310 String `strip` call contains duplicate characters - | -22 | # PLE1310 -23 | "Hello World".strip(r"Hello\\") - | ^^^^^^^^^^ PLE1310 -24 | -25 | # PLE1310 - | - -bad_str_strip_call.py:26:21: PLE1310 String `strip` call contains duplicate characters - | -25 | # PLE1310 -26 | "Hello World".strip("🤣🤣🤣🤣🙃👀😀") - | ^^^^^^^^^^^^^^^^ PLE1310 -27 | -28 | # PLE1310 - | - -bad_str_strip_call.py:30:5: PLE1310 String `strip` call contains duplicate characters - | -28 | # PLE1310 -29 | "Hello World".strip( -30 | """ - | _____^ -31 | | there are a lot of characters to strip -32 | | """ - | |___^ PLE1310 -33 | ) - | - -bad_str_strip_call.py:36:21: PLE1310 String `strip` call contains duplicate characters - | -35 | # PLE1310 -36 | "Hello World".strip("can we get a long " \ - | _____________________^ -37 | | "string of characters to strip " \ -38 | | "please?") - | |_____________________________^ PLE1310 -39 | -40 | # PLE1310 - | - -bad_str_strip_call.py:42:5: PLE1310 String `strip` call contains duplicate characters - | -40 | # PLE1310 -41 | "Hello World".strip( -42 | "can we get a long " - | _____^ -43 | | "string of characters to strip " -44 | | "please?" - | |_____________^ PLE1310 -45 | ) - | - -bad_str_strip_call.py:49:5: PLE1310 String `strip` call contains duplicate characters - | -47 | # PLE1310 -48 | "Hello World".strip( -49 | "can \t we get a long" - | _____^ -50 | | "string \t of characters to strip" -51 | | "please?" - | |_____________^ PLE1310 -52 | ) - | - -bad_str_strip_call.py:61:11: PLE1310 String `strip` call contains duplicate characters - | -60 | # PLE1310 -61 | u''.strip('http://') - | ^^^^^^^^^ PLE1310 -62 | -63 | # PLE1310 - | - -bad_str_strip_call.py:64:12: PLE1310 String `lstrip` call contains duplicate characters (did you mean `removeprefix`?) - | -63 | # PLE1310 -64 | u''.lstrip('http://') - | ^^^^^^^^^ PLE1310 -65 | -66 | # PLE1310 - | - -bad_str_strip_call.py:67:12: PLE1310 String `rstrip` call contains duplicate characters (did you mean `removesuffix`?) - | -66 | # PLE1310 -67 | b''.rstrip('http://') - | ^^^^^^^^^ PLE1310 -68 | -69 | # OK - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1507_invalid_envvar_value.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1507_invalid_envvar_value.py.snap deleted file mode 100644 index 6564ff6dd0..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1507_invalid_envvar_value.py.snap +++ /dev/null @@ -1,54 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -invalid_envvar_value.py:3:11: PLE1507 Invalid type for initial `os.getenv` argument; expected `str` - | -1 | import os -2 | -3 | os.getenv(1) # [invalid-envvar-value] - | ^ PLE1507 -4 | os.getenv("a") -5 | os.getenv("test") - | - -invalid_envvar_value.py:7:15: PLE1507 Invalid type for initial `os.getenv` argument; expected `str` - | -5 | os.getenv("test") -6 | os.getenv(key="testingAgain") -7 | os.getenv(key=11) # [invalid-envvar-value] - | ^^ PLE1507 -8 | os.getenv(["hello"]) # [invalid-envvar-value] -9 | os.getenv(key="foo", default="bar") - | - -invalid_envvar_value.py:8:11: PLE1507 Invalid type for initial `os.getenv` argument; expected `str` - | - 6 | os.getenv(key="testingAgain") - 7 | os.getenv(key=11) # [invalid-envvar-value] - 8 | os.getenv(["hello"]) # [invalid-envvar-value] - | ^^^^^^^^^ PLE1507 - 9 | os.getenv(key="foo", default="bar") -10 | os.getenv(key=f"foo", default="bar") - | - -invalid_envvar_value.py:12:15: PLE1507 Invalid type for initial `os.getenv` argument; expected `str` - | -10 | os.getenv(key=f"foo", default="bar") -11 | os.getenv(key="foo" + "bar", default=1) -12 | os.getenv(key=1 + "bar", default=1) # [invalid-envvar-value] - | ^^^^^^^^^ PLE1507 -13 | os.getenv("PATH_TEST" if using_clear_path else "PATH_ORIG") -14 | os.getenv(1 if using_clear_path else "PATH_ORIG") - | - -invalid_envvar_value.py:14:11: PLE1507 Invalid type for initial `os.getenv` argument; expected `str` - | -12 | os.getenv(key=1 + "bar", default=1) # [invalid-envvar-value] -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 | -16 | AA = "aa" - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1700_yield_from_in_async_function.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1700_yield_from_in_async_function.py.snap deleted file mode 100644 index c9962ec74e..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE1700_yield_from_in_async_function.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -yield_from_in_async_function.py:7:5: PLE1700 `yield from` statement in async function; use `async for` instead - | -5 | async def fail(): -6 | l = (1, 2, 3) -7 | yield from l - | ^^^^^^^^^^^^ PLE1700 - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2502_bidirectional_unicode.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2502_bidirectional_unicode.py.snap deleted file mode 100644 index e2ad6c0900..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2502_bidirectional_unicode.py.snap +++ /dev/null @@ -1,43 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -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 - | - -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 - | - -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 - | - -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 - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2510_invalid_characters.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2510_invalid_characters.py.snap deleted file mode 100644 index 7cba4adf6d..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2510_invalid_characters.py.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -invalid_characters.py:15:6: PLE2510 [*] Invalid unescaped character backspace, use "\b" instead - | -13 | # (Pylint, "C3002") => Rule::UnnecessaryDirectLambdaCall, -14 | #foo = 'hi' -15 | b = '' - | PLE2510 -16 | -17 | b_ok = '\\b' - | - = help: Replace with escape sequence - -ℹ Fix -12 12 | # (Pylint, "C0414") => Rule::UselessImportAlias, -13 13 | # (Pylint, "C3002") => Rule::UnnecessaryDirectLambdaCall, -14 14 | #foo = 'hi' -15 |-b = '' - 15 |+b = '\b' -16 16 | -17 17 | b_ok = '\\b' -18 18 | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2512_invalid_characters.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2512_invalid_characters.py.snap deleted file mode 100644 index dbde22f71b..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2512_invalid_characters.py.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -invalid_characters.py:21:12: PLE2512 [*] Invalid unescaped character SUB, use "\x1A" instead - | -19 | cr_ok = '\\r' -20 | -21 | sub = 'sub ' - | PLE2512 -22 | -23 | sub_ok = '\x1a' - | - = help: Replace with escape sequence - -ℹ Fix -18 18 | -19 19 | cr_ok = '\\r' -20 20 | -21 |-sub = 'sub ' - 21 |+sub = 'sub \x1A' -22 22 | -23 23 | sub_ok = '\x1a' -24 24 | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2513_invalid_characters.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2513_invalid_characters.py.snap deleted file mode 100644 index d8b61f4e13..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2513_invalid_characters.py.snap +++ /dev/null @@ -1,25 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -invalid_characters.py:25:16: PLE2513 [*] Invalid unescaped character ESC, use "\x1B" instead - | -23 | sub_ok = '\x1a' -24 | -25 | esc = 'esc esc ' - | PLE2513 -26 | -27 | esc_ok = '\x1b' - | - = help: Replace with escape sequence - -ℹ Fix -22 22 | -23 23 | sub_ok = '\x1a' -24 24 | -25 |-esc = 'esc esc ' - 25 |+esc = 'esc esc \x1B' -26 26 | -27 27 | esc_ok = '\x1b' -28 28 | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2514_invalid_characters.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2514_invalid_characters.py.snap deleted file mode 100644 index 6adc278155..0000000000 Binary files a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2514_invalid_characters.py.snap and /dev/null differ diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2515_invalid_characters.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2515_invalid_characters.py.snap deleted file mode 100644 index b12204f098..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2515_invalid_characters.py.snap +++ /dev/null @@ -1,73 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -invalid_characters.py:34:13: PLE2515 [*] Invalid unescaped character zero-width-space, use "\u200B" instead - | -32 | nul_ok = '\0' -33 | -34 | zwsp = 'zero​width' - | PLE2515 -35 | -36 | zwsp_ok = '\u200b' - | - = help: Replace with escape sequence - -ℹ Fix -31 31 | -32 32 | nul_ok = '\0' -33 33 | -34 |-zwsp = 'zero​width' - 34 |+zwsp = 'zero\u200bwidth' -35 35 | -36 36 | zwsp_ok = '\u200b' -37 37 | - -invalid_characters.py:38:36: PLE2515 [*] Invalid unescaped character zero-width-space, use "\u200B" instead - | -36 | zwsp_ok = '\u200b' -37 | -38 | zwsp_after_multibyte_character = "ಫ​" - | PLE2515 -39 | zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" - | - = help: Replace with escape sequence - -ℹ Fix -35 35 | -36 36 | zwsp_ok = '\u200b' -37 37 | -38 |-zwsp_after_multibyte_character = "ಫ​" - 38 |+zwsp_after_multibyte_character = "ಫ\u200b" -39 39 | zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" - -invalid_characters.py:39:60: PLE2515 [*] Invalid unescaped character zero-width-space, use "\u200B" instead - | -38 | zwsp_after_multibyte_character = "ಫ​" -39 | zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" - | PLE2515 - | - = help: Replace with escape sequence - -ℹ Fix -36 36 | zwsp_ok = '\u200b' -37 37 | -38 38 | zwsp_after_multibyte_character = "ಫ​" -39 |-zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" - 39 |+zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ \u200b​" - -invalid_characters.py:39:61: PLE2515 [*] Invalid unescaped character zero-width-space, use "\u200B" instead - | -38 | zwsp_after_multibyte_character = "ಫ​" -39 | zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" - | PLE2515 - | - = help: Replace with escape sequence - -ℹ Fix -36 36 | zwsp_ok = '\u200b' -37 37 | -38 38 | zwsp_after_multibyte_character = "ಫ​" -39 |-zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" - 39 |+zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​\u200b" - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0124_comparison_with_itself.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0124_comparison_with_itself.py.snap deleted file mode 100644 index 711834227e..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0124_comparison_with_itself.py.snap +++ /dev/null @@ -1,123 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -comparison_with_itself.py:2:1: PLR0124 Name compared with itself, consider replacing `foo == foo` - | -1 | # Errors. -2 | foo == foo - | ^^^ PLR0124 -3 | -4 | foo != foo - | - -comparison_with_itself.py:4:1: PLR0124 Name compared with itself, consider replacing `foo != foo` - | -2 | foo == foo -3 | -4 | foo != foo - | ^^^ PLR0124 -5 | -6 | foo > foo - | - -comparison_with_itself.py:6:1: PLR0124 Name compared with itself, consider replacing `foo > foo` - | -4 | foo != foo -5 | -6 | foo > foo - | ^^^ PLR0124 -7 | -8 | foo >= foo - | - -comparison_with_itself.py:8:1: PLR0124 Name compared with itself, consider replacing `foo >= foo` - | - 6 | foo > foo - 7 | - 8 | foo >= foo - | ^^^ PLR0124 - 9 | -10 | foo < foo - | - -comparison_with_itself.py:10:1: PLR0124 Name compared with itself, consider replacing `foo < foo` - | - 8 | foo >= foo - 9 | -10 | foo < foo - | ^^^ PLR0124 -11 | -12 | foo <= foo - | - -comparison_with_itself.py:12:1: PLR0124 Name compared with itself, consider replacing `foo <= foo` - | -10 | foo < foo -11 | -12 | foo <= foo - | ^^^ PLR0124 -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 | -14 | foo is foo - | ^^^ PLR0124 -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 | -16 | foo is not foo - | ^^^ PLR0124 -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 | -18 | foo in foo - | ^^^ PLR0124 -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 | -20 | foo not in foo - | ^^^ PLR0124 -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 | -22 | id(foo) == id(foo) - | ^^^^^^^ PLR0124 -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 | -24 | len(foo) == len(foo) - | ^^^^^^^^ PLR0124 -25 | -26 | # Non-errors. - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0133_comparison_of_constant.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0133_comparison_of_constant.py.snap deleted file mode 100644 index e3639c5785..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0133_comparison_of_constant.py.snap +++ /dev/null @@ -1,93 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -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 | -3 | if 100 == 100: # [comparison-of-constants] - | ^^^ PLR0133 -4 | pass - | - -comparison_of_constant.py:6:4: PLR0133 Two constants compared in a comparison, consider replacing `1 == 3` - | -4 | pass -5 | -6 | if 1 == 3: # [comparison-of-constants] - | ^ PLR0133 -7 | pass - | - -comparison_of_constant.py:9:4: PLR0133 Two constants compared in a comparison, consider replacing `1 != 3` - | - 7 | pass - 8 | - 9 | if 1 != 3: # [comparison-of-constants] - | ^ PLR0133 -10 | pass - | - -comparison_of_constant.py:13:4: PLR0133 Two constants compared in a comparison, consider replacing `4 == 3` - | -12 | x = 0 -13 | if 4 == 3 == x: # [comparison-of-constants] - | ^ PLR0133 -14 | pass - | - -comparison_of_constant.py:23:4: PLR0133 Two constants compared in a comparison, consider replacing `1 > 0` - | -21 | pass -22 | -23 | if 1 > 0: # [comparison-of-constants] - | ^ PLR0133 -24 | pass - | - -comparison_of_constant.py:29:4: PLR0133 Two constants compared in a comparison, consider replacing `1 >= 0` - | -27 | pass -28 | -29 | if 1 >= 0: # [comparison-of-constants] - | ^ PLR0133 -30 | pass - | - -comparison_of_constant.py:35:4: PLR0133 Two constants compared in a comparison, consider replacing `1 < 0` - | -33 | pass -34 | -35 | if 1 < 0: # [comparison-of-constants] - | ^ PLR0133 -36 | pass - | - -comparison_of_constant.py:41:4: PLR0133 Two constants compared in a comparison, consider replacing `1 <= 0` - | -39 | pass -40 | -41 | if 1 <= 0: # [comparison-of-constants] - | ^ PLR0133 -42 | pass - | - -comparison_of_constant.py:51:4: PLR0133 Two constants compared in a comparison, consider replacing `"hello" == ""` - | -49 | pass -50 | -51 | if "hello" == "": # [comparison-of-constants] - | ^^^^^^^ PLR0133 -52 | pass - | - -comparison_of_constant.py:58:4: PLR0133 Two constants compared in a comparison, consider replacing `True == False` - | -56 | pass -57 | -58 | if True == False: # [comparison-of-constants] - | ^^^^ PLR0133 -59 | pass - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0206_property_with_parameters.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0206_property_with_parameters.py.snap deleted file mode 100644 index 811ae56f67..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0206_property_with_parameters.py.snap +++ /dev/null @@ -1,29 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -property_with_parameters.py:7:9: PLR0206 Cannot have defined parameters for properties - | -5 | class Cls: -6 | @property -7 | def attribute(self, param, param1): # [property-with-parameters] - | ^^^^^^^^^ PLR0206 -8 | return param + param1 - | - -property_with_parameters.py:11:9: PLR0206 Cannot have defined parameters for properties - | -10 | @property -11 | def attribute_keyword_only(self, *, param, param1): # [property-with-parameters] - | ^^^^^^^^^^^^^^^^^^^^^^ PLR0206 -12 | return param + param1 - | - -property_with_parameters.py:15:9: PLR0206 Cannot have defined parameters for properties - | -14 | @property -15 | def attribute_positional_only(self, param, param1, /): # [property-with-parameters] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0206 -16 | return param + param1 - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0402_import_aliasing.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0402_import_aliasing.py.snap deleted file mode 100644 index 2a7894af14..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0402_import_aliasing.py.snap +++ /dev/null @@ -1,57 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -import_aliasing.py:9:8: PLR0402 [*] Use `from os import path` in lieu of alias - | - 7 | from collections import OrderedDict as OrderedDict # [useless-import-alias] - 8 | from collections import OrderedDict as o_dict - 9 | import os.path as path # [consider-using-from-import] - | ^^^^^^^^^^^^^^^ PLR0402 -10 | import os.path as p -11 | import foo.bar.foobar as foobar # [consider-using-from-import] - | - = help: Replace with `from os import path` - -ℹ Fix -6 6 | import collections as collections # [useless-import-alias] -7 7 | from collections import OrderedDict as OrderedDict # [useless-import-alias] -8 8 | from collections import OrderedDict as o_dict -9 |-import os.path as path # [consider-using-from-import] - 9 |+from os import path # [consider-using-from-import] -10 10 | import os.path as p -11 11 | import foo.bar.foobar as foobar # [consider-using-from-import] -12 12 | import foo.bar.foobar as foobar, sys # [consider-using-from-import] - -import_aliasing.py:11:8: PLR0402 [*] Use `from foo.bar import foobar` in lieu of alias - | - 9 | import os.path as path # [consider-using-from-import] -10 | import os.path as p -11 | import foo.bar.foobar as foobar # [consider-using-from-import] - | ^^^^^^^^^^^^^^^^^^^^^^^^ PLR0402 -12 | import foo.bar.foobar as foobar, sys # [consider-using-from-import] -13 | import os - | - = help: Replace with `from foo.bar import foobar` - -ℹ Fix -8 8 | from collections import OrderedDict as o_dict -9 9 | import os.path as path # [consider-using-from-import] -10 10 | import os.path as p -11 |-import foo.bar.foobar as foobar # [consider-using-from-import] - 11 |+from foo.bar import foobar # [consider-using-from-import] -12 12 | import foo.bar.foobar as foobar, sys # [consider-using-from-import] -13 13 | import os -14 14 | import os as OS - -import_aliasing.py:12:8: PLR0402 Use `from foo.bar import foobar` in lieu of alias - | -10 | import os.path as p -11 | import foo.bar.foobar as foobar # [consider-using-from-import] -12 | import foo.bar.foobar as foobar, sys # [consider-using-from-import] - | ^^^^^^^^^^^^^^^^^^^^^^^^ PLR0402 -13 | import os -14 | import os as OS - | - = help: Replace with `from foo.bar import foobar` - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0911_too_many_return_statements.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0911_too_many_return_statements.py.snap deleted file mode 100644 index 48c1a98034..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0911_too_many_return_statements.py.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -too_many_return_statements.py:4:5: PLR0911 Too many return statements (11 > 6) - | -2 | https://github.com/PyCQA/pylint/blob/69eca9b3f9856c3033957b769358803ee48e8e47/tests/functional/t/too/too_many_return_statements.py -3 | """ -4 | def stupid_function(arg): # [too-many-return-statements] - | ^^^^^^^^^^^^^^^ PLR0911 -5 | if arg == 1: -6 | return 1 - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0912_too_many_branches.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0912_too_many_branches.py.snap deleted file mode 100644 index d3d701a7f5..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0912_too_many_branches.py.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -too_many_branches.py:6:5: PLR0912 Too many branches (13 > 12) - | -4 | """ -5 | # pylint: disable=using-constant-test -6 | def wrong(): # [too-many-branches] - | ^^^^^ PLR0912 -7 | """ Has too many branches. """ -8 | if 1: - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0913_too_many_arguments.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0913_too_many_arguments.py.snap deleted file mode 100644 index e64ab51552..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0913_too_many_arguments.py.snap +++ /dev/null @@ -1,39 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -too_many_arguments.py:1:5: PLR0913 Too many arguments to function call (8 > 5) - | -1 | def f(x, y, z, t, u, v, w, r): # Too many arguments (8/5) - | ^ PLR0913 -2 | pass - | - -too_many_arguments.py:17:5: PLR0913 Too many arguments to function call (6 > 5) - | -17 | def f(x, y, z, u=1, v=1, r=1): # Too many arguments (6/5) - | ^ PLR0913 -18 | pass - | - -too_many_arguments.py:25:5: PLR0913 Too many arguments to function call (6 > 5) - | -25 | def f(x, y, z, /, u, v, w): # Too many arguments (6/5) - | ^ PLR0913 -26 | pass - | - -too_many_arguments.py:29:5: PLR0913 Too many arguments to function call (6 > 5) - | -29 | def f(x, y, z, *, u, v, w): # Too many arguments (6/5) - | ^ PLR0913 -30 | pass - | - -too_many_arguments.py:33:5: PLR0913 Too many arguments to function call (9 > 5) - | -33 | def f(x, y, z, a, b, c, *, u, v, w): # Too many arguments (9/5) - | ^ PLR0913 -34 | pass - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0915_too_many_statements.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0915_too_many_statements.py.snap deleted file mode 100644 index 9f64562901..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR0915_too_many_statements.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -too_many_statements.py:5:11: PLR0915 Too many statements (51 > 50) - | -5 | async def f(): # Too many statements (52/50) - | ^ PLR0915 -6 | print() -7 | print() - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1701_repeated_isinstance_calls.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1701_repeated_isinstance_calls.py.snap deleted file mode 100644 index 00f975c461..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1701_repeated_isinstance_calls.py.snap +++ /dev/null @@ -1,144 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -repeated_isinstance_calls.py:15:8: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[3], float | int)` - | -14 | # not merged -15 | if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True: # [consider-merging-isinstance] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 -16 | pass -17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] - | - = help: Replace with `isinstance(var[3], float | int)` - -ℹ Fix -12 12 | result = isinstance(var[2], (int, float)) -13 13 | -14 14 | # not merged -15 |- if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True: # [consider-merging-isinstance] - 15 |+ if isinstance(var[3], float | int): # [consider-merging-isinstance] -16 16 | pass -17 17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] -18 18 | - -repeated_isinstance_calls.py:17:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[4], float | int)` - | -15 | if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True: # [consider-merging-isinstance] -16 | pass -17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 -18 | -19 | result = isinstance(var[5], int) or True or isinstance(var[5], float) # [consider-merging-isinstance] - | - = help: Replace with `isinstance(var[4], float | int)` - -ℹ Fix -14 14 | # not merged -15 15 | if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True: # [consider-merging-isinstance] -16 16 | pass -17 |- result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] - 17 |+ result = isinstance(var[4], float | int) # [consider-merging-isinstance] -18 18 | -19 19 | result = isinstance(var[5], int) or True or isinstance(var[5], float) # [consider-merging-isinstance] -20 20 | - -repeated_isinstance_calls.py:19:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[5], float | int)` - | -17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] -18 | -19 | result = isinstance(var[5], int) or True or isinstance(var[5], float) # [consider-merging-isinstance] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 -20 | -21 | inferred_isinstance = isinstance - | - = help: Replace with `isinstance(var[5], float | int)` - -ℹ Fix -16 16 | pass -17 17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] -18 18 | -19 |- result = isinstance(var[5], int) or True or isinstance(var[5], float) # [consider-merging-isinstance] - 19 |+ result = isinstance(var[5], float | int) # [consider-merging-isinstance] -20 20 | -21 21 | inferred_isinstance = isinstance -22 22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] - -repeated_isinstance_calls.py:23:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[10], list | str)` - | -21 | inferred_isinstance = isinstance -22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] -23 | result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list) # [consider-merging-isinstance] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 -24 | result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float) # [consider-merging-isinstance] - | - = help: Replace with `isinstance(var[10], list | str)` - -ℹ Fix -20 20 | -21 21 | inferred_isinstance = isinstance -22 22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] -23 |- result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list) # [consider-merging-isinstance] - 23 |+ result = isinstance(var[10], list | str) # [consider-merging-isinstance] -24 24 | result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float) # [consider-merging-isinstance] -25 25 | -26 26 | result = isinstance(var[20]) - -repeated_isinstance_calls.py:24:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[11], float | int)` - | -22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] -23 | result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list) # [consider-merging-isinstance] -24 | result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float) # [consider-merging-isinstance] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 -25 | -26 | result = isinstance(var[20]) - | - = help: Replace with `isinstance(var[11], float | int)` - -ℹ Fix -21 21 | inferred_isinstance = isinstance -22 22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] -23 23 | result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list) # [consider-merging-isinstance] -24 |- result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float) # [consider-merging-isinstance] - 24 |+ result = isinstance(var[11], float | int) # [consider-merging-isinstance] -25 25 | -26 26 | result = isinstance(var[20]) -27 27 | result = isinstance() - -repeated_isinstance_calls.py:30:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[12], float | int | list)` - | -29 | # Combination merged and not merged -30 | result = isinstance(var[12], (int, float)) or isinstance(var[12], list) # [consider-merging-isinstance] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 -31 | -32 | # not merged but valid - | - = help: Replace with `isinstance(var[12], float | int | list)` - -ℹ Fix -27 27 | result = isinstance() -28 28 | -29 29 | # Combination merged and not merged -30 |- result = isinstance(var[12], (int, float)) or isinstance(var[12], list) # [consider-merging-isinstance] - 30 |+ result = isinstance(var[12], float | int | list) # [consider-merging-isinstance] -31 31 | -32 32 | # not merged but valid -33 33 | result = isinstance(var[5], int) and var[5] * 14 or isinstance(var[5], float) and var[5] * 14.4 - -repeated_isinstance_calls.py:42:3: PLR1701 [*] Merge `isinstance` calls: `isinstance(self.k, float | int)` - | -41 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722460483 -42 | if(isinstance(self.k, int)) or (isinstance(self.k, float)): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 -43 | ... - | - = help: Replace with `isinstance(self.k, float | int)` - -ℹ Fix -39 39 | -40 40 | -41 41 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722460483 -42 |-if(isinstance(self.k, int)) or (isinstance(self.k, float)): - 42 |+if isinstance(self.k, float | int): -43 43 | ... - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1711_useless_return.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1711_useless_return.py.snap deleted file mode 100644 index 9c4273b16a..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1711_useless_return.py.snap +++ /dev/null @@ -1,109 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -useless_return.py:6:5: PLR1711 [*] Useless `return` statement at end of function - | -4 | def print_python_version(): -5 | print(sys.version) -6 | return None # [useless-return] - | ^^^^^^^^^^^ PLR1711 - | - = help: Remove useless `return` statement - -ℹ Fix -3 3 | -4 4 | def print_python_version(): -5 5 | print(sys.version) -6 |- return None # [useless-return] -7 6 | -8 7 | -9 8 | def print_python_version(): - -useless_return.py:11:5: PLR1711 [*] Useless `return` statement at end of function - | - 9 | def print_python_version(): -10 | print(sys.version) -11 | return None # [useless-return] - | ^^^^^^^^^^^ PLR1711 - | - = help: Remove useless `return` statement - -ℹ Fix -8 8 | -9 9 | def print_python_version(): -10 10 | print(sys.version) -11 |- return None # [useless-return] -12 11 | -13 12 | -14 13 | def print_python_version(): - -useless_return.py:16:5: PLR1711 [*] Useless `return` statement at end of function - | -14 | def print_python_version(): -15 | print(sys.version) -16 | return None # [useless-return] - | ^^^^^^^^^^^ PLR1711 - | - = help: Remove useless `return` statement - -ℹ Fix -13 13 | -14 14 | def print_python_version(): -15 15 | print(sys.version) -16 |- return None # [useless-return] -17 16 | -18 17 | -19 18 | class SomeClass: - -useless_return.py:22:9: PLR1711 [*] Useless `return` statement at end of function - | -20 | def print_python_version(self): -21 | print(sys.version) -22 | return None # [useless-return] - | ^^^^^^^^^^^ PLR1711 - | - = help: Remove useless `return` statement - -ℹ Fix -19 19 | class SomeClass: -20 20 | def print_python_version(self): -21 21 | print(sys.version) -22 |- return None # [useless-return] -23 22 | -24 23 | -25 24 | def print_python_version(): - -useless_return.py:50:5: PLR1711 [*] Useless `return` statement at end of function - | -48 | """This function returns None.""" -49 | print(sys.version) -50 | return None # [useless-return] - | ^^^^^^^^^^^ PLR1711 - | - = help: Remove useless `return` statement - -ℹ Fix -47 47 | def print_python_version(): -48 48 | """This function returns None.""" -49 49 | print(sys.version) -50 |- return None # [useless-return] -51 50 | -52 51 | -53 52 | class BaseCache: - -useless_return.py:60:9: PLR1711 [*] Useless `return` statement at end of function - | -58 | def get(self, key: str) -> None: -59 | print(f"{key} not found") -60 | return None - | ^^^^^^^^^^^ PLR1711 - | - = help: Remove useless `return` statement - -ℹ Fix -57 57 | -58 58 | def get(self, key: str) -> None: -59 59 | print(f"{key} not found") -60 |- return None - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap deleted file mode 100644 index 0b5c497221..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap +++ /dev/null @@ -1,143 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -repeated_equality_comparison.py:2:1: PLR1714 Consider merging multiple comparisons: `foo in ("a", "b")`. Use a `set` if the elements are hashable. - | -1 | # Errors. -2 | foo == "a" or foo == "b" - | ^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -3 | -4 | foo != "a" and foo != "b" - | - -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 | -4 | foo != "a" and foo != "b" - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -5 | -6 | foo == "a" or foo == "b" or foo == "c" - | - -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 | -6 | foo == "a" or foo == "b" or foo == "c" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -7 | -8 | foo != "a" and foo != "b" and foo != "c" - | - -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 | - 8 | foo != "a" and foo != "b" and foo != "c" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 - 9 | -10 | foo == a or foo == "b" or foo == 3 # Mixed types. - | - -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 | -10 | foo == a or foo == "b" or foo == 3 # Mixed types. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -11 | -12 | "a" == foo or "b" == foo or "c" == foo - | - -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 | -12 | "a" == foo or "b" == foo or "c" == foo - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -13 | -14 | "a" != foo and "b" != foo and "c" != foo - | - -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 | -14 | "a" != foo and "b" != foo and "c" != foo - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -15 | -16 | "a" == foo or foo == "b" or "c" == foo - | - -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 | -16 | "a" == foo or foo == "b" or "c" == foo - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -17 | -18 | foo == bar or baz == foo or qux == foo - | - -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 | -18 | foo == bar or baz == foo or qux == foo - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -19 | -20 | foo == "a" or "b" == foo or foo == "c" - | - -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 | -20 | foo == "a" or "b" == foo or foo == "c" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -21 | -22 | foo != "a" and "b" != foo and foo != "c" - | - -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 | -22 | foo != "a" and "b" != foo and foo != "c" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -23 | -24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets - | - -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 | -24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -25 | -26 | foo.bar == "a" or foo.bar == "b" # Attributes. - | - -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 | -24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -25 | -26 | foo.bar == "a" or foo.bar == "b" # Attributes. - | - -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 | -26 | foo.bar == "a" or foo.bar == "b" # Attributes. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 -27 | -28 | # OK - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap deleted file mode 100644 index 620f560648..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap +++ /dev/null @@ -1,77 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -sys_exit_alias_0.py:1:1: PLR1722 [*] Use `sys.exit()` instead of `exit` - | -1 | exit(0) - | ^^^^ PLR1722 -2 | quit(0) - | - = help: Replace `exit` with `sys.exit()` - -ℹ Suggested fix -1 |-exit(0) - 1 |+import sys - 2 |+sys.exit(0) -2 3 | quit(0) -3 4 | -4 5 | - -sys_exit_alias_0.py:2:1: PLR1722 [*] Use `sys.exit()` instead of `quit` - | -1 | exit(0) -2 | quit(0) - | ^^^^ PLR1722 - | - = help: Replace `quit` with `sys.exit()` - -ℹ Suggested fix - 1 |+import sys -1 2 | exit(0) -2 |-quit(0) - 3 |+sys.exit(0) -3 4 | -4 5 | -5 6 | def main(): - -sys_exit_alias_0.py:6:5: PLR1722 [*] Use `sys.exit()` instead of `exit` - | -5 | def main(): -6 | exit(2) - | ^^^^ PLR1722 -7 | quit(2) - | - = help: Replace `exit` with `sys.exit()` - -ℹ Suggested fix - 1 |+import sys -1 2 | exit(0) -2 3 | quit(0) -3 4 | -4 5 | -5 6 | def main(): -6 |- exit(2) - 7 |+ sys.exit(2) -7 8 | quit(2) - -sys_exit_alias_0.py:7:5: PLR1722 [*] Use `sys.exit()` instead of `quit` - | -5 | def main(): -6 | exit(2) -7 | quit(2) - | ^^^^ PLR1722 - | - = help: Replace `quit` with `sys.exit()` - -ℹ Suggested fix - 1 |+import sys -1 2 | exit(0) -2 3 | quit(0) -3 4 | -4 5 | -5 6 | def main(): -6 7 | exit(2) -7 |- quit(2) - 8 |+ sys.exit(2) - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap deleted file mode 100644 index 0a57af4be9..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap +++ /dev/null @@ -1,97 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -sys_exit_alias_1.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` - | -1 | import sys -2 | -3 | exit(0) - | ^^^^ PLR1722 -4 | quit(0) - | - = help: Replace `exit` with `sys.exit()` - -ℹ Suggested fix -1 1 | import sys -2 2 | -3 |-exit(0) - 3 |+sys.exit(0) -4 4 | quit(0) -5 5 | -6 6 | - -sys_exit_alias_1.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` - | -3 | exit(0) -4 | quit(0) - | ^^^^ PLR1722 - | - = help: Replace `quit` with `sys.exit()` - -ℹ Suggested fix -1 1 | import sys -2 2 | -3 3 | exit(0) -4 |-quit(0) - 4 |+sys.exit(0) -5 5 | -6 6 | -7 7 | def main(): - -sys_exit_alias_1.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` - | -7 | def main(): -8 | exit(1) - | ^^^^ PLR1722 -9 | quit(1) - | - = help: Replace `exit` with `sys.exit()` - -ℹ Suggested fix -5 5 | -6 6 | -7 7 | def main(): -8 |- exit(1) - 8 |+ sys.exit(1) -9 9 | quit(1) -10 10 | -11 11 | - -sys_exit_alias_1.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` - | -7 | def main(): -8 | exit(1) -9 | quit(1) - | ^^^^ PLR1722 - | - = help: Replace `quit` with `sys.exit()` - -ℹ Suggested fix -6 6 | -7 7 | def main(): -8 8 | exit(1) -9 |- quit(1) - 9 |+ sys.exit(1) -10 10 | -11 11 | -12 12 | def main(): - -sys_exit_alias_1.py:15:5: PLR1722 Use `sys.exit()` instead of `exit` - | -13 | sys = 1 -14 | -15 | exit(1) - | ^^^^ PLR1722 -16 | quit(1) - | - = help: Replace `exit` with `sys.exit()` - -sys_exit_alias_1.py:16:5: PLR1722 Use `sys.exit()` instead of `quit` - | -15 | exit(1) -16 | quit(1) - | ^^^^ PLR1722 - | - = help: Replace `quit` with `sys.exit()` - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_10.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_10.py.snap deleted file mode 100644 index 914414fade..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_10.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -sys_exit_alias_10.py:8:5: PLR1722 Use `sys.exit()` instead of `exit` - | -7 | def main(): -8 | exit(0) - | ^^^^ PLR1722 - | - = help: Replace `exit` with `sys.exit()` - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_11.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_11.py.snap deleted file mode 100644 index ef9fc255fc..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_11.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -sys_exit_alias_11.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` - | -1 | from sys import * -2 | -3 | exit(0) - | ^^^^ PLR1722 - | - = help: Replace `exit` with `sys.exit()` - -ℹ Suggested fix -1 1 | from sys import * - 2 |+import sys -2 3 | -3 |-exit(0) - 4 |+sys.exit(0) - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap deleted file mode 100644 index 7fe507657c..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap +++ /dev/null @@ -1,74 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -sys_exit_alias_2.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` - | -1 | import sys as sys2 -2 | -3 | exit(0) - | ^^^^ PLR1722 -4 | quit(0) - | - = help: Replace `exit` with `sys.exit()` - -ℹ Suggested fix -1 1 | import sys as sys2 -2 2 | -3 |-exit(0) - 3 |+sys2.exit(0) -4 4 | quit(0) -5 5 | -6 6 | - -sys_exit_alias_2.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` - | -3 | exit(0) -4 | quit(0) - | ^^^^ PLR1722 - | - = help: Replace `quit` with `sys.exit()` - -ℹ Suggested fix -1 1 | import sys as sys2 -2 2 | -3 3 | exit(0) -4 |-quit(0) - 4 |+sys2.exit(0) -5 5 | -6 6 | -7 7 | def main(): - -sys_exit_alias_2.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` - | -7 | def main(): -8 | exit(1) - | ^^^^ PLR1722 -9 | quit(1) - | - = help: Replace `exit` with `sys.exit()` - -ℹ Suggested fix -5 5 | -6 6 | -7 7 | def main(): -8 |- exit(1) - 8 |+ sys2.exit(1) -9 9 | quit(1) - -sys_exit_alias_2.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` - | -7 | def main(): -8 | exit(1) -9 | quit(1) - | ^^^^ PLR1722 - | - = help: Replace `quit` with `sys.exit()` - -ℹ Suggested fix -6 6 | -7 7 | def main(): -8 8 | exit(1) -9 |- quit(1) - 9 |+ sys2.exit(1) - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap deleted file mode 100644 index c969feedae..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap +++ /dev/null @@ -1,49 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -sys_exit_alias_3.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` - | -3 | exit(0) -4 | quit(0) - | ^^^^ PLR1722 - | - = help: Replace `quit` with `sys.exit()` - -ℹ Suggested fix -1 1 | from sys import exit -2 2 | -3 3 | exit(0) -4 |-quit(0) - 4 |+exit(0) -5 5 | -6 6 | -7 7 | def main(): - -sys_exit_alias_3.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` - | -7 | def main(): -8 | exit(1) -9 | quit(1) - | ^^^^ PLR1722 - | - = help: Replace `quit` with `sys.exit()` - -ℹ Suggested fix -6 6 | -7 7 | def main(): -8 8 | exit(1) -9 |- quit(1) - 9 |+ exit(1) -10 10 | -11 11 | -12 12 | def main(): - -sys_exit_alias_3.py:16:5: PLR1722 Use `sys.exit()` instead of `quit` - | -15 | exit(1) -16 | quit(1) - | ^^^^ PLR1722 - | - = help: Replace `quit` with `sys.exit()` - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap deleted file mode 100644 index d70b29f16d..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap +++ /dev/null @@ -1,74 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -sys_exit_alias_4.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` - | -1 | from sys import exit as exit2 -2 | -3 | exit(0) - | ^^^^ PLR1722 -4 | quit(0) - | - = help: Replace `exit` with `sys.exit()` - -ℹ Suggested fix -1 1 | from sys import exit as exit2 -2 2 | -3 |-exit(0) - 3 |+exit2(0) -4 4 | quit(0) -5 5 | -6 6 | - -sys_exit_alias_4.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` - | -3 | exit(0) -4 | quit(0) - | ^^^^ PLR1722 - | - = help: Replace `quit` with `sys.exit()` - -ℹ Suggested fix -1 1 | from sys import exit as exit2 -2 2 | -3 3 | exit(0) -4 |-quit(0) - 4 |+exit2(0) -5 5 | -6 6 | -7 7 | def main(): - -sys_exit_alias_4.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` - | -7 | def main(): -8 | exit(1) - | ^^^^ PLR1722 -9 | quit(1) - | - = help: Replace `exit` with `sys.exit()` - -ℹ Suggested fix -5 5 | -6 6 | -7 7 | def main(): -8 |- exit(1) - 8 |+ exit2(1) -9 9 | quit(1) - -sys_exit_alias_4.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` - | -7 | def main(): -8 | exit(1) -9 | quit(1) - | ^^^^ PLR1722 - | - = help: Replace `quit` with `sys.exit()` - -ℹ Suggested fix -6 6 | -7 7 | def main(): -8 8 | exit(1) -9 |- quit(1) - 9 |+ exit2(1) - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_5.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_5.py.snap deleted file mode 100644 index 8bc6c5f889..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_5.py.snap +++ /dev/null @@ -1,87 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -sys_exit_alias_5.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` - | -1 | from sys import * -2 | -3 | exit(0) - | ^^^^ PLR1722 -4 | quit(0) - | - = help: Replace `exit` with `sys.exit()` - -ℹ Suggested fix -1 1 | from sys import * - 2 |+import sys -2 3 | -3 |-exit(0) - 4 |+sys.exit(0) -4 5 | quit(0) -5 6 | -6 7 | - -sys_exit_alias_5.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` - | -3 | exit(0) -4 | quit(0) - | ^^^^ PLR1722 - | - = help: Replace `quit` with `sys.exit()` - -ℹ Suggested fix -1 1 | from sys import * - 2 |+import sys -2 3 | -3 4 | exit(0) -4 |-quit(0) - 5 |+sys.exit(0) -5 6 | -6 7 | -7 8 | def main(): - -sys_exit_alias_5.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` - | -7 | def main(): -8 | exit(1) - | ^^^^ PLR1722 -9 | quit(1) - | - = help: Replace `exit` with `sys.exit()` - -ℹ Suggested fix -1 1 | from sys import * - 2 |+import sys -2 3 | -3 4 | exit(0) -4 5 | quit(0) -5 6 | -6 7 | -7 8 | def main(): -8 |- exit(1) - 9 |+ sys.exit(1) -9 10 | quit(1) - -sys_exit_alias_5.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` - | -7 | def main(): -8 | exit(1) -9 | quit(1) - | ^^^^ PLR1722 - | - = help: Replace `quit` with `sys.exit()` - -ℹ Suggested fix -1 1 | from sys import * - 2 |+import sys -2 3 | -3 4 | exit(0) -4 5 | quit(0) --------------------------------------------------------------------------------- -6 7 | -7 8 | def main(): -8 9 | exit(1) -9 |- quit(1) - 10 |+ sys.exit(1) - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap deleted file mode 100644 index 8f05fd18e2..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap +++ /dev/null @@ -1,37 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -sys_exit_alias_6.py:1:1: PLR1722 [*] Use `sys.exit()` instead of `exit` - | -1 | exit(0) - | ^^^^ PLR1722 -2 | quit(0) - | - = help: Replace `exit` with `sys.exit()` - -ℹ Suggested fix -1 |-exit(0) - 1 |+import sys - 2 |+sys.exit(0) -2 3 | quit(0) -3 4 | -4 5 | - -sys_exit_alias_6.py:2:1: PLR1722 [*] Use `sys.exit()` instead of `quit` - | -1 | exit(0) -2 | quit(0) - | ^^^^ PLR1722 - | - = help: Replace `quit` with `sys.exit()` - -ℹ Suggested fix - 1 |+import sys -1 2 | exit(0) -2 |-quit(0) - 3 |+sys.exit(0) -3 4 | -4 5 | -5 6 | def exit(e): - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap deleted file mode 100644 index 2ddf6a8a53..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -sys_exit_alias_7.py:2:5: PLR1722 [*] Use `sys.exit()` instead of `exit` - | -1 | def main(): -2 | exit(0) - | ^^^^ PLR1722 - | - = help: Replace `exit` with `sys.exit()` - -ℹ Suggested fix - 1 |+import sys -1 2 | def main(): -2 |- exit(0) - 3 |+ sys.exit(0) -3 4 | -4 5 | -5 6 | import functools - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap deleted file mode 100644 index 861d05a93f..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -sys_exit_alias_8.py:5:5: PLR1722 [*] Use `sys.exit()` instead of `exit` - | -4 | def main(): -5 | exit(0) - | ^^^^ PLR1722 - | - = help: Replace `exit` with `sys.exit()` - -ℹ Suggested fix -1 |-from sys import argv - 1 |+from sys import argv, exit -2 2 | -3 3 | -4 4 | def main(): - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap deleted file mode 100644 index a6be8caed6..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -sys_exit_alias_9.py:2:5: PLR1722 [*] Use `sys.exit()` instead of `exit` - | -1 | def main(): -2 | exit(0) - | ^^^^ PLR1722 - | - = help: Replace `exit` with `sys.exit()` - -ℹ Suggested fix - 1 |+import sys -1 2 | def main(): -2 |- exit(0) - 3 |+ sys.exit(0) -3 4 | -4 5 | -5 6 | from sys import argv - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR2004_magic_value_comparison.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR2004_magic_value_comparison.py.snap deleted file mode 100644 index 0959259b8c..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR2004_magic_value_comparison.py.snap +++ /dev/null @@ -1,49 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -magic_value_comparison.py:5:4: PLR2004 Magic value used in comparison, consider replacing 10 with a constant variable - | -3 | user_input = 10 -4 | -5 | if 10 > user_input: # [magic-value-comparison] - | ^^ PLR2004 -6 | pass - | - -magic_value_comparison.py:38:12: PLR2004 Magic value used in comparison, consider replacing 2 with a constant variable - | -36 | pass -37 | -38 | if argc != 2: # [magic-value-comparison] - | ^ PLR2004 -39 | pass - | - -magic_value_comparison.py:41:12: PLR2004 Magic value used in comparison, consider replacing -2 with a constant variable - | -39 | pass -40 | -41 | if argc != -2: # [magic-value-comparison] - | ^^ PLR2004 -42 | pass - | - -magic_value_comparison.py:44:12: PLR2004 Magic value used in comparison, consider replacing +2 with a constant variable - | -42 | pass -43 | -44 | if argc != +2: # [magic-value-comparison] - | ^^ PLR2004 -45 | pass - | - -magic_value_comparison.py:65:21: PLR2004 Magic value used in comparison, consider replacing 3.141592653589793 with a constant variable - | -63 | pi_estimation = 3.14 -64 | -65 | if pi_estimation == 3.141592653589793238: # [magic-value-comparison] - | ^^^^^^^^^^^^^^^^^^^^ PLR2004 -66 | pass - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR5501_collapsible_else_if.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR5501_collapsible_else_if.py.snap deleted file mode 100644 index cfb1bb48fe..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR5501_collapsible_else_if.py.snap +++ /dev/null @@ -1,39 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -collapsible_else_if.py:37:5: PLR5501 Use `elif` instead of `else` then `if`, to reduce indentation - | -35 | if 1: -36 | pass -37 | else: - | _____^ -38 | | if 2: - | |________^ PLR5501 -39 | pass - | - -collapsible_else_if.py:45:5: PLR5501 Use `elif` instead of `else` then `if`, to reduce indentation - | -43 | if 1: -44 | pass -45 | else: - | _____^ -46 | | if 2: - | |________^ PLR5501 -47 | pass -48 | else: - | - -collapsible_else_if.py:58:5: PLR5501 Use `elif` instead of `else` then `if`, to reduce indentation - | -56 | elif True: -57 | print(2) -58 | else: - | _____^ -59 | | if True: - | |________^ PLR5501 -60 | print(3) -61 | else: - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR6301_no_self_use.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR6301_no_self_use.py.snap deleted file mode 100644 index b37e142863..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR6301_no_self_use.py.snap +++ /dev/null @@ -1,39 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -no_self_use.py:5:28: PLR6301 Method `developer_greeting` could be a function or static method - | -4 | class Person: -5 | def developer_greeting(self, name): # [no-self-use] - | ^^^^ PLR6301 -6 | print(f"Greetings {name}!") - | - -no_self_use.py:8:20: PLR6301 Method `greeting_1` could be a function or static method - | -6 | print(f"Greetings {name}!") -7 | -8 | def greeting_1(self): # [no-self-use] - | ^^^^ PLR6301 -9 | print("Hello!") - | - -no_self_use.py:11:20: PLR6301 Method `greeting_2` could be a function or static method - | - 9 | print("Hello!") -10 | -11 | def greeting_2(self): # [no-self-use] - | ^^^^ PLR6301 -12 | print("Hi!") - | - -no_self_use.py:55:25: PLR6301 Method `abstract_method` could be a function or static method - | -53 | class Sub(Base): -54 | @override -55 | def abstract_method(self): - | ^^^^ PLR6301 -56 | print("concret method") - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0120_useless_else_on_loop.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0120_useless_else_on_loop.py.snap deleted file mode 100644 index 9c1dbf2e2c..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0120_useless_else_on_loop.py.snap +++ /dev/null @@ -1,72 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -useless_else_on_loop.py:9:5: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it - | - 7 | if i % 2: - 8 | return i - 9 | else: # [useless-else-on-loop] - | ^^^^ PLW0120 -10 | print("math is broken") -11 | return None - | - -useless_else_on_loop.py:18:5: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it - | -16 | while True: -17 | return 1 -18 | else: # [useless-else-on-loop] - | ^^^^ PLW0120 -19 | print("math is broken") -20 | return None - | - -useless_else_on_loop.py:30:1: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it - | -28 | break -29 | -30 | else: # [useless-else-on-loop] - | ^^^^ PLW0120 -31 | print("or else!") - | - -useless_else_on_loop.py:37:1: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it - | -35 | while False: -36 | break -37 | else: # [useless-else-on-loop] - | ^^^^ PLW0120 -38 | print("or else!") - | - -useless_else_on_loop.py:42:1: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it - | -40 | for j in range(10): -41 | pass -42 | else: # [useless-else-on-loop] - | ^^^^ PLW0120 -43 | print("fat chance") -44 | for j in range(10): - | - -useless_else_on_loop.py:88:5: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it - | -86 | else: -87 | print("all right") -88 | else: # [useless-else-on-loop] - | ^^^^ PLW0120 -89 | return True -90 | return False - | - -useless_else_on_loop.py:98:9: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it - | - 96 | for _ in range(3): - 97 | pass - 98 | else: - | ^^^^ PLW0120 - 99 | if 1 < 2: # pylint: disable=comparison-of-constants -100 | break - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0127_self_assigning_variable.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0127_self_assigning_variable.py.snap deleted file mode 100644 index 331144501f..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0127_self_assigning_variable.py.snap +++ /dev/null @@ -1,362 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -self_assigning_variable.py:6:1: PLW0127 Self-assignment of variable `foo` - | -5 | # Errors. -6 | foo = foo - | ^^^ PLW0127 -7 | bar = bar -8 | foo, bar = foo, bar - | - -self_assigning_variable.py:7:1: PLW0127 Self-assignment of variable `bar` - | -5 | # Errors. -6 | foo = foo -7 | bar = bar - | ^^^ PLW0127 -8 | foo, bar = foo, bar -9 | bar, foo = bar, foo - | - -self_assigning_variable.py:8:1: PLW0127 Self-assignment of variable `foo` - | - 6 | foo = foo - 7 | bar = bar - 8 | foo, bar = foo, bar - | ^^^ PLW0127 - 9 | bar, foo = bar, foo -10 | (foo, bar) = (foo, bar) - | - -self_assigning_variable.py:8:6: PLW0127 Self-assignment of variable `bar` - | - 6 | foo = foo - 7 | bar = bar - 8 | foo, bar = foo, bar - | ^^^ PLW0127 - 9 | bar, foo = bar, foo -10 | (foo, bar) = (foo, bar) - | - -self_assigning_variable.py:9:1: PLW0127 Self-assignment of variable `bar` - | - 7 | bar = bar - 8 | foo, bar = foo, bar - 9 | bar, foo = bar, foo - | ^^^ PLW0127 -10 | (foo, bar) = (foo, bar) -11 | (bar, foo) = (bar, foo) - | - -self_assigning_variable.py:9:6: PLW0127 Self-assignment of variable `foo` - | - 7 | bar = bar - 8 | foo, bar = foo, bar - 9 | bar, foo = bar, foo - | ^^^ PLW0127 -10 | (foo, bar) = (foo, bar) -11 | (bar, foo) = (bar, foo) - | - -self_assigning_variable.py:10:2: PLW0127 Self-assignment of variable `foo` - | - 8 | foo, bar = foo, bar - 9 | bar, foo = bar, foo -10 | (foo, bar) = (foo, bar) - | ^^^ PLW0127 -11 | (bar, foo) = (bar, foo) -12 | foo, (bar, baz) = foo, (bar, baz) - | - -self_assigning_variable.py:10:7: PLW0127 Self-assignment of variable `bar` - | - 8 | foo, bar = foo, bar - 9 | bar, foo = bar, foo -10 | (foo, bar) = (foo, bar) - | ^^^ PLW0127 -11 | (bar, foo) = (bar, foo) -12 | foo, (bar, baz) = foo, (bar, baz) - | - -self_assigning_variable.py:11:2: PLW0127 Self-assignment of variable `bar` - | - 9 | bar, foo = bar, foo -10 | (foo, bar) = (foo, bar) -11 | (bar, foo) = (bar, foo) - | ^^^ PLW0127 -12 | foo, (bar, baz) = foo, (bar, baz) -13 | bar, (foo, baz) = bar, (foo, baz) - | - -self_assigning_variable.py:11:7: PLW0127 Self-assignment of variable `foo` - | - 9 | bar, foo = bar, foo -10 | (foo, bar) = (foo, bar) -11 | (bar, foo) = (bar, foo) - | ^^^ PLW0127 -12 | foo, (bar, baz) = foo, (bar, baz) -13 | bar, (foo, baz) = bar, (foo, baz) - | - -self_assigning_variable.py:12:1: PLW0127 Self-assignment of variable `foo` - | -10 | (foo, bar) = (foo, bar) -11 | (bar, foo) = (bar, foo) -12 | foo, (bar, baz) = foo, (bar, baz) - | ^^^ PLW0127 -13 | bar, (foo, baz) = bar, (foo, baz) -14 | (foo, bar), baz = (foo, bar), baz - | - -self_assigning_variable.py:12:7: PLW0127 Self-assignment of variable `bar` - | -10 | (foo, bar) = (foo, bar) -11 | (bar, foo) = (bar, foo) -12 | foo, (bar, baz) = foo, (bar, baz) - | ^^^ PLW0127 -13 | bar, (foo, baz) = bar, (foo, baz) -14 | (foo, bar), baz = (foo, bar), baz - | - -self_assigning_variable.py:12:12: PLW0127 Self-assignment of variable `baz` - | -10 | (foo, bar) = (foo, bar) -11 | (bar, foo) = (bar, foo) -12 | foo, (bar, baz) = foo, (bar, baz) - | ^^^ PLW0127 -13 | bar, (foo, baz) = bar, (foo, baz) -14 | (foo, bar), baz = (foo, bar), baz - | - -self_assigning_variable.py:13:1: PLW0127 Self-assignment of variable `bar` - | -11 | (bar, foo) = (bar, foo) -12 | foo, (bar, baz) = foo, (bar, baz) -13 | bar, (foo, baz) = bar, (foo, baz) - | ^^^ PLW0127 -14 | (foo, bar), baz = (foo, bar), baz -15 | (foo, (bar, baz)) = (foo, (bar, baz)) - | - -self_assigning_variable.py:13:7: PLW0127 Self-assignment of variable `foo` - | -11 | (bar, foo) = (bar, foo) -12 | foo, (bar, baz) = foo, (bar, baz) -13 | bar, (foo, baz) = bar, (foo, baz) - | ^^^ PLW0127 -14 | (foo, bar), baz = (foo, bar), baz -15 | (foo, (bar, baz)) = (foo, (bar, baz)) - | - -self_assigning_variable.py:13:12: PLW0127 Self-assignment of variable `baz` - | -11 | (bar, foo) = (bar, foo) -12 | foo, (bar, baz) = foo, (bar, baz) -13 | bar, (foo, baz) = bar, (foo, baz) - | ^^^ PLW0127 -14 | (foo, bar), baz = (foo, bar), baz -15 | (foo, (bar, baz)) = (foo, (bar, baz)) - | - -self_assigning_variable.py:14:2: PLW0127 Self-assignment of variable `foo` - | -12 | foo, (bar, baz) = foo, (bar, baz) -13 | bar, (foo, baz) = bar, (foo, baz) -14 | (foo, bar), baz = (foo, bar), baz - | ^^^ PLW0127 -15 | (foo, (bar, baz)) = (foo, (bar, baz)) -16 | foo, bar = foo, 1 - | - -self_assigning_variable.py:14:7: PLW0127 Self-assignment of variable `bar` - | -12 | foo, (bar, baz) = foo, (bar, baz) -13 | bar, (foo, baz) = bar, (foo, baz) -14 | (foo, bar), baz = (foo, bar), baz - | ^^^ PLW0127 -15 | (foo, (bar, baz)) = (foo, (bar, baz)) -16 | foo, bar = foo, 1 - | - -self_assigning_variable.py:14:13: PLW0127 Self-assignment of variable `baz` - | -12 | foo, (bar, baz) = foo, (bar, baz) -13 | bar, (foo, baz) = bar, (foo, baz) -14 | (foo, bar), baz = (foo, bar), baz - | ^^^ PLW0127 -15 | (foo, (bar, baz)) = (foo, (bar, baz)) -16 | foo, bar = foo, 1 - | - -self_assigning_variable.py:15:2: PLW0127 Self-assignment of variable `foo` - | -13 | bar, (foo, baz) = bar, (foo, baz) -14 | (foo, bar), baz = (foo, bar), baz -15 | (foo, (bar, baz)) = (foo, (bar, baz)) - | ^^^ PLW0127 -16 | foo, bar = foo, 1 -17 | bar, foo = bar, 1 - | - -self_assigning_variable.py:15:8: PLW0127 Self-assignment of variable `bar` - | -13 | bar, (foo, baz) = bar, (foo, baz) -14 | (foo, bar), baz = (foo, bar), baz -15 | (foo, (bar, baz)) = (foo, (bar, baz)) - | ^^^ PLW0127 -16 | foo, bar = foo, 1 -17 | bar, foo = bar, 1 - | - -self_assigning_variable.py:15:13: PLW0127 Self-assignment of variable `baz` - | -13 | bar, (foo, baz) = bar, (foo, baz) -14 | (foo, bar), baz = (foo, bar), baz -15 | (foo, (bar, baz)) = (foo, (bar, baz)) - | ^^^ PLW0127 -16 | foo, bar = foo, 1 -17 | bar, foo = bar, 1 - | - -self_assigning_variable.py:16:1: PLW0127 Self-assignment of variable `foo` - | -14 | (foo, bar), baz = (foo, bar), baz -15 | (foo, (bar, baz)) = (foo, (bar, baz)) -16 | foo, bar = foo, 1 - | ^^^ PLW0127 -17 | bar, foo = bar, 1 -18 | (foo, bar) = (foo, 1) - | - -self_assigning_variable.py:17:1: PLW0127 Self-assignment of variable `bar` - | -15 | (foo, (bar, baz)) = (foo, (bar, baz)) -16 | foo, bar = foo, 1 -17 | bar, foo = bar, 1 - | ^^^ PLW0127 -18 | (foo, bar) = (foo, 1) -19 | (bar, foo) = (bar, 1) - | - -self_assigning_variable.py:18:2: PLW0127 Self-assignment of variable `foo` - | -16 | foo, bar = foo, 1 -17 | bar, foo = bar, 1 -18 | (foo, bar) = (foo, 1) - | ^^^ PLW0127 -19 | (bar, foo) = (bar, 1) -20 | foo, (bar, baz) = foo, (bar, 1) - | - -self_assigning_variable.py:19:2: PLW0127 Self-assignment of variable `bar` - | -17 | bar, foo = bar, 1 -18 | (foo, bar) = (foo, 1) -19 | (bar, foo) = (bar, 1) - | ^^^ PLW0127 -20 | foo, (bar, baz) = foo, (bar, 1) -21 | bar, (foo, baz) = bar, (foo, 1) - | - -self_assigning_variable.py:20:1: PLW0127 Self-assignment of variable `foo` - | -18 | (foo, bar) = (foo, 1) -19 | (bar, foo) = (bar, 1) -20 | foo, (bar, baz) = foo, (bar, 1) - | ^^^ PLW0127 -21 | bar, (foo, baz) = bar, (foo, 1) -22 | (foo, bar), baz = (foo, bar), 1 - | - -self_assigning_variable.py:20:7: PLW0127 Self-assignment of variable `bar` - | -18 | (foo, bar) = (foo, 1) -19 | (bar, foo) = (bar, 1) -20 | foo, (bar, baz) = foo, (bar, 1) - | ^^^ PLW0127 -21 | bar, (foo, baz) = bar, (foo, 1) -22 | (foo, bar), baz = (foo, bar), 1 - | - -self_assigning_variable.py:21:1: PLW0127 Self-assignment of variable `bar` - | -19 | (bar, foo) = (bar, 1) -20 | foo, (bar, baz) = foo, (bar, 1) -21 | bar, (foo, baz) = bar, (foo, 1) - | ^^^ PLW0127 -22 | (foo, bar), baz = (foo, bar), 1 -23 | (foo, (bar, baz)) = (foo, (bar, 1)) - | - -self_assigning_variable.py:21:7: PLW0127 Self-assignment of variable `foo` - | -19 | (bar, foo) = (bar, 1) -20 | foo, (bar, baz) = foo, (bar, 1) -21 | bar, (foo, baz) = bar, (foo, 1) - | ^^^ PLW0127 -22 | (foo, bar), baz = (foo, bar), 1 -23 | (foo, (bar, baz)) = (foo, (bar, 1)) - | - -self_assigning_variable.py:22:2: PLW0127 Self-assignment of variable `foo` - | -20 | foo, (bar, baz) = foo, (bar, 1) -21 | bar, (foo, baz) = bar, (foo, 1) -22 | (foo, bar), baz = (foo, bar), 1 - | ^^^ PLW0127 -23 | (foo, (bar, baz)) = (foo, (bar, 1)) -24 | foo: int = foo - | - -self_assigning_variable.py:22:7: PLW0127 Self-assignment of variable `bar` - | -20 | foo, (bar, baz) = foo, (bar, 1) -21 | bar, (foo, baz) = bar, (foo, 1) -22 | (foo, bar), baz = (foo, bar), 1 - | ^^^ PLW0127 -23 | (foo, (bar, baz)) = (foo, (bar, 1)) -24 | foo: int = foo - | - -self_assigning_variable.py:23:2: PLW0127 Self-assignment of variable `foo` - | -21 | bar, (foo, baz) = bar, (foo, 1) -22 | (foo, bar), baz = (foo, bar), 1 -23 | (foo, (bar, baz)) = (foo, (bar, 1)) - | ^^^ PLW0127 -24 | foo: int = foo -25 | bar: int = bar - | - -self_assigning_variable.py:23:8: PLW0127 Self-assignment of variable `bar` - | -21 | bar, (foo, baz) = bar, (foo, 1) -22 | (foo, bar), baz = (foo, bar), 1 -23 | (foo, (bar, baz)) = (foo, (bar, 1)) - | ^^^ PLW0127 -24 | foo: int = foo -25 | bar: int = bar - | - -self_assigning_variable.py:24:1: PLW0127 Self-assignment of variable `foo` - | -22 | (foo, bar), baz = (foo, bar), 1 -23 | (foo, (bar, baz)) = (foo, (bar, 1)) -24 | foo: int = foo - | ^^^ PLW0127 -25 | bar: int = bar - | - -self_assigning_variable.py:25:1: PLW0127 Self-assignment of variable `bar` - | -23 | (foo, (bar, baz)) = (foo, (bar, 1)) -24 | foo: int = foo -25 | bar: int = bar - | ^^^ PLW0127 -26 | -27 | # Non-errors. - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0129_assert_on_string_literal.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0129_assert_on_string_literal.py.snap deleted file mode 100644 index cd671704e7..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0129_assert_on_string_literal.py.snap +++ /dev/null @@ -1,99 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -assert_on_string_literal.py:3:12: PLW0129 Asserting on a non-empty string literal will always pass - | -1 | def test_division(): -2 | a = 9 / 3 -3 | assert "No ZeroDivisionError were raised" # [assert-on-string-literal] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0129 - | - -assert_on_string_literal.py:12:12: PLW0129 Asserting on a non-empty string literal will always pass - | -11 | try: -12 | assert "bad" # [assert-on-string-literal] - | ^^^^^ PLW0129 -13 | except: -14 | assert "bad again" # [assert-on-string-literal] - | - -assert_on_string_literal.py:14:12: PLW0129 Asserting on a non-empty string literal will always pass - | -12 | assert "bad" # [assert-on-string-literal] -13 | except: -14 | assert "bad again" # [assert-on-string-literal] - | ^^^^^^^^^^^ PLW0129 -15 | -16 | a = 12 - | - -assert_on_string_literal.py:17:8: PLW0129 Asserting on a non-empty string literal will always pass - | -16 | a = 12 -17 | assert f"hello {a}" # [assert-on-string-literal] - | ^^^^^^^^^^^^ PLW0129 -18 | assert f"{a}" # [assert-on-string-literal] -19 | assert f"" # [assert-on-string-literal] - | - -assert_on_string_literal.py:18:8: PLW0129 Asserting on a string literal may have unintended results - | -16 | a = 12 -17 | assert f"hello {a}" # [assert-on-string-literal] -18 | assert f"{a}" # [assert-on-string-literal] - | ^^^^^^ PLW0129 -19 | assert f"" # [assert-on-string-literal] -20 | assert "" # [assert-on-string-literal] - | - -assert_on_string_literal.py:19:8: PLW0129 Asserting on an empty string literal will never pass - | -17 | assert f"hello {a}" # [assert-on-string-literal] -18 | assert f"{a}" # [assert-on-string-literal] -19 | assert f"" # [assert-on-string-literal] - | ^^^ PLW0129 -20 | assert "" # [assert-on-string-literal] -21 | assert b"hello" # [assert-on-string-literal] - | - -assert_on_string_literal.py:20:8: PLW0129 Asserting on an empty string literal will never pass - | -18 | assert f"{a}" # [assert-on-string-literal] -19 | assert f"" # [assert-on-string-literal] -20 | assert "" # [assert-on-string-literal] - | ^^ PLW0129 -21 | assert b"hello" # [assert-on-string-literal] -22 | assert "", b"hi" # [assert-on-string-literal] - | - -assert_on_string_literal.py:21:8: PLW0129 Asserting on a non-empty string literal will always pass - | -19 | assert f"" # [assert-on-string-literal] -20 | assert "" # [assert-on-string-literal] -21 | assert b"hello" # [assert-on-string-literal] - | ^^^^^^^^ PLW0129 -22 | assert "", b"hi" # [assert-on-string-literal] -23 | assert "WhyNotHere?", "HereIsOk" # [assert-on-string-literal] - | - -assert_on_string_literal.py:22:8: PLW0129 Asserting on an empty string literal will never pass - | -20 | assert "" # [assert-on-string-literal] -21 | assert b"hello" # [assert-on-string-literal] -22 | assert "", b"hi" # [assert-on-string-literal] - | ^^ PLW0129 -23 | assert "WhyNotHere?", "HereIsOk" # [assert-on-string-literal] -24 | assert 12, "ok here" - | - -assert_on_string_literal.py:23:8: PLW0129 Asserting on a non-empty string literal will always pass - | -21 | assert b"hello" # [assert-on-string-literal] -22 | assert "", b"hi" # [assert-on-string-literal] -23 | assert "WhyNotHere?", "HereIsOk" # [assert-on-string-literal] - | ^^^^^^^^^^^^^ PLW0129 -24 | assert 12, "ok here" - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0131_named_expr_without_context.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0131_named_expr_without_context.py.snap deleted file mode 100644 index cc8486e643..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0131_named_expr_without_context.py.snap +++ /dev/null @@ -1,28 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -named_expr_without_context.py:2:2: PLW0131 Named expression used without context - | -1 | # Errors -2 | (a := 42) - | ^^^^^^^ PLW0131 -3 | if True: -4 | (b := 1) - | - -named_expr_without_context.py:4:6: PLW0131 Named expression used without context - | -2 | (a := 42) -3 | if True: -4 | (b := 1) - | ^^^^^^ PLW0131 - | - -named_expr_without_context.py:8:6: PLW0131 Named expression used without context - | -7 | class Foo: -8 | (c := 1) - | ^^^^^^ PLW0131 - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0406_import_self__module.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0406_import_self__module.py.snap deleted file mode 100644 index 956076eb0e..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0406_import_self__module.py.snap +++ /dev/null @@ -1,28 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -module.py:1:8: PLW0406 Module `import_self.module` imports itself - | -1 | import import_self.module - | ^^^^^^^^^^^^^^^^^^ PLW0406 -2 | from import_self import module -3 | from . import module - | - -module.py:2:25: PLW0406 Module `import_self.module` imports itself - | -1 | import import_self.module -2 | from import_self import module - | ^^^^^^ PLW0406 -3 | from . import module - | - -module.py:3:15: PLW0406 Module `import_self.module` imports itself - | -1 | import import_self.module -2 | from import_self import module -3 | from . import module - | ^^^^^^ PLW0406 - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0602_global_variable_not_assigned.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0602_global_variable_not_assigned.py.snap deleted file mode 100644 index 0f35f57e51..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0602_global_variable_not_assigned.py.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -global_variable_not_assigned.py:5:12: PLW0602 Using global for `X` but no assignment is done - | -3 | ### -4 | def f(): -5 | global X - | ^ PLW0602 - | - -global_variable_not_assigned.py:9:12: PLW0602 Using global for `X` but no assignment is done - | - 8 | def f(): - 9 | global X - | ^ PLW0602 -10 | -11 | print(X) - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0603_global_statement.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0603_global_statement.py.snap deleted file mode 100644 index c84a187a2d..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0603_global_statement.py.snap +++ /dev/null @@ -1,102 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -global_statement.py:17:12: PLW0603 Using the global statement to update `CONSTANT` is discouraged - | -15 | def fix_constant(value): -16 | """All this is ok, but try not to use `global` ;)""" -17 | global CONSTANT # [global-statement] - | ^^^^^^^^ PLW0603 -18 | print(CONSTANT) -19 | CONSTANT = value - | - -global_statement.py:24:12: PLW0603 Using the global statement to update `sys` is discouraged - | -22 | def global_with_import(): -23 | """Should only warn for global-statement when using `Import` node""" -24 | global sys # [global-statement] - | ^^^ PLW0603 -25 | import sys - | - -global_statement.py:30:12: PLW0603 Using the global statement to update `namedtuple` is discouraged - | -28 | def global_with_import_from(): -29 | """Should only warn for global-statement when using `ImportFrom` node""" -30 | global namedtuple # [global-statement] - | ^^^^^^^^^^ PLW0603 -31 | from collections import namedtuple - | - -global_statement.py:36:12: PLW0603 Using the global statement to update `CONSTANT` is discouraged - | -34 | def global_del(): -35 | """Deleting the global name prevents `global-variable-not-assigned`""" -36 | global CONSTANT # [global-statement] - | ^^^^^^^^ PLW0603 -37 | print(CONSTANT) -38 | del CONSTANT - | - -global_statement.py:43:12: PLW0603 Using the global statement to update `CONSTANT` is discouraged - | -41 | def global_operator_assign(): -42 | """Operator assigns should only throw a global statement error""" -43 | global CONSTANT # [global-statement] - | ^^^^^^^^ PLW0603 -44 | print(CONSTANT) -45 | CONSTANT += 1 - | - -global_statement.py:50:12: PLW0603 Using the global statement to update `CONSTANT` is discouraged - | -48 | def global_function_assign(): -49 | """Function assigns should only throw a global statement error""" -50 | global CONSTANT # [global-statement] - | ^^^^^^^^ PLW0603 -51 | -52 | def CONSTANT(): - | - -global_statement.py:60:12: PLW0603 Using the global statement to update `FUNC` is discouraged - | -58 | def override_func(): -59 | """Overriding a function should only throw a global statement error""" -60 | global FUNC # [global-statement] - | ^^^^ PLW0603 -61 | -62 | def FUNC(): - | - -global_statement.py:70:12: PLW0603 Using the global statement to update `CLASS` is discouraged - | -68 | def override_class(): -69 | """Overriding a class should only throw a global statement error""" -70 | global CLASS # [global-statement] - | ^^^^^ PLW0603 -71 | -72 | class CLASS: - | - -global_statement.py:80:12: PLW0603 Using the global statement to update `CONSTANT` is discouraged - | -78 | def multiple_assignment(): -79 | """Should warn on every assignment.""" -80 | global CONSTANT # [global-statement] - | ^^^^^^^^ PLW0603 -81 | CONSTANT = 1 -82 | CONSTANT = 2 - | - -global_statement.py:80:12: PLW0603 Using the global statement to update `CONSTANT` is discouraged - | -78 | def multiple_assignment(): -79 | """Should warn on every assignment.""" -80 | global CONSTANT # [global-statement] - | ^^^^^^^^ PLW0603 -81 | CONSTANT = 1 -82 | CONSTANT = 2 - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0711_binary_op_exception.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0711_binary_op_exception.py.snap deleted file mode 100644 index 7f3b19efa1..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW0711_binary_op_exception.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -binary_op_exception.py:3:8: PLW0711 Exception to catch is the result of a binary `or` operation - | -1 | try: -2 | 1 / 0 -3 | except ZeroDivisionError or ValueError as e: # [binary-op-exception] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0711 -4 | pass - | - -binary_op_exception.py:8:8: PLW0711 Exception to catch is the result of a binary `and` operation - | -6 | try: -7 | raise ValueError -8 | except ZeroDivisionError and ValueError as e: # [binary-op-exception] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0711 -9 | print(e) - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW1508_invalid_envvar_default.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW1508_invalid_envvar_default.py.snap deleted file mode 100644 index 130b2b95af..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW1508_invalid_envvar_default.py.snap +++ /dev/null @@ -1,44 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -invalid_envvar_default.py:3:29: PLW1508 Invalid type for environment variable default; expected `str` or `None` - | -1 | import os -2 | -3 | tempVar = os.getenv("TEST", 12) # [invalid-envvar-default] - | ^^ PLW1508 -4 | goodVar = os.getenv("TESTING", None) -5 | dictVarBad = os.getenv("AAA", {"a", 7}) # [invalid-envvar-default] - | - -invalid_envvar_default.py:5:31: PLW1508 Invalid type for environment variable default; expected `str` or `None` - | -3 | tempVar = os.getenv("TEST", 12) # [invalid-envvar-default] -4 | goodVar = os.getenv("TESTING", None) -5 | dictVarBad = os.getenv("AAA", {"a", 7}) # [invalid-envvar-default] - | ^^^^^^^^ PLW1508 -6 | print(os.getenv("TEST", False)) # [invalid-envvar-default] -7 | os.getenv("AA", "GOOD") - | - -invalid_envvar_default.py:6:25: PLW1508 Invalid type for environment variable default; expected `str` or `None` - | -4 | goodVar = os.getenv("TESTING", None) -5 | dictVarBad = os.getenv("AAA", {"a", 7}) # [invalid-envvar-default] -6 | print(os.getenv("TEST", False)) # [invalid-envvar-default] - | ^^^^^ PLW1508 -7 | os.getenv("AA", "GOOD") -8 | os.getenv("AA", f"GOOD") - | - -invalid_envvar_default.py:10:17: PLW1508 Invalid type for environment variable default; expected `str` or `None` - | - 8 | os.getenv("AA", f"GOOD") - 9 | os.getenv("AA", "GOOD" + "BAD") -10 | os.getenv("AA", "GOOD" + 1) - | ^^^^^^^^^^ PLW1508 -11 | os.getenv("AA", "GOOD %s" % "BAD") -12 | os.getenv("B", Z) - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW1509_subprocess_popen_preexec_fn.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW1509_subprocess_popen_preexec_fn.py.snap deleted file mode 100644 index a212f70e14..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW1509_subprocess_popen_preexec_fn.py.snap +++ /dev/null @@ -1,42 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -subprocess_popen_preexec_fn.py:9:18: PLW1509 `preexec_fn` argument is unsafe when using threads - | - 8 | # Errors. - 9 | subprocess.Popen(preexec_fn=foo) - | ^^^^^^^^^^^^^^ PLW1509 -10 | subprocess.Popen(["ls"], preexec_fn=foo) -11 | subprocess.Popen(preexec_fn=lambda: print("Hello, world!")) - | - -subprocess_popen_preexec_fn.py:10:26: PLW1509 `preexec_fn` argument is unsafe when using threads - | - 8 | # Errors. - 9 | subprocess.Popen(preexec_fn=foo) -10 | subprocess.Popen(["ls"], preexec_fn=foo) - | ^^^^^^^^^^^^^^ PLW1509 -11 | subprocess.Popen(preexec_fn=lambda: print("Hello, world!")) -12 | subprocess.Popen(["ls"], preexec_fn=lambda: print("Hello, world!")) - | - -subprocess_popen_preexec_fn.py:11:18: PLW1509 `preexec_fn` argument is unsafe when using threads - | - 9 | subprocess.Popen(preexec_fn=foo) -10 | subprocess.Popen(["ls"], preexec_fn=foo) -11 | subprocess.Popen(preexec_fn=lambda: print("Hello, world!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW1509 -12 | subprocess.Popen(["ls"], preexec_fn=lambda: print("Hello, world!")) - | - -subprocess_popen_preexec_fn.py:12:26: PLW1509 `preexec_fn` argument is unsafe when using threads - | -10 | subprocess.Popen(["ls"], preexec_fn=foo) -11 | subprocess.Popen(preexec_fn=lambda: print("Hello, world!")) -12 | subprocess.Popen(["ls"], preexec_fn=lambda: print("Hello, world!")) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW1509 -13 | -14 | # Non-errors. - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW1510_subprocess_run_without_check.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW1510_subprocess_run_without_check.py.snap deleted file mode 100644 index 481f380608..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW1510_subprocess_run_without_check.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -subprocess_run_without_check.py:4:1: PLW1510 `subprocess.run` without explicit `check` argument - | -3 | # Errors. -4 | subprocess.run("ls") - | ^^^^^^^^^^^^^^ PLW1510 -5 | subprocess.run("ls", shell=True) - | - -subprocess_run_without_check.py:5:1: PLW1510 `subprocess.run` without explicit `check` argument - | -3 | # Errors. -4 | subprocess.run("ls") -5 | subprocess.run("ls", shell=True) - | ^^^^^^^^^^^^^^ PLW1510 -6 | -7 | # Non-errors. - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW1641_eq_without_hash.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW1641_eq_without_hash.py.snap deleted file mode 100644 index 5be273e060..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW1641_eq_without_hash.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -eq_without_hash.py:1:7: PLW1641 Object does not implement `__hash__` method - | -1 | class Person: # [eq-without-hash] - | ^^^^^^ PLW1641 -2 | def __init__(self): -3 | self.name = "monty" - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW2901_redefined_loop_name.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW2901_redefined_loop_name.py.snap deleted file mode 100644 index 7ca951e257..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW2901_redefined_loop_name.py.snap +++ /dev/null @@ -1,252 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -redefined_loop_name.py:6:9: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target - | -4 | # For -> for, variable reused -5 | for i in []: -6 | for i in []: # error - | ^ PLW2901 -7 | pass - | - -redefined_loop_name.py:11:9: PLW2901 `with` statement variable `i` overwritten by `for` loop target - | - 9 | # With -> for, variable reused -10 | with None as i: -11 | for i in []: # error - | ^ PLW2901 -12 | pass - | - -redefined_loop_name.py:16:18: PLW2901 `for` loop variable `i` overwritten by `with` statement target - | -14 | # For -> with, variable reused -15 | for i in []: -16 | with None as i: # error - | ^ PLW2901 -17 | pass - | - -redefined_loop_name.py:21:18: PLW2901 Outer `with` statement variable `i` overwritten by inner `with` statement target - | -19 | # With -> with, variable reused -20 | with None as i: -21 | with None as i: # error - | ^ PLW2901 -22 | pass - | - -redefined_loop_name.py:36:18: PLW2901 Outer `with` statement variable `i` overwritten by inner `with` statement target - | -34 | # Async with -> with, variable reused -35 | async with None as i: -36 | with None as i: # error - | ^ PLW2901 -37 | pass - | - -redefined_loop_name.py:46:9: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target - | -44 | # Async for -> for, variable reused -45 | async for i in []: -46 | for i in []: # error - | ^ PLW2901 -47 | pass - | - -redefined_loop_name.py:52:13: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target - | -50 | for i in []: -51 | for j in []: -52 | for i in []: # error - | ^ PLW2901 -53 | pass - | - -redefined_loop_name.py:58:13: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target - | -56 | for i in []: -57 | for j in []: -58 | for i in []: # error - | ^ PLW2901 -59 | for j in []: # error -60 | pass - | - -redefined_loop_name.py:59:17: PLW2901 Outer `for` loop variable `j` overwritten by inner `for` loop target - | -57 | for j in []: -58 | for i in []: # error -59 | for j in []: # error - | ^ PLW2901 -60 | pass - | - -redefined_loop_name.py:67:5: PLW2901 `for` loop variable `i` overwritten by assignment target - | -65 | i = cast(int, i) -66 | i = typing.cast(int, i) -67 | i = 5 # error - | ^ PLW2901 -68 | -69 | # For -> augmented assignment - | - -redefined_loop_name.py:71:5: PLW2901 `for` loop variable `i` overwritten by assignment target - | -69 | # For -> augmented assignment -70 | for i in []: -71 | i += 5 # error - | ^ PLW2901 -72 | -73 | # For -> annotated assignment - | - -redefined_loop_name.py:75:5: PLW2901 `for` loop variable `i` overwritten by assignment target - | -73 | # For -> annotated assignment -74 | for i in []: -75 | i: int = 5 # error - | ^ PLW2901 -76 | -77 | # For -> annotated assignment without value - | - -redefined_loop_name.py:83:9: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target - | -81 | # Async for -> for, variable reused -82 | async for i in []: -83 | for i in []: # error - | ^ PLW2901 -84 | pass - | - -redefined_loop_name.py:88:15: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target - | -86 | # For -> async for, variable reused -87 | for i in []: -88 | async for i in []: # error - | ^ PLW2901 -89 | pass - | - -redefined_loop_name.py:93:9: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target - | -91 | # For -> for, outer loop unpacks tuple -92 | for i, j in enumerate([]): -93 | for i in []: # error - | ^ PLW2901 -94 | pass - | - -redefined_loop_name.py:98:9: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target - | -96 | # For -> for, inner loop unpacks tuple -97 | for i in []: -98 | for i, j in enumerate([]): # error - | ^ PLW2901 -99 | pass - | - -redefined_loop_name.py:103:9: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target - | -101 | # For -> for, both loops unpack tuple -102 | for (i, (j, k)) in []: -103 | for i, j in enumerate([]): # two errors - | ^ PLW2901 -104 | pass - | - -redefined_loop_name.py:103:12: PLW2901 Outer `for` loop variable `j` overwritten by inner `for` loop target - | -101 | # For -> for, both loops unpack tuple -102 | for (i, (j, k)) in []: -103 | for i, j in enumerate([]): # two errors - | ^ PLW2901 -104 | pass - | - -redefined_loop_name.py:120:9: PLW2901 Outer `for` loop variable `j` overwritten by inner `for` loop target - | -118 | # For -> for, outer loop unpacks with asterisk -119 | for i, *j in []: -120 | for j in []: # error - | ^ PLW2901 -121 | pass - | - -redefined_loop_name.py:137:13: PLW2901 `for` loop variable `i` overwritten by assignment target - | -135 | def f(): -136 | for i in []: # no error -137 | i = 2 # error - | ^ PLW2901 -138 | -139 | # For -> class definition -> for -> for - | - -redefined_loop_name.py:143:17: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target - | -141 | class A: -142 | for i in []: # no error -143 | for i in []: # error - | ^ PLW2901 -144 | pass - | - -redefined_loop_name.py:158:5: PLW2901 `for` loop variable `a[0]` overwritten by assignment target - | -156 | # For target with subscript -> assignment -157 | for a[0] in []: -158 | a[0] = 2 # error - | ^^^^ PLW2901 -159 | a[1] = 2 # no error - | - -redefined_loop_name.py:163:5: PLW2901 `for` loop variable `a['i']` overwritten by assignment target - | -161 | # For target with subscript -> assignment -162 | for a['i'] in []: -163 | a['i'] = 2 # error - | ^^^^^^ PLW2901 -164 | a['j'] = 2 # no error - | - -redefined_loop_name.py:168:5: PLW2901 `for` loop variable `a.i` overwritten by assignment target - | -166 | # For target with attribute -> assignment -167 | for a.i in []: -168 | a.i = 2 # error - | ^^^ PLW2901 -169 | a.j = 2 # no error - | - -redefined_loop_name.py:173:5: PLW2901 `for` loop variable `a.i.j` overwritten by assignment target - | -171 | # For target with double nested attribute -> assignment -172 | for a.i.j in []: -173 | a.i.j = 2 # error - | ^^^^^ PLW2901 -174 | a.j.i = 2 # no error - | - -redefined_loop_name.py:178:5: PLW2901 `for` loop variable `a.i` overwritten by assignment target - | -176 | # For target with attribute -> assignment with different spacing -177 | for a.i in []: -178 | a. i = 2 # error - | ^^^^ PLW2901 -179 | for a. i in []: -180 | a.i = 2 # error - | - -redefined_loop_name.py:180:5: PLW2901 `for` loop variable `a.i` overwritten by assignment target - | -178 | a. i = 2 # error -179 | for a. i in []: -180 | a.i = 2 # error - | ^^^ PLW2901 - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW3201_bad_dunder_method_name.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW3201_bad_dunder_method_name.py.snap deleted file mode 100644 index 286c40fb39..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW3201_bad_dunder_method_name.py.snap +++ /dev/null @@ -1,61 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -bad_dunder_method_name.py:5:9: PLW3201 Bad or misspelled dunder method name `_init_`. (bad-dunder-name) - | -4 | class Apples: -5 | def _init_(self): # [bad-dunder-name] - | ^^^^^^ PLW3201 -6 | pass - | - -bad_dunder_method_name.py:8:9: PLW3201 Bad or misspelled dunder method name `__hello__`. (bad-dunder-name) - | -6 | pass -7 | -8 | def __hello__(self): # [bad-dunder-name] - | ^^^^^^^^^ PLW3201 -9 | print("hello") - | - -bad_dunder_method_name.py:11:9: PLW3201 Bad or misspelled dunder method name `__init_`. (bad-dunder-name) - | - 9 | print("hello") -10 | -11 | def __init_(self): # [bad-dunder-name] - | ^^^^^^^ PLW3201 -12 | # author likely unintentionally misspelled the correct init dunder. -13 | pass - | - -bad_dunder_method_name.py:15:9: PLW3201 Bad or misspelled dunder method name `_init_`. (bad-dunder-name) - | -13 | pass -14 | -15 | def _init_(self): # [bad-dunder-name] - | ^^^^^^ PLW3201 -16 | # author likely unintentionally misspelled the correct init dunder. -17 | pass - | - -bad_dunder_method_name.py:19:9: PLW3201 Bad or misspelled dunder method name `___neg__`. (bad-dunder-name) - | -17 | pass -18 | -19 | def ___neg__(self): # [bad-dunder-name] - | ^^^^^^^^ PLW3201 -20 | # author likely accidentally added an additional `_` -21 | pass - | - -bad_dunder_method_name.py:23:9: PLW3201 Bad or misspelled dunder method name `__inv__`. (bad-dunder-name) - | -21 | pass -22 | -23 | def __inv__(self): # [bad-dunder-name] - | ^^^^^^^ PLW3201 -24 | # author likely meant to call the invert dunder method -25 | pass - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW3301_nested_min_max.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW3301_nested_min_max.py.snap deleted file mode 100644 index efd914b5da..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLW3301_nested_min_max.py.snap +++ /dev/null @@ -1,296 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -nested_min_max.py:2:1: PLW3301 [*] Nested `min` calls can be flattened - | -1 | min(1, 2, 3) -2 | min(1, min(2, 3)) - | ^^^^^^^^^^^^^^^^^ PLW3301 -3 | min(1, min(2, min(3, 4))) -4 | min(1, foo("a", "b"), min(3, 4)) - | - = help: Flatten nested `min` calls - -ℹ Suggested fix -1 1 | min(1, 2, 3) -2 |-min(1, min(2, 3)) - 2 |+min(1, 2, 3) -3 3 | min(1, min(2, min(3, 4))) -4 4 | min(1, foo("a", "b"), min(3, 4)) -5 5 | min(1, max(2, 3)) - -nested_min_max.py:3:1: PLW3301 [*] Nested `min` calls can be flattened - | -1 | min(1, 2, 3) -2 | min(1, min(2, 3)) -3 | min(1, min(2, min(3, 4))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 -4 | min(1, foo("a", "b"), min(3, 4)) -5 | min(1, max(2, 3)) - | - = help: Flatten nested `min` calls - -ℹ Suggested fix -1 1 | min(1, 2, 3) -2 2 | min(1, min(2, 3)) -3 |-min(1, min(2, min(3, 4))) - 3 |+min(1, 2, 3, 4) -4 4 | min(1, foo("a", "b"), min(3, 4)) -5 5 | min(1, max(2, 3)) -6 6 | max(1, 2, 3) - -nested_min_max.py:3:8: PLW3301 [*] Nested `min` calls can be flattened - | -1 | min(1, 2, 3) -2 | min(1, min(2, 3)) -3 | min(1, min(2, min(3, 4))) - | ^^^^^^^^^^^^^^^^^ PLW3301 -4 | min(1, foo("a", "b"), min(3, 4)) -5 | min(1, max(2, 3)) - | - = help: Flatten nested `min` calls - -ℹ Suggested fix -1 1 | min(1, 2, 3) -2 2 | min(1, min(2, 3)) -3 |-min(1, min(2, min(3, 4))) - 3 |+min(1, min(2, 3, 4)) -4 4 | min(1, foo("a", "b"), min(3, 4)) -5 5 | min(1, max(2, 3)) -6 6 | max(1, 2, 3) - -nested_min_max.py:4:1: PLW3301 [*] Nested `min` calls can be flattened - | -2 | min(1, min(2, 3)) -3 | min(1, min(2, min(3, 4))) -4 | min(1, foo("a", "b"), min(3, 4)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 -5 | min(1, max(2, 3)) -6 | max(1, 2, 3) - | - = help: Flatten nested `min` calls - -ℹ Suggested fix -1 1 | min(1, 2, 3) -2 2 | min(1, min(2, 3)) -3 3 | min(1, min(2, min(3, 4))) -4 |-min(1, foo("a", "b"), min(3, 4)) - 4 |+min(1, foo("a", "b"), 3, 4) -5 5 | min(1, max(2, 3)) -6 6 | max(1, 2, 3) -7 7 | max(1, max(2, 3)) - -nested_min_max.py:7:1: PLW3301 [*] Nested `max` calls can be flattened - | -5 | min(1, max(2, 3)) -6 | max(1, 2, 3) -7 | max(1, max(2, 3)) - | ^^^^^^^^^^^^^^^^^ PLW3301 -8 | max(1, max(2, max(3, 4))) -9 | max(1, foo("a", "b"), max(3, 4)) - | - = help: Flatten nested `max` calls - -ℹ Suggested fix -4 4 | min(1, foo("a", "b"), min(3, 4)) -5 5 | min(1, max(2, 3)) -6 6 | max(1, 2, 3) -7 |-max(1, max(2, 3)) - 7 |+max(1, 2, 3) -8 8 | max(1, max(2, max(3, 4))) -9 9 | max(1, foo("a", "b"), max(3, 4)) -10 10 | - -nested_min_max.py:8:1: PLW3301 [*] Nested `max` calls can be flattened - | -6 | max(1, 2, 3) -7 | max(1, max(2, 3)) -8 | max(1, max(2, max(3, 4))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 -9 | max(1, foo("a", "b"), max(3, 4)) - | - = help: Flatten nested `max` calls - -ℹ Suggested fix -5 5 | min(1, max(2, 3)) -6 6 | max(1, 2, 3) -7 7 | max(1, max(2, 3)) -8 |-max(1, max(2, max(3, 4))) - 8 |+max(1, 2, 3, 4) -9 9 | max(1, foo("a", "b"), max(3, 4)) -10 10 | -11 11 | # These should not trigger; we do not flag cases with keyword args. - -nested_min_max.py:8:8: PLW3301 [*] Nested `max` calls can be flattened - | -6 | max(1, 2, 3) -7 | max(1, max(2, 3)) -8 | max(1, max(2, max(3, 4))) - | ^^^^^^^^^^^^^^^^^ PLW3301 -9 | max(1, foo("a", "b"), max(3, 4)) - | - = help: Flatten nested `max` calls - -ℹ Suggested fix -5 5 | min(1, max(2, 3)) -6 6 | max(1, 2, 3) -7 7 | max(1, max(2, 3)) -8 |-max(1, max(2, max(3, 4))) - 8 |+max(1, max(2, 3, 4)) -9 9 | max(1, foo("a", "b"), max(3, 4)) -10 10 | -11 11 | # These should not trigger; we do not flag cases with keyword args. - -nested_min_max.py:9:1: PLW3301 [*] Nested `max` calls can be flattened - | - 7 | max(1, max(2, 3)) - 8 | max(1, max(2, max(3, 4))) - 9 | max(1, foo("a", "b"), max(3, 4)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 -10 | -11 | # These should not trigger; we do not flag cases with keyword args. - | - = help: Flatten nested `max` calls - -ℹ Suggested fix -6 6 | max(1, 2, 3) -7 7 | max(1, max(2, 3)) -8 8 | max(1, max(2, max(3, 4))) -9 |-max(1, foo("a", "b"), max(3, 4)) - 9 |+max(1, foo("a", "b"), 3, 4) -10 10 | -11 11 | # These should not trigger; we do not flag cases with keyword args. -12 12 | min(1, min(2, 3), key=test) - -nested_min_max.py:15:1: PLW3301 [*] Nested `min` calls can be flattened - | -13 | min(1, min(2, 3, key=test)) -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 | -17 | # Don't provide a fix if there are comments within the call. - | - = help: Flatten nested `min` calls - -ℹ Suggested fix -12 12 | min(1, min(2, 3), key=test) -13 13 | min(1, min(2, 3, key=test)) -14 14 | # This will still trigger, to merge the calls without keyword args. -15 |-min(1, min(2, 3, key=test), min(4, 5)) - 15 |+min(1, min(2, 3, key=test), 4, 5) -16 16 | -17 17 | # Don't provide a fix if there are comments within the call. -18 18 | min( - -nested_min_max.py:18:1: PLW3301 Nested `min` calls can be flattened - | -17 | # Don't provide a fix if there are comments within the call. -18 | / min( -19 | | 1, # This is a comment. -20 | | min(2, 3), -21 | | ) - | |_^ PLW3301 -22 | -23 | # Handle iterable expressions. - | - = help: Flatten nested `min` calls - -nested_min_max.py:24:1: PLW3301 [*] Nested `min` calls can be flattened - | -23 | # Handle iterable expressions. -24 | min(1, min(a)) - | ^^^^^^^^^^^^^^ PLW3301 -25 | min(1, min(i for i in range(10))) -26 | max(1, max(a)) - | - = help: Flatten nested `min` calls - -ℹ Suggested fix -21 21 | ) -22 22 | -23 23 | # Handle iterable expressions. -24 |-min(1, min(a)) - 24 |+min(1, *a) -25 25 | min(1, min(i for i in range(10))) -26 26 | max(1, max(a)) -27 27 | max(1, max(i for i in range(10))) - -nested_min_max.py:25:1: PLW3301 [*] Nested `min` calls can be flattened - | -23 | # Handle iterable expressions. -24 | min(1, min(a)) -25 | min(1, min(i for i in range(10))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 -26 | max(1, max(a)) -27 | max(1, max(i for i in range(10))) - | - = help: Flatten nested `min` calls - -ℹ Suggested fix -22 22 | -23 23 | # Handle iterable expressions. -24 24 | min(1, min(a)) -25 |-min(1, min(i for i in range(10))) - 25 |+min(1, *(i for i in range(10))) -26 26 | max(1, max(a)) -27 27 | max(1, max(i for i in range(10))) -28 28 | - -nested_min_max.py:26:1: PLW3301 [*] Nested `max` calls can be flattened - | -24 | min(1, min(a)) -25 | min(1, min(i for i in range(10))) -26 | max(1, max(a)) - | ^^^^^^^^^^^^^^ PLW3301 -27 | max(1, max(i for i in range(10))) - | - = help: Flatten nested `max` calls - -ℹ Suggested fix -23 23 | # Handle iterable expressions. -24 24 | min(1, min(a)) -25 25 | min(1, min(i for i in range(10))) -26 |-max(1, max(a)) - 26 |+max(1, *a) -27 27 | max(1, max(i for i in range(10))) -28 28 | -29 29 | tuples_list = [ - -nested_min_max.py:27:1: PLW3301 [*] Nested `max` calls can be flattened - | -25 | min(1, min(i for i in range(10))) -26 | max(1, max(a)) -27 | max(1, max(i for i in range(10))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 -28 | -29 | tuples_list = [ - | - = help: Flatten nested `max` calls - -ℹ Suggested fix -24 24 | min(1, min(a)) -25 25 | min(1, min(i for i in range(10))) -26 26 | max(1, max(a)) -27 |-max(1, max(i for i in range(10))) - 27 |+max(1, *(i for i in range(10))) -28 28 | -29 29 | tuples_list = [ -30 30 | (1, 2), - -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 - | - = help: Flatten nested `max` calls - -ℹ Suggested fix -38 38 | max(max(tuples_list)) -39 39 | -40 40 | # Starred argument should be copied as it is. -41 |-max(1, max(*a)) - 41 |+max(1, *a) - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__allow_magic_value_types.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__allow_magic_value_types.snap deleted file mode 100644 index 9e783bbf33..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__allow_magic_value_types.snap +++ /dev/null @@ -1,31 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -magic_value_comparison.py:59:22: PLR2004 Magic value used in comparison, consider replacing "Hunter2" with a constant variable - | -57 | pass -58 | -59 | if input_password == "Hunter2": # correct - | ^^^^^^^^^ PLR2004 -60 | pass - | - -magic_value_comparison.py:65:21: PLR2004 Magic value used in comparison, consider replacing 3.141592653589793 with a constant variable - | -63 | pi_estimation = 3.14 -64 | -65 | if pi_estimation == 3.141592653589793238: # [magic-value-comparison] - | ^^^^^^^^^^^^^^^^^^^^ PLR2004 -66 | pass - | - -magic_value_comparison.py:74:18: PLR2004 Magic value used in comparison, consider replacing b"something" with a constant variable - | -72 | user_input = b"Hello, There!" -73 | -74 | if user_input == b"something": # correct - | ^^^^^^^^^^^^ PLR2004 -75 | pass - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__continue_in_finally.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__continue_in_finally.snap deleted file mode 100644 index 611a3fbb48..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__continue_in_finally.snap +++ /dev/null @@ -1,128 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -continue_in_finally.py:5:9: PLE0116 `continue` not supported inside `finally` clause - | -3 | pass -4 | finally: -5 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 -6 | -7 | while True: - | - -continue_in_finally.py:16:13: PLE0116 `continue` not supported inside `finally` clause - | -14 | pass -15 | finally: -16 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 -17 | pass - | - -continue_in_finally.py:26:17: PLE0116 `continue` not supported inside `finally` clause - | -24 | match test: -25 | case "aa": -26 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 -27 | -28 | while True: - | - -continue_in_finally.py:33:13: PLE0116 `continue` not supported inside `finally` clause - | -31 | finally: -32 | with "aa" as f: -33 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 -34 | -35 | while True: - | - -continue_in_finally.py:40:13: PLE0116 `continue` not supported inside `finally` clause - | -38 | finally: -39 | if True: -40 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 -41 | continue # [continue-in-finally] - | - -continue_in_finally.py:41:9: PLE0116 `continue` not supported inside `finally` clause - | -39 | if True: -40 | continue # [continue-in-finally] -41 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 -42 | -43 | def test(): - | - -continue_in_finally.py:49:17: PLE0116 `continue` not supported inside `finally` clause - | -47 | pass -48 | finally: -49 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 - | - -continue_in_finally.py:56:9: PLE0116 `continue` not supported inside `finally` clause - | -54 | pass -55 | finally: -56 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 -57 | -58 | def test(): - | - -continue_in_finally.py:69:9: PLE0116 `continue` not supported inside `finally` clause - | -67 | for i in range(12): -68 | continue -69 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 -70 | -71 | while True: - | - -continue_in_finally.py:74:13: PLE0116 `continue` not supported inside `finally` clause - | -72 | pass -73 | else: -74 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 -75 | -76 | def test(): - | - -continue_in_finally.py:89:13: PLE0116 `continue` not supported inside `finally` clause - | -87 | pass -88 | elif False: -89 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 -90 | else: -91 | continue # [continue-in-finally] - | - -continue_in_finally.py:91:13: PLE0116 `continue` not supported inside `finally` clause - | -89 | continue # [continue-in-finally] -90 | else: -91 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 -92 | for i in range(10): -93 | pass - | - -continue_in_finally.py:95:17: PLE0116 `continue` not supported inside `finally` clause - | -93 | pass -94 | else: -95 | continue # [continue-in-finally] - | ^^^^^^^^ PLE0116 - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__max_args.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__max_args.snap deleted file mode 100644 index 3170aab943..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__max_args.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -too_many_arguments_params.py:3:5: PLR0913 Too many arguments to function call (6 > 4) - | -1 | # Too many args (6/4) for max_args=4 -2 | # OK for dummy_variable_rgx ~ "skip_.*" -3 | def f(x, y, z, skip_t, skip_u, skip_v): - | ^ PLR0913 -4 | pass - | - -too_many_arguments_params.py:9:5: PLR0913 Too many arguments to function call (6 > 4) - | - 7 | # Too many args (6/4) for max_args=4 - 8 | # Too many args (6/5) for dummy_variable_rgx ~ "skip_.*" - 9 | def f(x, y, z, t, u, v): - | ^ PLR0913 -10 | pass - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__max_args_with_dummy_variables.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__max_args_with_dummy_variables.snap deleted file mode 100644 index cdca59c810..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__max_args_with_dummy_variables.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -too_many_arguments_params.py:9:5: PLR0913 Too many arguments to function call (6 > 5) - | - 7 | # Too many args (6/4) for max_args=4 - 8 | # Too many args (6/5) for dummy_variable_rgx ~ "skip_.*" - 9 | def f(x, y, z, t, u, v): - | ^ PLR0913 -10 | pass - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__max_branches.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__max_branches.snap deleted file mode 100644 index e991065f64..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__max_branches.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -too_many_branches_params.py:6:5: PLR0912 Too many branches (2 > 1) - | -6 | def g(x): - | ^ PLR0912 -7 | if x: -8 | pass - | - -too_many_branches_params.py:15:9: PLR0912 Too many branches (2 > 1) - | -13 | return -14 | -15 | def i(x): - | ^ PLR0912 -16 | if x: -17 | pass - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__max_return_statements.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__max_return_statements.snap deleted file mode 100644 index 4b022ab606..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__max_return_statements.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -too_many_return_statements_params.py:1:5: PLR0911 Too many return statements (2 > 1) - | -1 | def f(x): # Too many return statements (2/1) - | ^ PLR0911 -2 | if x == 1: -3 | return - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__max_statements.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__max_statements.snap deleted file mode 100644 index 55e63e6817..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__max_statements.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -too_many_statements_params.py:6:5: PLR0915 Too many statements (2 > 1) - | -6 | def f(x): - | ^ PLR0915 -7 | def g(x): -8 | pass - | - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__repeated_isinstance_calls.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__repeated_isinstance_calls.snap deleted file mode 100644 index 77773a2d05..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__repeated_isinstance_calls.snap +++ /dev/null @@ -1,144 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -repeated_isinstance_calls.py:15:8: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[3], (float, int))` - | -14 | # not merged -15 | if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True: # [consider-merging-isinstance] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 -16 | pass -17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] - | - = help: Replace with `isinstance(var[3], (float, int))` - -ℹ Fix -12 12 | result = isinstance(var[2], (int, float)) -13 13 | -14 14 | # not merged -15 |- if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True: # [consider-merging-isinstance] - 15 |+ if isinstance(var[3], (float, int)): # [consider-merging-isinstance] -16 16 | pass -17 17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] -18 18 | - -repeated_isinstance_calls.py:17:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[4], (float, int))` - | -15 | if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True: # [consider-merging-isinstance] -16 | pass -17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 -18 | -19 | result = isinstance(var[5], int) or True or isinstance(var[5], float) # [consider-merging-isinstance] - | - = help: Replace with `isinstance(var[4], (float, int))` - -ℹ Fix -14 14 | # not merged -15 15 | if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True: # [consider-merging-isinstance] -16 16 | pass -17 |- result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] - 17 |+ result = isinstance(var[4], (float, int)) # [consider-merging-isinstance] -18 18 | -19 19 | result = isinstance(var[5], int) or True or isinstance(var[5], float) # [consider-merging-isinstance] -20 20 | - -repeated_isinstance_calls.py:19:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[5], (float, int))` - | -17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] -18 | -19 | result = isinstance(var[5], int) or True or isinstance(var[5], float) # [consider-merging-isinstance] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 -20 | -21 | inferred_isinstance = isinstance - | - = help: Replace with `isinstance(var[5], (float, int))` - -ℹ Fix -16 16 | pass -17 17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] -18 18 | -19 |- result = isinstance(var[5], int) or True or isinstance(var[5], float) # [consider-merging-isinstance] - 19 |+ result = isinstance(var[5], (float, int)) # [consider-merging-isinstance] -20 20 | -21 21 | inferred_isinstance = isinstance -22 22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] - -repeated_isinstance_calls.py:23:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[10], (list, str))` - | -21 | inferred_isinstance = isinstance -22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] -23 | result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list) # [consider-merging-isinstance] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 -24 | result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float) # [consider-merging-isinstance] - | - = help: Replace with `isinstance(var[10], (list, str))` - -ℹ Fix -20 20 | -21 21 | inferred_isinstance = isinstance -22 22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] -23 |- result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list) # [consider-merging-isinstance] - 23 |+ result = isinstance(var[10], (list, str)) # [consider-merging-isinstance] -24 24 | result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float) # [consider-merging-isinstance] -25 25 | -26 26 | result = isinstance(var[20]) - -repeated_isinstance_calls.py:24:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[11], (float, int))` - | -22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] -23 | result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list) # [consider-merging-isinstance] -24 | result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float) # [consider-merging-isinstance] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 -25 | -26 | result = isinstance(var[20]) - | - = help: Replace with `isinstance(var[11], (float, int))` - -ℹ Fix -21 21 | inferred_isinstance = isinstance -22 22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] -23 23 | result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list) # [consider-merging-isinstance] -24 |- result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float) # [consider-merging-isinstance] - 24 |+ result = isinstance(var[11], (float, int)) # [consider-merging-isinstance] -25 25 | -26 26 | result = isinstance(var[20]) -27 27 | result = isinstance() - -repeated_isinstance_calls.py:30:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[12], (float, int, list))` - | -29 | # Combination merged and not merged -30 | result = isinstance(var[12], (int, float)) or isinstance(var[12], list) # [consider-merging-isinstance] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 -31 | -32 | # not merged but valid - | - = help: Replace with `isinstance(var[12], (float, int, list))` - -ℹ Fix -27 27 | result = isinstance() -28 28 | -29 29 | # Combination merged and not merged -30 |- result = isinstance(var[12], (int, float)) or isinstance(var[12], list) # [consider-merging-isinstance] - 30 |+ result = isinstance(var[12], (float, int, list)) # [consider-merging-isinstance] -31 31 | -32 32 | # not merged but valid -33 33 | result = isinstance(var[5], int) and var[5] * 14 or isinstance(var[5], float) and var[5] * 14.4 - -repeated_isinstance_calls.py:42:3: PLR1701 [*] Merge `isinstance` calls: `isinstance(self.k, (float, int))` - | -41 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722460483 -42 | if(isinstance(self.k, int)) or (isinstance(self.k, float)): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 -43 | ... - | - = help: Replace with `isinstance(self.k, (float, int))` - -ℹ Fix -39 39 | -40 40 | -41 41 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722460483 -42 |-if(isinstance(self.k, int)) or (isinstance(self.k, float)): - 42 |+if isinstance(self.k, (float, int)): -43 43 | ... - - diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__too_many_public_methods.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__too_many_public_methods.snap deleted file mode 100644 index c24d559c4d..0000000000 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__too_many_public_methods.snap +++ /dev/null @@ -1,46 +0,0 @@ ---- -source: crates/ruff/src/rules/pylint/mod.rs ---- -too_many_public_methods.py:1:1: PLR0904 Too many public methods (10 > 7) - | - 1 | / class Everything: - 2 | | foo = 1 - 3 | | - 4 | | def __init__(self): - 5 | | pass - 6 | | - 7 | | def _private(self): - 8 | | pass - 9 | | -10 | | def method1(self): -11 | | pass -12 | | -13 | | def method2(self): -14 | | pass -15 | | -16 | | def method3(self): -17 | | pass -18 | | -19 | | def method4(self): -20 | | pass -21 | | -22 | | def method5(self): -23 | | pass -24 | | -25 | | def method6(self): -26 | | pass -27 | | -28 | | def method7(self): -29 | | pass -30 | | -31 | | def method8(self): -32 | | pass -33 | | -34 | | def method9(self): -35 | | pass - | |____________^ PLR0904 -36 | -37 | class Small: - | - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP001.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP001.py.snap deleted file mode 100644 index 2e10ceb721..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP001.py.snap +++ /dev/null @@ -1,39 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP001.py:2:5: UP001 [*] `__metaclass__ = type` is implied - | -1 | class A: -2 | __metaclass__ = type - | ^^^^^^^^^^^^^^^^^^^^ UP001 - | - = help: Remove `metaclass = type` - -ℹ Fix -1 1 | class A: -2 |- __metaclass__ = type - 2 |+ pass -3 3 | -4 4 | -5 5 | class B: - -UP001.py:6:5: UP001 [*] `__metaclass__ = type` is implied - | -5 | class B: -6 | __metaclass__ = type - | ^^^^^^^^^^^^^^^^^^^^ UP001 -7 | -8 | def __init__(self) -> None: - | - = help: Remove `metaclass = type` - -ℹ Fix -3 3 | -4 4 | -5 5 | class B: -6 |- __metaclass__ = type -7 6 | -8 7 | def __init__(self) -> None: -9 8 | pass - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP003.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP003.py.snap deleted file mode 100644 index 75a0d85895..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP003.py.snap +++ /dev/null @@ -1,114 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP003.py:1:1: UP003 [*] Use `str` instead of `type(...)` - | -1 | type("") - | ^^^^^^^^ UP003 -2 | type(b"") -3 | type(0) - | - = help: Replace `type(...)` with `str` - -ℹ Fix -1 |-type("") - 1 |+str -2 2 | type(b"") -3 3 | type(0) -4 4 | type(0.0) - -UP003.py:2:1: UP003 [*] Use `bytes` instead of `type(...)` - | -1 | type("") -2 | type(b"") - | ^^^^^^^^^ UP003 -3 | type(0) -4 | type(0.0) - | - = help: Replace `type(...)` with `bytes` - -ℹ Fix -1 1 | type("") -2 |-type(b"") - 2 |+bytes -3 3 | type(0) -4 4 | type(0.0) -5 5 | type(0j) - -UP003.py:3:1: UP003 [*] Use `int` instead of `type(...)` - | -1 | type("") -2 | type(b"") -3 | type(0) - | ^^^^^^^ UP003 -4 | type(0.0) -5 | type(0j) - | - = help: Replace `type(...)` with `int` - -ℹ Fix -1 1 | type("") -2 2 | type(b"") -3 |-type(0) - 3 |+int -4 4 | type(0.0) -5 5 | type(0j) -6 6 | - -UP003.py:4:1: UP003 [*] Use `float` instead of `type(...)` - | -2 | type(b"") -3 | type(0) -4 | type(0.0) - | ^^^^^^^^^ UP003 -5 | type(0j) - | - = help: Replace `type(...)` with `float` - -ℹ Fix -1 1 | type("") -2 2 | type(b"") -3 3 | type(0) -4 |-type(0.0) - 4 |+float -5 5 | type(0j) -6 6 | -7 7 | # OK - -UP003.py:5:1: UP003 [*] Use `complex` instead of `type(...)` - | -3 | type(0) -4 | type(0.0) -5 | type(0j) - | ^^^^^^^^ UP003 -6 | -7 | # OK - | - = help: Replace `type(...)` with `complex` - -ℹ Fix -2 2 | type(b"") -3 3 | type(0) -4 4 | type(0.0) -5 |-type(0j) - 5 |+complex -6 6 | -7 7 | # OK -8 8 | type(arg)(" ") - -UP003.py:14:29: UP003 [*] Use `str` instead of `type(...)` - | -13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459841 -14 | assert isinstance(fullname, type("")is not True) - | ^^^^^^^^ UP003 - | - = help: Replace `type(...)` with `str` - -ℹ Fix -11 11 | y = x.dtype.type(0.0) -12 12 | -13 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459841 -14 |-assert isinstance(fullname, type("")is not True) - 14 |+assert isinstance(fullname, str is not True) - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP004.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP004.py.snap deleted file mode 100644 index e106675943..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP004.py.snap +++ /dev/null @@ -1,493 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP004.py:5:9: UP004 [*] Class `A` inherits from `object` - | -5 | class A(object): - | ^^^^^^ UP004 -6 | ... - | - = help: Remove `object` inheritance - -ℹ Fix -2 2 | ... -3 3 | -4 4 | -5 |-class A(object): - 5 |+class A: -6 6 | ... -7 7 | -8 8 | - -UP004.py:10:5: UP004 [*] Class `A` inherits from `object` - | - 9 | class A( -10 | object, - | ^^^^^^ UP004 -11 | ): -12 | ... - | - = help: Remove `object` inheritance - -ℹ Fix -6 6 | ... -7 7 | -8 8 | -9 |-class A( -10 |- object, -11 |-): - 9 |+class A: -12 10 | ... -13 11 | -14 12 | - -UP004.py:16:5: UP004 [*] Class `A` inherits from `object` - | -15 | class A( -16 | object, - | ^^^^^^ UP004 -17 | # -18 | ): - | - = help: Remove `object` inheritance - -ℹ Fix -12 12 | ... -13 13 | -14 14 | -15 |-class A( -16 |- object, -17 |- # -18 |-): - 15 |+class A: -19 16 | ... -20 17 | -21 18 | - -UP004.py:24:5: UP004 [*] Class `A` inherits from `object` - | -22 | class A( -23 | # -24 | object, - | ^^^^^^ UP004 -25 | ): -26 | ... - | - = help: Remove `object` inheritance - -ℹ Fix -19 19 | ... -20 20 | -21 21 | -22 |-class A( -23 |- # -24 |- object, -25 |-): - 22 |+class A: -26 23 | ... -27 24 | -28 25 | - -UP004.py:31:5: UP004 [*] Class `A` inherits from `object` - | -29 | class A( -30 | # -31 | object - | ^^^^^^ UP004 -32 | ): -33 | ... - | - = help: Remove `object` inheritance - -ℹ Fix -26 26 | ... -27 27 | -28 28 | -29 |-class A( -30 |- # -31 |- object -32 |-): - 29 |+class A: -33 30 | ... -34 31 | -35 32 | - -UP004.py:37:5: UP004 [*] Class `A` inherits from `object` - | -36 | class A( -37 | object - | ^^^^^^ UP004 -38 | # -39 | ): - | - = help: Remove `object` inheritance - -ℹ Fix -33 33 | ... -34 34 | -35 35 | -36 |-class A( -37 |- object -38 |- # -39 |-): - 36 |+class A: -40 37 | ... -41 38 | -42 39 | - -UP004.py:45:5: UP004 [*] Class `A` inherits from `object` - | -43 | class A( -44 | # -45 | object, - | ^^^^^^ UP004 -46 | # -47 | ): - | - = help: Remove `object` inheritance - -ℹ Fix -40 40 | ... -41 41 | -42 42 | -43 |-class A( -44 |- # -45 |- object, -46 |- # -47 |-): - 43 |+class A: -48 44 | ... -49 45 | -50 46 | - -UP004.py:53:5: UP004 [*] Class `A` inherits from `object` - | -51 | class A( -52 | # -53 | object, - | ^^^^^^ UP004 -54 | # -55 | ): - | - = help: Remove `object` inheritance - -ℹ Fix -48 48 | ... -49 49 | -50 50 | -51 |-class A( -52 |- # -53 |- object, -54 |- # -55 |-): - 51 |+class A: -56 52 | ... -57 53 | -58 54 | - -UP004.py:61:5: UP004 [*] Class `A` inherits from `object` - | -59 | class A( -60 | # -61 | object - | ^^^^^^ UP004 -62 | # -63 | ): - | - = help: Remove `object` inheritance - -ℹ Fix -56 56 | ... -57 57 | -58 58 | -59 |-class A( -60 |- # -61 |- object -62 |- # -63 |-): - 59 |+class A: -64 60 | ... -65 61 | -66 62 | - -UP004.py:69:5: UP004 [*] Class `A` inherits from `object` - | -67 | class A( -68 | # -69 | object - | ^^^^^^ UP004 -70 | # -71 | ): - | - = help: Remove `object` inheritance - -ℹ Fix -64 64 | ... -65 65 | -66 66 | -67 |-class A( -68 |- # -69 |- object -70 |- # -71 |-): - 67 |+class A: -72 68 | ... -73 69 | -74 70 | - -UP004.py:75:12: UP004 [*] Class `B` inherits from `object` - | -75 | class B(A, object): - | ^^^^^^ UP004 -76 | ... - | - = help: Remove `object` inheritance - -ℹ Fix -72 72 | ... -73 73 | -74 74 | -75 |-class B(A, object): - 75 |+class B(A): -76 76 | ... -77 77 | -78 78 | - -UP004.py:79:9: UP004 [*] Class `B` inherits from `object` - | -79 | class B(object, A): - | ^^^^^^ UP004 -80 | ... - | - = help: Remove `object` inheritance - -ℹ Fix -76 76 | ... -77 77 | -78 78 | -79 |-class B(object, A): - 79 |+class B(A): -80 80 | ... -81 81 | -82 82 | - -UP004.py:84:5: UP004 [*] Class `B` inherits from `object` - | -83 | class B( -84 | object, - | ^^^^^^ UP004 -85 | A, -86 | ): - | - = help: Remove `object` inheritance - -ℹ Fix -81 81 | -82 82 | -83 83 | class B( -84 |- object, -85 84 | A, -86 85 | ): -87 86 | ... - -UP004.py:92:5: UP004 [*] Class `B` inherits from `object` - | -90 | class B( -91 | A, -92 | object, - | ^^^^^^ UP004 -93 | ): -94 | ... - | - = help: Remove `object` inheritance - -ℹ Fix -89 89 | -90 90 | class B( -91 91 | A, -92 |- object, -93 92 | ): -94 93 | ... -95 94 | - -UP004.py:98:5: UP004 [*] Class `B` inherits from `object` - | - 97 | class B( - 98 | object, - | ^^^^^^ UP004 - 99 | # Comment on A. -100 | A, - | - = help: Remove `object` inheritance - -ℹ Fix -95 95 | -96 96 | -97 97 | class B( -98 |- object, -99 98 | # Comment on A. -100 99 | A, -101 100 | ): - -UP004.py:108:5: UP004 [*] Class `B` inherits from `object` - | -106 | # Comment on A. -107 | A, -108 | object, - | ^^^^^^ UP004 -109 | ): -110 | ... - | - = help: Remove `object` inheritance - -ℹ Fix -105 105 | class B( -106 106 | # Comment on A. -107 107 | A, -108 |- object, -109 108 | ): -110 109 | ... -111 110 | - -UP004.py:119:5: UP004 [*] Class `A` inherits from `object` - | -118 | class A( -119 | object, - | ^^^^^^ UP004 -120 | ): -121 | ... - | - = help: Remove `object` inheritance - -ℹ Fix -115 115 | ... -116 116 | -117 117 | -118 |-class A( -119 |- object, -120 |-): - 118 |+class A: -121 119 | ... -122 120 | -123 121 | - -UP004.py:125:5: UP004 [*] Class `A` inherits from `object` - | -124 | class A( -125 | object, # ) - | ^^^^^^ UP004 -126 | ): -127 | ... - | - = help: Remove `object` inheritance - -ℹ Fix -121 121 | ... -122 122 | -123 123 | -124 |-class A( -125 |- object, # ) -126 |-): - 124 |+class A: -127 125 | ... -128 126 | -129 127 | - -UP004.py:131:5: UP004 [*] Class `A` inherits from `object` - | -130 | class A( -131 | object # ) - | ^^^^^^ UP004 -132 | , -133 | ): - | - = help: Remove `object` inheritance - -ℹ Fix -127 127 | ... -128 128 | -129 129 | -130 |-class A( -131 |- object # ) -132 |- , -133 |-): - 130 |+class A: -134 131 | ... -135 132 | -136 133 | - -UP004.py:137:9: UP004 [*] Class `A` inherits from `object` - | -137 | class A(object, object): - | ^^^^^^ UP004 -138 | ... - | - = help: Remove `object` inheritance - -ℹ Fix -134 134 | ... -135 135 | -136 136 | -137 |-class A(object, object): - 137 |+class A(object): -138 138 | ... -139 139 | -140 140 | - -UP004.py:137:17: UP004 [*] Class `A` inherits from `object` - | -137 | class A(object, object): - | ^^^^^^ UP004 -138 | ... - | - = help: Remove `object` inheritance - -ℹ Fix -134 134 | ... -135 135 | -136 136 | -137 |-class A(object, object): - 137 |+class A(object): -138 138 | ... -139 139 | -140 140 | - -UP004.py:142:9: UP004 [*] Class `A` inherits from `object` - | -141 | @decorator() -142 | class A(object): - | ^^^^^^ UP004 -143 | ... - | - = help: Remove `object` inheritance - -ℹ Fix -139 139 | -140 140 | -141 141 | @decorator() -142 |-class A(object): - 142 |+class A: -143 143 | ... -144 144 | -145 145 | @decorator() # class A(object): - -UP004.py:146:9: UP004 [*] Class `A` inherits from `object` - | -145 | @decorator() # class A(object): -146 | class A(object): - | ^^^^^^ UP004 -147 | ... - | - = help: Remove `object` inheritance - -ℹ Fix -143 143 | ... -144 144 | -145 145 | @decorator() # class A(object): -146 |-class A(object): - 146 |+class A: -147 147 | ... -148 148 | -149 149 | - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP005.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP005.py.snap deleted file mode 100644 index 9afb41f84a..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP005.py.snap +++ /dev/null @@ -1,80 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP005.py:6:9: UP005 [*] `assertEquals` is deprecated, use `assertEqual` - | -4 | class Suite(unittest.TestCase): -5 | def test(self) -> None: -6 | self.assertEquals (1, 2) - | ^^^^^^^^^^^^^^^^^ UP005 -7 | self.assertEquals(1, 2) -8 | self.assertEqual(3, 4) - | - = help: Replace `assertEqual` with `assertEquals` - -ℹ Suggested fix -3 3 | -4 4 | class Suite(unittest.TestCase): -5 5 | def test(self) -> None: -6 |- self.assertEquals (1, 2) - 6 |+ self.assertEqual (1, 2) -7 7 | self.assertEquals(1, 2) -8 8 | self.assertEqual(3, 4) -9 9 | self.failUnlessAlmostEqual(1, 1.1) - -UP005.py:7:9: UP005 [*] `assertEquals` is deprecated, use `assertEqual` - | -5 | def test(self) -> None: -6 | self.assertEquals (1, 2) -7 | self.assertEquals(1, 2) - | ^^^^^^^^^^^^^^^^^ UP005 -8 | self.assertEqual(3, 4) -9 | self.failUnlessAlmostEqual(1, 1.1) - | - = help: Replace `assertEqual` with `assertEquals` - -ℹ Suggested fix -4 4 | class Suite(unittest.TestCase): -5 5 | def test(self) -> None: -6 6 | self.assertEquals (1, 2) -7 |- self.assertEquals(1, 2) - 7 |+ self.assertEqual(1, 2) -8 8 | self.assertEqual(3, 4) -9 9 | self.failUnlessAlmostEqual(1, 1.1) -10 10 | self.assertNotRegexpMatches("a", "b") - -UP005.py:9:9: UP005 [*] `failUnlessAlmostEqual` is deprecated, use `assertAlmostEqual` - | - 7 | self.assertEquals(1, 2) - 8 | self.assertEqual(3, 4) - 9 | self.failUnlessAlmostEqual(1, 1.1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP005 -10 | self.assertNotRegexpMatches("a", "b") - | - = help: Replace `assertAlmostEqual` with `failUnlessAlmostEqual` - -ℹ Suggested fix -6 6 | self.assertEquals (1, 2) -7 7 | self.assertEquals(1, 2) -8 8 | self.assertEqual(3, 4) -9 |- self.failUnlessAlmostEqual(1, 1.1) - 9 |+ self.assertAlmostEqual(1, 1.1) -10 10 | self.assertNotRegexpMatches("a", "b") - -UP005.py:10:9: UP005 [*] `assertNotRegexpMatches` is deprecated, use `assertNotRegex` - | - 8 | self.assertEqual(3, 4) - 9 | self.failUnlessAlmostEqual(1, 1.1) -10 | self.assertNotRegexpMatches("a", "b") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP005 - | - = help: Replace `assertNotRegex` with `assertNotRegexpMatches` - -ℹ Suggested fix -7 7 | self.assertEquals(1, 2) -8 8 | self.assertEqual(3, 4) -9 9 | self.failUnlessAlmostEqual(1, 1.1) -10 |- self.assertNotRegexpMatches("a", "b") - 10 |+ self.assertNotRegex("a", "b") - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP006_0.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP006_0.py.snap deleted file mode 100644 index 2e0f6ee588..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP006_0.py.snap +++ /dev/null @@ -1,284 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP006_0.py:4:10: UP006 [*] Use `list` instead of `typing.List` for type annotation - | -4 | def f(x: typing.List[str]) -> None: - | ^^^^^^^^^^^ UP006 -5 | ... - | - = help: Replace with `list` - -ℹ Fix -1 1 | import typing -2 2 | -3 3 | -4 |-def f(x: typing.List[str]) -> None: - 4 |+def f(x: list[str]) -> None: -5 5 | ... -6 6 | -7 7 | - -UP006_0.py:11:10: UP006 [*] Use `list` instead of `List` for type annotation - | -11 | def f(x: List[str]) -> None: - | ^^^^ UP006 -12 | ... - | - = help: Replace with `list` - -ℹ Fix -8 8 | from typing import List -9 9 | -10 10 | -11 |-def f(x: List[str]) -> None: - 11 |+def f(x: list[str]) -> None: -12 12 | ... -13 13 | -14 14 | - -UP006_0.py:18:10: UP006 [*] Use `list` instead of `t.List` for type annotation - | -18 | def f(x: t.List[str]) -> None: - | ^^^^^^ UP006 -19 | ... - | - = help: Replace with `list` - -ℹ Fix -15 15 | import typing as t -16 16 | -17 17 | -18 |-def f(x: t.List[str]) -> None: - 18 |+def f(x: list[str]) -> None: -19 19 | ... -20 20 | -21 21 | - -UP006_0.py:25:10: UP006 [*] Use `list` instead of `IList` for type annotation - | -25 | def f(x: IList[str]) -> None: - | ^^^^^ UP006 -26 | ... - | - = help: Replace with `list` - -ℹ Fix -22 22 | from typing import List as IList -23 23 | -24 24 | -25 |-def f(x: IList[str]) -> None: - 25 |+def f(x: list[str]) -> None: -26 26 | ... -27 27 | -28 28 | - -UP006_0.py:29:11: UP006 [*] Use `list` instead of `List` for type annotation - | -29 | def f(x: "List[str]") -> None: - | ^^^^ UP006 -30 | ... - | - = help: Replace with `list` - -ℹ Fix -26 26 | ... -27 27 | -28 28 | -29 |-def f(x: "List[str]") -> None: - 29 |+def f(x: "list[str]") -> None: -30 30 | ... -31 31 | -32 32 | - -UP006_0.py:33:12: UP006 [*] Use `list` instead of `List` for type annotation - | -33 | def f(x: r"List[str]") -> None: - | ^^^^ UP006 -34 | ... - | - = help: Replace with `list` - -ℹ Fix -30 30 | ... -31 31 | -32 32 | -33 |-def f(x: r"List[str]") -> None: - 33 |+def f(x: r"list[str]") -> None: -34 34 | ... -35 35 | -36 36 | - -UP006_0.py:37:11: UP006 [*] Use `list` instead of `List` for type annotation - | -37 | def f(x: "List[str]") -> None: - | ^^^^ UP006 -38 | ... - | - = help: Replace with `list` - -ℹ Fix -34 34 | ... -35 35 | -36 36 | -37 |-def f(x: "List[str]") -> None: - 37 |+def f(x: "list[str]") -> None: -38 38 | ... -39 39 | -40 40 | - -UP006_0.py:41:13: UP006 [*] Use `list` instead of `List` for type annotation - | -41 | def f(x: """List[str]""") -> None: - | ^^^^ UP006 -42 | ... - | - = help: Replace with `list` - -ℹ Fix -38 38 | ... -39 39 | -40 40 | -41 |-def f(x: """List[str]""") -> None: - 41 |+def f(x: """list[str]""") -> None: -42 42 | ... -43 43 | -44 44 | - -UP006_0.py:45:10: UP006 Use `list` instead of `List` for type annotation - | -45 | def f(x: "Li" "st[str]") -> None: - | ^^^^^^^^^^^^^^ UP006 -46 | ... - | - = help: Replace with `list` - -UP006_0.py:49:11: UP006 [*] Use `list` instead of `List` for type annotation - | -49 | def f(x: "List['List[str]']") -> None: - | ^^^^ UP006 -50 | ... - | - = help: Replace with `list` - -ℹ Fix -46 46 | ... -47 47 | -48 48 | -49 |-def f(x: "List['List[str]']") -> None: - 49 |+def f(x: "list['List[str]']") -> None: -50 50 | ... -51 51 | -52 52 | - -UP006_0.py:49:17: UP006 [*] Use `list` instead of `List` for type annotation - | -49 | def f(x: "List['List[str]']") -> None: - | ^^^^ UP006 -50 | ... - | - = help: Replace with `list` - -ℹ Fix -46 46 | ... -47 47 | -48 48 | -49 |-def f(x: "List['List[str]']") -> None: - 49 |+def f(x: "List['list[str]']") -> None: -50 50 | ... -51 51 | -52 52 | - -UP006_0.py:53:11: UP006 [*] Use `list` instead of `List` for type annotation - | -53 | def f(x: "List['Li' 'st[str]']") -> None: - | ^^^^ UP006 -54 | ... - | - = help: Replace with `list` - -ℹ Fix -50 50 | ... -51 51 | -52 52 | -53 |-def f(x: "List['Li' 'st[str]']") -> None: - 53 |+def f(x: "list['Li' 'st[str]']") -> None: -54 54 | ... -55 55 | -56 56 | - -UP006_0.py:53:16: UP006 Use `list` instead of `List` for type annotation - | -53 | def f(x: "List['Li' 'st[str]']") -> None: - | ^^^^^^^^^^^^^^ UP006 -54 | ... - | - = help: Replace with `list` - -UP006_0.py:57:10: UP006 Use `list` instead of `List` for type annotation - | -57 | def f(x: "Li" "st['List[str]']") -> None: - | ^^^^^^^^^^^^^^^^^^^^^^ UP006 -58 | ... - | - = help: Replace with `list` - -UP006_0.py:57:10: UP006 Use `list` instead of `List` for type annotation - | -57 | def f(x: "Li" "st['List[str]']") -> None: - | ^^^^^^^^^^^^^^^^^^^^^^ UP006 -58 | ... - | - = help: Replace with `list` - -UP006_0.py:61:10: UP006 [*] Use `collections.deque` instead of `typing.Deque` for type annotation - | -61 | def f(x: typing.Deque[str]) -> None: - | ^^^^^^^^^^^^ UP006 -62 | ... - | - = help: Replace with `collections.deque` - -ℹ Suggested fix -20 20 | -21 21 | -22 22 | from typing import List as IList - 23 |+from collections import deque -23 24 | -24 25 | -25 26 | def f(x: IList[str]) -> None: --------------------------------------------------------------------------------- -58 59 | ... -59 60 | -60 61 | -61 |-def f(x: typing.Deque[str]) -> None: - 62 |+def f(x: deque[str]) -> None: -62 63 | ... -63 64 | -64 65 | - -UP006_0.py:65:10: UP006 [*] Use `collections.defaultdict` instead of `typing.DefaultDict` for type annotation - | -65 | def f(x: typing.DefaultDict[str, str]) -> None: - | ^^^^^^^^^^^^^^^^^^ UP006 -66 | ... - | - = help: Replace with `collections.defaultdict` - -ℹ Suggested fix -20 20 | -21 21 | -22 22 | from typing import List as IList - 23 |+from collections import defaultdict -23 24 | -24 25 | -25 26 | def f(x: IList[str]) -> None: --------------------------------------------------------------------------------- -62 63 | ... -63 64 | -64 65 | -65 |-def f(x: typing.DefaultDict[str, str]) -> None: - 66 |+def f(x: defaultdict[str, str]) -> None: -66 67 | ... - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP006_1.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP006_1.py.snap deleted file mode 100644 index d0b32a6494..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP006_1.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP006_1.py:9:10: UP006 [*] Use `collections.defaultdict` instead of `typing.DefaultDict` for type annotation - | - 9 | def f(x: typing.DefaultDict[str, str]) -> None: - | ^^^^^^^^^^^^^^^^^^ UP006 -10 | ... - | - = help: Replace with `collections.defaultdict` - -ℹ Suggested fix -6 6 | from collections import defaultdict -7 7 | -8 8 | -9 |-def f(x: typing.DefaultDict[str, str]) -> None: - 9 |+def f(x: defaultdict[str, str]) -> None: -10 10 | ... - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP006_2.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP006_2.py.snap deleted file mode 100644 index 58c06666cb..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP006_2.py.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP006_2.py:7:10: UP006 Use `collections.defaultdict` instead of `typing.DefaultDict` for type annotation - | -7 | def f(x: typing.DefaultDict[str, str]) -> None: - | ^^^^^^^^^^^^^^^^^^ UP006 -8 | ... - | - = help: Replace with `collections.defaultdict` - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP006_3.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP006_3.py.snap deleted file mode 100644 index 3a724af5ed..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP006_3.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP006_3.py:7:11: UP006 [*] Use `collections.defaultdict` instead of `typing.DefaultDict` for type annotation - | -7 | def f(x: "typing.DefaultDict[str, str]") -> None: - | ^^^^^^^^^^^^^^^^^^ UP006 -8 | ... - | - = help: Replace with `collections.defaultdict` - -ℹ Suggested fix -4 4 | from collections import defaultdict -5 5 | -6 6 | -7 |-def f(x: "typing.DefaultDict[str, str]") -> None: - 7 |+def f(x: "defaultdict[str, str]") -> None: -8 8 | ... - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP007.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP007.py.snap deleted file mode 100644 index a78faedf87..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP007.py.snap +++ /dev/null @@ -1,417 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP007.py:6:10: UP007 [*] Use `X | Y` for type annotations - | -6 | def f(x: Optional[str]) -> None: - | ^^^^^^^^^^^^^ UP007 -7 | ... - | - = help: Convert to `X | Y` - -ℹ Suggested fix -3 3 | from typing import Union -4 4 | -5 5 | -6 |-def f(x: Optional[str]) -> None: - 6 |+def f(x: str | None) -> None: -7 7 | ... -8 8 | -9 9 | - -UP007.py:10:10: UP007 [*] Use `X | Y` for type annotations - | -10 | def f(x: typing.Optional[str]) -> None: - | ^^^^^^^^^^^^^^^^^^^^ UP007 -11 | ... - | - = help: Convert to `X | Y` - -ℹ Suggested fix -7 7 | ... -8 8 | -9 9 | -10 |-def f(x: typing.Optional[str]) -> None: - 10 |+def f(x: str | None) -> None: -11 11 | ... -12 12 | -13 13 | - -UP007.py:14:10: UP007 [*] Use `X | Y` for type annotations - | -14 | def f(x: Union[str, int, Union[float, bytes]]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP007 -15 | ... - | - = help: Convert to `X | Y` - -ℹ Suggested fix -11 11 | ... -12 12 | -13 13 | -14 |-def f(x: Union[str, int, Union[float, bytes]]) -> None: - 14 |+def f(x: str | (int | Union[float, bytes])) -> None: -15 15 | ... -16 16 | -17 17 | - -UP007.py:14:26: UP007 [*] Use `X | Y` for type annotations - | -14 | def f(x: Union[str, int, Union[float, bytes]]) -> None: - | ^^^^^^^^^^^^^^^^^^^ UP007 -15 | ... - | - = help: Convert to `X | Y` - -ℹ Suggested fix -11 11 | ... -12 12 | -13 13 | -14 |-def f(x: Union[str, int, Union[float, bytes]]) -> None: - 14 |+def f(x: Union[str, int, float | bytes]) -> None: -15 15 | ... -16 16 | -17 17 | - -UP007.py:18:10: UP007 [*] Use `X | Y` for type annotations - | -18 | def f(x: typing.Union[str, int]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^ UP007 -19 | ... - | - = help: Convert to `X | Y` - -ℹ Suggested fix -15 15 | ... -16 16 | -17 17 | -18 |-def f(x: typing.Union[str, int]) -> None: - 18 |+def f(x: str | int) -> None: -19 19 | ... -20 20 | -21 21 | - -UP007.py:22:10: UP007 [*] Use `X | Y` for type annotations - | -22 | def f(x: typing.Union[(str, int)]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP007 -23 | ... - | - = help: Convert to `X | Y` - -ℹ Suggested fix -19 19 | ... -20 20 | -21 21 | -22 |-def f(x: typing.Union[(str, int)]) -> None: - 22 |+def f(x: str | int) -> None: -23 23 | ... -24 24 | -25 25 | - -UP007.py:26:10: UP007 [*] Use `X | Y` for type annotations - | -26 | def f(x: typing.Union[(str, int), float]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP007 -27 | ... - | - = help: Convert to `X | Y` - -ℹ Suggested fix -23 23 | ... -24 24 | -25 25 | -26 |-def f(x: typing.Union[(str, int), float]) -> None: - 26 |+def f(x: str | int | float) -> None: -27 27 | ... -28 28 | -29 29 | - -UP007.py:30:10: UP007 [*] Use `X | Y` for type annotations - | -30 | def f(x: typing.Union[(int,)]) -> None: - | ^^^^^^^^^^^^^^^^^^^^ UP007 -31 | ... - | - = help: Convert to `X | Y` - -ℹ Suggested fix -27 27 | ... -28 28 | -29 29 | -30 |-def f(x: typing.Union[(int,)]) -> None: - 30 |+def f(x: int) -> None: -31 31 | ... -32 32 | -33 33 | - -UP007.py:34:10: UP007 [*] Use `X | Y` for type annotations - | -34 | def f(x: typing.Union[()]) -> None: - | ^^^^^^^^^^^^^^^^ UP007 -35 | ... - | - = help: Convert to `X | Y` - -ℹ Suggested fix -31 31 | ... -32 32 | -33 33 | -34 |-def f(x: typing.Union[()]) -> None: - 34 |+def f(x: ()) -> None: -35 35 | ... -36 36 | -37 37 | - -UP007.py:38:11: UP007 [*] Use `X | Y` for type annotations - | -38 | def f(x: "Union[str, int, Union[float, bytes]]") -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP007 -39 | ... - | - = help: Convert to `X | Y` - -ℹ Suggested fix -35 35 | ... -36 36 | -37 37 | -38 |-def f(x: "Union[str, int, Union[float, bytes]]") -> None: - 38 |+def f(x: "str | (int | Union[float, bytes])") -> None: -39 39 | ... -40 40 | -41 41 | - -UP007.py:38:27: UP007 [*] Use `X | Y` for type annotations - | -38 | def f(x: "Union[str, int, Union[float, bytes]]") -> None: - | ^^^^^^^^^^^^^^^^^^^ UP007 -39 | ... - | - = help: Convert to `X | Y` - -ℹ Suggested fix -35 35 | ... -36 36 | -37 37 | -38 |-def f(x: "Union[str, int, Union[float, bytes]]") -> None: - 38 |+def f(x: "Union[str, int, float | bytes]") -> None: -39 39 | ... -40 40 | -41 41 | - -UP007.py:42:11: UP007 [*] Use `X | Y` for type annotations - | -42 | def f(x: "typing.Union[str, int]") -> None: - | ^^^^^^^^^^^^^^^^^^^^^^ UP007 -43 | ... - | - = help: Convert to `X | Y` - -ℹ Suggested fix -39 39 | ... -40 40 | -41 41 | -42 |-def f(x: "typing.Union[str, int]") -> None: - 42 |+def f(x: "str | int") -> None: -43 43 | ... -44 44 | -45 45 | - -UP007.py:55:8: UP007 [*] Use `X | Y` for type annotations - | -54 | def f() -> None: -55 | x: Optional[str] - | ^^^^^^^^^^^^^ UP007 -56 | x = Optional[str] - | - = help: Convert to `X | Y` - -ℹ Suggested fix -52 52 | -53 53 | -54 54 | def f() -> None: -55 |- x: Optional[str] - 55 |+ x: str | None -56 56 | x = Optional[str] -57 57 | -58 58 | x = Union[str, int] - -UP007.py:56:9: UP007 Use `X | Y` for type annotations - | -54 | def f() -> None: -55 | x: Optional[str] -56 | x = Optional[str] - | ^^^^^^^^^^^^^ UP007 -57 | -58 | x = Union[str, int] - | - = help: Convert to `X | Y` - -UP007.py:58:9: UP007 Use `X | Y` for type annotations - | -56 | x = Optional[str] -57 | -58 | x = Union[str, int] - | ^^^^^^^^^^^^^^^ UP007 -59 | x = Union["str", "int"] -60 | x: Union[str, int] - | - = help: Convert to `X | Y` - -UP007.py:60:8: UP007 [*] Use `X | Y` for type annotations - | -58 | x = Union[str, int] -59 | x = Union["str", "int"] -60 | x: Union[str, int] - | ^^^^^^^^^^^^^^^ UP007 -61 | x: Union["str", "int"] - | - = help: Convert to `X | Y` - -ℹ Suggested fix -57 57 | -58 58 | x = Union[str, int] -59 59 | x = Union["str", "int"] -60 |- x: Union[str, int] - 60 |+ x: str | int -61 61 | x: Union["str", "int"] -62 62 | -63 63 | - -UP007.py:61:8: UP007 [*] Use `X | Y` for type annotations - | -59 | x = Union["str", "int"] -60 | x: Union[str, int] -61 | x: Union["str", "int"] - | ^^^^^^^^^^^^^^^^^^^ UP007 - | - = help: Convert to `X | Y` - -ℹ Suggested fix -58 58 | x = Union[str, int] -59 59 | x = Union["str", "int"] -60 60 | x: Union[str, int] -61 |- x: Union["str", "int"] - 61 |+ x: "str" | "int" -62 62 | -63 63 | -64 64 | def f(x: Union[int : float]) -> None: - -UP007.py:64:10: UP007 Use `X | Y` for type annotations - | -64 | def f(x: Union[int : float]) -> None: - | ^^^^^^^^^^^^^^^^^^ UP007 -65 | ... - | - = help: Convert to `X | Y` - -UP007.py:68:10: UP007 Use `X | Y` for type annotations - | -68 | def f(x: Union[str, int : float]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^ UP007 -69 | ... - | - = help: Convert to `X | Y` - -UP007.py:72:10: UP007 Use `X | Y` for type annotations - | -72 | def f(x: Union[x := int]) -> None: - | ^^^^^^^^^^^^^^^ UP007 -73 | ... - | - = help: Convert to `X | Y` - -UP007.py:76:10: UP007 Use `X | Y` for type annotations - | -76 | def f(x: Union[str, x := int]) -> None: - | ^^^^^^^^^^^^^^^^^^^^ UP007 -77 | ... - | - = help: Convert to `X | Y` - -UP007.py:80:10: UP007 Use `X | Y` for type annotations - | -80 | def f(x: Union[lambda: int]) -> None: - | ^^^^^^^^^^^^^^^^^^ UP007 -81 | ... - | - = help: Convert to `X | Y` - -UP007.py:84:10: UP007 Use `X | Y` for type annotations - | -84 | def f(x: Union[str, lambda: int]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^ UP007 -85 | ... - | - = help: Convert to `X | Y` - -UP007.py:88:10: UP007 Use `X | Y` for type annotations - | -88 | def f(x: Optional[int : float]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^ UP007 -89 | ... - | - = help: Convert to `X | Y` - -UP007.py:92:10: UP007 Use `X | Y` for type annotations - | -92 | def f(x: Optional[str, int : float]) -> None: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP007 -93 | ... - | - = help: Convert to `X | Y` - -UP007.py:96:10: UP007 Use `X | Y` for type annotations - | -96 | def f(x: Optional[int, float]) -> None: - | ^^^^^^^^^^^^^^^^^^^^ UP007 -97 | ... - | - = help: Convert to `X | Y` - -UP007.py:102:28: UP007 [*] Use `X | Y` for type annotations - | -100 | # Regression test for: https://github.com/astral-sh/ruff/issues/7131 -101 | class ServiceRefOrValue: -102 | service_specification: Optional[ - | ____________________________^ -103 | | list[ServiceSpecificationRef] -104 | | | list[ServiceSpecification] -105 | | ] = None - | |_____^ UP007 - | - = help: Convert to `X | Y` - -ℹ Suggested fix -99 99 | -100 100 | # Regression test for: https://github.com/astral-sh/ruff/issues/7131 -101 101 | class ServiceRefOrValue: -102 |- service_specification: Optional[ -103 |- list[ServiceSpecificationRef] -104 |- | list[ServiceSpecification] -105 |- ] = None - 102 |+ service_specification: list[ServiceSpecificationRef] | list[ServiceSpecification] | None = None -106 103 | -107 104 | -108 105 | # Regression test for: https://github.com/astral-sh/ruff/issues/7201 - -UP007.py:110:28: UP007 [*] Use `X | Y` for type annotations - | -108 | # Regression test for: https://github.com/astral-sh/ruff/issues/7201 -109 | class ServiceRefOrValue: -110 | service_specification: Optional[str]is not True = None - | ^^^^^^^^^^^^^ UP007 - | - = help: Convert to `X | Y` - -ℹ Suggested fix -107 107 | -108 108 | # Regression test for: https://github.com/astral-sh/ruff/issues/7201 -109 109 | class ServiceRefOrValue: -110 |- service_specification: Optional[str]is not True = None - 110 |+ service_specification: str | None is not True = None -111 111 | -112 112 | -113 113 | # Regression test for: https://github.com/astral-sh/ruff/issues/7452 - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP008.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP008.py.snap deleted file mode 100644 index afafaf4db3..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP008.py.snap +++ /dev/null @@ -1,110 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP008.py:17:23: UP008 [*] Use `super()` instead of `super(__class__, self)` - | -16 | def wrong(self): -17 | parent = super(Child, self) # wrong - | ^^^^^^^^^^^^^ UP008 -18 | super(Child, self).method # wrong -19 | super( - | - = help: Remove `super` parameters - -ℹ Suggested fix -14 14 | Parent.super(1, 2) # ok -15 15 | -16 16 | def wrong(self): -17 |- parent = super(Child, self) # wrong - 17 |+ parent = super() # wrong -18 18 | super(Child, self).method # wrong -19 19 | super( -20 20 | Child, - -UP008.py:18:14: UP008 [*] Use `super()` instead of `super(__class__, self)` - | -16 | def wrong(self): -17 | parent = super(Child, self) # wrong -18 | super(Child, self).method # wrong - | ^^^^^^^^^^^^^ UP008 -19 | super( -20 | Child, - | - = help: Remove `super` parameters - -ℹ Suggested fix -15 15 | -16 16 | def wrong(self): -17 17 | parent = super(Child, self) # wrong -18 |- super(Child, self).method # wrong - 18 |+ super().method # wrong -19 19 | super( -20 20 | Child, -21 21 | self, - -UP008.py:19:14: UP008 [*] Use `super()` instead of `super(__class__, self)` - | -17 | parent = super(Child, self) # wrong -18 | super(Child, self).method # wrong -19 | super( - | ______________^ -20 | | Child, -21 | | self, -22 | | ).method() # wrong - | |_________^ UP008 - | - = help: Remove `super` parameters - -ℹ Suggested fix -16 16 | def wrong(self): -17 17 | parent = super(Child, self) # wrong -18 18 | super(Child, self).method # wrong -19 |- super( -20 |- Child, -21 |- self, -22 |- ).method() # wrong - 19 |+ super().method() # wrong -23 20 | -24 21 | -25 22 | class BaseClass: - -UP008.py:36:14: UP008 [*] Use `super()` instead of `super(__class__, self)` - | -34 | class MyClass(BaseClass): -35 | def normal(self): -36 | super(MyClass, self).f() # can use super() - | ^^^^^^^^^^^^^^^ UP008 -37 | super().f() - | - = help: Remove `super` parameters - -ℹ Suggested fix -33 33 | -34 34 | class MyClass(BaseClass): -35 35 | def normal(self): -36 |- super(MyClass, self).f() # can use super() - 36 |+ super().f() # can use super() -37 37 | super().f() -38 38 | -39 39 | def different_argument(self, other): - -UP008.py:50:18: UP008 [*] Use `super()` instead of `super(__class__, self)` - | -49 | def inner_argument(self): -50 | super(MyClass, self).f() # can use super() - | ^^^^^^^^^^^^^^^ UP008 -51 | super().f() - | - = help: Remove `super` parameters - -ℹ Suggested fix -47 47 | super(MyClass, self).f() # CANNOT use super() -48 48 | -49 49 | def inner_argument(self): -50 |- super(MyClass, self).f() # can use super() - 50 |+ super().f() # can use super() -51 51 | super().f() -52 52 | -53 53 | outer_argument() - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_0.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_0.py.snap deleted file mode 100644 index 8ea47cf286..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_0.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP009_0.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary - | -1 | # coding=utf8 - | ^^^^^^^^^^^^^ UP009 -2 | -3 | print("Hello world") - | - = help: Remove unnecessary coding comment - -ℹ Fix -1 |-# coding=utf8 -2 1 | -3 2 | print("Hello world") - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_1.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_1.py.snap deleted file mode 100644 index 047ed4c711..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_1.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP009_1.py:2:1: UP009 [*] UTF-8 encoding declaration is unnecessary - | -1 | #!/usr/bin/python -2 | # -*- coding: utf-8 -*- - | ^^^^^^^^^^^^^^^^^^^^^^^ UP009 -3 | -4 | print('Hello world') - | - = help: Remove unnecessary coding comment - -ℹ Fix -1 1 | #!/usr/bin/python -2 |-# -*- coding: utf-8 -*- -3 2 | -4 3 | print('Hello world') - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_10.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_10.py.snap deleted file mode 100644 index 870ad3bf5d..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_10.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_2.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_2.py.snap deleted file mode 100644 index 870ad3bf5d..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_2.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_3.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_3.py.snap deleted file mode 100644 index 870ad3bf5d..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_3.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_4.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_4.py.snap deleted file mode 100644 index 870ad3bf5d..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_4.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_5.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_5.py.snap deleted file mode 100644 index 870ad3bf5d..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_5.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_6.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_6.py.snap deleted file mode 100644 index faf65dd7cc..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_6.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP009_6.py:1:2: UP009 [*] UTF-8 encoding declaration is unnecessary - | -1 | # coding=utf8 - | ^^^^^^^^^^^^^ UP009 -2 | print("Hello world") - | - = help: Remove unnecessary coding comment - -ℹ Fix -1 |- # coding=utf8 -2 1 | print("Hello world") -3 2 | -4 3 | """ - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_7.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_7.py.snap deleted file mode 100644 index 8e7962330d..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_7.py.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP009_7.py:1:2: UP009 [*] UTF-8 encoding declaration is unnecessary - | -1 | # coding=utf8 - | ^^^^^^^^^^^^^ UP009 -2 | print("Hello world") - | - = help: Remove unnecessary coding comment - -ℹ Fix -1 |- # coding=utf8 -2 1 | print("Hello world") -3 2 | -4 3 | """ - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_8.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_8.py.snap deleted file mode 100644 index 870ad3bf5d..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_8.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_9.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_9.py.snap deleted file mode 100644 index 870ad3bf5d..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP009_9.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP010.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP010.py.snap deleted file mode 100644 index 5cffbcafd8..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP010.py.snap +++ /dev/null @@ -1,185 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP010.py:1:1: UP010 [*] Unnecessary `__future__` imports `generators`, `nested_scopes` for target Python version - | -1 | from __future__ import nested_scopes, generators - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 -2 | from __future__ import with_statement, unicode_literals -3 | from __future__ import absolute_import, division - | - = help: Remove unnecessary `future` import - -ℹ Suggested fix -1 |-from __future__ import nested_scopes, generators -2 1 | from __future__ import with_statement, unicode_literals -3 2 | from __future__ import absolute_import, division -4 3 | from __future__ import generator_stop - -UP010.py:2:1: UP010 [*] Unnecessary `__future__` imports `unicode_literals`, `with_statement` for target Python version - | -1 | from __future__ import nested_scopes, generators -2 | from __future__ import with_statement, unicode_literals - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 -3 | from __future__ import absolute_import, division -4 | from __future__ import generator_stop - | - = help: Remove unnecessary `future` import - -ℹ Suggested fix -1 1 | from __future__ import nested_scopes, generators -2 |-from __future__ import with_statement, unicode_literals -3 2 | from __future__ import absolute_import, division -4 3 | from __future__ import generator_stop -5 4 | from __future__ import print_function, generator_stop - -UP010.py:3:1: UP010 [*] Unnecessary `__future__` imports `absolute_import`, `division` for target Python version - | -1 | from __future__ import nested_scopes, generators -2 | from __future__ import with_statement, unicode_literals -3 | from __future__ import absolute_import, division - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 -4 | from __future__ import generator_stop -5 | from __future__ import print_function, generator_stop - | - = help: Remove unnecessary `future` import - -ℹ Suggested fix -1 1 | from __future__ import nested_scopes, generators -2 2 | from __future__ import with_statement, unicode_literals -3 |-from __future__ import absolute_import, division -4 3 | from __future__ import generator_stop -5 4 | from __future__ import print_function, generator_stop -6 5 | from __future__ import invalid_module, generators - -UP010.py:4:1: UP010 [*] Unnecessary `__future__` import `generator_stop` for target Python version - | -2 | from __future__ import with_statement, unicode_literals -3 | from __future__ import absolute_import, division -4 | from __future__ import generator_stop - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 -5 | from __future__ import print_function, generator_stop -6 | from __future__ import invalid_module, generators - | - = help: Remove unnecessary `future` import - -ℹ Suggested fix -1 1 | from __future__ import nested_scopes, generators -2 2 | from __future__ import with_statement, unicode_literals -3 3 | from __future__ import absolute_import, division -4 |-from __future__ import generator_stop -5 4 | from __future__ import print_function, generator_stop -6 5 | from __future__ import invalid_module, generators -7 6 | - -UP010.py:5:1: UP010 [*] Unnecessary `__future__` imports `generator_stop`, `print_function` for target Python version - | -3 | from __future__ import absolute_import, division -4 | from __future__ import generator_stop -5 | from __future__ import print_function, generator_stop - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 -6 | from __future__ import invalid_module, generators - | - = help: Remove unnecessary `future` import - -ℹ Suggested fix -2 2 | from __future__ import with_statement, unicode_literals -3 3 | from __future__ import absolute_import, division -4 4 | from __future__ import generator_stop -5 |-from __future__ import print_function, generator_stop -6 5 | from __future__ import invalid_module, generators -7 6 | -8 7 | if True: - -UP010.py:6:1: UP010 [*] Unnecessary `__future__` import `generators` for target Python version - | -4 | from __future__ import generator_stop -5 | from __future__ import print_function, generator_stop -6 | from __future__ import invalid_module, generators - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 -7 | -8 | if True: - | - = help: Remove unnecessary `future` import - -ℹ Suggested fix -3 3 | from __future__ import absolute_import, division -4 4 | from __future__ import generator_stop -5 5 | from __future__ import print_function, generator_stop -6 |-from __future__ import invalid_module, generators - 6 |+from __future__ import invalid_module -7 7 | -8 8 | if True: -9 9 | from __future__ import generator_stop - -UP010.py:9:5: UP010 [*] Unnecessary `__future__` import `generator_stop` for target Python version - | - 8 | if True: - 9 | from __future__ import generator_stop - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 -10 | from __future__ import generators - | - = help: Remove unnecessary `future` import - -ℹ Suggested fix -6 6 | from __future__ import invalid_module, generators -7 7 | -8 8 | if True: -9 |- from __future__ import generator_stop -10 9 | from __future__ import generators -11 10 | -12 11 | if True: - -UP010.py:10:5: UP010 [*] Unnecessary `__future__` import `generators` for target Python version - | - 8 | if True: - 9 | from __future__ import generator_stop -10 | from __future__ import generators - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 -11 | -12 | if True: - | - = help: Remove unnecessary `future` import - -ℹ Suggested fix -7 7 | -8 8 | if True: -9 9 | from __future__ import generator_stop -10 |- from __future__ import generators -11 10 | -12 11 | if True: -13 12 | from __future__ import generator_stop - -UP010.py:13:5: UP010 [*] Unnecessary `__future__` import `generator_stop` for target Python version - | -12 | if True: -13 | from __future__ import generator_stop - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 -14 | from __future__ import invalid_module, generators - | - = help: Remove unnecessary `future` import - -ℹ Suggested fix -10 10 | from __future__ import generators -11 11 | -12 12 | if True: -13 |- from __future__ import generator_stop -14 13 | from __future__ import invalid_module, generators - -UP010.py:14:5: UP010 [*] Unnecessary `__future__` import `generators` for target Python version - | -12 | if True: -13 | from __future__ import generator_stop -14 | from __future__ import invalid_module, generators - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 - | - = help: Remove unnecessary `future` import - -ℹ Suggested fix -11 11 | -12 12 | if True: -13 13 | from __future__ import generator_stop -14 |- from __future__ import invalid_module, generators - 14 |+ from __future__ import invalid_module - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP011.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP011.py.snap deleted file mode 100644 index a52adcc916..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP011.py.snap +++ /dev/null @@ -1,81 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP011.py:5:21: UP011 [*] Unnecessary parentheses to `functools.lru_cache` - | -5 | @functools.lru_cache() - | ^^ UP011 -6 | def fixme(): -7 | pass - | - = help: Remove unnecessary parentheses - -ℹ Fix -2 2 | from functools import lru_cache -3 3 | -4 4 | -5 |-@functools.lru_cache() - 5 |+@functools.lru_cache -6 6 | def fixme(): -7 7 | pass -8 8 | - -UP011.py:10:11: UP011 [*] Unnecessary parentheses to `functools.lru_cache` - | -10 | @lru_cache() - | ^^ UP011 -11 | def fixme(): -12 | pass - | - = help: Remove unnecessary parentheses - -ℹ Fix -7 7 | pass -8 8 | -9 9 | -10 |-@lru_cache() - 10 |+@lru_cache -11 11 | def fixme(): -12 12 | pass -13 13 | - -UP011.py:16:21: UP011 [*] Unnecessary parentheses to `functools.lru_cache` - | -15 | @other_decorator -16 | @functools.lru_cache() - | ^^ UP011 -17 | def fixme(): -18 | pass - | - = help: Remove unnecessary parentheses - -ℹ Fix -13 13 | -14 14 | -15 15 | @other_decorator -16 |-@functools.lru_cache() - 16 |+@functools.lru_cache -17 17 | def fixme(): -18 18 | pass -19 19 | - -UP011.py:21:21: UP011 [*] Unnecessary parentheses to `functools.lru_cache` - | -21 | @functools.lru_cache() - | ^^ UP011 -22 | @other_decorator -23 | def fixme(): - | - = help: Remove unnecessary parentheses - -ℹ Fix -18 18 | pass -19 19 | -20 20 | -21 |-@functools.lru_cache() - 21 |+@functools.lru_cache -22 22 | @other_decorator -23 23 | def fixme(): -24 24 | pass - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP012.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP012.py.snap deleted file mode 100644 index 8e275e72c9..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP012.py.snap +++ /dev/null @@ -1,570 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP012.py:2:1: UP012 [*] Unnecessary call to `encode` as UTF-8 - | -1 | # ASCII literals should be replaced by a bytes literal -2 | "foo".encode("utf-8") # b"foo" - | ^^^^^^^^^^^^^^^^^^^^^ UP012 -3 | "foo".encode("u8") # b"foo" -4 | "foo".encode() # b"foo" - | - = help: Rewrite as bytes literal - -ℹ Fix -1 1 | # ASCII literals should be replaced by a bytes literal -2 |-"foo".encode("utf-8") # b"foo" - 2 |+b"foo" # b"foo" -3 3 | "foo".encode("u8") # b"foo" -4 4 | "foo".encode() # b"foo" -5 5 | "foo".encode("UTF8") # b"foo" - -UP012.py:3:1: UP012 [*] Unnecessary call to `encode` as UTF-8 - | -1 | # ASCII literals should be replaced by a bytes literal -2 | "foo".encode("utf-8") # b"foo" -3 | "foo".encode("u8") # b"foo" - | ^^^^^^^^^^^^^^^^^^ UP012 -4 | "foo".encode() # b"foo" -5 | "foo".encode("UTF8") # b"foo" - | - = help: Rewrite as bytes literal - -ℹ Fix -1 1 | # ASCII literals should be replaced by a bytes literal -2 2 | "foo".encode("utf-8") # b"foo" -3 |-"foo".encode("u8") # b"foo" - 3 |+b"foo" # b"foo" -4 4 | "foo".encode() # b"foo" -5 5 | "foo".encode("UTF8") # b"foo" -6 6 | U"foo".encode("utf-8") # b"foo" - -UP012.py:4:1: UP012 [*] Unnecessary call to `encode` as UTF-8 - | -2 | "foo".encode("utf-8") # b"foo" -3 | "foo".encode("u8") # b"foo" -4 | "foo".encode() # b"foo" - | ^^^^^^^^^^^^^^ UP012 -5 | "foo".encode("UTF8") # b"foo" -6 | U"foo".encode("utf-8") # b"foo" - | - = help: Rewrite as bytes literal - -ℹ Fix -1 1 | # ASCII literals should be replaced by a bytes literal -2 2 | "foo".encode("utf-8") # b"foo" -3 3 | "foo".encode("u8") # b"foo" -4 |-"foo".encode() # b"foo" - 4 |+b"foo" # b"foo" -5 5 | "foo".encode("UTF8") # b"foo" -6 6 | U"foo".encode("utf-8") # b"foo" -7 7 | "foo".encode(encoding="utf-8") # b"foo" - -UP012.py:5:1: UP012 [*] Unnecessary call to `encode` as UTF-8 - | -3 | "foo".encode("u8") # b"foo" -4 | "foo".encode() # b"foo" -5 | "foo".encode("UTF8") # b"foo" - | ^^^^^^^^^^^^^^^^^^^^ UP012 -6 | U"foo".encode("utf-8") # b"foo" -7 | "foo".encode(encoding="utf-8") # b"foo" - | - = help: Rewrite as bytes literal - -ℹ Fix -2 2 | "foo".encode("utf-8") # b"foo" -3 3 | "foo".encode("u8") # b"foo" -4 4 | "foo".encode() # b"foo" -5 |-"foo".encode("UTF8") # b"foo" - 5 |+b"foo" # b"foo" -6 6 | U"foo".encode("utf-8") # b"foo" -7 7 | "foo".encode(encoding="utf-8") # b"foo" -8 8 | """ - -UP012.py:6:1: UP012 [*] Unnecessary call to `encode` as UTF-8 - | -4 | "foo".encode() # b"foo" -5 | "foo".encode("UTF8") # b"foo" -6 | U"foo".encode("utf-8") # b"foo" - | ^^^^^^^^^^^^^^^^^^^^^^ UP012 -7 | "foo".encode(encoding="utf-8") # b"foo" -8 | """ - | - = help: Rewrite as bytes literal - -ℹ Fix -3 3 | "foo".encode("u8") # b"foo" -4 4 | "foo".encode() # b"foo" -5 5 | "foo".encode("UTF8") # b"foo" -6 |-U"foo".encode("utf-8") # b"foo" - 6 |+b"foo" # b"foo" -7 7 | "foo".encode(encoding="utf-8") # b"foo" -8 8 | """ -9 9 | Lorem - -UP012.py:7:1: UP012 [*] Unnecessary call to `encode` as UTF-8 - | -5 | "foo".encode("UTF8") # b"foo" -6 | U"foo".encode("utf-8") # b"foo" -7 | "foo".encode(encoding="utf-8") # b"foo" - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 -8 | """ -9 | Lorem - | - = help: Rewrite as bytes literal - -ℹ Fix -4 4 | "foo".encode() # b"foo" -5 5 | "foo".encode("UTF8") # b"foo" -6 6 | U"foo".encode("utf-8") # b"foo" -7 |-"foo".encode(encoding="utf-8") # b"foo" - 7 |+b"foo" # b"foo" -8 8 | """ -9 9 | Lorem -10 10 | - -UP012.py:8:1: UP012 [*] Unnecessary call to `encode` as UTF-8 - | - 6 | U"foo".encode("utf-8") # b"foo" - 7 | "foo".encode(encoding="utf-8") # b"foo" - 8 | / """ - 9 | | Lorem -10 | | -11 | | Ipsum -12 | | """.encode( -13 | | "utf-8" -14 | | ) - | |_^ UP012 -15 | ( -16 | "Lorem " - | - = help: Rewrite as bytes literal - -ℹ Fix -5 5 | "foo".encode("UTF8") # b"foo" -6 6 | U"foo".encode("utf-8") # b"foo" -7 7 | "foo".encode(encoding="utf-8") # b"foo" -8 |-""" - 8 |+b""" -9 9 | Lorem -10 10 | -11 11 | Ipsum -12 |-""".encode( -13 |- "utf-8" -14 |-) - 12 |+""" -15 13 | ( -16 14 | "Lorem " -17 15 | "Ipsum".encode() - -UP012.py:16:5: UP012 [*] Unnecessary call to `encode` as UTF-8 - | -14 | ) -15 | ( -16 | "Lorem " - | _____^ -17 | | "Ipsum".encode() - | |____________________^ UP012 -18 | ) -19 | ( - | - = help: Rewrite as bytes literal - -ℹ Fix -13 13 | "utf-8" -14 14 | ) -15 15 | ( -16 |- "Lorem " -17 |- "Ipsum".encode() - 16 |+ b"Lorem " - 17 |+ b"Ipsum" -18 18 | ) -19 19 | ( -20 20 | "Lorem " # Comment - -UP012.py:20:5: UP012 [*] Unnecessary call to `encode` as UTF-8 - | -18 | ) -19 | ( -20 | "Lorem " # Comment - | _____^ -21 | | "Ipsum".encode() # Comment - | |____________________^ UP012 -22 | ) -23 | ( - | - = help: Rewrite as bytes literal - -ℹ Fix -17 17 | "Ipsum".encode() -18 18 | ) -19 19 | ( -20 |- "Lorem " # Comment -21 |- "Ipsum".encode() # Comment - 20 |+ b"Lorem " # Comment - 21 |+ b"Ipsum" # Comment -22 22 | ) -23 23 | ( -24 24 | "Lorem " "Ipsum".encode() - -UP012.py:24:5: UP012 [*] Unnecessary call to `encode` as UTF-8 - | -22 | ) -23 | ( -24 | "Lorem " "Ipsum".encode() - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 -25 | ) - | - = help: Rewrite as bytes literal - -ℹ Fix -21 21 | "Ipsum".encode() # Comment -22 22 | ) -23 23 | ( -24 |- "Lorem " "Ipsum".encode() - 24 |+ b"Lorem " b"Ipsum" -25 25 | ) -26 26 | -27 27 | # `encode` on variables should not be processed. - -UP012.py:32:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` - | -31 | bar = "bar" -32 | f"foo{bar}".encode("utf-8") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 -33 | encoding = "latin" -34 | "foo".encode(encoding) - | - = help: Remove unnecessary `encoding` argument - -ℹ Fix -29 29 | string.encode("utf-8") -30 30 | -31 31 | bar = "bar" -32 |-f"foo{bar}".encode("utf-8") - 32 |+f"foo{bar}".encode() -33 33 | encoding = "latin" -34 34 | "foo".encode(encoding) -35 35 | f"foo{bar}".encode(encoding) - -UP012.py:36:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` - | -34 | "foo".encode(encoding) -35 | f"foo{bar}".encode(encoding) -36 | / f"{a=} {b=}".encode( -37 | | "utf-8", -38 | | ) - | |_^ UP012 -39 | -40 | # `encode` with custom args and kwargs should not be processed. - | - = help: Remove unnecessary `encoding` argument - -ℹ Fix -33 33 | encoding = "latin" -34 34 | "foo".encode(encoding) -35 35 | f"foo{bar}".encode(encoding) -36 |-f"{a=} {b=}".encode( -37 |- "utf-8", -38 |-) - 36 |+f"{a=} {b=}".encode() -39 37 | -40 38 | # `encode` with custom args and kwargs should not be processed. -41 39 | "foo".encode("utf-8", errors="replace") - -UP012.py:53:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` - | -52 | # Unicode literals should only be stripped of default encoding. -53 | "unicode text©".encode("utf-8") # "unicode text©".encode() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 -54 | "unicode text©".encode() -55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() - | - = help: Remove unnecessary `encoding` argument - -ℹ Fix -50 50 | "unicode text©".encode(encoding="utf-8", errors="replace") -51 51 | -52 52 | # Unicode literals should only be stripped of default encoding. -53 |-"unicode text©".encode("utf-8") # "unicode text©".encode() - 53 |+"unicode text©".encode() # "unicode text©".encode() -54 54 | "unicode text©".encode() -55 55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() -56 56 | - -UP012.py:55:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` - | -53 | "unicode text©".encode("utf-8") # "unicode text©".encode() -54 | "unicode text©".encode() -55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 -56 | -57 | r"foo\o".encode("utf-8") # br"foo\o" - | - = help: Remove unnecessary `encoding` argument - -ℹ Fix -52 52 | # Unicode literals should only be stripped of default encoding. -53 53 | "unicode text©".encode("utf-8") # "unicode text©".encode() -54 54 | "unicode text©".encode() -55 |-"unicode text©".encode(encoding="UTF8") # "unicode text©".encode() - 55 |+"unicode text©".encode() # "unicode text©".encode() -56 56 | -57 57 | r"foo\o".encode("utf-8") # br"foo\o" -58 58 | u"foo".encode("utf-8") # b"foo" - -UP012.py:57:1: UP012 [*] Unnecessary call to `encode` as UTF-8 - | -55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() -56 | -57 | r"foo\o".encode("utf-8") # br"foo\o" - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP012 -58 | u"foo".encode("utf-8") # b"foo" -59 | R"foo\o".encode("utf-8") # br"foo\o" - | - = help: Rewrite as bytes literal - -ℹ Fix -54 54 | "unicode text©".encode() -55 55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() -56 56 | -57 |-r"foo\o".encode("utf-8") # br"foo\o" - 57 |+br"foo\o" # br"foo\o" -58 58 | u"foo".encode("utf-8") # b"foo" -59 59 | R"foo\o".encode("utf-8") # br"foo\o" -60 60 | U"foo".encode("utf-8") # b"foo" - -UP012.py:58:1: UP012 [*] Unnecessary call to `encode` as UTF-8 - | -57 | r"foo\o".encode("utf-8") # br"foo\o" -58 | u"foo".encode("utf-8") # b"foo" - | ^^^^^^^^^^^^^^^^^^^^^^ UP012 -59 | R"foo\o".encode("utf-8") # br"foo\o" -60 | U"foo".encode("utf-8") # b"foo" - | - = help: Rewrite as bytes literal - -ℹ Fix -55 55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() -56 56 | -57 57 | r"foo\o".encode("utf-8") # br"foo\o" -58 |-u"foo".encode("utf-8") # b"foo" - 58 |+b"foo" # b"foo" -59 59 | R"foo\o".encode("utf-8") # br"foo\o" -60 60 | U"foo".encode("utf-8") # b"foo" -61 61 | print("foo".encode()) # print(b"foo") - -UP012.py:59:1: UP012 [*] Unnecessary call to `encode` as UTF-8 - | -57 | r"foo\o".encode("utf-8") # br"foo\o" -58 | u"foo".encode("utf-8") # b"foo" -59 | R"foo\o".encode("utf-8") # br"foo\o" - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP012 -60 | U"foo".encode("utf-8") # b"foo" -61 | print("foo".encode()) # print(b"foo") - | - = help: Rewrite as bytes literal - -ℹ Fix -56 56 | -57 57 | r"foo\o".encode("utf-8") # br"foo\o" -58 58 | u"foo".encode("utf-8") # b"foo" -59 |-R"foo\o".encode("utf-8") # br"foo\o" - 59 |+bR"foo\o" # br"foo\o" -60 60 | U"foo".encode("utf-8") # b"foo" -61 61 | print("foo".encode()) # print(b"foo") -62 62 | - -UP012.py:60:1: UP012 [*] Unnecessary call to `encode` as UTF-8 - | -58 | u"foo".encode("utf-8") # b"foo" -59 | R"foo\o".encode("utf-8") # br"foo\o" -60 | U"foo".encode("utf-8") # b"foo" - | ^^^^^^^^^^^^^^^^^^^^^^ UP012 -61 | print("foo".encode()) # print(b"foo") - | - = help: Rewrite as bytes literal - -ℹ Fix -57 57 | r"foo\o".encode("utf-8") # br"foo\o" -58 58 | u"foo".encode("utf-8") # b"foo" -59 59 | R"foo\o".encode("utf-8") # br"foo\o" -60 |-U"foo".encode("utf-8") # b"foo" - 60 |+b"foo" # b"foo" -61 61 | print("foo".encode()) # print(b"foo") -62 62 | -63 63 | # `encode` on parenthesized strings. - -UP012.py:61:7: UP012 [*] Unnecessary call to `encode` as UTF-8 - | -59 | R"foo\o".encode("utf-8") # br"foo\o" -60 | U"foo".encode("utf-8") # b"foo" -61 | print("foo".encode()) # print(b"foo") - | ^^^^^^^^^^^^^^ UP012 -62 | -63 | # `encode` on parenthesized strings. - | - = help: Rewrite as bytes literal - -ℹ Fix -58 58 | u"foo".encode("utf-8") # b"foo" -59 59 | R"foo\o".encode("utf-8") # br"foo\o" -60 60 | U"foo".encode("utf-8") # b"foo" -61 |-print("foo".encode()) # print(b"foo") - 61 |+print(b"foo") # print(b"foo") -62 62 | -63 63 | # `encode` on parenthesized strings. -64 64 | ( - -UP012.py:64:1: UP012 [*] Unnecessary call to `encode` as UTF-8 - | -63 | # `encode` on parenthesized strings. -64 | / ( -65 | | "abc" -66 | | "def" -67 | | ).encode() - | |__________^ UP012 -68 | -69 | (( - | - = help: Rewrite as bytes literal - -ℹ Fix -62 62 | -63 63 | # `encode` on parenthesized strings. -64 64 | ( -65 |- "abc" -66 |- "def" -67 |-).encode() - 65 |+ b"abc" - 66 |+ b"def" - 67 |+) -68 68 | -69 69 | (( -70 70 | "abc" - -UP012.py:69:1: UP012 [*] Unnecessary call to `encode` as UTF-8 - | -67 | ).encode() -68 | -69 | / (( -70 | | "abc" -71 | | "def" -72 | | )).encode() - | |___________^ UP012 -73 | -74 | (f"foo{bar}").encode("utf-8") - | - = help: Rewrite as bytes literal - -ℹ Fix -67 67 | ).encode() -68 68 | -69 69 | (( -70 |- "abc" -71 |- "def" -72 |-)).encode() - 70 |+ b"abc" - 71 |+ b"def" - 72 |+)) -73 73 | -74 74 | (f"foo{bar}").encode("utf-8") -75 75 | (f"foo{bar}").encode(encoding="utf-8") - -UP012.py:74:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` - | -72 | )).encode() -73 | -74 | (f"foo{bar}").encode("utf-8") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 -75 | (f"foo{bar}").encode(encoding="utf-8") -76 | ("unicode text©").encode("utf-8") - | - = help: Remove unnecessary `encoding` argument - -ℹ Fix -71 71 | "def" -72 72 | )).encode() -73 73 | -74 |-(f"foo{bar}").encode("utf-8") - 74 |+(f"foo{bar}").encode() -75 75 | (f"foo{bar}").encode(encoding="utf-8") -76 76 | ("unicode text©").encode("utf-8") -77 77 | ("unicode text©").encode(encoding="utf-8") - -UP012.py:75:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` - | -74 | (f"foo{bar}").encode("utf-8") -75 | (f"foo{bar}").encode(encoding="utf-8") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 -76 | ("unicode text©").encode("utf-8") -77 | ("unicode text©").encode(encoding="utf-8") - | - = help: Remove unnecessary `encoding` argument - -ℹ Fix -72 72 | )).encode() -73 73 | -74 74 | (f"foo{bar}").encode("utf-8") -75 |-(f"foo{bar}").encode(encoding="utf-8") - 75 |+(f"foo{bar}").encode() -76 76 | ("unicode text©").encode("utf-8") -77 77 | ("unicode text©").encode(encoding="utf-8") -78 78 | - -UP012.py:76:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` - | -74 | (f"foo{bar}").encode("utf-8") -75 | (f"foo{bar}").encode(encoding="utf-8") -76 | ("unicode text©").encode("utf-8") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 -77 | ("unicode text©").encode(encoding="utf-8") - | - = help: Remove unnecessary `encoding` argument - -ℹ Fix -73 73 | -74 74 | (f"foo{bar}").encode("utf-8") -75 75 | (f"foo{bar}").encode(encoding="utf-8") -76 |-("unicode text©").encode("utf-8") - 76 |+("unicode text©").encode() -77 77 | ("unicode text©").encode(encoding="utf-8") -78 78 | -79 79 | - -UP012.py:77:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` - | -75 | (f"foo{bar}").encode(encoding="utf-8") -76 | ("unicode text©").encode("utf-8") -77 | ("unicode text©").encode(encoding="utf-8") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 - | - = help: Remove unnecessary `encoding` argument - -ℹ Fix -74 74 | (f"foo{bar}").encode("utf-8") -75 75 | (f"foo{bar}").encode(encoding="utf-8") -76 76 | ("unicode text©").encode("utf-8") -77 |-("unicode text©").encode(encoding="utf-8") - 77 |+("unicode text©").encode() -78 78 | -79 79 | -80 80 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459882 - -UP012.py:82:17: UP012 [*] Unnecessary call to `encode` as UTF-8 - | -80 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459882 -81 | def _match_ignore(line): -82 | input=stdin and'\n'.encode()or None - | ^^^^^^^^^^^^^ UP012 - | - = help: Rewrite as bytes literal - -ℹ Fix -79 79 | -80 80 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459882 -81 81 | def _match_ignore(line): -82 |- input=stdin and'\n'.encode()or None - 82 |+ input=stdin and b'\n' or None - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP013.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP013.py.snap deleted file mode 100644 index ed75cc195f..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP013.py.snap +++ /dev/null @@ -1,255 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP013.py:5:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax - | -4 | # dict literal -5 | MyType = TypedDict("MyType", {"a": int, "b": str}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -6 | -7 | # dict call - | - = help: Convert `MyType` to class syntax - -ℹ Suggested fix -2 2 | import typing -3 3 | -4 4 | # dict literal -5 |-MyType = TypedDict("MyType", {"a": int, "b": str}) - 5 |+class MyType(TypedDict): - 6 |+ a: int - 7 |+ b: str -6 8 | -7 9 | # dict call -8 10 | MyType = TypedDict("MyType", dict(a=int, b=str)) - -UP013.py:8:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax - | - 7 | # dict call - 8 | MyType = TypedDict("MyType", dict(a=int, b=str)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 - 9 | -10 | # kwargs - | - = help: Convert `MyType` to class syntax - -ℹ Suggested fix -5 5 | MyType = TypedDict("MyType", {"a": int, "b": str}) -6 6 | -7 7 | # dict call -8 |-MyType = TypedDict("MyType", dict(a=int, b=str)) - 8 |+class MyType(TypedDict): - 9 |+ a: int - 10 |+ b: str -9 11 | -10 12 | # kwargs -11 13 | MyType = TypedDict("MyType", a=int, b=str) - -UP013.py:11:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax - | -10 | # kwargs -11 | MyType = TypedDict("MyType", a=int, b=str) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -12 | -13 | # Empty TypedDict - | - = help: Convert `MyType` to class syntax - -ℹ Suggested fix -8 8 | MyType = TypedDict("MyType", dict(a=int, b=str)) -9 9 | -10 10 | # kwargs -11 |-MyType = TypedDict("MyType", a=int, b=str) - 11 |+class MyType(TypedDict): - 12 |+ a: int - 13 |+ b: str -12 14 | -13 15 | # Empty TypedDict -14 16 | MyType = TypedDict("MyType") - -UP013.py:14:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax - | -13 | # Empty TypedDict -14 | MyType = TypedDict("MyType") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -15 | -16 | # Literal values - | - = help: Convert `MyType` to class syntax - -ℹ Suggested fix -11 11 | MyType = TypedDict("MyType", a=int, b=str) -12 12 | -13 13 | # Empty TypedDict -14 |-MyType = TypedDict("MyType") - 14 |+class MyType(TypedDict): - 15 |+ pass -15 16 | -16 17 | # Literal values -17 18 | MyType = TypedDict("MyType", {"a": "hello"}) - -UP013.py:17:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax - | -16 | # Literal values -17 | MyType = TypedDict("MyType", {"a": "hello"}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -18 | MyType = TypedDict("MyType", a="hello") - | - = help: Convert `MyType` to class syntax - -ℹ Suggested fix -14 14 | MyType = TypedDict("MyType") -15 15 | -16 16 | # Literal values -17 |-MyType = TypedDict("MyType", {"a": "hello"}) - 17 |+class MyType(TypedDict): - 18 |+ a: "hello" -18 19 | MyType = TypedDict("MyType", a="hello") -19 20 | -20 21 | # NotRequired - -UP013.py:18:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax - | -16 | # Literal values -17 | MyType = TypedDict("MyType", {"a": "hello"}) -18 | MyType = TypedDict("MyType", a="hello") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -19 | -20 | # NotRequired - | - = help: Convert `MyType` to class syntax - -ℹ Suggested fix -15 15 | -16 16 | # Literal values -17 17 | MyType = TypedDict("MyType", {"a": "hello"}) -18 |-MyType = TypedDict("MyType", a="hello") - 18 |+class MyType(TypedDict): - 19 |+ a: "hello" -19 20 | -20 21 | # NotRequired -21 22 | MyType = TypedDict("MyType", {"a": NotRequired[dict]}) - -UP013.py:21:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax - | -20 | # NotRequired -21 | MyType = TypedDict("MyType", {"a": NotRequired[dict]}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -22 | -23 | # total - | - = help: Convert `MyType` to class syntax - -ℹ Suggested fix -18 18 | MyType = TypedDict("MyType", a="hello") -19 19 | -20 20 | # NotRequired -21 |-MyType = TypedDict("MyType", {"a": NotRequired[dict]}) - 21 |+class MyType(TypedDict): - 22 |+ a: NotRequired[dict] -22 23 | -23 24 | # total -24 25 | MyType = TypedDict("MyType", {"x": int, "y": int}, total=False) - -UP013.py:24:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax - | -23 | # total -24 | MyType = TypedDict("MyType", {"x": int, "y": int}, total=False) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -25 | -26 | # using Literal type - | - = help: Convert `MyType` to class syntax - -ℹ Suggested fix -21 21 | MyType = TypedDict("MyType", {"a": NotRequired[dict]}) -22 22 | -23 23 | # total -24 |-MyType = TypedDict("MyType", {"x": int, "y": int}, total=False) - 24 |+class MyType(TypedDict, total=False): - 25 |+ x: int - 26 |+ y: int -25 27 | -26 28 | # using Literal type -27 29 | MyType = TypedDict("MyType", {"key": Literal["value"]}) - -UP013.py:27:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax - | -26 | # using Literal type -27 | MyType = TypedDict("MyType", {"key": Literal["value"]}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -28 | -29 | # using namespace TypedDict - | - = help: Convert `MyType` to class syntax - -ℹ Suggested fix -24 24 | MyType = TypedDict("MyType", {"x": int, "y": int}, total=False) -25 25 | -26 26 | # using Literal type -27 |-MyType = TypedDict("MyType", {"key": Literal["value"]}) - 27 |+class MyType(TypedDict): - 28 |+ key: Literal["value"] -28 29 | -29 30 | # using namespace TypedDict -30 31 | MyType = typing.TypedDict("MyType", {"key": int}) - -UP013.py:30:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax - | -29 | # using namespace TypedDict -30 | MyType = typing.TypedDict("MyType", {"key": int}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -31 | -32 | # invalid identifiers (OK) - | - = help: Convert `MyType` to class syntax - -ℹ Suggested fix -27 27 | MyType = TypedDict("MyType", {"key": Literal["value"]}) -28 28 | -29 29 | # using namespace TypedDict -30 |-MyType = typing.TypedDict("MyType", {"key": int}) - 30 |+class MyType(typing.TypedDict): - 31 |+ key: int -31 32 | -32 33 | # invalid identifiers (OK) -33 34 | MyType = TypedDict("MyType", {"in": int, "x-y": int}) - -UP013.py:40:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax - | -39 | # Empty dict literal -40 | MyType = TypedDict("MyType", {}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 -41 | -42 | # Empty dict call - | - = help: Convert `MyType` to class syntax - -ℹ Suggested fix -37 37 | MyType = TypedDict("MyType", {"a": int, "b": str, **c}) -38 38 | -39 39 | # Empty dict literal -40 |-MyType = TypedDict("MyType", {}) - 40 |+class MyType(TypedDict): - 41 |+ pass -41 42 | -42 43 | # Empty dict call -43 44 | MyType = TypedDict("MyType", dict()) - -UP013.py:43:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax - | -42 | # Empty dict call -43 | MyType = TypedDict("MyType", dict()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 - | - = help: Convert `MyType` to class syntax - -ℹ Suggested fix -40 40 | MyType = TypedDict("MyType", {}) -41 41 | -42 42 | # Empty dict call -43 |-MyType = TypedDict("MyType", dict()) - 43 |+class MyType(TypedDict): - 44 |+ pass - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP014.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP014.py.snap deleted file mode 100644 index ee8d7ca89f..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP014.py.snap +++ /dev/null @@ -1,112 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP014.py:5:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax - | -4 | # with complex annotations -5 | MyType = NamedTuple("MyType", [("a", int), ("b", tuple[str, ...])]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 -6 | -7 | # with namespace - | - = help: Convert `MyType` to class syntax - -ℹ Suggested fix -2 2 | import typing -3 3 | -4 4 | # with complex annotations -5 |-MyType = NamedTuple("MyType", [("a", int), ("b", tuple[str, ...])]) - 5 |+class MyType(NamedTuple): - 6 |+ a: int - 7 |+ b: tuple[str, ...] -6 8 | -7 9 | # with namespace -8 10 | MyType = typing.NamedTuple("MyType", [("a", int), ("b", str)]) - -UP014.py:8:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax - | - 7 | # with namespace - 8 | MyType = typing.NamedTuple("MyType", [("a", int), ("b", str)]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 - 9 | -10 | # invalid identifiers (OK) - | - = help: Convert `MyType` to class syntax - -ℹ Suggested fix -5 5 | MyType = NamedTuple("MyType", [("a", int), ("b", tuple[str, ...])]) -6 6 | -7 7 | # with namespace -8 |-MyType = typing.NamedTuple("MyType", [("a", int), ("b", str)]) - 8 |+class MyType(typing.NamedTuple): - 9 |+ a: int - 10 |+ b: str -9 11 | -10 12 | # invalid identifiers (OK) -11 13 | MyType = NamedTuple("MyType", [("x-y", int), ("b", tuple[str, ...])]) - -UP014.py:14:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax - | -13 | # no fields -14 | MyType = typing.NamedTuple("MyType") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 -15 | -16 | # empty fields - | - = help: Convert `MyType` to class syntax - -ℹ Suggested fix -11 11 | MyType = NamedTuple("MyType", [("x-y", int), ("b", tuple[str, ...])]) -12 12 | -13 13 | # no fields -14 |-MyType = typing.NamedTuple("MyType") - 14 |+class MyType(typing.NamedTuple): - 15 |+ pass -15 16 | -16 17 | # empty fields -17 18 | MyType = typing.NamedTuple("MyType", []) - -UP014.py:17:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax - | -16 | # empty fields -17 | MyType = typing.NamedTuple("MyType", []) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 -18 | -19 | # keywords - | - = help: Convert `MyType` to class syntax - -ℹ Suggested fix -14 14 | MyType = typing.NamedTuple("MyType") -15 15 | -16 16 | # empty fields -17 |-MyType = typing.NamedTuple("MyType", []) - 17 |+class MyType(typing.NamedTuple): - 18 |+ pass -18 19 | -19 20 | # keywords -20 21 | MyType = typing.NamedTuple("MyType", a=int, b=tuple[str, ...]) - -UP014.py:20:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax - | -19 | # keywords -20 | MyType = typing.NamedTuple("MyType", a=int, b=tuple[str, ...]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 -21 | -22 | # unfixable - | - = help: Convert `MyType` to class syntax - -ℹ Suggested fix -17 17 | MyType = typing.NamedTuple("MyType", []) -18 18 | -19 19 | # keywords -20 |-MyType = typing.NamedTuple("MyType", a=int, b=tuple[str, ...]) - 20 |+class MyType(typing.NamedTuple): - 21 |+ a: int - 22 |+ b: tuple[str, ...] -21 23 | -22 24 | # unfixable -23 25 | MyType = typing.NamedTuple("MyType", [("a", int)], [("b", str)]) - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP015.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP015.py.snap deleted file mode 100644 index b227068992..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP015.py.snap +++ /dev/null @@ -1,902 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP015.py:1:1: UP015 [*] Unnecessary open mode parameters - | -1 | open("foo", "U") - | ^^^^^^^^^^^^^^^^ UP015 -2 | open("foo", "Ur") -3 | open("foo", "Ub") - | - = help: Remove open mode parameters - -ℹ Fix -1 |-open("foo", "U") - 1 |+open("foo") -2 2 | open("foo", "Ur") -3 3 | open("foo", "Ub") -4 4 | open("foo", "rUb") - -UP015.py:2:1: UP015 [*] Unnecessary open mode parameters - | -1 | open("foo", "U") -2 | open("foo", "Ur") - | ^^^^^^^^^^^^^^^^^ UP015 -3 | open("foo", "Ub") -4 | open("foo", "rUb") - | - = help: Remove open mode parameters - -ℹ Fix -1 1 | open("foo", "U") -2 |-open("foo", "Ur") - 2 |+open("foo") -3 3 | open("foo", "Ub") -4 4 | open("foo", "rUb") -5 5 | open("foo", "r") - -UP015.py:3:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" - | -1 | open("foo", "U") -2 | open("foo", "Ur") -3 | open("foo", "Ub") - | ^^^^^^^^^^^^^^^^^ UP015 -4 | open("foo", "rUb") -5 | open("foo", "r") - | - = help: Replace with ""rb"" - -ℹ Fix -1 1 | open("foo", "U") -2 2 | open("foo", "Ur") -3 |-open("foo", "Ub") - 3 |+open("foo", "rb") -4 4 | open("foo", "rUb") -5 5 | open("foo", "r") -6 6 | open("foo", "rt") - -UP015.py:4:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" - | -2 | open("foo", "Ur") -3 | open("foo", "Ub") -4 | open("foo", "rUb") - | ^^^^^^^^^^^^^^^^^^ UP015 -5 | open("foo", "r") -6 | open("foo", "rt") - | - = help: Replace with ""rb"" - -ℹ Fix -1 1 | open("foo", "U") -2 2 | open("foo", "Ur") -3 3 | open("foo", "Ub") -4 |-open("foo", "rUb") - 4 |+open("foo", "rb") -5 5 | open("foo", "r") -6 6 | open("foo", "rt") -7 7 | open("f", "r", encoding="UTF-8") - -UP015.py:5:1: UP015 [*] Unnecessary open mode parameters - | -3 | open("foo", "Ub") -4 | open("foo", "rUb") -5 | open("foo", "r") - | ^^^^^^^^^^^^^^^^ UP015 -6 | open("foo", "rt") -7 | open("f", "r", encoding="UTF-8") - | - = help: Remove open mode parameters - -ℹ Fix -2 2 | open("foo", "Ur") -3 3 | open("foo", "Ub") -4 4 | open("foo", "rUb") -5 |-open("foo", "r") - 5 |+open("foo") -6 6 | open("foo", "rt") -7 7 | open("f", "r", encoding="UTF-8") -8 8 | open("f", "wt") - -UP015.py:6:1: UP015 [*] Unnecessary open mode parameters - | -4 | open("foo", "rUb") -5 | open("foo", "r") -6 | open("foo", "rt") - | ^^^^^^^^^^^^^^^^^ UP015 -7 | open("f", "r", encoding="UTF-8") -8 | open("f", "wt") - | - = help: Remove open mode parameters - -ℹ Fix -3 3 | open("foo", "Ub") -4 4 | open("foo", "rUb") -5 5 | open("foo", "r") -6 |-open("foo", "rt") - 6 |+open("foo") -7 7 | open("f", "r", encoding="UTF-8") -8 8 | open("f", "wt") -9 9 | - -UP015.py:7:1: UP015 [*] Unnecessary open mode parameters - | -5 | open("foo", "r") -6 | open("foo", "rt") -7 | open("f", "r", encoding="UTF-8") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -8 | open("f", "wt") - | - = help: Remove open mode parameters - -ℹ Fix -4 4 | open("foo", "rUb") -5 5 | open("foo", "r") -6 6 | open("foo", "rt") -7 |-open("f", "r", encoding="UTF-8") - 7 |+open("f", encoding="UTF-8") -8 8 | open("f", "wt") -9 9 | -10 10 | with open("foo", "U") as f: - -UP015.py:8:1: UP015 [*] Unnecessary open mode parameters, use ""w"" - | - 6 | open("foo", "rt") - 7 | open("f", "r", encoding="UTF-8") - 8 | open("f", "wt") - | ^^^^^^^^^^^^^^^ UP015 - 9 | -10 | with open("foo", "U") as f: - | - = help: Replace with ""w"" - -ℹ Fix -5 5 | open("foo", "r") -6 6 | open("foo", "rt") -7 7 | open("f", "r", encoding="UTF-8") -8 |-open("f", "wt") - 8 |+open("f", "w") -9 9 | -10 10 | with open("foo", "U") as f: -11 11 | pass - -UP015.py:10:6: UP015 [*] Unnecessary open mode parameters - | - 8 | open("f", "wt") - 9 | -10 | with open("foo", "U") as f: - | ^^^^^^^^^^^^^^^^ UP015 -11 | pass -12 | with open("foo", "Ur") as f: - | - = help: Remove open mode parameters - -ℹ Fix -7 7 | open("f", "r", encoding="UTF-8") -8 8 | open("f", "wt") -9 9 | -10 |-with open("foo", "U") as f: - 10 |+with open("foo") as f: -11 11 | pass -12 12 | with open("foo", "Ur") as f: -13 13 | pass - -UP015.py:12:6: UP015 [*] Unnecessary open mode parameters - | -10 | with open("foo", "U") as f: -11 | pass -12 | with open("foo", "Ur") as f: - | ^^^^^^^^^^^^^^^^^ UP015 -13 | pass -14 | with open("foo", "Ub") as f: - | - = help: Remove open mode parameters - -ℹ Fix -9 9 | -10 10 | with open("foo", "U") as f: -11 11 | pass -12 |-with open("foo", "Ur") as f: - 12 |+with open("foo") as f: -13 13 | pass -14 14 | with open("foo", "Ub") as f: -15 15 | pass - -UP015.py:14:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" - | -12 | with open("foo", "Ur") as f: -13 | pass -14 | with open("foo", "Ub") as f: - | ^^^^^^^^^^^^^^^^^ UP015 -15 | pass -16 | with open("foo", "rUb") as f: - | - = help: Replace with ""rb"" - -ℹ Fix -11 11 | pass -12 12 | with open("foo", "Ur") as f: -13 13 | pass -14 |-with open("foo", "Ub") as f: - 14 |+with open("foo", "rb") as f: -15 15 | pass -16 16 | with open("foo", "rUb") as f: -17 17 | pass - -UP015.py:16:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" - | -14 | with open("foo", "Ub") as f: -15 | pass -16 | with open("foo", "rUb") as f: - | ^^^^^^^^^^^^^^^^^^ UP015 -17 | pass -18 | with open("foo", "r") as f: - | - = help: Replace with ""rb"" - -ℹ Fix -13 13 | pass -14 14 | with open("foo", "Ub") as f: -15 15 | pass -16 |-with open("foo", "rUb") as f: - 16 |+with open("foo", "rb") as f: -17 17 | pass -18 18 | with open("foo", "r") as f: -19 19 | pass - -UP015.py:18:6: UP015 [*] Unnecessary open mode parameters - | -16 | with open("foo", "rUb") as f: -17 | pass -18 | with open("foo", "r") as f: - | ^^^^^^^^^^^^^^^^ UP015 -19 | pass -20 | with open("foo", "rt") as f: - | - = help: Remove open mode parameters - -ℹ Fix -15 15 | pass -16 16 | with open("foo", "rUb") as f: -17 17 | pass -18 |-with open("foo", "r") as f: - 18 |+with open("foo") as f: -19 19 | pass -20 20 | with open("foo", "rt") as f: -21 21 | pass - -UP015.py:20:6: UP015 [*] Unnecessary open mode parameters - | -18 | with open("foo", "r") as f: -19 | pass -20 | with open("foo", "rt") as f: - | ^^^^^^^^^^^^^^^^^ UP015 -21 | pass -22 | with open("foo", "r", encoding="UTF-8") as f: - | - = help: Remove open mode parameters - -ℹ Fix -17 17 | pass -18 18 | with open("foo", "r") as f: -19 19 | pass -20 |-with open("foo", "rt") as f: - 20 |+with open("foo") as f: -21 21 | pass -22 22 | with open("foo", "r", encoding="UTF-8") as f: -23 23 | pass - -UP015.py:22:6: UP015 [*] Unnecessary open mode parameters - | -20 | with open("foo", "rt") as f: -21 | pass -22 | with open("foo", "r", encoding="UTF-8") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -23 | pass -24 | with open("foo", "wt") as f: - | - = help: Remove open mode parameters - -ℹ Fix -19 19 | pass -20 20 | with open("foo", "rt") as f: -21 21 | pass -22 |-with open("foo", "r", encoding="UTF-8") as f: - 22 |+with open("foo", encoding="UTF-8") as f: -23 23 | pass -24 24 | with open("foo", "wt") as f: -25 25 | pass - -UP015.py:24:6: UP015 [*] Unnecessary open mode parameters, use ""w"" - | -22 | with open("foo", "r", encoding="UTF-8") as f: -23 | pass -24 | with open("foo", "wt") as f: - | ^^^^^^^^^^^^^^^^^ UP015 -25 | pass - | - = help: Replace with ""w"" - -ℹ Fix -21 21 | pass -22 22 | with open("foo", "r", encoding="UTF-8") as f: -23 23 | pass -24 |-with open("foo", "wt") as f: - 24 |+with open("foo", "w") as f: -25 25 | pass -26 26 | -27 27 | open(f("a", "b", "c"), "U") - -UP015.py:27:1: UP015 [*] Unnecessary open mode parameters - | -25 | pass -26 | -27 | open(f("a", "b", "c"), "U") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -28 | open(f("a", "b", "c"), "Ub") - | - = help: Remove open mode parameters - -ℹ Fix -24 24 | with open("foo", "wt") as f: -25 25 | pass -26 26 | -27 |-open(f("a", "b", "c"), "U") - 27 |+open(f("a", "b", "c")) -28 28 | open(f("a", "b", "c"), "Ub") -29 29 | -30 30 | with open(f("a", "b", "c"), "U") as f: - -UP015.py:28:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" - | -27 | open(f("a", "b", "c"), "U") -28 | open(f("a", "b", "c"), "Ub") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -29 | -30 | with open(f("a", "b", "c"), "U") as f: - | - = help: Replace with ""rb"" - -ℹ Fix -25 25 | pass -26 26 | -27 27 | open(f("a", "b", "c"), "U") -28 |-open(f("a", "b", "c"), "Ub") - 28 |+open(f("a", "b", "c"), "rb") -29 29 | -30 30 | with open(f("a", "b", "c"), "U") as f: -31 31 | pass - -UP015.py:30:6: UP015 [*] Unnecessary open mode parameters - | -28 | open(f("a", "b", "c"), "Ub") -29 | -30 | with open(f("a", "b", "c"), "U") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -31 | pass -32 | with open(f("a", "b", "c"), "Ub") as f: - | - = help: Remove open mode parameters - -ℹ Fix -27 27 | open(f("a", "b", "c"), "U") -28 28 | open(f("a", "b", "c"), "Ub") -29 29 | -30 |-with open(f("a", "b", "c"), "U") as f: - 30 |+with open(f("a", "b", "c")) as f: -31 31 | pass -32 32 | with open(f("a", "b", "c"), "Ub") as f: -33 33 | pass - -UP015.py:32:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" - | -30 | with open(f("a", "b", "c"), "U") as f: -31 | pass -32 | with open(f("a", "b", "c"), "Ub") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -33 | pass - | - = help: Replace with ""rb"" - -ℹ Fix -29 29 | -30 30 | with open(f("a", "b", "c"), "U") as f: -31 31 | pass -32 |-with open(f("a", "b", "c"), "Ub") as f: - 32 |+with open(f("a", "b", "c"), "rb") as f: -33 33 | pass -34 34 | -35 35 | with open("foo", "U") as fa, open("bar", "U") as fb: - -UP015.py:35:6: UP015 [*] Unnecessary open mode parameters - | -33 | pass -34 | -35 | with open("foo", "U") as fa, open("bar", "U") as fb: - | ^^^^^^^^^^^^^^^^ UP015 -36 | pass -37 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: - | - = help: Remove open mode parameters - -ℹ Fix -32 32 | with open(f("a", "b", "c"), "Ub") as f: -33 33 | pass -34 34 | -35 |-with open("foo", "U") as fa, open("bar", "U") as fb: - 35 |+with open("foo") as fa, open("bar", "U") as fb: -36 36 | pass -37 37 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: -38 38 | pass - -UP015.py:35:30: UP015 [*] Unnecessary open mode parameters - | -33 | pass -34 | -35 | with open("foo", "U") as fa, open("bar", "U") as fb: - | ^^^^^^^^^^^^^^^^ UP015 -36 | pass -37 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: - | - = help: Remove open mode parameters - -ℹ Fix -32 32 | with open(f("a", "b", "c"), "Ub") as f: -33 33 | pass -34 34 | -35 |-with open("foo", "U") as fa, open("bar", "U") as fb: - 35 |+with open("foo", "U") as fa, open("bar") as fb: -36 36 | pass -37 37 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: -38 38 | pass - -UP015.py:37:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" - | -35 | with open("foo", "U") as fa, open("bar", "U") as fb: -36 | pass -37 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: - | ^^^^^^^^^^^^^^^^^ UP015 -38 | pass - | - = help: Replace with ""rb"" - -ℹ Fix -34 34 | -35 35 | with open("foo", "U") as fa, open("bar", "U") as fb: -36 36 | pass -37 |-with open("foo", "Ub") as fa, open("bar", "Ub") as fb: - 37 |+with open("foo", "rb") as fa, open("bar", "Ub") as fb: -38 38 | pass -39 39 | -40 40 | open("foo", mode="U") - -UP015.py:37:31: UP015 [*] Unnecessary open mode parameters, use ""rb"" - | -35 | with open("foo", "U") as fa, open("bar", "U") as fb: -36 | pass -37 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: - | ^^^^^^^^^^^^^^^^^ UP015 -38 | pass - | - = help: Replace with ""rb"" - -ℹ Fix -34 34 | -35 35 | with open("foo", "U") as fa, open("bar", "U") as fb: -36 36 | pass -37 |-with open("foo", "Ub") as fa, open("bar", "Ub") as fb: - 37 |+with open("foo", "Ub") as fa, open("bar", "rb") as fb: -38 38 | pass -39 39 | -40 40 | open("foo", mode="U") - -UP015.py:40:1: UP015 [*] Unnecessary open mode parameters - | -38 | pass -39 | -40 | open("foo", mode="U") - | ^^^^^^^^^^^^^^^^^^^^^ UP015 -41 | open(name="foo", mode="U") -42 | open(mode="U", name="foo") - | - = help: Remove open mode parameters - -ℹ Fix -37 37 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: -38 38 | pass -39 39 | -40 |-open("foo", mode="U") - 40 |+open("foo") -41 41 | open(name="foo", mode="U") -42 42 | open(mode="U", name="foo") -43 43 | - -UP015.py:41:1: UP015 [*] Unnecessary open mode parameters - | -40 | open("foo", mode="U") -41 | open(name="foo", mode="U") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -42 | open(mode="U", name="foo") - | - = help: Remove open mode parameters - -ℹ Fix -38 38 | pass -39 39 | -40 40 | open("foo", mode="U") -41 |-open(name="foo", mode="U") - 41 |+open(name="foo") -42 42 | open(mode="U", name="foo") -43 43 | -44 44 | with open("foo", mode="U") as f: - -UP015.py:42:1: UP015 [*] Unnecessary open mode parameters - | -40 | open("foo", mode="U") -41 | open(name="foo", mode="U") -42 | open(mode="U", name="foo") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -43 | -44 | with open("foo", mode="U") as f: - | - = help: Remove open mode parameters - -ℹ Fix -39 39 | -40 40 | open("foo", mode="U") -41 41 | open(name="foo", mode="U") -42 |-open(mode="U", name="foo") - 42 |+open(name="foo") -43 43 | -44 44 | with open("foo", mode="U") as f: -45 45 | pass - -UP015.py:44:6: UP015 [*] Unnecessary open mode parameters - | -42 | open(mode="U", name="foo") -43 | -44 | with open("foo", mode="U") as f: - | ^^^^^^^^^^^^^^^^^^^^^ UP015 -45 | pass -46 | with open(name="foo", mode="U") as f: - | - = help: Remove open mode parameters - -ℹ Fix -41 41 | open(name="foo", mode="U") -42 42 | open(mode="U", name="foo") -43 43 | -44 |-with open("foo", mode="U") as f: - 44 |+with open("foo") as f: -45 45 | pass -46 46 | with open(name="foo", mode="U") as f: -47 47 | pass - -UP015.py:46:6: UP015 [*] Unnecessary open mode parameters - | -44 | with open("foo", mode="U") as f: -45 | pass -46 | with open(name="foo", mode="U") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -47 | pass -48 | with open(mode="U", name="foo") as f: - | - = help: Remove open mode parameters - -ℹ Fix -43 43 | -44 44 | with open("foo", mode="U") as f: -45 45 | pass -46 |-with open(name="foo", mode="U") as f: - 46 |+with open(name="foo") as f: -47 47 | pass -48 48 | with open(mode="U", name="foo") as f: -49 49 | pass - -UP015.py:48:6: UP015 [*] Unnecessary open mode parameters - | -46 | with open(name="foo", mode="U") as f: -47 | pass -48 | with open(mode="U", name="foo") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -49 | pass - | - = help: Remove open mode parameters - -ℹ Fix -45 45 | pass -46 46 | with open(name="foo", mode="U") as f: -47 47 | pass -48 |-with open(mode="U", name="foo") as f: - 48 |+with open(name="foo") as f: -49 49 | pass -50 50 | -51 51 | open("foo", mode="Ub") - -UP015.py:51:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" - | -49 | pass -50 | -51 | open("foo", mode="Ub") - | ^^^^^^^^^^^^^^^^^^^^^^ UP015 -52 | open(name="foo", mode="Ub") -53 | open(mode="Ub", name="foo") - | - = help: Replace with ""rb"" - -ℹ Fix -48 48 | with open(mode="U", name="foo") as f: -49 49 | pass -50 50 | -51 |-open("foo", mode="Ub") - 51 |+open("foo", mode="rb") -52 52 | open(name="foo", mode="Ub") -53 53 | open(mode="Ub", name="foo") -54 54 | - -UP015.py:52:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" - | -51 | open("foo", mode="Ub") -52 | open(name="foo", mode="Ub") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -53 | open(mode="Ub", name="foo") - | - = help: Replace with ""rb"" - -ℹ Fix -49 49 | pass -50 50 | -51 51 | open("foo", mode="Ub") -52 |-open(name="foo", mode="Ub") - 52 |+open(name="foo", mode="rb") -53 53 | open(mode="Ub", name="foo") -54 54 | -55 55 | with open("foo", mode="Ub") as f: - -UP015.py:53:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" - | -51 | open("foo", mode="Ub") -52 | open(name="foo", mode="Ub") -53 | open(mode="Ub", name="foo") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -54 | -55 | with open("foo", mode="Ub") as f: - | - = help: Replace with ""rb"" - -ℹ Fix -50 50 | -51 51 | open("foo", mode="Ub") -52 52 | open(name="foo", mode="Ub") -53 |-open(mode="Ub", name="foo") - 53 |+open(mode="rb", name="foo") -54 54 | -55 55 | with open("foo", mode="Ub") as f: -56 56 | pass - -UP015.py:55:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" - | -53 | open(mode="Ub", name="foo") -54 | -55 | with open("foo", mode="Ub") as f: - | ^^^^^^^^^^^^^^^^^^^^^^ UP015 -56 | pass -57 | with open(name="foo", mode="Ub") as f: - | - = help: Replace with ""rb"" - -ℹ Fix -52 52 | open(name="foo", mode="Ub") -53 53 | open(mode="Ub", name="foo") -54 54 | -55 |-with open("foo", mode="Ub") as f: - 55 |+with open("foo", mode="rb") as f: -56 56 | pass -57 57 | with open(name="foo", mode="Ub") as f: -58 58 | pass - -UP015.py:57:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" - | -55 | with open("foo", mode="Ub") as f: -56 | pass -57 | with open(name="foo", mode="Ub") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -58 | pass -59 | with open(mode="Ub", name="foo") as f: - | - = help: Replace with ""rb"" - -ℹ Fix -54 54 | -55 55 | with open("foo", mode="Ub") as f: -56 56 | pass -57 |-with open(name="foo", mode="Ub") as f: - 57 |+with open(name="foo", mode="rb") as f: -58 58 | pass -59 59 | with open(mode="Ub", name="foo") as f: -60 60 | pass - -UP015.py:59:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" - | -57 | with open(name="foo", mode="Ub") as f: -58 | pass -59 | with open(mode="Ub", name="foo") as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -60 | pass - | - = help: Replace with ""rb"" - -ℹ Fix -56 56 | pass -57 57 | with open(name="foo", mode="Ub") as f: -58 58 | pass -59 |-with open(mode="Ub", name="foo") as f: - 59 |+with open(mode="rb", name="foo") as f: -60 60 | pass -61 61 | -62 62 | open(file="foo", mode='U', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - -UP015.py:62:1: UP015 [*] Unnecessary open mode parameters - | -60 | pass -61 | -62 | open(file="foo", mode='U', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -63 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') -64 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) - | - = help: Remove open mode parameters - -ℹ Fix -59 59 | with open(mode="Ub", name="foo") as f: -60 60 | pass -61 61 | -62 |-open(file="foo", mode='U', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - 62 |+open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -63 63 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') -64 64 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) -65 65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - -UP015.py:63:1: UP015 [*] Unnecessary open mode parameters - | -62 | open(file="foo", mode='U', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -63 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -64 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) -65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - | - = help: Remove open mode parameters - -ℹ Fix -60 60 | pass -61 61 | -62 62 | open(file="foo", mode='U', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -63 |-open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') - 63 |+open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -64 64 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) -65 65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -66 66 | - -UP015.py:64:1: UP015 [*] Unnecessary open mode parameters - | -62 | open(file="foo", mode='U', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -63 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') -64 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - | - = help: Remove open mode parameters - -ℹ Fix -61 61 | -62 62 | open(file="foo", mode='U', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -63 63 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') -64 |-open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) - 64 |+open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -65 65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -66 66 | -67 67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - -UP015.py:65:1: UP015 [*] Unnecessary open mode parameters - | -63 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') -64 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) -65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -66 | -67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - | - = help: Remove open mode parameters - -ℹ Fix -62 62 | open(file="foo", mode='U', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -63 63 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') -64 64 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) -65 |-open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - 65 |+open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -66 66 | -67 67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -68 68 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') - -UP015.py:67:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" - | -65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -66 | -67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -68 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') -69 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) - | - = help: Replace with ""rb"" - -ℹ Fix -64 64 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) -65 65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -66 66 | -67 |-open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - 67 |+open(file="foo", mode="rb", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -68 68 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') -69 69 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) -70 70 | open(mode='Ub', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - -UP015.py:68:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" - | -67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -68 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -69 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) -70 | open(mode='Ub', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - | - = help: Replace with ""rb"" - -ℹ Fix -65 65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -66 66 | -67 67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -68 |-open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') - 68 |+open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode="rb") -69 69 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) -70 70 | open(mode='Ub', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -71 71 | - -UP015.py:69:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" - | -67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -68 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') -69 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -70 | open(mode='Ub', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - | - = help: Replace with ""rb"" - -ℹ Fix -66 66 | -67 67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -68 68 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') -69 |-open(file="foo", buffering=- 1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) - 69 |+open(file="foo", buffering=- 1, encoding=None, errors=None, mode="rb", newline=None, closefd=True, opener=None) -70 70 | open(mode='Ub', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -71 71 | -72 72 | open = 1 - -UP015.py:70:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" - | -68 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') -69 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) -70 | open(mode='Ub', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 -71 | -72 | open = 1 - | - = help: Replace with ""rb"" - -ℹ Fix -67 67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -68 68 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') -69 69 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) -70 |-open(mode='Ub', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) - 70 |+open(mode="rb", file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -71 71 | -72 72 | open = 1 -73 73 | open("foo", "U") - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP018.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP018.py.snap deleted file mode 100644 index ee269a7004..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP018.py.snap +++ /dev/null @@ -1,317 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP018.py:37:1: UP018 [*] Unnecessary `str` call (rewrite as a literal) - | -36 | # These become string or byte literals -37 | str() - | ^^^^^ UP018 -38 | str("foo") -39 | str(""" - | - = help: Replace with empty string - -ℹ Fix -34 34 | int().denominator -35 35 | -36 36 | # These become string or byte literals -37 |-str() - 37 |+"" -38 38 | str("foo") -39 39 | str(""" -40 40 | foo""") - -UP018.py:38:1: UP018 [*] Unnecessary `str` call (rewrite as a literal) - | -36 | # These become string or byte literals -37 | str() -38 | str("foo") - | ^^^^^^^^^^ UP018 -39 | str(""" -40 | foo""") - | - = help: Replace with empty string - -ℹ Fix -35 35 | -36 36 | # These become string or byte literals -37 37 | str() -38 |-str("foo") - 38 |+"foo" -39 39 | str(""" -40 40 | foo""") -41 41 | bytes() - -UP018.py:39:1: UP018 [*] Unnecessary `str` call (rewrite as a literal) - | -37 | str() -38 | str("foo") -39 | / str(""" -40 | | foo""") - | |_______^ UP018 -41 | bytes() -42 | bytes(b"foo") - | - = help: Replace with empty string - -ℹ Fix -36 36 | # These become string or byte literals -37 37 | str() -38 38 | str("foo") -39 |-str(""" -40 |-foo""") - 39 |+""" - 40 |+foo""" -41 41 | bytes() -42 42 | bytes(b"foo") -43 43 | bytes(b""" - -UP018.py:41:1: UP018 [*] Unnecessary `bytes` call (rewrite as a literal) - | -39 | str(""" -40 | foo""") -41 | bytes() - | ^^^^^^^ UP018 -42 | bytes(b"foo") -43 | bytes(b""" - | - = help: Replace with empty bytes - -ℹ Fix -38 38 | str("foo") -39 39 | str(""" -40 40 | foo""") -41 |-bytes() - 41 |+b"" -42 42 | bytes(b"foo") -43 43 | bytes(b""" -44 44 | foo""") - -UP018.py:42:1: UP018 [*] Unnecessary `bytes` call (rewrite as a literal) - | -40 | foo""") -41 | bytes() -42 | bytes(b"foo") - | ^^^^^^^^^^^^^ UP018 -43 | bytes(b""" -44 | foo""") - | - = help: Replace with empty bytes - -ℹ Fix -39 39 | str(""" -40 40 | foo""") -41 41 | bytes() -42 |-bytes(b"foo") - 42 |+b"foo" -43 43 | bytes(b""" -44 44 | foo""") -45 45 | f"{str()}" - -UP018.py:43:1: UP018 [*] Unnecessary `bytes` call (rewrite as a literal) - | -41 | bytes() -42 | bytes(b"foo") -43 | / bytes(b""" -44 | | foo""") - | |_______^ UP018 -45 | f"{str()}" -46 | int() - | - = help: Replace with empty bytes - -ℹ Fix -40 40 | foo""") -41 41 | bytes() -42 42 | bytes(b"foo") -43 |-bytes(b""" -44 |-foo""") - 43 |+b""" - 44 |+foo""" -45 45 | f"{str()}" -46 46 | int() -47 47 | int(1) - -UP018.py:45:4: UP018 [*] Unnecessary `str` call (rewrite as a literal) - | -43 | bytes(b""" -44 | foo""") -45 | f"{str()}" - | ^^^^^ UP018 -46 | int() -47 | int(1) - | - = help: Replace with empty string - -ℹ Fix -42 42 | bytes(b"foo") -43 43 | bytes(b""" -44 44 | foo""") -45 |-f"{str()}" - 45 |+f"{''}" -46 46 | int() -47 47 | int(1) -48 48 | float() - -UP018.py:46:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) - | -44 | foo""") -45 | f"{str()}" -46 | int() - | ^^^^^ UP018 -47 | int(1) -48 | float() - | - = help: Replace with 0 - -ℹ Fix -43 43 | bytes(b""" -44 44 | foo""") -45 45 | f"{str()}" -46 |-int() - 46 |+0 -47 47 | int(1) -48 48 | float() -49 49 | float(1.0) - -UP018.py:47:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) - | -45 | f"{str()}" -46 | int() -47 | int(1) - | ^^^^^^ UP018 -48 | float() -49 | float(1.0) - | - = help: Replace with 0 - -ℹ Fix -44 44 | foo""") -45 45 | f"{str()}" -46 46 | int() -47 |-int(1) - 47 |+1 -48 48 | float() -49 49 | float(1.0) -50 50 | bool() - -UP018.py:48:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) - | -46 | int() -47 | int(1) -48 | float() - | ^^^^^^^ UP018 -49 | float(1.0) -50 | bool() - | - = help: Replace with 0.0 - -ℹ Fix -45 45 | f"{str()}" -46 46 | int() -47 47 | int(1) -48 |-float() - 48 |+0.0 -49 49 | float(1.0) -50 50 | bool() -51 51 | bool(True) - -UP018.py:49:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) - | -47 | int(1) -48 | float() -49 | float(1.0) - | ^^^^^^^^^^ UP018 -50 | bool() -51 | bool(True) - | - = help: Replace with 0.0 - -ℹ Fix -46 46 | int() -47 47 | int(1) -48 48 | float() -49 |-float(1.0) - 49 |+1.0 -50 50 | bool() -51 51 | bool(True) -52 52 | bool(False) - -UP018.py:50:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal) - | -48 | float() -49 | float(1.0) -50 | bool() - | ^^^^^^ UP018 -51 | bool(True) -52 | bool(False) - | - = help: Replace with `False` - -ℹ Fix -47 47 | int(1) -48 48 | float() -49 49 | float(1.0) -50 |-bool() - 50 |+False -51 51 | bool(True) -52 52 | bool(False) -53 53 | - -UP018.py:51:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal) - | -49 | float(1.0) -50 | bool() -51 | bool(True) - | ^^^^^^^^^^ UP018 -52 | bool(False) - | - = help: Replace with `False` - -ℹ Fix -48 48 | float() -49 49 | float(1.0) -50 50 | bool() -51 |-bool(True) - 51 |+True -52 52 | bool(False) -53 53 | -54 54 | # These become a literal but retain parentheses - -UP018.py:52:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal) - | -50 | bool() -51 | bool(True) -52 | bool(False) - | ^^^^^^^^^^^ UP018 -53 | -54 | # These become a literal but retain parentheses - | - = help: Replace with `False` - -ℹ Fix -49 49 | float(1.0) -50 50 | bool() -51 51 | bool(True) -52 |-bool(False) - 52 |+False -53 53 | -54 54 | # These become a literal but retain parentheses -55 55 | int(1).denominator - -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 - | - = help: Replace with 0 - -ℹ Fix -52 52 | bool(False) -53 53 | -54 54 | # These become a literal but retain parentheses -55 |-int(1).denominator - 55 |+(1).denominator - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP019.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP019.py.snap deleted file mode 100644 index 291ef30d33..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP019.py.snap +++ /dev/null @@ -1,74 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP019.py:7:22: UP019 [*] `typing.Text` is deprecated, use `str` - | -7 | def print_word(word: Text) -> None: - | ^^^^ UP019 -8 | print(word) - | - = help: Replace with `str` - -ℹ Fix -4 4 | from typing import Text as Goodbye -5 5 | -6 6 | -7 |-def print_word(word: Text) -> None: - 7 |+def print_word(word: str) -> None: -8 8 | print(word) -9 9 | -10 10 | - -UP019.py:11:29: UP019 [*] `typing.Text` is deprecated, use `str` - | -11 | def print_second_word(word: typing.Text) -> None: - | ^^^^^^^^^^^ UP019 -12 | print(word) - | - = help: Replace with `str` - -ℹ Fix -8 8 | print(word) -9 9 | -10 10 | -11 |-def print_second_word(word: typing.Text) -> None: - 11 |+def print_second_word(word: str) -> None: -12 12 | print(word) -13 13 | -14 14 | - -UP019.py:15:28: UP019 [*] `typing.Text` is deprecated, use `str` - | -15 | def print_third_word(word: Hello.Text) -> None: - | ^^^^^^^^^^ UP019 -16 | print(word) - | - = help: Replace with `str` - -ℹ Fix -12 12 | print(word) -13 13 | -14 14 | -15 |-def print_third_word(word: Hello.Text) -> None: - 15 |+def print_third_word(word: str) -> None: -16 16 | print(word) -17 17 | -18 18 | - -UP019.py:19:29: UP019 [*] `typing.Text` is deprecated, use `str` - | -19 | def print_fourth_word(word: Goodbye) -> None: - | ^^^^^^^ UP019 -20 | print(word) - | - = help: Replace with `str` - -ℹ Fix -16 16 | print(word) -17 17 | -18 18 | -19 |-def print_fourth_word(word: Goodbye) -> None: - 19 |+def print_fourth_word(word: str) -> None: -20 20 | print(word) - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP020.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP020.py.snap deleted file mode 100644 index 7379f29b7d..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP020.py.snap +++ /dev/null @@ -1,33 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP020.py:3:6: UP020 [*] Use builtin `open` - | -1 | import io -2 | -3 | with io.open("f.txt", mode="r", buffering=-1, **kwargs) as f: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP020 -4 | print(f.read()) - | - = help: Replace with builtin `open` - -ℹ Suggested fix -1 1 | import io -2 2 | -3 |-with io.open("f.txt", mode="r", buffering=-1, **kwargs) as f: - 3 |+with open("f.txt", mode="r", buffering=-1, **kwargs) as f: -4 4 | print(f.read()) -5 5 | -6 6 | from io import open - -UP020.py:8:6: UP020 Use builtin `open` - | -6 | from io import open -7 | -8 | with open("f.txt") as f: - | ^^^^^^^^^^^^^ UP020 -9 | print(f.read()) - | - = help: Replace with builtin `open` - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP021.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP021.py.snap deleted file mode 100644 index 6e82b0a418..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP021.py.snap +++ /dev/null @@ -1,65 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP021.py:5:25: UP021 [*] `universal_newlines` is deprecated, use `text` - | -4 | # Errors -5 | subprocess.run(["foo"], universal_newlines=True, check=True) - | ^^^^^^^^^^^^^^^^^^ UP021 -6 | subprocess.run(["foo"], universal_newlines=True, text=True) -7 | run(["foo"], universal_newlines=True, check=False) - | - = help: Replace with `text` keyword argument - -ℹ Suggested fix -2 2 | from subprocess import run -3 3 | -4 4 | # Errors -5 |-subprocess.run(["foo"], universal_newlines=True, check=True) - 5 |+subprocess.run(["foo"], text=True, check=True) -6 6 | subprocess.run(["foo"], universal_newlines=True, text=True) -7 7 | run(["foo"], universal_newlines=True, check=False) -8 8 | - -UP021.py:6:25: UP021 [*] `universal_newlines` is deprecated, use `text` - | -4 | # Errors -5 | subprocess.run(["foo"], universal_newlines=True, check=True) -6 | subprocess.run(["foo"], universal_newlines=True, text=True) - | ^^^^^^^^^^^^^^^^^^ UP021 -7 | run(["foo"], universal_newlines=True, check=False) - | - = help: Replace with `text` keyword argument - -ℹ Suggested fix -3 3 | -4 4 | # Errors -5 5 | subprocess.run(["foo"], universal_newlines=True, check=True) -6 |-subprocess.run(["foo"], universal_newlines=True, text=True) - 6 |+subprocess.run(["foo"], text=True) -7 7 | run(["foo"], universal_newlines=True, check=False) -8 8 | -9 9 | # OK - -UP021.py:7:14: UP021 [*] `universal_newlines` is deprecated, use `text` - | -5 | subprocess.run(["foo"], universal_newlines=True, check=True) -6 | subprocess.run(["foo"], universal_newlines=True, text=True) -7 | run(["foo"], universal_newlines=True, check=False) - | ^^^^^^^^^^^^^^^^^^ UP021 -8 | -9 | # OK - | - = help: Replace with `text` keyword argument - -ℹ Suggested fix -4 4 | # Errors -5 5 | subprocess.run(["foo"], universal_newlines=True, check=True) -6 6 | subprocess.run(["foo"], universal_newlines=True, text=True) -7 |-run(["foo"], universal_newlines=True, check=False) - 7 |+run(["foo"], text=True, check=False) -8 8 | -9 9 | # OK -10 10 | subprocess.run(["foo"], check=True) - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP022.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP022.py.snap deleted file mode 100644 index 5d8ff0b364..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP022.py.snap +++ /dev/null @@ -1,219 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP022.py:4:10: UP022 [*] Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` - | -2 | import subprocess -3 | -4 | output = run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP022 -5 | -6 | output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - | - = help: Replace with `capture_output` keyword argument - -ℹ Suggested fix -1 1 | from subprocess import run -2 2 | import subprocess -3 3 | -4 |-output = run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - 4 |+output = run(["foo"], capture_output=True) -5 5 | -6 6 | output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) -7 7 | - -UP022.py:6:10: UP022 [*] Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` - | -4 | output = run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) -5 | -6 | output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP022 -7 | -8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) - | - = help: Replace with `capture_output` keyword argument - -ℹ Suggested fix -3 3 | -4 4 | output = run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) -5 5 | -6 |-output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - 6 |+output = subprocess.run(["foo"], capture_output=True) -7 7 | -8 8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) -9 9 | - -UP022.py:8:10: UP022 [*] Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` - | - 6 | output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - 7 | - 8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP022 - 9 | -10 | output = subprocess.run( - | - = help: Replace with `capture_output` keyword argument - -ℹ Suggested fix -5 5 | -6 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) - 8 |+output = subprocess.run(capture_output=True, args=["foo"]) -9 9 | -10 10 | output = subprocess.run( -11 11 | ["foo"], stdout=subprocess.PIPE, check=True, stderr=subprocess.PIPE - -UP022.py:10:10: UP022 [*] Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` - | - 8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) - 9 | -10 | output = subprocess.run( - | __________^ -11 | | ["foo"], stdout=subprocess.PIPE, check=True, stderr=subprocess.PIPE -12 | | ) - | |_^ UP022 -13 | -14 | output = subprocess.run( - | - = help: Replace with `capture_output` keyword argument - -ℹ Suggested fix -8 8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) -9 9 | -10 10 | output = subprocess.run( -11 |- ["foo"], stdout=subprocess.PIPE, check=True, stderr=subprocess.PIPE - 11 |+ ["foo"], capture_output=True, check=True -12 12 | ) -13 13 | -14 14 | output = subprocess.run( - -UP022.py:14:10: UP022 [*] Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` - | -12 | ) -13 | -14 | output = subprocess.run( - | __________^ -15 | | ["foo"], stderr=subprocess.PIPE, check=True, stdout=subprocess.PIPE -16 | | ) - | |_^ UP022 -17 | -18 | output = subprocess.run( - | - = help: Replace with `capture_output` keyword argument - -ℹ Suggested fix -12 12 | ) -13 13 | -14 14 | output = subprocess.run( -15 |- ["foo"], stderr=subprocess.PIPE, check=True, stdout=subprocess.PIPE - 15 |+ ["foo"], capture_output=True, check=True -16 16 | ) -17 17 | -18 18 | output = subprocess.run( - -UP022.py:18:10: UP022 [*] Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` - | -16 | ) -17 | -18 | output = subprocess.run( - | __________^ -19 | | ["foo"], -20 | | stdout=subprocess.PIPE, -21 | | check=True, -22 | | stderr=subprocess.PIPE, -23 | | text=True, -24 | | encoding="utf-8", -25 | | close_fds=True, -26 | | ) - | |_^ UP022 -27 | -28 | if output: - | - = help: Replace with `capture_output` keyword argument - -ℹ Suggested fix -17 17 | -18 18 | output = subprocess.run( -19 19 | ["foo"], -20 |- stdout=subprocess.PIPE, - 20 |+ capture_output=True, -21 21 | check=True, -22 |- stderr=subprocess.PIPE, -23 22 | text=True, -24 23 | encoding="utf-8", -25 24 | close_fds=True, - -UP022.py:29:14: UP022 [*] Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` - | -28 | if output: -29 | output = subprocess.run( - | ______________^ -30 | | ["foo"], -31 | | stdout=subprocess.PIPE, -32 | | check=True, -33 | | stderr=subprocess.PIPE, -34 | | text=True, -35 | | encoding="utf-8", -36 | | ) - | |_____^ UP022 -37 | -38 | output = subprocess.run( - | - = help: Replace with `capture_output` keyword argument - -ℹ Suggested fix -28 28 | if output: -29 29 | output = subprocess.run( -30 30 | ["foo"], -31 |- stdout=subprocess.PIPE, - 31 |+ capture_output=True, -32 32 | check=True, -33 |- stderr=subprocess.PIPE, -34 33 | text=True, -35 34 | encoding="utf-8", -36 35 | ) - -UP022.py:38:10: UP022 Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` - | -36 | ) -37 | -38 | output = subprocess.run( - | __________^ -39 | | ["foo"], stdout=subprocess.PIPE, capture_output=True, stderr=subprocess.PIPE -40 | | ) - | |_^ UP022 -41 | -42 | output = subprocess.run( - | - = help: Replace with `capture_output` keyword argument - -UP022.py:42:10: UP022 Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` - | -40 | ) -41 | -42 | output = subprocess.run( - | __________^ -43 | | ["foo"], stdout=subprocess.PIPE, capture_output=False, stderr=subprocess.PIPE -44 | | ) - | |_^ UP022 -45 | -46 | output = subprocess.run( - | - = help: Replace with `capture_output` keyword argument - -UP022.py:46:10: UP022 Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` - | -44 | ) -45 | -46 | output = subprocess.run( - | __________^ -47 | | ["foo"], capture_output=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE -48 | | ) - | |_^ UP022 -49 | -50 | # OK - | - = help: Replace with `capture_output` keyword argument - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP023.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP023.py.snap deleted file mode 100644 index 3f6e5169e8..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP023.py.snap +++ /dev/null @@ -1,208 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP023.py:2:1: UP023 [*] `cElementTree` is deprecated, use `ElementTree` - | -1 | # These two imports have something after cElementTree, so they should be fixed. -2 | from xml.etree.cElementTree import XML, Element, SubElement - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 -3 | import xml.etree.cElementTree as ET - | - = help: Replace with `ElementTree` - -ℹ Suggested fix -1 1 | # These two imports have something after cElementTree, so they should be fixed. -2 |-from xml.etree.cElementTree import XML, Element, SubElement - 2 |+from xml.etree.ElementTree import XML, Element, SubElement -3 3 | import xml.etree.cElementTree as ET -4 4 | -5 5 | # Weird spacing should not cause issues. - -UP023.py:3:8: UP023 [*] `cElementTree` is deprecated, use `ElementTree` - | -1 | # These two imports have something after cElementTree, so they should be fixed. -2 | from xml.etree.cElementTree import XML, Element, SubElement -3 | import xml.etree.cElementTree as ET - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 -4 | -5 | # Weird spacing should not cause issues. - | - = help: Replace with `ElementTree` - -ℹ Suggested fix -1 1 | # These two imports have something after cElementTree, so they should be fixed. -2 2 | from xml.etree.cElementTree import XML, Element, SubElement -3 |-import xml.etree.cElementTree as ET - 3 |+import xml.etree.ElementTree as ET -4 4 | -5 5 | # Weird spacing should not cause issues. -6 6 | from xml.etree.cElementTree import XML - -UP023.py:6:1: UP023 [*] `cElementTree` is deprecated, use `ElementTree` - | -5 | # Weird spacing should not cause issues. -6 | from xml.etree.cElementTree import XML - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 -7 | import xml.etree.cElementTree as ET - | - = help: Replace with `ElementTree` - -ℹ Suggested fix -3 3 | import xml.etree.cElementTree as ET -4 4 | -5 5 | # Weird spacing should not cause issues. -6 |-from xml.etree.cElementTree import XML - 6 |+from xml.etree.ElementTree import XML -7 7 | import xml.etree.cElementTree as ET -8 8 | -9 9 | # Multi line imports should also work fine. - -UP023.py:7:11: UP023 [*] `cElementTree` is deprecated, use `ElementTree` - | -5 | # Weird spacing should not cause issues. -6 | from xml.etree.cElementTree import XML -7 | import xml.etree.cElementTree as ET - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 -8 | -9 | # Multi line imports should also work fine. - | - = help: Replace with `ElementTree` - -ℹ Suggested fix -4 4 | -5 5 | # Weird spacing should not cause issues. -6 6 | from xml.etree.cElementTree import XML -7 |-import xml.etree.cElementTree as ET - 7 |+import xml.etree.ElementTree as ET -8 8 | -9 9 | # Multi line imports should also work fine. -10 10 | from xml.etree.cElementTree import ( - -UP023.py:10:1: UP023 [*] `cElementTree` is deprecated, use `ElementTree` - | - 9 | # Multi line imports should also work fine. -10 | / from xml.etree.cElementTree import ( -11 | | XML, -12 | | Element, -13 | | SubElement, -14 | | ) - | |_^ UP023 -15 | if True: -16 | import xml.etree.cElementTree as ET - | - = help: Replace with `ElementTree` - -ℹ Suggested fix -7 7 | import xml.etree.cElementTree as ET -8 8 | -9 9 | # Multi line imports should also work fine. -10 |-from xml.etree.cElementTree import ( - 10 |+from xml.etree.ElementTree import ( -11 11 | XML, -12 12 | Element, -13 13 | SubElement, - -UP023.py:16:12: UP023 [*] `cElementTree` is deprecated, use `ElementTree` - | -14 | ) -15 | if True: -16 | import xml.etree.cElementTree as ET - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 -17 | from xml.etree import cElementTree as CET - | - = help: Replace with `ElementTree` - -ℹ Suggested fix -13 13 | SubElement, -14 14 | ) -15 15 | if True: -16 |- import xml.etree.cElementTree as ET - 16 |+ import xml.etree.ElementTree as ET -17 17 | from xml.etree import cElementTree as CET -18 18 | -19 19 | from xml.etree import cElementTree as ET - -UP023.py:17:27: UP023 [*] `cElementTree` is deprecated, use `ElementTree` - | -15 | if True: -16 | import xml.etree.cElementTree as ET -17 | from xml.etree import cElementTree as CET - | ^^^^^^^^^^^^^^^^^^^ UP023 -18 | -19 | from xml.etree import cElementTree as ET - | - = help: Replace with `ElementTree` - -ℹ Suggested fix -14 14 | ) -15 15 | if True: -16 16 | import xml.etree.cElementTree as ET -17 |- from xml.etree import cElementTree as CET - 17 |+ from xml.etree import ElementTree as CET -18 18 | -19 19 | from xml.etree import cElementTree as ET -20 20 | - -UP023.py:19:23: UP023 [*] `cElementTree` is deprecated, use `ElementTree` - | -17 | from xml.etree import cElementTree as CET -18 | -19 | from xml.etree import cElementTree as ET - | ^^^^^^^^^^^^^^^^^^ UP023 -20 | -21 | import contextlib, xml.etree.cElementTree as ET - | - = help: Replace with `ElementTree` - -ℹ Suggested fix -16 16 | import xml.etree.cElementTree as ET -17 17 | from xml.etree import cElementTree as CET -18 18 | -19 |-from xml.etree import cElementTree as ET - 19 |+from xml.etree import ElementTree as ET -20 20 | -21 21 | import contextlib, xml.etree.cElementTree as ET -22 22 | - -UP023.py:21:20: UP023 [*] `cElementTree` is deprecated, use `ElementTree` - | -19 | from xml.etree import cElementTree as ET -20 | -21 | import contextlib, xml.etree.cElementTree as ET - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 -22 | -23 | # This should fix the second, but not the first invocation. - | - = help: Replace with `ElementTree` - -ℹ Suggested fix -18 18 | -19 19 | from xml.etree import cElementTree as ET -20 20 | -21 |-import contextlib, xml.etree.cElementTree as ET - 21 |+import contextlib, xml.etree.ElementTree as ET -22 22 | -23 23 | # This should fix the second, but not the first invocation. -24 24 | import xml.etree.cElementTree, xml.etree.cElementTree as ET - -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 | -26 | # The below items should NOT be changed. - | - = help: Replace with `ElementTree` - -ℹ Suggested fix -21 21 | import contextlib, xml.etree.cElementTree as ET -22 22 | -23 23 | # This should fix the second, but not the first invocation. -24 |-import xml.etree.cElementTree, xml.etree.cElementTree as ET - 24 |+import xml.etree.cElementTree, xml.etree.ElementTree as ET -25 25 | -26 26 | # The below items should NOT be changed. -27 27 | import xml.etree.cElementTree - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP024_0.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP024_0.py.snap deleted file mode 100644 index aa0859fd46..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP024_0.py.snap +++ /dev/null @@ -1,285 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP024_0.py:6:8: UP024 [*] Replace aliased errors with `OSError` - | -4 | try: -5 | pass -6 | except EnvironmentError: - | ^^^^^^^^^^^^^^^^ UP024 -7 | pass - | - = help: Replace `EnvironmentError` with builtin `OSError` - -ℹ Fix -3 3 | # These should be fixed -4 4 | try: -5 5 | pass -6 |-except EnvironmentError: - 6 |+except OSError: -7 7 | pass -8 8 | -9 9 | try: - -UP024_0.py:11:8: UP024 [*] Replace aliased errors with `OSError` - | - 9 | try: -10 | pass -11 | except IOError: - | ^^^^^^^ UP024 -12 | pass - | - = help: Replace `IOError` with builtin `OSError` - -ℹ Fix -8 8 | -9 9 | try: -10 10 | pass -11 |-except IOError: - 11 |+except OSError: -12 12 | pass -13 13 | -14 14 | try: - -UP024_0.py:16:8: UP024 [*] Replace aliased errors with `OSError` - | -14 | try: -15 | pass -16 | except WindowsError: - | ^^^^^^^^^^^^ UP024 -17 | pass - | - = help: Replace `WindowsError` with builtin `OSError` - -ℹ Fix -13 13 | -14 14 | try: -15 15 | pass -16 |-except WindowsError: - 16 |+except OSError: -17 17 | pass -18 18 | -19 19 | try: - -UP024_0.py:21:8: UP024 [*] Replace aliased errors with `OSError` - | -19 | try: -20 | pass -21 | except mmap.error: - | ^^^^^^^^^^ UP024 -22 | pass - | - = help: Replace `mmap.error` with builtin `OSError` - -ℹ Fix -18 18 | -19 19 | try: -20 20 | pass -21 |-except mmap.error: - 21 |+except OSError: -22 22 | pass -23 23 | -24 24 | try: - -UP024_0.py:26:8: UP024 [*] Replace aliased errors with `OSError` - | -24 | try: -25 | pass -26 | except select.error: - | ^^^^^^^^^^^^ UP024 -27 | pass - | - = help: Replace `select.error` with builtin `OSError` - -ℹ Fix -23 23 | -24 24 | try: -25 25 | pass -26 |-except select.error: - 26 |+except OSError: -27 27 | pass -28 28 | -29 29 | try: - -UP024_0.py:31:8: UP024 [*] Replace aliased errors with `OSError` - | -29 | try: -30 | pass -31 | except socket.error: - | ^^^^^^^^^^^^ UP024 -32 | pass - | - = help: Replace `socket.error` with builtin `OSError` - -ℹ Fix -28 28 | -29 29 | try: -30 30 | pass -31 |-except socket.error: - 31 |+except OSError: -32 32 | pass -33 33 | -34 34 | try: - -UP024_0.py:36:8: UP024 [*] Replace aliased errors with `OSError` - | -34 | try: -35 | pass -36 | except error: - | ^^^^^ UP024 -37 | pass - | - = help: Replace `error` with builtin `OSError` - -ℹ Fix -33 33 | -34 34 | try: -35 35 | pass -36 |-except error: - 36 |+except OSError: -37 37 | pass -38 38 | -39 39 | # Should NOT be in parentheses when replaced - -UP024_0.py:43:8: UP024 [*] Replace aliased errors with `OSError` - | -41 | try: -42 | pass -43 | except (IOError,): - | ^^^^^^^^^^ UP024 -44 | pass -45 | try: - | - = help: Replace with builtin `OSError` - -ℹ Fix -40 40 | -41 41 | try: -42 42 | pass -43 |-except (IOError,): - 43 |+except OSError: -44 44 | pass -45 45 | try: -46 46 | pass - -UP024_0.py:47:8: UP024 [*] Replace aliased errors with `OSError` - | -45 | try: -46 | pass -47 | except (mmap.error,): - | ^^^^^^^^^^^^^ UP024 -48 | pass -49 | try: - | - = help: Replace with builtin `OSError` - -ℹ Fix -44 44 | pass -45 45 | try: -46 46 | pass -47 |-except (mmap.error,): - 47 |+except OSError: -48 48 | pass -49 49 | try: -50 50 | pass - -UP024_0.py:51:8: UP024 [*] Replace aliased errors with `OSError` - | -49 | try: -50 | pass -51 | except (EnvironmentError, IOError, OSError, select.error): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP024 -52 | pass - | - = help: Replace with builtin `OSError` - -ℹ Fix -48 48 | pass -49 49 | try: -50 50 | pass -51 |-except (EnvironmentError, IOError, OSError, select.error): - 51 |+except OSError: -52 52 | pass -53 53 | -54 54 | # Should be kept in parentheses (because multiple) - -UP024_0.py:58:8: UP024 [*] Replace aliased errors with `OSError` - | -56 | try: -57 | pass -58 | except (IOError, KeyError, OSError): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP024 -59 | pass - | - = help: Replace with builtin `OSError` - -ℹ Fix -55 55 | -56 56 | try: -57 57 | pass -58 |-except (IOError, KeyError, OSError): - 58 |+except (KeyError, OSError): -59 59 | pass -60 60 | -61 61 | # First should change, second should not - -UP024_0.py:65:8: UP024 [*] Replace aliased errors with `OSError` - | -63 | try: -64 | pass -65 | except (IOError, error): - | ^^^^^^^^^^^^^^^^ UP024 -66 | pass -67 | # These should not change - | - = help: Replace with builtin `OSError` - -ℹ Fix -62 62 | from .mmap import error -63 63 | try: -64 64 | pass -65 |-except (IOError, error): - 65 |+except (OSError, error): -66 66 | pass -67 67 | # These should not change -68 68 | - -UP024_0.py:87:8: UP024 [*] Replace aliased errors with `OSError` - | -85 | try: -86 | pass -87 | except (mmap).error: - | ^^^^^^^^^^^^ UP024 -88 | pass - | - = help: Replace `mmap.error` with builtin `OSError` - -ℹ Fix -84 84 | pass -85 85 | try: -86 86 | pass -87 |-except (mmap).error: - 87 |+except OSError: -88 88 | pass -89 89 | -90 90 | try: - -UP024_0.py:105:11: UP024 [*] Replace aliased errors with `OSError` - | -103 | try: -104 | mac_address = get_primary_mac_address() -105 | except(IOError, OSError) as ex: - | ^^^^^^^^^^^^^^^^^^ UP024 -106 | msg = 'Unable to query URL to get Owner ID: {u}\n{e}'.format(u=owner_id_url, e=ex) - | - = help: Replace with builtin `OSError` - -ℹ Fix -102 102 | def get_owner_id_from_mac_address(): -103 103 | try: -104 104 | mac_address = get_primary_mac_address() -105 |- except(IOError, OSError) as ex: - 105 |+ except OSError as ex: -106 106 | msg = 'Unable to query URL to get Owner ID: {u}\n{e}'.format(u=owner_id_url, e=ex) - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP024_1.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP024_1.py.snap deleted file mode 100644 index ed64b2e20f..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP024_1.py.snap +++ /dev/null @@ -1,72 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP024_1.py:5:8: UP024 [*] Replace aliased errors with `OSError` - | -3 | try: -4 | pass -5 | except (OSError, mmap.error, IOError): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP024 -6 | pass -7 | except (OSError, socket.error, KeyError): - | - = help: Replace with builtin `OSError` - -ℹ Fix -2 2 | -3 3 | try: -4 4 | pass -5 |-except (OSError, mmap.error, IOError): - 5 |+except OSError: -6 6 | pass -7 7 | except (OSError, socket.error, KeyError): -8 8 | pass - -UP024_1.py:7:8: UP024 [*] Replace aliased errors with `OSError` - | -5 | except (OSError, mmap.error, IOError): -6 | pass -7 | except (OSError, socket.error, KeyError): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP024 -8 | pass - | - = help: Replace with builtin `OSError` - -ℹ Fix -4 4 | pass -5 5 | except (OSError, mmap.error, IOError): -6 6 | pass -7 |-except (OSError, socket.error, KeyError): - 7 |+except (OSError, KeyError): -8 8 | pass -9 9 | -10 10 | try: - -UP024_1.py:12:8: UP024 [*] Replace aliased errors with `OSError` - | -10 | try: -11 | pass -12 | except ( - | ________^ -13 | | OSError, -14 | | select.error, -15 | | IOError, -16 | | ): - | |_^ UP024 -17 | pass - | - = help: Replace with builtin `OSError` - -ℹ Fix -9 9 | -10 10 | try: -11 11 | pass -12 |-except ( -13 |- OSError, -14 |- select.error, -15 |- IOError, -16 |-): - 12 |+except OSError: -17 13 | pass - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP024_2.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP024_2.py.snap deleted file mode 100644 index 36ce30b1e5..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP024_2.py.snap +++ /dev/null @@ -1,404 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP024_2.py:10:7: UP024 [*] Replace aliased errors with `OSError` - | - 8 | # Testing the modules - 9 | import socket, mmap, select -10 | raise socket.error - | ^^^^^^^^^^^^ UP024 -11 | raise mmap.error -12 | raise select.error - | - = help: Replace `socket.error` with builtin `OSError` - -ℹ Fix -7 7 | -8 8 | # Testing the modules -9 9 | import socket, mmap, select -10 |-raise socket.error - 10 |+raise OSError -11 11 | raise mmap.error -12 12 | raise select.error -13 13 | - -UP024_2.py:11:7: UP024 [*] Replace aliased errors with `OSError` - | - 9 | import socket, mmap, select -10 | raise socket.error -11 | raise mmap.error - | ^^^^^^^^^^ UP024 -12 | raise select.error - | - = help: Replace `mmap.error` with builtin `OSError` - -ℹ Fix -8 8 | # Testing the modules -9 9 | import socket, mmap, select -10 10 | raise socket.error -11 |-raise mmap.error - 11 |+raise OSError -12 12 | raise select.error -13 13 | -14 14 | raise socket.error() - -UP024_2.py:12:7: UP024 [*] Replace aliased errors with `OSError` - | -10 | raise socket.error -11 | raise mmap.error -12 | raise select.error - | ^^^^^^^^^^^^ UP024 -13 | -14 | raise socket.error() - | - = help: Replace `select.error` with builtin `OSError` - -ℹ Fix -9 9 | import socket, mmap, select -10 10 | raise socket.error -11 11 | raise mmap.error -12 |-raise select.error - 12 |+raise OSError -13 13 | -14 14 | raise socket.error() -15 15 | raise mmap.error(1) - -UP024_2.py:14:7: UP024 [*] Replace aliased errors with `OSError` - | -12 | raise select.error -13 | -14 | raise socket.error() - | ^^^^^^^^^^^^ UP024 -15 | raise mmap.error(1) -16 | raise select.error(1, 2) - | - = help: Replace `socket.error` with builtin `OSError` - -ℹ Fix -11 11 | raise mmap.error -12 12 | raise select.error -13 13 | -14 |-raise socket.error() - 14 |+raise OSError() -15 15 | raise mmap.error(1) -16 16 | raise select.error(1, 2) -17 17 | - -UP024_2.py:15:7: UP024 [*] Replace aliased errors with `OSError` - | -14 | raise socket.error() -15 | raise mmap.error(1) - | ^^^^^^^^^^ UP024 -16 | raise select.error(1, 2) - | - = help: Replace `mmap.error` with builtin `OSError` - -ℹ Fix -12 12 | raise select.error -13 13 | -14 14 | raise socket.error() -15 |-raise mmap.error(1) - 15 |+raise OSError(1) -16 16 | raise select.error(1, 2) -17 17 | -18 18 | raise socket.error( - -UP024_2.py:16:7: UP024 [*] Replace aliased errors with `OSError` - | -14 | raise socket.error() -15 | raise mmap.error(1) -16 | raise select.error(1, 2) - | ^^^^^^^^^^^^ UP024 -17 | -18 | raise socket.error( - | - = help: Replace `select.error` with builtin `OSError` - -ℹ Fix -13 13 | -14 14 | raise socket.error() -15 15 | raise mmap.error(1) -16 |-raise select.error(1, 2) - 16 |+raise OSError(1, 2) -17 17 | -18 18 | raise socket.error( -19 19 | 1, - -UP024_2.py:18:7: UP024 [*] Replace aliased errors with `OSError` - | -16 | raise select.error(1, 2) -17 | -18 | raise socket.error( - | ^^^^^^^^^^^^ UP024 -19 | 1, -20 | 2, - | - = help: Replace `socket.error` with builtin `OSError` - -ℹ Fix -15 15 | raise mmap.error(1) -16 16 | raise select.error(1, 2) -17 17 | -18 |-raise socket.error( - 18 |+raise OSError( -19 19 | 1, -20 20 | 2, -21 21 | 3, - -UP024_2.py:25:7: UP024 [*] Replace aliased errors with `OSError` - | -24 | from mmap import error -25 | raise error - | ^^^^^ UP024 -26 | -27 | from socket import error - | - = help: Replace `error` with builtin `OSError` - -ℹ Fix -22 22 | ) -23 23 | -24 24 | from mmap import error -25 |-raise error - 25 |+raise OSError -26 26 | -27 27 | from socket import error -28 28 | raise error(1) - -UP024_2.py:28:7: UP024 [*] Replace aliased errors with `OSError` - | -27 | from socket import error -28 | raise error(1) - | ^^^^^ UP024 -29 | -30 | from select import error - | - = help: Replace `error` with builtin `OSError` - -ℹ Fix -25 25 | raise error -26 26 | -27 27 | from socket import error -28 |-raise error(1) - 28 |+raise OSError(1) -29 29 | -30 30 | from select import error -31 31 | raise error(1, 2) - -UP024_2.py:31:7: UP024 [*] Replace aliased errors with `OSError` - | -30 | from select import error -31 | raise error(1, 2) - | ^^^^^ UP024 -32 | -33 | # Testing the names - | - = help: Replace `error` with builtin `OSError` - -ℹ Fix -28 28 | raise error(1) -29 29 | -30 30 | from select import error -31 |-raise error(1, 2) - 31 |+raise OSError(1, 2) -32 32 | -33 33 | # Testing the names -34 34 | raise EnvironmentError - -UP024_2.py:34:7: UP024 [*] Replace aliased errors with `OSError` - | -33 | # Testing the names -34 | raise EnvironmentError - | ^^^^^^^^^^^^^^^^ UP024 -35 | raise IOError -36 | raise WindowsError - | - = help: Replace `EnvironmentError` with builtin `OSError` - -ℹ Fix -31 31 | raise error(1, 2) -32 32 | -33 33 | # Testing the names -34 |-raise EnvironmentError - 34 |+raise OSError -35 35 | raise IOError -36 36 | raise WindowsError -37 37 | - -UP024_2.py:35:7: UP024 [*] Replace aliased errors with `OSError` - | -33 | # Testing the names -34 | raise EnvironmentError -35 | raise IOError - | ^^^^^^^ UP024 -36 | raise WindowsError - | - = help: Replace `IOError` with builtin `OSError` - -ℹ Fix -32 32 | -33 33 | # Testing the names -34 34 | raise EnvironmentError -35 |-raise IOError - 35 |+raise OSError -36 36 | raise WindowsError -37 37 | -38 38 | raise EnvironmentError() - -UP024_2.py:36:7: UP024 [*] Replace aliased errors with `OSError` - | -34 | raise EnvironmentError -35 | raise IOError -36 | raise WindowsError - | ^^^^^^^^^^^^ UP024 -37 | -38 | raise EnvironmentError() - | - = help: Replace `WindowsError` with builtin `OSError` - -ℹ Fix -33 33 | # Testing the names -34 34 | raise EnvironmentError -35 35 | raise IOError -36 |-raise WindowsError - 36 |+raise OSError -37 37 | -38 38 | raise EnvironmentError() -39 39 | raise IOError(1) - -UP024_2.py:38:7: UP024 [*] Replace aliased errors with `OSError` - | -36 | raise WindowsError -37 | -38 | raise EnvironmentError() - | ^^^^^^^^^^^^^^^^ UP024 -39 | raise IOError(1) -40 | raise WindowsError(1, 2) - | - = help: Replace `EnvironmentError` with builtin `OSError` - -ℹ Fix -35 35 | raise IOError -36 36 | raise WindowsError -37 37 | -38 |-raise EnvironmentError() - 38 |+raise OSError() -39 39 | raise IOError(1) -40 40 | raise WindowsError(1, 2) -41 41 | - -UP024_2.py:39:7: UP024 [*] Replace aliased errors with `OSError` - | -38 | raise EnvironmentError() -39 | raise IOError(1) - | ^^^^^^^ UP024 -40 | raise WindowsError(1, 2) - | - = help: Replace `IOError` with builtin `OSError` - -ℹ Fix -36 36 | raise WindowsError -37 37 | -38 38 | raise EnvironmentError() -39 |-raise IOError(1) - 39 |+raise OSError(1) -40 40 | raise WindowsError(1, 2) -41 41 | -42 42 | raise EnvironmentError( - -UP024_2.py:40:7: UP024 [*] Replace aliased errors with `OSError` - | -38 | raise EnvironmentError() -39 | raise IOError(1) -40 | raise WindowsError(1, 2) - | ^^^^^^^^^^^^ UP024 -41 | -42 | raise EnvironmentError( - | - = help: Replace `WindowsError` with builtin `OSError` - -ℹ Fix -37 37 | -38 38 | raise EnvironmentError() -39 39 | raise IOError(1) -40 |-raise WindowsError(1, 2) - 40 |+raise OSError(1, 2) -41 41 | -42 42 | raise EnvironmentError( -43 43 | 1, - -UP024_2.py:42:7: UP024 [*] Replace aliased errors with `OSError` - | -40 | raise WindowsError(1, 2) -41 | -42 | raise EnvironmentError( - | ^^^^^^^^^^^^^^^^ UP024 -43 | 1, -44 | 2, - | - = help: Replace `EnvironmentError` with builtin `OSError` - -ℹ Fix -39 39 | raise IOError(1) -40 40 | raise WindowsError(1, 2) -41 41 | -42 |-raise EnvironmentError( - 42 |+raise OSError( -43 43 | 1, -44 44 | 2, -45 45 | 3, - -UP024_2.py:48:7: UP024 [*] Replace aliased errors with `OSError` - | -46 | ) -47 | -48 | raise WindowsError - | ^^^^^^^^^^^^ UP024 -49 | raise EnvironmentError(1) -50 | raise IOError(1, 2) - | - = help: Replace `WindowsError` with builtin `OSError` - -ℹ Fix -45 45 | 3, -46 46 | ) -47 47 | -48 |-raise WindowsError - 48 |+raise OSError -49 49 | raise EnvironmentError(1) -50 50 | raise IOError(1, 2) - -UP024_2.py:49:7: UP024 [*] Replace aliased errors with `OSError` - | -48 | raise WindowsError -49 | raise EnvironmentError(1) - | ^^^^^^^^^^^^^^^^ UP024 -50 | raise IOError(1, 2) - | - = help: Replace `EnvironmentError` with builtin `OSError` - -ℹ Fix -46 46 | ) -47 47 | -48 48 | raise WindowsError -49 |-raise EnvironmentError(1) - 49 |+raise OSError(1) -50 50 | raise IOError(1, 2) - -UP024_2.py:50:7: UP024 [*] Replace aliased errors with `OSError` - | -48 | raise WindowsError -49 | raise EnvironmentError(1) -50 | raise IOError(1, 2) - | ^^^^^^^ UP024 - | - = help: Replace `IOError` with builtin `OSError` - -ℹ Fix -47 47 | -48 48 | raise WindowsError -49 49 | raise EnvironmentError(1) -50 |-raise IOError(1, 2) - 50 |+raise OSError(1, 2) - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP024_3.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP024_3.py.snap deleted file mode 100644 index 870ad3bf5d..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP024_3.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP024_4.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP024_4.py.snap deleted file mode 100644 index d1dec00413..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP024_4.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP024_4.py:9:8: UP024 [*] Replace aliased errors with `OSError` - | - 7 | conn.ensure_connection(max_retries=2) - 8 | conn._close() - 9 | except (socket.error, exceptions.OperationalError): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP024 -10 | return HttpResponseServerError("cache: cannot connect to broker.") - | - = help: Replace with builtin `OSError` - -ℹ Fix -6 6 | conn = Connection(settings.CELERY_BROKER_URL) -7 7 | conn.ensure_connection(max_retries=2) -8 8 | conn._close() -9 |-except (socket.error, exceptions.OperationalError): - 9 |+except (OSError, exceptions.OperationalError): -10 10 | return HttpResponseServerError("cache: cannot connect to broker.") - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP025.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP025.py.snap deleted file mode 100644 index 380d022354..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP025.py.snap +++ /dev/null @@ -1,251 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP025.py:2:5: UP025 [*] Remove unicode literals from strings - | -1 | # These should change -2 | x = u"Hello" - | ^^^^^^^^ UP025 -3 | -4 | u'world' - | - = help: Remove unicode prefix - -ℹ Fix -1 1 | # These should change -2 |-x = u"Hello" - 2 |+x = "Hello" -3 3 | -4 4 | u'world' -5 5 | - -UP025.py:4:1: UP025 [*] Remove unicode literals from strings - | -2 | x = u"Hello" -3 | -4 | u'world' - | ^^^^^^^^ UP025 -5 | -6 | print(u"Hello") - | - = help: Remove unicode prefix - -ℹ Fix -1 1 | # These should change -2 2 | x = u"Hello" -3 3 | -4 |-u'world' - 4 |+'world' -5 5 | -6 6 | print(u"Hello") -7 7 | - -UP025.py:6:7: UP025 [*] Remove unicode literals from strings - | -4 | u'world' -5 | -6 | print(u"Hello") - | ^^^^^^^^ UP025 -7 | -8 | print(u'world') - | - = help: Remove unicode prefix - -ℹ Fix -3 3 | -4 4 | u'world' -5 5 | -6 |-print(u"Hello") - 6 |+print("Hello") -7 7 | -8 8 | print(u'world') -9 9 | - -UP025.py:8:7: UP025 [*] Remove unicode literals from strings - | - 6 | print(u"Hello") - 7 | - 8 | print(u'world') - | ^^^^^^^^ UP025 - 9 | -10 | import foo - | - = help: Remove unicode prefix - -ℹ Fix -5 5 | -6 6 | print(u"Hello") -7 7 | -8 |-print(u'world') - 8 |+print('world') -9 9 | -10 10 | import foo -11 11 | - -UP025.py:12:5: UP025 [*] Remove unicode literals from strings - | -10 | import foo -11 | -12 | foo(u"Hello", U"world", a=u"Hello", b=u"world") - | ^^^^^^^^ UP025 -13 | -14 | # These should stay quoted they way they are - | - = help: Remove unicode prefix - -ℹ Fix -9 9 | -10 10 | import foo -11 11 | -12 |-foo(u"Hello", U"world", a=u"Hello", b=u"world") - 12 |+foo("Hello", U"world", a=u"Hello", b=u"world") -13 13 | -14 14 | # These should stay quoted they way they are -15 15 | - -UP025.py:12:15: UP025 [*] Remove unicode literals from strings - | -10 | import foo -11 | -12 | foo(u"Hello", U"world", a=u"Hello", b=u"world") - | ^^^^^^^^ UP025 -13 | -14 | # These should stay quoted they way they are - | - = help: Remove unicode prefix - -ℹ Fix -9 9 | -10 10 | import foo -11 11 | -12 |-foo(u"Hello", U"world", a=u"Hello", b=u"world") - 12 |+foo(u"Hello", "world", a=u"Hello", b=u"world") -13 13 | -14 14 | # These should stay quoted they way they are -15 15 | - -UP025.py:12:27: UP025 [*] Remove unicode literals from strings - | -10 | import foo -11 | -12 | foo(u"Hello", U"world", a=u"Hello", b=u"world") - | ^^^^^^^^ UP025 -13 | -14 | # These should stay quoted they way they are - | - = help: Remove unicode prefix - -ℹ Fix -9 9 | -10 10 | import foo -11 11 | -12 |-foo(u"Hello", U"world", a=u"Hello", b=u"world") - 12 |+foo(u"Hello", U"world", a="Hello", b=u"world") -13 13 | -14 14 | # These should stay quoted they way they are -15 15 | - -UP025.py:12:39: UP025 [*] Remove unicode literals from strings - | -10 | import foo -11 | -12 | foo(u"Hello", U"world", a=u"Hello", b=u"world") - | ^^^^^^^^ UP025 -13 | -14 | # These should stay quoted they way they are - | - = help: Remove unicode prefix - -ℹ Fix -9 9 | -10 10 | import foo -11 11 | -12 |-foo(u"Hello", U"world", a=u"Hello", b=u"world") - 12 |+foo(u"Hello", U"world", a=u"Hello", b="world") -13 13 | -14 14 | # These should stay quoted they way they are -15 15 | - -UP025.py:16:5: UP025 [*] Remove unicode literals from strings - | -14 | # These should stay quoted they way they are -15 | -16 | x = u'hello' - | ^^^^^^^^ UP025 -17 | x = u"""hello""" -18 | x = u'''hello''' - | - = help: Remove unicode prefix - -ℹ Fix -13 13 | -14 14 | # These should stay quoted they way they are -15 15 | -16 |-x = u'hello' - 16 |+x = 'hello' -17 17 | x = u"""hello""" -18 18 | x = u'''hello''' -19 19 | x = u'Hello "World"' - -UP025.py:17:5: UP025 [*] Remove unicode literals from strings - | -16 | x = u'hello' -17 | x = u"""hello""" - | ^^^^^^^^^^^^ UP025 -18 | x = u'''hello''' -19 | x = u'Hello "World"' - | - = help: Remove unicode prefix - -ℹ Fix -14 14 | # These should stay quoted they way they are -15 15 | -16 16 | x = u'hello' -17 |-x = u"""hello""" - 17 |+x = """hello""" -18 18 | x = u'''hello''' -19 19 | x = u'Hello "World"' -20 20 | - -UP025.py:18:5: UP025 [*] Remove unicode literals from strings - | -16 | x = u'hello' -17 | x = u"""hello""" -18 | x = u'''hello''' - | ^^^^^^^^^^^^ UP025 -19 | x = u'Hello "World"' - | - = help: Remove unicode prefix - -ℹ Fix -15 15 | -16 16 | x = u'hello' -17 17 | x = u"""hello""" -18 |-x = u'''hello''' - 18 |+x = '''hello''' -19 19 | x = u'Hello "World"' -20 20 | -21 21 | # These should not change - -UP025.py:19:5: UP025 [*] Remove unicode literals from strings - | -17 | x = u"""hello""" -18 | x = u'''hello''' -19 | x = u'Hello "World"' - | ^^^^^^^^^^^^^^^^ UP025 -20 | -21 | # These should not change - | - = help: Remove unicode prefix - -ℹ Fix -16 16 | x = u'hello' -17 17 | x = u"""hello""" -18 18 | x = u'''hello''' -19 |-x = u'Hello "World"' - 19 |+x = 'Hello "World"' -20 20 | -21 21 | # These should not change -22 22 | u = "Hello" - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP026.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP026.py.snap deleted file mode 100644 index a2f7f589be..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP026.py.snap +++ /dev/null @@ -1,607 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP026.py:3:12: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -1 | # Error (`from unittest import mock`) -2 | if True: -3 | import mock - | ^^^^ UP026 -4 | -5 | # Error (`from unittest import mock`) - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -1 1 | # Error (`from unittest import mock`) -2 2 | if True: -3 |- import mock - 3 |+ from unittest import mock -4 4 | -5 5 | # Error (`from unittest import mock`) -6 6 | if True: - -UP026.py:7:12: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -5 | # Error (`from unittest import mock`) -6 | if True: -7 | import mock, sys - | ^^^^ UP026 -8 | -9 | # Error (`from unittest.mock import *`) - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -4 4 | -5 5 | # Error (`from unittest import mock`) -6 6 | if True: -7 |- import mock, sys - 7 |+ import sys - 8 |+ from unittest import mock -8 9 | -9 10 | # Error (`from unittest.mock import *`) -10 11 | if True: - -UP026.py:11:5: UP026 [*] `mock` is deprecated, use `unittest.mock` - | - 9 | # Error (`from unittest.mock import *`) -10 | if True: -11 | from mock import * - | ^^^^^^^^^^^^^^^^^^ UP026 -12 | -13 | # Error (`from unittest import mock`) - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -8 8 | -9 9 | # Error (`from unittest.mock import *`) -10 10 | if True: -11 |- from mock import * - 11 |+ from unittest.mock import * -12 12 | -13 13 | # Error (`from unittest import mock`) -14 14 | import mock.mock - -UP026.py:14:8: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -13 | # Error (`from unittest import mock`) -14 | import mock.mock - | ^^^^^^^^^ UP026 -15 | -16 | # Error (`from unittest import mock`) - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -11 11 | from mock import * -12 12 | -13 13 | # Error (`from unittest import mock`) -14 |-import mock.mock - 14 |+from unittest import mock -15 15 | -16 16 | # Error (`from unittest import mock`) -17 17 | import contextlib, mock, sys - -UP026.py:17:20: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -16 | # Error (`from unittest import mock`) -17 | import contextlib, mock, sys - | ^^^^ UP026 -18 | -19 | # Error (`from unittest import mock`) - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -14 14 | import mock.mock -15 15 | -16 16 | # Error (`from unittest import mock`) -17 |-import contextlib, mock, sys - 17 |+import contextlib, sys - 18 |+from unittest import mock -18 19 | -19 20 | # Error (`from unittest import mock`) -20 21 | import mock, sys - -UP026.py:20:8: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -19 | # Error (`from unittest import mock`) -20 | import mock, sys - | ^^^^ UP026 -21 | x = "This code should be preserved one line below the mock" - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -17 17 | import contextlib, mock, sys -18 18 | -19 19 | # Error (`from unittest import mock`) -20 |-import mock, sys - 20 |+import sys - 21 |+from unittest import mock -21 22 | x = "This code should be preserved one line below the mock" -22 23 | -23 24 | # Error (`from unittest import mock`) - -UP026.py:24:1: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -23 | # Error (`from unittest import mock`) -24 | from mock import mock - | ^^^^^^^^^^^^^^^^^^^^^ UP026 -25 | -26 | # Error (keep trailing comma) - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -21 21 | x = "This code should be preserved one line below the mock" -22 22 | -23 23 | # Error (`from unittest import mock`) -24 |-from mock import mock - 24 |+from unittest import mock -25 25 | -26 26 | # Error (keep trailing comma) -27 27 | from mock import ( - -UP026.py:27:1: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -26 | # Error (keep trailing comma) -27 | / from mock import ( -28 | | mock, -29 | | a, -30 | | b, -31 | | c, -32 | | ) - | |_^ UP026 -33 | from mock import ( -34 | a, - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -24 24 | from mock import mock -25 25 | -26 26 | # Error (keep trailing comma) -27 |-from mock import ( -28 |- mock, - 27 |+from unittest.mock import ( -29 28 | a, -30 29 | b, -31 30 | c, -32 31 | ) - 32 |+from unittest import mock -33 33 | from mock import ( -34 34 | a, -35 35 | b, - -UP026.py:33:1: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -31 | c, -32 | ) -33 | / from mock import ( -34 | | a, -35 | | b, -36 | | c, -37 | | mock, -38 | | ) - | |_^ UP026 -39 | -40 | # Error (avoid trailing comma) - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -30 30 | b, -31 31 | c, -32 32 | ) -33 |-from mock import ( - 33 |+from unittest.mock import ( -34 34 | a, -35 35 | b, -36 36 | c, -37 |- mock, -38 37 | ) - 38 |+from unittest import mock -39 39 | -40 40 | # Error (avoid trailing comma) -41 41 | from mock import ( - -UP026.py:41:1: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -40 | # Error (avoid trailing comma) -41 | / from mock import ( -42 | | mock, -43 | | a, -44 | | b, -45 | | c -46 | | ) - | |_^ UP026 -47 | from mock import ( -48 | a, - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -38 38 | ) -39 39 | -40 40 | # Error (avoid trailing comma) -41 |-from mock import ( -42 |- mock, - 41 |+from unittest.mock import ( -43 42 | a, -44 43 | b, -45 44 | c -46 45 | ) - 46 |+from unittest import mock -47 47 | from mock import ( -48 48 | a, -49 49 | b, - -UP026.py:47:1: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -45 | c -46 | ) -47 | / from mock import ( -48 | | a, -49 | | b, -50 | | c, -51 | | mock -52 | | ) - | |_^ UP026 -53 | from mock import mock, a, b, c -54 | from mock import a, b, c, mock - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -44 44 | b, -45 45 | c -46 46 | ) -47 |-from mock import ( - 47 |+from unittest.mock import ( -48 48 | a, -49 49 | b, -50 |- c, -51 |- mock - 50 |+ c -52 51 | ) - 52 |+from unittest import mock -53 53 | from mock import mock, a, b, c -54 54 | from mock import a, b, c, mock -55 55 | - -UP026.py:53:1: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -51 | mock -52 | ) -53 | from mock import mock, a, b, c - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP026 -54 | from mock import a, b, c, mock - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -50 50 | c, -51 51 | mock -52 52 | ) -53 |-from mock import mock, a, b, c - 53 |+from unittest.mock import a, b, c - 54 |+from unittest import mock -54 55 | from mock import a, b, c, mock -55 56 | -56 57 | if True: - -UP026.py:54:1: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -52 | ) -53 | from mock import mock, a, b, c -54 | from mock import a, b, c, mock - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP026 -55 | -56 | if True: - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -51 51 | mock -52 52 | ) -53 53 | from mock import mock, a, b, c -54 |-from mock import a, b, c, mock - 54 |+from unittest.mock import a, b, c - 55 |+from unittest import mock -55 56 | -56 57 | if True: -57 58 | if False: - -UP026.py:58:9: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -56 | if True: -57 | if False: -58 | from mock import ( - | _________^ -59 | | mock, -60 | | a, -61 | | b, -62 | | c -63 | | ) - | |_________^ UP026 -64 | -65 | # OK - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -55 55 | -56 56 | if True: -57 57 | if False: -58 |- from mock import ( -59 |- mock, - 58 |+ from unittest.mock import ( -60 59 | a, -61 60 | b, -62 61 | c -63 62 | ) - 63 |+ from unittest import mock -64 64 | -65 65 | # OK -66 66 | import os, io - -UP026.py:69:8: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -68 | # Error (`from unittest import mock`) -69 | import mock, mock - | ^^^^ UP026 -70 | -71 | # Error (`from unittest import mock as foo`) - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -66 66 | import os, io -67 67 | -68 68 | # Error (`from unittest import mock`) -69 |-import mock, mock - 69 |+from unittest import mock - 70 |+from unittest import mock -70 71 | -71 72 | # Error (`from unittest import mock as foo`) -72 73 | import mock as foo - -UP026.py:69:14: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -68 | # Error (`from unittest import mock`) -69 | import mock, mock - | ^^^^ UP026 -70 | -71 | # Error (`from unittest import mock as foo`) - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -66 66 | import os, io -67 67 | -68 68 | # Error (`from unittest import mock`) -69 |-import mock, mock - 69 |+from unittest import mock - 70 |+from unittest import mock -70 71 | -71 72 | # Error (`from unittest import mock as foo`) -72 73 | import mock as foo - -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 | -74 | # Error (`from unittest import mock as foo`) - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -69 69 | import mock, mock -70 70 | -71 71 | # Error (`from unittest import mock as foo`) -72 |-import mock as foo - 72 |+from unittest import mock as foo -73 73 | -74 74 | # Error (`from unittest import mock as foo`) -75 75 | from mock import mock as foo - -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 | -77 | if True: - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -72 72 | import mock as foo -73 73 | -74 74 | # Error (`from unittest import mock as foo`) -75 |-from mock import mock as foo - 75 |+from unittest import mock as foo -76 76 | -77 77 | if True: -78 78 | # This should yield multiple, aliased imports. - -UP026.py:79:12: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -77 | if True: -78 | # This should yield multiple, aliased imports. -79 | import mock as foo, mock as bar, mock - | ^^^^^^^^^^^ UP026 -80 | -81 | # This should yield multiple, aliased imports, and preserve `os`. - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -76 76 | -77 77 | if True: -78 78 | # This should yield multiple, aliased imports. -79 |- import mock as foo, mock as bar, mock - 79 |+ from unittest import mock as foo - 80 |+ from unittest import mock as bar - 81 |+ from unittest import mock -80 82 | -81 83 | # This should yield multiple, aliased imports, and preserve `os`. -82 84 | import mock as foo, mock as bar, mock, os - -UP026.py:79:25: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -77 | if True: -78 | # This should yield multiple, aliased imports. -79 | import mock as foo, mock as bar, mock - | ^^^^^^^^^^^ UP026 -80 | -81 | # This should yield multiple, aliased imports, and preserve `os`. - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -76 76 | -77 77 | if True: -78 78 | # This should yield multiple, aliased imports. -79 |- import mock as foo, mock as bar, mock - 79 |+ from unittest import mock as foo - 80 |+ from unittest import mock as bar - 81 |+ from unittest import mock -80 82 | -81 83 | # This should yield multiple, aliased imports, and preserve `os`. -82 84 | import mock as foo, mock as bar, mock, os - -UP026.py:79:38: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -77 | if True: -78 | # This should yield multiple, aliased imports. -79 | import mock as foo, mock as bar, mock - | ^^^^ UP026 -80 | -81 | # This should yield multiple, aliased imports, and preserve `os`. - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -76 76 | -77 77 | if True: -78 78 | # This should yield multiple, aliased imports. -79 |- import mock as foo, mock as bar, mock - 79 |+ from unittest import mock as foo - 80 |+ from unittest import mock as bar - 81 |+ from unittest import mock -80 82 | -81 83 | # This should yield multiple, aliased imports, and preserve `os`. -82 84 | import mock as foo, mock as bar, mock, os - -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 | -84 | if True: - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -79 79 | import mock as foo, mock as bar, mock -80 80 | -81 81 | # This should yield multiple, aliased imports, and preserve `os`. -82 |- import mock as foo, mock as bar, mock, os - 82 |+ import os - 83 |+ from unittest import mock as foo - 84 |+ from unittest import mock as bar - 85 |+ from unittest import mock -83 86 | -84 87 | if True: -85 88 | # This should yield multiple, aliased imports. - -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 | -84 | if True: - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -79 79 | import mock as foo, mock as bar, mock -80 80 | -81 81 | # This should yield multiple, aliased imports, and preserve `os`. -82 |- import mock as foo, mock as bar, mock, os - 82 |+ import os - 83 |+ from unittest import mock as foo - 84 |+ from unittest import mock as bar - 85 |+ from unittest import mock -83 86 | -84 87 | if True: -85 88 | # This should yield multiple, aliased imports. - -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 | -84 | if True: - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -79 79 | import mock as foo, mock as bar, mock -80 80 | -81 81 | # This should yield multiple, aliased imports, and preserve `os`. -82 |- import mock as foo, mock as bar, mock, os - 82 |+ import os - 83 |+ from unittest import mock as foo - 84 |+ from unittest import mock as bar - 85 |+ from unittest import mock -83 86 | -84 87 | if True: -85 88 | # This should yield multiple, aliased imports. - -UP026.py:86:5: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -84 | if True: -85 | # This should yield multiple, aliased imports. -86 | from mock import mock as foo, mock as bar, mock - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP026 - | - = help: Import from `unittest.mock` instead - -ℹ Suggested fix -83 83 | -84 84 | if True: -85 85 | # This should yield multiple, aliased imports. -86 |- from mock import mock as foo, mock as bar, mock - 86 |+ from unittest import mock as foo - 87 |+ from unittest import mock as bar - 88 |+ from unittest import mock -87 89 | -88 90 | -89 91 | # OK. - -UP026.py:93:5: UP026 [*] `mock` is deprecated, use `unittest.mock` - | -92 | # Error (`mock.Mock()`). -93 | x = mock.mock.Mock() - | ^^^^^^^^^ UP026 - | - = help: Replace `mock.mock` with `mock` - -ℹ Suggested fix -90 90 | x = mock.Mock() -91 91 | -92 92 | # Error (`mock.Mock()`). -93 |-x = mock.mock.Mock() - 93 |+x = mock.Mock() - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP027.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP027.py.snap deleted file mode 100644 index da071d0812..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP027.py.snap +++ /dev/null @@ -1,114 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP027.py:2:17: UP027 [*] Replace unpacked list comprehension with a generator expression - | -1 | # Should change -2 | foo, bar, baz = [fn(x) for x in items] - | ^^^^^^^^^^^^^^^^^^^^^^ UP027 -3 | -4 | foo, bar, baz =[fn(x) for x in items] - | - = help: Replace with generator expression - -ℹ Suggested fix -1 1 | # Should change -2 |-foo, bar, baz = [fn(x) for x in items] - 2 |+foo, bar, baz = (fn(x) for x in items) -3 3 | -4 4 | foo, bar, baz =[fn(x) for x in items] -5 5 | - -UP027.py:4:16: UP027 [*] Replace unpacked list comprehension with a generator expression - | -2 | foo, bar, baz = [fn(x) for x in items] -3 | -4 | foo, bar, baz =[fn(x) for x in items] - | ^^^^^^^^^^^^^^^^^^^^^^ UP027 -5 | -6 | foo, bar, baz = [fn(x) for x in items] - | - = help: Replace with generator expression - -ℹ Suggested fix -1 1 | # Should change -2 2 | foo, bar, baz = [fn(x) for x in items] -3 3 | -4 |-foo, bar, baz =[fn(x) for x in items] - 4 |+foo, bar, baz =(fn(x) for x in items) -5 5 | -6 6 | foo, bar, baz = [fn(x) for x in items] -7 7 | - -UP027.py:6:26: UP027 [*] Replace unpacked list comprehension with a generator expression - | -4 | foo, bar, baz =[fn(x) for x in items] -5 | -6 | foo, bar, baz = [fn(x) for x in items] - | ^^^^^^^^^^^^^^^^^^^^^^ UP027 -7 | -8 | foo, bar, baz = [[i for i in fn(x)] for x in items] - | - = help: Replace with generator expression - -ℹ Suggested fix -3 3 | -4 4 | foo, bar, baz =[fn(x) for x in items] -5 5 | -6 |-foo, bar, baz = [fn(x) for x in items] - 6 |+foo, bar, baz = (fn(x) for x in items) -7 7 | -8 8 | foo, bar, baz = [[i for i in fn(x)] for x in items] -9 9 | - -UP027.py:8:17: UP027 [*] Replace unpacked list comprehension with a generator expression - | - 6 | foo, bar, baz = [fn(x) for x in items] - 7 | - 8 | foo, bar, baz = [[i for i in fn(x)] for x in items] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP027 - 9 | -10 | foo, bar, baz = [ - | - = help: Replace with generator expression - -ℹ Suggested fix -5 5 | -6 6 | foo, bar, baz = [fn(x) for x in items] -7 7 | -8 |-foo, bar, baz = [[i for i in fn(x)] for x in items] - 8 |+foo, bar, baz = ([i for i in fn(x)] for x in items) -9 9 | -10 10 | foo, bar, baz = [ -11 11 | fn(x) - -UP027.py:10:17: UP027 [*] Replace unpacked list comprehension with a generator expression - | - 8 | foo, bar, baz = [[i for i in fn(x)] for x in items] - 9 | -10 | foo, bar, baz = [ - | _________________^ -11 | | fn(x) -12 | | for x in items -13 | | ] - | |_^ UP027 -14 | -15 | # Should not change - | - = help: Replace with generator expression - -ℹ Suggested fix -7 7 | -8 8 | foo, bar, baz = [[i for i in fn(x)] for x in items] -9 9 | -10 |-foo, bar, baz = [ - 10 |+foo, bar, baz = ( -11 11 | fn(x) -12 12 | for x in items -13 |-] - 13 |+) -14 14 | -15 15 | # Should not change -16 16 | foo = [fn(x) for x in items] - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP028_0.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP028_0.py.snap deleted file mode 100644 index 56035122f8..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP028_0.py.snap +++ /dev/null @@ -1,302 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP028_0.py:2:5: UP028 [*] Replace `yield` over `for` loop with `yield from` - | -1 | def f(): -2 | for x in y: - | _____^ -3 | | yield x - | |_______________^ UP028 - | - = help: Replace with `yield from` - -ℹ Suggested fix -1 1 | def f(): -2 |- for x in y: -3 |- yield x - 2 |+ yield from y -4 3 | -5 4 | -6 5 | def g(): - -UP028_0.py:7:5: UP028 [*] Replace `yield` over `for` loop with `yield from` - | -6 | def g(): -7 | for x, y in z: - | _____^ -8 | | yield (x, y) - | |____________________^ UP028 - | - = help: Replace with `yield from` - -ℹ Suggested fix -4 4 | -5 5 | -6 6 | def g(): -7 |- for x, y in z: -8 |- yield (x, y) - 7 |+ yield from z -9 8 | -10 9 | -11 10 | def h(): - -UP028_0.py:12:5: UP028 [*] Replace `yield` over `for` loop with `yield from` - | -11 | def h(): -12 | for x in [1, 2, 3]: - | _____^ -13 | | yield x - | |_______________^ UP028 - | - = help: Replace with `yield from` - -ℹ Suggested fix -9 9 | -10 10 | -11 11 | def h(): -12 |- for x in [1, 2, 3]: -13 |- yield x - 12 |+ yield from [1, 2, 3] -14 13 | -15 14 | -16 15 | def i(): - -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}: - | _____^ -18 | | yield x - | |_______________^ UP028 - | - = help: Replace with `yield from` - -ℹ Suggested fix -14 14 | -15 15 | -16 16 | def i(): -17 |- for x in {x for x in y}: -18 |- yield x - 17 |+ yield from {x for x in y} -19 18 | -20 19 | -21 20 | def j(): - -UP028_0.py:22:5: UP028 [*] Replace `yield` over `for` loop with `yield from` - | -21 | def j(): -22 | for x in (1, 2, 3): - | _____^ -23 | | yield x - | |_______________^ UP028 - | - = help: Replace with `yield from` - -ℹ Suggested fix -19 19 | -20 20 | -21 21 | def j(): -22 |- for x in (1, 2, 3): -23 |- yield x - 22 |+ yield from (1, 2, 3) -24 23 | -25 24 | -26 25 | def k(): - -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"}: - | _____^ -28 | | yield x, y - | |__________________^ UP028 - | - = help: Replace with `yield from` - -ℹ Suggested fix -24 24 | -25 25 | -26 26 | def k(): -27 |- for x, y in {3: "x", 6: "y"}: -28 |- yield x, y - 27 |+ yield from {3: "x", 6: "y"} -29 28 | -30 29 | -31 30 | def f(): # Comment one\n' - -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' - | _____^ -34 | | 3: "x", # Comment four\n' -35 | | # Comment five\n' -36 | | 6: "y", # Comment six\n' -37 | | }: # Comment seven\n' -38 | | # Comment eight\n' -39 | | yield x, y # Comment nine\n' - | |__________________^ UP028 -40 | # Comment ten', - | - = help: Replace with `yield from` - -ℹ Suggested fix -30 30 | -31 31 | def f(): # Comment one\n' -32 32 | # Comment two\n' -33 |- for x, y in { # Comment three\n' - 33 |+ yield from { # Comment three\n' -34 34 | 3: "x", # Comment four\n' -35 35 | # Comment five\n' -36 36 | 6: "y", # Comment six\n' -37 |- }: # Comment seven\n' -38 |- # Comment eight\n' -39 |- yield x, y # Comment nine\n' - 37 |+ } # Comment nine\n' -40 38 | # Comment ten', -41 39 | -42 40 | - -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"}]: - | _____^ -45 | | yield x, y - | |__________________^ UP028 - | - = help: Replace with `yield from` - -ℹ Suggested fix -41 41 | -42 42 | -43 43 | def f(): -44 |- for x, y in [{3: (3, [44, "long ss"]), 6: "y"}]: -45 |- yield x, y - 44 |+ yield from [{3: (3, [44, "long ss"]), 6: "y"}] -46 45 | -47 46 | -48 47 | def f(): - -UP028_0.py:49:5: UP028 [*] Replace `yield` over `for` loop with `yield from` - | -48 | def f(): -49 | for x, y in z(): - | _____^ -50 | | yield x, y - | |__________________^ UP028 -51 | -52 | def f(): - | - = help: Replace with `yield from` - -ℹ Suggested fix -46 46 | -47 47 | -48 48 | def f(): -49 |- for x, y in z(): -50 |- yield x, y - 49 |+ yield from z() -51 50 | -52 51 | def f(): -53 52 | def func(): - -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' - | _________^ -56 | | # Comment two\n' -57 | | yield x, y # Comment three\n' - | |______________________^ UP028 -58 | # Comment four\n' -59 | # Comment\n' - | - = help: Replace with `yield from` - -ℹ Suggested fix -52 52 | def f(): -53 53 | def func(): -54 54 | # This comment is preserved\n' -55 |- for x, y in z(): # Comment one\n' -56 |- # Comment two\n' -57 |- yield x, y # Comment three\n' - 55 |+ yield from z() # Comment three\n' -58 56 | # Comment four\n' -59 57 | # Comment\n' -60 58 | def g(): - -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: - | _____^ -68 | | yield z - | |_______________^ UP028 - | - = help: Replace with `yield from` - -ℹ Suggested fix -64 64 | def f(): -65 65 | for x in y: -66 66 | yield x -67 |- for z in x: -68 |- yield z - 67 |+ yield from x -69 68 | -70 69 | -71 70 | def f(): - -UP028_0.py:72:5: UP028 [*] Replace `yield` over `for` loop with `yield from` - | -71 | def f(): -72 | for x, y in z(): - | _____^ -73 | | yield x, y - | |__________________^ UP028 -74 | x = 1 - | - = help: Replace with `yield from` - -ℹ Suggested fix -69 69 | -70 70 | -71 71 | def f(): -72 |- for x, y in z(): -73 |- yield x, y - 72 |+ yield from z() -74 73 | x = 1 -75 74 | -76 75 | - -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 ( - | _____^ -80 | | TaggedText.from_file(args.input) -81 | | .markup(highlight=args.region) -82 | | ): -83 | | yield h - | |_______________^ UP028 - | - = help: Replace with `yield from` - -ℹ Suggested fix -76 76 | -77 77 | # Regression test for: https://github.com/astral-sh/ruff/issues/7103 -78 78 | def _serve_method(fn): -79 |- for h in ( - 79 |+ yield from ( -80 80 | TaggedText.from_file(args.input) -81 81 | .markup(highlight=args.region) -82 |- ): -83 |- yield h - 82 |+ ) - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP028_1.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP028_1.py.snap deleted file mode 100644 index 870ad3bf5d..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP028_1.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP029.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP029.py.snap deleted file mode 100644 index 8291b4a89d..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP029.py.snap +++ /dev/null @@ -1,78 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP029.py:1:1: UP029 [*] Unnecessary builtin import: `*` - | -1 | from builtins import * - | ^^^^^^^^^^^^^^^^^^^^^^ UP029 -2 | from builtins import ascii, bytes, compile -3 | from builtins import str as _str - | - = help: Remove unnecessary builtin import - -ℹ Suggested fix -1 |-from builtins import * -2 1 | from builtins import ascii, bytes, compile -3 2 | from builtins import str as _str -4 3 | from six.moves import filter, zip, zip_longest - -UP029.py:2:1: UP029 [*] Unnecessary builtin imports: `ascii`, `bytes` - | -1 | from builtins import * -2 | from builtins import ascii, bytes, compile - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP029 -3 | from builtins import str as _str -4 | from six.moves import filter, zip, zip_longest - | - = help: Remove unnecessary builtin import - -ℹ Suggested fix -1 1 | from builtins import * -2 |-from builtins import ascii, bytes, compile - 2 |+from builtins import compile -3 3 | from builtins import str as _str -4 4 | from six.moves import filter, zip, zip_longest -5 5 | from io import open - -UP029.py:4:1: UP029 [*] Unnecessary builtin imports: `filter`, `zip` - | -2 | from builtins import ascii, bytes, compile -3 | from builtins import str as _str -4 | from six.moves import filter, zip, zip_longest - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP029 -5 | from io import open -6 | import io - | - = help: Remove unnecessary builtin import - -ℹ Suggested fix -1 1 | from builtins import * -2 2 | from builtins import ascii, bytes, compile -3 3 | from builtins import str as _str -4 |-from six.moves import filter, zip, zip_longest - 4 |+from six.moves import zip_longest -5 5 | from io import open -6 6 | import io -7 7 | import six - -UP029.py:5:1: UP029 [*] Unnecessary builtin import: `open` - | -3 | from builtins import str as _str -4 | from six.moves import filter, zip, zip_longest -5 | from io import open - | ^^^^^^^^^^^^^^^^^^^ UP029 -6 | import io -7 | import six - | - = help: Remove unnecessary builtin import - -ℹ Suggested fix -2 2 | from builtins import ascii, bytes, compile -3 3 | from builtins import str as _str -4 4 | from six.moves import filter, zip, zip_longest -5 |-from io import open -6 5 | import io -7 6 | import six -8 7 | import six.moves - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP030_0.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP030_0.py.snap deleted file mode 100644 index a0b8e1a467..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP030_0.py.snap +++ /dev/null @@ -1,503 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP030_0.py:3:1: UP030 [*] Use implicit references for positional format fields - | -1 | # Invalid calls; errors expected. -2 | -3 | "{0}" "{1}" "{2}".format(1, 2, 3) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -4 | -5 | "a {3} complicated {1} string with {0} {2}".format( - | - = help: Remove explicit positional indices - -ℹ Suggested fix -1 1 | # Invalid calls; errors expected. -2 2 | -3 |-"{0}" "{1}" "{2}".format(1, 2, 3) - 3 |+"{}" "{}" "{}".format(1, 2, 3) -4 4 | -5 5 | "a {3} complicated {1} string with {0} {2}".format( -6 6 | "first", "second", "third", "fourth" - -UP030_0.py:5:1: UP030 [*] Use implicit references for positional format fields - | -3 | "{0}" "{1}" "{2}".format(1, 2, 3) -4 | -5 | / "a {3} complicated {1} string with {0} {2}".format( -6 | | "first", "second", "third", "fourth" -7 | | ) - | |_^ UP030 -8 | -9 | '{0}'.format(1) - | - = help: Remove explicit positional indices - -ℹ Suggested fix -2 2 | -3 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" - 5 |+"a {} complicated {} string with {} {}".format( - 6 |+ "fourth", "second", "first", "third" -7 7 | ) -8 8 | -9 9 | '{0}'.format(1) - -UP030_0.py:9:1: UP030 [*] Use implicit references for positional format fields - | - 7 | ) - 8 | - 9 | '{0}'.format(1) - | ^^^^^^^^^^^^^^^ UP030 -10 | -11 | '{0:x}'.format(30) - | - = help: Remove explicit positional indices - -ℹ Suggested fix -6 6 | "first", "second", "third", "fourth" -7 7 | ) -8 8 | -9 |-'{0}'.format(1) - 9 |+'{}'.format(1) -10 10 | -11 11 | '{0:x}'.format(30) -12 12 | - -UP030_0.py:11:1: UP030 [*] Use implicit references for positional format fields - | - 9 | '{0}'.format(1) -10 | -11 | '{0:x}'.format(30) - | ^^^^^^^^^^^^^^^^^^ UP030 -12 | -13 | x = '{0}'.format(1) - | - = help: Remove explicit positional indices - -ℹ Suggested fix -8 8 | -9 9 | '{0}'.format(1) -10 10 | -11 |-'{0:x}'.format(30) - 11 |+'{:x}'.format(30) -12 12 | -13 13 | x = '{0}'.format(1) -14 14 | - -UP030_0.py:13:5: UP030 [*] Use implicit references for positional format fields - | -11 | '{0:x}'.format(30) -12 | -13 | x = '{0}'.format(1) - | ^^^^^^^^^^^^^^^ UP030 -14 | -15 | '''{0}\n{1}\n'''.format(1, 2) - | - = help: Remove explicit positional indices - -ℹ Suggested fix -10 10 | -11 11 | '{0:x}'.format(30) -12 12 | -13 |-x = '{0}'.format(1) - 13 |+x = '{}'.format(1) -14 14 | -15 15 | '''{0}\n{1}\n'''.format(1, 2) -16 16 | - -UP030_0.py:15:1: UP030 [*] Use implicit references for positional format fields - | -13 | x = '{0}'.format(1) -14 | -15 | '''{0}\n{1}\n'''.format(1, 2) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -16 | -17 | x = "foo {0}" \ - | - = help: Remove explicit positional indices - -ℹ Suggested fix -12 12 | -13 13 | x = '{0}'.format(1) -14 14 | -15 |-'''{0}\n{1}\n'''.format(1, 2) - 15 |+'''{}\n{}\n'''.format(1, 2) -16 16 | -17 17 | x = "foo {0}" \ -18 18 | "bar {1}".format(1, 2) - -UP030_0.py:17:5: UP030 [*] Use implicit references for positional format fields - | -15 | '''{0}\n{1}\n'''.format(1, 2) -16 | -17 | x = "foo {0}" \ - | _____^ -18 | | "bar {1}".format(1, 2) - | |__________________________^ UP030 -19 | -20 | ("{0}").format(1) - | - = help: Remove explicit positional indices - -ℹ Suggested fix -14 14 | -15 15 | '''{0}\n{1}\n'''.format(1, 2) -16 16 | -17 |-x = "foo {0}" \ -18 |- "bar {1}".format(1, 2) - 17 |+x = "foo {}" \ - 18 |+ "bar {}".format(1, 2) -19 19 | -20 20 | ("{0}").format(1) -21 21 | - -UP030_0.py:20:1: UP030 [*] Use implicit references for positional format fields - | -18 | "bar {1}".format(1, 2) -19 | -20 | ("{0}").format(1) - | ^^^^^^^^^^^^^^^^^ UP030 -21 | -22 | "\N{snowman} {0}".format(1) - | - = help: Remove explicit positional indices - -ℹ Suggested fix -17 17 | x = "foo {0}" \ -18 18 | "bar {1}".format(1, 2) -19 19 | -20 |-("{0}").format(1) - 20 |+("{}").format(1) -21 21 | -22 22 | "\N{snowman} {0}".format(1) -23 23 | - -UP030_0.py:22:1: UP030 [*] Use implicit references for positional format fields - | -20 | ("{0}").format(1) -21 | -22 | "\N{snowman} {0}".format(1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -23 | -24 | print( - | - = help: Remove explicit positional indices - -ℹ Suggested fix -19 19 | -20 20 | ("{0}").format(1) -21 21 | -22 |-"\N{snowman} {0}".format(1) - 22 |+"\N{snowman} {}".format(1) -23 23 | -24 24 | print( -25 25 | 'foo{0}' - -UP030_0.py:25:5: UP030 [*] Use implicit references for positional format fields - | -24 | print( -25 | 'foo{0}' - | _____^ -26 | | 'bar{1}'.format(1, 2) - | |_________________________^ UP030 -27 | ) - | - = help: Remove explicit positional indices - -ℹ Suggested fix -22 22 | "\N{snowman} {0}".format(1) -23 23 | -24 24 | print( -25 |- 'foo{0}' -26 |- 'bar{1}'.format(1, 2) - 25 |+ 'foo{}' - 26 |+ 'bar{}'.format(1, 2) -27 27 | ) -28 28 | -29 29 | print( - -UP030_0.py:30:5: UP030 [*] Use implicit references for positional format fields - | -29 | print( -30 | 'foo{0}' # ohai\n" - | _____^ -31 | | 'bar{1}'.format(1, 2) - | |_________________________^ UP030 -32 | ) - | - = help: Remove explicit positional indices - -ℹ Suggested fix -27 27 | ) -28 28 | -29 29 | print( -30 |- 'foo{0}' # ohai\n" -31 |- 'bar{1}'.format(1, 2) - 30 |+ 'foo{}' # ohai\n" - 31 |+ 'bar{}'.format(1, 2) -32 32 | ) -33 33 | -34 34 | '{' '0}'.format(1) - -UP030_0.py:34:1: UP030 Use implicit references for positional format fields - | -32 | ) -33 | -34 | '{' '0}'.format(1) - | ^^^^^^^^^^^^^^^^^^ UP030 -35 | -36 | args = list(range(10)) - | - = help: Remove explicit positional indices - -UP030_0.py:39:1: UP030 [*] Use implicit references for positional format fields - | -37 | kwargs = {x: x for x in range(10)} -38 | -39 | "{0}".format(*args) - | ^^^^^^^^^^^^^^^^^^^ UP030 -40 | -41 | "{0}".format(**kwargs) - | - = help: Remove explicit positional indices - -ℹ Suggested fix -36 36 | args = list(range(10)) -37 37 | kwargs = {x: x for x in range(10)} -38 38 | -39 |-"{0}".format(*args) - 39 |+"{}".format(*args) -40 40 | -41 41 | "{0}".format(**kwargs) -42 42 | - -UP030_0.py:41:1: UP030 [*] Use implicit references for positional format fields - | -39 | "{0}".format(*args) -40 | -41 | "{0}".format(**kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^ UP030 -42 | -43 | "{0}_{1}".format(*args) - | - = help: Remove explicit positional indices - -ℹ Suggested fix -38 38 | -39 39 | "{0}".format(*args) -40 40 | -41 |-"{0}".format(**kwargs) - 41 |+"{}".format(**kwargs) -42 42 | -43 43 | "{0}_{1}".format(*args) -44 44 | - -UP030_0.py:43:1: UP030 [*] Use implicit references for positional format fields - | -41 | "{0}".format(**kwargs) -42 | -43 | "{0}_{1}".format(*args) - | ^^^^^^^^^^^^^^^^^^^^^^^ UP030 -44 | -45 | "{0}_{1}".format(1, *args) - | - = help: Remove explicit positional indices - -ℹ Suggested fix -40 40 | -41 41 | "{0}".format(**kwargs) -42 42 | -43 |-"{0}_{1}".format(*args) - 43 |+"{}_{}".format(*args) -44 44 | -45 45 | "{0}_{1}".format(1, *args) -46 46 | - -UP030_0.py:45:1: UP030 [*] Use implicit references for positional format fields - | -43 | "{0}_{1}".format(*args) -44 | -45 | "{0}_{1}".format(1, *args) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -46 | -47 | "{0}_{1}".format(1, 2, *args) - | - = help: Remove explicit positional indices - -ℹ Suggested fix -42 42 | -43 43 | "{0}_{1}".format(*args) -44 44 | -45 |-"{0}_{1}".format(1, *args) - 45 |+"{}_{}".format(1, *args) -46 46 | -47 47 | "{0}_{1}".format(1, 2, *args) -48 48 | - -UP030_0.py:47:1: UP030 [*] Use implicit references for positional format fields - | -45 | "{0}_{1}".format(1, *args) -46 | -47 | "{0}_{1}".format(1, 2, *args) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -48 | -49 | "{0}_{1}".format(*args, 1, 2) - | - = help: Remove explicit positional indices - -ℹ Suggested fix -44 44 | -45 45 | "{0}_{1}".format(1, *args) -46 46 | -47 |-"{0}_{1}".format(1, 2, *args) - 47 |+"{}_{}".format(1, 2, *args) -48 48 | -49 49 | "{0}_{1}".format(*args, 1, 2) -50 50 | - -UP030_0.py:49:1: UP030 [*] Use implicit references for positional format fields - | -47 | "{0}_{1}".format(1, 2, *args) -48 | -49 | "{0}_{1}".format(*args, 1, 2) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -50 | -51 | "{0}_{1}_{2}".format(1, **kwargs) - | - = help: Remove explicit positional indices - -ℹ Suggested fix -46 46 | -47 47 | "{0}_{1}".format(1, 2, *args) -48 48 | -49 |-"{0}_{1}".format(*args, 1, 2) - 49 |+"{}_{}".format(*args, 1, 2) -50 50 | -51 51 | "{0}_{1}_{2}".format(1, **kwargs) -52 52 | - -UP030_0.py:51:1: UP030 [*] Use implicit references for positional format fields - | -49 | "{0}_{1}".format(*args, 1, 2) -50 | -51 | "{0}_{1}_{2}".format(1, **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -52 | -53 | "{0}_{1}_{2}".format(1, 2, **kwargs) - | - = help: Remove explicit positional indices - -ℹ Suggested fix -48 48 | -49 49 | "{0}_{1}".format(*args, 1, 2) -50 50 | -51 |-"{0}_{1}_{2}".format(1, **kwargs) - 51 |+"{}_{}_{}".format(1, **kwargs) -52 52 | -53 53 | "{0}_{1}_{2}".format(1, 2, **kwargs) -54 54 | - -UP030_0.py:53:1: UP030 [*] Use implicit references for positional format fields - | -51 | "{0}_{1}_{2}".format(1, **kwargs) -52 | -53 | "{0}_{1}_{2}".format(1, 2, **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -54 | -55 | "{0}_{1}_{2}".format(1, 2, 3, **kwargs) - | - = help: Remove explicit positional indices - -ℹ Suggested fix -50 50 | -51 51 | "{0}_{1}_{2}".format(1, **kwargs) -52 52 | -53 |-"{0}_{1}_{2}".format(1, 2, **kwargs) - 53 |+"{}_{}_{}".format(1, 2, **kwargs) -54 54 | -55 55 | "{0}_{1}_{2}".format(1, 2, 3, **kwargs) -56 56 | - -UP030_0.py:55:1: UP030 [*] Use implicit references for positional format fields - | -53 | "{0}_{1}_{2}".format(1, 2, **kwargs) -54 | -55 | "{0}_{1}_{2}".format(1, 2, 3, **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -56 | -57 | "{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) - | - = help: Remove explicit positional indices - -ℹ Suggested fix -52 52 | -53 53 | "{0}_{1}_{2}".format(1, 2, **kwargs) -54 54 | -55 |-"{0}_{1}_{2}".format(1, 2, 3, **kwargs) - 55 |+"{}_{}_{}".format(1, 2, 3, **kwargs) -56 56 | -57 57 | "{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) -58 58 | - -UP030_0.py:57:1: UP030 [*] Use implicit references for positional format fields - | -55 | "{0}_{1}_{2}".format(1, 2, 3, **kwargs) -56 | -57 | "{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -58 | -59 | "{1}_{0}".format(1, 2, *args) - | - = help: Remove explicit positional indices - -ℹ Suggested fix -54 54 | -55 55 | "{0}_{1}_{2}".format(1, 2, 3, **kwargs) -56 56 | -57 |-"{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) - 57 |+"{}_{}_{}".format(1, 2, 3, *args, **kwargs) -58 58 | -59 59 | "{1}_{0}".format(1, 2, *args) -60 60 | - -UP030_0.py:59:1: UP030 [*] Use implicit references for positional format fields - | -57 | "{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) -58 | -59 | "{1}_{0}".format(1, 2, *args) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 -60 | -61 | "{1}_{0}".format(1, 2) - | - = help: Remove explicit positional indices - -ℹ Suggested fix -56 56 | -57 57 | "{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) -58 58 | -59 |-"{1}_{0}".format(1, 2, *args) - 59 |+"{}_{}".format(2, 1, ) -60 60 | -61 61 | "{1}_{0}".format(1, 2) - -UP030_0.py:61:1: UP030 [*] Use implicit references for positional format fields - | -59 | "{1}_{0}".format(1, 2, *args) -60 | -61 | "{1}_{0}".format(1, 2) - | ^^^^^^^^^^^^^^^^^^^^^^ UP030 - | - = help: Remove explicit positional indices - -ℹ Suggested fix -58 58 | -59 59 | "{1}_{0}".format(1, 2, *args) -60 60 | -61 |-"{1}_{0}".format(1, 2) - 61 |+"{}_{}".format(2, 1) - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP030_1.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP030_1.py.snap deleted file mode 100644 index 870ad3bf5d..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP030_1.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP031_0.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP031_0.py.snap deleted file mode 100644 index 433d011792..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP031_0.py.snap +++ /dev/null @@ -1,910 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP031_0.py:4:7: UP031 [*] Use format specifiers instead of percent format - | -3 | # UP031 -4 | print('%s %s' % (a, b)) - | ^^^^^^^^^^^^^^^^ UP031 -5 | -6 | print('%s%s' % (a, b)) - | - = help: Replace with format specifiers - -ℹ Suggested fix -1 1 | a, b, x, y = 1, 2, 3, 4 -2 2 | -3 3 | # UP031 -4 |-print('%s %s' % (a, b)) - 4 |+print('{} {}'.format(a, b)) -5 5 | -6 6 | print('%s%s' % (a, b)) -7 7 | - -UP031_0.py:6:7: UP031 [*] Use format specifiers instead of percent format - | -4 | print('%s %s' % (a, b)) -5 | -6 | print('%s%s' % (a, b)) - | ^^^^^^^^^^^^^^^ UP031 -7 | -8 | print("trivial" % ()) - | - = help: Replace with format specifiers - -ℹ Suggested fix -3 3 | # UP031 -4 4 | print('%s %s' % (a, b)) -5 5 | -6 |-print('%s%s' % (a, b)) - 6 |+print('{}{}'.format(a, b)) -7 7 | -8 8 | print("trivial" % ()) -9 9 | - -UP031_0.py:8:7: UP031 [*] Use format specifiers instead of percent format - | - 6 | print('%s%s' % (a, b)) - 7 | - 8 | print("trivial" % ()) - | ^^^^^^^^^^^^^^ UP031 - 9 | -10 | print("%s" % ("simple",)) - | - = help: Replace with format specifiers - -ℹ Suggested fix -5 5 | -6 6 | print('%s%s' % (a, b)) -7 7 | -8 |-print("trivial" % ()) - 8 |+print("trivial".format()) -9 9 | -10 10 | print("%s" % ("simple",)) -11 11 | - -UP031_0.py:10:7: UP031 [*] Use format specifiers instead of percent format - | - 8 | print("trivial" % ()) - 9 | -10 | print("%s" % ("simple",)) - | ^^^^^^^^^^^^^^^^^^ UP031 -11 | -12 | print("%s" % ("%s" % ("nested",),)) - | - = help: Replace with format specifiers - -ℹ Suggested fix -7 7 | -8 8 | print("trivial" % ()) -9 9 | -10 |-print("%s" % ("simple",)) - 10 |+print("{}".format("simple")) -11 11 | -12 12 | print("%s" % ("%s" % ("nested",),)) -13 13 | - -UP031_0.py:12:7: UP031 [*] Use format specifiers instead of percent format - | -10 | print("%s" % ("simple",)) -11 | -12 | print("%s" % ("%s" % ("nested",),)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 -13 | -14 | print("%s%% percent" % (15,)) - | - = help: Replace with format specifiers - -ℹ Suggested fix -9 9 | -10 10 | print("%s" % ("simple",)) -11 11 | -12 |-print("%s" % ("%s" % ("nested",),)) - 12 |+print("{}".format("%s" % ("nested",))) -13 13 | -14 14 | print("%s%% percent" % (15,)) -15 15 | - -UP031_0.py:12:15: UP031 [*] Use format specifiers instead of percent format - | -10 | print("%s" % ("simple",)) -11 | -12 | print("%s" % ("%s" % ("nested",),)) - | ^^^^^^^^^^^^^^^^^^ UP031 -13 | -14 | print("%s%% percent" % (15,)) - | - = help: Replace with format specifiers - -ℹ Suggested fix -9 9 | -10 10 | print("%s" % ("simple",)) -11 11 | -12 |-print("%s" % ("%s" % ("nested",),)) - 12 |+print("%s" % ("{}".format("nested"),)) -13 13 | -14 14 | print("%s%% percent" % (15,)) -15 15 | - -UP031_0.py:14:7: UP031 [*] Use format specifiers instead of percent format - | -12 | print("%s" % ("%s" % ("nested",),)) -13 | -14 | print("%s%% percent" % (15,)) - | ^^^^^^^^^^^^^^^^^^^^^^ UP031 -15 | -16 | print("%f" % (15,)) - | - = help: Replace with format specifiers - -ℹ Suggested fix -11 11 | -12 12 | print("%s" % ("%s" % ("nested",),)) -13 13 | -14 |-print("%s%% percent" % (15,)) - 14 |+print("{}% percent".format(15)) -15 15 | -16 16 | print("%f" % (15,)) -17 17 | - -UP031_0.py:16:7: UP031 [*] Use format specifiers instead of percent format - | -14 | print("%s%% percent" % (15,)) -15 | -16 | print("%f" % (15,)) - | ^^^^^^^^^^^^ UP031 -17 | -18 | print("%.f" % (15,)) - | - = help: Replace with format specifiers - -ℹ Suggested fix -13 13 | -14 14 | print("%s%% percent" % (15,)) -15 15 | -16 |-print("%f" % (15,)) - 16 |+print("{:f}".format(15)) -17 17 | -18 18 | print("%.f" % (15,)) -19 19 | - -UP031_0.py:18:7: UP031 [*] Use format specifiers instead of percent format - | -16 | print("%f" % (15,)) -17 | -18 | print("%.f" % (15,)) - | ^^^^^^^^^^^^^ UP031 -19 | -20 | print("%.3f" % (15,)) - | - = help: Replace with format specifiers - -ℹ Suggested fix -15 15 | -16 16 | print("%f" % (15,)) -17 17 | -18 |-print("%.f" % (15,)) - 18 |+print("{:.0f}".format(15)) -19 19 | -20 20 | print("%.3f" % (15,)) -21 21 | - -UP031_0.py:20:7: UP031 [*] Use format specifiers instead of percent format - | -18 | print("%.f" % (15,)) -19 | -20 | print("%.3f" % (15,)) - | ^^^^^^^^^^^^^^ UP031 -21 | -22 | print("%3f" % (15,)) - | - = help: Replace with format specifiers - -ℹ Suggested fix -17 17 | -18 18 | print("%.f" % (15,)) -19 19 | -20 |-print("%.3f" % (15,)) - 20 |+print("{:.3f}".format(15)) -21 21 | -22 22 | print("%3f" % (15,)) -23 23 | - -UP031_0.py:22:7: UP031 [*] Use format specifiers instead of percent format - | -20 | print("%.3f" % (15,)) -21 | -22 | print("%3f" % (15,)) - | ^^^^^^^^^^^^^ UP031 -23 | -24 | print("%-5f" % (5,)) - | - = help: Replace with format specifiers - -ℹ Suggested fix -19 19 | -20 20 | print("%.3f" % (15,)) -21 21 | -22 |-print("%3f" % (15,)) - 22 |+print("{:3f}".format(15)) -23 23 | -24 24 | print("%-5f" % (5,)) -25 25 | - -UP031_0.py:24:7: UP031 [*] Use format specifiers instead of percent format - | -22 | print("%3f" % (15,)) -23 | -24 | print("%-5f" % (5,)) - | ^^^^^^^^^^^^^ UP031 -25 | -26 | print("%9f" % (5,)) - | - = help: Replace with format specifiers - -ℹ Suggested fix -21 21 | -22 22 | print("%3f" % (15,)) -23 23 | -24 |-print("%-5f" % (5,)) - 24 |+print("{:<5f}".format(5)) -25 25 | -26 26 | print("%9f" % (5,)) -27 27 | - -UP031_0.py:26:7: UP031 [*] Use format specifiers instead of percent format - | -24 | print("%-5f" % (5,)) -25 | -26 | print("%9f" % (5,)) - | ^^^^^^^^^^^^ UP031 -27 | -28 | print("%#o" % (123,)) - | - = help: Replace with format specifiers - -ℹ Suggested fix -23 23 | -24 24 | print("%-5f" % (5,)) -25 25 | -26 |-print("%9f" % (5,)) - 26 |+print("{:9f}".format(5)) -27 27 | -28 28 | print("%#o" % (123,)) -29 29 | - -UP031_0.py:28:7: UP031 [*] Use format specifiers instead of percent format - | -26 | print("%9f" % (5,)) -27 | -28 | print("%#o" % (123,)) - | ^^^^^^^^^^^^^^ UP031 -29 | -30 | print("brace {} %s" % (1,)) - | - = help: Replace with format specifiers - -ℹ Suggested fix -25 25 | -26 26 | print("%9f" % (5,)) -27 27 | -28 |-print("%#o" % (123,)) - 28 |+print("{:#o}".format(123)) -29 29 | -30 30 | print("brace {} %s" % (1,)) -31 31 | - -UP031_0.py:30:7: UP031 [*] Use format specifiers instead of percent format - | -28 | print("%#o" % (123,)) -29 | -30 | print("brace {} %s" % (1,)) - | ^^^^^^^^^^^^^^^^^^^^ UP031 -31 | -32 | print( - | - = help: Replace with format specifiers - -ℹ Suggested fix -27 27 | -28 28 | print("%#o" % (123,)) -29 29 | -30 |-print("brace {} %s" % (1,)) - 30 |+print("brace {{}} {}".format(1)) -31 31 | -32 32 | print( -33 33 | "%s" % ( - -UP031_0.py:33:3: UP031 [*] Use format specifiers instead of percent format - | -32 | print( -33 | "%s" % ( - | ___^ -34 | | "trailing comma", -35 | | ) - | |_________^ UP031 -36 | ) - | - = help: Replace with format specifiers - -ℹ Suggested fix -30 30 | print("brace {} %s" % (1,)) -31 31 | -32 32 | print( -33 |- "%s" % ( - 33 |+ "{}".format( -34 34 | "trailing comma", -35 35 | ) -36 36 | ) - -UP031_0.py:38:7: UP031 [*] Use format specifiers instead of percent format - | -36 | ) -37 | -38 | print("foo %s " % (x,)) - | ^^^^^^^^^^^^^^^^ UP031 -39 | -40 | print("%(k)s" % {"k": "v"}) - | - = help: Replace with format specifiers - -ℹ Suggested fix -35 35 | ) -36 36 | ) -37 37 | -38 |-print("foo %s " % (x,)) - 38 |+print("foo {} ".format(x)) -39 39 | -40 40 | print("%(k)s" % {"k": "v"}) -41 41 | - -UP031_0.py:40:7: UP031 [*] Use format specifiers instead of percent format - | -38 | print("foo %s " % (x,)) -39 | -40 | print("%(k)s" % {"k": "v"}) - | ^^^^^^^^^^^^^^^^^^^^ UP031 -41 | -42 | print("%(k)s" % { - | - = help: Replace with format specifiers - -ℹ Suggested fix -37 37 | -38 38 | print("foo %s " % (x,)) -39 39 | -40 |-print("%(k)s" % {"k": "v"}) - 40 |+print("{k}".format(k="v")) -41 41 | -42 42 | print("%(k)s" % { -43 43 | "k": "v", - -UP031_0.py:42:7: UP031 [*] Use format specifiers instead of percent format - | -40 | print("%(k)s" % {"k": "v"}) -41 | -42 | print("%(k)s" % { - | _______^ -43 | | "k": "v", -44 | | "i": "j" -45 | | }) - | |_^ UP031 -46 | -47 | print("%(to_list)s" % {"to_list": []}) - | - = help: Replace with format specifiers - -ℹ Suggested fix -39 39 | -40 40 | print("%(k)s" % {"k": "v"}) -41 41 | -42 |-print("%(k)s" % { -43 |- "k": "v", -44 |- "i": "j" -45 |-}) - 42 |+print("{k}".format( - 43 |+ k="v", - 44 |+ i="j", - 45 |+)) -46 46 | -47 47 | print("%(to_list)s" % {"to_list": []}) -48 48 | - -UP031_0.py:47:7: UP031 [*] Use format specifiers instead of percent format - | -45 | }) -46 | -47 | print("%(to_list)s" % {"to_list": []}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 -48 | -49 | print("%(k)s" % {"k": "v", "i": 1, "j": []}) - | - = help: Replace with format specifiers - -ℹ Suggested fix -44 44 | "i": "j" -45 45 | }) -46 46 | -47 |-print("%(to_list)s" % {"to_list": []}) - 47 |+print("{to_list}".format(to_list=[])) -48 48 | -49 49 | print("%(k)s" % {"k": "v", "i": 1, "j": []}) -50 50 | - -UP031_0.py:49:7: UP031 [*] Use format specifiers instead of percent format - | -47 | print("%(to_list)s" % {"to_list": []}) -48 | -49 | print("%(k)s" % {"k": "v", "i": 1, "j": []}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 -50 | -51 | print("%(ab)s" % {"a" "b": 1}) - | - = help: Replace with format specifiers - -ℹ Suggested fix -46 46 | -47 47 | print("%(to_list)s" % {"to_list": []}) -48 48 | -49 |-print("%(k)s" % {"k": "v", "i": 1, "j": []}) - 49 |+print("{k}".format(k="v", i=1, j=[])) -50 50 | -51 51 | print("%(ab)s" % {"a" "b": 1}) -52 52 | - -UP031_0.py:51:7: UP031 [*] Use format specifiers instead of percent format - | -49 | print("%(k)s" % {"k": "v", "i": 1, "j": []}) -50 | -51 | print("%(ab)s" % {"a" "b": 1}) - | ^^^^^^^^^^^^^^^^^^^^^^^ UP031 -52 | -53 | print("%(a)s" % {"a" : 1}) - | - = help: Replace with format specifiers - -ℹ Suggested fix -48 48 | -49 49 | print("%(k)s" % {"k": "v", "i": 1, "j": []}) -50 50 | -51 |-print("%(ab)s" % {"a" "b": 1}) - 51 |+print("{ab}".format(ab=1)) -52 52 | -53 53 | print("%(a)s" % {"a" : 1}) -54 54 | - -UP031_0.py:53:7: UP031 [*] Use format specifiers instead of percent format - | -51 | print("%(ab)s" % {"a" "b": 1}) -52 | -53 | print("%(a)s" % {"a" : 1}) - | ^^^^^^^^^^^^^^^^^^^^^ UP031 -54 | -55 | print(( - | - = help: Replace with format specifiers - -ℹ Suggested fix -50 50 | -51 51 | print("%(ab)s" % {"a" "b": 1}) -52 52 | -53 |-print("%(a)s" % {"a" : 1}) - 53 |+print("{a}".format(a=1)) -54 54 | -55 55 | print(( -56 56 | "foo %s " - -UP031_0.py:56:5: UP031 [*] Use format specifiers instead of percent format - | -55 | print(( -56 | "foo %s " - | _____^ -57 | | "bar %s" % (x, y) - | |_____________________^ UP031 -58 | )) - | - = help: Replace with format specifiers - -ℹ Suggested fix -53 53 | print("%(a)s" % {"a" : 1}) -54 54 | -55 55 | print(( -56 |- "foo %s " -57 |- "bar %s" % (x, y) - 56 |+ "foo {} " - 57 |+ "bar {}".format(x, y) -58 58 | )) -59 59 | -60 60 | print( - -UP031_0.py:61:5: UP031 [*] Use format specifiers instead of percent format - | -60 | print( -61 | "foo %(foo)s " - | _____^ -62 | | "bar %(bar)s" % {"foo": x, "bar": y} - | |________________________________________^ UP031 -63 | ) - | - = help: Replace with format specifiers - -ℹ Suggested fix -58 58 | )) -59 59 | -60 60 | print( -61 |- "foo %(foo)s " -62 |- "bar %(bar)s" % {"foo": x, "bar": y} - 61 |+ "foo {foo} " - 62 |+ "bar {bar}".format(foo=x, bar=y) -63 63 | ) -64 64 | -65 65 | bar = {"bar": y} - -UP031_0.py:67:5: UP031 [*] Use format specifiers instead of percent format - | -65 | bar = {"bar": y} -66 | print( -67 | "foo %(foo)s " - | _____^ -68 | | "bar %(bar)s" % {"foo": x, **bar} - | |_____________________________________^ UP031 -69 | ) - | - = help: Replace with format specifiers - -ℹ Suggested fix -64 64 | -65 65 | bar = {"bar": y} -66 66 | print( -67 |- "foo %(foo)s " -68 |- "bar %(bar)s" % {"foo": x, **bar} - 67 |+ "foo {foo} " - 68 |+ "bar {bar}".format(foo=x, **bar) -69 69 | ) -70 70 | -71 71 | print("%s \N{snowman}" % (a,)) - -UP031_0.py:71:7: UP031 [*] Use format specifiers instead of percent format - | -69 | ) -70 | -71 | print("%s \N{snowman}" % (a,)) - | ^^^^^^^^^^^^^^^^^^^^^^^ UP031 -72 | -73 | print("%(foo)s \N{snowman}" % {"foo": 1}) - | - = help: Replace with format specifiers - -ℹ Suggested fix -68 68 | "bar %(bar)s" % {"foo": x, **bar} -69 69 | ) -70 70 | -71 |-print("%s \N{snowman}" % (a,)) - 71 |+print("{} \N{snowman}".format(a)) -72 72 | -73 73 | print("%(foo)s \N{snowman}" % {"foo": 1}) -74 74 | - -UP031_0.py:73:7: UP031 [*] Use format specifiers instead of percent format - | -71 | print("%s \N{snowman}" % (a,)) -72 | -73 | print("%(foo)s \N{snowman}" % {"foo": 1}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 -74 | -75 | print(("foo %s " "bar %s") % (x, y)) - | - = help: Replace with format specifiers - -ℹ Suggested fix -70 70 | -71 71 | print("%s \N{snowman}" % (a,)) -72 72 | -73 |-print("%(foo)s \N{snowman}" % {"foo": 1}) - 73 |+print("{foo} \N{snowman}".format(foo=1)) -74 74 | -75 75 | print(("foo %s " "bar %s") % (x, y)) -76 76 | - -UP031_0.py:75:7: UP031 [*] Use format specifiers instead of percent format - | -73 | print("%(foo)s \N{snowman}" % {"foo": 1}) -74 | -75 | print(("foo %s " "bar %s") % (x, y)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 -76 | -77 | # Single-value expressions - | - = help: Replace with format specifiers - -ℹ Suggested fix -72 72 | -73 73 | print("%(foo)s \N{snowman}" % {"foo": 1}) -74 74 | -75 |-print(("foo %s " "bar %s") % (x, y)) - 75 |+print(("foo {} " "bar {}").format(x, y)) -76 76 | -77 77 | # Single-value expressions -78 78 | print('Hello %s' % "World") - -UP031_0.py:78:7: UP031 [*] Use format specifiers instead of percent format - | -77 | # Single-value expressions -78 | print('Hello %s' % "World") - | ^^^^^^^^^^^^^^^^^^^^ UP031 -79 | print('Hello %s' % f"World") -80 | print('Hello %s (%s)' % bar) - | - = help: Replace with format specifiers - -ℹ Suggested fix -75 75 | print(("foo %s " "bar %s") % (x, y)) -76 76 | -77 77 | # Single-value expressions -78 |-print('Hello %s' % "World") - 78 |+print('Hello {}'.format("World")) -79 79 | print('Hello %s' % f"World") -80 80 | print('Hello %s (%s)' % bar) -81 81 | print('Hello %s (%s)' % bar.baz) - -UP031_0.py:79:7: UP031 [*] Use format specifiers instead of percent format - | -77 | # Single-value expressions -78 | print('Hello %s' % "World") -79 | print('Hello %s' % f"World") - | ^^^^^^^^^^^^^^^^^^^^^ UP031 -80 | print('Hello %s (%s)' % bar) -81 | print('Hello %s (%s)' % bar.baz) - | - = help: Replace with format specifiers - -ℹ Suggested fix -76 76 | -77 77 | # Single-value expressions -78 78 | print('Hello %s' % "World") -79 |-print('Hello %s' % f"World") - 79 |+print('Hello {}'.format(f"World")) -80 80 | print('Hello %s (%s)' % bar) -81 81 | print('Hello %s (%s)' % bar.baz) -82 82 | print('Hello %s (%s)' % bar['bop']) - -UP031_0.py:80:7: UP031 [*] Use format specifiers instead of percent format - | -78 | print('Hello %s' % "World") -79 | print('Hello %s' % f"World") -80 | print('Hello %s (%s)' % bar) - | ^^^^^^^^^^^^^^^^^^^^^ UP031 -81 | print('Hello %s (%s)' % bar.baz) -82 | print('Hello %s (%s)' % bar['bop']) - | - = help: Replace with format specifiers - -ℹ Suggested fix -77 77 | # Single-value expressions -78 78 | print('Hello %s' % "World") -79 79 | print('Hello %s' % f"World") -80 |-print('Hello %s (%s)' % bar) - 80 |+print('Hello {} ({})'.format(*bar)) -81 81 | print('Hello %s (%s)' % bar.baz) -82 82 | print('Hello %s (%s)' % bar['bop']) -83 83 | print('Hello %(arg)s' % bar) - -UP031_0.py:81:7: UP031 [*] Use format specifiers instead of percent format - | -79 | print('Hello %s' % f"World") -80 | print('Hello %s (%s)' % bar) -81 | print('Hello %s (%s)' % bar.baz) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 -82 | print('Hello %s (%s)' % bar['bop']) -83 | print('Hello %(arg)s' % bar) - | - = help: Replace with format specifiers - -ℹ Suggested fix -78 78 | print('Hello %s' % "World") -79 79 | print('Hello %s' % f"World") -80 80 | print('Hello %s (%s)' % bar) -81 |-print('Hello %s (%s)' % bar.baz) - 81 |+print('Hello {} ({})'.format(*bar.baz)) -82 82 | print('Hello %s (%s)' % bar['bop']) -83 83 | print('Hello %(arg)s' % bar) -84 84 | print('Hello %(arg)s' % bar.baz) - -UP031_0.py:82:7: UP031 [*] Use format specifiers instead of percent format - | -80 | print('Hello %s (%s)' % bar) -81 | print('Hello %s (%s)' % bar.baz) -82 | print('Hello %s (%s)' % bar['bop']) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 -83 | print('Hello %(arg)s' % bar) -84 | print('Hello %(arg)s' % bar.baz) - | - = help: Replace with format specifiers - -ℹ Suggested fix -79 79 | print('Hello %s' % f"World") -80 80 | print('Hello %s (%s)' % bar) -81 81 | print('Hello %s (%s)' % bar.baz) -82 |-print('Hello %s (%s)' % bar['bop']) - 82 |+print('Hello {} ({})'.format(*bar['bop'])) -83 83 | print('Hello %(arg)s' % bar) -84 84 | print('Hello %(arg)s' % bar.baz) -85 85 | print('Hello %(arg)s' % bar['bop']) - -UP031_0.py:83:7: UP031 [*] Use format specifiers instead of percent format - | -81 | print('Hello %s (%s)' % bar.baz) -82 | print('Hello %s (%s)' % bar['bop']) -83 | print('Hello %(arg)s' % bar) - | ^^^^^^^^^^^^^^^^^^^^^ UP031 -84 | print('Hello %(arg)s' % bar.baz) -85 | print('Hello %(arg)s' % bar['bop']) - | - = help: Replace with format specifiers - -ℹ Suggested fix -80 80 | print('Hello %s (%s)' % bar) -81 81 | print('Hello %s (%s)' % bar.baz) -82 82 | print('Hello %s (%s)' % bar['bop']) -83 |-print('Hello %(arg)s' % bar) - 83 |+print('Hello {arg}'.format(**bar)) -84 84 | print('Hello %(arg)s' % bar.baz) -85 85 | print('Hello %(arg)s' % bar['bop']) -86 86 | - -UP031_0.py:84:7: UP031 [*] Use format specifiers instead of percent format - | -82 | print('Hello %s (%s)' % bar['bop']) -83 | print('Hello %(arg)s' % bar) -84 | print('Hello %(arg)s' % bar.baz) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 -85 | print('Hello %(arg)s' % bar['bop']) - | - = help: Replace with format specifiers - -ℹ Suggested fix -81 81 | print('Hello %s (%s)' % bar.baz) -82 82 | print('Hello %s (%s)' % bar['bop']) -83 83 | print('Hello %(arg)s' % bar) -84 |-print('Hello %(arg)s' % bar.baz) - 84 |+print('Hello {arg}'.format(**bar.baz)) -85 85 | print('Hello %(arg)s' % bar['bop']) -86 86 | -87 87 | # Hanging modulos - -UP031_0.py:85:7: UP031 [*] Use format specifiers instead of percent format - | -83 | print('Hello %(arg)s' % bar) -84 | print('Hello %(arg)s' % bar.baz) -85 | print('Hello %(arg)s' % bar['bop']) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 -86 | -87 | # Hanging modulos - | - = help: Replace with format specifiers - -ℹ Suggested fix -82 82 | print('Hello %s (%s)' % bar['bop']) -83 83 | print('Hello %(arg)s' % bar) -84 84 | print('Hello %(arg)s' % bar.baz) -85 |-print('Hello %(arg)s' % bar['bop']) - 85 |+print('Hello {arg}'.format(**bar['bop'])) -86 86 | -87 87 | # Hanging modulos -88 88 | ( - -UP031_0.py:88:1: UP031 [*] Use format specifiers instead of percent format - | -87 | # Hanging modulos -88 | / ( -89 | | "foo %s " -90 | | "bar %s" -91 | | ) % (x, y) - | |__________^ UP031 -92 | -93 | ( - | - = help: Replace with format specifiers - -ℹ Suggested fix -86 86 | -87 87 | # Hanging modulos -88 88 | ( -89 |- "foo %s " -90 |- "bar %s" -91 |-) % (x, y) - 89 |+ "foo {} " - 90 |+ "bar {}" - 91 |+).format(x, y) -92 92 | -93 93 | ( -94 94 | "foo %(foo)s " - -UP031_0.py:93:1: UP031 [*] Use format specifiers instead of percent format - | -91 | ) % (x, y) -92 | -93 | / ( -94 | | "foo %(foo)s " -95 | | "bar %(bar)s" -96 | | ) % {"foo": x, "bar": y} - | |________________________^ UP031 -97 | -98 | ( - | - = help: Replace with format specifiers - -ℹ Suggested fix -91 91 | ) % (x, y) -92 92 | -93 93 | ( -94 |- "foo %(foo)s " -95 |- "bar %(bar)s" -96 |-) % {"foo": x, "bar": y} - 94 |+ "foo {foo} " - 95 |+ "bar {bar}" - 96 |+).format(foo=x, bar=y) -97 97 | -98 98 | ( -99 99 | """foo %s""" - -UP031_0.py:99:5: UP031 [*] Use format specifiers instead of percent format - | - 98 | ( - 99 | """foo %s""" - | _____^ -100 | | % (x,) - | |__________^ UP031 -101 | ) - | - = help: Replace with format specifiers - -ℹ Suggested fix -96 96 | ) % {"foo": x, "bar": y} -97 97 | -98 98 | ( -99 |- """foo %s""" -100 |- % (x,) - 99 |+ """foo {}""".format(x) -101 100 | ) -102 101 | -103 102 | ( - -UP031_0.py:104:5: UP031 [*] Use format specifiers instead of percent format - | -103 | ( -104 | """ - | _____^ -105 | | foo %s -106 | | """ -107 | | % (x,) - | |__________^ UP031 -108 | ) - | - = help: Replace with format specifiers - -ℹ Suggested fix -102 102 | -103 103 | ( -104 104 | """ -105 |- foo %s -106 |- """ -107 |- % (x,) - 105 |+ foo {} - 106 |+ """.format(x) -108 107 | ) -109 108 | -110 109 | "%s" % ( - -UP031_0.py:110:1: UP031 Use format specifiers instead of percent format - | -108 | ) -109 | -110 | / "%s" % ( -111 | | x, # comment -112 | | ) - | |_^ UP031 - | - = help: Replace with format specifiers - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP031_1.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP031_1.py.snap deleted file mode 100644 index 870ad3bf5d..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP031_1.py.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP032_0.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP032_0.py.snap deleted file mode 100644 index 9daa8f2dbb..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP032_0.py.snap +++ /dev/null @@ -1,959 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP032_0.py:5:1: UP032 [*] Use f-string instead of `format` call - | -3 | ### -4 | -5 | "{} {}".format(a, b) - | ^^^^^^^^^^^^^^^^^^^^ UP032 -6 | -7 | "{1} {0}".format(a, b) - | - = help: Convert to f-string - -ℹ Suggested fix -2 2 | # Errors -3 3 | ### -4 4 | -5 |-"{} {}".format(a, b) - 5 |+f"{a} {b}" -6 6 | -7 7 | "{1} {0}".format(a, b) -8 8 | - -UP032_0.py:7:1: UP032 [*] Use f-string instead of `format` call - | -5 | "{} {}".format(a, b) -6 | -7 | "{1} {0}".format(a, b) - | ^^^^^^^^^^^^^^^^^^^^^^ UP032 -8 | -9 | "{0} {1} {0}".format(a, b) - | - = help: Convert to f-string - -ℹ Suggested fix -4 4 | -5 5 | "{} {}".format(a, b) -6 6 | -7 |-"{1} {0}".format(a, b) - 7 |+f"{b} {a}" -8 8 | -9 9 | "{0} {1} {0}".format(a, b) -10 10 | - -UP032_0.py:9:1: UP032 [*] Use f-string instead of `format` call - | - 7 | "{1} {0}".format(a, b) - 8 | - 9 | "{0} {1} {0}".format(a, b) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -10 | -11 | "{x.y}".format(x=z) - | - = help: Convert to f-string - -ℹ Suggested fix -6 6 | -7 7 | "{1} {0}".format(a, b) -8 8 | -9 |-"{0} {1} {0}".format(a, b) - 9 |+f"{a} {b} {a}" -10 10 | -11 11 | "{x.y}".format(x=z) -12 12 | - -UP032_0.py:11:1: UP032 [*] Use f-string instead of `format` call - | - 9 | "{0} {1} {0}".format(a, b) -10 | -11 | "{x.y}".format(x=z) - | ^^^^^^^^^^^^^^^^^^^ UP032 -12 | -13 | "{x} {y} {x}".format(x=a, y=b) - | - = help: Convert to f-string - -ℹ Suggested fix -8 8 | -9 9 | "{0} {1} {0}".format(a, b) -10 10 | -11 |-"{x.y}".format(x=z) - 11 |+f"{z.y}" -12 12 | -13 13 | "{x} {y} {x}".format(x=a, y=b) -14 14 | - -UP032_0.py:13:1: UP032 [*] Use f-string instead of `format` call - | -11 | "{x.y}".format(x=z) -12 | -13 | "{x} {y} {x}".format(x=a, y=b) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -14 | -15 | "{.x} {.y}".format(a, b) - | - = help: Convert to f-string - -ℹ Suggested fix -10 10 | -11 11 | "{x.y}".format(x=z) -12 12 | -13 |-"{x} {y} {x}".format(x=a, y=b) - 13 |+f"{a} {b} {a}" -14 14 | -15 15 | "{.x} {.y}".format(a, b) -16 16 | - -UP032_0.py:15:1: UP032 [*] Use f-string instead of `format` call - | -13 | "{x} {y} {x}".format(x=a, y=b) -14 | -15 | "{.x} {.y}".format(a, b) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -16 | -17 | "{} {}".format(a.b, c.d) - | - = help: Convert to f-string - -ℹ Suggested fix -12 12 | -13 13 | "{x} {y} {x}".format(x=a, y=b) -14 14 | -15 |-"{.x} {.y}".format(a, b) - 15 |+f"{a.x} {b.y}" -16 16 | -17 17 | "{} {}".format(a.b, c.d) -18 18 | - -UP032_0.py:17:1: UP032 [*] Use f-string instead of `format` call - | -15 | "{.x} {.y}".format(a, b) -16 | -17 | "{} {}".format(a.b, c.d) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -18 | -19 | "{}".format(a()) - | - = help: Convert to f-string - -ℹ Suggested fix -14 14 | -15 15 | "{.x} {.y}".format(a, b) -16 16 | -17 |-"{} {}".format(a.b, c.d) - 17 |+f"{a.b} {c.d}" -18 18 | -19 19 | "{}".format(a()) -20 20 | - -UP032_0.py:19:1: UP032 [*] Use f-string instead of `format` call - | -17 | "{} {}".format(a.b, c.d) -18 | -19 | "{}".format(a()) - | ^^^^^^^^^^^^^^^^ UP032 -20 | -21 | "{}".format(a.b()) - | - = help: Convert to f-string - -ℹ Suggested fix -16 16 | -17 17 | "{} {}".format(a.b, c.d) -18 18 | -19 |-"{}".format(a()) - 19 |+f"{a()}" -20 20 | -21 21 | "{}".format(a.b()) -22 22 | - -UP032_0.py:21:1: UP032 [*] Use f-string instead of `format` call - | -19 | "{}".format(a()) -20 | -21 | "{}".format(a.b()) - | ^^^^^^^^^^^^^^^^^^ UP032 -22 | -23 | "{}".format(a.b().c()) - | - = help: Convert to f-string - -ℹ Suggested fix -18 18 | -19 19 | "{}".format(a()) -20 20 | -21 |-"{}".format(a.b()) - 21 |+f"{a.b()}" -22 22 | -23 23 | "{}".format(a.b().c()) -24 24 | - -UP032_0.py:23:1: UP032 [*] Use f-string instead of `format` call - | -21 | "{}".format(a.b()) -22 | -23 | "{}".format(a.b().c()) - | ^^^^^^^^^^^^^^^^^^^^^^ UP032 -24 | -25 | "hello {}!".format(name) - | - = help: Convert to f-string - -ℹ Suggested fix -20 20 | -21 21 | "{}".format(a.b()) -22 22 | -23 |-"{}".format(a.b().c()) - 23 |+f"{a.b().c()}" -24 24 | -25 25 | "hello {}!".format(name) -26 26 | - -UP032_0.py:25:1: UP032 [*] Use f-string instead of `format` call - | -23 | "{}".format(a.b().c()) -24 | -25 | "hello {}!".format(name) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -26 | -27 | "{}{b}{}".format(a, c, b=b) - | - = help: Convert to f-string - -ℹ Suggested fix -22 22 | -23 23 | "{}".format(a.b().c()) -24 24 | -25 |-"hello {}!".format(name) - 25 |+f"hello {name}!" -26 26 | -27 27 | "{}{b}{}".format(a, c, b=b) -28 28 | - -UP032_0.py:27:1: UP032 [*] Use f-string instead of `format` call - | -25 | "hello {}!".format(name) -26 | -27 | "{}{b}{}".format(a, c, b=b) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -28 | -29 | "{}".format(0x0) - | - = help: Convert to f-string - -ℹ Suggested fix -24 24 | -25 25 | "hello {}!".format(name) -26 26 | -27 |-"{}{b}{}".format(a, c, b=b) - 27 |+f"{a}{b}{c}" -28 28 | -29 29 | "{}".format(0x0) -30 30 | - -UP032_0.py:29:1: UP032 [*] Use f-string instead of `format` call - | -27 | "{}{b}{}".format(a, c, b=b) -28 | -29 | "{}".format(0x0) - | ^^^^^^^^^^^^^^^^ UP032 -30 | -31 | "{} {}".format(a, b) - | - = help: Convert to f-string - -ℹ Suggested fix -26 26 | -27 27 | "{}{b}{}".format(a, c, b=b) -28 28 | -29 |-"{}".format(0x0) - 29 |+f"{0x0}" -30 30 | -31 31 | "{} {}".format(a, b) -32 32 | - -UP032_0.py:31:1: UP032 [*] Use f-string instead of `format` call - | -29 | "{}".format(0x0) -30 | -31 | "{} {}".format(a, b) - | ^^^^^^^^^^^^^^^^^^^^ UP032 -32 | -33 | """{} {}""".format(a, b) - | - = help: Convert to f-string - -ℹ Suggested fix -28 28 | -29 29 | "{}".format(0x0) -30 30 | -31 |-"{} {}".format(a, b) - 31 |+f"{a} {b}" -32 32 | -33 33 | """{} {}""".format(a, b) -34 34 | - -UP032_0.py:33:1: UP032 [*] Use f-string instead of `format` call - | -31 | "{} {}".format(a, b) -32 | -33 | """{} {}""".format(a, b) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -34 | -35 | "foo{}".format(1) - | - = help: Convert to f-string - -ℹ Suggested fix -30 30 | -31 31 | "{} {}".format(a, b) -32 32 | -33 |-"""{} {}""".format(a, b) - 33 |+f"""{a} {b}""" -34 34 | -35 35 | "foo{}".format(1) -36 36 | - -UP032_0.py:35:1: UP032 [*] Use f-string instead of `format` call - | -33 | """{} {}""".format(a, b) -34 | -35 | "foo{}".format(1) - | ^^^^^^^^^^^^^^^^^ UP032 -36 | -37 | r"foo{}".format(1) - | - = help: Convert to f-string - -ℹ Suggested fix -32 32 | -33 33 | """{} {}""".format(a, b) -34 34 | -35 |-"foo{}".format(1) - 35 |+f"foo{1}" -36 36 | -37 37 | r"foo{}".format(1) -38 38 | - -UP032_0.py:37:1: UP032 [*] Use f-string instead of `format` call - | -35 | "foo{}".format(1) -36 | -37 | r"foo{}".format(1) - | ^^^^^^^^^^^^^^^^^^ UP032 -38 | -39 | x = "{a}".format(a=1) - | - = help: Convert to f-string - -ℹ Suggested fix -34 34 | -35 35 | "foo{}".format(1) -36 36 | -37 |-r"foo{}".format(1) - 37 |+fr"foo{1}" -38 38 | -39 39 | x = "{a}".format(a=1) -40 40 | - -UP032_0.py:39:5: UP032 [*] Use f-string instead of `format` call - | -37 | r"foo{}".format(1) -38 | -39 | x = "{a}".format(a=1) - | ^^^^^^^^^^^^^^^^^ UP032 -40 | -41 | print("foo {} ".format(x)) - | - = help: Convert to f-string - -ℹ Suggested fix -36 36 | -37 37 | r"foo{}".format(1) -38 38 | -39 |-x = "{a}".format(a=1) - 39 |+x = f"{1}" -40 40 | -41 41 | print("foo {} ".format(x)) -42 42 | - -UP032_0.py:41:7: UP032 [*] Use f-string instead of `format` call - | -39 | x = "{a}".format(a=1) -40 | -41 | print("foo {} ".format(x)) - | ^^^^^^^^^^^^^^^^^^^ UP032 -42 | -43 | "{a[b]}".format(a=a) - | - = help: Convert to f-string - -ℹ Suggested fix -38 38 | -39 39 | x = "{a}".format(a=1) -40 40 | -41 |-print("foo {} ".format(x)) - 41 |+print(f"foo {x} ") -42 42 | -43 43 | "{a[b]}".format(a=a) -44 44 | - -UP032_0.py:43:1: UP032 [*] Use f-string instead of `format` call - | -41 | print("foo {} ".format(x)) -42 | -43 | "{a[b]}".format(a=a) - | ^^^^^^^^^^^^^^^^^^^^ UP032 -44 | -45 | "{a.a[b]}".format(a=a) - | - = help: Convert to f-string - -ℹ Suggested fix -40 40 | -41 41 | print("foo {} ".format(x)) -42 42 | -43 |-"{a[b]}".format(a=a) - 43 |+f"{a['b']}" -44 44 | -45 45 | "{a.a[b]}".format(a=a) -46 46 | - -UP032_0.py:45:1: UP032 [*] Use f-string instead of `format` call - | -43 | "{a[b]}".format(a=a) -44 | -45 | "{a.a[b]}".format(a=a) - | ^^^^^^^^^^^^^^^^^^^^^^ UP032 -46 | -47 | "{}{{}}{}".format(escaped, y) - | - = help: Convert to f-string - -ℹ Suggested fix -42 42 | -43 43 | "{a[b]}".format(a=a) -44 44 | -45 |-"{a.a[b]}".format(a=a) - 45 |+f"{a.a['b']}" -46 46 | -47 47 | "{}{{}}{}".format(escaped, y) -48 48 | - -UP032_0.py:47:1: UP032 [*] Use f-string instead of `format` call - | -45 | "{a.a[b]}".format(a=a) -46 | -47 | "{}{{}}{}".format(escaped, y) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -48 | -49 | "{}".format(a) - | - = help: Convert to f-string - -ℹ Suggested fix -44 44 | -45 45 | "{a.a[b]}".format(a=a) -46 46 | -47 |-"{}{{}}{}".format(escaped, y) - 47 |+f"{escaped}{{}}{y}" -48 48 | -49 49 | "{}".format(a) -50 50 | - -UP032_0.py:49:1: UP032 [*] Use f-string instead of `format` call - | -47 | "{}{{}}{}".format(escaped, y) -48 | -49 | "{}".format(a) - | ^^^^^^^^^^^^^^ UP032 -50 | -51 | '({}={{0!e}})'.format(a) - | - = help: Convert to f-string - -ℹ Suggested fix -46 46 | -47 47 | "{}{{}}{}".format(escaped, y) -48 48 | -49 |-"{}".format(a) - 49 |+f"{a}" -50 50 | -51 51 | '({}={{0!e}})'.format(a) -52 52 | - -UP032_0.py:51:1: UP032 [*] Use f-string instead of `format` call - | -49 | "{}".format(a) -50 | -51 | '({}={{0!e}})'.format(a) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -52 | -53 | "{[b]}".format(a) - | - = help: Convert to f-string - -ℹ Suggested fix -48 48 | -49 49 | "{}".format(a) -50 50 | -51 |-'({}={{0!e}})'.format(a) - 51 |+f'({a}={{0!e}})' -52 52 | -53 53 | "{[b]}".format(a) -54 54 | - -UP032_0.py:53:1: UP032 [*] Use f-string instead of `format` call - | -51 | '({}={{0!e}})'.format(a) -52 | -53 | "{[b]}".format(a) - | ^^^^^^^^^^^^^^^^^ UP032 -54 | -55 | '{[b]}'.format(a) - | - = help: Convert to f-string - -ℹ Suggested fix -50 50 | -51 51 | '({}={{0!e}})'.format(a) -52 52 | -53 |-"{[b]}".format(a) - 53 |+f"{a['b']}" -54 54 | -55 55 | '{[b]}'.format(a) -56 56 | - -UP032_0.py:55:1: UP032 [*] Use f-string instead of `format` call - | -53 | "{[b]}".format(a) -54 | -55 | '{[b]}'.format(a) - | ^^^^^^^^^^^^^^^^^ UP032 -56 | -57 | """{[b]}""".format(a) - | - = help: Convert to f-string - -ℹ Suggested fix -52 52 | -53 53 | "{[b]}".format(a) -54 54 | -55 |-'{[b]}'.format(a) - 55 |+f'{a["b"]}' -56 56 | -57 57 | """{[b]}""".format(a) -58 58 | - -UP032_0.py:57:1: UP032 [*] Use f-string instead of `format` call - | -55 | '{[b]}'.format(a) -56 | -57 | """{[b]}""".format(a) - | ^^^^^^^^^^^^^^^^^^^^^ UP032 -58 | -59 | '''{[b]}'''.format(a) - | - = help: Convert to f-string - -ℹ Suggested fix -54 54 | -55 55 | '{[b]}'.format(a) -56 56 | -57 |-"""{[b]}""".format(a) - 57 |+f"""{a["b"]}""" -58 58 | -59 59 | '''{[b]}'''.format(a) -60 60 | - -UP032_0.py:59:1: UP032 [*] Use f-string instead of `format` call - | -57 | """{[b]}""".format(a) -58 | -59 | '''{[b]}'''.format(a) - | ^^^^^^^^^^^^^^^^^^^^^ UP032 -60 | -61 | "{}".format( - | - = help: Convert to f-string - -ℹ Suggested fix -56 56 | -57 57 | """{[b]}""".format(a) -58 58 | -59 |-'''{[b]}'''.format(a) - 59 |+f'''{a["b"]}''' -60 60 | -61 61 | "{}".format( -62 62 | 1 - -UP032_0.py:61:1: UP032 [*] Use f-string instead of `format` call - | -59 | '''{[b]}'''.format(a) -60 | -61 | / "{}".format( -62 | | 1 -63 | | ) - | |_^ UP032 -64 | -65 | "123456789 {}".format( - | - = help: Convert to f-string - -ℹ Suggested fix -58 58 | -59 59 | '''{[b]}'''.format(a) -60 60 | -61 |-"{}".format( -62 |- 1 -63 |-) - 61 |+f"{1}" -64 62 | -65 63 | "123456789 {}".format( -66 64 | 1111111111111111111111111111111111111111111111111111111111111111111111111, - -UP032_0.py:65:1: UP032 [*] Use f-string instead of `format` call - | -63 | ) -64 | -65 | / "123456789 {}".format( -66 | | 1111111111111111111111111111111111111111111111111111111111111111111111111, -67 | | ) - | |_^ UP032 -68 | -69 | """ - | - = help: Convert to f-string - -ℹ Suggested fix -62 62 | 1 -63 63 | ) -64 64 | -65 |-"123456789 {}".format( -66 |- 1111111111111111111111111111111111111111111111111111111111111111111111111, -67 |-) - 65 |+f"123456789 {1111111111111111111111111111111111111111111111111111111111111111111111111}" -68 66 | -69 67 | """ -70 68 | {} - -UP032_0.py:69:1: UP032 [*] Use f-string instead of `format` call - | -67 | ) -68 | -69 | / """ -70 | | {} -71 | | """.format(1) - | |_____________^ UP032 -72 | -73 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = """ - | - = help: Convert to f-string - -ℹ Suggested fix -66 66 | 1111111111111111111111111111111111111111111111111111111111111111111111111, -67 67 | ) -68 68 | - 69 |+f""" - 70 |+{1} -69 71 | """ -70 |-{} -71 |-""".format(1) -72 72 | -73 73 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = """ -74 74 | {} - -UP032_0.py:73:85: UP032 [*] Use f-string instead of `format` call - | -71 | """.format(1) -72 | -73 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = """ - | _____________________________________________________________________________________^ -74 | | {} -75 | | """.format( -76 | | 111111 -77 | | ) - | |_^ UP032 -78 | -79 | "{a}" "{b}".format(a=1, b=1) - | - = help: Convert to f-string - -ℹ Suggested fix -70 70 | {} -71 71 | """.format(1) -72 72 | -73 |-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = """ -74 |-{} -75 |-""".format( -76 |- 111111 -77 |-) - 73 |+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = f""" - 74 |+{111111} - 75 |+""" -78 76 | -79 77 | "{a}" "{b}".format(a=1, b=1) -80 78 | - -UP032_0.py:79:1: UP032 [*] Use f-string instead of `format` call - | -77 | ) -78 | -79 | "{a}" "{b}".format(a=1, b=1) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -80 | -81 | ( - | - = help: Convert to f-string - -ℹ Suggested fix -76 76 | 111111 -77 77 | ) -78 78 | -79 |-"{a}" "{b}".format(a=1, b=1) - 79 |+f"{1}" f"{1}" -80 80 | -81 81 | ( -82 82 | "{a}" - -UP032_0.py:81:1: UP032 [*] Use f-string instead of `format` call - | -79 | "{a}" "{b}".format(a=1, b=1) -80 | -81 | / ( -82 | | "{a}" -83 | | "{b}" -84 | | ).format(a=1, b=1) - | |__________________^ UP032 -85 | -86 | ( - | - = help: Convert to f-string - -ℹ Suggested fix -79 79 | "{a}" "{b}".format(a=1, b=1) -80 80 | -81 81 | ( -82 |- "{a}" -83 |- "{b}" -84 |-).format(a=1, b=1) - 82 |+ f"{1}" - 83 |+ f"{1}" - 84 |+) -85 85 | -86 86 | ( -87 87 | "{a}" - -UP032_0.py:86:1: UP032 [*] Use f-string instead of `format` call - | -84 | ).format(a=1, b=1) -85 | -86 | / ( -87 | | "{a}" -88 | | "" -89 | | "{b}" -90 | | "" -91 | | ).format(a=1, b=1) - | |__________________^ UP032 -92 | -93 | ( - | - = help: Convert to f-string - -ℹ Suggested fix -84 84 | ).format(a=1, b=1) -85 85 | -86 86 | ( -87 |- "{a}" - 87 |+ f"{1}" -88 88 | "" -89 |- "{b}" - 89 |+ f"{1}" -90 90 | "" -91 |-).format(a=1, b=1) - 91 |+) -92 92 | -93 93 | ( -94 94 | ( - -UP032_0.py:94:5: UP032 [*] Use f-string instead of `format` call - | - 93 | ( - 94 | ( - | _____^ - 95 | | # comment - 96 | | "{a}" - 97 | | # comment - 98 | | "{b}" - 99 | | ) -100 | | # comment -101 | | .format(a=1, b=1) - | |_____________________^ UP032 -102 | ) - | - = help: Convert to f-string - -ℹ Suggested fix -93 93 | ( -94 94 | ( -95 95 | # comment -96 |- "{a}" - 96 |+ f"{1}" -97 97 | # comment -98 |- "{b}" - 98 |+ f"{1}" -99 99 | ) -100 100 | # comment -101 |- .format(a=1, b=1) - 101 |+ -102 102 | ) -103 103 | -104 104 | ( - -UP032_0.py:104:1: UP032 [*] Use f-string instead of `format` call - | -102 | ) -103 | -104 | / ( -105 | | "{a}" -106 | | "b" -107 | | ).format(a=1) - | |_____________^ UP032 - | - = help: Convert to f-string - -ℹ Suggested fix -102 102 | ) -103 103 | -104 104 | ( -105 |- "{a}" - 105 |+ f"{1}" -106 106 | "b" -107 |-).format(a=1) - 107 |+) -108 108 | -109 109 | -110 110 | def d(osname, version, release): - -UP032_0.py:111:11: UP032 [*] Use f-string instead of `format` call - | -110 | def d(osname, version, release): -111 | return"{}-{}.{}".format(osname, version, release) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 - | - = help: Convert to f-string - -ℹ Suggested fix -108 108 | -109 109 | -110 110 | def d(osname, version, release): -111 |- return"{}-{}.{}".format(osname, version, release) - 111 |+ return f"{osname}-{version}.{release}" -112 112 | -113 113 | -114 114 | def e(): - -UP032_0.py:115:10: UP032 [*] Use f-string instead of `format` call - | -114 | def e(): -115 | yield"{}".format(1) - | ^^^^^^^^^^^^^^ UP032 - | - = help: Convert to f-string - -ℹ Suggested fix -112 112 | -113 113 | -114 114 | def e(): -115 |- yield"{}".format(1) - 115 |+ yield f"{1}" -116 116 | -117 117 | -118 118 | assert"{}".format(1) - -UP032_0.py:118:7: UP032 [*] Use f-string instead of `format` call - | -118 | assert"{}".format(1) - | ^^^^^^^^^^^^^^ UP032 - | - = help: Convert to f-string - -ℹ Suggested fix -115 115 | yield"{}".format(1) -116 116 | -117 117 | -118 |-assert"{}".format(1) - 118 |+assert f"{1}" -119 119 | -120 120 | -121 121 | async def c(): - -UP032_0.py:122:12: UP032 [*] Use f-string instead of `format` call - | -121 | async def c(): -122 | return "{}".format(await 3) - | ^^^^^^^^^^^^^^^^^^^^ UP032 - | - = help: Convert to f-string - -ℹ Suggested fix -119 119 | -120 120 | -121 121 | async def c(): -122 |- return "{}".format(await 3) - 122 |+ return f"{await 3}" -123 123 | -124 124 | -125 125 | async def c(): - -UP032_0.py:126:12: UP032 [*] Use f-string instead of `format` call - | -125 | async def c(): -126 | return "{}".format(1 + await 3) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 - | - = help: Convert to f-string - -ℹ Suggested fix -123 123 | -124 124 | -125 125 | async def c(): -126 |- return "{}".format(1 + await 3) - 126 |+ return f"{1 + await 3}" -127 127 | -128 128 | -129 129 | "{}".format(1 * 2) - -UP032_0.py:129:1: UP032 [*] Use f-string instead of `format` call - | -129 | "{}".format(1 * 2) - | ^^^^^^^^^^^^^^^^^^ UP032 -130 | -131 | ### - | - = help: Convert to f-string - -ℹ Suggested fix -126 126 | return "{}".format(1 + await 3) -127 127 | -128 128 | -129 |-"{}".format(1 * 2) - 129 |+f"{1 * 2}" -130 130 | -131 131 | ### -132 132 | # Non-errors - -UP032_0.py:202:1: UP032 Use f-string instead of `format` call - | -200 | "{}".format(**c) -201 | -202 | / "{}".format( -203 | | 1 # comment -204 | | ) - | |_^ UP032 - | - = help: Convert to f-string - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP032_1.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP032_1.py.snap deleted file mode 100644 index ead382b08c..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP032_1.py.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP032_1.py:1:1: UP032 [*] Use f-string instead of `format` call - | -1 | "{} {}".format(a, b) # Intentionally at start-of-file, to ensure graceful handling. - | ^^^^^^^^^^^^^^^^^^^^ UP032 - | - = help: Convert to f-string - -ℹ Suggested fix -1 |-"{} {}".format(a, b) # Intentionally at start-of-file, to ensure graceful handling. - 1 |+f"{a} {b}" # Intentionally at start-of-file, to ensure graceful handling. - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP032_2.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP032_2.py.snap deleted file mode 100644 index f0b574f47d..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP032_2.py.snap +++ /dev/null @@ -1,443 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP032_2.py:2:1: UP032 [*] Use f-string instead of `format` call - | -1 | # Errors -2 | "{.real}".format(1) - | ^^^^^^^^^^^^^^^^^^^ UP032 -3 | "{0.real}".format(1) -4 | "{a.real}".format(a=1) - | - = help: Convert to f-string - -ℹ Suggested fix -1 1 | # Errors -2 |-"{.real}".format(1) - 2 |+f"{(1).real}" -3 3 | "{0.real}".format(1) -4 4 | "{a.real}".format(a=1) -5 5 | - -UP032_2.py:3:1: UP032 [*] Use f-string instead of `format` call - | -1 | # Errors -2 | "{.real}".format(1) -3 | "{0.real}".format(1) - | ^^^^^^^^^^^^^^^^^^^^ UP032 -4 | "{a.real}".format(a=1) - | - = help: Convert to f-string - -ℹ Suggested fix -1 1 | # Errors -2 2 | "{.real}".format(1) -3 |-"{0.real}".format(1) - 3 |+f"{(1).real}" -4 4 | "{a.real}".format(a=1) -5 5 | -6 6 | "{.real}".format(1.0) - -UP032_2.py:4:1: UP032 [*] Use f-string instead of `format` call - | -2 | "{.real}".format(1) -3 | "{0.real}".format(1) -4 | "{a.real}".format(a=1) - | ^^^^^^^^^^^^^^^^^^^^^^ UP032 -5 | -6 | "{.real}".format(1.0) - | - = help: Convert to f-string - -ℹ Suggested fix -1 1 | # Errors -2 2 | "{.real}".format(1) -3 3 | "{0.real}".format(1) -4 |-"{a.real}".format(a=1) - 4 |+f"{(1).real}" -5 5 | -6 6 | "{.real}".format(1.0) -7 7 | "{0.real}".format(1.0) - -UP032_2.py:6:1: UP032 [*] Use f-string instead of `format` call - | -4 | "{a.real}".format(a=1) -5 | -6 | "{.real}".format(1.0) - | ^^^^^^^^^^^^^^^^^^^^^ UP032 -7 | "{0.real}".format(1.0) -8 | "{a.real}".format(a=1.0) - | - = help: Convert to f-string - -ℹ Suggested fix -3 3 | "{0.real}".format(1) -4 4 | "{a.real}".format(a=1) -5 5 | -6 |-"{.real}".format(1.0) - 6 |+f"{1.0.real}" -7 7 | "{0.real}".format(1.0) -8 8 | "{a.real}".format(a=1.0) -9 9 | - -UP032_2.py:7:1: UP032 [*] Use f-string instead of `format` call - | -6 | "{.real}".format(1.0) -7 | "{0.real}".format(1.0) - | ^^^^^^^^^^^^^^^^^^^^^^ UP032 -8 | "{a.real}".format(a=1.0) - | - = help: Convert to f-string - -ℹ Suggested fix -4 4 | "{a.real}".format(a=1) -5 5 | -6 6 | "{.real}".format(1.0) -7 |-"{0.real}".format(1.0) - 7 |+f"{1.0.real}" -8 8 | "{a.real}".format(a=1.0) -9 9 | -10 10 | "{.real}".format(1j) - -UP032_2.py:8:1: UP032 [*] Use f-string instead of `format` call - | - 6 | "{.real}".format(1.0) - 7 | "{0.real}".format(1.0) - 8 | "{a.real}".format(a=1.0) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 - 9 | -10 | "{.real}".format(1j) - | - = help: Convert to f-string - -ℹ Suggested fix -5 5 | -6 6 | "{.real}".format(1.0) -7 7 | "{0.real}".format(1.0) -8 |-"{a.real}".format(a=1.0) - 8 |+f"{1.0.real}" -9 9 | -10 10 | "{.real}".format(1j) -11 11 | "{0.real}".format(1j) - -UP032_2.py:10:1: UP032 [*] Use f-string instead of `format` call - | - 8 | "{a.real}".format(a=1.0) - 9 | -10 | "{.real}".format(1j) - | ^^^^^^^^^^^^^^^^^^^^ UP032 -11 | "{0.real}".format(1j) -12 | "{a.real}".format(a=1j) - | - = help: Convert to f-string - -ℹ Suggested fix -7 7 | "{0.real}".format(1.0) -8 8 | "{a.real}".format(a=1.0) -9 9 | -10 |-"{.real}".format(1j) - 10 |+f"{1j.real}" -11 11 | "{0.real}".format(1j) -12 12 | "{a.real}".format(a=1j) -13 13 | - -UP032_2.py:11:1: UP032 [*] Use f-string instead of `format` call - | -10 | "{.real}".format(1j) -11 | "{0.real}".format(1j) - | ^^^^^^^^^^^^^^^^^^^^^ UP032 -12 | "{a.real}".format(a=1j) - | - = help: Convert to f-string - -ℹ Suggested fix -8 8 | "{a.real}".format(a=1.0) -9 9 | -10 10 | "{.real}".format(1j) -11 |-"{0.real}".format(1j) - 11 |+f"{1j.real}" -12 12 | "{a.real}".format(a=1j) -13 13 | -14 14 | "{.real}".format(0b01) - -UP032_2.py:12:1: UP032 [*] Use f-string instead of `format` call - | -10 | "{.real}".format(1j) -11 | "{0.real}".format(1j) -12 | "{a.real}".format(a=1j) - | ^^^^^^^^^^^^^^^^^^^^^^^ UP032 -13 | -14 | "{.real}".format(0b01) - | - = help: Convert to f-string - -ℹ Suggested fix -9 9 | -10 10 | "{.real}".format(1j) -11 11 | "{0.real}".format(1j) -12 |-"{a.real}".format(a=1j) - 12 |+f"{1j.real}" -13 13 | -14 14 | "{.real}".format(0b01) -15 15 | "{0.real}".format(0b01) - -UP032_2.py:14:1: UP032 [*] Use f-string instead of `format` call - | -12 | "{a.real}".format(a=1j) -13 | -14 | "{.real}".format(0b01) - | ^^^^^^^^^^^^^^^^^^^^^^ UP032 -15 | "{0.real}".format(0b01) -16 | "{a.real}".format(a=0b01) - | - = help: Convert to f-string - -ℹ Suggested fix -11 11 | "{0.real}".format(1j) -12 12 | "{a.real}".format(a=1j) -13 13 | -14 |-"{.real}".format(0b01) - 14 |+f"{0b01.real}" -15 15 | "{0.real}".format(0b01) -16 16 | "{a.real}".format(a=0b01) -17 17 | - -UP032_2.py:15:1: UP032 [*] Use f-string instead of `format` call - | -14 | "{.real}".format(0b01) -15 | "{0.real}".format(0b01) - | ^^^^^^^^^^^^^^^^^^^^^^^ UP032 -16 | "{a.real}".format(a=0b01) - | - = help: Convert to f-string - -ℹ Suggested fix -12 12 | "{a.real}".format(a=1j) -13 13 | -14 14 | "{.real}".format(0b01) -15 |-"{0.real}".format(0b01) - 15 |+f"{0b01.real}" -16 16 | "{a.real}".format(a=0b01) -17 17 | -18 18 | "{}".format(1 + 2) - -UP032_2.py:16:1: UP032 [*] Use f-string instead of `format` call - | -14 | "{.real}".format(0b01) -15 | "{0.real}".format(0b01) -16 | "{a.real}".format(a=0b01) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -17 | -18 | "{}".format(1 + 2) - | - = help: Convert to f-string - -ℹ Suggested fix -13 13 | -14 14 | "{.real}".format(0b01) -15 15 | "{0.real}".format(0b01) -16 |-"{a.real}".format(a=0b01) - 16 |+f"{0b01.real}" -17 17 | -18 18 | "{}".format(1 + 2) -19 19 | "{}".format([1, 2]) - -UP032_2.py:18:1: UP032 [*] Use f-string instead of `format` call - | -16 | "{a.real}".format(a=0b01) -17 | -18 | "{}".format(1 + 2) - | ^^^^^^^^^^^^^^^^^^ UP032 -19 | "{}".format([1, 2]) -20 | "{}".format({1, 2}) - | - = help: Convert to f-string - -ℹ Suggested fix -15 15 | "{0.real}".format(0b01) -16 16 | "{a.real}".format(a=0b01) -17 17 | -18 |-"{}".format(1 + 2) - 18 |+f"{1 + 2}" -19 19 | "{}".format([1, 2]) -20 20 | "{}".format({1, 2}) -21 21 | "{}".format({1: 2, 3: 4}) - -UP032_2.py:19:1: UP032 [*] Use f-string instead of `format` call - | -18 | "{}".format(1 + 2) -19 | "{}".format([1, 2]) - | ^^^^^^^^^^^^^^^^^^^ UP032 -20 | "{}".format({1, 2}) -21 | "{}".format({1: 2, 3: 4}) - | - = help: Convert to f-string - -ℹ Suggested fix -16 16 | "{a.real}".format(a=0b01) -17 17 | -18 18 | "{}".format(1 + 2) -19 |-"{}".format([1, 2]) - 19 |+f"{[1, 2]}" -20 20 | "{}".format({1, 2}) -21 21 | "{}".format({1: 2, 3: 4}) -22 22 | "{}".format((i for i in range(2))) - -UP032_2.py:20:1: UP032 [*] Use f-string instead of `format` call - | -18 | "{}".format(1 + 2) -19 | "{}".format([1, 2]) -20 | "{}".format({1, 2}) - | ^^^^^^^^^^^^^^^^^^^ UP032 -21 | "{}".format({1: 2, 3: 4}) -22 | "{}".format((i for i in range(2))) - | - = help: Convert to f-string - -ℹ Suggested fix -17 17 | -18 18 | "{}".format(1 + 2) -19 19 | "{}".format([1, 2]) -20 |-"{}".format({1, 2}) - 20 |+f"{({1, 2})}" -21 21 | "{}".format({1: 2, 3: 4}) -22 22 | "{}".format((i for i in range(2))) -23 23 | - -UP032_2.py:21:1: UP032 [*] Use f-string instead of `format` call - | -19 | "{}".format([1, 2]) -20 | "{}".format({1, 2}) -21 | "{}".format({1: 2, 3: 4}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -22 | "{}".format((i for i in range(2))) - | - = help: Convert to f-string - -ℹ Suggested fix -18 18 | "{}".format(1 + 2) -19 19 | "{}".format([1, 2]) -20 20 | "{}".format({1, 2}) -21 |-"{}".format({1: 2, 3: 4}) - 21 |+f"{({1: 2, 3: 4})}" -22 22 | "{}".format((i for i in range(2))) -23 23 | -24 24 | "{.real}".format(1 + 2) - -UP032_2.py:22:1: UP032 [*] Use f-string instead of `format` call - | -20 | "{}".format({1, 2}) -21 | "{}".format({1: 2, 3: 4}) -22 | "{}".format((i for i in range(2))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -23 | -24 | "{.real}".format(1 + 2) - | - = help: Convert to f-string - -ℹ Suggested fix -19 19 | "{}".format([1, 2]) -20 20 | "{}".format({1, 2}) -21 21 | "{}".format({1: 2, 3: 4}) -22 |-"{}".format((i for i in range(2))) - 22 |+f"{(i for i in range(2))}" -23 23 | -24 24 | "{.real}".format(1 + 2) -25 25 | "{.real}".format([1, 2]) - -UP032_2.py:24:1: UP032 [*] Use f-string instead of `format` call - | -22 | "{}".format((i for i in range(2))) -23 | -24 | "{.real}".format(1 + 2) - | ^^^^^^^^^^^^^^^^^^^^^^^ UP032 -25 | "{.real}".format([1, 2]) -26 | "{.real}".format({1, 2}) - | - = help: Convert to f-string - -ℹ Suggested fix -21 21 | "{}".format({1: 2, 3: 4}) -22 22 | "{}".format((i for i in range(2))) -23 23 | -24 |-"{.real}".format(1 + 2) - 24 |+f"{(1 + 2).real}" -25 25 | "{.real}".format([1, 2]) -26 26 | "{.real}".format({1, 2}) -27 27 | "{.real}".format({1: 2, 3: 4}) - -UP032_2.py:25:1: UP032 [*] Use f-string instead of `format` call - | -24 | "{.real}".format(1 + 2) -25 | "{.real}".format([1, 2]) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -26 | "{.real}".format({1, 2}) -27 | "{.real}".format({1: 2, 3: 4}) - | - = help: Convert to f-string - -ℹ Suggested fix -22 22 | "{}".format((i for i in range(2))) -23 23 | -24 24 | "{.real}".format(1 + 2) -25 |-"{.real}".format([1, 2]) - 25 |+f"{[1, 2].real}" -26 26 | "{.real}".format({1, 2}) -27 27 | "{.real}".format({1: 2, 3: 4}) -28 28 | "{}".format((i for i in range(2))) - -UP032_2.py:26:1: UP032 [*] Use f-string instead of `format` call - | -24 | "{.real}".format(1 + 2) -25 | "{.real}".format([1, 2]) -26 | "{.real}".format({1, 2}) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -27 | "{.real}".format({1: 2, 3: 4}) -28 | "{}".format((i for i in range(2))) - | - = help: Convert to f-string - -ℹ Suggested fix -23 23 | -24 24 | "{.real}".format(1 + 2) -25 25 | "{.real}".format([1, 2]) -26 |-"{.real}".format({1, 2}) - 26 |+f"{({1, 2}).real}" -27 27 | "{.real}".format({1: 2, 3: 4}) -28 28 | "{}".format((i for i in range(2))) - -UP032_2.py:27:1: UP032 [*] Use f-string instead of `format` call - | -25 | "{.real}".format([1, 2]) -26 | "{.real}".format({1, 2}) -27 | "{.real}".format({1: 2, 3: 4}) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 -28 | "{}".format((i for i in range(2))) - | - = help: Convert to f-string - -ℹ Suggested fix -24 24 | "{.real}".format(1 + 2) -25 25 | "{.real}".format([1, 2]) -26 26 | "{.real}".format({1, 2}) -27 |-"{.real}".format({1: 2, 3: 4}) - 27 |+f"{({1: 2, 3: 4}).real}" -28 28 | "{}".format((i for i in range(2))) - -UP032_2.py:28:1: UP032 [*] Use f-string instead of `format` call - | -26 | "{.real}".format({1, 2}) -27 | "{.real}".format({1: 2, 3: 4}) -28 | "{}".format((i for i in range(2))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 - | - = help: Convert to f-string - -ℹ Suggested fix -25 25 | "{.real}".format([1, 2]) -26 26 | "{.real}".format({1, 2}) -27 27 | "{.real}".format({1: 2, 3: 4}) -28 |-"{}".format((i for i in range(2))) - 28 |+f"{(i for i in range(2))}" - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP033_0.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP033_0.py.snap deleted file mode 100644 index dc40338e7e..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP033_0.py.snap +++ /dev/null @@ -1,62 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP033_0.py:4:21: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` - | -4 | @functools.lru_cache(maxsize=None) - | ^^^^^^^^^^^^^^ UP033 -5 | def fixme(): -6 | pass - | - = help: Rewrite with `@functools.cache - -ℹ Fix -1 1 | import functools -2 2 | -3 3 | -4 |-@functools.lru_cache(maxsize=None) - 4 |+@functools.cache -5 5 | def fixme(): -6 6 | pass -7 7 | - -UP033_0.py:10:21: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` - | - 9 | @other_decorator -10 | @functools.lru_cache(maxsize=None) - | ^^^^^^^^^^^^^^ UP033 -11 | def fixme(): -12 | pass - | - = help: Rewrite with `@functools.cache - -ℹ Fix -7 7 | -8 8 | -9 9 | @other_decorator -10 |-@functools.lru_cache(maxsize=None) - 10 |+@functools.cache -11 11 | def fixme(): -12 12 | pass -13 13 | - -UP033_0.py:15:21: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` - | -15 | @functools.lru_cache(maxsize=None) - | ^^^^^^^^^^^^^^ UP033 -16 | @other_decorator -17 | def fixme(): - | - = help: Rewrite with `@functools.cache - -ℹ Fix -12 12 | pass -13 13 | -14 14 | -15 |-@functools.lru_cache(maxsize=None) - 15 |+@functools.cache -16 16 | @other_decorator -17 17 | def fixme(): -18 18 | pass - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP033_1.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP033_1.py.snap deleted file mode 100644 index 5fe701079b..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP033_1.py.snap +++ /dev/null @@ -1,75 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP033_1.py:4:11: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` - | -4 | @lru_cache(maxsize=None) - | ^^^^^^^^^^^^^^ UP033 -5 | def fixme(): -6 | pass - | - = help: Rewrite with `@functools.cache - -ℹ Fix -1 |-from functools import lru_cache - 1 |+from functools import lru_cache, cache -2 2 | -3 3 | -4 |-@lru_cache(maxsize=None) - 4 |+@cache -5 5 | def fixme(): -6 6 | pass -7 7 | - -UP033_1.py:10:11: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` - | - 9 | @other_decorator -10 | @lru_cache(maxsize=None) - | ^^^^^^^^^^^^^^ UP033 -11 | def fixme(): -12 | pass - | - = help: Rewrite with `@functools.cache - -ℹ Fix -1 |-from functools import lru_cache - 1 |+from functools import lru_cache, cache -2 2 | -3 3 | -4 4 | @lru_cache(maxsize=None) --------------------------------------------------------------------------------- -7 7 | -8 8 | -9 9 | @other_decorator -10 |-@lru_cache(maxsize=None) - 10 |+@cache -11 11 | def fixme(): -12 12 | pass -13 13 | - -UP033_1.py:15:11: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` - | -15 | @lru_cache(maxsize=None) - | ^^^^^^^^^^^^^^ UP033 -16 | @other_decorator -17 | def fixme(): - | - = help: Rewrite with `@functools.cache - -ℹ Fix -1 |-from functools import lru_cache - 1 |+from functools import lru_cache, cache -2 2 | -3 3 | -4 4 | @lru_cache(maxsize=None) --------------------------------------------------------------------------------- -12 12 | pass -13 13 | -14 14 | -15 |-@lru_cache(maxsize=None) - 15 |+@cache -16 16 | @other_decorator -17 17 | def fixme(): -18 18 | pass - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP034.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP034.py.snap deleted file mode 100644 index 4373bdabd9..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP034.py.snap +++ /dev/null @@ -1,209 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP034.py:2:7: UP034 [*] Avoid extraneous parentheses - | -1 | # UP034 -2 | print(("foo")) - | ^^^^^^^ UP034 -3 | -4 | # UP034 - | - = help: Remove extraneous parentheses - -ℹ Fix -1 1 | # UP034 -2 |-print(("foo")) - 2 |+print("foo") -3 3 | -4 4 | # UP034 -5 5 | print(("hell((goodybe))o")) - -UP034.py:5:7: UP034 [*] Avoid extraneous parentheses - | -4 | # UP034 -5 | print(("hell((goodybe))o")) - | ^^^^^^^^^^^^^^^^^^^^ UP034 -6 | -7 | # UP034 - | - = help: Remove extraneous parentheses - -ℹ Fix -2 2 | print(("foo")) -3 3 | -4 4 | # UP034 -5 |-print(("hell((goodybe))o")) - 5 |+print("hell((goodybe))o") -6 6 | -7 7 | # UP034 -8 8 | print((("foo"))) - -UP034.py:8:7: UP034 [*] Avoid extraneous parentheses - | - 7 | # UP034 - 8 | print((("foo"))) - | ^^^^^^^^^ UP034 - 9 | -10 | # UP034 - | - = help: Remove extraneous parentheses - -ℹ Fix -5 5 | print(("hell((goodybe))o")) -6 6 | -7 7 | # UP034 -8 |-print((("foo"))) - 8 |+print(("foo")) -9 9 | -10 10 | # UP034 -11 11 | print((((1)))) - -UP034.py:11:7: UP034 [*] Avoid extraneous parentheses - | -10 | # UP034 -11 | print((((1)))) - | ^^^^^^^ UP034 -12 | -13 | # UP034 - | - = help: Remove extraneous parentheses - -ℹ Fix -8 8 | print((("foo"))) -9 9 | -10 10 | # UP034 -11 |-print((((1)))) - 11 |+print(((1))) -12 12 | -13 13 | # UP034 -14 14 | print(("foo{}".format(1))) - -UP034.py:14:7: UP034 [*] Avoid extraneous parentheses - | -13 | # UP034 -14 | print(("foo{}".format(1))) - | ^^^^^^^^^^^^^^^^^^^ UP034 -15 | -16 | # UP034 - | - = help: Remove extraneous parentheses - -ℹ Fix -11 11 | print((((1)))) -12 12 | -13 13 | # UP034 -14 |-print(("foo{}".format(1))) - 14 |+print("foo{}".format(1)) -15 15 | -16 16 | # UP034 -17 17 | print( - -UP034.py:18:5: UP034 [*] Avoid extraneous parentheses - | -16 | # UP034 -17 | print( -18 | ("foo{}".format(1)) - | ^^^^^^^^^^^^^^^^^^^ UP034 -19 | ) - | - = help: Remove extraneous parentheses - -ℹ Fix -15 15 | -16 16 | # UP034 -17 17 | print( -18 |- ("foo{}".format(1)) - 18 |+ "foo{}".format(1) -19 19 | ) -20 20 | -21 21 | # UP034 - -UP034.py:23:5: UP034 [*] Avoid extraneous parentheses - | -21 | # UP034 -22 | print( -23 | ( - | _____^ -24 | | "foo" -25 | | ) - | |_____^ UP034 -26 | ) - | - = help: Remove extraneous parentheses - -ℹ Fix -20 20 | -21 21 | # UP034 -22 22 | print( -23 |- ( - 23 |+ -24 24 | "foo" -25 |- ) - 25 |+ -26 26 | ) -27 27 | -28 28 | # UP034 - -UP034.py:30:13: UP034 [*] Avoid extraneous parentheses - | -28 | # UP034 -29 | def f(): -30 | x = int(((yield 1))) - | ^^^^^^^^^^^ UP034 -31 | -32 | # UP034 - | - = help: Remove extraneous parentheses - -ℹ Fix -27 27 | -28 28 | # UP034 -29 29 | def f(): -30 |- x = int(((yield 1))) - 30 |+ x = int((yield 1)) -31 31 | -32 32 | # UP034 -33 33 | if True: - -UP034.py:35:9: UP034 [*] Avoid extraneous parentheses - | -33 | if True: -34 | print( -35 | ("foo{}".format(1)) - | ^^^^^^^^^^^^^^^^^^^ UP034 -36 | ) - | - = help: Remove extraneous parentheses - -ℹ Fix -32 32 | # UP034 -33 33 | if True: -34 34 | print( -35 |- ("foo{}".format(1)) - 35 |+ "foo{}".format(1) -36 36 | ) -37 37 | -38 38 | # UP034 - -UP034.py:39:7: UP034 [*] Avoid extraneous parentheses - | -38 | # UP034 -39 | print((x for x in range(3))) - | ^^^^^^^^^^^^^^^^^^^^^ UP034 -40 | -41 | # OK - | - = help: Remove extraneous parentheses - -ℹ Fix -36 36 | ) -37 37 | -38 38 | # UP034 -39 |-print((x for x in range(3))) - 39 |+print(x for x in range(3)) -40 40 | -41 41 | # OK -42 42 | print("foo") - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP035.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP035.py.snap deleted file mode 100644 index 323380add2..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP035.py.snap +++ /dev/null @@ -1,1033 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP035.py:2:1: UP035 [*] Import from `collections.abc` instead: `Mapping` - | -1 | # UP035 -2 | from collections import Mapping - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -3 | -4 | from collections import Mapping as MAP - | - = help: Import from `collections.abc` - -ℹ Suggested fix -1 1 | # UP035 -2 |-from collections import Mapping - 2 |+from collections.abc import Mapping -3 3 | -4 4 | from collections import Mapping as MAP -5 5 | - -UP035.py:4:1: UP035 [*] Import from `collections.abc` instead: `Mapping` - | -2 | from collections import Mapping -3 | -4 | from collections import Mapping as MAP - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -5 | -6 | from collections import Mapping, Sequence - | - = help: Import from `collections.abc` - -ℹ Suggested fix -1 1 | # UP035 -2 2 | from collections import Mapping -3 3 | -4 |-from collections import Mapping as MAP - 4 |+from collections.abc import Mapping as MAP -5 5 | -6 6 | from collections import Mapping, Sequence -7 7 | - -UP035.py:6:1: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Sequence` - | -4 | from collections import Mapping as MAP -5 | -6 | from collections import Mapping, Sequence - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -7 | -8 | from collections import Counter, Mapping - | - = help: Import from `collections.abc` - -ℹ Suggested fix -3 3 | -4 4 | from collections import Mapping as MAP -5 5 | -6 |-from collections import Mapping, Sequence - 6 |+from collections.abc import Mapping, Sequence -7 7 | -8 8 | from collections import Counter, Mapping -9 9 | - -UP035.py:8:1: UP035 [*] Import from `collections.abc` instead: `Mapping` - | - 6 | from collections import Mapping, Sequence - 7 | - 8 | from collections import Counter, Mapping - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 - 9 | -10 | from collections import (Counter, Mapping) - | - = help: Import from `collections.abc` - -ℹ Suggested fix -5 5 | -6 6 | from collections import Mapping, Sequence -7 7 | -8 |-from collections import Counter, Mapping - 8 |+from collections import Counter - 9 |+from collections.abc import Mapping -9 10 | -10 11 | from collections import (Counter, Mapping) -11 12 | - -UP035.py:10:1: UP035 [*] Import from `collections.abc` instead: `Mapping` - | - 8 | from collections import Counter, Mapping - 9 | -10 | from collections import (Counter, Mapping) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -11 | -12 | from collections import (Counter, - | - = help: Import from `collections.abc` - -ℹ Suggested fix -7 7 | -8 8 | from collections import Counter, Mapping -9 9 | -10 |-from collections import (Counter, Mapping) - 10 |+from collections import (Counter) - 11 |+from collections.abc import Mapping -11 12 | -12 13 | from collections import (Counter, -13 14 | Mapping) - -UP035.py:12:1: UP035 [*] Import from `collections.abc` instead: `Mapping` - | -10 | from collections import (Counter, Mapping) -11 | -12 | / from collections import (Counter, -13 | | Mapping) - | |_________________________________^ UP035 -14 | -15 | from collections import Counter, \ - | - = help: Import from `collections.abc` - -ℹ Suggested fix -9 9 | -10 10 | from collections import (Counter, Mapping) -11 11 | -12 |-from collections import (Counter, -13 |- Mapping) - 12 |+from collections import (Counter) - 13 |+from collections.abc import Mapping -14 14 | -15 15 | from collections import Counter, \ -16 16 | Mapping - -UP035.py:15:1: UP035 [*] Import from `collections.abc` instead: `Mapping` - | -13 | Mapping) -14 | -15 | / from collections import Counter, \ -16 | | Mapping - | |________________________________^ UP035 -17 | -18 | from collections import Counter, Mapping, Sequence - | - = help: Import from `collections.abc` - -ℹ Suggested fix -12 12 | from collections import (Counter, -13 13 | Mapping) -14 14 | -15 |-from collections import Counter, \ -16 |- Mapping - 15 |+from collections import Counter - 16 |+from collections.abc import Mapping -17 17 | -18 18 | from collections import Counter, Mapping, Sequence -19 19 | - -UP035.py:18:1: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Sequence` - | -16 | Mapping -17 | -18 | from collections import Counter, Mapping, Sequence - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -19 | -20 | from collections import Mapping as mapping, Counter - | - = help: Import from `collections.abc` - -ℹ Suggested fix -15 15 | from collections import Counter, \ -16 16 | Mapping -17 17 | -18 |-from collections import Counter, Mapping, Sequence - 18 |+from collections import Counter - 19 |+from collections.abc import Mapping, Sequence -19 20 | -20 21 | from collections import Mapping as mapping, Counter -21 22 | - -UP035.py:20:1: UP035 [*] Import from `collections.abc` instead: `Mapping` - | -18 | from collections import Counter, Mapping, Sequence -19 | -20 | from collections import Mapping as mapping, Counter - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -21 | -22 | if True: - | - = help: Import from `collections.abc` - -ℹ Suggested fix -17 17 | -18 18 | from collections import Counter, Mapping, Sequence -19 19 | -20 |-from collections import Mapping as mapping, Counter - 20 |+from collections import Counter - 21 |+from collections.abc import Mapping as mapping -21 22 | -22 23 | if True: -23 24 | from collections import Mapping, Counter - -UP035.py:23:5: UP035 [*] Import from `collections.abc` instead: `Mapping` - | -22 | if True: -23 | from collections import Mapping, Counter - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -24 | -25 | if True: - | - = help: Import from `collections.abc` - -ℹ Suggested fix -20 20 | from collections import Mapping as mapping, Counter -21 21 | -22 22 | if True: -23 |- from collections import Mapping, Counter - 23 |+ from collections import Counter - 24 |+ from collections.abc import Mapping -24 25 | -25 26 | if True: -26 27 | if True: - -UP035.py:28:5: UP035 [*] Import from `collections.abc` instead: `Mapping` - | -26 | if True: -27 | pass -28 | from collections import Mapping, Counter - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -29 | -30 | if True: from collections import Mapping - | - = help: Import from `collections.abc` - -ℹ Suggested fix -25 25 | if True: -26 26 | if True: -27 27 | pass -28 |- from collections import Mapping, Counter - 28 |+ from collections import Counter - 29 |+ from collections.abc import Mapping -29 30 | -30 31 | if True: from collections import Mapping -31 32 | - -UP035.py:30:10: UP035 [*] Import from `collections.abc` instead: `Mapping` - | -28 | from collections import Mapping, Counter -29 | -30 | if True: from collections import Mapping - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -31 | -32 | import os - | - = help: Import from `collections.abc` - -ℹ Suggested fix -27 27 | pass -28 28 | from collections import Mapping, Counter -29 29 | -30 |-if True: from collections import Mapping - 30 |+if True: from collections.abc import Mapping -31 31 | -32 32 | import os -33 33 | from collections import Counter, Mapping - -UP035.py:33:1: UP035 [*] Import from `collections.abc` instead: `Mapping` - | -32 | import os -33 | from collections import Counter, Mapping - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -34 | import sys - | - = help: Import from `collections.abc` - -ℹ Suggested fix -30 30 | if True: from collections import Mapping -31 31 | -32 32 | import os -33 |-from collections import Counter, Mapping - 33 |+from collections import Counter - 34 |+from collections.abc import Mapping -34 35 | import sys -35 36 | -36 37 | if True: - -UP035.py:37:5: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Callable` - | -36 | if True: -37 | from collections import ( - | _____^ -38 | | Mapping, -39 | | Callable, -40 | | Bad, -41 | | Good, -42 | | ) - | |_____^ UP035 -43 | -44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager - | - = help: Import from `collections.abc` - -ℹ Suggested fix -35 35 | -36 36 | if True: -37 37 | from collections import ( -38 |- Mapping, -39 |- Callable, -40 38 | Bad, -41 39 | Good, -42 40 | ) - 41 |+ from collections.abc import Mapping, Callable -43 42 | -44 43 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager -45 44 | - -UP035.py:44:1: UP035 [*] Import from `collections.abc` instead: `Callable` - | -42 | ) -43 | -44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -45 | -46 | if True: from collections import ( - | - = help: Import from `collections.abc` - -ℹ Suggested fix -41 41 | Good, -42 42 | ) -43 43 | -44 |-from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager - 44 |+from typing import Match, Pattern, List, OrderedDict, AbstractSet, ContextManager - 45 |+from collections.abc import Callable -45 46 | -46 47 | if True: from collections import ( -47 48 | Mapping, Counter) - -UP035.py:44:1: UP035 [*] Import from `collections` instead: `OrderedDict` - | -42 | ) -43 | -44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -45 | -46 | if True: from collections import ( - | - = help: Import from `collections` - -ℹ Suggested fix -41 41 | Good, -42 42 | ) -43 43 | -44 |-from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager - 44 |+from typing import Callable, Match, Pattern, List, AbstractSet, ContextManager - 45 |+from collections import OrderedDict -45 46 | -46 47 | if True: from collections import ( -47 48 | Mapping, Counter) - -UP035.py:44:1: UP035 [*] Import from `re` instead: `Match`, `Pattern` - | -42 | ) -43 | -44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -45 | -46 | if True: from collections import ( - | - = help: Import from `re` - -ℹ Suggested fix -41 41 | Good, -42 42 | ) -43 43 | -44 |-from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager - 44 |+from typing import Callable, List, OrderedDict, AbstractSet, ContextManager - 45 |+from re import Match, Pattern -45 46 | -46 47 | if True: from collections import ( -47 48 | Mapping, Counter) - -UP035.py:44:1: UP035 `typing.List` is deprecated, use `list` instead - | -42 | ) -43 | -44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -45 | -46 | if True: from collections import ( - | - -UP035.py:44:1: UP035 `typing.AbstractSet` is deprecated, use `collections.abc.Set` instead - | -42 | ) -43 | -44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -45 | -46 | if True: from collections import ( - | - -UP035.py:44:1: UP035 `typing.ContextManager` is deprecated, use `contextlib.AbstractContextManager` instead - | -42 | ) -43 | -44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -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 | -46 | if True: from collections import ( - | __________^ -47 | | Mapping, Counter) - | |_____________________^ UP035 -48 | -49 | # Bad imports from PYI027 that are now handled by PYI022 (UP035) - | - = help: Import from `collections.abc` - -UP035.py:50:1: UP035 `typing.ContextManager` is deprecated, use `contextlib.AbstractContextManager` instead - | -49 | # Bad imports from PYI027 that are now handled by PYI022 (UP035) -50 | from typing import ContextManager - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -51 | from typing import OrderedDict -52 | from typing_extensions import OrderedDict - | - -UP035.py:51:1: UP035 [*] Import from `collections` instead: `OrderedDict` - | -49 | # Bad imports from PYI027 that are now handled by PYI022 (UP035) -50 | from typing import ContextManager -51 | from typing import OrderedDict - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -52 | from typing_extensions import OrderedDict -53 | from typing import Callable - | - = help: Import from `collections` - -ℹ Suggested fix -48 48 | -49 49 | # Bad imports from PYI027 that are now handled by PYI022 (UP035) -50 50 | from typing import ContextManager -51 |-from typing import OrderedDict - 51 |+from collections import OrderedDict -52 52 | from typing_extensions import OrderedDict -53 53 | from typing import Callable -54 54 | from typing import ByteString - -UP035.py:52:1: UP035 [*] Import from `typing` instead: `OrderedDict` - | -50 | from typing import ContextManager -51 | from typing import OrderedDict -52 | from typing_extensions import OrderedDict - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -53 | from typing import Callable -54 | from typing import ByteString - | - = help: Import from `typing` - -ℹ Suggested fix -49 49 | # Bad imports from PYI027 that are now handled by PYI022 (UP035) -50 50 | from typing import ContextManager -51 51 | from typing import OrderedDict -52 |-from typing_extensions import OrderedDict - 52 |+from typing import OrderedDict -53 53 | from typing import Callable -54 54 | from typing import ByteString -55 55 | from typing import Container - -UP035.py:53:1: UP035 [*] Import from `collections.abc` instead: `Callable` - | -51 | from typing import OrderedDict -52 | from typing_extensions import OrderedDict -53 | from typing import Callable - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -54 | from typing import ByteString -55 | from typing import Container - | - = help: Import from `collections.abc` - -ℹ Suggested fix -50 50 | from typing import ContextManager -51 51 | from typing import OrderedDict -52 52 | from typing_extensions import OrderedDict -53 |-from typing import Callable - 53 |+from collections.abc import Callable -54 54 | from typing import ByteString -55 55 | from typing import Container -56 56 | from typing import Hashable - -UP035.py:54:1: UP035 [*] Import from `collections.abc` instead: `ByteString` - | -52 | from typing_extensions import OrderedDict -53 | from typing import Callable -54 | from typing import ByteString - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -55 | from typing import Container -56 | from typing import Hashable - | - = help: Import from `collections.abc` - -ℹ Suggested fix -51 51 | from typing import OrderedDict -52 52 | from typing_extensions import OrderedDict -53 53 | from typing import Callable -54 |-from typing import ByteString - 54 |+from collections.abc import ByteString -55 55 | from typing import Container -56 56 | from typing import Hashable -57 57 | from typing import ItemsView - -UP035.py:55:1: UP035 [*] Import from `collections.abc` instead: `Container` - | -53 | from typing import Callable -54 | from typing import ByteString -55 | from typing import Container - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -56 | from typing import Hashable -57 | from typing import ItemsView - | - = help: Import from `collections.abc` - -ℹ Suggested fix -52 52 | from typing_extensions import OrderedDict -53 53 | from typing import Callable -54 54 | from typing import ByteString -55 |-from typing import Container - 55 |+from collections.abc import Container -56 56 | from typing import Hashable -57 57 | from typing import ItemsView -58 58 | from typing import Iterable - -UP035.py:56:1: UP035 [*] Import from `collections.abc` instead: `Hashable` - | -54 | from typing import ByteString -55 | from typing import Container -56 | from typing import Hashable - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -57 | from typing import ItemsView -58 | from typing import Iterable - | - = help: Import from `collections.abc` - -ℹ Suggested fix -53 53 | from typing import Callable -54 54 | from typing import ByteString -55 55 | from typing import Container -56 |-from typing import Hashable - 56 |+from collections.abc import Hashable -57 57 | from typing import ItemsView -58 58 | from typing import Iterable -59 59 | from typing import Iterator - -UP035.py:57:1: UP035 [*] Import from `collections.abc` instead: `ItemsView` - | -55 | from typing import Container -56 | from typing import Hashable -57 | from typing import ItemsView - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -58 | from typing import Iterable -59 | from typing import Iterator - | - = help: Import from `collections.abc` - -ℹ Suggested fix -54 54 | from typing import ByteString -55 55 | from typing import Container -56 56 | from typing import Hashable -57 |-from typing import ItemsView - 57 |+from collections.abc import ItemsView -58 58 | from typing import Iterable -59 59 | from typing import Iterator -60 60 | from typing import KeysView - -UP035.py:58:1: UP035 [*] Import from `collections.abc` instead: `Iterable` - | -56 | from typing import Hashable -57 | from typing import ItemsView -58 | from typing import Iterable - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -59 | from typing import Iterator -60 | from typing import KeysView - | - = help: Import from `collections.abc` - -ℹ Suggested fix -55 55 | from typing import Container -56 56 | from typing import Hashable -57 57 | from typing import ItemsView -58 |-from typing import Iterable - 58 |+from collections.abc import Iterable -59 59 | from typing import Iterator -60 60 | from typing import KeysView -61 61 | from typing import Mapping - -UP035.py:59:1: UP035 [*] Import from `collections.abc` instead: `Iterator` - | -57 | from typing import ItemsView -58 | from typing import Iterable -59 | from typing import Iterator - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -60 | from typing import KeysView -61 | from typing import Mapping - | - = help: Import from `collections.abc` - -ℹ Suggested fix -56 56 | from typing import Hashable -57 57 | from typing import ItemsView -58 58 | from typing import Iterable -59 |-from typing import Iterator - 59 |+from collections.abc import Iterator -60 60 | from typing import KeysView -61 61 | from typing import Mapping -62 62 | from typing import MappingView - -UP035.py:60:1: UP035 [*] Import from `collections.abc` instead: `KeysView` - | -58 | from typing import Iterable -59 | from typing import Iterator -60 | from typing import KeysView - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -61 | from typing import Mapping -62 | from typing import MappingView - | - = help: Import from `collections.abc` - -ℹ Suggested fix -57 57 | from typing import ItemsView -58 58 | from typing import Iterable -59 59 | from typing import Iterator -60 |-from typing import KeysView - 60 |+from collections.abc import KeysView -61 61 | from typing import Mapping -62 62 | from typing import MappingView -63 63 | from typing import MutableMapping - -UP035.py:61:1: UP035 [*] Import from `collections.abc` instead: `Mapping` - | -59 | from typing import Iterator -60 | from typing import KeysView -61 | from typing import Mapping - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -62 | from typing import MappingView -63 | from typing import MutableMapping - | - = help: Import from `collections.abc` - -ℹ Suggested fix -58 58 | from typing import Iterable -59 59 | from typing import Iterator -60 60 | from typing import KeysView -61 |-from typing import Mapping - 61 |+from collections.abc import Mapping -62 62 | from typing import MappingView -63 63 | from typing import MutableMapping -64 64 | from typing import MutableSequence - -UP035.py:62:1: UP035 [*] Import from `collections.abc` instead: `MappingView` - | -60 | from typing import KeysView -61 | from typing import Mapping -62 | from typing import MappingView - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -63 | from typing import MutableMapping -64 | from typing import MutableSequence - | - = help: Import from `collections.abc` - -ℹ Suggested fix -59 59 | from typing import Iterator -60 60 | from typing import KeysView -61 61 | from typing import Mapping -62 |-from typing import MappingView - 62 |+from collections.abc import MappingView -63 63 | from typing import MutableMapping -64 64 | from typing import MutableSequence -65 65 | from typing import MutableSet - -UP035.py:63:1: UP035 [*] Import from `collections.abc` instead: `MutableMapping` - | -61 | from typing import Mapping -62 | from typing import MappingView -63 | from typing import MutableMapping - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -64 | from typing import MutableSequence -65 | from typing import MutableSet - | - = help: Import from `collections.abc` - -ℹ Suggested fix -60 60 | from typing import KeysView -61 61 | from typing import Mapping -62 62 | from typing import MappingView -63 |-from typing import MutableMapping - 63 |+from collections.abc import MutableMapping -64 64 | from typing import MutableSequence -65 65 | from typing import MutableSet -66 66 | from typing import Sequence - -UP035.py:64:1: UP035 [*] Import from `collections.abc` instead: `MutableSequence` - | -62 | from typing import MappingView -63 | from typing import MutableMapping -64 | from typing import MutableSequence - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -65 | from typing import MutableSet -66 | from typing import Sequence - | - = help: Import from `collections.abc` - -ℹ Suggested fix -61 61 | from typing import Mapping -62 62 | from typing import MappingView -63 63 | from typing import MutableMapping -64 |-from typing import MutableSequence - 64 |+from collections.abc import MutableSequence -65 65 | from typing import MutableSet -66 66 | from typing import Sequence -67 67 | from typing import Sized - -UP035.py:65:1: UP035 [*] Import from `collections.abc` instead: `MutableSet` - | -63 | from typing import MutableMapping -64 | from typing import MutableSequence -65 | from typing import MutableSet - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -66 | from typing import Sequence -67 | from typing import Sized - | - = help: Import from `collections.abc` - -ℹ Suggested fix -62 62 | from typing import MappingView -63 63 | from typing import MutableMapping -64 64 | from typing import MutableSequence -65 |-from typing import MutableSet - 65 |+from collections.abc import MutableSet -66 66 | from typing import Sequence -67 67 | from typing import Sized -68 68 | from typing import ValuesView - -UP035.py:66:1: UP035 [*] Import from `collections.abc` instead: `Sequence` - | -64 | from typing import MutableSequence -65 | from typing import MutableSet -66 | from typing import Sequence - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -67 | from typing import Sized -68 | from typing import ValuesView - | - = help: Import from `collections.abc` - -ℹ Suggested fix -63 63 | from typing import MutableMapping -64 64 | from typing import MutableSequence -65 65 | from typing import MutableSet -66 |-from typing import Sequence - 66 |+from collections.abc import Sequence -67 67 | from typing import Sized -68 68 | from typing import ValuesView -69 69 | from typing import Awaitable - -UP035.py:67:1: UP035 [*] Import from `collections.abc` instead: `Sized` - | -65 | from typing import MutableSet -66 | from typing import Sequence -67 | from typing import Sized - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -68 | from typing import ValuesView -69 | from typing import Awaitable - | - = help: Import from `collections.abc` - -ℹ Suggested fix -64 64 | from typing import MutableSequence -65 65 | from typing import MutableSet -66 66 | from typing import Sequence -67 |-from typing import Sized - 67 |+from collections.abc import Sized -68 68 | from typing import ValuesView -69 69 | from typing import Awaitable -70 70 | from typing import AsyncIterator - -UP035.py:68:1: UP035 [*] Import from `collections.abc` instead: `ValuesView` - | -66 | from typing import Sequence -67 | from typing import Sized -68 | from typing import ValuesView - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -69 | from typing import Awaitable -70 | from typing import AsyncIterator - | - = help: Import from `collections.abc` - -ℹ Suggested fix -65 65 | from typing import MutableSet -66 66 | from typing import Sequence -67 67 | from typing import Sized -68 |-from typing import ValuesView - 68 |+from collections.abc import ValuesView -69 69 | from typing import Awaitable -70 70 | from typing import AsyncIterator -71 71 | from typing import AsyncIterable - -UP035.py:69:1: UP035 [*] Import from `collections.abc` instead: `Awaitable` - | -67 | from typing import Sized -68 | from typing import ValuesView -69 | from typing import Awaitable - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -70 | from typing import AsyncIterator -71 | from typing import AsyncIterable - | - = help: Import from `collections.abc` - -ℹ Suggested fix -66 66 | from typing import Sequence -67 67 | from typing import Sized -68 68 | from typing import ValuesView -69 |-from typing import Awaitable - 69 |+from collections.abc import Awaitable -70 70 | from typing import AsyncIterator -71 71 | from typing import AsyncIterable -72 72 | from typing import Coroutine - -UP035.py:70:1: UP035 [*] Import from `collections.abc` instead: `AsyncIterator` - | -68 | from typing import ValuesView -69 | from typing import Awaitable -70 | from typing import AsyncIterator - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -71 | from typing import AsyncIterable -72 | from typing import Coroutine - | - = help: Import from `collections.abc` - -ℹ Suggested fix -67 67 | from typing import Sized -68 68 | from typing import ValuesView -69 69 | from typing import Awaitable -70 |-from typing import AsyncIterator - 70 |+from collections.abc import AsyncIterator -71 71 | from typing import AsyncIterable -72 72 | from typing import Coroutine -73 73 | from typing import Collection - -UP035.py:71:1: UP035 [*] Import from `collections.abc` instead: `AsyncIterable` - | -69 | from typing import Awaitable -70 | from typing import AsyncIterator -71 | from typing import AsyncIterable - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -72 | from typing import Coroutine -73 | from typing import Collection - | - = help: Import from `collections.abc` - -ℹ Suggested fix -68 68 | from typing import ValuesView -69 69 | from typing import Awaitable -70 70 | from typing import AsyncIterator -71 |-from typing import AsyncIterable - 71 |+from collections.abc import AsyncIterable -72 72 | from typing import Coroutine -73 73 | from typing import Collection -74 74 | from typing import AsyncGenerator - -UP035.py:72:1: UP035 [*] Import from `collections.abc` instead: `Coroutine` - | -70 | from typing import AsyncIterator -71 | from typing import AsyncIterable -72 | from typing import Coroutine - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -73 | from typing import Collection -74 | from typing import AsyncGenerator - | - = help: Import from `collections.abc` - -ℹ Suggested fix -69 69 | from typing import Awaitable -70 70 | from typing import AsyncIterator -71 71 | from typing import AsyncIterable -72 |-from typing import Coroutine - 72 |+from collections.abc import Coroutine -73 73 | from typing import Collection -74 74 | from typing import AsyncGenerator -75 75 | from typing import Reversible - -UP035.py:73:1: UP035 [*] Import from `collections.abc` instead: `Collection` - | -71 | from typing import AsyncIterable -72 | from typing import Coroutine -73 | from typing import Collection - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -74 | from typing import AsyncGenerator -75 | from typing import Reversible - | - = help: Import from `collections.abc` - -ℹ Suggested fix -70 70 | from typing import AsyncIterator -71 71 | from typing import AsyncIterable -72 72 | from typing import Coroutine -73 |-from typing import Collection - 73 |+from collections.abc import Collection -74 74 | from typing import AsyncGenerator -75 75 | from typing import Reversible -76 76 | from typing import Generator - -UP035.py:74:1: UP035 [*] Import from `collections.abc` instead: `AsyncGenerator` - | -72 | from typing import Coroutine -73 | from typing import Collection -74 | from typing import AsyncGenerator - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -75 | from typing import Reversible -76 | from typing import Generator - | - = help: Import from `collections.abc` - -ℹ Suggested fix -71 71 | from typing import AsyncIterable -72 72 | from typing import Coroutine -73 73 | from typing import Collection -74 |-from typing import AsyncGenerator - 74 |+from collections.abc import AsyncGenerator -75 75 | from typing import Reversible -76 76 | from typing import Generator -77 77 | from typing import Callable - -UP035.py:75:1: UP035 [*] Import from `collections.abc` instead: `Reversible` - | -73 | from typing import Collection -74 | from typing import AsyncGenerator -75 | from typing import Reversible - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -76 | from typing import Generator -77 | from typing import Callable - | - = help: Import from `collections.abc` - -ℹ Suggested fix -72 72 | from typing import Coroutine -73 73 | from typing import Collection -74 74 | from typing import AsyncGenerator -75 |-from typing import Reversible - 75 |+from collections.abc import Reversible -76 76 | from typing import Generator -77 77 | from typing import Callable -78 78 | from typing import cast - -UP035.py:76:1: UP035 [*] Import from `collections.abc` instead: `Generator` - | -74 | from typing import AsyncGenerator -75 | from typing import Reversible -76 | from typing import Generator - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -77 | from typing import Callable -78 | from typing import cast - | - = help: Import from `collections.abc` - -ℹ Suggested fix -73 73 | from typing import Collection -74 74 | from typing import AsyncGenerator -75 75 | from typing import Reversible -76 |-from typing import Generator - 76 |+from collections.abc import Generator -77 77 | from typing import Callable -78 78 | from typing import cast -79 79 | - -UP035.py:77:1: UP035 [*] Import from `collections.abc` instead: `Callable` - | -75 | from typing import Reversible -76 | from typing import Generator -77 | from typing import Callable - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -78 | from typing import cast - | - = help: Import from `collections.abc` - -ℹ Suggested fix -74 74 | from typing import AsyncGenerator -75 75 | from typing import Reversible -76 76 | from typing import Generator -77 |-from typing import Callable - 77 |+from collections.abc import Callable -78 78 | from typing import cast -79 79 | -80 80 | # OK - -UP035.py:87:1: UP035 [*] Import from `typing` instead: `NamedTuple` - | -86 | # Ok: `typing_extensions` contains backported improvements. -87 | from typing_extensions import NamedTuple - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 -88 | -89 | # Ok: `typing_extensions` supports `frozen_default` (backported from 3.12). - | - = help: Import from `typing` - -ℹ Suggested fix -84 84 | from typing_extensions import SupportsIndex -85 85 | -86 86 | # Ok: `typing_extensions` contains backported improvements. -87 |-from typing_extensions import NamedTuple - 87 |+from typing import NamedTuple -88 88 | -89 89 | # Ok: `typing_extensions` supports `frozen_default` (backported from 3.12). -90 90 | from typing_extensions import dataclass_transform - -UP035.py:90:1: UP035 [*] Import from `typing` instead: `dataclass_transform` - | -89 | # Ok: `typing_extensions` supports `frozen_default` (backported from 3.12). -90 | from typing_extensions import dataclass_transform - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 - | - = help: Import from `typing` - -ℹ Suggested fix -87 87 | from typing_extensions import NamedTuple -88 88 | -89 89 | # Ok: `typing_extensions` supports `frozen_default` (backported from 3.12). -90 |-from typing_extensions import dataclass_transform - 90 |+from typing import dataclass_transform - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_0.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_0.py.snap deleted file mode 100644 index a2966d46d5..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_0.py.snap +++ /dev/null @@ -1,688 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP036_0.py:3:4: UP036 [*] Version block is outdated for minimum Python version - | -1 | import sys -2 | -3 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -4 | print("py2") -5 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -1 1 | import sys -2 2 | -3 |-if sys.version_info < (3,0): -4 |- print("py2") -5 |-else: -6 |- print("py3") - 3 |+print("py3") -7 4 | -8 5 | if sys.version_info < (3,0): -9 6 | if True: - -UP036_0.py:8:4: UP036 [*] Version block is outdated for minimum Python version - | - 6 | print("py3") - 7 | - 8 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 - 9 | if True: -10 | print("py2!") - | - = help: Remove outdated version block - -ℹ Suggested fix -5 5 | else: -6 6 | print("py3") -7 7 | -8 |-if sys.version_info < (3,0): -9 |- if True: -10 |- print("py2!") -11 |- else: -12 |- print("???") -13 |-else: -14 |- print("py3") - 8 |+print("py3") -15 9 | -16 10 | if sys.version_info < (3,0): print("PY2!") -17 11 | else: print("PY3!") - -UP036_0.py:16:4: UP036 [*] Version block is outdated for minimum Python version - | -14 | print("py3") -15 | -16 | if sys.version_info < (3,0): print("PY2!") - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -17 | else: print("PY3!") - | - = help: Remove outdated version block - -ℹ Suggested fix -13 13 | else: -14 14 | print("py3") -15 15 | -16 |-if sys.version_info < (3,0): print("PY2!") -17 |-else: print("PY3!") - 16 |+print("PY3!") -18 17 | -19 18 | if True: -20 19 | if sys.version_info < (3,0): - -UP036_0.py:20:8: UP036 [*] Version block is outdated for minimum Python version - | -19 | if True: -20 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -21 | print("PY2") -22 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -17 17 | else: print("PY3!") -18 18 | -19 19 | if True: -20 |- if sys.version_info < (3,0): -21 |- print("PY2") -22 |- else: -23 |- print("PY3") - 20 |+ print("PY3") -24 21 | -25 22 | if sys.version_info < (3,0): print(1 if True else 3) -26 23 | else: - -UP036_0.py:25:4: UP036 [*] Version block is outdated for minimum Python version - | -23 | print("PY3") -24 | -25 | if sys.version_info < (3,0): print(1 if True else 3) - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -26 | else: -27 | print("py3") - | - = help: Remove outdated version block - -ℹ Suggested fix -22 22 | else: -23 23 | print("PY3") -24 24 | -25 |-if sys.version_info < (3,0): print(1 if True else 3) -26 |-else: -27 |- print("py3") - 25 |+print("py3") -28 26 | -29 27 | if sys.version_info < (3,0): -30 28 | def f(): - -UP036_0.py:29:4: UP036 [*] Version block is outdated for minimum Python version - | -27 | print("py3") -28 | -29 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -30 | def f(): -31 | print("py2") - | - = help: Remove outdated version block - -ℹ Suggested fix -26 26 | else: -27 27 | print("py3") -28 28 | -29 |-if sys.version_info < (3,0): -30 |- def f(): -31 |- print("py2") -32 |-else: -33 |- def f(): -34 |- print("py3") -35 |- print("This the next") - 29 |+def f(): - 30 |+ print("py3") - 31 |+ print("This the next") -36 32 | -37 33 | if sys.version_info > (3,0): -38 34 | print("py3") - -UP036_0.py:37:4: UP036 [*] Version block is outdated for minimum Python version - | -35 | print("This the next") -36 | -37 | if sys.version_info > (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -38 | print("py3") -39 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -34 34 | print("py3") -35 35 | print("This the next") -36 36 | -37 |-if sys.version_info > (3,0): -38 |- print("py3") -39 |-else: -40 |- print("py2") - 37 |+print("py3") -41 38 | -42 39 | -43 40 | x = 1 - -UP036_0.py:45:4: UP036 [*] Version block is outdated for minimum Python version - | -43 | x = 1 -44 | -45 | if sys.version_info > (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -46 | print("py3") -47 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -42 42 | -43 43 | x = 1 -44 44 | -45 |-if sys.version_info > (3,0): -46 |- print("py3") -47 |-else: -48 |- print("py2") - 45 |+print("py3") -49 46 | # ohai -50 47 | -51 48 | x = 1 - -UP036_0.py:53:4: UP036 [*] Version block is outdated for minimum Python version - | -51 | x = 1 -52 | -53 | if sys.version_info > (3,0): print("py3") - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -54 | else: print("py2") - | - = help: Remove outdated version block - -ℹ Suggested fix -50 50 | -51 51 | x = 1 -52 52 | -53 |-if sys.version_info > (3,0): print("py3") -54 |-else: print("py2") - 53 |+print("py3") -55 54 | -56 55 | if sys.version_info > (3,): -57 56 | print("py3") - -UP036_0.py:56:4: UP036 [*] Version block is outdated for minimum Python version - | -54 | else: print("py2") -55 | -56 | if sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 -57 | print("py3") -58 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -53 53 | if sys.version_info > (3,0): print("py3") -54 54 | else: print("py2") -55 55 | -56 |-if sys.version_info > (3,): -57 |- print("py3") -58 |-else: -59 |- print("py2") - 56 |+print("py3") -60 57 | -61 58 | if True: -62 59 | if sys.version_info > (3,): - -UP036_0.py:62:8: UP036 [*] Version block is outdated for minimum Python version - | -61 | if True: -62 | if sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 -63 | print("py3") -64 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -59 59 | print("py2") -60 60 | -61 61 | if True: -62 |- if sys.version_info > (3,): -63 |- print("py3") -64 |- else: -65 |- print("py2") - 62 |+ print("py3") -66 63 | -67 64 | if sys.version_info < (3,): -68 65 | print("py2") - -UP036_0.py:67:4: UP036 [*] Version block is outdated for minimum Python version - | -65 | print("py2") -66 | -67 | if sys.version_info < (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 -68 | print("py2") -69 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -64 64 | else: -65 65 | print("py2") -66 66 | -67 |-if sys.version_info < (3,): -68 |- print("py2") -69 |-else: -70 |- print("py3") - 67 |+print("py3") -71 68 | -72 69 | def f(): -73 70 | if sys.version_info < (3,0): - -UP036_0.py:73:8: UP036 [*] Version block is outdated for minimum Python version - | -72 | def f(): -73 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -74 | try: -75 | yield - | - = help: Remove outdated version block - -ℹ Suggested fix -70 70 | print("py3") -71 71 | -72 72 | def f(): -73 |- if sys.version_info < (3,0): -74 |- try: -75 |- yield -76 |- finally: -77 |- pass -78 |- else: -79 |- yield - 73 |+ yield -80 74 | -81 75 | -82 76 | class C: - -UP036_0.py:86:8: UP036 [*] Version block is outdated for minimum Python version - | -84 | pass -85 | -86 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -87 | def f(py2): -88 | pass - | - = help: Remove outdated version block - -ℹ Suggested fix -83 83 | def g(): -84 84 | pass -85 85 | -86 |- if sys.version_info < (3,0): -87 |- def f(py2): -88 |- pass -89 |- else: -90 |- def f(py3): -91 |- pass - 86 |+ def f(py3): - 87 |+ pass -92 88 | -93 89 | def h(): -94 90 | pass - -UP036_0.py:97:8: UP036 [*] Version block is outdated for minimum Python version - | -96 | if True: -97 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -98 | 2 -99 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -94 94 | pass -95 95 | -96 96 | if True: -97 |- if sys.version_info < (3,0): -98 |- 2 -99 |- else: -100 |- 3 - 97 |+ 3 -101 98 | -102 99 | # comment -103 100 | - -UP036_0.py:104:4: UP036 [*] Version block is outdated for minimum Python version - | -102 | # comment -103 | -104 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -105 | def f(): -106 | print("py2") - | - = help: Remove outdated version block - -ℹ Suggested fix -101 101 | -102 102 | # comment -103 103 | -104 |-if sys.version_info < (3,0): -105 |- def f(): -106 |- print("py2") -107 |- def g(): -108 |- print("py2") -109 |-else: -110 |- def f(): -111 |- print("py3") -112 |- def g(): -113 |- print("py3") - 104 |+def f(): - 105 |+ print("py3") - 106 |+def g(): - 107 |+ print("py3") -114 108 | -115 109 | if True: -116 110 | if sys.version_info > (3,): - -UP036_0.py:116:8: UP036 [*] Version block is outdated for minimum Python version - | -115 | if True: -116 | if sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 -117 | print(3) -118 | # comment - | - = help: Remove outdated version block - -ℹ Suggested fix -113 113 | print("py3") -114 114 | -115 115 | if True: -116 |- if sys.version_info > (3,): -117 |- print(3) - 116 |+ print(3) -118 117 | # comment -119 118 | print(2+3) -120 119 | - -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 | -124 | if True: - | - = help: Remove outdated version block - -ℹ Suggested fix -119 119 | print(2+3) -120 120 | -121 121 | if True: -122 |- if sys.version_info > (3,): print(3) - 122 |+ print(3) -123 123 | -124 124 | if True: -125 125 | if sys.version_info > (3,): - -UP036_0.py:125:8: UP036 [*] Version block is outdated for minimum Python version - | -124 | if True: -125 | if sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 -126 | print(3) - | - = help: Remove outdated version block - -ℹ Suggested fix -122 122 | if sys.version_info > (3,): print(3) -123 123 | -124 124 | if True: -125 |- if sys.version_info > (3,): -126 |- print(3) - 125 |+ print(3) -127 126 | -128 127 | -129 128 | if True: - -UP036_0.py:130:8: UP036 [*] Version block is outdated for minimum Python version - | -129 | if True: -130 | if sys.version_info <= (3, 0): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -131 | expected_error = [] -132 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -127 127 | -128 128 | -129 129 | if True: -130 |- if sys.version_info <= (3, 0): -131 |- expected_error = [] -132 |- else: -133 |- expected_error = [ - 130 |+ expected_error = [ -134 131 | ":1:5: Generator expression must be parenthesized", -135 132 | "max(1 for i in range(10), key=lambda x: x+1)", -136 133 | " ^", -137 |- ] - 134 |+ ] -138 135 | -139 136 | -140 137 | if sys.version_info <= (3, 0): - -UP036_0.py:140:4: UP036 [*] Version block is outdated for minimum Python version - | -140 | if sys.version_info <= (3, 0): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -141 | expected_error = [] -142 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -137 137 | ] -138 138 | -139 139 | -140 |-if sys.version_info <= (3, 0): -141 |- expected_error = [] -142 |-else: -143 |- expected_error = [ - 140 |+expected_error = [ -144 141 | ":1:5: Generator expression must be parenthesized", -145 142 | "max(1 for i in range(10), key=lambda x: x+1)", -146 143 | " ^", -147 |- ] - 144 |+] -148 145 | -149 146 | -150 147 | if sys.version_info > (3,0): - -UP036_0.py:150:4: UP036 [*] Version block is outdated for minimum Python version - | -150 | if sys.version_info > (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -151 | """this -152 | is valid""" - | - = help: Remove outdated version block - -ℹ Suggested fix -147 147 | ] -148 148 | -149 149 | -150 |-if sys.version_info > (3,0): -151 |- """this - 150 |+"""this -152 151 | is valid""" -153 152 | -154 |- """the indentation on - 153 |+"""the indentation on -155 154 | this line is significant""" -156 155 | -157 |- "this is" \ - 156 |+"this is" \ -158 157 | "allowed too" -159 158 | -160 |- ("so is" -161 |- "this for some reason") - 159 |+("so is" - 160 |+ "this for some reason") -162 161 | -163 162 | if sys.version_info > (3, 0): expected_error = \ -164 163 | [] - -UP036_0.py:163:4: UP036 [*] Version block is outdated for minimum Python version - | -161 | "this for some reason") -162 | -163 | if sys.version_info > (3, 0): expected_error = \ - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -164 | [] - | - = help: Remove outdated version block - -ℹ Suggested fix -160 160 | ("so is" -161 161 | "this for some reason") -162 162 | -163 |-if sys.version_info > (3, 0): expected_error = \ - 163 |+expected_error = \ -164 164 | [] -165 165 | -166 166 | if sys.version_info > (3, 0): expected_error = [] - -UP036_0.py:166:4: UP036 [*] Version block is outdated for minimum Python version - | -164 | [] -165 | -166 | if sys.version_info > (3, 0): expected_error = [] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -167 | -168 | if sys.version_info > (3, 0): \ - | - = help: Remove outdated version block - -ℹ Suggested fix -163 163 | if sys.version_info > (3, 0): expected_error = \ -164 164 | [] -165 165 | -166 |-if sys.version_info > (3, 0): expected_error = [] - 166 |+expected_error = [] -167 167 | -168 168 | if sys.version_info > (3, 0): \ -169 169 | expected_error = [] - -UP036_0.py:168:4: UP036 [*] Version block is outdated for minimum Python version - | -166 | if sys.version_info > (3, 0): expected_error = [] -167 | -168 | if sys.version_info > (3, 0): \ - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -169 | expected_error = [] - | - = help: Remove outdated version block - -ℹ Suggested fix -165 165 | -166 166 | if sys.version_info > (3, 0): expected_error = [] -167 167 | -168 |-if sys.version_info > (3, 0): \ -169 |- expected_error = [] - 168 |+expected_error = [] -170 169 | -171 170 | if True: -172 171 | if sys.version_info > (3, 0): expected_error = \ - -UP036_0.py:172:8: UP036 [*] Version block is outdated for minimum Python version - | -171 | if True: -172 | if sys.version_info > (3, 0): expected_error = \ - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -173 | [] - | - = help: Remove outdated version block - -ℹ Suggested fix -169 169 | expected_error = [] -170 170 | -171 171 | if True: -172 |- if sys.version_info > (3, 0): expected_error = \ - 172 |+ expected_error = \ -173 173 | [] -174 174 | -175 175 | if True: - -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 | -178 | if True: - | - = help: Remove outdated version block - -ℹ Suggested fix -173 173 | [] -174 174 | -175 175 | if True: -176 |- if sys.version_info > (3, 0): expected_error = [] - 176 |+ expected_error = [] -177 177 | -178 178 | if True: -179 179 | if sys.version_info > (3, 0): \ - -UP036_0.py:179:8: UP036 [*] Version block is outdated for minimum Python version - | -178 | if True: -179 | if sys.version_info > (3, 0): \ - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -180 | expected_error = [] - | - = help: Remove outdated version block - -ℹ Suggested fix -176 176 | if sys.version_info > (3, 0): expected_error = [] -177 177 | -178 178 | if True: -179 |- if sys.version_info > (3, 0): \ -180 179 | expected_error = [] -181 180 | -182 181 | if sys.version_info < (3,12): - -UP036_0.py:182:4: UP036 [*] Version block is outdated for minimum Python version - | -180 | expected_error = [] -181 | -182 | if sys.version_info < (3,12): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -183 | print("py3") - | - = help: Remove outdated version block - -ℹ Suggested fix -179 179 | if sys.version_info > (3, 0): \ -180 180 | expected_error = [] -181 181 | -182 |-if sys.version_info < (3,12): -183 |- print("py3") -184 182 | -185 183 | if sys.version_info <= (3,12): -186 184 | print("py3") - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_1.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_1.py.snap deleted file mode 100644 index 5d385f538d..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_1.py.snap +++ /dev/null @@ -1,295 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP036_1.py:3:4: UP036 [*] Version block is outdated for minimum Python version - | -1 | import sys -2 | -3 | if sys.version_info == 2: - | ^^^^^^^^^^^^^^^^^^^^^ UP036 -4 | 2 -5 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -1 1 | import sys -2 2 | -3 |-if sys.version_info == 2: -4 |- 2 -5 |-else: -6 |- 3 - 3 |+3 -7 4 | -8 5 | if sys.version_info < (3,): -9 6 | 2 - -UP036_1.py:8:4: UP036 [*] Version block is outdated for minimum Python version - | - 6 | 3 - 7 | - 8 | if sys.version_info < (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 - 9 | 2 -10 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -5 5 | else: -6 6 | 3 -7 7 | -8 |-if sys.version_info < (3,): -9 |- 2 -10 |-else: -11 |- 3 - 8 |+3 -12 9 | -13 10 | if sys.version_info < (3,0): -14 11 | 2 - -UP036_1.py:13:4: UP036 [*] Version block is outdated for minimum Python version - | -11 | 3 -12 | -13 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -14 | 2 -15 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -10 10 | else: -11 11 | 3 -12 12 | -13 |-if sys.version_info < (3,0): -14 |- 2 -15 |-else: -16 |- 3 - 13 |+3 -17 14 | -18 15 | if sys.version_info == 3: -19 16 | 3 - -UP036_1.py:18:4: UP036 [*] Version block is outdated for minimum Python version - | -16 | 3 -17 | -18 | if sys.version_info == 3: - | ^^^^^^^^^^^^^^^^^^^^^ UP036 -19 | 3 -20 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -15 15 | else: -16 16 | 3 -17 17 | -18 |-if sys.version_info == 3: -19 |- 3 -20 |-else: -21 |- 2 - 18 |+3 -22 19 | -23 20 | if sys.version_info > (3,): -24 21 | 3 - -UP036_1.py:23:4: UP036 [*] Version block is outdated for minimum Python version - | -21 | 2 -22 | -23 | if sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 -24 | 3 -25 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -20 20 | else: -21 21 | 2 -22 22 | -23 |-if sys.version_info > (3,): -24 |- 3 -25 |-else: -26 |- 2 - 23 |+3 -27 24 | -28 25 | if sys.version_info >= (3,): -29 26 | 3 - -UP036_1.py:28:4: UP036 [*] Version block is outdated for minimum Python version - | -26 | 2 -27 | -28 | if sys.version_info >= (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -29 | 3 -30 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -25 25 | else: -26 26 | 2 -27 27 | -28 |-if sys.version_info >= (3,): -29 |- 3 -30 |-else: -31 |- 2 - 28 |+3 -32 29 | -33 30 | from sys import version_info -34 31 | - -UP036_1.py:35:4: UP036 [*] Version block is outdated for minimum Python version - | -33 | from sys import version_info -34 | -35 | if version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^ UP036 -36 | 3 -37 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -32 32 | -33 33 | from sys import version_info -34 34 | -35 |-if version_info > (3,): -36 |- 3 -37 |-else: -38 |- 2 - 35 |+3 -39 36 | -40 37 | if True: -41 38 | print(1) - -UP036_1.py:42:6: UP036 [*] Version block is outdated for minimum Python version - | -40 | if True: -41 | print(1) -42 | elif sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -43 | print(2) -44 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -39 39 | -40 40 | if True: -41 41 | print(1) -42 |-elif sys.version_info < (3,0): -43 |- print(2) -44 42 | else: -45 43 | print(3) -46 44 | - -UP036_1.py:49:6: UP036 [*] Version block is outdated for minimum Python version - | -47 | if True: -48 | print(1) -49 | elif sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 -50 | print(3) -51 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -46 46 | -47 47 | if True: -48 48 | print(1) -49 |-elif sys.version_info > (3,): - 49 |+else: -50 50 | print(3) -51 |-else: -52 |- print(2) -53 51 | -54 52 | if True: -55 53 | print(1) - -UP036_1.py:56:6: UP036 [*] Version block is outdated for minimum Python version - | -54 | if True: -55 | print(1) -56 | elif sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 -57 | print(3) - | - = help: Remove outdated version block - -ℹ Suggested fix -53 53 | -54 54 | if True: -55 55 | print(1) -56 |-elif sys.version_info > (3,): - 56 |+else: -57 57 | print(3) -58 58 | -59 59 | def f(): - -UP036_1.py:62:10: UP036 [*] Version block is outdated for minimum Python version - | -60 | if True: -61 | print(1) -62 | elif sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 -63 | print(3) - | - = help: Remove outdated version block - -ℹ Suggested fix -59 59 | def f(): -60 60 | if True: -61 61 | print(1) -62 |- elif sys.version_info > (3,): - 62 |+ else: -63 63 | print(3) -64 64 | -65 65 | if True: - -UP036_1.py:67:6: UP036 [*] Version block is outdated for minimum Python version - | -65 | if True: -66 | print(1) -67 | elif sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -68 | print(2) -69 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -64 64 | -65 65 | if True: -66 66 | print(1) -67 |-elif sys.version_info < (3,0): -68 |- print(2) -69 67 | else: -70 68 | print(3) -71 69 | - -UP036_1.py:75:10: UP036 [*] Version block is outdated for minimum Python version - | -73 | if True: -74 | print(1) -75 | elif sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 -76 | print(3) - | - = help: Remove outdated version block - -ℹ Suggested fix -72 72 | def f(): -73 73 | if True: -74 74 | print(1) -75 |- elif sys.version_info > (3,): - 75 |+ else: -76 76 | print(3) - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_2.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_2.py.snap deleted file mode 100644 index 9ca87c972a..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_2.py.snap +++ /dev/null @@ -1,280 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP036_2.py:4:4: UP036 [*] Version block is outdated for minimum Python version - | -2 | from sys import version_info -3 | -4 | if sys.version_info > (3, 5): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -5 | 3+6 -6 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -1 1 | import sys -2 2 | from sys import version_info -3 3 | -4 |-if sys.version_info > (3, 5): -5 |- 3+6 -6 |-else: -7 |- 3-5 - 4 |+3+6 -8 5 | -9 6 | if version_info > (3, 5): -10 7 | 3+6 - -UP036_2.py:9:4: UP036 [*] Version block is outdated for minimum Python version - | - 7 | 3-5 - 8 | - 9 | if version_info > (3, 5): - | ^^^^^^^^^^^^^^^^^^^^^ UP036 -10 | 3+6 -11 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -6 6 | else: -7 7 | 3-5 -8 8 | -9 |-if version_info > (3, 5): -10 |- 3+6 -11 |-else: -12 |- 3-5 - 9 |+3+6 -13 10 | -14 11 | if sys.version_info >= (3,6): -15 12 | 3+6 - -UP036_2.py:14:4: UP036 [*] Version block is outdated for minimum Python version - | -12 | 3-5 -13 | -14 | if sys.version_info >= (3,6): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -15 | 3+6 -16 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -11 11 | else: -12 12 | 3-5 -13 13 | -14 |-if sys.version_info >= (3,6): -15 |- 3+6 -16 |-else: -17 |- 3-5 - 14 |+3+6 -18 15 | -19 16 | if version_info >= (3,6): -20 17 | 3+6 - -UP036_2.py:19:4: UP036 [*] Version block is outdated for minimum Python version - | -17 | 3-5 -18 | -19 | if version_info >= (3,6): - | ^^^^^^^^^^^^^^^^^^^^^ UP036 -20 | 3+6 -21 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -16 16 | else: -17 17 | 3-5 -18 18 | -19 |-if version_info >= (3,6): -20 |- 3+6 -21 |-else: -22 |- 3-5 - 19 |+3+6 -23 20 | -24 21 | if sys.version_info < (3,6): -25 22 | 3-5 - -UP036_2.py:24:4: UP036 [*] Version block is outdated for minimum Python version - | -22 | 3-5 -23 | -24 | if sys.version_info < (3,6): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -25 | 3-5 -26 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -21 21 | else: -22 22 | 3-5 -23 23 | -24 |-if sys.version_info < (3,6): -25 |- 3-5 -26 |-else: -27 |- 3+6 - 24 |+3+6 -28 25 | -29 26 | if sys.version_info <= (3,5): -30 27 | 3-5 - -UP036_2.py:29:4: UP036 [*] Version block is outdated for minimum Python version - | -27 | 3+6 -28 | -29 | if sys.version_info <= (3,5): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -30 | 3-5 -31 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -26 26 | else: -27 27 | 3+6 -28 28 | -29 |-if sys.version_info <= (3,5): -30 |- 3-5 -31 |-else: -32 |- 3+6 - 29 |+3+6 -33 30 | -34 31 | if sys.version_info <= (3, 5): -35 32 | 3-5 - -UP036_2.py:34:4: UP036 [*] Version block is outdated for minimum Python version - | -32 | 3+6 -33 | -34 | if sys.version_info <= (3, 5): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -35 | 3-5 -36 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -31 31 | else: -32 32 | 3+6 -33 33 | -34 |-if sys.version_info <= (3, 5): -35 |- 3-5 -36 |-else: -37 |- 3+6 - 34 |+3+6 -38 35 | -39 36 | if sys.version_info >= (3, 5): -40 37 | pass - -UP036_2.py:39:4: UP036 [*] Version block is outdated for minimum Python version - | -37 | 3+6 -38 | -39 | if sys.version_info >= (3, 5): - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -40 | pass - | - = help: Remove outdated version block - -ℹ Suggested fix -36 36 | else: -37 37 | 3+6 -38 38 | -39 |-if sys.version_info >= (3, 5): -40 |- pass - 39 |+pass -41 40 | -42 41 | if sys.version_info < (3,0): -43 42 | pass - -UP036_2.py:42:4: UP036 [*] Version block is outdated for minimum Python version - | -40 | pass -41 | -42 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -43 | pass - | - = help: Remove outdated version block - -ℹ Suggested fix -39 39 | if sys.version_info >= (3, 5): -40 40 | pass -41 41 | -42 |-if sys.version_info < (3,0): -43 |- pass -44 42 | -45 43 | if True: -46 44 | if sys.version_info < (3,0): - -UP036_2.py:46:8: UP036 [*] Version block is outdated for minimum Python version - | -45 | if True: -46 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -47 | pass - | - = help: Remove outdated version block - -ℹ Suggested fix -43 43 | pass -44 44 | -45 45 | if True: -46 |- if sys.version_info < (3,0): -47 |- pass - 46 |+ pass -48 47 | -49 48 | if sys.version_info < (3,0): -50 49 | pass - -UP036_2.py:49:4: UP036 [*] Version block is outdated for minimum Python version - | -47 | pass -48 | -49 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -50 | pass -51 | elif False: - | - = help: Remove outdated version block - -ℹ Suggested fix -46 46 | if sys.version_info < (3,0): -47 47 | pass -48 48 | -49 |-if sys.version_info < (3,0): -50 |- pass -51 |-elif False: - 49 |+if False: -52 50 | pass -53 51 | -54 52 | if sys.version_info > (3,): - -UP036_2.py:54:4: UP036 [*] Version block is outdated for minimum Python version - | -52 | pass -53 | -54 | if sys.version_info > (3,): - | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 -55 | pass -56 | elif False: - | - = help: Remove outdated version block - -ℹ Suggested fix -51 51 | elif False: -52 52 | pass -53 53 | -54 |-if sys.version_info > (3,): -55 |- pass -56 |-elif False: -57 |- pass - 54 |+pass -58 55 | -59 56 | if sys.version_info[0] > "2": -60 57 | 3 - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_3.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_3.py.snap deleted file mode 100644 index d82d1aba25..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_3.py.snap +++ /dev/null @@ -1,78 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP036_3.py:3:15: UP036 [*] Version block is outdated for minimum Python version - | -1 | import sys -2 | -3 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -4 | print("py2") -5 | for item in range(10): - | - = help: Remove outdated version block - -ℹ Suggested fix -1 1 | import sys -2 2 | -3 |-if sys.version_info < (3,0): -4 |- print("py2") -5 |- for item in range(10): -6 |- print(f"PY2-{item}") -7 |-else : -8 |- print("py3") -9 |- for item in range(10): -10 |- print(f"PY3-{item}") - 3 |+print("py3") - 4 |+for item in range(10): - 5 |+ print(f"PY3-{item}") -11 6 | -12 7 | if False: -13 8 | if sys.version_info < (3,0): - -UP036_3.py:13:19: UP036 [*] Version block is outdated for minimum Python version - | -12 | if False: -13 | if sys.version_info < (3,0): - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -14 | print("py2") -15 | for item in range(10): - | - = help: Remove outdated version block - -ℹ Suggested fix -10 10 | print(f"PY3-{item}") -11 11 | -12 12 | if False: -13 |- if sys.version_info < (3,0): -14 |- print("py2") -15 |- for item in range(10): -16 |- print(f"PY2-{item}") -17 |- else : -18 |- print("py3") -19 |- for item in range(10): -20 |- print(f"PY3-{item}") - 13 |+ print("py3") - 14 |+ for item in range(10): - 15 |+ print(f"PY3-{item}") -21 16 | -22 17 | -23 18 | if sys.version_info < (3,0): print("PY2!") - -UP036_3.py:23:15: UP036 [*] Version block is outdated for minimum Python version - | -23 | if sys.version_info < (3,0): print("PY2!") - | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -24 | else : print("PY3!") - | - = help: Remove outdated version block - -ℹ Suggested fix -20 20 | print(f"PY3-{item}") -21 21 | -22 22 | -23 |-if sys.version_info < (3,0): print("PY2!") -24 |-else : print("PY3!") - 23 |+print("PY3!") - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_4.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_4.py.snap deleted file mode 100644 index a0bacbe7af..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_4.py.snap +++ /dev/null @@ -1,173 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP036_4.py:4:8: UP036 [*] Version block is outdated for minimum Python version - | -3 | if True: -4 | if sys.version_info < (3, 3): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -5 | cmd = [sys.executable, "-m", "test.regrtest"] - | - = help: Remove outdated version block - -ℹ Suggested fix -1 1 | import sys -2 2 | -3 3 | if True: -4 |- if sys.version_info < (3, 3): -5 |- cmd = [sys.executable, "-m", "test.regrtest"] - 4 |+ pass -6 5 | -7 6 | -8 7 | if True: - -UP036_4.py:11:10: UP036 [*] Version block is outdated for minimum Python version - | - 9 | if foo: -10 | print() -11 | elif sys.version_info < (3, 3): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -12 | cmd = [sys.executable, "-m", "test.regrtest"] - | - = help: Remove outdated version block - -ℹ Suggested fix -8 8 | if True: -9 9 | if foo: -10 10 | print() -11 |- elif sys.version_info < (3, 3): -12 |- cmd = [sys.executable, "-m", "test.regrtest"] - 11 |+ -13 12 | -14 13 | if True: -15 14 | if foo: - -UP036_4.py:17:10: UP036 [*] Version block is outdated for minimum Python version - | -15 | if foo: -16 | print() -17 | elif sys.version_info < (3, 3): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -18 | cmd = [sys.executable, "-m", "test.regrtest"] -19 | elif foo: - | - = help: Remove outdated version block - -ℹ Suggested fix -14 14 | if True: -15 15 | if foo: -16 16 | print() -17 |- elif sys.version_info < (3, 3): -18 |- cmd = [sys.executable, "-m", "test.regrtest"] -19 17 | elif foo: -20 18 | cmd = [sys.executable, "-m", "test", "-j0"] -21 19 | - -UP036_4.py:24:10: UP036 [*] Version block is outdated for minimum Python version - | -22 | if foo: -23 | print() -24 | elif sys.version_info < (3, 3): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -25 | cmd = [sys.executable, "-m", "test.regrtest"] - | - = help: Remove outdated version block - -ℹ Suggested fix -21 21 | -22 22 | if foo: -23 23 | print() -24 |- elif sys.version_info < (3, 3): -25 |- cmd = [sys.executable, "-m", "test.regrtest"] - 24 |+ -26 25 | -27 26 | if sys.version_info < (3, 3): -28 27 | cmd = [sys.executable, "-m", "test.regrtest"] - -UP036_4.py:27:8: UP036 [*] Version block is outdated for minimum Python version - | -25 | cmd = [sys.executable, "-m", "test.regrtest"] -26 | -27 | if sys.version_info < (3, 3): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -28 | cmd = [sys.executable, "-m", "test.regrtest"] - | - = help: Remove outdated version block - -ℹ Suggested fix -24 24 | elif sys.version_info < (3, 3): -25 25 | cmd = [sys.executable, "-m", "test.regrtest"] -26 26 | -27 |- if sys.version_info < (3, 3): -28 |- cmd = [sys.executable, "-m", "test.regrtest"] -29 27 | -30 28 | if foo: -31 29 | print() - -UP036_4.py:32:10: UP036 [*] Version block is outdated for minimum Python version - | -30 | if foo: -31 | print() -32 | elif sys.version_info < (3, 3): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -33 | cmd = [sys.executable, "-m", "test.regrtest"] -34 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -29 29 | -30 30 | if foo: -31 31 | print() -32 |- elif sys.version_info < (3, 3): -33 |- cmd = [sys.executable, "-m", "test.regrtest"] -34 32 | else: -35 33 | cmd = [sys.executable, "-m", "test", "-j0"] -36 34 | - -UP036_4.py:37:8: UP036 [*] Version block is outdated for minimum Python version - | -35 | cmd = [sys.executable, "-m", "test", "-j0"] -36 | -37 | if sys.version_info < (3, 3): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -38 | cmd = [sys.executable, "-m", "test.regrtest"] -39 | else: - | - = help: Remove outdated version block - -ℹ Suggested fix -34 34 | else: -35 35 | cmd = [sys.executable, "-m", "test", "-j0"] -36 36 | -37 |- if sys.version_info < (3, 3): -38 |- cmd = [sys.executable, "-m", "test.regrtest"] -39 |- else: -40 |- cmd = [sys.executable, "-m", "test", "-j0"] - 37 |+ cmd = [sys.executable, "-m", "test", "-j0"] -41 38 | -42 39 | if sys.version_info < (3, 3): -43 40 | cmd = [sys.executable, "-m", "test.regrtest"] - -UP036_4.py:42:8: UP036 [*] Version block is outdated for minimum Python version - | -40 | cmd = [sys.executable, "-m", "test", "-j0"] -41 | -42 | if sys.version_info < (3, 3): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -43 | cmd = [sys.executable, "-m", "test.regrtest"] -44 | elif foo: - | - = help: Remove outdated version block - -ℹ Suggested fix -39 39 | else: -40 40 | cmd = [sys.executable, "-m", "test", "-j0"] -41 41 | -42 |- if sys.version_info < (3, 3): -43 |- cmd = [sys.executable, "-m", "test.regrtest"] -44 |- elif foo: - 42 |+ if foo: -45 43 | cmd = [sys.executable, "-m", "test", "-j0"] - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_5.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_5.py.snap deleted file mode 100644 index 3bc04c32cb..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP036_5.py.snap +++ /dev/null @@ -1,70 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP036_5.py:3:4: UP036 [*] Version block is outdated for minimum Python version - | -1 | import sys -2 | -3 | if sys.version_info < (3, 8): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -4 | -5 | def a(): - | - = help: Remove outdated version block - -ℹ Suggested fix -1 1 | import sys -2 2 | -3 |-if sys.version_info < (3, 8): -4 |- -5 |- def a(): -6 |- if b: -7 |- print(1) -8 |- elif c: -9 |- print(2) -10 |- return None -11 |- -12 |-else: -13 |- pass - 3 |+pass -14 4 | -15 5 | -16 6 | import sys - -UP036_5.py:18:4: UP036 [*] Version block is outdated for minimum Python version - | -16 | import sys -17 | -18 | if sys.version_info < (3, 8): - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 -19 | pass - | - = help: Remove outdated version block - -ℹ Suggested fix -15 15 | -16 16 | import sys -17 17 | -18 |-if sys.version_info < (3, 8): -19 |- pass -20 |- -21 |-else: -22 |- -23 |- def a(): -24 |- if b: -25 |- print(1) -26 |- elif c: -27 |- print(2) -28 |- else: -29 |- print(3) -30 |- return None - 18 |+def a(): - 19 |+ if b: - 20 |+ print(1) - 21 |+ elif c: - 22 |+ print(2) - 23 |+ else: - 24 |+ print(3) - 25 |+ return None - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP037.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP037.py.snap deleted file mode 100644 index 8d3af3b967..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP037.py.snap +++ /dev/null @@ -1,559 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP037.py:18:14: UP037 [*] Remove quotes from type annotation - | -18 | def foo(var: "MyClass") -> "MyClass": - | ^^^^^^^^^ UP037 -19 | x: "MyClass" - | - = help: Remove quotes - -ℹ Fix -15 15 | from mypy_extensions import Arg, DefaultArg, DefaultNamedArg, NamedArg, VarArg -16 16 | -17 17 | -18 |-def foo(var: "MyClass") -> "MyClass": - 18 |+def foo(var: MyClass) -> "MyClass": -19 19 | x: "MyClass" -20 20 | -21 21 | - -UP037.py:18:28: UP037 [*] Remove quotes from type annotation - | -18 | def foo(var: "MyClass") -> "MyClass": - | ^^^^^^^^^ UP037 -19 | x: "MyClass" - | - = help: Remove quotes - -ℹ Fix -15 15 | from mypy_extensions import Arg, DefaultArg, DefaultNamedArg, NamedArg, VarArg -16 16 | -17 17 | -18 |-def foo(var: "MyClass") -> "MyClass": - 18 |+def foo(var: "MyClass") -> MyClass: -19 19 | x: "MyClass" -20 20 | -21 21 | - -UP037.py:19:8: UP037 [*] Remove quotes from type annotation - | -18 | def foo(var: "MyClass") -> "MyClass": -19 | x: "MyClass" - | ^^^^^^^^^ UP037 - | - = help: Remove quotes - -ℹ Fix -16 16 | -17 17 | -18 18 | def foo(var: "MyClass") -> "MyClass": -19 |- x: "MyClass" - 19 |+ x: MyClass -20 20 | -21 21 | -22 22 | def foo(*, inplace: "bool"): - -UP037.py:22:21: UP037 [*] Remove quotes from type annotation - | -22 | def foo(*, inplace: "bool"): - | ^^^^^^ UP037 -23 | pass - | - = help: Remove quotes - -ℹ Fix -19 19 | x: "MyClass" -20 20 | -21 21 | -22 |-def foo(*, inplace: "bool"): - 22 |+def foo(*, inplace: bool): -23 23 | pass -24 24 | -25 25 | - -UP037.py:26:16: UP037 [*] Remove quotes from type annotation - | -26 | def foo(*args: "str", **kwargs: "int"): - | ^^^^^ UP037 -27 | pass - | - = help: Remove quotes - -ℹ Fix -23 23 | pass -24 24 | -25 25 | -26 |-def foo(*args: "str", **kwargs: "int"): - 26 |+def foo(*args: str, **kwargs: "int"): -27 27 | pass -28 28 | -29 29 | - -UP037.py:26:33: UP037 [*] Remove quotes from type annotation - | -26 | def foo(*args: "str", **kwargs: "int"): - | ^^^^^ UP037 -27 | pass - | - = help: Remove quotes - -ℹ Fix -23 23 | pass -24 24 | -25 25 | -26 |-def foo(*args: "str", **kwargs: "int"): - 26 |+def foo(*args: "str", **kwargs: int): -27 27 | pass -28 28 | -29 29 | - -UP037.py:30:10: UP037 [*] Remove quotes from type annotation - | -30 | x: Tuple["MyClass"] - | ^^^^^^^^^ UP037 -31 | -32 | x: Callable[["MyClass"], None] - | - = help: Remove quotes - -ℹ Fix -27 27 | pass -28 28 | -29 29 | -30 |-x: Tuple["MyClass"] - 30 |+x: Tuple[MyClass] -31 31 | -32 32 | x: Callable[["MyClass"], None] -33 33 | - -UP037.py:32:14: UP037 [*] Remove quotes from type annotation - | -30 | x: Tuple["MyClass"] -31 | -32 | x: Callable[["MyClass"], None] - | ^^^^^^^^^ UP037 - | - = help: Remove quotes - -ℹ Fix -29 29 | -30 30 | x: Tuple["MyClass"] -31 31 | -32 |-x: Callable[["MyClass"], None] - 32 |+x: Callable[[MyClass], None] -33 33 | -34 34 | -35 35 | class Foo(NamedTuple): - -UP037.py:36:8: UP037 [*] Remove quotes from type annotation - | -35 | class Foo(NamedTuple): -36 | x: "MyClass" - | ^^^^^^^^^ UP037 - | - = help: Remove quotes - -ℹ Fix -33 33 | -34 34 | -35 35 | class Foo(NamedTuple): -36 |- x: "MyClass" - 36 |+ x: MyClass -37 37 | -38 38 | -39 39 | class D(TypedDict): - -UP037.py:40:27: UP037 [*] Remove quotes from type annotation - | -39 | class D(TypedDict): -40 | E: TypedDict("E", foo="int", total=False) - | ^^^^^ UP037 - | - = help: Remove quotes - -ℹ Fix -37 37 | -38 38 | -39 39 | class D(TypedDict): -40 |- E: TypedDict("E", foo="int", total=False) - 40 |+ E: TypedDict("E", foo=int, total=False) -41 41 | -42 42 | -43 43 | class D(TypedDict): - -UP037.py:44:31: UP037 [*] Remove quotes from type annotation - | -43 | class D(TypedDict): -44 | E: TypedDict("E", {"foo": "int"}) - | ^^^^^ UP037 - | - = help: Remove quotes - -ℹ Fix -41 41 | -42 42 | -43 43 | class D(TypedDict): -44 |- E: TypedDict("E", {"foo": "int"}) - 44 |+ E: TypedDict("E", {"foo": int}) -45 45 | -46 46 | -47 47 | x: Annotated["str", "metadata"] - -UP037.py:47:14: UP037 [*] Remove quotes from type annotation - | -47 | x: Annotated["str", "metadata"] - | ^^^^^ UP037 -48 | -49 | x: Arg("str", "name") - | - = help: Remove quotes - -ℹ Fix -44 44 | E: TypedDict("E", {"foo": "int"}) -45 45 | -46 46 | -47 |-x: Annotated["str", "metadata"] - 47 |+x: Annotated[str, "metadata"] -48 48 | -49 49 | x: Arg("str", "name") -50 50 | - -UP037.py:49:8: UP037 [*] Remove quotes from type annotation - | -47 | x: Annotated["str", "metadata"] -48 | -49 | x: Arg("str", "name") - | ^^^^^ UP037 -50 | -51 | x: DefaultArg("str", "name") - | - = help: Remove quotes - -ℹ Fix -46 46 | -47 47 | x: Annotated["str", "metadata"] -48 48 | -49 |-x: Arg("str", "name") - 49 |+x: Arg(str, "name") -50 50 | -51 51 | x: DefaultArg("str", "name") -52 52 | - -UP037.py:51:15: UP037 [*] Remove quotes from type annotation - | -49 | x: Arg("str", "name") -50 | -51 | x: DefaultArg("str", "name") - | ^^^^^ UP037 -52 | -53 | x: NamedArg("str", "name") - | - = help: Remove quotes - -ℹ Fix -48 48 | -49 49 | x: Arg("str", "name") -50 50 | -51 |-x: DefaultArg("str", "name") - 51 |+x: DefaultArg(str, "name") -52 52 | -53 53 | x: NamedArg("str", "name") -54 54 | - -UP037.py:53:13: UP037 [*] Remove quotes from type annotation - | -51 | x: DefaultArg("str", "name") -52 | -53 | x: NamedArg("str", "name") - | ^^^^^ UP037 -54 | -55 | x: DefaultNamedArg("str", "name") - | - = help: Remove quotes - -ℹ Fix -50 50 | -51 51 | x: DefaultArg("str", "name") -52 52 | -53 |-x: NamedArg("str", "name") - 53 |+x: NamedArg(str, "name") -54 54 | -55 55 | x: DefaultNamedArg("str", "name") -56 56 | - -UP037.py:55:20: UP037 [*] Remove quotes from type annotation - | -53 | x: NamedArg("str", "name") -54 | -55 | x: DefaultNamedArg("str", "name") - | ^^^^^ UP037 -56 | -57 | x: DefaultNamedArg("str", name="name") - | - = help: Remove quotes - -ℹ Fix -52 52 | -53 53 | x: NamedArg("str", "name") -54 54 | -55 |-x: DefaultNamedArg("str", "name") - 55 |+x: DefaultNamedArg(str, "name") -56 56 | -57 57 | x: DefaultNamedArg("str", name="name") -58 58 | - -UP037.py:57:20: UP037 [*] Remove quotes from type annotation - | -55 | x: DefaultNamedArg("str", "name") -56 | -57 | x: DefaultNamedArg("str", name="name") - | ^^^^^ UP037 -58 | -59 | x: VarArg("str") - | - = help: Remove quotes - -ℹ Fix -54 54 | -55 55 | x: DefaultNamedArg("str", "name") -56 56 | -57 |-x: DefaultNamedArg("str", name="name") - 57 |+x: DefaultNamedArg(str, name="name") -58 58 | -59 59 | x: VarArg("str") -60 60 | - -UP037.py:59:11: UP037 [*] Remove quotes from type annotation - | -57 | x: DefaultNamedArg("str", name="name") -58 | -59 | x: VarArg("str") - | ^^^^^ UP037 -60 | -61 | x: List[List[List["MyClass"]]] - | - = help: Remove quotes - -ℹ Fix -56 56 | -57 57 | x: DefaultNamedArg("str", name="name") -58 58 | -59 |-x: VarArg("str") - 59 |+x: VarArg(str) -60 60 | -61 61 | x: List[List[List["MyClass"]]] -62 62 | - -UP037.py:61:19: UP037 [*] Remove quotes from type annotation - | -59 | x: VarArg("str") -60 | -61 | x: List[List[List["MyClass"]]] - | ^^^^^^^^^ UP037 -62 | -63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) - | - = help: Remove quotes - -ℹ Fix -58 58 | -59 59 | x: VarArg("str") -60 60 | -61 |-x: List[List[List["MyClass"]]] - 61 |+x: List[List[List[MyClass]]] -62 62 | -63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) -64 64 | - -UP037.py:63:29: UP037 [*] Remove quotes from type annotation - | -61 | x: List[List[List["MyClass"]]] -62 | -63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) - | ^^^^^ UP037 -64 | -65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) - | - = help: Remove quotes - -ℹ Fix -60 60 | -61 61 | x: List[List[List["MyClass"]]] -62 62 | -63 |-x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) - 63 |+x: NamedTuple("X", [("foo", int), ("bar", "str")]) -64 64 | -65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) -66 66 | - -UP037.py:63:45: UP037 [*] Remove quotes from type annotation - | -61 | x: List[List[List["MyClass"]]] -62 | -63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) - | ^^^^^ UP037 -64 | -65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) - | - = help: Remove quotes - -ℹ Fix -60 60 | -61 61 | x: List[List[List["MyClass"]]] -62 62 | -63 |-x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) - 63 |+x: NamedTuple("X", [("foo", "int"), ("bar", str)]) -64 64 | -65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) -66 66 | - -UP037.py:65:29: UP037 [*] Remove quotes from type annotation - | -63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) -64 | -65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) - | ^^^^^ UP037 -66 | -67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) - | - = help: Remove quotes - -ℹ Fix -62 62 | -63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) -64 64 | -65 |-x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) - 65 |+x: NamedTuple("X", fields=[(foo, "int"), ("bar", "str")]) -66 66 | -67 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) -68 68 | - -UP037.py:65:36: UP037 [*] Remove quotes from type annotation - | -63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) -64 | -65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) - | ^^^^^ UP037 -66 | -67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) - | - = help: Remove quotes - -ℹ Fix -62 62 | -63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) -64 64 | -65 |-x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) - 65 |+x: NamedTuple("X", fields=[("foo", int), ("bar", "str")]) -66 66 | -67 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) -68 68 | - -UP037.py:65:45: UP037 [*] Remove quotes from type annotation - | -63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) -64 | -65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) - | ^^^^^ UP037 -66 | -67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) - | - = help: Remove quotes - -ℹ Fix -62 62 | -63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) -64 64 | -65 |-x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) - 65 |+x: NamedTuple("X", fields=[("foo", "int"), (bar, "str")]) -66 66 | -67 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) -68 68 | - -UP037.py:65:52: UP037 [*] Remove quotes from type annotation - | -63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) -64 | -65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) - | ^^^^^ UP037 -66 | -67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) - | - = help: Remove quotes - -ℹ Fix -62 62 | -63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) -64 64 | -65 |-x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) - 65 |+x: NamedTuple("X", fields=[("foo", "int"), ("bar", str)]) -66 66 | -67 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) -68 68 | - -UP037.py:67:24: UP037 [*] Remove quotes from type annotation - | -65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) -66 | -67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) - | ^^^ UP037 -68 | -69 | X: MyCallable("X") - | - = help: Remove quotes - -ℹ Fix -64 64 | -65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) -66 66 | -67 |-x: NamedTuple(typename="X", fields=[("foo", "int")]) - 67 |+x: NamedTuple(typename=X, fields=[("foo", "int")]) -68 68 | -69 69 | X: MyCallable("X") -70 70 | - -UP037.py:67:38: UP037 [*] Remove quotes from type annotation - | -65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) -66 | -67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) - | ^^^^^ UP037 -68 | -69 | X: MyCallable("X") - | - = help: Remove quotes - -ℹ Fix -64 64 | -65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) -66 66 | -67 |-x: NamedTuple(typename="X", fields=[("foo", "int")]) - 67 |+x: NamedTuple(typename="X", fields=[(foo, "int")]) -68 68 | -69 69 | X: MyCallable("X") -70 70 | - -UP037.py:67:45: UP037 [*] Remove quotes from type annotation - | -65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) -66 | -67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) - | ^^^^^ UP037 -68 | -69 | X: MyCallable("X") - | - = help: Remove quotes - -ℹ Fix -64 64 | -65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) -66 66 | -67 |-x: NamedTuple(typename="X", fields=[("foo", "int")]) - 67 |+x: NamedTuple(typename="X", fields=[("foo", int)]) -68 68 | -69 69 | X: MyCallable("X") -70 70 | - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP038.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP038.py.snap deleted file mode 100644 index 35cd76b877..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP038.py.snap +++ /dev/null @@ -1,37 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP038.py:1:1: UP038 [*] Use `X | Y` in `isinstance` call instead of `(X, Y)` - | -1 | isinstance(1, (int, float)) # UP038 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP038 -2 | issubclass("yes", (int, float, str)) # UP038 - | - = help: Convert to `X | Y` - -ℹ Suggested fix -1 |-isinstance(1, (int, float)) # UP038 - 1 |+isinstance(1, int | float) # UP038 -2 2 | issubclass("yes", (int, float, str)) # UP038 -3 3 | -4 4 | isinstance(1, int) # OK - -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 | -4 | isinstance(1, int) # OK - | - = help: Convert to `X | Y` - -ℹ Suggested fix -1 1 | isinstance(1, (int, float)) # UP038 -2 |-issubclass("yes", (int, float, str)) # UP038 - 2 |+issubclass("yes", int | float | str) # UP038 -3 3 | -4 4 | isinstance(1, int) # OK -5 5 | issubclass("yes", int) # OK - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP039.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP039.py.snap deleted file mode 100644 index 4d1a0bb04f..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP039.py.snap +++ /dev/null @@ -1,97 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP039.py:2:8: UP039 [*] Unnecessary parentheses after class definition - | -1 | # Errors -2 | class A(): - | ^^ UP039 -3 | pass - | - = help: Remove parentheses - -ℹ Fix -1 1 | # Errors -2 |-class A(): - 2 |+class A: -3 3 | pass -4 4 | -5 5 | - -UP039.py:6:8: UP039 [*] Unnecessary parentheses after class definition - | -6 | class A() \ - | ^^ UP039 -7 | : -8 | pass - | - = help: Remove parentheses - -ℹ Fix -3 3 | pass -4 4 | -5 5 | -6 |-class A() \ - 6 |+class A \ -7 7 | : -8 8 | pass -9 9 | - -UP039.py:12:9: UP039 [*] Unnecessary parentheses after class definition - | -11 | class A \ -12 | (): - | ^^ UP039 -13 | pass - | - = help: Remove parentheses - -ℹ Fix -9 9 | -10 10 | -11 11 | class A \ -12 |- (): - 12 |+ : -13 13 | pass -14 14 | -15 15 | - -UP039.py:17:8: UP039 [*] Unnecessary parentheses after class definition - | -16 | @decorator() -17 | class A(): - | ^^ UP039 -18 | pass - | - = help: Remove parentheses - -ℹ Fix -14 14 | -15 15 | -16 16 | @decorator() -17 |-class A(): - 17 |+class A: -18 18 | pass -19 19 | -20 20 | @decorator - -UP039.py:21:8: UP039 [*] Unnecessary parentheses after class definition - | -20 | @decorator -21 | class A(): - | ^^ UP039 -22 | pass - | - = help: Remove parentheses - -ℹ Fix -18 18 | pass -19 19 | -20 20 | @decorator -21 |-class A(): - 21 |+class A: -22 22 | pass -23 23 | -24 24 | # OK - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP040.py.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP040.py.snap deleted file mode 100644 index f5c3dc9625..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__UP040.py.snap +++ /dev/null @@ -1,233 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP040.py:5:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword - | -4 | # UP040 -5 | x: typing.TypeAlias = int - | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -6 | x: TypeAlias = int - | - = help: Use the `type` keyword - -ℹ Fix -2 2 | from typing import TypeAlias -3 3 | -4 4 | # UP040 -5 |-x: typing.TypeAlias = int - 5 |+type x = int -6 6 | x: TypeAlias = int -7 7 | -8 8 | # UP040 simple generic - -UP040.py:6:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword - | -4 | # UP040 -5 | x: typing.TypeAlias = int -6 | x: TypeAlias = int - | ^^^^^^^^^^^^^^^^^^ UP040 -7 | -8 | # UP040 simple generic - | - = help: Use the `type` keyword - -ℹ Fix -3 3 | -4 4 | # UP040 -5 5 | x: typing.TypeAlias = int -6 |-x: TypeAlias = int - 6 |+type x = int -7 7 | -8 8 | # UP040 simple generic -9 9 | T = typing.TypeVar["T"] - -UP040.py:10:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword - | - 8 | # UP040 simple generic - 9 | T = typing.TypeVar["T"] -10 | x: typing.TypeAlias = list[T] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -11 | -12 | # UP040 call style generic - | - = help: Use the `type` keyword - -ℹ Fix -7 7 | -8 8 | # UP040 simple generic -9 9 | T = typing.TypeVar["T"] -10 |-x: typing.TypeAlias = list[T] - 10 |+type x[T] = list[T] -11 11 | -12 12 | # UP040 call style generic -13 13 | T = typing.TypeVar("T") - -UP040.py:14:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword - | -12 | # UP040 call style generic -13 | T = typing.TypeVar("T") -14 | x: typing.TypeAlias = list[T] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -15 | -16 | # UP040 bounded generic - | - = help: Use the `type` keyword - -ℹ Fix -11 11 | -12 12 | # UP040 call style generic -13 13 | T = typing.TypeVar("T") -14 |-x: typing.TypeAlias = list[T] - 14 |+type x[T] = list[T] -15 15 | -16 16 | # UP040 bounded generic -17 17 | T = typing.TypeVar("T", bound=int) - -UP040.py:18:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword - | -16 | # UP040 bounded generic -17 | T = typing.TypeVar("T", bound=int) -18 | x: typing.TypeAlias = list[T] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -19 | -20 | # UP040 constrained generic - | - = help: Use the `type` keyword - -ℹ Fix -15 15 | -16 16 | # UP040 bounded generic -17 17 | T = typing.TypeVar("T", bound=int) -18 |-x: typing.TypeAlias = list[T] - 18 |+type x[T: int] = list[T] -19 19 | -20 20 | # UP040 constrained generic -21 21 | T = typing.TypeVar("T", int, str) - -UP040.py:22:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword - | -20 | # UP040 constrained generic -21 | T = typing.TypeVar("T", int, str) -22 | x: typing.TypeAlias = list[T] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -23 | -24 | # UP040 contravariant generic - | - = help: Use the `type` keyword - -ℹ Fix -19 19 | -20 20 | # UP040 constrained generic -21 21 | T = typing.TypeVar("T", int, str) -22 |-x: typing.TypeAlias = list[T] - 22 |+type x[T: (int, str)] = list[T] -23 23 | -24 24 | # UP040 contravariant generic -25 25 | T = typing.TypeVar("T", contravariant=True) - -UP040.py:26:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword - | -24 | # UP040 contravariant generic -25 | T = typing.TypeVar("T", contravariant=True) -26 | x: typing.TypeAlias = list[T] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -27 | -28 | # UP040 covariant generic - | - = help: Use the `type` keyword - -ℹ Fix -23 23 | -24 24 | # UP040 contravariant generic -25 25 | T = typing.TypeVar("T", contravariant=True) -26 |-x: typing.TypeAlias = list[T] - 26 |+type x[T] = list[T] -27 27 | -28 28 | # UP040 covariant generic -29 29 | T = typing.TypeVar("T", covariant=True) - -UP040.py:30:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword - | -28 | # UP040 covariant generic -29 | T = typing.TypeVar("T", covariant=True) -30 | x: typing.TypeAlias = list[T] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -31 | -32 | # UP040 in class scope - | - = help: Use the `type` keyword - -ℹ Fix -27 27 | -28 28 | # UP040 covariant generic -29 29 | T = typing.TypeVar("T", covariant=True) -30 |-x: typing.TypeAlias = list[T] - 30 |+type x[T] = list[T] -31 31 | -32 32 | # UP040 in class scope -33 33 | T = typing.TypeVar["T"] - -UP040.py:36:5: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword - | -34 | class Foo: -35 | # reference to global variable -36 | x: typing.TypeAlias = list[T] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -37 | -38 | # reference to class variable - | - = help: Use the `type` keyword - -ℹ Fix -33 33 | T = typing.TypeVar["T"] -34 34 | class Foo: -35 35 | # reference to global variable -36 |- x: typing.TypeAlias = list[T] - 36 |+ type x[T] = list[T] -37 37 | -38 38 | # reference to class variable -39 39 | TCLS = typing.TypeVar["TCLS"] - -UP040.py:40:5: UP040 [*] Type alias `y` uses `TypeAlias` annotation instead of the `type` keyword - | -38 | # reference to class variable -39 | TCLS = typing.TypeVar["TCLS"] -40 | y: typing.TypeAlias = list[TCLS] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -41 | -42 | # UP040 wont add generics in fix - | - = help: Use the `type` keyword - -ℹ Fix -37 37 | -38 38 | # reference to class variable -39 39 | TCLS = typing.TypeVar["TCLS"] -40 |- y: typing.TypeAlias = list[TCLS] - 40 |+ type y[TCLS] = list[TCLS] -41 41 | -42 42 | # UP040 wont add generics in fix -43 43 | T = typing.TypeVar(*args) - -UP040.py:44:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword - | -42 | # UP040 wont add generics in fix -43 | T = typing.TypeVar(*args) -44 | x: typing.TypeAlias = list[T] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 -45 | -46 | # OK - | - = help: Use the `type` keyword - -ℹ Fix -41 41 | -42 42 | # UP040 wont add generics in fix -43 43 | T = typing.TypeVar(*args) -44 |-x: typing.TypeAlias = list[T] - 44 |+type x = list[T] -45 45 | -46 46 | # OK -47 47 | x: TypeAlias - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__datetime_utc_alias_py311.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__datetime_utc_alias_py311.snap deleted file mode 100644 index 7c1bbecb22..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__datetime_utc_alias_py311.snap +++ /dev/null @@ -1,77 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -UP017.py:7:7: UP017 [*] Use `datetime.UTC` alias - | -6 | print(datetime.timezone(-1)) -7 | print(timezone.utc) - | ^^^^^^^^^^^^ UP017 -8 | print(tz.utc) - | - = help: Convert to `datetime.UTC` alias - -ℹ Suggested fix -4 4 | from datetime import timezone as tz -5 5 | -6 6 | print(datetime.timezone(-1)) -7 |-print(timezone.utc) - 7 |+print(datetime.UTC) -8 8 | print(tz.utc) -9 9 | -10 10 | print(datetime.timezone.utc) - -UP017.py:8:7: UP017 [*] Use `datetime.UTC` alias - | - 6 | print(datetime.timezone(-1)) - 7 | print(timezone.utc) - 8 | print(tz.utc) - | ^^^^^^ UP017 - 9 | -10 | print(datetime.timezone.utc) - | - = help: Convert to `datetime.UTC` alias - -ℹ Suggested fix -5 5 | -6 6 | print(datetime.timezone(-1)) -7 7 | print(timezone.utc) -8 |-print(tz.utc) - 8 |+print(datetime.UTC) -9 9 | -10 10 | print(datetime.timezone.utc) -11 11 | print(dt.timezone.utc) - -UP017.py:10:7: UP017 [*] Use `datetime.UTC` alias - | - 8 | print(tz.utc) - 9 | -10 | print(datetime.timezone.utc) - | ^^^^^^^^^^^^^^^^^^^^^ UP017 -11 | print(dt.timezone.utc) - | - = help: Convert to `datetime.UTC` alias - -ℹ Suggested fix -7 7 | print(timezone.utc) -8 8 | print(tz.utc) -9 9 | -10 |-print(datetime.timezone.utc) - 10 |+print(datetime.UTC) -11 11 | print(dt.timezone.utc) - -UP017.py:11:7: UP017 [*] Use `datetime.UTC` alias - | -10 | print(datetime.timezone.utc) -11 | print(dt.timezone.utc) - | ^^^^^^^^^^^^^^^ UP017 - | - = help: Convert to `datetime.UTC` alias - -ℹ Suggested fix -8 8 | print(tz.utc) -9 9 | -10 10 | print(datetime.timezone.utc) -11 |-print(dt.timezone.utc) - 11 |+print(datetime.UTC) - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p310.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p310.snap deleted file mode 100644 index c9972fb6d9..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p310.snap +++ /dev/null @@ -1,75 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -future_annotations.py:34:18: UP006 [*] Use `list` instead of `List` for type annotation - | -34 | def f(x: int) -> List[int]: - | ^^^^ UP006 -35 | y = List[int]() -36 | y.append(x) - | - = help: Replace with `list` - -ℹ Fix -31 31 | return cls(x=0, y=0) -32 32 | -33 33 | -34 |-def f(x: int) -> List[int]: - 34 |+def f(x: int) -> list[int]: -35 35 | y = List[int]() -36 36 | y.append(x) -37 37 | return y - -future_annotations.py:35:9: UP006 [*] Use `list` instead of `List` for type annotation - | -34 | def f(x: int) -> List[int]: -35 | y = List[int]() - | ^^^^ UP006 -36 | y.append(x) -37 | return y - | - = help: Replace with `list` - -ℹ Fix -32 32 | -33 33 | -34 34 | def f(x: int) -> List[int]: -35 |- y = List[int]() - 35 |+ y = list[int]() -36 36 | y.append(x) -37 37 | return y -38 38 | - -future_annotations.py:42:27: UP006 [*] Use `list` instead of `List` for type annotation - | -40 | x: Optional[int] = None -41 | -42 | MyList: TypeAlias = Union[List[int], List[str]] - | ^^^^ UP006 - | - = help: Replace with `list` - -ℹ Fix -39 39 | -40 40 | x: Optional[int] = None -41 41 | -42 |-MyList: TypeAlias = Union[List[int], List[str]] - 42 |+MyList: TypeAlias = Union[list[int], List[str]] - -future_annotations.py:42:38: UP006 [*] Use `list` instead of `List` for type annotation - | -40 | x: Optional[int] = None -41 | -42 | MyList: TypeAlias = Union[List[int], List[str]] - | ^^^^ UP006 - | - = help: Replace with `list` - -ℹ Fix -39 39 | -40 40 | x: Optional[int] = None -41 41 | -42 |-MyList: TypeAlias = Union[List[int], List[str]] - 42 |+MyList: TypeAlias = Union[List[int], list[str]] - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p37.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p37.snap deleted file mode 100644 index 870ad3bf5d..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p37.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_585_p37.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_585_p37.snap deleted file mode 100644 index d60757c3e0..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_585_p37.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -future_annotations.py:34:18: UP006 [*] Use `list` instead of `List` for type annotation - | -34 | def f(x: int) -> List[int]: - | ^^^^ UP006 -35 | y = List[int]() -36 | y.append(x) - | - = help: Replace with `list` - -ℹ Fix -31 31 | return cls(x=0, y=0) -32 32 | -33 33 | -34 |-def f(x: int) -> List[int]: - 34 |+def f(x: int) -> list[int]: -35 35 | y = List[int]() -36 36 | y.append(x) -37 37 | return y - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap deleted file mode 100644 index c9972fb6d9..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap +++ /dev/null @@ -1,75 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -future_annotations.py:34:18: UP006 [*] Use `list` instead of `List` for type annotation - | -34 | def f(x: int) -> List[int]: - | ^^^^ UP006 -35 | y = List[int]() -36 | y.append(x) - | - = help: Replace with `list` - -ℹ Fix -31 31 | return cls(x=0, y=0) -32 32 | -33 33 | -34 |-def f(x: int) -> List[int]: - 34 |+def f(x: int) -> list[int]: -35 35 | y = List[int]() -36 36 | y.append(x) -37 37 | return y - -future_annotations.py:35:9: UP006 [*] Use `list` instead of `List` for type annotation - | -34 | def f(x: int) -> List[int]: -35 | y = List[int]() - | ^^^^ UP006 -36 | y.append(x) -37 | return y - | - = help: Replace with `list` - -ℹ Fix -32 32 | -33 33 | -34 34 | def f(x: int) -> List[int]: -35 |- y = List[int]() - 35 |+ y = list[int]() -36 36 | y.append(x) -37 37 | return y -38 38 | - -future_annotations.py:42:27: UP006 [*] Use `list` instead of `List` for type annotation - | -40 | x: Optional[int] = None -41 | -42 | MyList: TypeAlias = Union[List[int], List[str]] - | ^^^^ UP006 - | - = help: Replace with `list` - -ℹ Fix -39 39 | -40 40 | x: Optional[int] = None -41 41 | -42 |-MyList: TypeAlias = Union[List[int], List[str]] - 42 |+MyList: TypeAlias = Union[list[int], List[str]] - -future_annotations.py:42:38: UP006 [*] Use `list` instead of `List` for type annotation - | -40 | x: Optional[int] = None -41 | -42 | MyList: TypeAlias = Union[List[int], List[str]] - | ^^^^ UP006 - | - = help: Replace with `list` - -ℹ Fix -39 39 | -40 40 | x: Optional[int] = None -41 41 | -42 |-MyList: TypeAlias = Union[List[int], List[str]] - 42 |+MyList: TypeAlias = Union[List[int], list[str]] - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap deleted file mode 100644 index a5a07f6b84..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -future_annotations.py:40:4: UP007 [*] Use `X | Y` for type annotations - | -40 | x: Optional[int] = None - | ^^^^^^^^^^^^^ UP007 -41 | -42 | MyList: TypeAlias = Union[List[int], List[str]] - | - = help: Convert to `X | Y` - -ℹ Suggested fix -37 37 | return y -38 38 | -39 39 | -40 |-x: Optional[int] = None - 40 |+x: int | None = None -41 41 | -42 42 | MyList: TypeAlias = Union[List[int], List[str]] - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap deleted file mode 100644 index db003ea51f..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap +++ /dev/null @@ -1,38 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- -future_annotations.py:40:4: UP007 [*] Use `X | Y` for type annotations - | -40 | x: Optional[int] = None - | ^^^^^^^^^^^^^ UP007 -41 | -42 | MyList: TypeAlias = Union[List[int], List[str]] - | - = help: Convert to `X | Y` - -ℹ Suggested fix -37 37 | return y -38 38 | -39 39 | -40 |-x: Optional[int] = None - 40 |+x: int | None = None -41 41 | -42 42 | MyList: TypeAlias = Union[List[int], List[str]] - -future_annotations.py:42:21: UP007 [*] Use `X | Y` for type annotations - | -40 | x: Optional[int] = None -41 | -42 | MyList: TypeAlias = Union[List[int], List[str]] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP007 - | - = help: Convert to `X | Y` - -ℹ Suggested fix -39 39 | -40 40 | x: Optional[int] = None -41 41 | -42 |-MyList: TypeAlias = Union[List[int], List[str]] - 42 |+MyList: TypeAlias = List[int] | List[str] - - diff --git a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__non_pep695_type_alias_not_applied_py311.snap b/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__non_pep695_type_alias_not_applied_py311.snap deleted file mode 100644 index 870ad3bf5d..0000000000 --- a/crates/ruff/src/rules/pyupgrade/snapshots/ruff__rules__pyupgrade__tests__non_pep695_type_alias_not_applied_py311.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/pyupgrade/mod.rs ---- - diff --git a/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB113_FURB113.py.snap b/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB113_FURB113.py.snap deleted file mode 100644 index 51024c918f..0000000000 --- a/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB113_FURB113.py.snap +++ /dev/null @@ -1,335 +0,0 @@ ---- -source: crates/ruff/src/rules/refurb/mod.rs ---- -FURB113.py:23:1: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly calling `nums.append()` - | -22 | # FURB113 -23 | / nums.append(1) -24 | | nums.append(2) - | |______________^ FURB113 -25 | pass - | - = help: Replace with `nums.extend((1, 2))` - -ℹ Suggested fix -20 20 | -21 21 | -22 22 | # FURB113 -23 |-nums.append(1) -24 |-nums.append(2) - 23 |+nums.extend((1, 2)) -25 24 | pass -26 25 | -27 26 | - -FURB113.py:29:1: FURB113 [*] Use `nums3.extend((1, 2))` instead of repeatedly calling `nums3.append()` - | -28 | # FURB113 -29 | / nums3.append(1) -30 | | nums3.append(2) - | |_______________^ FURB113 -31 | pass - | - = help: Replace with `nums3.extend((1, 2))` - -ℹ Suggested fix -26 26 | -27 27 | -28 28 | # FURB113 -29 |-nums3.append(1) -30 |-nums3.append(2) - 29 |+nums3.extend((1, 2)) -31 30 | pass -32 31 | -33 32 | - -FURB113.py:35:1: FURB113 [*] Use `nums4.extend((1, 2))` instead of repeatedly calling `nums4.append()` - | -34 | # FURB113 -35 | / nums4.append(1) -36 | | nums4.append(2) - | |_______________^ FURB113 -37 | pass - | - = help: Replace with `nums4.extend((1, 2))` - -ℹ Suggested fix -32 32 | -33 33 | -34 34 | # FURB113 -35 |-nums4.append(1) -36 |-nums4.append(2) - 35 |+nums4.extend((1, 2)) -37 36 | pass -38 37 | -39 38 | - -FURB113.py:41:1: FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` - | -40 | # FURB113 -41 | / nums.append(1) -42 | | nums2.append(1) -43 | | nums.append(2) -44 | | nums.append(3) - | |______________^ FURB113 -45 | pass - | - = help: Replace with `nums.extend((1, 2, 3))` - -FURB113.py:49:1: FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` - | -48 | # FURB113 -49 | / nums.append(1) -50 | | nums2.append(1) -51 | | nums.append(2) -52 | | # FURB113 -53 | | nums3.append(1) -54 | | nums.append(3) - | |______________^ FURB113 -55 | # FURB113 -56 | nums4.append(1) - | - = help: Replace with `nums.extend((1, 2, 3))` - -FURB113.py:53:1: FURB113 Use `nums3.extend((1, 2))` instead of repeatedly calling `nums3.append()` - | -51 | nums.append(2) -52 | # FURB113 -53 | / nums3.append(1) -54 | | nums.append(3) -55 | | # FURB113 -56 | | nums4.append(1) -57 | | nums4.append(2) -58 | | nums3.append(2) - | |_______________^ FURB113 -59 | pass - | - = help: Replace with `nums3.extend((1, 2))` - -FURB113.py:56:1: FURB113 [*] Use `nums4.extend((1, 2))` instead of repeatedly calling `nums4.append()` - | -54 | nums.append(3) -55 | # FURB113 -56 | / nums4.append(1) -57 | | nums4.append(2) - | |_______________^ FURB113 -58 | nums3.append(2) -59 | pass - | - = help: Replace with `nums4.extend((1, 2))` - -ℹ Suggested fix -53 53 | nums3.append(1) -54 54 | nums.append(3) -55 55 | # FURB113 -56 |-nums4.append(1) -57 |-nums4.append(2) - 56 |+nums4.extend((1, 2)) -58 57 | nums3.append(2) -59 58 | pass -60 59 | - -FURB113.py:62:1: FURB113 [*] Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` - | -61 | # FURB113 -62 | / nums.append(1) -63 | | nums.append(2) -64 | | nums.append(3) - | |______________^ FURB113 - | - = help: Replace with `nums.extend((1, 2, 3))` - -ℹ Suggested fix -59 59 | pass -60 60 | -61 61 | # FURB113 -62 |-nums.append(1) -63 |-nums.append(2) -64 |-nums.append(3) - 62 |+nums.extend((1, 2, 3)) -65 63 | -66 64 | -67 65 | if True: - -FURB113.py:69:5: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly calling `nums.append()` - | -67 | if True: -68 | # FURB113 -69 | nums.append(1) - | _____^ -70 | | nums.append(2) - | |__________________^ FURB113 - | - = help: Replace with `nums.extend((1, 2))` - -ℹ Suggested fix -66 66 | -67 67 | if True: -68 68 | # FURB113 -69 |- nums.append(1) -70 |- nums.append(2) - 69 |+ nums.extend((1, 2)) -71 70 | -72 71 | -73 72 | if True: - -FURB113.py:75:5: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly calling `nums.append()` - | -73 | if True: -74 | # FURB113 -75 | nums.append(1) - | _____^ -76 | | nums.append(2) - | |__________________^ FURB113 -77 | pass - | - = help: Replace with `nums.extend((1, 2))` - -ℹ Suggested fix -72 72 | -73 73 | if True: -74 74 | # FURB113 -75 |- nums.append(1) -76 |- nums.append(2) - 75 |+ nums.extend((1, 2)) -77 76 | pass -78 77 | -79 78 | - -FURB113.py:82:5: FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` - | -80 | if True: -81 | # FURB113 -82 | nums.append(1) - | _____^ -83 | | nums2.append(1) -84 | | nums.append(2) -85 | | nums.append(3) - | |__________________^ FURB113 - | - = help: Replace with `nums.extend((1, 2, 3))` - -FURB113.py:90:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` - | -88 | def yes_one(x: list[int]): -89 | # FURB113 -90 | x.append(1) - | _____^ -91 | | x.append(2) - | |_______________^ FURB113 - | - = help: Replace with `x.extend((1, 2))` - -ℹ Suggested fix -87 87 | -88 88 | def yes_one(x: list[int]): -89 89 | # FURB113 -90 |- x.append(1) -91 |- x.append(2) - 90 |+ x.extend((1, 2)) -92 91 | -93 92 | -94 93 | def yes_two(x: List[int]): - -FURB113.py:96:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` - | -94 | def yes_two(x: List[int]): -95 | # FURB113 -96 | x.append(1) - | _____^ -97 | | x.append(2) - | |_______________^ FURB113 - | - = help: Replace with `x.extend((1, 2))` - -ℹ Suggested fix -93 93 | -94 94 | def yes_two(x: List[int]): -95 95 | # FURB113 -96 |- x.append(1) -97 |- x.append(2) - 96 |+ x.extend((1, 2)) -98 97 | -99 98 | -100 99 | def yes_three(*, x: list[int]): - -FURB113.py:102:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` - | -100 | def yes_three(*, x: list[int]): -101 | # FURB113 -102 | x.append(1) - | _____^ -103 | | x.append(2) - | |_______________^ FURB113 - | - = help: Replace with `x.extend((1, 2))` - -ℹ Suggested fix -99 99 | -100 100 | def yes_three(*, x: list[int]): -101 101 | # FURB113 -102 |- x.append(1) -103 |- x.append(2) - 102 |+ x.extend((1, 2)) -104 103 | -105 104 | -106 105 | def yes_four(x: list[int], /): - -FURB113.py:108:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` - | -106 | def yes_four(x: list[int], /): -107 | # FURB113 -108 | x.append(1) - | _____^ -109 | | x.append(2) - | |_______________^ FURB113 - | - = help: Replace with `x.extend((1, 2))` - -ℹ Suggested fix -105 105 | -106 106 | def yes_four(x: list[int], /): -107 107 | # FURB113 -108 |- x.append(1) -109 |- x.append(2) - 108 |+ x.extend((1, 2)) -110 109 | -111 110 | -112 111 | def yes_five(x: list[int], y: list[int]): - -FURB113.py:114:5: FURB113 Use `x.extend((1, 2, 3))` instead of repeatedly calling `x.append()` - | -112 | def yes_five(x: list[int], y: list[int]): -113 | # FURB113 -114 | x.append(1) - | _____^ -115 | | x.append(2) -116 | | y.append(1) -117 | | x.append(3) - | |_______________^ FURB113 - | - = help: Replace with `x.extend((1, 2, 3))` - -FURB113.py:122:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` - | -120 | def yes_six(x: list): -121 | # FURB113 -122 | x.append(1) - | _____^ -123 | | x.append(2) - | |_______________^ FURB113 - | - = help: Replace with `x.extend((1, 2))` - -ℹ Suggested fix -119 119 | -120 120 | def yes_six(x: list): -121 121 | # FURB113 -122 |- x.append(1) -123 |- x.append(2) - 122 |+ x.extend((1, 2)) -124 123 | -125 124 | -126 125 | # Non-errors. - - diff --git a/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB131_FURB131.py.snap b/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB131_FURB131.py.snap deleted file mode 100644 index 40bed3199f..0000000000 --- a/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB131_FURB131.py.snap +++ /dev/null @@ -1,132 +0,0 @@ ---- -source: crates/ruff/src/rules/refurb/mod.rs ---- -FURB131.py:11:1: FURB131 [*] Prefer `clear` over deleting a full slice - | -10 | # FURB131 -11 | del nums[:] - | ^^^^^^^^^^^ FURB131 - | - = help: Replace with `clear()` - -ℹ Suggested fix -8 8 | # these should match -9 9 | -10 10 | # FURB131 -11 |-del nums[:] - 11 |+nums.clear() -12 12 | -13 13 | -14 14 | # FURB131 - -FURB131.py:15:1: FURB131 [*] Prefer `clear` over deleting a full slice - | -14 | # FURB131 -15 | del names[:] - | ^^^^^^^^^^^^ FURB131 - | - = help: Replace with `clear()` - -ℹ Suggested fix -12 12 | -13 13 | -14 14 | # FURB131 -15 |-del names[:] - 15 |+names.clear() -16 16 | -17 17 | -18 18 | # FURB131 - -FURB131.py:19:1: FURB131 Prefer `clear` over deleting a full slice - | -18 | # FURB131 -19 | del x, nums[:] - | ^^^^^^^^^^^^^^ FURB131 - | - = help: Replace with `clear()` - -FURB131.py:23:1: FURB131 Prefer `clear` over deleting a full slice - | -22 | # FURB131 -23 | del y, names[:], x - | ^^^^^^^^^^^^^^^^^^ FURB131 - | - = help: Replace with `clear()` - -FURB131.py:28:5: FURB131 [*] Prefer `clear` over deleting a full slice - | -26 | def yes_one(x: list[int]): -27 | # FURB131 -28 | del x[:] - | ^^^^^^^^ FURB131 - | - = help: Replace with `clear()` - -ℹ Suggested fix -25 25 | -26 26 | def yes_one(x: list[int]): -27 27 | # FURB131 -28 |- del x[:] - 28 |+ x.clear() -29 29 | -30 30 | -31 31 | def yes_two(x: dict[int, str]): - -FURB131.py:33:5: FURB131 [*] Prefer `clear` over deleting a full slice - | -31 | def yes_two(x: dict[int, str]): -32 | # FURB131 -33 | del x[:] - | ^^^^^^^^ FURB131 - | - = help: Replace with `clear()` - -ℹ Suggested fix -30 30 | -31 31 | def yes_two(x: dict[int, str]): -32 32 | # FURB131 -33 |- del x[:] - 33 |+ x.clear() -34 34 | -35 35 | -36 36 | def yes_three(x: List[int]): - -FURB131.py:38:5: FURB131 [*] Prefer `clear` over deleting a full slice - | -36 | def yes_three(x: List[int]): -37 | # FURB131 -38 | del x[:] - | ^^^^^^^^ FURB131 - | - = help: Replace with `clear()` - -ℹ Suggested fix -35 35 | -36 36 | def yes_three(x: List[int]): -37 37 | # FURB131 -38 |- del x[:] - 38 |+ x.clear() -39 39 | -40 40 | -41 41 | def yes_four(x: Dict[int, str]): - -FURB131.py:43:5: FURB131 [*] Prefer `clear` over deleting a full slice - | -41 | def yes_four(x: Dict[int, str]): -42 | # FURB131 -43 | del x[:] - | ^^^^^^^^ FURB131 - | - = help: Replace with `clear()` - -ℹ Suggested fix -40 40 | -41 41 | def yes_four(x: Dict[int, str]): -42 42 | # FURB131 -43 |- del x[:] - 43 |+ x.clear() -44 44 | -45 45 | -46 46 | # these should not - - diff --git a/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB132_FURB132.py.snap b/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB132_FURB132.py.snap deleted file mode 100644 index 448c6ccecd..0000000000 --- a/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB132_FURB132.py.snap +++ /dev/null @@ -1,84 +0,0 @@ ---- -source: crates/ruff/src/rules/refurb/mod.rs ---- -FURB132.py:12:1: FURB132 [*] Use `s.discard("x")` instead of check and `remove` - | -11 | # FURB132 -12 | / if "x" in s: -13 | | s.remove("x") - | |_________________^ FURB132 - | - = help: Replace with `s.discard("x")` - -ℹ Suggested fix -9 9 | # these should match -10 10 | -11 11 | # FURB132 -12 |-if "x" in s: -13 |- s.remove("x") - 12 |+s.discard("x") -14 13 | -15 14 | -16 15 | # FURB132 - -FURB132.py:22:1: FURB132 [*] Use `s3.discard("x")` instead of check and `remove` - | -21 | # FURB132 -22 | / if "x" in s3: -23 | | s3.remove("x") - | |__________________^ FURB132 - | - = help: Replace with `s3.discard("x")` - -ℹ Suggested fix -19 19 | -20 20 | -21 21 | # FURB132 -22 |-if "x" in s3: -23 |- s3.remove("x") - 22 |+s3.discard("x") -24 23 | -25 24 | -26 25 | var = "y" - -FURB132.py:28:1: FURB132 [*] Use `s.discard(var)` instead of check and `remove` - | -26 | var = "y" -27 | # FURB132 -28 | / if var in s: -29 | | s.remove(var) - | |_________________^ FURB132 - | - = help: Replace with `s.discard(var)` - -ℹ Suggested fix -25 25 | -26 26 | var = "y" -27 27 | # FURB132 -28 |-if var in s: -29 |- s.remove(var) - 28 |+s.discard(var) -30 29 | -31 30 | -32 31 | if f"{var}:{var}" in s: - -FURB132.py:32:1: FURB132 [*] Use `s.discard(f"{var}:{var}")` instead of check and `remove` - | -32 | / if f"{var}:{var}" in s: -33 | | s.remove(f"{var}:{var}") - | |____________________________^ FURB132 - | - = help: Replace with `s.discard(f"{var}:{var}")` - -ℹ Suggested fix -29 29 | s.remove(var) -30 30 | -31 31 | -32 |-if f"{var}:{var}" in s: -33 |- s.remove(f"{var}:{var}") - 32 |+s.discard(f"{var}:{var}") -34 33 | -35 34 | -36 35 | def identity(x): - - diff --git a/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB140_FURB140.py.snap b/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB140_FURB140.py.snap deleted file mode 100644 index 8e08c4c5c9..0000000000 --- a/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB140_FURB140.py.snap +++ /dev/null @@ -1,136 +0,0 @@ ---- -source: crates/ruff/src/rules/refurb/mod.rs ---- -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 | -9 | # FURB140 - | - = help: Replace with `itertools.starmap` - -ℹ Suggested fix - 1 |+from itertools import starmap -1 2 | def zipped(): -2 3 | return zip([1, 2, 3], "ABC") -3 4 | -4 5 | # Errors. -5 6 | -6 7 | # FURB140 -7 |-[print(x, y) for x, y in zipped()] - 8 |+list(starmap(print, zipped())) -8 9 | -9 10 | # FURB140 -10 11 | (print(x, y) for x, y in zipped()) - -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 | -12 | # FURB140 - | - = help: Replace with `itertools.starmap` - -ℹ Suggested fix - 1 |+from itertools import starmap -1 2 | def zipped(): -2 3 | return zip([1, 2, 3], "ABC") -3 4 | --------------------------------------------------------------------------------- -7 8 | [print(x, y) for x, y in zipped()] -8 9 | -9 10 | # FURB140 -10 |-(print(x, y) for x, y in zipped()) - 11 |+starmap(print, zipped()) -11 12 | -12 13 | # FURB140 -13 14 | {print(x, y) for x, y in zipped()} - -FURB140.py:13:1: FURB140 [*] Use `itertools.starmap` instead of the generator - | -12 | # FURB140 -13 | {print(x, y) for x, y in zipped()} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB140 - | - = help: Replace with `itertools.starmap` - -ℹ Suggested fix - 1 |+from itertools import starmap -1 2 | def zipped(): -2 3 | return zip([1, 2, 3], "ABC") -3 4 | --------------------------------------------------------------------------------- -10 11 | (print(x, y) for x, y in zipped()) -11 12 | -12 13 | # FURB140 -13 |-{print(x, y) for x, y in zipped()} - 14 |+set(starmap(print, zipped())) -14 15 | -15 16 | -16 17 | from itertools import starmap as sm - -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 | -21 | # FURB140 - | - = help: Replace with `itertools.starmap` - -ℹ Suggested fix -16 16 | from itertools import starmap as sm -17 17 | -18 18 | # FURB140 -19 |-[print(x, y) for x, y in zipped()] - 19 |+list(sm(print, zipped())) -20 20 | -21 21 | # FURB140 -22 22 | (print(x, y) for x, y in zipped()) - -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 | -24 | # FURB140 - | - = help: Replace with `itertools.starmap` - -ℹ Suggested fix -19 19 | [print(x, y) for x, y in zipped()] -20 20 | -21 21 | # FURB140 -22 |-(print(x, y) for x, y in zipped()) - 22 |+sm(print, zipped()) -23 23 | -24 24 | # FURB140 -25 25 | {print(x, y) for x, y in zipped()} - -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 | -27 | # Non-errors. - | - = help: Replace with `itertools.starmap` - -ℹ Suggested fix -22 22 | (print(x, y) for x, y in zipped()) -23 23 | -24 24 | # FURB140 -25 |-{print(x, y) for x, y in zipped()} - 25 |+set(sm(print, zipped())) -26 26 | -27 27 | # Non-errors. -28 28 | - - diff --git a/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB145_FURB145.py.snap b/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB145_FURB145.py.snap deleted file mode 100644 index 6686c0f3af..0000000000 --- a/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB145_FURB145.py.snap +++ /dev/null @@ -1,128 +0,0 @@ ---- -source: crates/ruff/src/rules/refurb/mod.rs ---- -FURB145.py:4:5: FURB145 [*] Prefer `copy` method over slicing - | -3 | # Errors. -4 | a = l[:] - | ^^^^ FURB145 -5 | b, c = 1, l[:] -6 | d, e = l[:], 1 - | - = help: Replace with `copy()` - -ℹ Suggested fix -1 1 | l = [1, 2, 3, 4, 5] -2 2 | -3 3 | # Errors. -4 |-a = l[:] - 4 |+a = l.copy() -5 5 | b, c = 1, l[:] -6 6 | d, e = l[:], 1 -7 7 | m = l[::] - -FURB145.py:5:11: FURB145 [*] Prefer `copy` method over slicing - | -3 | # Errors. -4 | a = l[:] -5 | b, c = 1, l[:] - | ^^^^ FURB145 -6 | d, e = l[:], 1 -7 | m = l[::] - | - = help: Replace with `copy()` - -ℹ Suggested fix -2 2 | -3 3 | # Errors. -4 4 | a = l[:] -5 |-b, c = 1, l[:] - 5 |+b, c = 1, l.copy() -6 6 | d, e = l[:], 1 -7 7 | m = l[::] -8 8 | l[:] - -FURB145.py:6:8: FURB145 [*] Prefer `copy` method over slicing - | -4 | a = l[:] -5 | b, c = 1, l[:] -6 | d, e = l[:], 1 - | ^^^^ FURB145 -7 | m = l[::] -8 | l[:] - | - = help: Replace with `copy()` - -ℹ Suggested fix -3 3 | # Errors. -4 4 | a = l[:] -5 5 | b, c = 1, l[:] -6 |-d, e = l[:], 1 - 6 |+d, e = l.copy(), 1 -7 7 | m = l[::] -8 8 | l[:] -9 9 | print(l[:]) - -FURB145.py:7:5: FURB145 [*] Prefer `copy` method over slicing - | -5 | b, c = 1, l[:] -6 | d, e = l[:], 1 -7 | m = l[::] - | ^^^^^ FURB145 -8 | l[:] -9 | print(l[:]) - | - = help: Replace with `copy()` - -ℹ Suggested fix -4 4 | a = l[:] -5 5 | b, c = 1, l[:] -6 6 | d, e = l[:], 1 -7 |-m = l[::] - 7 |+m = l.copy() -8 8 | l[:] -9 9 | print(l[:]) -10 10 | - -FURB145.py:8:1: FURB145 [*] Prefer `copy` method over slicing - | -6 | d, e = l[:], 1 -7 | m = l[::] -8 | l[:] - | ^^^^ FURB145 -9 | print(l[:]) - | - = help: Replace with `copy()` - -ℹ Suggested fix -5 5 | b, c = 1, l[:] -6 6 | d, e = l[:], 1 -7 7 | m = l[::] -8 |-l[:] - 8 |+l.copy() -9 9 | print(l[:]) -10 10 | -11 11 | # False negatives. - -FURB145.py:9:7: FURB145 [*] Prefer `copy` method over slicing - | - 7 | m = l[::] - 8 | l[:] - 9 | print(l[:]) - | ^^^^ FURB145 -10 | -11 | # False negatives. - | - = help: Replace with `copy()` - -ℹ Suggested fix -6 6 | d, e = l[:], 1 -7 7 | m = l[::] -8 8 | l[:] -9 |-print(l[:]) - 9 |+print(l.copy()) -10 10 | -11 11 | # False negatives. -12 12 | aa = a[:] # Type inference. - - diff --git a/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB148_FURB148.py.snap b/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB148_FURB148.py.snap deleted file mode 100644 index 1c4f0e78f1..0000000000 --- a/crates/ruff/src/rules/refurb/snapshots/ruff__rules__refurb__tests__FURB148_FURB148.py.snap +++ /dev/null @@ -1,323 +0,0 @@ ---- -source: crates/ruff/src/rules/refurb/mod.rs ---- -FURB148.py:4:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead - | -3 | # Errors -4 | for index, _ in enumerate(books): - | ^^^^^^^^^ FURB148 -5 | print(index) - | - = help: Replace with `range(len(...))` - -ℹ Suggested fix -1 1 | books = ["Dune", "Foundation", "Neuromancer"] -2 2 | -3 3 | # Errors -4 |-for index, _ in enumerate(books): - 4 |+for index in range(len(books)): -5 5 | print(index) -6 6 | -7 7 | for index, _ in enumerate(books, start=0): - -FURB148.py:7:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead - | -5 | print(index) -6 | -7 | for index, _ in enumerate(books, start=0): - | ^^^^^^^^^ FURB148 -8 | print(index) - | - = help: Replace with `range(len(...))` - -ℹ Suggested fix -4 4 | for index, _ in enumerate(books): -5 5 | print(index) -6 6 | -7 |-for index, _ in enumerate(books, start=0): - 7 |+for index in range(len(books)): -8 8 | print(index) -9 9 | -10 10 | for index, _ in enumerate(books, 0): - -FURB148.py:10:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead - | - 8 | print(index) - 9 | -10 | for index, _ in enumerate(books, 0): - | ^^^^^^^^^ FURB148 -11 | print(index) - | - = help: Replace with `range(len(...))` - -ℹ Suggested fix -7 7 | for index, _ in enumerate(books, start=0): -8 8 | print(index) -9 9 | -10 |-for index, _ in enumerate(books, 0): - 10 |+for index in range(len(books)): -11 11 | print(index) -12 12 | -13 13 | for index, _ in enumerate(books, start=1): - -FURB148.py:13:17: FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead - | -11 | print(index) -12 | -13 | for index, _ in enumerate(books, start=1): - | ^^^^^^^^^ FURB148 -14 | print(index) - | - = help: Replace with `range(len(...))` - -FURB148.py:16:17: FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead - | -14 | print(index) -15 | -16 | for index, _ in enumerate(books, 1): - | ^^^^^^^^^ FURB148 -17 | print(index) - | - = help: Replace with `range(len(...))` - -FURB148.py:19:17: FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead - | -17 | print(index) -18 | -19 | for index, _ in enumerate(books, start=x): - | ^^^^^^^^^ FURB148 -20 | print(book) - | - = help: Replace with `range(len(...))` - -FURB148.py:22:17: FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead - | -20 | print(book) -21 | -22 | for index, _ in enumerate(books, x): - | ^^^^^^^^^ FURB148 -23 | print(book) - | - = help: Replace with `range(len(...))` - -FURB148.py:25:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead - | -23 | print(book) -24 | -25 | for _, book in enumerate(books): - | ^^^^^^^^^ FURB148 -26 | print(book) - | - = help: Remove `enumerate` - -ℹ Suggested fix -22 22 | for index, _ in enumerate(books, x): -23 23 | print(book) -24 24 | -25 |-for _, book in enumerate(books): - 25 |+for book in books: -26 26 | print(book) -27 27 | -28 28 | for _, book in enumerate(books, start=0): - -FURB148.py:28:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead - | -26 | print(book) -27 | -28 | for _, book in enumerate(books, start=0): - | ^^^^^^^^^ FURB148 -29 | print(book) - | - = help: Remove `enumerate` - -ℹ Suggested fix -25 25 | for _, book in enumerate(books): -26 26 | print(book) -27 27 | -28 |-for _, book in enumerate(books, start=0): - 28 |+for book in books: -29 29 | print(book) -30 30 | -31 31 | for _, book in enumerate(books, 0): - -FURB148.py:31:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead - | -29 | print(book) -30 | -31 | for _, book in enumerate(books, 0): - | ^^^^^^^^^ FURB148 -32 | print(book) - | - = help: Remove `enumerate` - -ℹ Suggested fix -28 28 | for _, book in enumerate(books, start=0): -29 29 | print(book) -30 30 | -31 |-for _, book in enumerate(books, 0): - 31 |+for book in books: -32 32 | print(book) -33 33 | -34 34 | for _, book in enumerate(books, start=1): - -FURB148.py:34:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead - | -32 | print(book) -33 | -34 | for _, book in enumerate(books, start=1): - | ^^^^^^^^^ FURB148 -35 | print(book) - | - = help: Remove `enumerate` - -ℹ Suggested fix -31 31 | for _, book in enumerate(books, 0): -32 32 | print(book) -33 33 | -34 |-for _, book in enumerate(books, start=1): - 34 |+for book in books: -35 35 | print(book) -36 36 | -37 37 | for _, book in enumerate(books, 1): - -FURB148.py:37:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead - | -35 | print(book) -36 | -37 | for _, book in enumerate(books, 1): - | ^^^^^^^^^ FURB148 -38 | print(book) - | - = help: Remove `enumerate` - -ℹ Suggested fix -34 34 | for _, book in enumerate(books, start=1): -35 35 | print(book) -36 36 | -37 |-for _, book in enumerate(books, 1): - 37 |+for book in books: -38 38 | print(book) -39 39 | -40 40 | for _, book in enumerate(books, start=x): - -FURB148.py:40:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead - | -38 | print(book) -39 | -40 | for _, book in enumerate(books, start=x): - | ^^^^^^^^^ FURB148 -41 | print(book) - | - = help: Remove `enumerate` - -ℹ Suggested fix -37 37 | for _, book in enumerate(books, 1): -38 38 | print(book) -39 39 | -40 |-for _, book in enumerate(books, start=x): - 40 |+for book in books: -41 41 | print(book) -42 42 | -43 43 | for _, book in enumerate(books, x): - -FURB148.py:43:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead - | -41 | print(book) -42 | -43 | for _, book in enumerate(books, x): - | ^^^^^^^^^ FURB148 -44 | print(book) - | - = help: Remove `enumerate` - -ℹ Suggested fix -40 40 | for _, book in enumerate(books, start=x): -41 41 | print(book) -42 42 | -43 |-for _, book in enumerate(books, x): - 43 |+for book in books: -44 44 | print(book) -45 45 | -46 46 | for index, (_, _) in enumerate(books): - -FURB148.py:46:22: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead - | -44 | print(book) -45 | -46 | for index, (_, _) in enumerate(books): - | ^^^^^^^^^ FURB148 -47 | print(index) - | - = help: Replace with `range(len(...))` - -ℹ Suggested fix -43 43 | for _, book in enumerate(books, x): -44 44 | print(book) -45 45 | -46 |-for index, (_, _) in enumerate(books): - 46 |+for index in range(len(books)): -47 47 | print(index) -48 48 | -49 49 | for (_, _), book in enumerate(books): - -FURB148.py:49:21: FURB148 [*] `enumerate` index is unused, use `for x in y` instead - | -47 | print(index) -48 | -49 | for (_, _), book in enumerate(books): - | ^^^^^^^^^ FURB148 -50 | print(book) - | - = help: Remove `enumerate` - -ℹ Suggested fix -46 46 | for index, (_, _) in enumerate(books): -47 47 | print(index) -48 48 | -49 |-for (_, _), book in enumerate(books): - 49 |+for book in books: -50 50 | print(book) -51 51 | -52 52 | for(index, _)in enumerate(books): - -FURB148.py:52:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead - | -50 | print(book) -51 | -52 | for(index, _)in enumerate(books): - | ^^^^^^^^^ FURB148 -53 | print(index) - | - = help: Replace with `range(len(...))` - -ℹ Suggested fix -49 49 | for (_, _), book in enumerate(books): -50 50 | print(book) -51 51 | -52 |-for(index, _)in enumerate(books): - 52 |+for index in range(len(books)): -53 53 | print(index) -54 54 | -55 55 | for(index), _ in enumerate(books): - -FURB148.py:55:18: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead - | -53 | print(index) -54 | -55 | for(index), _ in enumerate(books): - | ^^^^^^^^^ FURB148 -56 | print(index) - | - = help: Replace with `range(len(...))` - -ℹ Suggested fix -52 52 | for(index, _)in enumerate(books): -53 53 | print(index) -54 54 | -55 |-for(index), _ in enumerate(books): - 55 |+for index in range(len(books)): -56 56 | print(index) -57 57 | -58 58 | # OK - - diff --git a/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__assert.py.md.snap b/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__assert.py.md.snap deleted file mode 100644 index 17ca4671a0..0000000000 --- a/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__assert.py.md.snap +++ /dev/null @@ -1,97 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/rules/unreachable.rs -description: "This is a Mermaid graph. You can use https://mermaid.live to visualize it as a diagram." ---- -## Function 0 -### Source -```python -def func(): - assert True -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1[["Exception raised"]] - block2["assert True\n"] - - start --> block2 - block2 -- "True" --> block0 - block2 -- "else" --> block1 - block1 --> return - block0 --> return -``` - -## Function 1 -### Source -```python -def func(): - assert False -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1[["Exception raised"]] - block2["assert False\n"] - - start --> block2 - block2 -- "False" --> block0 - block2 -- "else" --> block1 - block1 --> return - block0 --> return -``` - -## Function 2 -### Source -```python -def func(): - assert True, "oops" -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1[["Exception raised"]] - block2["assert True, #quot;oops#quot;\n"] - - start --> block2 - block2 -- "True" --> block0 - block2 -- "else" --> block1 - block1 --> return - block0 --> return -``` - -## Function 3 -### Source -```python -def func(): - assert False, "oops" -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1[["Exception raised"]] - block2["assert False, #quot;oops#quot;\n"] - - start --> block2 - block2 -- "False" --> block0 - block2 -- "else" --> block1 - block1 --> return - block0 --> return -``` - - diff --git a/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__async-for.py.md.snap b/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__async-for.py.md.snap deleted file mode 100644 index 431c82d33c..0000000000 --- a/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__async-for.py.md.snap +++ /dev/null @@ -1,241 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/rules/unreachable.rs -description: "This is a Mermaid graph. You can use https://mermaid.live to visualize it as a diagram." ---- -## Function 0 -### Source -```python -def func(): - async for i in range(5): - print(i) -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["print(i)\n"] - block2["async for i in range(5): - print(i)\n"] - - start --> block2 - block2 -- "range(5)" --> block1 - block2 -- "else" --> block0 - block1 --> block2 - block0 --> return -``` - -## Function 1 -### Source -```python -def func(): - async for i in range(20): - print(i) - else: - return 0 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["print(i)\n"] - block1["return 0\n"] - block2["async for i in range(20): - print(i) - else: - return 0\n"] - - start --> block2 - block2 -- "range(20)" --> block0 - block2 -- "else" --> block1 - block1 --> return - block0 --> return -``` - -## Function 2 -### Source -```python -def func(): - async for i in range(10): - if i == 5: - return 1 - return 0 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 0\n"] - block1["return 1\n"] - block2["if i == 5: - return 1\n"] - block3["async for i in range(10): - if i == 5: - return 1\n"] - - start --> block3 - block3 -- "range(10)" --> block2 - block3 -- "else" --> block0 - block2 -- "i == 5" --> block1 - block2 -- "else" --> block3 - block1 --> return - block0 --> return -``` - -## Function 3 -### Source -```python -def func(): - async for i in range(111): - if i == 5: - return 1 - else: - return 0 - return 2 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 2\n"] - block1["return 1\n"] - block2["if i == 5: - return 1\n"] - block3["return 0\n"] - block4["async for i in range(111): - if i == 5: - return 1 - else: - return 0\n"] - - start --> block4 - block4 -- "range(111)" --> block2 - block4 -- "else" --> block3 - block3 --> return - block2 -- "i == 5" --> block1 - block2 -- "else" --> block4 - block1 --> return - block0 --> return -``` - -## Function 4 -### Source -```python -def func(): - async for i in range(12): - continue -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["continue\n"] - block2["async for i in range(12): - continue\n"] - - start --> block2 - block2 -- "range(12)" --> block1 - block2 -- "else" --> block0 - block1 --> block2 - block0 --> return -``` - -## Function 5 -### Source -```python -def func(): - async for i in range(1110): - if True: - continue -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["continue\n"] - block2["if True: - continue\n"] - block3["async for i in range(1110): - if True: - continue\n"] - - start --> block3 - block3 -- "range(1110)" --> block2 - block3 -- "else" --> block0 - block2 -- "True" --> block1 - block2 -- "else" --> block3 - block1 --> block3 - block0 --> return -``` - -## Function 6 -### Source -```python -def func(): - async for i in range(13): - break -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["break\n"] - block2["async for i in range(13): - break\n"] - - start --> block2 - block2 -- "range(13)" --> block1 - block2 -- "else" --> block0 - block1 --> block0 - block0 --> return -``` - -## Function 7 -### Source -```python -def func(): - async for i in range(1110): - if True: - break -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["break\n"] - block2["if True: - break\n"] - block3["async for i in range(1110): - if True: - break\n"] - - start --> block3 - block3 -- "range(1110)" --> block2 - block3 -- "else" --> block0 - block2 -- "True" --> block1 - block2 -- "else" --> block3 - block1 --> block0 - block0 --> return -``` - - diff --git a/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__for.py.md.snap b/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__for.py.md.snap deleted file mode 100644 index f3d3def743..0000000000 --- a/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__for.py.md.snap +++ /dev/null @@ -1,241 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/rules/unreachable.rs -description: "This is a Mermaid graph. You can use https://mermaid.live to visualize it as a diagram." ---- -## Function 0 -### Source -```python -def func(): - for i in range(5): - print(i) -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["print(i)\n"] - block2["for i in range(5): - print(i)\n"] - - start --> block2 - block2 -- "range(5)" --> block1 - block2 -- "else" --> block0 - block1 --> block2 - block0 --> return -``` - -## Function 1 -### Source -```python -def func(): - for i in range(20): - print(i) - else: - return 0 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["print(i)\n"] - block1["return 0\n"] - block2["for i in range(20): - print(i) - else: - return 0\n"] - - start --> block2 - block2 -- "range(20)" --> block0 - block2 -- "else" --> block1 - block1 --> return - block0 --> return -``` - -## Function 2 -### Source -```python -def func(): - for i in range(10): - if i == 5: - return 1 - return 0 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 0\n"] - block1["return 1\n"] - block2["if i == 5: - return 1\n"] - block3["for i in range(10): - if i == 5: - return 1\n"] - - start --> block3 - block3 -- "range(10)" --> block2 - block3 -- "else" --> block0 - block2 -- "i == 5" --> block1 - block2 -- "else" --> block3 - block1 --> return - block0 --> return -``` - -## Function 3 -### Source -```python -def func(): - for i in range(111): - if i == 5: - return 1 - else: - return 0 - return 2 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 2\n"] - block1["return 1\n"] - block2["if i == 5: - return 1\n"] - block3["return 0\n"] - block4["for i in range(111): - if i == 5: - return 1 - else: - return 0\n"] - - start --> block4 - block4 -- "range(111)" --> block2 - block4 -- "else" --> block3 - block3 --> return - block2 -- "i == 5" --> block1 - block2 -- "else" --> block4 - block1 --> return - block0 --> return -``` - -## Function 4 -### Source -```python -def func(): - for i in range(12): - continue -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["continue\n"] - block2["for i in range(12): - continue\n"] - - start --> block2 - block2 -- "range(12)" --> block1 - block2 -- "else" --> block0 - block1 --> block2 - block0 --> return -``` - -## Function 5 -### Source -```python -def func(): - for i in range(1110): - if True: - continue -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["continue\n"] - block2["if True: - continue\n"] - block3["for i in range(1110): - if True: - continue\n"] - - start --> block3 - block3 -- "range(1110)" --> block2 - block3 -- "else" --> block0 - block2 -- "True" --> block1 - block2 -- "else" --> block3 - block1 --> block3 - block0 --> return -``` - -## Function 6 -### Source -```python -def func(): - for i in range(13): - break -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["break\n"] - block2["for i in range(13): - break\n"] - - start --> block2 - block2 -- "range(13)" --> block1 - block2 -- "else" --> block0 - block1 --> block0 - block0 --> return -``` - -## Function 7 -### Source -```python -def func(): - for i in range(1110): - if True: - break -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["break\n"] - block2["if True: - break\n"] - block3["for i in range(1110): - if True: - break\n"] - - start --> block3 - block3 -- "range(1110)" --> block2 - block3 -- "else" --> block0 - block2 -- "True" --> block1 - block2 -- "else" --> block3 - block1 --> block0 - block0 --> return -``` - - diff --git a/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__if.py.md.snap b/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__if.py.md.snap deleted file mode 100644 index 9294427514..0000000000 --- a/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__if.py.md.snap +++ /dev/null @@ -1,553 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/rules/unreachable.rs -description: "This is a Mermaid graph. You can use https://mermaid.live to visualize it as a diagram." ---- -## Function 0 -### Source -```python -def func(): - if False: - return 0 - return 1 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 1\n"] - block1["return 0\n"] - block2["if False: - return 0\n"] - - start --> block2 - block2 -- "False" --> block1 - block2 -- "else" --> block0 - block1 --> return - block0 --> return -``` - -## Function 1 -### Source -```python -def func(): - if True: - return 1 - return 0 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 0\n"] - block1["return 1\n"] - block2["if True: - return 1\n"] - - start --> block2 - block2 -- "True" --> block1 - block2 -- "else" --> block0 - block1 --> return - block0 --> return -``` - -## Function 2 -### Source -```python -def func(): - if False: - return 0 - else: - return 1 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 0\n"] - block1["return 1\n"] - block2["if False: - return 0 - else: - return 1\n"] - - start --> block2 - block2 -- "False" --> block0 - block2 -- "else" --> block1 - block1 --> return - block0 --> return -``` - -## Function 3 -### Source -```python -def func(): - if True: - return 1 - else: - return 0 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 1\n"] - block1["return 0\n"] - block2["if True: - return 1 - else: - return 0\n"] - - start --> block2 - block2 -- "True" --> block0 - block2 -- "else" --> block1 - block1 --> return - block0 --> return -``` - -## Function 4 -### Source -```python -def func(): - if False: - return 0 - else: - return 1 - return "unreachable" -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return #quot;unreachable#quot;\n"] - block1["return 0\n"] - block2["return 1\n"] - block3["if False: - return 0 - else: - return 1\n"] - - start --> block3 - block3 -- "False" --> block1 - block3 -- "else" --> block2 - block2 --> return - block1 --> return - block0 --> return -``` - -## Function 5 -### Source -```python -def func(): - if True: - return 1 - else: - return 0 - return "unreachable" -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return #quot;unreachable#quot;\n"] - block1["return 1\n"] - block2["return 0\n"] - block3["if True: - return 1 - else: - return 0\n"] - - start --> block3 - block3 -- "True" --> block1 - block3 -- "else" --> block2 - block2 --> return - block1 --> return - block0 --> return -``` - -## Function 6 -### Source -```python -def func(): - if True: - if True: - return 1 - return 2 - else: - return 3 - return "unreachable2" -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return #quot;unreachable2#quot;\n"] - block1["return 2\n"] - block2["return 1\n"] - block3["if True: - return 1\n"] - block4["return 3\n"] - block5["if True: - if True: - return 1 - return 2 - else: - return 3\n"] - - start --> block5 - block5 -- "True" --> block3 - block5 -- "else" --> block4 - block4 --> return - block3 -- "True" --> block2 - block3 -- "else" --> block1 - block2 --> return - block1 --> return - block0 --> return -``` - -## Function 7 -### Source -```python -def func(): - if False: - return 0 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["return 0\n"] - block2["if False: - return 0\n"] - - start --> block2 - block2 -- "False" --> block1 - block2 -- "else" --> block0 - block1 --> return - block0 --> return -``` - -## Function 8 -### Source -```python -def func(): - if True: - return 1 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["return 1\n"] - block2["if True: - return 1\n"] - - start --> block2 - block2 -- "True" --> block1 - block2 -- "else" --> block0 - block1 --> return - block0 --> return -``` - -## Function 9 -### Source -```python -def func(): - if True: - return 1 - elif False: - return 2 - else: - return 0 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 1\n"] - block1["return 0\n"] - block2["return 2\n"] - block3["if True: - return 1 - elif False: - return 2 - else: - return 0\n"] - block4["if True: - return 1 - elif False: - return 2 - else: - return 0\n"] - - start --> block4 - block4 -- "True" --> block0 - block4 -- "else" --> block3 - block3 -- "False" --> block2 - block3 -- "else" --> block1 - block2 --> return - block1 --> return - block0 --> return -``` - -## Function 10 -### Source -```python -def func(): - if False: - return 1 - elif True: - return 2 - else: - return 0 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 1\n"] - block1["return 0\n"] - block2["return 2\n"] - block3["if False: - return 1 - elif True: - return 2 - else: - return 0\n"] - block4["if False: - return 1 - elif True: - return 2 - else: - return 0\n"] - - start --> block4 - block4 -- "False" --> block0 - block4 -- "else" --> block3 - block3 -- "True" --> block2 - block3 -- "else" --> block1 - block2 --> return - block1 --> return - block0 --> return -``` - -## Function 11 -### Source -```python -def func(): - if True: - if False: - return 0 - elif True: - return 1 - else: - return 2 - return 3 - elif True: - return 4 - else: - return 5 - return 6 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 6\n"] - block1["return 3\n"] - block2["return 0\n"] - block3["return 2\n"] - block4["return 1\n"] - block5["if False: - return 0 - elif True: - return 1 - else: - return 2\n"] - block6["if False: - return 0 - elif True: - return 1 - else: - return 2\n"] - block7["return 5\n"] - block8["return 4\n"] - block9["if True: - if False: - return 0 - elif True: - return 1 - else: - return 2 - return 3 - elif True: - return 4 - else: - return 5\n"] - block10["if True: - if False: - return 0 - elif True: - return 1 - else: - return 2 - return 3 - elif True: - return 4 - else: - return 5\n"] - - start --> block10 - block10 -- "True" --> block6 - block10 -- "else" --> block9 - block9 -- "True" --> block8 - block9 -- "else" --> block7 - block8 --> return - block7 --> return - block6 -- "False" --> block2 - block6 -- "else" --> block5 - block5 -- "True" --> block4 - block5 -- "else" --> block3 - block4 --> return - block3 --> return - block2 --> return - block1 --> return - block0 --> return -``` - -## Function 12 -### Source -```python -def func(): - if False: - return "unreached" - elif False: - return "also unreached" - return "reached" -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return #quot;reached#quot;\n"] - block1["return #quot;unreached#quot;\n"] - block2["return #quot;also unreached#quot;\n"] - block3["if False: - return #quot;unreached#quot; - elif False: - return #quot;also unreached#quot;\n"] - block4["if False: - return #quot;unreached#quot; - elif False: - return #quot;also unreached#quot;\n"] - - start --> block4 - block4 -- "False" --> block1 - block4 -- "else" --> block3 - block3 -- "False" --> block2 - block3 -- "else" --> block0 - block2 --> return - block1 --> return - block0 --> return -``` - -## Function 13 -### Source -```python -def func(self, obj: BytesRep) -> bytes: - data = obj["data"] - - if isinstance(data, str): - return base64.b64decode(data) - elif isinstance(data, Buffer): - buffer = data - else: - id = data["id"] - - if id in self._buffers: - buffer = self._buffers[id] - else: - self.error(f"can't resolve buffer '{id}'") - - return buffer.data -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return buffer.data\n"] - block1["return base64.b64decode(data)\n"] - block2["buffer = self._buffers[id]\n"] - block3["self.error(f#quot;can't resolve buffer '{id}'#quot;)\n"] - block4["id = data[#quot;id#quot;]\nif id in self._buffers: - buffer = self._buffers[id] - else: - self.error(f#quot;can't resolve buffer '{id}'#quot;)\n"] - block5["buffer = data\n"] - block6["if isinstance(data, str): - return base64.b64decode(data) - elif isinstance(data, Buffer): - buffer = data - else: - id = data[#quot;id#quot;] - - if id in self._buffers: - buffer = self._buffers[id] - else: - self.error(f#quot;can't resolve buffer '{id}'#quot;)\n"] - block7["data = obj[#quot;data#quot;]\nif isinstance(data, str): - return base64.b64decode(data) - elif isinstance(data, Buffer): - buffer = data - else: - id = data[#quot;id#quot;] - - if id in self._buffers: - buffer = self._buffers[id] - else: - self.error(f#quot;can't resolve buffer '{id}'#quot;)\n"] - - start --> block7 - block7 -- "isinstance(data, str)" --> block1 - block7 -- "else" --> block6 - block6 -- "isinstance(data, Buffer)" --> block5 - block6 -- "else" --> block4 - block5 --> block0 - block4 -- "id in self._buffers" --> block2 - block4 -- "else" --> block3 - block3 --> block0 - block2 --> block0 - block1 --> return - block0 --> return -``` - - diff --git a/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__match.py.md.snap b/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__match.py.md.snap deleted file mode 100644 index d8a6ddb59b..0000000000 --- a/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__match.py.md.snap +++ /dev/null @@ -1,776 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/rules/unreachable.rs -description: "This is a Mermaid graph. You can use https://mermaid.live to visualize it as a diagram." ---- -## Function 0 -### Source -```python -def func(status): - match status: - case _: - return 0 - return "unreachable" -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return #quot;unreachable#quot;\n"] - block1["return 0\n"] - block2["match status: - case _: - return 0\n"] - - start --> block2 - block2 --> block1 - block1 --> return - block0 --> return -``` - -## Function 1 -### Source -```python -def func(status): - match status: - case 1: - return 1 - return 0 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 0\n"] - block1["return 1\n"] - block2["match status: - case 1: - return 1\n"] - - start --> block2 - block2 -- "case 1" --> block1 - block2 -- "else" --> block0 - block1 --> return - block0 --> return -``` - -## Function 2 -### Source -```python -def func(status): - match status: - case 1: - return 1 - case _: - return 0 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 0\n"] - block1["match status: - case 1: - return 1 - case _: - return 0\n"] - block2["return 1\n"] - block3["match status: - case 1: - return 1 - case _: - return 0\n"] - - start --> block3 - block3 -- "case 1" --> block2 - block3 -- "else" --> block1 - block2 --> return - block1 --> block0 - block0 --> return -``` - -## Function 3 -### Source -```python -def func(status): - match status: - case 1 | 2 | 3: - return 5 - return 6 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 6\n"] - block1["return 5\n"] - block2["match status: - case 1 | 2 | 3: - return 5\n"] - - start --> block2 - block2 -- "case 1 | 2 | 3" --> block1 - block2 -- "else" --> block0 - block1 --> return - block0 --> return -``` - -## Function 4 -### Source -```python -def func(status): - match status: - case 1 | 2 | 3: - return 5 - case _: - return 10 - return 0 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 0\n"] - block1["return 10\n"] - block2["match status: - case 1 | 2 | 3: - return 5 - case _: - return 10\n"] - block3["return 5\n"] - block4["match status: - case 1 | 2 | 3: - return 5 - case _: - return 10\n"] - - start --> block4 - block4 -- "case 1 | 2 | 3" --> block3 - block4 -- "else" --> block2 - block3 --> return - block2 --> block1 - block1 --> return - block0 --> return -``` - -## Function 5 -### Source -```python -def func(status): - match status: - case 0: - return 0 - case 1: - return 1 - case 1: - return "1 again" - case _: - return 3 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 3\n"] - block1["match status: - case 0: - return 0 - case 1: - return 1 - case 1: - return #quot;1 again#quot; - case _: - return 3\n"] - block2["return #quot;1 again#quot;\n"] - block3["match status: - case 0: - return 0 - case 1: - return 1 - case 1: - return #quot;1 again#quot; - case _: - return 3\n"] - block4["return 1\n"] - block5["match status: - case 0: - return 0 - case 1: - return 1 - case 1: - return #quot;1 again#quot; - case _: - return 3\n"] - block6["return 0\n"] - block7["match status: - case 0: - return 0 - case 1: - return 1 - case 1: - return #quot;1 again#quot; - case _: - return 3\n"] - - start --> block7 - block7 -- "case 0" --> block6 - block7 -- "else" --> block5 - block6 --> return - block5 -- "case 1" --> block4 - block5 -- "else" --> block3 - block4 --> return - block3 -- "case 1" --> block2 - block3 -- "else" --> block1 - block2 --> return - block1 --> block0 - block0 --> return -``` - -## Function 6 -### Source -```python -def func(status): - i = 0 - match status, i: - case _, _: - return 0 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["return 0\n"] - block2["match status, i: - case _, _: - return 0\n"] - block3["i = 0\n"] - - start --> block3 - block3 --> block2 - block2 -- "case _, _" --> block1 - block2 -- "else" --> block0 - block1 --> return - block0 --> return -``` - -## Function 7 -### Source -```python -def func(status): - i = 0 - match status, i: - case _, 0: - return 0 - case _, 2: - return 0 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["return 0\n"] - block2["match status, i: - case _, 0: - return 0 - case _, 2: - return 0\n"] - block3["return 0\n"] - block4["match status, i: - case _, 0: - return 0 - case _, 2: - return 0\n"] - block5["i = 0\n"] - - start --> block5 - block5 --> block4 - block4 -- "case _, 0" --> block3 - block4 -- "else" --> block2 - block3 --> return - block2 -- "case _, 2" --> block1 - block2 -- "else" --> block0 - block1 --> return - block0 --> return -``` - -## Function 8 -### Source -```python -def func(point): - match point: - case (0, 0): - print("Origin") - case _: - raise ValueError("oops") -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["raise ValueError(#quot;oops#quot;)\n"] - block2["match point: - case (0, 0): - print(#quot;Origin#quot;) - case _: - raise ValueError(#quot;oops#quot;)\n"] - block3["print(#quot;Origin#quot;)\n"] - block4["match point: - case (0, 0): - print(#quot;Origin#quot;) - case _: - raise ValueError(#quot;oops#quot;)\n"] - - start --> block4 - block4 -- "case (0, 0)" --> block3 - block4 -- "else" --> block2 - block3 --> block0 - block2 --> block1 - block1 --> return - block0 --> return -``` - -## Function 9 -### Source -```python -def func(point): - match point: - case (0, 0): - print("Origin") - case (0, y): - print(f"Y={y}") - case (x, 0): - print(f"X={x}") - case (x, y): - print(f"X={x}, Y={y}") - case _: - raise ValueError("Not a point") -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["raise ValueError(#quot;Not a point#quot;)\n"] - block2["match point: - case (0, 0): - print(#quot;Origin#quot;) - case (0, y): - print(f#quot;Y={y}#quot;) - case (x, 0): - print(f#quot;X={x}#quot;) - case (x, y): - print(f#quot;X={x}, Y={y}#quot;) - case _: - raise ValueError(#quot;Not a point#quot;)\n"] - block3["print(f#quot;X={x}, Y={y}#quot;)\n"] - block4["match point: - case (0, 0): - print(#quot;Origin#quot;) - case (0, y): - print(f#quot;Y={y}#quot;) - case (x, 0): - print(f#quot;X={x}#quot;) - case (x, y): - print(f#quot;X={x}, Y={y}#quot;) - case _: - raise ValueError(#quot;Not a point#quot;)\n"] - block5["print(f#quot;X={x}#quot;)\n"] - block6["match point: - case (0, 0): - print(#quot;Origin#quot;) - case (0, y): - print(f#quot;Y={y}#quot;) - case (x, 0): - print(f#quot;X={x}#quot;) - case (x, y): - print(f#quot;X={x}, Y={y}#quot;) - case _: - raise ValueError(#quot;Not a point#quot;)\n"] - block7["print(f#quot;Y={y}#quot;)\n"] - block8["match point: - case (0, 0): - print(#quot;Origin#quot;) - case (0, y): - print(f#quot;Y={y}#quot;) - case (x, 0): - print(f#quot;X={x}#quot;) - case (x, y): - print(f#quot;X={x}, Y={y}#quot;) - case _: - raise ValueError(#quot;Not a point#quot;)\n"] - block9["print(#quot;Origin#quot;)\n"] - block10["match point: - case (0, 0): - print(#quot;Origin#quot;) - case (0, y): - print(f#quot;Y={y}#quot;) - case (x, 0): - print(f#quot;X={x}#quot;) - case (x, y): - print(f#quot;X={x}, Y={y}#quot;) - case _: - raise ValueError(#quot;Not a point#quot;)\n"] - - start --> block10 - block10 -- "case (0, 0)" --> block9 - block10 -- "else" --> block8 - block9 --> block0 - block8 -- "case (0, y)" --> block7 - block8 -- "else" --> block6 - block7 --> block0 - block6 -- "case (x, 0)" --> block5 - block6 -- "else" --> block4 - block5 --> block0 - block4 -- "case (x, y)" --> block3 - block4 -- "else" --> block2 - block3 --> block0 - block2 --> block1 - block1 --> return - block0 --> return -``` - -## Function 10 -### Source -```python -def where_is(point): - class Point: - x: int - y: int - - match point: - case Point(x=0, y=0): - print("Origin") - case Point(x=0, y=y): - print(f"Y={y}") - case Point(x=x, y=0): - print(f"X={x}") - case Point(): - print("Somewhere else") - case _: - print("Not a point") -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["print(#quot;Not a point#quot;)\n"] - block2["match point: - case Point(x=0, y=0): - print(#quot;Origin#quot;) - case Point(x=0, y=y): - print(f#quot;Y={y}#quot;) - case Point(x=x, y=0): - print(f#quot;X={x}#quot;) - case Point(): - print(#quot;Somewhere else#quot;) - case _: - print(#quot;Not a point#quot;)\n"] - block3["print(#quot;Somewhere else#quot;)\n"] - block4["match point: - case Point(x=0, y=0): - print(#quot;Origin#quot;) - case Point(x=0, y=y): - print(f#quot;Y={y}#quot;) - case Point(x=x, y=0): - print(f#quot;X={x}#quot;) - case Point(): - print(#quot;Somewhere else#quot;) - case _: - print(#quot;Not a point#quot;)\n"] - block5["print(f#quot;X={x}#quot;)\n"] - block6["match point: - case Point(x=0, y=0): - print(#quot;Origin#quot;) - case Point(x=0, y=y): - print(f#quot;Y={y}#quot;) - case Point(x=x, y=0): - print(f#quot;X={x}#quot;) - case Point(): - print(#quot;Somewhere else#quot;) - case _: - print(#quot;Not a point#quot;)\n"] - block7["print(f#quot;Y={y}#quot;)\n"] - block8["match point: - case Point(x=0, y=0): - print(#quot;Origin#quot;) - case Point(x=0, y=y): - print(f#quot;Y={y}#quot;) - case Point(x=x, y=0): - print(f#quot;X={x}#quot;) - case Point(): - print(#quot;Somewhere else#quot;) - case _: - print(#quot;Not a point#quot;)\n"] - block9["print(#quot;Origin#quot;)\n"] - block10["match point: - case Point(x=0, y=0): - print(#quot;Origin#quot;) - case Point(x=0, y=y): - print(f#quot;Y={y}#quot;) - case Point(x=x, y=0): - print(f#quot;X={x}#quot;) - case Point(): - print(#quot;Somewhere else#quot;) - case _: - print(#quot;Not a point#quot;)\n"] - block11["class Point: - x: int - y: int\n"] - - start --> block11 - block11 --> block10 - block10 -- "case Point(x=0, y=0)" --> block9 - block10 -- "else" --> block8 - block9 --> block0 - block8 -- "case Point(x=0, y=y)" --> block7 - block8 -- "else" --> block6 - block7 --> block0 - block6 -- "case Point(x=x, y=0)" --> block5 - block6 -- "else" --> block4 - block5 --> block0 - block4 -- "case Point()" --> block3 - block4 -- "else" --> block2 - block3 --> block0 - block2 --> block1 - block1 --> block0 - block0 --> return -``` - -## Function 11 -### Source -```python -def func(points): - match points: - case []: - print("No points") - case [Point(0, 0)]: - print("The origin") - case [Point(x, y)]: - print(f"Single point {x}, {y}") - case [Point(0, y1), Point(0, y2)]: - print(f"Two on the Y axis at {y1}, {y2}") - case _: - print("Something else") -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["print(#quot;Something else#quot;)\n"] - block2["match points: - case []: - print(#quot;No points#quot;) - case [Point(0, 0)]: - print(#quot;The origin#quot;) - case [Point(x, y)]: - print(f#quot;Single point {x}, {y}#quot;) - case [Point(0, y1), Point(0, y2)]: - print(f#quot;Two on the Y axis at {y1}, {y2}#quot;) - case _: - print(#quot;Something else#quot;)\n"] - block3["print(f#quot;Two on the Y axis at {y1}, {y2}#quot;)\n"] - block4["match points: - case []: - print(#quot;No points#quot;) - case [Point(0, 0)]: - print(#quot;The origin#quot;) - case [Point(x, y)]: - print(f#quot;Single point {x}, {y}#quot;) - case [Point(0, y1), Point(0, y2)]: - print(f#quot;Two on the Y axis at {y1}, {y2}#quot;) - case _: - print(#quot;Something else#quot;)\n"] - block5["print(f#quot;Single point {x}, {y}#quot;)\n"] - block6["match points: - case []: - print(#quot;No points#quot;) - case [Point(0, 0)]: - print(#quot;The origin#quot;) - case [Point(x, y)]: - print(f#quot;Single point {x}, {y}#quot;) - case [Point(0, y1), Point(0, y2)]: - print(f#quot;Two on the Y axis at {y1}, {y2}#quot;) - case _: - print(#quot;Something else#quot;)\n"] - block7["print(#quot;The origin#quot;)\n"] - block8["match points: - case []: - print(#quot;No points#quot;) - case [Point(0, 0)]: - print(#quot;The origin#quot;) - case [Point(x, y)]: - print(f#quot;Single point {x}, {y}#quot;) - case [Point(0, y1), Point(0, y2)]: - print(f#quot;Two on the Y axis at {y1}, {y2}#quot;) - case _: - print(#quot;Something else#quot;)\n"] - block9["print(#quot;No points#quot;)\n"] - block10["match points: - case []: - print(#quot;No points#quot;) - case [Point(0, 0)]: - print(#quot;The origin#quot;) - case [Point(x, y)]: - print(f#quot;Single point {x}, {y}#quot;) - case [Point(0, y1), Point(0, y2)]: - print(f#quot;Two on the Y axis at {y1}, {y2}#quot;) - case _: - print(#quot;Something else#quot;)\n"] - - start --> block10 - block10 -- "case []" --> block9 - block10 -- "else" --> block8 - block9 --> block0 - block8 -- "case [Point(0, 0)]" --> block7 - block8 -- "else" --> block6 - block7 --> block0 - block6 -- "case [Point(x, y)]" --> block5 - block6 -- "else" --> block4 - block5 --> block0 - block4 -- "case [Point(0, y1), Point(0, y2)]" --> block3 - block4 -- "else" --> block2 - block3 --> block0 - block2 --> block1 - block1 --> block0 - block0 --> return -``` - -## Function 12 -### Source -```python -def func(point): - match point: - case Point(x, y) if x == y: - print(f"Y=X at {x}") - case Point(x, y): - print(f"Not on the diagonal") -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["print(f#quot;Not on the diagonal#quot;)\n"] - block2["match point: - case Point(x, y) if x == y: - print(f#quot;Y=X at {x}#quot;) - case Point(x, y): - print(f#quot;Not on the diagonal#quot;)\n"] - block3["print(f#quot;Y=X at {x}#quot;)\n"] - block4["match point: - case Point(x, y) if x == y: - print(f#quot;Y=X at {x}#quot;) - case Point(x, y): - print(f#quot;Not on the diagonal#quot;)\n"] - - start --> block4 - block4 -- "case Point(x, y) if x == y" --> block3 - block4 -- "else" --> block2 - block3 --> block0 - block2 -- "case Point(x, y)" --> block1 - block2 -- "else" --> block0 - block1 --> block0 - block0 --> return -``` - -## Function 13 -### Source -```python -def func(): - from enum import Enum - class Color(Enum): - RED = 'red' - GREEN = 'green' - BLUE = 'blue' - - color = Color(input("Enter your choice of 'red', 'blue' or 'green': ")) - - match color: - case Color.RED: - print("I see red!") - case Color.GREEN: - print("Grass is green") - case Color.BLUE: - print("I'm feeling the blues :(") -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["print(#quot;I'm feeling the blues :(#quot;)\n"] - block2["match color: - case Color.RED: - print(#quot;I see red!#quot;) - case Color.GREEN: - print(#quot;Grass is green#quot;) - case Color.BLUE: - print(#quot;I'm feeling the blues :(#quot;)\n"] - block3["print(#quot;Grass is green#quot;)\n"] - block4["match color: - case Color.RED: - print(#quot;I see red!#quot;) - case Color.GREEN: - print(#quot;Grass is green#quot;) - case Color.BLUE: - print(#quot;I'm feeling the blues :(#quot;)\n"] - block5["print(#quot;I see red!#quot;)\n"] - block6["match color: - case Color.RED: - print(#quot;I see red!#quot;) - case Color.GREEN: - print(#quot;Grass is green#quot;) - case Color.BLUE: - print(#quot;I'm feeling the blues :(#quot;)\n"] - block7["from enum import Enum\nclass Color(Enum): - RED = 'red' - GREEN = 'green' - BLUE = 'blue'\ncolor = Color(input(#quot;Enter your choice of 'red', 'blue' or 'green': #quot;))\n"] - - start --> block7 - block7 --> block6 - block6 -- "case Color.RED" --> block5 - block6 -- "else" --> block4 - block5 --> block0 - block4 -- "case Color.GREEN" --> block3 - block4 -- "else" --> block2 - block3 --> block0 - block2 -- "case Color.BLUE" --> block1 - block2 -- "else" --> block0 - block1 --> block0 - block0 --> return -``` - - diff --git a/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__raise.py.md.snap b/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__raise.py.md.snap deleted file mode 100644 index 7da998458d..0000000000 --- a/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__raise.py.md.snap +++ /dev/null @@ -1,41 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/rules/unreachable.rs -description: "This is a Mermaid graph. You can use https://mermaid.live to visualize it as a diagram." ---- -## Function 0 -### Source -```python -def func(): - raise Exception -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["raise Exception\n"] - - start --> block0 - block0 --> return -``` - -## Function 1 -### Source -```python -def func(): - raise "a glass!" -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["raise #quot;a glass!#quot;\n"] - - start --> block0 - block0 --> return -``` - - diff --git a/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__simple.py.md.snap b/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__simple.py.md.snap deleted file mode 100644 index 881df6fad1..0000000000 --- a/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__simple.py.md.snap +++ /dev/null @@ -1,136 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/rules/unreachable.rs -description: "This is a Mermaid graph. You can use https://mermaid.live to visualize it as a diagram." ---- -## Function 0 -### Source -```python -def func(): - pass -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["pass\n"] - - start --> block0 - block0 --> return -``` - -## Function 1 -### Source -```python -def func(): - pass -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["pass\n"] - - start --> block0 - block0 --> return -``` - -## Function 2 -### Source -```python -def func(): - return -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return\n"] - - start --> block0 - block0 --> return -``` - -## Function 3 -### Source -```python -def func(): - return 1 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 1\n"] - - start --> block0 - block0 --> return -``` - -## Function 4 -### Source -```python -def func(): - return 1 - return "unreachable" -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return #quot;unreachable#quot;\n"] - block1["return 1\n"] - - start --> block1 - block1 --> return - block0 --> return -``` - -## Function 5 -### Source -```python -def func(): - i = 0 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["i = 0\n"] - - start --> block0 - block0 --> return -``` - -## Function 6 -### Source -```python -def func(): - i = 0 - i += 2 - return i -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["i = 0\ni += 2\nreturn i\n"] - - start --> block0 - block0 --> return -``` - - diff --git a/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__while.py.md.snap b/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__while.py.md.snap deleted file mode 100644 index aa030a03a4..0000000000 --- a/crates/ruff/src/rules/ruff/rules/snapshots/ruff__rules__ruff__rules__unreachable__tests__while.py.md.snap +++ /dev/null @@ -1,527 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/rules/unreachable.rs -description: "This is a Mermaid graph. You can use https://mermaid.live to visualize it as a diagram." ---- -## Function 0 -### Source -```python -def func(): - while False: - return "unreachable" - return 1 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 1\n"] - block1["return #quot;unreachable#quot;\n"] - block2["while False: - return #quot;unreachable#quot;\n"] - - start --> block2 - block2 -- "False" --> block1 - block2 -- "else" --> block0 - block1 --> return - block0 --> return -``` - -## Function 1 -### Source -```python -def func(): - while False: - return "unreachable" - else: - return 1 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return #quot;unreachable#quot;\n"] - block1["return 1\n"] - block2["while False: - return #quot;unreachable#quot; - else: - return 1\n"] - - start --> block2 - block2 -- "False" --> block0 - block2 -- "else" --> block1 - block1 --> return - block0 --> return -``` - -## Function 2 -### Source -```python -def func(): - while False: - return "unreachable" - else: - return 1 - return "also unreachable" -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return #quot;also unreachable#quot;\n"] - block1["return #quot;unreachable#quot;\n"] - block2["return 1\n"] - block3["while False: - return #quot;unreachable#quot; - else: - return 1\n"] - - start --> block3 - block3 -- "False" --> block1 - block3 -- "else" --> block2 - block2 --> return - block1 --> return - block0 --> return -``` - -## Function 3 -### Source -```python -def func(): - while True: - return 1 - return "unreachable" -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return #quot;unreachable#quot;\n"] - block1["return 1\n"] - block2["while True: - return 1\n"] - - start --> block2 - block2 -- "True" --> block1 - block2 -- "else" --> block0 - block1 --> return - block0 --> return -``` - -## Function 4 -### Source -```python -def func(): - while True: - return 1 - else: - return "unreachable" -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 1\n"] - block1["return #quot;unreachable#quot;\n"] - block2["while True: - return 1 - else: - return #quot;unreachable#quot;\n"] - - start --> block2 - block2 -- "True" --> block0 - block2 -- "else" --> block1 - block1 --> return - block0 --> return -``` - -## Function 5 -### Source -```python -def func(): - while True: - return 1 - else: - return "unreachable" - return "also unreachable" -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return #quot;also unreachable#quot;\n"] - block1["return 1\n"] - block2["return #quot;unreachable#quot;\n"] - block3["while True: - return 1 - else: - return #quot;unreachable#quot;\n"] - - start --> block3 - block3 -- "True" --> block1 - block3 -- "else" --> block2 - block2 --> return - block1 --> return - block0 --> return -``` - -## Function 6 -### Source -```python -def func(): - i = 0 - while False: - i += 1 - return i -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return i\n"] - block1["i += 1\n"] - block2["i = 0\nwhile False: - i += 1\n"] - - start --> block2 - block2 -- "False" --> block1 - block2 -- "else" --> block0 - block1 --> block2 - block0 --> return -``` - -## Function 7 -### Source -```python -def func(): - i = 0 - while True: - i += 1 - return i -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return i\n"] - block1["i += 1\n"] - block2["i = 0\nwhile True: - i += 1\n"] - - start --> block2 - block2 -- "True" --> block1 - block2 -- "else" --> block0 - block1 --> block2 - block0 --> return -``` - -## Function 8 -### Source -```python -def func(): - while True: - pass - return 1 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 1\n"] - block1["pass\n"] - block2["while True: - pass\n"] - - start --> block2 - block2 -- "True" --> block1 - block2 -- "else" --> block0 - block1 --> block2 - block0 --> return -``` - -## Function 9 -### Source -```python -def func(): - i = 0 - while True: - if True: - print("ok") - i += 1 - return i -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return i\n"] - block1["i += 1\n"] - block2["print(#quot;ok#quot;)\n"] - block3["if True: - print(#quot;ok#quot;)\n"] - block4["i = 0\nwhile True: - if True: - print(#quot;ok#quot;) - i += 1\n"] - - start --> block4 - block4 -- "True" --> block3 - block4 -- "else" --> block0 - block3 -- "True" --> block2 - block3 -- "else" --> block1 - block2 --> block1 - block1 --> block4 - block0 --> return -``` - -## Function 10 -### Source -```python -def func(): - i = 0 - while True: - if False: - print("ok") - i += 1 - return i -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return i\n"] - block1["i += 1\n"] - block2["print(#quot;ok#quot;)\n"] - block3["if False: - print(#quot;ok#quot;)\n"] - block4["i = 0\nwhile True: - if False: - print(#quot;ok#quot;) - i += 1\n"] - - start --> block4 - block4 -- "True" --> block3 - block4 -- "else" --> block0 - block3 -- "False" --> block2 - block3 -- "else" --> block1 - block2 --> block1 - block1 --> block4 - block0 --> return -``` - -## Function 11 -### Source -```python -def func(): - while True: - if True: - return 1 - return 0 -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0["return 0\n"] - block1["return 1\n"] - block2["if True: - return 1\n"] - block3["while True: - if True: - return 1\n"] - - start --> block3 - block3 -- "True" --> block2 - block3 -- "else" --> block0 - block2 -- "True" --> block1 - block2 -- "else" --> block3 - block1 --> return - block0 --> return -``` - -## Function 12 -### Source -```python -def func(): - while True: - continue -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["continue\n"] - block2["while True: - continue\n"] - - start --> block2 - block2 -- "True" --> block1 - block2 -- "else" --> block0 - block1 --> block2 - block0 --> return -``` - -## Function 13 -### Source -```python -def func(): - while False: - continue -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["continue\n"] - block2["while False: - continue\n"] - - start --> block2 - block2 -- "False" --> block1 - block2 -- "else" --> block0 - block1 --> block2 - block0 --> return -``` - -## Function 14 -### Source -```python -def func(): - while True: - break -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["break\n"] - block2["while True: - break\n"] - - start --> block2 - block2 -- "True" --> block1 - block2 -- "else" --> block0 - block1 --> block0 - block0 --> return -``` - -## Function 15 -### Source -```python -def func(): - while False: - break -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["break\n"] - block2["while False: - break\n"] - - start --> block2 - block2 -- "False" --> block1 - block2 -- "else" --> block0 - block1 --> block0 - block0 --> return -``` - -## Function 16 -### Source -```python -def func(): - while True: - if True: - continue -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["continue\n"] - block2["if True: - continue\n"] - block3["while True: - if True: - continue\n"] - - start --> block3 - block3 -- "True" --> block2 - block3 -- "else" --> block0 - block2 -- "True" --> block1 - block2 -- "else" --> block3 - block1 --> block3 - block0 --> return -``` - -## Function 17 -### Source -```python -def func(): - while True: - if True: - break -``` - -### Control Flow Graph -```mermaid -flowchart TD - start(("Start")) - return(("End")) - block0[["`*(empty)*`"]] - block1["break\n"] - block2["if True: - break\n"] - block3["while True: - if True: - break\n"] - - start --> block3 - block3 -- "True" --> block2 - block3 -- "else" --> block0 - block2 -- "True" --> block1 - block2 -- "else" --> block3 - block1 --> block0 - block0 --> return -``` - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__PY39_RUF013_RUF013_0.py.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__PY39_RUF013_RUF013_0.py.snap deleted file mode 100644 index 1e25245a2a..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__PY39_RUF013_RUF013_0.py.snap +++ /dev/null @@ -1,416 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF013_0.py:21:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -21 | def f(arg: int = None): # RUF013 - | ^^^ RUF013 -22 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -18 18 | pass -19 19 | -20 20 | -21 |-def f(arg: int = None): # RUF013 - 21 |+def f(arg: Optional[int] = None): # RUF013 -22 22 | pass -23 23 | -24 24 | - -RUF013_0.py:25:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -25 | def f(arg: str = None): # RUF013 - | ^^^ RUF013 -26 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -22 22 | pass -23 23 | -24 24 | -25 |-def f(arg: str = None): # RUF013 - 25 |+def f(arg: Optional[str] = None): # RUF013 -26 26 | pass -27 27 | -28 28 | - -RUF013_0.py:29:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -29 | def f(arg: typing.List[str] = None): # RUF013 - | ^^^^^^^^^^^^^^^^ RUF013 -30 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -26 26 | pass -27 27 | -28 28 | -29 |-def f(arg: typing.List[str] = None): # RUF013 - 29 |+def f(arg: Optional[typing.List[str]] = None): # RUF013 -30 30 | pass -31 31 | -32 32 | - -RUF013_0.py:33:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -33 | def f(arg: Tuple[str] = None): # RUF013 - | ^^^^^^^^^^ RUF013 -34 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -30 30 | pass -31 31 | -32 32 | -33 |-def f(arg: Tuple[str] = None): # RUF013 - 33 |+def f(arg: Optional[Tuple[str]] = None): # RUF013 -34 34 | pass -35 35 | -36 36 | - -RUF013_0.py:71:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -71 | def f(arg: Union = None): # RUF013 - | ^^^^^ RUF013 -72 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -68 68 | pass -69 69 | -70 70 | -71 |-def f(arg: Union = None): # RUF013 - 71 |+def f(arg: Optional[Union] = None): # RUF013 -72 72 | pass -73 73 | -74 74 | - -RUF013_0.py:75:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -75 | def f(arg: Union[int] = None): # RUF013 - | ^^^^^^^^^^ RUF013 -76 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -72 72 | pass -73 73 | -74 74 | -75 |-def f(arg: Union[int] = None): # RUF013 - 75 |+def f(arg: Optional[Union[int]] = None): # RUF013 -76 76 | pass -77 77 | -78 78 | - -RUF013_0.py:79:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -79 | def f(arg: Union[int, str] = None): # RUF013 - | ^^^^^^^^^^^^^^^ RUF013 -80 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -76 76 | pass -77 77 | -78 78 | -79 |-def f(arg: Union[int, str] = None): # RUF013 - 79 |+def f(arg: Optional[Union[int, str]] = None): # RUF013 -80 80 | pass -81 81 | -82 82 | - -RUF013_0.py:83:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -83 | def f(arg: typing.Union[int, str] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^^^^ RUF013 -84 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -80 80 | pass -81 81 | -82 82 | -83 |-def f(arg: typing.Union[int, str] = None): # RUF013 - 83 |+def f(arg: Optional[typing.Union[int, str]] = None): # RUF013 -84 84 | pass -85 85 | -86 86 | - -RUF013_0.py:102:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -102 | def f(arg: int | float = None): # RUF013 - | ^^^^^^^^^^^ RUF013 -103 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -99 99 | pass -100 100 | -101 101 | -102 |-def f(arg: int | float = None): # RUF013 - 102 |+def f(arg: Optional[int | float] = None): # RUF013 -103 103 | pass -104 104 | -105 105 | - -RUF013_0.py:106:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -106 | def f(arg: int | float | str | bytes = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 -107 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -103 103 | pass -104 104 | -105 105 | -106 |-def f(arg: int | float | str | bytes = None): # RUF013 - 106 |+def f(arg: Optional[int | float | str | bytes] = None): # RUF013 -107 107 | pass -108 108 | -109 109 | - -RUF013_0.py:125:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -125 | def f(arg: Literal[1] = None): # RUF013 - | ^^^^^^^^^^ RUF013 -126 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -122 122 | pass -123 123 | -124 124 | -125 |-def f(arg: Literal[1] = None): # RUF013 - 125 |+def f(arg: Optional[Literal[1]] = None): # RUF013 -126 126 | pass -127 127 | -128 128 | - -RUF013_0.py:129:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -129 | def f(arg: Literal[1, "foo"] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^ RUF013 -130 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -126 126 | pass -127 127 | -128 128 | -129 |-def f(arg: Literal[1, "foo"] = None): # RUF013 - 129 |+def f(arg: Optional[Literal[1, "foo"]] = None): # RUF013 -130 130 | pass -131 131 | -132 132 | - -RUF013_0.py:133:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -133 | def f(arg: typing.Literal[1, "foo", True] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 -134 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -130 130 | pass -131 131 | -132 132 | -133 |-def f(arg: typing.Literal[1, "foo", True] = None): # RUF013 - 133 |+def f(arg: Optional[typing.Literal[1, "foo", True]] = None): # RUF013 -134 134 | pass -135 135 | -136 136 | - -RUF013_0.py:152:22: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -152 | def f(arg: Annotated[int, ...] = None): # RUF013 - | ^^^ RUF013 -153 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -149 149 | pass -150 150 | -151 151 | -152 |-def f(arg: Annotated[int, ...] = None): # RUF013 - 152 |+def f(arg: Annotated[Optional[int], ...] = None): # RUF013 -153 153 | pass -154 154 | -155 155 | - -RUF013_0.py:156:32: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -156 | def f(arg: Annotated[Annotated[int | str, ...], ...] = None): # RUF013 - | ^^^^^^^^^ RUF013 -157 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -153 153 | pass -154 154 | -155 155 | -156 |-def f(arg: Annotated[Annotated[int | str, ...], ...] = None): # RUF013 - 156 |+def f(arg: Annotated[Annotated[Optional[int | str], ...], ...] = None): # RUF013 -157 157 | pass -158 158 | -159 159 | - -RUF013_0.py:172:11: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -171 | def f( -172 | arg1: int = None, # RUF013 - | ^^^ RUF013 -173 | arg2: Union[int, float] = None, # RUF013 -174 | arg3: Literal[1, 2, 3] = None, # RUF013 - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -169 169 | -170 170 | -171 171 | def f( -172 |- arg1: int = None, # RUF013 - 172 |+ arg1: Optional[int] = None, # RUF013 -173 173 | arg2: Union[int, float] = None, # RUF013 -174 174 | arg3: Literal[1, 2, 3] = None, # RUF013 -175 175 | ): - -RUF013_0.py:173:11: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -171 | def f( -172 | arg1: int = None, # RUF013 -173 | arg2: Union[int, float] = None, # RUF013 - | ^^^^^^^^^^^^^^^^^ RUF013 -174 | arg3: Literal[1, 2, 3] = None, # RUF013 -175 | ): - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -170 170 | -171 171 | def f( -172 172 | arg1: int = None, # RUF013 -173 |- arg2: Union[int, float] = None, # RUF013 - 173 |+ arg2: Optional[Union[int, float]] = None, # RUF013 -174 174 | arg3: Literal[1, 2, 3] = None, # RUF013 -175 175 | ): -176 176 | pass - -RUF013_0.py:174:11: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -172 | arg1: int = None, # RUF013 -173 | arg2: Union[int, float] = None, # RUF013 -174 | arg3: Literal[1, 2, 3] = None, # RUF013 - | ^^^^^^^^^^^^^^^^ RUF013 -175 | ): -176 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -171 171 | def f( -172 172 | arg1: int = None, # RUF013 -173 173 | arg2: Union[int, float] = None, # RUF013 -174 |- arg3: Literal[1, 2, 3] = None, # RUF013 - 174 |+ arg3: Optional[Literal[1, 2, 3]] = None, # RUF013 -175 175 | ): -176 176 | pass -177 177 | - -RUF013_0.py:202:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -202 | def f(arg: Union[Annotated[int, ...], Union[str, bytes]] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 -203 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -199 199 | pass -200 200 | -201 201 | -202 |-def f(arg: Union[Annotated[int, ...], Union[str, bytes]] = None): # RUF013 - 202 |+def f(arg: Optional[Union[Annotated[int, ...], Union[str, bytes]]] = None): # RUF013 -203 203 | pass -204 204 | -205 205 | - -RUF013_0.py:209:13: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -209 | def f(arg: "int" = None): # RUF013 - | ^^^ RUF013 -210 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -206 206 | # Quoted -207 207 | -208 208 | -209 |-def f(arg: "int" = None): # RUF013 - 209 |+def f(arg: "Optional[int]" = None): # RUF013 -210 210 | pass -211 211 | -212 212 | - -RUF013_0.py:213:13: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -213 | def f(arg: "str" = None): # RUF013 - | ^^^ RUF013 -214 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -210 210 | pass -211 211 | -212 212 | -213 |-def f(arg: "str" = None): # RUF013 - 213 |+def f(arg: "Optional[str]" = None): # RUF013 -214 214 | pass -215 215 | -216 216 | - -RUF013_0.py:217:12: RUF013 PEP 484 prohibits implicit `Optional` - | -217 | def f(arg: "st" "r" = None): # RUF013 - | ^^^^^^^^ RUF013 -218 | pass - | - = help: Convert to `Optional[T]` - -RUF013_0.py:225:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -225 | def f(arg: Union["int", "str"] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^ RUF013 -226 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -222 222 | pass -223 223 | -224 224 | -225 |-def f(arg: Union["int", "str"] = None): # RUF013 - 225 |+def f(arg: Optional[Union["int", "str"]] = None): # RUF013 -226 226 | pass -227 227 | -228 228 | - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__PY39_RUF013_RUF013_1.py.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__PY39_RUF013_RUF013_1.py.snap deleted file mode 100644 index ef30934200..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__PY39_RUF013_RUF013_1.py.snap +++ /dev/null @@ -1,21 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF013_1.py:4:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -4 | def f(arg: int = None): # RUF011 - | ^^^ RUF013 -5 | pass - | - = help: Convert to `Optional[T]` - -ℹ Suggested fix -1 1 | # No `typing.Optional` import - 2 |+from typing import Optional -2 3 | -3 4 | -4 |-def f(arg: int = None): # RUF011 - 5 |+def f(arg: Optional[int] = None): # RUF011 -5 6 | pass - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF005_RUF005.py.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF005_RUF005.py.snap deleted file mode 100644 index d2596ef929..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF005_RUF005.py.snap +++ /dev/null @@ -1,357 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF005.py:4:1: RUF005 Consider `[*foo]` instead of concatenation - | -2 | # Non-fixable Errors. -3 | ### -4 | / foo + [ # This will be preserved. -5 | | ] - | |_^ RUF005 -6 | [*foo] + [ # This will be preserved. -7 | ] - | - = help: Replace with `[*foo]` - -RUF005.py:6:1: RUF005 Consider `[*foo]` instead of concatenation - | -4 | foo + [ # This will be preserved. -5 | ] -6 | / [*foo] + [ # This will be preserved. -7 | | ] - | |_^ RUF005 -8 | first = [ -9 | # The order - | - = help: Replace with `[*foo]` - -RUF005.py:16:10: RUF005 Consider `[*first, 4, 5, 6]` instead of concatenation - | -14 | # to preserve -15 | ] -16 | second = first + [ - | __________^ -17 | | # please -18 | | 4, -19 | | # don't -20 | | 5, -21 | | # touch -22 | | 6, -23 | | ] - | |_^ RUF005 - | - = help: Replace with `[*first, 4, 5, 6]` - -RUF005.py:39:7: RUF005 [*] Consider `[1, 2, 3, *foo]` instead of concatenation - | -38 | foo = [4, 5, 6] -39 | bar = [1, 2, 3] + foo - | ^^^^^^^^^^^^^^^ RUF005 -40 | zoob = tuple(bar) -41 | quux = (7, 8, 9) + zoob - | - = help: Replace with `[1, 2, 3, *foo]` - -ℹ Suggested fix -36 36 | yay = Fun().yay -37 37 | -38 38 | foo = [4, 5, 6] -39 |-bar = [1, 2, 3] + foo - 39 |+bar = [1, 2, 3, *foo] -40 40 | zoob = tuple(bar) -41 41 | quux = (7, 8, 9) + zoob -42 42 | spam = quux + (10, 11, 12) - -RUF005.py:41:8: RUF005 [*] Consider `(7, 8, 9, *zoob)` instead of concatenation - | -39 | bar = [1, 2, 3] + foo -40 | zoob = tuple(bar) -41 | quux = (7, 8, 9) + zoob - | ^^^^^^^^^^^^^^^^ RUF005 -42 | spam = quux + (10, 11, 12) -43 | spom = list(spam) - | - = help: Replace with `(7, 8, 9, *zoob)` - -ℹ Suggested fix -38 38 | foo = [4, 5, 6] -39 39 | bar = [1, 2, 3] + foo -40 40 | zoob = tuple(bar) -41 |-quux = (7, 8, 9) + zoob - 41 |+quux = (7, 8, 9, *zoob) -42 42 | spam = quux + (10, 11, 12) -43 43 | spom = list(spam) -44 44 | eggs = spom + [13, 14, 15] - -RUF005.py:42:8: RUF005 [*] Consider `(*quux, 10, 11, 12)` instead of concatenation - | -40 | zoob = tuple(bar) -41 | quux = (7, 8, 9) + zoob -42 | spam = quux + (10, 11, 12) - | ^^^^^^^^^^^^^^^^^^^ RUF005 -43 | spom = list(spam) -44 | eggs = spom + [13, 14, 15] - | - = help: Replace with `(*quux, 10, 11, 12)` - -ℹ Suggested fix -39 39 | bar = [1, 2, 3] + foo -40 40 | zoob = tuple(bar) -41 41 | quux = (7, 8, 9) + zoob -42 |-spam = quux + (10, 11, 12) - 42 |+spam = (*quux, 10, 11, 12) -43 43 | spom = list(spam) -44 44 | eggs = spom + [13, 14, 15] -45 45 | elatement = ("we all say",) + yay() - -RUF005.py:44:8: RUF005 [*] Consider `[*spom, 13, 14, 15]` instead of concatenation - | -42 | spam = quux + (10, 11, 12) -43 | spom = list(spam) -44 | eggs = spom + [13, 14, 15] - | ^^^^^^^^^^^^^^^^^^^ RUF005 -45 | elatement = ("we all say",) + yay() -46 | excitement = ("we all think",) + Fun().yay() - | - = help: Replace with `[*spom, 13, 14, 15]` - -ℹ Suggested fix -41 41 | quux = (7, 8, 9) + zoob -42 42 | spam = quux + (10, 11, 12) -43 43 | spom = list(spam) -44 |-eggs = spom + [13, 14, 15] - 44 |+eggs = [*spom, 13, 14, 15] -45 45 | elatement = ("we all say",) + yay() -46 46 | excitement = ("we all think",) + Fun().yay() -47 47 | astonishment = ("we all feel",) + Fun.words - -RUF005.py:45:13: RUF005 [*] Consider `("we all say", *yay())` instead of concatenation - | -43 | spom = list(spam) -44 | eggs = spom + [13, 14, 15] -45 | elatement = ("we all say",) + yay() - | ^^^^^^^^^^^^^^^^^^^^^^^ RUF005 -46 | excitement = ("we all think",) + Fun().yay() -47 | astonishment = ("we all feel",) + Fun.words - | - = help: Replace with `("we all say", *yay())` - -ℹ Suggested fix -42 42 | spam = quux + (10, 11, 12) -43 43 | spom = list(spam) -44 44 | eggs = spom + [13, 14, 15] -45 |-elatement = ("we all say",) + yay() - 45 |+elatement = ("we all say", *yay()) -46 46 | excitement = ("we all think",) + Fun().yay() -47 47 | astonishment = ("we all feel",) + Fun.words -48 48 | - -RUF005.py:46:14: RUF005 [*] Consider `("we all think", *Fun().yay())` instead of concatenation - | -44 | eggs = spom + [13, 14, 15] -45 | elatement = ("we all say",) + yay() -46 | excitement = ("we all think",) + Fun().yay() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 -47 | astonishment = ("we all feel",) + Fun.words - | - = help: Replace with `("we all think", *Fun().yay())` - -ℹ Suggested fix -43 43 | spom = list(spam) -44 44 | eggs = spom + [13, 14, 15] -45 45 | elatement = ("we all say",) + yay() -46 |-excitement = ("we all think",) + Fun().yay() - 46 |+excitement = ("we all think", *Fun().yay()) -47 47 | astonishment = ("we all feel",) + Fun.words -48 48 | -49 49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) - -RUF005.py:47:16: RUF005 [*] Consider `("we all feel", *Fun.words)` instead of concatenation - | -45 | elatement = ("we all say",) + yay() -46 | excitement = ("we all think",) + Fun().yay() -47 | astonishment = ("we all feel",) + Fun.words - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 -48 | -49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) - | - = help: Replace with `("we all feel", *Fun.words)` - -ℹ Suggested fix -44 44 | eggs = spom + [13, 14, 15] -45 45 | elatement = ("we all say",) + yay() -46 46 | excitement = ("we all think",) + Fun().yay() -47 |-astonishment = ("we all feel",) + Fun.words - 47 |+astonishment = ("we all feel", *Fun.words) -48 48 | -49 49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) -50 50 | - -RUF005.py:49:9: RUF005 [*] Consider iterable unpacking instead of concatenation - | -47 | astonishment = ("we all feel",) + Fun.words -48 | -49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 -50 | -51 | baz = () + zoob - | - = help: Replace with iterable unpacking - -ℹ Suggested fix -46 46 | excitement = ("we all think",) + Fun().yay() -47 47 | astonishment = ("we all feel",) + Fun.words -48 48 | -49 |-chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) - 49 |+chain = ["a", "b", "c", *eggs, *list(("yes", "no", "pants") + zoob)] -50 50 | -51 51 | baz = () + zoob -52 52 | - -RUF005.py:49:39: RUF005 [*] Consider `("yes", "no", "pants", *zoob)` instead of concatenation - | -47 | astonishment = ("we all feel",) + Fun.words -48 | -49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 -50 | -51 | baz = () + zoob - | - = help: Replace with `("yes", "no", "pants", *zoob)` - -ℹ Suggested fix -46 46 | excitement = ("we all think",) + Fun().yay() -47 47 | astonishment = ("we all feel",) + Fun.words -48 48 | -49 |-chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) - 49 |+chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants", *zoob)) -50 50 | -51 51 | baz = () + zoob -52 52 | - -RUF005.py:51:7: RUF005 [*] Consider `(*zoob,)` instead of concatenation - | -49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) -50 | -51 | baz = () + zoob - | ^^^^^^^^^ RUF005 -52 | -53 | [] + foo + [ - | - = help: Replace with `(*zoob,)` - -ℹ Suggested fix -48 48 | -49 49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) -50 50 | -51 |-baz = () + zoob - 51 |+baz = (*zoob,) -52 52 | -53 53 | [] + foo + [ -54 54 | ] - -RUF005.py:53:1: RUF005 [*] Consider `[*foo]` instead of concatenation - | -51 | baz = () + zoob -52 | -53 | / [] + foo + [ -54 | | ] - | |_^ RUF005 -55 | -56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] - | - = help: Replace with `[*foo]` - -ℹ Suggested fix -50 50 | -51 51 | baz = () + zoob -52 52 | -53 |-[] + foo + [ -54 |-] - 53 |+[*foo] -55 54 | -56 55 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] -57 56 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) - -RUF005.py:56:15: RUF005 [*] Consider `[sys.executable, "-m", "pylint", *args, path]` instead of concatenation - | -54 | ] -55 | -56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 -57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) -58 | b = a + [2, 3] + [4] - | - = help: Replace with `[sys.executable, "-m", "pylint", *args, path]` - -ℹ Suggested fix -53 53 | [] + foo + [ -54 54 | ] -55 55 | -56 |-pylint_call = [sys.executable, "-m", "pylint"] + args + [path] - 56 |+pylint_call = [sys.executable, "-m", "pylint", *args, path] -57 57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) -58 58 | b = a + [2, 3] + [4] -59 59 | - -RUF005.py:57:21: RUF005 [*] Consider iterable unpacking instead of concatenation - | -56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] -57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 -58 | b = a + [2, 3] + [4] - | - = help: Replace with iterable unpacking - -ℹ Suggested fix -54 54 | ] -55 55 | -56 56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] -57 |-pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) - 57 |+pylint_call_tuple = (sys.executable, "-m", "pylint", *args, path, path2) -58 58 | b = a + [2, 3] + [4] -59 59 | -60 60 | # Uses the non-preferred quote style, which should be retained. - -RUF005.py:58:5: RUF005 [*] Consider `[*a, 2, 3, 4]` instead of concatenation - | -56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] -57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) -58 | b = a + [2, 3] + [4] - | ^^^^^^^^^^^^^^^^ RUF005 -59 | -60 | # Uses the non-preferred quote style, which should be retained. - | - = help: Replace with `[*a, 2, 3, 4]` - -ℹ Suggested fix -55 55 | -56 56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] -57 57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) -58 |-b = a + [2, 3] + [4] - 58 |+b = [*a, 2, 3, 4] -59 59 | -60 60 | # Uses the non-preferred quote style, which should be retained. -61 61 | f"{a() + ['b']}" - -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 | -63 | ### - | - = help: Replace with `[*a(), 'b']` - -ℹ Suggested fix -58 58 | b = a + [2, 3] + [4] -59 59 | -60 60 | # Uses the non-preferred quote style, which should be retained. -61 |-f"{a() + ['b']}" - 61 |+f"{[*a(), 'b']}" -62 62 | -63 63 | ### -64 64 | # Non-errors. - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF006_RUF006.py.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF006_RUF006.py.snap deleted file mode 100644 index d920cfd671..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF006_RUF006.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF006.py:6:5: RUF006 Store a reference to the return value of `asyncio.create_task` - | -4 | # Error -5 | def f(): -6 | asyncio.create_task(coordinator.ws_connect()) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF006 - | - -RUF006.py:11:5: RUF006 Store a reference to the return value of `asyncio.ensure_future` - | - 9 | # Error -10 | def f(): -11 | asyncio.ensure_future(coordinator.ws_connect()) # Error - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF006 - | - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF007_RUF007.py.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF007_RUF007.py.snap deleted file mode 100644 index d96ffbd2d5..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF007_RUF007.py.snap +++ /dev/null @@ -1,100 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF007.py:16:1: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs - | -15 | # Errors -16 | zip(input, input[1:]) - | ^^^ RUF007 -17 | zip(input, input[1::1]) -18 | zip(input[:-1], input[1:]) - | - -RUF007.py:17:1: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs - | -15 | # Errors -16 | zip(input, input[1:]) -17 | zip(input, input[1::1]) - | ^^^ RUF007 -18 | zip(input[:-1], input[1:]) -19 | zip(input[1:], input[2:]) - | - -RUF007.py:18:1: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs - | -16 | zip(input, input[1:]) -17 | zip(input, input[1::1]) -18 | zip(input[:-1], input[1:]) - | ^^^ RUF007 -19 | zip(input[1:], input[2:]) -20 | zip(input[1:-1], input[2:]) - | - -RUF007.py:19:1: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs - | -17 | zip(input, input[1::1]) -18 | zip(input[:-1], input[1:]) -19 | zip(input[1:], input[2:]) - | ^^^ RUF007 -20 | zip(input[1:-1], input[2:]) -21 | list(zip(input, input[1:])) - | - -RUF007.py:20:1: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs - | -18 | zip(input[:-1], input[1:]) -19 | zip(input[1:], input[2:]) -20 | zip(input[1:-1], input[2:]) - | ^^^ RUF007 -21 | list(zip(input, input[1:])) -22 | list(zip(input[:-1], input[1:])) - | - -RUF007.py:21:6: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs - | -19 | zip(input[1:], input[2:]) -20 | zip(input[1:-1], input[2:]) -21 | list(zip(input, input[1:])) - | ^^^ RUF007 -22 | list(zip(input[:-1], input[1:])) -23 | zip(foo[:-1], foo[1:], strict=True) - | - -RUF007.py:22:6: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs - | -20 | zip(input[1:-1], input[2:]) -21 | list(zip(input, input[1:])) -22 | list(zip(input[:-1], input[1:])) - | ^^^ RUF007 -23 | zip(foo[:-1], foo[1:], strict=True) -24 | zip(foo[:-1], foo[1:], strict=False) - | - -RUF007.py:23:1: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs - | -21 | list(zip(input, input[1:])) -22 | list(zip(input[:-1], input[1:])) -23 | zip(foo[:-1], foo[1:], strict=True) - | ^^^ RUF007 -24 | zip(foo[:-1], foo[1:], strict=False) -25 | zip(foo[:-1], foo[1:], strict=bool(foo)) - | - -RUF007.py:24:1: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs - | -22 | list(zip(input[:-1], input[1:])) -23 | zip(foo[:-1], foo[1:], strict=True) -24 | zip(foo[:-1], foo[1:], strict=False) - | ^^^ RUF007 -25 | zip(foo[:-1], foo[1:], strict=bool(foo)) - | - -RUF007.py:25:1: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs - | -23 | zip(foo[:-1], foo[1:], strict=True) -24 | zip(foo[:-1], foo[1:], strict=False) -25 | zip(foo[:-1], foo[1:], strict=bool(foo)) - | ^^^ RUF007 - | - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF008_RUF008.py.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF008_RUF008.py.snap deleted file mode 100644 index e1d7054a57..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF008_RUF008.py.snap +++ /dev/null @@ -1,24 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF008.py:10:34: RUF008 Do not use mutable default values for dataclass attributes - | - 8 | @dataclass - 9 | class A: -10 | mutable_default: list[int] = [] - | ^^ RUF008 -11 | immutable_annotation: typing.Sequence[int] = [] -12 | without_annotation = [] - | - -RUF008.py:20:34: RUF008 Do not use mutable default values for dataclass attributes - | -18 | @dataclass -19 | class B: -20 | mutable_default: list[int] = [] - | ^^ RUF008 -21 | immutable_annotation: Sequence[int] = [] -22 | without_annotation = [] - | - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF009_RUF009.py.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF009_RUF009.py.snap deleted file mode 100644 index 64571bbe2d..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF009_RUF009.py.snap +++ /dev/null @@ -1,44 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF009.py:20:41: RUF009 Do not perform function call `default_function` in dataclass defaults - | -18 | @dataclass() -19 | class A: -20 | hidden_mutable_default: list[int] = default_function() - | ^^^^^^^^^^^^^^^^^^ RUF009 -21 | class_variable: typing.ClassVar[list[int]] = default_function() -22 | another_class_var: ClassVar[list[int]] = default_function() - | - -RUF009.py:43:41: RUF009 Do not perform function call `default_function` in dataclass defaults - | -41 | @dataclass -42 | class B: -43 | hidden_mutable_default: list[int] = default_function() - | ^^^^^^^^^^^^^^^^^^ RUF009 -44 | another_dataclass: A = A() -45 | not_optimal: ImmutableType = ImmutableType(20) - | - -RUF009.py:44:28: RUF009 Do not perform function call `A` in dataclass defaults - | -42 | class B: -43 | hidden_mutable_default: list[int] = default_function() -44 | another_dataclass: A = A() - | ^^^ RUF009 -45 | not_optimal: ImmutableType = ImmutableType(20) -46 | good_variant: ImmutableType = DEFAULT_IMMUTABLETYPE_FOR_ALL_DATACLASSES - | - -RUF009.py:45:34: RUF009 Do not perform function call `ImmutableType` in dataclass defaults - | -43 | hidden_mutable_default: list[int] = default_function() -44 | another_dataclass: A = A() -45 | not_optimal: ImmutableType = ImmutableType(20) - | ^^^^^^^^^^^^^^^^^ RUF009 -46 | good_variant: ImmutableType = DEFAULT_IMMUTABLETYPE_FOR_ALL_DATACLASSES -47 | okay_variant: A = DEFAULT_A_FOR_ALL_DATACLASSES - | - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF010_RUF010.py.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF010_RUF010.py.snap deleted file mode 100644 index da5f4232c5..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF010_RUF010.py.snap +++ /dev/null @@ -1,249 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF010.py:9:4: RUF010 [*] Use explicit conversion flag - | - 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 - | ^^^^^^^^ RUF010 -10 | -11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 - | - = help: Replace with conversion flag - -ℹ Fix -6 6 | pass -7 7 | -8 8 | -9 |-f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 - 9 |+f"{bla!s}, {repr(bla)}, {ascii(bla)}" # RUF010 -10 10 | -11 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 -12 12 | - -RUF010.py:9:16: RUF010 [*] Use explicit conversion flag - | - 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 - | ^^^^^^^^^ RUF010 -10 | -11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 - | - = help: Replace with conversion flag - -ℹ Fix -6 6 | pass -7 7 | -8 8 | -9 |-f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 - 9 |+f"{str(bla)}, {bla!r}, {ascii(bla)}" # RUF010 -10 10 | -11 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 -12 12 | - -RUF010.py:9:29: RUF010 [*] Use explicit conversion flag - | - 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 - | ^^^^^^^^^^ RUF010 -10 | -11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 - | - = help: Replace with conversion flag - -ℹ Fix -6 6 | pass -7 7 | -8 8 | -9 |-f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 - 9 |+f"{str(bla)}, {repr(bla)}, {bla!a}" # RUF010 -10 10 | -11 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 -12 12 | - -RUF010.py:11:4: RUF010 [*] Use explicit conversion flag - | - 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 -10 | -11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 - | ^^^^^^^^^^^ RUF010 -12 | -13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - | - = help: Replace with conversion flag - -ℹ Fix -8 8 | -9 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 -10 10 | -11 |-f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 - 11 |+f"{d['a']!s}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 -12 12 | -13 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 -14 14 | - -RUF010.py:11:19: RUF010 [*] Use explicit conversion flag - | - 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 -10 | -11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 - | ^^^^^^^^^^^^ RUF010 -12 | -13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - | - = help: Replace with conversion flag - -ℹ Fix -8 8 | -9 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 -10 10 | -11 |-f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 - 11 |+f"{str(d['a'])}, {d['b']!r}, {ascii(d['c'])}" # RUF010 -12 12 | -13 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 -14 14 | - -RUF010.py:11:35: RUF010 [*] Use explicit conversion flag - | - 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 -10 | -11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 - | ^^^^^^^^^^^^^ RUF010 -12 | -13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - | - = help: Replace with conversion flag - -ℹ Fix -8 8 | -9 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 -10 10 | -11 |-f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 - 11 |+f"{str(d['a'])}, {repr(d['b'])}, {d['c']!a}" # RUF010 -12 12 | -13 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 -14 14 | - -RUF010.py:13:5: RUF010 [*] Use explicit conversion flag - | -11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 -12 | -13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - | ^^^^^^^^ RUF010 -14 | -15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - | - = help: Replace with conversion flag - -ℹ Fix -10 10 | -11 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 -12 12 | -13 |-f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - 13 |+f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 -14 14 | -15 15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 -16 16 | - -RUF010.py:13:19: RUF010 [*] Use explicit conversion flag - | -11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 -12 | -13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - | ^^^^^^^^^ RUF010 -14 | -15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - | - = help: Replace with conversion flag - -ℹ Fix -10 10 | -11 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 -12 12 | -13 |-f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - 13 |+f"{(str(bla))}, {bla!r}, {(ascii(bla))}" # RUF010 -14 14 | -15 15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 -16 16 | - -RUF010.py:13:34: RUF010 [*] Use explicit conversion flag - | -11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 -12 | -13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - | ^^^^^^^^^^ RUF010 -14 | -15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - | - = help: Replace with conversion flag - -ℹ Fix -10 10 | -11 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 -12 12 | -13 |-f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - 13 |+f"{(str(bla))}, {(repr(bla))}, {bla!a}" # RUF010 -14 14 | -15 15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 -16 16 | - -RUF010.py:15:14: RUF010 [*] Use explicit conversion flag - | -13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 -14 | -15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - | ^^^^^^^^^ RUF010 -16 | -17 | f"{foo(bla)}" # OK - | - = help: Replace with conversion flag - -ℹ Fix -12 12 | -13 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 -14 14 | -15 |-f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - 15 |+f"{bla!s}, {bla!r}, {(ascii(bla))}" # RUF010 -16 16 | -17 17 | f"{foo(bla)}" # OK -18 18 | - -RUF010.py:15:29: RUF010 [*] Use explicit conversion flag - | -13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 -14 | -15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - | ^^^^^^^^^^ RUF010 -16 | -17 | f"{foo(bla)}" # OK - | - = help: Replace with conversion flag - -ℹ Fix -12 12 | -13 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 -14 14 | -15 |-f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 - 15 |+f"{bla!s}, {(repr(bla))}, {bla!a}" # RUF010 -16 16 | -17 17 | f"{foo(bla)}" # OK -18 18 | - -RUF010.py:35:20: RUF010 [*] Use explicit conversion flag - | -33 | f"Member of tuple mismatches type at index {i}. Expected {of_shape_i}. Got " -34 | " intermediary content " -35 | f" that flows {repr(obj)} of type {type(obj)}.{additional_message}" # RUF010 - | ^^^^^^^^^ RUF010 -36 | ) - | - = help: Replace with conversion flag - -ℹ Fix -32 32 | ( -33 33 | f"Member of tuple mismatches type at index {i}. Expected {of_shape_i}. Got " -34 34 | " intermediary content " -35 |- f" that flows {repr(obj)} of type {type(obj)}.{additional_message}" # RUF010 - 35 |+ f" that flows {obj!r} of type {type(obj)}.{additional_message}" # RUF010 -36 36 | ) -37 37 | -38 38 | - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF011_RUF011.py.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF011_RUF011.py.snap deleted file mode 100644 index 667bc3a390..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF011_RUF011.py.snap +++ /dev/null @@ -1,40 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF011.py:10:2: RUF011 Dictionary comprehension uses static key: `"key"` - | - 9 | # Errors -10 | {"key": value.upper() for value in data} - | ^^^^^ RUF011 -11 | {True: value.upper() for value in data} -12 | {0: value.upper() for value in data} - | - -RUF011.py:11:2: RUF011 Dictionary comprehension uses static key: `True` - | - 9 | # Errors -10 | {"key": value.upper() for value in data} -11 | {True: value.upper() for value in data} - | ^^^^ RUF011 -12 | {0: value.upper() for value in data} -13 | {(1, "a"): value.upper() for value in data} # constant tuple - | - -RUF011.py:12:2: RUF011 Dictionary comprehension uses static key: `0` - | -10 | {"key": value.upper() for value in data} -11 | {True: value.upper() for value in data} -12 | {0: value.upper() for value in data} - | ^ RUF011 -13 | {(1, "a"): value.upper() for value in data} # constant tuple - | - -RUF011.py:13:2: RUF011 Dictionary comprehension uses static key: `(1, "a")` - | -11 | {True: value.upper() for value in data} -12 | {0: value.upper() for value in data} -13 | {(1, "a"): value.upper() for value in data} # constant tuple - | ^^^^^^^^ RUF011 - | - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF012_RUF012.py.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF012_RUF012.py.snap deleted file mode 100644 index 81b1adfed7..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF012_RUF012.py.snap +++ /dev/null @@ -1,34 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF012.py:9:34: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` - | - 7 | } - 8 | - 9 | mutable_default: list[int] = [] - | ^^ RUF012 -10 | immutable_annotation: Sequence[int] = [] -11 | without_annotation = [] - | - -RUF012.py:11:26: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` - | - 9 | mutable_default: list[int] = [] -10 | immutable_annotation: Sequence[int] = [] -11 | without_annotation = [] - | ^^ RUF012 -12 | class_variable: ClassVar[list[int]] = [] -13 | final_variable: Final[list[int]] = [] - | - -RUF012.py:25:26: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` - | -23 | mutable_default: list[int] = [] -24 | immutable_annotation: Sequence[int] = [] -25 | without_annotation = [] - | ^^ RUF012 -26 | perfectly_fine: list[int] = field(default_factory=list) -27 | class_variable: ClassVar[list[int]] = [] - | - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF013_RUF013_0.py.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF013_RUF013_0.py.snap deleted file mode 100644 index 3ff56b6bc2..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF013_RUF013_0.py.snap +++ /dev/null @@ -1,416 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF013_0.py:21:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -21 | def f(arg: int = None): # RUF013 - | ^^^ RUF013 -22 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -18 18 | pass -19 19 | -20 20 | -21 |-def f(arg: int = None): # RUF013 - 21 |+def f(arg: int | None = None): # RUF013 -22 22 | pass -23 23 | -24 24 | - -RUF013_0.py:25:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -25 | def f(arg: str = None): # RUF013 - | ^^^ RUF013 -26 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -22 22 | pass -23 23 | -24 24 | -25 |-def f(arg: str = None): # RUF013 - 25 |+def f(arg: str | None = None): # RUF013 -26 26 | pass -27 27 | -28 28 | - -RUF013_0.py:29:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -29 | def f(arg: typing.List[str] = None): # RUF013 - | ^^^^^^^^^^^^^^^^ RUF013 -30 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -26 26 | pass -27 27 | -28 28 | -29 |-def f(arg: typing.List[str] = None): # RUF013 - 29 |+def f(arg: typing.List[str] | None = None): # RUF013 -30 30 | pass -31 31 | -32 32 | - -RUF013_0.py:33:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -33 | def f(arg: Tuple[str] = None): # RUF013 - | ^^^^^^^^^^ RUF013 -34 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -30 30 | pass -31 31 | -32 32 | -33 |-def f(arg: Tuple[str] = None): # RUF013 - 33 |+def f(arg: Tuple[str] | None = None): # RUF013 -34 34 | pass -35 35 | -36 36 | - -RUF013_0.py:71:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -71 | def f(arg: Union = None): # RUF013 - | ^^^^^ RUF013 -72 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -68 68 | pass -69 69 | -70 70 | -71 |-def f(arg: Union = None): # RUF013 - 71 |+def f(arg: Union | None = None): # RUF013 -72 72 | pass -73 73 | -74 74 | - -RUF013_0.py:75:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -75 | def f(arg: Union[int] = None): # RUF013 - | ^^^^^^^^^^ RUF013 -76 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -72 72 | pass -73 73 | -74 74 | -75 |-def f(arg: Union[int] = None): # RUF013 - 75 |+def f(arg: Union[int] | None = None): # RUF013 -76 76 | pass -77 77 | -78 78 | - -RUF013_0.py:79:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -79 | def f(arg: Union[int, str] = None): # RUF013 - | ^^^^^^^^^^^^^^^ RUF013 -80 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -76 76 | pass -77 77 | -78 78 | -79 |-def f(arg: Union[int, str] = None): # RUF013 - 79 |+def f(arg: Union[int, str] | None = None): # RUF013 -80 80 | pass -81 81 | -82 82 | - -RUF013_0.py:83:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -83 | def f(arg: typing.Union[int, str] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^^^^ RUF013 -84 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -80 80 | pass -81 81 | -82 82 | -83 |-def f(arg: typing.Union[int, str] = None): # RUF013 - 83 |+def f(arg: typing.Union[int, str] | None = None): # RUF013 -84 84 | pass -85 85 | -86 86 | - -RUF013_0.py:102:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -102 | def f(arg: int | float = None): # RUF013 - | ^^^^^^^^^^^ RUF013 -103 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -99 99 | pass -100 100 | -101 101 | -102 |-def f(arg: int | float = None): # RUF013 - 102 |+def f(arg: int | float | None = None): # RUF013 -103 103 | pass -104 104 | -105 105 | - -RUF013_0.py:106:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -106 | def f(arg: int | float | str | bytes = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 -107 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -103 103 | pass -104 104 | -105 105 | -106 |-def f(arg: int | float | str | bytes = None): # RUF013 - 106 |+def f(arg: int | float | str | bytes | None = None): # RUF013 -107 107 | pass -108 108 | -109 109 | - -RUF013_0.py:125:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -125 | def f(arg: Literal[1] = None): # RUF013 - | ^^^^^^^^^^ RUF013 -126 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -122 122 | pass -123 123 | -124 124 | -125 |-def f(arg: Literal[1] = None): # RUF013 - 125 |+def f(arg: Literal[1] | None = None): # RUF013 -126 126 | pass -127 127 | -128 128 | - -RUF013_0.py:129:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -129 | def f(arg: Literal[1, "foo"] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^ RUF013 -130 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -126 126 | pass -127 127 | -128 128 | -129 |-def f(arg: Literal[1, "foo"] = None): # RUF013 - 129 |+def f(arg: Literal[1, "foo"] | None = None): # RUF013 -130 130 | pass -131 131 | -132 132 | - -RUF013_0.py:133:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -133 | def f(arg: typing.Literal[1, "foo", True] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 -134 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -130 130 | pass -131 131 | -132 132 | -133 |-def f(arg: typing.Literal[1, "foo", True] = None): # RUF013 - 133 |+def f(arg: typing.Literal[1, "foo", True] | None = None): # RUF013 -134 134 | pass -135 135 | -136 136 | - -RUF013_0.py:152:22: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -152 | def f(arg: Annotated[int, ...] = None): # RUF013 - | ^^^ RUF013 -153 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -149 149 | pass -150 150 | -151 151 | -152 |-def f(arg: Annotated[int, ...] = None): # RUF013 - 152 |+def f(arg: Annotated[int | None, ...] = None): # RUF013 -153 153 | pass -154 154 | -155 155 | - -RUF013_0.py:156:32: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -156 | def f(arg: Annotated[Annotated[int | str, ...], ...] = None): # RUF013 - | ^^^^^^^^^ RUF013 -157 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -153 153 | pass -154 154 | -155 155 | -156 |-def f(arg: Annotated[Annotated[int | str, ...], ...] = None): # RUF013 - 156 |+def f(arg: Annotated[Annotated[int | str | None, ...], ...] = None): # RUF013 -157 157 | pass -158 158 | -159 159 | - -RUF013_0.py:172:11: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -171 | def f( -172 | arg1: int = None, # RUF013 - | ^^^ RUF013 -173 | arg2: Union[int, float] = None, # RUF013 -174 | arg3: Literal[1, 2, 3] = None, # RUF013 - | - = help: Convert to `T | None` - -ℹ Suggested fix -169 169 | -170 170 | -171 171 | def f( -172 |- arg1: int = None, # RUF013 - 172 |+ arg1: int | None = None, # RUF013 -173 173 | arg2: Union[int, float] = None, # RUF013 -174 174 | arg3: Literal[1, 2, 3] = None, # RUF013 -175 175 | ): - -RUF013_0.py:173:11: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -171 | def f( -172 | arg1: int = None, # RUF013 -173 | arg2: Union[int, float] = None, # RUF013 - | ^^^^^^^^^^^^^^^^^ RUF013 -174 | arg3: Literal[1, 2, 3] = None, # RUF013 -175 | ): - | - = help: Convert to `T | None` - -ℹ Suggested fix -170 170 | -171 171 | def f( -172 172 | arg1: int = None, # RUF013 -173 |- arg2: Union[int, float] = None, # RUF013 - 173 |+ arg2: Union[int, float] | None = None, # RUF013 -174 174 | arg3: Literal[1, 2, 3] = None, # RUF013 -175 175 | ): -176 176 | pass - -RUF013_0.py:174:11: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -172 | arg1: int = None, # RUF013 -173 | arg2: Union[int, float] = None, # RUF013 -174 | arg3: Literal[1, 2, 3] = None, # RUF013 - | ^^^^^^^^^^^^^^^^ RUF013 -175 | ): -176 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -171 171 | def f( -172 172 | arg1: int = None, # RUF013 -173 173 | arg2: Union[int, float] = None, # RUF013 -174 |- arg3: Literal[1, 2, 3] = None, # RUF013 - 174 |+ arg3: Literal[1, 2, 3] | None = None, # RUF013 -175 175 | ): -176 176 | pass -177 177 | - -RUF013_0.py:202:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -202 | def f(arg: Union[Annotated[int, ...], Union[str, bytes]] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 -203 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -199 199 | pass -200 200 | -201 201 | -202 |-def f(arg: Union[Annotated[int, ...], Union[str, bytes]] = None): # RUF013 - 202 |+def f(arg: Union[Annotated[int, ...], Union[str, bytes]] | None = None): # RUF013 -203 203 | pass -204 204 | -205 205 | - -RUF013_0.py:209:13: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -209 | def f(arg: "int" = None): # RUF013 - | ^^^ RUF013 -210 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -206 206 | # Quoted -207 207 | -208 208 | -209 |-def f(arg: "int" = None): # RUF013 - 209 |+def f(arg: "int | None" = None): # RUF013 -210 210 | pass -211 211 | -212 212 | - -RUF013_0.py:213:13: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -213 | def f(arg: "str" = None): # RUF013 - | ^^^ RUF013 -214 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -210 210 | pass -211 211 | -212 212 | -213 |-def f(arg: "str" = None): # RUF013 - 213 |+def f(arg: "str | None" = None): # RUF013 -214 214 | pass -215 215 | -216 216 | - -RUF013_0.py:217:12: RUF013 PEP 484 prohibits implicit `Optional` - | -217 | def f(arg: "st" "r" = None): # RUF013 - | ^^^^^^^^ RUF013 -218 | pass - | - = help: Convert to `T | None` - -RUF013_0.py:225:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -225 | def f(arg: Union["int", "str"] = None): # RUF013 - | ^^^^^^^^^^^^^^^^^^^ RUF013 -226 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -222 222 | pass -223 223 | -224 224 | -225 |-def f(arg: Union["int", "str"] = None): # RUF013 - 225 |+def f(arg: Union["int", "str"] | None = None): # RUF013 -226 226 | pass -227 227 | -228 228 | - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF013_RUF013_1.py.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF013_RUF013_1.py.snap deleted file mode 100644 index 65568b66a3..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF013_RUF013_1.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF013_1.py:4:12: RUF013 [*] PEP 484 prohibits implicit `Optional` - | -4 | def f(arg: int = None): # RUF011 - | ^^^ RUF013 -5 | pass - | - = help: Convert to `T | None` - -ℹ Suggested fix -1 1 | # No `typing.Optional` import -2 2 | -3 3 | -4 |-def f(arg: int = None): # RUF011 - 4 |+def f(arg: int | None = None): # RUF011 -5 5 | pass - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF014_RUF014.py.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF014_RUF014.py.snap deleted file mode 100644 index f2457017e3..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF014_RUF014.py.snap +++ /dev/null @@ -1,249 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF014.py:3:5: RUF014 Unreachable code in after_return - | -1 | def after_return(): -2 | return "reachable" -3 | return "unreachable" - | ^^^^^^^^^^^^^^^^^^^^ RUF014 -4 | -5 | async def also_works_on_async_functions(): - | - -RUF014.py:7:5: RUF014 Unreachable code in also_works_on_async_functions - | -5 | async def also_works_on_async_functions(): -6 | return "reachable" -7 | return "unreachable" - | ^^^^^^^^^^^^^^^^^^^^ RUF014 -8 | -9 | def if_always_true(): - | - -RUF014.py:12:5: RUF014 Unreachable code in if_always_true - | -10 | if True: -11 | return "reachable" -12 | return "unreachable" - | ^^^^^^^^^^^^^^^^^^^^ RUF014 -13 | -14 | def if_always_false(): - | - -RUF014.py:16:9: RUF014 Unreachable code in if_always_false - | -14 | def if_always_false(): -15 | if False: -16 | return "unreachable" - | ^^^^^^^^^^^^^^^^^^^^ RUF014 -17 | return "reachable" - | - -RUF014.py:21:9: RUF014 Unreachable code in if_elif_always_false - | -19 | def if_elif_always_false(): -20 | if False: -21 | return "unreachable" - | ^^^^^^^^^^^^^^^^^^^^ RUF014 -22 | elif False: -23 | return "also unreachable" - | - -RUF014.py:23:9: RUF014 Unreachable code in if_elif_always_false - | -21 | return "unreachable" -22 | elif False: -23 | return "also unreachable" - | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF014 -24 | return "reachable" - | - -RUF014.py:28:9: RUF014 Unreachable code in if_elif_always_true - | -26 | def if_elif_always_true(): -27 | if False: -28 | return "unreachable" - | ^^^^^^^^^^^^^^^^^^^^ RUF014 -29 | elif True: -30 | return "reachable" - | - -RUF014.py:31:5: RUF014 Unreachable code in if_elif_always_true - | -29 | elif True: -30 | return "reachable" -31 | return "also unreachable" - | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF014 -32 | -33 | def ends_with_if(): - | - -RUF014.py:35:9: RUF014 Unreachable code in ends_with_if - | -33 | def ends_with_if(): -34 | if False: -35 | return "unreachable" - | ^^^^^^^^^^^^^^^^^^^^ RUF014 -36 | else: -37 | return "reachable" - | - -RUF014.py:42:5: RUF014 Unreachable code in infinite_loop - | -40 | while True: -41 | continue -42 | return "unreachable" - | ^^^^^^^^^^^^^^^^^^^^ RUF014 -43 | -44 | ''' TODO: we could determine these, but we don't yet. - | - -RUF014.py:75:5: RUF014 Unreachable code in match_wildcard - | -73 | case _: -74 | return "reachable" -75 | return "unreachable" - | ^^^^^^^^^^^^^^^^^^^^ RUF014 -76 | -77 | def match_case_and_wildcard(status): - | - -RUF014.py:83:5: RUF014 Unreachable code in match_case_and_wildcard - | -81 | case _: -82 | return "reachable" -83 | return "unreachable" - | ^^^^^^^^^^^^^^^^^^^^ RUF014 -84 | -85 | def raise_exception(): - | - -RUF014.py:87:5: RUF014 Unreachable code in raise_exception - | -85 | def raise_exception(): -86 | raise Exception -87 | return "unreachable" - | ^^^^^^^^^^^^^^^^^^^^ RUF014 -88 | -89 | def while_false(): - | - -RUF014.py:91:9: RUF014 Unreachable code in while_false - | -89 | def while_false(): -90 | while False: -91 | return "unreachable" - | ^^^^^^^^^^^^^^^^^^^^ RUF014 -92 | return "reachable" - | - -RUF014.py:96:9: RUF014 Unreachable code in while_false_else - | -94 | def while_false_else(): -95 | while False: -96 | return "unreachable" - | ^^^^^^^^^^^^^^^^^^^^ RUF014 -97 | else: -98 | return "reachable" - | - -RUF014.py:102:9: RUF014 Unreachable code in while_false_else_return - | -100 | def while_false_else_return(): -101 | while False: -102 | return "unreachable" - | ^^^^^^^^^^^^^^^^^^^^ RUF014 -103 | else: -104 | return "reachable" - | - -RUF014.py:105:5: RUF014 Unreachable code in while_false_else_return - | -103 | else: -104 | return "reachable" -105 | return "also unreachable" - | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF014 -106 | -107 | def while_true(): - | - -RUF014.py:110:5: RUF014 Unreachable code in while_true - | -108 | while True: -109 | return "reachable" -110 | return "unreachable" - | ^^^^^^^^^^^^^^^^^^^^ RUF014 -111 | -112 | def while_true_else(): - | - -RUF014.py:116:9: RUF014 Unreachable code in while_true_else - | -114 | return "reachable" -115 | else: -116 | return "unreachable" - | ^^^^^^^^^^^^^^^^^^^^ RUF014 -117 | -118 | def while_true_else_return(): - | - -RUF014.py:122:9: RUF014 Unreachable code in while_true_else_return - | -120 | return "reachable" -121 | else: -122 | return "unreachable" - | ^^^^^^^^^^^^^^^^^^^^ RUF014 -123 | return "also unreachable" - | - -RUF014.py:123:5: RUF014 Unreachable code in while_true_else_return - | -121 | else: -122 | return "unreachable" -123 | return "also unreachable" - | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF014 -124 | -125 | def while_false_var_i(): - | - -RUF014.py:128:9: RUF014 Unreachable code in while_false_var_i - | -126 | i = 0 -127 | while False: -128 | i += 1 - | ^^^^^^ RUF014 -129 | return i - | - -RUF014.py:135:5: RUF014 Unreachable code in while_true_var_i - | -133 | while True: -134 | i += 1 -135 | return i - | ^^^^^^^^ RUF014 -136 | -137 | def while_infinite(): - | - -RUF014.py:140:5: RUF014 Unreachable code in while_infinite - | -138 | while True: -139 | pass -140 | return "unreachable" - | ^^^^^^^^^^^^^^^^^^^^ RUF014 -141 | -142 | def while_if_true(): - | - -RUF014.py:146:5: RUF014 Unreachable code in while_if_true - | -144 | if True: -145 | return "reachable" -146 | return "unreachable" - | ^^^^^^^^^^^^^^^^^^^^ RUF014 -147 | -148 | # Test case found in the Bokeh repository that trigger a false positive. - | - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF015_RUF015.py.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF015_RUF015.py.snap deleted file mode 100644 index e8f01fe1a2..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF015_RUF015.py.snap +++ /dev/null @@ -1,254 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF015.py:4:1: RUF015 [*] Prefer `next(iter(x))` over single element slice - | -3 | # RUF015 -4 | list(x)[0] - | ^^^^^^^^^^ RUF015 -5 | tuple(x)[0] -6 | list(i for i in x)[0] - | - = help: Replace with `next(iter(x))` - -ℹ Suggested fix -1 1 | x = range(10) -2 2 | -3 3 | # RUF015 -4 |-list(x)[0] - 4 |+next(iter(x)) -5 5 | tuple(x)[0] -6 6 | list(i for i in x)[0] -7 7 | [i for i in x][0] - -RUF015.py:5:1: RUF015 [*] Prefer `next(iter(x))` over single element slice - | -3 | # RUF015 -4 | list(x)[0] -5 | tuple(x)[0] - | ^^^^^^^^^^^ RUF015 -6 | list(i for i in x)[0] -7 | [i for i in x][0] - | - = help: Replace with `next(iter(x))` - -ℹ Suggested fix -2 2 | -3 3 | # RUF015 -4 4 | list(x)[0] -5 |-tuple(x)[0] - 5 |+next(iter(x)) -6 6 | list(i for i in x)[0] -7 7 | [i for i in x][0] -8 8 | - -RUF015.py:6:1: RUF015 [*] Prefer `next(iter(x))` over single element slice - | -4 | list(x)[0] -5 | tuple(x)[0] -6 | list(i for i in x)[0] - | ^^^^^^^^^^^^^^^^^^^^^ RUF015 -7 | [i for i in x][0] - | - = help: Replace with `next(iter(x))` - -ℹ Suggested fix -3 3 | # RUF015 -4 4 | list(x)[0] -5 5 | tuple(x)[0] -6 |-list(i for i in x)[0] - 6 |+next(iter(x)) -7 7 | [i for i in x][0] -8 8 | -9 9 | # OK (not indexing (solely) the first element) - -RUF015.py:7:1: RUF015 [*] Prefer `next(iter(x))` over single element slice - | -5 | tuple(x)[0] -6 | list(i for i in x)[0] -7 | [i for i in x][0] - | ^^^^^^^^^^^^^^^^^ RUF015 -8 | -9 | # OK (not indexing (solely) the first element) - | - = help: Replace with `next(iter(x))` - -ℹ Suggested fix -4 4 | list(x)[0] -5 5 | tuple(x)[0] -6 6 | list(i for i in x)[0] -7 |-[i for i in x][0] - 7 |+next(iter(x)) -8 8 | -9 9 | # OK (not indexing (solely) the first element) -10 10 | list(x) - -RUF015.py:29:1: RUF015 [*] Prefer `next(i + 1 for i in x)` over single element slice - | -28 | # RUF015 (doesn't mirror the underlying list) -29 | [i + 1 for i in x][0] - | ^^^^^^^^^^^^^^^^^^^^^ RUF015 -30 | [i for i in x if i > 5][0] -31 | [(i, i + 1) for i in x][0] - | - = help: Replace with `next(i + 1 for i in x)` - -ℹ Suggested fix -26 26 | [i for i in x][::] -27 27 | -28 28 | # RUF015 (doesn't mirror the underlying list) -29 |-[i + 1 for i in x][0] - 29 |+next(i + 1 for i in x) -30 30 | [i for i in x if i > 5][0] -31 31 | [(i, i + 1) for i in x][0] -32 32 | - -RUF015.py:30:1: RUF015 [*] Prefer `next(i for i in x if i > 5)` over single element slice - | -28 | # RUF015 (doesn't mirror the underlying list) -29 | [i + 1 for i in x][0] -30 | [i for i in x if i > 5][0] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF015 -31 | [(i, i + 1) for i in x][0] - | - = help: Replace with `next(i for i in x if i > 5)` - -ℹ Suggested fix -27 27 | -28 28 | # RUF015 (doesn't mirror the underlying list) -29 29 | [i + 1 for i in x][0] -30 |-[i for i in x if i > 5][0] - 30 |+next(i for i in x if i > 5) -31 31 | [(i, i + 1) for i in x][0] -32 32 | -33 33 | # RUF015 (multiple generators) - -RUF015.py:31:1: RUF015 [*] Prefer `next((i, i + 1) for i in x)` over single element slice - | -29 | [i + 1 for i in x][0] -30 | [i for i in x if i > 5][0] -31 | [(i, i + 1) for i in x][0] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF015 -32 | -33 | # RUF015 (multiple generators) - | - = help: Replace with `next((i, i + 1) for i in x)` - -ℹ Suggested fix -28 28 | # RUF015 (doesn't mirror the underlying list) -29 29 | [i + 1 for i in x][0] -30 30 | [i for i in x if i > 5][0] -31 |-[(i, i + 1) for i in x][0] - 31 |+next((i, i + 1) for i in x) -32 32 | -33 33 | # RUF015 (multiple generators) -34 34 | y = range(10) - -RUF015.py:35:1: RUF015 [*] Prefer `next(i + j for i in x for j in y)` over single element slice - | -33 | # RUF015 (multiple generators) -34 | y = range(10) -35 | [i + j for i in x for j in y][0] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF015 -36 | -37 | # RUF015 - | - = help: Replace with `next(i + j for i in x for j in y)` - -ℹ Suggested fix -32 32 | -33 33 | # RUF015 (multiple generators) -34 34 | y = range(10) -35 |-[i + j for i in x for j in y][0] - 35 |+next(i + j for i in x for j in y) -36 36 | -37 37 | # RUF015 -38 38 | list(range(10))[0] - -RUF015.py:38:1: RUF015 [*] Prefer `next(iter(range(10)))` over single element slice - | -37 | # RUF015 -38 | list(range(10))[0] - | ^^^^^^^^^^^^^^^^^^ RUF015 -39 | list(x.y)[0] -40 | list(x["y"])[0] - | - = help: Replace with `next(iter(range(10)))` - -ℹ Suggested fix -35 35 | [i + j for i in x for j in y][0] -36 36 | -37 37 | # RUF015 -38 |-list(range(10))[0] - 38 |+next(iter(range(10))) -39 39 | list(x.y)[0] -40 40 | list(x["y"])[0] -41 41 | - -RUF015.py:39:1: RUF015 [*] Prefer `next(iter(x.y))` over single element slice - | -37 | # RUF015 -38 | list(range(10))[0] -39 | list(x.y)[0] - | ^^^^^^^^^^^^ RUF015 -40 | list(x["y"])[0] - | - = help: Replace with `next(iter(x.y))` - -ℹ Suggested fix -36 36 | -37 37 | # RUF015 -38 38 | list(range(10))[0] -39 |-list(x.y)[0] - 39 |+next(iter(x.y)) -40 40 | list(x["y"])[0] -41 41 | -42 42 | # RUF015 (multi-line) - -RUF015.py:40:1: RUF015 [*] Prefer `next(iter(x["y"]))` over single element slice - | -38 | list(range(10))[0] -39 | list(x.y)[0] -40 | list(x["y"])[0] - | ^^^^^^^^^^^^^^^ RUF015 -41 | -42 | # RUF015 (multi-line) - | - = help: Replace with `next(iter(x["y"]))` - -ℹ Suggested fix -37 37 | # RUF015 -38 38 | list(range(10))[0] -39 39 | list(x.y)[0] -40 |-list(x["y"])[0] - 40 |+next(iter(x["y"])) -41 41 | -42 42 | # RUF015 (multi-line) -43 43 | revision_heads_map_ast = [ - -RUF015.py:43:26: RUF015 [*] Prefer `next(...)` over single element slice - | -42 | # RUF015 (multi-line) -43 | revision_heads_map_ast = [ - | __________________________^ -44 | | a -45 | | for a in revision_heads_map_ast_obj.body -46 | | if isinstance(a, ast.Assign) and a.targets[0].id == "REVISION_HEADS_MAP" -47 | | ][0] - | |____^ RUF015 - | - = help: Replace with `next(...)` - -ℹ Suggested fix -40 40 | list(x["y"])[0] -41 41 | -42 42 | # RUF015 (multi-line) -43 |-revision_heads_map_ast = [ - 43 |+revision_heads_map_ast = next( -44 44 | a -45 45 | for a in revision_heads_map_ast_obj.body -46 46 | if isinstance(a, ast.Assign) and a.targets[0].id == "REVISION_HEADS_MAP" -47 |-][0] - 47 |+) - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF016_RUF016.py.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF016_RUF016.py.snap deleted file mode 100644 index bf56f0d36c..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF016_RUF016.py.snap +++ /dev/null @@ -1,379 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF016.py:20:13: RUF016 Indexed access to type `str` uses type `str` instead of an integer or slice. - | -19 | # Should emit for invalid access on strings -20 | var = "abc"["x"] - | ^^^ RUF016 -21 | var = f"abc"["x"] - | - -RUF016.py:21:14: RUF016 Indexed access to type `str` uses type `str` instead of an integer or slice. - | -19 | # Should emit for invalid access on strings -20 | var = "abc"["x"] -21 | var = f"abc"["x"] - | ^^^ RUF016 -22 | -23 | # Should emit for invalid access on bytes - | - -RUF016.py:24:14: RUF016 Indexed access to type `bytes` uses type `str` instead of an integer or slice. - | -23 | # Should emit for invalid access on bytes -24 | var = b"abc"["x"] - | ^^^ RUF016 -25 | -26 | # Should emit for invalid access on lists and tuples - | - -RUF016.py:27:17: RUF016 Indexed access to type `list` uses type `str` instead of an integer or slice. - | -26 | # Should emit for invalid access on lists and tuples -27 | var = [1, 2, 3]["x"] - | ^^^ RUF016 -28 | var = (1, 2, 3)["x"] - | - -RUF016.py:28:17: RUF016 Indexed access to type `tuple` uses type `str` instead of an integer or slice. - | -26 | # Should emit for invalid access on lists and tuples -27 | var = [1, 2, 3]["x"] -28 | var = (1, 2, 3)["x"] - | ^^^ RUF016 -29 | -30 | # Should emit for invalid access on list comprehensions - | - -RUF016.py:31:30: RUF016 Indexed access to type `list comprehension` uses type `str` instead of an integer or slice. - | -30 | # Should emit for invalid access on list comprehensions -31 | var = [x for x in range(10)]["x"] - | ^^^ RUF016 -32 | -33 | # Should emit for invalid access using tuple - | - -RUF016.py:34:13: RUF016 Indexed access to type `str` uses type `tuple` instead of an integer or slice. - | -33 | # Should emit for invalid access using tuple -34 | var = "abc"[1, 2] - | ^^^^ RUF016 -35 | -36 | # Should emit for invalid access using string - | - -RUF016.py:37:14: RUF016 Indexed access to type `list` uses type `str` instead of an integer or slice. - | -36 | # Should emit for invalid access using string -37 | var = [1, 2]["x"] - | ^^^ RUF016 -38 | -39 | # Should emit for invalid access using float - | - -RUF016.py:40:14: RUF016 Indexed access to type `list` uses type `float` instead of an integer or slice. - | -39 | # Should emit for invalid access using float -40 | var = [1, 2][0.25] - | ^^^^ RUF016 -41 | -42 | # Should emit for invalid access using dict - | - -RUF016.py:43:14: RUF016 Indexed access to type `list` uses type `dict` instead of an integer or slice. - | -42 | # Should emit for invalid access using dict -43 | var = [1, 2][{"x": "y"}] - | ^^^^^^^^^^ RUF016 -44 | -45 | # Should emit for invalid access using dict comp - | - -RUF016.py:46:14: RUF016 Indexed access to type `list` uses type `dict comprehension` instead of an integer or slice. - | -45 | # Should emit for invalid access using dict comp -46 | var = [1, 2][{x: "y" for x in range(2)}] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF016 -47 | -48 | # Should emit for invalid access using list - | - -RUF016.py:49:14: RUF016 Indexed access to type `list` uses type `tuple` instead of an integer or slice. - | -48 | # Should emit for invalid access using list -49 | var = [1, 2][2, 3] - | ^^^^ RUF016 -50 | -51 | # Should emit for invalid access using list comp - | - -RUF016.py:52:14: RUF016 Indexed access to type `list` uses type `list comprehension` instead of an integer or slice. - | -51 | # Should emit for invalid access using list comp -52 | var = [1, 2][[x for x in range(2)]] - | ^^^^^^^^^^^^^^^^^^^^^ RUF016 -53 | -54 | # Should emit on invalid access using set - | - -RUF016.py:55:14: RUF016 Indexed access to type `list` uses type `set` instead of an integer or slice. - | -54 | # Should emit on invalid access using set -55 | var = [1, 2][{"x", "y"}] - | ^^^^^^^^^^ RUF016 -56 | -57 | # Should emit on invalid access using set comp - | - -RUF016.py:58:14: RUF016 Indexed access to type `list` uses type `set comprehension` instead of an integer or slice. - | -57 | # Should emit on invalid access using set comp -58 | var = [1, 2][{x for x in range(2)}] - | ^^^^^^^^^^^^^^^^^^^^^ RUF016 -59 | -60 | # Should emit on invalid access using bytes - | - -RUF016.py:61:14: RUF016 Indexed access to type `list` uses type `bytes` instead of an integer or slice. - | -60 | # Should emit on invalid access using bytes -61 | var = [1, 2][b"x"] - | ^^^^ RUF016 -62 | -63 | # Should emit for non-integer slice start - | - -RUF016.py:64:17: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer. - | -63 | # Should emit for non-integer slice start -64 | var = [1, 2, 3]["x":2] - | ^^^ RUF016 -65 | var = [1, 2, 3][f"x":2] -66 | var = [1, 2, 3][1.2:2] - | - -RUF016.py:65:17: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer. - | -63 | # Should emit for non-integer slice start -64 | var = [1, 2, 3]["x":2] -65 | var = [1, 2, 3][f"x":2] - | ^^^^ RUF016 -66 | var = [1, 2, 3][1.2:2] -67 | var = [1, 2, 3][{"x"}:2] - | - -RUF016.py:66:17: RUF016 Slice in indexed access to type `list` uses type `float` instead of an integer. - | -64 | var = [1, 2, 3]["x":2] -65 | var = [1, 2, 3][f"x":2] -66 | var = [1, 2, 3][1.2:2] - | ^^^ RUF016 -67 | var = [1, 2, 3][{"x"}:2] -68 | var = [1, 2, 3][{x for x in range(2)}:2] - | - -RUF016.py:67:17: RUF016 Slice in indexed access to type `list` uses type `set` instead of an integer. - | -65 | var = [1, 2, 3][f"x":2] -66 | var = [1, 2, 3][1.2:2] -67 | var = [1, 2, 3][{"x"}:2] - | ^^^^^ RUF016 -68 | var = [1, 2, 3][{x for x in range(2)}:2] -69 | var = [1, 2, 3][{"x": x for x in range(2)}:2] - | - -RUF016.py:68:17: RUF016 Slice in indexed access to type `list` uses type `set comprehension` instead of an integer. - | -66 | var = [1, 2, 3][1.2:2] -67 | var = [1, 2, 3][{"x"}:2] -68 | var = [1, 2, 3][{x for x in range(2)}:2] - | ^^^^^^^^^^^^^^^^^^^^^ RUF016 -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.py:69:17: RUF016 Slice in indexed access to type `list` uses type `dict comprehension` instead of an integer. - | -67 | var = [1, 2, 3][{"x"}:2] -68 | var = [1, 2, 3][{x for x in range(2)}:2] -69 | var = [1, 2, 3][{"x": x for x in range(2)}:2] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF016 -70 | var = [1, 2, 3][[x for x in range(2)]:2] - | - -RUF016.py:70:17: RUF016 Slice in indexed access to type `list` uses type `list comprehension` instead of an integer. - | -68 | var = [1, 2, 3][{x for x in range(2)}:2] -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 | -72 | # Should emit for non-integer slice end - | - -RUF016.py:73:19: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer. - | -72 | # Should emit for non-integer slice end -73 | var = [1, 2, 3][0:"x"] - | ^^^ RUF016 -74 | var = [1, 2, 3][0:f"x"] -75 | var = [1, 2, 3][0:1.2] - | - -RUF016.py:74:19: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer. - | -72 | # Should emit for non-integer slice end -73 | var = [1, 2, 3][0:"x"] -74 | var = [1, 2, 3][0:f"x"] - | ^^^^ RUF016 -75 | var = [1, 2, 3][0:1.2] -76 | var = [1, 2, 3][0:{"x"}] - | - -RUF016.py:75:19: RUF016 Slice in indexed access to type `list` uses type `float` instead of an integer. - | -73 | var = [1, 2, 3][0:"x"] -74 | var = [1, 2, 3][0:f"x"] -75 | var = [1, 2, 3][0:1.2] - | ^^^ RUF016 -76 | var = [1, 2, 3][0:{"x"}] -77 | var = [1, 2, 3][0:{x for x in range(2)}] - | - -RUF016.py:76:19: RUF016 Slice in indexed access to type `list` uses type `set` instead of an integer. - | -74 | var = [1, 2, 3][0:f"x"] -75 | var = [1, 2, 3][0:1.2] -76 | var = [1, 2, 3][0:{"x"}] - | ^^^^^ RUF016 -77 | var = [1, 2, 3][0:{x for x in range(2)}] -78 | var = [1, 2, 3][0:{"x": x for x in range(2)}] - | - -RUF016.py:77:19: RUF016 Slice in indexed access to type `list` uses type `set comprehension` instead of an integer. - | -75 | var = [1, 2, 3][0:1.2] -76 | var = [1, 2, 3][0:{"x"}] -77 | var = [1, 2, 3][0:{x for x in range(2)}] - | ^^^^^^^^^^^^^^^^^^^^^ RUF016 -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.py:78:19: RUF016 Slice in indexed access to type `list` uses type `dict comprehension` instead of an integer. - | -76 | var = [1, 2, 3][0:{"x"}] -77 | var = [1, 2, 3][0:{x for x in range(2)}] -78 | var = [1, 2, 3][0:{"x": x for x in range(2)}] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF016 -79 | var = [1, 2, 3][0:[x for x in range(2)]] - | - -RUF016.py:79:19: RUF016 Slice in indexed access to type `list` uses type `list comprehension` instead of an integer. - | -77 | var = [1, 2, 3][0:{x for x in range(2)}] -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 | -81 | # Should emit for non-integer slice step - | - -RUF016.py:82:21: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer. - | -81 | # Should emit for non-integer slice step -82 | var = [1, 2, 3][0:1:"x"] - | ^^^ RUF016 -83 | var = [1, 2, 3][0:1:f"x"] -84 | var = [1, 2, 3][0:1:1.2] - | - -RUF016.py:83:21: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer. - | -81 | # Should emit for non-integer slice step -82 | var = [1, 2, 3][0:1:"x"] -83 | var = [1, 2, 3][0:1:f"x"] - | ^^^^ RUF016 -84 | var = [1, 2, 3][0:1:1.2] -85 | var = [1, 2, 3][0:1:{"x"}] - | - -RUF016.py:84:21: RUF016 Slice in indexed access to type `list` uses type `float` instead of an integer. - | -82 | var = [1, 2, 3][0:1:"x"] -83 | var = [1, 2, 3][0:1:f"x"] -84 | var = [1, 2, 3][0:1:1.2] - | ^^^ RUF016 -85 | var = [1, 2, 3][0:1:{"x"}] -86 | var = [1, 2, 3][0:1:{x for x in range(2)}] - | - -RUF016.py:85:21: RUF016 Slice in indexed access to type `list` uses type `set` instead of an integer. - | -83 | var = [1, 2, 3][0:1:f"x"] -84 | var = [1, 2, 3][0:1:1.2] -85 | var = [1, 2, 3][0:1:{"x"}] - | ^^^^^ RUF016 -86 | var = [1, 2, 3][0:1:{x for x in range(2)}] -87 | var = [1, 2, 3][0:1:{"x": x for x in range(2)}] - | - -RUF016.py:86:21: RUF016 Slice in indexed access to type `list` uses type `set comprehension` instead of an integer. - | -84 | var = [1, 2, 3][0:1:1.2] -85 | var = [1, 2, 3][0:1:{"x"}] -86 | var = [1, 2, 3][0:1:{x for x in range(2)}] - | ^^^^^^^^^^^^^^^^^^^^^ RUF016 -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.py:87:21: RUF016 Slice in indexed access to type `list` uses type `dict comprehension` instead of an integer. - | -85 | var = [1, 2, 3][0:1:{"x"}] -86 | var = [1, 2, 3][0:1:{x for x in range(2)}] -87 | var = [1, 2, 3][0:1:{"x": x for x in range(2)}] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF016 -88 | var = [1, 2, 3][0:1:[x for x in range(2)]] - | - -RUF016.py:88:21: RUF016 Slice in indexed access to type `list` uses type `list comprehension` instead of an integer. - | -86 | var = [1, 2, 3][0:1:{x for x in range(2)}] -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 | -90 | # Should emit for non-integer slice start and end; should emit twice with specific ranges - | - -RUF016.py:91:17: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer. - | -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 | -93 | # Should emit once for repeated invalid access - | - -RUF016.py:91:21: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer. - | -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 | -93 | # Should emit once for repeated invalid access - | - -RUF016.py:94:17: RUF016 Indexed access to type `list` uses type `str` instead of an integer or slice. - | -93 | # Should emit once for repeated invalid access -94 | var = [1, 2, 3]["x"]["y"]["z"] - | ^^^ RUF016 -95 | -96 | # Cannot emit on invalid access using variable in index - | - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF017_RUF017.py.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF017_RUF017.py.snap deleted file mode 100644 index 4cda3a5c80..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF017_RUF017.py.snap +++ /dev/null @@ -1,150 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF017.py:5:1: RUF017 [*] Avoid quadratic list summation - | -4 | # RUF017 -5 | sum([x, y], start=[]) - | ^^^^^^^^^^^^^^^^^^^^^ RUF017 -6 | sum([x, y], []) -7 | sum([[1, 2, 3], [4, 5, 6]], start=[]) - | - = help: Replace with `functools.reduce` - -ℹ Suggested fix - 1 |+import functools - 2 |+import operator -1 3 | x = [1, 2, 3] -2 4 | y = [4, 5, 6] -3 5 | -4 6 | # RUF017 -5 |-sum([x, y], start=[]) - 7 |+functools.reduce(operator.iadd, [x, y], []) -6 8 | sum([x, y], []) -7 9 | sum([[1, 2, 3], [4, 5, 6]], start=[]) -8 10 | sum([[1, 2, 3], [4, 5, 6]], []) - -RUF017.py:6:1: RUF017 [*] Avoid quadratic list summation - | -4 | # RUF017 -5 | sum([x, y], start=[]) -6 | sum([x, y], []) - | ^^^^^^^^^^^^^^^ RUF017 -7 | sum([[1, 2, 3], [4, 5, 6]], start=[]) -8 | sum([[1, 2, 3], [4, 5, 6]], []) - | - = help: Replace with `functools.reduce` - -ℹ Suggested fix - 1 |+import functools - 2 |+import operator -1 3 | x = [1, 2, 3] -2 4 | y = [4, 5, 6] -3 5 | -4 6 | # RUF017 -5 7 | sum([x, y], start=[]) -6 |-sum([x, y], []) - 8 |+functools.reduce(operator.iadd, [x, y], []) -7 9 | sum([[1, 2, 3], [4, 5, 6]], start=[]) -8 10 | sum([[1, 2, 3], [4, 5, 6]], []) -9 11 | sum([[1, 2, 3], [4, 5, 6]], - -RUF017.py:7:1: RUF017 [*] Avoid quadratic list summation - | -5 | sum([x, y], start=[]) -6 | sum([x, y], []) -7 | sum([[1, 2, 3], [4, 5, 6]], start=[]) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF017 -8 | sum([[1, 2, 3], [4, 5, 6]], []) -9 | sum([[1, 2, 3], [4, 5, 6]], - | - = help: Replace with `functools.reduce` - -ℹ Suggested fix - 1 |+import functools - 2 |+import operator -1 3 | x = [1, 2, 3] -2 4 | y = [4, 5, 6] -3 5 | -4 6 | # RUF017 -5 7 | sum([x, y], start=[]) -6 8 | sum([x, y], []) -7 |-sum([[1, 2, 3], [4, 5, 6]], start=[]) - 9 |+functools.reduce(operator.iadd, [[1, 2, 3], [4, 5, 6]], []) -8 10 | sum([[1, 2, 3], [4, 5, 6]], []) -9 11 | sum([[1, 2, 3], [4, 5, 6]], -10 12 | []) - -RUF017.py:8:1: RUF017 [*] Avoid quadratic list summation - | - 6 | sum([x, y], []) - 7 | sum([[1, 2, 3], [4, 5, 6]], start=[]) - 8 | sum([[1, 2, 3], [4, 5, 6]], []) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF017 - 9 | sum([[1, 2, 3], [4, 5, 6]], -10 | []) - | - = help: Replace with `functools.reduce` - -ℹ Suggested fix - 1 |+import functools - 2 |+import operator -1 3 | x = [1, 2, 3] -2 4 | y = [4, 5, 6] -3 5 | --------------------------------------------------------------------------------- -5 7 | sum([x, y], start=[]) -6 8 | sum([x, y], []) -7 9 | sum([[1, 2, 3], [4, 5, 6]], start=[]) -8 |-sum([[1, 2, 3], [4, 5, 6]], []) - 10 |+functools.reduce(operator.iadd, [[1, 2, 3], [4, 5, 6]], []) -9 11 | sum([[1, 2, 3], [4, 5, 6]], -10 12 | []) -11 13 | - -RUF017.py:9:1: RUF017 [*] Avoid quadratic list summation - | - 7 | sum([[1, 2, 3], [4, 5, 6]], start=[]) - 8 | sum([[1, 2, 3], [4, 5, 6]], []) - 9 | / sum([[1, 2, 3], [4, 5, 6]], -10 | | []) - | |_______^ RUF017 -11 | -12 | # OK - | - = help: Replace with `functools.reduce` - -ℹ Suggested fix - 1 |+import functools - 2 |+import operator -1 3 | x = [1, 2, 3] -2 4 | y = [4, 5, 6] -3 5 | --------------------------------------------------------------------------------- -6 8 | sum([x, y], []) -7 9 | sum([[1, 2, 3], [4, 5, 6]], start=[]) -8 10 | sum([[1, 2, 3], [4, 5, 6]], []) -9 |-sum([[1, 2, 3], [4, 5, 6]], -10 |- []) - 11 |+functools.reduce(operator.iadd, [[1, 2, 3], [4, 5, 6]], []) -11 12 | -12 13 | # OK -13 14 | sum([x, y]) - -RUF017.py:21:5: RUF017 [*] Avoid quadratic list summation - | -19 | import functools, operator -20 | -21 | sum([x, y], []) - | ^^^^^^^^^^^^^^^ RUF017 - | - = help: Replace with `functools.reduce` - -ℹ Suggested fix -18 18 | def func(): -19 19 | import functools, operator -20 20 | -21 |- sum([x, y], []) - 21 |+ functools.reduce(operator.iadd, [x, y], []) - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF200_bleach.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF200_bleach.snap deleted file mode 100644 index ab117d5dbe..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF200_bleach.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -pyproject.toml:5:16: RUF200 Failed to parse pyproject.toml: Version specifier `>=1.1.0<1.2` doesn't match PEP 440 rules -tinycss2>=1.1.0<1.2 - ^^^^^^^^^^^ - | -3 | version = "0.1.0" -4 | # There's a comma missing here -5 | dependencies = [ - | ________________^ -6 | | "tinycss2>=1.1.0<1.2", -7 | | ] - | |_^ RUF200 - | - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF200_invalid_author.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF200_invalid_author.snap deleted file mode 100644 index 403a523017..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF200_invalid_author.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -pyproject.toml:6:84: RUF200 Failed to parse pyproject.toml: invalid type: integer `1`, expected a string - | -4 | # Ensure that the spans from toml handle utf-8 correctly -5 | authors = [ -6 | { name = "Z͑ͫ̓ͪ̂ͫ̽͏̴̙̤̞͉͚̯̞̠͍A̴̵̜̰͔ͫ͗͢L̠ͨͧͩ͘G̴̻͈͍͔̹̑͗̎̅͛́Ǫ̵̹̻̝̳͂̌̌͘", email = 1 } - | ^ RUF200 -7 | ] - | - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF200_maturin.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF200_maturin.snap deleted file mode 100644 index e51f71f811..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF200_maturin.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF200_maturin_gh_1615.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF200_maturin_gh_1615.snap deleted file mode 100644 index 48972593ee..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__RUF200_maturin_gh_1615.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -pyproject.toml:9:17: RUF200 Failed to parse pyproject.toml: wanted string or table - | - 7 | [project] - 8 | name = "..." - 9 | license-files = [ "license.txt",] - | ^^^^^^^^^^^^^^^^^ RUF200 -10 | requires-python = ">=3.8" -11 | requires-dist = [ "maturin>=0.14", "...",] - | - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__confusables.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__confusables.snap deleted file mode 100644 index e5df2e7ca5..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__confusables.snap +++ /dev/null @@ -1,62 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -confusables.py:1:6: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? - | -1 | x = "𝐁ad string" - | ^ RUF001 -2 | y = "−" - | - -confusables.py:6:56: RUF002 Docstring contains ambiguous `)` (FULLWIDTH RIGHT PARENTHESIS). Did you mean `)` (RIGHT PARENTHESIS)? - | -5 | def f(): -6 | """Here's a docstring with an unusual parenthesis: )""" - | ^^ RUF002 -7 | # And here's a comment with an unusual punctuation mark: ᜵ -8 | ... - | - -confusables.py:7:62: RUF003 Comment contains ambiguous `᜵` (PHILIPPINE SINGLE PUNCTUATION). Did you mean `/` (SOLIDUS)? - | -5 | def f(): -6 | """Here's a docstring with an unusual parenthesis: )""" -7 | # And here's a comment with an unusual punctuation mark: ᜵ - | ^ RUF003 -8 | ... - | - -confusables.py:17:6: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? - | -17 | x = "𝐁ad string" - | ^ RUF001 -18 | x = "−" - | - -confusables.py:26:10: RUF001 String contains ambiguous `α` (GREEK SMALL LETTER ALPHA). Did you mean `a` (LATIN SMALL LETTER A)? - | -24 | # The first word should be ignored, while the second should be included, since it -25 | # contains ASCII. -26 | x = "βα Bαd" - | ^ RUF001 -27 | -28 | # The two characters should be flagged here. The first character is a "word" - | - -confusables.py:31:6: RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LETTER ER). Did you mean `P` (LATIN CAPITAL LETTER P)? - | -29 | # consisting of a single ambiguous character, while the second character is a "word -30 | # boundary" (whitespace) that it itself ambiguous. -31 | x = "Р усский" - | ^ RUF001 - | - -confusables.py:31:7: RUF001 String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? - | -29 | # consisting of a single ambiguous character, while the second character is a "word -30 | # boundary" (whitespace) that it itself ambiguous. -31 | x = "Р усский" - | ^ RUF001 - | - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__flake8_noqa.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__flake8_noqa.snap deleted file mode 100644 index e51f71f811..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__flake8_noqa.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__noqa.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__noqa.snap deleted file mode 100644 index f82bd63b9b..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__noqa.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -noqa.py:23:5: F841 [*] Local variable `I` is assigned to but never used - | -21 | def f(): -22 | # Only `E741` should be ignored by the `noqa`. -23 | I = 1 # noqa: E741.F841 - | ^ F841 - | - = help: Remove assignment to unused variable `I` - -ℹ Suggested fix -20 20 | -21 21 | def f(): -22 22 | # Only `E741` should be ignored by the `noqa`. -23 |- I = 1 # noqa: E741.F841 - 23 |+ pass # noqa: E741.F841 - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__redirects.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__redirects.snap deleted file mode 100644 index e51f71f811..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__redirects.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_0.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_0.snap deleted file mode 100644 index 96a0369c89..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_0.snap +++ /dev/null @@ -1,267 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF100_0.py:9:12: RUF100 [*] Unused blanket `noqa` directive - | - 8 | # Invalid - 9 | c = 1 # noqa - | ^^^^^^ RUF100 -10 | print(c) - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -6 6 | b = 2 # noqa: F841 -7 7 | -8 8 | # Invalid -9 |- c = 1 # noqa - 9 |+ c = 1 -10 10 | print(c) -11 11 | -12 12 | # Invalid - -RUF100_0.py:13:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) - | -12 | # Invalid -13 | d = 1 # noqa: E501 - | ^^^^^^^^^^^^ RUF100 -14 | -15 | # Invalid - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -10 10 | print(c) -11 11 | -12 12 | # Invalid -13 |- d = 1 # noqa: E501 - 13 |+ d = 1 -14 14 | -15 15 | # Invalid -16 16 | d = 1 # noqa: F841, E501 - -RUF100_0.py:16:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `E501`) - | -15 | # Invalid -16 | d = 1 # noqa: F841, E501 - | ^^^^^^^^^^^^^^^^^^ RUF100 -17 | -18 | # Invalid (and unimplemented or not enabled) - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -13 13 | d = 1 # noqa: E501 -14 14 | -15 15 | # Invalid -16 |- d = 1 # noqa: F841, E501 - 16 |+ d = 1 -17 17 | -18 18 | # Invalid (and unimplemented or not enabled) -19 19 | d = 1 # noqa: F841, W191, F821 - -RUF100_0.py:19:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `W191`; non-enabled: `F821`) - | -18 | # Invalid (and unimplemented or not enabled) -19 | d = 1 # noqa: F841, W191, F821 - | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 -20 | -21 | # Invalid (but external) - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -16 16 | d = 1 # noqa: F841, E501 -17 17 | -18 18 | # Invalid (and unimplemented or not enabled) -19 |- d = 1 # noqa: F841, W191, F821 - 19 |+ d = 1 -20 20 | -21 21 | # Invalid (but external) -22 22 | d = 1 # noqa: F841, V101 - -RUF100_0.py:22:12: RUF100 [*] Unused `noqa` directive (unused: `F841`) - | -21 | # Invalid (but external) -22 | d = 1 # noqa: F841, V101 - | ^^^^^^^^^^^^^^^^^^ RUF100 -23 | -24 | # fmt: off - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -19 19 | d = 1 # noqa: F841, W191, F821 -20 20 | -21 21 | # Invalid (but external) -22 |- d = 1 # noqa: F841, V101 - 22 |+ d = 1 # noqa: V101 -23 23 | -24 24 | # fmt: off -25 25 | # Invalid - no space before # - -RUF100_0.py:26:10: RUF100 [*] Unused `noqa` directive (unused: `E501`) - | -24 | # fmt: off -25 | # Invalid - no space before # -26 | d = 1# noqa: E501 - | ^^^^^^^^^^^^ RUF100 -27 | -28 | # Invalid - many spaces before # - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -23 23 | -24 24 | # fmt: off -25 25 | # Invalid - no space before # -26 |- d = 1# noqa: E501 - 26 |+ d = 1 -27 27 | -28 28 | # Invalid - many spaces before # -29 29 | d = 1 # noqa: E501 - -RUF100_0.py:29:5: F841 [*] Local variable `d` is assigned to but never used - | -28 | # Invalid - many spaces before # -29 | d = 1 # noqa: E501 - | ^ F841 -30 | # fmt: on - | - = help: Remove assignment to unused variable `d` - -ℹ Suggested fix -26 26 | d = 1# noqa: E501 -27 27 | -28 28 | # Invalid - many spaces before # -29 |- d = 1 # noqa: E501 -30 29 | # fmt: on -31 30 | -32 31 | - -RUF100_0.py:29:33: RUF100 [*] Unused `noqa` directive (unused: `E501`) - | -28 | # Invalid - many spaces before # -29 | d = 1 # noqa: E501 - | ^^^^^^^^^^^^ RUF100 -30 | # fmt: on - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -26 26 | d = 1# noqa: E501 -27 27 | -28 28 | # Invalid - many spaces before # -29 |- d = 1 # noqa: E501 - 29 |+ d = 1 -30 30 | # fmt: on -31 31 | -32 32 | - -RUF100_0.py:55:6: RUF100 [*] Unused `noqa` directive (unused: `F841`) - | -54 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. -55 | """ # noqa: E501, F841 - | ^^^^^^^^^^^^^^^^^^ RUF100 -56 | -57 | # Invalid - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -52 52 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 -53 53 | -54 54 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. -55 |-""" # noqa: E501, F841 - 55 |+""" # noqa: E501 -56 56 | -57 57 | # Invalid -58 58 | _ = """Lorem ipsum dolor sit amet. - -RUF100_0.py:63:6: RUF100 [*] Unused `noqa` directive (unused: `E501`) - | -62 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. -63 | """ # noqa: E501 - | ^^^^^^^^^^^^ RUF100 -64 | -65 | # Invalid - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -60 60 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 -61 61 | -62 62 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. -63 |-""" # noqa: E501 - 63 |+""" -64 64 | -65 65 | # Invalid -66 66 | _ = """Lorem ipsum dolor sit amet. - -RUF100_0.py:71:6: RUF100 [*] Unused blanket `noqa` directive - | -70 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. -71 | """ # noqa - | ^^^^^^ RUF100 -72 | -73 | # Valid - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -68 68 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 -69 69 | -70 70 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. -71 |-""" # noqa - 71 |+""" -72 72 | -73 73 | # Valid -74 74 | # this is a veryyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy long comment # noqa: E501 - -RUF100_0.py:85:8: F401 [*] `shelve` imported but unused - | -83 | import collections # noqa -84 | import os # noqa: F401, RUF100 -85 | import shelve # noqa: RUF100 - | ^^^^^^ F401 -86 | import sys # noqa: F401, RUF100 - | - = help: Remove unused import: `shelve` - -ℹ Fix -82 82 | -83 83 | import collections # noqa -84 84 | import os # noqa: F401, RUF100 -85 |-import shelve # noqa: RUF100 -86 85 | import sys # noqa: F401, RUF100 -87 86 | -88 87 | print(sys.path) - -RUF100_0.py:90:89: E501 Line too long (103 > 88 characters) - | -88 | print(sys.path) -89 | -90 | "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 - | - -RUF100_0.py:90:92: RUF100 [*] Unused `noqa` directive (unused: `F401`) - | -88 | print(sys.path) -89 | -90 | "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 - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -87 87 | -88 88 | print(sys.path) -89 89 | -90 |-"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 - 90 |+"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]" -91 91 | -92 92 | -93 93 | def f(): - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_1.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_1.snap deleted file mode 100644 index ad606136dd..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_1.snap +++ /dev/null @@ -1,154 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF100_1.py:37:9: F401 [*] `typing.Union` imported but unused - | -35 | from typing import ( -36 | Mapping, # noqa: F401 -37 | Union, - | ^^^^^ F401 -38 | ) - | - = help: Remove unused import: `typing.Union` - -ℹ Fix -34 34 | # This should ignore the first error. -35 35 | from typing import ( -36 36 | Mapping, # noqa: F401 -37 |- Union, -38 |- ) - 37 |+ ) -39 38 | -40 39 | -41 40 | def f(): - -RUF100_1.py:52:20: RUF100 [*] Unused `noqa` directive (unused: `F401`) - | -50 | # This should ignore the error, but the inner noqa should be marked as unused. -51 | from typing import ( # noqa: F401 -52 | Optional, # noqa: F401 - | ^^^^^^^^^^^^ RUF100 -53 | ) - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -49 49 | def f(): -50 50 | # This should ignore the error, but the inner noqa should be marked as unused. -51 51 | from typing import ( # noqa: F401 -52 |- Optional, # noqa: F401 - 52 |+ Optional, -53 53 | ) -54 54 | -55 55 | - -RUF100_1.py:59:20: RUF100 [*] Unused `noqa` directive (unused: `F401`) - | -57 | # This should ignore the error, but the inner noqa should be marked as unused. -58 | from typing import ( # noqa -59 | Optional, # noqa: F401 - | ^^^^^^^^^^^^ RUF100 -60 | ) - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -56 56 | def f(): -57 57 | # This should ignore the error, but the inner noqa should be marked as unused. -58 58 | from typing import ( # noqa -59 |- Optional, # noqa: F401 - 59 |+ Optional, -60 60 | ) -61 61 | -62 62 | - -RUF100_1.py:66:16: RUF100 [*] Unused `noqa` directive (non-enabled: `F501`) - | -64 | # This should ignore the error, but mark F501 as unused. -65 | from typing import ( # noqa: F401 -66 | Dict, # noqa: F501 - | ^^^^^^^^^^^^ RUF100 -67 | ) - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -63 63 | def f(): -64 64 | # This should ignore the error, but mark F501 as unused. -65 65 | from typing import ( # noqa: F401 -66 |- Dict, # noqa: F501 - 66 |+ Dict, -67 67 | ) -68 68 | -69 69 | - -RUF100_1.py:72:27: RUF100 [*] Unused `noqa` directive (non-enabled: `F501`) - | -70 | def f(): -71 | # This should ignore the error, but mark F501 as unused. -72 | from typing import ( # noqa: F501 - | ^^^^^^^^^^^^ RUF100 -73 | Tuple, # noqa: F401 -74 | ) - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -69 69 | -70 70 | def f(): -71 71 | # This should ignore the error, but mark F501 as unused. -72 |- from typing import ( # noqa: F501 - 72 |+ from typing import ( -73 73 | Tuple, # noqa: F401 -74 74 | ) -75 75 | - -RUF100_1.py:89:24: F401 [*] `typing.Awaitable` imported but unused - | -87 | def f(): -88 | # This should mark F501 as unused. -89 | from typing import Awaitable, AwaitableGenerator # noqa: F501 - | ^^^^^^^^^ F401 - | - = help: Remove unused import - -ℹ Fix -86 86 | -87 87 | def f(): -88 88 | # This should mark F501 as unused. -89 |- from typing import Awaitable, AwaitableGenerator # noqa: F501 - 89 |+ pass # noqa: F501 - -RUF100_1.py:89:35: F401 [*] `typing.AwaitableGenerator` imported but unused - | -87 | def f(): -88 | # This should mark F501 as unused. -89 | from typing import Awaitable, AwaitableGenerator # noqa: F501 - | ^^^^^^^^^^^^^^^^^^ F401 - | - = help: Remove unused import - -ℹ Fix -86 86 | -87 87 | def f(): -88 88 | # This should mark F501 as unused. -89 |- from typing import Awaitable, AwaitableGenerator # noqa: F501 - 89 |+ pass # noqa: F501 - -RUF100_1.py:89:55: RUF100 [*] Unused `noqa` directive (non-enabled: `F501`) - | -87 | def f(): -88 | # This should mark F501 as unused. -89 | from typing import Awaitable, AwaitableGenerator # noqa: F501 - | ^^^^^^^^^^^^ RUF100 - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -86 86 | -87 87 | def f(): -88 88 | # This should mark F501 as unused. -89 |- from typing import Awaitable, AwaitableGenerator # noqa: F501 - 89 |+ from typing import Awaitable, AwaitableGenerator - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_2.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_2.snap deleted file mode 100644 index 7fd1341d11..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_2.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF100_2.py:1:19: RUF100 [*] Unused `noqa` directive (unused: `F401`) - | -1 | import itertools # noqa: F401 - | ^^^^^^^^^^^^ RUF100 - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -1 |-import itertools # noqa: F401 - 1 |+import itertools - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_3.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_3.snap deleted file mode 100644 index 4c56171cc0..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_3.snap +++ /dev/null @@ -1,382 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF100_3.py:1:1: RUF100 [*] Unused blanket `noqa` directive - | -1 | # noqa - | ^^^^^^ RUF100 -2 | # noqa # comment -3 | print() # noqa - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -1 |-# noqa -2 1 | # noqa # comment -3 2 | print() # noqa -4 3 | print() # noqa # comment - -RUF100_3.py:2:1: RUF100 [*] Unused blanket `noqa` directive - | -1 | # noqa -2 | # noqa # comment - | ^^^^^^ RUF100 -3 | print() # noqa -4 | print() # noqa # comment - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -1 1 | # noqa -2 |-# noqa # comment - 2 |+# comment -3 3 | print() # noqa -4 4 | print() # noqa # comment -5 5 | print() # noqa # comment - -RUF100_3.py:3:10: RUF100 [*] Unused blanket `noqa` directive - | -1 | # noqa -2 | # noqa # comment -3 | print() # noqa - | ^^^^^^ RUF100 -4 | print() # noqa # comment -5 | print() # noqa # comment - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -1 1 | # noqa -2 2 | # noqa # comment -3 |-print() # noqa - 3 |+print() -4 4 | print() # noqa # comment -5 5 | print() # noqa # comment -6 6 | print() # noqa comment - -RUF100_3.py:4:10: RUF100 [*] Unused blanket `noqa` directive - | -2 | # noqa # comment -3 | print() # noqa -4 | print() # noqa # comment - | ^^^^^^ RUF100 -5 | print() # noqa # comment -6 | print() # noqa comment - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -1 1 | # noqa -2 2 | # noqa # comment -3 3 | print() # noqa -4 |-print() # noqa # comment - 4 |+print() # comment -5 5 | print() # noqa # comment -6 6 | print() # noqa comment -7 7 | print() # noqa comment - -RUF100_3.py:5:10: RUF100 [*] Unused blanket `noqa` directive - | -3 | print() # noqa -4 | print() # noqa # comment -5 | print() # noqa # comment - | ^^^^^^ RUF100 -6 | print() # noqa comment -7 | print() # noqa comment - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -2 2 | # noqa # comment -3 3 | print() # noqa -4 4 | print() # noqa # comment -5 |-print() # noqa # comment - 5 |+print() # comment -6 6 | print() # noqa comment -7 7 | print() # noqa comment -8 8 | print(a) # noqa - -RUF100_3.py:6:10: RUF100 [*] Unused blanket `noqa` directive - | -4 | print() # noqa # comment -5 | print() # noqa # comment -6 | print() # noqa comment - | ^^^^^^ RUF100 -7 | print() # noqa comment -8 | print(a) # noqa - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -3 3 | print() # noqa -4 4 | print() # noqa # comment -5 5 | print() # noqa # comment -6 |-print() # noqa comment - 6 |+print() # comment -7 7 | print() # noqa comment -8 8 | print(a) # noqa -9 9 | print(a) # noqa # comment - -RUF100_3.py:7:10: RUF100 [*] Unused blanket `noqa` directive - | -5 | print() # noqa # comment -6 | print() # noqa comment -7 | print() # noqa comment - | ^^^^^^ RUF100 -8 | print(a) # noqa -9 | print(a) # noqa # comment - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -4 4 | print() # noqa # comment -5 5 | print() # noqa # comment -6 6 | print() # noqa comment -7 |-print() # noqa comment - 7 |+print() # comment -8 8 | print(a) # noqa -9 9 | print(a) # noqa # comment -10 10 | print(a) # noqa # comment - -RUF100_3.py:14:1: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) - | -12 | print(a) # noqa comment -13 | -14 | # noqa: E501, F821 - | ^^^^^^^^^^^^^^^^^^ RUF100 -15 | # noqa: E501, F821 # comment -16 | print() # noqa: E501, F821 - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -11 11 | print(a) # noqa comment -12 12 | print(a) # noqa comment -13 13 | -14 |-# noqa: E501, F821 -15 14 | # noqa: E501, F821 # comment -16 15 | print() # noqa: E501, F821 -17 16 | print() # noqa: E501, F821 # comment - -RUF100_3.py:15:1: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) - | -14 | # noqa: E501, F821 -15 | # noqa: E501, F821 # comment - | ^^^^^^^^^^^^^^^^^^ RUF100 -16 | print() # noqa: E501, F821 -17 | print() # noqa: E501, F821 # comment - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -12 12 | print(a) # noqa comment -13 13 | -14 14 | # noqa: E501, F821 -15 |-# noqa: E501, F821 # comment - 15 |+# comment -16 16 | print() # noqa: E501, F821 -17 17 | print() # noqa: E501, F821 # comment -18 18 | print() # noqa: E501, F821 # comment - -RUF100_3.py:16:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) - | -14 | # noqa: E501, F821 -15 | # noqa: E501, F821 # comment -16 | print() # noqa: E501, F821 - | ^^^^^^^^^^^^^^^^^^ RUF100 -17 | print() # noqa: E501, F821 # comment -18 | print() # noqa: E501, F821 # comment - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -13 13 | -14 14 | # noqa: E501, F821 -15 15 | # noqa: E501, F821 # comment -16 |-print() # noqa: E501, F821 - 16 |+print() -17 17 | print() # noqa: E501, F821 # comment -18 18 | print() # noqa: E501, F821 # comment -19 19 | print() # noqa: E501, F821 comment - -RUF100_3.py:17:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) - | -15 | # noqa: E501, F821 # comment -16 | print() # noqa: E501, F821 -17 | print() # noqa: E501, F821 # comment - | ^^^^^^^^^^^^^^^^^^ RUF100 -18 | print() # noqa: E501, F821 # comment -19 | print() # noqa: E501, F821 comment - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -14 14 | # noqa: E501, F821 -15 15 | # noqa: E501, F821 # comment -16 16 | print() # noqa: E501, F821 -17 |-print() # noqa: E501, F821 # comment - 17 |+print() # comment -18 18 | print() # noqa: E501, F821 # comment -19 19 | print() # noqa: E501, F821 comment -20 20 | print() # noqa: E501, F821 comment - -RUF100_3.py:18:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) - | -16 | print() # noqa: E501, F821 -17 | print() # noqa: E501, F821 # comment -18 | print() # noqa: E501, F821 # comment - | ^^^^^^^^^^^^^^^^^^ RUF100 -19 | print() # noqa: E501, F821 comment -20 | print() # noqa: E501, F821 comment - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -15 15 | # noqa: E501, F821 # comment -16 16 | print() # noqa: E501, F821 -17 17 | print() # noqa: E501, F821 # comment -18 |-print() # noqa: E501, F821 # comment - 18 |+print() # comment -19 19 | print() # noqa: E501, F821 comment -20 20 | print() # noqa: E501, F821 comment -21 21 | print(a) # noqa: E501, F821 - -RUF100_3.py:19:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) - | -17 | print() # noqa: E501, F821 # comment -18 | print() # noqa: E501, F821 # comment -19 | print() # noqa: E501, F821 comment - | ^^^^^^^^^^^^^^^^^^ RUF100 -20 | print() # noqa: E501, F821 comment -21 | print(a) # noqa: E501, F821 - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -16 16 | print() # noqa: E501, F821 -17 17 | print() # noqa: E501, F821 # comment -18 18 | print() # noqa: E501, F821 # comment -19 |-print() # noqa: E501, F821 comment - 19 |+print() # comment -20 20 | print() # noqa: E501, F821 comment -21 21 | print(a) # noqa: E501, F821 -22 22 | print(a) # noqa: E501, F821 # comment - -RUF100_3.py:20:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) - | -18 | print() # noqa: E501, F821 # comment -19 | print() # noqa: E501, F821 comment -20 | print() # noqa: E501, F821 comment - | ^^^^^^^^^^^^^^^^^^ RUF100 -21 | print(a) # noqa: E501, F821 -22 | print(a) # noqa: E501, F821 # comment - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -17 17 | print() # noqa: E501, F821 # comment -18 18 | print() # noqa: E501, F821 # comment -19 19 | print() # noqa: E501, F821 comment -20 |-print() # noqa: E501, F821 comment - 20 |+print() # comment -21 21 | print(a) # noqa: E501, F821 -22 22 | print(a) # noqa: E501, F821 # comment -23 23 | print(a) # noqa: E501, F821 # comment - -RUF100_3.py:21:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) - | -19 | print() # noqa: E501, F821 comment -20 | print() # noqa: E501, F821 comment -21 | print(a) # noqa: E501, F821 - | ^^^^^^^^^^^^^^^^^^ RUF100 -22 | print(a) # noqa: E501, F821 # comment -23 | print(a) # noqa: E501, F821 # comment - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -18 18 | print() # noqa: E501, F821 # comment -19 19 | print() # noqa: E501, F821 comment -20 20 | print() # noqa: E501, F821 comment -21 |-print(a) # noqa: E501, F821 - 21 |+print(a) # noqa: F821 -22 22 | print(a) # noqa: E501, F821 # comment -23 23 | print(a) # noqa: E501, F821 # comment -24 24 | print(a) # noqa: E501, F821 comment - -RUF100_3.py:22:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) - | -20 | print() # noqa: E501, F821 comment -21 | print(a) # noqa: E501, F821 -22 | print(a) # noqa: E501, F821 # comment - | ^^^^^^^^^^^^^^^^^^ RUF100 -23 | print(a) # noqa: E501, F821 # comment -24 | print(a) # noqa: E501, F821 comment - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -19 19 | print() # noqa: E501, F821 comment -20 20 | print() # noqa: E501, F821 comment -21 21 | print(a) # noqa: E501, F821 -22 |-print(a) # noqa: E501, F821 # comment - 22 |+print(a) # noqa: F821 # comment -23 23 | print(a) # noqa: E501, F821 # comment -24 24 | print(a) # noqa: E501, F821 comment -25 25 | print(a) # noqa: E501, F821 comment - -RUF100_3.py:23:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) - | -21 | print(a) # noqa: E501, F821 -22 | print(a) # noqa: E501, F821 # comment -23 | print(a) # noqa: E501, F821 # comment - | ^^^^^^^^^^^^^^^^^^ RUF100 -24 | print(a) # noqa: E501, F821 comment -25 | print(a) # noqa: E501, F821 comment - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -20 20 | print() # noqa: E501, F821 comment -21 21 | print(a) # noqa: E501, F821 -22 22 | print(a) # noqa: E501, F821 # comment -23 |-print(a) # noqa: E501, F821 # comment - 23 |+print(a) # noqa: F821 # comment -24 24 | print(a) # noqa: E501, F821 comment -25 25 | print(a) # noqa: E501, F821 comment - -RUF100_3.py:24:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) - | -22 | print(a) # noqa: E501, F821 # comment -23 | print(a) # noqa: E501, F821 # comment -24 | print(a) # noqa: E501, F821 comment - | ^^^^^^^^^^^^^^^^^^ RUF100 -25 | print(a) # noqa: E501, F821 comment - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -21 21 | print(a) # noqa: E501, F821 -22 22 | print(a) # noqa: E501, F821 # comment -23 23 | print(a) # noqa: E501, F821 # comment -24 |-print(a) # noqa: E501, F821 comment - 24 |+print(a) # noqa: F821 comment -25 25 | print(a) # noqa: E501, F821 comment - -RUF100_3.py:25:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) - | -23 | print(a) # noqa: E501, F821 # comment -24 | print(a) # noqa: E501, F821 comment -25 | print(a) # noqa: E501, F821 comment - | ^^^^^^^^^^^^^^^^^^ RUF100 - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -22 22 | print(a) # noqa: E501, F821 # comment -23 23 | print(a) # noqa: E501, F821 # comment -24 24 | print(a) # noqa: E501, F821 comment -25 |-print(a) # noqa: E501, F821 comment - 25 |+print(a) # noqa: F821 comment - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_4.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_4.snap deleted file mode 100644 index e51f71f811..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_4.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_5.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_5.snap deleted file mode 100644 index 9f212869a4..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruf100_5.snap +++ /dev/null @@ -1,50 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -RUF100_5.py:7:5: ERA001 [*] Found commented-out code - | -5 | # "key1": 123, # noqa: ERA001 -6 | # "key2": 456, # noqa -7 | # "key3": 789, - | ^^^^^^^^^^^^^^ ERA001 -8 | } - | - = help: Remove commented-out code - -ℹ Possible fix -4 4 | dictionary = { -5 5 | # "key1": 123, # noqa: ERA001 -6 6 | # "key2": 456, # noqa -7 |- # "key3": 789, -8 7 | } -9 8 | -10 9 | - -RUF100_5.py:11:1: ERA001 [*] Found commented-out code - | -11 | #import os # noqa: E501 - | ^^^^^^^^^^^^^^^^^^^^^^^^ ERA001 - | - = help: Remove commented-out code - -ℹ Possible fix -8 8 | } -9 9 | -10 10 | -11 |-#import os # noqa: E501 - -RUF100_5.py:11:13: RUF100 [*] Unused `noqa` directive (unused: `E501`) - | -11 | #import os # noqa: E501 - | ^^^^^^^^^^^^ RUF100 - | - = help: Remove unused `noqa` directive - -ℹ Suggested fix -8 8 | } -9 9 | -10 10 | -11 |-#import os # noqa: E501 - 11 |+#import os - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruff_noqa_all.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruff_noqa_all.snap deleted file mode 100644 index e51f71f811..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruff_noqa_all.snap +++ /dev/null @@ -1,4 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruff_noqa_codes.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruff_noqa_codes.snap deleted file mode 100644 index 5821686708..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruff_noqa_codes.snap +++ /dev/null @@ -1,19 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -ruff_noqa_codes.py:8:5: F841 [*] Local variable `x` is assigned to but never used - | -7 | def f(): -8 | x = 1 - | ^ F841 - | - = help: Remove assignment to unused variable `x` - -ℹ Suggested fix -5 5 | -6 6 | -7 7 | def f(): -8 |- x = 1 - 8 |+ pass - - diff --git a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruff_noqa_invalid.snap b/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruff_noqa_invalid.snap deleted file mode 100644 index 73a4e55545..0000000000 --- a/crates/ruff/src/rules/ruff/snapshots/ruff__rules__ruff__tests__ruff_noqa_invalid.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: crates/ruff/src/rules/ruff/mod.rs ---- -ruff_noqa_invalid.py:1:8: F401 [*] `os` imported but unused - | -1 | import os # ruff: noqa: F401 - | ^^ F401 - | - = help: Remove unused import: `os` - -ℹ Fix -1 |-import os # ruff: noqa: F401 -2 1 | -3 2 | -4 3 | def f(): - -ruff_noqa_invalid.py:5:5: F841 [*] Local variable `x` is assigned to but never used - | -4 | def f(): -5 | x = 1 - | ^ F841 - | - = help: Remove assignment to unused variable `x` - -ℹ Suggested fix -2 2 | -3 3 | -4 4 | def f(): -5 |- x = 1 - 5 |+ pass - - diff --git a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__error-instead-of-exception_TRY400.py.snap b/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__error-instead-of-exception_TRY400.py.snap deleted file mode 100644 index facd4139e3..0000000000 --- a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__error-instead-of-exception_TRY400.py.snap +++ /dev/null @@ -1,72 +0,0 @@ ---- -source: crates/ruff/src/rules/tryceratops/mod.rs ---- -TRY400.py:16:9: TRY400 Use `logging.exception` instead of `logging.error` - | -14 | a = 1 -15 | except Exception: -16 | logging.error("Context message here") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 -17 | -18 | if True: - | - -TRY400.py:19:13: TRY400 Use `logging.exception` instead of `logging.error` - | -18 | if True: -19 | logging.error("Context message here") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 - | - -TRY400.py:26:9: TRY400 Use `logging.exception` instead of `logging.error` - | -24 | a = 1 -25 | except Exception: -26 | logger.error("Context message here") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 -27 | -28 | if True: - | - -TRY400.py:29:13: TRY400 Use `logging.exception` instead of `logging.error` - | -28 | if True: -29 | logger.error("Context message here") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 - | - -TRY400.py:36:9: TRY400 Use `logging.exception` instead of `logging.error` - | -34 | a = 1 -35 | except Exception: -36 | log.error("Context message here") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 -37 | -38 | if True: - | - -TRY400.py:39:13: TRY400 Use `logging.exception` instead of `logging.error` - | -38 | if True: -39 | log.error("Context message here") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 - | - -TRY400.py:46:9: TRY400 Use `logging.exception` instead of `logging.error` - | -44 | a = 1 -45 | except Exception: -46 | self.logger.error("Context message here") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 -47 | -48 | if True: - | - -TRY400.py:49:13: TRY400 Use `logging.exception` instead of `logging.error` - | -48 | if True: -49 | self.logger.error("Context message here") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 - | - - diff --git a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__raise-vanilla-args_TRY003.py.snap b/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__raise-vanilla-args_TRY003.py.snap deleted file mode 100644 index 288e4da5a0..0000000000 --- a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__raise-vanilla-args_TRY003.py.snap +++ /dev/null @@ -1,38 +0,0 @@ ---- -source: crates/ruff/src/rules/tryceratops/mod.rs ---- -TRY003.py:8:15: TRY003 Avoid specifying long messages outside the exception class - | - 6 | a = 1 - 7 | if a == 1: - 8 | raise CustomException("Long message") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY003 - 9 | elif a == 2: -10 | raise CustomException("Short") # This is acceptable - | - -TRY003.py:34:15: TRY003 Avoid specifying long messages outside the exception class - | -32 | def bad(a): -33 | if a % 2 == 0: -34 | raise BadArgCantBeEven(f"The argument '{a}' should be even") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY003 - | - -TRY003.py:39:15: TRY003 Avoid specifying long messages outside the exception class - | -37 | def another_bad(a): -38 | if a % 2 == 0: -39 | raise BadArgCantBeEven(f"The argument {a} should not be odd.") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY003 - | - -TRY003.py:44:15: TRY003 Avoid specifying long messages outside the exception class - | -42 | def and_another_bad(a): -43 | if a % 2 == 0: -44 | raise BadArgCantBeEven("The argument `a` should not be odd.") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY003 - | - - diff --git a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__raise-vanilla-class_TRY002.py.snap b/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__raise-vanilla-class_TRY002.py.snap deleted file mode 100644 index 5e8db584e4..0000000000 --- a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__raise-vanilla-class_TRY002.py.snap +++ /dev/null @@ -1,22 +0,0 @@ ---- -source: crates/ruff/src/rules/tryceratops/mod.rs ---- -TRY002.py:13:15: TRY002 Create your own exception - | -11 | a = 1 -12 | if a == 1: -13 | raise Exception("Custom message") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY002 -14 | -15 | b = 1 - | - -TRY002.py:17:15: TRY002 Create your own exception - | -15 | b = 1 -16 | if b == 1: -17 | raise Exception - | ^^^^^^^^^ TRY002 - | - - diff --git a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__raise-within-try_TRY301.py.snap b/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__raise-within-try_TRY301.py.snap deleted file mode 100644 index 994d67f24f..0000000000 --- a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__raise-within-try_TRY301.py.snap +++ /dev/null @@ -1,64 +0,0 @@ ---- -source: crates/ruff/src/rules/tryceratops/mod.rs ---- -TRY301.py:14:13: TRY301 Abstract `raise` to an inner function - | -12 | a = process() -13 | if not a: -14 | raise MyException(a) - | ^^^^^^^^^^^^^^^^^^^^ TRY301 -15 | -16 | raise MyException(a) - | - -TRY301.py:16:9: TRY301 Abstract `raise` to an inner function - | -14 | raise MyException(a) -15 | -16 | raise MyException(a) - | ^^^^^^^^^^^^^^^^^^^^ TRY301 -17 | -18 | try: - | - -TRY301.py:21:17: TRY301 Abstract `raise` to an inner function - | -19 | b = process() -20 | if not b: -21 | raise MyException(b) - | ^^^^^^^^^^^^^^^^^^^^ TRY301 -22 | except Exception: -23 | logger.exception("something failed") - | - -TRY301.py:32:13: TRY301 Abstract `raise` to an inner function - | -30 | a = process() -31 | if not a: -32 | raise MyException(a) - | ^^^^^^^^^^^^^^^^^^^^ TRY301 -33 | -34 | raise MyException(a) - | - -TRY301.py:34:9: TRY301 Abstract `raise` to an inner function - | -32 | raise MyException(a) -33 | -34 | raise MyException(a) - | ^^^^^^^^^^^^^^^^^^^^ TRY301 -35 | -36 | try: - | - -TRY301.py:39:17: TRY301 Abstract `raise` to an inner function - | -37 | b = process() -38 | if not b: -39 | raise MyException(b) - | ^^^^^^^^^^^^^^^^^^^^ TRY301 -40 | except* Exception: -41 | logger.exception("something failed") - | - - diff --git a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__reraise-no-cause_TRY200.py.snap b/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__reraise-no-cause_TRY200.py.snap deleted file mode 100644 index 7bc956b097..0000000000 --- a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__reraise-no-cause_TRY200.py.snap +++ /dev/null @@ -1,20 +0,0 @@ ---- -source: crates/ruff/src/rules/tryceratops/mod.rs ---- -TRY200.py:15:9: TRY200 Use `raise from` to specify exception cause - | -13 | a = 1 -14 | except Exception: -15 | raise MyException() - | ^^^^^^^^^^^^^^^^^^^ TRY200 - | - -TRY200.py:23:13: TRY200 Use `raise from` to specify exception cause - | -21 | except Exception: -22 | if True: -23 | raise MyException() - | ^^^^^^^^^^^^^^^^^^^ TRY200 - | - - diff --git a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__try-consider-else_TRY300.py.snap b/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__try-consider-else_TRY300.py.snap deleted file mode 100644 index 9db92a83ae..0000000000 --- a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__try-consider-else_TRY300.py.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/rules/tryceratops/mod.rs ---- -TRY300.py:20:9: TRY300 Consider moving this statement to an `else` block - | -18 | a = 1 -19 | b = process() -20 | return b - | ^^^^^^^^ TRY300 -21 | except MyException: -22 | logger.exception("process failed") - | - - diff --git a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__type-check-without-type-error_TRY004.py.snap b/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__type-check-without-type-error_TRY004.py.snap deleted file mode 100644 index be351bfdc4..0000000000 --- a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__type-check-without-type-error_TRY004.py.snap +++ /dev/null @@ -1,299 +0,0 @@ ---- -source: crates/ruff/src/rules/tryceratops/mod.rs ---- -TRY004.py:12:9: TRY004 Prefer `TypeError` exception for invalid type - | -10 | pass -11 | else: -12 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:19:9: TRY004 Prefer `TypeError` exception for invalid type - | -17 | pass -18 | else: -19 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:30:9: TRY004 Prefer `TypeError` exception for invalid type - | -28 | pass -29 | else: -30 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:37:9: TRY004 Prefer `TypeError` exception for invalid type - | -35 | pass -36 | else: -37 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:44:9: TRY004 Prefer `TypeError` exception for invalid type - | -42 | pass -43 | else: -44 | raise ArithmeticError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:51:9: TRY004 Prefer `TypeError` exception for invalid type - | -49 | pass -50 | else: -51 | raise AssertionError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:58:9: TRY004 Prefer `TypeError` exception for invalid type - | -56 | pass -57 | else: -58 | raise AttributeError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:65:9: TRY004 Prefer `TypeError` exception for invalid type - | -63 | pass -64 | else: -65 | raise BufferError # should be typeerror - | ^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:72:9: TRY004 Prefer `TypeError` exception for invalid type - | -70 | pass -71 | else: -72 | raise EOFError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:79:9: TRY004 Prefer `TypeError` exception for invalid type - | -77 | pass -78 | else: -79 | raise ImportError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:86:9: TRY004 Prefer `TypeError` exception for invalid type - | -84 | pass -85 | else: -86 | raise LookupError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -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( - | _________^ -96 | | "..." -97 | | ) - | |_________^ TRY004 - | - -TRY004.py:104:9: TRY004 Prefer `TypeError` exception for invalid type - | -102 | pass -103 | else: -104 | raise NameError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:111:9: TRY004 Prefer `TypeError` exception for invalid type - | -109 | pass -110 | else: -111 | raise ReferenceError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:118:9: TRY004 Prefer `TypeError` exception for invalid type - | -116 | pass -117 | else: -118 | raise RuntimeError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:125:9: TRY004 Prefer `TypeError` exception for invalid type - | -123 | pass -124 | else: -125 | raise SyntaxError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:132:9: TRY004 Prefer `TypeError` exception for invalid type - | -130 | pass -131 | else: -132 | raise SystemError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:139:9: TRY004 Prefer `TypeError` exception for invalid type - | -137 | pass -138 | else: -139 | raise ValueError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:146:9: TRY004 Prefer `TypeError` exception for invalid type - | -144 | pass -145 | else: -146 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:153:9: TRY004 Prefer `TypeError` exception for invalid type - | -151 | pass -152 | else: -153 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:160:9: TRY004 Prefer `TypeError` exception for invalid type - | -158 | pass -159 | else: -160 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:167:9: TRY004 Prefer `TypeError` exception for invalid type - | -165 | pass -166 | else: -167 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:174:9: TRY004 Prefer `TypeError` exception for invalid type - | -172 | pass -173 | else: -174 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:181:9: TRY004 Prefer `TypeError` exception for invalid type - | -179 | pass -180 | else: -181 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:188:9: TRY004 Prefer `TypeError` exception for invalid type - | -186 | pass -187 | else: -188 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:195:9: TRY004 Prefer `TypeError` exception for invalid type - | -193 | pass -194 | else: -195 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:202:9: TRY004 Prefer `TypeError` exception for invalid type - | -200 | pass -201 | else: -202 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:209:9: TRY004 Prefer `TypeError` exception for invalid type - | -207 | pass -208 | else: -209 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:216:9: TRY004 Prefer `TypeError` exception for invalid type - | -214 | pass -215 | else: -216 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:223:9: TRY004 Prefer `TypeError` exception for invalid type - | -221 | pass -222 | else: -223 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:230:9: TRY004 Prefer `TypeError` exception for invalid type - | -228 | pass -229 | elif isinstance(arg2, int): -230 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:239:9: TRY004 Prefer `TypeError` exception for invalid type - | -237 | pass -238 | else: -239 | raise Exception("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:276:9: TRY004 Prefer `TypeError` exception for invalid type - | -274 | def check_body(some_args): -275 | if isinstance(some_args, int): -276 | raise ValueError("...") # should be typeerror - | ^^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - -TRY004.py:286:9: TRY004 Prefer `TypeError` exception for invalid type - | -284 | def multiple_elifs(some_args): -285 | if not isinstance(some_args, int): -286 | raise ValueError("...") # should be typerror - | ^^^^^^^^^^^^^^^^^^^^^^^ TRY004 -287 | elif some_args < 3: -288 | raise ValueError("...") # this is ok - | - -TRY004.py:297:9: TRY004 Prefer `TypeError` exception for invalid type - | -295 | def multiple_ifs(some_args): -296 | if not isinstance(some_args, int): -297 | raise ValueError("...") # should be typerror - | ^^^^^^^^^^^^^^^^^^^^^^^ TRY004 -298 | else: -299 | if some_args < 3: - | - -TRY004.py:316:9: TRY004 Prefer `TypeError` exception for invalid type - | -314 | return "CronExpression" -315 | else: -316 | raise Exception(f"Unknown object type: {obj.__class__.__name__}") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 - | - - diff --git a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__useless-try-except_TRY302.py.snap b/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__useless-try-except_TRY302.py.snap deleted file mode 100644 index f6889549ba..0000000000 --- a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__useless-try-except_TRY302.py.snap +++ /dev/null @@ -1,150 +0,0 @@ ---- -source: crates/ruff/src/rules/tryceratops/mod.rs ---- -TRY302.py:12:5: TRY302 Remove exception handler; error is immediately re-raised - | -10 | try: -11 | process() -12 | except Exception: - | _____^ -13 | | raise - | |_____________^ TRY302 -14 | -15 | def bad(): - | - -TRY302.py:18:5: TRY302 Remove exception handler; error is immediately re-raised - | -16 | try: -17 | process() -18 | except Exception: - | _____^ -19 | | raise -20 | | print("this code is pointless!") - | |________________________________________^ TRY302 -21 | -22 | def bad(): - | - -TRY302.py:25:5: TRY302 Remove exception handler; error is immediately re-raised - | -23 | try: -24 | process() -25 | except: - | _____^ -26 | | # I am a comment, not a statement! -27 | | raise - | |_____________^ TRY302 -28 | -29 | def bad(): - | - -TRY302.py:32:5: TRY302 Remove exception handler; error is immediately re-raised - | -30 | try: -31 | process() -32 | except Exception: - | _____^ -33 | | raise - | |_____________^ TRY302 -34 | -35 | def bad(): - | - -TRY302.py:38:5: TRY302 Remove exception handler; error is immediately re-raised - | -36 | try: -37 | process() -38 | except Exception as e: - | _____^ -39 | | raise - | |_____________^ TRY302 -40 | -41 | def bad(): - | - -TRY302.py:44:5: TRY302 Remove exception handler; error is immediately re-raised - | -42 | try: -43 | process() -44 | except Exception as e: - | _____^ -45 | | raise e - | |_______________^ TRY302 -46 | -47 | def bad(): - | - -TRY302.py:50:5: TRY302 Remove exception handler; error is immediately re-raised - | -48 | try: -49 | process() -50 | except MyException: - | _____^ -51 | | raise - | |_____________^ TRY302 -52 | except Exception: -53 | raise - | - -TRY302.py:52:5: TRY302 Remove exception handler; error is immediately re-raised - | -50 | except MyException: -51 | raise -52 | except Exception: - | _____^ -53 | | raise - | |_____________^ TRY302 -54 | -55 | def bad(): - | - -TRY302.py:58:5: TRY302 Remove exception handler; error is immediately re-raised - | -56 | try: -57 | process() -58 | except MyException as e: - | _____^ -59 | | raise e - | |_______________^ TRY302 -60 | except Exception as e: -61 | raise e - | - -TRY302.py:60:5: TRY302 Remove exception handler; error is immediately re-raised - | -58 | except MyException as e: -59 | raise e -60 | except Exception as e: - | _____^ -61 | | raise e - | |_______________^ TRY302 -62 | -63 | def bad(): - | - -TRY302.py:66:5: TRY302 Remove exception handler; error is immediately re-raised - | -64 | try: -65 | process() -66 | except MyException as ex: - | _____^ -67 | | raise ex - | |________________^ TRY302 -68 | except Exception as e: -69 | raise e - | - -TRY302.py:68:5: TRY302 Remove exception handler; error is immediately re-raised - | -66 | except MyException as ex: -67 | raise ex -68 | except Exception as e: - | _____^ -69 | | raise e - | |_______________^ TRY302 -70 | -71 | def fine(): - | - - diff --git a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__verbose-log-message_TRY401.py.snap b/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__verbose-log-message_TRY401.py.snap deleted file mode 100644 index bb4de318be..0000000000 --- a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__verbose-log-message_TRY401.py.snap +++ /dev/null @@ -1,92 +0,0 @@ ---- -source: crates/ruff/src/rules/tryceratops/mod.rs ---- -TRY401.py:8:45: TRY401 Redundant exception object included in `logging.exception` call - | -6 | finish() -7 | except Exception as ex: -8 | logger.exception(f"Found an error: {ex}") # TRY401 - | ^^ TRY401 - | - -TRY401.py:19:53: TRY401 Redundant exception object included in `logging.exception` call - | -17 | if True is False: -18 | for i in range(10): -19 | logger.exception(f"Found an error: {bad} {good}") # TRY401 - | ^^^ TRY401 -20 | except IndexError as bad: -21 | logger.exception(f"Found an error: {bad} {bad}") # TRY401 - | - -TRY401.py:21:45: TRY401 Redundant exception object included in `logging.exception` call - | -19 | logger.exception(f"Found an error: {bad} {good}") # TRY401 -20 | except IndexError as bad: -21 | logger.exception(f"Found an error: {bad} {bad}") # TRY401 - | ^^^ TRY401 -22 | except Exception as bad: -23 | logger.exception(f"Found an error: {bad}") # TRY401 - | - -TRY401.py:21:51: TRY401 Redundant exception object included in `logging.exception` call - | -19 | logger.exception(f"Found an error: {bad} {good}") # TRY401 -20 | except IndexError as bad: -21 | logger.exception(f"Found an error: {bad} {bad}") # TRY401 - | ^^^ TRY401 -22 | except Exception as bad: -23 | logger.exception(f"Found an error: {bad}") # TRY401 - | - -TRY401.py:23:45: TRY401 Redundant exception object included in `logging.exception` call - | -21 | logger.exception(f"Found an error: {bad} {bad}") # TRY401 -22 | except Exception as bad: -23 | logger.exception(f"Found an error: {bad}") # TRY401 - | ^^^ TRY401 -24 | logger.exception(f"Found an error: {bad}") # TRY401 - | - -TRY401.py:24:45: TRY401 Redundant exception object included in `logging.exception` call - | -22 | except Exception as bad: -23 | logger.exception(f"Found an error: {bad}") # TRY401 -24 | logger.exception(f"Found an error: {bad}") # TRY401 - | ^^^ TRY401 -25 | -26 | if True: - | - -TRY401.py:27:49: TRY401 Redundant exception object included in `logging.exception` call - | -26 | if True: -27 | logger.exception(f"Found an error: {bad}") # TRY401 - | ^^^ TRY401 - | - -TRY401.py:39:47: TRY401 Redundant exception object included in `logging.exception` call - | -37 | ... -38 | except Exception as ex: -39 | logger.exception(f"Logging an error: {ex}") # TRY401 - | ^^ TRY401 - | - -TRY401.py:46:53: TRY401 Redundant exception object included in `logging.exception` call - | -44 | ... -45 | except Exception as ex: -46 | logger.exception("Logging an error: " + str(ex)) # TRY401 - | ^^ TRY401 - | - -TRY401.py:53:47: TRY401 Redundant exception object included in `logging.exception` call - | -51 | ... -52 | except Exception as ex: -53 | logger.exception("Logging an error:", ex) # TRY401 - | ^^ TRY401 - | - - diff --git a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__verbose-raise_TRY201.py.snap b/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__verbose-raise_TRY201.py.snap deleted file mode 100644 index 9ee76c288e..0000000000 --- a/crates/ruff/src/rules/tryceratops/snapshots/ruff__rules__tryceratops__tests__verbose-raise_TRY201.py.snap +++ /dev/null @@ -1,57 +0,0 @@ ---- -source: crates/ruff/src/rules/tryceratops/mod.rs ---- -TRY201.py:20:15: TRY201 [*] Use `raise` without specifying exception name - | -18 | except MyException as e: -19 | logger.exception("process failed") -20 | raise e - | ^ TRY201 - | - = help: Remove exception name - -ℹ Suggested fix -17 17 | process() -18 18 | except MyException as e: -19 19 | logger.exception("process failed") -20 |- raise e - 20 |+ raise -21 21 | -22 22 | -23 23 | def good(): - -TRY201.py:63:19: TRY201 [*] Use `raise` without specifying exception name - | -61 | logger.exception("process failed") -62 | if True: -63 | raise e - | ^ TRY201 - | - = help: Remove exception name - -ℹ Suggested fix -60 60 | except MyException as e: -61 61 | logger.exception("process failed") -62 62 | if True: -63 |- raise e - 63 |+ raise -64 64 | -65 65 | -66 66 | def bad_that_needs_recursion_2(): - -TRY201.py:74:23: TRY201 [*] Use `raise` without specifying exception name - | -73 | def foo(): -74 | raise e - | ^ TRY201 - | - = help: Remove exception name - -ℹ Suggested fix -71 71 | if True: -72 72 | -73 73 | def foo(): -74 |- raise e - 74 |+ raise - - diff --git a/crates/ruff/src/snapshots/ruff__linter__tests__import_sorting.snap b/crates/ruff/src/snapshots/ruff__linter__tests__import_sorting.snap deleted file mode 100644 index 1bba6e1056..0000000000 --- a/crates/ruff/src/snapshots/ruff__linter__tests__import_sorting.snap +++ /dev/null @@ -1,89 +0,0 @@ ---- -source: crates/ruff/src/linter.rs ---- -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 -5 | import collections -6 | # Newline should be added here - | - = help: Organize imports - -ℹ Fix - 1 |+import math - 2 |+import random -1 3 | from pathlib import Path -2 |-import random -3 |-import math -4 4 | from typing import Any -5 5 | import collections -6 6 | # Newline should be added here - -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 -4 | def foo(): -5 | pass - | - = help: Organize imports - -ℹ Fix -1 1 | from pathlib import Path -2 2 | import random -3 3 | import math - 4 |+import collections -4 5 | from typing import Any -5 |-import collections - 6 |+ - 7 |+ -6 8 | # Newline should be added here -7 9 | def foo(): -8 10 | pass - -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 -5 | --inline - | - = help: Organize imports - -ℹ Fix -6 6 | # Newline should be added here -7 7 | def foo(): -8 8 | pass - 9 |+import sys -9 10 | from pathlib import Path -10 |-import sys -11 11 | -12 12 | %matplotlib \ -13 13 | --inline - -isort.ipynb:cell 3:7:1: I001 [*] Import block is un-sorted or un-formatted - | -5 | --inline -6 | -7 | / import math -8 | | import abc - | - = help: Organize imports - -ℹ Fix -12 12 | %matplotlib \ -13 13 | --inline -14 14 | - 15 |+import abc -15 16 | import math -16 |-import abc - - diff --git a/crates/ruff/src/snapshots/ruff__linter__tests__ipy_escape_command.snap b/crates/ruff/src/snapshots/ruff__linter__tests__ipy_escape_command.snap deleted file mode 100644 index c471bd56aa..0000000000 --- a/crates/ruff/src/snapshots/ruff__linter__tests__ipy_escape_command.snap +++ /dev/null @@ -1,23 +0,0 @@ ---- -source: crates/ruff/src/linter.rs ---- -ipy_escape_command.ipynb:cell 1:5:8: F401 [*] `os` imported but unused - | -3 | %matplotlib inline -4 | -5 | import os - | ^^ F401 -6 | -7 | _ = math.pi - | - = help: Remove unused import: `os` - -ℹ Fix -2 2 | -3 3 | %matplotlib inline -4 4 | -5 |-import os -6 5 | -7 6 | _ = math.pi - - diff --git a/crates/ruff/src/snapshots/ruff__linter__tests__unused_variable.snap b/crates/ruff/src/snapshots/ruff__linter__tests__unused_variable.snap deleted file mode 100644 index 5557899715..0000000000 --- a/crates/ruff/src/snapshots/ruff__linter__tests__unused_variable.snap +++ /dev/null @@ -1,72 +0,0 @@ ---- -source: crates/ruff/src/linter.rs ---- -unused_variable.ipynb:cell 1:2:5: F841 [*] Local variable `foo1` is assigned to but never used - | -1 | def f(): -2 | foo1 = %matplotlib --list - | ^^^^ F841 -3 | foo2: list[str] = %matplotlib --list - | - = help: Remove assignment to unused variable `foo1` - -ℹ Suggested fix -1 1 | def f(): -2 |- foo1 = %matplotlib --list - 2 |+ %matplotlib --list -3 3 | foo2: list[str] = %matplotlib --list -4 4 | def f(): -5 5 | bar1 = !pwd - -unused_variable.ipynb:cell 1:3:5: F841 [*] Local variable `foo2` is assigned to but never used - | -1 | def f(): -2 | foo1 = %matplotlib --list -3 | foo2: list[str] = %matplotlib --list - | ^^^^ F841 - | - = help: Remove assignment to unused variable `foo2` - -ℹ Suggested fix -1 1 | def f(): -2 2 | foo1 = %matplotlib --list -3 |- foo2: list[str] = %matplotlib --list - 3 |+ %matplotlib --list -4 4 | def f(): -5 5 | bar1 = !pwd -6 6 | bar2: str = !pwd - -unused_variable.ipynb:cell 2:2:5: F841 [*] Local variable `bar1` is assigned to but never used - | -1 | def f(): -2 | bar1 = !pwd - | ^^^^ F841 -3 | bar2: str = !pwd - | - = help: Remove assignment to unused variable `bar1` - -ℹ Suggested fix -2 2 | foo1 = %matplotlib --list -3 3 | foo2: list[str] = %matplotlib --list -4 4 | def f(): -5 |- bar1 = !pwd - 5 |+ !pwd -6 6 | bar2: str = !pwd - -unused_variable.ipynb:cell 2:3:5: F841 [*] Local variable `bar2` is assigned to but never used - | -1 | def f(): -2 | bar1 = !pwd -3 | bar2: str = !pwd - | ^^^^ F841 - | - = help: Remove assignment to unused variable `bar2` - -ℹ Suggested fix -3 3 | foo2: list[str] = %matplotlib --list -4 4 | def f(): -5 5 | bar1 = !pwd -6 |- bar2: str = !pwd - 6 |+ !pwd - - diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__flake8_exemption_all.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__flake8_exemption_all.snap deleted file mode 100644 index 55b08ffd6f..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__flake8_exemption_all.snap +++ /dev/null @@ -1,9 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "ParsedFileExemption::try_extract(source)" ---- -Ok( - Some( - All, - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__flake8_exemption_all_case_insensitive.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__flake8_exemption_all_case_insensitive.snap deleted file mode 100644 index 55b08ffd6f..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__flake8_exemption_all_case_insensitive.snap +++ /dev/null @@ -1,9 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "ParsedFileExemption::try_extract(source)" ---- -Ok( - Some( - All, - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__flake8_exemption_all_no_space.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__flake8_exemption_all_no_space.snap deleted file mode 100644 index 55b08ffd6f..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__flake8_exemption_all_no_space.snap +++ /dev/null @@ -1,9 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "ParsedFileExemption::try_extract(source)" ---- -Ok( - Some( - All, - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__flake8_exemption_codes.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__flake8_exemption_codes.snap deleted file mode 100644 index b45c9ca1ae..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__flake8_exemption_codes.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "ParsedFileExemption::try_extract(source)" ---- -Ok( - Some( - Codes( - [ - "F401", - "F841", - ], - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_all.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_all.snap deleted file mode 100644 index 806987e18b..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_all.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - All( - All { - range: 0..6, - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_all_case_insensitive.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_all_case_insensitive.snap deleted file mode 100644 index 806987e18b..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_all_case_insensitive.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - All( - All { - range: 0..6, - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_all_leading_comment.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_all_leading_comment.snap deleted file mode 100644 index bd4fea2744..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_all_leading_comment.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - All( - All { - range: 35..41, - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_all_multi_space.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_all_multi_space.snap deleted file mode 100644 index b7fa476cc1..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_all_multi_space.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - All( - All { - range: 0..7, - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_all_no_space.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_all_no_space.snap deleted file mode 100644 index b5dcc889b8..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_all_no_space.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - All( - All { - range: 0..5, - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_all_trailing_comment.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_all_trailing_comment.snap deleted file mode 100644 index 806987e18b..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_all_trailing_comment.snap +++ /dev/null @@ -1,13 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - All( - All { - range: 0..6, - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_code.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_code.snap deleted file mode 100644 index bee06c0364..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_code.snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - Codes( - Codes { - range: 0..12, - codes: [ - "F401", - ], - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_code_case_insensitive.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_code_case_insensitive.snap deleted file mode 100644 index bee06c0364..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_code_case_insensitive.snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - Codes( - Codes { - range: 0..12, - codes: [ - "F401", - ], - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_code_leading_comment.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_code_leading_comment.snap deleted file mode 100644 index 4577119d57..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_code_leading_comment.snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - Codes( - Codes { - range: 35..47, - codes: [ - "F401", - ], - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_code_multi_space.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_code_multi_space.snap deleted file mode 100644 index 4b6104870f..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_code_multi_space.snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - Codes( - Codes { - range: 0..13, - codes: [ - "F401", - ], - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_code_no_space.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_code_no_space.snap deleted file mode 100644 index 5f3e8124ff..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_code_no_space.snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - Codes( - Codes { - range: 0..10, - codes: [ - "F401", - ], - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_code_trailing_comment.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_code_trailing_comment.snap deleted file mode 100644 index bee06c0364..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_code_trailing_comment.snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - Codes( - Codes { - range: 0..12, - codes: [ - "F401", - ], - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_codes.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_codes.snap deleted file mode 100644 index 65e429c7af..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_codes.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - Codes( - Codes { - range: 0..18, - codes: [ - "F401", - "F841", - ], - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_codes_case_insensitive.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_codes_case_insensitive.snap deleted file mode 100644 index 65e429c7af..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_codes_case_insensitive.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - Codes( - Codes { - range: 0..18, - codes: [ - "F401", - "F841", - ], - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_codes_leading_comment.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_codes_leading_comment.snap deleted file mode 100644 index 9f72b14ab0..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_codes_leading_comment.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - Codes( - Codes { - range: 35..53, - codes: [ - "F401", - "F841", - ], - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_codes_multi_space.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_codes_multi_space.snap deleted file mode 100644 index c4e9c8643c..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_codes_multi_space.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - Codes( - Codes { - range: 0..20, - codes: [ - "F401", - "F841", - ], - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_codes_no_space.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_codes_no_space.snap deleted file mode 100644 index 4c699e253f..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_codes_no_space.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - Codes( - Codes { - range: 0..15, - codes: [ - "F401", - "F841", - ], - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_codes_trailing_comment.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_codes_trailing_comment.snap deleted file mode 100644 index 65e429c7af..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_codes_trailing_comment.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - Codes( - Codes { - range: 0..18, - codes: [ - "F401", - "F841", - ], - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_invalid_codes.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_invalid_codes.snap deleted file mode 100644 index deb7795314..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_invalid_codes.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Err( - MissingCodes, -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_invalid_suffix.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_invalid_suffix.snap deleted file mode 100644 index 0e5602b979..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_invalid_suffix.snap +++ /dev/null @@ -1,7 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Err( - InvalidSuffix, -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_leading_space.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_leading_space.snap deleted file mode 100644 index 47f626e011..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_leading_space.snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - Codes( - Codes { - range: 4..16, - codes: [ - "F401", - ], - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_trailing_space.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_trailing_space.snap deleted file mode 100644 index bee06c0364..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__noqa_trailing_space.snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "Directive::try_extract(source, TextSize::default())" ---- -Ok( - Some( - Codes( - Codes { - range: 0..12, - codes: [ - "F401", - ], - }, - ), - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__ruff_exemption_all.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__ruff_exemption_all.snap deleted file mode 100644 index 55b08ffd6f..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__ruff_exemption_all.snap +++ /dev/null @@ -1,9 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "ParsedFileExemption::try_extract(source)" ---- -Ok( - Some( - All, - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__ruff_exemption_all_case_insensitive.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__ruff_exemption_all_case_insensitive.snap deleted file mode 100644 index 55b08ffd6f..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__ruff_exemption_all_case_insensitive.snap +++ /dev/null @@ -1,9 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "ParsedFileExemption::try_extract(source)" ---- -Ok( - Some( - All, - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__ruff_exemption_all_no_space.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__ruff_exemption_all_no_space.snap deleted file mode 100644 index 55b08ffd6f..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__ruff_exemption_all_no_space.snap +++ /dev/null @@ -1,9 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "ParsedFileExemption::try_extract(source)" ---- -Ok( - Some( - All, - ), -) diff --git a/crates/ruff/src/snapshots/ruff__noqa__tests__ruff_exemption_codes.snap b/crates/ruff/src/snapshots/ruff__noqa__tests__ruff_exemption_codes.snap deleted file mode 100644 index b45c9ca1ae..0000000000 --- a/crates/ruff/src/snapshots/ruff__noqa__tests__ruff_exemption_codes.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/ruff/src/noqa.rs -expression: "ParsedFileExemption::try_extract(source)" ---- -Ok( - Some( - Codes( - [ - "F401", - "F841", - ], - ), - ), -) diff --git a/crates/ruff_benchmark/Cargo.toml b/crates/ruff_benchmark/Cargo.toml index afe80b0602..97f1e8607f 100644 --- a/crates/ruff_benchmark/Cargo.toml +++ b/crates/ruff_benchmark/Cargo.toml @@ -40,7 +40,7 @@ criterion = { version = "0.5.1", default-features = false } codspeed-criterion-compat = { version="2.2.0", default-features = false, optional = true} [dev-dependencies] -ruff.path = "../ruff" +ruff_linter.path = "../ruff_linter" ruff_python_ast.path = "../ruff_python_ast" ruff_python_formatter = { path = "../ruff_python_formatter" } ruff_python_index = { path = "../ruff_python_index" } diff --git a/crates/ruff_benchmark/benches/linter.rs b/crates/ruff_benchmark/benches/linter.rs index 91e77850e4..50f3f4be8b 100644 --- a/crates/ruff_benchmark/benches/linter.rs +++ b/crates/ruff_benchmark/benches/linter.rs @@ -1,12 +1,12 @@ -use ruff::linter::lint_only; -use ruff::settings::rule_table::RuleTable; -use ruff::settings::{flags, Settings}; -use ruff::source_kind::SourceKind; -use ruff::{registry::Rule, RuleSelector}; use ruff_benchmark::criterion::{ criterion_group, criterion_main, BenchmarkGroup, BenchmarkId, Criterion, Throughput, }; use ruff_benchmark::{TestCase, TestFile, TestFileDownloadError}; +use ruff_linter::linter::lint_only; +use ruff_linter::settings::rule_table::RuleTable; +use ruff_linter::settings::{flags, Settings}; +use ruff_linter::source_kind::SourceKind; +use ruff_linter::{registry::Rule, RuleSelector}; use ruff_python_ast::PySourceType; #[cfg(target_os = "windows")] diff --git a/crates/ruff_cli/Cargo.toml b/crates/ruff_cli/Cargo.toml index 6c37ed6028..d85843f8ab 100644 --- a/crates/ruff_cli/Cargo.toml +++ b/crates/ruff_cli/Cargo.toml @@ -14,14 +14,8 @@ readme = "../../README.md" [[bin]] name = "ruff" -# Since the name of the binary is the same as the name of the `ruff` crate -# running `cargo doc --no-deps --all` results in an `output filename collision` -# See also https://github.com/rust-lang/cargo/issues/6313. -# We therefore disable the documentation generation for the binary. -doc = false - [dependencies] -ruff = { path = "../ruff", features = ["clap"] } +ruff_linter = { path = "../ruff_linter", features = ["clap"] } ruff_cache = { path = "../ruff_cache" } ruff_diagnostics = { path = "../ruff_diagnostics" } ruff_formatter = { path = "../ruff_formatter" } diff --git a/crates/ruff_cli/src/args.rs b/crates/ruff_cli/src/args.rs index c08fd003e7..41daf170ff 100644 --- a/crates/ruff_cli/src/args.rs +++ b/crates/ruff_cli/src/args.rs @@ -4,13 +4,13 @@ use clap::{command, Parser}; use regex::Regex; use rustc_hash::FxHashMap; -use ruff::line_width::LineLength; -use ruff::logging::LogLevel; -use ruff::registry::Rule; -use ruff::settings::types::{ +use ruff_linter::line_width::LineLength; +use ruff_linter::logging::LogLevel; +use ruff_linter::registry::Rule; +use ruff_linter::settings::types::{ FilePattern, PatternPrefixPair, PerFileIgnore, PreviewMode, PythonVersion, SerializationFormat, }; -use ruff::{RuleSelector, RuleSelectorParser}; +use ruff_linter::{RuleSelector, RuleSelectorParser}; use ruff_workspace::configuration::{Configuration, RuleSelection}; use ruff_workspace::resolver::ConfigProcessor; diff --git a/crates/ruff_cli/src/cache.rs b/crates/ruff_cli/src/cache.rs index c5cae6dbb0..189c11dbb3 100644 --- a/crates/ruff_cli/src/cache.rs +++ b/crates/ruff_cli/src/cache.rs @@ -11,11 +11,11 @@ use anyhow::{Context, Result}; use rustc_hash::FxHashMap; use serde::{Deserialize, Serialize}; -use ruff::message::Message; -use ruff::settings::Settings; -use ruff::warn_user; use ruff_cache::{CacheKey, CacheKeyHasher}; use ruff_diagnostics::{DiagnosticKind, Fix}; +use ruff_linter::message::Message; +use ruff_linter::settings::Settings; +use ruff_linter::warn_user; use ruff_notebook::NotebookIndex; use ruff_python_ast::imports::ImportMap; use ruff_source_file::SourceFileBuilder; @@ -349,8 +349,8 @@ mod tests { use std::time::SystemTime; use itertools::Itertools; - use ruff::settings::{flags, AllSettings, Settings}; use ruff_cache::CACHE_DIR_NAME; + use ruff_linter::settings::{flags, AllSettings, Settings}; use crate::cache::RelativePathBuf; use crate::cache::{self, Cache, FileCache}; @@ -363,7 +363,7 @@ mod tests { use test_case::test_case; - #[test_case("../ruff/resources/test/fixtures", "ruff_tests/cache_same_results_ruff"; "ruff_fixtures")] + #[test_case("../ruff_linter/resources/test/fixtures", "ruff_tests/cache_same_results_ruff_linter"; "ruff_linter_fixtures")] #[test_case("../ruff_notebook/resources/test/fixtures", "ruff_tests/cache_same_results_ruff_notebook"; "ruff_notebook_fixtures")] fn same_results(package_root: &str, cache_dir_path: &str) { let mut cache_dir = temp_dir(); diff --git a/crates/ruff_cli/src/commands/add_noqa.rs b/crates/ruff_cli/src/commands/add_noqa.rs index 8c59c5df76..b49843a57f 100644 --- a/crates/ruff_cli/src/commands/add_noqa.rs +++ b/crates/ruff_cli/src/commands/add_noqa.rs @@ -6,8 +6,8 @@ use log::{debug, error}; #[cfg(not(target_family = "wasm"))] use rayon::prelude::*; -use ruff::linter::add_noqa_to_path; -use ruff::warn_user_once; +use ruff_linter::linter::add_noqa_to_path; +use ruff_linter::warn_user_once; use ruff_python_ast::{PySourceType, SourceType}; use ruff_workspace::resolver::{python_files_in_path, PyprojectConfig}; diff --git a/crates/ruff_cli/src/commands/check.rs b/crates/ruff_cli/src/commands/check.rs index b450b49e43..32599ca8c3 100644 --- a/crates/ruff_cli/src/commands/check.rs +++ b/crates/ruff_cli/src/commands/check.rs @@ -13,11 +13,11 @@ use log::{debug, error, warn}; use rayon::prelude::*; use rustc_hash::FxHashMap; -use ruff::message::Message; -use ruff::registry::Rule; -use ruff::settings::{flags, Settings}; -use ruff::{fs, warn_user_once, IOError}; use ruff_diagnostics::Diagnostic; +use ruff_linter::message::Message; +use ruff_linter::registry::Rule; +use ruff_linter::settings::{flags, Settings}; +use ruff_linter::{fs, warn_user_once, IOError}; use ruff_python_ast::imports::ImportMap; use ruff_source_file::SourceFileBuilder; use ruff_text_size::{TextRange, TextSize}; @@ -240,9 +240,9 @@ mod test { use rustc_hash::FxHashMap; use tempfile::TempDir; - use ruff::message::{Emitter, EmitterContext, TextEmitter}; - use ruff::registry::Rule; - use ruff::settings::{flags, AllSettings, CliSettings, Settings}; + use ruff_linter::message::{Emitter, EmitterContext, TextEmitter}; + use ruff_linter::registry::Rule; + use ruff_linter::settings::{flags, AllSettings, CliSettings, Settings}; use ruff_workspace::resolver::{PyprojectConfig, PyprojectDiscoveryStrategy}; use crate::args::Overrides; diff --git a/crates/ruff_cli/src/commands/check_stdin.rs b/crates/ruff_cli/src/commands/check_stdin.rs index e1fbf3f44d..cd7f6fa111 100644 --- a/crates/ruff_cli/src/commands/check_stdin.rs +++ b/crates/ruff_cli/src/commands/check_stdin.rs @@ -2,8 +2,8 @@ use std::path::Path; use anyhow::Result; -use ruff::packaging; -use ruff::settings::flags; +use ruff_linter::packaging; +use ruff_linter::settings::flags; use ruff_workspace::resolver::{python_file_at_path, PyprojectConfig}; use crate::args::Overrides; diff --git a/crates/ruff_cli/src/commands/clean.rs b/crates/ruff_cli/src/commands/clean.rs index d89f643a53..a514ac1640 100644 --- a/crates/ruff_cli/src/commands/clean.rs +++ b/crates/ruff_cli/src/commands/clean.rs @@ -6,9 +6,9 @@ use colored::Colorize; use path_absolutize::path_dedot; use walkdir::WalkDir; -use ruff::fs; -use ruff::logging::LogLevel; use ruff_cache::CACHE_DIR_NAME; +use ruff_linter::fs; +use ruff_linter::logging::LogLevel; /// Clear any caches in the current directory or any subdirectories. pub(crate) fn clean(level: LogLevel) -> Result<()> { diff --git a/crates/ruff_cli/src/commands/format.rs b/crates/ruff_cli/src/commands/format.rs index e150d73308..d9ca480a6f 100644 --- a/crates/ruff_cli/src/commands/format.rs +++ b/crates/ruff_cli/src/commands/format.rs @@ -12,11 +12,11 @@ use rayon::iter::{IntoParallelIterator, ParallelIterator}; use thiserror::Error; use tracing::{debug, warn}; -use ruff::fs; -use ruff::logging::LogLevel; -use ruff::settings::types::PreviewMode; -use ruff::warn_user_once; use ruff_formatter::LineWidth; +use ruff_linter::fs; +use ruff_linter::logging::LogLevel; +use ruff_linter::settings::types::PreviewMode; +use ruff_linter::warn_user_once; use ruff_python_ast::{PySourceType, SourceType}; use ruff_python_formatter::{format_module, FormatModuleError, PyFormatOptions}; use ruff_source_file::{find_newline, LineEnding}; diff --git a/crates/ruff_cli/src/commands/format_stdin.rs b/crates/ruff_cli/src/commands/format_stdin.rs index 0f3b7ab4ea..d0de2f9e4b 100644 --- a/crates/ruff_cli/src/commands/format_stdin.rs +++ b/crates/ruff_cli/src/commands/format_stdin.rs @@ -4,8 +4,8 @@ use std::path::Path; use anyhow::Result; use log::warn; -use ruff::settings::types::PreviewMode; use ruff_formatter::LineWidth; +use ruff_linter::settings::types::PreviewMode; use ruff_python_formatter::{format_module, PyFormatOptions}; use ruff_workspace::resolver::python_file_at_path; diff --git a/crates/ruff_cli/src/commands/linter.rs b/crates/ruff_cli/src/commands/linter.rs index 76d6845b06..083102c09c 100644 --- a/crates/ruff_cli/src/commands/linter.rs +++ b/crates/ruff_cli/src/commands/linter.rs @@ -7,7 +7,7 @@ use itertools::Itertools; use serde::Serialize; use strum::IntoEnumIterator; -use ruff::registry::{Linter, RuleNamespace}; +use ruff_linter::registry::{Linter, RuleNamespace}; use crate::args::HelpFormat; diff --git a/crates/ruff_cli/src/commands/rule.rs b/crates/ruff_cli/src/commands/rule.rs index 7593d2466e..f9b9f86c95 100644 --- a/crates/ruff_cli/src/commands/rule.rs +++ b/crates/ruff_cli/src/commands/rule.rs @@ -5,8 +5,8 @@ use serde::ser::SerializeSeq; use serde::{Serialize, Serializer}; use strum::IntoEnumIterator; -use ruff::registry::{Linter, Rule, RuleNamespace}; use ruff_diagnostics::AutofixKind; +use ruff_linter::registry::{Linter, Rule, RuleNamespace}; use crate::args::HelpFormat; diff --git a/crates/ruff_cli/src/commands/show_files.rs b/crates/ruff_cli/src/commands/show_files.rs index 1f6a972fe0..bcbd91c804 100644 --- a/crates/ruff_cli/src/commands/show_files.rs +++ b/crates/ruff_cli/src/commands/show_files.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; use anyhow::Result; use itertools::Itertools; -use ruff::warn_user_once; +use ruff_linter::warn_user_once; use ruff_workspace::resolver::{python_files_in_path, PyprojectConfig}; use crate::args::Overrides; diff --git a/crates/ruff_cli/src/diagnostics.rs b/crates/ruff_cli/src/diagnostics.rs index dc4e49e3e1..487fce997b 100644 --- a/crates/ruff_cli/src/diagnostics.rs +++ b/crates/ruff_cli/src/diagnostics.rs @@ -16,15 +16,15 @@ use rustc_hash::FxHashMap; use similar::TextDiff; use thiserror::Error; -use ruff::linter::{lint_fix, lint_only, FixTable, FixerResult, LinterResult}; -use ruff::logging::DisplayParseError; -use ruff::message::Message; -use ruff::pyproject_toml::lint_pyproject_toml; -use ruff::registry::AsRule; -use ruff::settings::{flags, Settings}; -use ruff::source_kind::SourceKind; -use ruff::{fs, IOError, SyntaxError}; use ruff_diagnostics::Diagnostic; +use ruff_linter::linter::{lint_fix, lint_only, FixTable, FixerResult, LinterResult}; +use ruff_linter::logging::DisplayParseError; +use ruff_linter::message::Message; +use ruff_linter::pyproject_toml::lint_pyproject_toml; +use ruff_linter::registry::AsRule; +use ruff_linter::settings::{flags, Settings}; +use ruff_linter::source_kind::SourceKind; +use ruff_linter::{fs, IOError, SyntaxError}; use ruff_macros::CacheKey; use ruff_notebook::{Cell, Notebook, NotebookError, NotebookIndex}; use ruff_python_ast::imports::ImportMap; diff --git a/crates/ruff_cli/src/lib.rs b/crates/ruff_cli/src/lib.rs index 8e1b9d6cbe..4fb4dc94da 100644 --- a/crates/ruff_cli/src/lib.rs +++ b/crates/ruff_cli/src/lib.rs @@ -9,10 +9,10 @@ use clap::CommandFactory; use log::warn; use notify::{recommended_watcher, RecursiveMode, Watcher}; -use ruff::logging::{set_up_logging, LogLevel}; -use ruff::settings::types::SerializationFormat; -use ruff::settings::{flags, CliSettings}; -use ruff::{fs, warn_user_once}; +use ruff_linter::logging::{set_up_logging, LogLevel}; +use ruff_linter::settings::types::SerializationFormat; +use ruff_linter::settings::{flags, CliSettings}; +use ruff_linter::{fs, warn_user_once}; use crate::args::{Args, CheckCommand, Command, FormatCommand}; use crate::printer::{Flags as PrinterFlags, Printer}; diff --git a/crates/ruff_cli/src/printer.rs b/crates/ruff_cli/src/printer.rs index ea6c50d7cc..07757fed83 100644 --- a/crates/ruff_cli/src/printer.rs +++ b/crates/ruff_cli/src/printer.rs @@ -10,17 +10,17 @@ use itertools::{iterate, Itertools}; use rustc_hash::FxHashMap; use serde::Serialize; -use ruff::fs::relativize_path; -use ruff::linter::FixTable; -use ruff::logging::LogLevel; -use ruff::message::{ +use ruff_linter::fs::relativize_path; +use ruff_linter::linter::FixTable; +use ruff_linter::logging::LogLevel; +use ruff_linter::message::{ AzureEmitter, Emitter, EmitterContext, GithubEmitter, GitlabEmitter, GroupedEmitter, JsonEmitter, JsonLinesEmitter, JunitEmitter, PylintEmitter, TextEmitter, }; -use ruff::notify_user; -use ruff::registry::{AsRule, Rule}; -use ruff::settings::flags; -use ruff::settings::types::SerializationFormat; +use ruff_linter::notify_user; +use ruff_linter::registry::{AsRule, Rule}; +use ruff_linter::settings::flags; +use ruff_linter::settings::types::SerializationFormat; use crate::diagnostics::Diagnostics; diff --git a/crates/ruff_cli/tests/black_compatibility_test.rs b/crates/ruff_cli/tests/black_compatibility_test.rs index fb66e2e6dd..53159716e7 100644 --- a/crates/ruff_cli/tests/black_compatibility_test.rs +++ b/crates/ruff_cli/tests/black_compatibility_test.rs @@ -13,7 +13,7 @@ use insta_cmd::get_cargo_bin; use log::info; use walkdir::WalkDir; -use ruff::logging::{set_up_logging, LogLevel}; +use ruff_linter::logging::{set_up_logging, LogLevel}; /// Handles `blackd` process and allows submitting code to it for formatting. struct Blackd { diff --git a/crates/ruff_dev/Cargo.toml b/crates/ruff_dev/Cargo.toml index c8bee0c03b..79a0ffc3f5 100644 --- a/crates/ruff_dev/Cargo.toml +++ b/crates/ruff_dev/Cargo.toml @@ -11,7 +11,7 @@ repository = { workspace = true } license = { workspace = true } [dependencies] -ruff = { path = "../ruff", features = ["schemars"] } +ruff_linter = { path = "../ruff_linter", features = ["schemars"] } ruff_cli = { path = "../ruff_cli" } ruff_diagnostics = { path = "../ruff_diagnostics" } ruff_formatter = { path = "../ruff_formatter" } diff --git a/crates/ruff_dev/src/format_dev.rs b/crates/ruff_dev/src/format_dev.rs index fa80101326..fc7c67e6b7 100644 --- a/crates/ruff_dev/src/format_dev.rs +++ b/crates/ruff_dev/src/format_dev.rs @@ -18,7 +18,7 @@ use imara_diff::{diff, Algorithm}; use indicatif::ProgressStyle; #[cfg_attr(feature = "singlethreaded", allow(unused_imports))] use rayon::iter::{IntoParallelIterator, ParallelIterator}; -use ruff::line_width::LineLength; +use ruff_linter::line_width::LineLength; use serde::Deserialize; use similar::{ChangeTag, TextDiff}; use tempfile::NamedTempFile; @@ -29,11 +29,11 @@ use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; use tracing_subscriber::EnvFilter; -use ruff::logging::LogLevel; -use ruff::settings::types::{FilePattern, FilePatternSet}; use ruff_cli::args::{FormatCommand, LogLevelArgs}; use ruff_cli::resolve::resolve; use ruff_formatter::{FormatError, LineWidth, PrintError}; +use ruff_linter::logging::LogLevel; +use ruff_linter::settings::types::{FilePattern, FilePatternSet}; use ruff_python_formatter::{ format_module, FormatModuleError, MagicTrailingComma, PyFormatOptions, }; diff --git a/crates/ruff_dev/src/generate_docs.rs b/crates/ruff_dev/src/generate_docs.rs index e1ce27360e..3cbb295509 100644 --- a/crates/ruff_dev/src/generate_docs.rs +++ b/crates/ruff_dev/src/generate_docs.rs @@ -8,8 +8,8 @@ use anyhow::Result; use regex::{Captures, Regex}; use strum::IntoEnumIterator; -use ruff::registry::{Linter, Rule, RuleNamespace}; use ruff_diagnostics::AutofixKind; +use ruff_linter::registry::{Linter, Rule, RuleNamespace}; use ruff_workspace::options::Options; use crate::ROOT_DIR; diff --git a/crates/ruff_dev/src/generate_rules_table.rs b/crates/ruff_dev/src/generate_rules_table.rs index 7e9d3d9431..76deeeb8b2 100644 --- a/crates/ruff_dev/src/generate_rules_table.rs +++ b/crates/ruff_dev/src/generate_rules_table.rs @@ -5,9 +5,9 @@ use itertools::Itertools; use strum::IntoEnumIterator; -use ruff::registry::{Linter, Rule, RuleNamespace}; -use ruff::upstream_categories::UpstreamCategoryAndPrefix; use ruff_diagnostics::AutofixKind; +use ruff_linter::registry::{Linter, Rule, RuleNamespace}; +use ruff_linter::upstream_categories::UpstreamCategoryAndPrefix; use ruff_workspace::options::Options; const FIX_SYMBOL: &str = "🛠️"; diff --git a/crates/ruff_dev/src/main.rs b/crates/ruff_dev/src/main.rs index e3857332cb..e4e7a43d69 100644 --- a/crates/ruff_dev/src/main.rs +++ b/crates/ruff_dev/src/main.rs @@ -4,8 +4,8 @@ use anyhow::Result; use clap::{Parser, Subcommand}; -use ruff::logging::{set_up_logging, LogLevel}; use ruff_cli::check; +use ruff_linter::logging::{set_up_logging, LogLevel}; use std::process::ExitCode; mod format_dev; diff --git a/crates/ruff/Cargo.toml b/crates/ruff_linter/Cargo.toml similarity index 98% rename from crates/ruff/Cargo.toml rename to crates/ruff_linter/Cargo.toml index d9a464b785..cecd1d42bf 100644 --- a/crates/ruff/Cargo.toml +++ b/crates/ruff_linter/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "ruff" +name = "ruff_linter" version = "0.0.290" publish = false authors = { workspace = true } @@ -9,10 +9,8 @@ homepage = { workspace = true } documentation = { workspace = true } repository = { workspace = true } license = { workspace = true } -readme = "README.md" [lib] -name = "ruff" [dependencies] ruff_cache = { path = "../ruff_cache" } diff --git a/crates/ruff/resources/test/disallowed_rule_names.txt b/crates/ruff_linter/resources/test/disallowed_rule_names.txt similarity index 100% rename from crates/ruff/resources/test/disallowed_rule_names.txt rename to crates/ruff_linter/resources/test/disallowed_rule_names.txt diff --git a/crates/ruff/resources/test/fixtures/README.md b/crates/ruff_linter/resources/test/fixtures/README.md similarity index 100% rename from crates/ruff/resources/test/fixtures/README.md rename to crates/ruff_linter/resources/test/fixtures/README.md diff --git a/crates/ruff/resources/test/fixtures/airflow/AIR001.py b/crates/ruff_linter/resources/test/fixtures/airflow/AIR001.py similarity index 100% rename from crates/ruff/resources/test/fixtures/airflow/AIR001.py rename to crates/ruff_linter/resources/test/fixtures/airflow/AIR001.py diff --git a/crates/ruff/resources/test/fixtures/control-flow-graph/assert.py b/crates/ruff_linter/resources/test/fixtures/control-flow-graph/assert.py similarity index 100% rename from crates/ruff/resources/test/fixtures/control-flow-graph/assert.py rename to crates/ruff_linter/resources/test/fixtures/control-flow-graph/assert.py diff --git a/crates/ruff/resources/test/fixtures/control-flow-graph/async-for.py b/crates/ruff_linter/resources/test/fixtures/control-flow-graph/async-for.py similarity index 100% rename from crates/ruff/resources/test/fixtures/control-flow-graph/async-for.py rename to crates/ruff_linter/resources/test/fixtures/control-flow-graph/async-for.py diff --git a/crates/ruff/resources/test/fixtures/control-flow-graph/for.py b/crates/ruff_linter/resources/test/fixtures/control-flow-graph/for.py similarity index 100% rename from crates/ruff/resources/test/fixtures/control-flow-graph/for.py rename to crates/ruff_linter/resources/test/fixtures/control-flow-graph/for.py diff --git a/crates/ruff/resources/test/fixtures/control-flow-graph/if.py b/crates/ruff_linter/resources/test/fixtures/control-flow-graph/if.py similarity index 100% rename from crates/ruff/resources/test/fixtures/control-flow-graph/if.py rename to crates/ruff_linter/resources/test/fixtures/control-flow-graph/if.py diff --git a/crates/ruff/resources/test/fixtures/control-flow-graph/match.py b/crates/ruff_linter/resources/test/fixtures/control-flow-graph/match.py similarity index 100% rename from crates/ruff/resources/test/fixtures/control-flow-graph/match.py rename to crates/ruff_linter/resources/test/fixtures/control-flow-graph/match.py diff --git a/crates/ruff/resources/test/fixtures/control-flow-graph/raise.py b/crates/ruff_linter/resources/test/fixtures/control-flow-graph/raise.py similarity index 100% rename from crates/ruff/resources/test/fixtures/control-flow-graph/raise.py rename to crates/ruff_linter/resources/test/fixtures/control-flow-graph/raise.py diff --git a/crates/ruff/resources/test/fixtures/control-flow-graph/simple.py b/crates/ruff_linter/resources/test/fixtures/control-flow-graph/simple.py similarity index 100% rename from crates/ruff/resources/test/fixtures/control-flow-graph/simple.py rename to crates/ruff_linter/resources/test/fixtures/control-flow-graph/simple.py diff --git a/crates/ruff/resources/test/fixtures/control-flow-graph/try.py b/crates/ruff_linter/resources/test/fixtures/control-flow-graph/try.py similarity index 100% rename from crates/ruff/resources/test/fixtures/control-flow-graph/try.py rename to crates/ruff_linter/resources/test/fixtures/control-flow-graph/try.py diff --git a/crates/ruff/resources/test/fixtures/control-flow-graph/while.py b/crates/ruff_linter/resources/test/fixtures/control-flow-graph/while.py similarity index 100% rename from crates/ruff/resources/test/fixtures/control-flow-graph/while.py rename to crates/ruff_linter/resources/test/fixtures/control-flow-graph/while.py diff --git a/crates/ruff/resources/test/fixtures/eradicate/ERA001.py b/crates/ruff_linter/resources/test/fixtures/eradicate/ERA001.py similarity index 100% rename from crates/ruff/resources/test/fixtures/eradicate/ERA001.py rename to crates/ruff_linter/resources/test/fixtures/eradicate/ERA001.py diff --git a/crates/ruff/resources/test/fixtures/filesystem/excluded_file.py b/crates/ruff_linter/resources/test/fixtures/filesystem/excluded_file.py similarity index 100% rename from crates/ruff/resources/test/fixtures/filesystem/excluded_file.py rename to crates/ruff_linter/resources/test/fixtures/filesystem/excluded_file.py diff --git a/crates/ruff/resources/test/fixtures/filesystem/with_excluded_directory/__init__.py b/crates/ruff_linter/resources/test/fixtures/filesystem/with_excluded_directory/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/filesystem/with_excluded_directory/__init__.py rename to crates/ruff_linter/resources/test/fixtures/filesystem/with_excluded_directory/__init__.py diff --git a/crates/ruff/resources/test/fixtures/filesystem/with_excluded_directory/migrations/__init__.py b/crates/ruff_linter/resources/test/fixtures/filesystem/with_excluded_directory/migrations/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/filesystem/with_excluded_directory/migrations/__init__.py rename to crates/ruff_linter/resources/test/fixtures/filesystem/with_excluded_directory/migrations/__init__.py diff --git a/crates/ruff/resources/test/fixtures/filesystem/with_excluded_directory/migrations/migration.py b/crates/ruff_linter/resources/test/fixtures/filesystem/with_excluded_directory/migrations/migration.py similarity index 100% rename from crates/ruff/resources/test/fixtures/filesystem/with_excluded_directory/migrations/migration.py rename to crates/ruff_linter/resources/test/fixtures/filesystem/with_excluded_directory/migrations/migration.py diff --git a/crates/ruff/resources/test/fixtures/filesystem/with_excluded_file/other_excluded_file.py b/crates/ruff_linter/resources/test/fixtures/filesystem/with_excluded_file/other_excluded_file.py similarity index 100% rename from crates/ruff/resources/test/fixtures/filesystem/with_excluded_file/other_excluded_file.py rename to crates/ruff_linter/resources/test/fixtures/filesystem/with_excluded_file/other_excluded_file.py diff --git a/crates/ruff/resources/test/fixtures/flake8_2020/YTT101.py b/crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT101.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_2020/YTT101.py rename to crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT101.py diff --git a/crates/ruff/resources/test/fixtures/flake8_2020/YTT102.py b/crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT102.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_2020/YTT102.py rename to crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT102.py diff --git a/crates/ruff/resources/test/fixtures/flake8_2020/YTT103.py b/crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT103.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_2020/YTT103.py rename to crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT103.py diff --git a/crates/ruff/resources/test/fixtures/flake8_2020/YTT201.py b/crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT201.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_2020/YTT201.py rename to crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT201.py diff --git a/crates/ruff/resources/test/fixtures/flake8_2020/YTT202.py b/crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT202.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_2020/YTT202.py rename to crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT202.py diff --git a/crates/ruff/resources/test/fixtures/flake8_2020/YTT203.py b/crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT203.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_2020/YTT203.py rename to crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT203.py diff --git a/crates/ruff/resources/test/fixtures/flake8_2020/YTT204.py b/crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT204.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_2020/YTT204.py rename to crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT204.py diff --git a/crates/ruff/resources/test/fixtures/flake8_2020/YTT301.py b/crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT301.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_2020/YTT301.py rename to crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT301.py diff --git a/crates/ruff/resources/test/fixtures/flake8_2020/YTT302.py b/crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT302.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_2020/YTT302.py rename to crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT302.py diff --git a/crates/ruff/resources/test/fixtures/flake8_2020/YTT303.py b/crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT303.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_2020/YTT303.py rename to crates/ruff_linter/resources/test/fixtures/flake8_2020/YTT303.py diff --git a/crates/ruff/resources/test/fixtures/flake8_annotations/allow_nested_overload.py b/crates/ruff_linter/resources/test/fixtures/flake8_annotations/allow_nested_overload.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_annotations/allow_nested_overload.py rename to crates/ruff_linter/resources/test/fixtures/flake8_annotations/allow_nested_overload.py diff --git a/crates/ruff/resources/test/fixtures/flake8_annotations/allow_overload.py b/crates/ruff_linter/resources/test/fixtures/flake8_annotations/allow_overload.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_annotations/allow_overload.py rename to crates/ruff_linter/resources/test/fixtures/flake8_annotations/allow_overload.py diff --git a/crates/ruff/resources/test/fixtures/flake8_annotations/allow_star_arg_any.py b/crates/ruff_linter/resources/test/fixtures/flake8_annotations/allow_star_arg_any.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_annotations/allow_star_arg_any.py rename to crates/ruff_linter/resources/test/fixtures/flake8_annotations/allow_star_arg_any.py diff --git a/crates/ruff/resources/test/fixtures/flake8_annotations/annotation_presence.py b/crates/ruff_linter/resources/test/fixtures/flake8_annotations/annotation_presence.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_annotations/annotation_presence.py rename to crates/ruff_linter/resources/test/fixtures/flake8_annotations/annotation_presence.py diff --git a/crates/ruff/resources/test/fixtures/flake8_annotations/ignore_fully_untyped.py b/crates/ruff_linter/resources/test/fixtures/flake8_annotations/ignore_fully_untyped.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_annotations/ignore_fully_untyped.py rename to crates/ruff_linter/resources/test/fixtures/flake8_annotations/ignore_fully_untyped.py diff --git a/crates/ruff/resources/test/fixtures/flake8_annotations/mypy_init_return.py b/crates/ruff_linter/resources/test/fixtures/flake8_annotations/mypy_init_return.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_annotations/mypy_init_return.py rename to crates/ruff_linter/resources/test/fixtures/flake8_annotations/mypy_init_return.py diff --git a/crates/ruff/resources/test/fixtures/flake8_annotations/simple_magic_methods.py b/crates/ruff_linter/resources/test/fixtures/flake8_annotations/simple_magic_methods.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_annotations/simple_magic_methods.py rename to crates/ruff_linter/resources/test/fixtures/flake8_annotations/simple_magic_methods.py diff --git a/crates/ruff/resources/test/fixtures/flake8_annotations/suppress_dummy_args.py b/crates/ruff_linter/resources/test/fixtures/flake8_annotations/suppress_dummy_args.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_annotations/suppress_dummy_args.py rename to crates/ruff_linter/resources/test/fixtures/flake8_annotations/suppress_dummy_args.py diff --git a/crates/ruff/resources/test/fixtures/flake8_annotations/suppress_none_returning.py b/crates/ruff_linter/resources/test/fixtures/flake8_annotations/suppress_none_returning.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_annotations/suppress_none_returning.py rename to crates/ruff_linter/resources/test/fixtures/flake8_annotations/suppress_none_returning.py diff --git a/crates/ruff/resources/test/fixtures/flake8_async/ASYNC100.py b/crates/ruff_linter/resources/test/fixtures/flake8_async/ASYNC100.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_async/ASYNC100.py rename to crates/ruff_linter/resources/test/fixtures/flake8_async/ASYNC100.py diff --git a/crates/ruff/resources/test/fixtures/flake8_async/ASYNC101.py b/crates/ruff_linter/resources/test/fixtures/flake8_async/ASYNC101.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_async/ASYNC101.py rename to crates/ruff_linter/resources/test/fixtures/flake8_async/ASYNC101.py diff --git a/crates/ruff/resources/test/fixtures/flake8_async/ASYNC102.py b/crates/ruff_linter/resources/test/fixtures/flake8_async/ASYNC102.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_async/ASYNC102.py rename to crates/ruff_linter/resources/test/fixtures/flake8_async/ASYNC102.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S101.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S101.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S101.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S101.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S102.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S102.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S102.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S102.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S103.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S103.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S103.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S103.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S104.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S104.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S104.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S104.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S105.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S105.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S105.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S105.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S106.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S106.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S106.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S106.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S107.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S107.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S107.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S107.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S108.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S108.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S108.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S108.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S110.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S110.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S110.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S110.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S112.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S112.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S112.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S112.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S113.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S113.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S113.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S113.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S201.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S201.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S201.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S201.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S301.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S301.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S301.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S301.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S307.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S307.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S307.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S307.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S312.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S312.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S312.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S312.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S324.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S324.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S324.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S324.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S501.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S501.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S501.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S501.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S506.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S506.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S506.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S506.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S507.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S507.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S507.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S507.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S508.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S508.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S508.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S508.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S509.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S509.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S509.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S509.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S601.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S601.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S601.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S601.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S602.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S602.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S602.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S602.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S603.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S603.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S603.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S603.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S604.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S604.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S604.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S604.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S605.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S605.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S605.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S605.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S606.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S606.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S606.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S606.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S607.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S607.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S607.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S607.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S608.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S608.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S608.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S608.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S609.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S609.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S609.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S609.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S612.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S612.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S612.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S612.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bandit/S701.py b/crates/ruff_linter/resources/test/fixtures/flake8_bandit/S701.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bandit/S701.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bandit/S701.py diff --git a/crates/ruff/resources/test/fixtures/flake8_blind_except/BLE.py b/crates/ruff_linter/resources/test/fixtures/flake8_blind_except/BLE.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_blind_except/BLE.py rename to crates/ruff_linter/resources/test/fixtures/flake8_blind_except/BLE.py diff --git a/crates/ruff/resources/test/fixtures/flake8_boolean_trap/FBT.py b/crates/ruff_linter/resources/test/fixtures/flake8_boolean_trap/FBT.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_boolean_trap/FBT.py rename to crates/ruff_linter/resources/test/fixtures/flake8_boolean_trap/FBT.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B002.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B002.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B002.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B002.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B003.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B003.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B003.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B003.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B004.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B004.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B004.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B004.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B005.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B005.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B005.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B005.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B006_1.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B006_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B006_1.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B006_1.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B006_2.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B006_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B006_2.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B006_2.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B006_3.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B006_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B006_3.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B006_3.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B006_4.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B006_4.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B006_4.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B006_4.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B006_B008.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B006_B008.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B006_B008.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B006_B008.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B006_extended.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B006_extended.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B006_extended.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B006_extended.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B007.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B007.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B007.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B007.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B008_extended.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B008_extended.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B008_extended.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B008_extended.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B009_B010.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B009_B010.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B009_B010.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B009_B010.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B011.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B011.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B011.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B011.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B012.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B012.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B012.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B012.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B013.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B013.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B013.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B013.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B014.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B014.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B014.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B014.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B015.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B015.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B015.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B015.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B016.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B016.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B016.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B016.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B017.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B017.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B017.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B017.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B018.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B018.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B018.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B018.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B019.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B019.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B019.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B019.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B020.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B020.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B020.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B020.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B021.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B021.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B021.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B021.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B022.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B022.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B022.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B022.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B023.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B023.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B023.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B023.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B024.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B024.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B024.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B024.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B025.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B025.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B025.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B025.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B026.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B026.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B026.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B026.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B027.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B027.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B027.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B027.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B027.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B027.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B027.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B027.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B028.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B028.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B028.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B028.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B029.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B029.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B029.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B029.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B030.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B030.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B030.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B030.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B031.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B031.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B031.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B031.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B032.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B032.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B032.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B032.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B033.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B033.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B033.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B033.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B034.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B034.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B034.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B034.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B904.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B904.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B904.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B904.py diff --git a/crates/ruff/resources/test/fixtures/flake8_bugbear/B905.py b/crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B905.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_bugbear/B905.py rename to crates/ruff_linter/resources/test/fixtures/flake8_bugbear/B905.py diff --git a/crates/ruff/resources/test/fixtures/flake8_builtins/A001.py b/crates/ruff_linter/resources/test/fixtures/flake8_builtins/A001.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_builtins/A001.py rename to crates/ruff_linter/resources/test/fixtures/flake8_builtins/A001.py diff --git a/crates/ruff/resources/test/fixtures/flake8_builtins/A002.py b/crates/ruff_linter/resources/test/fixtures/flake8_builtins/A002.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_builtins/A002.py rename to crates/ruff_linter/resources/test/fixtures/flake8_builtins/A002.py diff --git a/crates/ruff/resources/test/fixtures/flake8_builtins/A003.py b/crates/ruff_linter/resources/test/fixtures/flake8_builtins/A003.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_builtins/A003.py rename to crates/ruff_linter/resources/test/fixtures/flake8_builtins/A003.py diff --git a/crates/ruff/resources/test/fixtures/flake8_commas/COM81.py b/crates/ruff_linter/resources/test/fixtures/flake8_commas/COM81.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_commas/COM81.py rename to crates/ruff_linter/resources/test/fixtures/flake8_commas/COM81.py diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C400.py b/crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C400.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_comprehensions/C400.py rename to crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C400.py diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C401.py b/crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C401.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_comprehensions/C401.py rename to crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C401.py diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C402.py b/crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C402.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_comprehensions/C402.py rename to crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C402.py diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C403.py b/crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C403.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_comprehensions/C403.py rename to crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C403.py diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C404.py b/crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C404.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_comprehensions/C404.py rename to crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C404.py diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C405.py b/crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C405.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_comprehensions/C405.py rename to crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C405.py diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C406.py b/crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C406.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_comprehensions/C406.py rename to crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C406.py diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C408.py b/crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C408.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_comprehensions/C408.py rename to crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C408.py diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C409.py b/crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C409.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_comprehensions/C409.py rename to crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C409.py diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C410.py b/crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C410.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_comprehensions/C410.py rename to crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C410.py diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C411.py b/crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C411.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_comprehensions/C411.py rename to crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C411.py diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C413.py b/crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C413.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_comprehensions/C413.py rename to crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C413.py diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C414.py b/crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C414.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_comprehensions/C414.py rename to crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C414.py diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C415.py b/crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C415.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_comprehensions/C415.py rename to crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C415.py diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C416.py b/crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C416.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_comprehensions/C416.py rename to crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C416.py diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C417.py b/crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C417.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_comprehensions/C417.py rename to crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C417.py diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C418.py b/crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C418.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_comprehensions/C418.py rename to crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C418.py diff --git a/crates/ruff/resources/test/fixtures/flake8_comprehensions/C419.py b/crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C419.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_comprehensions/C419.py rename to crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C419.py diff --git a/crates/ruff/resources/test/fixtures/flake8_datetimez/DTZ001.py b/crates/ruff_linter/resources/test/fixtures/flake8_datetimez/DTZ001.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_datetimez/DTZ001.py rename to crates/ruff_linter/resources/test/fixtures/flake8_datetimez/DTZ001.py diff --git a/crates/ruff/resources/test/fixtures/flake8_datetimez/DTZ002.py b/crates/ruff_linter/resources/test/fixtures/flake8_datetimez/DTZ002.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_datetimez/DTZ002.py rename to crates/ruff_linter/resources/test/fixtures/flake8_datetimez/DTZ002.py diff --git a/crates/ruff/resources/test/fixtures/flake8_datetimez/DTZ003.py b/crates/ruff_linter/resources/test/fixtures/flake8_datetimez/DTZ003.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_datetimez/DTZ003.py rename to crates/ruff_linter/resources/test/fixtures/flake8_datetimez/DTZ003.py diff --git a/crates/ruff/resources/test/fixtures/flake8_datetimez/DTZ004.py b/crates/ruff_linter/resources/test/fixtures/flake8_datetimez/DTZ004.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_datetimez/DTZ004.py rename to crates/ruff_linter/resources/test/fixtures/flake8_datetimez/DTZ004.py diff --git a/crates/ruff/resources/test/fixtures/flake8_datetimez/DTZ005.py b/crates/ruff_linter/resources/test/fixtures/flake8_datetimez/DTZ005.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_datetimez/DTZ005.py rename to crates/ruff_linter/resources/test/fixtures/flake8_datetimez/DTZ005.py diff --git a/crates/ruff/resources/test/fixtures/flake8_datetimez/DTZ006.py b/crates/ruff_linter/resources/test/fixtures/flake8_datetimez/DTZ006.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_datetimez/DTZ006.py rename to crates/ruff_linter/resources/test/fixtures/flake8_datetimez/DTZ006.py diff --git a/crates/ruff/resources/test/fixtures/flake8_datetimez/DTZ007.py b/crates/ruff_linter/resources/test/fixtures/flake8_datetimez/DTZ007.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_datetimez/DTZ007.py rename to crates/ruff_linter/resources/test/fixtures/flake8_datetimez/DTZ007.py diff --git a/crates/ruff/resources/test/fixtures/flake8_datetimez/DTZ011.py b/crates/ruff_linter/resources/test/fixtures/flake8_datetimez/DTZ011.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_datetimez/DTZ011.py rename to crates/ruff_linter/resources/test/fixtures/flake8_datetimez/DTZ011.py diff --git a/crates/ruff/resources/test/fixtures/flake8_datetimez/DTZ012.py b/crates/ruff_linter/resources/test/fixtures/flake8_datetimez/DTZ012.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_datetimez/DTZ012.py rename to crates/ruff_linter/resources/test/fixtures/flake8_datetimez/DTZ012.py diff --git a/crates/ruff/resources/test/fixtures/flake8_debugger/T100.py b/crates/ruff_linter/resources/test/fixtures/flake8_debugger/T100.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_debugger/T100.py rename to crates/ruff_linter/resources/test/fixtures/flake8_debugger/T100.py diff --git a/crates/ruff/resources/test/fixtures/flake8_django/DJ001.py b/crates/ruff_linter/resources/test/fixtures/flake8_django/DJ001.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_django/DJ001.py rename to crates/ruff_linter/resources/test/fixtures/flake8_django/DJ001.py diff --git a/crates/ruff/resources/test/fixtures/flake8_django/DJ003.py b/crates/ruff_linter/resources/test/fixtures/flake8_django/DJ003.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_django/DJ003.py rename to crates/ruff_linter/resources/test/fixtures/flake8_django/DJ003.py diff --git a/crates/ruff/resources/test/fixtures/flake8_django/DJ006.py b/crates/ruff_linter/resources/test/fixtures/flake8_django/DJ006.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_django/DJ006.py rename to crates/ruff_linter/resources/test/fixtures/flake8_django/DJ006.py diff --git a/crates/ruff/resources/test/fixtures/flake8_django/DJ007.py b/crates/ruff_linter/resources/test/fixtures/flake8_django/DJ007.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_django/DJ007.py rename to crates/ruff_linter/resources/test/fixtures/flake8_django/DJ007.py diff --git a/crates/ruff/resources/test/fixtures/flake8_django/DJ008.py b/crates/ruff_linter/resources/test/fixtures/flake8_django/DJ008.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_django/DJ008.py rename to crates/ruff_linter/resources/test/fixtures/flake8_django/DJ008.py diff --git a/crates/ruff/resources/test/fixtures/flake8_django/DJ012.py b/crates/ruff_linter/resources/test/fixtures/flake8_django/DJ012.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_django/DJ012.py rename to crates/ruff_linter/resources/test/fixtures/flake8_django/DJ012.py diff --git a/crates/ruff/resources/test/fixtures/flake8_django/DJ013.py b/crates/ruff_linter/resources/test/fixtures/flake8_django/DJ013.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_django/DJ013.py rename to crates/ruff_linter/resources/test/fixtures/flake8_django/DJ013.py diff --git a/crates/ruff/resources/test/fixtures/flake8_errmsg/EM.py b/crates/ruff_linter/resources/test/fixtures/flake8_errmsg/EM.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_errmsg/EM.py rename to crates/ruff_linter/resources/test/fixtures/flake8_errmsg/EM.py diff --git a/crates/ruff/resources/test/fixtures/flake8_executable/EXE001_1.py b/crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE001_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_executable/EXE001_1.py rename to crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE001_1.py diff --git a/crates/ruff/resources/test/fixtures/flake8_executable/EXE001_2.py b/crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE001_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_executable/EXE001_2.py rename to crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE001_2.py diff --git a/crates/ruff/resources/test/fixtures/flake8_executable/EXE001_3.py b/crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE001_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_executable/EXE001_3.py rename to crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE001_3.py diff --git a/crates/ruff/resources/test/fixtures/flake8_executable/EXE002_1.py b/crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE002_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_executable/EXE002_1.py rename to crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE002_1.py diff --git a/crates/ruff/resources/test/fixtures/flake8_executable/EXE002_2.py b/crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE002_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_executable/EXE002_2.py rename to crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE002_2.py diff --git a/crates/ruff/resources/test/fixtures/flake8_executable/EXE002_3.py b/crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE002_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_executable/EXE002_3.py rename to crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE002_3.py diff --git a/crates/ruff/resources/test/fixtures/flake8_executable/EXE003.py b/crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE003.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_executable/EXE003.py rename to crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE003.py diff --git a/crates/ruff/resources/test/fixtures/flake8_executable/EXE004_1.py b/crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE004_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_executable/EXE004_1.py rename to crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE004_1.py diff --git a/crates/ruff/resources/test/fixtures/flake8_executable/EXE004_2.py b/crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE004_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_executable/EXE004_2.py rename to crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE004_2.py diff --git a/crates/ruff/resources/test/fixtures/flake8_executable/EXE004_3.py b/crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE004_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_executable/EXE004_3.py rename to crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE004_3.py diff --git a/crates/ruff/resources/test/fixtures/flake8_executable/EXE004_4.py b/crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE004_4.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_executable/EXE004_4.py rename to crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE004_4.py diff --git a/crates/ruff/resources/test/fixtures/flake8_executable/EXE005_1.py b/crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE005_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_executable/EXE005_1.py rename to crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE005_1.py diff --git a/crates/ruff/resources/test/fixtures/flake8_executable/EXE005_2.py b/crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE005_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_executable/EXE005_2.py rename to crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE005_2.py diff --git a/crates/ruff/resources/test/fixtures/flake8_executable/EXE005_3.py b/crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE005_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_executable/EXE005_3.py rename to crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE005_3.py diff --git a/crates/ruff/resources/test/fixtures/flake8_fixme/T00.py b/crates/ruff_linter/resources/test/fixtures/flake8_fixme/T00.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_fixme/T00.py rename to crates/ruff_linter/resources/test/fixtures/flake8_fixme/T00.py diff --git a/crates/ruff/resources/test/fixtures/flake8_future_annotations/edge_case.py b/crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/edge_case.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_future_annotations/edge_case.py rename to crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/edge_case.py diff --git a/crates/ruff/resources/test/fixtures/flake8_future_annotations/from_typing_import.py b/crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/from_typing_import.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_future_annotations/from_typing_import.py rename to crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/from_typing_import.py diff --git a/crates/ruff/resources/test/fixtures/flake8_future_annotations/from_typing_import_many.py b/crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/from_typing_import_many.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_future_annotations/from_typing_import_many.py rename to crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/from_typing_import_many.py diff --git a/crates/ruff/resources/test/fixtures/flake8_future_annotations/import_typing.py b/crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/import_typing.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_future_annotations/import_typing.py rename to crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/import_typing.py diff --git a/crates/ruff/resources/test/fixtures/flake8_future_annotations/import_typing_as.py b/crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/import_typing_as.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_future_annotations/import_typing_as.py rename to crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/import_typing_as.py diff --git a/crates/ruff/resources/test/fixtures/flake8_future_annotations/no_future_import_uses_lowercase.py b/crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/no_future_import_uses_lowercase.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_future_annotations/no_future_import_uses_lowercase.py rename to crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/no_future_import_uses_lowercase.py diff --git a/crates/ruff/resources/test/fixtures/flake8_future_annotations/no_future_import_uses_union.py b/crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/no_future_import_uses_union.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_future_annotations/no_future_import_uses_union.py rename to crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/no_future_import_uses_union.py diff --git a/crates/ruff/resources/test/fixtures/flake8_future_annotations/no_future_import_uses_union_inner.py b/crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/no_future_import_uses_union_inner.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_future_annotations/no_future_import_uses_union_inner.py rename to crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/no_future_import_uses_union_inner.py diff --git a/crates/ruff/resources/test/fixtures/flake8_future_annotations/ok_no_types.py b/crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/ok_no_types.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_future_annotations/ok_no_types.py rename to crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/ok_no_types.py diff --git a/crates/ruff/resources/test/fixtures/flake8_future_annotations/ok_non_simplifiable_types.py b/crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/ok_non_simplifiable_types.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_future_annotations/ok_non_simplifiable_types.py rename to crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/ok_non_simplifiable_types.py diff --git a/crates/ruff/resources/test/fixtures/flake8_future_annotations/ok_uses_future.py b/crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/ok_uses_future.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_future_annotations/ok_uses_future.py rename to crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/ok_uses_future.py diff --git a/crates/ruff/resources/test/fixtures/flake8_future_annotations/ok_variable_name.py b/crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/ok_variable_name.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_future_annotations/ok_variable_name.py rename to crates/ruff_linter/resources/test/fixtures/flake8_future_annotations/ok_variable_name.py diff --git a/crates/ruff/resources/test/fixtures/flake8_gettext/INT001.py b/crates/ruff_linter/resources/test/fixtures/flake8_gettext/INT001.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_gettext/INT001.py rename to crates/ruff_linter/resources/test/fixtures/flake8_gettext/INT001.py diff --git a/crates/ruff/resources/test/fixtures/flake8_gettext/INT002.py b/crates/ruff_linter/resources/test/fixtures/flake8_gettext/INT002.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_gettext/INT002.py rename to crates/ruff_linter/resources/test/fixtures/flake8_gettext/INT002.py diff --git a/crates/ruff/resources/test/fixtures/flake8_gettext/INT003.py b/crates/ruff_linter/resources/test/fixtures/flake8_gettext/INT003.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_gettext/INT003.py rename to crates/ruff_linter/resources/test/fixtures/flake8_gettext/INT003.py diff --git a/crates/ruff/resources/test/fixtures/flake8_implicit_str_concat/ISC.py b/crates/ruff_linter/resources/test/fixtures/flake8_implicit_str_concat/ISC.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_implicit_str_concat/ISC.py rename to crates/ruff_linter/resources/test/fixtures/flake8_implicit_str_concat/ISC.py diff --git a/crates/ruff/resources/test/fixtures/flake8_import_conventions/custom.py b/crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/custom.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_import_conventions/custom.py rename to crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/custom.py diff --git a/crates/ruff/resources/test/fixtures/flake8_import_conventions/custom_banned.py b/crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/custom_banned.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_import_conventions/custom_banned.py rename to crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/custom_banned.py diff --git a/crates/ruff/resources/test/fixtures/flake8_import_conventions/custom_banned_from.py b/crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/custom_banned_from.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_import_conventions/custom_banned_from.py rename to crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/custom_banned_from.py diff --git a/crates/ruff/resources/test/fixtures/flake8_import_conventions/defaults.py b/crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/defaults.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_import_conventions/defaults.py rename to crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/defaults.py diff --git a/crates/ruff/resources/test/fixtures/flake8_import_conventions/from_imports.py b/crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/from_imports.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_import_conventions/from_imports.py rename to crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/from_imports.py diff --git a/crates/ruff/resources/test/fixtures/flake8_import_conventions/override_default.py b/crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/override_default.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_import_conventions/override_default.py rename to crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/override_default.py diff --git a/crates/ruff/resources/test/fixtures/flake8_import_conventions/remove_default.py b/crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/remove_default.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_import_conventions/remove_default.py rename to crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/remove_default.py diff --git a/crates/ruff/resources/test/fixtures/flake8_import_conventions/tricky.py b/crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/tricky.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_import_conventions/tricky.py rename to crates/ruff_linter/resources/test/fixtures/flake8_import_conventions/tricky.py diff --git a/crates/ruff/resources/test/fixtures/flake8_logging/LOG001.py b/crates/ruff_linter/resources/test/fixtures/flake8_logging/LOG001.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_logging/LOG001.py rename to crates/ruff_linter/resources/test/fixtures/flake8_logging/LOG001.py diff --git a/crates/ruff/resources/test/fixtures/flake8_logging/LOG002.py b/crates/ruff_linter/resources/test/fixtures/flake8_logging/LOG002.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_logging/LOG002.py rename to crates/ruff_linter/resources/test/fixtures/flake8_logging/LOG002.py diff --git a/crates/ruff/resources/test/fixtures/flake8_logging/LOG007.py b/crates/ruff_linter/resources/test/fixtures/flake8_logging/LOG007.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_logging/LOG007.py rename to crates/ruff_linter/resources/test/fixtures/flake8_logging/LOG007.py diff --git a/crates/ruff/resources/test/fixtures/flake8_logging/LOG009.py b/crates/ruff_linter/resources/test/fixtures/flake8_logging/LOG009.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_logging/LOG009.py rename to crates/ruff_linter/resources/test/fixtures/flake8_logging/LOG009.py diff --git a/crates/ruff/resources/test/fixtures/flake8_logging_format/G001.py b/crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G001.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_logging_format/G001.py rename to crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G001.py diff --git a/crates/ruff/resources/test/fixtures/flake8_logging_format/G002.py b/crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G002.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_logging_format/G002.py rename to crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G002.py diff --git a/crates/ruff/resources/test/fixtures/flake8_logging_format/G003.py b/crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G003.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_logging_format/G003.py rename to crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G003.py diff --git a/crates/ruff/resources/test/fixtures/flake8_logging_format/G004.py b/crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G004.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_logging_format/G004.py rename to crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G004.py diff --git a/crates/ruff/resources/test/fixtures/flake8_logging_format/G010.py b/crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G010.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_logging_format/G010.py rename to crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G010.py diff --git a/crates/ruff/resources/test/fixtures/flake8_logging_format/G101_1.py b/crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G101_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_logging_format/G101_1.py rename to crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G101_1.py diff --git a/crates/ruff/resources/test/fixtures/flake8_logging_format/G101_2.py b/crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G101_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_logging_format/G101_2.py rename to crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G101_2.py diff --git a/crates/ruff/resources/test/fixtures/flake8_logging_format/G201.py b/crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G201.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_logging_format/G201.py rename to crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G201.py diff --git a/crates/ruff/resources/test/fixtures/flake8_logging_format/G202.py b/crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G202.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_logging_format/G202.py rename to crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G202.py diff --git a/crates/ruff/resources/test/fixtures/flake8_logging_format/G_argparse_parser_error_ok.py b/crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G_argparse_parser_error_ok.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_logging_format/G_argparse_parser_error_ok.py rename to crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G_argparse_parser_error_ok.py diff --git a/crates/ruff/resources/test/fixtures/flake8_logging_format/G_extra_ok.py b/crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G_extra_ok.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_logging_format/G_extra_ok.py rename to crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G_extra_ok.py diff --git a/crates/ruff/resources/test/fixtures/flake8_logging_format/G_extra_str_format_ok.py b/crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G_extra_str_format_ok.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_logging_format/G_extra_str_format_ok.py rename to crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G_extra_str_format_ok.py diff --git a/crates/ruff/resources/test/fixtures/flake8_logging_format/G_simple_ok.py b/crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G_simple_ok.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_logging_format/G_simple_ok.py rename to crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G_simple_ok.py diff --git a/crates/ruff/resources/test/fixtures/flake8_logging_format/G_warnings_ok.py b/crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G_warnings_ok.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_logging_format/G_warnings_ok.py rename to crates/ruff_linter/resources/test/fixtures/flake8_logging_format/G_warnings_ok.py diff --git a/crates/ruff/resources/test/fixtures/flake8_no_pep420/test_fail_empty/example.py b/crates/ruff_linter/resources/test/fixtures/flake8_no_pep420/test_fail_empty/example.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_no_pep420/test_fail_empty/example.py rename to crates/ruff_linter/resources/test/fixtures/flake8_no_pep420/test_fail_empty/example.py diff --git a/crates/ruff/resources/test/fixtures/flake8_no_pep420/test_fail_nonempty/example.py b/crates/ruff_linter/resources/test/fixtures/flake8_no_pep420/test_fail_nonempty/example.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_no_pep420/test_fail_nonempty/example.py rename to crates/ruff_linter/resources/test/fixtures/flake8_no_pep420/test_fail_nonempty/example.py diff --git a/crates/ruff/resources/test/fixtures/flake8_no_pep420/test_fail_shebang/example.py b/crates/ruff_linter/resources/test/fixtures/flake8_no_pep420/test_fail_shebang/example.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_no_pep420/test_fail_shebang/example.py rename to crates/ruff_linter/resources/test/fixtures/flake8_no_pep420/test_fail_shebang/example.py diff --git a/crates/ruff/resources/test/fixtures/flake8_no_pep420/test_ignored/example.py b/crates/ruff_linter/resources/test/fixtures/flake8_no_pep420/test_ignored/example.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_no_pep420/test_ignored/example.py rename to crates/ruff_linter/resources/test/fixtures/flake8_no_pep420/test_ignored/example.py diff --git a/crates/ruff/resources/test/fixtures/flake8_no_pep420/test_pass_init/__init__.py b/crates/ruff_linter/resources/test/fixtures/flake8_no_pep420/test_pass_init/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_no_pep420/test_pass_init/__init__.py rename to crates/ruff_linter/resources/test/fixtures/flake8_no_pep420/test_pass_init/__init__.py diff --git a/crates/ruff/resources/test/fixtures/flake8_no_pep420/test_pass_init/example.py b/crates/ruff_linter/resources/test/fixtures/flake8_no_pep420/test_pass_init/example.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_no_pep420/test_pass_init/example.py rename to crates/ruff_linter/resources/test/fixtures/flake8_no_pep420/test_pass_init/example.py diff --git a/crates/ruff/resources/test/fixtures/flake8_no_pep420/test_pass_namespace_package/example.py b/crates/ruff_linter/resources/test/fixtures/flake8_no_pep420/test_pass_namespace_package/example.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_no_pep420/test_pass_namespace_package/example.py rename to crates/ruff_linter/resources/test/fixtures/flake8_no_pep420/test_pass_namespace_package/example.py diff --git a/crates/ruff/resources/test/fixtures/flake8_no_pep420/test_pass_pyi/example.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_no_pep420/test_pass_pyi/example.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_no_pep420/test_pass_pyi/example.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_no_pep420/test_pass_pyi/example.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_no_pep420/test_pass_script/script b/crates/ruff_linter/resources/test/fixtures/flake8_no_pep420/test_pass_script/script similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_no_pep420/test_pass_script/script rename to crates/ruff_linter/resources/test/fixtures/flake8_no_pep420/test_pass_script/script diff --git a/crates/ruff/resources/test/fixtures/flake8_pie/PIE790.py b/crates/ruff_linter/resources/test/fixtures/flake8_pie/PIE790.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pie/PIE790.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pie/PIE790.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pie/PIE794.py b/crates/ruff_linter/resources/test/fixtures/flake8_pie/PIE794.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pie/PIE794.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pie/PIE794.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pie/PIE796.py b/crates/ruff_linter/resources/test/fixtures/flake8_pie/PIE796.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pie/PIE796.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pie/PIE796.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pie/PIE800.py b/crates/ruff_linter/resources/test/fixtures/flake8_pie/PIE800.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pie/PIE800.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pie/PIE800.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pie/PIE804.py b/crates/ruff_linter/resources/test/fixtures/flake8_pie/PIE804.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pie/PIE804.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pie/PIE804.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pie/PIE807.py b/crates/ruff_linter/resources/test/fixtures/flake8_pie/PIE807.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pie/PIE807.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pie/PIE807.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pie/PIE808.py b/crates/ruff_linter/resources/test/fixtures/flake8_pie/PIE808.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pie/PIE808.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pie/PIE808.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pie/PIE810.py b/crates/ruff_linter/resources/test/fixtures/flake8_pie/PIE810.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pie/PIE810.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pie/PIE810.py diff --git a/crates/ruff/resources/test/fixtures/flake8_print/T201.py b/crates/ruff_linter/resources/test/fixtures/flake8_print/T201.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_print/T201.py rename to crates/ruff_linter/resources/test/fixtures/flake8_print/T201.py diff --git a/crates/ruff/resources/test/fixtures/flake8_print/T203.py b/crates/ruff_linter/resources/test/fixtures/flake8_print/T203.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_print/T203.py rename to crates/ruff_linter/resources/test/fixtures/flake8_print/T203.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI001.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI001.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI001.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI001.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI001.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI001.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI001.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI001.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI002.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI002.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI002.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI002.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI002.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI002.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI002.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI002.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI003.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI003.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI003.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI003.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI003.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI003.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI003.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI003.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI004.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI004.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI004.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI004.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI004.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI004.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI004.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI004.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI005.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI005.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI005.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI005.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI005.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI005.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI005.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI005.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI006.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI006.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI006.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI006.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI006.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI006.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI006.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI006.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI007.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI007.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI007.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI007.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI007.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI007.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI007.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI007.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI008.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI008.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI008.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI008.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI008.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI008.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI008.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI008.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI009.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI009.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI009.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI009.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI009.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI009.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI009.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI009.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI010.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI010.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI010.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI010.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI010.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI010.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI010.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI010.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI011.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI011.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI011.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI011.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI011.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI011.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI011.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI011.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI012.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI012.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI012.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI012.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI012.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI012.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI012.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI012.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI013.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI013.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI013.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI013.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI013.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI013.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI013.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI013.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI014.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI014.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI014.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI014.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI014.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI014.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI014.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI014.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI015.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI015.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI015.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI015.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI015.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI015.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI015.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI015.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI016.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI016.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI016.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI016.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI016.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI016.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI016.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI016.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI017.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI017.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI017.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI017.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI017.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI017.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI017.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI017.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI018.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI018.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI018.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI018.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI018.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI018.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI018.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI018.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI019.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI019.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI019.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI019.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI019.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI019.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI019.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI019.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI020.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI020.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI020.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI020.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI020.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI020.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI020.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI020.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI021.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI021.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI021.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI021.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI021.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI021.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI021.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI021.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI024.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI024.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI024.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI024.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI024.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI024.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI024.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI024.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI025.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI025.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI025.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI025.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI025.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI025.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI025.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI025.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI026.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI026.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI026.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI026.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI026.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI026.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI026.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI026.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI029.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI029.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI029.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI029.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI029.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI029.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI029.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI029.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI030.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI030.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI030.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI030.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI030.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI030.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI030.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI030.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI032.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI032.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI032.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI032.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI032.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI032.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI032.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI032.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI033.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI033.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI033.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI033.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI033.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI033.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI033.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI033.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI034.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI034.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI034.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI034.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI034.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI034.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI034.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI034.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI035.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI035.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI035.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI035.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI035.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI035.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI035.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI035.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI036.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI036.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI036.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI036.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI036.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI036.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI036.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI036.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI041.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI041.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI041.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI041.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI041.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI041.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI041.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI041.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI042.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI042.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI042.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI042.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI042.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI042.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI042.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI042.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI043.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI043.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI043.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI043.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI043.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI043.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI043.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI043.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI044.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI044.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI044.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI044.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI044.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI044.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI044.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI044.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI045.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI045.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI045.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI045.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI045.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI045.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI045.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI045.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI046.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI046.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI046.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI046.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI046.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI046.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI046.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI046.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI047.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI047.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI047.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI047.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI047.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI047.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI047.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI047.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI048.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI048.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI048.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI048.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI048.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI048.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI048.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI048.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI049.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI049.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI049.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI049.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI049.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI049.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI049.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI049.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI050.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI050.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI050.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI050.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI050.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI050.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI050.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI050.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI051.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI051.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI051.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI051.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI051.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI051.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI051.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI051.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI052.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI052.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI052.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI052.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI052.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI052.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI052.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI052.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI053.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI053.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI053.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI053.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI053.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI053.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI053.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI053.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI054.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI054.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI054.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI054.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI054.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI054.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI054.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI054.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI055.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI055.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI055.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI055.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI055.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI055.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI055.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI055.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI056.py b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI056.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI056.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI056.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pyi/PYI056.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI056.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pyi/PYI056.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_pyi/PYI056.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT001.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT001.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT001.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT001.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT002.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT002.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT002.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT002.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT003.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT003.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT003.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT003.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT004.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT004.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT004.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT004.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT005.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT005.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT005.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT005.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT006.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT006.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT006.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT006.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT007.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT007.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT007.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT007.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT008.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT008.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT008.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT008.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT009.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT009.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT009.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT009.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT010.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT010.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT010.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT010.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT011.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT011.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT011.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT011.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT012.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT012.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT012.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT012.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT013.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT013.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT013.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT013.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT014.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT014.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT014.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT014.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT015.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT015.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT015.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT015.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT016.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT016.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT016.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT016.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT017.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT017.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT017.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT017.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT018.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT018.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT018.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT018.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT019.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT019.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT019.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT019.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT020.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT020.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT020.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT020.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT021.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT021.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT021.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT021.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT022.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT022.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT022.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT022.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT023.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT023.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT023.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT023.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT024.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT024.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT024.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT024.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT025.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT025.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT025.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT025.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT026.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT026.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT026.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT026.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT027_0.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT027_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT027_0.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT027_0.py diff --git a/crates/ruff/resources/test/fixtures/flake8_pytest_style/PT027_1.py b/crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT027_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_pytest_style/PT027_1.py rename to crates/ruff_linter/resources/test/fixtures/flake8_pytest_style/PT027_1.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/docstring_doubles.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_doubles.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/docstring_doubles.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_doubles.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/docstring_doubles_class.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_doubles_class.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/docstring_doubles_class.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_doubles_class.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/docstring_doubles_function.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_doubles_function.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/docstring_doubles_function.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_doubles_function.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/docstring_doubles_module_multiline.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_doubles_module_multiline.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/docstring_doubles_module_multiline.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_doubles_module_multiline.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/docstring_doubles_module_singleline.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_doubles_module_singleline.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/docstring_doubles_module_singleline.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_doubles_module_singleline.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/docstring_singles.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_singles.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/docstring_singles.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_singles.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/docstring_singles_class.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_singles_class.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/docstring_singles_class.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_singles_class.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/docstring_singles_function.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_singles_function.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/docstring_singles_function.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_singles_function.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/docstring_singles_module_multiline.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_singles_module_multiline.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/docstring_singles_module_multiline.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_singles_module_multiline.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/docstring_singles_module_singleline.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_singles_module_singleline.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/docstring_singles_module_singleline.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/docstring_singles_module_singleline.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/doubles.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/doubles.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/doubles.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/doubles.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/doubles_escaped.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/doubles_escaped.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/doubles_escaped.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/doubles_escaped.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/doubles_implicit.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/doubles_implicit.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/doubles_implicit.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/doubles_implicit.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/doubles_multiline_string.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/doubles_multiline_string.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/doubles_multiline_string.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/doubles_multiline_string.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/doubles_noqa.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/doubles_noqa.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/doubles_noqa.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/doubles_noqa.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/doubles_wrapped.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/doubles_wrapped.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/doubles_wrapped.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/doubles_wrapped.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/singles.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/singles.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/singles.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/singles.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/singles_escaped.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/singles_escaped.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/singles_escaped.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/singles_escaped.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/singles_implicit.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/singles_implicit.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/singles_implicit.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/singles_implicit.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/singles_multiline_string.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/singles_multiline_string.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/singles_multiline_string.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/singles_multiline_string.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/singles_noqa.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/singles_noqa.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/singles_noqa.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/singles_noqa.py diff --git a/crates/ruff/resources/test/fixtures/flake8_quotes/singles_wrapped.py b/crates/ruff_linter/resources/test/fixtures/flake8_quotes/singles_wrapped.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_quotes/singles_wrapped.py rename to crates/ruff_linter/resources/test/fixtures/flake8_quotes/singles_wrapped.py diff --git a/crates/ruff/resources/test/fixtures/flake8_raise/RSE102.py b/crates/ruff_linter/resources/test/fixtures/flake8_raise/RSE102.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_raise/RSE102.py rename to crates/ruff_linter/resources/test/fixtures/flake8_raise/RSE102.py diff --git a/crates/ruff/resources/test/fixtures/flake8_return/RET501.py b/crates/ruff_linter/resources/test/fixtures/flake8_return/RET501.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_return/RET501.py rename to crates/ruff_linter/resources/test/fixtures/flake8_return/RET501.py diff --git a/crates/ruff/resources/test/fixtures/flake8_return/RET502.py b/crates/ruff_linter/resources/test/fixtures/flake8_return/RET502.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_return/RET502.py rename to crates/ruff_linter/resources/test/fixtures/flake8_return/RET502.py diff --git a/crates/ruff/resources/test/fixtures/flake8_return/RET503.py b/crates/ruff_linter/resources/test/fixtures/flake8_return/RET503.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_return/RET503.py rename to crates/ruff_linter/resources/test/fixtures/flake8_return/RET503.py diff --git a/crates/ruff/resources/test/fixtures/flake8_return/RET504.py b/crates/ruff_linter/resources/test/fixtures/flake8_return/RET504.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_return/RET504.py rename to crates/ruff_linter/resources/test/fixtures/flake8_return/RET504.py diff --git a/crates/ruff/resources/test/fixtures/flake8_return/RET505.py b/crates/ruff_linter/resources/test/fixtures/flake8_return/RET505.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_return/RET505.py rename to crates/ruff_linter/resources/test/fixtures/flake8_return/RET505.py diff --git a/crates/ruff/resources/test/fixtures/flake8_return/RET506.py b/crates/ruff_linter/resources/test/fixtures/flake8_return/RET506.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_return/RET506.py rename to crates/ruff_linter/resources/test/fixtures/flake8_return/RET506.py diff --git a/crates/ruff/resources/test/fixtures/flake8_return/RET507.py b/crates/ruff_linter/resources/test/fixtures/flake8_return/RET507.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_return/RET507.py rename to crates/ruff_linter/resources/test/fixtures/flake8_return/RET507.py diff --git a/crates/ruff/resources/test/fixtures/flake8_return/RET508.py b/crates/ruff_linter/resources/test/fixtures/flake8_return/RET508.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_return/RET508.py rename to crates/ruff_linter/resources/test/fixtures/flake8_return/RET508.py diff --git a/crates/ruff/resources/test/fixtures/flake8_self/SLF001.py b/crates/ruff_linter/resources/test/fixtures/flake8_self/SLF001.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_self/SLF001.py rename to crates/ruff_linter/resources/test/fixtures/flake8_self/SLF001.py diff --git a/crates/ruff/resources/test/fixtures/flake8_self/SLF001_extended.py b/crates/ruff_linter/resources/test/fixtures/flake8_self/SLF001_extended.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_self/SLF001_extended.py rename to crates/ruff_linter/resources/test/fixtures/flake8_self/SLF001_extended.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM101.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM101.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM101.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM101.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM102.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM102.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM102.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM102.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM103.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM103.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM103.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM103.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM105_0.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM105_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM105_0.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM105_0.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM105_1.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM105_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM105_1.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM105_1.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM105_2.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM105_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM105_2.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM105_2.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM105_3.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM105_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM105_3.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM105_3.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM107.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM107.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM107.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM107.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM108.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM108.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM108.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM108.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM109.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM109.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM109.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM109.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM110.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM110.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM110.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM110.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM111.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM111.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM111.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM111.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM112.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM112.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM112.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM112.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM114.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM114.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM114.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM114.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM115.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM115.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM115.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM115.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM116.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM116.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM116.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM116.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM117.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM117.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM117.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM117.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM118.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM118.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM118.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM118.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM201.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM201.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM201.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM201.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM202.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM202.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM202.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM202.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM208.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM208.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM208.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM208.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM210.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM210.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM210.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM210.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM211.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM211.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM211.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM211.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM212.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM212.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM212.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM212.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM220.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM220.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM220.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM220.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM221.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM221.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM221.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM221.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM222.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM222.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM222.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM222.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM223.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM223.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM223.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM223.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM300.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM300.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM300.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM300.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM401.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM401.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM401.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM401.py diff --git a/crates/ruff/resources/test/fixtures/flake8_simplify/SIM910.py b/crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM910.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_simplify/SIM910.py rename to crates/ruff_linter/resources/test/fixtures/flake8_simplify/SIM910.py diff --git a/crates/ruff/resources/test/fixtures/flake8_slots/SLOT000.py b/crates/ruff_linter/resources/test/fixtures/flake8_slots/SLOT000.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_slots/SLOT000.py rename to crates/ruff_linter/resources/test/fixtures/flake8_slots/SLOT000.py diff --git a/crates/ruff/resources/test/fixtures/flake8_slots/SLOT001.py b/crates/ruff_linter/resources/test/fixtures/flake8_slots/SLOT001.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_slots/SLOT001.py rename to crates/ruff_linter/resources/test/fixtures/flake8_slots/SLOT001.py diff --git a/crates/ruff/resources/test/fixtures/flake8_slots/SLOT002.py b/crates/ruff_linter/resources/test/fixtures/flake8_slots/SLOT002.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_slots/SLOT002.py rename to crates/ruff_linter/resources/test/fixtures/flake8_slots/SLOT002.py diff --git a/crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/__init__.py b/crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/__init__.py rename to crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/__init__.py diff --git a/crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/__init__.py b/crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/__init__.py rename to crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/__init__.py diff --git a/crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/api/__init__.py b/crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/api/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/api/__init__.py rename to crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/api/__init__.py diff --git a/crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/api/application.py b/crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/api/application.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/api/application.py rename to crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/api/application.py diff --git a/crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/api/logger.py b/crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/api/logger.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/api/logger.py rename to crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/api/logger.py diff --git a/crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/api/models.py b/crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/api/models.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/api/models.py rename to crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/api/models.py diff --git a/crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/UpperCaseModule.py b/crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/UpperCaseModule.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/UpperCaseModule.py rename to crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/UpperCaseModule.py diff --git a/crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/__init__.py b/crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/__init__.py rename to crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/__init__.py diff --git a/crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/commands.py b/crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/commands.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/commands.py rename to crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/commands.py diff --git a/crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/definitions.py b/crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/definitions.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/definitions.py rename to crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/definitions.py diff --git a/crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/responses.py b/crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/responses.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/responses.py rename to crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/protocol/responses.py diff --git a/crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/server/__init__.py b/crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/server/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/server/__init__.py rename to crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/server/__init__.py diff --git a/crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/server/example.py b/crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/server/example.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/server/example.py rename to crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID/my_package/sublib/server/example.py diff --git a/crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID251.py b/crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID251.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID251.py rename to crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID251.py diff --git a/crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID252.py b/crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID252.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID252.py rename to crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID252.py diff --git a/crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID253.py b/crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID253.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_tidy_imports/TID253.py rename to crates/ruff_linter/resources/test/fixtures/flake8_tidy_imports/TID253.py diff --git a/crates/ruff/resources/test/fixtures/flake8_todos/TD001.py b/crates/ruff_linter/resources/test/fixtures/flake8_todos/TD001.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_todos/TD001.py rename to crates/ruff_linter/resources/test/fixtures/flake8_todos/TD001.py diff --git a/crates/ruff/resources/test/fixtures/flake8_todos/TD002.py b/crates/ruff_linter/resources/test/fixtures/flake8_todos/TD002.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_todos/TD002.py rename to crates/ruff_linter/resources/test/fixtures/flake8_todos/TD002.py diff --git a/crates/ruff/resources/test/fixtures/flake8_todos/TD003.py b/crates/ruff_linter/resources/test/fixtures/flake8_todos/TD003.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_todos/TD003.py rename to crates/ruff_linter/resources/test/fixtures/flake8_todos/TD003.py diff --git a/crates/ruff/resources/test/fixtures/flake8_todos/TD004.py b/crates/ruff_linter/resources/test/fixtures/flake8_todos/TD004.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_todos/TD004.py rename to crates/ruff_linter/resources/test/fixtures/flake8_todos/TD004.py diff --git a/crates/ruff/resources/test/fixtures/flake8_todos/TD005.py b/crates/ruff_linter/resources/test/fixtures/flake8_todos/TD005.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_todos/TD005.py rename to crates/ruff_linter/resources/test/fixtures/flake8_todos/TD005.py diff --git a/crates/ruff/resources/test/fixtures/flake8_todos/TD006.py b/crates/ruff_linter/resources/test/fixtures/flake8_todos/TD006.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_todos/TD006.py rename to crates/ruff_linter/resources/test/fixtures/flake8_todos/TD006.py diff --git a/crates/ruff/resources/test/fixtures/flake8_todos/TD007.py b/crates/ruff_linter/resources/test/fixtures/flake8_todos/TD007.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_todos/TD007.py rename to crates/ruff_linter/resources/test/fixtures/flake8_todos/TD007.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/TCH001.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH001.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/TCH001.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH001.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/TCH002.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH002.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/TCH002.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH002.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/TCH003.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH003.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/TCH003.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH003.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_1.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_1.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_1.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_10.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_10.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_10.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_10.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_11.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_11.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_11.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_11.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_12.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_12.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_12.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_12.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_13.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_13.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_13.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_13.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_14.pyi b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_14.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_14.pyi rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_14.pyi diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_2.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_2.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_2.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_3.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_3.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_3.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_4.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_4.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_4.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_4.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_5.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_5.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_5.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_5.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_6.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_6.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_6.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_6.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_7.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_7.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_7.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_7.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_8.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_8.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_8.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_8.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_9.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_9.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/TCH004_9.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH004_9.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/TCH005.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH005.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/TCH005.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/TCH005.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/exempt_modules.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/exempt_modules.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/exempt_modules.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/exempt_modules.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/runtime_evaluated_base_classes_1.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/runtime_evaluated_base_classes_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/runtime_evaluated_base_classes_1.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/runtime_evaluated_base_classes_1.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/runtime_evaluated_base_classes_2.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/runtime_evaluated_base_classes_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/runtime_evaluated_base_classes_2.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/runtime_evaluated_base_classes_2.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/runtime_evaluated_base_classes_3.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/runtime_evaluated_base_classes_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/runtime_evaluated_base_classes_3.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/runtime_evaluated_base_classes_3.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/runtime_evaluated_base_classes_4.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/runtime_evaluated_base_classes_4.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/runtime_evaluated_base_classes_4.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/runtime_evaluated_base_classes_4.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/runtime_evaluated_decorators_1.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/runtime_evaluated_decorators_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/runtime_evaluated_decorators_1.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/runtime_evaluated_decorators_1.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/runtime_evaluated_decorators_2.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/runtime_evaluated_decorators_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/runtime_evaluated_decorators_2.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/runtime_evaluated_decorators_2.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/runtime_evaluated_decorators_3.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/runtime_evaluated_decorators_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/runtime_evaluated_decorators_3.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/runtime_evaluated_decorators_3.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/snapshot.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/snapshot.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/snapshot.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/snapshot.py diff --git a/crates/ruff/resources/test/fixtures/flake8_type_checking/strict.py b/crates/ruff_linter/resources/test/fixtures/flake8_type_checking/strict.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_type_checking/strict.py rename to crates/ruff_linter/resources/test/fixtures/flake8_type_checking/strict.py diff --git a/crates/ruff/resources/test/fixtures/flake8_unused_arguments/ARG.py b/crates/ruff_linter/resources/test/fixtures/flake8_unused_arguments/ARG.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_unused_arguments/ARG.py rename to crates/ruff_linter/resources/test/fixtures/flake8_unused_arguments/ARG.py diff --git a/crates/ruff/resources/test/fixtures/flake8_unused_arguments/ignore_variadic_names.py b/crates/ruff_linter/resources/test/fixtures/flake8_unused_arguments/ignore_variadic_names.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_unused_arguments/ignore_variadic_names.py rename to crates/ruff_linter/resources/test/fixtures/flake8_unused_arguments/ignore_variadic_names.py diff --git a/crates/ruff/resources/test/fixtures/flake8_use_pathlib/PTH201.py b/crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/PTH201.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_use_pathlib/PTH201.py rename to crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/PTH201.py diff --git a/crates/ruff/resources/test/fixtures/flake8_use_pathlib/PTH202.py b/crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/PTH202.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_use_pathlib/PTH202.py rename to crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/PTH202.py diff --git a/crates/ruff/resources/test/fixtures/flake8_use_pathlib/PTH203.py b/crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/PTH203.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_use_pathlib/PTH203.py rename to crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/PTH203.py diff --git a/crates/ruff/resources/test/fixtures/flake8_use_pathlib/PTH204.py b/crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/PTH204.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_use_pathlib/PTH204.py rename to crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/PTH204.py diff --git a/crates/ruff/resources/test/fixtures/flake8_use_pathlib/PTH205.py b/crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/PTH205.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_use_pathlib/PTH205.py rename to crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/PTH205.py diff --git a/crates/ruff/resources/test/fixtures/flake8_use_pathlib/PTH206.py b/crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/PTH206.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_use_pathlib/PTH206.py rename to crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/PTH206.py diff --git a/crates/ruff/resources/test/fixtures/flake8_use_pathlib/PTH207.py b/crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/PTH207.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_use_pathlib/PTH207.py rename to crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/PTH207.py diff --git a/crates/ruff/resources/test/fixtures/flake8_use_pathlib/full_name.py b/crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/full_name.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_use_pathlib/full_name.py rename to crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/full_name.py diff --git a/crates/ruff/resources/test/fixtures/flake8_use_pathlib/import_as.py b/crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/import_as.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_use_pathlib/import_as.py rename to crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/import_as.py diff --git a/crates/ruff/resources/test/fixtures/flake8_use_pathlib/import_from.py b/crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/import_from.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_use_pathlib/import_from.py rename to crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/import_from.py diff --git a/crates/ruff/resources/test/fixtures/flake8_use_pathlib/import_from_as.py b/crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/import_from_as.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_use_pathlib/import_from_as.py rename to crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/import_from_as.py diff --git a/crates/ruff/resources/test/fixtures/flake8_use_pathlib/py_path_1.py b/crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/py_path_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_use_pathlib/py_path_1.py rename to crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/py_path_1.py diff --git a/crates/ruff/resources/test/fixtures/flake8_use_pathlib/py_path_2.py b/crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/py_path_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_use_pathlib/py_path_2.py rename to crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/py_path_2.py diff --git a/crates/ruff/resources/test/fixtures/flake8_use_pathlib/use_pathlib.py b/crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/use_pathlib.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flake8_use_pathlib/use_pathlib.py rename to crates/ruff_linter/resources/test/fixtures/flake8_use_pathlib/use_pathlib.py diff --git a/crates/ruff/resources/test/fixtures/flynt/FLY002.py b/crates/ruff_linter/resources/test/fixtures/flynt/FLY002.py similarity index 100% rename from crates/ruff/resources/test/fixtures/flynt/FLY002.py rename to crates/ruff_linter/resources/test/fixtures/flynt/FLY002.py diff --git a/crates/ruff/resources/test/fixtures/isort/add_newline_before_comments.py b/crates/ruff_linter/resources/test/fixtures/isort/add_newline_before_comments.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/add_newline_before_comments.py rename to crates/ruff_linter/resources/test/fixtures/isort/add_newline_before_comments.py diff --git a/crates/ruff/resources/test/fixtures/isort/as_imports_comments.py b/crates/ruff_linter/resources/test/fixtures/isort/as_imports_comments.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/as_imports_comments.py rename to crates/ruff_linter/resources/test/fixtures/isort/as_imports_comments.py diff --git a/crates/ruff/resources/test/fixtures/isort/bom_sorted.py b/crates/ruff_linter/resources/test/fixtures/isort/bom_sorted.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/bom_sorted.py rename to crates/ruff_linter/resources/test/fixtures/isort/bom_sorted.py diff --git a/crates/ruff/resources/test/fixtures/isort/bom_unsorted.py b/crates/ruff_linter/resources/test/fixtures/isort/bom_unsorted.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/bom_unsorted.py rename to crates/ruff_linter/resources/test/fixtures/isort/bom_unsorted.py diff --git a/crates/ruff/resources/test/fixtures/isort/case_sensitive.py b/crates/ruff_linter/resources/test/fixtures/isort/case_sensitive.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/case_sensitive.py rename to crates/ruff_linter/resources/test/fixtures/isort/case_sensitive.py diff --git a/crates/ruff/resources/test/fixtures/isort/combine_as_imports.py b/crates/ruff_linter/resources/test/fixtures/isort/combine_as_imports.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/combine_as_imports.py rename to crates/ruff_linter/resources/test/fixtures/isort/combine_as_imports.py diff --git a/crates/ruff/resources/test/fixtures/isort/combine_import_from.py b/crates/ruff_linter/resources/test/fixtures/isort/combine_import_from.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/combine_import_from.py rename to crates/ruff_linter/resources/test/fixtures/isort/combine_import_from.py diff --git a/crates/ruff/resources/test/fixtures/isort/comments.py b/crates/ruff_linter/resources/test/fixtures/isort/comments.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/comments.py rename to crates/ruff_linter/resources/test/fixtures/isort/comments.py diff --git a/crates/ruff/resources/test/fixtures/isort/deduplicate_imports.py b/crates/ruff_linter/resources/test/fixtures/isort/deduplicate_imports.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/deduplicate_imports.py rename to crates/ruff_linter/resources/test/fixtures/isort/deduplicate_imports.py diff --git a/crates/ruff/resources/test/fixtures/isort/detect_same_package/foo/__init__.py b/crates/ruff_linter/resources/test/fixtures/isort/detect_same_package/foo/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/detect_same_package/foo/__init__.py rename to crates/ruff_linter/resources/test/fixtures/isort/detect_same_package/foo/__init__.py diff --git a/crates/ruff/resources/test/fixtures/isort/detect_same_package/foo/bar.py b/crates/ruff_linter/resources/test/fixtures/isort/detect_same_package/foo/bar.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/detect_same_package/foo/bar.py rename to crates/ruff_linter/resources/test/fixtures/isort/detect_same_package/foo/bar.py diff --git a/crates/ruff/resources/test/fixtures/isort/detect_same_package/pyproject.toml b/crates/ruff_linter/resources/test/fixtures/isort/detect_same_package/pyproject.toml similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/detect_same_package/pyproject.toml rename to crates/ruff_linter/resources/test/fixtures/isort/detect_same_package/pyproject.toml diff --git a/crates/ruff/resources/test/fixtures/isort/fit_line_length.py b/crates/ruff_linter/resources/test/fixtures/isort/fit_line_length.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/fit_line_length.py rename to crates/ruff_linter/resources/test/fixtures/isort/fit_line_length.py diff --git a/crates/ruff/resources/test/fixtures/isort/fit_line_length_comment.py b/crates/ruff_linter/resources/test/fixtures/isort/fit_line_length_comment.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/fit_line_length_comment.py rename to crates/ruff_linter/resources/test/fixtures/isort/fit_line_length_comment.py diff --git a/crates/ruff/resources/test/fixtures/isort/force_single_line.py b/crates/ruff_linter/resources/test/fixtures/isort/force_single_line.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/force_single_line.py rename to crates/ruff_linter/resources/test/fixtures/isort/force_single_line.py diff --git a/crates/ruff/resources/test/fixtures/isort/force_sort_within_sections.py b/crates/ruff_linter/resources/test/fixtures/isort/force_sort_within_sections.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/force_sort_within_sections.py rename to crates/ruff_linter/resources/test/fixtures/isort/force_sort_within_sections.py diff --git a/crates/ruff/resources/test/fixtures/isort/force_to_top.py b/crates/ruff_linter/resources/test/fixtures/isort/force_to_top.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/force_to_top.py rename to crates/ruff_linter/resources/test/fixtures/isort/force_to_top.py diff --git a/crates/ruff/resources/test/fixtures/isort/force_wrap_aliases.py b/crates/ruff_linter/resources/test/fixtures/isort/force_wrap_aliases.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/force_wrap_aliases.py rename to crates/ruff_linter/resources/test/fixtures/isort/force_wrap_aliases.py diff --git a/crates/ruff/resources/test/fixtures/isort/forced_separate.py b/crates/ruff_linter/resources/test/fixtures/isort/forced_separate.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/forced_separate.py rename to crates/ruff_linter/resources/test/fixtures/isort/forced_separate.py diff --git a/crates/ruff/resources/test/fixtures/isort/if_elif_else.py b/crates/ruff_linter/resources/test/fixtures/isort/if_elif_else.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/if_elif_else.py rename to crates/ruff_linter/resources/test/fixtures/isort/if_elif_else.py diff --git a/crates/ruff/resources/test/fixtures/isort/import_from_after_import.py b/crates/ruff_linter/resources/test/fixtures/isort/import_from_after_import.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/import_from_after_import.py rename to crates/ruff_linter/resources/test/fixtures/isort/import_from_after_import.py diff --git a/crates/ruff/resources/test/fixtures/isort/inline_comments.py b/crates/ruff_linter/resources/test/fixtures/isort/inline_comments.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/inline_comments.py rename to crates/ruff_linter/resources/test/fixtures/isort/inline_comments.py diff --git a/crates/ruff/resources/test/fixtures/isort/insert_empty_lines.py b/crates/ruff_linter/resources/test/fixtures/isort/insert_empty_lines.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/insert_empty_lines.py rename to crates/ruff_linter/resources/test/fixtures/isort/insert_empty_lines.py diff --git a/crates/ruff/resources/test/fixtures/isort/insert_empty_lines.pyi b/crates/ruff_linter/resources/test/fixtures/isort/insert_empty_lines.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/insert_empty_lines.pyi rename to crates/ruff_linter/resources/test/fixtures/isort/insert_empty_lines.pyi diff --git a/crates/ruff/resources/test/fixtures/isort/isort_skip_file.py b/crates/ruff_linter/resources/test/fixtures/isort/isort_skip_file.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/isort_skip_file.py rename to crates/ruff_linter/resources/test/fixtures/isort/isort_skip_file.py diff --git a/crates/ruff/resources/test/fixtures/isort/leading_prefix.py b/crates/ruff_linter/resources/test/fixtures/isort/leading_prefix.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/leading_prefix.py rename to crates/ruff_linter/resources/test/fixtures/isort/leading_prefix.py diff --git a/crates/ruff/resources/test/fixtures/isort/line_ending_crlf.py b/crates/ruff_linter/resources/test/fixtures/isort/line_ending_crlf.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/line_ending_crlf.py rename to crates/ruff_linter/resources/test/fixtures/isort/line_ending_crlf.py diff --git a/crates/ruff/resources/test/fixtures/isort/line_ending_lf.py b/crates/ruff_linter/resources/test/fixtures/isort/line_ending_lf.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/line_ending_lf.py rename to crates/ruff_linter/resources/test/fixtures/isort/line_ending_lf.py diff --git a/crates/ruff/resources/test/fixtures/isort/lines_after_imports_class_after.py b/crates/ruff_linter/resources/test/fixtures/isort/lines_after_imports_class_after.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/lines_after_imports_class_after.py rename to crates/ruff_linter/resources/test/fixtures/isort/lines_after_imports_class_after.py diff --git a/crates/ruff/resources/test/fixtures/isort/lines_after_imports_func_after.py b/crates/ruff_linter/resources/test/fixtures/isort/lines_after_imports_func_after.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/lines_after_imports_func_after.py rename to crates/ruff_linter/resources/test/fixtures/isort/lines_after_imports_func_after.py diff --git a/crates/ruff/resources/test/fixtures/isort/lines_after_imports_nothing_after.py b/crates/ruff_linter/resources/test/fixtures/isort/lines_after_imports_nothing_after.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/lines_after_imports_nothing_after.py rename to crates/ruff_linter/resources/test/fixtures/isort/lines_after_imports_nothing_after.py diff --git a/crates/ruff/resources/test/fixtures/isort/lines_between_types.py b/crates/ruff_linter/resources/test/fixtures/isort/lines_between_types.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/lines_between_types.py rename to crates/ruff_linter/resources/test/fixtures/isort/lines_between_types.py diff --git a/crates/ruff/resources/test/fixtures/isort/magic_trailing_comma.py b/crates/ruff_linter/resources/test/fixtures/isort/magic_trailing_comma.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/magic_trailing_comma.py rename to crates/ruff_linter/resources/test/fixtures/isort/magic_trailing_comma.py diff --git a/crates/ruff/resources/test/fixtures/isort/match_case.py b/crates/ruff_linter/resources/test/fixtures/isort/match_case.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/match_case.py rename to crates/ruff_linter/resources/test/fixtures/isort/match_case.py diff --git a/crates/ruff/resources/test/fixtures/isort/natural_order.py b/crates/ruff_linter/resources/test/fixtures/isort/natural_order.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/natural_order.py rename to crates/ruff_linter/resources/test/fixtures/isort/natural_order.py diff --git a/crates/ruff/resources/test/fixtures/isort/no_lines_before.py b/crates/ruff_linter/resources/test/fixtures/isort/no_lines_before.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/no_lines_before.py rename to crates/ruff_linter/resources/test/fixtures/isort/no_lines_before.py diff --git a/crates/ruff/resources/test/fixtures/isort/no_lines_before_with_empty_sections.py b/crates/ruff_linter/resources/test/fixtures/isort/no_lines_before_with_empty_sections.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/no_lines_before_with_empty_sections.py rename to crates/ruff_linter/resources/test/fixtures/isort/no_lines_before_with_empty_sections.py diff --git a/crates/ruff/resources/test/fixtures/isort/no_reorder_within_section.py b/crates/ruff_linter/resources/test/fixtures/isort/no_reorder_within_section.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/no_reorder_within_section.py rename to crates/ruff_linter/resources/test/fixtures/isort/no_reorder_within_section.py diff --git a/crates/ruff/resources/test/fixtures/isort/no_wrap_star.py b/crates/ruff_linter/resources/test/fixtures/isort/no_wrap_star.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/no_wrap_star.py rename to crates/ruff_linter/resources/test/fixtures/isort/no_wrap_star.py diff --git a/crates/ruff/resources/test/fixtures/isort/order_by_type.py b/crates/ruff_linter/resources/test/fixtures/isort/order_by_type.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/order_by_type.py rename to crates/ruff_linter/resources/test/fixtures/isort/order_by_type.py diff --git a/crates/ruff/resources/test/fixtures/isort/order_by_type_with_custom_classes.py b/crates/ruff_linter/resources/test/fixtures/isort/order_by_type_with_custom_classes.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/order_by_type_with_custom_classes.py rename to crates/ruff_linter/resources/test/fixtures/isort/order_by_type_with_custom_classes.py diff --git a/crates/ruff/resources/test/fixtures/isort/order_by_type_with_custom_constants.py b/crates/ruff_linter/resources/test/fixtures/isort/order_by_type_with_custom_constants.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/order_by_type_with_custom_constants.py rename to crates/ruff_linter/resources/test/fixtures/isort/order_by_type_with_custom_constants.py diff --git a/crates/ruff/resources/test/fixtures/isort/order_by_type_with_custom_variables.py b/crates/ruff_linter/resources/test/fixtures/isort/order_by_type_with_custom_variables.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/order_by_type_with_custom_variables.py rename to crates/ruff_linter/resources/test/fixtures/isort/order_by_type_with_custom_variables.py diff --git a/crates/ruff/resources/test/fixtures/isort/order_relative_imports_by_level.py b/crates/ruff_linter/resources/test/fixtures/isort/order_relative_imports_by_level.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/order_relative_imports_by_level.py rename to crates/ruff_linter/resources/test/fixtures/isort/order_relative_imports_by_level.py diff --git a/crates/ruff/resources/test/fixtures/isort/preserve_comment_order.py b/crates/ruff_linter/resources/test/fixtures/isort/preserve_comment_order.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/preserve_comment_order.py rename to crates/ruff_linter/resources/test/fixtures/isort/preserve_comment_order.py diff --git a/crates/ruff/resources/test/fixtures/isort/preserve_import_star.py b/crates/ruff_linter/resources/test/fixtures/isort/preserve_import_star.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/preserve_import_star.py rename to crates/ruff_linter/resources/test/fixtures/isort/preserve_import_star.py diff --git a/crates/ruff/resources/test/fixtures/isort/preserve_indentation.py b/crates/ruff_linter/resources/test/fixtures/isort/preserve_indentation.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/preserve_indentation.py rename to crates/ruff_linter/resources/test/fixtures/isort/preserve_indentation.py diff --git a/crates/ruff/resources/test/fixtures/isort/preserve_tabs.py b/crates/ruff_linter/resources/test/fixtures/isort/preserve_tabs.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/preserve_tabs.py rename to crates/ruff_linter/resources/test/fixtures/isort/preserve_tabs.py diff --git a/crates/ruff/resources/test/fixtures/isort/preserve_tabs_2.py b/crates/ruff_linter/resources/test/fixtures/isort/preserve_tabs_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/preserve_tabs_2.py rename to crates/ruff_linter/resources/test/fixtures/isort/preserve_tabs_2.py diff --git a/crates/ruff/resources/test/fixtures/isort/propagate_inline_comments.py b/crates/ruff_linter/resources/test/fixtures/isort/propagate_inline_comments.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/propagate_inline_comments.py rename to crates/ruff_linter/resources/test/fixtures/isort/propagate_inline_comments.py diff --git a/crates/ruff/resources/test/fixtures/isort/pyproject.toml b/crates/ruff_linter/resources/test/fixtures/isort/pyproject.toml similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/pyproject.toml rename to crates/ruff_linter/resources/test/fixtures/isort/pyproject.toml diff --git a/crates/ruff/resources/test/fixtures/isort/relative_imports_order.py b/crates/ruff_linter/resources/test/fixtures/isort/relative_imports_order.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/relative_imports_order.py rename to crates/ruff_linter/resources/test/fixtures/isort/relative_imports_order.py diff --git a/crates/ruff/resources/test/fixtures/isort/reorder_within_section.py b/crates/ruff_linter/resources/test/fixtures/isort/reorder_within_section.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/reorder_within_section.py rename to crates/ruff_linter/resources/test/fixtures/isort/reorder_within_section.py diff --git a/crates/ruff/resources/test/fixtures/isort/required_imports/comment.py b/crates/ruff_linter/resources/test/fixtures/isort/required_imports/comment.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/required_imports/comment.py rename to crates/ruff_linter/resources/test/fixtures/isort/required_imports/comment.py diff --git a/crates/ruff/resources/test/fixtures/isort/required_imports/comments_and_newlines.py b/crates/ruff_linter/resources/test/fixtures/isort/required_imports/comments_and_newlines.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/required_imports/comments_and_newlines.py rename to crates/ruff_linter/resources/test/fixtures/isort/required_imports/comments_and_newlines.py diff --git a/crates/ruff/resources/test/fixtures/isort/required_imports/docstring.py b/crates/ruff_linter/resources/test/fixtures/isort/required_imports/docstring.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/required_imports/docstring.py rename to crates/ruff_linter/resources/test/fixtures/isort/required_imports/docstring.py diff --git a/crates/ruff/resources/test/fixtures/isort/required_imports/docstring.pyi b/crates/ruff_linter/resources/test/fixtures/isort/required_imports/docstring.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/required_imports/docstring.pyi rename to crates/ruff_linter/resources/test/fixtures/isort/required_imports/docstring.pyi diff --git a/crates/ruff/resources/test/fixtures/isort/required_imports/docstring_only.py b/crates/ruff_linter/resources/test/fixtures/isort/required_imports/docstring_only.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/required_imports/docstring_only.py rename to crates/ruff_linter/resources/test/fixtures/isort/required_imports/docstring_only.py diff --git a/crates/ruff/resources/test/fixtures/isort/required_imports/docstring_with_continuation.py b/crates/ruff_linter/resources/test/fixtures/isort/required_imports/docstring_with_continuation.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/required_imports/docstring_with_continuation.py rename to crates/ruff_linter/resources/test/fixtures/isort/required_imports/docstring_with_continuation.py diff --git a/crates/ruff/resources/test/fixtures/isort/required_imports/docstring_with_semicolon.py b/crates/ruff_linter/resources/test/fixtures/isort/required_imports/docstring_with_semicolon.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/required_imports/docstring_with_semicolon.py rename to crates/ruff_linter/resources/test/fixtures/isort/required_imports/docstring_with_semicolon.py diff --git a/crates/ruff/resources/test/fixtures/isort/required_imports/empty.py b/crates/ruff_linter/resources/test/fixtures/isort/required_imports/empty.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/required_imports/empty.py rename to crates/ruff_linter/resources/test/fixtures/isort/required_imports/empty.py diff --git a/crates/ruff/resources/test/fixtures/isort/required_imports/existing_import.py b/crates/ruff_linter/resources/test/fixtures/isort/required_imports/existing_import.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/required_imports/existing_import.py rename to crates/ruff_linter/resources/test/fixtures/isort/required_imports/existing_import.py diff --git a/crates/ruff/resources/test/fixtures/isort/required_imports/multiline_docstring.py b/crates/ruff_linter/resources/test/fixtures/isort/required_imports/multiline_docstring.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/required_imports/multiline_docstring.py rename to crates/ruff_linter/resources/test/fixtures/isort/required_imports/multiline_docstring.py diff --git a/crates/ruff/resources/test/fixtures/isort/required_imports/off.py b/crates/ruff_linter/resources/test/fixtures/isort/required_imports/off.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/required_imports/off.py rename to crates/ruff_linter/resources/test/fixtures/isort/required_imports/off.py diff --git a/crates/ruff/resources/test/fixtures/isort/ruff_skip_file.py b/crates/ruff_linter/resources/test/fixtures/isort/ruff_skip_file.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/ruff_skip_file.py rename to crates/ruff_linter/resources/test/fixtures/isort/ruff_skip_file.py diff --git a/crates/ruff/resources/test/fixtures/isort/sections.py b/crates/ruff_linter/resources/test/fixtures/isort/sections.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/sections.py rename to crates/ruff_linter/resources/test/fixtures/isort/sections.py diff --git a/crates/ruff/resources/test/fixtures/isort/separate_first_party_imports.py b/crates/ruff_linter/resources/test/fixtures/isort/separate_first_party_imports.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/separate_first_party_imports.py rename to crates/ruff_linter/resources/test/fixtures/isort/separate_first_party_imports.py diff --git a/crates/ruff/resources/test/fixtures/isort/separate_future_imports.py b/crates/ruff_linter/resources/test/fixtures/isort/separate_future_imports.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/separate_future_imports.py rename to crates/ruff_linter/resources/test/fixtures/isort/separate_future_imports.py diff --git a/crates/ruff/resources/test/fixtures/isort/separate_local_folder_imports.py b/crates/ruff_linter/resources/test/fixtures/isort/separate_local_folder_imports.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/separate_local_folder_imports.py rename to crates/ruff_linter/resources/test/fixtures/isort/separate_local_folder_imports.py diff --git a/crates/ruff/resources/test/fixtures/isort/separate_subpackage_first_and_third_party_imports.py b/crates/ruff_linter/resources/test/fixtures/isort/separate_subpackage_first_and_third_party_imports.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/separate_subpackage_first_and_third_party_imports.py rename to crates/ruff_linter/resources/test/fixtures/isort/separate_subpackage_first_and_third_party_imports.py diff --git a/crates/ruff/resources/test/fixtures/isort/separate_third_party_imports.py b/crates/ruff_linter/resources/test/fixtures/isort/separate_third_party_imports.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/separate_third_party_imports.py rename to crates/ruff_linter/resources/test/fixtures/isort/separate_third_party_imports.py diff --git a/crates/ruff/resources/test/fixtures/isort/skip.py b/crates/ruff_linter/resources/test/fixtures/isort/skip.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/skip.py rename to crates/ruff_linter/resources/test/fixtures/isort/skip.py diff --git a/crates/ruff/resources/test/fixtures/isort/sort_similar_imports.py b/crates/ruff_linter/resources/test/fixtures/isort/sort_similar_imports.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/sort_similar_imports.py rename to crates/ruff_linter/resources/test/fixtures/isort/sort_similar_imports.py diff --git a/crates/ruff/resources/test/fixtures/isort/split.py b/crates/ruff_linter/resources/test/fixtures/isort/split.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/split.py rename to crates/ruff_linter/resources/test/fixtures/isort/split.py diff --git a/crates/ruff/resources/test/fixtures/isort/star_before_others.py b/crates/ruff_linter/resources/test/fixtures/isort/star_before_others.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/star_before_others.py rename to crates/ruff_linter/resources/test/fixtures/isort/star_before_others.py diff --git a/crates/ruff/resources/test/fixtures/isort/trailing_suffix.py b/crates/ruff_linter/resources/test/fixtures/isort/trailing_suffix.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/trailing_suffix.py rename to crates/ruff_linter/resources/test/fixtures/isort/trailing_suffix.py diff --git a/crates/ruff/resources/test/fixtures/isort/type_comments.py b/crates/ruff_linter/resources/test/fixtures/isort/type_comments.py similarity index 100% rename from crates/ruff/resources/test/fixtures/isort/type_comments.py rename to crates/ruff_linter/resources/test/fixtures/isort/type_comments.py diff --git a/crates/ruff/resources/test/fixtures/mccabe/C901.py b/crates/ruff_linter/resources/test/fixtures/mccabe/C901.py similarity index 100% rename from crates/ruff/resources/test/fixtures/mccabe/C901.py rename to crates/ruff_linter/resources/test/fixtures/mccabe/C901.py diff --git a/crates/ruff/resources/test/fixtures/numpy/NPY001.py b/crates/ruff_linter/resources/test/fixtures/numpy/NPY001.py similarity index 100% rename from crates/ruff/resources/test/fixtures/numpy/NPY001.py rename to crates/ruff_linter/resources/test/fixtures/numpy/NPY001.py diff --git a/crates/ruff/resources/test/fixtures/numpy/NPY002.py b/crates/ruff_linter/resources/test/fixtures/numpy/NPY002.py similarity index 100% rename from crates/ruff/resources/test/fixtures/numpy/NPY002.py rename to crates/ruff_linter/resources/test/fixtures/numpy/NPY002.py diff --git a/crates/ruff/resources/test/fixtures/numpy/NPY003.py b/crates/ruff_linter/resources/test/fixtures/numpy/NPY003.py similarity index 100% rename from crates/ruff/resources/test/fixtures/numpy/NPY003.py rename to crates/ruff_linter/resources/test/fixtures/numpy/NPY003.py diff --git a/crates/ruff/resources/test/fixtures/pandas_vet/PD002.py b/crates/ruff_linter/resources/test/fixtures/pandas_vet/PD002.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pandas_vet/PD002.py rename to crates/ruff_linter/resources/test/fixtures/pandas_vet/PD002.py diff --git a/crates/ruff/resources/test/fixtures/pandas_vet/PD101.py b/crates/ruff_linter/resources/test/fixtures/pandas_vet/PD101.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pandas_vet/PD101.py rename to crates/ruff_linter/resources/test/fixtures/pandas_vet/PD101.py diff --git a/crates/ruff/resources/test/fixtures/pandas_vet/pandas_use_of_dot_read_table.py b/crates/ruff_linter/resources/test/fixtures/pandas_vet/pandas_use_of_dot_read_table.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pandas_vet/pandas_use_of_dot_read_table.py rename to crates/ruff_linter/resources/test/fixtures/pandas_vet/pandas_use_of_dot_read_table.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N801.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N801.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N801.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N801.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N802.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N802.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N802.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N802.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N803.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N803.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N803.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N803.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N804.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N804.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N804.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N804.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N805.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N805.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N805.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N805.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N806.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N806.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N806.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N806.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N807.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N807.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N807.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N807.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N811.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N811.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N811.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N811.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N812.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N812.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N812.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N812.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N813.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N813.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N813.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N813.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N814.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N814.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N814.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N814.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N815.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N815.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N815.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N815.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N816.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N816.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N816.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N816.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N817.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N817.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N817.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N817.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N818.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N818.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N818.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N818.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N999/module/MODULE/__init__.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/MODULE/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N999/module/MODULE/__init__.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/MODULE/__init__.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N999/module/MODULE/file.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/MODULE/file.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N999/module/MODULE/file.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/MODULE/file.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N999/module/flake9/__init__.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/flake9/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N999/module/flake9/__init__.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/flake9/__init__.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N999/module/invalid_name/0001_initial.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/invalid_name/0001_initial.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N999/module/invalid_name/0001_initial.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/invalid_name/0001_initial.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N999/module/invalid_name/__init__.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/invalid_name/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N999/module/invalid_name/__init__.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/invalid_name/__init__.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N999/module/invalid_name/import.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/invalid_name/import.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N999/module/invalid_name/import.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/invalid_name/import.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N999/module/mod with spaces/__init__.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/mod with spaces/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N999/module/mod with spaces/__init__.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/mod with spaces/__init__.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N999/module/mod with spaces/file.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/mod with spaces/file.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N999/module/mod with spaces/file.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/mod with spaces/file.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N999/module/mod with spaces/file2.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/mod with spaces/file2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N999/module/mod with spaces/file2.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/mod with spaces/file2.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N999/module/mod-with-dashes/__init__.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/mod-with-dashes/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N999/module/mod-with-dashes/__init__.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/mod-with-dashes/__init__.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N999/module/no_module/test.txt b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/no_module/test.txt similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N999/module/no_module/test.txt rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/no_module/test.txt diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N999/module/valid_name/__init__.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/valid_name/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N999/module/valid_name/__init__.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/valid_name/__init__.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N999/module/valid_name/__main__.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/valid_name/__main__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N999/module/valid_name/__main__.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/valid_name/__main__.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N999/module/valid_name/__setup__.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/valid_name/__setup__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N999/module/valid_name/__setup__.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/valid_name/__setup__.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N999/module/valid_name/file-with-dashes b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/valid_name/file-with-dashes similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N999/module/valid_name/file-with-dashes rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/valid_name/file-with-dashes diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/N999/module/valid_name/file-with-dashes.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/valid_name/file-with-dashes.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/N999/module/valid_name/file-with-dashes.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/N999/module/valid_name/file-with-dashes.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N801.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N801.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N801.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N801.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N802.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N802.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N802.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N802.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N803.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N803.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N803.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N803.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N804.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N804.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N804.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N804.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N805.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N805.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N805.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N805.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N806.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N806.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N806.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N806.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N807.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N807.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N807.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N807.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N811.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N811.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N811.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N811.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N812.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N812.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N812.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N812.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N813.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N813.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N813.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N813.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N814.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N814.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N814.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N814.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N815.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N815.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N815.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N815.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N816.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N816.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N816.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N816.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N817.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N817.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N817.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N817.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N818.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N818.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N818.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N818.py diff --git a/crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N999/badAllowed/__init__.py b/crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N999/badAllowed/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pep8_naming/ignore_names/N999/badAllowed/__init__.py rename to crates/ruff_linter/resources/test/fixtures/pep8_naming/ignore_names/N999/badAllowed/__init__.py diff --git a/crates/ruff/resources/test/fixtures/perflint/PERF101.py b/crates/ruff_linter/resources/test/fixtures/perflint/PERF101.py similarity index 100% rename from crates/ruff/resources/test/fixtures/perflint/PERF101.py rename to crates/ruff_linter/resources/test/fixtures/perflint/PERF101.py diff --git a/crates/ruff/resources/test/fixtures/perflint/PERF102.py b/crates/ruff_linter/resources/test/fixtures/perflint/PERF102.py similarity index 100% rename from crates/ruff/resources/test/fixtures/perflint/PERF102.py rename to crates/ruff_linter/resources/test/fixtures/perflint/PERF102.py diff --git a/crates/ruff/resources/test/fixtures/perflint/PERF203.py b/crates/ruff_linter/resources/test/fixtures/perflint/PERF203.py similarity index 100% rename from crates/ruff/resources/test/fixtures/perflint/PERF203.py rename to crates/ruff_linter/resources/test/fixtures/perflint/PERF203.py diff --git a/crates/ruff/resources/test/fixtures/perflint/PERF401.py b/crates/ruff_linter/resources/test/fixtures/perflint/PERF401.py similarity index 100% rename from crates/ruff/resources/test/fixtures/perflint/PERF401.py rename to crates/ruff_linter/resources/test/fixtures/perflint/PERF401.py diff --git a/crates/ruff/resources/test/fixtures/perflint/PERF402.py b/crates/ruff_linter/resources/test/fixtures/perflint/PERF402.py similarity index 100% rename from crates/ruff/resources/test/fixtures/perflint/PERF402.py rename to crates/ruff_linter/resources/test/fixtures/perflint/PERF402.py diff --git a/crates/ruff/resources/test/fixtures/perflint/PERF403.py b/crates/ruff_linter/resources/test/fixtures/perflint/PERF403.py similarity index 100% rename from crates/ruff/resources/test/fixtures/perflint/PERF403.py rename to crates/ruff_linter/resources/test/fixtures/perflint/PERF403.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E101.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E101.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E101.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E101.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E11.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E11.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E11.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E11.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E20.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E20.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E20.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E20.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E21.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E21.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E21.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E21.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E22.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E22.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E22.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E22.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E23.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E23.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E23.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E23.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E24.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E24.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E24.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E24.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E25.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E25.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E25.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E25.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E26.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E26.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E26.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E26.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E27.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E27.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E27.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E27.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E40.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E40.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E40.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E40.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E402.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E402.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E402.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E402.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E501.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E501.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E501.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E501.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E501_1.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E501_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E501_1.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E501_1.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E501_2.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E501_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E501_2.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E501_2.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E70.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E70.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E70.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E70.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E711.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E711.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E711.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E711.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E712.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E712.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E712.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E712.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E713.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E713.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E713.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E713.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E714.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E714.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E714.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E714.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E721.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E721.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E721.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E721.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E722.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E722.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E722.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E722.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E731.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E731.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E731.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E731.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E741.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E741.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E741.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E741.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E742.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E742.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E742.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E742.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E743.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E743.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E743.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E743.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/E999.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/E999.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/E999.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/E999.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/W19.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/W19.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/W19.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/W19.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/W29.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/W29.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/W29.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/W29.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/W292_0.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/W292_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/W292_0.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/W292_0.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/W292_1.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/W292_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/W292_1.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/W292_1.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/W292_2.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/W292_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/W292_2.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/W292_2.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/W292_3.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/W292_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/W292_3.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/W292_3.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/W292_4.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/W292_4.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/W292_4.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/W292_4.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/W505.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/W505.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/W505.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/W505.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/W505_utf_8.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/W505_utf_8.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/W505_utf_8.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/W505_utf_8.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/W605_0.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/W605_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/W605_0.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/W605_0.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/W605_1.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/W605_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/W605_1.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/W605_1.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/constant_literals.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/constant_literals.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/constant_literals.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/constant_literals.py diff --git a/crates/ruff/resources/test/fixtures/pycodestyle/shebang.py b/crates/ruff_linter/resources/test/fixtures/pycodestyle/shebang.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pycodestyle/shebang.py rename to crates/ruff_linter/resources/test/fixtures/pycodestyle/shebang.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/D.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/D.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/D.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/D.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/D104/__init__.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/D104/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/D104/__init__.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/D104/__init__.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/D200.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/D200.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/D200.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/D200.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/D202.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/D202.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/D202.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/D202.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/D209_D400.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/D209_D400.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/D209_D400.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/D209_D400.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/D214_module.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/D214_module.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/D214_module.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/D214_module.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/D301.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/D301.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/D301.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/D301.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/D400.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/D400.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/D400.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/D400.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/D401.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/D401.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/D401.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/D401.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/D403.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/D403.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/D403.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/D403.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/D410.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/D410.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/D410.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/D410.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/D417.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/D417.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/D417.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/D417.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/_unrelated/_no_pkg_priv.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/_unrelated/_no_pkg_priv.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/_unrelated/_no_pkg_priv.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/_unrelated/_no_pkg_priv.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/_unrelated/pkg/D100_pub.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/_unrelated/pkg/D100_pub.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/_unrelated/pkg/D100_pub.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/_unrelated/pkg/D100_pub.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/_unrelated/pkg/__init__.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/_unrelated/pkg/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/_unrelated/pkg/__init__.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/_unrelated/pkg/__init__.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/_unrelated/pkg/_priv/__init__.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/_unrelated/pkg/_priv/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/_unrelated/pkg/_priv/__init__.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/_unrelated/pkg/_priv/__init__.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/_unrelated/pkg/_priv/no_D100_priv.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/_unrelated/pkg/_priv/no_D100_priv.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/_unrelated/pkg/_priv/no_D100_priv.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/_unrelated/pkg/_priv/no_D100_priv.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/all.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/all.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/all.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/all.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/bom.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/bom.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/bom.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/bom.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/canonical_google_examples.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/canonical_google_examples.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/canonical_google_examples.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/canonical_google_examples.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/canonical_numpy_examples.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/canonical_numpy_examples.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/canonical_numpy_examples.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/canonical_numpy_examples.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/sections.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/sections.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/sections.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/sections.py diff --git a/crates/ruff/resources/test/fixtures/pydocstyle/setter.py b/crates/ruff_linter/resources/test/fixtures/pydocstyle/setter.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pydocstyle/setter.py rename to crates/ruff_linter/resources/test/fixtures/pydocstyle/setter.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_0.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F401_0.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F401_0.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_1.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F401_1.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F401_1.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_10.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_10.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F401_10.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F401_10.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_11.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_11.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F401_11.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F401_11.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_12.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_12.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F401_12.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F401_12.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_13.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_13.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F401_13.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F401_13.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_14.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_14.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F401_14.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F401_14.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_15.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_15.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F401_15.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F401_15.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_16.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_16.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F401_16.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F401_16.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_17.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_17.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F401_17.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F401_17.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_18.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_18.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F401_18.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F401_18.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_2.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F401_2.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F401_2.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_3.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F401_3.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F401_3.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_4.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_4.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F401_4.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F401_4.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_5.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_5.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F401_5.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F401_5.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_6.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_6.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F401_6.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F401_6.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_7.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_7.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F401_7.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F401_7.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_8.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_8.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F401_8.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F401_8.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F401_9.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F401_9.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F401_9.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F401_9.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F402.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F402.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F402.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F402.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F403.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F403.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F403.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F403.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F404.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F404.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F404.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F404.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F405.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F405.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F405.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F405.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F406.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F406.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F406.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F406.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F407.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F407.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F407.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F407.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F502.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F502.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F502.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F502.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F503.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F503.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F503.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F503.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F504.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F504.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F504.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F504.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F50x.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F50x.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F50x.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F50x.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F521.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F521.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F521.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F521.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F522.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F522.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F522.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F522.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F523.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F523.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F523.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F523.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F524.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F524.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F524.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F524.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F525.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F525.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F525.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F525.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F541.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F541.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F541.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F541.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F601.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F601.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F601.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F601.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F602.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F602.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F602.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F602.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F622.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F622.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F622.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F622.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F631.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F631.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F631.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F631.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F632.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F632.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F632.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F632.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F633.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F633.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F633.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F633.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F634.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F634.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F634.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F634.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F701.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F701.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F701.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F701.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F702.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F702.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F702.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F702.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F704.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F704.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F704.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F704.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F706.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F706.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F706.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F706.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F707.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F707.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F707.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F707.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F722.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F722.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F722.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F722.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_0.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_0.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_0.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_1.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_1.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_1.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_10.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_10.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_10.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_10.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_11.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_11.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_11.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_11.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_12.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_12.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_12.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_12.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_13.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_13.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_13.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_13.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_14.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_14.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_14.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_14.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_15.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_15.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_15.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_15.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_16.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_16.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_16.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_16.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_17.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_17.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_17.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_17.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_18.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_18.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_18.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_18.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_19.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_19.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_19.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_19.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_2.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_2.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_2.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_20.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_20.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_20.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_20.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_21.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_21.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_21.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_21.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_22.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_22.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_22.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_22.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_23.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_23.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_23.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_23.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_24.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_24.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_24.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_24.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_25.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_25.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_25.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_25.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_26.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_26.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_26.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_26.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_3.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_3.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_3.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_4.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_4.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_4.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_4.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_5.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_5.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_5.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_5.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_6.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_6.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_6.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_6.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_7.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_7.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_7.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_7.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_8.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_8.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_8.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_8.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F811_9.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F811_9.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F811_9.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F811_9.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F821_0.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F821_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F821_0.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F821_0.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F821_1.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F821_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F821_1.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F821_1.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F821_10.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F821_10.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F821_10.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F821_10.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F821_11.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F821_11.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F821_11.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F821_11.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F821_12.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F821_12.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F821_12.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F821_12.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F821_13.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F821_13.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F821_13.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F821_13.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F821_14.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F821_14.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F821_14.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F821_14.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F821_15.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F821_15.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F821_15.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F821_15.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F821_16.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F821_16.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F821_16.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F821_16.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F821_17.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F821_17.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F821_17.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F821_17.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F821_2.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F821_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F821_2.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F821_2.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F821_3.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F821_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F821_3.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F821_3.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F821_4.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F821_4.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F821_4.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F821_4.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F821_5.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F821_5.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F821_5.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F821_5.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F821_6.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F821_6.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F821_6.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F821_6.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F821_7.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F821_7.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F821_7.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F821_7.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F821_8.pyi b/crates/ruff_linter/resources/test/fixtures/pyflakes/F821_8.pyi similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F821_8.pyi rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F821_8.pyi diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F821_9.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F821_9.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F821_9.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F821_9.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F822_0.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F822_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F822_0.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F822_0.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F822_1.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F822_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F822_1.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F822_1.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F822_2.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F822_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F822_2.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F822_2.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F823.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F823.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F823.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F823.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F841_0.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F841_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F841_0.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F841_0.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F841_1.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F841_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F841_1.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F841_1.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F841_2.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F841_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F841_2.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F841_2.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F841_3.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F841_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F841_3.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F841_3.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F842.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F842.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F842.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F842.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/F901.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/F901.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/F901.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/F901.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/__init__.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/__init__.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/__init__.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/builtins.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/builtins.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/builtins.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/builtins.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/future_annotations.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/future_annotations.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/future_annotations.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/future_annotations.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/multi_statement_lines.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/multi_statement_lines.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/multi_statement_lines.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/multi_statement_lines.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/project/foo/__init__.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/project/foo/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/project/foo/__init__.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/project/foo/__init__.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/project/foo/bar.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/project/foo/bar.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/project/foo/bar.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/project/foo/bar.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/project/foo/bop/__init__.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/project/foo/bop/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/project/foo/bop/__init__.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/project/foo/bop/__init__.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/project/foo/bop/baz.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/project/foo/bop/baz.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/project/foo/bop/baz.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/project/foo/bop/baz.py diff --git a/crates/ruff/resources/test/fixtures/pyflakes/typing_modules.py b/crates/ruff_linter/resources/test/fixtures/pyflakes/typing_modules.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyflakes/typing_modules.py rename to crates/ruff_linter/resources/test/fixtures/pyflakes/typing_modules.py diff --git a/crates/ruff/resources/test/fixtures/pygrep_hooks/PGH001_0.py b/crates/ruff_linter/resources/test/fixtures/pygrep_hooks/PGH001_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pygrep_hooks/PGH001_0.py rename to crates/ruff_linter/resources/test/fixtures/pygrep_hooks/PGH001_0.py diff --git a/crates/ruff/resources/test/fixtures/pygrep_hooks/PGH001_1.py b/crates/ruff_linter/resources/test/fixtures/pygrep_hooks/PGH001_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pygrep_hooks/PGH001_1.py rename to crates/ruff_linter/resources/test/fixtures/pygrep_hooks/PGH001_1.py diff --git a/crates/ruff/resources/test/fixtures/pygrep_hooks/PGH002_0.py b/crates/ruff_linter/resources/test/fixtures/pygrep_hooks/PGH002_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pygrep_hooks/PGH002_0.py rename to crates/ruff_linter/resources/test/fixtures/pygrep_hooks/PGH002_0.py diff --git a/crates/ruff/resources/test/fixtures/pygrep_hooks/PGH002_1.py b/crates/ruff_linter/resources/test/fixtures/pygrep_hooks/PGH002_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pygrep_hooks/PGH002_1.py rename to crates/ruff_linter/resources/test/fixtures/pygrep_hooks/PGH002_1.py diff --git a/crates/ruff/resources/test/fixtures/pygrep_hooks/PGH003_0.py b/crates/ruff_linter/resources/test/fixtures/pygrep_hooks/PGH003_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pygrep_hooks/PGH003_0.py rename to crates/ruff_linter/resources/test/fixtures/pygrep_hooks/PGH003_0.py diff --git a/crates/ruff/resources/test/fixtures/pygrep_hooks/PGH003_1.py b/crates/ruff_linter/resources/test/fixtures/pygrep_hooks/PGH003_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pygrep_hooks/PGH003_1.py rename to crates/ruff_linter/resources/test/fixtures/pygrep_hooks/PGH003_1.py diff --git a/crates/ruff/resources/test/fixtures/pygrep_hooks/PGH004_0.py b/crates/ruff_linter/resources/test/fixtures/pygrep_hooks/PGH004_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pygrep_hooks/PGH004_0.py rename to crates/ruff_linter/resources/test/fixtures/pygrep_hooks/PGH004_0.py diff --git a/crates/ruff/resources/test/fixtures/pygrep_hooks/PGH005_0.py b/crates/ruff_linter/resources/test/fixtures/pygrep_hooks/PGH005_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pygrep_hooks/PGH005_0.py rename to crates/ruff_linter/resources/test/fixtures/pygrep_hooks/PGH005_0.py diff --git a/crates/ruff/resources/test/fixtures/pylint/assert_on_string_literal.py b/crates/ruff_linter/resources/test/fixtures/pylint/assert_on_string_literal.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/assert_on_string_literal.py rename to crates/ruff_linter/resources/test/fixtures/pylint/assert_on_string_literal.py diff --git a/crates/ruff/resources/test/fixtures/pylint/await_outside_async.py b/crates/ruff_linter/resources/test/fixtures/pylint/await_outside_async.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/await_outside_async.py rename to crates/ruff_linter/resources/test/fixtures/pylint/await_outside_async.py diff --git a/crates/ruff/resources/test/fixtures/pylint/bad_dunder_method_name.py b/crates/ruff_linter/resources/test/fixtures/pylint/bad_dunder_method_name.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/bad_dunder_method_name.py rename to crates/ruff_linter/resources/test/fixtures/pylint/bad_dunder_method_name.py diff --git a/crates/ruff/resources/test/fixtures/pylint/bad_str_strip_call.py b/crates/ruff_linter/resources/test/fixtures/pylint/bad_str_strip_call.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/bad_str_strip_call.py rename to crates/ruff_linter/resources/test/fixtures/pylint/bad_str_strip_call.py diff --git a/crates/ruff/resources/test/fixtures/pylint/bad_string_format_character.py b/crates/ruff_linter/resources/test/fixtures/pylint/bad_string_format_character.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/bad_string_format_character.py rename to crates/ruff_linter/resources/test/fixtures/pylint/bad_string_format_character.py diff --git a/crates/ruff/resources/test/fixtures/pylint/bad_string_format_type.py b/crates/ruff_linter/resources/test/fixtures/pylint/bad_string_format_type.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/bad_string_format_type.py rename to crates/ruff_linter/resources/test/fixtures/pylint/bad_string_format_type.py diff --git a/crates/ruff/resources/test/fixtures/pylint/bidirectional_unicode.py b/crates/ruff_linter/resources/test/fixtures/pylint/bidirectional_unicode.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/bidirectional_unicode.py rename to crates/ruff_linter/resources/test/fixtures/pylint/bidirectional_unicode.py diff --git a/crates/ruff/resources/test/fixtures/pylint/binary_op_exception.py b/crates/ruff_linter/resources/test/fixtures/pylint/binary_op_exception.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/binary_op_exception.py rename to crates/ruff_linter/resources/test/fixtures/pylint/binary_op_exception.py diff --git a/crates/ruff/resources/test/fixtures/pylint/collapsible_else_if.py b/crates/ruff_linter/resources/test/fixtures/pylint/collapsible_else_if.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/collapsible_else_if.py rename to crates/ruff_linter/resources/test/fixtures/pylint/collapsible_else_if.py diff --git a/crates/ruff/resources/test/fixtures/pylint/compare_to_empty_string.py b/crates/ruff_linter/resources/test/fixtures/pylint/compare_to_empty_string.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/compare_to_empty_string.py rename to crates/ruff_linter/resources/test/fixtures/pylint/compare_to_empty_string.py diff --git a/crates/ruff/resources/test/fixtures/pylint/comparison_of_constant.py b/crates/ruff_linter/resources/test/fixtures/pylint/comparison_of_constant.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/comparison_of_constant.py rename to crates/ruff_linter/resources/test/fixtures/pylint/comparison_of_constant.py diff --git a/crates/ruff/resources/test/fixtures/pylint/comparison_with_itself.py b/crates/ruff_linter/resources/test/fixtures/pylint/comparison_with_itself.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/comparison_with_itself.py rename to crates/ruff_linter/resources/test/fixtures/pylint/comparison_with_itself.py diff --git a/crates/ruff/resources/test/fixtures/pylint/continue_in_finally.py b/crates/ruff_linter/resources/test/fixtures/pylint/continue_in_finally.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/continue_in_finally.py rename to crates/ruff_linter/resources/test/fixtures/pylint/continue_in_finally.py diff --git a/crates/ruff/resources/test/fixtures/pylint/duplicate_bases.py b/crates/ruff_linter/resources/test/fixtures/pylint/duplicate_bases.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/duplicate_bases.py rename to crates/ruff_linter/resources/test/fixtures/pylint/duplicate_bases.py diff --git a/crates/ruff/resources/test/fixtures/pylint/eq_without_hash.py b/crates/ruff_linter/resources/test/fixtures/pylint/eq_without_hash.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/eq_without_hash.py rename to crates/ruff_linter/resources/test/fixtures/pylint/eq_without_hash.py diff --git a/crates/ruff/resources/test/fixtures/pylint/global_statement.py b/crates/ruff_linter/resources/test/fixtures/pylint/global_statement.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/global_statement.py rename to crates/ruff_linter/resources/test/fixtures/pylint/global_statement.py diff --git a/crates/ruff/resources/test/fixtures/pylint/global_variable_not_assigned.py b/crates/ruff_linter/resources/test/fixtures/pylint/global_variable_not_assigned.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/global_variable_not_assigned.py rename to crates/ruff_linter/resources/test/fixtures/pylint/global_variable_not_assigned.py diff --git a/crates/ruff/resources/test/fixtures/pylint/import_aliasing.py b/crates/ruff_linter/resources/test/fixtures/pylint/import_aliasing.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/import_aliasing.py rename to crates/ruff_linter/resources/test/fixtures/pylint/import_aliasing.py diff --git a/crates/ruff/resources/test/fixtures/pylint/import_self/__init__.py b/crates/ruff_linter/resources/test/fixtures/pylint/import_self/__init__.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/import_self/__init__.py rename to crates/ruff_linter/resources/test/fixtures/pylint/import_self/__init__.py diff --git a/crates/ruff/resources/test/fixtures/pylint/import_self/module.py b/crates/ruff_linter/resources/test/fixtures/pylint/import_self/module.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/import_self/module.py rename to crates/ruff_linter/resources/test/fixtures/pylint/import_self/module.py diff --git a/crates/ruff/resources/test/fixtures/pylint/invalid_all_format.py b/crates/ruff_linter/resources/test/fixtures/pylint/invalid_all_format.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/invalid_all_format.py rename to crates/ruff_linter/resources/test/fixtures/pylint/invalid_all_format.py diff --git a/crates/ruff/resources/test/fixtures/pylint/invalid_all_object.py b/crates/ruff_linter/resources/test/fixtures/pylint/invalid_all_object.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/invalid_all_object.py rename to crates/ruff_linter/resources/test/fixtures/pylint/invalid_all_object.py diff --git a/crates/ruff/resources/test/fixtures/pylint/invalid_characters.py b/crates/ruff_linter/resources/test/fixtures/pylint/invalid_characters.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/invalid_characters.py rename to crates/ruff_linter/resources/test/fixtures/pylint/invalid_characters.py diff --git a/crates/ruff/resources/test/fixtures/pylint/invalid_envvar_default.py b/crates/ruff_linter/resources/test/fixtures/pylint/invalid_envvar_default.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/invalid_envvar_default.py rename to crates/ruff_linter/resources/test/fixtures/pylint/invalid_envvar_default.py diff --git a/crates/ruff/resources/test/fixtures/pylint/invalid_envvar_value.py b/crates/ruff_linter/resources/test/fixtures/pylint/invalid_envvar_value.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/invalid_envvar_value.py rename to crates/ruff_linter/resources/test/fixtures/pylint/invalid_envvar_value.py diff --git a/crates/ruff/resources/test/fixtures/pylint/invalid_return_type_str.py b/crates/ruff_linter/resources/test/fixtures/pylint/invalid_return_type_str.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/invalid_return_type_str.py rename to crates/ruff_linter/resources/test/fixtures/pylint/invalid_return_type_str.py diff --git a/crates/ruff/resources/test/fixtures/pylint/iteration_over_set.py b/crates/ruff_linter/resources/test/fixtures/pylint/iteration_over_set.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/iteration_over_set.py rename to crates/ruff_linter/resources/test/fixtures/pylint/iteration_over_set.py diff --git a/crates/ruff/resources/test/fixtures/pylint/load_before_global_declaration.py b/crates/ruff_linter/resources/test/fixtures/pylint/load_before_global_declaration.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/load_before_global_declaration.py rename to crates/ruff_linter/resources/test/fixtures/pylint/load_before_global_declaration.py diff --git a/crates/ruff/resources/test/fixtures/pylint/logging_too_few_args.py b/crates/ruff_linter/resources/test/fixtures/pylint/logging_too_few_args.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/logging_too_few_args.py rename to crates/ruff_linter/resources/test/fixtures/pylint/logging_too_few_args.py diff --git a/crates/ruff/resources/test/fixtures/pylint/logging_too_many_args.py b/crates/ruff_linter/resources/test/fixtures/pylint/logging_too_many_args.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/logging_too_many_args.py rename to crates/ruff_linter/resources/test/fixtures/pylint/logging_too_many_args.py diff --git a/crates/ruff/resources/test/fixtures/pylint/magic_value_comparison.py b/crates/ruff_linter/resources/test/fixtures/pylint/magic_value_comparison.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/magic_value_comparison.py rename to crates/ruff_linter/resources/test/fixtures/pylint/magic_value_comparison.py diff --git a/crates/ruff/resources/test/fixtures/pylint/misplaced_comparison_constant.py b/crates/ruff_linter/resources/test/fixtures/pylint/misplaced_comparison_constant.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/misplaced_comparison_constant.py rename to crates/ruff_linter/resources/test/fixtures/pylint/misplaced_comparison_constant.py diff --git a/crates/ruff/resources/test/fixtures/pylint/named_expr_without_context.py b/crates/ruff_linter/resources/test/fixtures/pylint/named_expr_without_context.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/named_expr_without_context.py rename to crates/ruff_linter/resources/test/fixtures/pylint/named_expr_without_context.py diff --git a/crates/ruff/resources/test/fixtures/pylint/nested_min_max.py b/crates/ruff_linter/resources/test/fixtures/pylint/nested_min_max.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/nested_min_max.py rename to crates/ruff_linter/resources/test/fixtures/pylint/nested_min_max.py diff --git a/crates/ruff/resources/test/fixtures/pylint/no_self_use.py b/crates/ruff_linter/resources/test/fixtures/pylint/no_self_use.py similarity index 96% rename from crates/ruff/resources/test/fixtures/pylint/no_self_use.py rename to crates/ruff_linter/resources/test/fixtures/pylint/no_self_use.py index 33524c5916..e1cb0c3bda 100644 --- a/crates/ruff/resources/test/fixtures/pylint/no_self_use.py +++ b/crates/ruff_linter/resources/test/fixtures/pylint/no_self_use.py @@ -53,7 +53,7 @@ class Base(abc.ABC): class Sub(Base): @override def abstract_method(self): - print("concret method") + print("concrete method") class Prop: diff --git a/crates/ruff/resources/test/fixtures/pylint/nonlocal_without_binding.py b/crates/ruff_linter/resources/test/fixtures/pylint/nonlocal_without_binding.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/nonlocal_without_binding.py rename to crates/ruff_linter/resources/test/fixtures/pylint/nonlocal_without_binding.py diff --git a/crates/ruff/resources/test/fixtures/pylint/property_with_parameters.py b/crates/ruff_linter/resources/test/fixtures/pylint/property_with_parameters.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/property_with_parameters.py rename to crates/ruff_linter/resources/test/fixtures/pylint/property_with_parameters.py diff --git a/crates/ruff/resources/test/fixtures/pylint/redefined_loop_name.py b/crates/ruff_linter/resources/test/fixtures/pylint/redefined_loop_name.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/redefined_loop_name.py rename to crates/ruff_linter/resources/test/fixtures/pylint/redefined_loop_name.py diff --git a/crates/ruff/resources/test/fixtures/pylint/repeated_equality_comparison.py b/crates/ruff_linter/resources/test/fixtures/pylint/repeated_equality_comparison.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/repeated_equality_comparison.py rename to crates/ruff_linter/resources/test/fixtures/pylint/repeated_equality_comparison.py diff --git a/crates/ruff/resources/test/fixtures/pylint/repeated_isinstance_calls.py b/crates/ruff_linter/resources/test/fixtures/pylint/repeated_isinstance_calls.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/repeated_isinstance_calls.py rename to crates/ruff_linter/resources/test/fixtures/pylint/repeated_isinstance_calls.py diff --git a/crates/ruff/resources/test/fixtures/pylint/return_in_init.py b/crates/ruff_linter/resources/test/fixtures/pylint/return_in_init.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/return_in_init.py rename to crates/ruff_linter/resources/test/fixtures/pylint/return_in_init.py diff --git a/crates/ruff/resources/test/fixtures/pylint/self_assigning_variable.py b/crates/ruff_linter/resources/test/fixtures/pylint/self_assigning_variable.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/self_assigning_variable.py rename to crates/ruff_linter/resources/test/fixtures/pylint/self_assigning_variable.py diff --git a/crates/ruff/resources/test/fixtures/pylint/single_string_slots.py b/crates/ruff_linter/resources/test/fixtures/pylint/single_string_slots.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/single_string_slots.py rename to crates/ruff_linter/resources/test/fixtures/pylint/single_string_slots.py diff --git a/crates/ruff/resources/test/fixtures/pylint/subprocess_popen_preexec_fn.py b/crates/ruff_linter/resources/test/fixtures/pylint/subprocess_popen_preexec_fn.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/subprocess_popen_preexec_fn.py rename to crates/ruff_linter/resources/test/fixtures/pylint/subprocess_popen_preexec_fn.py diff --git a/crates/ruff/resources/test/fixtures/pylint/subprocess_run_without_check.py b/crates/ruff_linter/resources/test/fixtures/pylint/subprocess_run_without_check.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/subprocess_run_without_check.py rename to crates/ruff_linter/resources/test/fixtures/pylint/subprocess_run_without_check.py diff --git a/crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_0.py b/crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_0.py rename to crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_0.py diff --git a/crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_1.py b/crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_1.py rename to crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_1.py diff --git a/crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_10.py b/crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_10.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_10.py rename to crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_10.py diff --git a/crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_11.py b/crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_11.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_11.py rename to crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_11.py diff --git a/crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_2.py b/crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_2.py rename to crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_2.py diff --git a/crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_3.py b/crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_3.py rename to crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_3.py diff --git a/crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_4.py b/crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_4.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_4.py rename to crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_4.py diff --git a/crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_5.py b/crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_5.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_5.py rename to crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_5.py diff --git a/crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_6.py b/crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_6.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_6.py rename to crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_6.py diff --git a/crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_7.py b/crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_7.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_7.py rename to crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_7.py diff --git a/crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_8.py b/crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_8.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_8.py rename to crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_8.py diff --git a/crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_9.py b/crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_9.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/sys_exit_alias_9.py rename to crates/ruff_linter/resources/test/fixtures/pylint/sys_exit_alias_9.py diff --git a/crates/ruff/resources/test/fixtures/pylint/too_many_arguments.py b/crates/ruff_linter/resources/test/fixtures/pylint/too_many_arguments.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/too_many_arguments.py rename to crates/ruff_linter/resources/test/fixtures/pylint/too_many_arguments.py diff --git a/crates/ruff/resources/test/fixtures/pylint/too_many_arguments_params.py b/crates/ruff_linter/resources/test/fixtures/pylint/too_many_arguments_params.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/too_many_arguments_params.py rename to crates/ruff_linter/resources/test/fixtures/pylint/too_many_arguments_params.py diff --git a/crates/ruff/resources/test/fixtures/pylint/too_many_branches.py b/crates/ruff_linter/resources/test/fixtures/pylint/too_many_branches.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/too_many_branches.py rename to crates/ruff_linter/resources/test/fixtures/pylint/too_many_branches.py diff --git a/crates/ruff/resources/test/fixtures/pylint/too_many_branches_params.py b/crates/ruff_linter/resources/test/fixtures/pylint/too_many_branches_params.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/too_many_branches_params.py rename to crates/ruff_linter/resources/test/fixtures/pylint/too_many_branches_params.py diff --git a/crates/ruff/resources/test/fixtures/pylint/too_many_public_methods.py b/crates/ruff_linter/resources/test/fixtures/pylint/too_many_public_methods.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/too_many_public_methods.py rename to crates/ruff_linter/resources/test/fixtures/pylint/too_many_public_methods.py diff --git a/crates/ruff/resources/test/fixtures/pylint/too_many_return_statements.py b/crates/ruff_linter/resources/test/fixtures/pylint/too_many_return_statements.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/too_many_return_statements.py rename to crates/ruff_linter/resources/test/fixtures/pylint/too_many_return_statements.py diff --git a/crates/ruff/resources/test/fixtures/pylint/too_many_return_statements_params.py b/crates/ruff_linter/resources/test/fixtures/pylint/too_many_return_statements_params.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/too_many_return_statements_params.py rename to crates/ruff_linter/resources/test/fixtures/pylint/too_many_return_statements_params.py diff --git a/crates/ruff/resources/test/fixtures/pylint/too_many_statements.py b/crates/ruff_linter/resources/test/fixtures/pylint/too_many_statements.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/too_many_statements.py rename to crates/ruff_linter/resources/test/fixtures/pylint/too_many_statements.py diff --git a/crates/ruff/resources/test/fixtures/pylint/too_many_statements_params.py b/crates/ruff_linter/resources/test/fixtures/pylint/too_many_statements_params.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/too_many_statements_params.py rename to crates/ruff_linter/resources/test/fixtures/pylint/too_many_statements_params.py diff --git a/crates/ruff/resources/test/fixtures/pylint/type_bivariance.py b/crates/ruff_linter/resources/test/fixtures/pylint/type_bivariance.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/type_bivariance.py rename to crates/ruff_linter/resources/test/fixtures/pylint/type_bivariance.py diff --git a/crates/ruff/resources/test/fixtures/pylint/type_name_incorrect_variance.py b/crates/ruff_linter/resources/test/fixtures/pylint/type_name_incorrect_variance.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/type_name_incorrect_variance.py rename to crates/ruff_linter/resources/test/fixtures/pylint/type_name_incorrect_variance.py diff --git a/crates/ruff/resources/test/fixtures/pylint/type_param_name_mismatch.py b/crates/ruff_linter/resources/test/fixtures/pylint/type_param_name_mismatch.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/type_param_name_mismatch.py rename to crates/ruff_linter/resources/test/fixtures/pylint/type_param_name_mismatch.py diff --git a/crates/ruff/resources/test/fixtures/pylint/unexpected_special_method_signature.py b/crates/ruff_linter/resources/test/fixtures/pylint/unexpected_special_method_signature.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/unexpected_special_method_signature.py rename to crates/ruff_linter/resources/test/fixtures/pylint/unexpected_special_method_signature.py diff --git a/crates/ruff/resources/test/fixtures/pylint/unnecessary_direct_lambda_call.py b/crates/ruff_linter/resources/test/fixtures/pylint/unnecessary_direct_lambda_call.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/unnecessary_direct_lambda_call.py rename to crates/ruff_linter/resources/test/fixtures/pylint/unnecessary_direct_lambda_call.py diff --git a/crates/ruff/resources/test/fixtures/pylint/useless_else_on_loop.py b/crates/ruff_linter/resources/test/fixtures/pylint/useless_else_on_loop.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/useless_else_on_loop.py rename to crates/ruff_linter/resources/test/fixtures/pylint/useless_else_on_loop.py diff --git a/crates/ruff/resources/test/fixtures/pylint/useless_return.py b/crates/ruff_linter/resources/test/fixtures/pylint/useless_return.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/useless_return.py rename to crates/ruff_linter/resources/test/fixtures/pylint/useless_return.py diff --git a/crates/ruff/resources/test/fixtures/pylint/yield_from_in_async_function.py b/crates/ruff_linter/resources/test/fixtures/pylint/yield_from_in_async_function.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/yield_from_in_async_function.py rename to crates/ruff_linter/resources/test/fixtures/pylint/yield_from_in_async_function.py diff --git a/crates/ruff/resources/test/fixtures/pylint/yield_in_init.py b/crates/ruff_linter/resources/test/fixtures/pylint/yield_in_init.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pylint/yield_in_init.py rename to crates/ruff_linter/resources/test/fixtures/pylint/yield_in_init.py diff --git a/crates/ruff/resources/test/fixtures/pyproject.toml b/crates/ruff_linter/resources/test/fixtures/pyproject.toml similarity index 100% rename from crates/ruff/resources/test/fixtures/pyproject.toml rename to crates/ruff_linter/resources/test/fixtures/pyproject.toml diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP001.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP001.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP001.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP001.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP003.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP003.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP003.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP003.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP004.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP004.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP004.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP004.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP005.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP005.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP005.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP005.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP006_0.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP006_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP006_0.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP006_0.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP006_1.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP006_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP006_1.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP006_1.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP006_2.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP006_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP006_2.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP006_2.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP006_3.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP006_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP006_3.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP006_3.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP007.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP007.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP007.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP007.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP008.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP008.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP008.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP008.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP009_0.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP009_0.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_0.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP009_1.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP009_1.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_1.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP009_10.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_10.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP009_10.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_10.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP009_2.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP009_2.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_2.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP009_3.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP009_3.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_3.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP009_4.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_4.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP009_4.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_4.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP009_5.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_5.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP009_5.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_5.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP009_6.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_6.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP009_6.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_6.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP009_7.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_7.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP009_7.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_7.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP009_8.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_8.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP009_8.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_8.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP009_9.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_9.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP009_9.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP009_9.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP010.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP010.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP010.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP010.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP011.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP011.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP011.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP011.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP012.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP012.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP012.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP012.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP013.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP013.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP013.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP013.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP014.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP014.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP014.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP014.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP015.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP015.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP015.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP015.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP017.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP017.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP017.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP017.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP018.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP018.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP018.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP018.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP019.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP019.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP019.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP019.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP020.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP020.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP020.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP020.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP021.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP021.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP021.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP021.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP022.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP022.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP022.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP022.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP023.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP023.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP023.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP023.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP024_0.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP024_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP024_0.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP024_0.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP024_1.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP024_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP024_1.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP024_1.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP024_2.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP024_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP024_2.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP024_2.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP024_3.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP024_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP024_3.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP024_3.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP024_4.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP024_4.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP024_4.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP024_4.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP025.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP025.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP025.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP025.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP026.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP026.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP026.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP026.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP027.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP027.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP027.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP027.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP028_0.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP028_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP028_0.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP028_0.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP028_1.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP028_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP028_1.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP028_1.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP029.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP029.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP029.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP029.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP030_0.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP030_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP030_0.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP030_0.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP030_1.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP030_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP030_1.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP030_1.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP031_0.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP031_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP031_0.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP031_0.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP031_1.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP031_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP031_1.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP031_1.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP032_0.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP032_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP032_0.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP032_0.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP032_1.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP032_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP032_1.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP032_1.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP032_2.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP032_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP032_2.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP032_2.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP033_0.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP033_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP033_0.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP033_0.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP033_1.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP033_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP033_1.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP033_1.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP034.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP034.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP034.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP034.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP035.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP035.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP035.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP035.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP036_0.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP036_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP036_0.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP036_0.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP036_1.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP036_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP036_1.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP036_1.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP036_2.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP036_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP036_2.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP036_2.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP036_3.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP036_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP036_3.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP036_3.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP036_4.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP036_4.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP036_4.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP036_4.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP036_5.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP036_5.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP036_5.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP036_5.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP037.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP037.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP037.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP037.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP038.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP038.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP038.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP038.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP039.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP039.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP039.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP039.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/UP040.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP040.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/UP040.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/UP040.py diff --git a/crates/ruff/resources/test/fixtures/pyupgrade/future_annotations.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/future_annotations.py similarity index 100% rename from crates/ruff/resources/test/fixtures/pyupgrade/future_annotations.py rename to crates/ruff_linter/resources/test/fixtures/pyupgrade/future_annotations.py diff --git a/crates/ruff/resources/test/fixtures/refurb/FURB113.py b/crates/ruff_linter/resources/test/fixtures/refurb/FURB113.py similarity index 100% rename from crates/ruff/resources/test/fixtures/refurb/FURB113.py rename to crates/ruff_linter/resources/test/fixtures/refurb/FURB113.py diff --git a/crates/ruff/resources/test/fixtures/refurb/FURB131.py b/crates/ruff_linter/resources/test/fixtures/refurb/FURB131.py similarity index 100% rename from crates/ruff/resources/test/fixtures/refurb/FURB131.py rename to crates/ruff_linter/resources/test/fixtures/refurb/FURB131.py diff --git a/crates/ruff/resources/test/fixtures/refurb/FURB132.py b/crates/ruff_linter/resources/test/fixtures/refurb/FURB132.py similarity index 100% rename from crates/ruff/resources/test/fixtures/refurb/FURB132.py rename to crates/ruff_linter/resources/test/fixtures/refurb/FURB132.py diff --git a/crates/ruff/resources/test/fixtures/refurb/FURB140.py b/crates/ruff_linter/resources/test/fixtures/refurb/FURB140.py similarity index 100% rename from crates/ruff/resources/test/fixtures/refurb/FURB140.py rename to crates/ruff_linter/resources/test/fixtures/refurb/FURB140.py diff --git a/crates/ruff/resources/test/fixtures/refurb/FURB145.py b/crates/ruff_linter/resources/test/fixtures/refurb/FURB145.py similarity index 100% rename from crates/ruff/resources/test/fixtures/refurb/FURB145.py rename to crates/ruff_linter/resources/test/fixtures/refurb/FURB145.py diff --git a/crates/ruff/resources/test/fixtures/refurb/FURB148.py b/crates/ruff_linter/resources/test/fixtures/refurb/FURB148.py similarity index 100% rename from crates/ruff/resources/test/fixtures/refurb/FURB148.py rename to crates/ruff_linter/resources/test/fixtures/refurb/FURB148.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF005.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF005.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF005.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF005.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF006.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF006.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF006.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF006.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF007.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF007.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF007.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF007.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF008.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF008.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF008.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF008.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF009.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF009.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF009.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF009.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF010.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF010.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF010.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF010.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF011.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF011.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF011.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF011.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF012.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF012.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF012.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF012.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF013_0.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF013_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF013_0.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF013_0.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF013_1.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF013_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF013_1.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF013_1.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF014.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF014.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF014.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF014.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF015.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF015.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF015.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF015.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF016.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF016.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF016.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF016.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF017.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF017.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF017.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF017.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF100_0.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF100_0.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF100_0.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF100_0.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF100_1.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF100_1.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF100_1.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF100_1.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF100_2.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF100_2.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF100_2.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF100_2.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF100_3.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF100_3.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF100_3.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF100_3.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF100_4.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF100_4.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF100_4.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF100_4.py diff --git a/crates/ruff/resources/test/fixtures/ruff/RUF100_5.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF100_5.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/RUF100_5.py rename to crates/ruff_linter/resources/test/fixtures/ruff/RUF100_5.py diff --git a/crates/ruff/resources/test/fixtures/ruff/confusables.py b/crates/ruff_linter/resources/test/fixtures/ruff/confusables.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/confusables.py rename to crates/ruff_linter/resources/test/fixtures/ruff/confusables.py diff --git a/crates/ruff/resources/test/fixtures/ruff/flake8_noqa.py b/crates/ruff_linter/resources/test/fixtures/ruff/flake8_noqa.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/flake8_noqa.py rename to crates/ruff_linter/resources/test/fixtures/ruff/flake8_noqa.py diff --git a/crates/ruff/resources/test/fixtures/ruff/noqa.py b/crates/ruff_linter/resources/test/fixtures/ruff/noqa.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/noqa.py rename to crates/ruff_linter/resources/test/fixtures/ruff/noqa.py diff --git a/crates/ruff/resources/test/fixtures/ruff/pyproject_toml/bleach/pyproject.toml b/crates/ruff_linter/resources/test/fixtures/ruff/pyproject_toml/bleach/pyproject.toml similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/pyproject_toml/bleach/pyproject.toml rename to crates/ruff_linter/resources/test/fixtures/ruff/pyproject_toml/bleach/pyproject.toml diff --git a/crates/ruff/resources/test/fixtures/ruff/pyproject_toml/invalid_author/pyproject.toml b/crates/ruff_linter/resources/test/fixtures/ruff/pyproject_toml/invalid_author/pyproject.toml similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/pyproject_toml/invalid_author/pyproject.toml rename to crates/ruff_linter/resources/test/fixtures/ruff/pyproject_toml/invalid_author/pyproject.toml diff --git a/crates/ruff/resources/test/fixtures/ruff/pyproject_toml/maturin/pyproject.toml b/crates/ruff_linter/resources/test/fixtures/ruff/pyproject_toml/maturin/pyproject.toml similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/pyproject_toml/maturin/pyproject.toml rename to crates/ruff_linter/resources/test/fixtures/ruff/pyproject_toml/maturin/pyproject.toml diff --git a/crates/ruff/resources/test/fixtures/ruff/pyproject_toml/maturin_gh_1615/pyproject.toml b/crates/ruff_linter/resources/test/fixtures/ruff/pyproject_toml/maturin_gh_1615/pyproject.toml similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/pyproject_toml/maturin_gh_1615/pyproject.toml rename to crates/ruff_linter/resources/test/fixtures/ruff/pyproject_toml/maturin_gh_1615/pyproject.toml diff --git a/crates/ruff/resources/test/fixtures/ruff/redirects.py b/crates/ruff_linter/resources/test/fixtures/ruff/redirects.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/redirects.py rename to crates/ruff_linter/resources/test/fixtures/ruff/redirects.py diff --git a/crates/ruff/resources/test/fixtures/ruff/ruff_noqa_all.py b/crates/ruff_linter/resources/test/fixtures/ruff/ruff_noqa_all.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/ruff_noqa_all.py rename to crates/ruff_linter/resources/test/fixtures/ruff/ruff_noqa_all.py diff --git a/crates/ruff/resources/test/fixtures/ruff/ruff_noqa_codes.py b/crates/ruff_linter/resources/test/fixtures/ruff/ruff_noqa_codes.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/ruff_noqa_codes.py rename to crates/ruff_linter/resources/test/fixtures/ruff/ruff_noqa_codes.py diff --git a/crates/ruff/resources/test/fixtures/ruff/ruff_noqa_invalid.py b/crates/ruff_linter/resources/test/fixtures/ruff/ruff_noqa_invalid.py similarity index 100% rename from crates/ruff/resources/test/fixtures/ruff/ruff_noqa_invalid.py rename to crates/ruff_linter/resources/test/fixtures/ruff/ruff_noqa_invalid.py diff --git a/crates/ruff/resources/test/fixtures/tryceratops/TRY002.py b/crates/ruff_linter/resources/test/fixtures/tryceratops/TRY002.py similarity index 100% rename from crates/ruff/resources/test/fixtures/tryceratops/TRY002.py rename to crates/ruff_linter/resources/test/fixtures/tryceratops/TRY002.py diff --git a/crates/ruff/resources/test/fixtures/tryceratops/TRY003.py b/crates/ruff_linter/resources/test/fixtures/tryceratops/TRY003.py similarity index 100% rename from crates/ruff/resources/test/fixtures/tryceratops/TRY003.py rename to crates/ruff_linter/resources/test/fixtures/tryceratops/TRY003.py diff --git a/crates/ruff/resources/test/fixtures/tryceratops/TRY004.py b/crates/ruff_linter/resources/test/fixtures/tryceratops/TRY004.py similarity index 100% rename from crates/ruff/resources/test/fixtures/tryceratops/TRY004.py rename to crates/ruff_linter/resources/test/fixtures/tryceratops/TRY004.py diff --git a/crates/ruff/resources/test/fixtures/tryceratops/TRY200.py b/crates/ruff_linter/resources/test/fixtures/tryceratops/TRY200.py similarity index 100% rename from crates/ruff/resources/test/fixtures/tryceratops/TRY200.py rename to crates/ruff_linter/resources/test/fixtures/tryceratops/TRY200.py diff --git a/crates/ruff/resources/test/fixtures/tryceratops/TRY201.py b/crates/ruff_linter/resources/test/fixtures/tryceratops/TRY201.py similarity index 100% rename from crates/ruff/resources/test/fixtures/tryceratops/TRY201.py rename to crates/ruff_linter/resources/test/fixtures/tryceratops/TRY201.py diff --git a/crates/ruff/resources/test/fixtures/tryceratops/TRY300.py b/crates/ruff_linter/resources/test/fixtures/tryceratops/TRY300.py similarity index 100% rename from crates/ruff/resources/test/fixtures/tryceratops/TRY300.py rename to crates/ruff_linter/resources/test/fixtures/tryceratops/TRY300.py diff --git a/crates/ruff/resources/test/fixtures/tryceratops/TRY301.py b/crates/ruff_linter/resources/test/fixtures/tryceratops/TRY301.py similarity index 100% rename from crates/ruff/resources/test/fixtures/tryceratops/TRY301.py rename to crates/ruff_linter/resources/test/fixtures/tryceratops/TRY301.py diff --git a/crates/ruff/resources/test/fixtures/tryceratops/TRY302.py b/crates/ruff_linter/resources/test/fixtures/tryceratops/TRY302.py similarity index 100% rename from crates/ruff/resources/test/fixtures/tryceratops/TRY302.py rename to crates/ruff_linter/resources/test/fixtures/tryceratops/TRY302.py diff --git a/crates/ruff/resources/test/fixtures/tryceratops/TRY400.py b/crates/ruff_linter/resources/test/fixtures/tryceratops/TRY400.py similarity index 100% rename from crates/ruff/resources/test/fixtures/tryceratops/TRY400.py rename to crates/ruff_linter/resources/test/fixtures/tryceratops/TRY400.py diff --git a/crates/ruff/resources/test/fixtures/tryceratops/TRY401.py b/crates/ruff_linter/resources/test/fixtures/tryceratops/TRY401.py similarity index 100% rename from crates/ruff/resources/test/fixtures/tryceratops/TRY401.py rename to crates/ruff_linter/resources/test/fixtures/tryceratops/TRY401.py diff --git a/crates/ruff/resources/test/package/pyproject.toml b/crates/ruff_linter/resources/test/package/pyproject.toml similarity index 100% rename from crates/ruff/resources/test/package/pyproject.toml rename to crates/ruff_linter/resources/test/package/pyproject.toml diff --git a/crates/ruff/resources/test/package/resources/ignored.py b/crates/ruff_linter/resources/test/package/resources/ignored.py similarity index 100% rename from crates/ruff/resources/test/package/resources/ignored.py rename to crates/ruff_linter/resources/test/package/resources/ignored.py diff --git a/crates/ruff/resources/test/package/src/package/__init__.py b/crates/ruff_linter/resources/test/package/src/package/__init__.py similarity index 100% rename from crates/ruff/resources/test/package/src/package/__init__.py rename to crates/ruff_linter/resources/test/package/src/package/__init__.py diff --git a/crates/ruff/resources/test/package/src/package/app.py b/crates/ruff_linter/resources/test/package/src/package/app.py similarity index 100% rename from crates/ruff/resources/test/package/src/package/app.py rename to crates/ruff_linter/resources/test/package/src/package/app.py diff --git a/crates/ruff/resources/test/package/src/package/core.py b/crates/ruff_linter/resources/test/package/src/package/core.py similarity index 100% rename from crates/ruff/resources/test/package/src/package/core.py rename to crates/ruff_linter/resources/test/package/src/package/core.py diff --git a/crates/ruff/resources/test/project/.gitignore b/crates/ruff_linter/resources/test/project/.gitignore similarity index 100% rename from crates/ruff/resources/test/project/.gitignore rename to crates/ruff_linter/resources/test/project/.gitignore diff --git a/crates/ruff_linter/resources/test/project/README.md b/crates/ruff_linter/resources/test/project/README.md new file mode 100644 index 0000000000..c112d71692 --- /dev/null +++ b/crates/ruff_linter/resources/test/project/README.md @@ -0,0 +1,96 @@ +# project + +An example multi-package Python project used to test setting resolution and other complex +behaviors. + +## Expected behavior + +Running from the repo root should pick up and enforce the appropriate settings for each package: + +```console +∴ cargo run -p ruff_cli -- check crates/ruff_linter/resources/test/project/ +crates/ruff_linter/resources/test/project/examples/.dotfiles/script.py:1:1: I001 [*] Import block is un-sorted or un-formatted +crates/ruff_linter/resources/test/project/examples/.dotfiles/script.py:1:8: F401 [*] `numpy` imported but unused +crates/ruff_linter/resources/test/project/examples/.dotfiles/script.py:2:17: F401 [*] `app.app_file` imported but unused +crates/ruff_linter/resources/test/project/examples/docs/docs/file.py:1:1: I001 [*] Import block is un-sorted or un-formatted +crates/ruff_linter/resources/test/project/examples/docs/docs/file.py:8:5: F841 [*] Local variable `x` is assigned to but never used +crates/ruff_linter/resources/test/project/project/file.py:1:8: F401 [*] `os` imported but unused +crates/ruff_linter/resources/test/project/project/import_file.py:1:1: I001 [*] Import block is un-sorted or un-formatted +Found 7 errors. +[*] 7 potentially fixable with the --fix option. +``` + +Running from the project directory itself should exhibit the same behavior: + +```console +∴ (cd crates/ruff_linter/resources/test/project/ && cargo run -p ruff_cli -- check .) +examples/.dotfiles/script.py:1:1: I001 [*] Import block is un-sorted or un-formatted +examples/.dotfiles/script.py:1:8: F401 [*] `numpy` imported but unused +examples/.dotfiles/script.py:2:17: F401 [*] `app.app_file` imported but unused +examples/docs/docs/file.py:1:1: I001 [*] Import block is un-sorted or un-formatted +examples/docs/docs/file.py:8:5: F841 [*] Local variable `x` is assigned to but never used +project/file.py:1:8: F401 [*] `os` imported but unused +project/import_file.py:1:1: I001 [*] Import block is un-sorted or un-formatted +Found 7 errors. +[*] 7 potentially fixable with the --fix option. +``` + +Running from the sub-package directory should exhibit the same behavior, but omit the top-level +files: + +```console +∴ (cd crates/ruff_linter/resources/test/project/examples/docs && cargo run -p ruff_cli -- check .) +docs/file.py:1:1: I001 [*] Import block is un-sorted or un-formatted +docs/file.py:8:5: F841 [*] Local variable `x` is assigned to but never used +Found 2 errors. +[*] 2 potentially fixable with the --fix option. +``` + +`--config` should force Ruff to use the specified `pyproject.toml` for all files, and resolve +file paths from the current working directory: + +```console +∴ (cargo run -p ruff_cli -- check --config=crates/ruff_linter/resources/test/project/pyproject.toml crates/ruff_linter/resources/test/project/) +crates/ruff_linter/resources/test/project/examples/.dotfiles/script.py:1:8: F401 [*] `numpy` imported but unused +crates/ruff_linter/resources/test/project/examples/.dotfiles/script.py:2:17: F401 [*] `app.app_file` imported but unused +crates/ruff_linter/resources/test/project/examples/docs/docs/concepts/file.py:1:8: F401 [*] `os` imported but unused +crates/ruff_linter/resources/test/project/examples/docs/docs/file.py:1:1: I001 [*] Import block is un-sorted or un-formatted +crates/ruff_linter/resources/test/project/examples/docs/docs/file.py:1:8: F401 [*] `os` imported but unused +crates/ruff_linter/resources/test/project/examples/docs/docs/file.py:3:8: F401 [*] `numpy` imported but unused +crates/ruff_linter/resources/test/project/examples/docs/docs/file.py:4:27: F401 [*] `docs.concepts.file` imported but unused +crates/ruff_linter/resources/test/project/examples/excluded/script.py:1:8: F401 [*] `os` imported but unused +crates/ruff_linter/resources/test/project/project/file.py:1:8: F401 [*] `os` imported but unused +Found 9 errors. +[*] 9 potentially fixable with the --fix option. +``` + +Running from a parent directory should "ignore" the `exclude` (hence, `concepts/file.py` gets +included in the output): + +```console +∴ (cd crates/ruff_linter/resources/test/project/examples && cargo run -p ruff_cli -- check --config=docs/ruff.toml .) +docs/docs/concepts/file.py:5:5: F841 [*] Local variable `x` is assigned to but never used +docs/docs/file.py:1:1: I001 [*] Import block is un-sorted or un-formatted +docs/docs/file.py:8:5: F841 [*] Local variable `x` is assigned to but never used +excluded/script.py:5:5: F841 [*] Local variable `x` is assigned to but never used +Found 4 errors. +[*] 4 potentially fixable with the --fix option. +``` + +Passing an excluded directory directly should report errors in the contained files: + +```console +∴ cargo run -p ruff_cli -- check crates/ruff_linter/resources/test/project/examples/excluded/ +crates/ruff_linter/resources/test/project/examples/excluded/script.py:1:8: F401 [*] `os` imported but unused +Found 1 error. +[*] 1 potentially fixable with the --fix option. +``` + +Unless we `--force-exclude`: + +```console +∴ cargo run -p ruff_cli -- check crates/ruff_linter/resources/test/project/examples/excluded/ --force-exclude +warning: No Python files found under the given path(s) +∴ cargo run -p ruff_cli -- check crates/ruff_linter/resources/test/project/examples/excluded/script.py --force-exclude +warning: No Python files found under the given path(s) +``` diff --git a/crates/ruff/resources/test/project/examples/.dotfiles/pyproject.toml b/crates/ruff_linter/resources/test/project/examples/.dotfiles/pyproject.toml similarity index 100% rename from crates/ruff/resources/test/project/examples/.dotfiles/pyproject.toml rename to crates/ruff_linter/resources/test/project/examples/.dotfiles/pyproject.toml diff --git a/crates/ruff/resources/test/project/examples/.dotfiles/script.py b/crates/ruff_linter/resources/test/project/examples/.dotfiles/script.py similarity index 100% rename from crates/ruff/resources/test/project/examples/.dotfiles/script.py rename to crates/ruff_linter/resources/test/project/examples/.dotfiles/script.py diff --git a/crates/ruff/resources/test/project/examples/docs/docs/__init__.py b/crates/ruff_linter/resources/test/project/examples/docs/docs/__init__.py similarity index 100% rename from crates/ruff/resources/test/project/examples/docs/docs/__init__.py rename to crates/ruff_linter/resources/test/project/examples/docs/docs/__init__.py diff --git a/crates/ruff/resources/test/project/examples/docs/docs/concepts/__init__.py b/crates/ruff_linter/resources/test/project/examples/docs/docs/concepts/__init__.py similarity index 100% rename from crates/ruff/resources/test/project/examples/docs/docs/concepts/__init__.py rename to crates/ruff_linter/resources/test/project/examples/docs/docs/concepts/__init__.py diff --git a/crates/ruff/resources/test/project/examples/docs/docs/concepts/file.py b/crates/ruff_linter/resources/test/project/examples/docs/docs/concepts/file.py similarity index 100% rename from crates/ruff/resources/test/project/examples/docs/docs/concepts/file.py rename to crates/ruff_linter/resources/test/project/examples/docs/docs/concepts/file.py diff --git a/crates/ruff/resources/test/project/examples/docs/docs/file.py b/crates/ruff_linter/resources/test/project/examples/docs/docs/file.py similarity index 100% rename from crates/ruff/resources/test/project/examples/docs/docs/file.py rename to crates/ruff_linter/resources/test/project/examples/docs/docs/file.py diff --git a/crates/ruff/resources/test/project/examples/docs/ruff.toml b/crates/ruff_linter/resources/test/project/examples/docs/ruff.toml similarity index 100% rename from crates/ruff/resources/test/project/examples/docs/ruff.toml rename to crates/ruff_linter/resources/test/project/examples/docs/ruff.toml diff --git a/crates/ruff/resources/test/project/examples/excluded/script.py b/crates/ruff_linter/resources/test/project/examples/excluded/script.py similarity index 100% rename from crates/ruff/resources/test/project/examples/excluded/script.py rename to crates/ruff_linter/resources/test/project/examples/excluded/script.py diff --git a/crates/ruff/resources/test/project/project/__init__.py b/crates/ruff_linter/resources/test/project/project/__init__.py similarity index 100% rename from crates/ruff/resources/test/project/project/__init__.py rename to crates/ruff_linter/resources/test/project/project/__init__.py diff --git a/crates/ruff/resources/test/project/project/file.py b/crates/ruff_linter/resources/test/project/project/file.py similarity index 100% rename from crates/ruff/resources/test/project/project/file.py rename to crates/ruff_linter/resources/test/project/project/file.py diff --git a/crates/ruff/resources/test/project/project/import_file.py b/crates/ruff_linter/resources/test/project/project/import_file.py similarity index 100% rename from crates/ruff/resources/test/project/project/import_file.py rename to crates/ruff_linter/resources/test/project/project/import_file.py diff --git a/crates/ruff/resources/test/project/pyproject.toml b/crates/ruff_linter/resources/test/project/pyproject.toml similarity index 100% rename from crates/ruff/resources/test/project/pyproject.toml rename to crates/ruff_linter/resources/test/project/pyproject.toml diff --git a/crates/ruff/resources/test/project/python_modules/app/app/__init__.py b/crates/ruff_linter/resources/test/project/python_modules/app/app/__init__.py similarity index 100% rename from crates/ruff/resources/test/project/python_modules/app/app/__init__.py rename to crates/ruff_linter/resources/test/project/python_modules/app/app/__init__.py diff --git a/crates/ruff/resources/test/project/python_modules/app/app/app_file.py b/crates/ruff_linter/resources/test/project/python_modules/app/app/app_file.py similarity index 100% rename from crates/ruff/resources/test/project/python_modules/app/app/app_file.py rename to crates/ruff_linter/resources/test/project/python_modules/app/app/app_file.py diff --git a/crates/ruff/resources/test/project/python_modules/core/core/__init__.py b/crates/ruff_linter/resources/test/project/python_modules/core/core/__init__.py similarity index 100% rename from crates/ruff/resources/test/project/python_modules/core/core/__init__.py rename to crates/ruff_linter/resources/test/project/python_modules/core/core/__init__.py diff --git a/crates/ruff/resources/test/project/python_modules/core/core/core_file.py b/crates/ruff_linter/resources/test/project/python_modules/core/core/core_file.py similarity index 100% rename from crates/ruff/resources/test/project/python_modules/core/core/core_file.py rename to crates/ruff_linter/resources/test/project/python_modules/core/core/core_file.py diff --git a/crates/ruff/src/autofix/codemods.rs b/crates/ruff_linter/src/autofix/codemods.rs similarity index 100% rename from crates/ruff/src/autofix/codemods.rs rename to crates/ruff_linter/src/autofix/codemods.rs diff --git a/crates/ruff/src/autofix/edits.rs b/crates/ruff_linter/src/autofix/edits.rs similarity index 100% rename from crates/ruff/src/autofix/edits.rs rename to crates/ruff_linter/src/autofix/edits.rs diff --git a/crates/ruff/src/autofix/mod.rs b/crates/ruff_linter/src/autofix/mod.rs similarity index 100% rename from crates/ruff/src/autofix/mod.rs rename to crates/ruff_linter/src/autofix/mod.rs diff --git a/crates/ruff/src/autofix/snippet.rs b/crates/ruff_linter/src/autofix/snippet.rs similarity index 100% rename from crates/ruff/src/autofix/snippet.rs rename to crates/ruff_linter/src/autofix/snippet.rs diff --git a/crates/ruff/src/checkers/ast/analyze/bindings.rs b/crates/ruff_linter/src/checkers/ast/analyze/bindings.rs similarity index 100% rename from crates/ruff/src/checkers/ast/analyze/bindings.rs rename to crates/ruff_linter/src/checkers/ast/analyze/bindings.rs diff --git a/crates/ruff/src/checkers/ast/analyze/comprehension.rs b/crates/ruff_linter/src/checkers/ast/analyze/comprehension.rs similarity index 100% rename from crates/ruff/src/checkers/ast/analyze/comprehension.rs rename to crates/ruff_linter/src/checkers/ast/analyze/comprehension.rs diff --git a/crates/ruff/src/checkers/ast/analyze/deferred_for_loops.rs b/crates/ruff_linter/src/checkers/ast/analyze/deferred_for_loops.rs similarity index 100% rename from crates/ruff/src/checkers/ast/analyze/deferred_for_loops.rs rename to crates/ruff_linter/src/checkers/ast/analyze/deferred_for_loops.rs diff --git a/crates/ruff/src/checkers/ast/analyze/deferred_scopes.rs b/crates/ruff_linter/src/checkers/ast/analyze/deferred_scopes.rs similarity index 100% rename from crates/ruff/src/checkers/ast/analyze/deferred_scopes.rs rename to crates/ruff_linter/src/checkers/ast/analyze/deferred_scopes.rs diff --git a/crates/ruff/src/checkers/ast/analyze/definitions.rs b/crates/ruff_linter/src/checkers/ast/analyze/definitions.rs similarity index 100% rename from crates/ruff/src/checkers/ast/analyze/definitions.rs rename to crates/ruff_linter/src/checkers/ast/analyze/definitions.rs diff --git a/crates/ruff/src/checkers/ast/analyze/except_handler.rs b/crates/ruff_linter/src/checkers/ast/analyze/except_handler.rs similarity index 100% rename from crates/ruff/src/checkers/ast/analyze/except_handler.rs rename to crates/ruff_linter/src/checkers/ast/analyze/except_handler.rs diff --git a/crates/ruff/src/checkers/ast/analyze/expression.rs b/crates/ruff_linter/src/checkers/ast/analyze/expression.rs similarity index 100% rename from crates/ruff/src/checkers/ast/analyze/expression.rs rename to crates/ruff_linter/src/checkers/ast/analyze/expression.rs diff --git a/crates/ruff/src/checkers/ast/analyze/mod.rs b/crates/ruff_linter/src/checkers/ast/analyze/mod.rs similarity index 100% rename from crates/ruff/src/checkers/ast/analyze/mod.rs rename to crates/ruff_linter/src/checkers/ast/analyze/mod.rs diff --git a/crates/ruff/src/checkers/ast/analyze/module.rs b/crates/ruff_linter/src/checkers/ast/analyze/module.rs similarity index 100% rename from crates/ruff/src/checkers/ast/analyze/module.rs rename to crates/ruff_linter/src/checkers/ast/analyze/module.rs diff --git a/crates/ruff/src/checkers/ast/analyze/parameter.rs b/crates/ruff_linter/src/checkers/ast/analyze/parameter.rs similarity index 100% rename from crates/ruff/src/checkers/ast/analyze/parameter.rs rename to crates/ruff_linter/src/checkers/ast/analyze/parameter.rs diff --git a/crates/ruff/src/checkers/ast/analyze/parameters.rs b/crates/ruff_linter/src/checkers/ast/analyze/parameters.rs similarity index 100% rename from crates/ruff/src/checkers/ast/analyze/parameters.rs rename to crates/ruff_linter/src/checkers/ast/analyze/parameters.rs diff --git a/crates/ruff/src/checkers/ast/analyze/statement.rs b/crates/ruff_linter/src/checkers/ast/analyze/statement.rs similarity index 100% rename from crates/ruff/src/checkers/ast/analyze/statement.rs rename to crates/ruff_linter/src/checkers/ast/analyze/statement.rs diff --git a/crates/ruff/src/checkers/ast/analyze/suite.rs b/crates/ruff_linter/src/checkers/ast/analyze/suite.rs similarity index 100% rename from crates/ruff/src/checkers/ast/analyze/suite.rs rename to crates/ruff_linter/src/checkers/ast/analyze/suite.rs diff --git a/crates/ruff/src/checkers/ast/analyze/unresolved_references.rs b/crates/ruff_linter/src/checkers/ast/analyze/unresolved_references.rs similarity index 100% rename from crates/ruff/src/checkers/ast/analyze/unresolved_references.rs rename to crates/ruff_linter/src/checkers/ast/analyze/unresolved_references.rs diff --git a/crates/ruff/src/checkers/ast/deferred.rs b/crates/ruff_linter/src/checkers/ast/deferred.rs similarity index 100% rename from crates/ruff/src/checkers/ast/deferred.rs rename to crates/ruff_linter/src/checkers/ast/deferred.rs diff --git a/crates/ruff/src/checkers/ast/mod.rs b/crates/ruff_linter/src/checkers/ast/mod.rs similarity index 100% rename from crates/ruff/src/checkers/ast/mod.rs rename to crates/ruff_linter/src/checkers/ast/mod.rs diff --git a/crates/ruff/src/checkers/filesystem.rs b/crates/ruff_linter/src/checkers/filesystem.rs similarity index 100% rename from crates/ruff/src/checkers/filesystem.rs rename to crates/ruff_linter/src/checkers/filesystem.rs diff --git a/crates/ruff/src/checkers/imports.rs b/crates/ruff_linter/src/checkers/imports.rs similarity index 100% rename from crates/ruff/src/checkers/imports.rs rename to crates/ruff_linter/src/checkers/imports.rs diff --git a/crates/ruff/src/checkers/logical_lines.rs b/crates/ruff_linter/src/checkers/logical_lines.rs similarity index 100% rename from crates/ruff/src/checkers/logical_lines.rs rename to crates/ruff_linter/src/checkers/logical_lines.rs diff --git a/crates/ruff/src/checkers/mod.rs b/crates/ruff_linter/src/checkers/mod.rs similarity index 100% rename from crates/ruff/src/checkers/mod.rs rename to crates/ruff_linter/src/checkers/mod.rs diff --git a/crates/ruff/src/checkers/noqa.rs b/crates/ruff_linter/src/checkers/noqa.rs similarity index 100% rename from crates/ruff/src/checkers/noqa.rs rename to crates/ruff_linter/src/checkers/noqa.rs diff --git a/crates/ruff/src/checkers/physical_lines.rs b/crates/ruff_linter/src/checkers/physical_lines.rs similarity index 100% rename from crates/ruff/src/checkers/physical_lines.rs rename to crates/ruff_linter/src/checkers/physical_lines.rs diff --git a/crates/ruff/src/checkers/tokens.rs b/crates/ruff_linter/src/checkers/tokens.rs similarity index 100% rename from crates/ruff/src/checkers/tokens.rs rename to crates/ruff_linter/src/checkers/tokens.rs diff --git a/crates/ruff/src/codes.rs b/crates/ruff_linter/src/codes.rs similarity index 100% rename from crates/ruff/src/codes.rs rename to crates/ruff_linter/src/codes.rs diff --git a/crates/ruff/src/comments/mod.rs b/crates/ruff_linter/src/comments/mod.rs similarity index 100% rename from crates/ruff/src/comments/mod.rs rename to crates/ruff_linter/src/comments/mod.rs diff --git a/crates/ruff/src/comments/shebang.rs b/crates/ruff_linter/src/comments/shebang.rs similarity index 100% rename from crates/ruff/src/comments/shebang.rs rename to crates/ruff_linter/src/comments/shebang.rs diff --git a/crates/ruff_linter/src/comments/snapshots/ruff_linter__comments__shebang__tests__shebang_end_of_line.snap b/crates/ruff_linter/src/comments/snapshots/ruff_linter__comments__shebang__tests__shebang_end_of_line.snap new file mode 100644 index 0000000000..6e540f9ee6 --- /dev/null +++ b/crates/ruff_linter/src/comments/snapshots/ruff_linter__comments__shebang__tests__shebang_end_of_line.snap @@ -0,0 +1,5 @@ +--- +source: crates/ruff_linter/src/comments/shebang.rs +expression: "ShebangDirective::try_extract(source)" +--- +None diff --git a/crates/ruff_linter/src/comments/snapshots/ruff_linter__comments__shebang__tests__shebang_leading_space.snap b/crates/ruff_linter/src/comments/snapshots/ruff_linter__comments__shebang__tests__shebang_leading_space.snap new file mode 100644 index 0000000000..6e540f9ee6 --- /dev/null +++ b/crates/ruff_linter/src/comments/snapshots/ruff_linter__comments__shebang__tests__shebang_leading_space.snap @@ -0,0 +1,5 @@ +--- +source: crates/ruff_linter/src/comments/shebang.rs +expression: "ShebangDirective::try_extract(source)" +--- +None diff --git a/crates/ruff_linter/src/comments/snapshots/ruff_linter__comments__shebang__tests__shebang_match.snap b/crates/ruff_linter/src/comments/snapshots/ruff_linter__comments__shebang__tests__shebang_match.snap new file mode 100644 index 0000000000..87bd31a99c --- /dev/null +++ b/crates/ruff_linter/src/comments/snapshots/ruff_linter__comments__shebang__tests__shebang_match.snap @@ -0,0 +1,9 @@ +--- +source: crates/ruff_linter/src/comments/shebang.rs +expression: "ShebangDirective::try_extract(source)" +--- +Some( + ShebangDirective( + "/usr/bin/env python", + ), +) diff --git a/crates/ruff_linter/src/comments/snapshots/ruff_linter__comments__shebang__tests__shebang_match_trailing_comment.snap b/crates/ruff_linter/src/comments/snapshots/ruff_linter__comments__shebang__tests__shebang_match_trailing_comment.snap new file mode 100644 index 0000000000..6177b629e2 --- /dev/null +++ b/crates/ruff_linter/src/comments/snapshots/ruff_linter__comments__shebang__tests__shebang_match_trailing_comment.snap @@ -0,0 +1,9 @@ +--- +source: crates/ruff_linter/src/comments/shebang.rs +expression: "ShebangDirective::try_extract(source)" +--- +Some( + ShebangDirective( + "/usr/bin/env python # trailing comment", + ), +) diff --git a/crates/ruff_linter/src/comments/snapshots/ruff_linter__comments__shebang__tests__shebang_non_match.snap b/crates/ruff_linter/src/comments/snapshots/ruff_linter__comments__shebang__tests__shebang_non_match.snap new file mode 100644 index 0000000000..6e540f9ee6 --- /dev/null +++ b/crates/ruff_linter/src/comments/snapshots/ruff_linter__comments__shebang__tests__shebang_non_match.snap @@ -0,0 +1,5 @@ +--- +source: crates/ruff_linter/src/comments/shebang.rs +expression: "ShebangDirective::try_extract(source)" +--- +None diff --git a/crates/ruff/src/cst/helpers.rs b/crates/ruff_linter/src/cst/helpers.rs similarity index 100% rename from crates/ruff/src/cst/helpers.rs rename to crates/ruff_linter/src/cst/helpers.rs diff --git a/crates/ruff/src/cst/matchers.rs b/crates/ruff_linter/src/cst/matchers.rs similarity index 100% rename from crates/ruff/src/cst/matchers.rs rename to crates/ruff_linter/src/cst/matchers.rs diff --git a/crates/ruff/src/cst/mod.rs b/crates/ruff_linter/src/cst/mod.rs similarity index 100% rename from crates/ruff/src/cst/mod.rs rename to crates/ruff_linter/src/cst/mod.rs diff --git a/crates/ruff/src/directives.rs b/crates/ruff_linter/src/directives.rs similarity index 100% rename from crates/ruff/src/directives.rs rename to crates/ruff_linter/src/directives.rs diff --git a/crates/ruff/src/doc_lines.rs b/crates/ruff_linter/src/doc_lines.rs similarity index 100% rename from crates/ruff/src/doc_lines.rs rename to crates/ruff_linter/src/doc_lines.rs diff --git a/crates/ruff/src/docstrings/extraction.rs b/crates/ruff_linter/src/docstrings/extraction.rs similarity index 100% rename from crates/ruff/src/docstrings/extraction.rs rename to crates/ruff_linter/src/docstrings/extraction.rs diff --git a/crates/ruff/src/docstrings/google.rs b/crates/ruff_linter/src/docstrings/google.rs similarity index 100% rename from crates/ruff/src/docstrings/google.rs rename to crates/ruff_linter/src/docstrings/google.rs diff --git a/crates/ruff/src/docstrings/mod.rs b/crates/ruff_linter/src/docstrings/mod.rs similarity index 100% rename from crates/ruff/src/docstrings/mod.rs rename to crates/ruff_linter/src/docstrings/mod.rs diff --git a/crates/ruff/src/docstrings/numpy.rs b/crates/ruff_linter/src/docstrings/numpy.rs similarity index 100% rename from crates/ruff/src/docstrings/numpy.rs rename to crates/ruff_linter/src/docstrings/numpy.rs diff --git a/crates/ruff/src/docstrings/sections.rs b/crates/ruff_linter/src/docstrings/sections.rs similarity index 100% rename from crates/ruff/src/docstrings/sections.rs rename to crates/ruff_linter/src/docstrings/sections.rs diff --git a/crates/ruff/src/docstrings/styles.rs b/crates/ruff_linter/src/docstrings/styles.rs similarity index 100% rename from crates/ruff/src/docstrings/styles.rs rename to crates/ruff_linter/src/docstrings/styles.rs diff --git a/crates/ruff/src/fs.rs b/crates/ruff_linter/src/fs.rs similarity index 100% rename from crates/ruff/src/fs.rs rename to crates/ruff_linter/src/fs.rs diff --git a/crates/ruff/src/importer/insertion.rs b/crates/ruff_linter/src/importer/insertion.rs similarity index 100% rename from crates/ruff/src/importer/insertion.rs rename to crates/ruff_linter/src/importer/insertion.rs diff --git a/crates/ruff/src/importer/mod.rs b/crates/ruff_linter/src/importer/mod.rs similarity index 100% rename from crates/ruff/src/importer/mod.rs rename to crates/ruff_linter/src/importer/mod.rs diff --git a/crates/ruff/src/lex/docstring_detection.rs b/crates/ruff_linter/src/lex/docstring_detection.rs similarity index 100% rename from crates/ruff/src/lex/docstring_detection.rs rename to crates/ruff_linter/src/lex/docstring_detection.rs diff --git a/crates/ruff/src/lex/mod.rs b/crates/ruff_linter/src/lex/mod.rs similarity index 100% rename from crates/ruff/src/lex/mod.rs rename to crates/ruff_linter/src/lex/mod.rs diff --git a/crates/ruff/src/lib.rs b/crates/ruff_linter/src/lib.rs similarity index 100% rename from crates/ruff/src/lib.rs rename to crates/ruff_linter/src/lib.rs diff --git a/crates/ruff/src/line_width.rs b/crates/ruff_linter/src/line_width.rs similarity index 100% rename from crates/ruff/src/line_width.rs rename to crates/ruff_linter/src/line_width.rs diff --git a/crates/ruff/src/linter.rs b/crates/ruff_linter/src/linter.rs similarity index 100% rename from crates/ruff/src/linter.rs rename to crates/ruff_linter/src/linter.rs diff --git a/crates/ruff/src/logging.rs b/crates/ruff_linter/src/logging.rs similarity index 100% rename from crates/ruff/src/logging.rs rename to crates/ruff_linter/src/logging.rs diff --git a/crates/ruff/src/message/azure.rs b/crates/ruff_linter/src/message/azure.rs similarity index 100% rename from crates/ruff/src/message/azure.rs rename to crates/ruff_linter/src/message/azure.rs diff --git a/crates/ruff/src/message/diff.rs b/crates/ruff_linter/src/message/diff.rs similarity index 100% rename from crates/ruff/src/message/diff.rs rename to crates/ruff_linter/src/message/diff.rs diff --git a/crates/ruff/src/message/github.rs b/crates/ruff_linter/src/message/github.rs similarity index 100% rename from crates/ruff/src/message/github.rs rename to crates/ruff_linter/src/message/github.rs diff --git a/crates/ruff/src/message/gitlab.rs b/crates/ruff_linter/src/message/gitlab.rs similarity index 100% rename from crates/ruff/src/message/gitlab.rs rename to crates/ruff_linter/src/message/gitlab.rs diff --git a/crates/ruff/src/message/grouped.rs b/crates/ruff_linter/src/message/grouped.rs similarity index 100% rename from crates/ruff/src/message/grouped.rs rename to crates/ruff_linter/src/message/grouped.rs diff --git a/crates/ruff/src/message/json.rs b/crates/ruff_linter/src/message/json.rs similarity index 100% rename from crates/ruff/src/message/json.rs rename to crates/ruff_linter/src/message/json.rs diff --git a/crates/ruff/src/message/json_lines.rs b/crates/ruff_linter/src/message/json_lines.rs similarity index 100% rename from crates/ruff/src/message/json_lines.rs rename to crates/ruff_linter/src/message/json_lines.rs diff --git a/crates/ruff/src/message/junit.rs b/crates/ruff_linter/src/message/junit.rs similarity index 100% rename from crates/ruff/src/message/junit.rs rename to crates/ruff_linter/src/message/junit.rs diff --git a/crates/ruff/src/message/mod.rs b/crates/ruff_linter/src/message/mod.rs similarity index 100% rename from crates/ruff/src/message/mod.rs rename to crates/ruff_linter/src/message/mod.rs diff --git a/crates/ruff/src/message/pylint.rs b/crates/ruff_linter/src/message/pylint.rs similarity index 100% rename from crates/ruff/src/message/pylint.rs rename to crates/ruff_linter/src/message/pylint.rs diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__azure__tests__output.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__azure__tests__output.snap new file mode 100644 index 0000000000..f918d0cc57 --- /dev/null +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__azure__tests__output.snap @@ -0,0 +1,8 @@ +--- +source: crates/ruff_linter/src/message/azure.rs +expression: content +--- +##vso[task.logissue type=error;sourcepath=fib.py;linenumber=1;columnnumber=8;code=F401;]`os` imported but unused +##vso[task.logissue type=error;sourcepath=fib.py;linenumber=6;columnnumber=5;code=F841;]Local variable `x` is assigned to but never used +##vso[task.logissue type=error;sourcepath=undef.py;linenumber=1;columnnumber=4;code=F821;]Undefined name `a` + diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__github__tests__output.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__github__tests__output.snap new file mode 100644 index 0000000000..868741b71d --- /dev/null +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__github__tests__output.snap @@ -0,0 +1,8 @@ +--- +source: crates/ruff_linter/src/message/github.rs +expression: content +--- +::error title=Ruff (F401),file=fib.py,line=1,col=8,endLine=1,endColumn=10::fib.py:1:8: F401 `os` imported but unused +::error title=Ruff (F841),file=fib.py,line=6,col=5,endLine=6,endColumn=6::fib.py:6:5: F841 Local variable `x` is assigned to but never used +::error title=Ruff (F821),file=undef.py,line=1,col=4,endLine=1,endColumn=5::undef.py:1:4: F821 Undefined name `a` + diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__gitlab__tests__output.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__gitlab__tests__output.snap new file mode 100644 index 0000000000..c059077eed --- /dev/null +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__gitlab__tests__output.snap @@ -0,0 +1,42 @@ +--- +source: crates/ruff_linter/src/message/gitlab.rs +expression: redact_fingerprint(&content) +--- +[ + { + "description": "(F401) `os` imported but unused", + "fingerprint": "", + "location": { + "lines": { + "begin": 1, + "end": 1 + }, + "path": "fib.py" + }, + "severity": "major" + }, + { + "description": "(F841) Local variable `x` is assigned to but never used", + "fingerprint": "", + "location": { + "lines": { + "begin": 6, + "end": 6 + }, + "path": "fib.py" + }, + "severity": "major" + }, + { + "description": "(F821) Undefined name `a`", + "fingerprint": "", + "location": { + "lines": { + "begin": 1, + "end": 1 + }, + "path": "undef.py" + }, + "severity": "major" + } +] diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__grouped__tests__default.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__grouped__tests__default.snap new file mode 100644 index 0000000000..66b13ba67d --- /dev/null +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__grouped__tests__default.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/message/grouped.rs +expression: content +--- +fib.py: + 1:8 F401 `os` imported but unused + 6:5 F841 Local variable `x` is assigned to but never used + +undef.py: + 1:4 F821 Undefined name `a` + + diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__grouped__tests__fix_status.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__grouped__tests__fix_status.snap new file mode 100644 index 0000000000..453cf1eda4 --- /dev/null +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__grouped__tests__fix_status.snap @@ -0,0 +1,31 @@ +--- +source: crates/ruff_linter/src/message/grouped.rs +expression: content +--- +fib.py: + 1:8 F401 [*] `os` imported but unused + | + 1 | import os + | ^^ F401 + | + = help: Remove unused import: `os` + + 6:5 F841 [*] Local variable `x` is assigned to but never used + | + 4 | def fibonacci(n): + 5 | """Compute the nth number in the Fibonacci sequence.""" + 6 | x = 1 + | ^ F841 + 7 | if n == 0: + 8 | return 0 + | + = help: Remove assignment to unused variable `x` + +undef.py: + 1:4 F821 Undefined name `a` + | + 1 | if a == 1: pass + | ^ F821 + | + + diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__grouped__tests__show_source.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__grouped__tests__show_source.snap new file mode 100644 index 0000000000..37344ef488 --- /dev/null +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__grouped__tests__show_source.snap @@ -0,0 +1,31 @@ +--- +source: crates/ruff_linter/src/message/grouped.rs +expression: content +--- +fib.py: + 1:8 F401 `os` imported but unused + | + 1 | import os + | ^^ F401 + | + = help: Remove unused import: `os` + + 6:5 F841 Local variable `x` is assigned to but never used + | + 4 | def fibonacci(n): + 5 | """Compute the nth number in the Fibonacci sequence.""" + 6 | x = 1 + | ^ F841 + 7 | if n == 0: + 8 | return 0 + | + = help: Remove assignment to unused variable `x` + +undef.py: + 1:4 F821 Undefined name `a` + | + 1 | if a == 1: pass + | ^ F821 + | + + diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__json__tests__output.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__json__tests__output.snap new file mode 100644 index 0000000000..d149e4ec54 --- /dev/null +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__json__tests__output.snap @@ -0,0 +1,86 @@ +--- +source: crates/ruff_linter/src/message/json.rs +expression: content +--- +[ + { + "code": "F401", + "end_location": { + "column": 10, + "row": 1 + }, + "filename": "fib.py", + "fix": { + "applicability": "Suggested", + "edits": [ + { + "content": "", + "end_location": { + "column": 1, + "row": 2 + }, + "location": { + "column": 1, + "row": 1 + } + } + ], + "message": "Remove unused import: `os`" + }, + "location": { + "column": 8, + "row": 1 + }, + "message": "`os` imported but unused", + "noqa_row": 1, + "url": "https://docs.astral.sh/ruff/rules/unused-import" + }, + { + "code": "F841", + "end_location": { + "column": 6, + "row": 6 + }, + "filename": "fib.py", + "fix": { + "applicability": "Suggested", + "edits": [ + { + "content": "", + "end_location": { + "column": 10, + "row": 6 + }, + "location": { + "column": 5, + "row": 6 + } + } + ], + "message": "Remove assignment to unused variable `x`" + }, + "location": { + "column": 5, + "row": 6 + }, + "message": "Local variable `x` is assigned to but never used", + "noqa_row": 6, + "url": "https://docs.astral.sh/ruff/rules/unused-variable" + }, + { + "code": "F821", + "end_location": { + "column": 5, + "row": 1 + }, + "filename": "undef.py", + "fix": null, + "location": { + "column": 4, + "row": 1 + }, + "message": "Undefined name `a`", + "noqa_row": 1, + "url": "https://docs.astral.sh/ruff/rules/undefined-name" + } +] diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__json_lines__tests__output.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__json_lines__tests__output.snap new file mode 100644 index 0000000000..4a4c04222d --- /dev/null +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__json_lines__tests__output.snap @@ -0,0 +1,8 @@ +--- +source: crates/ruff_linter/src/message/json_lines.rs +expression: content +--- +{"code":"F401","end_location":{"column":10,"row":1},"filename":"fib.py","fix":{"applicability":"Suggested","edits":[{"content":"","end_location":{"column":1,"row":2},"location":{"column":1,"row":1}}],"message":"Remove unused import: `os`"},"location":{"column":8,"row":1},"message":"`os` imported but unused","noqa_row":1,"url":"https://docs.astral.sh/ruff/rules/unused-import"} +{"code":"F841","end_location":{"column":6,"row":6},"filename":"fib.py","fix":{"applicability":"Suggested","edits":[{"content":"","end_location":{"column":10,"row":6},"location":{"column":5,"row":6}}],"message":"Remove assignment to unused variable `x`"},"location":{"column":5,"row":6},"message":"Local variable `x` is assigned to but never used","noqa_row":6,"url":"https://docs.astral.sh/ruff/rules/unused-variable"} +{"code":"F821","end_location":{"column":5,"row":1},"filename":"undef.py","fix":null,"location":{"column":4,"row":1},"message":"Undefined name `a`","noqa_row":1,"url":"https://docs.astral.sh/ruff/rules/undefined-name"} + diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__junit__tests__output.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__junit__tests__output.snap new file mode 100644 index 0000000000..ae5e6c8b43 --- /dev/null +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__junit__tests__output.snap @@ -0,0 +1,21 @@ +--- +source: crates/ruff_linter/src/message/junit.rs +expression: content +--- + + + + + line 1, col 8, `os` imported but unused + + + line 6, col 5, Local variable `x` is assigned to but never used + + + + + line 1, col 4, Undefined name `a` + + + + diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__pylint__tests__output.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__pylint__tests__output.snap new file mode 100644 index 0000000000..02b55a4884 --- /dev/null +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__pylint__tests__output.snap @@ -0,0 +1,8 @@ +--- +source: crates/ruff_linter/src/message/pylint.rs +expression: content +--- +fib.py:1: [F401] `os` imported but unused +fib.py:6: [F841] Local variable `x` is assigned to but never used +undef.py:1: [F821] Undefined name `a` + diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__default.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__default.snap new file mode 100644 index 0000000000..77cd92056a --- /dev/null +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__default.snap @@ -0,0 +1,29 @@ +--- +source: crates/ruff_linter/src/message/text.rs +expression: content +--- +fib.py:1:8: F401 `os` imported but unused + | +1 | import os + | ^^ F401 + | + = help: Remove unused import: `os` + +fib.py:6:5: F841 Local variable `x` is assigned to but never used + | +4 | def fibonacci(n): +5 | """Compute the nth number in the Fibonacci sequence.""" +6 | x = 1 + | ^ F841 +7 | if n == 0: +8 | return 0 + | + = help: Remove assignment to unused variable `x` + +undef.py:1:4: F821 Undefined name `a` + | +1 | if a == 1: pass + | ^ F821 + | + + diff --git a/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__fix_status.snap b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__fix_status.snap new file mode 100644 index 0000000000..a53420329c --- /dev/null +++ b/crates/ruff_linter/src/message/snapshots/ruff_linter__message__text__tests__fix_status.snap @@ -0,0 +1,29 @@ +--- +source: crates/ruff_linter/src/message/text.rs +expression: content +--- +fib.py:1:8: F401 [*] `os` imported but unused + | +1 | import os + | ^^ F401 + | + = help: Remove unused import: `os` + +fib.py:6:5: F841 [*] Local variable `x` is assigned to but never used + | +4 | def fibonacci(n): +5 | """Compute the nth number in the Fibonacci sequence.""" +6 | x = 1 + | ^ F841 +7 | if n == 0: +8 | return 0 + | + = help: Remove assignment to unused variable `x` + +undef.py:1:4: F821 Undefined name `a` + | +1 | if a == 1: pass + | ^ F821 + | + + diff --git a/crates/ruff/src/message/text.rs b/crates/ruff_linter/src/message/text.rs similarity index 100% rename from crates/ruff/src/message/text.rs rename to crates/ruff_linter/src/message/text.rs diff --git a/crates/ruff/src/noqa.rs b/crates/ruff_linter/src/noqa.rs similarity index 100% rename from crates/ruff/src/noqa.rs rename to crates/ruff_linter/src/noqa.rs diff --git a/crates/ruff/src/packaging.rs b/crates/ruff_linter/src/packaging.rs similarity index 100% rename from crates/ruff/src/packaging.rs rename to crates/ruff_linter/src/packaging.rs diff --git a/crates/ruff/src/pyproject_toml.rs b/crates/ruff_linter/src/pyproject_toml.rs similarity index 100% rename from crates/ruff/src/pyproject_toml.rs rename to crates/ruff_linter/src/pyproject_toml.rs diff --git a/crates/ruff/src/registry.rs b/crates/ruff_linter/src/registry.rs similarity index 100% rename from crates/ruff/src/registry.rs rename to crates/ruff_linter/src/registry.rs diff --git a/crates/ruff/src/registry/rule_set.rs b/crates/ruff_linter/src/registry/rule_set.rs similarity index 95% rename from crates/ruff/src/registry/rule_set.rs rename to crates/ruff_linter/src/registry/rule_set.rs index e141a4e25e..77ce199b98 100644 --- a/crates/ruff/src/registry/rule_set.rs +++ b/crates/ruff_linter/src/registry/rule_set.rs @@ -68,7 +68,7 @@ impl RuleSet { /// ## Examples /// /// ```rust - /// # use ruff::registry::{Rule, RuleSet}; + /// # use ruff_linter::registry::{Rule, RuleSet}; /// let set_1 = RuleSet::from_rules(&[Rule::AmbiguousFunctionName, Rule::AnyType]); /// let set_2 = RuleSet::from_rules(&[ /// Rule::BadQuotesInlineString, @@ -98,7 +98,7 @@ impl RuleSet { /// /// ## Examples /// ```rust - /// # use ruff::registry::{Rule, RuleSet}; + /// # use ruff_linter::registry::{Rule, RuleSet}; /// let set_1 = RuleSet::from_rules(&[Rule::AmbiguousFunctionName, Rule::AnyType]); /// let set_2 = RuleSet::from_rules(&[Rule::AmbiguousFunctionName, Rule::Debugger]); /// @@ -123,7 +123,7 @@ impl RuleSet { /// /// ## Examples /// ```rust - /// # use ruff::registry::{Rule, RuleSet}; + /// # use ruff_linter::registry::{Rule, RuleSet}; /// let set_1 = RuleSet::from_rules(&[Rule::AmbiguousFunctionName, Rule::AnyType]); /// /// assert!(set_1.intersects(&RuleSet::from_rules(&[ @@ -154,7 +154,7 @@ impl RuleSet { /// ## Examples /// /// ```rust - /// # use ruff::registry::{Rule, RuleSet}; + /// # use ruff_linter::registry::{Rule, RuleSet}; /// assert!(RuleSet::empty().is_empty()); /// assert!( /// !RuleSet::from_rules(&[Rule::AmbiguousFunctionName, Rule::BadQuotesInlineString]) @@ -170,7 +170,7 @@ impl RuleSet { /// ## Examples /// /// ```rust - /// # use ruff::registry::{Rule, RuleSet}; + /// # use ruff_linter::registry::{Rule, RuleSet}; /// assert_eq!(RuleSet::empty().len(), 0); /// assert_eq!( /// RuleSet::from_rules(&[Rule::AmbiguousFunctionName, Rule::BadQuotesInlineString]).len(), @@ -193,7 +193,7 @@ impl RuleSet { /// /// ## Examples /// ```rust - /// # use ruff::registry::{Rule, RuleSet}; + /// # use ruff_linter::registry::{Rule, RuleSet}; /// let mut set = RuleSet::empty(); /// /// assert!(!set.contains(Rule::AnyType)); @@ -211,7 +211,7 @@ impl RuleSet { /// /// ## Examples /// ```rust - /// # use ruff::registry::{Rule, RuleSet}; + /// # use ruff_linter::registry::{Rule, RuleSet}; /// let mut set = RuleSet::from_rules(&[Rule::AmbiguousFunctionName, Rule::AnyType]); /// /// set.remove(Rule::AmbiguousFunctionName); @@ -228,7 +228,7 @@ impl RuleSet { /// /// ## Examples /// ```rust - /// # use ruff::registry::{Rule, RuleSet}; + /// # use ruff_linter::registry::{Rule, RuleSet}; /// let set = RuleSet::from_rules(&[Rule::AmbiguousFunctionName, Rule::AnyType]); /// /// assert!(set.contains(Rule::AmbiguousFunctionName)); @@ -248,7 +248,7 @@ impl RuleSet { /// ## Examples /// /// ```rust - /// # use ruff::registry::{Rule, RuleSet}; + /// # use ruff_linter::registry::{Rule, RuleSet}; /// let set = RuleSet::from_rules(&[Rule::AmbiguousFunctionName, Rule::AnyType]); /// /// let iter: Vec<_> = set.iter().collect(); diff --git a/crates/ruff/src/renamer.rs b/crates/ruff_linter/src/renamer.rs similarity index 100% rename from crates/ruff/src/renamer.rs rename to crates/ruff_linter/src/renamer.rs diff --git a/crates/ruff/src/rule_redirects.rs b/crates/ruff_linter/src/rule_redirects.rs similarity index 100% rename from crates/ruff/src/rule_redirects.rs rename to crates/ruff_linter/src/rule_redirects.rs diff --git a/crates/ruff/src/rule_selector.rs b/crates/ruff_linter/src/rule_selector.rs similarity index 100% rename from crates/ruff/src/rule_selector.rs rename to crates/ruff_linter/src/rule_selector.rs diff --git a/crates/ruff/src/rules/airflow/mod.rs b/crates/ruff_linter/src/rules/airflow/mod.rs similarity index 100% rename from crates/ruff/src/rules/airflow/mod.rs rename to crates/ruff_linter/src/rules/airflow/mod.rs diff --git a/crates/ruff/src/rules/airflow/rules/mod.rs b/crates/ruff_linter/src/rules/airflow/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/airflow/rules/mod.rs rename to crates/ruff_linter/src/rules/airflow/rules/mod.rs diff --git a/crates/ruff/src/rules/airflow/rules/task_variable_name.rs b/crates/ruff_linter/src/rules/airflow/rules/task_variable_name.rs similarity index 100% rename from crates/ruff/src/rules/airflow/rules/task_variable_name.rs rename to crates/ruff_linter/src/rules/airflow/rules/task_variable_name.rs 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 new file mode 100644 index 0000000000..c4bf5bd7b9 --- /dev/null +++ b/crates/ruff_linter/src/rules/airflow/snapshots/ruff_linter__rules__airflow__tests__AIR001_AIR001.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/airflow/mod.rs +--- +AIR001.py:11:1: AIR001 Task variable name should match the `task_id`: "my_task" + | + 9 | my_task_2 = PythonOperator(callable=my_callable, task_id="my_task_2") +10 | +11 | incorrect_name = PythonOperator(task_id="my_task") + | ^^^^^^^^^^^^^^ AIR001 +12 | incorrect_name_2 = PythonOperator(callable=my_callable, task_id="my_task_2") + | + +AIR001.py:12:1: AIR001 Task variable name should match the `task_id`: "my_task_2" + | +11 | incorrect_name = PythonOperator(task_id="my_task") +12 | incorrect_name_2 = PythonOperator(callable=my_callable, task_id="my_task_2") + | ^^^^^^^^^^^^^^^^ AIR001 +13 | +14 | from my_module import MyClass + | + + diff --git a/crates/ruff/src/rules/eradicate/detection.rs b/crates/ruff_linter/src/rules/eradicate/detection.rs similarity index 100% rename from crates/ruff/src/rules/eradicate/detection.rs rename to crates/ruff_linter/src/rules/eradicate/detection.rs diff --git a/crates/ruff/src/rules/eradicate/mod.rs b/crates/ruff_linter/src/rules/eradicate/mod.rs similarity index 100% rename from crates/ruff/src/rules/eradicate/mod.rs rename to crates/ruff_linter/src/rules/eradicate/mod.rs diff --git a/crates/ruff/src/rules/eradicate/rules/commented_out_code.rs b/crates/ruff_linter/src/rules/eradicate/rules/commented_out_code.rs similarity index 100% rename from crates/ruff/src/rules/eradicate/rules/commented_out_code.rs rename to crates/ruff_linter/src/rules/eradicate/rules/commented_out_code.rs diff --git a/crates/ruff/src/rules/eradicate/rules/mod.rs b/crates/ruff_linter/src/rules/eradicate/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/eradicate/rules/mod.rs rename to crates/ruff_linter/src/rules/eradicate/rules/mod.rs 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 new file mode 100644 index 0000000000..c33d3b0978 --- /dev/null +++ b/crates/ruff_linter/src/rules/eradicate/snapshots/ruff_linter__rules__eradicate__tests__ERA001_ERA001.py.snap @@ -0,0 +1,151 @@ +--- +source: crates/ruff_linter/src/rules/eradicate/mod.rs +--- +ERA001.py:1:1: ERA001 [*] Found commented-out code + | +1 | #import os + | ^^^^^^^^^^ ERA001 +2 | # from foo import junk +3 | #a = 3 + | + = help: Remove commented-out code + +ℹ Possible fix +1 |-#import os +2 1 | # from foo import junk +3 2 | #a = 3 +4 3 | a = 4 + +ERA001.py:2:1: ERA001 [*] Found commented-out code + | +1 | #import os +2 | # from foo import junk + | ^^^^^^^^^^^^^^^^^^^^^^ ERA001 +3 | #a = 3 +4 | a = 4 + | + = help: Remove commented-out code + +ℹ Possible fix +1 1 | #import os +2 |-# from foo import junk +3 2 | #a = 3 +4 3 | a = 4 +5 4 | #foo(1, 2, 3) + +ERA001.py:3:1: ERA001 [*] Found commented-out code + | +1 | #import os +2 | # from foo import junk +3 | #a = 3 + | ^^^^^^ ERA001 +4 | a = 4 +5 | #foo(1, 2, 3) + | + = help: Remove commented-out code + +ℹ Possible fix +1 1 | #import os +2 2 | # from foo import junk +3 |-#a = 3 +4 3 | a = 4 +5 4 | #foo(1, 2, 3) +6 5 | + +ERA001.py:5:1: ERA001 [*] Found commented-out code + | +3 | #a = 3 +4 | a = 4 +5 | #foo(1, 2, 3) + | ^^^^^^^^^^^^^ ERA001 +6 | +7 | def foo(x, y, z): + | + = help: Remove commented-out code + +ℹ Possible fix +2 2 | # from foo import junk +3 3 | #a = 3 +4 4 | a = 4 +5 |-#foo(1, 2, 3) +6 5 | +7 6 | def foo(x, y, z): +8 7 | content = 1 # print('hello') + +ERA001.py:13:5: ERA001 [*] Found commented-out code + | +11 | # This is a real comment. +12 | # # This is a (nested) comment. +13 | #return True + | ^^^^^^^^^^^^ ERA001 +14 | return False + | + = help: Remove commented-out code + +ℹ Possible fix +10 10 | +11 11 | # This is a real comment. +12 12 | # # This is a (nested) comment. +13 |- #return True +14 13 | return False +15 14 | +16 15 | #import os # noqa: ERA001 + +ERA001.py:21:5: ERA001 [*] Found commented-out code + | +19 | class A(): +20 | pass +21 | # b = c + | ^^^^^^^ ERA001 + | + = help: Remove commented-out code + +ℹ Possible fix +18 18 | +19 19 | class A(): +20 20 | pass +21 |- # b = c +22 21 | +23 22 | +24 23 | dictionary = { + +ERA001.py:26:5: ERA001 [*] Found commented-out code + | +24 | dictionary = { +25 | # "key1": 123, # noqa: ERA001 +26 | # "key2": 456, + | ^^^^^^^^^^^^^^ ERA001 +27 | # "key3": 789, # test +28 | } + | + = help: Remove commented-out code + +ℹ Possible fix +23 23 | +24 24 | dictionary = { +25 25 | # "key1": 123, # noqa: ERA001 +26 |- # "key2": 456, +27 26 | # "key3": 789, # test +28 27 | } +29 28 | + +ERA001.py:27:5: ERA001 [*] Found commented-out code + | +25 | # "key1": 123, # noqa: ERA001 +26 | # "key2": 456, +27 | # "key3": 789, # test + | ^^^^^^^^^^^^^^^^^^^^^^ ERA001 +28 | } + | + = help: Remove commented-out code + +ℹ Possible fix +24 24 | dictionary = { +25 25 | # "key1": 123, # noqa: ERA001 +26 26 | # "key2": 456, +27 |- # "key3": 789, # test +28 27 | } +29 28 | +30 29 | #import os # noqa + + diff --git a/crates/ruff/src/rules/flake8_2020/helpers.rs b/crates/ruff_linter/src/rules/flake8_2020/helpers.rs similarity index 100% rename from crates/ruff/src/rules/flake8_2020/helpers.rs rename to crates/ruff_linter/src/rules/flake8_2020/helpers.rs diff --git a/crates/ruff/src/rules/flake8_2020/mod.rs b/crates/ruff_linter/src/rules/flake8_2020/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_2020/mod.rs rename to crates/ruff_linter/src/rules/flake8_2020/mod.rs diff --git a/crates/ruff/src/rules/flake8_2020/rules/compare.rs b/crates/ruff_linter/src/rules/flake8_2020/rules/compare.rs similarity index 100% rename from crates/ruff/src/rules/flake8_2020/rules/compare.rs rename to crates/ruff_linter/src/rules/flake8_2020/rules/compare.rs diff --git a/crates/ruff/src/rules/flake8_2020/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_2020/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_2020/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_2020/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_2020/rules/name_or_attribute.rs b/crates/ruff_linter/src/rules/flake8_2020/rules/name_or_attribute.rs similarity index 100% rename from crates/ruff/src/rules/flake8_2020/rules/name_or_attribute.rs rename to crates/ruff_linter/src/rules/flake8_2020/rules/name_or_attribute.rs diff --git a/crates/ruff/src/rules/flake8_2020/rules/subscript.rs b/crates/ruff_linter/src/rules/flake8_2020/rules/subscript.rs similarity index 100% rename from crates/ruff/src/rules/flake8_2020/rules/subscript.rs rename to crates/ruff_linter/src/rules/flake8_2020/rules/subscript.rs 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 new file mode 100644 index 0000000000..bc9ee591ad --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT101_YTT101.py.snap @@ -0,0 +1,32 @@ +--- +source: crates/ruff_linter/src/rules/flake8_2020/mod.rs +--- +YTT101.py:6:7: YTT101 `sys.version[:3]` referenced (python3.10), use `sys.version_info` + | +4 | print(sys.version) +5 | +6 | print(sys.version[:3]) + | ^^^^^^^^^^^ YTT101 +7 | print(version[:3]) +8 | print(v[:3]) + | + +YTT101.py:7:7: YTT101 `sys.version[:3]` referenced (python3.10), use `sys.version_info` + | +6 | print(sys.version[:3]) +7 | print(version[:3]) + | ^^^^^^^ YTT101 +8 | print(v[:3]) + | + +YTT101.py:8:7: YTT101 `sys.version[:3]` referenced (python3.10), use `sys.version_info` + | + 6 | print(sys.version[:3]) + 7 | print(version[:3]) + 8 | print(v[:3]) + | ^ YTT101 + 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 new file mode 100644 index 0000000000..d53992394e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT102_YTT102.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/flake8_2020/mod.rs +--- +YTT102.py:4:12: YTT102 `sys.version[2]` referenced (python3.10), use `sys.version_info` + | +2 | from sys import version +3 | +4 | py_minor = sys.version[2] + | ^^^^^^^^^^^ YTT102 +5 | py_minor = version[2] + | + +YTT102.py:5:12: YTT102 `sys.version[2]` referenced (python3.10), use `sys.version_info` + | +4 | py_minor = sys.version[2] +5 | py_minor = version[2] + | ^^^^^^^ YTT102 + | + + 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 new file mode 100644 index 0000000000..8adb672777 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT103_YTT103.py.snap @@ -0,0 +1,50 @@ +--- +source: crates/ruff_linter/src/rules/flake8_2020/mod.rs +--- +YTT103.py:4:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` + | +2 | from sys import version +3 | +4 | version < "3.5" + | ^^^^^^^ YTT103 +5 | sys.version < "3.5" +6 | sys.version <= "3.5" + | + +YTT103.py:5:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` + | +4 | version < "3.5" +5 | sys.version < "3.5" + | ^^^^^^^^^^^ YTT103 +6 | sys.version <= "3.5" +7 | sys.version > "3.5" + | + +YTT103.py:6:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` + | +4 | version < "3.5" +5 | sys.version < "3.5" +6 | sys.version <= "3.5" + | ^^^^^^^^^^^ YTT103 +7 | sys.version > "3.5" +8 | sys.version >= "3.5" + | + +YTT103.py:7:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` + | +5 | sys.version < "3.5" +6 | sys.version <= "3.5" +7 | sys.version > "3.5" + | ^^^^^^^^^^^ YTT103 +8 | sys.version >= "3.5" + | + +YTT103.py:8:1: YTT103 `sys.version` compared to string (python3.10), use `sys.version_info` + | +6 | sys.version <= "3.5" +7 | sys.version > "3.5" +8 | sys.version >= "3.5" + | ^^^^^^^^^^^ YTT103 + | + + 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 new file mode 100644 index 0000000000..f546967999 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT201_YTT201.py.snap @@ -0,0 +1,40 @@ +--- +source: crates/ruff_linter/src/rules/flake8_2020/mod.rs +--- +YTT201.py:7:7: YTT201 `sys.version_info[0] == 3` referenced (python4), use `>=` + | +5 | PY3 = sys.version_info[0] >= 3 +6 | +7 | PY3 = sys.version_info[0] == 3 + | ^^^^^^^^^^^^^^^^^^^ YTT201 +8 | PY3 = version_info[0] == 3 +9 | PY2 = sys.version_info[0] != 3 + | + +YTT201.py:8:7: YTT201 `sys.version_info[0] == 3` referenced (python4), use `>=` + | + 7 | PY3 = sys.version_info[0] == 3 + 8 | PY3 = version_info[0] == 3 + | ^^^^^^^^^^^^^^^ YTT201 + 9 | PY2 = sys.version_info[0] != 3 +10 | PY2 = version_info[0] != 3 + | + +YTT201.py:9:7: YTT201 `sys.version_info[0] == 3` referenced (python4), use `>=` + | + 7 | PY3 = sys.version_info[0] == 3 + 8 | PY3 = version_info[0] == 3 + 9 | PY2 = sys.version_info[0] != 3 + | ^^^^^^^^^^^^^^^^^^^ YTT201 +10 | PY2 = version_info[0] != 3 + | + +YTT201.py:10:7: YTT201 `sys.version_info[0] == 3` referenced (python4), use `>=` + | + 8 | PY3 = version_info[0] == 3 + 9 | PY2 = sys.version_info[0] != 3 +10 | PY2 = version_info[0] != 3 + | ^^^^^^^^^^^^^^^ YTT201 + | + + 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 new file mode 100644 index 0000000000..0e587466f9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT202_YTT202.py.snap @@ -0,0 +1,23 @@ +--- +source: crates/ruff_linter/src/rules/flake8_2020/mod.rs +--- +YTT202.py:4:4: YTT202 `six.PY3` referenced (python4), use `not six.PY2` + | +2 | from six import PY3 +3 | +4 | if six.PY3: + | ^^^^^^^ YTT202 +5 | print("3") +6 | if PY3: + | + +YTT202.py:6:4: YTT202 `six.PY3` referenced (python4), use `not six.PY2` + | +4 | if six.PY3: +5 | print("3") +6 | if PY3: + | ^^^ YTT202 +7 | 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 new file mode 100644 index 0000000000..a10f86b44e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT203_YTT203.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/flake8_2020/mod.rs +--- +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 | +4 | sys.version_info[1] >= 5 + | ^^^^^^^^^^^^^^^^^^^ YTT203 +5 | version_info[1] < 6 + | + +YTT203.py:5:1: YTT203 `sys.version_info[1]` compared to integer (python4), compare `sys.version_info` to tuple + | +4 | sys.version_info[1] >= 5 +5 | version_info[1] < 6 + | ^^^^^^^^^^^^^^^ YTT203 + | + + 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 new file mode 100644 index 0000000000..69997d727b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT204_YTT204.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/flake8_2020/mod.rs +--- +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 | +4 | sys.version_info.minor <= 7 + | ^^^^^^^^^^^^^^^^^^^^^^ YTT204 +5 | version_info.minor > 8 + | + +YTT204.py:5:1: YTT204 `sys.version_info.minor` compared to integer (python4), compare `sys.version_info` to tuple + | +4 | sys.version_info.minor <= 7 +5 | version_info.minor > 8 + | ^^^^^^^^^^^^^^^^^^ YTT204 + | + + 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 new file mode 100644 index 0000000000..543dd08b1e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT301_YTT301.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/flake8_2020/mod.rs +--- +YTT301.py:4:12: YTT301 `sys.version[0]` referenced (python10), use `sys.version_info` + | +2 | from sys import version +3 | +4 | py_major = sys.version[0] + | ^^^^^^^^^^^ YTT301 +5 | py_major = version[0] + | + +YTT301.py:5:12: YTT301 `sys.version[0]` referenced (python10), use `sys.version_info` + | +4 | py_major = sys.version[0] +5 | py_major = version[0] + | ^^^^^^^ YTT301 + | + + 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 new file mode 100644 index 0000000000..11a4dea38b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT302_YTT302.py.snap @@ -0,0 +1,50 @@ +--- +source: crates/ruff_linter/src/rules/flake8_2020/mod.rs +--- +YTT302.py:4:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info` + | +2 | from sys import version +3 | +4 | version < "3" + | ^^^^^^^ YTT302 +5 | sys.version < "3" +6 | sys.version <= "3" + | + +YTT302.py:5:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info` + | +4 | version < "3" +5 | sys.version < "3" + | ^^^^^^^^^^^ YTT302 +6 | sys.version <= "3" +7 | sys.version > "3" + | + +YTT302.py:6:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info` + | +4 | version < "3" +5 | sys.version < "3" +6 | sys.version <= "3" + | ^^^^^^^^^^^ YTT302 +7 | sys.version > "3" +8 | sys.version >= "3" + | + +YTT302.py:7:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info` + | +5 | sys.version < "3" +6 | sys.version <= "3" +7 | sys.version > "3" + | ^^^^^^^^^^^ YTT302 +8 | sys.version >= "3" + | + +YTT302.py:8:1: YTT302 `sys.version` compared to string (python10), use `sys.version_info` + | +6 | sys.version <= "3" +7 | sys.version > "3" +8 | sys.version >= "3" + | ^^^^^^^^^^^ YTT302 + | + + 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 new file mode 100644 index 0000000000..0e84487271 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_2020/snapshots/ruff_linter__rules__flake8_2020__tests__YTT303_YTT303.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/flake8_2020/mod.rs +--- +YTT303.py:4:7: YTT303 `sys.version[:1]` referenced (python10), use `sys.version_info` + | +2 | from sys import version +3 | +4 | print(sys.version[:1]) + | ^^^^^^^^^^^ YTT303 +5 | print(version[:1]) + | + +YTT303.py:5:7: YTT303 `sys.version[:1]` referenced (python10), use `sys.version_info` + | +4 | print(sys.version[:1]) +5 | print(version[:1]) + | ^^^^^^^ YTT303 + | + + diff --git a/crates/ruff/src/rules/flake8_annotations/helpers.rs b/crates/ruff_linter/src/rules/flake8_annotations/helpers.rs similarity index 100% rename from crates/ruff/src/rules/flake8_annotations/helpers.rs rename to crates/ruff_linter/src/rules/flake8_annotations/helpers.rs diff --git a/crates/ruff/src/rules/flake8_annotations/mod.rs b/crates/ruff_linter/src/rules/flake8_annotations/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_annotations/mod.rs rename to crates/ruff_linter/src/rules/flake8_annotations/mod.rs diff --git a/crates/ruff/src/rules/flake8_annotations/rules/definition.rs b/crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs similarity index 100% rename from crates/ruff/src/rules/flake8_annotations/rules/definition.rs rename to crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs diff --git a/crates/ruff/src/rules/flake8_annotations/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_annotations/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_annotations/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_annotations/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_annotations/settings.rs b/crates/ruff_linter/src/rules/flake8_annotations/settings.rs similarity index 100% rename from crates/ruff/src/rules/flake8_annotations/settings.rs rename to crates/ruff_linter/src/rules/flake8_annotations/settings.rs diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__allow_nested_overload.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__allow_nested_overload.snap new file mode 100644 index 0000000000..1cda90bb2d --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__allow_nested_overload.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__allow_overload.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__allow_overload.snap new file mode 100644 index 0000000000..b120a666f6 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__allow_overload.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs +--- +allow_overload.py:29:9: ANN201 Missing return type annotation for public function `bar` + | +28 | class X: +29 | def bar(i): + | ^^^ ANN201 +30 | return i + | + + diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__allow_star_arg_any.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__allow_star_arg_any.snap new file mode 100644 index 0000000000..15afb68229 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__allow_star_arg_any.snap @@ -0,0 +1,36 @@ +--- +source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs +--- +allow_star_arg_any.py:10:12: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + | + 9 | # ANN401 +10 | def foo(a: Any, *args: str, **kwargs: str) -> int: + | ^^^ ANN401 +11 | pass + | + +allow_star_arg_any.py:15:47: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo` + | +14 | # ANN401 +15 | def foo(a: int, *args: str, **kwargs: str) -> Any: + | ^^^ ANN401 +16 | pass + | + +allow_star_arg_any.py:40:29: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + | +39 | # ANN401 +40 | def foo_method(self, a: Any, *params: str, **options: str) -> int: + | ^^^ ANN401 +41 | pass + | + +allow_star_arg_any.py:44:67: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo_method` + | +43 | # ANN401 +44 | def foo_method(self, a: int, *params: str, **options: str) -> Any: + | ^^^ ANN401 +45 | pass + | + + diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__defaults.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__defaults.snap new file mode 100644 index 0000000000..10154ea5c0 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__defaults.snap @@ -0,0 +1,263 @@ +--- +source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs +--- +annotation_presence.py:5:5: ANN201 Missing return type annotation for public function `foo` + | +4 | # Error +5 | def foo(a, b): + | ^^^ ANN201 +6 | pass + | + +annotation_presence.py:5:9: ANN001 Missing type annotation for function argument `a` + | +4 | # Error +5 | def foo(a, b): + | ^ ANN001 +6 | pass + | + +annotation_presence.py:5:12: ANN001 Missing type annotation for function argument `b` + | +4 | # Error +5 | def foo(a, b): + | ^ ANN001 +6 | pass + | + +annotation_presence.py:10:5: ANN201 Missing return type annotation for public function `foo` + | + 9 | # Error +10 | def foo(a: int, b): + | ^^^ ANN201 +11 | pass + | + +annotation_presence.py:10:17: ANN001 Missing type annotation for function argument `b` + | + 9 | # Error +10 | def foo(a: int, b): + | ^ ANN001 +11 | pass + | + +annotation_presence.py:15:17: ANN001 Missing type annotation for function argument `b` + | +14 | # Error +15 | def foo(a: int, b) -> int: + | ^ ANN001 +16 | pass + | + +annotation_presence.py:20:5: ANN201 Missing return type annotation for public function `foo` + | +19 | # Error +20 | def foo(a: int, b: int): + | ^^^ ANN201 +21 | pass + | + +annotation_presence.py:25:5: ANN201 Missing return type annotation for public function `foo` + | +24 | # Error +25 | def foo(): + | ^^^ ANN201 +26 | pass + | + +annotation_presence.py:45:12: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + | +44 | # ANN401 +45 | def foo(a: Any, *args: str, **kwargs: str) -> int: + | ^^^ ANN401 +46 | pass + | + +annotation_presence.py:50:47: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo` + | +49 | # ANN401 +50 | def foo(a: int, *args: str, **kwargs: str) -> Any: + | ^^^ ANN401 +51 | pass + | + +annotation_presence.py:55:24: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*args` + | +54 | # ANN401 +55 | def foo(a: int, *args: Any, **kwargs: Any) -> int: + | ^^^ ANN401 +56 | pass + | + +annotation_presence.py:55:39: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**kwargs` + | +54 | # ANN401 +55 | def foo(a: int, *args: Any, **kwargs: Any) -> int: + | ^^^ ANN401 +56 | pass + | + +annotation_presence.py:60:24: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*args` + | +59 | # ANN401 +60 | def foo(a: int, *args: Any, **kwargs: str) -> int: + | ^^^ ANN401 +61 | pass + | + +annotation_presence.py:65:39: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**kwargs` + | +64 | # ANN401 +65 | def foo(a: int, *args: str, **kwargs: Any) -> int: + | ^^^ ANN401 +66 | pass + | + +annotation_presence.py:75:13: ANN101 Missing type annotation for `self` in method + | +74 | # ANN101 +75 | def foo(self, a: int, b: int) -> int: + | ^^^^ ANN101 +76 | pass + | + +annotation_presence.py:79:29: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + | +78 | # ANN401 +79 | def foo(self: "Foo", a: Any, *params: str, **options: str) -> int: + | ^^^ ANN401 +80 | pass + | + +annotation_presence.py:83:67: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `foo` + | +82 | # ANN401 +83 | def foo(self: "Foo", a: int, *params: str, **options: str) -> Any: + | ^^^ ANN401 +84 | pass + | + +annotation_presence.py:87:43: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*params` + | +86 | # ANN401 +87 | def foo(self: "Foo", a: int, *params: Any, **options: Any) -> int: + | ^^^ ANN401 +88 | pass + | + +annotation_presence.py:87:59: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**options` + | +86 | # ANN401 +87 | def foo(self: "Foo", a: int, *params: Any, **options: Any) -> int: + | ^^^ ANN401 +88 | pass + | + +annotation_presence.py:91:43: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `*params` + | +90 | # ANN401 +91 | def foo(self: "Foo", a: int, *params: Any, **options: str) -> int: + | ^^^ ANN401 +92 | pass + | + +annotation_presence.py:95:59: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `**options` + | +94 | # ANN401 +95 | def foo(self: "Foo", a: int, *params: str, **options: Any) -> int: + | ^^^ ANN401 +96 | pass + | + +annotation_presence.py:130:13: ANN102 Missing type annotation for `cls` in classmethod + | +128 | # ANN102 +129 | @classmethod +130 | def foo(cls, a: int, b: int) -> int: + | ^^^ ANN102 +131 | pass + | + +annotation_presence.py:134:13: ANN101 Missing type annotation for `self` in method + | +133 | # ANN101 +134 | def foo(self, /, a: int, b: int) -> int: + | ^^^^ ANN101 +135 | pass + | + +annotation_presence.py:149:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + | +148 | # ANN401 +149 | def f(a: Any | int) -> None: ... + | ^^^^^^^^^ ANN401 +150 | def f(a: int | Any) -> None: ... +151 | def f(a: Union[str, bytes, Any]) -> None: ... + | + +annotation_presence.py:150:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + | +148 | # ANN401 +149 | def f(a: Any | int) -> None: ... +150 | def f(a: int | Any) -> None: ... + | ^^^^^^^^^ ANN401 +151 | def f(a: Union[str, bytes, Any]) -> None: ... +152 | def f(a: Optional[Any]) -> None: ... + | + +annotation_presence.py:151:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + | +149 | def f(a: Any | int) -> None: ... +150 | def f(a: int | Any) -> None: ... +151 | def f(a: Union[str, bytes, Any]) -> None: ... + | ^^^^^^^^^^^^^^^^^^^^^^ ANN401 +152 | def f(a: Optional[Any]) -> None: ... +153 | def f(a: Annotated[Any, ...]) -> None: ... + | + +annotation_presence.py:152:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + | +150 | def f(a: int | Any) -> None: ... +151 | def f(a: Union[str, bytes, Any]) -> None: ... +152 | def f(a: Optional[Any]) -> None: ... + | ^^^^^^^^^^^^^ ANN401 +153 | def f(a: Annotated[Any, ...]) -> None: ... +154 | def f(a: "Union[str, bytes, Any]") -> None: ... + | + +annotation_presence.py:153:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + | +151 | def f(a: Union[str, bytes, Any]) -> None: ... +152 | def f(a: Optional[Any]) -> None: ... +153 | def f(a: Annotated[Any, ...]) -> None: ... + | ^^^^^^^^^^^^^^^^^^^ ANN401 +154 | def f(a: "Union[str, bytes, Any]") -> None: ... + | + +annotation_presence.py:154:10: ANN401 Dynamically typed expressions (typing.Any) are disallowed in `a` + | +152 | def f(a: Optional[Any]) -> None: ... +153 | def f(a: Annotated[Any, ...]) -> None: ... +154 | def f(a: "Union[str, bytes, Any]") -> None: ... + | ^^^^^^^^^^^^^^^^^^^^^^^^ ANN401 + | + +annotation_presence.py:159:9: ANN204 [*] Missing return type annotation for special method `__init__` + | +157 | class Foo: +158 | @decorator() +159 | def __init__(self: "Foo", foo: int): + | ^^^^^^^^ ANN204 +160 | ... + | + = help: Add `None` return type + +ℹ Suggested fix +156 156 | +157 157 | class Foo: +158 158 | @decorator() +159 |- def __init__(self: "Foo", foo: int): + 159 |+ def __init__(self: "Foo", foo: int) -> None: +160 160 | ... + + 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 new file mode 100644 index 0000000000..70d0e78d8d --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__ignore_fully_untyped.snap @@ -0,0 +1,41 @@ +--- +source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs +--- +ignore_fully_untyped.py:24:5: ANN201 Missing return type annotation for public function `error_partially_typed_1` + | +24 | def error_partially_typed_1(a: int, b): + | ^^^^^^^^^^^^^^^^^^^^^^^ ANN201 +25 | pass + | + +ignore_fully_untyped.py:24:37: ANN001 Missing type annotation for function argument `b` + | +24 | def error_partially_typed_1(a: int, b): + | ^ ANN001 +25 | pass + | + +ignore_fully_untyped.py:28:37: ANN001 Missing type annotation for function argument `b` + | +28 | def error_partially_typed_2(a: int, b) -> int: + | ^ ANN001 +29 | pass + | + +ignore_fully_untyped.py:32:5: ANN201 Missing return type annotation for public function `error_partially_typed_3` + | +32 | def error_partially_typed_3(a: int, b: int): + | ^^^^^^^^^^^^^^^^^^^^^^^ ANN201 +33 | pass + | + +ignore_fully_untyped.py:43:9: ANN201 Missing return type annotation for public function `error_typed_self` + | +41 | pass +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__mypy_init_return.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__mypy_init_return.snap new file mode 100644 index 0000000000..193ef4f8ba --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__mypy_init_return.snap @@ -0,0 +1,70 @@ +--- +source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs +--- +mypy_init_return.py:5:9: ANN204 [*] Missing return type annotation for special method `__init__` + | +3 | # Error +4 | class Foo: +5 | def __init__(self): + | ^^^^^^^^ ANN204 +6 | ... + | + = help: Add `None` return type + +ℹ Suggested fix +2 2 | +3 3 | # Error +4 4 | class Foo: +5 |- def __init__(self): + 5 |+ def __init__(self) -> None: +6 6 | ... +7 7 | +8 8 | + +mypy_init_return.py:11:9: ANN204 [*] Missing return type annotation for special method `__init__` + | + 9 | # Error +10 | class Foo: +11 | def __init__(self, foo): + | ^^^^^^^^ ANN204 +12 | ... + | + = help: Add `None` return type + +ℹ Suggested fix +8 8 | +9 9 | # Error +10 10 | class Foo: +11 |- def __init__(self, foo): + 11 |+ def __init__(self, foo) -> None: +12 12 | ... +13 13 | +14 14 | + +mypy_init_return.py:40:5: ANN202 Missing return type annotation for private function `__init__` + | +39 | # Error +40 | def __init__(self, foo: int): + | ^^^^^^^^ ANN202 +41 | ... + | + +mypy_init_return.py:47:9: ANN204 [*] Missing return type annotation for special method `__init__` + | +45 | # of a vararg falsely indicated that the function has a typed argument. +46 | class Foo: +47 | def __init__(self, *arg): + | ^^^^^^^^ ANN204 +48 | ... + | + = help: Add `None` return type + +ℹ Suggested fix +44 44 | # Error – used to be ok for a moment since the mere presence +45 45 | # of a vararg falsely indicated that the function has a typed argument. +46 46 | class Foo: +47 |- def __init__(self, *arg): + 47 |+ def __init__(self, *arg) -> None: +48 48 | ... + + 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 new file mode 100644 index 0000000000..8dd48048c6 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__simple_magic_methods.snap @@ -0,0 +1,279 @@ +--- +source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs +--- +simple_magic_methods.py:2:9: ANN204 [*] Missing return type annotation for special method `__str__` + | +1 | class Foo: +2 | def __str__(self): + | ^^^^^^^ ANN204 +3 | ... + | + = help: Add `None` return type + +ℹ Suggested fix +1 1 | class Foo: +2 |- def __str__(self): + 2 |+ def __str__(self) -> str: +3 3 | ... +4 4 | +5 5 | def __repr__(self): + +simple_magic_methods.py:5:9: ANN204 [*] Missing return type annotation for special method `__repr__` + | +3 | ... +4 | +5 | def __repr__(self): + | ^^^^^^^^ ANN204 +6 | ... + | + = help: Add `None` return type + +ℹ Suggested fix +2 2 | def __str__(self): +3 3 | ... +4 4 | +5 |- def __repr__(self): + 5 |+ def __repr__(self) -> str: +6 6 | ... +7 7 | +8 8 | def __len__(self): + +simple_magic_methods.py:8:9: ANN204 [*] Missing return type annotation for special method `__len__` + | +6 | ... +7 | +8 | def __len__(self): + | ^^^^^^^ ANN204 +9 | ... + | + = help: Add `None` return type + +ℹ Suggested fix +5 5 | def __repr__(self): +6 6 | ... +7 7 | +8 |- def __len__(self): + 8 |+ def __len__(self) -> int: +9 9 | ... +10 10 | +11 11 | def __length_hint__(self): + +simple_magic_methods.py:11:9: ANN204 [*] Missing return type annotation for special method `__length_hint__` + | + 9 | ... +10 | +11 | def __length_hint__(self): + | ^^^^^^^^^^^^^^^ ANN204 +12 | ... + | + = help: Add `None` return type + +ℹ Suggested fix +8 8 | def __len__(self): +9 9 | ... +10 10 | +11 |- def __length_hint__(self): + 11 |+ def __length_hint__(self) -> int: +12 12 | ... +13 13 | +14 14 | def __init__(self): + +simple_magic_methods.py:14:9: ANN204 [*] Missing return type annotation for special method `__init__` + | +12 | ... +13 | +14 | def __init__(self): + | ^^^^^^^^ ANN204 +15 | ... + | + = help: Add `None` return type + +ℹ Suggested fix +11 11 | def __length_hint__(self): +12 12 | ... +13 13 | +14 |- def __init__(self): + 14 |+ def __init__(self) -> None: +15 15 | ... +16 16 | +17 17 | def __del__(self): + +simple_magic_methods.py:17:9: ANN204 [*] Missing return type annotation for special method `__del__` + | +15 | ... +16 | +17 | def __del__(self): + | ^^^^^^^ ANN204 +18 | ... + | + = help: Add `None` return type + +ℹ Suggested fix +14 14 | def __init__(self): +15 15 | ... +16 16 | +17 |- def __del__(self): + 17 |+ def __del__(self) -> None: +18 18 | ... +19 19 | +20 20 | def __bool__(self): + +simple_magic_methods.py:20:9: ANN204 [*] Missing return type annotation for special method `__bool__` + | +18 | ... +19 | +20 | def __bool__(self): + | ^^^^^^^^ ANN204 +21 | ... + | + = help: Add `None` return type + +ℹ Suggested fix +17 17 | def __del__(self): +18 18 | ... +19 19 | +20 |- def __bool__(self): + 20 |+ def __bool__(self) -> bool: +21 21 | ... +22 22 | +23 23 | def __bytes__(self): + +simple_magic_methods.py:23:9: ANN204 [*] Missing return type annotation for special method `__bytes__` + | +21 | ... +22 | +23 | def __bytes__(self): + | ^^^^^^^^^ ANN204 +24 | ... + | + = help: Add `None` return type + +ℹ Suggested fix +20 20 | def __bool__(self): +21 21 | ... +22 22 | +23 |- def __bytes__(self): + 23 |+ def __bytes__(self) -> bytes: +24 24 | ... +25 25 | +26 26 | def __format__(self, format_spec): + +simple_magic_methods.py:26:9: ANN204 [*] Missing return type annotation for special method `__format__` + | +24 | ... +25 | +26 | def __format__(self, format_spec): + | ^^^^^^^^^^ ANN204 +27 | ... + | + = help: Add `None` return type + +ℹ Suggested fix +23 23 | def __bytes__(self): +24 24 | ... +25 25 | +26 |- def __format__(self, format_spec): + 26 |+ def __format__(self, format_spec) -> str: +27 27 | ... +28 28 | +29 29 | def __contains__(self, item): + +simple_magic_methods.py:29:9: ANN204 [*] Missing return type annotation for special method `__contains__` + | +27 | ... +28 | +29 | def __contains__(self, item): + | ^^^^^^^^^^^^ ANN204 +30 | ... + | + = help: Add `None` return type + +ℹ Suggested fix +26 26 | def __format__(self, format_spec): +27 27 | ... +28 28 | +29 |- def __contains__(self, item): + 29 |+ def __contains__(self, item) -> bool: +30 30 | ... +31 31 | +32 32 | def __complex__(self): + +simple_magic_methods.py:32:9: ANN204 [*] Missing return type annotation for special method `__complex__` + | +30 | ... +31 | +32 | def __complex__(self): + | ^^^^^^^^^^^ ANN204 +33 | ... + | + = help: Add `None` return type + +ℹ Suggested fix +29 29 | def __contains__(self, item): +30 30 | ... +31 31 | +32 |- def __complex__(self): + 32 |+ def __complex__(self) -> complex: +33 33 | ... +34 34 | +35 35 | def __int__(self): + +simple_magic_methods.py:35:9: ANN204 [*] Missing return type annotation for special method `__int__` + | +33 | ... +34 | +35 | def __int__(self): + | ^^^^^^^ ANN204 +36 | ... + | + = help: Add `None` return type + +ℹ Suggested fix +32 32 | def __complex__(self): +33 33 | ... +34 34 | +35 |- def __int__(self): + 35 |+ def __int__(self) -> int: +36 36 | ... +37 37 | +38 38 | def __float__(self): + +simple_magic_methods.py:38:9: ANN204 [*] Missing return type annotation for special method `__float__` + | +36 | ... +37 | +38 | def __float__(self): + | ^^^^^^^^^ ANN204 +39 | ... + | + = help: Add `None` return type + +ℹ Suggested fix +35 35 | def __int__(self): +36 36 | ... +37 37 | +38 |- def __float__(self): + 38 |+ def __float__(self) -> float: +39 39 | ... +40 40 | +41 41 | def __index__(self): + +simple_magic_methods.py:41:9: ANN204 [*] Missing return type annotation for special method `__index__` + | +39 | ... +40 | +41 | def __index__(self): + | ^^^^^^^^^ ANN204 +42 | ... + | + = help: Add `None` return type + +ℹ Suggested fix +38 38 | def __float__(self): +39 39 | ... +40 40 | +41 |- def __index__(self): + 41 |+ def __index__(self) -> int: +42 42 | ... + + diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__suppress_dummy_args.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__suppress_dummy_args.snap new file mode 100644 index 0000000000..1cda90bb2d --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__suppress_dummy_args.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__suppress_none_returning.snap b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__suppress_none_returning.snap new file mode 100644 index 0000000000..2b5ddaa81e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_annotations/snapshots/ruff_linter__rules__flake8_annotations__tests__suppress_none_returning.snap @@ -0,0 +1,29 @@ +--- +source: crates/ruff_linter/src/rules/flake8_annotations/mod.rs +--- +suppress_none_returning.py:45:5: ANN201 Missing return type annotation for public function `foo` + | +44 | # Error +45 | def foo(): + | ^^^ ANN201 +46 | return True + | + +suppress_none_returning.py:50:5: ANN201 Missing return type annotation for public function `foo` + | +49 | # Error +50 | def foo(): + | ^^^ ANN201 +51 | a = 2 + 2 +52 | if a == 4: + | + +suppress_none_returning.py:59:9: ANN001 Missing type annotation for function argument `a` + | +58 | # Error (on the argument, but not the return type) +59 | def foo(a): + | ^ ANN001 +60 | a = 2 + 2 + | + + diff --git a/crates/ruff/src/rules/flake8_async/mod.rs b/crates/ruff_linter/src/rules/flake8_async/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_async/mod.rs rename to crates/ruff_linter/src/rules/flake8_async/mod.rs diff --git a/crates/ruff/src/rules/flake8_async/rules/blocking_http_call.rs b/crates/ruff_linter/src/rules/flake8_async/rules/blocking_http_call.rs similarity index 100% rename from crates/ruff/src/rules/flake8_async/rules/blocking_http_call.rs rename to crates/ruff_linter/src/rules/flake8_async/rules/blocking_http_call.rs diff --git a/crates/ruff/src/rules/flake8_async/rules/blocking_os_call.rs b/crates/ruff_linter/src/rules/flake8_async/rules/blocking_os_call.rs similarity index 100% rename from crates/ruff/src/rules/flake8_async/rules/blocking_os_call.rs rename to crates/ruff_linter/src/rules/flake8_async/rules/blocking_os_call.rs diff --git a/crates/ruff/src/rules/flake8_async/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_async/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_async/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_async/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_async/rules/open_sleep_or_subprocess_call.rs b/crates/ruff_linter/src/rules/flake8_async/rules/open_sleep_or_subprocess_call.rs similarity index 100% rename from crates/ruff/src/rules/flake8_async/rules/open_sleep_or_subprocess_call.rs rename to crates/ruff_linter/src/rules/flake8_async/rules/open_sleep_or_subprocess_call.rs 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 new file mode 100644 index 0000000000..b7612ca1bc --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC100_ASYNC100.py.snap @@ -0,0 +1,39 @@ +--- +source: crates/ruff_linter/src/rules/flake8_async/mod.rs +--- +ASYNC100.py:7:5: ASYNC100 Async functions should not call blocking HTTP methods + | +6 | async def foo(): +7 | urllib.request.urlopen("http://example.com/foo/bar").read() + | ^^^^^^^^^^^^^^^^^^^^^^ ASYNC100 + | + +ASYNC100.py:11:5: ASYNC100 Async functions should not call blocking HTTP methods + | +10 | async def foo(): +11 | requests.get() + | ^^^^^^^^^^^^ ASYNC100 + | + +ASYNC100.py:15:5: ASYNC100 Async functions should not call blocking HTTP methods + | +14 | async def foo(): +15 | httpx.get() + | ^^^^^^^^^ ASYNC100 + | + +ASYNC100.py:19:5: ASYNC100 Async functions should not call blocking HTTP methods + | +18 | async def foo(): +19 | requests.post() + | ^^^^^^^^^^^^^ ASYNC100 + | + +ASYNC100.py:23:5: ASYNC100 Async functions should not call blocking HTTP methods + | +22 | async def foo(): +23 | httpx.post() + | ^^^^^^^^^^ ASYNC100 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC101_ASYNC101.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC101_ASYNC101.py.snap new file mode 100644 index 0000000000..da9e3b2500 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC101_ASYNC101.py.snap @@ -0,0 +1,46 @@ +--- +source: crates/ruff_linter/src/rules/flake8_async/mod.rs +--- +ASYNC101.py:7:5: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods + | +6 | async def foo(): +7 | open("foo") + | ^^^^ ASYNC101 + | + +ASYNC101.py:11:5: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods + | +10 | async def foo(): +11 | time.sleep(1) + | ^^^^^^^^^^ ASYNC101 + | + +ASYNC101.py:15:5: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods + | +14 | async def foo(): +15 | subprocess.run("foo") + | ^^^^^^^^^^^^^^ ASYNC101 + | + +ASYNC101.py:19:5: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods + | +18 | async def foo(): +19 | subprocess.call("foo") + | ^^^^^^^^^^^^^^^ ASYNC101 + | + +ASYNC101.py:27:5: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods + | +26 | async def foo(): +27 | os.wait4(10) + | ^^^^^^^^ ASYNC101 + | + +ASYNC101.py:31:5: ASYNC101 Async functions should not call `open`, `time.sleep`, or `subprocess` methods + | +30 | async def foo(): +31 | os.wait(12) + | ^^^^^^^ ASYNC101 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC102_ASYNC102.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC102_ASYNC102.py.snap new file mode 100644 index 0000000000..d97b6da81c --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC102_ASYNC102.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/flake8_async/mod.rs +--- +ASYNC102.py:5:5: ASYNC102 Async functions should not call synchronous `os` methods + | +4 | async def foo(): +5 | os.popen() + | ^^^^^^^^ ASYNC102 + | + +ASYNC102.py:9:5: ASYNC102 Async functions should not call synchronous `os` methods + | +8 | async def foo(): +9 | os.spawnl() + | ^^^^^^^^^ ASYNC102 + | + + diff --git a/crates/ruff/src/rules/flake8_bandit/helpers.rs b/crates/ruff_linter/src/rules/flake8_bandit/helpers.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/helpers.rs rename to crates/ruff_linter/src/rules/flake8_bandit/helpers.rs diff --git a/crates/ruff/src/rules/flake8_bandit/mod.rs b/crates/ruff_linter/src/rules/flake8_bandit/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/mod.rs rename to crates/ruff_linter/src/rules/flake8_bandit/mod.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/assert_used.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/assert_used.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/assert_used.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/assert_used.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/bad_file_permissions.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/bad_file_permissions.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/bad_file_permissions.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/bad_file_permissions.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/exec_used.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/exec_used.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/exec_used.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/exec_used.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/flask_debug_true.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/flask_debug_true.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/flask_debug_true.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/flask_debug_true.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_bind_all_interfaces.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_bind_all_interfaces.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/hardcoded_bind_all_interfaces.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_bind_all_interfaces.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_password_default.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_password_default.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/hardcoded_password_default.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_password_default.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_password_func_arg.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_password_func_arg.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/hardcoded_password_func_arg.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_password_func_arg.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_password_string.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_password_string.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/hardcoded_password_string.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_password_string.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_sql_expression.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_sql_expression.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/hardcoded_sql_expression.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_sql_expression.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_tmp_directory.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_tmp_directory.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/hardcoded_tmp_directory.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_tmp_directory.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/hashlib_insecure_hash_functions.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/hashlib_insecure_hash_functions.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/hashlib_insecure_hash_functions.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/hashlib_insecure_hash_functions.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/jinja2_autoescape_false.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/jinja2_autoescape_false.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/jinja2_autoescape_false.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/jinja2_autoescape_false.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/logging_config_insecure_listen.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/logging_config_insecure_listen.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/logging_config_insecure_listen.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/logging_config_insecure_listen.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/paramiko_calls.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/paramiko_calls.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/paramiko_calls.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/paramiko_calls.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/request_with_no_cert_validation.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/request_with_no_cert_validation.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/request_with_no_cert_validation.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/request_with_no_cert_validation.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/request_without_timeout.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/request_without_timeout.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/request_without_timeout.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/request_without_timeout.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/shell_injection.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/shell_injection.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/shell_injection.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/shell_injection.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/snmp_insecure_version.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/snmp_insecure_version.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/snmp_insecure_version.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/snmp_insecure_version.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/snmp_weak_cryptography.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/snmp_weak_cryptography.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/snmp_weak_cryptography.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/snmp_weak_cryptography.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/ssh_no_host_key_verification.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/ssh_no_host_key_verification.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/ssh_no_host_key_verification.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/ssh_no_host_key_verification.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/suspicious_function_call.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/suspicious_function_call.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/suspicious_function_call.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/suspicious_function_call.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/try_except_continue.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/try_except_continue.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/try_except_continue.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/try_except_continue.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/try_except_pass.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/try_except_pass.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/try_except_pass.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/try_except_pass.rs diff --git a/crates/ruff/src/rules/flake8_bandit/rules/unsafe_yaml_load.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/unsafe_yaml_load.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/rules/unsafe_yaml_load.rs rename to crates/ruff_linter/src/rules/flake8_bandit/rules/unsafe_yaml_load.rs diff --git a/crates/ruff/src/rules/flake8_bandit/settings.rs b/crates/ruff_linter/src/rules/flake8_bandit/settings.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bandit/settings.rs rename to crates/ruff_linter/src/rules/flake8_bandit/settings.rs diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S101_S101.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S101_S101.py.snap new file mode 100644 index 0000000000..d879988b27 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S101_S101.py.snap @@ -0,0 +1,27 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S101.py:1:1: S101 Use of `assert` detected + | +1 | assert True # S101 + | ^^^^^^ S101 + | + +S101.py:6:5: S101 Use of `assert` detected + | +4 | def fn(): +5 | x = 1 +6 | assert x == 1 # S101 + | ^^^^^^ S101 +7 | assert x == 2 # S101 + | + +S101.py:7:5: S101 Use of `assert` detected + | +5 | x = 1 +6 | assert x == 1 # S101 +7 | assert x == 2 # S101 + | ^^^^^^ S101 + | + + 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 new file mode 100644 index 0000000000..ee1dd35169 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S102_S102.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S102.py:3:5: S102 Use of `exec` detected + | +1 | def fn(): +2 | # Error +3 | exec('x = 2') + | ^^^^ S102 +4 | +5 | exec('y = 3') + | + +S102.py:5:1: S102 Use of `exec` detected + | +3 | exec('x = 2') +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 new file mode 100644 index 0000000000..60379d8f1c --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S103_S103.py.snap @@ -0,0 +1,131 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S103.py:6:25: S103 `os.chmod` setting a permissive mask `0o227` on file or directory + | +4 | keyfile = "foo" +5 | +6 | os.chmod("/etc/passwd", 0o227) # Error + | ^^^^^ S103 +7 | os.chmod("/etc/passwd", 0o7) # Error +8 | os.chmod("/etc/passwd", 0o664) # OK + | + +S103.py:7:25: S103 `os.chmod` setting a permissive mask `0o7` on file or directory + | +6 | os.chmod("/etc/passwd", 0o227) # Error +7 | os.chmod("/etc/passwd", 0o7) # Error + | ^^^ S103 +8 | os.chmod("/etc/passwd", 0o664) # OK +9 | os.chmod("/etc/passwd", 0o777) # Error + | + +S103.py:9:25: S103 `os.chmod` setting a permissive mask `0o777` on file or directory + | + 7 | os.chmod("/etc/passwd", 0o7) # Error + 8 | os.chmod("/etc/passwd", 0o664) # OK + 9 | os.chmod("/etc/passwd", 0o777) # Error + | ^^^^^ S103 +10 | os.chmod("/etc/passwd", 0o770) # Error +11 | os.chmod("/etc/passwd", 0o776) # Error + | + +S103.py:10:25: S103 `os.chmod` setting a permissive mask `0o770` on file or directory + | + 8 | os.chmod("/etc/passwd", 0o664) # OK + 9 | os.chmod("/etc/passwd", 0o777) # Error +10 | os.chmod("/etc/passwd", 0o770) # Error + | ^^^^^ S103 +11 | os.chmod("/etc/passwd", 0o776) # Error +12 | os.chmod("/etc/passwd", 0o760) # OK + | + +S103.py:11:25: S103 `os.chmod` setting a permissive mask `0o776` on file or directory + | + 9 | os.chmod("/etc/passwd", 0o777) # Error +10 | os.chmod("/etc/passwd", 0o770) # Error +11 | os.chmod("/etc/passwd", 0o776) # Error + | ^^^^^ S103 +12 | os.chmod("/etc/passwd", 0o760) # OK +13 | os.chmod("~/.bashrc", 511) # Error + | + +S103.py:13:23: S103 `os.chmod` setting a permissive mask `0o777` on file or directory + | +11 | os.chmod("/etc/passwd", 0o776) # Error +12 | os.chmod("/etc/passwd", 0o760) # OK +13 | os.chmod("~/.bashrc", 511) # Error + | ^^^ S103 +14 | os.chmod("/etc/hosts", 0o777) # Error +15 | os.chmod("/tmp/oh_hai", 0x1FF) # Error + | + +S103.py:14:24: S103 `os.chmod` setting a permissive mask `0o777` on file or directory + | +12 | os.chmod("/etc/passwd", 0o760) # OK +13 | os.chmod("~/.bashrc", 511) # Error +14 | os.chmod("/etc/hosts", 0o777) # Error + | ^^^^^ S103 +15 | os.chmod("/tmp/oh_hai", 0x1FF) # Error +16 | os.chmod("/etc/passwd", stat.S_IRWXU) # OK + | + +S103.py:15:25: S103 `os.chmod` setting a permissive mask `0o777` on file or directory + | +13 | os.chmod("~/.bashrc", 511) # Error +14 | os.chmod("/etc/hosts", 0o777) # Error +15 | os.chmod("/tmp/oh_hai", 0x1FF) # Error + | ^^^^^ S103 +16 | os.chmod("/etc/passwd", stat.S_IRWXU) # OK +17 | os.chmod(keyfile, 0o777) # Error + | + +S103.py:17:19: S103 `os.chmod` setting a permissive mask `0o777` on file or directory + | +15 | os.chmod("/tmp/oh_hai", 0x1FF) # Error +16 | os.chmod("/etc/passwd", stat.S_IRWXU) # OK +17 | os.chmod(keyfile, 0o777) # Error + | ^^^^^ S103 +18 | os.chmod(keyfile, 0o7 | 0o70 | 0o700) # Error +19 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU) # Error + | + +S103.py:18:19: S103 `os.chmod` setting a permissive mask `0o777` on file or directory + | +16 | os.chmod("/etc/passwd", stat.S_IRWXU) # OK +17 | os.chmod(keyfile, 0o777) # Error +18 | os.chmod(keyfile, 0o7 | 0o70 | 0o700) # Error + | ^^^^^^^^^^^^^^^^^^ S103 +19 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU) # Error +20 | os.chmod("~/hidden_exec", stat.S_IXGRP) # Error + | + +S103.py:19:19: S103 `os.chmod` setting a permissive mask `0o777` on file or directory + | +17 | os.chmod(keyfile, 0o777) # Error +18 | os.chmod(keyfile, 0o7 | 0o70 | 0o700) # Error +19 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU) # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S103 +20 | os.chmod("~/hidden_exec", stat.S_IXGRP) # Error +21 | os.chmod("~/hidden_exec", stat.S_IXOTH) # OK + | + +S103.py:20:27: S103 `os.chmod` setting a permissive mask `0o10` on file or directory + | +18 | os.chmod(keyfile, 0o7 | 0o70 | 0o700) # Error +19 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU) # Error +20 | os.chmod("~/hidden_exec", stat.S_IXGRP) # Error + | ^^^^^^^^^^^^ S103 +21 | os.chmod("~/hidden_exec", stat.S_IXOTH) # OK +22 | os.chmod("/etc/passwd", stat.S_IWOTH) # Error + | + +S103.py:22:25: S103 `os.chmod` setting a permissive mask `0o2` on file or directory + | +20 | os.chmod("~/hidden_exec", stat.S_IXGRP) # Error +21 | os.chmod("~/hidden_exec", stat.S_IXOTH) # OK +22 | os.chmod("/etc/passwd", stat.S_IWOTH) # Error + | ^^^^^^^^^^^^ S103 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S104_S104.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S104_S104.py.snap new file mode 100644 index 0000000000..1927319794 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S104_S104.py.snap @@ -0,0 +1,35 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S104.py:9:1: S104 Possible binding to all interfaces + | + 8 | # Error + 9 | "0.0.0.0" + | ^^^^^^^^^ S104 +10 | '0.0.0.0' + | + +S104.py:10:1: S104 Possible binding to all interfaces + | + 8 | # Error + 9 | "0.0.0.0" +10 | '0.0.0.0' + | ^^^^^^^^^ S104 + | + +S104.py:14:6: S104 Possible binding to all interfaces + | +13 | # Error +14 | func("0.0.0.0") + | ^^^^^^^^^ S104 + | + +S104.py:18:9: S104 Possible binding to all interfaces + | +17 | def my_func(): +18 | x = "0.0.0.0" + | ^^^^^^^^^ S104 +19 | print(x) + | + + 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 new file mode 100644 index 0000000000..0da2294763 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S105_S105.py.snap @@ -0,0 +1,377 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S105.py:13:12: S105 Possible hardcoded password assigned to: "password" + | +12 | # Errors +13 | password = "s3cr3t" + | ^^^^^^^^ S105 +14 | _pass = "s3cr3t" +15 | passwd = "s3cr3t" + | + +S105.py:14:9: S105 Possible hardcoded password assigned to: "_pass" + | +12 | # Errors +13 | password = "s3cr3t" +14 | _pass = "s3cr3t" + | ^^^^^^^^ S105 +15 | passwd = "s3cr3t" +16 | pwd = "s3cr3t" + | + +S105.py:15:10: S105 Possible hardcoded password assigned to: "passwd" + | +13 | password = "s3cr3t" +14 | _pass = "s3cr3t" +15 | passwd = "s3cr3t" + | ^^^^^^^^ S105 +16 | pwd = "s3cr3t" +17 | secret = "s3cr3t" + | + +S105.py:16:7: S105 Possible hardcoded password assigned to: "pwd" + | +14 | _pass = "s3cr3t" +15 | passwd = "s3cr3t" +16 | pwd = "s3cr3t" + | ^^^^^^^^ S105 +17 | secret = "s3cr3t" +18 | token = "s3cr3t" + | + +S105.py:17:10: S105 Possible hardcoded password assigned to: "secret" + | +15 | passwd = "s3cr3t" +16 | pwd = "s3cr3t" +17 | secret = "s3cr3t" + | ^^^^^^^^ S105 +18 | token = "s3cr3t" +19 | secrete = "s3cr3t" + | + +S105.py:18:9: S105 Possible hardcoded password assigned to: "token" + | +16 | pwd = "s3cr3t" +17 | secret = "s3cr3t" +18 | token = "s3cr3t" + | ^^^^^^^^ S105 +19 | secrete = "s3cr3t" +20 | safe = password = "s3cr3t" + | + +S105.py:19:11: S105 Possible hardcoded password assigned to: "secrete" + | +17 | secret = "s3cr3t" +18 | token = "s3cr3t" +19 | secrete = "s3cr3t" + | ^^^^^^^^ S105 +20 | safe = password = "s3cr3t" +21 | password = safe = "s3cr3t" + | + +S105.py:20:19: S105 Possible hardcoded password assigned to: "password" + | +18 | token = "s3cr3t" +19 | secrete = "s3cr3t" +20 | safe = password = "s3cr3t" + | ^^^^^^^^ S105 +21 | password = safe = "s3cr3t" +22 | PASSWORD = "s3cr3t" + | + +S105.py:21:19: S105 Possible hardcoded password assigned to: "password" + | +19 | secrete = "s3cr3t" +20 | safe = password = "s3cr3t" +21 | password = safe = "s3cr3t" + | ^^^^^^^^ S105 +22 | PASSWORD = "s3cr3t" +23 | PassWord = "s3cr3t" + | + +S105.py:22:12: S105 Possible hardcoded password assigned to: "PASSWORD" + | +20 | safe = password = "s3cr3t" +21 | password = safe = "s3cr3t" +22 | PASSWORD = "s3cr3t" + | ^^^^^^^^ S105 +23 | PassWord = "s3cr3t" + | + +S105.py:23:12: S105 Possible hardcoded password assigned to: "PassWord" + | +21 | password = safe = "s3cr3t" +22 | PASSWORD = "s3cr3t" +23 | PassWord = "s3cr3t" + | ^^^^^^^^ S105 +24 | +25 | d["password"] = "s3cr3t" + | + +S105.py:25:17: S105 Possible hardcoded password assigned to: "password" + | +23 | PassWord = "s3cr3t" +24 | +25 | d["password"] = "s3cr3t" + | ^^^^^^^^ S105 +26 | d["pass"] = "s3cr3t" +27 | d["passwd"] = "s3cr3t" + | + +S105.py:26:13: S105 Possible hardcoded password assigned to: "pass" + | +25 | d["password"] = "s3cr3t" +26 | d["pass"] = "s3cr3t" + | ^^^^^^^^ S105 +27 | d["passwd"] = "s3cr3t" +28 | d["pwd"] = "s3cr3t" + | + +S105.py:27:15: S105 Possible hardcoded password assigned to: "passwd" + | +25 | d["password"] = "s3cr3t" +26 | d["pass"] = "s3cr3t" +27 | d["passwd"] = "s3cr3t" + | ^^^^^^^^ S105 +28 | d["pwd"] = "s3cr3t" +29 | d["secret"] = "s3cr3t" + | + +S105.py:28:12: S105 Possible hardcoded password assigned to: "pwd" + | +26 | d["pass"] = "s3cr3t" +27 | d["passwd"] = "s3cr3t" +28 | d["pwd"] = "s3cr3t" + | ^^^^^^^^ S105 +29 | d["secret"] = "s3cr3t" +30 | d["token"] = "s3cr3t" + | + +S105.py:29:15: S105 Possible hardcoded password assigned to: "secret" + | +27 | d["passwd"] = "s3cr3t" +28 | d["pwd"] = "s3cr3t" +29 | d["secret"] = "s3cr3t" + | ^^^^^^^^ S105 +30 | d["token"] = "s3cr3t" +31 | d["secrete"] = "s3cr3t" + | + +S105.py:30:14: S105 Possible hardcoded password assigned to: "token" + | +28 | d["pwd"] = "s3cr3t" +29 | d["secret"] = "s3cr3t" +30 | d["token"] = "s3cr3t" + | ^^^^^^^^ S105 +31 | d["secrete"] = "s3cr3t" +32 | safe = d["password"] = "s3cr3t" + | + +S105.py:31:16: S105 Possible hardcoded password assigned to: "secrete" + | +29 | d["secret"] = "s3cr3t" +30 | d["token"] = "s3cr3t" +31 | d["secrete"] = "s3cr3t" + | ^^^^^^^^ S105 +32 | safe = d["password"] = "s3cr3t" +33 | d["password"] = safe = "s3cr3t" + | + +S105.py:32:24: S105 Possible hardcoded password assigned to: "password" + | +30 | d["token"] = "s3cr3t" +31 | d["secrete"] = "s3cr3t" +32 | safe = d["password"] = "s3cr3t" + | ^^^^^^^^ S105 +33 | d["password"] = safe = "s3cr3t" + | + +S105.py:33:24: S105 Possible hardcoded password assigned to: "password" + | +31 | d["secrete"] = "s3cr3t" +32 | safe = d["password"] = "s3cr3t" +33 | d["password"] = safe = "s3cr3t" + | ^^^^^^^^ S105 + | + +S105.py:37:16: S105 Possible hardcoded password assigned to: "password" + | +36 | class MyClass: +37 | password = "s3cr3t" + | ^^^^^^^^ S105 +38 | safe = password + | + +S105.py:41:20: S105 Possible hardcoded password assigned to: "password" + | +41 | MyClass.password = "s3cr3t" + | ^^^^^^^^ S105 +42 | MyClass._pass = "s3cr3t" +43 | MyClass.passwd = "s3cr3t" + | + +S105.py:42:17: S105 Possible hardcoded password assigned to: "_pass" + | +41 | MyClass.password = "s3cr3t" +42 | MyClass._pass = "s3cr3t" + | ^^^^^^^^ S105 +43 | MyClass.passwd = "s3cr3t" +44 | MyClass.pwd = "s3cr3t" + | + +S105.py:43:18: S105 Possible hardcoded password assigned to: "passwd" + | +41 | MyClass.password = "s3cr3t" +42 | MyClass._pass = "s3cr3t" +43 | MyClass.passwd = "s3cr3t" + | ^^^^^^^^ S105 +44 | MyClass.pwd = "s3cr3t" +45 | MyClass.secret = "s3cr3t" + | + +S105.py:44:15: S105 Possible hardcoded password assigned to: "pwd" + | +42 | MyClass._pass = "s3cr3t" +43 | MyClass.passwd = "s3cr3t" +44 | MyClass.pwd = "s3cr3t" + | ^^^^^^^^ S105 +45 | MyClass.secret = "s3cr3t" +46 | MyClass.token = "s3cr3t" + | + +S105.py:45:18: S105 Possible hardcoded password assigned to: "secret" + | +43 | MyClass.passwd = "s3cr3t" +44 | MyClass.pwd = "s3cr3t" +45 | MyClass.secret = "s3cr3t" + | ^^^^^^^^ S105 +46 | MyClass.token = "s3cr3t" +47 | MyClass.secrete = "s3cr3t" + | + +S105.py:46:17: S105 Possible hardcoded password assigned to: "token" + | +44 | MyClass.pwd = "s3cr3t" +45 | MyClass.secret = "s3cr3t" +46 | MyClass.token = "s3cr3t" + | ^^^^^^^^ S105 +47 | MyClass.secrete = "s3cr3t" + | + +S105.py:47:19: S105 Possible hardcoded password assigned to: "secrete" + | +45 | MyClass.secret = "s3cr3t" +46 | MyClass.token = "s3cr3t" +47 | MyClass.secrete = "s3cr3t" + | ^^^^^^^^ S105 +48 | +49 | password == "s3cr3t" + | + +S105.py:49:13: S105 Possible hardcoded password assigned to: "password" + | +47 | MyClass.secrete = "s3cr3t" +48 | +49 | password == "s3cr3t" + | ^^^^^^^^ S105 +50 | _pass == "s3cr3t" +51 | passwd == "s3cr3t" + | + +S105.py:50:10: S105 Possible hardcoded password assigned to: "_pass" + | +49 | password == "s3cr3t" +50 | _pass == "s3cr3t" + | ^^^^^^^^ S105 +51 | passwd == "s3cr3t" +52 | pwd == "s3cr3t" + | + +S105.py:51:11: S105 Possible hardcoded password assigned to: "passwd" + | +49 | password == "s3cr3t" +50 | _pass == "s3cr3t" +51 | passwd == "s3cr3t" + | ^^^^^^^^ S105 +52 | pwd == "s3cr3t" +53 | secret == "s3cr3t" + | + +S105.py:52:8: S105 Possible hardcoded password assigned to: "pwd" + | +50 | _pass == "s3cr3t" +51 | passwd == "s3cr3t" +52 | pwd == "s3cr3t" + | ^^^^^^^^ S105 +53 | secret == "s3cr3t" +54 | token == "s3cr3t" + | + +S105.py:53:11: S105 Possible hardcoded password assigned to: "secret" + | +51 | passwd == "s3cr3t" +52 | pwd == "s3cr3t" +53 | secret == "s3cr3t" + | ^^^^^^^^ S105 +54 | token == "s3cr3t" +55 | secrete == "s3cr3t" + | + +S105.py:54:10: S105 Possible hardcoded password assigned to: "token" + | +52 | pwd == "s3cr3t" +53 | secret == "s3cr3t" +54 | token == "s3cr3t" + | ^^^^^^^^ S105 +55 | secrete == "s3cr3t" +56 | password == safe == "s3cr3t" + | + +S105.py:55:12: S105 Possible hardcoded password assigned to: "secrete" + | +53 | secret == "s3cr3t" +54 | token == "s3cr3t" +55 | secrete == "s3cr3t" + | ^^^^^^^^ S105 +56 | password == safe == "s3cr3t" + | + +S105.py:56:21: S105 Possible hardcoded password assigned to: "password" + | +54 | token == "s3cr3t" +55 | secrete == "s3cr3t" +56 | password == safe == "s3cr3t" + | ^^^^^^^^ S105 +57 | +58 | if token == "1\n2": + | + +S105.py:58:13: S105 Possible hardcoded password assigned to: "token" + | +56 | password == safe == "s3cr3t" +57 | +58 | if token == "1\n2": + | ^^^^^^ S105 +59 | pass + | + +S105.py:61:13: S105 Possible hardcoded password assigned to: "token" + | +59 | pass +60 | +61 | if token == "3\t4": + | ^^^^^^ S105 +62 | pass + | + +S105.py:64:13: S105 Possible hardcoded password assigned to: "token" + | +62 | pass +63 | +64 | if token == "5\r6": + | ^^^^^^ S105 +65 | pass + | + + diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S106_S106.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S106_S106.py.snap new file mode 100644 index 0000000000..6677f394e0 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S106_S106.py.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S106.py:14:9: S106 Possible hardcoded password assigned to argument: "password" + | +13 | # Error +14 | func(1, password="s3cr3t") + | ^^^^^^^^^^^^^^^^^ S106 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S107_S107.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S107_S107.py.snap new file mode 100644 index 0000000000..339d3126fb --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S107_S107.py.snap @@ -0,0 +1,39 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S107.py:5:29: S107 Possible hardcoded password assigned to function default: "password" + | +5 | def default(first, password="default"): + | ^^^^^^^^^ S107 +6 | pass + | + +S107.py:13:45: S107 Possible hardcoded password assigned to function default: "password" + | +13 | def default_posonly(first, /, pos, password="posonly"): + | ^^^^^^^^^ S107 +14 | pass + | + +S107.py:21:39: S107 Possible hardcoded password assigned to function default: "password" + | +21 | def default_kwonly(first, *, password="kwonly"): + | ^^^^^^^^ S107 +22 | pass + | + +S107.py:29:39: S107 Possible hardcoded password assigned to function default: "secret" + | +29 | def default_all(first, /, pos, secret="posonly", *, password="kwonly"): + | ^^^^^^^^^ S107 +30 | pass + | + +S107.py:29:62: S107 Possible hardcoded password assigned to function default: "password" + | +29 | def default_all(first, /, pos, secret="posonly", *, password="kwonly"): + | ^^^^^^^^ S107 +30 | 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 new file mode 100644 index 0000000000..9ecf1141d9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S108_S108.py.snap @@ -0,0 +1,31 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S108.py:5:11: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" + | +3 | f.write("def") +4 | +5 | with open("/tmp/abc", "w") as f: + | ^^^^^^^^^^ S108 +6 | f.write("def") + | + +S108.py:8:11: S108 Probable insecure usage of temporary file or directory: "/var/tmp/123" + | +6 | f.write("def") +7 | +8 | with open("/var/tmp/123", "w") as f: + | ^^^^^^^^^^^^^^ S108 +9 | f.write("def") + | + +S108.py:11:11: S108 Probable insecure usage of temporary file or directory: "/dev/shm/unit/test" + | + 9 | f.write("def") +10 | +11 | with open("/dev/shm/unit/test", "w") as f: + | ^^^^^^^^^^^^^^^^^^^^ S108 +12 | 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 new file mode 100644 index 0000000000..998bc90059 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S108_extend.snap @@ -0,0 +1,39 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S108.py:5:11: S108 Probable insecure usage of temporary file or directory: "/tmp/abc" + | +3 | f.write("def") +4 | +5 | with open("/tmp/abc", "w") as f: + | ^^^^^^^^^^ S108 +6 | f.write("def") + | + +S108.py:8:11: S108 Probable insecure usage of temporary file or directory: "/var/tmp/123" + | +6 | f.write("def") +7 | +8 | with open("/var/tmp/123", "w") as f: + | ^^^^^^^^^^^^^^ S108 +9 | f.write("def") + | + +S108.py:11:11: S108 Probable insecure usage of temporary file or directory: "/dev/shm/unit/test" + | + 9 | f.write("def") +10 | +11 | with open("/dev/shm/unit/test", "w") as f: + | ^^^^^^^^^^^^^^^^^^^^ S108 +12 | f.write("def") + | + +S108.py:15:11: S108 Probable insecure usage of temporary file or directory: "/foo/bar" + | +14 | # not ok by config +15 | with open("/foo/bar", "w") as f: + | ^^^^^^^^^^ S108 +16 | 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 new file mode 100644 index 0000000000..8197e8f16c --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S110_S110.py.snap @@ -0,0 +1,26 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S110.py:3:1: S110 `try`-`except`-`pass` detected, consider logging the exception + | +1 | try: +2 | pass +3 | / except Exception: +4 | | pass + | |________^ S110 +5 | +6 | try: + | + +S110.py:8:1: S110 `try`-`except`-`pass` detected, consider logging the exception + | + 6 | try: + 7 | pass + 8 | / except: + 9 | | pass + | |________^ S110 +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 new file mode 100644 index 0000000000..701d4112c2 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S110_typed.snap @@ -0,0 +1,35 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S110.py:3:1: S110 `try`-`except`-`pass` detected, consider logging the exception + | +1 | try: +2 | pass +3 | / except Exception: +4 | | pass + | |________^ S110 +5 | +6 | try: + | + +S110.py:8:1: S110 `try`-`except`-`pass` detected, consider logging the exception + | + 6 | try: + 7 | pass + 8 | / except: + 9 | | pass + | |________^ S110 +10 | +11 | try: + | + +S110.py:13:1: S110 `try`-`except`-`pass` detected, consider logging the exception + | +11 | try: +12 | pass +13 | / except ValueError: +14 | | pass + | |________^ S110 + | + + 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 new file mode 100644 index 0000000000..96976d8b0a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S112_S112.py.snap @@ -0,0 +1,48 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S112.py:3:1: S112 `try`-`except`-`continue` detected, consider logging the exception + | +1 | try: +2 | pass +3 | / except Exception: +4 | | continue + | |____________^ S112 +5 | +6 | try: + | + +S112.py:8:1: S112 `try`-`except`-`continue` detected, consider logging the exception + | + 6 | try: + 7 | pass + 8 | / except: + 9 | | continue + | |____________^ S112 +10 | +11 | try: + | + +S112.py:13:1: S112 `try`-`except`-`continue` detected, consider logging the exception + | +11 | try: +12 | pass +13 | / except (Exception,): +14 | | continue + | |____________^ S112 +15 | +16 | try: + | + +S112.py:18:1: S112 `try`-`except`-`continue` detected, consider logging the exception + | +16 | try: +17 | pass +18 | / except (Exception, ValueError): +19 | | continue + | |____________^ S112 +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 new file mode 100644 index 0000000000..472679eee9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S113_S113.py.snap @@ -0,0 +1,142 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S113.py:3:1: S113 Probable use of requests call without timeout + | +1 | import requests +2 | +3 | requests.get('https://gmail.com') + | ^^^^^^^^^^^^ S113 +4 | requests.get('https://gmail.com', timeout=None) +5 | requests.get('https://gmail.com', timeout=5) + | + +S113.py:4:35: S113 Probable use of requests call with timeout set to `None` + | +3 | requests.get('https://gmail.com') +4 | requests.get('https://gmail.com', timeout=None) + | ^^^^^^^^^^^^ S113 +5 | requests.get('https://gmail.com', timeout=5) +6 | requests.post('https://gmail.com') + | + +S113.py:6:1: S113 Probable use of requests call without timeout + | +4 | requests.get('https://gmail.com', timeout=None) +5 | requests.get('https://gmail.com', timeout=5) +6 | requests.post('https://gmail.com') + | ^^^^^^^^^^^^^ S113 +7 | requests.post('https://gmail.com', timeout=None) +8 | requests.post('https://gmail.com', timeout=5) + | + +S113.py:7:36: S113 Probable use of requests call with timeout set to `None` + | +5 | requests.get('https://gmail.com', timeout=5) +6 | requests.post('https://gmail.com') +7 | requests.post('https://gmail.com', timeout=None) + | ^^^^^^^^^^^^ S113 +8 | requests.post('https://gmail.com', timeout=5) +9 | requests.put('https://gmail.com') + | + +S113.py:9:1: S113 Probable use of requests call without timeout + | + 7 | requests.post('https://gmail.com', timeout=None) + 8 | requests.post('https://gmail.com', timeout=5) + 9 | requests.put('https://gmail.com') + | ^^^^^^^^^^^^ S113 +10 | requests.put('https://gmail.com', timeout=None) +11 | requests.put('https://gmail.com', timeout=5) + | + +S113.py:10:35: S113 Probable use of requests call with timeout set to `None` + | + 8 | requests.post('https://gmail.com', timeout=5) + 9 | requests.put('https://gmail.com') +10 | requests.put('https://gmail.com', timeout=None) + | ^^^^^^^^^^^^ S113 +11 | requests.put('https://gmail.com', timeout=5) +12 | requests.delete('https://gmail.com') + | + +S113.py:12:1: S113 Probable use of requests call without timeout + | +10 | requests.put('https://gmail.com', timeout=None) +11 | requests.put('https://gmail.com', timeout=5) +12 | requests.delete('https://gmail.com') + | ^^^^^^^^^^^^^^^ S113 +13 | requests.delete('https://gmail.com', timeout=None) +14 | requests.delete('https://gmail.com', timeout=5) + | + +S113.py:13:38: S113 Probable use of requests call with timeout set to `None` + | +11 | requests.put('https://gmail.com', timeout=5) +12 | requests.delete('https://gmail.com') +13 | requests.delete('https://gmail.com', timeout=None) + | ^^^^^^^^^^^^ S113 +14 | requests.delete('https://gmail.com', timeout=5) +15 | requests.patch('https://gmail.com') + | + +S113.py:15:1: S113 Probable use of requests call without timeout + | +13 | requests.delete('https://gmail.com', timeout=None) +14 | requests.delete('https://gmail.com', timeout=5) +15 | requests.patch('https://gmail.com') + | ^^^^^^^^^^^^^^ S113 +16 | requests.patch('https://gmail.com', timeout=None) +17 | requests.patch('https://gmail.com', timeout=5) + | + +S113.py:16:37: S113 Probable use of requests call with timeout set to `None` + | +14 | requests.delete('https://gmail.com', timeout=5) +15 | requests.patch('https://gmail.com') +16 | requests.patch('https://gmail.com', timeout=None) + | ^^^^^^^^^^^^ S113 +17 | requests.patch('https://gmail.com', timeout=5) +18 | requests.options('https://gmail.com') + | + +S113.py:18:1: S113 Probable use of requests call without timeout + | +16 | requests.patch('https://gmail.com', timeout=None) +17 | requests.patch('https://gmail.com', timeout=5) +18 | requests.options('https://gmail.com') + | ^^^^^^^^^^^^^^^^ S113 +19 | requests.options('https://gmail.com', timeout=None) +20 | requests.options('https://gmail.com', timeout=5) + | + +S113.py:19:39: S113 Probable use of requests call with timeout set to `None` + | +17 | requests.patch('https://gmail.com', timeout=5) +18 | requests.options('https://gmail.com') +19 | requests.options('https://gmail.com', timeout=None) + | ^^^^^^^^^^^^ S113 +20 | requests.options('https://gmail.com', timeout=5) +21 | requests.head('https://gmail.com') + | + +S113.py:21:1: S113 Probable use of requests call without timeout + | +19 | requests.options('https://gmail.com', timeout=None) +20 | requests.options('https://gmail.com', timeout=5) +21 | requests.head('https://gmail.com') + | ^^^^^^^^^^^^^ S113 +22 | requests.head('https://gmail.com', timeout=None) +23 | requests.head('https://gmail.com', timeout=5) + | + +S113.py:22:36: S113 Probable use of requests call with timeout set to `None` + | +20 | requests.options('https://gmail.com', timeout=5) +21 | requests.head('https://gmail.com') +22 | requests.head('https://gmail.com', timeout=None) + | ^^^^^^^^^^^^ S113 +23 | requests.head('https://gmail.com', timeout=5) + | + + 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 new file mode 100644 index 0000000000..117d522f94 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S201_S201.py.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S201.py:10:9: S201 Use of `debug=True` in Flask app detected + | + 9 | # OK +10 | app.run(debug=True) + | ^^^^^^^^^^ S201 +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 new file mode 100644 index 0000000000..6377796b72 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S301_S301.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +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 | +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 new file mode 100644 index 0000000000..596c3c2a30 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S307_S307.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S307.py:3:7: S307 Use of possibly insecure function; consider using `ast.literal_eval` + | +1 | import os +2 | +3 | print(eval("1+1")) # S307 + | ^^^^^^^^^^^ S307 +4 | print(eval("os.getcwd()")) # S307 + | + +S307.py:4:7: S307 Use of possibly insecure function; consider using `ast.literal_eval` + | +3 | print(eval("1+1")) # S307 +4 | print(eval("os.getcwd()")) # S307 + | ^^^^^^^^^^^^^^^^^^^ S307 + | + + 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 new file mode 100644 index 0000000000..61adb56edd --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S312_S312.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +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 | +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 new file mode 100644 index 0000000000..8cd080b375 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S324_S324.py.snap @@ -0,0 +1,133 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S324.py:7:13: S324 Probable use of insecure hash functions in `hashlib`: `md5` + | +5 | # Invalid +6 | +7 | hashlib.new('md5') + | ^^^^^ S324 +8 | +9 | hashlib.new('md4', b'test') + | + +S324.py:9:13: S324 Probable use of insecure hash functions in `hashlib`: `md4` + | + 7 | hashlib.new('md5') + 8 | + 9 | hashlib.new('md4', b'test') + | ^^^^^ S324 +10 | +11 | hashlib.new(name='md5', data=b'test') + | + +S324.py:11:18: S324 Probable use of insecure hash functions in `hashlib`: `md5` + | + 9 | hashlib.new('md4', b'test') +10 | +11 | hashlib.new(name='md5', data=b'test') + | ^^^^^ S324 +12 | +13 | hashlib.new('MD4', data=b'test') + | + +S324.py:13:13: S324 Probable use of insecure hash functions in `hashlib`: `MD4` + | +11 | hashlib.new(name='md5', data=b'test') +12 | +13 | hashlib.new('MD4', data=b'test') + | ^^^^^ S324 +14 | +15 | hashlib.new('sha1') + | + +S324.py:15:13: S324 Probable use of insecure hash functions in `hashlib`: `sha1` + | +13 | hashlib.new('MD4', data=b'test') +14 | +15 | hashlib.new('sha1') + | ^^^^^^ S324 +16 | +17 | hashlib.new('sha1', data=b'test') + | + +S324.py:17:13: S324 Probable use of insecure hash functions in `hashlib`: `sha1` + | +15 | hashlib.new('sha1') +16 | +17 | hashlib.new('sha1', data=b'test') + | ^^^^^^ S324 +18 | +19 | hashlib.new('sha', data=b'test') + | + +S324.py:19:13: S324 Probable use of insecure hash functions in `hashlib`: `sha` + | +17 | hashlib.new('sha1', data=b'test') +18 | +19 | hashlib.new('sha', data=b'test') + | ^^^^^ S324 +20 | +21 | hashlib.new(name='SHA', data=b'test') + | + +S324.py:21:18: S324 Probable use of insecure hash functions in `hashlib`: `SHA` + | +19 | hashlib.new('sha', data=b'test') +20 | +21 | hashlib.new(name='SHA', data=b'test') + | ^^^^^ S324 +22 | +23 | hashlib.sha(data=b'test') + | + +S324.py:23:1: S324 Probable use of insecure hash functions in `hashlib`: `sha` + | +21 | hashlib.new(name='SHA', data=b'test') +22 | +23 | hashlib.sha(data=b'test') + | ^^^^^^^^^^^ S324 +24 | +25 | hashlib.md5() + | + +S324.py:25:1: S324 Probable use of insecure hash functions in `hashlib`: `md5` + | +23 | hashlib.sha(data=b'test') +24 | +25 | hashlib.md5() + | ^^^^^^^^^^^ S324 +26 | +27 | hashlib_new('sha1') + | + +S324.py:27:13: S324 Probable use of insecure hash functions in `hashlib`: `sha1` + | +25 | hashlib.md5() +26 | +27 | hashlib_new('sha1') + | ^^^^^^ S324 +28 | +29 | hashlib_sha1('sha1') + | + +S324.py:29:1: S324 Probable use of insecure hash functions in `hashlib`: `sha1` + | +27 | hashlib_new('sha1') +28 | +29 | hashlib_sha1('sha1') + | ^^^^^^^^^^^^ S324 +30 | +31 | # usedforsecurity arg only available in Python 3.9+ + | + +S324.py:32:13: S324 Probable use of insecure hash functions in `hashlib`: `sha1` + | +31 | # usedforsecurity arg only available in Python 3.9+ +32 | hashlib.new('sha1', usedforsecurity=True) + | ^^^^^^ S324 +33 | +34 | # Valid + | + + 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 new file mode 100644 index 0000000000..3320a4a810 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S501_S501.py.snap @@ -0,0 +1,180 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S501.py:5:47: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks + | +4 | requests.get('https://gmail.com', timeout=30, verify=True) +5 | requests.get('https://gmail.com', timeout=30, verify=False) + | ^^^^^^^^^^^^ S501 +6 | requests.post('https://gmail.com', timeout=30, verify=True) +7 | requests.post('https://gmail.com', timeout=30, verify=False) + | + +S501.py:7:48: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks + | +5 | requests.get('https://gmail.com', timeout=30, verify=False) +6 | requests.post('https://gmail.com', timeout=30, verify=True) +7 | requests.post('https://gmail.com', timeout=30, verify=False) + | ^^^^^^^^^^^^ S501 +8 | requests.put('https://gmail.com', timeout=30, verify=True) +9 | requests.put('https://gmail.com', timeout=30, verify=False) + | + +S501.py:9:47: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks + | + 7 | requests.post('https://gmail.com', timeout=30, verify=False) + 8 | requests.put('https://gmail.com', timeout=30, verify=True) + 9 | requests.put('https://gmail.com', timeout=30, verify=False) + | ^^^^^^^^^^^^ S501 +10 | requests.delete('https://gmail.com', timeout=30, verify=True) +11 | requests.delete('https://gmail.com', timeout=30, verify=False) + | + +S501.py:11:50: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks + | + 9 | requests.put('https://gmail.com', timeout=30, verify=False) +10 | requests.delete('https://gmail.com', timeout=30, verify=True) +11 | requests.delete('https://gmail.com', timeout=30, verify=False) + | ^^^^^^^^^^^^ S501 +12 | requests.patch('https://gmail.com', timeout=30, verify=True) +13 | requests.patch('https://gmail.com', timeout=30, verify=False) + | + +S501.py:13:49: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks + | +11 | requests.delete('https://gmail.com', timeout=30, verify=False) +12 | requests.patch('https://gmail.com', timeout=30, verify=True) +13 | requests.patch('https://gmail.com', timeout=30, verify=False) + | ^^^^^^^^^^^^ S501 +14 | requests.options('https://gmail.com', timeout=30, verify=True) +15 | requests.options('https://gmail.com', timeout=30, verify=False) + | + +S501.py:15:51: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks + | +13 | requests.patch('https://gmail.com', timeout=30, verify=False) +14 | requests.options('https://gmail.com', timeout=30, verify=True) +15 | requests.options('https://gmail.com', timeout=30, verify=False) + | ^^^^^^^^^^^^ S501 +16 | requests.head('https://gmail.com', timeout=30, verify=True) +17 | requests.head('https://gmail.com', timeout=30, verify=False) + | + +S501.py:17:48: S501 Probable use of `requests` call with `verify=False` disabling SSL certificate checks + | +15 | requests.options('https://gmail.com', timeout=30, verify=False) +16 | requests.head('https://gmail.com', timeout=30, verify=True) +17 | requests.head('https://gmail.com', timeout=30, verify=False) + | ^^^^^^^^^^^^ S501 +18 | +19 | httpx.request('GET', 'https://gmail.com', verify=True) + | + +S501.py:20:43: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + | +19 | httpx.request('GET', 'https://gmail.com', verify=True) +20 | httpx.request('GET', 'https://gmail.com', verify=False) + | ^^^^^^^^^^^^ S501 +21 | httpx.get('https://gmail.com', verify=True) +22 | httpx.get('https://gmail.com', verify=False) + | + +S501.py:22:32: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + | +20 | httpx.request('GET', 'https://gmail.com', verify=False) +21 | httpx.get('https://gmail.com', verify=True) +22 | httpx.get('https://gmail.com', verify=False) + | ^^^^^^^^^^^^ S501 +23 | httpx.options('https://gmail.com', verify=True) +24 | httpx.options('https://gmail.com', verify=False) + | + +S501.py:24:36: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + | +22 | httpx.get('https://gmail.com', verify=False) +23 | httpx.options('https://gmail.com', verify=True) +24 | httpx.options('https://gmail.com', verify=False) + | ^^^^^^^^^^^^ S501 +25 | httpx.head('https://gmail.com', verify=True) +26 | httpx.head('https://gmail.com', verify=False) + | + +S501.py:26:33: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + | +24 | httpx.options('https://gmail.com', verify=False) +25 | httpx.head('https://gmail.com', verify=True) +26 | httpx.head('https://gmail.com', verify=False) + | ^^^^^^^^^^^^ S501 +27 | httpx.post('https://gmail.com', verify=True) +28 | httpx.post('https://gmail.com', verify=False) + | + +S501.py:28:33: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + | +26 | httpx.head('https://gmail.com', verify=False) +27 | httpx.post('https://gmail.com', verify=True) +28 | httpx.post('https://gmail.com', verify=False) + | ^^^^^^^^^^^^ S501 +29 | httpx.put('https://gmail.com', verify=True) +30 | httpx.put('https://gmail.com', verify=False) + | + +S501.py:30:32: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + | +28 | httpx.post('https://gmail.com', verify=False) +29 | httpx.put('https://gmail.com', verify=True) +30 | httpx.put('https://gmail.com', verify=False) + | ^^^^^^^^^^^^ S501 +31 | httpx.patch('https://gmail.com', verify=True) +32 | httpx.patch('https://gmail.com', verify=False) + | + +S501.py:32:34: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + | +30 | httpx.put('https://gmail.com', verify=False) +31 | httpx.patch('https://gmail.com', verify=True) +32 | httpx.patch('https://gmail.com', verify=False) + | ^^^^^^^^^^^^ S501 +33 | httpx.delete('https://gmail.com', verify=True) +34 | httpx.delete('https://gmail.com', verify=False) + | + +S501.py:34:35: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + | +32 | httpx.patch('https://gmail.com', verify=False) +33 | httpx.delete('https://gmail.com', verify=True) +34 | httpx.delete('https://gmail.com', verify=False) + | ^^^^^^^^^^^^ S501 +35 | httpx.stream('https://gmail.com', verify=True) +36 | httpx.stream('https://gmail.com', verify=False) + | + +S501.py:36:35: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + | +34 | httpx.delete('https://gmail.com', verify=False) +35 | httpx.stream('https://gmail.com', verify=True) +36 | httpx.stream('https://gmail.com', verify=False) + | ^^^^^^^^^^^^ S501 +37 | httpx.Client() +38 | httpx.Client(verify=False) + | + +S501.py:38:14: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + | +36 | httpx.stream('https://gmail.com', verify=False) +37 | httpx.Client() +38 | httpx.Client(verify=False) + | ^^^^^^^^^^^^ S501 +39 | httpx.AsyncClient() +40 | httpx.AsyncClient(verify=False) + | + +S501.py:40:19: S501 Probable use of `httpx` call with `verify=False` disabling SSL certificate checks + | +38 | httpx.Client(verify=False) +39 | httpx.AsyncClient() +40 | httpx.AsyncClient(verify=False) + | ^^^^^^^^^^^^ S501 + | + + 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 new file mode 100644 index 0000000000..466f3e9f21 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S506_S506.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S506.py:10:9: S506 Probable use of unsafe `yaml.load`. Allows instantiation of arbitrary objects. Consider `yaml.safe_load`. + | + 8 | def test_yaml_load(): + 9 | ystr = yaml.dump({"a": 1, "b": 2, "c": 3}) +10 | y = yaml.load(ystr) + | ^^^^^^^^^ S506 +11 | yaml.dump(y) +12 | try: + | + +S506.py:24:24: S506 Probable use of unsafe loader `Loader` with `yaml.load`. Allows instantiation of arbitrary objects. Consider `yaml.safe_load`. + | +24 | yaml.load("{}", Loader=yaml.Loader) + | ^^^^^^^^^^^ S506 +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 new file mode 100644 index 0000000000..bd590f67ea --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S507_S507.py.snap @@ -0,0 +1,62 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S507.py:13:40: S507 Paramiko call with policy set to automatically trust the unknown host key + | +12 | # Errors +13 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy) + | ^^^^^^^^^^^^^^^^^^^^ S507 +14 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) +15 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) + | + +S507.py:14:40: S507 Paramiko call with policy set to automatically trust the unknown host key + | +12 | # Errors +13 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy) +14 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) + | ^^^^^^^^^^^^^^^^^^^^ S507 +15 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) +16 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) + | + +S507.py:15:40: S507 Paramiko call with policy set to automatically trust the unknown host key + | +13 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy) +14 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) +15 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) + | ^^^^^^^^^^^^^ S507 +16 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) +17 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) + | + +S507.py:16:47: S507 Paramiko call with policy set to automatically trust the unknown host key + | +14 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) +15 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) +16 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) + | ^^^^^^^^^^^^^^^^^^^^ S507 +17 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) +18 | ssh_client.set_missing_host_key_policy(policy=WarningPolicy) + | + +S507.py:17:47: S507 Paramiko call with policy set to automatically trust the unknown host key + | +15 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) +16 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) +17 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) + | ^^^^^^^^^^^^^^^^^^^^ S507 +18 | ssh_client.set_missing_host_key_policy(policy=WarningPolicy) + | + +S507.py:18:47: S507 Paramiko call with policy set to automatically trust the unknown host key + | +16 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) +17 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) +18 | ssh_client.set_missing_host_key_policy(policy=WarningPolicy) + | ^^^^^^^^^^^^^ S507 +19 | +20 | # 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 new file mode 100644 index 0000000000..7b72946d50 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S508_S508.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S508.py:3:25: S508 The use of SNMPv1 and SNMPv2 is insecure. Use SNMPv3 if able. + | +1 | from pysnmp.hlapi import CommunityData +2 | +3 | CommunityData("public", mpModel=0) # S508 + | ^^^^^^^^^ S508 +4 | CommunityData("public", mpModel=1) # S508 + | + +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 | +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 new file mode 100644 index 0000000000..f9ba5df59d --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S509_S509.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S509.py:4:12: S509 You should not use SNMPv3 without encryption. `noAuthNoPriv` & `authNoPriv` is insecure. + | +4 | insecure = UsmUserData("securityName") # S509 + | ^^^^^^^^^^^ S509 +5 | auth_no_priv = UsmUserData("securityName", "authName") # S509 + | + +S509.py:5:16: S509 You should not use SNMPv3 without encryption. `noAuthNoPriv` & `authNoPriv` is insecure. + | +4 | insecure = UsmUserData("securityName") # S509 +5 | auth_no_priv = UsmUserData("securityName", "authName") # S509 + | ^^^^^^^^^^^ S509 +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 new file mode 100644 index 0000000000..11c0d31bbb --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S601_S601.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S601.py:3:1: S601 Possible shell injection via Paramiko call; check inputs are properly sanitized + | +1 | import paramiko +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 new file mode 100644 index 0000000000..7e93ab2dd7 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S602_S602.py.snap @@ -0,0 +1,117 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S602.py:4:15: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` + | +3 | # Check different Popen wrappers are checked. +4 | Popen("true", shell=True) + | ^^^^^^^^^^ S602 +5 | call("true", shell=True) +6 | check_call("true", shell=True) + | + +S602.py:5:14: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` + | +3 | # Check different Popen wrappers are checked. +4 | Popen("true", shell=True) +5 | call("true", shell=True) + | ^^^^^^^^^^ S602 +6 | check_call("true", shell=True) +7 | check_output("true", shell=True) + | + +S602.py:6:20: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` + | +4 | Popen("true", shell=True) +5 | call("true", shell=True) +6 | check_call("true", shell=True) + | ^^^^^^^^^^ S602 +7 | check_output("true", shell=True) +8 | run("true", shell=True) + | + +S602.py:7:22: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` + | +5 | call("true", shell=True) +6 | check_call("true", shell=True) +7 | check_output("true", shell=True) + | ^^^^^^^^^^ S602 +8 | run("true", shell=True) + | + +S602.py:8:13: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` + | + 6 | check_call("true", shell=True) + 7 | check_output("true", shell=True) + 8 | run("true", shell=True) + | ^^^^^^^^^^ S602 + 9 | +10 | # Check values that truthy values are treated as true. + | + +S602.py:11:15: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` + | +10 | # Check values that truthy values are treated as true. +11 | Popen("true", shell=1) + | ^^^^^^^ S602 +12 | Popen("true", shell=[1]) +13 | Popen("true", shell={1: 1}) + | + +S602.py:12:15: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` + | +10 | # Check values that truthy values are treated as true. +11 | Popen("true", shell=1) +12 | Popen("true", shell=[1]) + | ^^^^^^^^^ S602 +13 | Popen("true", shell={1: 1}) +14 | Popen("true", shell=(1,)) + | + +S602.py:13:15: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` + | +11 | Popen("true", shell=1) +12 | Popen("true", shell=[1]) +13 | Popen("true", shell={1: 1}) + | ^^^^^^^^^^^^ S602 +14 | Popen("true", shell=(1,)) + | + +S602.py:14:15: S602 `subprocess` call with `shell=True` seems safe, but may be changed in the future; consider rewriting without `shell` + | +12 | Popen("true", shell=[1]) +13 | Popen("true", shell={1: 1}) +14 | Popen("true", shell=(1,)) + | ^^^^^^^^^^ S602 +15 | +16 | # Check command argument looks unsafe. + | + +S602.py:18:19: S602 `subprocess` call with `shell=True` identified, security issue + | +16 | # Check command argument looks unsafe. +17 | var_string = "true" +18 | Popen(var_string, shell=True) + | ^^^^^^^^^^ S602 +19 | Popen([var_string], shell=True) +20 | Popen([var_string, ""], shell=True) + | + +S602.py:19:21: S602 `subprocess` call with `shell=True` identified, security issue + | +17 | var_string = "true" +18 | Popen(var_string, shell=True) +19 | Popen([var_string], shell=True) + | ^^^^^^^^^^ S602 +20 | Popen([var_string, ""], shell=True) + | + +S602.py:20:25: S602 `subprocess` call with `shell=True` identified, security issue + | +18 | Popen(var_string, shell=True) +19 | Popen([var_string], shell=True) +20 | Popen([var_string, ""], shell=True) + | ^^^^^^^^^^ S602 + | + + 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 new file mode 100644 index 0000000000..bbfcb77cbc --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S603_S603.py.snap @@ -0,0 +1,106 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S603.py:4:15: S603 `subprocess` call: check for execution of untrusted input + | +3 | # Different Popen wrappers are checked. +4 | Popen("true", shell=False) + | ^^^^^^^^^^^ S603 +5 | call("true", shell=False) +6 | check_call("true", shell=False) + | + +S603.py:5:14: S603 `subprocess` call: check for execution of untrusted input + | +3 | # Different Popen wrappers are checked. +4 | Popen("true", shell=False) +5 | call("true", shell=False) + | ^^^^^^^^^^^ S603 +6 | check_call("true", shell=False) +7 | check_output("true", shell=False) + | + +S603.py:6:20: S603 `subprocess` call: check for execution of untrusted input + | +4 | Popen("true", shell=False) +5 | call("true", shell=False) +6 | check_call("true", shell=False) + | ^^^^^^^^^^^ S603 +7 | check_output("true", shell=False) +8 | run("true", shell=False) + | + +S603.py:7:22: S603 `subprocess` call: check for execution of untrusted input + | +5 | call("true", shell=False) +6 | check_call("true", shell=False) +7 | check_output("true", shell=False) + | ^^^^^^^^^^^ S603 +8 | run("true", shell=False) + | + +S603.py:8:13: S603 `subprocess` call: check for execution of untrusted input + | + 6 | check_call("true", shell=False) + 7 | check_output("true", shell=False) + 8 | run("true", shell=False) + | ^^^^^^^^^^^ S603 + 9 | +10 | # Values that falsey values are treated as false. + | + +S603.py:11:15: S603 `subprocess` call: check for execution of untrusted input + | +10 | # Values that falsey values are treated as false. +11 | Popen("true", shell=0) + | ^^^^^^^ S603 +12 | Popen("true", shell=[]) +13 | Popen("true", shell={}) + | + +S603.py:12:15: S603 `subprocess` call: check for execution of untrusted input + | +10 | # Values that falsey values are treated as false. +11 | Popen("true", shell=0) +12 | Popen("true", shell=[]) + | ^^^^^^^^ S603 +13 | Popen("true", shell={}) +14 | Popen("true", shell=None) + | + +S603.py:13:15: S603 `subprocess` call: check for execution of untrusted input + | +11 | Popen("true", shell=0) +12 | Popen("true", shell=[]) +13 | Popen("true", shell={}) + | ^^^^^^^^ S603 +14 | Popen("true", shell=None) + | + +S603.py:14:15: S603 `subprocess` call: check for execution of untrusted input + | +12 | Popen("true", shell=[]) +13 | Popen("true", shell={}) +14 | Popen("true", shell=None) + | ^^^^^^^^^^ S603 +15 | +16 | # Unknown values are treated as falsey. + | + +S603.py:17:15: 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 | +19 | # No value is also caught. + | + +S603.py:20:7: S603 `subprocess` call: check for execution of untrusted input + | +19 | # No value is also caught. +20 | Popen("true") + | ^^^^^^ S603 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S604_S604.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S604_S604.py.snap new file mode 100644 index 0000000000..70a4c8aca2 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S604_S604.py.snap @@ -0,0 +1,10 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S604.py:5:5: S604 Function call with `shell=True` parameter identified, security issue + | +5 | foo(shell=True) + | ^^^^^^^^^^ S604 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S605_S605.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S605_S605.py.snap new file mode 100644 index 0000000000..49b3823a03 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S605_S605.py.snap @@ -0,0 +1,147 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S605.py:7:11: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + | +6 | # Check all shell functions. +7 | os.system("true") + | ^^^^^^ S605 +8 | os.popen("true") +9 | os.popen2("true") + | + +S605.py:8:10: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + | + 6 | # Check all shell functions. + 7 | os.system("true") + 8 | os.popen("true") + | ^^^^^^ S605 + 9 | os.popen2("true") +10 | os.popen3("true") + | + +S605.py:9:11: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + | + 7 | os.system("true") + 8 | os.popen("true") + 9 | os.popen2("true") + | ^^^^^^ S605 +10 | os.popen3("true") +11 | os.popen4("true") + | + +S605.py:10:11: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + | + 8 | os.popen("true") + 9 | os.popen2("true") +10 | os.popen3("true") + | ^^^^^^ S605 +11 | os.popen4("true") +12 | popen2.popen2("true") + | + +S605.py:11:11: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + | + 9 | os.popen2("true") +10 | os.popen3("true") +11 | os.popen4("true") + | ^^^^^^ S605 +12 | popen2.popen2("true") +13 | popen2.popen3("true") + | + +S605.py:12:15: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + | +10 | os.popen3("true") +11 | os.popen4("true") +12 | popen2.popen2("true") + | ^^^^^^ S605 +13 | popen2.popen3("true") +14 | popen2.popen4("true") + | + +S605.py:13:15: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + | +11 | os.popen4("true") +12 | popen2.popen2("true") +13 | popen2.popen3("true") + | ^^^^^^ S605 +14 | popen2.popen4("true") +15 | popen2.Popen3("true") + | + +S605.py:14:15: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + | +12 | popen2.popen2("true") +13 | popen2.popen3("true") +14 | popen2.popen4("true") + | ^^^^^^ S605 +15 | popen2.Popen3("true") +16 | popen2.Popen4("true") + | + +S605.py:15:15: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + | +13 | popen2.popen3("true") +14 | popen2.popen4("true") +15 | popen2.Popen3("true") + | ^^^^^^ S605 +16 | popen2.Popen4("true") +17 | commands.getoutput("true") + | + +S605.py:16:15: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + | +14 | popen2.popen4("true") +15 | popen2.Popen3("true") +16 | popen2.Popen4("true") + | ^^^^^^ S605 +17 | commands.getoutput("true") +18 | commands.getstatusoutput("true") + | + +S605.py:17:20: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + | +15 | popen2.Popen3("true") +16 | popen2.Popen4("true") +17 | commands.getoutput("true") + | ^^^^^^ S605 +18 | commands.getstatusoutput("true") + | + +S605.py:18:26: S605 Starting a process with a shell: seems safe, but may be changed in the future; consider rewriting without `shell` + | +16 | popen2.Popen4("true") +17 | commands.getoutput("true") +18 | commands.getstatusoutput("true") + | ^^^^^^ S605 + | + +S605.py:23:11: S605 Starting a process with a shell, possible injection detected + | +21 | # Check command argument looks unsafe. +22 | var_string = "true" +23 | os.system(var_string) + | ^^^^^^^^^^ S605 +24 | os.system([var_string]) +25 | os.system([var_string, ""]) + | + +S605.py:24:11: S605 Starting a process with a shell, possible injection detected + | +22 | var_string = "true" +23 | os.system(var_string) +24 | os.system([var_string]) + | ^^^^^^^^^^^^ S605 +25 | os.system([var_string, ""]) + | + +S605.py:25:11: S605 Starting a process with a shell, possible injection detected + | +23 | os.system(var_string) +24 | os.system([var_string]) +25 | os.system([var_string, ""]) + | ^^^^^^^^^^^^^^^^ S605 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S606_S606.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S606_S606.py.snap new file mode 100644 index 0000000000..32c3651950 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S606_S606.py.snap @@ -0,0 +1,170 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S606.py:4:1: S606 Starting a process without a shell + | +3 | # Check all shell functions. +4 | os.execl("true") + | ^^^^^^^^ S606 +5 | os.execle("true") +6 | os.execlp("true") + | + +S606.py:5:1: S606 Starting a process without a shell + | +3 | # Check all shell functions. +4 | os.execl("true") +5 | os.execle("true") + | ^^^^^^^^^ S606 +6 | os.execlp("true") +7 | os.execlpe("true") + | + +S606.py:6:1: S606 Starting a process without a shell + | +4 | os.execl("true") +5 | os.execle("true") +6 | os.execlp("true") + | ^^^^^^^^^ S606 +7 | os.execlpe("true") +8 | os.execv("true") + | + +S606.py:7:1: S606 Starting a process without a shell + | +5 | os.execle("true") +6 | os.execlp("true") +7 | os.execlpe("true") + | ^^^^^^^^^^ S606 +8 | os.execv("true") +9 | os.execve("true") + | + +S606.py:8:1: S606 Starting a process without a shell + | + 6 | os.execlp("true") + 7 | os.execlpe("true") + 8 | os.execv("true") + | ^^^^^^^^ S606 + 9 | os.execve("true") +10 | os.execvp("true") + | + +S606.py:9:1: S606 Starting a process without a shell + | + 7 | os.execlpe("true") + 8 | os.execv("true") + 9 | os.execve("true") + | ^^^^^^^^^ S606 +10 | os.execvp("true") +11 | os.execvpe("true") + | + +S606.py:10:1: S606 Starting a process without a shell + | + 8 | os.execv("true") + 9 | os.execve("true") +10 | os.execvp("true") + | ^^^^^^^^^ S606 +11 | os.execvpe("true") +12 | os.spawnl("true") + | + +S606.py:11:1: S606 Starting a process without a shell + | + 9 | os.execve("true") +10 | os.execvp("true") +11 | os.execvpe("true") + | ^^^^^^^^^^ S606 +12 | os.spawnl("true") +13 | os.spawnle("true") + | + +S606.py:12:1: S606 Starting a process without a shell + | +10 | os.execvp("true") +11 | os.execvpe("true") +12 | os.spawnl("true") + | ^^^^^^^^^ S606 +13 | os.spawnle("true") +14 | os.spawnlp("true") + | + +S606.py:13:1: S606 Starting a process without a shell + | +11 | os.execvpe("true") +12 | os.spawnl("true") +13 | os.spawnle("true") + | ^^^^^^^^^^ S606 +14 | os.spawnlp("true") +15 | os.spawnlpe("true") + | + +S606.py:14:1: S606 Starting a process without a shell + | +12 | os.spawnl("true") +13 | os.spawnle("true") +14 | os.spawnlp("true") + | ^^^^^^^^^^ S606 +15 | os.spawnlpe("true") +16 | os.spawnv("true") + | + +S606.py:15:1: S606 Starting a process without a shell + | +13 | os.spawnle("true") +14 | os.spawnlp("true") +15 | os.spawnlpe("true") + | ^^^^^^^^^^^ S606 +16 | os.spawnv("true") +17 | os.spawnve("true") + | + +S606.py:16:1: S606 Starting a process without a shell + | +14 | os.spawnlp("true") +15 | os.spawnlpe("true") +16 | os.spawnv("true") + | ^^^^^^^^^ S606 +17 | os.spawnve("true") +18 | os.spawnvp("true") + | + +S606.py:17:1: S606 Starting a process without a shell + | +15 | os.spawnlpe("true") +16 | os.spawnv("true") +17 | os.spawnve("true") + | ^^^^^^^^^^ S606 +18 | os.spawnvp("true") +19 | os.spawnvpe("true") + | + +S606.py:18:1: S606 Starting a process without a shell + | +16 | os.spawnv("true") +17 | os.spawnve("true") +18 | os.spawnvp("true") + | ^^^^^^^^^^ S606 +19 | os.spawnvpe("true") +20 | os.startfile("true") + | + +S606.py:19:1: S606 Starting a process without a shell + | +17 | os.spawnve("true") +18 | os.spawnvp("true") +19 | os.spawnvpe("true") + | ^^^^^^^^^^^ S606 +20 | os.startfile("true") + | + +S606.py:20:1: S606 Starting a process without a shell + | +18 | os.spawnvp("true") +19 | os.spawnvpe("true") +20 | os.startfile("true") + | ^^^^^^^^^^^^ S606 + | + + 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 new file mode 100644 index 0000000000..1e82703d36 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S607_S607.py.snap @@ -0,0 +1,223 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S607.py:9:11: S607 Starting a process with a partial executable path + | + 7 | subprocess.check_output("true") + 8 | subprocess.run("true") + 9 | os.system("true") + | ^^^^^^ S607 +10 | os.popen("true") +11 | os.popen2("true") + | + +S607.py:10:10: S607 Starting a process with a partial executable path + | + 8 | subprocess.run("true") + 9 | os.system("true") +10 | os.popen("true") + | ^^^^^^ S607 +11 | os.popen2("true") +12 | os.popen3("true") + | + +S607.py:11:11: S607 Starting a process with a partial executable path + | + 9 | os.system("true") +10 | os.popen("true") +11 | os.popen2("true") + | ^^^^^^ S607 +12 | os.popen3("true") +13 | os.popen4("true") + | + +S607.py:12:11: S607 Starting a process with a partial executable path + | +10 | os.popen("true") +11 | os.popen2("true") +12 | os.popen3("true") + | ^^^^^^ S607 +13 | os.popen4("true") +14 | popen2.popen2("true") + | + +S607.py:13:11: S607 Starting a process with a partial executable path + | +11 | os.popen2("true") +12 | os.popen3("true") +13 | os.popen4("true") + | ^^^^^^ S607 +14 | popen2.popen2("true") +15 | popen2.popen3("true") + | + +S607.py:21:10: S607 Starting a process with a partial executable path + | +19 | commands.getoutput("true") +20 | commands.getstatusoutput("true") +21 | os.execl("true") + | ^^^^^^ S607 +22 | os.execle("true") +23 | os.execlp("true") + | + +S607.py:22:11: S607 Starting a process with a partial executable path + | +20 | commands.getstatusoutput("true") +21 | os.execl("true") +22 | os.execle("true") + | ^^^^^^ S607 +23 | os.execlp("true") +24 | os.execlpe("true") + | + +S607.py:23:11: S607 Starting a process with a partial executable path + | +21 | os.execl("true") +22 | os.execle("true") +23 | os.execlp("true") + | ^^^^^^ S607 +24 | os.execlpe("true") +25 | os.execv("true") + | + +S607.py:24:12: S607 Starting a process with a partial executable path + | +22 | os.execle("true") +23 | os.execlp("true") +24 | os.execlpe("true") + | ^^^^^^ S607 +25 | os.execv("true") +26 | os.execve("true") + | + +S607.py:25:10: S607 Starting a process with a partial executable path + | +23 | os.execlp("true") +24 | os.execlpe("true") +25 | os.execv("true") + | ^^^^^^ S607 +26 | os.execve("true") +27 | os.execvp("true") + | + +S607.py:26:11: S607 Starting a process with a partial executable path + | +24 | os.execlpe("true") +25 | os.execv("true") +26 | os.execve("true") + | ^^^^^^ S607 +27 | os.execvp("true") +28 | os.execvpe("true") + | + +S607.py:27:11: S607 Starting a process with a partial executable path + | +25 | os.execv("true") +26 | os.execve("true") +27 | os.execvp("true") + | ^^^^^^ S607 +28 | os.execvpe("true") +29 | os.spawnl("true") + | + +S607.py:28:12: S607 Starting a process with a partial executable path + | +26 | os.execve("true") +27 | os.execvp("true") +28 | os.execvpe("true") + | ^^^^^^ S607 +29 | os.spawnl("true") +30 | os.spawnle("true") + | + +S607.py:29:11: S607 Starting a process with a partial executable path + | +27 | os.execvp("true") +28 | os.execvpe("true") +29 | os.spawnl("true") + | ^^^^^^ S607 +30 | os.spawnle("true") +31 | os.spawnlp("true") + | + +S607.py:30:12: S607 Starting a process with a partial executable path + | +28 | os.execvpe("true") +29 | os.spawnl("true") +30 | os.spawnle("true") + | ^^^^^^ S607 +31 | os.spawnlp("true") +32 | os.spawnlpe("true") + | + +S607.py:31:12: S607 Starting a process with a partial executable path + | +29 | os.spawnl("true") +30 | os.spawnle("true") +31 | os.spawnlp("true") + | ^^^^^^ S607 +32 | os.spawnlpe("true") +33 | os.spawnv("true") + | + +S607.py:32:13: S607 Starting a process with a partial executable path + | +30 | os.spawnle("true") +31 | os.spawnlp("true") +32 | os.spawnlpe("true") + | ^^^^^^ S607 +33 | os.spawnv("true") +34 | os.spawnve("true") + | + +S607.py:33:11: S607 Starting a process with a partial executable path + | +31 | os.spawnlp("true") +32 | os.spawnlpe("true") +33 | os.spawnv("true") + | ^^^^^^ S607 +34 | os.spawnve("true") +35 | os.spawnvp("true") + | + +S607.py:34:12: S607 Starting a process with a partial executable path + | +32 | os.spawnlpe("true") +33 | os.spawnv("true") +34 | os.spawnve("true") + | ^^^^^^ S607 +35 | os.spawnvp("true") +36 | os.spawnvpe("true") + | + +S607.py:35:12: S607 Starting a process with a partial executable path + | +33 | os.spawnv("true") +34 | os.spawnve("true") +35 | os.spawnvp("true") + | ^^^^^^ S607 +36 | os.spawnvpe("true") +37 | os.startfile("true") + | + +S607.py:36:13: S607 Starting a process with a partial executable path + | +34 | os.spawnve("true") +35 | os.spawnvp("true") +36 | os.spawnvpe("true") + | ^^^^^^ S607 +37 | os.startfile("true") + | + +S607.py:37:14: S607 Starting a process with a partial executable path + | +35 | os.spawnvp("true") +36 | os.spawnvpe("true") +37 | os.startfile("true") + | ^^^^^^ S607 +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__S608_S608.py.snap b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S608_S608.py.snap new file mode 100644 index 0000000000..82e67171d8 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S608_S608.py.snap @@ -0,0 +1,482 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S608.py:2:10: S608 Possible SQL injection vector through string-based query construction + | +1 | # single-line failures +2 | query1 = "SELECT %s FROM table" % (var,) # bad + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +3 | query2 = "SELECT var FROM " + table +4 | query3 = "SELECT " + val + " FROM " + table + | + +S608.py:3:10: S608 Possible SQL injection vector through string-based query construction + | +1 | # single-line failures +2 | query1 = "SELECT %s FROM table" % (var,) # bad +3 | query2 = "SELECT var FROM " + table + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +4 | query3 = "SELECT " + val + " FROM " + table +5 | query4 = "SELECT {} FROM table;".format(var) + | + +S608.py:4:10: S608 Possible SQL injection vector through string-based query construction + | +2 | query1 = "SELECT %s FROM table" % (var,) # bad +3 | query2 = "SELECT var FROM " + table +4 | query3 = "SELECT " + val + " FROM " + table + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +5 | query4 = "SELECT {} FROM table;".format(var) +6 | query5 = f"SELECT * FROM table WHERE var = {var}" + | + +S608.py:5:10: S608 Possible SQL injection vector through string-based query construction + | +3 | query2 = "SELECT var FROM " + table +4 | query3 = "SELECT " + val + " FROM " + table +5 | query4 = "SELECT {} FROM table;".format(var) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +6 | query5 = f"SELECT * FROM table WHERE var = {var}" + | + +S608.py:6:10: S608 Possible SQL injection vector through string-based query construction + | +4 | query3 = "SELECT " + val + " FROM " + table +5 | query4 = "SELECT {} FROM table;".format(var) +6 | query5 = f"SELECT * FROM table WHERE var = {var}" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +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 | + 8 | query6 = "DELETE FROM table WHERE var = %s" % (var,) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + 9 | query7 = "DELETE FROM table WHERE VAR = " + var +10 | query8 = "DELETE FROM " + table + "WHERE var = " + var + | + +S608.py:9:10: S608 Possible SQL injection vector through string-based query construction + | + 8 | query6 = "DELETE FROM table WHERE var = %s" % (var,) + 9 | query7 = "DELETE FROM table WHERE VAR = " + var + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +10 | query8 = "DELETE FROM " + table + "WHERE var = " + var +11 | query9 = "DELETE FROM table WHERE var = {}".format(var) + | + +S608.py:10:10: S608 Possible SQL injection vector through string-based query construction + | + 8 | query6 = "DELETE FROM table WHERE var = %s" % (var,) + 9 | query7 = "DELETE FROM table WHERE VAR = " + var +10 | query8 = "DELETE FROM " + table + "WHERE var = " + var + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +11 | query9 = "DELETE FROM table WHERE var = {}".format(var) +12 | query10 = f"DELETE FROM table WHERE var = {var}" + | + +S608.py:11:10: S608 Possible SQL injection vector through string-based query construction + | + 9 | query7 = "DELETE FROM table WHERE VAR = " + var +10 | query8 = "DELETE FROM " + table + "WHERE var = " + var +11 | query9 = "DELETE FROM table WHERE var = {}".format(var) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +12 | query10 = f"DELETE FROM table WHERE var = {var}" + | + +S608.py:12:11: S608 Possible SQL injection vector through string-based query construction + | +10 | query8 = "DELETE FROM " + table + "WHERE var = " + var +11 | query9 = "DELETE FROM table WHERE var = {}".format(var) +12 | query10 = f"DELETE FROM table WHERE var = {var}" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +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 | +14 | query11 = "INSERT INTO table VALUES (%s)" % (var,) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +15 | query12 = "INSERT INTO TABLE VALUES (" + var + ")" +16 | query13 = "INSERT INTO {} VALUES ({})".format(table, var) + | + +S608.py:15:11: S608 Possible SQL injection vector through string-based query construction + | +14 | query11 = "INSERT INTO table VALUES (%s)" % (var,) +15 | query12 = "INSERT INTO TABLE VALUES (" + var + ")" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +16 | query13 = "INSERT INTO {} VALUES ({})".format(table, var) +17 | query14 = f"INSERT INTO {table} VALUES var = {var}" + | + +S608.py:16:11: S608 Possible SQL injection vector through string-based query construction + | +14 | query11 = "INSERT INTO table VALUES (%s)" % (var,) +15 | query12 = "INSERT INTO TABLE VALUES (" + var + ")" +16 | query13 = "INSERT INTO {} VALUES ({})".format(table, var) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +17 | query14 = f"INSERT INTO {table} VALUES var = {var}" + | + +S608.py:17:11: S608 Possible SQL injection vector through string-based query construction + | +15 | query12 = "INSERT INTO TABLE VALUES (" + var + ")" +16 | query13 = "INSERT INTO {} VALUES ({})".format(table, var) +17 | query14 = f"INSERT INTO {table} VALUES var = {var}" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +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 | +19 | query15 = "UPDATE %s SET var = %s" % (table, var) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +20 | query16 = "UPDATE " + table + " SET var = " + var +21 | query17 = "UPDATE {} SET var = {}".format(table, var) + | + +S608.py:20:11: S608 Possible SQL injection vector through string-based query construction + | +19 | query15 = "UPDATE %s SET var = %s" % (table, var) +20 | query16 = "UPDATE " + table + " SET var = " + var + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +21 | query17 = "UPDATE {} SET var = {}".format(table, var) +22 | query18 = f"UPDATE {table} SET var = {var}" + | + +S608.py:21:11: S608 Possible SQL injection vector through string-based query construction + | +19 | query15 = "UPDATE %s SET var = %s" % (table, var) +20 | query16 = "UPDATE " + table + " SET var = " + var +21 | query17 = "UPDATE {} SET var = {}".format(table, var) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +22 | query18 = f"UPDATE {table} SET var = {var}" + | + +S608.py:22:11: S608 Possible SQL injection vector through string-based query construction + | +20 | query16 = "UPDATE " + table + " SET var = " + var +21 | query17 = "UPDATE {} SET var = {}".format(table, var) +22 | query18 = f"UPDATE {table} SET var = {var}" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +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 | +24 | query19 = "select %s from table" % (var,) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +25 | query20 = "select var from " + table +26 | query21 = "select " + val + " from " + table + | + +S608.py:25:11: S608 Possible SQL injection vector through string-based query construction + | +24 | query19 = "select %s from table" % (var,) +25 | query20 = "select var from " + table + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +26 | query21 = "select " + val + " from " + table +27 | query22 = "select {} from table;".format(var) + | + +S608.py:26:11: S608 Possible SQL injection vector through string-based query construction + | +24 | query19 = "select %s from table" % (var,) +25 | query20 = "select var from " + table +26 | query21 = "select " + val + " from " + table + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +27 | query22 = "select {} from table;".format(var) +28 | query23 = f"select * from table where var = {var}" + | + +S608.py:27:11: S608 Possible SQL injection vector through string-based query construction + | +25 | query20 = "select var from " + table +26 | query21 = "select " + val + " from " + table +27 | query22 = "select {} from table;".format(var) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +28 | query23 = f"select * from table where var = {var}" + | + +S608.py:28:11: S608 Possible SQL injection vector through string-based query construction + | +26 | query21 = "select " + val + " from " + table +27 | query22 = "select {} from table;".format(var) +28 | query23 = f"select * from table where var = {var}" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +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 | +30 | query24 = "delete from table where var = %s" % (var,) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +31 | query25 = "delete from table where var = " + var +32 | query26 = "delete from " + table + "where var = " + var + | + +S608.py:31:11: S608 Possible SQL injection vector through string-based query construction + | +30 | query24 = "delete from table where var = %s" % (var,) +31 | query25 = "delete from table where var = " + var + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +32 | query26 = "delete from " + table + "where var = " + var +33 | query27 = "delete from table where var = {}".format(var) + | + +S608.py:32:11: S608 Possible SQL injection vector through string-based query construction + | +30 | query24 = "delete from table where var = %s" % (var,) +31 | query25 = "delete from table where var = " + var +32 | query26 = "delete from " + table + "where var = " + var + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +33 | query27 = "delete from table where var = {}".format(var) +34 | query28 = f"delete from table where var = {var}" + | + +S608.py:33:11: S608 Possible SQL injection vector through string-based query construction + | +31 | query25 = "delete from table where var = " + var +32 | query26 = "delete from " + table + "where var = " + var +33 | query27 = "delete from table where var = {}".format(var) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +34 | query28 = f"delete from table where var = {var}" + | + +S608.py:34:11: S608 Possible SQL injection vector through string-based query construction + | +32 | query26 = "delete from " + table + "where var = " + var +33 | query27 = "delete from table where var = {}".format(var) +34 | query28 = f"delete from table where var = {var}" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +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 | +36 | query29 = "insert into table values (%s)" % (var,) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +37 | query30 = "insert into table values (" + var + ")" +38 | query31 = "insert into {} values ({})".format(table, var) + | + +S608.py:37:11: S608 Possible SQL injection vector through string-based query construction + | +36 | query29 = "insert into table values (%s)" % (var,) +37 | query30 = "insert into table values (" + var + ")" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +38 | query31 = "insert into {} values ({})".format(table, var) +39 | query32 = f"insert into {table} values var = {var}" + | + +S608.py:38:11: S608 Possible SQL injection vector through string-based query construction + | +36 | query29 = "insert into table values (%s)" % (var,) +37 | query30 = "insert into table values (" + var + ")" +38 | query31 = "insert into {} values ({})".format(table, var) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +39 | query32 = f"insert into {table} values var = {var}" + | + +S608.py:39:11: S608 Possible SQL injection vector through string-based query construction + | +37 | query30 = "insert into table values (" + var + ")" +38 | query31 = "insert into {} values ({})".format(table, var) +39 | query32 = f"insert into {table} values var = {var}" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +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 | +41 | query33 = "update %s set var = %s" % (table, var) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +42 | query34 = "update " + table + " set var = " + var +43 | query35 = "update {} set var = {}".format(table, var) + | + +S608.py:42:11: S608 Possible SQL injection vector through string-based query construction + | +41 | query33 = "update %s set var = %s" % (table, var) +42 | query34 = "update " + table + " set var = " + var + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +43 | query35 = "update {} set var = {}".format(table, var) +44 | query36 = f"update {table} set var = {var}" + | + +S608.py:43:11: S608 Possible SQL injection vector through string-based query construction + | +41 | query33 = "update %s set var = %s" % (table, var) +42 | query34 = "update " + table + " set var = " + var +43 | query35 = "update {} set var = {}".format(table, var) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +44 | query36 = f"update {table} set var = {var}" + | + +S608.py:44:11: S608 Possible SQL injection vector through string-based query construction + | +42 | query34 = "update " + table + " set var = " + var +43 | query35 = "update {} set var = {}".format(table, var) +44 | query36 = f"update {table} set var = {var}" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +45 | +46 | # multi-line failures + | + +S608.py:48:12: S608 Possible SQL injection vector through string-based query construction + | +46 | # multi-line failures +47 | def query37(): +48 | return """ + | ____________^ +49 | | SELECT * +50 | | FROM table +51 | | WHERE var = %s +52 | | """ % var + | |_____________^ S608 +53 | +54 | def query38(): + | + +S608.py:55:12: S608 Possible SQL injection vector through string-based query construction + | +54 | def query38(): +55 | return """ + | ____________^ +56 | | SELECT * +57 | | FROM TABLE +58 | | WHERE var = +59 | | """ + var + | |_____________^ S608 +60 | +61 | def query39(): + | + +S608.py:62:12: S608 Possible SQL injection vector through string-based query construction + | +61 | def query39(): +62 | return """ + | ____________^ +63 | | SELECT * +64 | | FROM table +65 | | WHERE var = {} +66 | | """.format(var) + | |___________________^ S608 +67 | +68 | def query40(): + | + +S608.py:69:12: S608 Possible SQL injection vector through string-based query construction + | +68 | def query40(): +69 | return f""" + | ____________^ +70 | | SELECT * +71 | | FROM table +72 | | WHERE var = {var} +73 | | """ + | |_______^ S608 +74 | +75 | def query41(): + | + +S608.py:77:9: S608 Possible SQL injection vector through string-based query construction + | +75 | def query41(): +76 | return ( +77 | "SELECT * " + | _________^ +78 | | "FROM table " +79 | | f"WHERE var = {var}" + | |____________________________^ S608 +80 | ) + | + +S608.py:83:26: S608 Possible SQL injection vector through string-based query construction + | +82 | # # cursor-wrapped failures +83 | query42 = cursor.execute("SELECT * FROM table WHERE var = %s" % var) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +84 | query43 = cursor.execute(f"SELECT * FROM table WHERE var = {var}") +85 | query44 = cursor.execute("SELECT * FROM table WHERE var = {}".format(var)) + | + +S608.py:84:26: S608 Possible SQL injection vector through string-based query construction + | +82 | # # cursor-wrapped failures +83 | query42 = cursor.execute("SELECT * FROM table WHERE var = %s" % var) +84 | query43 = cursor.execute(f"SELECT * FROM table WHERE var = {var}") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +85 | query44 = cursor.execute("SELECT * FROM table WHERE var = {}".format(var)) +86 | query45 = cursor.executemany("SELECT * FROM table WHERE var = %s" % var, []) + | + +S608.py:85:26: S608 Possible SQL injection vector through string-based query construction + | +83 | query42 = cursor.execute("SELECT * FROM table WHERE var = %s" % var) +84 | query43 = cursor.execute(f"SELECT * FROM table WHERE var = {var}") +85 | query44 = cursor.execute("SELECT * FROM table WHERE var = {}".format(var)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +86 | query45 = cursor.executemany("SELECT * FROM table WHERE var = %s" % var, []) + | + +S608.py:86:30: S608 Possible SQL injection vector through string-based query construction + | +84 | query43 = cursor.execute(f"SELECT * FROM table WHERE var = {var}") +85 | query44 = cursor.execute("SELECT * FROM table WHERE var = {}".format(var)) +86 | query45 = cursor.executemany("SELECT * FROM table WHERE var = %s" % var, []) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +87 | +88 | # # pass + | + +S608.py:98:9: S608 Possible SQL injection vector through string-based query construction + | + 97 | # # INSERT without INTO (e.g. MySQL and derivatives) + 98 | query = "INSERT table VALUES (%s)" % (var,) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 + 99 | +100 | # # REPLACE (e.g. MySQL and derivatives, SQLite) + | + +S608.py:101:9: S608 Possible SQL injection vector through string-based query construction + | +100 | # # REPLACE (e.g. MySQL and derivatives, SQLite) +101 | query = "REPLACE INTO table VALUES (%s)" % (var,) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +102 | query = "REPLACE table VALUES (%s)" % (var,) + | + +S608.py:102:9: S608 Possible SQL injection vector through string-based query construction + | +100 | # # REPLACE (e.g. MySQL and derivatives, SQLite) +101 | query = "REPLACE INTO table VALUES (%s)" % (var,) +102 | query = "REPLACE table VALUES (%s)" % (var,) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ S608 +103 | +104 | query = "Deselect something that is not SQL even though it has a ' from ' somewhere in %s." % "there" + | + + 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 new file mode 100644 index 0000000000..db4e30bb6b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S609_S609.py.snap @@ -0,0 +1,41 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S609.py:4:1: S609 Possible wildcard injection in call due to `*` usage + | +2 | import subprocess +3 | +4 | os.popen("chmod +w foo*") + | ^^^^^^^^ S609 +5 | subprocess.Popen("/bin/chown root: *", shell=True) +6 | subprocess.Popen(["/usr/local/bin/rsync", "*", "some_where:"], shell=True) + | + +S609.py:5:1: S609 Possible wildcard injection in call due to `*` usage + | +4 | os.popen("chmod +w foo*") +5 | subprocess.Popen("/bin/chown root: *", shell=True) + | ^^^^^^^^^^^^^^^^ S609 +6 | subprocess.Popen(["/usr/local/bin/rsync", "*", "some_where:"], shell=True) +7 | subprocess.Popen("/usr/local/bin/rsync * no_injection_here:") + | + +S609.py:6:1: S609 Possible wildcard injection in call due to `*` usage + | +4 | os.popen("chmod +w foo*") +5 | subprocess.Popen("/bin/chown root: *", shell=True) +6 | subprocess.Popen(["/usr/local/bin/rsync", "*", "some_where:"], shell=True) + | ^^^^^^^^^^^^^^^^ S609 +7 | subprocess.Popen("/usr/local/bin/rsync * no_injection_here:") +8 | os.system("tar cf foo.tar bar/*") + | + +S609.py:8:1: S609 Possible wildcard injection in call due to `*` usage + | +6 | subprocess.Popen(["/usr/local/bin/rsync", "*", "some_where:"], shell=True) +7 | subprocess.Popen("/usr/local/bin/rsync * no_injection_here:") +8 | os.system("tar cf foo.tar bar/*") + | ^^^^^^^^^ S609 + | + + 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 new file mode 100644 index 0000000000..7e70531b62 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S612_S612.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +S612.py:3:5: S612 Use of insecure `logging.config.listen` detected + | +1 | import logging.config +2 | +3 | t = logging.config.listen(9999) + | ^^^^^^^^^^^^^^^^^^^^^ S612 +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 new file mode 100644 index 0000000000..a6f08cb71a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S701_S701.py.snap @@ -0,0 +1,51 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs +--- +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. + | + 7 | templateEnv = jinja2.Environment(autoescape=True, + 8 | loader=templateLoader ) + 9 | Environment(loader=templateLoader, load=templateLoader, autoescape=something) # S701 + | ^^^^^^^^^^^^^^^^^^^^ S701 +10 | templateEnv = jinja2.Environment(autoescape=False, loader=templateLoader ) # S701 +11 | Environment(loader=templateLoader, + | + +S701.py:10:34: S701 Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function. + | + 8 | loader=templateLoader ) + 9 | Environment(loader=templateLoader, load=templateLoader, autoescape=something) # S701 +10 | templateEnv = jinja2.Environment(autoescape=False, loader=templateLoader ) # S701 + | ^^^^^^^^^^^^^^^^ S701 +11 | Environment(loader=templateLoader, +12 | load=templateLoader, + | + +S701.py:13:13: S701 Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function. + | +11 | Environment(loader=templateLoader, +12 | load=templateLoader, +13 | autoescape=False) # S701 + | ^^^^^^^^^^^^^^^^ S701 +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 | +15 | Environment(loader=templateLoader, # S701 + | ^^^^^^^^^^^ S701 +16 | load=templateLoader) + | + +S701.py:29:36: S701 Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function. + | +27 | def fake_func(): +28 | return 'foobar' +29 | Environment(loader=templateLoader, autoescape=fake_func()) # S701 + | ^^^^^^^^^^^^^^^^^^^^^^ S701 + | + + diff --git a/crates/ruff/src/rules/flake8_blind_except/mod.rs b/crates/ruff_linter/src/rules/flake8_blind_except/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_blind_except/mod.rs rename to crates/ruff_linter/src/rules/flake8_blind_except/mod.rs diff --git a/crates/ruff/src/rules/flake8_blind_except/rules/blind_except.rs b/crates/ruff_linter/src/rules/flake8_blind_except/rules/blind_except.rs similarity index 100% rename from crates/ruff/src/rules/flake8_blind_except/rules/blind_except.rs rename to crates/ruff_linter/src/rules/flake8_blind_except/rules/blind_except.rs diff --git a/crates/ruff/src/rules/flake8_blind_except/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_blind_except/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_blind_except/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_blind_except/rules/mod.rs diff --git a/crates/ruff_linter/src/rules/flake8_blind_except/snapshots/ruff_linter__rules__flake8_blind_except__tests__BLE001_BLE.py.snap b/crates/ruff_linter/src/rules/flake8_blind_except/snapshots/ruff_linter__rules__flake8_blind_except__tests__BLE001_BLE.py.snap new file mode 100644 index 0000000000..0555d9a748 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_blind_except/snapshots/ruff_linter__rules__flake8_blind_except__tests__BLE001_BLE.py.snap @@ -0,0 +1,97 @@ +--- +source: crates/ruff_linter/src/rules/flake8_blind_except/mod.rs +--- +BLE.py:25:8: BLE001 Do not catch blind exception: `BaseException` + | +23 | except Exception as e: +24 | raise e +25 | except BaseException: + | ^^^^^^^^^^^^^ BLE001 +26 | pass + | + +BLE.py:31:8: BLE001 Do not catch blind exception: `Exception` + | +29 | try: +30 | pass +31 | except Exception: + | ^^^^^^^^^ BLE001 +32 | pass +33 | finally: + | + +BLE.py:42:8: BLE001 Do not catch blind exception: `Exception` + | +40 | try: +41 | pass +42 | except Exception as e: + | ^^^^^^^^^ BLE001 +43 | try: +44 | raise e + | + +BLE.py:45:12: BLE001 Do not catch blind exception: `BaseException` + | +43 | try: +44 | raise e +45 | except BaseException: + | ^^^^^^^^^^^^^ BLE001 +46 | pass + | + +BLE.py:54:8: BLE001 Do not catch blind exception: `Exception` + | +52 | except BaseException as e: +53 | raise e +54 | except Exception: + | ^^^^^^^^^ BLE001 +55 | pass + | + +BLE.py:60:8: BLE001 Do not catch blind exception: `Exception` + | +58 | try: +59 | pass +60 | except Exception as e: + | ^^^^^^^^^ BLE001 +61 | raise bad +62 | except BaseException: + | + +BLE.py:62:8: BLE001 Do not catch blind exception: `BaseException` + | +60 | except Exception as e: +61 | raise bad +62 | except BaseException: + | ^^^^^^^^^^^^^ BLE001 +63 | pass + | + +BLE.py:69:8: BLE001 Do not catch blind exception: `Exception` + | +67 | try: +68 | pass +69 | except Exception: + | ^^^^^^^^^ BLE001 +70 | logging.error("...") + | + +BLE.py:75:8: BLE001 Do not catch blind exception: `Exception` + | +73 | try: +74 | pass +75 | except Exception: + | ^^^^^^^^^ BLE001 +76 | logging.error("...", exc_info=False) + | + +BLE.py:81:8: BLE001 Do not catch blind exception: `Exception` + | +79 | try: +80 | pass +81 | except Exception: + | ^^^^^^^^^ BLE001 +82 | logging.error("...", exc_info=None) + | + + diff --git a/crates/ruff/src/rules/flake8_boolean_trap/helpers.rs b/crates/ruff_linter/src/rules/flake8_boolean_trap/helpers.rs similarity index 100% rename from crates/ruff/src/rules/flake8_boolean_trap/helpers.rs rename to crates/ruff_linter/src/rules/flake8_boolean_trap/helpers.rs diff --git a/crates/ruff/src/rules/flake8_boolean_trap/mod.rs b/crates/ruff_linter/src/rules/flake8_boolean_trap/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_boolean_trap/mod.rs rename to crates/ruff_linter/src/rules/flake8_boolean_trap/mod.rs diff --git a/crates/ruff/src/rules/flake8_boolean_trap/rules/boolean_default_value_positional_argument.rs b/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_default_value_positional_argument.rs similarity index 100% rename from crates/ruff/src/rules/flake8_boolean_trap/rules/boolean_default_value_positional_argument.rs rename to crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_default_value_positional_argument.rs diff --git a/crates/ruff/src/rules/flake8_boolean_trap/rules/boolean_positional_value_in_call.rs b/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_positional_value_in_call.rs similarity index 100% rename from crates/ruff/src/rules/flake8_boolean_trap/rules/boolean_positional_value_in_call.rs rename to crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_positional_value_in_call.rs diff --git a/crates/ruff/src/rules/flake8_boolean_trap/rules/boolean_type_hint_positional_argument.rs b/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_type_hint_positional_argument.rs similarity index 100% rename from crates/ruff/src/rules/flake8_boolean_trap/rules/boolean_type_hint_positional_argument.rs rename to crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_type_hint_positional_argument.rs diff --git a/crates/ruff/src/rules/flake8_boolean_trap/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_boolean_trap/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_boolean_trap/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_boolean_trap/rules/mod.rs diff --git a/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT001_FBT.py.snap b/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT001_FBT.py.snap new file mode 100644 index 0000000000..b1f894ec5c --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT001_FBT.py.snap @@ -0,0 +1,92 @@ +--- +source: crates/ruff_linter/src/rules/flake8_boolean_trap/mod.rs +--- +FBT.py:4:5: FBT001 Boolean-typed positional argument in function definition + | +2 | posonly_nohint, +3 | posonly_nonboolhint: int, +4 | posonly_boolhint: bool, + | ^^^^^^^^^^^^^^^^ FBT001 +5 | posonly_boolstrhint: "bool", +6 | /, + | + +FBT.py:5:5: FBT001 Boolean-typed positional argument in function definition + | +3 | posonly_nonboolhint: int, +4 | posonly_boolhint: bool, +5 | posonly_boolstrhint: "bool", + | ^^^^^^^^^^^^^^^^^^^ FBT001 +6 | /, +7 | offset, + | + +FBT.py:10:5: FBT001 Boolean-typed positional argument in function definition + | + 8 | posorkw_nonvalued_nohint, + 9 | posorkw_nonvalued_nonboolhint: int, +10 | posorkw_nonvalued_boolhint: bool, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001 +11 | posorkw_nonvalued_boolstrhint: "bool", +12 | posorkw_boolvalued_nohint=True, + | + +FBT.py:11:5: FBT001 Boolean-typed positional argument in function definition + | + 9 | posorkw_nonvalued_nonboolhint: int, +10 | posorkw_nonvalued_boolhint: bool, +11 | posorkw_nonvalued_boolstrhint: "bool", + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001 +12 | posorkw_boolvalued_nohint=True, +13 | posorkw_boolvalued_nonboolhint: int = True, + | + +FBT.py:14:5: FBT001 Boolean-typed positional argument in function definition + | +12 | posorkw_boolvalued_nohint=True, +13 | posorkw_boolvalued_nonboolhint: int = True, +14 | posorkw_boolvalued_boolhint: bool = True, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001 +15 | posorkw_boolvalued_boolstrhint: "bool" = True, +16 | posorkw_nonboolvalued_nohint=1, + | + +FBT.py:15:5: FBT001 Boolean-typed positional argument in function definition + | +13 | posorkw_boolvalued_nonboolhint: int = True, +14 | posorkw_boolvalued_boolhint: bool = True, +15 | posorkw_boolvalued_boolstrhint: "bool" = True, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001 +16 | posorkw_nonboolvalued_nohint=1, +17 | posorkw_nonboolvalued_nonboolhint: int = 2, + | + +FBT.py:18:5: FBT001 Boolean-typed positional argument in function definition + | +16 | posorkw_nonboolvalued_nohint=1, +17 | posorkw_nonboolvalued_nonboolhint: int = 2, +18 | posorkw_nonboolvalued_boolhint: bool = 3, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001 +19 | posorkw_nonboolvalued_boolstrhint: "bool" = 4, +20 | *, + | + +FBT.py:19:5: FBT001 Boolean-typed positional argument in function definition + | +17 | posorkw_nonboolvalued_nonboolhint: int = 2, +18 | posorkw_nonboolvalued_boolhint: bool = 3, +19 | posorkw_nonboolvalued_boolstrhint: "bool" = 4, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT001 +20 | *, +21 | kwonly_nonvalued_nohint, + | + +FBT.py:87:19: FBT001 Boolean-typed positional argument in function definition + | +86 | # FBT001: Boolean positional arg in function definition +87 | def foo(self, value: bool) -> None: + | ^^^^^ FBT001 +88 | pass + | + + diff --git a/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT002_FBT.py.snap b/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT002_FBT.py.snap new file mode 100644 index 0000000000..14c5a21a11 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT002_FBT.py.snap @@ -0,0 +1,44 @@ +--- +source: crates/ruff_linter/src/rules/flake8_boolean_trap/mod.rs +--- +FBT.py:12:5: FBT002 Boolean default positional argument in function definition + | +10 | posorkw_nonvalued_boolhint: bool, +11 | posorkw_nonvalued_boolstrhint: "bool", +12 | posorkw_boolvalued_nohint=True, + | ^^^^^^^^^^^^^^^^^^^^^^^^^ FBT002 +13 | posorkw_boolvalued_nonboolhint: int = True, +14 | posorkw_boolvalued_boolhint: bool = True, + | + +FBT.py:13:5: FBT002 Boolean default positional argument in function definition + | +11 | posorkw_nonvalued_boolstrhint: "bool", +12 | posorkw_boolvalued_nohint=True, +13 | posorkw_boolvalued_nonboolhint: int = True, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT002 +14 | posorkw_boolvalued_boolhint: bool = True, +15 | posorkw_boolvalued_boolstrhint: "bool" = True, + | + +FBT.py:14:5: FBT002 Boolean default positional argument in function definition + | +12 | posorkw_boolvalued_nohint=True, +13 | posorkw_boolvalued_nonboolhint: int = True, +14 | posorkw_boolvalued_boolhint: bool = True, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT002 +15 | posorkw_boolvalued_boolstrhint: "bool" = True, +16 | posorkw_nonboolvalued_nohint=1, + | + +FBT.py:15:5: FBT002 Boolean default positional argument in function definition + | +13 | posorkw_boolvalued_nonboolhint: int = True, +14 | posorkw_boolvalued_boolhint: bool = True, +15 | posorkw_boolvalued_boolstrhint: "bool" = True, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FBT002 +16 | posorkw_nonboolvalued_nohint=1, +17 | posorkw_nonboolvalued_nonboolhint: int = 2, + | + + diff --git a/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT003_FBT.py.snap b/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT003_FBT.py.snap new file mode 100644 index 0000000000..d2b9021145 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_boolean_trap/snapshots/ruff_linter__rules__flake8_boolean_trap__tests__FBT003_FBT.py.snap @@ -0,0 +1,41 @@ +--- +source: crates/ruff_linter/src/rules/flake8_boolean_trap/mod.rs +--- +FBT.py:42:11: FBT003 Boolean positional value in function call + | +42 | used("a", True) + | ^^^^ FBT003 +43 | used(do=True) + | + +FBT.py:57:11: FBT003 Boolean positional value in function call + | +55 | {}.pop(True, False) +56 | dict.fromkeys(("world",), True) +57 | {}.deploy(True, False) + | ^^^^ FBT003 +58 | getattr(someobj, attrname, False) +59 | mylist.index(True) + | + +FBT.py:57:17: FBT003 Boolean positional value in function call + | +55 | {}.pop(True, False) +56 | dict.fromkeys(("world",), True) +57 | {}.deploy(True, False) + | ^^^^^ FBT003 +58 | getattr(someobj, attrname, False) +59 | mylist.index(True) + | + +FBT.py:69:38: FBT003 Boolean positional value in function call + | +67 | os.set_blocking(0, False) +68 | g_action.set_enabled(True) +69 | settings.set_enable_developer_extras(True) + | ^^^^ FBT003 +70 | foo.is_(True) +71 | bar.is_not(False) + | + + diff --git a/crates/ruff/src/rules/flake8_bugbear/mod.rs b/crates/ruff_linter/src/rules/flake8_bugbear/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/mod.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/mod.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/abstract_base_class.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/abstract_base_class.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/abstract_base_class.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/abstract_base_class.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/assert_false.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/assert_false.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/assert_false.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/assert_false.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/assert_raises_exception.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/assert_raises_exception.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/assert_raises_exception.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/assert_raises_exception.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/assignment_to_os_environ.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/assignment_to_os_environ.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/assignment_to_os_environ.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/assignment_to_os_environ.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/cached_instance_method.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/cached_instance_method.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/cached_instance_method.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/cached_instance_method.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/duplicate_exceptions.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/duplicate_exceptions.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/duplicate_exceptions.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/duplicate_exceptions.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/duplicate_value.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/duplicate_value.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/duplicate_value.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/duplicate_value.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/except_with_empty_tuple.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/except_with_empty_tuple.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/except_with_empty_tuple.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/except_with_empty_tuple.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/except_with_non_exception_classes.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/except_with_non_exception_classes.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/except_with_non_exception_classes.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/except_with_non_exception_classes.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/f_string_docstring.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/f_string_docstring.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/f_string_docstring.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/f_string_docstring.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/function_call_in_argument_default.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/function_call_in_argument_default.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/function_call_in_argument_default.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/function_call_in_argument_default.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/function_uses_loop_variable.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/function_uses_loop_variable.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/function_uses_loop_variable.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/function_uses_loop_variable.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/getattr_with_constant.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/getattr_with_constant.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/getattr_with_constant.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/getattr_with_constant.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/jump_statement_in_finally.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/jump_statement_in_finally.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/jump_statement_in_finally.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/jump_statement_in_finally.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/loop_variable_overrides_iterator.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/loop_variable_overrides_iterator.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/loop_variable_overrides_iterator.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/loop_variable_overrides_iterator.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/mutable_argument_default.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/mutable_argument_default.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/mutable_argument_default.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/mutable_argument_default.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/no_explicit_stacklevel.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/no_explicit_stacklevel.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/no_explicit_stacklevel.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/no_explicit_stacklevel.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/raise_literal.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/raise_literal.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/raise_literal.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/raise_literal.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/raise_without_from_inside_except.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/raise_without_from_inside_except.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/raise_without_from_inside_except.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/raise_without_from_inside_except.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/re_sub_positional_args.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/re_sub_positional_args.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/re_sub_positional_args.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/re_sub_positional_args.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/redundant_tuple_in_exception_handler.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/redundant_tuple_in_exception_handler.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/redundant_tuple_in_exception_handler.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/redundant_tuple_in_exception_handler.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/reuse_of_groupby_generator.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/reuse_of_groupby_generator.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/reuse_of_groupby_generator.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/reuse_of_groupby_generator.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/setattr_with_constant.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/setattr_with_constant.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/setattr_with_constant.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/setattr_with_constant.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/star_arg_unpacking_after_keyword_arg.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/star_arg_unpacking_after_keyword_arg.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/star_arg_unpacking_after_keyword_arg.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/star_arg_unpacking_after_keyword_arg.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/strip_with_multi_characters.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/strip_with_multi_characters.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/strip_with_multi_characters.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/strip_with_multi_characters.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/unary_prefix_increment_decrement.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/unary_prefix_increment_decrement.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/unary_prefix_increment_decrement.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/unary_prefix_increment_decrement.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/unintentional_type_annotation.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/unintentional_type_annotation.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/unintentional_type_annotation.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/unintentional_type_annotation.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/unreliable_callable_check.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/unreliable_callable_check.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/unreliable_callable_check.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/unreliable_callable_check.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/unused_loop_control_variable.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/unused_loop_control_variable.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/unused_loop_control_variable.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/unused_loop_control_variable.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/useless_comparison.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/useless_comparison.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/useless_comparison.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/useless_comparison.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/useless_contextlib_suppress.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/useless_contextlib_suppress.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/useless_contextlib_suppress.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/useless_contextlib_suppress.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/useless_expression.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/useless_expression.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/useless_expression.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/useless_expression.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/zip_without_explicit_strict.rs b/crates/ruff_linter/src/rules/flake8_bugbear/rules/zip_without_explicit_strict.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/rules/zip_without_explicit_strict.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/rules/zip_without_explicit_strict.rs diff --git a/crates/ruff/src/rules/flake8_bugbear/settings.rs b/crates/ruff_linter/src/rules/flake8_bugbear/settings.rs similarity index 100% rename from crates/ruff/src/rules/flake8_bugbear/settings.rs rename to crates/ruff_linter/src/rules/flake8_bugbear/settings.rs diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B002_B002.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B002_B002.py.snap new file mode 100644 index 0000000000..2f7974eab8 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B002_B002.py.snap @@ -0,0 +1,36 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B002.py:18:9: B002 Python does not support the unary prefix increment operator (`++`) + | +17 | def this_is_buggy(n): +18 | x = ++n + | ^^^ B002 +19 | y = --n +20 | return x, y + | + +B002.py:19:9: B002 Python does not support the unary prefix decrement operator (`--`) + | +17 | def this_is_buggy(n): +18 | x = ++n +19 | y = --n + | ^^^ B002 +20 | return x, y + | + +B002.py:24:12: B002 Python does not support the unary prefix increment operator (`++`) + | +23 | def this_is_buggy_too(n): +24 | return ++n, --n + | ^^^ B002 + | + +B002.py:24:17: B002 Python does not support the unary prefix decrement operator (`--`) + | +23 | def this_is_buggy_too(n): +24 | return ++n, --n + | ^^^ B002 + | + + 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 new file mode 100644 index 0000000000..0ee03ce25d --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B003_B003.py.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B003.py:9:1: B003 Assigning to `os.environ` doesn't clear the environment + | + 7 | from os import environ + 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 new file mode 100644 index 0000000000..67c56e33de --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B004_B004.py.snap @@ -0,0 +1,34 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B004.py:3:8: B004 [*] Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results. + | +1 | def this_is_a_bug(): +2 | o = object() +3 | if hasattr(o, "__call__"): + | ^^^^^^^^^^^^^^^^^^^^^^ B004 +4 | print("Ooh, callable! Or is it?") +5 | if getattr(o, "__call__", False): + | + = help: Replace with `callable()` + +ℹ Fix +1 1 | def this_is_a_bug(): +2 2 | o = object() +3 |- if hasattr(o, "__call__"): + 3 |+ if callable(o): +4 4 | print("Ooh, callable! Or is it?") +5 5 | if getattr(o, "__call__", False): +6 6 | print("Ooh, callable! Or is it?") + +B004.py:5:8: B004 Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results. + | +3 | if hasattr(o, "__call__"): +4 | print("Ooh, callable! Or is it?") +5 | if getattr(o, "__call__", False): + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B004 +6 | print("Ooh, callable! Or is it?") + | + = help: Replace with `callable()` + + 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 new file mode 100644 index 0000000000..a17c4cf3fd --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B005_B005.py.snap @@ -0,0 +1,84 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B005.py:4:1: B005 Using `.strip()` with multi-character strings is misleading the reader + | +2 | s.strip(s) # no warning +3 | s.strip("we") # no warning +4 | s.strip(".facebook.com") # warning + | ^^^^^^^^^^^^^^^^^^^^^^^^ B005 +5 | s.strip("e") # no warning +6 | s.strip("\n\t ") # no warning + | + +B005.py:7:1: B005 Using `.strip()` with multi-character strings is misleading the reader + | +5 | s.strip("e") # no warning +6 | s.strip("\n\t ") # no warning +7 | s.strip(r"\n\t ") # warning + | ^^^^^^^^^^^^^^^^^ B005 +8 | s.lstrip(s) # no warning +9 | s.lstrip("we") # no warning + | + +B005.py:10:1: B005 Using `.strip()` with multi-character strings is misleading the reader + | + 8 | s.lstrip(s) # no warning + 9 | s.lstrip("we") # no warning +10 | s.lstrip(".facebook.com") # warning + | ^^^^^^^^^^^^^^^^^^^^^^^^^ B005 +11 | s.lstrip("e") # no warning +12 | s.lstrip("\n\t ") # no warning + | + +B005.py:13:1: B005 Using `.strip()` with multi-character strings is misleading the reader + | +11 | s.lstrip("e") # no warning +12 | s.lstrip("\n\t ") # no warning +13 | s.lstrip(r"\n\t ") # warning + | ^^^^^^^^^^^^^^^^^^ B005 +14 | s.rstrip(s) # no warning +15 | s.rstrip("we") # warning + | + +B005.py:16:1: B005 Using `.strip()` with multi-character strings is misleading the reader + | +14 | s.rstrip(s) # no warning +15 | s.rstrip("we") # warning +16 | s.rstrip(".facebook.com") # warning + | ^^^^^^^^^^^^^^^^^^^^^^^^^ B005 +17 | s.rstrip("e") # no warning +18 | s.rstrip("\n\t ") # no warning + | + +B005.py:19:1: B005 Using `.strip()` with multi-character strings is misleading the reader + | +17 | s.rstrip("e") # no warning +18 | s.rstrip("\n\t ") # no warning +19 | s.rstrip(r"\n\t ") # warning + | ^^^^^^^^^^^^^^^^^^ B005 +20 | s.strip("a") # no warning +21 | s.strip("あ") # no warning + | + +B005.py:22:1: B005 Using `.strip()` with multi-character strings is misleading the reader + | +20 | s.strip("a") # no warning +21 | s.strip("あ") # no warning +22 | s.strip("ああ") # warning + | ^^^^^^^^^^^^^^^ B005 +23 | s.strip("\ufeff") # no warning +24 | s.strip("\u0074\u0065\u0073\u0074") # warning + | + +B005.py:24:1: B005 Using `.strip()` with multi-character strings is misleading the reader + | +22 | s.strip("ああ") # warning +23 | s.strip("\ufeff") # no warning +24 | s.strip("\u0074\u0065\u0073\u0074") # warning + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B005 +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 new file mode 100644 index 0000000000..5bf88bfe61 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_1.py.snap @@ -0,0 +1,26 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B006_1.py:3:22: B006 [*] Do not use mutable data structures for argument defaults + | +1 | # Docstring followed by a newline +2 | +3 | def foobar(foor, bar={}): + | ^^ B006 +4 | """ +5 | """ + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +1 1 | # Docstring followed by a newline +2 2 | +3 |-def foobar(foor, bar={}): + 3 |+def foobar(foor, bar=None): +4 4 | """ +5 5 | """ + 6 |+ + 7 |+ if bar is None: + 8 |+ bar = {} + + 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 new file mode 100644 index 0000000000..5cf776a598 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_2.py.snap @@ -0,0 +1,27 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +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 | +4 | def foobar(foor, bar={}): + | ^^ B006 +5 | """ +6 | """ + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +1 1 | # Docstring followed by whitespace with no newline +2 2 | # Regression test for https://github.com/astral-sh/ruff/issues/7155 +3 3 | +4 |-def foobar(foor, bar={}): + 4 |+def foobar(foor, bar=None): +5 5 | """ +6 |- """ + 6 |+ """ + 7 |+ if bar is None: + 8 |+ bar = {} + + diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_3.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_3.py.snap new file mode 100644 index 0000000000..aed13094fb --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_3.py.snap @@ -0,0 +1,25 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B006_3.py:4:22: B006 [*] Do not use mutable data structures for argument defaults + | +4 | def foobar(foor, bar={}): + | ^^ B006 +5 | """ +6 | """ + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +1 1 | # Docstring with no newline +2 2 | +3 3 | +4 |-def foobar(foor, bar={}): + 4 |+def foobar(foor, bar=None): + 5 |+ """ +5 6 | """ +6 |- """ + 7 |+ if bar is None: + 8 |+ bar = {} + + diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_4.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_4.py.snap new file mode 100644 index 0000000000..d145208706 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_4.py.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B006_4.py:7:26: B006 [*] Do not use mutable data structures for argument defaults + | +6 | class FormFeedIndent: +7 | def __init__(self, a=[]): + | ^^ B006 +8 | print(a) + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +4 4 | +5 5 | +6 6 | class FormFeedIndent: +7 |- def __init__(self, a=[]): + 7 |+ def __init__(self, a=None): + 8 |+ if a is None: + 9 |+ a = [] +8 10 | print(a) +9 11 | + + 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 new file mode 100644 index 0000000000..8272eb6aa6 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B006_B006_B008.py.snap @@ -0,0 +1,498 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B006_B008.py:63:25: B006 [*] Do not use mutable data structures for argument defaults + | +63 | def this_is_wrong(value=[1, 2, 3]): + | ^^^^^^^^^ B006 +64 | ... + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +60 60 | # Flag mutable literals/comprehensions +61 61 | +62 62 | +63 |-def this_is_wrong(value=[1, 2, 3]): + 63 |+def this_is_wrong(value=None): + 64 |+ if value is None: + 65 |+ value = [1, 2, 3] +64 66 | ... +65 67 | +66 68 | + +B006_B008.py:67:30: B006 [*] Do not use mutable data structures for argument defaults + | +67 | def this_is_also_wrong(value={}): + | ^^ B006 +68 | ... + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +64 64 | ... +65 65 | +66 66 | +67 |-def this_is_also_wrong(value={}): + 67 |+def this_is_also_wrong(value=None): + 68 |+ if value is None: + 69 |+ value = {} +68 70 | ... +69 71 | +70 72 | + +B006_B008.py:73:52: B006 [*] Do not use mutable data structures for argument defaults + | +71 | class Foo: +72 | @staticmethod +73 | def this_is_also_wrong_and_more_indented(value={}): + | ^^ B006 +74 | pass + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +70 70 | +71 71 | class Foo: +72 72 | @staticmethod +73 |- def this_is_also_wrong_and_more_indented(value={}): + 73 |+ def this_is_also_wrong_and_more_indented(value=None): + 74 |+ if value is None: + 75 |+ value = {} +74 76 | pass +75 77 | +76 78 | + +B006_B008.py:77:31: B006 [*] Do not use mutable data structures for argument defaults + | +77 | def multiline_arg_wrong(value={ + | _______________________________^ +78 | | +79 | | }): + | |_^ B006 +80 | ... + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +74 74 | pass +75 75 | +76 76 | +77 |-def multiline_arg_wrong(value={ +78 |- +79 |-}): + 77 |+def multiline_arg_wrong(value=None): + 78 |+ if value is None: + 79 |+ value = {} +80 80 | ... +81 81 | +82 82 | def single_line_func_wrong(value = {}): ... + +B006_B008.py:82:36: B006 Do not use mutable data structures for argument defaults + | +80 | ... +81 | +82 | def single_line_func_wrong(value = {}): ... + | ^^ B006 + | + = help: Replace with `None`; initialize within function + +B006_B008.py:85:20: B006 [*] Do not use mutable data structures for argument defaults + | +85 | def and_this(value=set()): + | ^^^^^ B006 +86 | ... + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +82 82 | def single_line_func_wrong(value = {}): ... +83 83 | +84 84 | +85 |-def and_this(value=set()): + 85 |+def and_this(value=None): + 86 |+ if value is None: + 87 |+ value = set() +86 88 | ... +87 89 | +88 90 | + +B006_B008.py:89:20: B006 [*] Do not use mutable data structures for argument defaults + | +89 | def this_too(value=collections.OrderedDict()): + | ^^^^^^^^^^^^^^^^^^^^^^^^^ B006 +90 | ... + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +86 86 | ... +87 87 | +88 88 | +89 |-def this_too(value=collections.OrderedDict()): + 89 |+def this_too(value=None): + 90 |+ if value is None: + 91 |+ value = collections.OrderedDict() +90 92 | ... +91 93 | +92 94 | + +B006_B008.py:93:32: B006 [*] Do not use mutable data structures for argument defaults + | +93 | async def async_this_too(value=collections.defaultdict()): + | ^^^^^^^^^^^^^^^^^^^^^^^^^ B006 +94 | ... + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +90 90 | ... +91 91 | +92 92 | +93 |-async def async_this_too(value=collections.defaultdict()): + 93 |+async def async_this_too(value=None): + 94 |+ if value is None: + 95 |+ value = collections.defaultdict() +94 96 | ... +95 97 | +96 98 | + +B006_B008.py:97:26: B006 [*] Do not use mutable data structures for argument defaults + | +97 | def dont_forget_me(value=collections.deque()): + | ^^^^^^^^^^^^^^^^^^^ B006 +98 | ... + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +94 94 | ... +95 95 | +96 96 | +97 |-def dont_forget_me(value=collections.deque()): + 97 |+def dont_forget_me(value=None): + 98 |+ if value is None: + 99 |+ value = collections.deque() +98 100 | ... +99 101 | +100 102 | + +B006_B008.py:102:46: B006 [*] Do not use mutable data structures for argument defaults + | +101 | # N.B. we're also flagging the function call in the comprehension +102 | def list_comprehension_also_not_okay(default=[i**2 for i in range(3)]): + | ^^^^^^^^^^^^^^^^^^^^^^^^ B006 +103 | pass + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +99 99 | +100 100 | +101 101 | # N.B. we're also flagging the function call in the comprehension +102 |-def list_comprehension_also_not_okay(default=[i**2 for i in range(3)]): + 102 |+def list_comprehension_also_not_okay(default=None): + 103 |+ if default is None: + 104 |+ default = [i ** 2 for i in range(3)] +103 105 | pass +104 106 | +105 107 | + +B006_B008.py:106:46: B006 [*] Do not use mutable data structures for argument defaults + | +106 | def dict_comprehension_also_not_okay(default={i: i**2 for i in range(3)}): + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B006 +107 | pass + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +103 103 | pass +104 104 | +105 105 | +106 |-def dict_comprehension_also_not_okay(default={i: i**2 for i in range(3)}): + 106 |+def dict_comprehension_also_not_okay(default=None): + 107 |+ if default is None: + 108 |+ default = {i: i ** 2 for i in range(3)} +107 109 | pass +108 110 | +109 111 | + +B006_B008.py:110:45: B006 [*] Do not use mutable data structures for argument defaults + | +110 | def set_comprehension_also_not_okay(default={i**2 for i in range(3)}): + | ^^^^^^^^^^^^^^^^^^^^^^^^ B006 +111 | pass + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +107 107 | pass +108 108 | +109 109 | +110 |-def set_comprehension_also_not_okay(default={i**2 for i in range(3)}): + 110 |+def set_comprehension_also_not_okay(default=None): + 111 |+ if default is None: + 112 |+ default = {i ** 2 for i in range(3)} +111 113 | pass +112 114 | +113 115 | + +B006_B008.py:114:33: B006 [*] Do not use mutable data structures for argument defaults + | +114 | def kwonlyargs_mutable(*, value=[]): + | ^^ B006 +115 | ... + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +111 111 | pass +112 112 | +113 113 | +114 |-def kwonlyargs_mutable(*, value=[]): + 114 |+def kwonlyargs_mutable(*, value=None): + 115 |+ if value is None: + 116 |+ value = [] +115 117 | ... +116 118 | +117 119 | + +B006_B008.py:239:20: B006 [*] Do not use mutable data structures for argument defaults + | +237 | # B006 and B008 +238 | # We should handle arbitrary nesting of these B008. +239 | def nested_combo(a=[float(3), dt.datetime.now()]): + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B006 +240 | pass + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +236 236 | +237 237 | # B006 and B008 +238 238 | # We should handle arbitrary nesting of these B008. +239 |-def nested_combo(a=[float(3), dt.datetime.now()]): + 239 |+def nested_combo(a=None): + 240 |+ if a is None: + 241 |+ a = [float(3), dt.datetime.now()] +240 242 | pass +241 243 | +242 244 | + +B006_B008.py:276:27: B006 [*] Do not use mutable data structures for argument defaults + | +275 | def mutable_annotations( +276 | a: list[int] | None = [], + | ^^ B006 +277 | b: Optional[Dict[int, int]] = {}, +278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +273 273 | +274 274 | +275 275 | def mutable_annotations( +276 |- a: list[int] | None = [], + 276 |+ a: list[int] | None = None, +277 277 | b: Optional[Dict[int, int]] = {}, +278 278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), +279 279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), +280 280 | ): + 281 |+ if a is None: + 282 |+ a = [] +281 283 | pass +282 284 | +283 285 | + +B006_B008.py:277:35: B006 [*] Do not use mutable data structures for argument defaults + | +275 | def mutable_annotations( +276 | a: list[int] | None = [], +277 | b: Optional[Dict[int, int]] = {}, + | ^^ B006 +278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), +279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +274 274 | +275 275 | def mutable_annotations( +276 276 | a: list[int] | None = [], +277 |- b: Optional[Dict[int, int]] = {}, + 277 |+ b: Optional[Dict[int, int]] = None, +278 278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), +279 279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), +280 280 | ): + 281 |+ if b is None: + 282 |+ b = {} +281 283 | pass +282 284 | +283 285 | + +B006_B008.py:278:62: B006 [*] Do not use mutable data structures for argument defaults + | +276 | a: list[int] | None = [], +277 | b: Optional[Dict[int, int]] = {}, +278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), + | ^^^^^ B006 +279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), +280 | ): + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +275 275 | def mutable_annotations( +276 276 | a: list[int] | None = [], +277 277 | b: Optional[Dict[int, int]] = {}, +278 |- c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), + 278 |+ c: Annotated[Union[Set[str], abc.Sized], "annotation"] = None, +279 279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), +280 280 | ): + 281 |+ if c is None: + 282 |+ c = set() +281 283 | pass +282 284 | +283 285 | + +B006_B008.py:279:80: B006 [*] Do not use mutable data structures for argument defaults + | +277 | b: Optional[Dict[int, int]] = {}, +278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), +279 | d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), + | ^^^^^ B006 +280 | ): +281 | pass + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +276 276 | a: list[int] | None = [], +277 277 | b: Optional[Dict[int, int]] = {}, +278 278 | c: Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), +279 |- d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = set(), + 279 |+ d: typing_extensions.Annotated[Union[Set[str], abc.Sized], "annotation"] = None, +280 280 | ): + 281 |+ if d is None: + 282 |+ d = set() +281 283 | pass +282 284 | +283 285 | + +B006_B008.py:284:52: B006 [*] Do not use mutable data structures for argument defaults + | +284 | def single_line_func_wrong(value: dict[str, str] = {}): + | ^^ B006 +285 | """Docstring""" + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +281 281 | pass +282 282 | +283 283 | +284 |-def single_line_func_wrong(value: dict[str, str] = {}): + 284 |+def single_line_func_wrong(value: dict[str, str] = None): +285 285 | """Docstring""" + 286 |+ if value is None: + 287 |+ value = {} +286 288 | +287 289 | +288 290 | def single_line_func_wrong(value: dict[str, str] = {}): + +B006_B008.py:288:52: B006 [*] Do not use mutable data structures for argument defaults + | +288 | def single_line_func_wrong(value: dict[str, str] = {}): + | ^^ B006 +289 | """Docstring""" +290 | ... + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +285 285 | """Docstring""" +286 286 | +287 287 | +288 |-def single_line_func_wrong(value: dict[str, str] = {}): + 288 |+def single_line_func_wrong(value: dict[str, str] = None): +289 289 | """Docstring""" + 290 |+ if value is None: + 291 |+ value = {} +290 292 | ... +291 293 | +292 294 | + +B006_B008.py:293:52: B006 Do not use mutable data structures for argument defaults + | +293 | def single_line_func_wrong(value: dict[str, str] = {}): + | ^^ B006 +294 | """Docstring"""; ... + | + = help: Replace with `None`; initialize within function + +B006_B008.py:297:52: B006 Do not use mutable data structures for argument defaults + | +297 | def single_line_func_wrong(value: dict[str, str] = {}): + | ^^ B006 +298 | """Docstring"""; \ +299 | ... + | + = help: Replace with `None`; initialize within function + +B006_B008.py:302:52: B006 [*] Do not use mutable data structures for argument defaults + | +302 | def single_line_func_wrong(value: dict[str, str] = { + | ____________________________________________________^ +303 | | # This is a comment +304 | | }): + | |_^ B006 +305 | """Docstring""" + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +299 299 | ... +300 300 | +301 301 | +302 |-def single_line_func_wrong(value: dict[str, str] = { +303 |- # This is a comment +304 |-}): + 302 |+def single_line_func_wrong(value: dict[str, str] = None): +305 303 | """Docstring""" + 304 |+ if value is None: + 305 |+ value = {} +306 306 | +307 307 | +308 308 | def single_line_func_wrong(value: dict[str, str] = {}) \ + +B006_B008.py:308:52: B006 Do not use mutable data structures for argument defaults + | +308 | def single_line_func_wrong(value: dict[str, str] = {}) \ + | ^^ B006 +309 | : \ +310 | """Docstring""" + | + = help: Replace with `None`; initialize within function + +B006_B008.py:313:52: B006 [*] Do not use mutable data structures for argument defaults + | +313 | def single_line_func_wrong(value: dict[str, str] = {}): + | ^^ B006 +314 | """Docstring without newline""" + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +310 310 | """Docstring""" +311 311 | +312 312 | +313 |-def single_line_func_wrong(value: dict[str, str] = {}): +314 |- """Docstring without newline""" + 313 |+def single_line_func_wrong(value: dict[str, str] = None): + 314 |+ """Docstring without newline""" + 315 |+ if value is None: + 316 |+ value = {} + + 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 new file mode 100644 index 0000000000..283f28ee82 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B007_B007.py.snap @@ -0,0 +1,186 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +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 | +6 | for i in range(10): # name not used within the loop; B007 + | ^ B007 +7 | print(10) + | + = help: Rename unused `i` to `_i` + +B007.py:18:13: B007 [*] Loop control variable `k` not used within loop body + | +16 | for i in range(10): +17 | for j in range(10): +18 | for k in range(10): # k not used, i and j used transitively + | ^ B007 +19 | print(i + j) + | + = help: Rename unused `k` to `_k` + +ℹ Suggested fix +15 15 | +16 16 | for i in range(10): +17 17 | for j in range(10): +18 |- for k in range(10): # k not used, i and j used transitively + 18 |+ for _k in range(10): # k not used, i and j used transitively +19 19 | print(i + j) +20 20 | +21 21 | + +B007.py:30:5: B007 Loop control variable `i` not used within loop body + | +30 | for i, (j, (k, l)) in strange_generator(): # i, k not used + | ^ B007 +31 | print(j, l) + | + = help: Rename unused `i` to `_i` + +B007.py:30:13: B007 [*] Loop control variable `k` not used within loop body + | +30 | for i, (j, (k, l)) in strange_generator(): # i, k not used + | ^ B007 +31 | print(j, l) + | + = help: Rename unused `k` to `_k` + +ℹ Suggested fix +27 27 | yield i, (j, (k, l)) +28 28 | +29 29 | +30 |-for i, (j, (k, l)) in strange_generator(): # i, k not used + 30 |+for i, (j, (_k, l)) in strange_generator(): # i, k not used +31 31 | print(j, l) +32 32 | +33 33 | FMT = "{foo} {bar}" + +B007.py:34:10: B007 Loop control variable `bar` may not be used within loop body + | +33 | FMT = "{foo} {bar}" +34 | for foo, bar in [(1, 2)]: + | ^^^ B007 +35 | if foo: +36 | print(FMT.format(**locals())) + | + = help: Rename unused `bar` to `_bar` + +B007.py:38:10: B007 Loop control variable `bar` may not be used within loop body + | +36 | print(FMT.format(**locals())) +37 | +38 | for foo, bar in [(1, 2)]: + | ^^^ B007 +39 | if foo: +40 | print(FMT.format(**globals())) + | + = help: Rename unused `bar` to `_bar` + +B007.py:42:10: B007 Loop control variable `bar` may not be used within loop body + | +40 | print(FMT.format(**globals())) +41 | +42 | for foo, bar in [(1, 2)]: + | ^^^ B007 +43 | if foo: +44 | print(FMT.format(**vars())) + | + = help: Rename unused `bar` to `_bar` + +B007.py:46:10: B007 Loop control variable `bar` may not be used within loop body + | +44 | print(FMT.format(**vars())) +45 | +46 | for foo, bar in [(1, 2)]: + | ^^^ B007 +47 | print(FMT.format(foo=foo, bar=eval("bar"))) + | + = help: Rename unused `bar` to `_bar` + +B007.py:52:14: B007 [*] Loop control variable `bar` not used within loop body + | +50 | def f(): +51 | # Fixable. +52 | for foo, bar, baz in (["1", "2", "3"],): + | ^^^ B007 +53 | if foo or baz: +54 | break + | + = help: Rename unused `bar` to `_bar` + +ℹ Suggested fix +49 49 | +50 50 | def f(): +51 51 | # Fixable. +52 |- for foo, bar, baz in (["1", "2", "3"],): + 52 |+ for foo, _bar, baz in (["1", "2", "3"],): +53 53 | if foo or baz: +54 54 | break +55 55 | + +B007.py:59:14: B007 Loop control variable `bar` not used within loop body + | +57 | def f(): +58 | # Unfixable due to usage of `bar` outside of loop. +59 | for foo, bar, baz in (["1", "2", "3"],): + | ^^^ B007 +60 | if foo or baz: +61 | break + | + = help: Rename unused `bar` to `_bar` + +B007.py:68:14: B007 [*] Loop control variable `bar` not used within loop body + | +66 | def f(): +67 | # Fixable. +68 | for foo, bar, baz in (["1", "2", "3"],): + | ^^^ B007 +69 | if foo or baz: +70 | break + | + = help: Rename unused `bar` to `_bar` + +ℹ Suggested fix +65 65 | +66 66 | def f(): +67 67 | # Fixable. +68 |- for foo, bar, baz in (["1", "2", "3"],): + 68 |+ for foo, _bar, baz in (["1", "2", "3"],): +69 69 | if foo or baz: +70 70 | break +71 71 | + +B007.py:77:14: B007 Loop control variable `bar` not used within loop body + | +75 | def f(): +76 | # Unfixable. +77 | for foo, bar, baz in (["1", "2", "3"],): + | ^^^ B007 +78 | if foo or baz: +79 | break + | + = help: Rename unused `bar` to `_bar` + +B007.py:88:14: B007 Loop control variable `bar` not used within loop body + | +86 | def f(): +87 | # Unfixable (false negative) due to usage of `bar` outside of loop. +88 | for foo, bar, baz in (["1", "2", "3"],): + | ^^^ B007 +89 | if foo or baz: +90 | break + | + = help: Rename unused `bar` to `_bar` + +B007.py:98:5: B007 Loop control variable `line_` not used within loop body + | +96 | # Unfixable due to trailing underscore (`_line_` wouldn't be considered an ignorable +97 | # variable name). +98 | for line_ in range(self.header_lines): + | ^^^^^ B007 +99 | fp.readline() + | + + diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B008_B006_B008.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B008_B006_B008.py.snap new file mode 100644 index 0000000000..c45d87aa5a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B008_B006_B008.py.snap @@ -0,0 +1,83 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B006_B008.py:102:61: B008 Do not perform function call `range` in argument defaults + | +101 | # N.B. we're also flagging the function call in the comprehension +102 | def list_comprehension_also_not_okay(default=[i**2 for i in range(3)]): + | ^^^^^^^^ B008 +103 | pass + | + +B006_B008.py:106:64: B008 Do not perform function call `range` in argument defaults + | +106 | def dict_comprehension_also_not_okay(default={i: i**2 for i in range(3)}): + | ^^^^^^^^ B008 +107 | pass + | + +B006_B008.py:110:60: B008 Do not perform function call `range` in argument defaults + | +110 | def set_comprehension_also_not_okay(default={i**2 for i in range(3)}): + | ^^^^^^^^ B008 +111 | pass + | + +B006_B008.py:126:39: B008 Do not perform function call `time.time` in argument defaults + | +124 | # B008 +125 | # Flag function calls as default args (including if they are part of a sub-expression) +126 | def in_fact_all_calls_are_wrong(value=time.time()): + | ^^^^^^^^^^^ B008 +127 | ... + | + +B006_B008.py:130:12: B008 Do not perform function call `dt.datetime.now` in argument defaults + | +130 | def f(when=dt.datetime.now() + dt.timedelta(days=7)): + | ^^^^^^^^^^^^^^^^^ B008 +131 | pass + | + +B006_B008.py:134:30: B008 Do not perform function call in argument defaults + | +134 | def can_even_catch_lambdas(a=(lambda x: x)()): + | ^^^^^^^^^^^^^^^ B008 +135 | ... + | + +B006_B008.py:239:31: B008 Do not perform function call `dt.datetime.now` in argument defaults + | +237 | # B006 and B008 +238 | # We should handle arbitrary nesting of these B008. +239 | def nested_combo(a=[float(3), dt.datetime.now()]): + | ^^^^^^^^^^^^^^^^^ B008 +240 | pass + | + +B006_B008.py:245:22: B008 Do not perform function call `map` in argument defaults + | +243 | # Don't flag nested B006 since we can't guarantee that +244 | # it isn't made mutable by the outer operation. +245 | def no_nested_b006(a=map(lambda s: s.upper(), ["a", "b", "c"])): + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B008 +246 | pass + | + +B006_B008.py:250:19: B008 Do not perform function call `random.randint` in argument defaults + | +249 | # B008-ception. +250 | def nested_b008(a=random.randint(0, dt.datetime.now().year)): + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B008 +251 | pass + | + +B006_B008.py:250:37: B008 Do not perform function call `dt.datetime.now` in argument defaults + | +249 | # B008-ception. +250 | def nested_b008(a=random.randint(0, dt.datetime.now().year)): + | ^^^^^^^^^^^^^^^^^ B008 +251 | pass + | + + 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 new file mode 100644 index 0000000000..a88d7061b3 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B009_B009_B010.py.snap @@ -0,0 +1,334 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B009_B010.py:19:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +18 | # Invalid usage +19 | getattr(foo, "bar") + | ^^^^^^^^^^^^^^^^^^^ B009 +20 | getattr(foo, "_123abc") +21 | getattr(foo, "__123abc__") + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +16 16 | getattr(foo, "__123abc") +17 17 | +18 18 | # Invalid usage +19 |-getattr(foo, "bar") + 19 |+foo.bar +20 20 | getattr(foo, "_123abc") +21 21 | getattr(foo, "__123abc__") +22 22 | getattr(foo, "abc123") + +B009_B010.py:20:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +18 | # Invalid usage +19 | getattr(foo, "bar") +20 | getattr(foo, "_123abc") + | ^^^^^^^^^^^^^^^^^^^^^^^ B009 +21 | getattr(foo, "__123abc__") +22 | getattr(foo, "abc123") + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +17 17 | +18 18 | # Invalid usage +19 19 | getattr(foo, "bar") +20 |-getattr(foo, "_123abc") + 20 |+foo._123abc +21 21 | getattr(foo, "__123abc__") +22 22 | getattr(foo, "abc123") +23 23 | getattr(foo, r"abc123") + +B009_B010.py:21:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +19 | getattr(foo, "bar") +20 | getattr(foo, "_123abc") +21 | getattr(foo, "__123abc__") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ B009 +22 | getattr(foo, "abc123") +23 | getattr(foo, r"abc123") + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +18 18 | # Invalid usage +19 19 | getattr(foo, "bar") +20 20 | getattr(foo, "_123abc") +21 |-getattr(foo, "__123abc__") + 21 |+foo.__123abc__ +22 22 | getattr(foo, "abc123") +23 23 | getattr(foo, r"abc123") +24 24 | _ = lambda x: getattr(x, "bar") + +B009_B010.py:22:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +20 | getattr(foo, "_123abc") +21 | getattr(foo, "__123abc__") +22 | getattr(foo, "abc123") + | ^^^^^^^^^^^^^^^^^^^^^^ B009 +23 | getattr(foo, r"abc123") +24 | _ = lambda x: getattr(x, "bar") + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +19 19 | getattr(foo, "bar") +20 20 | getattr(foo, "_123abc") +21 21 | getattr(foo, "__123abc__") +22 |-getattr(foo, "abc123") + 22 |+foo.abc123 +23 23 | getattr(foo, r"abc123") +24 24 | _ = lambda x: getattr(x, "bar") +25 25 | if getattr(x, "bar"): + +B009_B010.py:23:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +21 | getattr(foo, "__123abc__") +22 | getattr(foo, "abc123") +23 | getattr(foo, r"abc123") + | ^^^^^^^^^^^^^^^^^^^^^^^ B009 +24 | _ = lambda x: getattr(x, "bar") +25 | if getattr(x, "bar"): + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +20 20 | getattr(foo, "_123abc") +21 21 | getattr(foo, "__123abc__") +22 22 | getattr(foo, "abc123") +23 |-getattr(foo, r"abc123") + 23 |+foo.abc123 +24 24 | _ = lambda x: getattr(x, "bar") +25 25 | if getattr(x, "bar"): +26 26 | pass + +B009_B010.py:24:15: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +22 | getattr(foo, "abc123") +23 | getattr(foo, r"abc123") +24 | _ = lambda x: getattr(x, "bar") + | ^^^^^^^^^^^^^^^^^ B009 +25 | if getattr(x, "bar"): +26 | pass + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +21 21 | getattr(foo, "__123abc__") +22 22 | getattr(foo, "abc123") +23 23 | getattr(foo, r"abc123") +24 |-_ = lambda x: getattr(x, "bar") + 24 |+_ = lambda x: x.bar +25 25 | if getattr(x, "bar"): +26 26 | pass +27 27 | getattr(1, "real") + +B009_B010.py:25:4: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +23 | getattr(foo, r"abc123") +24 | _ = lambda x: getattr(x, "bar") +25 | if getattr(x, "bar"): + | ^^^^^^^^^^^^^^^^^ B009 +26 | pass +27 | getattr(1, "real") + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +22 22 | getattr(foo, "abc123") +23 23 | getattr(foo, r"abc123") +24 24 | _ = lambda x: getattr(x, "bar") +25 |-if getattr(x, "bar"): + 25 |+if x.bar: +26 26 | pass +27 27 | getattr(1, "real") +28 28 | getattr(1., "real") + +B009_B010.py:27:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +25 | if getattr(x, "bar"): +26 | pass +27 | getattr(1, "real") + | ^^^^^^^^^^^^^^^^^^ B009 +28 | getattr(1., "real") +29 | getattr(1.0, "real") + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +24 24 | _ = lambda x: getattr(x, "bar") +25 25 | if getattr(x, "bar"): +26 26 | pass +27 |-getattr(1, "real") + 27 |+(1).real +28 28 | getattr(1., "real") +29 29 | getattr(1.0, "real") +30 30 | getattr(1j, "real") + +B009_B010.py:28:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +26 | pass +27 | getattr(1, "real") +28 | getattr(1., "real") + | ^^^^^^^^^^^^^^^^^^^ B009 +29 | getattr(1.0, "real") +30 | getattr(1j, "real") + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +25 25 | if getattr(x, "bar"): +26 26 | pass +27 27 | getattr(1, "real") +28 |-getattr(1., "real") + 28 |+(1.).real +29 29 | getattr(1.0, "real") +30 30 | getattr(1j, "real") +31 31 | getattr(True, "real") + +B009_B010.py:29:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +27 | getattr(1, "real") +28 | getattr(1., "real") +29 | getattr(1.0, "real") + | ^^^^^^^^^^^^^^^^^^^^ B009 +30 | getattr(1j, "real") +31 | getattr(True, "real") + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +26 26 | pass +27 27 | getattr(1, "real") +28 28 | getattr(1., "real") +29 |-getattr(1.0, "real") + 29 |+(1.0).real +30 30 | getattr(1j, "real") +31 31 | getattr(True, "real") +32 32 | getattr(x := 1, "real") + +B009_B010.py:30:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +28 | getattr(1., "real") +29 | getattr(1.0, "real") +30 | getattr(1j, "real") + | ^^^^^^^^^^^^^^^^^^^ B009 +31 | getattr(True, "real") +32 | getattr(x := 1, "real") + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +27 27 | getattr(1, "real") +28 28 | getattr(1., "real") +29 29 | getattr(1.0, "real") +30 |-getattr(1j, "real") + 30 |+(1j).real +31 31 | getattr(True, "real") +32 32 | getattr(x := 1, "real") +33 33 | getattr(x + y, "real") + +B009_B010.py:31:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +29 | getattr(1.0, "real") +30 | getattr(1j, "real") +31 | getattr(True, "real") + | ^^^^^^^^^^^^^^^^^^^^^ B009 +32 | getattr(x := 1, "real") +33 | getattr(x + y, "real") + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +28 28 | getattr(1., "real") +29 29 | getattr(1.0, "real") +30 30 | getattr(1j, "real") +31 |-getattr(True, "real") + 31 |+(True).real +32 32 | getattr(x := 1, "real") +33 33 | getattr(x + y, "real") +34 34 | getattr("foo" + +B009_B010.py:32:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +30 | getattr(1j, "real") +31 | getattr(True, "real") +32 | getattr(x := 1, "real") + | ^^^^^^^^^^^^^^^^^^^^^^^ B009 +33 | getattr(x + y, "real") +34 | getattr("foo" + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +29 29 | getattr(1.0, "real") +30 30 | getattr(1j, "real") +31 31 | getattr(True, "real") +32 |-getattr(x := 1, "real") + 32 |+(x := 1).real +33 33 | getattr(x + y, "real") +34 34 | getattr("foo" +35 35 | "bar", "real") + +B009_B010.py:33:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +31 | getattr(True, "real") +32 | getattr(x := 1, "real") +33 | getattr(x + y, "real") + | ^^^^^^^^^^^^^^^^^^^^^^ B009 +34 | getattr("foo" +35 | "bar", "real") + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +30 30 | getattr(1j, "real") +31 31 | getattr(True, "real") +32 32 | getattr(x := 1, "real") +33 |-getattr(x + y, "real") + 33 |+(x + y).real +34 34 | getattr("foo" +35 35 | "bar", "real") +36 36 | + +B009_B010.py:34:1: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +32 | getattr(x := 1, "real") +33 | getattr(x + y, "real") +34 | / getattr("foo" +35 | | "bar", "real") + | |______________________^ B009 + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +31 31 | getattr(True, "real") +32 32 | getattr(x := 1, "real") +33 33 | getattr(x + y, "real") +34 |-getattr("foo" +35 |- "bar", "real") + 34 |+("foo" + 35 |+ "bar").real +36 36 | +37 37 | +38 38 | # Valid setattr usage + +B009_B010.py:58:8: B009 [*] Do not call `getattr` with a constant attribute value. It is not any safer than normal property access. + | +57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458885 +58 | assert getattr(func, '_rpc')is True + | ^^^^^^^^^^^^^^^^^^^^^ B009 + | + = help: Replace `getattr` with attribute access + +ℹ Suggested fix +55 55 | setattr(foo.bar, r"baz", None) +56 56 | +57 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458885 +58 |-assert getattr(func, '_rpc')is True + 58 |+assert func._rpc is True + + 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 new file mode 100644 index 0000000000..2945aafb43 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B010_B009_B010.py.snap @@ -0,0 +1,128 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B009_B010.py:50:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. + | +49 | # Invalid usage +50 | setattr(foo, "bar", None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ B010 +51 | setattr(foo, "_123abc", None) +52 | setattr(foo, "__123abc__", None) + | + = help: Replace `setattr` with assignment + +ℹ Suggested fix +47 47 | pass +48 48 | +49 49 | # Invalid usage +50 |-setattr(foo, "bar", None) + 50 |+foo.bar = None +51 51 | setattr(foo, "_123abc", None) +52 52 | setattr(foo, "__123abc__", None) +53 53 | setattr(foo, "abc123", None) + +B009_B010.py:51:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. + | +49 | # Invalid usage +50 | setattr(foo, "bar", None) +51 | setattr(foo, "_123abc", None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 +52 | setattr(foo, "__123abc__", None) +53 | setattr(foo, "abc123", None) + | + = help: Replace `setattr` with assignment + +ℹ Suggested fix +48 48 | +49 49 | # Invalid usage +50 50 | setattr(foo, "bar", None) +51 |-setattr(foo, "_123abc", None) + 51 |+foo._123abc = None +52 52 | setattr(foo, "__123abc__", None) +53 53 | setattr(foo, "abc123", None) +54 54 | setattr(foo, r"abc123", None) + +B009_B010.py:52:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. + | +50 | setattr(foo, "bar", None) +51 | setattr(foo, "_123abc", None) +52 | setattr(foo, "__123abc__", None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 +53 | setattr(foo, "abc123", None) +54 | setattr(foo, r"abc123", None) + | + = help: Replace `setattr` with assignment + +ℹ Suggested fix +49 49 | # Invalid usage +50 50 | setattr(foo, "bar", None) +51 51 | setattr(foo, "_123abc", None) +52 |-setattr(foo, "__123abc__", None) + 52 |+foo.__123abc__ = None +53 53 | setattr(foo, "abc123", None) +54 54 | setattr(foo, r"abc123", None) +55 55 | setattr(foo.bar, r"baz", None) + +B009_B010.py:53:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. + | +51 | setattr(foo, "_123abc", None) +52 | setattr(foo, "__123abc__", None) +53 | setattr(foo, "abc123", None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 +54 | setattr(foo, r"abc123", None) +55 | setattr(foo.bar, r"baz", None) + | + = help: Replace `setattr` with assignment + +ℹ Suggested fix +50 50 | setattr(foo, "bar", None) +51 51 | setattr(foo, "_123abc", None) +52 52 | setattr(foo, "__123abc__", None) +53 |-setattr(foo, "abc123", None) + 53 |+foo.abc123 = None +54 54 | setattr(foo, r"abc123", None) +55 55 | setattr(foo.bar, r"baz", None) +56 56 | + +B009_B010.py:54:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. + | +52 | setattr(foo, "__123abc__", None) +53 | setattr(foo, "abc123", None) +54 | setattr(foo, r"abc123", None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 +55 | setattr(foo.bar, r"baz", None) + | + = help: Replace `setattr` with assignment + +ℹ Suggested fix +51 51 | setattr(foo, "_123abc", None) +52 52 | setattr(foo, "__123abc__", None) +53 53 | setattr(foo, "abc123", None) +54 |-setattr(foo, r"abc123", None) + 54 |+foo.abc123 = None +55 55 | setattr(foo.bar, r"baz", None) +56 56 | +57 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458885 + +B009_B010.py:55:1: B010 [*] Do not call `setattr` with a constant attribute value. It is not any safer than normal property access. + | +53 | setattr(foo, "abc123", None) +54 | setattr(foo, r"abc123", None) +55 | setattr(foo.bar, r"baz", None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B010 +56 | +57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458885 + | + = help: Replace `setattr` with assignment + +ℹ Suggested fix +52 52 | setattr(foo, "__123abc__", None) +53 53 | setattr(foo, "abc123", None) +54 54 | setattr(foo, r"abc123", None) +55 |-setattr(foo.bar, r"baz", None) + 55 |+foo.bar.baz = None +56 56 | +57 57 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458885 +58 58 | assert getattr(func, '_rpc')is True + + diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B011_B011.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B011_B011.py.snap new file mode 100644 index 0000000000..5415cf1eae --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B011_B011.py.snap @@ -0,0 +1,39 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B011.py:8:8: B011 [*] Do not `assert False` (`python -O` removes these calls), raise `AssertionError()` + | + 7 | assert 1 != 2 + 8 | assert False + | ^^^^^ B011 + 9 | assert 1 != 2, "message" +10 | assert False, "message" + | + = help: Replace `assert False` + +ℹ Suggested fix +5 5 | """ +6 6 | +7 7 | assert 1 != 2 +8 |-assert False + 8 |+raise AssertionError() +9 9 | assert 1 != 2, "message" +10 10 | assert False, "message" + +B011.py:10:8: B011 [*] Do not `assert False` (`python -O` removes these calls), raise `AssertionError()` + | + 8 | assert False + 9 | assert 1 != 2, "message" +10 | assert False, "message" + | ^^^^^ B011 + | + = help: Replace `assert False` + +ℹ Suggested fix +7 7 | assert 1 != 2 +8 8 | assert False +9 9 | assert 1 != 2, "message" +10 |-assert False, "message" + 10 |+raise AssertionError("message") + + 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 new file mode 100644 index 0000000000..bba51ea123 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B012_B012.py.snap @@ -0,0 +1,104 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B012.py:5:9: B012 `return` inside `finally` blocks cause exceptions to be silenced + | +3 | pass +4 | finally: +5 | return # warning + | ^^^^^^ B012 + | + +B012.py:13:13: B012 `return` inside `finally` blocks cause exceptions to be silenced + | +11 | finally: +12 | if 1 + 0 == 2 - 1: +13 | return # warning + | ^^^^^^ B012 + | + +B012.py:21:13: B012 `return` inside `finally` blocks cause exceptions to be silenced + | +19 | finally: +20 | try: +21 | return # warning + | ^^^^^^ B012 +22 | except Exception: +23 | pass + | + +B012.py:31:13: B012 `return` inside `finally` blocks cause exceptions to be silenced + | +29 | pass +30 | finally: +31 | return # warning + | ^^^^^^ B012 +32 | finally: +33 | pass + | + +B012.py:44:21: B012 `return` inside `finally` blocks cause exceptions to be silenced + | +42 | pass +43 | finally: +44 | return # warning + | ^^^^^^ B012 +45 | +46 | finally: + | + +B012.py:66:13: B012 `break` inside `finally` blocks cause exceptions to be silenced + | +64 | pass +65 | finally: +66 | break # warning + | ^^^^^ B012 +67 | +68 | def j(): + | + +B012.py:78:13: B012 `continue` inside `finally` blocks cause exceptions to be silenced + | +76 | pass +77 | finally: +78 | continue # warning + | ^^^^^^^^ B012 +79 | +80 | def j(): + | + +B012.py:94:13: B012 `return` inside `finally` blocks cause exceptions to be silenced + | +92 | continue # no warning +93 | while True: +94 | return # warning + | ^^^^^^ B012 + | + +B012.py:101:9: B012 `continue` inside `finally` blocks cause exceptions to be silenced + | + 99 | pass +100 | finally: +101 | continue # warning + | ^^^^^^^^ B012 +102 | +103 | while True: + | + +B012.py:107:9: B012 `break` inside `finally` blocks cause exceptions to be silenced + | +105 | pass +106 | finally: +107 | break # warning + | ^^^^^ B012 + | + +B012.py:118:17: B012 `break` inside `finally` blocks cause exceptions to be silenced + | +116 | y = 0 +117 | case 0, *x: +118 | break # warning + | ^^^^^ B012 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B013_B013.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B013_B013.py.snap new file mode 100644 index 0000000000..3cbb27b7aa --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B013_B013.py.snap @@ -0,0 +1,64 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B013.py:5:8: B013 [*] A length-one tuple literal is redundant in exception handlers + | +3 | try: +4 | pass +5 | except (ValueError,): + | ^^^^^^^^^^^^^ B013 +6 | pass +7 | except AttributeError: + | + = help: Replace with `except ValueError` + +ℹ Fix +2 2 | +3 3 | try: +4 4 | pass +5 |-except (ValueError,): + 5 |+except ValueError: +6 6 | pass +7 7 | except AttributeError: +8 8 | pass + +B013.py:11:8: B013 [*] A length-one tuple literal is redundant in exception handlers + | + 9 | except (ImportError, TypeError): +10 | pass +11 | except (*retriable_exceptions,): + | ^^^^^^^^^^^^^^^^^^^^^^^^ B013 +12 | pass +13 | except(ValueError,): + | + = help: Replace with `except retriable_exceptions` + +ℹ Fix +8 8 | pass +9 9 | except (ImportError, TypeError): +10 10 | pass +11 |-except (*retriable_exceptions,): + 11 |+except retriable_exceptions: +12 12 | pass +13 13 | except(ValueError,): +14 14 | pass + +B013.py:13:7: B013 [*] A length-one tuple literal is redundant in exception handlers + | +11 | except (*retriable_exceptions,): +12 | pass +13 | except(ValueError,): + | ^^^^^^^^^^^^^ B013 +14 | pass + | + = help: Replace with `except ValueError` + +ℹ Fix +10 10 | pass +11 11 | except (*retriable_exceptions,): +12 12 | pass +13 |-except(ValueError,): + 13 |+except ValueError: +14 14 | pass + + diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B014_B014.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B014_B014.py.snap new file mode 100644 index 0000000000..87ececd961 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B014_B014.py.snap @@ -0,0 +1,85 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B014.py:17:8: B014 [*] Exception handler with duplicate exception: `OSError` + | +15 | try: +16 | pass +17 | except (OSError, OSError) as err: + | ^^^^^^^^^^^^^^^^^^ B014 +18 | # Duplicate exception types are useless +19 | pass + | + = help: De-duplicate exceptions + +ℹ Fix +14 14 | +15 15 | try: +16 16 | pass +17 |-except (OSError, OSError) as err: + 17 |+except OSError as err: +18 18 | # Duplicate exception types are useless +19 19 | pass +20 20 | + +B014.py:28:8: B014 [*] Exception handler with duplicate exception: `MyError` + | +26 | try: +27 | pass +28 | except (MyError, MyError): + | ^^^^^^^^^^^^^^^^^^ B014 +29 | # Detect duplicate non-builtin errors +30 | pass + | + = help: De-duplicate exceptions + +ℹ Fix +25 25 | +26 26 | try: +27 27 | pass +28 |-except (MyError, MyError): + 28 |+except MyError: +29 29 | # Detect duplicate non-builtin errors +30 30 | pass +31 31 | + +B014.py:49:8: B014 [*] Exception handler with duplicate exception: `re.error` + | +47 | try: +48 | pass +49 | except (re.error, re.error): + | ^^^^^^^^^^^^^^^^^^^^ B014 +50 | # Duplicate exception types as attributes +51 | pass + | + = help: De-duplicate exceptions + +ℹ Fix +46 46 | +47 47 | try: +48 48 | pass +49 |-except (re.error, re.error): + 49 |+except re.error: +50 50 | # Duplicate exception types as attributes +51 51 | pass +52 52 | + +B014.py:82:8: B014 [*] Exception handler with duplicate exception: `ValueError` + | +80 | try: +81 | pass +82 | except (ValueError, ValueError, TypeError): + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B014 +83 | pass + | + = help: De-duplicate exceptions + +ℹ Fix +79 79 | # https://github.com/astral-sh/ruff/issues/6412 +80 80 | try: +81 81 | pass +82 |-except (ValueError, ValueError, TypeError): + 82 |+except (ValueError, TypeError): +83 83 | pass + + 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 new file mode 100644 index 0000000000..46702e5a58 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B015_B015.py.snap @@ -0,0 +1,37 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B015.py:3:1: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + | +1 | assert 1 == 1 +2 | +3 | 1 == 1 + | ^^^^^^ B015 +4 | +5 | assert 1 in (1, 2) + | + +B015.py:7:1: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + | +5 | assert 1 in (1, 2) +6 | +7 | 1 in (1, 2) + | ^^^^^^^^^^^ B015 + | + +B015.py:17:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + | +15 | assert 1 in (1, 2) +16 | +17 | 1 in (1, 2) + | ^^^^^^^^^^^ B015 + | + +B015.py:24:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it. + | +23 | class TestClass: +24 | 1 == 1 + | ^^^^^^ 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 new file mode 100644 index 0000000000..e0183b0a65 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B016_B016.py.snap @@ -0,0 +1,33 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B016.py:6:7: B016 Cannot raise a literal. Did you intend to return it or raise an Exception? + | +4 | """ +5 | +6 | raise False + | ^^^^^ B016 +7 | raise 1 +8 | raise "string" + | + +B016.py:7:7: B016 Cannot raise a literal. Did you intend to return it or raise an Exception? + | +6 | raise False +7 | raise 1 + | ^ B016 +8 | raise "string" +9 | raise Exception(False) + | + +B016.py:8:7: B016 Cannot raise a literal. Did you intend to return it or raise an Exception? + | + 6 | raise False + 7 | raise 1 + 8 | raise "string" + | ^^^^^^^^ B016 + 9 | raise Exception(False) +10 | raise Exception(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 new file mode 100644 index 0000000000..59e2c1b579 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B017_B017.py.snap @@ -0,0 +1,38 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B017.py:23:14: B017 `assertRaises(Exception)` should be considered evil + | +21 | class Foobar(unittest.TestCase): +22 | def evil_raises(self) -> None: +23 | with self.assertRaises(Exception): + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017 +24 | raise Exception("Evil I say!") + | + +B017.py:27:14: B017 `assertRaises(BaseException)` should be considered evil + | +26 | def also_evil_raises(self) -> None: +27 | with self.assertRaises(BaseException): + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B017 +28 | raise Exception("Evil I say!") + | + +B017.py:45:10: B017 `pytest.raises(Exception)` should be considered evil + | +44 | def test_pytest_raises(): +45 | with pytest.raises(Exception): + | ^^^^^^^^^^^^^^^^^^^^^^^^ B017 +46 | raise ValueError("Hello") + | + +B017.py:48:10: B017 `pytest.raises(Exception)` should be considered evil + | +46 | raise ValueError("Hello") +47 | +48 | with pytest.raises(Exception), pytest.raises(ValueError): + | ^^^^^^^^^^^^^^^^^^^^^^^^ B017 +49 | raise ValueError("Hello") + | + + diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B018_B018.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B018_B018.py.snap new file mode 100644 index 0000000000..a3cded1d21 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B018_B018.py.snap @@ -0,0 +1,258 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B018.py:11:5: B018 Found useless expression. Either assign it to a variable or remove it. + | + 9 | "str" # Str (no raise) +10 | f"{int}" # JoinedStr (no raise) +11 | 1j # Number (complex) + | ^^ B018 +12 | 1 # Number (int) +13 | 1.0 # Number (float) + | + +B018.py:12:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +10 | f"{int}" # JoinedStr (no raise) +11 | 1j # Number (complex) +12 | 1 # Number (int) + | ^ B018 +13 | 1.0 # Number (float) +14 | b"foo" # Binary + | + +B018.py:13:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +11 | 1j # Number (complex) +12 | 1 # Number (int) +13 | 1.0 # Number (float) + | ^^^ B018 +14 | b"foo" # Binary +15 | True # NameConstant (True) + | + +B018.py:14:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +12 | 1 # Number (int) +13 | 1.0 # Number (float) +14 | b"foo" # Binary + | ^^^^^^ B018 +15 | True # NameConstant (True) +16 | False # NameConstant (False) + | + +B018.py:15:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +13 | 1.0 # Number (float) +14 | b"foo" # Binary +15 | True # NameConstant (True) + | ^^^^ B018 +16 | False # NameConstant (False) +17 | None # NameConstant (None) + | + +B018.py:16:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +14 | b"foo" # Binary +15 | True # NameConstant (True) +16 | False # NameConstant (False) + | ^^^^^ B018 +17 | None # NameConstant (None) +18 | [1, 2] # list + | + +B018.py:17:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +15 | True # NameConstant (True) +16 | False # NameConstant (False) +17 | None # NameConstant (None) + | ^^^^ B018 +18 | [1, 2] # list +19 | {1, 2} # set + | + +B018.py:18:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +16 | False # NameConstant (False) +17 | None # NameConstant (None) +18 | [1, 2] # list + | ^^^^^^ B018 +19 | {1, 2} # set +20 | {"foo": "bar"} # dict + | + +B018.py:19:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +17 | None # NameConstant (None) +18 | [1, 2] # list +19 | {1, 2} # set + | ^^^^^^ B018 +20 | {"foo": "bar"} # dict + | + +B018.py:20:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +18 | [1, 2] # list +19 | {1, 2} # set +20 | {"foo": "bar"} # dict + | ^^^^^^^^^^^^^^ B018 + | + +B018.py:24:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +23 | class Foo3: +24 | 123 + | ^^^ B018 +25 | a = 2 +26 | "str" + | + +B018.py:27:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +25 | a = 2 +26 | "str" +27 | 1 + | ^ B018 + | + +B018.py:39:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +37 | "str" # Str (no raise) +38 | f"{int}" # JoinedStr (no raise) +39 | 1j # Number (complex) + | ^^ B018 +40 | 1 # Number (int) +41 | 1.0 # Number (float) + | + +B018.py:40:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +38 | f"{int}" # JoinedStr (no raise) +39 | 1j # Number (complex) +40 | 1 # Number (int) + | ^ B018 +41 | 1.0 # Number (float) +42 | b"foo" # Binary + | + +B018.py:41:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +39 | 1j # Number (complex) +40 | 1 # Number (int) +41 | 1.0 # Number (float) + | ^^^ B018 +42 | b"foo" # Binary +43 | True # NameConstant (True) + | + +B018.py:42:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +40 | 1 # Number (int) +41 | 1.0 # Number (float) +42 | b"foo" # Binary + | ^^^^^^ B018 +43 | True # NameConstant (True) +44 | False # NameConstant (False) + | + +B018.py:43:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +41 | 1.0 # Number (float) +42 | b"foo" # Binary +43 | True # NameConstant (True) + | ^^^^ B018 +44 | False # NameConstant (False) +45 | None # NameConstant (None) + | + +B018.py:44:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +42 | b"foo" # Binary +43 | True # NameConstant (True) +44 | False # NameConstant (False) + | ^^^^^ B018 +45 | None # NameConstant (None) +46 | [1, 2] # list + | + +B018.py:45:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +43 | True # NameConstant (True) +44 | False # NameConstant (False) +45 | None # NameConstant (None) + | ^^^^ B018 +46 | [1, 2] # list +47 | {1, 2} # set + | + +B018.py:46:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +44 | False # NameConstant (False) +45 | None # NameConstant (None) +46 | [1, 2] # list + | ^^^^^^ B018 +47 | {1, 2} # set +48 | {"foo": "bar"} # dict + | + +B018.py:47:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +45 | None # NameConstant (None) +46 | [1, 2] # list +47 | {1, 2} # set + | ^^^^^^ B018 +48 | {"foo": "bar"} # dict + | + +B018.py:48:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +46 | [1, 2] # list +47 | {1, 2} # set +48 | {"foo": "bar"} # dict + | ^^^^^^^^^^^^^^ B018 + | + +B018.py:52:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +51 | def foo3(): +52 | 123 + | ^^^ B018 +53 | a = 2 +54 | "str" + | + +B018.py:55:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +53 | a = 2 +54 | "str" +55 | 3 + | ^ B018 + | + +B018.py:63:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +62 | def foo5(): +63 | foo.bar # Attribute (raise) + | ^^^^^^^ B018 +64 | object().__class__ # Attribute (raise) +65 | "foo" + "bar" # BinOp (raise) + | + +B018.py:64:5: B018 Found useless attribute access. Either assign it to a variable or remove it. + | +62 | def foo5(): +63 | foo.bar # Attribute (raise) +64 | object().__class__ # Attribute (raise) + | ^^^^^^^^^^^^^^^^^^ B018 +65 | "foo" + "bar" # BinOp (raise) + | + +B018.py:65:5: B018 Found useless expression. Either assign it to a variable or remove it. + | +63 | foo.bar # Attribute (raise) +64 | object().__class__ # Attribute (raise) +65 | "foo" + "bar" # BinOp (raise) + | ^^^^^^^^^^^^^ B018 + | + + 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 new file mode 100644 index 0000000000..76541860c0 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B019_B019.py.snap @@ -0,0 +1,83 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B019.py:78:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks + | +77 | # Remaining methods should emit B019 +78 | @functools.cache + | ^^^^^^^^^^^^^^^^ B019 +79 | def cached_instance_method(self, y): +80 | ... + | + +B019.py:82:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks + | +80 | ... +81 | +82 | @cache + | ^^^^^^ B019 +83 | def another_cached_instance_method(self, y): +84 | ... + | + +B019.py:86:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks + | +84 | ... +85 | +86 | @functools.cache() + | ^^^^^^^^^^^^^^^^^^ B019 +87 | def called_cached_instance_method(self, y): +88 | ... + | + +B019.py:90:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks + | +88 | ... +89 | +90 | @cache() + | ^^^^^^^^ B019 +91 | def another_called_cached_instance_method(self, y): +92 | ... + | + +B019.py:94:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks + | +92 | ... +93 | +94 | @functools.lru_cache + | ^^^^^^^^^^^^^^^^^^^^ B019 +95 | def lru_cached_instance_method(self, y): +96 | ... + | + +B019.py:98:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks + | + 96 | ... + 97 | + 98 | @lru_cache + | ^^^^^^^^^^ B019 + 99 | def another_lru_cached_instance_method(self, y): +100 | ... + | + +B019.py:102:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks + | +100 | ... +101 | +102 | @functools.lru_cache() + | ^^^^^^^^^^^^^^^^^^^^^^ B019 +103 | def called_lru_cached_instance_method(self, y): +104 | ... + | + +B019.py:106:5: B019 Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks + | +104 | ... +105 | +106 | @lru_cache() + | ^^^^^^^^^^^^ B019 +107 | def another_called_lru_cached_instance_method(self, y): +108 | ... + | + + 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 new file mode 100644 index 0000000000..ceedf56d97 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B020_B020.py.snap @@ -0,0 +1,30 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B020.py:8:5: B020 Loop control variable `items` overrides iterable it iterates + | +6 | items = [1, 2, 3] +7 | +8 | for items in items: + | ^^^^^ B020 +9 | print(items) + | + +B020.py:21:10: B020 Loop control variable `values` overrides iterable it iterates + | +19 | print(f"{key}, {value}") +20 | +21 | for key, values in values.items(): + | ^^^^^^ B020 +22 | print(f"{key}, {values}") + | + +B020.py:36:5: B020 Loop control variable `vars` overrides iterable it iterates + | +35 | # However we still call out reassigning the iterable in the comprehension. +36 | for vars in [i for i in vars]: + | ^^^^ B020 +37 | print(vars) + | + + 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 new file mode 100644 index 0000000000..55429a9759 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B021_B021.py.snap @@ -0,0 +1,80 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B021.py:1:1: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + | +1 | / f""" +2 | | Should emit: +3 | | B021 - on lines 14, 22, 30, 38, 46, 54, 62, 70, 73 +4 | | """ + | |___^ B021 +5 | +6 | VARIABLE = "world" + | + +B021.py:14:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + | +13 | def foo2(): +14 | f"""hello {VARIABLE}!""" + | ^^^^^^^^^^^^^^^^^^^^^^^^ B021 + | + +B021.py:22:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + | +21 | class bar2: +22 | f"""hello {VARIABLE}!""" + | ^^^^^^^^^^^^^^^^^^^^^^^^ B021 + | + +B021.py:30:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + | +29 | def foo2(): +30 | f"""hello {VARIABLE}!""" + | ^^^^^^^^^^^^^^^^^^^^^^^^ B021 + | + +B021.py:38:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + | +37 | class bar2: +38 | f"""hello {VARIABLE}!""" + | ^^^^^^^^^^^^^^^^^^^^^^^^ B021 + | + +B021.py:46:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + | +45 | def foo2(): +46 | f"hello {VARIABLE}!" + | ^^^^^^^^^^^^^^^^^^^^ B021 + | + +B021.py:54:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + | +53 | class bar2: +54 | f"hello {VARIABLE}!" + | ^^^^^^^^^^^^^^^^^^^^ B021 + | + +B021.py:62:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + | +61 | def foo2(): +62 | f"hello {VARIABLE}!" + | ^^^^^^^^^^^^^^^^^^^^ B021 + | + +B021.py:70:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + | +69 | class bar2: +70 | f"hello {VARIABLE}!" + | ^^^^^^^^^^^^^^^^^^^^ B021 + | + +B021.py:74:5: B021 f-string used as docstring. Python will interpret this as a joined string, rather than a docstring. + | +73 | def baz(): +74 | f"""I'm probably a docstring: {VARIABLE}!""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B021 +75 | print(f"""I'm a normal string""") +76 | f"""Don't detect me!""" + | + + 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 new file mode 100644 index 0000000000..a24c945eed --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B022_B022.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +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 | + 9 | with contextlib.suppress(): + | ^^^^^^^^^^^^^^^^^^^^^ B022 +10 | raise ValueError + | + +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 | +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 new file mode 100644 index 0000000000..b9a759b2d8 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B023_B023.py.snap @@ -0,0 +1,224 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B023.py:12:30: B023 Function definition does not bind loop variable `x` + | +10 | y = x + 1 +11 | # Subject to late-binding problems +12 | functions.append(lambda: x) + | ^ B023 +13 | functions.append(lambda: y) # not just the loop var + | + +B023.py:13:30: B023 Function definition does not bind loop variable `y` + | +11 | # Subject to late-binding problems +12 | functions.append(lambda: x) +13 | functions.append(lambda: y) # not just the loop var + | ^ B023 +14 | +15 | def f_bad_1(): + | + +B023.py:16:16: B023 Function definition does not bind loop variable `x` + | +15 | def f_bad_1(): +16 | return x + | ^ B023 +17 | +18 | # Actually OK + | + +B023.py:28:19: B023 Function definition does not bind loop variable `x` + | +27 | def check_inside_functions_too(): +28 | ls = [lambda: x for x in range(2)] # error + | ^ B023 +29 | st = {lambda: x for x in range(2)} # error +30 | gn = (lambda: x for x in range(2)) # error + | + +B023.py:29:19: B023 Function definition does not bind loop variable `x` + | +27 | def check_inside_functions_too(): +28 | ls = [lambda: x for x in range(2)] # error +29 | st = {lambda: x for x in range(2)} # error + | ^ B023 +30 | gn = (lambda: x for x in range(2)) # error +31 | dt = {x: lambda: x for x in range(2)} # error + | + +B023.py:30:19: B023 Function definition does not bind loop variable `x` + | +28 | ls = [lambda: x for x in range(2)] # error +29 | st = {lambda: x for x in range(2)} # error +30 | gn = (lambda: x for x in range(2)) # error + | ^ B023 +31 | dt = {x: lambda: x for x in range(2)} # error + | + +B023.py:31:22: B023 Function definition does not bind loop variable `x` + | +29 | st = {lambda: x for x in range(2)} # error +30 | gn = (lambda: x for x in range(2)) # error +31 | dt = {x: lambda: x for x in range(2)} # error + | ^ B023 + | + +B023.py:40:34: B023 Function definition does not bind loop variable `x` + | +38 | async def container_for_problems(): +39 | async for x in pointless_async_iterable(): +40 | functions.append(lambda: x) # error + | ^ B023 +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 | +42 | [lambda: x async for x in pointless_async_iterable()] # error + | ^ B023 + | + +B023.py:50:30: B023 Function definition does not bind loop variable `a` + | +48 | a = a_ = a - 1 +49 | b += 1 +50 | functions.append(lambda: a) # error + | ^ B023 +51 | functions.append(lambda: a_) # error +52 | functions.append(lambda: b) # error + | + +B023.py:51:30: B023 Function definition does not bind loop variable `a_` + | +49 | b += 1 +50 | functions.append(lambda: a) # error +51 | functions.append(lambda: a_) # error + | ^^ B023 +52 | functions.append(lambda: b) # error +53 | functions.append(lambda: c) # error, but not a name error due to late binding + | + +B023.py:52:30: B023 Function definition does not bind loop variable `b` + | +50 | functions.append(lambda: a) # error +51 | functions.append(lambda: a_) # error +52 | functions.append(lambda: b) # error + | ^ B023 +53 | functions.append(lambda: c) # error, but not a name error due to late binding +54 | c: bool = a > 3 + | + +B023.py:53:30: B023 Function definition does not bind loop variable `c` + | +51 | functions.append(lambda: a_) # error +52 | functions.append(lambda: b) # error +53 | functions.append(lambda: c) # error, but not a name error due to late binding + | ^ B023 +54 | c: bool = a > 3 +55 | if not c: + | + +B023.py:61:17: B023 Function definition does not bind loop variable `j` + | +59 | for j in range(2): +60 | for k in range(3): +61 | lambda: j * k # error + | ^ B023 + | + +B023.py:61:21: B023 Function definition does not bind loop variable `k` + | +59 | for j in range(2): +60 | for k in range(3): +61 | lambda: j * k # error + | ^ B023 + | + +B023.py:68:10: B023 Function definition does not bind loop variable `l` + | +66 | def f(): +67 | j = None # OK because it's an assignment +68 | [l for k in range(2)] # error for l, not for k + | ^ B023 +69 | +70 | assert a and functions + | + +B023.py:82:16: B023 Function definition does not bind loop variable `i` + | +81 | for i in range(3): +82 | lambda: f"{i}" + | ^ B023 + | + +B023.py:117:24: B023 Function definition does not bind loop variable `x` + | +115 | for x in range(2): +116 | # It's not a complete get-out-of-linting-free construct - these should fail: +117 | min([None, lambda: x], key=repr) + | ^ B023 +118 | sorted([None, lambda: x], key=repr) +119 | any(filter(bool, [None, lambda: x])) + | + +B023.py:118:27: B023 Function definition does not bind loop variable `x` + | +116 | # It's not a complete get-out-of-linting-free construct - these should fail: +117 | min([None, lambda: x], key=repr) +118 | sorted([None, lambda: x], key=repr) + | ^ B023 +119 | any(filter(bool, [None, lambda: x])) +120 | list(filter(bool, [None, lambda: x])) + | + +B023.py:119:37: B023 Function definition does not bind loop variable `x` + | +117 | min([None, lambda: x], key=repr) +118 | sorted([None, lambda: x], key=repr) +119 | any(filter(bool, [None, lambda: x])) + | ^ B023 +120 | list(filter(bool, [None, lambda: x])) +121 | all(reduce(bool, [None, lambda: x])) + | + +B023.py:120:38: B023 Function definition does not bind loop variable `x` + | +118 | sorted([None, lambda: x], key=repr) +119 | any(filter(bool, [None, lambda: x])) +120 | list(filter(bool, [None, lambda: x])) + | ^ B023 +121 | all(reduce(bool, [None, lambda: x])) + | + +B023.py:121:37: B023 Function definition does not bind loop variable `x` + | +119 | any(filter(bool, [None, lambda: x])) +120 | list(filter(bool, [None, lambda: x])) +121 | all(reduce(bool, [None, lambda: x])) + | ^ B023 +122 | +123 | # But all these should be OK: + | + +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 | +173 | if False: + | + +B023.py:174:29: B023 Function definition does not bind loop variable `i` + | +173 | if False: +174 | return [lambda: i for i in range(3)] # error + | ^ B023 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B024_B024.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B024_B024.py.snap new file mode 100644 index 0000000000..b2e5c9eb67 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B024_B024.py.snap @@ -0,0 +1,52 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B024.py:18:7: B024 `Base_1` is an abstract base class, but it has no abstract methods + | +18 | class Base_1(ABC): # error + | ^^^^^^ B024 +19 | def method(self): +20 | foo() + | + +B024.py:71:7: B024 `MetaBase_1` is an abstract base class, but it has no abstract methods + | +71 | class MetaBase_1(metaclass=ABCMeta): # error + | ^^^^^^^^^^ B024 +72 | def method(self): +73 | foo() + | + +B024.py:82:7: B024 `abc_Base_1` is an abstract base class, but it has no abstract methods + | +82 | class abc_Base_1(abc.ABC): # error + | ^^^^^^^^^^ B024 +83 | def method(self): +84 | foo() + | + +B024.py:87:7: B024 `abc_Base_2` is an abstract base class, but it has no abstract methods + | +87 | class abc_Base_2(metaclass=abc.ABCMeta): # error + | ^^^^^^^^^^ B024 +88 | def method(self): +89 | foo() + | + +B024.py:92:7: B024 `notabc_Base_1` is an abstract base class, but it has no abstract methods + | +92 | class notabc_Base_1(notabc.ABC): # error + | ^^^^^^^^^^^^^ B024 +93 | def method(self): +94 | foo() + | + +B024.py:141:7: B024 `abc_set_class_variable_4` is an abstract base class, but it has no abstract methods + | +140 | # this doesn't actually declare a class variable, it's just an expression +141 | class abc_set_class_variable_4(ABC): # error + | ^^^^^^^^^^^^^^^^^^^^^^^^ B024 +142 | foo + | + + diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B025_B025.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B025_B025.py.snap new file mode 100644 index 0000000000..238ea4893d --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B025_B025.py.snap @@ -0,0 +1,41 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B025.py:19:8: B025 try-except block with duplicate exception `ValueError` + | +17 | except ValueError: +18 | a = 2 +19 | except ValueError: + | ^^^^^^^^^^ B025 +20 | a = 2 + | + +B025.py:28:8: B025 try-except block with duplicate exception `pickle.PickleError` + | +26 | except ValueError: +27 | a = 2 +28 | except pickle.PickleError: + | ^^^^^^^^^^^^^^^^^^ B025 +29 | a = 2 + | + +B025.py:35:8: B025 try-except block with duplicate exception `ValueError` + | +33 | except (ValueError, TypeError): +34 | a = 2 +35 | except ValueError: + | ^^^^^^^^^^ B025 +36 | a = 2 +37 | except (OSError, TypeError): + | + +B025.py:37:18: B025 try-except block with duplicate exception `TypeError` + | +35 | except ValueError: +36 | a = 2 +37 | except (OSError, TypeError): + | ^^^^^^^^^ B025 +38 | a = 2 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B026_B026.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B026_B026.py.snap new file mode 100644 index 0000000000..272c3f749e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B026_B026.py.snap @@ -0,0 +1,70 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B026.py:16:16: B026 Star-arg unpacking after a keyword argument is strongly discouraged + | +14 | foo("bar", baz="baz", bam="bam") +15 | foo(bar="bar", baz="baz", bam="bam") +16 | foo(bam="bam", *["bar", "baz"]) + | ^^^^^^^^^^^^^^^ B026 +17 | foo(bam="bam", *bar_baz) +18 | foo(baz="baz", bam="bam", *["bar"]) + | + +B026.py:17:16: B026 Star-arg unpacking after a keyword argument is strongly discouraged + | +15 | foo(bar="bar", baz="baz", bam="bam") +16 | foo(bam="bam", *["bar", "baz"]) +17 | foo(bam="bam", *bar_baz) + | ^^^^^^^^ B026 +18 | foo(baz="baz", bam="bam", *["bar"]) +19 | foo(bar="bar", baz="baz", bam="bam", *[]) + | + +B026.py:18:27: B026 Star-arg unpacking after a keyword argument is strongly discouraged + | +16 | foo(bam="bam", *["bar", "baz"]) +17 | foo(bam="bam", *bar_baz) +18 | foo(baz="baz", bam="bam", *["bar"]) + | ^^^^^^^^ B026 +19 | foo(bar="bar", baz="baz", bam="bam", *[]) +20 | foo(bam="bam", *["bar"], *["baz"]) + | + +B026.py:19:38: B026 Star-arg unpacking after a keyword argument is strongly discouraged + | +17 | foo(bam="bam", *bar_baz) +18 | foo(baz="baz", bam="bam", *["bar"]) +19 | foo(bar="bar", baz="baz", bam="bam", *[]) + | ^^^ B026 +20 | foo(bam="bam", *["bar"], *["baz"]) +21 | foo(*["bar"], bam="bam", *["baz"]) + | + +B026.py:20:16: B026 Star-arg unpacking after a keyword argument is strongly discouraged + | +18 | foo(baz="baz", bam="bam", *["bar"]) +19 | foo(bar="bar", baz="baz", bam="bam", *[]) +20 | foo(bam="bam", *["bar"], *["baz"]) + | ^^^^^^^^ B026 +21 | foo(*["bar"], bam="bam", *["baz"]) + | + +B026.py:20:26: B026 Star-arg unpacking after a keyword argument is strongly discouraged + | +18 | foo(baz="baz", bam="bam", *["bar"]) +19 | foo(bar="bar", baz="baz", bam="bam", *[]) +20 | foo(bam="bam", *["bar"], *["baz"]) + | ^^^^^^^^ B026 +21 | foo(*["bar"], bam="bam", *["baz"]) + | + +B026.py:21:26: B026 Star-arg unpacking after a keyword argument is strongly discouraged + | +19 | foo(bar="bar", baz="baz", bam="bam", *[]) +20 | foo(bam="bam", *["bar"], *["baz"]) +21 | foo(*["bar"], bam="bam", *["baz"]) + | ^^^^^^^^ B026 + | + + 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 new file mode 100644 index 0000000000..b3da6237de --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B027_B027.py.snap @@ -0,0 +1,56 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +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 + | _____^ +19 | | ... + | |___________^ B027 +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 + | _____^ +22 | | pass + | |____________^ B027 +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 + | _____^ +25 | | """docstring""" +26 | | ... + | |___________^ B027 +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 + | _____^ +29 | | """multiple ellipsis/pass""" +30 | | ... +31 | | pass +32 | | ... +33 | | pass + | |____________^ B027 +34 | +35 | @notabstract + | + + diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B027_B027.pyi.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B027_B027.pyi.snap new file mode 100644 index 0000000000..967e60a4f9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B027_B027.pyi.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- + 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 new file mode 100644 index 0000000000..2b89da03fe --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B028_B028.py.snap @@ -0,0 +1,23 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B028.py:8:1: B028 No explicit `stacklevel` keyword argument found + | + 6 | """ + 7 | + 8 | warnings.warn(DeprecationWarning("test")) + | ^^^^^^^^^^^^^ B028 + 9 | warnings.warn(DeprecationWarning("test"), source=None) +10 | warnings.warn(DeprecationWarning("test"), source=None, stacklevel=2) + | + +B028.py:9:1: B028 No explicit `stacklevel` keyword argument found + | + 8 | warnings.warn(DeprecationWarning("test")) + 9 | warnings.warn(DeprecationWarning("test"), source=None) + | ^^^^^^^^^^^^^ B028 +10 | warnings.warn(DeprecationWarning("test"), source=None, stacklevel=2) +11 | warnings.warn(DeprecationWarning("test"), stacklevel=1) + | + + 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 new file mode 100644 index 0000000000..8c469dd418 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B029_B029.py.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B029.py:8:1: B029 Using `except ():` with an empty tuple does not catch anything; add exceptions to handle + | + 6 | try: + 7 | pass + 8 | / except (): + 9 | | pass + | |________^ B029 +10 | +11 | try: + | + +B029.py:13:1: B029 Using `except ():` with an empty tuple does not catch anything; add exceptions to handle + | +11 | try: +12 | pass +13 | / except () as e: +14 | | pass + | |________^ B029 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B030_B030.py.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B030_B030.py.snap new file mode 100644 index 0000000000..e93dfe9db3 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B030_B030.py.snap @@ -0,0 +1,49 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B030.py:12:8: B030 `except` handlers should only be exception classes or tuples of exception classes + | +10 | try: +11 | pass +12 | except 1: # error + | ^ B030 +13 | pass + | + +B030.py:17:9: B030 `except` handlers should only be exception classes or tuples of exception classes + | +15 | try: +16 | pass +17 | except (1, ValueError): # error + | ^ B030 +18 | pass + | + +B030.py:22:21: B030 `except` handlers should only be exception classes or tuples of exception classes + | +20 | try: +21 | pass +22 | except (ValueError, (RuntimeError, (KeyError, TypeError))): # error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B030 +23 | pass + | + +B030.py:27:37: B030 `except` handlers should only be exception classes or tuples of exception classes + | +25 | try: +26 | pass +27 | except (ValueError, *(RuntimeError, (KeyError, TypeError))): # error + | ^^^^^^^^^^^^^^^^^^^^^ B030 +28 | pass + | + +B030.py:33:29: B030 `except` handlers should only be exception classes or tuples of exception classes + | +31 | try: +32 | pass +33 | except (*a, *(RuntimeError, (KeyError, TypeError))): # error + | ^^^^^^^^^^^^^^^^^^^^^ B030 +34 | pass + | + + 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 new file mode 100644 index 0000000000..b2de85a2f4 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B031_B031.py.snap @@ -0,0 +1,198 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B031.py:27:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | +25 | for shopper in shoppers: +26 | shopper = shopper.title() +27 | collect_shop_items(shopper, section_items) # B031 + | ^^^^^^^^^^^^^ B031 +28 | # We're outside the nested loop and used the group again. +29 | collect_shop_items(shopper, section_items) # B031 + | + +B031.py:29:33: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | +27 | collect_shop_items(shopper, section_items) # B031 +28 | # We're outside the nested loop and used the group again. +29 | collect_shop_items(shopper, section_items) # B031 + | ^^^^^^^^^^^^^ B031 +30 | +31 | for _section, section_items in groupby(items, key=lambda p: p[1]): + | + +B031.py:33:31: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | +31 | for _section, section_items in groupby(items, key=lambda p: p[1]): +32 | collect_shop_items("Jane", section_items) +33 | collect_shop_items("Joe", section_items) # B031 + | ^^^^^^^^^^^^^ B031 + | + +B031.py:40:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | +38 | countdown = 3 +39 | while countdown > 0: +40 | collect_shop_items(shopper, section_items) # B031 + | ^^^^^^^^^^^^^ B031 +41 | countdown -= 1 + | + +B031.py:46:29: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | +44 | collection = [] +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 | +48 | unique_items = set() + | + +B031.py:56:17: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | +55 | # But it should be detected when used again +56 | for item in section_items: # B031 + | ^^^^^^^^^^^^^ B031 +57 | another_set.add(item) + | + +B031.py:79:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | +77 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): +78 | for shopper in shoppers: +79 | collect_shop_items(shopper, section_items) # B031 + | ^^^^^^^^^^^^^ B031 +80 | +81 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): + | + +B031.py:82:38: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | +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 | +84 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): + | + +B031.py:94:65: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | +92 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): +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 | +96 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): + | + +B031.py:101:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | + 99 | else: +100 | collect_shop_items(shopper, section_items) +101 | collect_shop_items(shopper, section_items) # B031 + | ^^^^^^^^^^^^^ B031 +102 | +103 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): + | + +B031.py:108:41: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | +106 | collect_shop_items(shopper, section_items) +107 | if _section == "greens": +108 | collect_shop_items(shopper, section_items) # B031 + | ^^^^^^^^^^^^^ B031 +109 | elif _section == "frozen items": +110 | collect_shop_items(shopper, section_items) # B031 + | + +B031.py:110:41: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | +108 | collect_shop_items(shopper, section_items) # B031 +109 | elif _section == "frozen items": +110 | collect_shop_items(shopper, section_items) # B031 + | ^^^^^^^^^^^^^ B031 +111 | else: +112 | collect_shop_items(shopper, section_items) # B031 + | + +B031.py:112:41: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | +110 | collect_shop_items(shopper, section_items) # B031 +111 | else: +112 | collect_shop_items(shopper, section_items) # B031 + | ^^^^^^^^^^^^^ B031 +113 | collect_shop_items(shopper, section_items) # B031 +114 | elif _section == "frozen items": + | + +B031.py:113:37: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | +111 | else: +112 | collect_shop_items(shopper, section_items) # B031 +113 | collect_shop_items(shopper, section_items) # B031 + | ^^^^^^^^^^^^^ B031 +114 | elif _section == "frozen items": +115 | # Mix `match` and `if` statements + | + +B031.py:120:49: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | +118 | collect_shop_items(shopper, section_items) +119 | if _section == "fourth": +120 | collect_shop_items(shopper, section_items) # B031 + | ^^^^^^^^^^^^^ B031 +121 | case _: +122 | collect_shop_items(shopper, section_items) + | + +B031.py:126:33: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | +124 | collect_shop_items(shopper, section_items) +125 | # Now, it should detect +126 | collect_shop_items(shopper, section_items) # B031 + | ^^^^^^^^^^^^^ B031 +127 | +128 | for _section, section_items in itertools.groupby(items, key=lambda p: p[1]): + | + +B031.py:135:49: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | +133 | match shopper: +134 | case "Jane": +135 | collect_shop_items(shopper, section_items) # B031 + | ^^^^^^^^^^^^^ B031 +136 | case _: +137 | collect_shop_items(shopper, section_items) # B031 + | + +B031.py:137:49: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | +135 | collect_shop_items(shopper, section_items) # B031 +136 | case _: +137 | collect_shop_items(shopper, section_items) # B031 + | ^^^^^^^^^^^^^ B031 +138 | case "frozen items": +139 | collect_shop_items(shopper, section_items) + | + +B031.py:140:41: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | +138 | case "frozen items": +139 | collect_shop_items(shopper, section_items) +140 | collect_shop_items(shopper, section_items) # B031 + | ^^^^^^^^^^^^^ B031 +141 | case _: +142 | collect_shop_items(shopper, section_items) + | + +B031.py:144:33: B031 Using the generator returned from `itertools.groupby()` more than once will do nothing on the second usage + | +142 | collect_shop_items(shopper, section_items) +143 | # Now, it should detect +144 | collect_shop_items(shopper, section_items) # B031 + | ^^^^^^^^^^^^^ B031 +145 | +146 | for group in groupby(items, key=lambda p: p[1]): + | + + 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 new file mode 100644 index 0000000000..a55e9006fa --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B032_B032.py.snap @@ -0,0 +1,78 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B032.py:9:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? + | + 7 | dct = {"a": 1} + 8 | + 9 | dct["b"]: 2 + | ^^^^^^^^^^^ B032 +10 | dct.b: 2 + | + +B032.py:10:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? + | + 9 | dct["b"]: 2 +10 | dct.b: 2 + | ^^^^^^^^ B032 +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 | +12 | dct["b"]: "test" + | ^^^^^^^^^^^^^^^^ B032 +13 | dct.b: "test" + | + +B032.py:13:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? + | +12 | dct["b"]: "test" +13 | dct.b: "test" + | ^^^^^^^^^^^^^ B032 +14 | +15 | test = "test" + | + +B032.py:16:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? + | +15 | test = "test" +16 | dct["b"]: test + | ^^^^^^^^^^^^^^ B032 +17 | dct["b"]: test.lower() +18 | dct.b: test + | + +B032.py:17:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? + | +15 | test = "test" +16 | dct["b"]: test +17 | dct["b"]: test.lower() + | ^^^^^^^^^^^^^^^^^^^^^^ B032 +18 | dct.b: test +19 | dct.b: test.lower() + | + +B032.py:18:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? + | +16 | dct["b"]: test +17 | dct["b"]: test.lower() +18 | dct.b: test + | ^^^^^^^^^^^ B032 +19 | dct.b: test.lower() + | + +B032.py:19:1: B032 Possible unintentional type annotation (using `:`). Did you mean to assign (using `=`)? + | +17 | dct["b"]: test.lower() +18 | dct.b: test +19 | dct.b: test.lower() + | ^^^^^^^^^^^^^^^^^^^ B032 +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 new file mode 100644 index 0000000000..3f7c07a98b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B033_B033.py.snap @@ -0,0 +1,23 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B033.py:4:35: B033 Sets should not contain duplicate item `"value1"` + | +2 | # Errors. +3 | ### +4 | incorrect_set = {"value1", 23, 5, "value1"} + | ^^^^^^^^ B033 +5 | incorrect_set = {1, 1} + | + +B033.py:5:21: B033 Sets should not contain duplicate item `1` + | +3 | ### +4 | incorrect_set = {"value1", 23, 5, "value1"} +5 | incorrect_set = {1, 1} + | ^ B033 +6 | +7 | ### + | + + 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 new file mode 100644 index 0000000000..92631d1ed8 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B034_B034.py.snap @@ -0,0 +1,102 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B034.py:5:1: B034 `re.sub` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + | +4 | # B034 +5 | re.sub("a", "b", "aaa", re.IGNORECASE) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 +6 | re.sub("a", "b", "aaa", 5) +7 | re.sub("a", "b", "aaa", 5, re.IGNORECASE) + | + +B034.py:6:1: B034 `re.sub` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + | +4 | # B034 +5 | re.sub("a", "b", "aaa", re.IGNORECASE) +6 | re.sub("a", "b", "aaa", 5) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 +7 | re.sub("a", "b", "aaa", 5, re.IGNORECASE) +8 | re.subn("a", "b", "aaa", re.IGNORECASE) + | + +B034.py:7:1: B034 `re.sub` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + | +5 | re.sub("a", "b", "aaa", re.IGNORECASE) +6 | re.sub("a", "b", "aaa", 5) +7 | re.sub("a", "b", "aaa", 5, re.IGNORECASE) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 +8 | re.subn("a", "b", "aaa", re.IGNORECASE) +9 | re.subn("a", "b", "aaa", 5) + | + +B034.py:8:1: B034 `re.subn` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + | + 6 | re.sub("a", "b", "aaa", 5) + 7 | re.sub("a", "b", "aaa", 5, re.IGNORECASE) + 8 | re.subn("a", "b", "aaa", re.IGNORECASE) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 + 9 | re.subn("a", "b", "aaa", 5) +10 | re.subn("a", "b", "aaa", 5, re.IGNORECASE) + | + +B034.py:9:1: B034 `re.subn` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + | + 7 | re.sub("a", "b", "aaa", 5, re.IGNORECASE) + 8 | re.subn("a", "b", "aaa", re.IGNORECASE) + 9 | re.subn("a", "b", "aaa", 5) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 +10 | re.subn("a", "b", "aaa", 5, re.IGNORECASE) +11 | re.split(" ", "a a a a", re.I) + | + +B034.py:10:1: B034 `re.subn` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + | + 8 | re.subn("a", "b", "aaa", re.IGNORECASE) + 9 | re.subn("a", "b", "aaa", 5) +10 | re.subn("a", "b", "aaa", 5, re.IGNORECASE) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 +11 | re.split(" ", "a a a a", re.I) +12 | re.split(" ", "a a a a", 2) + | + +B034.py:11:1: B034 `re.split` should pass `maxsplit` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + | + 9 | re.subn("a", "b", "aaa", 5) +10 | re.subn("a", "b", "aaa", 5, re.IGNORECASE) +11 | re.split(" ", "a a a a", re.I) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 +12 | re.split(" ", "a a a a", 2) +13 | re.split(" ", "a a a a", 2, re.I) + | + +B034.py:12:1: B034 `re.split` should pass `maxsplit` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + | +10 | re.subn("a", "b", "aaa", 5, re.IGNORECASE) +11 | re.split(" ", "a a a a", re.I) +12 | re.split(" ", "a a a a", 2) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 +13 | re.split(" ", "a a a a", 2, re.I) +14 | sub("a", "b", "aaa", re.IGNORECASE) + | + +B034.py:13:1: B034 `re.split` should pass `maxsplit` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + | +11 | re.split(" ", "a a a a", re.I) +12 | re.split(" ", "a a a a", 2) +13 | re.split(" ", "a a a a", 2, re.I) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 +14 | sub("a", "b", "aaa", re.IGNORECASE) + | + +B034.py:14:1: B034 `re.sub` should pass `count` and `flags` as keyword arguments to avoid confusion due to unintuitive argument positions + | +12 | re.split(" ", "a a a a", 2) +13 | re.split(" ", "a a a a", 2, re.I) +14 | sub("a", "b", "aaa", re.IGNORECASE) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B034 +15 | +16 | # OK + | + + 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 new file mode 100644 index 0000000000..5e39344cb5 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B904_B904.py.snap @@ -0,0 +1,70 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +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 + | + 8 | except ValueError: + 9 | if "abc": +10 | raise TypeError + | ^^^^^^^^^^^^^^^ B904 +11 | raise UserWarning +12 | except AssertionError: + | + +B904.py:11:5: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling + | + 9 | if "abc": +10 | raise TypeError +11 | raise UserWarning + | ^^^^^^^^^^^^^^^^^ B904 +12 | except AssertionError: +13 | raise # Bare `raise` should not be an error + | + +B904.py:16:5: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling + | +14 | except Exception as err: +15 | assert err +16 | raise Exception("No cause here...") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904 +17 | except BaseException as err: +18 | raise err + | + +B904.py:20:5: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling + | +18 | raise err +19 | except BaseException as err: +20 | raise some_other_err + | ^^^^^^^^^^^^^^^^^^^^ B904 +21 | finally: +22 | raise Exception("Nothing to chain from, so no warning here") + | + +B904.py:63:9: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling + | +61 | except Exception as e: +62 | if ...: +63 | raise RuntimeError("boom!") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904 +64 | else: +65 | raise RuntimeError("bang!") + | + +B904.py:65:9: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling + | +63 | raise RuntimeError("boom!") +64 | else: +65 | raise RuntimeError("bang!") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904 + | + +B904.py:73:13: B904 Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling + | +71 | match 0: +72 | case 0: +73 | raise RuntimeError("boom!") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ B904 + | + + 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 new file mode 100644 index 0000000000..f4b41f2239 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__B905.py.snap @@ -0,0 +1,88 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B905.py:4:1: B905 `zip()` without an explicit `strict=` parameter + | +3 | # Errors +4 | zip() + | ^^^^^ B905 +5 | zip(range(3)) +6 | zip("a", "b") + | + +B905.py:5:1: B905 `zip()` without an explicit `strict=` parameter + | +3 | # Errors +4 | zip() +5 | zip(range(3)) + | ^^^^^^^^^^^^^ B905 +6 | zip("a", "b") +7 | zip("a", "b", *zip("c")) + | + +B905.py:6:1: B905 `zip()` without an explicit `strict=` parameter + | +4 | zip() +5 | zip(range(3)) +6 | zip("a", "b") + | ^^^^^^^^^^^^^ B905 +7 | zip("a", "b", *zip("c")) +8 | zip(zip("a"), strict=False) + | + +B905.py:7:1: B905 `zip()` without an explicit `strict=` parameter + | +5 | zip(range(3)) +6 | zip("a", "b") +7 | zip("a", "b", *zip("c")) + | ^^^^^^^^^^^^^^^^^^^^^^^^ B905 +8 | zip(zip("a"), strict=False) +9 | zip(zip("a", strict=True)) + | + +B905.py:7:16: B905 `zip()` without an explicit `strict=` parameter + | +5 | zip(range(3)) +6 | zip("a", "b") +7 | zip("a", "b", *zip("c")) + | ^^^^^^^^ B905 +8 | zip(zip("a"), strict=False) +9 | zip(zip("a", strict=True)) + | + +B905.py:8:5: B905 `zip()` without an explicit `strict=` parameter + | +6 | zip("a", "b") +7 | zip("a", "b", *zip("c")) +8 | zip(zip("a"), strict=False) + | ^^^^^^^^ B905 +9 | zip(zip("a", strict=True)) + | + +B905.py:9:1: B905 `zip()` without an explicit `strict=` parameter + | + 7 | zip("a", "b", *zip("c")) + 8 | zip(zip("a"), strict=False) + 9 | zip(zip("a", strict=True)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ B905 +10 | +11 | # OK + | + +B905.py:24:1: B905 `zip()` without an explicit `strict=` parameter + | +23 | # Errors (limited iterators). +24 | zip([1, 2, 3], repeat(1, 1)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B905 +25 | zip([1, 2, 3], repeat(1, times=4)) + | + +B905.py:25:1: B905 `zip()` without an explicit `strict=` parameter + | +23 | # Errors (limited iterators). +24 | zip([1, 2, 3], repeat(1, 1)) +25 | zip([1, 2, 3], repeat(1, times=4)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ B905 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_immutable_calls_arg_annotation.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_immutable_calls_arg_annotation.snap new file mode 100644 index 0000000000..d191804dd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_immutable_calls_arg_annotation.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B006_extended.py:17:55: B006 [*] Do not use mutable data structures for argument defaults + | +17 | def error_due_to_missing_import(foo: ImmutableTypeA = []): + | ^^ B006 +18 | ... + | + = help: Replace with `None`; initialize within function + +ℹ Possible fix +14 14 | ... +15 15 | +16 16 | +17 |-def error_due_to_missing_import(foo: ImmutableTypeA = []): + 17 |+def error_due_to_missing_import(foo: ImmutableTypeA = None): + 18 |+ if foo is None: + 19 |+ foo = [] +18 20 | ... + + diff --git a/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_immutable_calls_arg_default.snap b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_immutable_calls_arg_default.snap new file mode 100644 index 0000000000..56b5a1db75 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_bugbear/snapshots/ruff_linter__rules__flake8_bugbear__tests__extend_immutable_calls_arg_default.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/flake8_bugbear/mod.rs +--- +B008_extended.py:24:51: B008 Do not perform function call `Depends` in argument defaults + | +24 | def error_due_to_missing_import(data: List[str] = Depends(None)): + | ^^^^^^^^^^^^^ B008 +25 | ... + | + + diff --git a/crates/ruff/src/rules/flake8_builtins/helpers.rs b/crates/ruff_linter/src/rules/flake8_builtins/helpers.rs similarity index 100% rename from crates/ruff/src/rules/flake8_builtins/helpers.rs rename to crates/ruff_linter/src/rules/flake8_builtins/helpers.rs diff --git a/crates/ruff/src/rules/flake8_builtins/mod.rs b/crates/ruff_linter/src/rules/flake8_builtins/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_builtins/mod.rs rename to crates/ruff_linter/src/rules/flake8_builtins/mod.rs diff --git a/crates/ruff/src/rules/flake8_builtins/rules/builtin_argument_shadowing.rs b/crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_argument_shadowing.rs similarity index 100% rename from crates/ruff/src/rules/flake8_builtins/rules/builtin_argument_shadowing.rs rename to crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_argument_shadowing.rs diff --git a/crates/ruff/src/rules/flake8_builtins/rules/builtin_attribute_shadowing.rs b/crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_attribute_shadowing.rs similarity index 100% rename from crates/ruff/src/rules/flake8_builtins/rules/builtin_attribute_shadowing.rs rename to crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_attribute_shadowing.rs diff --git a/crates/ruff/src/rules/flake8_builtins/rules/builtin_variable_shadowing.rs b/crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_variable_shadowing.rs similarity index 100% rename from crates/ruff/src/rules/flake8_builtins/rules/builtin_variable_shadowing.rs rename to crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_variable_shadowing.rs diff --git a/crates/ruff/src/rules/flake8_builtins/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_builtins/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_builtins/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_builtins/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_builtins/settings.rs b/crates/ruff_linter/src/rules/flake8_builtins/settings.rs similarity index 100% rename from crates/ruff/src/rules/flake8_builtins/settings.rs rename to crates/ruff_linter/src/rules/flake8_builtins/settings.rs 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 new file mode 100644 index 0000000000..60efd05563 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A001_A001.py.snap @@ -0,0 +1,187 @@ +--- +source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs +--- +A001.py:1:16: A001 Variable `sum` is shadowing a Python builtin + | +1 | import some as sum + | ^^^ A001 +2 | from some import other as int +3 | from directory import new as dir + | + +A001.py:2:27: A001 Variable `int` is shadowing a Python builtin + | +1 | import some as sum +2 | from some import other as int + | ^^^ A001 +3 | from directory import new as dir + | + +A001.py:3:30: A001 Variable `dir` is shadowing a Python builtin + | +1 | import some as sum +2 | from some import other as int +3 | from directory import new as dir + | ^^^ A001 +4 | +5 | print = 1 + | + +A001.py:5:1: A001 Variable `print` is shadowing a Python builtin + | +3 | from directory import new as dir +4 | +5 | print = 1 + | ^^^^^ A001 +6 | copyright: 'annotation' = 2 +7 | (complex := 3) + | + +A001.py:6:1: A001 Variable `copyright` is shadowing a Python builtin + | +5 | print = 1 +6 | copyright: 'annotation' = 2 + | ^^^^^^^^^ A001 +7 | (complex := 3) +8 | float = object = 4 + | + +A001.py:7:2: A001 Variable `complex` is shadowing a Python builtin + | +5 | print = 1 +6 | copyright: 'annotation' = 2 +7 | (complex := 3) + | ^^^^^^^ A001 +8 | float = object = 4 +9 | min, max = 5, 6 + | + +A001.py:8:1: A001 Variable `float` is shadowing a Python builtin + | +6 | copyright: 'annotation' = 2 +7 | (complex := 3) +8 | float = object = 4 + | ^^^^^ A001 +9 | min, max = 5, 6 + | + +A001.py:8:9: A001 Variable `object` is shadowing a Python builtin + | +6 | copyright: 'annotation' = 2 +7 | (complex := 3) +8 | float = object = 4 + | ^^^^^^ A001 +9 | min, max = 5, 6 + | + +A001.py:9:1: A001 Variable `min` is shadowing a Python builtin + | + 7 | (complex := 3) + 8 | float = object = 4 + 9 | min, max = 5, 6 + | ^^^ A001 +10 | +11 | id = 4 + | + +A001.py:9:6: A001 Variable `max` is shadowing a Python builtin + | + 7 | (complex := 3) + 8 | float = object = 4 + 9 | min, max = 5, 6 + | ^^^ A001 +10 | +11 | id = 4 + | + +A001.py:11:1: A001 Variable `id` is shadowing a Python builtin + | + 9 | min, max = 5, 6 +10 | +11 | id = 4 + | ^^ A001 +12 | +13 | def bytes(): + | + +A001.py:13:5: A001 Variable `bytes` is shadowing a Python builtin + | +11 | id = 4 +12 | +13 | def bytes(): + | ^^^^^ A001 +14 | pass + | + +A001.py:16:7: A001 Variable `slice` is shadowing a Python builtin + | +14 | pass +15 | +16 | class slice: + | ^^^^^ A001 +17 | pass + | + +A001.py:21:23: A001 Variable `ValueError` is shadowing a Python builtin + | +19 | try: +20 | ... +21 | except ImportError as ValueError: + | ^^^^^^^^^^ A001 +22 | ... + | + +A001.py:24:5: A001 Variable `memoryview` is shadowing a Python builtin + | +22 | ... +23 | +24 | for memoryview, *bytearray in []: + | ^^^^^^^^^^ A001 +25 | pass + | + +A001.py:24:18: A001 Variable `bytearray` is shadowing a Python builtin + | +22 | ... +23 | +24 | for memoryview, *bytearray in []: + | ^^^^^^^^^ A001 +25 | pass + | + +A001.py:27:22: A001 Variable `str` is shadowing a Python builtin + | +25 | pass +26 | +27 | with open('file') as str, open('file2') as (all, any): + | ^^^ A001 +28 | pass + | + +A001.py:27:45: A001 Variable `all` is shadowing a Python builtin + | +25 | pass +26 | +27 | with open('file') as str, open('file2') as (all, any): + | ^^^ A001 +28 | pass + | + +A001.py:27:50: A001 Variable `any` is shadowing a Python builtin + | +25 | pass +26 | +27 | with open('file') as str, open('file2') as (all, any): + | ^^^ A001 +28 | pass + | + +A001.py:30:8: A001 Variable `sum` is shadowing a Python builtin + | +28 | pass +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 new file mode 100644 index 0000000000..dfdd12fe91 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A001_A001.py_builtins_ignorelist.snap @@ -0,0 +1,167 @@ +--- +source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs +--- +A001.py:1:16: A001 Variable `sum` is shadowing a Python builtin + | +1 | import some as sum + | ^^^ A001 +2 | from some import other as int +3 | from directory import new as dir + | + +A001.py:2:27: A001 Variable `int` is shadowing a Python builtin + | +1 | import some as sum +2 | from some import other as int + | ^^^ A001 +3 | from directory import new as dir + | + +A001.py:5:1: A001 Variable `print` is shadowing a Python builtin + | +3 | from directory import new as dir +4 | +5 | print = 1 + | ^^^^^ A001 +6 | copyright: 'annotation' = 2 +7 | (complex := 3) + | + +A001.py:6:1: A001 Variable `copyright` is shadowing a Python builtin + | +5 | print = 1 +6 | copyright: 'annotation' = 2 + | ^^^^^^^^^ A001 +7 | (complex := 3) +8 | float = object = 4 + | + +A001.py:7:2: A001 Variable `complex` is shadowing a Python builtin + | +5 | print = 1 +6 | copyright: 'annotation' = 2 +7 | (complex := 3) + | ^^^^^^^ A001 +8 | float = object = 4 +9 | min, max = 5, 6 + | + +A001.py:8:1: A001 Variable `float` is shadowing a Python builtin + | +6 | copyright: 'annotation' = 2 +7 | (complex := 3) +8 | float = object = 4 + | ^^^^^ A001 +9 | min, max = 5, 6 + | + +A001.py:8:9: A001 Variable `object` is shadowing a Python builtin + | +6 | copyright: 'annotation' = 2 +7 | (complex := 3) +8 | float = object = 4 + | ^^^^^^ A001 +9 | min, max = 5, 6 + | + +A001.py:9:1: A001 Variable `min` is shadowing a Python builtin + | + 7 | (complex := 3) + 8 | float = object = 4 + 9 | min, max = 5, 6 + | ^^^ A001 +10 | +11 | id = 4 + | + +A001.py:9:6: A001 Variable `max` is shadowing a Python builtin + | + 7 | (complex := 3) + 8 | float = object = 4 + 9 | min, max = 5, 6 + | ^^^ A001 +10 | +11 | id = 4 + | + +A001.py:13:5: A001 Variable `bytes` is shadowing a Python builtin + | +11 | id = 4 +12 | +13 | def bytes(): + | ^^^^^ A001 +14 | pass + | + +A001.py:16:7: A001 Variable `slice` is shadowing a Python builtin + | +14 | pass +15 | +16 | class slice: + | ^^^^^ A001 +17 | pass + | + +A001.py:21:23: A001 Variable `ValueError` is shadowing a Python builtin + | +19 | try: +20 | ... +21 | except ImportError as ValueError: + | ^^^^^^^^^^ A001 +22 | ... + | + +A001.py:24:5: A001 Variable `memoryview` is shadowing a Python builtin + | +22 | ... +23 | +24 | for memoryview, *bytearray in []: + | ^^^^^^^^^^ A001 +25 | pass + | + +A001.py:24:18: A001 Variable `bytearray` is shadowing a Python builtin + | +22 | ... +23 | +24 | for memoryview, *bytearray in []: + | ^^^^^^^^^ A001 +25 | pass + | + +A001.py:27:22: A001 Variable `str` is shadowing a Python builtin + | +25 | pass +26 | +27 | with open('file') as str, open('file2') as (all, any): + | ^^^ A001 +28 | pass + | + +A001.py:27:45: A001 Variable `all` is shadowing a Python builtin + | +25 | pass +26 | +27 | with open('file') as str, open('file2') as (all, any): + | ^^^ A001 +28 | pass + | + +A001.py:27:50: A001 Variable `any` is shadowing a Python builtin + | +25 | pass +26 | +27 | with open('file') as str, open('file2') as (all, any): + | ^^^ A001 +28 | pass + | + +A001.py:30:8: A001 Variable `sum` is shadowing a Python builtin + | +28 | pass +29 | +30 | [0 for sum in ()] + | ^^^ A001 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A002_A002.py.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A002_A002.py.snap new file mode 100644 index 0000000000..d58e06a785 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A002_A002.py.snap @@ -0,0 +1,72 @@ +--- +source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs +--- +A002.py:1:11: A002 Argument `str` is shadowing a Python builtin + | +1 | def func1(str, /, type, *complex, Exception, **getattr): + | ^^^ A002 +2 | pass + | + +A002.py:1:19: A002 Argument `type` is shadowing a Python builtin + | +1 | def func1(str, /, type, *complex, Exception, **getattr): + | ^^^^ A002 +2 | pass + | + +A002.py:1:26: A002 Argument `complex` is shadowing a Python builtin + | +1 | def func1(str, /, type, *complex, Exception, **getattr): + | ^^^^^^^ A002 +2 | pass + | + +A002.py:1:35: A002 Argument `Exception` is shadowing a Python builtin + | +1 | def func1(str, /, type, *complex, Exception, **getattr): + | ^^^^^^^^^ A002 +2 | pass + | + +A002.py:1:48: A002 Argument `getattr` is shadowing a Python builtin + | +1 | def func1(str, /, type, *complex, Exception, **getattr): + | ^^^^^^^ A002 +2 | pass + | + +A002.py:5:17: A002 Argument `bytes` is shadowing a Python builtin + | +5 | async def func2(bytes): + | ^^^^^ A002 +6 | pass + | + +A002.py:8:17: A002 Argument `id` is shadowing a Python builtin + | +6 | pass +7 | +8 | async def func3(id, dir): + | ^^ A002 +9 | pass + | + +A002.py:8:21: A002 Argument `dir` is shadowing a Python builtin + | +6 | pass +7 | +8 | async def func3(id, dir): + | ^^^ A002 +9 | pass + | + +A002.py:11:16: A002 Argument `float` is shadowing a Python builtin + | + 9 | pass +10 | +11 | map([], lambda float: ...) + | ^^^^^ A002 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A002_A002.py_builtins_ignorelist.snap b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A002_A002.py_builtins_ignorelist.snap new file mode 100644 index 0000000000..ed3377c023 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A002_A002.py_builtins_ignorelist.snap @@ -0,0 +1,54 @@ +--- +source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs +--- +A002.py:1:11: A002 Argument `str` is shadowing a Python builtin + | +1 | def func1(str, /, type, *complex, Exception, **getattr): + | ^^^ A002 +2 | pass + | + +A002.py:1:19: A002 Argument `type` is shadowing a Python builtin + | +1 | def func1(str, /, type, *complex, Exception, **getattr): + | ^^^^ A002 +2 | pass + | + +A002.py:1:26: A002 Argument `complex` is shadowing a Python builtin + | +1 | def func1(str, /, type, *complex, Exception, **getattr): + | ^^^^^^^ A002 +2 | pass + | + +A002.py:1:35: A002 Argument `Exception` is shadowing a Python builtin + | +1 | def func1(str, /, type, *complex, Exception, **getattr): + | ^^^^^^^^^ A002 +2 | pass + | + +A002.py:1:48: A002 Argument `getattr` is shadowing a Python builtin + | +1 | def func1(str, /, type, *complex, Exception, **getattr): + | ^^^^^^^ A002 +2 | pass + | + +A002.py:5:17: A002 Argument `bytes` is shadowing a Python builtin + | +5 | async def func2(bytes): + | ^^^^^ A002 +6 | pass + | + +A002.py:11:16: A002 Argument `float` is shadowing a Python builtin + | + 9 | pass +10 | +11 | map([], lambda float: ...) + | ^^^^^ A002 + | + + 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 new file mode 100644 index 0000000000..4e871c0691 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A003_A003.py.snap @@ -0,0 +1,68 @@ +--- +source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs +--- +A003.py:2:5: A003 Class attribute `ImportError` is shadowing a Python builtin + | +1 | class MyClass: +2 | ImportError = 4 + | ^^^^^^^^^^^ A003 +3 | id: int +4 | dir = "/" + | + +A003.py:3:5: A003 Class attribute `id` is shadowing a Python builtin + | +1 | class MyClass: +2 | ImportError = 4 +3 | id: int + | ^^ A003 +4 | dir = "/" + | + +A003.py:4:5: A003 Class attribute `dir` is shadowing a Python builtin + | +2 | ImportError = 4 +3 | id: int +4 | dir = "/" + | ^^^ A003 +5 | +6 | def __init__(self): + | + +A003.py:11:9: A003 Class attribute `str` is shadowing a Python builtin + | + 9 | self.dir = "." +10 | +11 | def str(self): + | ^^^ A003 +12 | pass + | + +A003.py:29:9: A003 Class attribute `str` is shadowing a Python builtin + | +27 | ... +28 | +29 | def str(self) -> None: + | ^^^ A003 +30 | ... + | + +A003.py:40:9: A003 Class attribute `str` is shadowing a Python builtin + | +38 | ... +39 | +40 | def str(self) -> None: + | ^^^ A003 +41 | ... + | + +A003.py:52:9: A003 Class attribute `int` is shadowing a Python builtin + | +50 | pass +51 | +52 | def int(self): + | ^^^ A003 +53 | 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 new file mode 100644 index 0000000000..d533b2ac7c --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_builtins/snapshots/ruff_linter__rules__flake8_builtins__tests__A003_A003.py_builtins_ignorelist.snap @@ -0,0 +1,49 @@ +--- +source: crates/ruff_linter/src/rules/flake8_builtins/mod.rs +--- +A003.py:2:5: A003 Class attribute `ImportError` is shadowing a Python builtin + | +1 | class MyClass: +2 | ImportError = 4 + | ^^^^^^^^^^^ A003 +3 | id: int +4 | dir = "/" + | + +A003.py:11:9: A003 Class attribute `str` is shadowing a Python builtin + | + 9 | self.dir = "." +10 | +11 | def str(self): + | ^^^ A003 +12 | pass + | + +A003.py:29:9: A003 Class attribute `str` is shadowing a Python builtin + | +27 | ... +28 | +29 | def str(self) -> None: + | ^^^ A003 +30 | ... + | + +A003.py:40:9: A003 Class attribute `str` is shadowing a Python builtin + | +38 | ... +39 | +40 | def str(self) -> None: + | ^^^ A003 +41 | ... + | + +A003.py:52:9: A003 Class attribute `int` is shadowing a Python builtin + | +50 | pass +51 | +52 | def int(self): + | ^^^ A003 +53 | pass + | + + diff --git a/crates/ruff/src/rules/flake8_commas/mod.rs b/crates/ruff_linter/src/rules/flake8_commas/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_commas/mod.rs rename to crates/ruff_linter/src/rules/flake8_commas/mod.rs diff --git a/crates/ruff/src/rules/flake8_commas/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_commas/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_commas/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_commas/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_commas/rules/trailing_commas.rs b/crates/ruff_linter/src/rules/flake8_commas/rules/trailing_commas.rs similarity index 100% rename from crates/ruff/src/rules/flake8_commas/rules/trailing_commas.rs rename to crates/ruff_linter/src/rules/flake8_commas/rules/trailing_commas.rs 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 new file mode 100644 index 0000000000..0fa18c2cea --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_commas/snapshots/ruff_linter__rules__flake8_commas__tests__COM81.py.snap @@ -0,0 +1,942 @@ +--- +source: crates/ruff_linter/src/rules/flake8_commas/mod.rs +--- +COM81.py:4:18: COM812 [*] Trailing comma missing + | +2 | bad_function_call( +3 | param1='test', +4 | param2='test' + | COM812 +5 | ) +6 | # ==> bad_list.py <== + | + = help: Add trailing comma + +ℹ Fix +1 1 | # ==> bad_function_call.py <== +2 2 | bad_function_call( +3 3 | param1='test', +4 |- param2='test' + 4 |+ param2='test', +5 5 | ) +6 6 | # ==> bad_list.py <== +7 7 | bad_list = [ + +COM81.py:10:6: COM812 [*] Trailing comma missing + | + 8 | 1, + 9 | 2, +10 | 3 + | COM812 +11 | ] + | + = help: Add trailing comma + +ℹ Fix +7 7 | bad_list = [ +8 8 | 1, +9 9 | 2, +10 |- 3 + 10 |+ 3, +11 11 | ] +12 12 | +13 13 | bad_list_with_comment = [ + +COM81.py:16:6: COM812 [*] Trailing comma missing + | +14 | 1, +15 | 2, +16 | 3 + | COM812 +17 | # still needs a comma! +18 | ] + | + = help: Add trailing comma + +ℹ Fix +13 13 | bad_list_with_comment = [ +14 14 | 1, +15 15 | 2, +16 |- 3 + 16 |+ 3, +17 17 | # still needs a comma! +18 18 | ] +19 19 | + +COM81.py:23:6: COM812 [*] Trailing comma missing + | +21 | 1, +22 | 2, +23 | 3 + | COM812 + | + = help: Add trailing comma + +ℹ Fix +20 20 | bad_list_with_extra_empty = [ +21 21 | 1, +22 22 | 2, +23 |- 3 + 23 |+ 3, +24 24 | +25 25 | +26 26 | + +COM81.py:36:8: COM818 Trailing comma on bare tuple prohibited + | +34 | foo = (1,) +35 | +36 | foo = 1, + | ^ COM818 +37 | +38 | bar = 1; foo = bar, + | + +COM81.py:38:19: COM818 Trailing comma on bare tuple prohibited + | +36 | foo = 1, +37 | +38 | bar = 1; foo = bar, + | ^ COM818 +39 | +40 | foo = ( + | + +COM81.py:45:8: COM818 Trailing comma on bare tuple prohibited + | +43 | ) +44 | +45 | foo = 3, + | ^ COM818 +46 | +47 | class A(object): + | + +COM81.py:49:10: COM818 Trailing comma on bare tuple prohibited + | +47 | class A(object): +48 | foo = 3 +49 | bar = 10, + | ^ COM818 +50 | foo_bar = 2 + | + +COM81.py:56:32: COM818 Trailing comma on bare tuple prohibited + | +54 | from foo import bar, baz +55 | +56 | group_by = function_call('arg'), + | ^ COM818 +57 | +58 | group_by = ('foobar' * 3), + | + +COM81.py:58:26: COM818 Trailing comma on bare tuple prohibited + | +56 | group_by = function_call('arg'), +57 | +58 | group_by = ('foobar' * 3), + | ^ COM818 +59 | +60 | def foo(): + | + +COM81.py:61:17: COM818 Trailing comma on bare tuple prohibited + | +60 | def foo(): +61 | return False, + | ^ COM818 +62 | +63 | # ==> callable_before_parenth_form.py <== + | + +COM81.py:70:8: COM812 [*] Trailing comma missing + | +69 | {'foo': foo}['foo']( +70 | bar + | COM812 +71 | ) + | + = help: Add trailing comma + +ℹ Fix +67 67 | pass +68 68 | +69 69 | {'foo': foo}['foo']( +70 |- bar + 70 |+ bar, +71 71 | ) +72 72 | +73 73 | {'foo': foo}['foo']( + +COM81.py:78:8: COM812 [*] Trailing comma missing + | +77 | (foo)( +78 | bar + | COM812 +79 | ) + | + = help: Add trailing comma + +ℹ Fix +75 75 | ) +76 76 | +77 77 | (foo)( +78 |- bar + 78 |+ bar, +79 79 | ) +80 80 | +81 81 | (foo)[0]( + +COM81.py:86:8: COM812 [*] Trailing comma missing + | +85 | [foo][0]( +86 | bar + | COM812 +87 | ) + | + = help: Add trailing comma + +ℹ Fix +83 83 | ) +84 84 | +85 85 | [foo][0]( +86 |- bar + 86 |+ bar, +87 87 | ) +88 88 | +89 89 | [foo][0]( + +COM81.py:152:6: COM812 [*] Trailing comma missing + | +150 | # ==> keyword_before_parenth_form/base_bad.py <== +151 | from x import ( +152 | y + | COM812 +153 | ) + | + = help: Add trailing comma + +ℹ Fix +149 149 | +150 150 | # ==> keyword_before_parenth_form/base_bad.py <== +151 151 | from x import ( +152 |- y + 152 |+ y, +153 153 | ) +154 154 | +155 155 | assert( + +COM81.py:158:11: COM812 [*] Trailing comma missing + | +156 | SyntaxWarning, +157 | ThrownHere, +158 | Anyway + | COM812 +159 | ) + | + = help: Add trailing comma + +ℹ Fix +155 155 | assert( +156 156 | SyntaxWarning, +157 157 | ThrownHere, +158 |- Anyway + 158 |+ Anyway, +159 159 | ) +160 160 | +161 161 | # async await is fine outside an async def + +COM81.py:293:15: COM812 [*] Trailing comma missing + | +291 | # ==> multiline_bad_dict.py <== +292 | multiline_bad_dict = { +293 | "bad": 123 + | COM812 +294 | } +295 | # ==> multiline_bad_function_def.py <== + | + = help: Add trailing comma + +ℹ Fix +290 290 | +291 291 | # ==> multiline_bad_dict.py <== +292 292 | multiline_bad_dict = { +293 |- "bad": 123 + 293 |+ "bad": 123, +294 294 | } +295 295 | # ==> multiline_bad_function_def.py <== +296 296 | def func_good( + +COM81.py:304:14: COM812 [*] Trailing comma missing + | +302 | def func_bad( +303 | a = 3, +304 | b = 2 + | COM812 +305 | ): +306 | pass + | + = help: Add trailing comma + +ℹ Fix +301 301 | +302 302 | def func_bad( +303 303 | a = 3, +304 |- b = 2 + 304 |+ b = 2, +305 305 | ): +306 306 | pass +307 307 | + +COM81.py:310:14: COM812 [*] Trailing comma missing + | +308 | # ==> multiline_bad_function_one_param.py <== +309 | def func( +310 | a = 3 + | COM812 +311 | ): +312 | pass + | + = help: Add trailing comma + +ℹ Fix +307 307 | +308 308 | # ==> multiline_bad_function_one_param.py <== +309 309 | def func( +310 |- a = 3 + 310 |+ a = 3, +311 311 | ): +312 312 | pass +313 313 | + +COM81.py:316:10: COM812 [*] Trailing comma missing + | +315 | func( +316 | a = 3 + | COM812 +317 | ) + | + = help: Add trailing comma + +ℹ Fix +313 313 | +314 314 | +315 315 | func( +316 |- a = 3 + 316 |+ a = 3, +317 317 | ) +318 318 | +319 319 | # ==> multiline_bad_or_dict.py <== + +COM81.py:322:15: COM812 [*] Trailing comma missing + | +320 | multiline_bad_or_dict = { +321 | "good": True or False, +322 | "bad": 123 + | COM812 +323 | } + | + = help: Add trailing comma + +ℹ Fix +319 319 | # ==> multiline_bad_or_dict.py <== +320 320 | multiline_bad_or_dict = { +321 321 | "good": True or False, +322 |- "bad": 123 + 322 |+ "bad": 123, +323 323 | } +324 324 | +325 325 | # ==> multiline_good_dict.py <== + +COM81.py:368:15: COM812 [*] Trailing comma missing + | +366 | multiline_index_access[ +367 | "probably fine", +368 | "not good" + | COM812 +369 | ] + | + = help: Add trailing comma + +ℹ Fix +365 365 | +366 366 | multiline_index_access[ +367 367 | "probably fine", +368 |- "not good" + 368 |+ "not good", +369 369 | ] +370 370 | +371 371 | multiline_index_access[ + +COM81.py:375:15: COM812 [*] Trailing comma missing + | +373 | "fine", +374 | : +375 | "not good" + | COM812 +376 | ] + | + = help: Add trailing comma + +ℹ Fix +372 372 | "fine", +373 373 | "fine", +374 374 | : +375 |- "not good" + 375 |+ "not good", +376 376 | ] +377 377 | +378 378 | # ==> multiline_string.py <== + +COM81.py:404:15: COM812 [*] Trailing comma missing + | +402 | "fine" +403 | : +404 | "not fine" + | COM812 +405 | ] + | + = help: Add trailing comma + +ℹ Fix +401 401 | "fine", +402 402 | "fine" +403 403 | : +404 |- "not fine" + 404 |+ "not fine", +405 405 | ] +406 406 | +407 407 | multiline_index_access[ + +COM81.py:432:15: COM812 [*] Trailing comma missing + | +430 | : +431 | "fine", +432 | "not fine" + | COM812 +433 | ] + | + = help: Add trailing comma + +ℹ Fix +429 429 | "fine" +430 430 | : +431 431 | "fine", +432 |- "not fine" + 432 |+ "not fine", +433 433 | ] +434 434 | +435 435 | multiline_index_access[ + +COM81.py:485:21: COM819 [*] Trailing comma prohibited + | +484 | # ==> prohibited.py <== +485 | foo = ['a', 'b', 'c',] + | ^ COM819 +486 | +487 | bar = { a: b,} + | + = help: Remove trailing comma + +ℹ Fix +482 482 | ) +483 483 | +484 484 | # ==> prohibited.py <== +485 |-foo = ['a', 'b', 'c',] + 485 |+foo = ['a', 'b', 'c'] +486 486 | +487 487 | bar = { a: b,} +488 488 | + +COM81.py:487:13: COM819 [*] Trailing comma prohibited + | +485 | foo = ['a', 'b', 'c',] +486 | +487 | bar = { a: b,} + | ^ COM819 +488 | +489 | def bah(ham, spam,): + | + = help: Remove trailing comma + +ℹ Fix +484 484 | # ==> prohibited.py <== +485 485 | foo = ['a', 'b', 'c',] +486 486 | +487 |-bar = { a: b,} + 487 |+bar = { a: b} +488 488 | +489 489 | def bah(ham, spam,): +490 490 | pass + +COM81.py:489:18: COM819 [*] Trailing comma prohibited + | +487 | bar = { a: b,} +488 | +489 | def bah(ham, spam,): + | ^ COM819 +490 | pass + | + = help: Remove trailing comma + +ℹ Fix +486 486 | +487 487 | bar = { a: b,} +488 488 | +489 |-def bah(ham, spam,): + 489 |+def bah(ham, spam): +490 490 | pass +491 491 | +492 492 | (0,) + +COM81.py:494:6: COM819 [*] Trailing comma prohibited + | +492 | (0,) +493 | +494 | (0, 1,) + | ^ COM819 +495 | +496 | foo = ['a', 'b', 'c', ] + | + = help: Remove trailing comma + +ℹ Fix +491 491 | +492 492 | (0,) +493 493 | +494 |-(0, 1,) + 494 |+(0, 1) +495 495 | +496 496 | foo = ['a', 'b', 'c', ] +497 497 | + +COM81.py:496:21: COM819 [*] Trailing comma prohibited + | +494 | (0, 1,) +495 | +496 | foo = ['a', 'b', 'c', ] + | ^ COM819 +497 | +498 | bar = { a: b, } + | + = help: Remove trailing comma + +ℹ Fix +493 493 | +494 494 | (0, 1,) +495 495 | +496 |-foo = ['a', 'b', 'c', ] + 496 |+foo = ['a', 'b', 'c' ] +497 497 | +498 498 | bar = { a: b, } +499 499 | + +COM81.py:498:13: COM819 [*] Trailing comma prohibited + | +496 | foo = ['a', 'b', 'c', ] +497 | +498 | bar = { a: b, } + | ^ COM819 +499 | +500 | def bah(ham, spam, ): + | + = help: Remove trailing comma + +ℹ Fix +495 495 | +496 496 | foo = ['a', 'b', 'c', ] +497 497 | +498 |-bar = { a: b, } + 498 |+bar = { a: b } +499 499 | +500 500 | def bah(ham, spam, ): +501 501 | pass + +COM81.py:500:18: COM819 [*] Trailing comma prohibited + | +498 | bar = { a: b, } +499 | +500 | def bah(ham, spam, ): + | ^ COM819 +501 | pass + | + = help: Remove trailing comma + +ℹ Fix +497 497 | +498 498 | bar = { a: b, } +499 499 | +500 |-def bah(ham, spam, ): + 500 |+def bah(ham, spam ): +501 501 | pass +502 502 | +503 503 | (0, ) + +COM81.py:505:6: COM819 [*] Trailing comma prohibited + | +503 | (0, ) +504 | +505 | (0, 1, ) + | ^ COM819 +506 | +507 | image[:, :, 0] + | + = help: Remove trailing comma + +ℹ Fix +502 502 | +503 503 | (0, ) +504 504 | +505 |-(0, 1, ) + 505 |+(0, 1 ) +506 506 | +507 507 | image[:, :, 0] +508 508 | + +COM81.py:511:10: COM819 [*] Trailing comma prohibited + | +509 | image[:,] +510 | +511 | image[:,:,] + | ^ COM819 +512 | +513 | lambda x, : + | + = help: Remove trailing comma + +ℹ Fix +508 508 | +509 509 | image[:,] +510 510 | +511 |-image[:,:,] + 511 |+image[:,:] +512 512 | +513 513 | lambda x, : +514 514 | + +COM81.py:513:9: COM819 [*] Trailing comma prohibited + | +511 | image[:,:,] +512 | +513 | lambda x, : + | ^ COM819 +514 | +515 | # ==> unpack.py <== + | + = help: Remove trailing comma + +ℹ Fix +510 510 | +511 511 | image[:,:,] +512 512 | +513 |-lambda x, : + 513 |+lambda x : +514 514 | +515 515 | # ==> unpack.py <== +516 516 | def function( + +COM81.py:519:13: COM812 [*] Trailing comma missing + | +517 | foo, +518 | bar, +519 | **kwargs + | COM812 +520 | ): +521 | pass + | + = help: Add trailing comma + +ℹ Fix +516 516 | def function( +517 517 | foo, +518 518 | bar, +519 |- **kwargs + 519 |+ **kwargs, +520 520 | ): +521 521 | pass +522 522 | + +COM81.py:526:10: COM812 [*] Trailing comma missing + | +524 | foo, +525 | bar, +526 | *args + | COM812 +527 | ): +528 | pass + | + = help: Add trailing comma + +ℹ Fix +523 523 | def function( +524 524 | foo, +525 525 | bar, +526 |- *args + 526 |+ *args, +527 527 | ): +528 528 | pass +529 529 | + +COM81.py:534:16: COM812 [*] Trailing comma missing + | +532 | bar, +533 | *args, +534 | extra_kwarg + | COM812 +535 | ): +536 | pass + | + = help: Add trailing comma + +ℹ Fix +531 531 | foo, +532 532 | bar, +533 533 | *args, +534 |- extra_kwarg + 534 |+ extra_kwarg, +535 535 | ): +536 536 | pass +537 537 | + +COM81.py:541:13: COM812 [*] Trailing comma missing + | +539 | foo, +540 | bar, +541 | **kwargs + | COM812 +542 | ) + | + = help: Add trailing comma + +ℹ Fix +538 538 | result = function( +539 539 | foo, +540 540 | bar, +541 |- **kwargs + 541 |+ **kwargs, +542 542 | ) +543 543 | +544 544 | result = function( + +COM81.py:547:24: COM812 [*] Trailing comma missing + | +545 | foo, +546 | bar, +547 | **not_called_kwargs + | COM812 +548 | ) + | + = help: Add trailing comma + +ℹ Fix +544 544 | result = function( +545 545 | foo, +546 546 | bar, +547 |- **not_called_kwargs + 547 |+ **not_called_kwargs, +548 548 | ) +549 549 | +550 550 | def foo( + +COM81.py:554:15: COM812 [*] Trailing comma missing + | +552 | spam, +553 | *args, +554 | kwarg_only + | COM812 +555 | ): +556 | pass + | + = help: Add trailing comma + +ℹ Fix +551 551 | ham, +552 552 | spam, +553 553 | *args, +554 |- kwarg_only + 554 |+ kwarg_only, +555 555 | ): +556 556 | pass +557 557 | + +COM81.py:561:13: COM812 [*] Trailing comma missing + | +560 | foo( +561 | **kwargs + | COM812 +562 | ) + | + = help: Add trailing comma + +ℹ Fix +558 558 | # In python 3.5 if it's not a function def, commas are mandatory. +559 559 | +560 560 | foo( +561 |- **kwargs + 561 |+ **kwargs, +562 562 | ) +563 563 | +564 564 | { + +COM81.py:565:13: COM812 [*] Trailing comma missing + | +564 | { +565 | **kwargs + | COM812 +566 | } + | + = help: Add trailing comma + +ℹ Fix +562 562 | ) +563 563 | +564 564 | { +565 |- **kwargs + 565 |+ **kwargs, +566 566 | } +567 567 | +568 568 | ( + +COM81.py:573:10: COM812 [*] Trailing comma missing + | +572 | { +573 | *args + | COM812 +574 | } + | + = help: Add trailing comma + +ℹ Fix +570 570 | ) +571 571 | +572 572 | { +573 |- *args + 573 |+ *args, +574 574 | } +575 575 | +576 576 | [ + +COM81.py:577:10: COM812 [*] Trailing comma missing + | +576 | [ +577 | *args + | COM812 +578 | ] + | + = help: Add trailing comma + +ℹ Fix +574 574 | } +575 575 | +576 576 | [ +577 |- *args + 577 |+ *args, +578 578 | ] +579 579 | +580 580 | def foo( + +COM81.py:583:10: COM812 [*] Trailing comma missing + | +581 | ham, +582 | spam, +583 | *args + | COM812 +584 | ): +585 | pass + | + = help: Add trailing comma + +ℹ Fix +580 580 | def foo( +581 581 | ham, +582 582 | spam, +583 |- *args + 583 |+ *args, +584 584 | ): +585 585 | pass +586 586 | + +COM81.py:590:13: COM812 [*] Trailing comma missing + | +588 | ham, +589 | spam, +590 | **kwargs + | COM812 +591 | ): +592 | pass + | + = help: Add trailing comma + +ℹ Fix +587 587 | def foo( +588 588 | ham, +589 589 | spam, +590 |- **kwargs + 590 |+ **kwargs, +591 591 | ): +592 592 | pass +593 593 | + +COM81.py:598:15: COM812 [*] Trailing comma missing + | +596 | spam, +597 | *args, +598 | kwarg_only + | COM812 +599 | ): +600 | pass + | + = help: Add trailing comma + +ℹ Fix +595 595 | ham, +596 596 | spam, +597 597 | *args, +598 |- kwarg_only + 598 |+ kwarg_only, +599 599 | ): +600 600 | pass +601 601 | + +COM81.py:627:20: COM812 [*] Trailing comma missing + | +625 | foo, +626 | bar, +627 | **{'ham': spam} + | COM812 +628 | ) + | + = help: Add trailing comma + +ℹ Fix +624 624 | result = function( +625 625 | foo, +626 626 | bar, +627 |- **{'ham': spam} + 627 |+ **{'ham': spam}, +628 628 | ) +629 629 | +630 630 | # Make sure the COM812 and UP034 rules don't autofix simultaneously and cause a syntax error. + +COM81.py:632:42: COM812 [*] Trailing comma missing + | +630 | # Make sure the COM812 and UP034 rules don't autofix simultaneously and cause a syntax error. +631 | the_first_one = next( +632 | (i for i in range(10) if i // 2 == 0) # COM812 fix should include the final bracket + | COM812 +633 | ) + | + = help: Add trailing comma + +ℹ Fix +629 629 | +630 630 | # Make sure the COM812 and UP034 rules don't autofix simultaneously and cause a syntax error. +631 631 | the_first_one = next( +632 |- (i for i in range(10) if i // 2 == 0) # COM812 fix should include the final bracket + 632 |+ (i for i in range(10) if i // 2 == 0), # COM812 fix should include the final bracket +633 633 | ) +634 634 | +635 635 | foo = namedtuple( + + diff --git a/crates/ruff/src/rules/flake8_comprehensions/fixes.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/fixes.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/mod.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/mod.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/helpers.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/helpers.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/helpers.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/helpers.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_collection_call.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_collection_call.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_collection_call.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_collection_call.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_comprehension.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_comprehension.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension_any_all.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_comprehension_any_all.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension_any_all.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_comprehension_any_all.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_double_cast_or_process.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_double_cast_or_process.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_double_cast_or_process.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_double_cast_or_process.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_dict.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_dict.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_dict.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_dict.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_call.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_list_call.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_call.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_list_call.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_dict.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_dict.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_dict.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_dict.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_set.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_set.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_set.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_set.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_dict.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_dict.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_dict.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_dict.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_set.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_set.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_set.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_set.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_dict_call.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_dict_call.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_dict_call.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_dict_call.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_list_call.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_list_call.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_list_call.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_list_call.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_map.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_map.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_map.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_map.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_subscript_reversal.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_subscript_reversal.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_subscript_reversal.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_subscript_reversal.rs diff --git a/crates/ruff/src/rules/flake8_comprehensions/settings.rs b/crates/ruff_linter/src/rules/flake8_comprehensions/settings.rs similarity index 100% rename from crates/ruff/src/rules/flake8_comprehensions/settings.rs rename to crates/ruff_linter/src/rules/flake8_comprehensions/settings.rs 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 new file mode 100644 index 0000000000..924f9aad19 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C400_C400.py.snap @@ -0,0 +1,42 @@ +--- +source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs +--- +C400.py:1:5: C400 [*] Unnecessary generator (rewrite as a `list` comprehension) + | +1 | x = list(x for x in range(3)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ C400 +2 | x = list( +3 | x for x in range(3) + | + = help: Rewrite as a `list` comprehension + +ℹ Suggested fix +1 |-x = list(x for x in range(3)) + 1 |+x = [x for x in range(3)] +2 2 | x = list( +3 3 | x for x in range(3) +4 4 | ) + +C400.py:2:5: C400 [*] Unnecessary generator (rewrite as a `list` comprehension) + | +1 | x = list(x for x in range(3)) +2 | x = list( + | _____^ +3 | | x for x in range(3) +4 | | ) + | |_^ C400 + | + = help: Rewrite as a `list` comprehension + +ℹ Suggested fix +1 1 | x = list(x for x in range(3)) +2 |-x = list( + 2 |+x = [ +3 3 | x for x in range(3) +4 |-) + 4 |+] +5 5 | +6 6 | +7 7 | def list(*args, **kwargs): + + 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 new file mode 100644 index 0000000000..a46cb832d2 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C401_C401.py.snap @@ -0,0 +1,255 @@ +--- +source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs +--- +C401.py:1:5: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) + | +1 | x = set(x for x in range(3)) + | ^^^^^^^^^^^^^^^^^^^^^^^^ C401 +2 | x = set(x for x in range(3)) +3 | y = f"{set(a if a < 6 else 0 for a in range(3))}" + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +1 |-x = set(x for x in range(3)) + 1 |+x = {x for x in range(3)} +2 2 | x = set(x for x in range(3)) +3 3 | y = f"{set(a if a < 6 else 0 for a in range(3))}" +4 4 | _ = "{}".format(set(a if a < 6 else 0 for a in range(3))) + +C401.py:2:5: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) + | +1 | x = set(x for x in range(3)) +2 | x = set(x for x in range(3)) + | ^^^^^^^^^^^^^^^^^^^^^^^^ C401 +3 | y = f"{set(a if a < 6 else 0 for a in range(3))}" +4 | _ = "{}".format(set(a if a < 6 else 0 for a in range(3))) + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +1 1 | x = set(x for x in range(3)) +2 |-x = set(x for x in range(3)) + 2 |+x = {x for x in range(3)} +3 3 | y = f"{set(a if a < 6 else 0 for a in range(3))}" +4 4 | _ = "{}".format(set(a if a < 6 else 0 for a in range(3))) +5 5 | print(f"Hello {set(a for a in range(3))} World") + +C401.py:3:8: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) + | +1 | x = set(x for x in range(3)) +2 | x = set(x for x in range(3)) +3 | y = f"{set(a if a < 6 else 0 for a in range(3))}" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C401 +4 | _ = "{}".format(set(a if a < 6 else 0 for a in range(3))) +5 | print(f"Hello {set(a for a in range(3))} World") + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +1 1 | x = set(x for x in range(3)) +2 2 | x = set(x for x in range(3)) +3 |-y = f"{set(a if a < 6 else 0 for a in range(3))}" + 3 |+y = f"{ {a if a < 6 else 0 for a in range(3)} }" +4 4 | _ = "{}".format(set(a if a < 6 else 0 for a in range(3))) +5 5 | print(f"Hello {set(a for a in range(3))} World") +6 6 | + +C401.py:4:17: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) + | +2 | x = set(x for x in range(3)) +3 | y = f"{set(a if a < 6 else 0 for a in range(3))}" +4 | _ = "{}".format(set(a if a < 6 else 0 for a in range(3))) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C401 +5 | print(f"Hello {set(a for a in range(3))} World") + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +1 1 | x = set(x for x in range(3)) +2 2 | x = set(x for x in range(3)) +3 3 | y = f"{set(a if a < 6 else 0 for a in range(3))}" +4 |-_ = "{}".format(set(a if a < 6 else 0 for a in range(3))) + 4 |+_ = "{}".format({a if a < 6 else 0 for a in range(3)}) +5 5 | print(f"Hello {set(a for a in range(3))} World") +6 6 | +7 7 | + +C401.py:5:16: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) + | +3 | y = f"{set(a if a < 6 else 0 for a in range(3))}" +4 | _ = "{}".format(set(a if a < 6 else 0 for a in range(3))) +5 | print(f"Hello {set(a for a in range(3))} World") + | ^^^^^^^^^^^^^^^^^^^^^^^^ C401 + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +2 2 | x = set(x for x in range(3)) +3 3 | y = f"{set(a if a < 6 else 0 for a in range(3))}" +4 4 | _ = "{}".format(set(a if a < 6 else 0 for a in range(3))) +5 |-print(f"Hello {set(a for a in range(3))} World") + 5 |+print(f"Hello { {a for a in range(3)} } World") +6 6 | +7 7 | +8 8 | def f(x): + +C401.py:12:16: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) + | +12 | print(f'Hello {set(a for a in "abc")} World') + | ^^^^^^^^^^^^^^^^^^^^^ C401 +13 | print(f"Hello {set(a for a in 'abc')} World") +14 | print(f"Hello {set(f(a) for a in 'abc')} World") + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +9 9 | return x +10 10 | +11 11 | +12 |-print(f'Hello {set(a for a in "abc")} World') + 12 |+print(f'Hello { {a for a in "abc"} } World') +13 13 | print(f"Hello {set(a for a in 'abc')} World") +14 14 | print(f"Hello {set(f(a) for a in 'abc')} World") +15 15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") + +C401.py:13:16: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) + | +12 | print(f'Hello {set(a for a in "abc")} World') +13 | print(f"Hello {set(a for a in 'abc')} World") + | ^^^^^^^^^^^^^^^^^^^^^ C401 +14 | print(f"Hello {set(f(a) for a in 'abc')} World") +15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +10 10 | +11 11 | +12 12 | print(f'Hello {set(a for a in "abc")} World') +13 |-print(f"Hello {set(a for a in 'abc')} World") + 13 |+print(f"Hello { {a for a in 'abc'} } World") +14 14 | print(f"Hello {set(f(a) for a in 'abc')} World") +15 15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") +16 16 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") + +C401.py:14:16: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) + | +12 | print(f'Hello {set(a for a in "abc")} World') +13 | print(f"Hello {set(a for a in 'abc')} World") +14 | print(f"Hello {set(f(a) for a in 'abc')} World") + | ^^^^^^^^^^^^^^^^^^^^^^^^ C401 +15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") +16 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +11 11 | +12 12 | print(f'Hello {set(a for a in "abc")} World') +13 13 | print(f"Hello {set(a for a in 'abc')} World") +14 |-print(f"Hello {set(f(a) for a in 'abc')} World") + 14 |+print(f"Hello { {f(a) for a in 'abc'} } World") +15 15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") +16 16 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") +17 17 | + +C401.py:15:10: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) + | +13 | print(f"Hello {set(a for a in 'abc')} World") +14 | print(f"Hello {set(f(a) for a in 'abc')} World") +15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") + | ^^^^^^^^^^^^^^^^^^^^^ C401 +16 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +12 12 | print(f'Hello {set(a for a in "abc")} World') +13 13 | print(f"Hello {set(a for a in 'abc')} World") +14 14 | print(f"Hello {set(f(a) for a in 'abc')} World") +15 |-print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") + 15 |+print(f"{ {a for a in 'abc'} - set(a for a in 'ab')}") +16 16 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") +17 17 | +18 18 | # The fix generated for this diagnostic is incorrect, as we add additional space + +C401.py:15:34: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) + | +13 | print(f"Hello {set(a for a in 'abc')} World") +14 | print(f"Hello {set(f(a) for a in 'abc')} World") +15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") + | ^^^^^^^^^^^^^^^^^^^^ C401 +16 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +12 12 | print(f'Hello {set(a for a in "abc")} World') +13 13 | print(f"Hello {set(a for a in 'abc')} World") +14 14 | print(f"Hello {set(f(a) for a in 'abc')} World") +15 |-print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") + 15 |+print(f"{set(a for a in 'abc') - {a for a in 'ab'} }") +16 16 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") +17 17 | +18 18 | # The fix generated for this diagnostic is incorrect, as we add additional space + +C401.py:16:11: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) + | +14 | print(f"Hello {set(f(a) for a in 'abc')} World") +15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") +16 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") + | ^^^^^^^^^^^^^^^^^^^^^ C401 +17 | +18 | # The fix generated for this diagnostic is incorrect, as we add additional space + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +13 13 | print(f"Hello {set(a for a in 'abc')} World") +14 14 | print(f"Hello {set(f(a) for a in 'abc')} World") +15 15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") +16 |-print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") + 16 |+print(f"{ {a for a in 'abc'} - set(a for a in 'ab') }") +17 17 | +18 18 | # The fix generated for this diagnostic is incorrect, as we add additional space +19 19 | # around the set comprehension. + +C401.py:16:35: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) + | +14 | print(f"Hello {set(f(a) for a in 'abc')} World") +15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") +16 | print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") + | ^^^^^^^^^^^^^^^^^^^^ C401 +17 | +18 | # The fix generated for this diagnostic is incorrect, as we add additional space + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +13 13 | print(f"Hello {set(a for a in 'abc')} World") +14 14 | print(f"Hello {set(f(a) for a in 'abc')} World") +15 15 | print(f"{set(a for a in 'abc') - set(a for a in 'ab')}") +16 |-print(f"{ set(a for a in 'abc') - set(a for a in 'ab') }") + 16 |+print(f"{ set(a for a in 'abc') - {a for a in 'ab'} }") +17 17 | +18 18 | # The fix generated for this diagnostic is incorrect, as we add additional space +19 19 | # around the set comprehension. + +C401.py:20:12: C401 [*] Unnecessary generator (rewrite as a `set` comprehension) + | +18 | # The fix generated for this diagnostic is incorrect, as we add additional space +19 | # around the set comprehension. +20 | print(f"{ {set(a for a in 'abc')} }") + | ^^^^^^^^^^^^^^^^^^^^^ C401 + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +17 17 | +18 18 | # The fix generated for this diagnostic is incorrect, as we add additional space +19 19 | # around the set comprehension. +20 |-print(f"{ {set(a for a in 'abc')} }") + 20 |+print(f"{ { {a for a in 'abc'} } }") + + 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 new file mode 100644 index 0000000000..86d9bacc13 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C402_C402.py.snap @@ -0,0 +1,269 @@ +--- +source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs +--- +C402.py:1:1: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) + | +1 | dict((x, x) for x in range(3)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 +2 | dict( +3 | (x, x) for x in range(3) + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +1 |-dict((x, x) for x in range(3)) + 1 |+{x: x for x in range(3)} +2 2 | dict( +3 3 | (x, x) for x in range(3) +4 4 | ) + +C402.py:2:1: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) + | +1 | dict((x, x) for x in range(3)) +2 | / dict( +3 | | (x, x) for x in range(3) +4 | | ) + | |_^ C402 +5 | dict(((x, x) for x in range(3)), z=3) +6 | y = f'{dict((x, x) for x in range(3))}' + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +1 1 | dict((x, x) for x in range(3)) +2 |-dict( +3 |- (x, x) for x in range(3) +4 |-) + 2 |+{ + 3 |+ x: x for x in range(3) + 4 |+} +5 5 | dict(((x, x) for x in range(3)), z=3) +6 6 | y = f'{dict((x, x) for x in range(3))}' +7 7 | print(f'Hello {dict((x, x) for x in range(3))} World') + +C402.py:6:8: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) + | +4 | ) +5 | dict(((x, x) for x in range(3)), z=3) +6 | y = f'{dict((x, x) for x in range(3))}' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 +7 | print(f'Hello {dict((x, x) for x in range(3))} World') +8 | print(f"Hello {dict((x, x) for x in 'abc')} World") + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +3 3 | (x, x) for x in range(3) +4 4 | ) +5 5 | dict(((x, x) for x in range(3)), z=3) +6 |-y = f'{dict((x, x) for x in range(3))}' + 6 |+y = f'{ {x: x for x in range(3)} }' +7 7 | print(f'Hello {dict((x, x) for x in range(3))} World') +8 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") +9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') + +C402.py:7:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) + | +5 | dict(((x, x) for x in range(3)), z=3) +6 | y = f'{dict((x, x) for x in range(3))}' +7 | print(f'Hello {dict((x, x) for x in range(3))} World') + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 +8 | print(f"Hello {dict((x, x) for x in 'abc')} World") +9 | print(f'Hello {dict((x, x) for x in "abc")} World') + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +4 4 | ) +5 5 | dict(((x, x) for x in range(3)), z=3) +6 6 | y = f'{dict((x, x) for x in range(3))}' +7 |-print(f'Hello {dict((x, x) for x in range(3))} World') + 7 |+print(f'Hello { {x: x for x in range(3)} } World') +8 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") +9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') +10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') + +C402.py:8:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) + | + 6 | y = f'{dict((x, x) for x in range(3))}' + 7 | print(f'Hello {dict((x, x) for x in range(3))} World') + 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 + 9 | print(f'Hello {dict((x, x) for x in "abc")} World') +10 | print(f'Hello {dict((x,x) for x in "abc")} World') + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +5 5 | dict(((x, x) for x in range(3)), z=3) +6 6 | y = f'{dict((x, x) for x in range(3))}' +7 7 | print(f'Hello {dict((x, x) for x in range(3))} World') +8 |-print(f"Hello {dict((x, x) for x in 'abc')} World") + 8 |+print(f"Hello { {x: x for x in 'abc'} } World") +9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') +10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') +11 11 | + +C402.py:9:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) + | + 7 | print(f'Hello {dict((x, x) for x in range(3))} World') + 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") + 9 | print(f'Hello {dict((x, x) for x in "abc")} World') + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 +10 | print(f'Hello {dict((x,x) for x in "abc")} World') + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +6 6 | y = f'{dict((x, x) for x in range(3))}' +7 7 | print(f'Hello {dict((x, x) for x in range(3))} World') +8 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") +9 |-print(f'Hello {dict((x, x) for x in "abc")} World') + 9 |+print(f'Hello { {x: x for x in "abc"} } World') +10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') +11 11 | +12 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' + +C402.py:10:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) + | + 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") + 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 | +12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +7 7 | print(f'Hello {dict((x, x) for x in range(3))} World') +8 8 | print(f"Hello {dict((x, x) for x in 'abc')} World") +9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') +10 |-print(f'Hello {dict((x,x) for x in "abc")} World') + 10 |+print(f'Hello { {x: x for x in "abc"} } World') +11 11 | +12 12 | f'{dict((x, x) for x in range(3)) | dict((x, x) for x in range(3))}' +13 13 | f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' + +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 | +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)) }' + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') +10 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))}' + 12 |+f'{ {x: x for x in range(3)} | dict((x, x) for x in range(3))}' +13 13 | f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' +14 14 | +15 15 | def f(x): + +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 | +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)) }' + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +9 9 | print(f'Hello {dict((x, x) for x in "abc")} World') +10 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))}' + 12 |+f'{dict((x, x) for x in range(3)) | {x: x for x in range(3)} }' +13 13 | f'{ dict((x, x) for x in range(3)) | dict((x, x) for x in range(3)) }' +14 14 | +15 15 | def f(x): + +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 | +15 | def f(x): + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') +11 11 | +12 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)) }' + 13 |+f'{ {x: x for x in range(3)} | dict((x, x) for x in range(3)) }' +14 14 | +15 15 | def f(x): +16 16 | return x + +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 | +15 | def f(x): + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +10 10 | print(f'Hello {dict((x,x) for x in "abc")} World') +11 11 | +12 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)) }' + 13 |+f'{ dict((x, x) for x in range(3)) | {x: x for x in range(3)} }' +14 14 | +15 15 | def f(x): +16 16 | return x + +C402.py:18:16: C402 [*] Unnecessary generator (rewrite as a `dict` comprehension) + | +16 | return x +17 | +18 | print(f'Hello {dict((x,f(x)) for x in "abc")} World') + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C402 +19 | +20 | # Regression test for: https://github.com/astral-sh/ruff/issues/7086 + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +15 15 | def f(x): +16 16 | return x +17 17 | +18 |-print(f'Hello {dict((x,f(x)) for x in "abc")} World') + 18 |+print(f'Hello { {x: f(x) for x in "abc"} } World') +19 19 | +20 20 | # Regression test for: https://github.com/astral-sh/ruff/issues/7086 +21 21 | dict((k,v)for k,v in d.iteritems() if k in only_args) + +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 | +23 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458940 + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +18 18 | print(f'Hello {dict((x,f(x)) for x in "abc")} World') +19 19 | +20 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) + 21 |+{k: v for k,v in d.iteritems() if k in only_args} +22 22 | +23 23 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722458940 +24 24 | dict((*v, k) for k, v in enumerate(calendar.month_abbr)) + + 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 new file mode 100644 index 0000000000..9091d9352b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C403_C403.py.snap @@ -0,0 +1,172 @@ +--- +source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs +--- +C403.py:1:5: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) + | +1 | s = set([x for x in range(3)]) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ C403 +2 | s = set( +3 | [x for x in range(3)] + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +1 |-s = set([x for x in range(3)]) + 1 |+s = {x for x in range(3)} +2 2 | s = set( +3 3 | [x for x in range(3)] +4 4 | ) + +C403.py:2:5: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) + | +1 | s = set([x for x in range(3)]) +2 | s = set( + | _____^ +3 | | [x for x in range(3)] +4 | | ) + | |_^ C403 +5 | +6 | s = f"{set([x for x in 'ab'])}" + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +1 1 | s = set([x for x in range(3)]) +2 |-s = set( +3 |- [x for x in range(3)] +4 |-) + 2 |+s = { + 3 |+ x for x in range(3) + 4 |+} +5 5 | +6 6 | s = f"{set([x for x in 'ab'])}" +7 7 | s = f'{set([x for x in "ab"])}' + +C403.py:6:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) + | +4 | ) +5 | +6 | s = f"{set([x for x in 'ab'])}" + | ^^^^^^^^^^^^^^^^^^^^^^ C403 +7 | s = f'{set([x for x in "ab"])}' + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +3 3 | [x for x in range(3)] +4 4 | ) +5 5 | +6 |-s = f"{set([x for x in 'ab'])}" + 6 |+s = f"{ {x for x in 'ab'} }" +7 7 | s = f'{set([x for x in "ab"])}' +8 8 | +9 9 | def f(x): + +C403.py:7:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) + | +6 | s = f"{set([x for x in 'ab'])}" +7 | s = f'{set([x for x in "ab"])}' + | ^^^^^^^^^^^^^^^^^^^^^^ C403 +8 | +9 | def f(x): + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +4 4 | ) +5 5 | +6 6 | s = f"{set([x for x in 'ab'])}" +7 |-s = f'{set([x for x in "ab"])}' + 7 |+s = f'{ {x for x in "ab"} }' +8 8 | +9 9 | def f(x): +10 10 | return x + +C403.py:12:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) + | +10 | return x +11 | +12 | s = f"{set([f(x) for x in 'ab'])}" + | ^^^^^^^^^^^^^^^^^^^^^^^^^ C403 +13 | +14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +9 9 | def f(x): +10 10 | return x +11 11 | +12 |-s = f"{set([f(x) for x in 'ab'])}" + 12 |+s = f"{ {f(x) for x in 'ab'} }" +13 13 | +14 14 | s = f"{ set([x for x in 'ab']) | set([x for x in 'ab']) }" +15 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" + +C403.py:14:9: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) + | +12 | s = f"{set([f(x) for x in 'ab'])}" +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'])}" + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +11 11 | +12 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']) }" + 14 |+s = f"{ {x for x in 'ab'} | set([x for x in 'ab']) }" +15 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" + +C403.py:14:34: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) + | +12 | s = f"{set([f(x) for x in 'ab'])}" +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'])}" + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +11 11 | +12 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']) }" + 14 |+s = f"{ set([x for x in 'ab']) | {x for x in 'ab'} }" +15 15 | s = f"{set([x for x in 'ab']) | set([x for x in 'ab'])}" + +C403.py:15:8: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) + | +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 + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +12 12 | s = f"{set([f(x) for x in 'ab'])}" +13 13 | +14 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'])}" + 15 |+s = f"{ {x for x in 'ab'} | set([x for x in 'ab'])}" + +C403.py:15:33: C403 [*] Unnecessary `list` comprehension (rewrite as a `set` comprehension) + | +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 + | + = help: Rewrite as a `set` comprehension + +ℹ Suggested fix +12 12 | s = f"{set([f(x) for x in 'ab'])}" +13 13 | +14 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'])}" + 15 |+s = f"{set([x for x in 'ab']) | {x for x in 'ab'} }" + + 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 new file mode 100644 index 0000000000..d5bfe8a3a9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C404_C404.py.snap @@ -0,0 +1,196 @@ +--- +source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs +--- +C404.py:1:1: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) + | +1 | dict([(i, i) for i in range(3)]) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 +2 | dict([(i, i) for i in range(3)], z=4) + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +1 |-dict([(i, i) for i in range(3)]) + 1 |+{i: i for i in range(3)} +2 2 | dict([(i, i) for i in range(3)], z=4) +3 3 | +4 4 | def f(x): + +C404.py:7:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) + | +5 | return x +6 | +7 | f'{dict([(s,s) for s in "ab"])}' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 +8 | f"{dict([(s,s) for s in 'ab'])}" +9 | f"{dict([(s, s) for s in 'ab'])}" + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +4 4 | def f(x): +5 5 | return x +6 6 | +7 |-f'{dict([(s,s) for s in "ab"])}' + 7 |+f'{ {s: s for s in "ab"} }' +8 8 | f"{dict([(s,s) for s in 'ab'])}" +9 9 | f"{dict([(s, s) for s in 'ab'])}" +10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" + +C404.py:8:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) + | + 7 | f'{dict([(s,s) for s in "ab"])}' + 8 | f"{dict([(s,s) for s in 'ab'])}" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 + 9 | f"{dict([(s, s) for s in 'ab'])}" +10 | f"{dict([(s,f(s)) for s in 'ab'])}" + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +5 5 | return x +6 6 | +7 7 | f'{dict([(s,s) for s in "ab"])}' +8 |-f"{dict([(s,s) for s in 'ab'])}" + 8 |+f"{ {s: s for s in 'ab'} }" +9 9 | f"{dict([(s, s) for s in 'ab'])}" +10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" +11 11 | + +C404.py:9:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) + | + 7 | f'{dict([(s,s) for s in "ab"])}' + 8 | f"{dict([(s,s) for s in 'ab'])}" + 9 | f"{dict([(s, s) for s in 'ab'])}" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 +10 | f"{dict([(s,f(s)) for s in 'ab'])}" + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +6 6 | +7 7 | f'{dict([(s,s) for s in "ab"])}' +8 8 | f"{dict([(s,s) for s in 'ab'])}" +9 |-f"{dict([(s, s) for s in 'ab'])}" + 9 |+f"{ {s: s for s in 'ab'} }" +10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" +11 11 | +12 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' + +C404.py:10:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) + | + 8 | f"{dict([(s,s) for s in 'ab'])}" + 9 | f"{dict([(s, s) for s in 'ab'])}" +10 | f"{dict([(s,f(s)) for s in 'ab'])}" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 +11 | +12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +7 7 | f'{dict([(s,s) for s in "ab"])}' +8 8 | f"{dict([(s,s) for s in 'ab'])}" +9 9 | f"{dict([(s, s) for s in 'ab'])}" +10 |-f"{dict([(s,f(s)) for s in 'ab'])}" + 10 |+f"{ {s: f(s) for s in 'ab'} }" +11 11 | +12 12 | f'{dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"])}' +13 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' + +C404.py:12:4: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) + | +10 | f"{dict([(s,f(s)) for s in 'ab'])}" +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"]) }' + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +9 9 | f"{dict([(s, s) for s in 'ab'])}" +10 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"])}' + 12 |+f'{ {s: s for s in "ab"} | dict([(s,s) for s in "ab"])}' +13 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' +14 14 | +15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 + +C404.py:12:34: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) + | +10 | f"{dict([(s,f(s)) for s in 'ab'])}" +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"]) }' + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +9 9 | f"{dict([(s, s) for s in 'ab'])}" +10 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"])}' + 12 |+f'{dict([(s,s) for s in "ab"]) | {s: s for s in "ab"} }' +13 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' +14 14 | +15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 + +C404.py:13:5: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) + | +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 | +15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" +11 11 | +12 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"]) }' + 13 |+f'{ {s: s for s in "ab"} | dict([(s,s) for s in "ab"]) }' +14 14 | +15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 +16 16 | saved.append(dict([(k, v)for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]])) + +C404.py:13:35: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) + | +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 | +15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +10 10 | f"{dict([(s,f(s)) for s in 'ab'])}" +11 11 | +12 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"]) }' + 13 |+f'{ dict([(s,s) for s in "ab"]) | {s: s for s in "ab"} }' +14 14 | +15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 +16 16 | saved.append(dict([(k, v)for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]])) + +C404.py:16:14: C404 [*] Unnecessary `list` comprehension (rewrite as a `dict` comprehension) + | +15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 +16 | saved.append(dict([(k, v)for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]])) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C404 + | + = help: Rewrite as a `dict` comprehension + +ℹ Suggested fix +13 13 | f'{ dict([(s,s) for s in "ab"]) | dict([(s,s) for s in "ab"]) }' +14 14 | +15 15 | # Regression test for: https://github.com/astral-sh/ruff/issues/7087 +16 |-saved.append(dict([(k, v)for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]])) + 16 |+saved.append({k: v for k,v in list(unique_instance.__dict__.items()) if k in [f.name for f in unique_instance._meta.fields]}) + + 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 new file mode 100644 index 0000000000..1ae0f55d0d --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C405_C405.py.snap @@ -0,0 +1,413 @@ +--- +source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs +--- +C405.py:1:1: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) + | +1 | set([1, 2]) + | ^^^^^^^^^^^ C405 +2 | set((1, 2)) +3 | set([]) + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +1 |-set([1, 2]) + 1 |+{1, 2} +2 2 | set((1, 2)) +3 3 | set([]) +4 4 | set(()) + +C405.py:2:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) + | +1 | set([1, 2]) +2 | set((1, 2)) + | ^^^^^^^^^^^ C405 +3 | set([]) +4 | set(()) + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +1 1 | set([1, 2]) +2 |-set((1, 2)) + 2 |+{1, 2} +3 3 | set([]) +4 4 | set(()) +5 5 | set() + +C405.py:3:1: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) + | +1 | set([1, 2]) +2 | set((1, 2)) +3 | set([]) + | ^^^^^^^ C405 +4 | set(()) +5 | set() + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +1 1 | set([1, 2]) +2 2 | set((1, 2)) +3 |-set([]) + 3 |+set() +4 4 | set(()) +5 5 | set() +6 6 | set((1,)) + +C405.py:4:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) + | +2 | set((1, 2)) +3 | set([]) +4 | set(()) + | ^^^^^^^ C405 +5 | set() +6 | set((1,)) + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +1 1 | set([1, 2]) +2 2 | set((1, 2)) +3 3 | set([]) +4 |-set(()) +5 4 | set() + 5 |+set() +6 6 | set((1,)) +7 7 | set(( +8 8 | 1, + +C405.py:6:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) + | +4 | set(()) +5 | set() +6 | set((1,)) + | ^^^^^^^^^ C405 +7 | set(( +8 | 1, + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +3 3 | set([]) +4 4 | set(()) +5 5 | set() +6 |-set((1,)) + 6 |+{1} +7 7 | set(( +8 8 | 1, +9 9 | )) + +C405.py:7:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) + | + 5 | set() + 6 | set((1,)) + 7 | / set(( + 8 | | 1, + 9 | | )) + | |__^ C405 +10 | set([ +11 | 1, + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +4 4 | set(()) +5 5 | set() +6 6 | set((1,)) +7 |-set(( + 7 |+{ +8 8 | 1, +9 |-)) + 9 |+} +10 10 | set([ +11 11 | 1, +12 12 | ]) + +C405.py:10:1: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) + | + 8 | 1, + 9 | )) +10 | / set([ +11 | | 1, +12 | | ]) + | |__^ C405 +13 | set( +14 | (1,) + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +7 7 | set(( +8 8 | 1, +9 9 | )) +10 |-set([ + 10 |+{ +11 11 | 1, +12 |-]) + 12 |+} +13 13 | set( +14 14 | (1,) +15 15 | ) + +C405.py:13:1: C405 [*] Unnecessary `tuple` literal (rewrite as a `set` literal) + | +11 | 1, +12 | ]) +13 | / set( +14 | | (1,) +15 | | ) + | |_^ C405 +16 | set( +17 | [1,] + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +10 10 | set([ +11 11 | 1, +12 12 | ]) +13 |-set( +14 |- (1,) +15 |-) + 13 |+{1} +16 14 | set( +17 15 | [1,] +18 16 | ) + +C405.py:16:1: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) + | +14 | (1,) +15 | ) +16 | / set( +17 | | [1,] +18 | | ) + | |_^ C405 +19 | f"{set([1,2,3])}" +20 | f"{set(['a', 'b'])}" + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +13 13 | set( +14 14 | (1,) +15 15 | ) +16 |-set( +17 |- [1,] +18 |-) + 16 |+{1,} +19 17 | f"{set([1,2,3])}" +20 18 | f"{set(['a', 'b'])}" +21 19 | f'{set(["a", "b"])}' + +C405.py:19:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) + | +17 | [1,] +18 | ) +19 | f"{set([1,2,3])}" + | ^^^^^^^^^^^^ C405 +20 | f"{set(['a', 'b'])}" +21 | f'{set(["a", "b"])}' + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +16 16 | set( +17 17 | [1,] +18 18 | ) +19 |-f"{set([1,2,3])}" + 19 |+f"{ {1,2,3} }" +20 20 | f"{set(['a', 'b'])}" +21 21 | f'{set(["a", "b"])}' +22 22 | + +C405.py:20:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) + | +18 | ) +19 | f"{set([1,2,3])}" +20 | f"{set(['a', 'b'])}" + | ^^^^^^^^^^^^^^^ C405 +21 | f'{set(["a", "b"])}' + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +17 17 | [1,] +18 18 | ) +19 19 | f"{set([1,2,3])}" +20 |-f"{set(['a', 'b'])}" + 20 |+f"{ {'a', 'b'} }" +21 21 | f'{set(["a", "b"])}' +22 22 | +23 23 | f"{set(['a', 'b']) - set(['a'])}" + +C405.py:21:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) + | +19 | f"{set([1,2,3])}" +20 | f"{set(['a', 'b'])}" +21 | f'{set(["a", "b"])}' + | ^^^^^^^^^^^^^^^ C405 +22 | +23 | f"{set(['a', 'b']) - set(['a'])}" + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +18 18 | ) +19 19 | f"{set([1,2,3])}" +20 20 | f"{set(['a', 'b'])}" +21 |-f'{set(["a", "b"])}' + 21 |+f'{ {"a", "b"} }' +22 22 | +23 23 | f"{set(['a', 'b']) - set(['a'])}" +24 24 | f"{ set(['a', 'b']) - set(['a']) }" + +C405.py:23:4: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) + | +21 | f'{set(["a", "b"])}' +22 | +23 | f"{set(['a', 'b']) - set(['a'])}" + | ^^^^^^^^^^^^^^^ C405 +24 | f"{ set(['a', 'b']) - set(['a']) }" +25 | f"a {set(['a', 'b']) - set(['a'])} b" + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +20 20 | f"{set(['a', 'b'])}" +21 21 | f'{set(["a", "b"])}' +22 22 | +23 |-f"{set(['a', 'b']) - set(['a'])}" + 23 |+f"{ {'a', 'b'} - set(['a'])}" +24 24 | f"{ set(['a', 'b']) - set(['a']) }" +25 25 | f"a {set(['a', 'b']) - set(['a'])} b" +26 26 | f"a { set(['a', 'b']) - set(['a']) } b" + +C405.py:23:22: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) + | +21 | f'{set(["a", "b"])}' +22 | +23 | f"{set(['a', 'b']) - set(['a'])}" + | ^^^^^^^^^^ C405 +24 | f"{ set(['a', 'b']) - set(['a']) }" +25 | f"a {set(['a', 'b']) - set(['a'])} b" + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +20 20 | f"{set(['a', 'b'])}" +21 21 | f'{set(["a", "b"])}' +22 22 | +23 |-f"{set(['a', 'b']) - set(['a'])}" + 23 |+f"{set(['a', 'b']) - {'a'} }" +24 24 | f"{ set(['a', 'b']) - set(['a']) }" +25 25 | f"a {set(['a', 'b']) - set(['a'])} b" +26 26 | f"a { set(['a', 'b']) - set(['a']) } b" + +C405.py:24:5: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) + | +23 | f"{set(['a', 'b']) - set(['a'])}" +24 | f"{ set(['a', 'b']) - set(['a']) }" + | ^^^^^^^^^^^^^^^ C405 +25 | f"a {set(['a', 'b']) - set(['a'])} b" +26 | f"a { set(['a', 'b']) - set(['a']) } b" + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +21 21 | f'{set(["a", "b"])}' +22 22 | +23 23 | f"{set(['a', 'b']) - set(['a'])}" +24 |-f"{ set(['a', 'b']) - set(['a']) }" + 24 |+f"{ {'a', 'b'} - set(['a']) }" +25 25 | f"a {set(['a', 'b']) - set(['a'])} b" +26 26 | f"a { set(['a', 'b']) - set(['a']) } b" + +C405.py:24:23: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) + | +23 | f"{set(['a', 'b']) - set(['a'])}" +24 | f"{ set(['a', 'b']) - set(['a']) }" + | ^^^^^^^^^^ C405 +25 | f"a {set(['a', 'b']) - set(['a'])} b" +26 | f"a { set(['a', 'b']) - set(['a']) } b" + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +21 21 | f'{set(["a", "b"])}' +22 22 | +23 23 | f"{set(['a', 'b']) - set(['a'])}" +24 |-f"{ set(['a', 'b']) - set(['a']) }" + 24 |+f"{ set(['a', 'b']) - {'a'} }" +25 25 | f"a {set(['a', 'b']) - set(['a'])} b" +26 26 | f"a { set(['a', 'b']) - set(['a']) } b" + +C405.py:25:6: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) + | +23 | f"{set(['a', 'b']) - set(['a'])}" +24 | f"{ set(['a', 'b']) - set(['a']) }" +25 | f"a {set(['a', 'b']) - set(['a'])} b" + | ^^^^^^^^^^^^^^^ C405 +26 | f"a { set(['a', 'b']) - set(['a']) } b" + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +22 22 | +23 23 | f"{set(['a', 'b']) - set(['a'])}" +24 24 | f"{ set(['a', 'b']) - set(['a']) }" +25 |-f"a {set(['a', 'b']) - set(['a'])} b" + 25 |+f"a { {'a', 'b'} - set(['a'])} b" +26 26 | f"a { set(['a', 'b']) - set(['a']) } b" + +C405.py:25:24: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) + | +23 | f"{set(['a', 'b']) - set(['a'])}" +24 | f"{ set(['a', 'b']) - set(['a']) }" +25 | f"a {set(['a', 'b']) - set(['a'])} b" + | ^^^^^^^^^^ C405 +26 | f"a { set(['a', 'b']) - set(['a']) } b" + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +22 22 | +23 23 | f"{set(['a', 'b']) - set(['a'])}" +24 24 | f"{ set(['a', 'b']) - set(['a']) }" +25 |-f"a {set(['a', 'b']) - set(['a'])} b" + 25 |+f"a {set(['a', 'b']) - {'a'} } b" +26 26 | f"a { set(['a', 'b']) - set(['a']) } b" + +C405.py:26:7: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) + | +24 | f"{ set(['a', 'b']) - set(['a']) }" +25 | f"a {set(['a', 'b']) - set(['a'])} b" +26 | f"a { set(['a', 'b']) - set(['a']) } b" + | ^^^^^^^^^^^^^^^ C405 + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +23 23 | f"{set(['a', 'b']) - set(['a'])}" +24 24 | f"{ set(['a', 'b']) - set(['a']) }" +25 25 | f"a {set(['a', 'b']) - set(['a'])} b" +26 |-f"a { set(['a', 'b']) - set(['a']) } b" + 26 |+f"a { {'a', 'b'} - set(['a']) } b" + +C405.py:26:25: C405 [*] Unnecessary `list` literal (rewrite as a `set` literal) + | +24 | f"{ set(['a', 'b']) - set(['a']) }" +25 | f"a {set(['a', 'b']) - set(['a'])} b" +26 | f"a { set(['a', 'b']) - set(['a']) } b" + | ^^^^^^^^^^ C405 + | + = help: Rewrite as a `set` literal + +ℹ Suggested fix +23 23 | f"{set(['a', 'b']) - set(['a'])}" +24 24 | f"{ set(['a', 'b']) - set(['a']) }" +25 25 | f"a {set(['a', 'b']) - set(['a'])} b" +26 |-f"a { set(['a', 'b']) - set(['a']) } b" + 26 |+f"a { set(['a', 'b']) - {'a'} } b" + + diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C406_C406.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C406_C406.py.snap new file mode 100644 index 0000000000..f8983c1683 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C406_C406.py.snap @@ -0,0 +1,75 @@ +--- +source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs +--- +C406.py:1:6: C406 [*] Unnecessary `list` literal (rewrite as a `dict` literal) + | +1 | d1 = dict([(1, 2)]) + | ^^^^^^^^^^^^^^ C406 +2 | d2 = dict(((1, 2),)) +3 | d3 = dict([]) + | + = help: Rewrite as a `dict` literal + +ℹ Suggested fix +1 |-d1 = dict([(1, 2)]) + 1 |+d1 = {1: 2} +2 2 | d2 = dict(((1, 2),)) +3 3 | d3 = dict([]) +4 4 | d4 = dict(()) + +C406.py:2:6: C406 [*] Unnecessary `tuple` literal (rewrite as a `dict` literal) + | +1 | d1 = dict([(1, 2)]) +2 | d2 = dict(((1, 2),)) + | ^^^^^^^^^^^^^^^ C406 +3 | d3 = dict([]) +4 | d4 = dict(()) + | + = help: Rewrite as a `dict` literal + +ℹ Suggested fix +1 1 | d1 = dict([(1, 2)]) +2 |-d2 = dict(((1, 2),)) + 2 |+d2 = {1: 2,} +3 3 | d3 = dict([]) +4 4 | d4 = dict(()) +5 5 | d5 = dict() + +C406.py:3:6: C406 [*] Unnecessary `list` literal (rewrite as a `dict` literal) + | +1 | d1 = dict([(1, 2)]) +2 | d2 = dict(((1, 2),)) +3 | d3 = dict([]) + | ^^^^^^^^ C406 +4 | d4 = dict(()) +5 | d5 = dict() + | + = help: Rewrite as a `dict` literal + +ℹ Suggested fix +1 1 | d1 = dict([(1, 2)]) +2 2 | d2 = dict(((1, 2),)) +3 |-d3 = dict([]) + 3 |+d3 = {} +4 4 | d4 = dict(()) +5 5 | d5 = dict() + +C406.py:4:6: C406 [*] Unnecessary `tuple` literal (rewrite as a `dict` literal) + | +2 | d2 = dict(((1, 2),)) +3 | d3 = dict([]) +4 | d4 = dict(()) + | ^^^^^^^^ C406 +5 | d5 = dict() + | + = help: Rewrite as a `dict` literal + +ℹ Suggested fix +1 1 | d1 = dict([(1, 2)]) +2 2 | d2 = dict(((1, 2),)) +3 3 | d3 = dict([]) +4 |-d4 = dict(()) + 4 |+d4 = {} +5 5 | d5 = dict() + + 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 new file mode 100644 index 0000000000..09904c22e2 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C408_C408.py.snap @@ -0,0 +1,308 @@ +--- +source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs +--- +C408.py:1:5: C408 [*] Unnecessary `tuple` call (rewrite as a literal) + | +1 | t = tuple() + | ^^^^^^^ C408 +2 | l = list() +3 | d1 = dict() + | + = help: Rewrite as a literal + +ℹ Suggested fix +1 |-t = tuple() + 1 |+t = () +2 2 | l = list() +3 3 | d1 = dict() +4 4 | d2 = dict(a=1) + +C408.py:2:5: C408 [*] Unnecessary `list` call (rewrite as a literal) + | +1 | t = tuple() +2 | l = list() + | ^^^^^^ C408 +3 | d1 = dict() +4 | d2 = dict(a=1) + | + = help: Rewrite as a literal + +ℹ Suggested fix +1 1 | t = tuple() +2 |-l = list() + 2 |+l = [] +3 3 | d1 = dict() +4 4 | d2 = dict(a=1) +5 5 | d3 = dict(**d2) + +C408.py:3:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) + | +1 | t = tuple() +2 | l = list() +3 | d1 = dict() + | ^^^^^^ C408 +4 | d2 = dict(a=1) +5 | d3 = dict(**d2) + | + = help: Rewrite as a literal + +ℹ Suggested fix +1 1 | t = tuple() +2 2 | l = list() +3 |-d1 = dict() + 3 |+d1 = {} +4 4 | d2 = dict(a=1) +5 5 | d3 = dict(**d2) +6 6 | + +C408.py:4:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) + | +2 | l = list() +3 | d1 = dict() +4 | d2 = dict(a=1) + | ^^^^^^^^^ C408 +5 | d3 = dict(**d2) + | + = help: Rewrite as a literal + +ℹ Suggested fix +1 1 | t = tuple() +2 2 | l = list() +3 3 | d1 = dict() +4 |-d2 = dict(a=1) + 4 |+d2 = {"a": 1} +5 5 | d3 = dict(**d2) +6 6 | +7 7 | + +C408.py:14:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) + | +12 | a = list() +13 | +14 | f"{dict(x='y')}" + | ^^^^^^^^^^^ C408 +15 | f'{dict(x="y")}' +16 | f"{dict()}" + | + = help: Rewrite as a literal + +ℹ Suggested fix +11 11 | +12 12 | a = list() +13 13 | +14 |-f"{dict(x='y')}" + 14 |+f"{ {'x': 'y'} }" +15 15 | f'{dict(x="y")}' +16 16 | f"{dict()}" +17 17 | f"a {dict()} b" + +C408.py:15:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) + | +14 | f"{dict(x='y')}" +15 | f'{dict(x="y")}' + | ^^^^^^^^^^^ C408 +16 | f"{dict()}" +17 | f"a {dict()} b" + | + = help: Rewrite as a literal + +ℹ Suggested fix +12 12 | a = list() +13 13 | +14 14 | f"{dict(x='y')}" +15 |-f'{dict(x="y")}' + 15 |+f'{ {"x": "y"} }' +16 16 | f"{dict()}" +17 17 | f"a {dict()} b" +18 18 | + +C408.py:16:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) + | +14 | f"{dict(x='y')}" +15 | f'{dict(x="y")}' +16 | f"{dict()}" + | ^^^^^^ C408 +17 | f"a {dict()} b" + | + = help: Rewrite as a literal + +ℹ Suggested fix +13 13 | +14 14 | f"{dict(x='y')}" +15 15 | f'{dict(x="y")}' +16 |-f"{dict()}" + 16 |+f"{ {} }" +17 17 | f"a {dict()} b" +18 18 | +19 19 | f"{dict(x='y') | dict(y='z')}" + +C408.py:17:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) + | +15 | f'{dict(x="y")}' +16 | f"{dict()}" +17 | f"a {dict()} b" + | ^^^^^^ C408 +18 | +19 | f"{dict(x='y') | dict(y='z')}" + | + = help: Rewrite as a literal + +ℹ Suggested fix +14 14 | f"{dict(x='y')}" +15 15 | f'{dict(x="y")}' +16 16 | f"{dict()}" +17 |-f"a {dict()} b" + 17 |+f"a { {} } b" +18 18 | +19 19 | f"{dict(x='y') | dict(y='z')}" +20 20 | f"{ dict(x='y') | dict(y='z') }" + +C408.py:19:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) + | +17 | f"a {dict()} b" +18 | +19 | f"{dict(x='y') | dict(y='z')}" + | ^^^^^^^^^^^ C408 +20 | f"{ dict(x='y') | dict(y='z') }" +21 | f"a {dict(x='y') | dict(y='z')} b" + | + = help: Rewrite as a literal + +ℹ Suggested fix +16 16 | f"{dict()}" +17 17 | f"a {dict()} b" +18 18 | +19 |-f"{dict(x='y') | dict(y='z')}" + 19 |+f"{ {'x': 'y'} | dict(y='z')}" +20 20 | f"{ dict(x='y') | dict(y='z') }" +21 21 | f"a {dict(x='y') | dict(y='z')} b" +22 22 | f"a { dict(x='y') | dict(y='z') } b" + +C408.py:19:18: C408 [*] Unnecessary `dict` call (rewrite as a literal) + | +17 | f"a {dict()} b" +18 | +19 | f"{dict(x='y') | dict(y='z')}" + | ^^^^^^^^^^^ C408 +20 | f"{ dict(x='y') | dict(y='z') }" +21 | f"a {dict(x='y') | dict(y='z')} b" + | + = help: Rewrite as a literal + +ℹ Suggested fix +16 16 | f"{dict()}" +17 17 | f"a {dict()} b" +18 18 | +19 |-f"{dict(x='y') | dict(y='z')}" + 19 |+f"{dict(x='y') | {'y': 'z'} }" +20 20 | f"{ dict(x='y') | dict(y='z') }" +21 21 | f"a {dict(x='y') | dict(y='z')} b" +22 22 | f"a { dict(x='y') | dict(y='z') } b" + +C408.py:20:5: C408 [*] Unnecessary `dict` call (rewrite as a literal) + | +19 | f"{dict(x='y') | dict(y='z')}" +20 | f"{ dict(x='y') | dict(y='z') }" + | ^^^^^^^^^^^ C408 +21 | f"a {dict(x='y') | dict(y='z')} b" +22 | f"a { dict(x='y') | dict(y='z') } b" + | + = help: Rewrite as a literal + +ℹ Suggested fix +17 17 | f"a {dict()} b" +18 18 | +19 19 | f"{dict(x='y') | dict(y='z')}" +20 |-f"{ dict(x='y') | dict(y='z') }" + 20 |+f"{ {'x': 'y'} | dict(y='z') }" +21 21 | f"a {dict(x='y') | dict(y='z')} b" +22 22 | f"a { dict(x='y') | dict(y='z') } b" + +C408.py:20:19: C408 [*] Unnecessary `dict` call (rewrite as a literal) + | +19 | f"{dict(x='y') | dict(y='z')}" +20 | f"{ dict(x='y') | dict(y='z') }" + | ^^^^^^^^^^^ C408 +21 | f"a {dict(x='y') | dict(y='z')} b" +22 | f"a { dict(x='y') | dict(y='z') } b" + | + = help: Rewrite as a literal + +ℹ Suggested fix +17 17 | f"a {dict()} b" +18 18 | +19 19 | f"{dict(x='y') | dict(y='z')}" +20 |-f"{ dict(x='y') | dict(y='z') }" + 20 |+f"{ dict(x='y') | {'y': 'z'} }" +21 21 | f"a {dict(x='y') | dict(y='z')} b" +22 22 | f"a { dict(x='y') | dict(y='z') } b" + +C408.py:21:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) + | +19 | f"{dict(x='y') | dict(y='z')}" +20 | f"{ dict(x='y') | dict(y='z') }" +21 | f"a {dict(x='y') | dict(y='z')} b" + | ^^^^^^^^^^^ C408 +22 | f"a { dict(x='y') | dict(y='z') } b" + | + = help: Rewrite as a literal + +ℹ Suggested fix +18 18 | +19 19 | f"{dict(x='y') | dict(y='z')}" +20 20 | f"{ dict(x='y') | dict(y='z') }" +21 |-f"a {dict(x='y') | dict(y='z')} b" + 21 |+f"a { {'x': 'y'} | dict(y='z')} b" +22 22 | f"a { dict(x='y') | dict(y='z') } b" + +C408.py:21:20: C408 [*] Unnecessary `dict` call (rewrite as a literal) + | +19 | f"{dict(x='y') | dict(y='z')}" +20 | f"{ dict(x='y') | dict(y='z') }" +21 | f"a {dict(x='y') | dict(y='z')} b" + | ^^^^^^^^^^^ C408 +22 | f"a { dict(x='y') | dict(y='z') } b" + | + = help: Rewrite as a literal + +ℹ Suggested fix +18 18 | +19 19 | f"{dict(x='y') | dict(y='z')}" +20 20 | f"{ dict(x='y') | dict(y='z') }" +21 |-f"a {dict(x='y') | dict(y='z')} b" + 21 |+f"a {dict(x='y') | {'y': 'z'} } b" +22 22 | f"a { dict(x='y') | dict(y='z') } b" + +C408.py:22:7: C408 [*] Unnecessary `dict` call (rewrite as a literal) + | +20 | f"{ dict(x='y') | dict(y='z') }" +21 | f"a {dict(x='y') | dict(y='z')} b" +22 | f"a { dict(x='y') | dict(y='z') } b" + | ^^^^^^^^^^^ C408 + | + = help: Rewrite as a literal + +ℹ Suggested fix +19 19 | f"{dict(x='y') | dict(y='z')}" +20 20 | f"{ dict(x='y') | dict(y='z') }" +21 21 | f"a {dict(x='y') | dict(y='z')} b" +22 |-f"a { dict(x='y') | dict(y='z') } b" + 22 |+f"a { {'x': 'y'} | dict(y='z') } b" + +C408.py:22:21: C408 [*] Unnecessary `dict` call (rewrite as a literal) + | +20 | f"{ dict(x='y') | dict(y='z') }" +21 | f"a {dict(x='y') | dict(y='z')} b" +22 | f"a { dict(x='y') | dict(y='z') } b" + | ^^^^^^^^^^^ C408 + | + = help: Rewrite as a literal + +ℹ Suggested fix +19 19 | f"{dict(x='y') | dict(y='z')}" +20 20 | f"{ dict(x='y') | dict(y='z') }" +21 21 | f"a {dict(x='y') | dict(y='z')} b" +22 |-f"a { dict(x='y') | dict(y='z') } b" + 22 |+f"a { dict(x='y') | {'y': 'z'} } b" + + 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 new file mode 100644 index 0000000000..7032a8c451 --- /dev/null +++ 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 @@ -0,0 +1,99 @@ +--- +source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs +--- +C408.py:1:5: C408 [*] Unnecessary `tuple` call (rewrite as a literal) + | +1 | t = tuple() + | ^^^^^^^ C408 +2 | l = list() +3 | d1 = dict() + | + = help: Rewrite as a literal + +ℹ Suggested fix +1 |-t = tuple() + 1 |+t = () +2 2 | l = list() +3 3 | d1 = dict() +4 4 | d2 = dict(a=1) + +C408.py:2:5: C408 [*] Unnecessary `list` call (rewrite as a literal) + | +1 | t = tuple() +2 | l = list() + | ^^^^^^ C408 +3 | d1 = dict() +4 | d2 = dict(a=1) + | + = help: Rewrite as a literal + +ℹ Suggested fix +1 1 | t = tuple() +2 |-l = list() + 2 |+l = [] +3 3 | d1 = dict() +4 4 | d2 = dict(a=1) +5 5 | d3 = dict(**d2) + +C408.py:3:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) + | +1 | t = tuple() +2 | l = list() +3 | d1 = dict() + | ^^^^^^ C408 +4 | d2 = dict(a=1) +5 | d3 = dict(**d2) + | + = help: Rewrite as a literal + +ℹ Suggested fix +1 1 | t = tuple() +2 2 | l = list() +3 |-d1 = dict() + 3 |+d1 = {} +4 4 | d2 = dict(a=1) +5 5 | d3 = dict(**d2) +6 6 | + +C408.py:16:4: C408 [*] Unnecessary `dict` call (rewrite as a literal) + | +14 | f"{dict(x='y')}" +15 | f'{dict(x="y")}' +16 | f"{dict()}" + | ^^^^^^ C408 +17 | f"a {dict()} b" + | + = help: Rewrite as a literal + +ℹ Suggested fix +13 13 | +14 14 | f"{dict(x='y')}" +15 15 | f'{dict(x="y")}' +16 |-f"{dict()}" + 16 |+f"{ {} }" +17 17 | f"a {dict()} b" +18 18 | +19 19 | f"{dict(x='y') | dict(y='z')}" + +C408.py:17:6: C408 [*] Unnecessary `dict` call (rewrite as a literal) + | +15 | f'{dict(x="y")}' +16 | f"{dict()}" +17 | f"a {dict()} b" + | ^^^^^^ C408 +18 | +19 | f"{dict(x='y') | dict(y='z')}" + | + = help: Rewrite as a literal + +ℹ Suggested fix +14 14 | f"{dict(x='y')}" +15 15 | f'{dict(x="y")}' +16 16 | f"{dict()}" +17 |-f"a {dict()} b" + 17 |+f"a { {} } b" +18 18 | +19 19 | f"{dict(x='y') | dict(y='z')}" +20 20 | f"{ dict(x='y') | dict(y='z') }" + + 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 new file mode 100644 index 0000000000..962bd5c19a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C409_C409.py.snap @@ -0,0 +1,108 @@ +--- +source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs +--- +C409.py:1:6: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite as a `tuple` literal) + | +1 | t1 = tuple([]) + | ^^^^^^^^^ C409 +2 | t2 = tuple([1, 2]) +3 | t3 = tuple((1, 2)) + | + = help: Rewrite as a `tuple` literal + +ℹ Suggested fix +1 |-t1 = tuple([]) + 1 |+t1 = () +2 2 | t2 = tuple([1, 2]) +3 3 | t3 = tuple((1, 2)) +4 4 | t4 = tuple([ + +C409.py:2:6: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite as a `tuple` literal) + | +1 | t1 = tuple([]) +2 | t2 = tuple([1, 2]) + | ^^^^^^^^^^^^^ C409 +3 | t3 = tuple((1, 2)) +4 | t4 = tuple([ + | + = help: Rewrite as a `tuple` literal + +ℹ Suggested fix +1 1 | t1 = tuple([]) +2 |-t2 = tuple([1, 2]) + 2 |+t2 = (1, 2) +3 3 | t3 = tuple((1, 2)) +4 4 | t4 = tuple([ +5 5 | 1, + +C409.py:3:6: C409 [*] Unnecessary `tuple` literal passed to `tuple()` (remove the outer call to `tuple()`) + | +1 | t1 = tuple([]) +2 | t2 = tuple([1, 2]) +3 | t3 = tuple((1, 2)) + | ^^^^^^^^^^^^^ C409 +4 | t4 = tuple([ +5 | 1, + | + = help: Remove outer `tuple` call + +ℹ Suggested fix +1 1 | t1 = tuple([]) +2 2 | t2 = tuple([1, 2]) +3 |-t3 = tuple((1, 2)) + 3 |+t3 = (1, 2) +4 4 | t4 = tuple([ +5 5 | 1, +6 6 | 2 + +C409.py:4:6: C409 [*] Unnecessary `list` literal passed to `tuple()` (rewrite as a `tuple` literal) + | +2 | t2 = tuple([1, 2]) +3 | t3 = tuple((1, 2)) +4 | t4 = tuple([ + | ______^ +5 | | 1, +6 | | 2 +7 | | ]) + | |__^ C409 +8 | t5 = tuple( +9 | (1, 2) + | + = help: Rewrite as a `tuple` literal + +ℹ Suggested fix +1 1 | t1 = tuple([]) +2 2 | t2 = tuple([1, 2]) +3 3 | t3 = tuple((1, 2)) +4 |-t4 = tuple([ + 4 |+t4 = ( +5 5 | 1, +6 6 | 2 +7 |-]) + 7 |+) +8 8 | t5 = tuple( +9 9 | (1, 2) +10 10 | ) + +C409.py:8:6: C409 [*] Unnecessary `tuple` literal passed to `tuple()` (remove the outer call to `tuple()`) + | + 6 | 2 + 7 | ]) + 8 | t5 = tuple( + | ______^ + 9 | | (1, 2) +10 | | ) + | |_^ C409 + | + = help: Remove outer `tuple` call + +ℹ Suggested fix +5 5 | 1, +6 6 | 2 +7 7 | ]) +8 |-t5 = tuple( +9 |- (1, 2) +10 |-) + 8 |+t5 = (1, 2) + + 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 new file mode 100644 index 0000000000..997e854757 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C410_C410.py.snap @@ -0,0 +1,70 @@ +--- +source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs +--- +C410.py:1:6: C410 [*] Unnecessary `list` literal passed to `list()` (remove the outer call to `list()`) + | +1 | l1 = list([1, 2]) + | ^^^^^^^^^^^^ C410 +2 | l2 = list((1, 2)) +3 | l3 = list([]) + | + = help: Remove outer `list` call + +ℹ Suggested fix +1 |-l1 = list([1, 2]) + 1 |+l1 = [1, 2] +2 2 | l2 = list((1, 2)) +3 3 | l3 = list([]) +4 4 | l4 = list(()) + +C410.py:2:6: C410 [*] Unnecessary `tuple` literal passed to `list()` (rewrite as a `list` literal) + | +1 | l1 = list([1, 2]) +2 | l2 = list((1, 2)) + | ^^^^^^^^^^^^ C410 +3 | l3 = list([]) +4 | l4 = list(()) + | + = help: Rewrite as a `list` literal + +ℹ Suggested fix +1 1 | l1 = list([1, 2]) +2 |-l2 = list((1, 2)) + 2 |+l2 = [1, 2] +3 3 | l3 = list([]) +4 4 | l4 = list(()) + +C410.py:3:6: C410 [*] Unnecessary `list` literal passed to `list()` (remove the outer call to `list()`) + | +1 | l1 = list([1, 2]) +2 | l2 = list((1, 2)) +3 | l3 = list([]) + | ^^^^^^^^ C410 +4 | l4 = list(()) + | + = help: Remove outer `list` call + +ℹ Suggested fix +1 1 | l1 = list([1, 2]) +2 2 | l2 = list((1, 2)) +3 |-l3 = list([]) + 3 |+l3 = [] +4 4 | l4 = list(()) + +C410.py:4:6: C410 [*] Unnecessary `tuple` literal passed to `list()` (rewrite as a `list` literal) + | +2 | l2 = list((1, 2)) +3 | l3 = list([]) +4 | l4 = list(()) + | ^^^^^^^^ C410 + | + = help: Rewrite as a `list` literal + +ℹ Suggested fix +1 1 | l1 = list([1, 2]) +2 2 | l2 = list((1, 2)) +3 3 | l3 = list([]) +4 |-l4 = list(()) + 4 |+l4 = [] + + diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C411_C411.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C411_C411.py.snap new file mode 100644 index 0000000000..1878f091a7 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C411_C411.py.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs +--- +C411.py:2:1: C411 [*] Unnecessary `list` call (remove the outer call to `list()`) + | +1 | x = [1, 2, 3] +2 | list([i for i in x]) + | ^^^^^^^^^^^^^^^^^^^^ C411 + | + = help: Remove outer `list` call + +ℹ Suggested fix +1 1 | x = [1, 2, 3] +2 |-list([i for i in x]) + 2 |+[i for i in x] + + 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 new file mode 100644 index 0000000000..ae89b1802a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C413_C413.py.snap @@ -0,0 +1,229 @@ +--- +source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs +--- +C413.py:3:1: C413 [*] Unnecessary `list` call around `sorted()` + | +1 | x = [2, 3, 1] +2 | list(x) +3 | list(sorted(x)) + | ^^^^^^^^^^^^^^^ C413 +4 | reversed(sorted(x)) +5 | reversed(sorted(x, key=lambda e: e)) + | + = help: Remove unnecessary `list` call + +ℹ Fix +1 1 | x = [2, 3, 1] +2 2 | list(x) +3 |-list(sorted(x)) + 3 |+sorted(x) +4 4 | reversed(sorted(x)) +5 5 | reversed(sorted(x, key=lambda e: e)) +6 6 | reversed(sorted(x, reverse=True)) + +C413.py:4:1: C413 [*] Unnecessary `reversed` call around `sorted()` + | +2 | list(x) +3 | list(sorted(x)) +4 | reversed(sorted(x)) + | ^^^^^^^^^^^^^^^^^^^ C413 +5 | reversed(sorted(x, key=lambda e: e)) +6 | reversed(sorted(x, reverse=True)) + | + = help: Remove unnecessary `reversed` call + +ℹ Suggested fix +1 1 | x = [2, 3, 1] +2 2 | list(x) +3 3 | list(sorted(x)) +4 |-reversed(sorted(x)) + 4 |+sorted(x, reverse=True) +5 5 | reversed(sorted(x, key=lambda e: e)) +6 6 | reversed(sorted(x, reverse=True)) +7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) + +C413.py:5:1: C413 [*] Unnecessary `reversed` call around `sorted()` + | +3 | list(sorted(x)) +4 | reversed(sorted(x)) +5 | reversed(sorted(x, key=lambda e: e)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 +6 | reversed(sorted(x, reverse=True)) +7 | reversed(sorted(x, key=lambda e: e, reverse=True)) + | + = help: Remove unnecessary `reversed` call + +ℹ Suggested fix +2 2 | list(x) +3 3 | list(sorted(x)) +4 4 | reversed(sorted(x)) +5 |-reversed(sorted(x, key=lambda e: e)) + 5 |+sorted(x, key=lambda e: e, reverse=True) +6 6 | reversed(sorted(x, reverse=True)) +7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) +8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) + +C413.py:6:1: C413 [*] Unnecessary `reversed` call around `sorted()` + | +4 | reversed(sorted(x)) +5 | reversed(sorted(x, key=lambda e: e)) +6 | reversed(sorted(x, reverse=True)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 +7 | reversed(sorted(x, key=lambda e: e, reverse=True)) +8 | reversed(sorted(x, reverse=True, key=lambda e: e)) + | + = help: Remove unnecessary `reversed` call + +ℹ Suggested fix +3 3 | list(sorted(x)) +4 4 | reversed(sorted(x)) +5 5 | reversed(sorted(x, key=lambda e: e)) +6 |-reversed(sorted(x, reverse=True)) + 6 |+sorted(x, reverse=False) +7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) +8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) +9 9 | reversed(sorted(x, reverse=False)) + +C413.py:7:1: C413 [*] Unnecessary `reversed` call around `sorted()` + | +5 | reversed(sorted(x, key=lambda e: e)) +6 | reversed(sorted(x, reverse=True)) +7 | reversed(sorted(x, key=lambda e: e, reverse=True)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 +8 | reversed(sorted(x, reverse=True, key=lambda e: e)) +9 | reversed(sorted(x, reverse=False)) + | + = help: Remove unnecessary `reversed` call + +ℹ Suggested fix +4 4 | reversed(sorted(x)) +5 5 | reversed(sorted(x, key=lambda e: e)) +6 6 | reversed(sorted(x, reverse=True)) +7 |-reversed(sorted(x, key=lambda e: e, reverse=True)) + 7 |+sorted(x, key=lambda e: e, reverse=False) +8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) +9 9 | reversed(sorted(x, reverse=False)) +10 10 | reversed(sorted(x, reverse=x)) + +C413.py:8:1: C413 [*] Unnecessary `reversed` call around `sorted()` + | + 6 | reversed(sorted(x, reverse=True)) + 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) + 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 + 9 | reversed(sorted(x, reverse=False)) +10 | reversed(sorted(x, reverse=x)) + | + = help: Remove unnecessary `reversed` call + +ℹ Suggested fix +5 5 | reversed(sorted(x, key=lambda e: e)) +6 6 | reversed(sorted(x, reverse=True)) +7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) +8 |-reversed(sorted(x, reverse=True, key=lambda e: e)) + 8 |+sorted(x, reverse=False, key=lambda e: e) +9 9 | reversed(sorted(x, reverse=False)) +10 10 | reversed(sorted(x, reverse=x)) +11 11 | reversed(sorted(x, reverse=not x)) + +C413.py:9:1: C413 [*] Unnecessary `reversed` call around `sorted()` + | + 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) + 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) + 9 | reversed(sorted(x, reverse=False)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 +10 | reversed(sorted(x, reverse=x)) +11 | reversed(sorted(x, reverse=not x)) + | + = help: Remove unnecessary `reversed` call + +ℹ Suggested fix +6 6 | reversed(sorted(x, reverse=True)) +7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) +8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) +9 |-reversed(sorted(x, reverse=False)) + 9 |+sorted(x, reverse=True) +10 10 | reversed(sorted(x, reverse=x)) +11 11 | reversed(sorted(x, reverse=not x)) +12 12 | + +C413.py:10:1: C413 [*] Unnecessary `reversed` call around `sorted()` + | + 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) + 9 | reversed(sorted(x, reverse=False)) +10 | reversed(sorted(x, reverse=x)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 +11 | reversed(sorted(x, reverse=not x)) + | + = help: Remove unnecessary `reversed` call + +ℹ Suggested fix +7 7 | reversed(sorted(x, key=lambda e: e, reverse=True)) +8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) +9 9 | reversed(sorted(x, reverse=False)) +10 |-reversed(sorted(x, reverse=x)) + 10 |+sorted(x, reverse=not x) +11 11 | reversed(sorted(x, reverse=not x)) +12 12 | +13 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 + +C413.py:11:1: C413 [*] Unnecessary `reversed` call around `sorted()` + | + 9 | reversed(sorted(x, reverse=False)) +10 | reversed(sorted(x, reverse=x)) +11 | reversed(sorted(x, reverse=not x)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 +12 | +13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 + | + = help: Remove unnecessary `reversed` call + +ℹ Suggested fix +8 8 | reversed(sorted(x, reverse=True, key=lambda e: e)) +9 9 | reversed(sorted(x, reverse=False)) +10 10 | reversed(sorted(x, reverse=x)) +11 |-reversed(sorted(x, reverse=not x)) + 11 |+sorted(x, reverse=x) +12 12 | +13 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 +14 14 | reversed(sorted(i for i in range(42))) + +C413.py:14:1: C413 [*] Unnecessary `reversed` call around `sorted()` + | +13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 +14 | reversed(sorted(i for i in range(42))) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 +15 | reversed(sorted((i for i in range(42)), reverse=True)) + | + = help: Remove unnecessary `reversed` call + +ℹ Suggested fix +11 11 | reversed(sorted(x, reverse=not x)) +12 12 | +13 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 +14 |-reversed(sorted(i for i in range(42))) + 14 |+sorted((i for i in range(42)), reverse=True) +15 15 | reversed(sorted((i for i in range(42)), reverse=True)) +16 16 | +17 17 | + +C413.py:15:1: C413 [*] Unnecessary `reversed` call around `sorted()` + | +13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 +14 | reversed(sorted(i for i in range(42))) +15 | reversed(sorted((i for i in range(42)), reverse=True)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C413 + | + = help: Remove unnecessary `reversed` call + +ℹ Suggested fix +12 12 | +13 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7289 +14 14 | reversed(sorted(i for i in range(42))) +15 |-reversed(sorted((i for i in range(42)), reverse=True)) + 15 |+sorted((i for i in range(42)), reverse=False) +16 16 | +17 17 | +18 18 | def reversed(*args, **kwargs): + + 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 new file mode 100644 index 0000000000..d2cae0af64 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C414_C414.py.snap @@ -0,0 +1,470 @@ +--- +source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs +--- +C414.py:2:1: C414 [*] Unnecessary `list` call within `list()` + | +1 | x = [1, 2, 3] +2 | list(list(x)) + | ^^^^^^^^^^^^^ C414 +3 | list(tuple(x)) +4 | tuple(list(x)) + | + = help: Remove the inner `list` call + +ℹ Suggested fix +1 1 | x = [1, 2, 3] +2 |-list(list(x)) + 2 |+list(x) +3 3 | list(tuple(x)) +4 4 | tuple(list(x)) +5 5 | tuple(tuple(x)) + +C414.py:3:1: C414 [*] Unnecessary `tuple` call within `list()` + | +1 | x = [1, 2, 3] +2 | list(list(x)) +3 | list(tuple(x)) + | ^^^^^^^^^^^^^^ C414 +4 | tuple(list(x)) +5 | tuple(tuple(x)) + | + = help: Remove the inner `tuple` call + +ℹ Suggested fix +1 1 | x = [1, 2, 3] +2 2 | list(list(x)) +3 |-list(tuple(x)) + 3 |+list(x) +4 4 | tuple(list(x)) +5 5 | tuple(tuple(x)) +6 6 | set(set(x)) + +C414.py:4:1: C414 [*] Unnecessary `list` call within `tuple()` + | +2 | list(list(x)) +3 | list(tuple(x)) +4 | tuple(list(x)) + | ^^^^^^^^^^^^^^ C414 +5 | tuple(tuple(x)) +6 | set(set(x)) + | + = help: Remove the inner `list` call + +ℹ Suggested fix +1 1 | x = [1, 2, 3] +2 2 | list(list(x)) +3 3 | list(tuple(x)) +4 |-tuple(list(x)) + 4 |+tuple(x) +5 5 | tuple(tuple(x)) +6 6 | set(set(x)) +7 7 | set(list(x)) + +C414.py:5:1: C414 [*] Unnecessary `tuple` call within `tuple()` + | +3 | list(tuple(x)) +4 | tuple(list(x)) +5 | tuple(tuple(x)) + | ^^^^^^^^^^^^^^^ C414 +6 | set(set(x)) +7 | set(list(x)) + | + = help: Remove the inner `tuple` call + +ℹ Suggested fix +2 2 | list(list(x)) +3 3 | list(tuple(x)) +4 4 | tuple(list(x)) +5 |-tuple(tuple(x)) + 5 |+tuple(x) +6 6 | set(set(x)) +7 7 | set(list(x)) +8 8 | set(tuple(x)) + +C414.py:6:1: C414 [*] Unnecessary `set` call within `set()` + | +4 | tuple(list(x)) +5 | tuple(tuple(x)) +6 | set(set(x)) + | ^^^^^^^^^^^ C414 +7 | set(list(x)) +8 | set(tuple(x)) + | + = help: Remove the inner `set` call + +ℹ Suggested fix +3 3 | list(tuple(x)) +4 4 | tuple(list(x)) +5 5 | tuple(tuple(x)) +6 |-set(set(x)) + 6 |+set(x) +7 7 | set(list(x)) +8 8 | set(tuple(x)) +9 9 | set(sorted(x)) + +C414.py:7:1: C414 [*] Unnecessary `list` call within `set()` + | +5 | tuple(tuple(x)) +6 | set(set(x)) +7 | set(list(x)) + | ^^^^^^^^^^^^ C414 +8 | set(tuple(x)) +9 | set(sorted(x)) + | + = help: Remove the inner `list` call + +ℹ Suggested fix +4 4 | tuple(list(x)) +5 5 | tuple(tuple(x)) +6 6 | set(set(x)) +7 |-set(list(x)) + 7 |+set(x) +8 8 | set(tuple(x)) +9 9 | set(sorted(x)) +10 10 | set(sorted(x, key=lambda y: y)) + +C414.py:8:1: C414 [*] Unnecessary `tuple` call within `set()` + | + 6 | set(set(x)) + 7 | set(list(x)) + 8 | set(tuple(x)) + | ^^^^^^^^^^^^^ C414 + 9 | set(sorted(x)) +10 | set(sorted(x, key=lambda y: y)) + | + = help: Remove the inner `tuple` call + +ℹ Suggested fix +5 5 | tuple(tuple(x)) +6 6 | set(set(x)) +7 7 | set(list(x)) +8 |-set(tuple(x)) + 8 |+set(x) +9 9 | set(sorted(x)) +10 10 | set(sorted(x, key=lambda y: y)) +11 11 | set(reversed(x)) + +C414.py:9:1: C414 [*] Unnecessary `sorted` call within `set()` + | + 7 | set(list(x)) + 8 | set(tuple(x)) + 9 | set(sorted(x)) + | ^^^^^^^^^^^^^^ C414 +10 | set(sorted(x, key=lambda y: y)) +11 | set(reversed(x)) + | + = help: Remove the inner `sorted` call + +ℹ Suggested fix +6 6 | set(set(x)) +7 7 | set(list(x)) +8 8 | set(tuple(x)) +9 |-set(sorted(x)) + 9 |+set(x) +10 10 | set(sorted(x, key=lambda y: y)) +11 11 | set(reversed(x)) +12 12 | sorted(list(x)) + +C414.py:10:1: C414 [*] Unnecessary `sorted` call within `set()` + | + 8 | set(tuple(x)) + 9 | set(sorted(x)) +10 | set(sorted(x, key=lambda y: y)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C414 +11 | set(reversed(x)) +12 | sorted(list(x)) + | + = help: Remove the inner `sorted` call + +ℹ Suggested fix +7 7 | set(list(x)) +8 8 | set(tuple(x)) +9 9 | set(sorted(x)) +10 |-set(sorted(x, key=lambda y: y)) + 10 |+set(x, ) +11 11 | set(reversed(x)) +12 12 | sorted(list(x)) +13 13 | sorted(tuple(x)) + +C414.py:11:1: C414 [*] Unnecessary `reversed` call within `set()` + | + 9 | set(sorted(x)) +10 | set(sorted(x, key=lambda y: y)) +11 | set(reversed(x)) + | ^^^^^^^^^^^^^^^^ C414 +12 | sorted(list(x)) +13 | sorted(tuple(x)) + | + = help: Remove the inner `reversed` call + +ℹ Suggested fix +8 8 | set(tuple(x)) +9 9 | set(sorted(x)) +10 10 | set(sorted(x, key=lambda y: y)) +11 |-set(reversed(x)) + 11 |+set(x) +12 12 | sorted(list(x)) +13 13 | sorted(tuple(x)) +14 14 | sorted(sorted(x)) + +C414.py:12:1: C414 [*] Unnecessary `list` call within `sorted()` + | +10 | set(sorted(x, key=lambda y: y)) +11 | set(reversed(x)) +12 | sorted(list(x)) + | ^^^^^^^^^^^^^^^ C414 +13 | sorted(tuple(x)) +14 | sorted(sorted(x)) + | + = help: Remove the inner `list` call + +ℹ Suggested fix +9 9 | set(sorted(x)) +10 10 | set(sorted(x, key=lambda y: y)) +11 11 | set(reversed(x)) +12 |-sorted(list(x)) + 12 |+sorted(x) +13 13 | sorted(tuple(x)) +14 14 | sorted(sorted(x)) +15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) + +C414.py:13:1: C414 [*] Unnecessary `tuple` call within `sorted()` + | +11 | set(reversed(x)) +12 | sorted(list(x)) +13 | sorted(tuple(x)) + | ^^^^^^^^^^^^^^^^ C414 +14 | sorted(sorted(x)) +15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) + | + = help: Remove the inner `tuple` call + +ℹ Suggested fix +10 10 | set(sorted(x, key=lambda y: y)) +11 11 | set(reversed(x)) +12 12 | sorted(list(x)) +13 |-sorted(tuple(x)) + 13 |+sorted(x) +14 14 | sorted(sorted(x)) +15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) +16 16 | sorted(sorted(x, reverse=True), reverse=True) + +C414.py:14:1: C414 [*] Unnecessary `sorted` call within `sorted()` + | +12 | sorted(list(x)) +13 | sorted(tuple(x)) +14 | sorted(sorted(x)) + | ^^^^^^^^^^^^^^^^^ C414 +15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) +16 | sorted(sorted(x, reverse=True), reverse=True) + | + = help: Remove the inner `sorted` call + +ℹ Suggested fix +11 11 | set(reversed(x)) +12 12 | sorted(list(x)) +13 13 | sorted(tuple(x)) +14 |-sorted(sorted(x)) + 14 |+sorted(x) +15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) +16 16 | sorted(sorted(x, reverse=True), reverse=True) +17 17 | sorted(reversed(x)) + +C414.py:15:1: C414 [*] Unnecessary `sorted` call within `sorted()` + | +13 | sorted(tuple(x)) +14 | sorted(sorted(x)) +15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C414 +16 | sorted(sorted(x, reverse=True), reverse=True) +17 | sorted(reversed(x)) + | + = help: Remove the inner `sorted` call + +ℹ Suggested fix +12 12 | sorted(list(x)) +13 13 | sorted(tuple(x)) +14 14 | sorted(sorted(x)) +15 |-sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) + 15 |+sorted(x, reverse=False, key=foo) +16 16 | sorted(sorted(x, reverse=True), reverse=True) +17 17 | sorted(reversed(x)) +18 18 | sorted(list(x), key=lambda y: y) + +C414.py:16:1: C414 [*] Unnecessary `sorted` call within `sorted()` + | +14 | sorted(sorted(x)) +15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) +16 | sorted(sorted(x, reverse=True), reverse=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C414 +17 | sorted(reversed(x)) +18 | sorted(list(x), key=lambda y: y) + | + = help: Remove the inner `sorted` call + +ℹ Suggested fix +13 13 | sorted(tuple(x)) +14 14 | sorted(sorted(x)) +15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) +16 |-sorted(sorted(x, reverse=True), reverse=True) + 16 |+sorted(x, reverse=True) +17 17 | sorted(reversed(x)) +18 18 | sorted(list(x), key=lambda y: y) +19 19 | tuple( + +C414.py:17:1: C414 [*] Unnecessary `reversed` call within `sorted()` + | +15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) +16 | sorted(sorted(x, reverse=True), reverse=True) +17 | sorted(reversed(x)) + | ^^^^^^^^^^^^^^^^^^^ C414 +18 | sorted(list(x), key=lambda y: y) +19 | tuple( + | + = help: Remove the inner `reversed` call + +ℹ Suggested fix +14 14 | sorted(sorted(x)) +15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) +16 16 | sorted(sorted(x, reverse=True), reverse=True) +17 |-sorted(reversed(x)) + 17 |+sorted(x) +18 18 | sorted(list(x), key=lambda y: y) +19 19 | tuple( +20 20 | list( + +C414.py:18:1: C414 [*] Unnecessary `list` call within `sorted()` + | +16 | sorted(sorted(x, reverse=True), reverse=True) +17 | sorted(reversed(x)) +18 | sorted(list(x), key=lambda y: y) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C414 +19 | tuple( +20 | list( + | + = help: Remove the inner `list` call + +ℹ Suggested fix +15 15 | sorted(sorted(x, key=foo, reverse=False), reverse=False, key=foo) +16 16 | sorted(sorted(x, reverse=True), reverse=True) +17 17 | sorted(reversed(x)) +18 |-sorted(list(x), key=lambda y: y) + 18 |+sorted(x, key=lambda y: y) +19 19 | tuple( +20 20 | list( +21 21 | [x, 3, "hell"\ + +C414.py:19:1: C414 [*] Unnecessary `list` call within `tuple()` + | +17 | sorted(reversed(x)) +18 | sorted(list(x), key=lambda y: y) +19 | / tuple( +20 | | list( +21 | | [x, 3, "hell"\ +22 | | "o"] +23 | | ) +24 | | ) + | |_^ C414 +25 | set(set()) +26 | set(list()) + | + = help: Remove the inner `list` call + +ℹ Suggested fix +17 17 | sorted(reversed(x)) +18 18 | sorted(list(x), key=lambda y: y) +19 19 | tuple( +20 |- list( +21 |- [x, 3, "hell"\ + 20 |+ [x, 3, "hell"\ +22 21 | "o"] +23 22 | ) +24 |-) +25 23 | set(set()) +26 24 | set(list()) +27 25 | set(tuple()) + +C414.py:25:1: C414 [*] Unnecessary `set` call within `set()` + | +23 | ) +24 | ) +25 | set(set()) + | ^^^^^^^^^^ C414 +26 | set(list()) +27 | set(tuple()) + | + = help: Remove the inner `set` call + +ℹ Suggested fix +22 22 | "o"] +23 23 | ) +24 24 | ) +25 |-set(set()) + 25 |+set() +26 26 | set(list()) +27 27 | set(tuple()) +28 28 | sorted(reversed()) + +C414.py:26:1: C414 [*] Unnecessary `list` call within `set()` + | +24 | ) +25 | set(set()) +26 | set(list()) + | ^^^^^^^^^^^ C414 +27 | set(tuple()) +28 | sorted(reversed()) + | + = help: Remove the inner `list` call + +ℹ Suggested fix +23 23 | ) +24 24 | ) +25 25 | set(set()) +26 |-set(list()) + 26 |+set() +27 27 | set(tuple()) +28 28 | sorted(reversed()) +29 29 | + +C414.py:27:1: C414 [*] Unnecessary `tuple` call within `set()` + | +25 | set(set()) +26 | set(list()) +27 | set(tuple()) + | ^^^^^^^^^^^^ C414 +28 | sorted(reversed()) + | + = help: Remove the inner `tuple` call + +ℹ Suggested fix +24 24 | ) +25 25 | set(set()) +26 26 | set(list()) +27 |-set(tuple()) + 27 |+set() +28 28 | sorted(reversed()) +29 29 | +30 30 | # Nested sorts with differing keyword arguments. Not flagged. + +C414.py:28:1: C414 [*] Unnecessary `reversed` call within `sorted()` + | +26 | set(list()) +27 | set(tuple()) +28 | sorted(reversed()) + | ^^^^^^^^^^^^^^^^^^ C414 +29 | +30 | # Nested sorts with differing keyword arguments. Not flagged. + | + = help: Remove the inner `reversed` call + +ℹ Suggested fix +25 25 | set(set()) +26 26 | set(list()) +27 27 | set(tuple()) +28 |-sorted(reversed()) + 28 |+sorted() +29 29 | +30 30 | # Nested sorts with differing keyword arguments. Not flagged. +31 31 | sorted(sorted(x, key=lambda y: y)) + + diff --git a/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C415_C415.py.snap b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C415_C415.py.snap new file mode 100644 index 0000000000..3e3463d093 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C415_C415.py.snap @@ -0,0 +1,43 @@ +--- +source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs +--- +C415.py:2:5: C415 Unnecessary subscript reversal of iterable within `set()` + | +1 | lst = [2, 1, 3] +2 | a = set(lst[::-1]) + | ^^^^^^^^^^^^^^ C415 +3 | b = reversed(lst[::-1]) +4 | c = sorted(lst[::-1]) + | + +C415.py:3:5: C415 Unnecessary subscript reversal of iterable within `reversed()` + | +1 | lst = [2, 1, 3] +2 | a = set(lst[::-1]) +3 | b = reversed(lst[::-1]) + | ^^^^^^^^^^^^^^^^^^^ C415 +4 | c = sorted(lst[::-1]) +5 | d = sorted(lst[::-1], reverse=True) + | + +C415.py:4:5: C415 Unnecessary subscript reversal of iterable within `sorted()` + | +2 | a = set(lst[::-1]) +3 | b = reversed(lst[::-1]) +4 | c = sorted(lst[::-1]) + | ^^^^^^^^^^^^^^^^^ C415 +5 | d = sorted(lst[::-1], reverse=True) +6 | e = set(lst[2:-1]) + | + +C415.py:5:5: C415 Unnecessary subscript reversal of iterable within `sorted()` + | +3 | b = reversed(lst[::-1]) +4 | c = sorted(lst[::-1]) +5 | d = sorted(lst[::-1], reverse=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C415 +6 | e = set(lst[2:-1]) +7 | f = set(lst[:1:-1]) + | + + 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 new file mode 100644 index 0000000000..f7ea1bfbbc --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C416_C416.py.snap @@ -0,0 +1,143 @@ +--- +source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs +--- +C416.py:6:1: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`) + | +4 | d = {"a": 1, "b": 2, "c": 3} +5 | +6 | [i for i in x] + | ^^^^^^^^^^^^^^ C416 +7 | {i for i in x} +8 | {k: v for k, v in y} + | + = help: Rewrite using `list()` + +ℹ Suggested fix +3 3 | z = [(1,), (2,), (3,)] +4 4 | d = {"a": 1, "b": 2, "c": 3} +5 5 | +6 |-[i for i in x] + 6 |+list(x) +7 7 | {i for i in x} +8 8 | {k: v for k, v in y} +9 9 | {k: v for k, v in d.items()} + +C416.py:7:1: C416 [*] Unnecessary `set` comprehension (rewrite using `set()`) + | +6 | [i for i in x] +7 | {i for i in x} + | ^^^^^^^^^^^^^^ C416 +8 | {k: v for k, v in y} +9 | {k: v for k, v in d.items()} + | + = help: Rewrite using `set()` + +ℹ Suggested fix +4 4 | d = {"a": 1, "b": 2, "c": 3} +5 5 | +6 6 | [i for i in x] +7 |-{i for i in x} + 7 |+set(x) +8 8 | {k: v for k, v in y} +9 9 | {k: v for k, v in d.items()} +10 10 | [(k, v) for k, v in d.items()] + +C416.py:8:1: C416 [*] Unnecessary `dict` comprehension (rewrite using `dict()`) + | + 6 | [i for i in x] + 7 | {i for i in x} + 8 | {k: v for k, v in y} + | ^^^^^^^^^^^^^^^^^^^^ C416 + 9 | {k: v for k, v in d.items()} +10 | [(k, v) for k, v in d.items()] + | + = help: Rewrite using `dict()` + +ℹ Suggested fix +5 5 | +6 6 | [i for i in x] +7 7 | {i for i in x} +8 |-{k: v for k, v in y} + 8 |+dict(y) +9 9 | {k: v for k, v in d.items()} +10 10 | [(k, v) for k, v in d.items()] +11 11 | {k: (a, b) for k, (a, b) in d.items()} + +C416.py:9:1: C416 [*] Unnecessary `dict` comprehension (rewrite using `dict()`) + | + 7 | {i for i in x} + 8 | {k: v for k, v in y} + 9 | {k: v for k, v in d.items()} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C416 +10 | [(k, v) for k, v in d.items()] +11 | {k: (a, b) for k, (a, b) in d.items()} + | + = help: Rewrite using `dict()` + +ℹ Suggested fix +6 6 | [i for i in x] +7 7 | {i for i in x} +8 8 | {k: v for k, v in y} +9 |-{k: v for k, v in d.items()} + 9 |+dict(d.items()) +10 10 | [(k, v) for k, v in d.items()] +11 11 | {k: (a, b) for k, (a, b) in d.items()} +12 12 | + +C416.py:10:1: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`) + | + 8 | {k: v for k, v in y} + 9 | {k: v for k, v in d.items()} +10 | [(k, v) for k, v in d.items()] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C416 +11 | {k: (a, b) for k, (a, b) in d.items()} + | + = help: Rewrite using `list()` + +ℹ Suggested fix +7 7 | {i for i in x} +8 8 | {k: v for k, v in y} +9 9 | {k: v for k, v in d.items()} +10 |-[(k, v) for k, v in d.items()] + 10 |+list(d.items()) +11 11 | {k: (a, b) for k, (a, b) in d.items()} +12 12 | +13 13 | [i for i, in z] + +C416.py:11:1: C416 [*] Unnecessary `dict` comprehension (rewrite using `dict()`) + | + 9 | {k: v for k, v in d.items()} +10 | [(k, v) for k, v in d.items()] +11 | {k: (a, b) for k, (a, b) in d.items()} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C416 +12 | +13 | [i for i, in z] + | + = help: Rewrite using `dict()` + +ℹ Suggested fix +8 8 | {k: v for k, v in y} +9 9 | {k: v for k, v in d.items()} +10 10 | [(k, v) for k, v in d.items()] +11 |-{k: (a, b) for k, (a, b) in d.items()} + 11 |+dict(d.items()) +12 12 | +13 13 | [i for i, in z] +14 14 | [i for i, j in y] + +C416.py:24:70: C416 [*] Unnecessary `list` comprehension (rewrite using `list()`) + | +23 | # Regression test for: https://github.com/astral-sh/ruff/issues/7196 +24 | any(len(symbol_table.get_by_type(symbol_type)) > 0 for symbol_type in[t for t in SymbolType]) + | ^^^^^^^^^^^^^^^^^^^^^^^ C416 + | + = help: Rewrite using `list()` + +ℹ Suggested fix +21 21 | {k: v if v else None for k, v in y} +22 22 | +23 23 | # Regression test for: https://github.com/astral-sh/ruff/issues/7196 +24 |-any(len(symbol_table.get_by_type(symbol_type)) > 0 for symbol_type in[t for t in SymbolType]) + 24 |+any(len(symbol_table.get_by_type(symbol_type)) > 0 for symbol_type in list(SymbolType)) + + 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 new file mode 100644 index 0000000000..1418d486ed --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C417_C417.py.snap @@ -0,0 +1,367 @@ +--- +source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs +--- +C417.py:3:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) + | +1 | # Errors. +2 | nums = [1, 2, 3] +3 | map(lambda x: x + 1, nums) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 +4 | map(lambda x: str(x), nums) +5 | list(map(lambda x: x * 2, nums)) + | + = help: Replace `map` with a generator expression + +ℹ Suggested fix +1 1 | # Errors. +2 2 | nums = [1, 2, 3] +3 |-map(lambda x: x + 1, nums) + 3 |+(x + 1 for x in nums) +4 4 | map(lambda x: str(x), nums) +5 5 | list(map(lambda x: x * 2, nums)) +6 6 | set(map(lambda x: x % 2 == 0, nums)) + +C417.py:4:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) + | +2 | nums = [1, 2, 3] +3 | map(lambda x: x + 1, nums) +4 | map(lambda x: str(x), nums) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 +5 | list(map(lambda x: x * 2, nums)) +6 | set(map(lambda x: x % 2 == 0, nums)) + | + = help: Replace `map` with a generator expression + +ℹ Suggested fix +1 1 | # Errors. +2 2 | nums = [1, 2, 3] +3 3 | map(lambda x: x + 1, nums) +4 |-map(lambda x: str(x), nums) + 4 |+(str(x) for x in nums) +5 5 | list(map(lambda x: x * 2, nums)) +6 6 | set(map(lambda x: x % 2 == 0, nums)) +7 7 | dict(map(lambda v: (v, v**2), nums)) + +C417.py:5:1: C417 [*] Unnecessary `map` usage (rewrite using a `list` comprehension) + | +3 | map(lambda x: x + 1, nums) +4 | map(lambda x: str(x), nums) +5 | list(map(lambda x: x * 2, nums)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 +6 | set(map(lambda x: x % 2 == 0, nums)) +7 | dict(map(lambda v: (v, v**2), nums)) + | + = help: Replace `map` with a `list` comprehension + +ℹ Suggested fix +2 2 | nums = [1, 2, 3] +3 3 | map(lambda x: x + 1, nums) +4 4 | map(lambda x: str(x), nums) +5 |-list(map(lambda x: x * 2, nums)) + 5 |+[x * 2 for x in nums] +6 6 | set(map(lambda x: x % 2 == 0, nums)) +7 7 | dict(map(lambda v: (v, v**2), nums)) +8 8 | dict(map(lambda v: [v, v**2], nums)) + +C417.py:6:1: C417 [*] Unnecessary `map` usage (rewrite using a `set` comprehension) + | +4 | map(lambda x: str(x), nums) +5 | list(map(lambda x: x * 2, nums)) +6 | set(map(lambda x: x % 2 == 0, nums)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 +7 | dict(map(lambda v: (v, v**2), nums)) +8 | dict(map(lambda v: [v, v**2], nums)) + | + = help: Replace `map` with a `set` comprehension + +ℹ Suggested fix +3 3 | map(lambda x: x + 1, nums) +4 4 | map(lambda x: str(x), nums) +5 5 | list(map(lambda x: x * 2, nums)) +6 |-set(map(lambda x: x % 2 == 0, nums)) + 6 |+{x % 2 == 0 for x in nums} +7 7 | dict(map(lambda v: (v, v**2), nums)) +8 8 | dict(map(lambda v: [v, v**2], nums)) +9 9 | map(lambda: "const", nums) + +C417.py:7:1: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehension) + | +5 | list(map(lambda x: x * 2, nums)) +6 | set(map(lambda x: x % 2 == 0, nums)) +7 | dict(map(lambda v: (v, v**2), nums)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 +8 | dict(map(lambda v: [v, v**2], nums)) +9 | map(lambda: "const", nums) + | + = help: Replace `map` with a `dict` comprehension + +ℹ Suggested fix +4 4 | map(lambda x: str(x), nums) +5 5 | list(map(lambda x: x * 2, nums)) +6 6 | set(map(lambda x: x % 2 == 0, nums)) +7 |-dict(map(lambda v: (v, v**2), nums)) + 7 |+{v: v**2 for v in nums} +8 8 | dict(map(lambda v: [v, v**2], nums)) +9 9 | map(lambda: "const", nums) +10 10 | map(lambda _: 3.0, nums) + +C417.py:8:1: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehension) + | + 6 | set(map(lambda x: x % 2 == 0, nums)) + 7 | dict(map(lambda v: (v, v**2), nums)) + 8 | dict(map(lambda v: [v, v**2], nums)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + 9 | map(lambda: "const", nums) +10 | map(lambda _: 3.0, nums) + | + = help: Replace `map` with a `dict` comprehension + +ℹ Suggested fix +5 5 | list(map(lambda x: x * 2, nums)) +6 6 | set(map(lambda x: x % 2 == 0, nums)) +7 7 | dict(map(lambda v: (v, v**2), nums)) +8 |-dict(map(lambda v: [v, v**2], nums)) + 8 |+{v: v**2 for v in nums} +9 9 | map(lambda: "const", nums) +10 10 | map(lambda _: 3.0, nums) +11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) + +C417.py:9:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) + | + 7 | dict(map(lambda v: (v, v**2), nums)) + 8 | dict(map(lambda v: [v, v**2], nums)) + 9 | map(lambda: "const", nums) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 +10 | map(lambda _: 3.0, nums) +11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) + | + = help: Replace `map` with a generator expression + +ℹ Suggested fix +6 6 | set(map(lambda x: x % 2 == 0, nums)) +7 7 | dict(map(lambda v: (v, v**2), nums)) +8 8 | dict(map(lambda v: [v, v**2], nums)) +9 |-map(lambda: "const", nums) + 9 |+("const" for _ in nums) +10 10 | map(lambda _: 3.0, nums) +11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) +12 12 | all(map(lambda v: isinstance(v, dict), nums)) + +C417.py:10:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) + | + 8 | dict(map(lambda v: [v, v**2], nums)) + 9 | map(lambda: "const", nums) +10 | map(lambda _: 3.0, nums) + | ^^^^^^^^^^^^^^^^^^^^^^^^ C417 +11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) +12 | all(map(lambda v: isinstance(v, dict), nums)) + | + = help: Replace `map` with a generator expression + +ℹ Suggested fix +7 7 | dict(map(lambda v: (v, v**2), nums)) +8 8 | dict(map(lambda v: [v, v**2], nums)) +9 9 | map(lambda: "const", nums) +10 |-map(lambda _: 3.0, nums) + 10 |+(3.0 for _ in nums) +11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) +12 12 | all(map(lambda v: isinstance(v, dict), nums)) +13 13 | filter(func, map(lambda v: v, nums)) + +C417.py:11:13: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) + | + 9 | map(lambda: "const", nums) +10 | map(lambda _: 3.0, nums) +11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 +12 | all(map(lambda v: isinstance(v, dict), nums)) +13 | filter(func, map(lambda v: v, nums)) + | + = help: Replace `map` with a generator expression + +ℹ Suggested fix +8 8 | dict(map(lambda v: [v, v**2], nums)) +9 9 | map(lambda: "const", nums) +10 10 | map(lambda _: 3.0, nums) +11 |-_ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) + 11 |+_ = "".join((x in nums and "1" or "0" for x in range(123))) +12 12 | all(map(lambda v: isinstance(v, dict), nums)) +13 13 | filter(func, map(lambda v: v, nums)) +14 14 | list(map(lambda x, y: x * y, nums)) + +C417.py:12:5: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) + | +10 | map(lambda _: 3.0, nums) +11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) +12 | all(map(lambda v: isinstance(v, dict), nums)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 +13 | filter(func, map(lambda v: v, nums)) +14 | list(map(lambda x, y: x * y, nums)) + | + = help: Replace `map` with a generator expression + +ℹ Suggested fix +9 9 | map(lambda: "const", nums) +10 10 | map(lambda _: 3.0, nums) +11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) +12 |-all(map(lambda v: isinstance(v, dict), nums)) + 12 |+all((isinstance(v, dict) for v in nums)) +13 13 | filter(func, map(lambda v: v, nums)) +14 14 | list(map(lambda x, y: x * y, nums)) +15 15 | + +C417.py:13:14: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) + | +11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) +12 | all(map(lambda v: isinstance(v, dict), nums)) +13 | filter(func, map(lambda v: v, nums)) + | ^^^^^^^^^^^^^^^^^^^^^^ C417 +14 | list(map(lambda x, y: x * y, nums)) + | + = help: Replace `map` with a generator expression + +ℹ Suggested fix +10 10 | map(lambda _: 3.0, nums) +11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) +12 12 | all(map(lambda v: isinstance(v, dict), nums)) +13 |-filter(func, map(lambda v: v, nums)) + 13 |+filter(func, (v for v in nums)) +14 14 | list(map(lambda x, y: x * y, nums)) +15 15 | +16 16 | # When inside f-string, then the fix should be surrounded by whitespace + +C417.py:14:1: C417 [*] Unnecessary `map` usage (rewrite using a `list` comprehension) + | +12 | all(map(lambda v: isinstance(v, dict), nums)) +13 | filter(func, map(lambda v: v, nums)) +14 | list(map(lambda x, y: x * y, nums)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 +15 | +16 | # When inside f-string, then the fix should be surrounded by whitespace + | + = help: Replace `map` with a `list` comprehension + +ℹ Suggested fix +11 11 | _ = "".join(map(lambda x: x in nums and "1" or "0", range(123))) +12 12 | all(map(lambda v: isinstance(v, dict), nums)) +13 13 | filter(func, map(lambda v: v, nums)) +14 |-list(map(lambda x, y: x * y, nums)) + 14 |+[x * y for x, y in nums] +15 15 | +16 16 | # When inside f-string, then the fix should be surrounded by whitespace +17 17 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" + +C417.py:17:8: C417 [*] Unnecessary `map` usage (rewrite using a `set` comprehension) + | +16 | # When inside f-string, then the fix should be surrounded by whitespace +17 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 +18 | _ = f"{dict(map(lambda v: (v, v**2), nums))}" + | + = help: Replace `map` with a `set` comprehension + +ℹ Suggested fix +14 14 | list(map(lambda x, y: x * y, nums)) +15 15 | +16 16 | # When inside f-string, then the fix should be surrounded by whitespace +17 |-_ = f"{set(map(lambda x: x % 2 == 0, nums))}" + 17 |+_ = f"{ {x % 2 == 0 for x in nums} }" +18 18 | _ = f"{dict(map(lambda v: (v, v**2), nums))}" +19 19 | +20 20 | # False negatives. + +C417.py:18:8: C417 [*] Unnecessary `map` usage (rewrite using a `dict` comprehension) + | +16 | # When inside f-string, then the fix should be surrounded by whitespace +17 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" +18 | _ = f"{dict(map(lambda v: (v, v**2), nums))}" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 +19 | +20 | # False negatives. + | + = help: Replace `map` with a `dict` comprehension + +ℹ Suggested fix +15 15 | +16 16 | # When inside f-string, then the fix should be surrounded by whitespace +17 17 | _ = f"{set(map(lambda x: x % 2 == 0, nums))}" +18 |-_ = f"{dict(map(lambda v: (v, v**2), nums))}" + 18 |+_ = f"{ {v: v**2 for v in nums} }" +19 19 | +20 20 | # False negatives. +21 21 | map(lambda x=2, y=1: x + y, nums, nums) + +C417.py:36:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) + | +35 | # Error: the `x` is overridden by the inner lambda. +36 | map(lambda x: lambda x: x, range(4)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 +37 | +38 | # Ok because of the default parameters, and variadic arguments. + | + = help: Replace `map` with a generator expression + +ℹ Suggested fix +33 33 | map(lambda x: lambda: x, range(4)) +34 34 | +35 35 | # Error: the `x` is overridden by the inner lambda. +36 |-map(lambda x: lambda x: x, range(4)) + 36 |+(lambda x: x for x in range(4)) +37 37 | +38 38 | # Ok because of the default parameters, and variadic arguments. +39 39 | map(lambda x=1: x, nums) + +C417.py:47:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) + | +46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 +47 | map(lambda x: x, y if y else z) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 +48 | map(lambda x: x, (y if y else z)) +49 | map(lambda x: x, (x, y, z)) + | + = help: Replace `map` with a generator expression + +ℹ Suggested fix +44 44 | dict(map(lambda k, v: (k, v), keys, values)) +45 45 | +46 46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 +47 |-map(lambda x: x, y if y else z) + 47 |+(x for x in (y if y else z)) +48 48 | map(lambda x: x, (y if y else z)) +49 49 | map(lambda x: x, (x, y, z)) + +C417.py:48:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) + | +46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 +47 | map(lambda x: x, y if y else z) +48 | map(lambda x: x, (y if y else z)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 +49 | map(lambda x: x, (x, y, z)) + | + = help: Replace `map` with a generator expression + +ℹ Suggested fix +45 45 | +46 46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 +47 47 | map(lambda x: x, y if y else z) +48 |-map(lambda x: x, (y if y else z)) + 48 |+(x for x in (y if y else z)) +49 49 | map(lambda x: x, (x, y, z)) + +C417.py:49:1: C417 [*] Unnecessary `map` usage (rewrite using a generator expression) + | +47 | map(lambda x: x, y if y else z) +48 | map(lambda x: x, (y if y else z)) +49 | map(lambda x: x, (x, y, z)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ C417 + | + = help: Replace `map` with a generator expression + +ℹ Suggested fix +46 46 | # Regression test for: https://github.com/astral-sh/ruff/issues/7121 +47 47 | map(lambda x: x, y if y else z) +48 48 | map(lambda x: x, (y if y else z)) +49 |-map(lambda x: x, (x, y, z)) + 49 |+(x for x in (x, y, z)) + + 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 new file mode 100644 index 0000000000..301da13fcd --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C418_C418.py.snap @@ -0,0 +1,83 @@ +--- +source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs +--- +C418.py:1:1: C418 [*] Unnecessary `dict` literal passed to `dict()` (remove the outer call to `dict()`) + | +1 | dict({}) + | ^^^^^^^^ C418 +2 | dict({'a': 1}) +3 | dict({'x': 1 for x in range(10)}) + | + = help: Remove outer `dict` call + +ℹ Suggested fix +1 |-dict({}) + 1 |+{} +2 2 | dict({'a': 1}) +3 3 | dict({'x': 1 for x in range(10)}) +4 4 | dict( + +C418.py:2:1: C418 [*] Unnecessary `dict` literal passed to `dict()` (remove the outer call to `dict()`) + | +1 | dict({}) +2 | dict({'a': 1}) + | ^^^^^^^^^^^^^^ C418 +3 | dict({'x': 1 for x in range(10)}) +4 | dict( + | + = help: Remove outer `dict` call + +ℹ Suggested fix +1 1 | dict({}) +2 |-dict({'a': 1}) + 2 |+{'a': 1} +3 3 | dict({'x': 1 for x in range(10)}) +4 4 | dict( +5 5 | {'x': 1 for x in range(10)} + +C418.py:3:1: C418 [*] Unnecessary `dict` comprehension passed to `dict()` (remove the outer call to `dict()`) + | +1 | dict({}) +2 | dict({'a': 1}) +3 | dict({'x': 1 for x in range(10)}) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C418 +4 | dict( +5 | {'x': 1 for x in range(10)} + | + = help: Remove outer `dict` call + +ℹ Suggested fix +1 1 | dict({}) +2 2 | dict({'a': 1}) +3 |-dict({'x': 1 for x in range(10)}) + 3 |+{'x': 1 for x in range(10)} +4 4 | dict( +5 5 | {'x': 1 for x in range(10)} +6 6 | ) + +C418.py:4:1: C418 [*] Unnecessary `dict` comprehension passed to `dict()` (remove the outer call to `dict()`) + | +2 | dict({'a': 1}) +3 | dict({'x': 1 for x in range(10)}) +4 | / dict( +5 | | {'x': 1 for x in range(10)} +6 | | ) + | |_^ C418 +7 | +8 | dict({}, a=1) + | + = help: Remove outer `dict` call + +ℹ Suggested fix +1 1 | dict({}) +2 2 | dict({'a': 1}) +3 3 | dict({'x': 1 for x in range(10)}) +4 |-dict( +5 |- {'x': 1 for x in range(10)} +6 |-) + 4 |+{'x': 1 for x in range(10)} +7 5 | +8 6 | dict({}, a=1) +9 7 | dict({x: 1 for x in range(1)}, a=1) + + 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 new file mode 100644 index 0000000000..611f4aac47 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C419_C419.py.snap @@ -0,0 +1,164 @@ +--- +source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs +--- +C419.py:1:5: C419 [*] Unnecessary list comprehension. + | +1 | any([x.id for x in bar]) + | ^^^^^^^^^^^^^^^^^^^ C419 +2 | all([x.id for x in bar]) +3 | any( # first comment + | + = help: Remove unnecessary list comprehension + +ℹ Suggested fix +1 |-any([x.id for x in bar]) + 1 |+any(x.id for x in bar) +2 2 | all([x.id for x in bar]) +3 3 | any( # first comment +4 4 | [x.id for x in bar], # second comment + +C419.py:2:5: C419 [*] Unnecessary list comprehension. + | +1 | any([x.id for x in bar]) +2 | all([x.id for x in bar]) + | ^^^^^^^^^^^^^^^^^^^ C419 +3 | any( # first comment +4 | [x.id for x in bar], # second comment + | + = help: Remove unnecessary list comprehension + +ℹ Suggested fix +1 1 | any([x.id for x in bar]) +2 |-all([x.id for x in bar]) + 2 |+all(x.id for x in bar) +3 3 | any( # first comment +4 4 | [x.id for x in bar], # second comment +5 5 | ) # third comment + +C419.py:4:5: C419 [*] Unnecessary list comprehension. + | +2 | all([x.id for x in bar]) +3 | any( # first comment +4 | [x.id for x in bar], # second comment + | ^^^^^^^^^^^^^^^^^^^ C419 +5 | ) # third comment +6 | all( # first comment + | + = help: Remove unnecessary list comprehension + +ℹ Suggested fix +1 1 | any([x.id for x in bar]) +2 2 | all([x.id for x in bar]) +3 3 | any( # first comment +4 |- [x.id for x in bar], # second comment + 4 |+ x.id for x in bar # second comment +5 5 | ) # third comment +6 6 | all( # first comment +7 7 | [x.id for x in bar], # second comment + +C419.py:7:5: C419 [*] Unnecessary list comprehension. + | +5 | ) # third comment +6 | all( # first comment +7 | [x.id for x in bar], # second comment + | ^^^^^^^^^^^^^^^^^^^ C419 +8 | ) # third comment +9 | any({x.id for x in bar}) + | + = help: Remove unnecessary list comprehension + +ℹ Suggested fix +4 4 | [x.id for x in bar], # second comment +5 5 | ) # third comment +6 6 | all( # first comment +7 |- [x.id for x in bar], # second comment + 7 |+ x.id for x in bar # second comment +8 8 | ) # third comment +9 9 | any({x.id for x in bar}) +10 10 | + +C419.py:9:5: C419 [*] Unnecessary list comprehension. + | + 7 | [x.id for x in bar], # second comment + 8 | ) # third comment + 9 | any({x.id for x in bar}) + | ^^^^^^^^^^^^^^^^^^^ C419 +10 | +11 | # OK + | + = help: Remove unnecessary list comprehension + +ℹ Suggested fix +6 6 | all( # first comment +7 7 | [x.id for x in bar], # second comment +8 8 | ) # third comment +9 |-any({x.id for x in bar}) + 9 |+any(x.id for x in bar) +10 10 | +11 11 | # OK +12 12 | all(x.id for x in bar) + +C419.py:24:5: C419 [*] Unnecessary list comprehension. + | +22 | # Special comment handling +23 | any( +24 | [ # lbracket comment + | _____^ +25 | | # second line comment +26 | | i.bit_count() +27 | | # random middle comment +28 | | for i in range(5) # rbracket comment +29 | | ] # rpar comment + | |_____^ C419 +30 | # trailing comment +31 | ) + | + = help: Remove unnecessary list comprehension + +ℹ Suggested fix +21 21 | +22 22 | # Special comment handling +23 23 | any( +24 |- [ # lbracket comment +25 |- # second line comment +26 |- i.bit_count() + 24 |+ # lbracket comment + 25 |+ # second line comment + 26 |+ i.bit_count() +27 27 | # random middle comment +28 |- for i in range(5) # rbracket comment +29 |- ] # rpar comment + 28 |+ for i in range(5) # rbracket comment # rpar comment +30 29 | # trailing comment +31 30 | ) +32 31 | + +C419.py:35:5: C419 [*] Unnecessary list comprehension. + | +33 | # Weird case where the function call, opening bracket, and comment are all +34 | # on the same line. +35 | any([ # lbracket comment + | _____^ +36 | | # second line comment +37 | | i.bit_count() for i in range(5) # rbracket comment +38 | | ] # rpar comment + | |_____^ C419 +39 | ) + | + = help: Remove unnecessary list comprehension + +ℹ Suggested fix +32 32 | +33 33 | # Weird case where the function call, opening bracket, and comment are all +34 34 | # on the same line. +35 |-any([ # lbracket comment +36 |- # second line comment +37 |- i.bit_count() for i in range(5) # rbracket comment +38 |- ] # rpar comment + 35 |+any( + 36 |+# lbracket comment + 37 |+# second line comment + 38 |+i.bit_count() for i in range(5) # rbracket comment # rpar comment +39 39 | ) + + diff --git a/crates/ruff/src/rules/flake8_copyright/mod.rs b/crates/ruff_linter/src/rules/flake8_copyright/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_copyright/mod.rs rename to crates/ruff_linter/src/rules/flake8_copyright/mod.rs diff --git a/crates/ruff/src/rules/flake8_copyright/rules/missing_copyright_notice.rs b/crates/ruff_linter/src/rules/flake8_copyright/rules/missing_copyright_notice.rs similarity index 100% rename from crates/ruff/src/rules/flake8_copyright/rules/missing_copyright_notice.rs rename to crates/ruff_linter/src/rules/flake8_copyright/rules/missing_copyright_notice.rs diff --git a/crates/ruff/src/rules/flake8_copyright/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_copyright/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_copyright/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_copyright/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_copyright/settings.rs b/crates/ruff_linter/src/rules/flake8_copyright/settings.rs similarity index 100% rename from crates/ruff/src/rules/flake8_copyright/settings.rs rename to crates/ruff_linter/src/rules/flake8_copyright/settings.rs diff --git a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__char_boundary.snap b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__char_boundary.snap new file mode 100644 index 0000000000..1f52748b8e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__char_boundary.snap @@ -0,0 +1,10 @@ +--- +source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs +--- +:1:1: CPY001 Missing copyright notice at top of file + | +1 | কককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককককক + | CPY001 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__invalid_author.snap b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__invalid_author.snap new file mode 100644 index 0000000000..ee07c07140 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__invalid_author.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs +--- +:1:1: CPY001 Missing copyright notice at top of file + | +1 | # Copyright (C) 2023 Some Author + | CPY001 +2 | +3 | import os + | + + diff --git a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__late_notice.snap b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__late_notice.snap new file mode 100644 index 0000000000..73a072d539 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__late_notice.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs +--- +:1:1: CPY001 Missing copyright notice at top of file + | +1 | # Content Content Content Content Content Content Content Content Content Content + | CPY001 +2 | # Content Content Content Content Content Content Content Content Content Content +3 | # Content Content Content Content Content Content Content Content Content Content + | + + diff --git a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__notice.snap b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__notice.snap new file mode 100644 index 0000000000..314ed9c4f9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__notice.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__notice_with_c.snap b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__notice_with_c.snap new file mode 100644 index 0000000000..314ed9c4f9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__notice_with_c.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__notice_with_caps.snap b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__notice_with_caps.snap new file mode 100644 index 0000000000..314ed9c4f9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__notice_with_caps.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__notice_with_range.snap b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__notice_with_range.snap new file mode 100644 index 0000000000..314ed9c4f9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__notice_with_range.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__small_file.snap b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__small_file.snap new file mode 100644 index 0000000000..314ed9c4f9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__small_file.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__valid_author.snap b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__valid_author.snap new file mode 100644 index 0000000000..314ed9c4f9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_copyright/snapshots/ruff_linter__rules__flake8_copyright__tests__valid_author.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_copyright/mod.rs +--- + diff --git a/crates/ruff/src/rules/flake8_datetimez/mod.rs b/crates/ruff_linter/src/rules/flake8_datetimez/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_datetimez/mod.rs rename to crates/ruff_linter/src/rules/flake8_datetimez/mod.rs diff --git a/crates/ruff/src/rules/flake8_datetimez/rules/call_date_fromtimestamp.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_fromtimestamp.rs similarity index 100% rename from crates/ruff/src/rules/flake8_datetimez/rules/call_date_fromtimestamp.rs rename to crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_fromtimestamp.rs diff --git a/crates/ruff/src/rules/flake8_datetimez/rules/call_date_today.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_today.rs similarity index 100% rename from crates/ruff/src/rules/flake8_datetimez/rules/call_date_today.rs rename to crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_today.rs diff --git a/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs similarity index 100% rename from crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs rename to crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs diff --git a/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_now_without_tzinfo.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_now_without_tzinfo.rs similarity index 100% rename from crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_now_without_tzinfo.rs rename to crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_now_without_tzinfo.rs diff --git a/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_strptime_without_zone.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_strptime_without_zone.rs similarity index 100% rename from crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_strptime_without_zone.rs rename to crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_strptime_without_zone.rs diff --git a/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_today.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_today.rs similarity index 100% rename from crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_today.rs rename to crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_today.rs diff --git a/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_utcfromtimestamp.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_utcfromtimestamp.rs similarity index 100% rename from crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_utcfromtimestamp.rs rename to crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_utcfromtimestamp.rs diff --git a/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_utcnow.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_utcnow.rs similarity index 100% rename from crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_utcnow.rs rename to crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_utcnow.rs diff --git a/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs similarity index 100% rename from crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs rename to crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs diff --git a/crates/ruff/src/rules/flake8_datetimez/rules/helpers.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/helpers.rs similarity index 100% rename from crates/ruff/src/rules/flake8_datetimez/rules/helpers.rs rename to crates/ruff_linter/src/rules/flake8_datetimez/rules/helpers.rs diff --git a/crates/ruff/src/rules/flake8_datetimez/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_datetimez/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_datetimez/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_datetimez/rules/mod.rs 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 new file mode 100644 index 0000000000..45f6dc6657 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ001_DTZ001.py.snap @@ -0,0 +1,49 @@ +--- +source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs +--- +DTZ001.py:4:1: DTZ001 The use of `datetime.datetime()` without `tzinfo` argument is not allowed + | +3 | # no args +4 | datetime.datetime(2000, 1, 1, 0, 0, 0) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 +5 | +6 | # none args + | + +DTZ001.py:7:1: DTZ001 The use of `datetime.datetime()` without `tzinfo` argument is not allowed + | +6 | # none args +7 | datetime.datetime(2000, 1, 1, 0, 0, 0, 0, None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 +8 | +9 | # not none arg + | + +DTZ001.py:13:1: DTZ001 The use of `datetime.datetime()` without `tzinfo` argument is not allowed + | +12 | # no kwargs +13 | datetime.datetime(2000, 1, 1, fold=1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 +14 | +15 | # none kwargs + | + +DTZ001.py:16:1: DTZ001 The use of `datetime.datetime()` without `tzinfo` argument is not allowed + | +15 | # none kwargs +16 | datetime.datetime(2000, 1, 1, tzinfo=None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 +17 | +18 | from datetime import datetime + | + +DTZ001.py:21:1: DTZ001 The use of `datetime.datetime()` without `tzinfo` argument is not allowed + | +20 | # no args unqualified +21 | datetime(2000, 1, 1, 0, 0, 0) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ001 +22 | +23 | # uses `astimezone` method + | + + 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 new file mode 100644 index 0000000000..d7ff15f3f5 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ002_DTZ002.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs +--- +DTZ002.py:4:1: DTZ002 The use of `datetime.datetime.today()` is not allowed, use `datetime.datetime.now(tz=)` instead + | +3 | # qualified +4 | datetime.datetime.today() + | ^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ002 +5 | +6 | from datetime import datetime + | + +DTZ002.py:9:1: DTZ002 The use of `datetime.datetime.today()` is not allowed, use `datetime.datetime.now(tz=)` instead + | + 8 | # unqualified + 9 | datetime.today() + | ^^^^^^^^^^^^^^^^ DTZ002 +10 | +11 | # uses `astimezone` method + | + + 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 new file mode 100644 index 0000000000..0c1da8d49b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ003_DTZ003.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs +--- +DTZ003.py:4:1: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead + | +3 | # qualified +4 | datetime.datetime.utcnow() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ003 +5 | +6 | from datetime import datetime + | + +DTZ003.py:9:1: DTZ003 The use of `datetime.datetime.utcnow()` is not allowed, use `datetime.datetime.now(tz=)` instead + | + 8 | # unqualified + 9 | datetime.utcnow() + | ^^^^^^^^^^^^^^^^^ DTZ003 +10 | +11 | # uses `astimezone` method + | + + 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 new file mode 100644 index 0000000000..d0a0184fe3 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ004_DTZ004.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs +--- +DTZ004.py:4:1: DTZ004 The use of `datetime.datetime.utcfromtimestamp()` is not allowed, use `datetime.datetime.fromtimestamp(ts, tz=)` instead + | +3 | # qualified +4 | datetime.datetime.utcfromtimestamp(1234) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ004 +5 | +6 | from datetime import datetime + | + +DTZ004.py:9:1: DTZ004 The use of `datetime.datetime.utcfromtimestamp()` is not allowed, use `datetime.datetime.fromtimestamp(ts, tz=)` instead + | + 8 | # unqualified + 9 | datetime.utcfromtimestamp(1234) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ004 +10 | +11 | # uses `astimezone` method + | + + 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 new file mode 100644 index 0000000000..a20ccd8a46 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ005_DTZ005.py.snap @@ -0,0 +1,49 @@ +--- +source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs +--- +DTZ005.py:4:1: DTZ005 The use of `datetime.datetime.now()` without `tz` argument is not allowed + | +3 | # no args +4 | datetime.datetime.now() + | ^^^^^^^^^^^^^^^^^^^^^^^ DTZ005 +5 | +6 | # wrong keywords + | + +DTZ005.py:7:1: DTZ005 The use of `datetime.datetime.now()` without `tz` argument is not allowed + | +6 | # wrong keywords +7 | datetime.datetime.now(bad=datetime.timezone.utc) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ005 +8 | +9 | # none args + | + +DTZ005.py:10:1: DTZ005 The use of `datetime.datetime.now()` without `tz` argument is not allowed + | + 9 | # none args +10 | datetime.datetime.now(None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ005 +11 | +12 | # none keywords + | + +DTZ005.py:13:1: DTZ005 The use of `datetime.datetime.now()` without `tz` argument is not allowed + | +12 | # none keywords +13 | datetime.datetime.now(tz=None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ005 +14 | +15 | from datetime import datetime + | + +DTZ005.py:18:1: DTZ005 The use of `datetime.datetime.now()` without `tz` argument is not allowed + | +17 | # no args unqualified +18 | datetime.now() + | ^^^^^^^^^^^^^^ DTZ005 +19 | +20 | # uses `astimezone` method + | + + 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 new file mode 100644 index 0000000000..671c428306 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ006_DTZ006.py.snap @@ -0,0 +1,49 @@ +--- +source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs +--- +DTZ006.py:4:1: DTZ006 The use of `datetime.datetime.fromtimestamp()` without `tz` argument is not allowed + | +3 | # no args +4 | datetime.datetime.fromtimestamp(1234) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 +5 | +6 | # wrong keywords + | + +DTZ006.py:7:1: DTZ006 The use of `datetime.datetime.fromtimestamp()` without `tz` argument is not allowed + | +6 | # wrong keywords +7 | datetime.datetime.fromtimestamp(1234, bad=datetime.timezone.utc) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 +8 | +9 | # none args + | + +DTZ006.py:10:1: DTZ006 The use of `datetime.datetime.fromtimestamp()` without `tz` argument is not allowed + | + 9 | # none args +10 | datetime.datetime.fromtimestamp(1234, None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 +11 | +12 | # none keywords + | + +DTZ006.py:13:1: DTZ006 The use of `datetime.datetime.fromtimestamp()` without `tz` argument is not allowed + | +12 | # none keywords +13 | datetime.datetime.fromtimestamp(1234, tz=None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 +14 | +15 | from datetime import datetime + | + +DTZ006.py:18:1: DTZ006 The use of `datetime.datetime.fromtimestamp()` without `tz` argument is not allowed + | +17 | # no args unqualified +18 | datetime.fromtimestamp(1234) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ006 +19 | +20 | # uses `astimezone` method + | + + 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 new file mode 100644 index 0000000000..d47324ece6 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ007_DTZ007.py.snap @@ -0,0 +1,47 @@ +--- +source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs +--- +DTZ007.py:4:1: DTZ007 The use of `datetime.datetime.strptime()` without %z must be followed by `.replace(tzinfo=)` or `.astimezone()` + | +3 | # bad format +4 | datetime.datetime.strptime("something", "%H:%M:%S%Z") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 +5 | +6 | # no replace or astimezone + | + +DTZ007.py:7:1: DTZ007 The use of `datetime.datetime.strptime()` without %z must be followed by `.replace(tzinfo=)` or `.astimezone()` + | +6 | # no replace or astimezone +7 | datetime.datetime.strptime("something", "something") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 +8 | +9 | # wrong replace + | + +DTZ007.py:10:1: DTZ007 The use of `datetime.datetime.strptime()` without %z must be followed by `.replace(tzinfo=)` or `.astimezone()` + | + 9 | # wrong replace +10 | datetime.datetime.strptime("something", "something").replace(hour=1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 +11 | +12 | # none replace + | + +DTZ007.py:13:1: DTZ007 The use of `datetime.datetime.strptime()` without %z must be followed by `.replace(tzinfo=)` or `.astimezone()` + | +12 | # none replace +13 | datetime.datetime.strptime("something", "something").replace(tzinfo=None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 +14 | +15 | # OK + | + +DTZ007.py:35:1: DTZ007 The use of `datetime.datetime.strptime()` without %z must be followed by `.replace(tzinfo=)` or `.astimezone()` + | +34 | # no replace orastimezone unqualified +35 | datetime.strptime("something", "something") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ007 + | + + 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 new file mode 100644 index 0000000000..546f8e9bbf --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ011_DTZ011.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs +--- +DTZ011.py:4:1: DTZ011 The use of `datetime.date.today()` is not allowed, use `datetime.datetime.now(tz=).date()` instead + | +3 | # qualified +4 | datetime.date.today() + | ^^^^^^^^^^^^^^^^^^^^^ DTZ011 +5 | +6 | from datetime import date + | + +DTZ011.py:9:1: DTZ011 The use of `datetime.date.today()` is not allowed, use `datetime.datetime.now(tz=).date()` instead + | +8 | # unqualified +9 | date.today() + | ^^^^^^^^^^^^ DTZ011 + | + + 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 new file mode 100644 index 0000000000..cce6418b93 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_datetimez/snapshots/ruff_linter__rules__flake8_datetimez__tests__DTZ012_DTZ012.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/flake8_datetimez/mod.rs +--- +DTZ012.py:4:1: DTZ012 The use of `datetime.date.fromtimestamp()` is not allowed, use `datetime.datetime.fromtimestamp(ts, tz=).date()` instead + | +3 | # qualified +4 | datetime.date.fromtimestamp(1234) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DTZ012 +5 | +6 | from datetime import date + | + +DTZ012.py:9:1: DTZ012 The use of `datetime.date.fromtimestamp()` is not allowed, use `datetime.datetime.fromtimestamp(ts, tz=).date()` instead + | +8 | # unqualified +9 | date.fromtimestamp(1234) + | ^^^^^^^^^^^^^^^^^^^^^^^^ DTZ012 + | + + diff --git a/crates/ruff/src/rules/flake8_debugger/mod.rs b/crates/ruff_linter/src/rules/flake8_debugger/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_debugger/mod.rs rename to crates/ruff_linter/src/rules/flake8_debugger/mod.rs diff --git a/crates/ruff/src/rules/flake8_debugger/rules/debugger.rs b/crates/ruff_linter/src/rules/flake8_debugger/rules/debugger.rs similarity index 100% rename from crates/ruff/src/rules/flake8_debugger/rules/debugger.rs rename to crates/ruff_linter/src/rules/flake8_debugger/rules/debugger.rs diff --git a/crates/ruff/src/rules/flake8_debugger/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_debugger/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_debugger/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_debugger/rules/mod.rs 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 new file mode 100644 index 0000000000..6bc248c15b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_debugger/snapshots/ruff_linter__rules__flake8_debugger__tests__T100_T100.py.snap @@ -0,0 +1,88 @@ +--- +source: crates/ruff_linter/src/rules/flake8_debugger/mod.rs +--- +T100.py:1:1: T100 Trace found: `breakpoint` used + | +1 | breakpoint() + | ^^^^^^^^^^^^ T100 +2 | +3 | import pdb + | + +T100.py:3:1: T100 Import for `pdb` found + | +1 | breakpoint() +2 | +3 | import pdb + | ^^^^^^^^^^ T100 +4 | import builtins +5 | from builtins import breakpoint + | + +T100.py:5:1: T100 Import for `builtins.breakpoint` found + | +3 | import pdb +4 | import builtins +5 | from builtins import breakpoint + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ T100 +6 | from pdb import set_trace as st +7 | from celery.contrib.rdb import set_trace + | + +T100.py:6:1: T100 Import for `pdb.set_trace` found + | +4 | import builtins +5 | from builtins import breakpoint +6 | from pdb import set_trace as st + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ T100 +7 | from celery.contrib.rdb import set_trace +8 | from celery.contrib import rdb + | + +T100.py:7:1: T100 Import for `celery.contrib.rdb.set_trace` found + | +5 | from builtins import breakpoint +6 | from pdb import set_trace as st +7 | from celery.contrib.rdb import set_trace + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ T100 +8 | from celery.contrib import rdb +9 | import celery.contrib.rdb + | + +T100.py:9:1: T100 Import for `celery.contrib.rdb` found + | + 7 | from celery.contrib.rdb import set_trace + 8 | from celery.contrib import rdb + 9 | import celery.contrib.rdb + | ^^^^^^^^^^^^^^^^^^^^^^^^^ T100 +10 | +11 | breakpoint() + | + +T100.py:11:1: T100 Trace found: `builtins.breakpoint` used + | + 9 | import celery.contrib.rdb +10 | +11 | breakpoint() + | ^^^^^^^^^^^^ T100 +12 | st() +13 | set_trace() + | + +T100.py:12:1: T100 Trace found: `pdb.set_trace` used + | +11 | breakpoint() +12 | st() + | ^^^^ T100 +13 | set_trace() + | + +T100.py:13:1: T100 Trace found: `celery.contrib.rdb.set_trace` used + | +11 | breakpoint() +12 | st() +13 | set_trace() + | ^^^^^^^^^^^ T100 + | + + diff --git a/crates/ruff/src/rules/flake8_debugger/types.rs b/crates/ruff_linter/src/rules/flake8_debugger/types.rs similarity index 100% rename from crates/ruff/src/rules/flake8_debugger/types.rs rename to crates/ruff_linter/src/rules/flake8_debugger/types.rs diff --git a/crates/ruff/src/rules/flake8_django/mod.rs b/crates/ruff_linter/src/rules/flake8_django/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_django/mod.rs rename to crates/ruff_linter/src/rules/flake8_django/mod.rs diff --git a/crates/ruff/src/rules/flake8_django/rules/all_with_model_form.rs b/crates/ruff_linter/src/rules/flake8_django/rules/all_with_model_form.rs similarity index 100% rename from crates/ruff/src/rules/flake8_django/rules/all_with_model_form.rs rename to crates/ruff_linter/src/rules/flake8_django/rules/all_with_model_form.rs diff --git a/crates/ruff/src/rules/flake8_django/rules/exclude_with_model_form.rs b/crates/ruff_linter/src/rules/flake8_django/rules/exclude_with_model_form.rs similarity index 100% rename from crates/ruff/src/rules/flake8_django/rules/exclude_with_model_form.rs rename to crates/ruff_linter/src/rules/flake8_django/rules/exclude_with_model_form.rs diff --git a/crates/ruff/src/rules/flake8_django/rules/helpers.rs b/crates/ruff_linter/src/rules/flake8_django/rules/helpers.rs similarity index 100% rename from crates/ruff/src/rules/flake8_django/rules/helpers.rs rename to crates/ruff_linter/src/rules/flake8_django/rules/helpers.rs diff --git a/crates/ruff/src/rules/flake8_django/rules/locals_in_render_function.rs b/crates/ruff_linter/src/rules/flake8_django/rules/locals_in_render_function.rs similarity index 100% rename from crates/ruff/src/rules/flake8_django/rules/locals_in_render_function.rs rename to crates/ruff_linter/src/rules/flake8_django/rules/locals_in_render_function.rs diff --git a/crates/ruff/src/rules/flake8_django/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_django/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_django/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_django/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_django/rules/model_without_dunder_str.rs b/crates/ruff_linter/src/rules/flake8_django/rules/model_without_dunder_str.rs similarity index 100% rename from crates/ruff/src/rules/flake8_django/rules/model_without_dunder_str.rs rename to crates/ruff_linter/src/rules/flake8_django/rules/model_without_dunder_str.rs diff --git a/crates/ruff/src/rules/flake8_django/rules/non_leading_receiver_decorator.rs b/crates/ruff_linter/src/rules/flake8_django/rules/non_leading_receiver_decorator.rs similarity index 100% rename from crates/ruff/src/rules/flake8_django/rules/non_leading_receiver_decorator.rs rename to crates/ruff_linter/src/rules/flake8_django/rules/non_leading_receiver_decorator.rs diff --git a/crates/ruff/src/rules/flake8_django/rules/nullable_model_string_field.rs b/crates/ruff_linter/src/rules/flake8_django/rules/nullable_model_string_field.rs similarity index 100% rename from crates/ruff/src/rules/flake8_django/rules/nullable_model_string_field.rs rename to crates/ruff_linter/src/rules/flake8_django/rules/nullable_model_string_field.rs diff --git a/crates/ruff/src/rules/flake8_django/rules/unordered_body_content_in_model.rs b/crates/ruff_linter/src/rules/flake8_django/rules/unordered_body_content_in_model.rs similarity index 100% rename from crates/ruff/src/rules/flake8_django/rules/unordered_body_content_in_model.rs rename to crates/ruff_linter/src/rules/flake8_django/rules/unordered_body_content_in_model.rs diff --git a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ001_DJ001.py.snap b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ001_DJ001.py.snap new file mode 100644 index 0000000000..d3c4c698a0 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ001_DJ001.py.snap @@ -0,0 +1,172 @@ +--- +source: crates/ruff_linter/src/rules/flake8_django/mod.rs +--- +DJ001.py:7:17: DJ001 Avoid using `null=True` on string-based fields such as CharField + | +6 | class IncorrectModel(models.Model): +7 | charfield = models.CharField(max_length=255, null=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 +8 | textfield = models.TextField(max_length=255, null=True) +9 | slugfield = models.SlugField(max_length=255, null=True) + | + +DJ001.py:8:17: DJ001 Avoid using `null=True` on string-based fields such as TextField + | + 6 | class IncorrectModel(models.Model): + 7 | charfield = models.CharField(max_length=255, null=True) + 8 | textfield = models.TextField(max_length=255, null=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + 9 | slugfield = models.SlugField(max_length=255, null=True) +10 | emailfield = models.EmailField(max_length=255, null=True) + | + +DJ001.py:9:17: DJ001 Avoid using `null=True` on string-based fields such as SlugField + | + 7 | charfield = models.CharField(max_length=255, null=True) + 8 | textfield = models.TextField(max_length=255, null=True) + 9 | slugfield = models.SlugField(max_length=255, null=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 +10 | emailfield = models.EmailField(max_length=255, null=True) +11 | filepathfield = models.FilePathField(max_length=255, null=True) + | + +DJ001.py:10:18: DJ001 Avoid using `null=True` on string-based fields such as EmailField + | + 8 | textfield = models.TextField(max_length=255, null=True) + 9 | slugfield = models.SlugField(max_length=255, null=True) +10 | emailfield = models.EmailField(max_length=255, null=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 +11 | filepathfield = models.FilePathField(max_length=255, null=True) +12 | urlfield = models.URLField(max_length=255, null=True) + | + +DJ001.py:11:21: DJ001 Avoid using `null=True` on string-based fields such as FilePathField + | + 9 | slugfield = models.SlugField(max_length=255, null=True) +10 | emailfield = models.EmailField(max_length=255, null=True) +11 | filepathfield = models.FilePathField(max_length=255, null=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 +12 | urlfield = models.URLField(max_length=255, null=True) + | + +DJ001.py:12:16: DJ001 Avoid using `null=True` on string-based fields such as URLField + | +10 | emailfield = models.EmailField(max_length=255, null=True) +11 | filepathfield = models.FilePathField(max_length=255, null=True) +12 | urlfield = models.URLField(max_length=255, null=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | + +DJ001.py:16:17: DJ001 Avoid using `null=True` on string-based fields such as CharField + | +15 | class IncorrectModelWithAlias(DjangoModel): +16 | charfield = DjangoModel.CharField(max_length=255, null=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 +17 | textfield = SmthCharField(max_length=255, null=True) +18 | slugfield = models.SlugField(max_length=255, null=True) + | + +DJ001.py:17:17: DJ001 Avoid using `null=True` on string-based fields such as CharField + | +15 | class IncorrectModelWithAlias(DjangoModel): +16 | charfield = DjangoModel.CharField(max_length=255, null=True) +17 | textfield = SmthCharField(max_length=255, null=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 +18 | slugfield = models.SlugField(max_length=255, null=True) +19 | emailfield = models.EmailField(max_length=255, null=True) + | + +DJ001.py:18:17: DJ001 Avoid using `null=True` on string-based fields such as SlugField + | +16 | charfield = DjangoModel.CharField(max_length=255, null=True) +17 | textfield = SmthCharField(max_length=255, null=True) +18 | slugfield = models.SlugField(max_length=255, null=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 +19 | emailfield = models.EmailField(max_length=255, null=True) +20 | filepathfield = models.FilePathField(max_length=255, null=True) + | + +DJ001.py:19:18: DJ001 Avoid using `null=True` on string-based fields such as EmailField + | +17 | textfield = SmthCharField(max_length=255, null=True) +18 | slugfield = models.SlugField(max_length=255, null=True) +19 | emailfield = models.EmailField(max_length=255, null=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 +20 | filepathfield = models.FilePathField(max_length=255, null=True) +21 | urlfield = models.URLField(max_length=255, null=True) + | + +DJ001.py:20:21: DJ001 Avoid using `null=True` on string-based fields such as FilePathField + | +18 | slugfield = models.SlugField(max_length=255, null=True) +19 | emailfield = models.EmailField(max_length=255, null=True) +20 | filepathfield = models.FilePathField(max_length=255, null=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 +21 | urlfield = models.URLField(max_length=255, null=True) + | + +DJ001.py:21:16: DJ001 Avoid using `null=True` on string-based fields such as URLField + | +19 | emailfield = models.EmailField(max_length=255, null=True) +20 | filepathfield = models.FilePathField(max_length=255, null=True) +21 | urlfield = models.URLField(max_length=255, null=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | + +DJ001.py:25:17: DJ001 Avoid using `null=True` on string-based fields such as CharField + | +24 | class IncorrectModelWithoutSuperclass: +25 | charfield = DjangoModel.CharField(max_length=255, null=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 +26 | textfield = SmthCharField(max_length=255, null=True) +27 | slugfield = models.SlugField(max_length=255, null=True) + | + +DJ001.py:26:17: DJ001 Avoid using `null=True` on string-based fields such as CharField + | +24 | class IncorrectModelWithoutSuperclass: +25 | charfield = DjangoModel.CharField(max_length=255, null=True) +26 | textfield = SmthCharField(max_length=255, null=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 +27 | slugfield = models.SlugField(max_length=255, null=True) +28 | emailfield = models.EmailField(max_length=255, null=True) + | + +DJ001.py:27:17: DJ001 Avoid using `null=True` on string-based fields such as SlugField + | +25 | charfield = DjangoModel.CharField(max_length=255, null=True) +26 | textfield = SmthCharField(max_length=255, null=True) +27 | slugfield = models.SlugField(max_length=255, null=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 +28 | emailfield = models.EmailField(max_length=255, null=True) +29 | filepathfield = models.FilePathField(max_length=255, null=True) + | + +DJ001.py:28:18: DJ001 Avoid using `null=True` on string-based fields such as EmailField + | +26 | textfield = SmthCharField(max_length=255, null=True) +27 | slugfield = models.SlugField(max_length=255, null=True) +28 | emailfield = models.EmailField(max_length=255, null=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 +29 | filepathfield = models.FilePathField(max_length=255, null=True) +30 | urlfield = models.URLField(max_length=255, null=True) + | + +DJ001.py:29:21: DJ001 Avoid using `null=True` on string-based fields such as FilePathField + | +27 | slugfield = models.SlugField(max_length=255, null=True) +28 | emailfield = models.EmailField(max_length=255, null=True) +29 | filepathfield = models.FilePathField(max_length=255, null=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 +30 | urlfield = models.URLField(max_length=255, null=True) + | + +DJ001.py:30:16: DJ001 Avoid using `null=True` on string-based fields such as URLField + | +28 | emailfield = models.EmailField(max_length=255, null=True) +29 | filepathfield = models.FilePathField(max_length=255, null=True) +30 | urlfield = models.URLField(max_length=255, null=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ001 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ003_DJ003.py.snap b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ003_DJ003.py.snap new file mode 100644 index 0000000000..ce26aedc42 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ003_DJ003.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/flake8_django/mod.rs +--- +DJ003.py:5:42: DJ003 Avoid passing `locals()` as context to a `render` function + | +4 | def test_view1(request): +5 | return render(request, "index.html", locals()) + | ^^^^^^^^ DJ003 + | + +DJ003.py:9:50: DJ003 Avoid passing `locals()` as context to a `render` function + | +8 | def test_view2(request): +9 | return render(request, "index.html", context=locals()) + | ^^^^^^^^ DJ003 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ006_DJ006.py.snap b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ006_DJ006.py.snap new file mode 100644 index 0000000000..185382fe24 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ006_DJ006.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_django/mod.rs +--- +DJ006.py:6:9: DJ006 Do not use `exclude` with `ModelForm`, use `fields` instead + | +4 | class TestModelForm1(forms.ModelForm): +5 | class Meta: +6 | exclude = ["bar"] + | ^^^^^^^ DJ006 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ007_DJ007.py.snap b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ007_DJ007.py.snap new file mode 100644 index 0000000000..4a38c1a542 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ007_DJ007.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/flake8_django/mod.rs +--- +DJ007.py:6:9: DJ007 Do not use `__all__` with `ModelForm`, use `fields` instead + | +4 | class TestModelForm1(forms.ModelForm): +5 | class Meta: +6 | fields = "__all__" + | ^^^^^^^^^^^^^^^^^^ DJ007 + | + +DJ007.py:11:9: DJ007 Do not use `__all__` with `ModelForm`, use `fields` instead + | + 9 | class TestModelForm2(forms.ModelForm): +10 | class Meta: +11 | fields = b"__all__" + | ^^^^^^^^^^^^^^^^^^^ DJ007 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ008_DJ008.py.snap b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ008_DJ008.py.snap new file mode 100644 index 0000000000..159ee3a9d2 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ008_DJ008.py.snap @@ -0,0 +1,26 @@ +--- +source: crates/ruff_linter/src/rules/flake8_django/mod.rs +--- +DJ008.py:6:7: DJ008 Model does not define `__str__` method + | +5 | # Models without __str__ +6 | class TestModel1(models.Model): + | ^^^^^^^^^^ DJ008 +7 | new_field = models.CharField(max_length=10) + | + +DJ008.py:21:7: DJ008 Model does not define `__str__` method + | +21 | class TestModel2(Model): + | ^^^^^^^^^^ DJ008 +22 | new_field = models.CharField(max_length=10) + | + +DJ008.py:36:7: DJ008 Model does not define `__str__` method + | +36 | class TestModel3(Model): + | ^^^^^^^^^^ DJ008 +37 | new_field = models.CharField(max_length=10) + | + + 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 new file mode 100644 index 0000000000..5f15655232 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ012_DJ012.py.snap @@ -0,0 +1,57 @@ +--- +source: crates/ruff_linter/src/rules/flake8_django/mod.rs +--- +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 | +28 | first_name = models.CharField(max_length=32) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ012 + | + +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 | +43 | first_name = models.CharField(max_length=32) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ012 + | + +DJ012.py:56:5: DJ012 Order of model's inner classes, methods, and fields does not follow the Django Style Guide: `__str__` method should come before custom method + | +54 | pass +55 | +56 | def __str__(self): + | _____^ +57 | | return "foobar" + | |_______________________^ DJ012 + | + +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): + | _____^ +70 | | pass + | |____________^ DJ012 + | + +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 | +123 | first_name = models.CharField(max_length=32) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ012 +124 | last_name = models.CharField(max_length=32) + | + +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 | +129 | middle_name = models.CharField(max_length=32) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ012 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ013_DJ013.py.snap b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ013_DJ013.py.snap new file mode 100644 index 0000000000..dbceb4b69b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_django/snapshots/ruff_linter__rules__flake8_django__tests__DJ013_DJ013.py.snap @@ -0,0 +1,23 @@ +--- +source: crates/ruff_linter/src/rules/flake8_django/mod.rs +--- +DJ013.py:15:1: DJ013 `@receiver` decorator must be on top of all the other decorators + | +14 | @test_decorator +15 | @receiver(pre_save, sender=MyModel) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ013 +16 | def incorrect_pre_save_handler(): +17 | pass + | + +DJ013.py:35:1: DJ013 `@receiver` decorator must be on top of all the other decorators + | +33 | @receiver(pre_save, sender=MyModel) +34 | @test_decorator +35 | @receiver(pre_save, sender=MyModel) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ DJ013 +36 | def incorrect_multiple(): +37 | pass + | + + diff --git a/crates/ruff/src/rules/flake8_errmsg/mod.rs b/crates/ruff_linter/src/rules/flake8_errmsg/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_errmsg/mod.rs rename to crates/ruff_linter/src/rules/flake8_errmsg/mod.rs diff --git a/crates/ruff/src/rules/flake8_errmsg/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_errmsg/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_errmsg/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_errmsg/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_errmsg/rules/string_in_exception.rs b/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs similarity index 100% rename from crates/ruff/src/rules/flake8_errmsg/rules/string_in_exception.rs rename to crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs diff --git a/crates/ruff/src/rules/flake8_errmsg/settings.rs b/crates/ruff_linter/src/rules/flake8_errmsg/settings.rs similarity index 100% rename from crates/ruff/src/rules/flake8_errmsg/settings.rs rename to crates/ruff_linter/src/rules/flake8_errmsg/settings.rs 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 new file mode 100644 index 0000000000..d972240482 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__custom.snap @@ -0,0 +1,180 @@ +--- +source: crates/ruff_linter/src/rules/flake8_errmsg/mod.rs +--- +EM.py:5:24: EM101 [*] Exception must not use a string literal, assign to variable first + | +4 | def f_a(): +5 | raise RuntimeError("This is an example exception") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | + = help: Assign to variable; remove string literal + +ℹ Suggested fix +2 2 | +3 3 | +4 4 | def f_a(): +5 |- raise RuntimeError("This is an example exception") + 5 |+ msg = "This is an example exception" + 6 |+ raise RuntimeError(msg) +6 7 | +7 8 | +8 9 | def f_a_short(): + +EM.py:18:24: EM102 [*] Exception must not use an f-string literal, assign to variable first + | +16 | def f_b(): +17 | example = "example" +18 | raise RuntimeError(f"This is an {example} exception") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM102 + | + = help: Assign to variable; remove f-string literal + +ℹ Suggested fix +15 15 | +16 16 | def f_b(): +17 17 | example = "example" +18 |- raise RuntimeError(f"This is an {example} exception") + 18 |+ msg = f"This is an {example} exception" + 19 |+ raise RuntimeError(msg) +19 20 | +20 21 | +21 22 | def f_c(): + +EM.py:22:24: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first + | +21 | def f_c(): +22 | raise RuntimeError("This is an {example} exception".format(example="example")) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM103 + | + = help: Assign to variable; remove `.format()` string + +ℹ Suggested fix +19 19 | +20 20 | +21 21 | def f_c(): +22 |- raise RuntimeError("This is an {example} exception".format(example="example")) + 22 |+ msg = "This is an {example} exception".format(example="example") + 23 |+ raise RuntimeError(msg) +23 24 | +24 25 | +25 26 | def f_ok(): + +EM.py:32:24: EM101 Exception must not use a string literal, assign to variable first + | +30 | def f_unfixable(): +31 | msg = "hello" +32 | raise RuntimeError("This is an example exception") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | + = help: Assign to variable; remove string literal + +EM.py:39:24: EM101 [*] Exception must not use a string literal, assign to variable first + | +37 | msg = "hello" +38 | +39 | raise RuntimeError("This is an example exception") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | + = help: Assign to variable; remove string literal + +ℹ Suggested fix +36 36 | def nested(): +37 37 | msg = "hello" +38 38 | +39 |- raise RuntimeError("This is an example exception") + 39 |+ msg = "This is an example exception" + 40 |+ raise RuntimeError(msg) +40 41 | +41 42 | +42 43 | def f_msg_in_parent_scope(): + +EM.py:46:28: EM101 Exception must not use a string literal, assign to variable first + | +45 | def nested(): +46 | raise RuntimeError("This is an example exception") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | + = help: Assign to variable; remove string literal + +EM.py:51:28: EM101 [*] Exception must not use a string literal, assign to variable first + | +49 | def f_fix_indentation_check(foo): +50 | if foo: +51 | raise RuntimeError("This is an example exception") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 +52 | else: +53 | if foo == "foo": + | + = help: Assign to variable; remove string literal + +ℹ Suggested fix +48 48 | +49 49 | def f_fix_indentation_check(foo): +50 50 | if foo: +51 |- raise RuntimeError("This is an example exception") + 51 |+ msg = "This is an example exception" + 52 |+ raise RuntimeError(msg) +52 53 | else: +53 54 | if foo == "foo": +54 55 | raise RuntimeError(f"This is an exception: {foo}") + +EM.py:54:32: EM102 [*] Exception must not use an f-string literal, assign to variable first + | +52 | else: +53 | if foo == "foo": +54 | raise RuntimeError(f"This is an exception: {foo}") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM102 +55 | raise RuntimeError("This is an exception: {}".format(foo)) + | + = help: Assign to variable; remove f-string literal + +ℹ Suggested fix +51 51 | raise RuntimeError("This is an example exception") +52 52 | else: +53 53 | if foo == "foo": +54 |- raise RuntimeError(f"This is an exception: {foo}") + 54 |+ msg = f"This is an exception: {foo}" + 55 |+ raise RuntimeError(msg) +55 56 | raise RuntimeError("This is an exception: {}".format(foo)) +56 57 | +57 58 | + +EM.py:55:24: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first + | +53 | if foo == "foo": +54 | raise RuntimeError(f"This is an exception: {foo}") +55 | raise RuntimeError("This is an exception: {}".format(foo)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM103 + | + = help: Assign to variable; remove `.format()` string + +ℹ Suggested fix +52 52 | else: +53 53 | if foo == "foo": +54 54 | raise RuntimeError(f"This is an exception: {foo}") +55 |- raise RuntimeError("This is an exception: {}".format(foo)) + 55 |+ msg = "This is an exception: {}".format(foo) + 56 |+ raise RuntimeError(msg) +56 57 | +57 58 | +58 59 | # Report these, but don't fix them + +EM.py:59:28: EM101 Exception must not use a string literal, assign to variable first + | +58 | # Report these, but don't fix them +59 | if foo: raise RuntimeError("This is an example exception") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 +60 | if foo: x = 1; raise RuntimeError("This is an example exception") + | + = help: Assign to variable; remove string literal + +EM.py:60:35: EM101 Exception must not use a string literal, assign to variable first + | +58 | # Report these, but don't fix them +59 | if foo: raise RuntimeError("This is an example exception") +60 | if foo: x = 1; raise RuntimeError("This is an example exception") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | + = help: Assign to variable; remove string literal + + 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 new file mode 100644 index 0000000000..03784c23fc --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__defaults.snap @@ -0,0 +1,218 @@ +--- +source: crates/ruff_linter/src/rules/flake8_errmsg/mod.rs +--- +EM.py:5:24: EM101 [*] Exception must not use a string literal, assign to variable first + | +4 | def f_a(): +5 | raise RuntimeError("This is an example exception") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | + = help: Assign to variable; remove string literal + +ℹ Suggested fix +2 2 | +3 3 | +4 4 | def f_a(): +5 |- raise RuntimeError("This is an example exception") + 5 |+ msg = "This is an example exception" + 6 |+ raise RuntimeError(msg) +6 7 | +7 8 | +8 9 | def f_a_short(): + +EM.py:9:24: EM101 [*] Exception must not use a string literal, assign to variable first + | +8 | def f_a_short(): +9 | raise RuntimeError("Error") + | ^^^^^^^ EM101 + | + = help: Assign to variable; remove string literal + +ℹ Suggested fix +6 6 | +7 7 | +8 8 | def f_a_short(): +9 |- raise RuntimeError("Error") + 9 |+ msg = "Error" + 10 |+ raise RuntimeError(msg) +10 11 | +11 12 | +12 13 | def f_a_empty(): + +EM.py:13:24: EM101 [*] Exception must not use a string literal, assign to variable first + | +12 | def f_a_empty(): +13 | raise RuntimeError("") + | ^^ EM101 + | + = help: Assign to variable; remove string literal + +ℹ Suggested fix +10 10 | +11 11 | +12 12 | def f_a_empty(): +13 |- raise RuntimeError("") + 13 |+ msg = "" + 14 |+ raise RuntimeError(msg) +14 15 | +15 16 | +16 17 | def f_b(): + +EM.py:18:24: EM102 [*] Exception must not use an f-string literal, assign to variable first + | +16 | def f_b(): +17 | example = "example" +18 | raise RuntimeError(f"This is an {example} exception") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM102 + | + = help: Assign to variable; remove f-string literal + +ℹ Suggested fix +15 15 | +16 16 | def f_b(): +17 17 | example = "example" +18 |- raise RuntimeError(f"This is an {example} exception") + 18 |+ msg = f"This is an {example} exception" + 19 |+ raise RuntimeError(msg) +19 20 | +20 21 | +21 22 | def f_c(): + +EM.py:22:24: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first + | +21 | def f_c(): +22 | raise RuntimeError("This is an {example} exception".format(example="example")) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM103 + | + = help: Assign to variable; remove `.format()` string + +ℹ Suggested fix +19 19 | +20 20 | +21 21 | def f_c(): +22 |- raise RuntimeError("This is an {example} exception".format(example="example")) + 22 |+ msg = "This is an {example} exception".format(example="example") + 23 |+ raise RuntimeError(msg) +23 24 | +24 25 | +25 26 | def f_ok(): + +EM.py:32:24: EM101 Exception must not use a string literal, assign to variable first + | +30 | def f_unfixable(): +31 | msg = "hello" +32 | raise RuntimeError("This is an example exception") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | + = help: Assign to variable; remove string literal + +EM.py:39:24: EM101 [*] Exception must not use a string literal, assign to variable first + | +37 | msg = "hello" +38 | +39 | raise RuntimeError("This is an example exception") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | + = help: Assign to variable; remove string literal + +ℹ Suggested fix +36 36 | def nested(): +37 37 | msg = "hello" +38 38 | +39 |- raise RuntimeError("This is an example exception") + 39 |+ msg = "This is an example exception" + 40 |+ raise RuntimeError(msg) +40 41 | +41 42 | +42 43 | def f_msg_in_parent_scope(): + +EM.py:46:28: EM101 Exception must not use a string literal, assign to variable first + | +45 | def nested(): +46 | raise RuntimeError("This is an example exception") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | + = help: Assign to variable; remove string literal + +EM.py:51:28: EM101 [*] Exception must not use a string literal, assign to variable first + | +49 | def f_fix_indentation_check(foo): +50 | if foo: +51 | raise RuntimeError("This is an example exception") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 +52 | else: +53 | if foo == "foo": + | + = help: Assign to variable; remove string literal + +ℹ Suggested fix +48 48 | +49 49 | def f_fix_indentation_check(foo): +50 50 | if foo: +51 |- raise RuntimeError("This is an example exception") + 51 |+ msg = "This is an example exception" + 52 |+ raise RuntimeError(msg) +52 53 | else: +53 54 | if foo == "foo": +54 55 | raise RuntimeError(f"This is an exception: {foo}") + +EM.py:54:32: EM102 [*] Exception must not use an f-string literal, assign to variable first + | +52 | else: +53 | if foo == "foo": +54 | raise RuntimeError(f"This is an exception: {foo}") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM102 +55 | raise RuntimeError("This is an exception: {}".format(foo)) + | + = help: Assign to variable; remove f-string literal + +ℹ Suggested fix +51 51 | raise RuntimeError("This is an example exception") +52 52 | else: +53 53 | if foo == "foo": +54 |- raise RuntimeError(f"This is an exception: {foo}") + 54 |+ msg = f"This is an exception: {foo}" + 55 |+ raise RuntimeError(msg) +55 56 | raise RuntimeError("This is an exception: {}".format(foo)) +56 57 | +57 58 | + +EM.py:55:24: EM103 [*] Exception must not use a `.format()` string directly, assign to variable first + | +53 | if foo == "foo": +54 | raise RuntimeError(f"This is an exception: {foo}") +55 | raise RuntimeError("This is an exception: {}".format(foo)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM103 + | + = help: Assign to variable; remove `.format()` string + +ℹ Suggested fix +52 52 | else: +53 53 | if foo == "foo": +54 54 | raise RuntimeError(f"This is an exception: {foo}") +55 |- raise RuntimeError("This is an exception: {}".format(foo)) + 55 |+ msg = "This is an exception: {}".format(foo) + 56 |+ raise RuntimeError(msg) +56 57 | +57 58 | +58 59 | # Report these, but don't fix them + +EM.py:59:28: EM101 Exception must not use a string literal, assign to variable first + | +58 | # Report these, but don't fix them +59 | if foo: raise RuntimeError("This is an example exception") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 +60 | if foo: x = 1; raise RuntimeError("This is an example exception") + | + = help: Assign to variable; remove string literal + +EM.py:60:35: EM101 Exception must not use a string literal, assign to variable first + | +58 | # Report these, but don't fix them +59 | if foo: raise RuntimeError("This is an example exception") +60 | if foo: x = 1; raise RuntimeError("This is an example exception") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ EM101 + | + = help: Assign to variable; remove string literal + + diff --git a/crates/ruff/src/rules/flake8_executable/helpers.rs b/crates/ruff_linter/src/rules/flake8_executable/helpers.rs similarity index 100% rename from crates/ruff/src/rules/flake8_executable/helpers.rs rename to crates/ruff_linter/src/rules/flake8_executable/helpers.rs diff --git a/crates/ruff/src/rules/flake8_executable/mod.rs b/crates/ruff_linter/src/rules/flake8_executable/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_executable/mod.rs rename to crates/ruff_linter/src/rules/flake8_executable/mod.rs diff --git a/crates/ruff/src/rules/flake8_executable/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_executable/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_executable/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_executable/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_executable/rules/shebang_leading_whitespace.rs b/crates/ruff_linter/src/rules/flake8_executable/rules/shebang_leading_whitespace.rs similarity index 100% rename from crates/ruff/src/rules/flake8_executable/rules/shebang_leading_whitespace.rs rename to crates/ruff_linter/src/rules/flake8_executable/rules/shebang_leading_whitespace.rs diff --git a/crates/ruff/src/rules/flake8_executable/rules/shebang_missing_executable_file.rs b/crates/ruff_linter/src/rules/flake8_executable/rules/shebang_missing_executable_file.rs similarity index 100% rename from crates/ruff/src/rules/flake8_executable/rules/shebang_missing_executable_file.rs rename to crates/ruff_linter/src/rules/flake8_executable/rules/shebang_missing_executable_file.rs diff --git a/crates/ruff/src/rules/flake8_executable/rules/shebang_missing_python.rs b/crates/ruff_linter/src/rules/flake8_executable/rules/shebang_missing_python.rs similarity index 100% rename from crates/ruff/src/rules/flake8_executable/rules/shebang_missing_python.rs rename to crates/ruff_linter/src/rules/flake8_executable/rules/shebang_missing_python.rs diff --git a/crates/ruff/src/rules/flake8_executable/rules/shebang_not_executable.rs b/crates/ruff_linter/src/rules/flake8_executable/rules/shebang_not_executable.rs similarity index 100% rename from crates/ruff/src/rules/flake8_executable/rules/shebang_not_executable.rs rename to crates/ruff_linter/src/rules/flake8_executable/rules/shebang_not_executable.rs diff --git a/crates/ruff/src/rules/flake8_executable/rules/shebang_not_first_line.rs b/crates/ruff_linter/src/rules/flake8_executable/rules/shebang_not_first_line.rs similarity index 100% rename from crates/ruff/src/rules/flake8_executable/rules/shebang_not_first_line.rs rename to crates/ruff_linter/src/rules/flake8_executable/rules/shebang_not_first_line.rs 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 new file mode 100644 index 0000000000..0a58f7dfcc --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE001_1.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_executable/mod.rs +--- +EXE001_1.py:1:1: EXE001 Shebang is present but file is not executable + | +1 | #!/usr/bin/python + | ^^^^^^^^^^^^^^^^^ EXE001 +2 | +3 | if __name__ == '__main__': + | + + diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE001_2.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE001_2.py.snap new file mode 100644 index 0000000000..26e075ae3e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE001_2.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_executable/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE001_3.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE001_3.py.snap new file mode 100644 index 0000000000..26e075ae3e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE001_3.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_executable/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE002_1.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE002_1.py.snap new file mode 100644 index 0000000000..8f47999522 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE002_1.py.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/flake8_executable/mod.rs +--- +EXE002_1.py:1:1: EXE002 The file is executable but no shebang is present + | +1 | if __name__ == '__main__': + | EXE002 +2 | print('I should be executable.') + | + + diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE002_2.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE002_2.py.snap new file mode 100644 index 0000000000..26e075ae3e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE002_2.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_executable/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE002_3.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE002_3.py.snap new file mode 100644 index 0000000000..26e075ae3e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE002_3.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_executable/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE003.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE003.py.snap new file mode 100644 index 0000000000..eb03aeab9e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE003.py.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/flake8_executable/mod.rs +--- +EXE003.py:1:1: EXE003 Shebang should contain `python` + | +1 | #!/usr/bin/bash + | ^^^^^^^^^^^^^^^ EXE003 +2 | print("hello world") + | + + diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_1.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_1.py.snap new file mode 100644 index 0000000000..feff5295d0 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_1.py.snap @@ -0,0 +1,15 @@ +--- +source: crates/ruff_linter/src/rules/flake8_executable/mod.rs +--- +EXE004_1.py:1:1: EXE004 [*] Avoid whitespace before shebang + | +1 | #!/usr/bin/python + | ^^^^ EXE004 + | + = help: Remove whitespace before shebang + +ℹ Fix +1 |- #!/usr/bin/python + 1 |+#!/usr/bin/python + + diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_2.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_2.py.snap new file mode 100644 index 0000000000..26e075ae3e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_2.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_executable/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_3.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_3.py.snap new file mode 100644 index 0000000000..0a919de422 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_3.py.snap @@ -0,0 +1,10 @@ +--- +source: crates/ruff_linter/src/rules/flake8_executable/mod.rs +--- +EXE004_3.py:2:7: EXE005 Shebang should be at the beginning of the file + | +2 | pass #!/usr/bin/env python + | ^^^^^^^^^^^^^^^^^^^^^ EXE005 + | + + 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 new file mode 100644 index 0000000000..97fc901b81 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE004_4.py.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_linter/src/rules/flake8_executable/mod.rs +--- +EXE004_4.py:1:1: EXE004 [*] Avoid whitespace before shebang + | +1 | / +2 | | #!/usr/bin/env python + | |____^ EXE004 + | + = help: Remove whitespace before shebang + +ℹ Fix +1 |- +2 |- #!/usr/bin/env python + 1 |+#!/usr/bin/env python + + diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_1.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_1.py.snap new file mode 100644 index 0000000000..d19aa7a32f --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_1.py.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/flake8_executable/mod.rs +--- +EXE005_1.py:3:1: EXE005 Shebang should be at the beginning of the file + | +2 | # A python comment +3 | #!/usr/bin/python + | ^^^^^^^^^^^^^^^^^ EXE005 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_2.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_2.py.snap new file mode 100644 index 0000000000..fb99a0db01 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_2.py.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/flake8_executable/mod.rs +--- +EXE005_2.py:4:1: EXE005 Shebang should be at the beginning of the file + | +3 | # A python comment +4 | #!/usr/bin/python + | ^^^^^^^^^^^^^^^^^ EXE005 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_3.py.snap b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_3.py.snap new file mode 100644 index 0000000000..9e0e16200c --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_executable/snapshots/ruff_linter__rules__flake8_executable__tests__EXE005_3.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_executable/mod.rs +--- +EXE005_3.py:6:1: EXE005 Shebang should be at the beginning of the file + | +4 | """ +5 | # A python comment +6 | #!/usr/bin/python + | ^^^^^^^^^^^^^^^^^ EXE005 + | + + diff --git a/crates/ruff/src/rules/flake8_fixme/mod.rs b/crates/ruff_linter/src/rules/flake8_fixme/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_fixme/mod.rs rename to crates/ruff_linter/src/rules/flake8_fixme/mod.rs diff --git a/crates/ruff/src/rules/flake8_fixme/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_fixme/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_fixme/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_fixme/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_fixme/rules/todos.rs b/crates/ruff_linter/src/rules/flake8_fixme/rules/todos.rs similarity index 100% rename from crates/ruff/src/rules/flake8_fixme/rules/todos.rs rename to crates/ruff_linter/src/rules/flake8_fixme/rules/todos.rs 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 new file mode 100644 index 0000000000..c704c93411 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-fixme_T00.py.snap @@ -0,0 +1,21 @@ +--- +source: crates/ruff_linter/src/rules/flake8_fixme/mod.rs +--- +T00.py:7:3: FIX001 Line contains FIXME, consider resolving the issue + | +5 | # HACK: hack +6 | # hack: hack +7 | # FIXME: fixme + | ^^^^^ FIX001 +8 | # fixme: fixme + | + +T00.py:8:3: FIX001 Line contains FIXME, consider resolving the issue + | +6 | # hack: hack +7 | # FIXME: fixme +8 | # fixme: fixme + | ^^^^^ FIX001 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-hack_T00.py.snap b/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-hack_T00.py.snap new file mode 100644 index 0000000000..48be15b4fd --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-hack_T00.py.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/flake8_fixme/mod.rs +--- +T00.py:5:3: FIX004 Line contains HACK, consider resolving the issue + | +3 | # XXX: xxx +4 | # xxx: xxx +5 | # HACK: hack + | ^^^^ FIX004 +6 | # hack: hack +7 | # FIXME: fixme + | + +T00.py:6:3: FIX004 Line contains HACK, consider resolving the issue + | +4 | # xxx: xxx +5 | # HACK: hack +6 | # hack: hack + | ^^^^ FIX004 +7 | # FIXME: fixme +8 | # fixme: fixme + | + + 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 new file mode 100644 index 0000000000..4917963f2a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-todo_T00.py.snap @@ -0,0 +1,21 @@ +--- +source: crates/ruff_linter/src/rules/flake8_fixme/mod.rs +--- +T00.py:1:3: FIX002 Line contains TODO, consider resolving the issue + | +1 | # TODO: todo + | ^^^^ FIX002 +2 | # todo: todo +3 | # XXX: xxx + | + +T00.py:2:3: FIX002 Line contains TODO, consider resolving the issue + | +1 | # TODO: todo +2 | # todo: todo + | ^^^^ FIX002 +3 | # XXX: xxx +4 | # xxx: xxx + | + + diff --git a/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-xxx_T00.py.snap b/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-xxx_T00.py.snap new file mode 100644 index 0000000000..18eb43a49c --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_fixme/snapshots/ruff_linter__rules__flake8_fixme__tests__line-contains-xxx_T00.py.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/flake8_fixme/mod.rs +--- +T00.py:3:3: FIX003 Line contains XXX, consider resolving the issue + | +1 | # TODO: todo +2 | # todo: todo +3 | # XXX: xxx + | ^^^ FIX003 +4 | # xxx: xxx +5 | # HACK: hack + | + +T00.py:4:3: FIX003 Line contains XXX, consider resolving the issue + | +2 | # todo: todo +3 | # XXX: xxx +4 | # xxx: xxx + | ^^^ FIX003 +5 | # HACK: hack +6 | # hack: hack + | + + diff --git a/crates/ruff/src/rules/flake8_future_annotations/mod.rs b/crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_future_annotations/mod.rs rename to crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs diff --git a/crates/ruff/src/rules/flake8_future_annotations/rules/future_required_type_annotation.rs b/crates/ruff_linter/src/rules/flake8_future_annotations/rules/future_required_type_annotation.rs similarity index 100% rename from crates/ruff/src/rules/flake8_future_annotations/rules/future_required_type_annotation.rs rename to crates/ruff_linter/src/rules/flake8_future_annotations/rules/future_required_type_annotation.rs diff --git a/crates/ruff/src/rules/flake8_future_annotations/rules/future_rewritable_type_annotation.rs b/crates/ruff_linter/src/rules/flake8_future_annotations/rules/future_rewritable_type_annotation.rs similarity index 100% rename from crates/ruff/src/rules/flake8_future_annotations/rules/future_rewritable_type_annotation.rs rename to crates/ruff_linter/src/rules/flake8_future_annotations/rules/future_rewritable_type_annotation.rs diff --git a/crates/ruff/src/rules/flake8_future_annotations/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_future_annotations/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_future_annotations/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_future_annotations/rules/mod.rs diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__edge_case.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__edge_case.py.snap new file mode 100644 index 0000000000..bdba068b16 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__edge_case.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs +--- +edge_case.py:5:13: FA100 Missing `from __future__ import annotations`, but uses `typing.List` + | +5 | def main(_: List[int]) -> None: + | ^^^^ FA100 +6 | a_list: t.List[str] = [] +7 | a_list.append("hello") + | + +edge_case.py:6:13: FA100 Missing `from __future__ import annotations`, but uses `typing.List` + | +5 | def main(_: List[int]) -> None: +6 | a_list: t.List[str] = [] + | ^^^^^^ FA100 +7 | a_list.append("hello") + | + + diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_lowercase.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_lowercase.py.snap new file mode 100644 index 0000000000..c90769eccd --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_lowercase.py.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs +--- +no_future_import_uses_lowercase.py:2:13: FA102 Missing `from __future__ import annotations`, but uses PEP 585 collection + | +1 | def main() -> None: +2 | a_list: list[str] = [] + | ^^^^^^^^^ FA102 +3 | a_list.append("hello") + | + +no_future_import_uses_lowercase.py:6:14: FA102 Missing `from __future__ import annotations`, but uses PEP 585 collection + | +6 | def hello(y: dict[str, int]) -> None: + | ^^^^^^^^^^^^^^ FA102 +7 | del y + | + + diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union.py.snap new file mode 100644 index 0000000000..2e946cd581 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union.py.snap @@ -0,0 +1,34 @@ +--- +source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs +--- +no_future_import_uses_union.py:2:13: FA102 Missing `from __future__ import annotations`, but uses PEP 585 collection + | +1 | def main() -> None: +2 | a_list: list[str] | None = [] + | ^^^^^^^^^ FA102 +3 | a_list.append("hello") + | + +no_future_import_uses_union.py:2:13: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union + | +1 | def main() -> None: +2 | a_list: list[str] | None = [] + | ^^^^^^^^^^^^^^^^ FA102 +3 | a_list.append("hello") + | + +no_future_import_uses_union.py:6:14: FA102 Missing `from __future__ import annotations`, but uses PEP 585 collection + | +6 | def hello(y: dict[str, int] | None) -> None: + | ^^^^^^^^^^^^^^ FA102 +7 | del y + | + +no_future_import_uses_union.py:6:14: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union + | +6 | def hello(y: dict[str, int] | None) -> None: + | ^^^^^^^^^^^^^^^^^^^^^ FA102 +7 | del y + | + + diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union_inner.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union_inner.py.snap new file mode 100644 index 0000000000..1d4c55dd62 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_no_future_import_uses_union_inner.py.snap @@ -0,0 +1,52 @@ +--- +source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs +--- +no_future_import_uses_union_inner.py:2:13: FA102 Missing `from __future__ import annotations`, but uses PEP 585 collection + | +1 | def main() -> None: +2 | a_list: list[str | None] = [] + | ^^^^^^^^^^^^^^^^ FA102 +3 | a_list.append("hello") + | + +no_future_import_uses_union_inner.py:2:18: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union + | +1 | def main() -> None: +2 | a_list: list[str | None] = [] + | ^^^^^^^^^^ FA102 +3 | a_list.append("hello") + | + +no_future_import_uses_union_inner.py:6:14: FA102 Missing `from __future__ import annotations`, but uses PEP 585 collection + | +6 | def hello(y: dict[str | None, int]) -> None: + | ^^^^^^^^^^^^^^^^^^^^^ FA102 +7 | z: tuple[str, str | None, str] = tuple(y) +8 | del z + | + +no_future_import_uses_union_inner.py:6:19: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union + | +6 | def hello(y: dict[str | None, int]) -> None: + | ^^^^^^^^^^ FA102 +7 | z: tuple[str, str | None, str] = tuple(y) +8 | del z + | + +no_future_import_uses_union_inner.py:7:8: FA102 Missing `from __future__ import annotations`, but uses PEP 585 collection + | +6 | def hello(y: dict[str | None, int]) -> None: +7 | z: tuple[str, str | None, str] = tuple(y) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ FA102 +8 | del z + | + +no_future_import_uses_union_inner.py:7:19: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union + | +6 | def hello(y: dict[str | None, int]) -> None: +7 | z: tuple[str, str | None, str] = tuple(y) + | ^^^^^^^^^^ FA102 +8 | del z + | + + diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_ok_no_types.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_ok_no_types.py.snap new file mode 100644 index 0000000000..0e51cf4a6f --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_ok_no_types.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_ok_uses_future.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_ok_uses_future.py.snap new file mode 100644 index 0000000000..0e51cf4a6f --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__fa102_ok_uses_future.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__from_typing_import.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__from_typing_import.py.snap new file mode 100644 index 0000000000..042876422b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__from_typing_import.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs +--- +from_typing_import.py:5:13: FA100 Missing `from __future__ import annotations`, but uses `typing.List` + | +4 | def main() -> None: +5 | a_list: List[str] = [] + | ^^^^ FA100 +6 | a_list.append("hello") + | + + diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__from_typing_import_many.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__from_typing_import_many.py.snap new file mode 100644 index 0000000000..e24e25744a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__from_typing_import_many.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs +--- +from_typing_import_many.py:5:13: FA100 Missing `from __future__ import annotations`, but uses `typing.List` + | +4 | def main() -> None: +5 | a_list: List[Optional[str]] = [] + | ^^^^ FA100 +6 | a_list.append("hello") +7 | a_dict = cast(Dict[int | None, Union[int, Set[bool]]], {}) + | + +from_typing_import_many.py:5:18: FA100 Missing `from __future__ import annotations`, but uses `typing.Optional` + | +4 | def main() -> None: +5 | a_list: List[Optional[str]] = [] + | ^^^^^^^^ FA100 +6 | a_list.append("hello") +7 | a_dict = cast(Dict[int | None, Union[int, Set[bool]]], {}) + | + + diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__import_typing.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__import_typing.py.snap new file mode 100644 index 0000000000..fa23852dc4 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__import_typing.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs +--- +import_typing.py:5:13: FA100 Missing `from __future__ import annotations`, but uses `typing.List` + | +4 | def main() -> None: +5 | a_list: typing.List[str] = [] + | ^^^^^^^^^^^ FA100 +6 | a_list.append("hello") + | + + diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__import_typing_as.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__import_typing_as.py.snap new file mode 100644 index 0000000000..58f10568d7 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__import_typing_as.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs +--- +import_typing_as.py:5:13: FA100 Missing `from __future__ import annotations`, but uses `typing.List` + | +4 | def main() -> None: +5 | a_list: t.List[str] = [] + | ^^^^^^ FA100 +6 | a_list.append("hello") + | + + diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__no_future_import_uses_lowercase.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__no_future_import_uses_lowercase.py.snap new file mode 100644 index 0000000000..0e51cf4a6f --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__no_future_import_uses_lowercase.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__no_future_import_uses_union.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__no_future_import_uses_union.py.snap new file mode 100644 index 0000000000..0e51cf4a6f --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__no_future_import_uses_union.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__no_future_import_uses_union_inner.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__no_future_import_uses_union_inner.py.snap new file mode 100644 index 0000000000..0e51cf4a6f --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__no_future_import_uses_union_inner.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__ok_no_types.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__ok_no_types.py.snap new file mode 100644 index 0000000000..0e51cf4a6f --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__ok_no_types.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__ok_non_simplifiable_types.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__ok_non_simplifiable_types.py.snap new file mode 100644 index 0000000000..0e51cf4a6f --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__ok_non_simplifiable_types.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__ok_uses_future.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__ok_uses_future.py.snap new file mode 100644 index 0000000000..0e51cf4a6f --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__ok_uses_future.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__ok_variable_name.py.snap b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__ok_variable_name.py.snap new file mode 100644 index 0000000000..0e51cf4a6f --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_future_annotations/snapshots/ruff_linter__rules__flake8_future_annotations__tests__ok_variable_name.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_future_annotations/mod.rs +--- + diff --git a/crates/ruff/src/rules/flake8_gettext/mod.rs b/crates/ruff_linter/src/rules/flake8_gettext/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_gettext/mod.rs rename to crates/ruff_linter/src/rules/flake8_gettext/mod.rs diff --git a/crates/ruff/src/rules/flake8_gettext/rules/f_string_in_gettext_func_call.rs b/crates/ruff_linter/src/rules/flake8_gettext/rules/f_string_in_gettext_func_call.rs similarity index 100% rename from crates/ruff/src/rules/flake8_gettext/rules/f_string_in_gettext_func_call.rs rename to crates/ruff_linter/src/rules/flake8_gettext/rules/f_string_in_gettext_func_call.rs diff --git a/crates/ruff/src/rules/flake8_gettext/rules/format_in_gettext_func_call.rs b/crates/ruff_linter/src/rules/flake8_gettext/rules/format_in_gettext_func_call.rs similarity index 100% rename from crates/ruff/src/rules/flake8_gettext/rules/format_in_gettext_func_call.rs rename to crates/ruff_linter/src/rules/flake8_gettext/rules/format_in_gettext_func_call.rs diff --git a/crates/ruff/src/rules/flake8_gettext/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_gettext/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_gettext/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_gettext/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_gettext/rules/printf_in_gettext_func_call.rs b/crates/ruff_linter/src/rules/flake8_gettext/rules/printf_in_gettext_func_call.rs similarity index 100% rename from crates/ruff/src/rules/flake8_gettext/rules/printf_in_gettext_func_call.rs rename to crates/ruff_linter/src/rules/flake8_gettext/rules/printf_in_gettext_func_call.rs diff --git a/crates/ruff/src/rules/flake8_gettext/settings.rs b/crates/ruff_linter/src/rules/flake8_gettext/settings.rs similarity index 100% rename from crates/ruff/src/rules/flake8_gettext/settings.rs rename to crates/ruff_linter/src/rules/flake8_gettext/settings.rs diff --git a/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__f-string-in-get-text-func-call_INT001.py.snap b/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__f-string-in-get-text-func-call_INT001.py.snap new file mode 100644 index 0000000000..6c37750fc8 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__f-string-in-get-text-func-call_INT001.py.snap @@ -0,0 +1,10 @@ +--- +source: crates/ruff_linter/src/rules/flake8_gettext/mod.rs +--- +INT001.py:1:3: INT001 f-string is resolved before function call; consider `_("string %s") % arg` + | +1 | _(f"{'value'}") + | ^^^^^^^^^^^^ INT001 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__format-in-get-text-func-call_INT002.py.snap b/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__format-in-get-text-func-call_INT002.py.snap new file mode 100644 index 0000000000..6f37b92e29 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__format-in-get-text-func-call_INT002.py.snap @@ -0,0 +1,10 @@ +--- +source: crates/ruff_linter/src/rules/flake8_gettext/mod.rs +--- +INT002.py:1:3: INT002 `format` method argument is resolved before function call; consider `_("string %s") % arg` + | +1 | _("{}".format("line")) + | ^^^^^^^^^^^^^^^^^^^ INT002 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__printf-in-get-text-func-call_INT003.py.snap b/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__printf-in-get-text-func-call_INT003.py.snap new file mode 100644 index 0000000000..789401f897 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_gettext/snapshots/ruff_linter__rules__flake8_gettext__tests__printf-in-get-text-func-call_INT003.py.snap @@ -0,0 +1,10 @@ +--- +source: crates/ruff_linter/src/rules/flake8_gettext/mod.rs +--- +INT003.py:1:3: INT003 printf-style format is resolved before function call; consider `_("string %s") % arg` + | +1 | _("%s" % "line") + | ^^^^^^^^^^^^^ INT003 + | + + diff --git a/crates/ruff/src/rules/flake8_implicit_str_concat/mod.rs b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_implicit_str_concat/mod.rs rename to crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs diff --git a/crates/ruff/src/rules/flake8_implicit_str_concat/rules/explicit.rs b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/rules/explicit.rs similarity index 100% rename from crates/ruff/src/rules/flake8_implicit_str_concat/rules/explicit.rs rename to crates/ruff_linter/src/rules/flake8_implicit_str_concat/rules/explicit.rs diff --git a/crates/ruff/src/rules/flake8_implicit_str_concat/rules/implicit.rs b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/rules/implicit.rs similarity index 100% rename from crates/ruff/src/rules/flake8_implicit_str_concat/rules/implicit.rs rename to crates/ruff_linter/src/rules/flake8_implicit_str_concat/rules/implicit.rs diff --git a/crates/ruff/src/rules/flake8_implicit_str_concat/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_implicit_str_concat/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_implicit_str_concat/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_implicit_str_concat/settings.rs b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/settings.rs similarity index 100% rename from crates/ruff/src/rules/flake8_implicit_str_concat/settings.rs rename to crates/ruff_linter/src/rules/flake8_implicit_str_concat/settings.rs 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 new file mode 100644 index 0000000000..f939661b4a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC001_ISC.py.snap @@ -0,0 +1,156 @@ +--- +source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs +--- +ISC.py:1:5: ISC001 [*] Implicitly concatenated string literals on one line + | +1 | _ = "a" "b" "c" + | ^^^^^^^ ISC001 +2 | +3 | _ = "abc" + "def" + | + = help: Combine string literals + +ℹ Fix +1 |-_ = "a" "b" "c" + 1 |+_ = "ab" "c" +2 2 | +3 3 | _ = "abc" + "def" +4 4 | + +ISC.py:1:9: ISC001 [*] Implicitly concatenated string literals on one line + | +1 | _ = "a" "b" "c" + | ^^^^^^^ ISC001 +2 | +3 | _ = "abc" + "def" + | + = help: Combine string literals + +ℹ Fix +1 |-_ = "a" "b" "c" + 1 |+_ = "a" "bc" +2 2 | +3 3 | _ = "abc" + "def" +4 4 | + +ISC.py:38:5: ISC001 [*] Implicitly concatenated string literals on one line + | +36 | ) +37 | +38 | _ = """a""" """b""" + | ^^^^^^^^^^^^^^^ ISC001 +39 | +40 | _ = """a + | + = help: Combine string literals + +ℹ Fix +35 35 | b"def" +36 36 | ) +37 37 | +38 |-_ = """a""" """b""" + 38 |+_ = """ab""" +39 39 | +40 40 | _ = """a +41 41 | b""" """c + +ISC.py:40:5: ISC001 [*] Implicitly concatenated string literals on one line + | +38 | _ = """a""" """b""" +39 | +40 | _ = """a + | _____^ +41 | | b""" """c +42 | | d""" + | |____^ ISC001 +43 | +44 | _ = f"""a""" f"""b""" + | + = help: Combine string literals + +ℹ Fix +38 38 | _ = """a""" """b""" +39 39 | +40 40 | _ = """a +41 |-b""" """c + 41 |+bc +42 42 | d""" +43 43 | +44 44 | _ = f"""a""" f"""b""" + +ISC.py:44:5: ISC001 [*] Implicitly concatenated string literals on one line + | +42 | d""" +43 | +44 | _ = f"""a""" f"""b""" + | ^^^^^^^^^^^^^^^^^ ISC001 +45 | +46 | _ = f"a" "b" + | + = help: Combine string literals + +ℹ Fix +41 41 | b""" """c +42 42 | d""" +43 43 | +44 |-_ = f"""a""" f"""b""" + 44 |+_ = f"""ab""" +45 45 | +46 46 | _ = f"a" "b" +47 47 | + +ISC.py:46:5: ISC001 Implicitly concatenated string literals on one line + | +44 | _ = f"""a""" f"""b""" +45 | +46 | _ = f"a" "b" + | ^^^^^^^^ ISC001 +47 | +48 | _ = """a""" "b" + | + = help: Combine string literals + +ISC.py:48:5: ISC001 Implicitly concatenated string literals on one line + | +46 | _ = f"a" "b" +47 | +48 | _ = """a""" "b" + | ^^^^^^^^^^^ ISC001 +49 | +50 | _ = 'a' "b" + | + = help: Combine string literals + +ISC.py:50:5: ISC001 Implicitly concatenated string literals on one line + | +48 | _ = """a""" "b" +49 | +50 | _ = 'a' "b" + | ^^^^^^^ ISC001 +51 | +52 | _ = rf"a" rf"b" + | + = help: Combine string literals + +ISC.py:52:5: ISC001 [*] Implicitly concatenated string literals on one line + | +50 | _ = 'a' "b" +51 | +52 | _ = rf"a" rf"b" + | ^^^^^^^^^^^ ISC001 +53 | +54 | # Single-line explicit concatenation should be ignored. + | + = help: Combine string literals + +ℹ Fix +49 49 | +50 50 | _ = 'a' "b" +51 51 | +52 |-_ = rf"a" rf"b" + 52 |+_ = rf"ab" +53 53 | +54 54 | # Single-line explicit concatenation should be ignored. +55 55 | _ = "abc" + "def" + "ghi" + + 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 new file mode 100644 index 0000000000..93a64327e2 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC002_ISC.py.snap @@ -0,0 +1,16 @@ +--- +source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs +--- +ISC.py:5:5: ISC002 Implicitly concatenated string literals over multiple lines + | +3 | _ = "abc" + "def" +4 | +5 | _ = "abc" \ + | _____^ +6 | | "def" + | |_________^ ISC002 +7 | +8 | _ = ( + | + + 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 new file mode 100644 index 0000000000..5c993ef97f --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__ISC003_ISC.py.snap @@ -0,0 +1,34 @@ +--- +source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs +--- +ISC.py:9:3: ISC003 Explicitly concatenated string should be implicitly concatenated + | + 8 | _ = ( + 9 | "abc" + + | ___^ +10 | | "def" + | |_______^ ISC003 +11 | ) + | + +ISC.py:14:3: ISC003 Explicitly concatenated string should be implicitly concatenated + | +13 | _ = ( +14 | f"abc" + + | ___^ +15 | | "def" + | |_______^ ISC003 +16 | ) + | + +ISC.py:19:3: ISC003 Explicitly concatenated string should be implicitly concatenated + | +18 | _ = ( +19 | b"abc" + + | ___^ +20 | | b"def" + | |________^ ISC003 +21 | ) + | + + 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 new file mode 100644 index 0000000000..f939661b4a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC001_ISC.py.snap @@ -0,0 +1,156 @@ +--- +source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs +--- +ISC.py:1:5: ISC001 [*] Implicitly concatenated string literals on one line + | +1 | _ = "a" "b" "c" + | ^^^^^^^ ISC001 +2 | +3 | _ = "abc" + "def" + | + = help: Combine string literals + +ℹ Fix +1 |-_ = "a" "b" "c" + 1 |+_ = "ab" "c" +2 2 | +3 3 | _ = "abc" + "def" +4 4 | + +ISC.py:1:9: ISC001 [*] Implicitly concatenated string literals on one line + | +1 | _ = "a" "b" "c" + | ^^^^^^^ ISC001 +2 | +3 | _ = "abc" + "def" + | + = help: Combine string literals + +ℹ Fix +1 |-_ = "a" "b" "c" + 1 |+_ = "a" "bc" +2 2 | +3 3 | _ = "abc" + "def" +4 4 | + +ISC.py:38:5: ISC001 [*] Implicitly concatenated string literals on one line + | +36 | ) +37 | +38 | _ = """a""" """b""" + | ^^^^^^^^^^^^^^^ ISC001 +39 | +40 | _ = """a + | + = help: Combine string literals + +ℹ Fix +35 35 | b"def" +36 36 | ) +37 37 | +38 |-_ = """a""" """b""" + 38 |+_ = """ab""" +39 39 | +40 40 | _ = """a +41 41 | b""" """c + +ISC.py:40:5: ISC001 [*] Implicitly concatenated string literals on one line + | +38 | _ = """a""" """b""" +39 | +40 | _ = """a + | _____^ +41 | | b""" """c +42 | | d""" + | |____^ ISC001 +43 | +44 | _ = f"""a""" f"""b""" + | + = help: Combine string literals + +ℹ Fix +38 38 | _ = """a""" """b""" +39 39 | +40 40 | _ = """a +41 |-b""" """c + 41 |+bc +42 42 | d""" +43 43 | +44 44 | _ = f"""a""" f"""b""" + +ISC.py:44:5: ISC001 [*] Implicitly concatenated string literals on one line + | +42 | d""" +43 | +44 | _ = f"""a""" f"""b""" + | ^^^^^^^^^^^^^^^^^ ISC001 +45 | +46 | _ = f"a" "b" + | + = help: Combine string literals + +ℹ Fix +41 41 | b""" """c +42 42 | d""" +43 43 | +44 |-_ = f"""a""" f"""b""" + 44 |+_ = f"""ab""" +45 45 | +46 46 | _ = f"a" "b" +47 47 | + +ISC.py:46:5: ISC001 Implicitly concatenated string literals on one line + | +44 | _ = f"""a""" f"""b""" +45 | +46 | _ = f"a" "b" + | ^^^^^^^^ ISC001 +47 | +48 | _ = """a""" "b" + | + = help: Combine string literals + +ISC.py:48:5: ISC001 Implicitly concatenated string literals on one line + | +46 | _ = f"a" "b" +47 | +48 | _ = """a""" "b" + | ^^^^^^^^^^^ ISC001 +49 | +50 | _ = 'a' "b" + | + = help: Combine string literals + +ISC.py:50:5: ISC001 Implicitly concatenated string literals on one line + | +48 | _ = """a""" "b" +49 | +50 | _ = 'a' "b" + | ^^^^^^^ ISC001 +51 | +52 | _ = rf"a" rf"b" + | + = help: Combine string literals + +ISC.py:52:5: ISC001 [*] Implicitly concatenated string literals on one line + | +50 | _ = 'a' "b" +51 | +52 | _ = rf"a" rf"b" + | ^^^^^^^^^^^ ISC001 +53 | +54 | # Single-line explicit concatenation should be ignored. + | + = help: Combine string literals + +ℹ Fix +49 49 | +50 50 | _ = 'a' "b" +51 51 | +52 |-_ = rf"a" rf"b" + 52 |+_ = rf"ab" +53 53 | +54 54 | # Single-line explicit concatenation should be ignored. +55 55 | _ = "abc" + "def" + "ghi" + + 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 new file mode 100644 index 0000000000..64cb7e8acb --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC002_ISC.py.snap @@ -0,0 +1,46 @@ +--- +source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs +--- +ISC.py:5:5: ISC002 Implicitly concatenated string literals over multiple lines + | +3 | _ = "abc" + "def" +4 | +5 | _ = "abc" \ + | _____^ +6 | | "def" + | |_________^ ISC002 +7 | +8 | _ = ( + | + +ISC.py:24:3: ISC002 Implicitly concatenated string literals over multiple lines + | +23 | _ = ( +24 | "abc" + | ___^ +25 | | "def" + | |_______^ ISC002 +26 | ) + | + +ISC.py:29:3: ISC002 Implicitly concatenated string literals over multiple lines + | +28 | _ = ( +29 | f"abc" + | ___^ +30 | | "def" + | |_______^ ISC002 +31 | ) + | + +ISC.py:34:3: ISC002 Implicitly concatenated string literals over multiple lines + | +33 | _ = ( +34 | b"abc" + | ___^ +35 | | b"def" + | |________^ ISC002 +36 | ) + | + + diff --git a/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC003_ISC.py.snap b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC003_ISC.py.snap new file mode 100644 index 0000000000..5c993ef97f --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_implicit_str_concat/snapshots/ruff_linter__rules__flake8_implicit_str_concat__tests__multiline_ISC003_ISC.py.snap @@ -0,0 +1,34 @@ +--- +source: crates/ruff_linter/src/rules/flake8_implicit_str_concat/mod.rs +--- +ISC.py:9:3: ISC003 Explicitly concatenated string should be implicitly concatenated + | + 8 | _ = ( + 9 | "abc" + + | ___^ +10 | | "def" + | |_______^ ISC003 +11 | ) + | + +ISC.py:14:3: ISC003 Explicitly concatenated string should be implicitly concatenated + | +13 | _ = ( +14 | f"abc" + + | ___^ +15 | | "def" + | |_______^ ISC003 +16 | ) + | + +ISC.py:19:3: ISC003 Explicitly concatenated string should be implicitly concatenated + | +18 | _ = ( +19 | b"abc" + + | ___^ +20 | | b"def" + | |________^ ISC003 +21 | ) + | + + diff --git a/crates/ruff/src/rules/flake8_import_conventions/mod.rs b/crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_import_conventions/mod.rs rename to crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs diff --git a/crates/ruff/src/rules/flake8_import_conventions/rules/banned_import_alias.rs b/crates/ruff_linter/src/rules/flake8_import_conventions/rules/banned_import_alias.rs similarity index 100% rename from crates/ruff/src/rules/flake8_import_conventions/rules/banned_import_alias.rs rename to crates/ruff_linter/src/rules/flake8_import_conventions/rules/banned_import_alias.rs diff --git a/crates/ruff/src/rules/flake8_import_conventions/rules/banned_import_from.rs b/crates/ruff_linter/src/rules/flake8_import_conventions/rules/banned_import_from.rs similarity index 100% rename from crates/ruff/src/rules/flake8_import_conventions/rules/banned_import_from.rs rename to crates/ruff_linter/src/rules/flake8_import_conventions/rules/banned_import_from.rs diff --git a/crates/ruff/src/rules/flake8_import_conventions/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_import_conventions/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_import_conventions/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_import_conventions/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_import_conventions/rules/unconventional_import_alias.rs b/crates/ruff_linter/src/rules/flake8_import_conventions/rules/unconventional_import_alias.rs similarity index 100% rename from crates/ruff/src/rules/flake8_import_conventions/rules/unconventional_import_alias.rs rename to crates/ruff_linter/src/rules/flake8_import_conventions/rules/unconventional_import_alias.rs diff --git a/crates/ruff/src/rules/flake8_import_conventions/settings.rs b/crates/ruff_linter/src/rules/flake8_import_conventions/settings.rs similarity index 100% rename from crates/ruff/src/rules/flake8_import_conventions/settings.rs rename to crates/ruff_linter/src/rules/flake8_import_conventions/settings.rs 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 new file mode 100644 index 0000000000..5a34324fe7 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom.snap @@ -0,0 +1,308 @@ +--- +source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs +--- +custom.py:3:8: ICN001 `altair` should be imported as `alt` + | +1 | import math # not checked +2 | +3 | import altair # unconventional + | ^^^^^^ ICN001 +4 | import dask.array # unconventional +5 | import dask.dataframe # unconventional + | + = help: Alias `altair` to `alt` + +custom.py:4:8: ICN001 `dask.array` should be imported as `da` + | +3 | import altair # unconventional +4 | import dask.array # unconventional + | ^^^^^^^^^^ ICN001 +5 | import dask.dataframe # unconventional +6 | import matplotlib.pyplot # unconventional + | + = help: Alias `dask.array` to `da` + +custom.py:5:8: ICN001 `dask.dataframe` should be imported as `dd` + | +3 | import altair # unconventional +4 | import dask.array # unconventional +5 | import dask.dataframe # unconventional + | ^^^^^^^^^^^^^^ ICN001 +6 | import matplotlib.pyplot # unconventional +7 | import numpy # unconventional + | + = help: Alias `dask.dataframe` to `dd` + +custom.py:6:8: ICN001 `matplotlib.pyplot` should be imported as `plt` + | +4 | import dask.array # unconventional +5 | import dask.dataframe # unconventional +6 | import matplotlib.pyplot # unconventional + | ^^^^^^^^^^^^^^^^^ ICN001 +7 | import numpy # unconventional +8 | import pandas # unconventional + | + = help: Alias `matplotlib.pyplot` to `plt` + +custom.py:7:8: ICN001 `numpy` should be imported as `np` + | +5 | import dask.dataframe # unconventional +6 | import matplotlib.pyplot # unconventional +7 | import numpy # unconventional + | ^^^^^ ICN001 +8 | import pandas # unconventional +9 | import seaborn # unconventional + | + = help: Alias `numpy` to `np` + +custom.py:8:8: ICN001 `pandas` should be imported as `pd` + | + 6 | import matplotlib.pyplot # unconventional + 7 | import numpy # unconventional + 8 | import pandas # unconventional + | ^^^^^^ ICN001 + 9 | import seaborn # unconventional +10 | import tensorflow # unconventional + | + = help: Alias `pandas` to `pd` + +custom.py:9:8: ICN001 `seaborn` should be imported as `sns` + | + 7 | import numpy # unconventional + 8 | import pandas # unconventional + 9 | import seaborn # unconventional + | ^^^^^^^ ICN001 +10 | import tensorflow # unconventional +11 | import holoviews # unconventional + | + = help: Alias `seaborn` to `sns` + +custom.py:10:8: ICN001 `tensorflow` should be imported as `tf` + | + 8 | import pandas # unconventional + 9 | import seaborn # unconventional +10 | import tensorflow # unconventional + | ^^^^^^^^^^ ICN001 +11 | import holoviews # unconventional +12 | import panel # unconventional + | + = help: Alias `tensorflow` to `tf` + +custom.py:11:8: ICN001 `holoviews` should be imported as `hv` + | + 9 | import seaborn # unconventional +10 | import tensorflow # unconventional +11 | import holoviews # unconventional + | ^^^^^^^^^ ICN001 +12 | import panel # unconventional +13 | import plotly.express # unconventional + | + = help: Alias `holoviews` to `hv` + +custom.py:12:8: ICN001 `panel` should be imported as `pn` + | +10 | import tensorflow # unconventional +11 | import holoviews # unconventional +12 | import panel # unconventional + | ^^^^^ ICN001 +13 | import plotly.express # unconventional +14 | import matplotlib # unconventional + | + = help: Alias `panel` to `pn` + +custom.py:13:8: ICN001 `plotly.express` should be imported as `px` + | +11 | import holoviews # unconventional +12 | import panel # unconventional +13 | import plotly.express # unconventional + | ^^^^^^^^^^^^^^ ICN001 +14 | import matplotlib # unconventional +15 | import polars # unconventional + | + = help: Alias `plotly.express` to `px` + +custom.py:14:8: ICN001 `matplotlib` should be imported as `mpl` + | +12 | import panel # unconventional +13 | import plotly.express # unconventional +14 | import matplotlib # unconventional + | ^^^^^^^^^^ ICN001 +15 | import polars # unconventional +16 | import pyarrow # unconventional + | + = help: Alias `matplotlib` to `mpl` + +custom.py:15:8: ICN001 `polars` should be imported as `pl` + | +13 | import plotly.express # unconventional +14 | import matplotlib # unconventional +15 | import polars # unconventional + | ^^^^^^ ICN001 +16 | import pyarrow # unconventional + | + = help: Alias `polars` to `pl` + +custom.py:16:8: ICN001 `pyarrow` should be imported as `pa` + | +14 | import matplotlib # unconventional +15 | import polars # unconventional +16 | import pyarrow # unconventional + | ^^^^^^^ ICN001 +17 | +18 | import altair as altr # unconventional + | + = help: Alias `pyarrow` to `pa` + +custom.py:18:18: ICN001 `altair` should be imported as `alt` + | +16 | import pyarrow # unconventional +17 | +18 | import altair as altr # unconventional + | ^^^^ ICN001 +19 | import matplotlib.pyplot as plot # unconventional +20 | import dask.array as darray # unconventional + | + = help: Alias `altair` to `alt` + +custom.py:19:29: ICN001 `matplotlib.pyplot` should be imported as `plt` + | +18 | import altair as altr # unconventional +19 | import matplotlib.pyplot as plot # unconventional + | ^^^^ ICN001 +20 | import dask.array as darray # unconventional +21 | import dask.dataframe as ddf # unconventional + | + = help: Alias `matplotlib.pyplot` to `plt` + +custom.py:20:22: ICN001 `dask.array` should be imported as `da` + | +18 | import altair as altr # unconventional +19 | import matplotlib.pyplot as plot # unconventional +20 | import dask.array as darray # unconventional + | ^^^^^^ ICN001 +21 | import dask.dataframe as ddf # unconventional +22 | import numpy as nmp # unconventional + | + = help: Alias `dask.array` to `da` + +custom.py:21:26: ICN001 `dask.dataframe` should be imported as `dd` + | +19 | import matplotlib.pyplot as plot # unconventional +20 | import dask.array as darray # unconventional +21 | import dask.dataframe as ddf # unconventional + | ^^^ ICN001 +22 | import numpy as nmp # unconventional +23 | import pandas as pdas # unconventional + | + = help: Alias `dask.dataframe` to `dd` + +custom.py:22:17: ICN001 `numpy` should be imported as `np` + | +20 | import dask.array as darray # unconventional +21 | import dask.dataframe as ddf # unconventional +22 | import numpy as nmp # unconventional + | ^^^ ICN001 +23 | import pandas as pdas # unconventional +24 | import seaborn as sbrn # unconventional + | + = help: Alias `numpy` to `np` + +custom.py:23:18: ICN001 `pandas` should be imported as `pd` + | +21 | import dask.dataframe as ddf # unconventional +22 | import numpy as nmp # unconventional +23 | import pandas as pdas # unconventional + | ^^^^ ICN001 +24 | import seaborn as sbrn # unconventional +25 | import tensorflow as tfz # unconventional + | + = help: Alias `pandas` to `pd` + +custom.py:24:19: ICN001 `seaborn` should be imported as `sns` + | +22 | import numpy as nmp # unconventional +23 | import pandas as pdas # unconventional +24 | import seaborn as sbrn # unconventional + | ^^^^ ICN001 +25 | import tensorflow as tfz # unconventional +26 | import holoviews as hsv # unconventional + | + = help: Alias `seaborn` to `sns` + +custom.py:25:22: ICN001 `tensorflow` should be imported as `tf` + | +23 | import pandas as pdas # unconventional +24 | import seaborn as sbrn # unconventional +25 | import tensorflow as tfz # unconventional + | ^^^ ICN001 +26 | import holoviews as hsv # unconventional +27 | import panel as pns # unconventional + | + = help: Alias `tensorflow` to `tf` + +custom.py:26:21: ICN001 `holoviews` should be imported as `hv` + | +24 | import seaborn as sbrn # unconventional +25 | import tensorflow as tfz # unconventional +26 | import holoviews as hsv # unconventional + | ^^^ ICN001 +27 | import panel as pns # unconventional +28 | import plotly.express as pltx # unconventional + | + = help: Alias `holoviews` to `hv` + +custom.py:27:17: ICN001 `panel` should be imported as `pn` + | +25 | import tensorflow as tfz # unconventional +26 | import holoviews as hsv # unconventional +27 | import panel as pns # unconventional + | ^^^ ICN001 +28 | import plotly.express as pltx # unconventional +29 | import matplotlib as ml # unconventional + | + = help: Alias `panel` to `pn` + +custom.py:28:26: ICN001 `plotly.express` should be imported as `px` + | +26 | import holoviews as hsv # unconventional +27 | import panel as pns # unconventional +28 | import plotly.express as pltx # unconventional + | ^^^^ ICN001 +29 | import matplotlib as ml # unconventional +30 | import polars as ps # unconventional + | + = help: Alias `plotly.express` to `px` + +custom.py:29:22: ICN001 `matplotlib` should be imported as `mpl` + | +27 | import panel as pns # unconventional +28 | import plotly.express as pltx # unconventional +29 | import matplotlib as ml # unconventional + | ^^ ICN001 +30 | import polars as ps # unconventional +31 | import pyarrow as arr # unconventional + | + = help: Alias `matplotlib` to `mpl` + +custom.py:30:18: ICN001 `polars` should be imported as `pl` + | +28 | import plotly.express as pltx # unconventional +29 | import matplotlib as ml # unconventional +30 | import polars as ps # unconventional + | ^^ ICN001 +31 | import pyarrow as arr # unconventional + | + = help: Alias `polars` to `pl` + +custom.py:31:19: ICN001 `pyarrow` should be imported as `pa` + | +29 | import matplotlib as ml # unconventional +30 | import polars as ps # unconventional +31 | import pyarrow as arr # unconventional + | ^^^ ICN001 +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 new file mode 100644 index 0000000000..f0d5ae061b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom_banned.snap @@ -0,0 +1,78 @@ +--- +source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs +--- +custom_banned.py:1:1: ICN002 `typing` should not be imported as `t` + | +1 | import typing as t # banned + | ^^^^^^^^^^^^^^^^^^ ICN002 +2 | import typing as ty # banned + | + +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 | +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 | +4 | import numpy as nmp # banned + | ^^^^^^^^^^^^^^^^^^^ ICN002 +5 | import numpy as npy # banned +6 | import tensorflow.keras.backend as K # banned + | + +custom_banned.py:5:1: ICN002 `numpy` should not be imported as `npy` + | +4 | import numpy as nmp # banned +5 | import numpy as npy # banned + | ^^^^^^^^^^^^^^^^^^^ ICN002 +6 | import tensorflow.keras.backend as K # banned +7 | import torch.nn.functional as F # banned + | + +custom_banned.py:6:1: ICN002 `tensorflow.keras.backend` should not be imported as `K` + | +4 | import numpy as nmp # banned +5 | import numpy as npy # banned +6 | import tensorflow.keras.backend as K # banned + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN002 +7 | import torch.nn.functional as F # banned +8 | from tensorflow.keras import backend as K # banned + | + +custom_banned.py:7:1: ICN002 `torch.nn.functional` should not be imported as `F` + | +5 | import numpy as npy # banned +6 | import tensorflow.keras.backend as K # banned +7 | import torch.nn.functional as F # banned + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN002 +8 | from tensorflow.keras import backend as K # banned +9 | from torch.nn import functional as F # banned + | + +custom_banned.py:8:1: ICN002 `tensorflow.keras.backend` should not be imported as `K` + | +6 | import tensorflow.keras.backend as K # banned +7 | import torch.nn.functional as F # banned +8 | from tensorflow.keras import backend as K # banned + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN002 +9 | from torch.nn import functional as F # banned + | + +custom_banned.py:9:1: ICN002 `torch.nn.functional` should not be imported as `F` + | + 7 | import torch.nn.functional as F # banned + 8 | from tensorflow.keras import backend as K # banned + 9 | from torch.nn import functional as F # banned + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN002 +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 new file mode 100644 index 0000000000..529369a42d --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__custom_banned_from.snap @@ -0,0 +1,48 @@ +--- +source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs +--- +custom_banned_from.py:1:1: ICN003 Members of `logging.config` should not be imported explicitly + | +1 | from logging.config import BaseConfigurator # banned + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN003 +2 | from typing import Any, Dict # banned +3 | from typing import * # banned + | + +custom_banned_from.py:2:1: ICN003 Members of `typing` should not be imported explicitly + | +1 | from logging.config import BaseConfigurator # banned +2 | from typing import Any, Dict # banned + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN003 +3 | from typing import * # banned + | + +custom_banned_from.py:3:1: ICN003 Members of `typing` should not be imported explicitly + | +1 | from logging.config import BaseConfigurator # banned +2 | from typing import Any, Dict # banned +3 | from typing import * # banned + | ^^^^^^^^^^^^^^^^^^^^ ICN003 +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 | +5 | from pandas import DataFrame # banned + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ICN003 +6 | from pandas import * # banned + | + +custom_banned_from.py:6:1: ICN003 Members of `pandas` should not be imported explicitly + | +5 | from pandas import DataFrame # banned +6 | from pandas import * # banned + | ^^^^^^^^^^^^^^^^^^^^ ICN003 +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__defaults.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__defaults.snap new file mode 100644 index 0000000000..848b339416 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__defaults.snap @@ -0,0 +1,282 @@ +--- +source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs +--- +defaults.py:6:12: ICN001 [*] `altair` should be imported as `alt` + | +5 | def unconventional(): +6 | import altair + | ^^^^^^ ICN001 +7 | import matplotlib.pyplot +8 | import numpy + | + = help: Alias `altair` to `alt` + +ℹ Suggested fix +3 3 | +4 4 | +5 5 | def unconventional(): +6 |- import altair + 6 |+ import altair as alt +7 7 | import matplotlib.pyplot +8 8 | import numpy +9 9 | import pandas + +defaults.py:7:12: ICN001 `matplotlib.pyplot` should be imported as `plt` + | +5 | def unconventional(): +6 | import altair +7 | import matplotlib.pyplot + | ^^^^^^^^^^^^^^^^^ ICN001 +8 | import numpy +9 | import pandas + | + = help: Alias `matplotlib.pyplot` to `plt` + +defaults.py:8:12: ICN001 [*] `numpy` should be imported as `np` + | + 6 | import altair + 7 | import matplotlib.pyplot + 8 | import numpy + | ^^^^^ ICN001 + 9 | import pandas +10 | import seaborn + | + = help: Alias `numpy` to `np` + +ℹ Suggested fix +5 5 | def unconventional(): +6 6 | import altair +7 7 | import matplotlib.pyplot +8 |- import numpy + 8 |+ import numpy as np +9 9 | import pandas +10 10 | import seaborn +11 11 | import tkinter + +defaults.py:9:12: ICN001 [*] `pandas` should be imported as `pd` + | + 7 | import matplotlib.pyplot + 8 | import numpy + 9 | import pandas + | ^^^^^^ ICN001 +10 | import seaborn +11 | import tkinter + | + = help: Alias `pandas` to `pd` + +ℹ Suggested fix +6 6 | import altair +7 7 | import matplotlib.pyplot +8 8 | import numpy +9 |- import pandas + 9 |+ import pandas as pd +10 10 | import seaborn +11 11 | import tkinter +12 12 | import networkx + +defaults.py:10:12: ICN001 [*] `seaborn` should be imported as `sns` + | + 8 | import numpy + 9 | import pandas +10 | import seaborn + | ^^^^^^^ ICN001 +11 | import tkinter +12 | import networkx + | + = help: Alias `seaborn` to `sns` + +ℹ Suggested fix +7 7 | import matplotlib.pyplot +8 8 | import numpy +9 9 | import pandas +10 |- import seaborn + 10 |+ import seaborn as sns +11 11 | import tkinter +12 12 | import networkx +13 13 | + +defaults.py:11:12: ICN001 [*] `tkinter` should be imported as `tk` + | + 9 | import pandas +10 | import seaborn +11 | import tkinter + | ^^^^^^^ ICN001 +12 | import networkx + | + = help: Alias `tkinter` to `tk` + +ℹ Suggested fix +8 8 | import numpy +9 9 | import pandas +10 10 | import seaborn +11 |- import tkinter + 11 |+ import tkinter as tk +12 12 | import networkx +13 13 | +14 14 | + +defaults.py:12:12: ICN001 [*] `networkx` should be imported as `nx` + | +10 | import seaborn +11 | import tkinter +12 | import networkx + | ^^^^^^^^ ICN001 + | + = help: Alias `networkx` to `nx` + +ℹ Suggested fix +9 9 | import pandas +10 10 | import seaborn +11 11 | import tkinter +12 |- import networkx + 12 |+ import networkx as nx +13 13 | +14 14 | +15 15 | def unconventional_aliases(): + +defaults.py:16:22: ICN001 [*] `altair` should be imported as `alt` + | +15 | def unconventional_aliases(): +16 | import altair as altr + | ^^^^ ICN001 +17 | import matplotlib.pyplot as plot +18 | import numpy as nmp + | + = help: Alias `altair` to `alt` + +ℹ Suggested fix +13 13 | +14 14 | +15 15 | def unconventional_aliases(): +16 |- import altair as altr + 16 |+ import altair as alt +17 17 | import matplotlib.pyplot as plot +18 18 | import numpy as nmp +19 19 | import pandas as pdas + +defaults.py:17:33: ICN001 [*] `matplotlib.pyplot` should be imported as `plt` + | +15 | def unconventional_aliases(): +16 | import altair as altr +17 | import matplotlib.pyplot as plot + | ^^^^ ICN001 +18 | import numpy as nmp +19 | import pandas as pdas + | + = help: Alias `matplotlib.pyplot` to `plt` + +ℹ Suggested fix +14 14 | +15 15 | def unconventional_aliases(): +16 16 | import altair as altr +17 |- import matplotlib.pyplot as plot + 17 |+ import matplotlib.pyplot as plt +18 18 | import numpy as nmp +19 19 | import pandas as pdas +20 20 | import seaborn as sbrn + +defaults.py:18:21: ICN001 [*] `numpy` should be imported as `np` + | +16 | import altair as altr +17 | import matplotlib.pyplot as plot +18 | import numpy as nmp + | ^^^ ICN001 +19 | import pandas as pdas +20 | import seaborn as sbrn + | + = help: Alias `numpy` to `np` + +ℹ Suggested fix +15 15 | def unconventional_aliases(): +16 16 | import altair as altr +17 17 | import matplotlib.pyplot as plot +18 |- import numpy as nmp + 18 |+ import numpy as np +19 19 | import pandas as pdas +20 20 | import seaborn as sbrn +21 21 | import tkinter as tkr + +defaults.py:19:22: ICN001 [*] `pandas` should be imported as `pd` + | +17 | import matplotlib.pyplot as plot +18 | import numpy as nmp +19 | import pandas as pdas + | ^^^^ ICN001 +20 | import seaborn as sbrn +21 | import tkinter as tkr + | + = help: Alias `pandas` to `pd` + +ℹ Suggested fix +16 16 | import altair as altr +17 17 | import matplotlib.pyplot as plot +18 18 | import numpy as nmp +19 |- import pandas as pdas + 19 |+ import pandas as pd +20 20 | import seaborn as sbrn +21 21 | import tkinter as tkr +22 22 | import networkx as nxy + +defaults.py:20:23: ICN001 [*] `seaborn` should be imported as `sns` + | +18 | import numpy as nmp +19 | import pandas as pdas +20 | import seaborn as sbrn + | ^^^^ ICN001 +21 | import tkinter as tkr +22 | import networkx as nxy + | + = help: Alias `seaborn` to `sns` + +ℹ Suggested fix +17 17 | import matplotlib.pyplot as plot +18 18 | import numpy as nmp +19 19 | import pandas as pdas +20 |- import seaborn as sbrn + 20 |+ import seaborn as sns +21 21 | import tkinter as tkr +22 22 | import networkx as nxy +23 23 | + +defaults.py:21:23: ICN001 [*] `tkinter` should be imported as `tk` + | +19 | import pandas as pdas +20 | import seaborn as sbrn +21 | import tkinter as tkr + | ^^^ ICN001 +22 | import networkx as nxy + | + = help: Alias `tkinter` to `tk` + +ℹ Suggested fix +18 18 | import numpy as nmp +19 19 | import pandas as pdas +20 20 | import seaborn as sbrn +21 |- import tkinter as tkr + 21 |+ import tkinter as tk +22 22 | import networkx as nxy +23 23 | +24 24 | def conventional_aliases(): + +defaults.py:22:24: ICN001 [*] `networkx` should be imported as `nx` + | +20 | import seaborn as sbrn +21 | import tkinter as tkr +22 | import networkx as nxy + | ^^^ ICN001 +23 | +24 | def conventional_aliases(): + | + = help: Alias `networkx` to `nx` + +ℹ Suggested fix +19 19 | import pandas as pdas +20 20 | import seaborn as sbrn +21 21 | import tkinter as tkr +22 |- import networkx as nxy + 22 |+ import networkx as nx +23 23 | +24 24 | def conventional_aliases(): +25 25 | import altair as alt + + 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 new file mode 100644 index 0000000000..37d2bed52d --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__from_imports.snap @@ -0,0 +1,91 @@ +--- +source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs +--- +from_imports.py:3:8: ICN001 `xml.dom.minidom` should be imported as `md` + | +1 | # Test absolute imports +2 | # Violation cases +3 | import xml.dom.minidom + | ^^^^^^^^^^^^^^^ ICN001 +4 | import xml.dom.minidom as wrong +5 | from xml.dom import minidom as wrong + | + = help: Alias `xml.dom.minidom` to `md` + +from_imports.py:4:27: ICN001 `xml.dom.minidom` should be imported as `md` + | +2 | # Violation cases +3 | import xml.dom.minidom +4 | import xml.dom.minidom as wrong + | ^^^^^ ICN001 +5 | from xml.dom import minidom as wrong +6 | from xml.dom import minidom + | + = help: Alias `xml.dom.minidom` to `md` + +from_imports.py:5:32: ICN001 `xml.dom.minidom` should be imported as `md` + | +3 | import xml.dom.minidom +4 | import xml.dom.minidom as wrong +5 | from xml.dom import minidom as wrong + | ^^^^^ ICN001 +6 | from xml.dom import minidom +7 | from xml.dom.minidom import parseString as wrong # Ensure ICN001 throws on function import. + | + = help: Alias `xml.dom.minidom` to `md` + +from_imports.py:6:21: ICN001 `xml.dom.minidom` should be imported as `md` + | +4 | import xml.dom.minidom as wrong +5 | from xml.dom import minidom as wrong +6 | from xml.dom import minidom + | ^^^^^^^ ICN001 +7 | from xml.dom.minidom import parseString as wrong # Ensure ICN001 throws on function import. +8 | from xml.dom.minidom import parseString + | + = help: Alias `xml.dom.minidom` to `md` + +from_imports.py:7:44: ICN001 `xml.dom.minidom.parseString` should be imported as `pstr` + | +5 | from xml.dom import minidom as wrong +6 | from xml.dom import minidom +7 | from xml.dom.minidom import parseString as wrong # Ensure ICN001 throws on function import. + | ^^^^^ ICN001 +8 | from xml.dom.minidom import parseString +9 | from xml.dom.minidom import parse, parseString + | + = help: Alias `xml.dom.minidom.parseString` to `pstr` + +from_imports.py:8:29: ICN001 `xml.dom.minidom.parseString` should be imported as `pstr` + | + 6 | from xml.dom import minidom + 7 | from xml.dom.minidom import parseString as wrong # Ensure ICN001 throws on function import. + 8 | from xml.dom.minidom import parseString + | ^^^^^^^^^^^ ICN001 + 9 | from xml.dom.minidom import parse, parseString +10 | from xml.dom.minidom import parse as ps, parseString as wrong + | + = help: Alias `xml.dom.minidom.parseString` to `pstr` + +from_imports.py:9:36: ICN001 `xml.dom.minidom.parseString` should be imported as `pstr` + | + 7 | from xml.dom.minidom import parseString as wrong # Ensure ICN001 throws on function import. + 8 | from xml.dom.minidom import parseString + 9 | from xml.dom.minidom import parse, parseString + | ^^^^^^^^^^^ ICN001 +10 | from xml.dom.minidom import parse as ps, parseString as wrong + | + = help: Alias `xml.dom.minidom.parseString` to `pstr` + +from_imports.py:10:57: ICN001 `xml.dom.minidom.parseString` should be imported as `pstr` + | + 8 | from xml.dom.minidom import parseString + 9 | from xml.dom.minidom import parse, parseString +10 | from xml.dom.minidom import parse as ps, parseString as wrong + | ^^^^^ ICN001 +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 new file mode 100644 index 0000000000..1b81f2b87d --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__override_defaults.snap @@ -0,0 +1,110 @@ +--- +source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs +--- +override_default.py:3:8: ICN001 `altair` should be imported as `alt` + | +1 | import math # not checked +2 | +3 | import altair # unconventional + | ^^^^^^ ICN001 +4 | import matplotlib.pyplot # unconventional +5 | import numpy # unconventional + | + = help: Alias `altair` to `alt` + +override_default.py:4:8: ICN001 `matplotlib.pyplot` should be imported as `plt` + | +3 | import altair # unconventional +4 | import matplotlib.pyplot # unconventional + | ^^^^^^^^^^^^^^^^^ ICN001 +5 | import numpy # unconventional +6 | import pandas # unconventional + | + = help: Alias `matplotlib.pyplot` to `plt` + +override_default.py:5:8: ICN001 `numpy` should be imported as `nmp` + | +3 | import altair # unconventional +4 | import matplotlib.pyplot # unconventional +5 | import numpy # unconventional + | ^^^^^ ICN001 +6 | import pandas # unconventional +7 | import seaborn # unconventional + | + = help: Alias `numpy` to `nmp` + +override_default.py:6:8: ICN001 `pandas` should be imported as `pd` + | +4 | import matplotlib.pyplot # unconventional +5 | import numpy # unconventional +6 | import pandas # unconventional + | ^^^^^^ ICN001 +7 | import seaborn # unconventional + | + = help: Alias `pandas` to `pd` + +override_default.py:7:8: ICN001 `seaborn` should be imported as `sns` + | +5 | import numpy # unconventional +6 | import pandas # unconventional +7 | import seaborn # unconventional + | ^^^^^^^ ICN001 +8 | +9 | import altair as altr # unconventional + | + = help: Alias `seaborn` to `sns` + +override_default.py:9:18: ICN001 `altair` should be imported as `alt` + | + 7 | import seaborn # unconventional + 8 | + 9 | import altair as altr # unconventional + | ^^^^ ICN001 +10 | import matplotlib.pyplot as plot # unconventional +11 | import numpy as np # unconventional + | + = help: Alias `altair` to `alt` + +override_default.py:10:29: ICN001 `matplotlib.pyplot` should be imported as `plt` + | + 9 | import altair as altr # unconventional +10 | import matplotlib.pyplot as plot # unconventional + | ^^^^ ICN001 +11 | import numpy as np # unconventional +12 | import pandas as pdas # unconventional + | + = help: Alias `matplotlib.pyplot` to `plt` + +override_default.py:11:17: ICN001 `numpy` should be imported as `nmp` + | + 9 | import altair as altr # unconventional +10 | import matplotlib.pyplot as plot # unconventional +11 | import numpy as np # unconventional + | ^^ ICN001 +12 | import pandas as pdas # unconventional +13 | import seaborn as sbrn # unconventional + | + = help: Alias `numpy` to `nmp` + +override_default.py:12:18: ICN001 `pandas` should be imported as `pd` + | +10 | import matplotlib.pyplot as plot # unconventional +11 | import numpy as np # unconventional +12 | import pandas as pdas # unconventional + | ^^^^ ICN001 +13 | import seaborn as sbrn # unconventional + | + = help: Alias `pandas` to `pd` + +override_default.py:13:19: ICN001 `seaborn` should be imported as `sns` + | +11 | import numpy as np # unconventional +12 | import pandas as pdas # unconventional +13 | import seaborn as sbrn # unconventional + | ^^^^ ICN001 +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 new file mode 100644 index 0000000000..2af1097a2e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__remove_defaults.snap @@ -0,0 +1,88 @@ +--- +source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs +--- +remove_default.py:3:8: ICN001 `altair` should be imported as `alt` + | +1 | import math # not checked +2 | +3 | import altair # unconventional + | ^^^^^^ ICN001 +4 | import matplotlib.pyplot # unconventional +5 | import numpy # not checked + | + = help: Alias `altair` to `alt` + +remove_default.py:4:8: ICN001 `matplotlib.pyplot` should be imported as `plt` + | +3 | import altair # unconventional +4 | import matplotlib.pyplot # unconventional + | ^^^^^^^^^^^^^^^^^ ICN001 +5 | import numpy # not checked +6 | import pandas # unconventional + | + = help: Alias `matplotlib.pyplot` to `plt` + +remove_default.py:6:8: ICN001 `pandas` should be imported as `pd` + | +4 | import matplotlib.pyplot # unconventional +5 | import numpy # not checked +6 | import pandas # unconventional + | ^^^^^^ ICN001 +7 | import seaborn # unconventional + | + = help: Alias `pandas` to `pd` + +remove_default.py:7:8: ICN001 `seaborn` should be imported as `sns` + | +5 | import numpy # not checked +6 | import pandas # unconventional +7 | import seaborn # unconventional + | ^^^^^^^ ICN001 +8 | +9 | import altair as altr # unconventional + | + = help: Alias `seaborn` to `sns` + +remove_default.py:9:18: ICN001 `altair` should be imported as `alt` + | + 7 | import seaborn # unconventional + 8 | + 9 | import altair as altr # unconventional + | ^^^^ ICN001 +10 | import matplotlib.pyplot as plot # unconventional +11 | import numpy as nmp # not checked + | + = help: Alias `altair` to `alt` + +remove_default.py:10:29: ICN001 `matplotlib.pyplot` should be imported as `plt` + | + 9 | import altair as altr # unconventional +10 | import matplotlib.pyplot as plot # unconventional + | ^^^^ ICN001 +11 | import numpy as nmp # not checked +12 | import pandas as pdas # unconventional + | + = help: Alias `matplotlib.pyplot` to `plt` + +remove_default.py:12:18: ICN001 `pandas` should be imported as `pd` + | +10 | import matplotlib.pyplot as plot # unconventional +11 | import numpy as nmp # not checked +12 | import pandas as pdas # unconventional + | ^^^^ ICN001 +13 | import seaborn as sbrn # unconventional + | + = help: Alias `pandas` to `pd` + +remove_default.py:13:19: ICN001 `seaborn` should be imported as `sns` + | +11 | import numpy as nmp # not checked +12 | import pandas as pdas # unconventional +13 | import seaborn as sbrn # unconventional + | ^^^^ ICN001 +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__tricky.snap b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__tricky.snap new file mode 100644 index 0000000000..2078183e50 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_import_conventions/snapshots/ruff_linter__rules__flake8_import_conventions__tests__tricky.snap @@ -0,0 +1,26 @@ +--- +source: crates/ruff_linter/src/rules/flake8_import_conventions/mod.rs +--- +tricky.py:7:16: ICN001 [*] `pandas` should be imported as `pd` + | +5 | try: +6 | global pandas +7 | import pandas + | ^^^^^^ ICN001 +8 | except ImportError: +9 | return False + | + = help: Alias `pandas` to `pd` + +ℹ Suggested fix +3 3 | +4 4 | def rename_global(): +5 5 | try: +6 |- global pandas +7 |- import pandas + 6 |+ global pd + 7 |+ import pandas as pd +8 8 | except ImportError: +9 9 | return False + + diff --git a/crates/ruff/src/rules/flake8_logging/mod.rs b/crates/ruff_linter/src/rules/flake8_logging/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_logging/mod.rs rename to crates/ruff_linter/src/rules/flake8_logging/mod.rs diff --git a/crates/ruff/src/rules/flake8_logging/rules/direct_logger_instantiation.rs b/crates/ruff_linter/src/rules/flake8_logging/rules/direct_logger_instantiation.rs similarity index 100% rename from crates/ruff/src/rules/flake8_logging/rules/direct_logger_instantiation.rs rename to crates/ruff_linter/src/rules/flake8_logging/rules/direct_logger_instantiation.rs diff --git a/crates/ruff/src/rules/flake8_logging/rules/exception_without_exc_info.rs b/crates/ruff_linter/src/rules/flake8_logging/rules/exception_without_exc_info.rs similarity index 100% rename from crates/ruff/src/rules/flake8_logging/rules/exception_without_exc_info.rs rename to crates/ruff_linter/src/rules/flake8_logging/rules/exception_without_exc_info.rs diff --git a/crates/ruff/src/rules/flake8_logging/rules/invalid_get_logger_argument.rs b/crates/ruff_linter/src/rules/flake8_logging/rules/invalid_get_logger_argument.rs similarity index 100% rename from crates/ruff/src/rules/flake8_logging/rules/invalid_get_logger_argument.rs rename to crates/ruff_linter/src/rules/flake8_logging/rules/invalid_get_logger_argument.rs diff --git a/crates/ruff/src/rules/flake8_logging/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_logging/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_logging/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_logging/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_logging/rules/undocumented_warn.rs b/crates/ruff_linter/src/rules/flake8_logging/rules/undocumented_warn.rs similarity index 100% rename from crates/ruff/src/rules/flake8_logging/rules/undocumented_warn.rs rename to crates/ruff_linter/src/rules/flake8_logging/rules/undocumented_warn.rs 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 new file mode 100644 index 0000000000..c7ee37c94c --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG001_LOG001.py.snap @@ -0,0 +1,40 @@ +--- +source: crates/ruff_linter/src/rules/flake8_logging/mod.rs +--- +LOG001.py:3:1: LOG001 [*] Use `logging.getLogger()` to instantiate loggers + | +1 | import logging +2 | +3 | logging.Logger(__name__) + | ^^^^^^^^^^^^^^ LOG001 +4 | logging.Logger() +5 | logging.getLogger(__name__) + | + = help: Replace with `logging.getLogger()` + +ℹ Suggested fix +1 1 | import logging +2 2 | +3 |-logging.Logger(__name__) + 3 |+logging.getLogger(__name__) +4 4 | logging.Logger() +5 5 | logging.getLogger(__name__) + +LOG001.py:4:1: LOG001 [*] Use `logging.getLogger()` to instantiate loggers + | +3 | logging.Logger(__name__) +4 | logging.Logger() + | ^^^^^^^^^^^^^^ LOG001 +5 | logging.getLogger(__name__) + | + = help: Replace with `logging.getLogger()` + +ℹ Suggested fix +1 1 | import logging +2 2 | +3 3 | logging.Logger(__name__) +4 |-logging.Logger() + 4 |+logging.getLogger() +5 5 | logging.getLogger(__name__) + + 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 new file mode 100644 index 0000000000..e208e94121 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG002_LOG002.py.snap @@ -0,0 +1,82 @@ +--- +source: crates/ruff_linter/src/rules/flake8_logging/mod.rs +--- +LOG002.py:11:11: LOG002 [*] Use `__name__` with `logging.getLogger()` + | +10 | # LOG002 +11 | getLogger(__file__) + | ^^^^^^^^ LOG002 +12 | logging.getLogger(name=__file__) + | + = help: Replace with `name` + +ℹ Suggested fix +8 8 | logging.getLogger(name="custom") +9 9 | +10 10 | # LOG002 +11 |-getLogger(__file__) + 11 |+getLogger(__name__) +12 12 | logging.getLogger(name=__file__) +13 13 | +14 14 | logging.getLogger(__cached__) + +LOG002.py:12:24: LOG002 [*] Use `__name__` with `logging.getLogger()` + | +10 | # LOG002 +11 | getLogger(__file__) +12 | logging.getLogger(name=__file__) + | ^^^^^^^^ LOG002 +13 | +14 | logging.getLogger(__cached__) + | + = help: Replace with `name` + +ℹ Suggested fix +9 9 | +10 10 | # LOG002 +11 11 | getLogger(__file__) +12 |-logging.getLogger(name=__file__) + 12 |+logging.getLogger(name=__name__) +13 13 | +14 14 | logging.getLogger(__cached__) +15 15 | getLogger(name=__cached__) + +LOG002.py:14:19: LOG002 [*] Use `__name__` with `logging.getLogger()` + | +12 | logging.getLogger(name=__file__) +13 | +14 | logging.getLogger(__cached__) + | ^^^^^^^^^^ LOG002 +15 | getLogger(name=__cached__) + | + = help: Replace with `name` + +ℹ Suggested fix +11 11 | getLogger(__file__) +12 12 | logging.getLogger(name=__file__) +13 13 | +14 |-logging.getLogger(__cached__) + 14 |+logging.getLogger(__name__) +15 15 | getLogger(name=__cached__) +16 16 | +17 17 | + +LOG002.py:15:16: LOG002 [*] Use `__name__` with `logging.getLogger()` + | +14 | logging.getLogger(__cached__) +15 | getLogger(name=__cached__) + | ^^^^^^^^^^ LOG002 + | + = help: Replace with `name` + +ℹ Suggested fix +12 12 | logging.getLogger(name=__file__) +13 13 | +14 14 | logging.getLogger(__cached__) +15 |-getLogger(name=__cached__) + 15 |+getLogger(name=__name__) +16 16 | +17 17 | +18 18 | # Override `logging.getLogger` + + 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 new file mode 100644 index 0000000000..df6cb6a004 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG007_LOG007.py.snap @@ -0,0 +1,43 @@ +--- +source: crates/ruff_linter/src/rules/flake8_logging/mod.rs +--- +LOG007.py:6:1: LOG007 Use of `logging.exception` with falsy `exc_info` + | +5 | logging.exception("foo") # OK +6 | logging.exception("foo", exc_info=False) # LOG007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LOG007 +7 | logging.exception("foo", exc_info=[]) # LOG007 +8 | logger.exception("foo") # OK + | + +LOG007.py:7:1: LOG007 Use of `logging.exception` with falsy `exc_info` + | +5 | logging.exception("foo") # OK +6 | logging.exception("foo", exc_info=False) # LOG007 +7 | logging.exception("foo", exc_info=[]) # LOG007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LOG007 +8 | logger.exception("foo") # OK +9 | logger.exception("foo", exc_info=False) # LOG007 + | + +LOG007.py:9:1: LOG007 Use of `logging.exception` with falsy `exc_info` + | + 7 | logging.exception("foo", exc_info=[]) # LOG007 + 8 | logger.exception("foo") # OK + 9 | logger.exception("foo", exc_info=False) # LOG007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LOG007 +10 | logger.exception("foo", exc_info=[]) # LOG007 +11 | logger.error("foo", exc_info=False) # OK + | + +LOG007.py:10:1: LOG007 Use of `logging.exception` with falsy `exc_info` + | + 8 | logger.exception("foo") # OK + 9 | logger.exception("foo", exc_info=False) # LOG007 +10 | logger.exception("foo", exc_info=[]) # LOG007 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LOG007 +11 | logger.error("foo", exc_info=False) # OK +12 | logger.info("foo", exc_info=False) # 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 new file mode 100644 index 0000000000..a31c6a2b1c --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_logging/snapshots/ruff_linter__rules__flake8_logging__tests__LOG009_LOG009.py.snap @@ -0,0 +1,41 @@ +--- +source: crates/ruff_linter/src/rules/flake8_logging/mod.rs +--- +LOG009.py:3:1: LOG009 [*] Use of undocumented `logging.WARN` constant + | +1 | import logging +2 | +3 | logging.WARN # LOG009 + | ^^^^^^^^^^^^ LOG009 +4 | logging.WARNING # OK + | + = help: Replace `logging.WARN` with `logging.WARNING` + +ℹ Suggested fix +1 1 | import logging +2 2 | +3 |-logging.WARN # LOG009 + 3 |+logging.WARNING # LOG009 +4 4 | logging.WARNING # OK +5 5 | +6 6 | from logging import WARN, WARNING + +LOG009.py:8:1: LOG009 [*] Use of undocumented `logging.WARN` constant + | +6 | from logging import WARN, WARNING +7 | +8 | WARN # LOG009 + | ^^^^ LOG009 +9 | WARNING # OK + | + = help: Replace `logging.WARN` with `logging.WARNING` + +ℹ Suggested fix +5 5 | +6 6 | from logging import WARN, WARNING +7 7 | +8 |-WARN # LOG009 + 8 |+logging.WARNING # LOG009 +9 9 | WARNING # OK + + diff --git a/crates/ruff/src/rules/flake8_logging_format/mod.rs b/crates/ruff_linter/src/rules/flake8_logging_format/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_logging_format/mod.rs rename to crates/ruff_linter/src/rules/flake8_logging_format/mod.rs diff --git a/crates/ruff/src/rules/flake8_logging_format/rules/logging_call.rs b/crates/ruff_linter/src/rules/flake8_logging_format/rules/logging_call.rs similarity index 100% rename from crates/ruff/src/rules/flake8_logging_format/rules/logging_call.rs rename to crates/ruff_linter/src/rules/flake8_logging_format/rules/logging_call.rs diff --git a/crates/ruff/src/rules/flake8_logging_format/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_logging_format/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_logging_format/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_logging_format/rules/mod.rs 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 new file mode 100644 index 0000000000..7e2391e7b3 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G001.py.snap @@ -0,0 +1,88 @@ +--- +source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs +--- +G001.py:4:14: G001 Logging statement uses `str.format` + | +2 | import logging as foo +3 | +4 | logging.info("Hello {}".format("World!")) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 +5 | logging.log(logging.INFO, "Hello {}".format("World!")) +6 | foo.info("Hello {}".format("World!")) + | + +G001.py:5:27: G001 Logging statement uses `str.format` + | +4 | logging.info("Hello {}".format("World!")) +5 | logging.log(logging.INFO, "Hello {}".format("World!")) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 +6 | foo.info("Hello {}".format("World!")) +7 | logging.log(logging.INFO, msg="Hello {}".format("World!")) + | + +G001.py:6:10: G001 Logging statement uses `str.format` + | +4 | logging.info("Hello {}".format("World!")) +5 | logging.log(logging.INFO, "Hello {}".format("World!")) +6 | foo.info("Hello {}".format("World!")) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 +7 | logging.log(logging.INFO, msg="Hello {}".format("World!")) +8 | logging.log(level=logging.INFO, msg="Hello {}".format("World!")) + | + +G001.py:7:31: G001 Logging statement uses `str.format` + | +5 | logging.log(logging.INFO, "Hello {}".format("World!")) +6 | foo.info("Hello {}".format("World!")) +7 | logging.log(logging.INFO, msg="Hello {}".format("World!")) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 +8 | logging.log(level=logging.INFO, msg="Hello {}".format("World!")) +9 | logging.log(msg="Hello {}".format("World!"), level=logging.INFO) + | + +G001.py:8:37: G001 Logging statement uses `str.format` + | +6 | foo.info("Hello {}".format("World!")) +7 | logging.log(logging.INFO, msg="Hello {}".format("World!")) +8 | logging.log(level=logging.INFO, msg="Hello {}".format("World!")) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 +9 | logging.log(msg="Hello {}".format("World!"), level=logging.INFO) + | + +G001.py:9:17: G001 Logging statement uses `str.format` + | + 7 | logging.log(logging.INFO, msg="Hello {}".format("World!")) + 8 | logging.log(level=logging.INFO, msg="Hello {}".format("World!")) + 9 | logging.log(msg="Hello {}".format("World!"), level=logging.INFO) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 +10 | +11 | # Flask support + | + +G001.py:16:31: G001 Logging statement uses `str.format` + | +14 | from flask import current_app as app +15 | +16 | flask.current_app.logger.info("Hello {}".format("World!")) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 +17 | current_app.logger.info("Hello {}".format("World!")) +18 | app.logger.log(logging.INFO, "Hello {}".format("World!")) + | + +G001.py:17:25: G001 Logging statement uses `str.format` + | +16 | flask.current_app.logger.info("Hello {}".format("World!")) +17 | current_app.logger.info("Hello {}".format("World!")) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 +18 | app.logger.log(logging.INFO, "Hello {}".format("World!")) + | + +G001.py:18:30: G001 Logging statement uses `str.format` + | +16 | flask.current_app.logger.info("Hello {}".format("World!")) +17 | current_app.logger.info("Hello {}".format("World!")) +18 | app.logger.log(logging.INFO, "Hello {}".format("World!")) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ G001 + | + + 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 new file mode 100644 index 0000000000..ebe2ad3482 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G002.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs +--- +G002.py:3:14: G002 Logging statement uses `%` + | +1 | import logging +2 | +3 | logging.info("Hello %s" % "World!") + | ^^^^^^^^^^^^^^^^^^^^^ G002 +4 | logging.log(logging.INFO, "Hello %s" % "World!") + | + +G002.py:4:27: G002 Logging statement uses `%` + | +3 | logging.info("Hello %s" % "World!") +4 | logging.log(logging.INFO, "Hello %s" % "World!") + | ^^^^^^^^^^^^^^^^^^^^^ G002 + | + + 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 new file mode 100644 index 0000000000..873b9e74f9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G003.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs +--- +G003.py:3:14: G003 Logging statement uses `+` + | +1 | import logging +2 | +3 | logging.info("Hello" + " " + "World!") + | ^^^^^^^^^^^^^^^^^^^^^^^^ G003 +4 | logging.log(logging.INFO, "Hello" + " " + "World!") + | + +G003.py:4:27: G003 Logging statement uses `+` + | +3 | logging.info("Hello" + " " + "World!") +4 | logging.log(logging.INFO, "Hello" + " " + "World!") + | ^^^^^^^^^^^^^^^^^^^^^^^^ G003 + | + + 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 new file mode 100644 index 0000000000..a2d3ef00f8 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G004.py.snap @@ -0,0 +1,29 @@ +--- +source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs +--- +G004.py:4:14: G004 Logging statement uses f-string + | +3 | name = "world" +4 | logging.info(f"Hello {name}") + | ^^^^^^^^^^^^^^^ G004 +5 | logging.log(logging.INFO, f"Hello {name}") + | + +G004.py:5:27: G004 Logging statement uses f-string + | +3 | name = "world" +4 | logging.info(f"Hello {name}") +5 | logging.log(logging.INFO, f"Hello {name}") + | ^^^^^^^^^^^^^^^ G004 +6 | +7 | _LOGGER = logging.getLogger() + | + +G004.py:8:14: G004 Logging statement uses f-string + | +7 | _LOGGER = logging.getLogger() +8 | _LOGGER.info(f"{__name__}") + | ^^^^^^^^^^^^^ G004 + | + + 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 new file mode 100644 index 0000000000..f56206e88c --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G010.py.snap @@ -0,0 +1,61 @@ +--- +source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs +--- +G010.py:6:9: G010 [*] Logging statement uses `warn` instead of `warning` + | +4 | from logging_setup import logger +5 | +6 | logging.warn("Hello World!") + | ^^^^ G010 +7 | log.warn("Hello world!") # This shouldn't be considered as a logger candidate +8 | logger.warn("Hello world!") + | + = help: Convert to `warn` + +ℹ Fix +3 3 | +4 4 | from logging_setup import logger +5 5 | +6 |-logging.warn("Hello World!") + 6 |+logging.warning("Hello World!") +7 7 | log.warn("Hello world!") # This shouldn't be considered as a logger candidate +8 8 | logger.warn("Hello world!") +9 9 | + +G010.py:8:8: G010 [*] Logging statement uses `warn` instead of `warning` + | + 6 | logging.warn("Hello World!") + 7 | log.warn("Hello world!") # This shouldn't be considered as a logger candidate + 8 | logger.warn("Hello world!") + | ^^^^ G010 + 9 | +10 | logging . warn("Hello World!") + | + = help: Convert to `warn` + +ℹ Fix +5 5 | +6 6 | logging.warn("Hello World!") +7 7 | log.warn("Hello world!") # This shouldn't be considered as a logger candidate +8 |-logger.warn("Hello world!") + 8 |+logger.warning("Hello world!") +9 9 | +10 10 | logging . warn("Hello World!") + +G010.py:10:11: G010 [*] Logging statement uses `warn` instead of `warning` + | + 8 | logger.warn("Hello world!") + 9 | +10 | logging . warn("Hello World!") + | ^^^^ G010 + | + = help: Convert to `warn` + +ℹ Fix +7 7 | log.warn("Hello world!") # This shouldn't be considered as a logger candidate +8 8 | logger.warn("Hello world!") +9 9 | +10 |-logging . warn("Hello World!") + 10 |+logging . warning("Hello World!") + + diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G101_1.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G101_1.py.snap new file mode 100644 index 0000000000..d35d9f2bd4 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G101_1.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs +--- +G101_1.py:6:9: G101 Logging statement uses an `extra` field that clashes with a `LogRecord` field: `name` + | +4 | "Hello world!", +5 | extra={ +6 | "name": "foobar", + | ^^^^^^ G101 +7 | }, +8 | ) + | + + diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G101_2.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G101_2.py.snap new file mode 100644 index 0000000000..2ea3d56ded --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G101_2.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs +--- +G101_2.py:6:9: G101 Logging statement uses an `extra` field that clashes with a `LogRecord` field: `name` + | +4 | "Hello world!", +5 | extra=dict( +6 | name="foobar", + | ^^^^^^^^^^^^^ G101 +7 | ), +8 | ) + | + + 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 new file mode 100644 index 0000000000..a4cbafa5d2 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G201.py.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs +--- +G201.py:8:13: G201 Logging `.exception(...)` should be used instead of `.error(..., exc_info=True)` + | + 6 | pass + 7 | except: + 8 | logging.error("Hello World", exc_info=True) + | ^^^^^ G201 + 9 | +10 | try: + | + +G201.py:13:13: G201 Logging `.exception(...)` should be used instead of `.error(..., exc_info=True)` + | +11 | pass +12 | except: +13 | logging.error("Hello World", exc_info=sys.exc_info()) + | ^^^^^ G201 +14 | +15 | # 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 new file mode 100644 index 0000000000..9fc9a87608 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G202.py.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs +--- +G202.py:8:38: G202 Logging statement has redundant `exc_info` + | + 6 | pass + 7 | except: + 8 | logging.exception("Hello World", exc_info=True) + | ^^^^^^^^^^^^^ G202 + 9 | +10 | try: + | + +G202.py:13:38: G202 Logging statement has redundant `exc_info` + | +11 | pass +12 | except: +13 | logging.exception("Hello World", exc_info=sys.exc_info()) + | ^^^^^^^^^^^^^^^^^^^^^^^ G202 +14 | +15 | # OK + | + + diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G_argparse_parser_error_ok.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G_argparse_parser_error_ok.py.snap new file mode 100644 index 0000000000..d8fca09633 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G_argparse_parser_error_ok.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G_extra_ok.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G_extra_ok.py.snap new file mode 100644 index 0000000000..d8fca09633 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G_extra_ok.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G_extra_str_format_ok.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G_extra_str_format_ok.py.snap new file mode 100644 index 0000000000..d8fca09633 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G_extra_str_format_ok.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G_simple_ok.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G_simple_ok.py.snap new file mode 100644 index 0000000000..d8fca09633 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G_simple_ok.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G_warnings_ok.py.snap b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G_warnings_ok.py.snap new file mode 100644 index 0000000000..d8fca09633 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_logging_format/snapshots/ruff_linter__rules__flake8_logging_format__tests__G_warnings_ok.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_logging_format/mod.rs +--- + diff --git a/crates/ruff/src/rules/flake8_logging_format/violations.rs b/crates/ruff_linter/src/rules/flake8_logging_format/violations.rs similarity index 100% rename from crates/ruff/src/rules/flake8_logging_format/violations.rs rename to crates/ruff_linter/src/rules/flake8_logging_format/violations.rs diff --git a/crates/ruff/src/rules/flake8_no_pep420/mod.rs b/crates/ruff_linter/src/rules/flake8_no_pep420/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_no_pep420/mod.rs rename to crates/ruff_linter/src/rules/flake8_no_pep420/mod.rs diff --git a/crates/ruff/src/rules/flake8_no_pep420/rules/implicit_namespace_package.rs b/crates/ruff_linter/src/rules/flake8_no_pep420/rules/implicit_namespace_package.rs similarity index 100% rename from crates/ruff/src/rules/flake8_no_pep420/rules/implicit_namespace_package.rs rename to crates/ruff_linter/src/rules/flake8_no_pep420/rules/implicit_namespace_package.rs diff --git a/crates/ruff/src/rules/flake8_no_pep420/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_no_pep420/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_no_pep420/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_no_pep420/rules/mod.rs diff --git a/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_fail_empty.snap b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_fail_empty.snap new file mode 100644 index 0000000000..1d73378623 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_fail_empty.snap @@ -0,0 +1,8 @@ +--- +source: crates/ruff_linter/src/rules/flake8_no_pep420/mod.rs +--- +example.py:1:1: INP001 File `./resources/test/fixtures/flake8_no_pep420/test_fail_empty/example.py` is part of an implicit namespace package. Add an `__init__.py`. + | + | + + diff --git a/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_fail_nonempty.snap b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_fail_nonempty.snap new file mode 100644 index 0000000000..4184e6b7a8 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_fail_nonempty.snap @@ -0,0 +1,10 @@ +--- +source: crates/ruff_linter/src/rules/flake8_no_pep420/mod.rs +--- +example.py:1:1: INP001 File `./resources/test/fixtures/flake8_no_pep420/test_fail_nonempty/example.py` is part of an implicit namespace package. Add an `__init__.py`. + | +1 | print('hi') + | INP001 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_fail_shebang.snap b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_fail_shebang.snap new file mode 100644 index 0000000000..8d8d47554f --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_fail_shebang.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/flake8_no_pep420/mod.rs +--- +example.py:1:1: INP001 File `./resources/test/fixtures/flake8_no_pep420/test_fail_shebang/example.py` is part of an implicit namespace package. Add an `__init__.py`. + | +1 | #!/bin/env/python + | INP001 +2 | print('hi') + | + + diff --git a/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_ignored.snap b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_ignored.snap new file mode 100644 index 0000000000..624dce3225 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_ignored.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_no_pep420/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_pass_init.snap b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_pass_init.snap new file mode 100644 index 0000000000..624dce3225 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_pass_init.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_no_pep420/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_pass_namespace_package.snap b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_pass_namespace_package.snap new file mode 100644 index 0000000000..624dce3225 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_pass_namespace_package.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_no_pep420/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_pass_pyi.snap b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_pass_pyi.snap new file mode 100644 index 0000000000..624dce3225 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_pass_pyi.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_no_pep420/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_pass_script.snap b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_pass_script.snap new file mode 100644 index 0000000000..624dce3225 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_no_pep420/snapshots/ruff_linter__rules__flake8_no_pep420__tests__test_pass_script.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_no_pep420/mod.rs +--- + diff --git a/crates/ruff/src/rules/flake8_pie/mod.rs b/crates/ruff_linter/src/rules/flake8_pie/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pie/mod.rs rename to crates/ruff_linter/src/rules/flake8_pie/mod.rs diff --git a/crates/ruff/src/rules/flake8_pie/rules/duplicate_class_field_definition.rs b/crates/ruff_linter/src/rules/flake8_pie/rules/duplicate_class_field_definition.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pie/rules/duplicate_class_field_definition.rs rename to crates/ruff_linter/src/rules/flake8_pie/rules/duplicate_class_field_definition.rs diff --git a/crates/ruff/src/rules/flake8_pie/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_pie/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pie/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_pie/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_pie/rules/multiple_starts_ends_with.rs b/crates/ruff_linter/src/rules/flake8_pie/rules/multiple_starts_ends_with.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pie/rules/multiple_starts_ends_with.rs rename to crates/ruff_linter/src/rules/flake8_pie/rules/multiple_starts_ends_with.rs diff --git a/crates/ruff/src/rules/flake8_pie/rules/no_unnecessary_pass.rs b/crates/ruff_linter/src/rules/flake8_pie/rules/no_unnecessary_pass.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pie/rules/no_unnecessary_pass.rs rename to crates/ruff_linter/src/rules/flake8_pie/rules/no_unnecessary_pass.rs diff --git a/crates/ruff/src/rules/flake8_pie/rules/non_unique_enums.rs b/crates/ruff_linter/src/rules/flake8_pie/rules/non_unique_enums.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pie/rules/non_unique_enums.rs rename to crates/ruff_linter/src/rules/flake8_pie/rules/non_unique_enums.rs diff --git a/crates/ruff/src/rules/flake8_pie/rules/reimplemented_list_builtin.rs b/crates/ruff_linter/src/rules/flake8_pie/rules/reimplemented_list_builtin.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pie/rules/reimplemented_list_builtin.rs rename to crates/ruff_linter/src/rules/flake8_pie/rules/reimplemented_list_builtin.rs diff --git a/crates/ruff/src/rules/flake8_pie/rules/unnecessary_dict_kwargs.rs b/crates/ruff_linter/src/rules/flake8_pie/rules/unnecessary_dict_kwargs.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pie/rules/unnecessary_dict_kwargs.rs rename to crates/ruff_linter/src/rules/flake8_pie/rules/unnecessary_dict_kwargs.rs diff --git a/crates/ruff/src/rules/flake8_pie/rules/unnecessary_range_start.rs b/crates/ruff_linter/src/rules/flake8_pie/rules/unnecessary_range_start.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pie/rules/unnecessary_range_start.rs rename to crates/ruff_linter/src/rules/flake8_pie/rules/unnecessary_range_start.rs diff --git a/crates/ruff/src/rules/flake8_pie/rules/unnecessary_spread.rs b/crates/ruff_linter/src/rules/flake8_pie/rules/unnecessary_spread.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pie/rules/unnecessary_spread.rs rename to crates/ruff_linter/src/rules/flake8_pie/rules/unnecessary_spread.rs 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 new file mode 100644 index 0000000000..8a10e5db44 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE790_PIE790.py.snap @@ -0,0 +1,320 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pie/mod.rs +--- +PIE790.py:4:5: PIE790 [*] Unnecessary `pass` statement + | +2 | """buzz""" +3 | +4 | pass + | ^^^^ PIE790 + | + = help: Remove unnecessary `pass` + +ℹ Fix +1 1 | class Foo: +2 2 | """buzz""" +3 3 | +4 |- pass +5 4 | +6 5 | +7 6 | if foo: + +PIE790.py:9:5: PIE790 [*] Unnecessary `pass` statement + | +7 | if foo: +8 | """foo""" +9 | pass + | ^^^^ PIE790 + | + = help: Remove unnecessary `pass` + +ℹ Fix +6 6 | +7 7 | if foo: +8 8 | """foo""" +9 |- pass +10 9 | +11 10 | +12 11 | def multi_statement() -> None: + +PIE790.py:14:5: PIE790 [*] Unnecessary `pass` statement + | +12 | def multi_statement() -> None: +13 | """This is a function.""" +14 | pass; print("hello") + | ^^^^ PIE790 + | + = help: Remove unnecessary `pass` + +ℹ Fix +11 11 | +12 12 | def multi_statement() -> None: +13 13 | """This is a function.""" +14 |- pass; print("hello") + 14 |+ print("hello") +15 15 | +16 16 | +17 17 | if foo: + +PIE790.py:21:5: PIE790 [*] Unnecessary `pass` statement + | +19 | else: +20 | """bar""" +21 | pass + | ^^^^ PIE790 + | + = help: Remove unnecessary `pass` + +ℹ Fix +18 18 | pass +19 19 | else: +20 20 | """bar""" +21 |- pass +22 21 | +23 22 | +24 23 | while True: + +PIE790.py:28:5: PIE790 [*] Unnecessary `pass` statement + | +26 | else: +27 | """bar""" +28 | pass + | ^^^^ PIE790 + | + = help: Remove unnecessary `pass` + +ℹ Fix +25 25 | pass +26 26 | else: +27 27 | """bar""" +28 |- pass +29 28 | +30 29 | +31 30 | for _ in range(10): + +PIE790.py:35:5: PIE790 [*] Unnecessary `pass` statement + | +33 | else: +34 | """bar""" +35 | pass + | ^^^^ PIE790 + | + = help: Remove unnecessary `pass` + +ℹ Fix +32 32 | pass +33 33 | else: +34 34 | """bar""" +35 |- pass +36 35 | +37 36 | +38 37 | async for _ in range(10): + +PIE790.py:42:5: PIE790 [*] Unnecessary `pass` statement + | +40 | else: +41 | """bar""" +42 | pass + | ^^^^ PIE790 + | + = help: Remove unnecessary `pass` + +ℹ Fix +39 39 | pass +40 40 | else: +41 41 | """bar""" +42 |- pass +43 42 | +44 43 | +45 44 | def foo() -> None: + +PIE790.py:50:5: PIE790 [*] Unnecessary `pass` statement + | +48 | """ +49 | +50 | pass + | ^^^^ PIE790 + | + = help: Remove unnecessary `pass` + +ℹ Fix +47 47 | buzz +48 48 | """ +49 49 | +50 |- pass +51 50 | +52 51 | +53 52 | async def foo(): + +PIE790.py:58:5: PIE790 [*] Unnecessary `pass` statement + | +56 | """ +57 | +58 | pass + | ^^^^ PIE790 + | + = help: Remove unnecessary `pass` + +ℹ Fix +55 55 | buzz +56 56 | """ +57 57 | +58 |- pass +59 58 | +60 59 | +61 60 | try: + +PIE790.py:65:5: PIE790 [*] Unnecessary `pass` statement + | +63 | buzz +64 | """ +65 | pass + | ^^^^ PIE790 +66 | except ValueError: +67 | pass + | + = help: Remove unnecessary `pass` + +ℹ Fix +62 62 | """ +63 63 | buzz +64 64 | """ +65 |- pass +66 65 | except ValueError: +67 66 | pass +68 67 | + +PIE790.py:74:5: PIE790 [*] Unnecessary `pass` statement + | +72 | except ValueError: +73 | """bar""" +74 | pass + | ^^^^ PIE790 + | + = help: Remove unnecessary `pass` + +ℹ Fix +71 71 | bar() +72 72 | except ValueError: +73 73 | """bar""" +74 |- pass +75 74 | +76 75 | +77 76 | for _ in range(10): + +PIE790.py:79:5: PIE790 [*] Unnecessary `pass` statement + | +77 | for _ in range(10): +78 | """buzz""" +79 | pass + | ^^^^ PIE790 +80 | +81 | async for _ in range(10): + | + = help: Remove unnecessary `pass` + +ℹ Fix +76 76 | +77 77 | for _ in range(10): +78 78 | """buzz""" +79 |- pass +80 79 | +81 80 | async for _ in range(10): +82 81 | """buzz""" + +PIE790.py:83:5: PIE790 [*] Unnecessary `pass` statement + | +81 | async for _ in range(10): +82 | """buzz""" +83 | pass + | ^^^^ PIE790 +84 | +85 | while cond: + | + = help: Remove unnecessary `pass` + +ℹ Fix +80 80 | +81 81 | async for _ in range(10): +82 82 | """buzz""" +83 |- pass +84 83 | +85 84 | while cond: +86 85 | """buzz""" + +PIE790.py:87:5: PIE790 [*] Unnecessary `pass` statement + | +85 | while cond: +86 | """buzz""" +87 | pass + | ^^^^ PIE790 + | + = help: Remove unnecessary `pass` + +ℹ Fix +84 84 | +85 85 | while cond: +86 86 | """buzz""" +87 |- pass +88 87 | +89 88 | +90 89 | with bar: + +PIE790.py:92:5: PIE790 [*] Unnecessary `pass` statement + | +90 | with bar: +91 | """buzz""" +92 | pass + | ^^^^ PIE790 +93 | +94 | async with bar: + | + = help: Remove unnecessary `pass` + +ℹ Fix +89 89 | +90 90 | with bar: +91 91 | """buzz""" +92 |- pass +93 92 | +94 93 | async with bar: +95 94 | """buzz""" + +PIE790.py:96:5: PIE790 [*] Unnecessary `pass` statement + | +94 | async with bar: +95 | """buzz""" +96 | pass + | ^^^^ PIE790 + | + = help: Remove unnecessary `pass` + +ℹ Fix +93 93 | +94 94 | async with bar: +95 95 | """buzz""" +96 |- pass +97 96 | +98 97 | +99 98 | def foo() -> None: + +PIE790.py:101:5: PIE790 [*] Unnecessary `pass` statement + | + 99 | def foo() -> None: +100 | """buzz""" +101 | pass # bar + | ^^^^ PIE790 + | + = help: Remove unnecessary `pass` + +ℹ Fix +98 98 | +99 99 | def foo() -> None: +100 100 | """buzz""" +101 |- pass # bar + 101 |+ # bar +102 102 | +103 103 | +104 104 | class Foo: + + 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 new file mode 100644 index 0000000000..d67d3cfe87 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE794_PIE794.py.snap @@ -0,0 +1,77 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pie/mod.rs +--- +PIE794.py:4:5: PIE794 [*] Class field `name` is defined multiple times + | +2 | name = StringField() +3 | # .... +4 | name = StringField() # PIE794 + | ^^^^^^^^^^^^^^^^^^^^ PIE794 +5 | +6 | def remove(self) -> None: + | + = help: Remove duplicate field definition for `name` + +ℹ Suggested fix +1 1 | class Foo(BaseModel): +2 2 | name = StringField() +3 3 | # .... +4 |- name = StringField() # PIE794 +5 4 | +6 5 | def remove(self) -> None: +7 6 | ... + +PIE794.py:13:5: PIE794 [*] Class field `name` is defined multiple times + | +11 | name: str = StringField() +12 | # .... +13 | name = StringField() # PIE794 + | ^^^^^^^^^^^^^^^^^^^^ PIE794 +14 | +15 | def foo(self) -> None: + | + = help: Remove duplicate field definition for `name` + +ℹ Suggested fix +10 10 | class Foo(BaseModel): +11 11 | name: str = StringField() +12 12 | # .... +13 |- name = StringField() # PIE794 +14 13 | +15 14 | def foo(self) -> None: +16 15 | ... + +PIE794.py:23:5: PIE794 [*] Class field `bar` is defined multiple times + | +21 | foo: bool = BooleanField() +22 | # ... +23 | bar = StringField() # PIE794 + | ^^^^^^^^^^^^^^^^^^^ PIE794 + | + = help: Remove duplicate field definition for `bar` + +ℹ Suggested fix +20 20 | bar: str = StringField() +21 21 | foo: bool = BooleanField() +22 22 | # ... +23 |- bar = StringField() # PIE794 +24 23 | +25 24 | +26 25 | class User(BaseModel): + +PIE794.py:40:5: PIE794 [*] Class field `bar` is defined multiple times + | +38 | foo: bool = BooleanField() +39 | # ... +40 | bar = StringField() # PIE794 + | ^^^^^^^^^^^^^^^^^^^ PIE794 + | + = help: Remove duplicate field definition for `bar` + +ℹ Suggested fix +37 37 | bar: str = StringField() +38 38 | foo: bool = BooleanField() +39 39 | # ... +40 |- bar = StringField() # PIE794 + + diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE796_PIE796.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE796_PIE796.py.snap new file mode 100644 index 0000000000..df58500ba5 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE796_PIE796.py.snap @@ -0,0 +1,60 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pie/mod.rs +--- +PIE796.py:8:5: PIE796 Enum contains duplicate value: `"B"` + | +6 | A = "A" +7 | B = "B" +8 | C = "B" # PIE796 + | ^^^^^^^ PIE796 + | + +PIE796.py:14:5: PIE796 Enum contains duplicate value: `2` + | +12 | A = 1 +13 | B = 2 +14 | C = 2 # PIE796 + | ^^^^^ PIE796 + | + +PIE796.py:20:5: PIE796 Enum contains duplicate value: `"2"` + | +18 | A = "1" +19 | B = "2" +20 | C = "2" # PIE796 + | ^^^^^^^ PIE796 + | + +PIE796.py:26:5: PIE796 Enum contains duplicate value: `2.5` + | +24 | A = 1.0 +25 | B = 2.5 +26 | C = 2.5 # PIE796 + | ^^^^^^^ PIE796 + | + +PIE796.py:33:5: PIE796 Enum contains duplicate value: `False` + | +31 | B = True +32 | C = False +33 | D = False # PIE796 + | ^^^^^^^^^ PIE796 + | + +PIE796.py:40:5: PIE796 Enum contains duplicate value: `None` + | +38 | B = 2 +39 | C = None +40 | D = None # PIE796 + | ^^^^^^^^ PIE796 + | + +PIE796.py:54:5: PIE796 Enum contains duplicate value: `2` + | +52 | A = 1 +53 | B = 2 +54 | C = 2 # PIE796 + | ^^^^^ PIE796 + | + + 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 new file mode 100644 index 0000000000..16d06e62b7 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE800_PIE800.py.snap @@ -0,0 +1,42 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pie/mod.rs +--- +PIE800.py:1:14: PIE800 Unnecessary spread `**` + | +1 | {"foo": 1, **{"bar": 1}} # PIE800 + | ^^^^^^^^^^ PIE800 +2 | +3 | foo({**foo, **{"bar": True}}) # PIE800 + | + +PIE800.py:3:15: PIE800 Unnecessary spread `**` + | +1 | {"foo": 1, **{"bar": 1}} # PIE800 +2 | +3 | foo({**foo, **{"bar": True}}) # PIE800 + | ^^^^^^^^^^^^^ PIE800 +4 | +5 | {**foo, **{"bar": 10}} # PIE800 + | + +PIE800.py:5:11: PIE800 Unnecessary spread `**` + | +3 | foo({**foo, **{"bar": True}}) # PIE800 +4 | +5 | {**foo, **{"bar": 10}} # PIE800 + | ^^^^^^^^^^^ PIE800 +6 | +7 | {**foo, **buzz, **{bar: 10}} # PIE800 + | + +PIE800.py:7:19: PIE800 Unnecessary spread `**` + | +5 | {**foo, **{"bar": 10}} # PIE800 +6 | +7 | {**foo, **buzz, **{bar: 10}} # PIE800 + | ^^^^^^^^^ PIE800 +8 | +9 | {**foo, "bar": True } # OK + | + + 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 new file mode 100644 index 0000000000..7f7b0c9521 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE804_PIE804.py.snap @@ -0,0 +1,50 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pie/mod.rs +--- +PIE804.py:1:1: PIE804 Unnecessary `dict` kwargs + | +1 | foo(**{"bar": True}) # PIE804 + | ^^^^^^^^^^^^^^^^^^^^ PIE804 +2 | +3 | foo(**{"r2d2": True}) # PIE804 + | + +PIE804.py:3:1: PIE804 Unnecessary `dict` kwargs + | +1 | foo(**{"bar": True}) # PIE804 +2 | +3 | foo(**{"r2d2": True}) # PIE804 + | ^^^^^^^^^^^^^^^^^^^^^ PIE804 +4 | +5 | Foo.objects.create(**{"bar": True}) # PIE804 + | + +PIE804.py:5:1: PIE804 Unnecessary `dict` kwargs + | +3 | foo(**{"r2d2": True}) # PIE804 +4 | +5 | Foo.objects.create(**{"bar": True}) # PIE804 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE804 +6 | +7 | Foo.objects.create(**{"_id": some_id}) # PIE804 + | + +PIE804.py:7:1: PIE804 Unnecessary `dict` kwargs + | +5 | Foo.objects.create(**{"bar": True}) # PIE804 +6 | +7 | Foo.objects.create(**{"_id": some_id}) # PIE804 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE804 +8 | +9 | Foo.objects.create(**{**bar}) # PIE804 + | + +PIE804.py:9:1: PIE804 Unnecessary `dict` kwargs + | +7 | Foo.objects.create(**{"_id": some_id}) # PIE804 +8 | +9 | Foo.objects.create(**{**bar}) # PIE804 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE804 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE807_PIE807.py.snap b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE807_PIE807.py.snap new file mode 100644 index 0000000000..bf3189dc42 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE807_PIE807.py.snap @@ -0,0 +1,58 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pie/mod.rs +--- +PIE807.py:3:44: PIE807 [*] Prefer `list` over useless lambda + | +1 | @dataclass +2 | class Foo: +3 | foo: List[str] = field(default_factory=lambda: []) # PIE807 + | ^^^^^^^^^^ PIE807 + | + = help: Replace with `list` + +ℹ Fix +1 1 | @dataclass +2 2 | class Foo: +3 |- foo: List[str] = field(default_factory=lambda: []) # PIE807 + 3 |+ foo: List[str] = field(default_factory=list) # PIE807 +4 4 | +5 5 | +6 6 | class FooTable(BaseTable): + +PIE807.py:7:36: PIE807 [*] Prefer `list` over useless lambda + | +6 | class FooTable(BaseTable): +7 | bar = fields.ListField(default=lambda: []) # PIE807 + | ^^^^^^^^^^ PIE807 + | + = help: Replace with `list` + +ℹ Fix +4 4 | +5 5 | +6 6 | class FooTable(BaseTable): +7 |- bar = fields.ListField(default=lambda: []) # PIE807 + 7 |+ bar = fields.ListField(default=list) # PIE807 +8 8 | +9 9 | +10 10 | class FooTable(BaseTable): + +PIE807.py:11:28: PIE807 [*] Prefer `list` over useless lambda + | +10 | class FooTable(BaseTable): +11 | bar = fields.ListField(lambda: []) # PIE807 + | ^^^^^^^^^^ PIE807 + | + = help: Replace with `list` + +ℹ Fix +8 8 | +9 9 | +10 10 | class FooTable(BaseTable): +11 |- bar = fields.ListField(lambda: []) # PIE807 + 11 |+ bar = fields.ListField(list) # PIE807 +12 12 | +13 13 | +14 14 | @dataclass + + 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 new file mode 100644 index 0000000000..8205dd7ac7 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE808_PIE808.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pie/mod.rs +--- +PIE808.py:2:7: PIE808 [*] Unnecessary `start` argument in `range` + | +1 | # PIE808 +2 | range(0, 10) + | ^ PIE808 +3 | +4 | # OK + | + = help: Remove `start` argument + +ℹ Fix +1 1 | # PIE808 +2 |-range(0, 10) + 2 |+range(10) +3 3 | +4 4 | # OK +5 5 | range(x, 10) + + 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 new file mode 100644 index 0000000000..a889297249 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pie/snapshots/ruff_linter__rules__flake8_pie__tests__PIE810_PIE810.py.snap @@ -0,0 +1,106 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pie/mod.rs +--- +PIE810.py:2:1: PIE810 [*] Call `startswith` once with a `tuple` + | +1 | # error +2 | obj.startswith("foo") or obj.startswith("bar") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 +3 | # error +4 | obj.endswith("foo") or obj.endswith("bar") + | + = help: Merge into a single `startswith` call + +ℹ Suggested fix +1 1 | # error +2 |-obj.startswith("foo") or obj.startswith("bar") + 2 |+obj.startswith(("foo", "bar")) +3 3 | # error +4 4 | obj.endswith("foo") or obj.endswith("bar") +5 5 | # error + +PIE810.py:4:1: PIE810 [*] Call `endswith` once with a `tuple` + | +2 | obj.startswith("foo") or obj.startswith("bar") +3 | # error +4 | obj.endswith("foo") or obj.endswith("bar") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 +5 | # error +6 | obj.startswith(foo) or obj.startswith(bar) + | + = help: Merge into a single `endswith` call + +ℹ Suggested fix +1 1 | # error +2 2 | obj.startswith("foo") or obj.startswith("bar") +3 3 | # error +4 |-obj.endswith("foo") or obj.endswith("bar") + 4 |+obj.endswith(("foo", "bar")) +5 5 | # error +6 6 | obj.startswith(foo) or obj.startswith(bar) +7 7 | # error + +PIE810.py:6:1: PIE810 [*] Call `startswith` once with a `tuple` + | +4 | obj.endswith("foo") or obj.endswith("bar") +5 | # error +6 | obj.startswith(foo) or obj.startswith(bar) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 +7 | # error +8 | obj.startswith(foo) or obj.startswith("foo") + | + = help: Merge into a single `startswith` call + +ℹ Suggested fix +3 3 | # error +4 4 | obj.endswith("foo") or obj.endswith("bar") +5 5 | # error +6 |-obj.startswith(foo) or obj.startswith(bar) + 6 |+obj.startswith((foo, bar)) +7 7 | # error +8 8 | obj.startswith(foo) or obj.startswith("foo") +9 9 | # error + +PIE810.py:8:1: PIE810 [*] Call `startswith` once with a `tuple` + | + 6 | obj.startswith(foo) or obj.startswith(bar) + 7 | # error + 8 | obj.startswith(foo) or obj.startswith("foo") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 + 9 | # error +10 | obj.endswith(foo) or obj.startswith(foo) or obj.startswith("foo") + | + = help: Merge into a single `startswith` call + +ℹ Suggested fix +5 5 | # error +6 6 | obj.startswith(foo) or obj.startswith(bar) +7 7 | # error +8 |-obj.startswith(foo) or obj.startswith("foo") + 8 |+obj.startswith((foo, "foo")) +9 9 | # error +10 10 | obj.endswith(foo) or obj.startswith(foo) or obj.startswith("foo") +11 11 | + +PIE810.py:10:1: PIE810 [*] Call `startswith` once with a `tuple` + | + 8 | obj.startswith(foo) or obj.startswith("foo") + 9 | # error +10 | obj.endswith(foo) or obj.startswith(foo) or obj.startswith("foo") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PIE810 +11 | +12 | # ok + | + = help: Merge into a single `startswith` call + +ℹ Suggested fix +7 7 | # error +8 8 | obj.startswith(foo) or obj.startswith("foo") +9 9 | # error +10 |-obj.endswith(foo) or obj.startswith(foo) or obj.startswith("foo") + 10 |+obj.endswith(foo) or obj.startswith((foo, "foo")) +11 11 | +12 12 | # ok +13 13 | obj.startswith(("foo", "bar")) + + diff --git a/crates/ruff/src/rules/flake8_print/mod.rs b/crates/ruff_linter/src/rules/flake8_print/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_print/mod.rs rename to crates/ruff_linter/src/rules/flake8_print/mod.rs diff --git a/crates/ruff/src/rules/flake8_print/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_print/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_print/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_print/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_print/rules/print_call.rs b/crates/ruff_linter/src/rules/flake8_print/rules/print_call.rs similarity index 100% rename from crates/ruff/src/rules/flake8_print/rules/print_call.rs rename to crates/ruff_linter/src/rules/flake8_print/rules/print_call.rs 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 new file mode 100644 index 0000000000..97fb0c0676 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T201_T201.py.snap @@ -0,0 +1,42 @@ +--- +source: crates/ruff_linter/src/rules/flake8_print/mod.rs +--- +T201.py:4:1: T201 `print` found + | +2 | import tempfile +3 | +4 | print("Hello, world!") # T201 + | ^^^^^ T201 +5 | print("Hello, world!", file=None) # T201 +6 | print("Hello, world!", file=sys.stdout) # T201 + | + +T201.py:5:1: T201 `print` found + | +4 | print("Hello, world!") # T201 +5 | print("Hello, world!", file=None) # T201 + | ^^^^^ T201 +6 | print("Hello, world!", file=sys.stdout) # T201 +7 | print("Hello, world!", file=sys.stderr) # T201 + | + +T201.py:6:1: T201 `print` found + | +4 | print("Hello, world!") # T201 +5 | print("Hello, world!", file=None) # T201 +6 | print("Hello, world!", file=sys.stdout) # T201 + | ^^^^^ T201 +7 | print("Hello, world!", file=sys.stderr) # T201 + | + +T201.py:7:1: T201 `print` found + | +5 | print("Hello, world!", file=None) # T201 +6 | print("Hello, world!", file=sys.stdout) # T201 +7 | print("Hello, world!", file=sys.stderr) # T201 + | ^^^^^ T201 +8 | +9 | with tempfile.NamedTemporaryFile() as fp: + | + + 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 new file mode 100644 index 0000000000..1fe8d2ea41 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_print/snapshots/ruff_linter__rules__flake8_print__tests__T203_T203.py.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/flake8_print/mod.rs +--- +T203.py:3:1: T203 `pprint` found + | +1 | from pprint import pprint +2 | +3 | pprint("Hello, world!") # T203 + | ^^^^^^ T203 +4 | +5 | import pprint + | + +T203.py:7:1: T203 `pprint` found + | +5 | import pprint +6 | +7 | pprint.pprint("Hello, world!") # T203 + | ^^^^^^^^^^^^^ T203 +8 | +9 | pprint.pformat("Hello, world!") + | + + diff --git a/crates/ruff/src/rules/flake8_pyi/helpers.rs b/crates/ruff_linter/src/rules/flake8_pyi/helpers.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/helpers.rs rename to crates/ruff_linter/src/rules/flake8_pyi/helpers.rs diff --git a/crates/ruff/src/rules/flake8_pyi/mod.rs b/crates/ruff_linter/src/rules/flake8_pyi/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/mod.rs rename to crates/ruff_linter/src/rules/flake8_pyi/mod.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/any_eq_ne_annotation.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/any_eq_ne_annotation.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/any_eq_ne_annotation.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/any_eq_ne_annotation.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/bad_version_info_comparison.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/bad_version_info_comparison.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/bad_version_info_comparison.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/bad_version_info_comparison.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/collections_named_tuple.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/collections_named_tuple.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/collections_named_tuple.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/collections_named_tuple.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/complex_assignment_in_stub.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/complex_assignment_in_stub.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/complex_assignment_in_stub.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/complex_assignment_in_stub.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/complex_if_statement_in_stub.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/complex_if_statement_in_stub.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/complex_if_statement_in_stub.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/complex_if_statement_in_stub.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/docstring_in_stubs.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/docstring_in_stubs.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/docstring_in_stubs.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/docstring_in_stubs.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/duplicate_union_member.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_union_member.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/duplicate_union_member.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_union_member.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/ellipsis_in_non_empty_class_body.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/ellipsis_in_non_empty_class_body.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/ellipsis_in_non_empty_class_body.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/ellipsis_in_non_empty_class_body.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/exit_annotations.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/exit_annotations.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/exit_annotations.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/exit_annotations.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/future_annotations_in_stub.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/future_annotations_in_stub.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/future_annotations_in_stub.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/future_annotations_in_stub.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/iter_method_return_iterable.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/iter_method_return_iterable.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/iter_method_return_iterable.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/iter_method_return_iterable.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/no_return_argument_annotation.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/no_return_argument_annotation.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/no_return_argument_annotation.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/no_return_argument_annotation.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/non_empty_stub_body.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/non_empty_stub_body.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/non_empty_stub_body.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/non_empty_stub_body.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/non_self_return_type.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/non_self_return_type.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/non_self_return_type.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/non_self_return_type.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/numeric_literal_too_long.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/numeric_literal_too_long.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/numeric_literal_too_long.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/numeric_literal_too_long.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/pass_in_class_body.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/pass_in_class_body.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/pass_in_class_body.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/pass_in_class_body.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/pass_statement_stub_body.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/pass_statement_stub_body.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/pass_statement_stub_body.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/pass_statement_stub_body.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/prefix_type_params.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/prefix_type_params.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/prefix_type_params.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/prefix_type_params.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/quoted_annotation_in_stub.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/quoted_annotation_in_stub.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/quoted_annotation_in_stub.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/quoted_annotation_in_stub.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/redundant_literal_union.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_literal_union.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/redundant_literal_union.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_literal_union.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/redundant_numeric_union.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_numeric_union.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/redundant_numeric_union.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_numeric_union.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/simple_defaults.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/simple_defaults.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/str_or_repr_defined_in_stub.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/str_or_repr_defined_in_stub.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/str_or_repr_defined_in_stub.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/str_or_repr_defined_in_stub.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/string_or_bytes_too_long.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/string_or_bytes_too_long.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/string_or_bytes_too_long.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/string_or_bytes_too_long.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/stub_body_multiple_statements.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/stub_body_multiple_statements.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/stub_body_multiple_statements.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/stub_body_multiple_statements.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/type_alias_naming.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/type_alias_naming.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/type_alias_naming.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/type_alias_naming.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/type_comment_in_stub.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/type_comment_in_stub.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/type_comment_in_stub.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/type_comment_in_stub.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/unaliased_collections_abc_set_import.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/unaliased_collections_abc_set_import.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/unaliased_collections_abc_set_import.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/unaliased_collections_abc_set_import.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/unnecessary_literal_union.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/unnecessary_literal_union.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/unnecessary_literal_union.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/unnecessary_literal_union.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/unnecessary_type_union.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/unnecessary_type_union.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/unnecessary_type_union.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/unnecessary_type_union.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/unrecognized_platform.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/unrecognized_platform.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/unrecognized_platform.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/unrecognized_platform.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/unrecognized_version_info.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/unrecognized_version_info.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/unrecognized_version_info.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/unrecognized_version_info.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/unsupported_method_call_on_all.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/unsupported_method_call_on_all.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/unsupported_method_call_on_all.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/unsupported_method_call_on_all.rs diff --git a/crates/ruff/src/rules/flake8_pyi/rules/unused_private_type_definition.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/unused_private_type_definition.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pyi/rules/unused_private_type_definition.rs rename to crates/ruff_linter/src/rules/flake8_pyi/rules/unused_private_type_definition.rs diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI001_PYI001.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI001_PYI001.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI001_PYI001.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..507a18c3ea --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI001_PYI001.pyi.snap @@ -0,0 +1,34 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI001.pyi:3:5: PYI001 Name of private `TypeVar` must start with `_` + | +1 | from typing import ParamSpec, TypeVar, TypeVarTuple +2 | +3 | T = TypeVar("T") # Error: TypeVars in stubs must start with _ + | ^^^^^^^^^^^^ PYI001 +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 | +5 | TTuple = TypeVarTuple("TTuple") # Error: TypeVarTuples must also start with _ + | ^^^^^^^^^^^^^^^^^^^^^^ PYI001 +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 | +7 | P = ParamSpec("P") # Error: ParamSpecs must start with _ + | ^^^^^^^^^^^^^^ PYI001 +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.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI002_PYI002.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI002_PYI002.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..06c726dff4 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI002_PYI002.pyi.snap @@ -0,0 +1,40 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI002.pyi:3:4: PYI002 `if` test must be a simple comparison against `sys.platform` or `sys.version_info` + | +1 | import sys +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 +5 | if hasattr(sys, 'maxint'): ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info + | + +PYI002.pyi:4:4: PYI002 `if` test must be a simple comparison against `sys.platform` or `sys.version_info` + | +3 | if sys.version == 'Python 2.7.10': ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info +4 | if 'linux' == sys.platform: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info + | ^^^^^^^^^^^^^^^^^^^^^^^ PYI002 +5 | if hasattr(sys, 'maxint'): ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info +6 | if sys.maxsize == 42: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info + | + +PYI002.pyi:5:4: PYI002 `if` test must be a simple comparison against `sys.platform` or `sys.version_info` + | +3 | if sys.version == 'Python 2.7.10': ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info +4 | if 'linux' == sys.platform: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info +5 | if hasattr(sys, 'maxint'): ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info + | ^^^^^^^^^^^^^^^^^^^^^^ PYI002 +6 | if sys.maxsize == 42: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info + | + +PYI002.pyi:6:4: PYI002 `if` test must be a simple comparison against `sys.platform` or `sys.version_info` + | +4 | if 'linux' == sys.platform: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info +5 | if hasattr(sys, 'maxint'): ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info +6 | if sys.maxsize == 42: ... # Y002 If test must be a simple comparison against sys.platform or sys.version_info + | ^^^^^^^^^^^^^^^^^ PYI002 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI003_PYI003.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI003_PYI003.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI003_PYI003.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..192cfafc96 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI003_PYI003.pyi.snap @@ -0,0 +1,173 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +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:' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 + | + +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:' +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 +7 | if sys.version_info[0j] == 2: ... # Y003 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:' +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 +7 | if sys.version_info[0j] == 2: ... # Y003 Unrecognized sys.version_info check +8 | if sys.version_info[0] == (2, 7): ... # Y003 Unrecognized sys.version_info check + | + +PYI003.pyi:7:4: PYI003 Unrecognized `sys.version_info` check + | +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 +7 | if sys.version_info[0j] == 2: ... # Y003 Unrecognized sys.version_info check + | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 +8 | if sys.version_info[0] == (2, 7): ... # Y003 Unrecognized sys.version_info check +9 | if sys.version_info[0] == '2': ... # Y003 Unrecognized sys.version_info check + | + +PYI003.pyi:8:4: PYI003 Unrecognized `sys.version_info` check + | + 6 | if sys.version_info[False] == 2: ... # Y003 Unrecognized sys.version_info check + 7 | if sys.version_info[0j] == 2: ... # Y003 Unrecognized sys.version_info check + 8 | if sys.version_info[0] == (2, 7): ... # Y003 Unrecognized sys.version_info check + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 + 9 | if sys.version_info[0] == '2': ... # Y003 Unrecognized sys.version_info check +10 | if sys.version_info[1:] >= (7, 11): ... # Y003 Unrecognized sys.version_info check + | + +PYI003.pyi:9:4: PYI003 Unrecognized `sys.version_info` check + | + 7 | if sys.version_info[0j] == 2: ... # Y003 Unrecognized sys.version_info check + 8 | if sys.version_info[0] == (2, 7): ... # Y003 Unrecognized sys.version_info check + 9 | if sys.version_info[0] == '2': ... # Y003 Unrecognized sys.version_info check + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 +10 | if sys.version_info[1:] >= (7, 11): ... # Y003 Unrecognized sys.version_info check +11 | if sys.version_info[::-1] < (11, 7): ... # Y003 Unrecognized sys.version_info check + | + +PYI003.pyi:10:4: PYI003 Unrecognized `sys.version_info` check + | + 8 | if sys.version_info[0] == (2, 7): ... # Y003 Unrecognized sys.version_info check + 9 | if sys.version_info[0] == '2': ... # Y003 Unrecognized sys.version_info check +10 | if sys.version_info[1:] >= (7, 11): ... # Y003 Unrecognized sys.version_info check + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 +11 | if sys.version_info[::-1] < (11, 7): ... # Y003 Unrecognized sys.version_info check +12 | if sys.version_info[:3] >= (2, 7): ... # Y003 Unrecognized sys.version_info check + | + +PYI003.pyi:11:4: PYI003 Unrecognized `sys.version_info` check + | + 9 | if sys.version_info[0] == '2': ... # Y003 Unrecognized sys.version_info check +10 | if sys.version_info[1:] >= (7, 11): ... # Y003 Unrecognized sys.version_info check +11 | if sys.version_info[::-1] < (11, 7): ... # Y003 Unrecognized sys.version_info check + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 +12 | if sys.version_info[:3] >= (2, 7): ... # Y003 Unrecognized sys.version_info check +13 | if sys.version_info[:True] >= (2, 7): ... # Y003 Unrecognized sys.version_info check + | + +PYI003.pyi:12:4: PYI003 Unrecognized `sys.version_info` check + | +10 | if sys.version_info[1:] >= (7, 11): ... # Y003 Unrecognized sys.version_info check +11 | if sys.version_info[::-1] < (11, 7): ... # Y003 Unrecognized sys.version_info check +12 | if sys.version_info[:3] >= (2, 7): ... # Y003 Unrecognized sys.version_info check + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 +13 | if sys.version_info[:True] >= (2, 7): ... # Y003 Unrecognized sys.version_info check +14 | if sys.version_info[:1] == (2,): ... + | + +PYI003.pyi:13:4: PYI003 Unrecognized `sys.version_info` check + | +11 | if sys.version_info[::-1] < (11, 7): ... # Y003 Unrecognized sys.version_info check +12 | if sys.version_info[:3] >= (2, 7): ... # Y003 Unrecognized sys.version_info check +13 | if sys.version_info[:True] >= (2, 7): ... # Y003 Unrecognized sys.version_info check + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 +14 | if sys.version_info[:1] == (2,): ... +15 | if sys.version_info[:1] == (True,): ... # Y003 Unrecognized sys.version_info check + | + +PYI003.pyi:15:4: PYI003 Unrecognized `sys.version_info` check + | +13 | if sys.version_info[:True] >= (2, 7): ... # Y003 Unrecognized sys.version_info check +14 | if sys.version_info[:1] == (2,): ... +15 | if sys.version_info[:1] == (True,): ... # Y003 Unrecognized sys.version_info check + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 +16 | if sys.version_info[:1] == (2, 7): ... # Y005 Version comparison must be against a length-1 tuple +17 | if sys.version_info[:2] == (2, 7): ... + | + +PYI003.pyi:19:4: PYI003 Unrecognized `sys.version_info` check + | +17 | if sys.version_info[:2] == (2, 7): ... +18 | if sys.version_info[:2] == (2,): ... # Y005 Version comparison must be against a length-2 tuple +19 | if sys.version_info[:2] == "lol": ... # Y003 Unrecognized sys.version_info check + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 +20 | if sys.version_info[:2.0] >= (3, 9): ... # Y003 Unrecognized sys.version_info check +21 | if sys.version_info[:2j] >= (3, 9): ... # Y003 Unrecognized sys.version_info check + | + +PYI003.pyi:20:4: PYI003 Unrecognized `sys.version_info` check + | +18 | if sys.version_info[:2] == (2,): ... # Y005 Version comparison must be against a length-2 tuple +19 | if sys.version_info[:2] == "lol": ... # Y003 Unrecognized sys.version_info check +20 | if sys.version_info[:2.0] >= (3, 9): ... # Y003 Unrecognized sys.version_info check + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 +21 | if sys.version_info[:2j] >= (3, 9): ... # Y003 Unrecognized sys.version_info check +22 | if sys.version_info[:, :] >= (2, 7): ... # Y003 Unrecognized sys.version_info check + | + +PYI003.pyi:21:4: PYI003 Unrecognized `sys.version_info` check + | +19 | if sys.version_info[:2] == "lol": ... # Y003 Unrecognized sys.version_info check +20 | if sys.version_info[:2.0] >= (3, 9): ... # Y003 Unrecognized sys.version_info check +21 | if sys.version_info[:2j] >= (3, 9): ... # Y003 Unrecognized sys.version_info check + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 +22 | if sys.version_info[:, :] >= (2, 7): ... # Y003 Unrecognized sys.version_info check +23 | if sys.version_info < [3, 0]: ... # Y003 Unrecognized sys.version_info check + | + +PYI003.pyi:22:4: PYI003 Unrecognized `sys.version_info` check + | +20 | if sys.version_info[:2.0] >= (3, 9): ... # Y003 Unrecognized sys.version_info check +21 | if sys.version_info[:2j] >= (3, 9): ... # Y003 Unrecognized sys.version_info check +22 | if sys.version_info[:, :] >= (2, 7): ... # Y003 Unrecognized sys.version_info check + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 +23 | if sys.version_info < [3, 0]: ... # Y003 Unrecognized sys.version_info check +24 | if sys.version_info < ('3', '0'): ... # Y003 Unrecognized sys.version_info check + | + +PYI003.pyi:23:4: PYI003 Unrecognized `sys.version_info` check + | +21 | if sys.version_info[:2j] >= (3, 9): ... # Y003 Unrecognized sys.version_info check +22 | if sys.version_info[:, :] >= (2, 7): ... # Y003 Unrecognized sys.version_info check +23 | if sys.version_info < [3, 0]: ... # Y003 Unrecognized sys.version_info check + | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 +24 | if sys.version_info < ('3', '0'): ... # Y003 Unrecognized sys.version_info check +25 | if sys.version_info >= (3, 4, 3): ... # Y004 Version comparison must use only major and minor version + | + +PYI003.pyi:24:4: PYI003 Unrecognized `sys.version_info` check + | +22 | if sys.version_info[:, :] >= (2, 7): ... # Y003 Unrecognized sys.version_info check +23 | if sys.version_info < [3, 0]: ... # Y003 Unrecognized sys.version_info check +24 | if sys.version_info < ('3', '0'): ... # Y003 Unrecognized sys.version_info check + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI003 +25 | if sys.version_info >= (3, 4, 3): ... # Y004 Version comparison must use only major and minor version +26 | if sys.version_info == (3, 4): ... # Y006 Use only < and >= for version comparisons + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI004_PYI004.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI004_PYI004.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI004_PYI004.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..8be6ef6e1b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI004_PYI004.pyi.snap @@ -0,0 +1,42 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI004.pyi:4:4: PYI004 Version comparison must use only major and minor version + | +2 | from sys import version_info +3 | +4 | if sys.version_info >= (3, 4, 3): ... # PYI004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI004 +5 | if sys.version_info < (3, 4, 3): ... # PYI004 +6 | if sys.version_info == (3, 4, 3): ... # PYI004 + | + +PYI004.pyi:5:4: PYI004 Version comparison must use only major and minor version + | +4 | if sys.version_info >= (3, 4, 3): ... # PYI004 +5 | if sys.version_info < (3, 4, 3): ... # PYI004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI004 +6 | if sys.version_info == (3, 4, 3): ... # PYI004 +7 | if sys.version_info != (3, 4, 3): ... # PYI004 + | + +PYI004.pyi:6:4: PYI004 Version comparison must use only major and minor version + | +4 | if sys.version_info >= (3, 4, 3): ... # PYI004 +5 | if sys.version_info < (3, 4, 3): ... # PYI004 +6 | if sys.version_info == (3, 4, 3): ... # PYI004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI004 +7 | if sys.version_info != (3, 4, 3): ... # PYI004 + | + +PYI004.pyi:7:4: PYI004 Version comparison must use only major and minor version + | +5 | if sys.version_info < (3, 4, 3): ... # PYI004 +6 | if sys.version_info == (3, 4, 3): ... # PYI004 +7 | if sys.version_info != (3, 4, 3): ... # PYI004 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI004 +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.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI005_PYI005.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI005_PYI005.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..45c52d42c3 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI005_PYI005.pyi.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI005.pyi:4:4: PYI005 Version comparison must be against a length-1 tuple + | +2 | from sys import platform, version_info +3 | +4 | if sys.version_info[:1] == (2, 7): ... # Y005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI005 +5 | if sys.version_info[:2] == (2,): ... # Y005 + | + +PYI005.pyi:5:4: PYI005 Version comparison must be against a length-2 tuple + | +4 | if sys.version_info[:1] == (2, 7): ... # Y005 +5 | if sys.version_info[:2] == (2,): ... # Y005 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI005 + | + + 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 new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI006_PYI006.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..b928d5d4ad --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI006_PYI006.pyi.snap @@ -0,0 +1,62 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI006.pyi:8:4: PYI006 Use `<` or `>=` for `sys.version_info` comparisons + | + 6 | if sys.version_info >= (3, 9): ... # OK + 7 | + 8 | if sys.version_info == (3, 9): ... # OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 + 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 | +10 | if sys.version_info == (3, 9): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 +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 | +12 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 +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 | +14 | if sys.version_info <= (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 +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 | +16 | if sys.version_info > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 +17 | +18 | if python_version > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons + | + +PYI006.pyi:18:4: 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 | +18 | if python_version > (3, 10): ... # Error: PYI006 Use only `<` and `>=` for version info comparisons + | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI006 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI007_PYI007.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI007_PYI007.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI007_PYI007.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..91457d5fc0 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI007_PYI007.pyi.snap @@ -0,0 +1,32 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI007.pyi:7:4: PYI007 Unrecognized `sys.platform` check + | +5 | if sys.platform != "platform_name_2": ... # OK +6 | +7 | if sys.platform in ["linux"]: ... # Error: PYI007 Unrecognized sys.platform check + | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI007 +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 | + 9 | if sys.platform > 3: ... # Error: PYI007 Unrecognized sys.platform check + | ^^^^^^^^^^^^^^^^ PYI007 +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 | +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.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI008_PYI008.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI008_PYI008.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..43550f78a4 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI008_PYI008.pyi.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI008.pyi:3:20: PYI008 Unrecognized platform `linus` + | +1 | import sys +2 | +3 | if sys.platform == "linus": ... # Error: PYI008 Unrecognized platform `linus` + | ^^^^^^^ PYI008 +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.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI009_PYI009.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI009_PYI009.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..11e17ab3ca --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI009_PYI009.pyi.snap @@ -0,0 +1,39 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI009.pyi:3:5: PYI009 [*] Empty body should contain `...`, not `pass` + | +1 | def bar(): ... # OK +2 | def foo(): +3 | pass # ERROR PYI009, since we're in a stub file + | ^^^^ PYI009 +4 | +5 | class Bar: ... # OK + | + = help: Replace `pass` with `...` + +ℹ Fix +1 1 | def bar(): ... # OK +2 2 | def foo(): +3 |- pass # ERROR PYI009, since we're in a stub file + 3 |+ ... # ERROR PYI009, since we're in a stub file +4 4 | +5 5 | class Bar: ... # OK +6 6 | + +PYI009.pyi:8:5: PYI009 [*] Empty body should contain `...`, not `pass` + | +7 | class Foo: +8 | pass # ERROR PYI009, since we're in a stub file + | ^^^^ PYI009 + | + = help: Replace `pass` with `...` + +ℹ Fix +5 5 | class Bar: ... # OK +6 6 | +7 7 | class Foo: +8 |- pass # ERROR PYI009, since we're in a stub file + 8 |+ ... # ERROR PYI009, since we're in a stub file + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI010_PYI010.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI010_PYI010.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI010_PYI010.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..b68bdf828c --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI010_PYI010.pyi.snap @@ -0,0 +1,64 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI010.pyi:6:5: PYI010 [*] Function body must contain only `...` + | +5 | def buzz(): +6 | print("buzz") # ERROR PYI010 + | ^^^^^^^^^^^^^ PYI010 +7 | +8 | def foo2(): + | + = help: Replace function body with `...` + +ℹ Suggested fix +3 3 | """foo""" # OK, docstrings are handled by another rule +4 4 | +5 5 | def buzz(): +6 |- print("buzz") # ERROR PYI010 + 6 |+ ... # ERROR PYI010 +7 7 | +8 8 | def foo2(): +9 9 | 123 # ERROR PYI010 + +PYI010.pyi:9:5: PYI010 [*] Function body must contain only `...` + | + 8 | def foo2(): + 9 | 123 # ERROR PYI010 + | ^^^ PYI010 +10 | +11 | def bizz(): + | + = help: Replace function body with `...` + +ℹ Suggested fix +6 6 | print("buzz") # ERROR PYI010 +7 7 | +8 8 | def foo2(): +9 |- 123 # ERROR PYI010 + 9 |+ ... # ERROR PYI010 +10 10 | +11 11 | def bizz(): +12 12 | x = 123 # ERROR PYI010 + +PYI010.pyi:12:5: PYI010 [*] Function body must contain only `...` + | +11 | def bizz(): +12 | x = 123 # ERROR PYI010 + | ^^^^^^^ PYI010 +13 | +14 | def foo3(): + | + = help: Replace function body with `...` + +ℹ Suggested fix +9 9 | 123 # ERROR PYI010 +10 10 | +11 11 | def bizz(): +12 |- x = 123 # ERROR PYI010 + 12 |+ ... # ERROR PYI010 +13 13 | +14 14 | def foo3(): +15 15 | pass # OK, pass is handled by another rule + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI011_PYI011.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI011_PYI011.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI011_PYI011.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI011_PYI011.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI011_PYI011.pyi.snap new file mode 100644 index 0000000000..b883a369b2 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI011_PYI011.pyi.snap @@ -0,0 +1,457 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI011.pyi:10:14: PYI011 [*] Only simple default values allowed for typed arguments + | + 8 | def f12( + 9 | x, +10 | y: str = os.pathsep, # Error PYI011 Only simple default values allowed for typed arguments + | ^^^^^^^^^^ PYI011 +11 | ) -> None: ... +12 | def f11(*, x: str = "x") -> None: ... # OK + | + = help: Replace default value with `...` + +ℹ Suggested fix +7 7 | +8 8 | def f12( +9 9 | x, +10 |- y: str = os.pathsep, # Error PYI011 Only simple default values allowed for typed arguments + 10 |+ y: str = ..., # Error PYI011 Only simple default values allowed for typed arguments +11 11 | ) -> None: ... +12 12 | def f11(*, x: str = "x") -> None: ... # OK +13 13 | def f13( + +PYI011.pyi:38:9: PYI011 [*] Only simple default values allowed for typed arguments + | +36 | x: dict[ +37 | int, int +38 | ] = { # Error PYI011 Only simple default values allowed for typed arguments + | _________^ +39 | | 1: 2, +40 | | **{3: 4}, +41 | | } + | |_____^ PYI011 +42 | ) -> None: ... +43 | def f153( + | + = help: Replace default value with `...` + +ℹ Suggested fix +35 35 | def f152( +36 36 | x: dict[ +37 37 | int, int +38 |- ] = { # Error PYI011 Only simple default values allowed for typed arguments +39 |- 1: 2, +40 |- **{3: 4}, +41 |- } + 38 |+ ] = ... +42 39 | ) -> None: ... +43 40 | def f153( +44 41 | x: list[ + +PYI011.pyi:46:9: PYI011 [*] Only simple default values allowed for typed arguments + | +44 | x: list[ +45 | int +46 | ] = [ # Error PYI011 Only simple default values allowed for typed arguments + | _________^ +47 | | 1, +48 | | 2, +49 | | 3, +50 | | 4, +51 | | 5, +52 | | 6, +53 | | 7, +54 | | 8, +55 | | 9, +56 | | 10, +57 | | 11, +58 | | ] + | |_____^ PYI011 +59 | ) -> None: ... +60 | def f154( + | + = help: Replace default value with `...` + +ℹ Suggested fix +43 43 | def f153( +44 44 | x: list[ +45 45 | int +46 |- ] = [ # Error PYI011 Only simple default values allowed for typed arguments +47 |- 1, +48 |- 2, +49 |- 3, +50 |- 4, +51 |- 5, +52 |- 6, +53 |- 7, +54 |- 8, +55 |- 9, +56 |- 10, +57 |- 11, +58 |- ] + 46 |+ ] = ... +59 47 | ) -> None: ... +60 48 | def f154( +61 49 | x: tuple[ + +PYI011.pyi:63:9: PYI011 [*] Only simple default values allowed for typed arguments + | +61 | x: tuple[ +62 | str, tuple[str, ...] +63 | ] = ( # Error PYI011 Only simple default values allowed for typed arguments + | _________^ +64 | | "foo", +65 | | ("bar", "baz"), +66 | | ) + | |_____^ PYI011 +67 | ) -> None: ... +68 | def f141( + | + = help: Replace default value with `...` + +ℹ Suggested fix +60 60 | def f154( +61 61 | x: tuple[ +62 62 | str, tuple[str, ...] +63 |- ] = ( # Error PYI011 Only simple default values allowed for typed arguments +64 |- "foo", +65 |- ("bar", "baz"), +66 |- ) + 63 |+ ] = ... +67 64 | ) -> None: ... +68 65 | def f141( +69 66 | x: list[ + +PYI011.pyi:71:9: PYI011 [*] Only simple default values allowed for typed arguments + | +69 | x: list[ +70 | int +71 | ] = [ # Error PYI011 Only simple default values allowed for typed arguments + | _________^ +72 | | *range(10) +73 | | ], + | |_____^ PYI011 +74 | ) -> None: ... +75 | def f142( + | + = help: Replace default value with `...` + +ℹ Suggested fix +68 68 | def f141( +69 69 | x: list[ +70 70 | int +71 |- ] = [ # Error PYI011 Only simple default values allowed for typed arguments +72 |- *range(10) +73 |- ], + 71 |+ ] = ..., +74 72 | ) -> None: ... +75 73 | def f142( +76 74 | x: list[ + +PYI011.pyi:78:9: PYI011 [*] Only simple default values allowed for typed arguments + | +76 | x: list[ +77 | int +78 | ] = list( # Error PYI011 Only simple default values allowed for typed arguments + | _________^ +79 | | range(10) +80 | | ), + | |_____^ PYI011 +81 | ) -> None: ... +82 | def f16( + | + = help: Replace default value with `...` + +ℹ Suggested fix +75 75 | def f142( +76 76 | x: list[ +77 77 | int +78 |- ] = list( # Error PYI011 Only simple default values allowed for typed arguments +79 |- range(10) +80 |- ), + 78 |+ ] = ..., +81 79 | ) -> None: ... +82 80 | def f16( +83 81 | x: frozenset[ + +PYI011.pyi:85:9: PYI011 [*] Only simple default values allowed for typed arguments + | +83 | x: frozenset[ +84 | bytes +85 | ] = frozenset( # Error PYI011 Only simple default values allowed for typed arguments + | _________^ +86 | | {b"foo", b"bar", b"baz"} +87 | | ) + | |_____^ PYI011 +88 | ) -> None: ... +89 | def f17( + | + = help: Replace default value with `...` + +ℹ Suggested fix +82 82 | def f16( +83 83 | x: frozenset[ +84 84 | bytes +85 |- ] = frozenset( # Error PYI011 Only simple default values allowed for typed arguments +86 |- {b"foo", b"bar", b"baz"} +87 |- ) + 85 |+ ] = ... +88 86 | ) -> None: ... +89 87 | def f17( +90 88 | x: str = "foo" # Error PYI011 Only simple default values allowed for typed arguments + +PYI011.pyi:90:14: PYI011 [*] Only simple default values allowed for typed arguments + | +88 | ) -> None: ... +89 | def f17( +90 | x: str = "foo" # Error PYI011 Only simple default values allowed for typed arguments + | ______________^ +91 | | + "bar", + | |___________^ PYI011 +92 | ) -> None: ... +93 | def f18( + | + = help: Replace default value with `...` + +ℹ Suggested fix +87 87 | ) +88 88 | ) -> None: ... +89 89 | def f17( +90 |- x: str = "foo" # Error PYI011 Only simple default values allowed for typed arguments +91 |- + "bar", + 90 |+ x: str = ..., +92 91 | ) -> None: ... +93 92 | def f18( +94 93 | x: str = b"foo" # Error PYI011 Only simple default values allowed for typed arguments + +PYI011.pyi:94:14: PYI011 [*] Only simple default values allowed for typed arguments + | +92 | ) -> None: ... +93 | def f18( +94 | x: str = b"foo" # Error PYI011 Only simple default values allowed for typed arguments + | ______________^ +95 | | + b"bar", + | |____________^ PYI011 +96 | ) -> None: ... +97 | def f19( + | + = help: Replace default value with `...` + +ℹ Suggested fix +91 91 | + "bar", +92 92 | ) -> None: ... +93 93 | def f18( +94 |- x: str = b"foo" # Error PYI011 Only simple default values allowed for typed arguments +95 |- + b"bar", + 94 |+ x: str = ..., +96 95 | ) -> None: ... +97 96 | def f19( +98 97 | x: object = "foo" # Error PYI011 Only simple default values allowed for typed arguments + +PYI011.pyi:98:17: PYI011 [*] Only simple default values allowed for typed arguments + | + 96 | ) -> None: ... + 97 | def f19( + 98 | x: object = "foo" # Error PYI011 Only simple default values allowed for typed arguments + | _________________^ + 99 | | + 4, + | |_______^ PYI011 +100 | ) -> None: ... +101 | def f20( + | + = help: Replace default value with `...` + +ℹ Suggested fix +95 95 | + b"bar", +96 96 | ) -> None: ... +97 97 | def f19( +98 |- x: object = "foo" # Error PYI011 Only simple default values allowed for typed arguments +99 |- + 4, + 98 |+ x: object = ..., +100 99 | ) -> None: ... +101 100 | def f20( +102 101 | x: int = 5 + +PYI011.pyi:102:14: PYI011 [*] Only simple default values allowed for typed arguments + | +100 | ) -> None: ... +101 | def f20( +102 | x: int = 5 + | ______________^ +103 | | + 5, # Error PYI011 Only simple default values allowed for typed arguments + | |_______^ PYI011 +104 | ) -> None: ... +105 | def f21( + | + = help: Replace default value with `...` + +ℹ Suggested fix +99 99 | + 4, +100 100 | ) -> None: ... +101 101 | def f20( +102 |- x: int = 5 +103 |- + 5, # Error PYI011 Only simple default values allowed for typed arguments + 102 |+ x: int = ..., # Error PYI011 Only simple default values allowed for typed arguments +104 103 | ) -> None: ... +105 104 | def f21( +106 105 | x: complex = 3j + +PYI011.pyi:106:18: PYI011 [*] Only simple default values allowed for typed arguments + | +104 | ) -> None: ... +105 | def f21( +106 | x: complex = 3j + | __________________^ +107 | | - 3j, # Error PYI011 Only simple default values allowed for typed arguments + | |________^ PYI011 +108 | ) -> None: ... +109 | def f22( + | + = help: Replace default value with `...` + +ℹ Suggested fix +103 103 | + 5, # Error PYI011 Only simple default values allowed for typed arguments +104 104 | ) -> None: ... +105 105 | def f21( +106 |- x: complex = 3j +107 |- - 3j, # Error PYI011 Only simple default values allowed for typed arguments + 106 |+ x: complex = ..., # Error PYI011 Only simple default values allowed for typed arguments +108 107 | ) -> None: ... +109 108 | def f22( +110 109 | x: complex = -42.5j # Error PYI011 Only simple default values allowed for typed arguments + +PYI011.pyi:110:18: PYI011 [*] Only simple default values allowed for typed arguments + | +108 | ) -> None: ... +109 | def f22( +110 | x: complex = -42.5j # Error PYI011 Only simple default values allowed for typed arguments + | __________________^ +111 | | + 4.3j, + | |__________^ PYI011 +112 | ) -> None: ... +113 | def f23( + | + = help: Replace default value with `...` + +ℹ Suggested fix +107 107 | - 3j, # Error PYI011 Only simple default values allowed for typed arguments +108 108 | ) -> None: ... +109 109 | def f22( +110 |- x: complex = -42.5j # Error PYI011 Only simple default values allowed for typed arguments +111 |- + 4.3j, + 110 |+ x: complex = ..., +112 111 | ) -> None: ... +113 112 | def f23( +114 113 | x: bool = True, # OK + +PYI011.pyi:138:16: PYI011 [*] Only simple default values allowed for typed arguments + | +136 | ) -> None: ... +137 | def f31( +138 | x: float = inf, # Error PYI011 Only simple default values allowed for typed arguments + | ^^^ PYI011 +139 | ) -> None: ... +140 | def f32( + | + = help: Replace default value with `...` + +ℹ Suggested fix +135 135 | x: float = -math.inf, # OK +136 136 | ) -> None: ... +137 137 | def f31( +138 |- x: float = inf, # Error PYI011 Only simple default values allowed for typed arguments + 138 |+ x: float = ..., # Error PYI011 Only simple default values allowed for typed arguments +139 139 | ) -> None: ... +140 140 | def f32( +141 141 | x: float = np.inf, # Error PYI011 Only simple default values allowed for typed arguments + +PYI011.pyi:141:16: PYI011 [*] Only simple default values allowed for typed arguments + | +139 | ) -> None: ... +140 | def f32( +141 | x: float = np.inf, # Error PYI011 Only simple default values allowed for typed arguments + | ^^^^^^ PYI011 +142 | ) -> None: ... +143 | def f33( + | + = help: Replace default value with `...` + +ℹ Suggested fix +138 138 | x: float = inf, # Error PYI011 Only simple default values allowed for typed arguments +139 139 | ) -> None: ... +140 140 | def f32( +141 |- x: float = np.inf, # Error PYI011 Only simple default values allowed for typed arguments + 141 |+ x: float = ..., # Error PYI011 Only simple default values allowed for typed arguments +142 142 | ) -> None: ... +143 143 | def f33( +144 144 | x: float = math.nan, # OK + +PYI011.pyi:147:16: PYI011 [*] Only simple default values allowed for typed arguments + | +145 | ) -> None: ... +146 | def f34( +147 | x: float = -math.nan, # Error PYI011 Only simple default values allowed for typed arguments + | ^^^^^^^^^ PYI011 +148 | ) -> None: ... +149 | def f35( + | + = help: Replace default value with `...` + +ℹ Suggested fix +144 144 | x: float = math.nan, # OK +145 145 | ) -> None: ... +146 146 | def f34( +147 |- x: float = -math.nan, # Error PYI011 Only simple default values allowed for typed arguments + 147 |+ x: float = ..., # Error PYI011 Only simple default values allowed for typed arguments +148 148 | ) -> None: ... +149 149 | def f35( +150 150 | x: complex = math.inf # Error PYI011 Only simple default values allowed for typed arguments + +PYI011.pyi:150:18: PYI011 [*] Only simple default values allowed for typed arguments + | +148 | ) -> None: ... +149 | def f35( +150 | x: complex = math.inf # Error PYI011 Only simple default values allowed for typed arguments + | __________________^ +151 | | + 1j, + | |________^ PYI011 +152 | ) -> None: ... +153 | def f36( + | + = help: Replace default value with `...` + +ℹ Suggested fix +147 147 | x: float = -math.nan, # Error PYI011 Only simple default values allowed for typed arguments +148 148 | ) -> None: ... +149 149 | def f35( +150 |- x: complex = math.inf # Error PYI011 Only simple default values allowed for typed arguments +151 |- + 1j, + 150 |+ x: complex = ..., +152 151 | ) -> None: ... +153 152 | def f36( +154 153 | *, + +PYI011.pyi:159:14: PYI011 [*] Only simple default values allowed for typed arguments + | +157 | def f37( +158 | *, +159 | x: str = "" # Error PYI011 Only simple default values allowed for typed arguments + | ______________^ +160 | | + "", + | |________^ PYI011 +161 | ) -> None: ... + | + = help: Replace default value with `...` + +ℹ Suggested fix +156 156 | ) -> None: ... +157 157 | def f37( +158 158 | *, +159 |- x: str = "" # Error PYI011 Only simple default values allowed for typed arguments +160 |- + "", + 159 |+ x: str = ..., +161 160 | ) -> None: ... + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI012_PYI012.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI012_PYI012.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI012_PYI012.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..7f583b17d9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI012_PYI012.pyi.snap @@ -0,0 +1,120 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI012.pyi:5:5: PYI012 [*] Class body must not contain `pass` + | +3 | class OneAttributeClass: +4 | value: int +5 | pass # PYI012 Class body must not contain `pass` + | ^^^^ PYI012 +6 | +7 | class OneAttributeClassRev: + | + = help: Remove unnecessary `pass` + +ℹ Fix +2 2 | +3 3 | class OneAttributeClass: +4 4 | value: int +5 |- pass # PYI012 Class body must not contain `pass` +6 5 | +7 6 | class OneAttributeClassRev: +8 7 | pass # PYI012 Class body must not contain `pass` + +PYI012.pyi:8:5: PYI012 [*] Class body must not contain `pass` + | +7 | class OneAttributeClassRev: +8 | pass # PYI012 Class body must not contain `pass` + | ^^^^ PYI012 +9 | value: int + | + = help: Remove unnecessary `pass` + +ℹ Fix +5 5 | pass # PYI012 Class body must not contain `pass` +6 6 | +7 7 | class OneAttributeClassRev: +8 |- pass # PYI012 Class body must not contain `pass` +9 8 | value: int +10 9 | +11 10 | class DocstringClass: + +PYI012.pyi:16:5: PYI012 [*] Class body must not contain `pass` + | +14 | """ +15 | +16 | pass # PYI012 Class body must not contain `pass` + | ^^^^ PYI012 +17 | +18 | class NonEmptyChild(Exception): + | + = help: Remove unnecessary `pass` + +ℹ Fix +13 13 | My body only contains pass. +14 14 | """ +15 15 | +16 |- pass # PYI012 Class body must not contain `pass` +17 16 | +18 17 | class NonEmptyChild(Exception): +19 18 | value: int + +PYI012.pyi:20:5: PYI012 [*] Class body must not contain `pass` + | +18 | class NonEmptyChild(Exception): +19 | value: int +20 | pass # PYI012 Class body must not contain `pass` + | ^^^^ PYI012 +21 | +22 | class NonEmptyChild2(Exception): + | + = help: Remove unnecessary `pass` + +ℹ Fix +17 17 | +18 18 | class NonEmptyChild(Exception): +19 19 | value: int +20 |- pass # PYI012 Class body must not contain `pass` +21 20 | +22 21 | class NonEmptyChild2(Exception): +23 22 | pass # PYI012 Class body must not contain `pass` + +PYI012.pyi:23:5: PYI012 [*] Class body must not contain `pass` + | +22 | class NonEmptyChild2(Exception): +23 | pass # PYI012 Class body must not contain `pass` + | ^^^^ PYI012 +24 | value: int + | + = help: Remove unnecessary `pass` + +ℹ Fix +20 20 | pass # PYI012 Class body must not contain `pass` +21 21 | +22 22 | class NonEmptyChild2(Exception): +23 |- pass # PYI012 Class body must not contain `pass` +24 23 | value: int +25 24 | +26 25 | class NonEmptyWithInit: + +PYI012.pyi:28:5: PYI012 [*] Class body must not contain `pass` + | +26 | class NonEmptyWithInit: +27 | value: int +28 | pass # PYI012 Class body must not contain `pass` + | ^^^^ PYI012 +29 | +30 | def __init__(): + | + = help: Remove unnecessary `pass` + +ℹ Fix +25 25 | +26 26 | class NonEmptyWithInit: +27 27 | value: int +28 |- pass # PYI012 Class body must not contain `pass` +29 28 | +30 29 | def __init__(): +31 30 | 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 new file mode 100644 index 0000000000..ddcef79dee --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.py.snap @@ -0,0 +1,149 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI013.py:3:5: PYI013 [*] Non-empty class body must not contain `...` + | +1 | class OneAttributeClass: +2 | value: int +3 | ... + | ^^^ PYI013 + | + = help: Remove unnecessary `...` + +ℹ Fix +1 1 | class OneAttributeClass: +2 2 | value: int +3 |- ... +4 3 | +5 4 | +6 5 | class OneAttributeClass2: + +PYI013.py:7:5: PYI013 [*] Non-empty class body must not contain `...` + | +6 | class OneAttributeClass2: +7 | ... + | ^^^ PYI013 +8 | value: int + | + = help: Remove unnecessary `...` + +ℹ Fix +4 4 | +5 5 | +6 6 | class OneAttributeClass2: +7 |- ... +8 7 | value: int +9 8 | +10 9 | + +PYI013.py:12:5: PYI013 [*] Non-empty class body must not contain `...` + | +11 | class TwoEllipsesClass: +12 | ... + | ^^^ PYI013 +13 | ... + | + = help: Remove unnecessary `...` + +ℹ Fix +10 10 | +11 11 | class TwoEllipsesClass: +12 12 | ... +13 |- ... +14 13 | +15 14 | +16 15 | class DocstringClass: + +PYI013.py:13:5: PYI013 [*] Non-empty class body must not contain `...` + | +11 | class TwoEllipsesClass: +12 | ... +13 | ... + | ^^^ PYI013 + | + = help: Remove unnecessary `...` + +ℹ Fix +10 10 | +11 11 | class TwoEllipsesClass: +12 12 | ... +13 |- ... +14 13 | +15 14 | +16 15 | class DocstringClass: + +PYI013.py:21:5: PYI013 [*] Non-empty class body must not contain `...` + | +19 | """ +20 | +21 | ... + | ^^^ PYI013 + | + = help: Remove unnecessary `...` + +ℹ Fix +18 18 | My body only contains an ellipsis. +19 19 | """ +20 20 | +21 |- ... +22 21 | +23 22 | +24 23 | class NonEmptyChild(Exception): + +PYI013.py:26:5: PYI013 [*] Non-empty class body must not contain `...` + | +24 | class NonEmptyChild(Exception): +25 | value: int +26 | ... + | ^^^ PYI013 + | + = help: Remove unnecessary `...` + +ℹ Fix +23 23 | +24 24 | class NonEmptyChild(Exception): +25 25 | value: int +26 |- ... +27 26 | +28 27 | +29 28 | class NonEmptyChild2(Exception): + +PYI013.py:30:5: PYI013 [*] Non-empty class body must not contain `...` + | +29 | class NonEmptyChild2(Exception): +30 | ... + | ^^^ PYI013 +31 | value: int + | + = help: Remove unnecessary `...` + +ℹ Fix +27 27 | +28 28 | +29 29 | class NonEmptyChild2(Exception): +30 |- ... +31 30 | value: int +32 31 | +33 32 | + +PYI013.py:36:5: PYI013 [*] Non-empty class body must not contain `...` + | +34 | class NonEmptyWithInit: +35 | value: int +36 | ... + | ^^^ PYI013 +37 | +38 | def __init__(): + | + = help: Remove unnecessary `...` + +ℹ Fix +33 33 | +34 34 | class NonEmptyWithInit: +35 35 | value: int +36 |- ... +37 36 | +38 37 | def __init__(): +39 38 | pass + + 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 new file mode 100644 index 0000000000..93cd91ba4a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI013_PYI013.pyi.snap @@ -0,0 +1,176 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI013.pyi:5:5: PYI013 [*] Non-empty class body must not contain `...` + | +3 | class OneAttributeClass: +4 | value: int +5 | ... # Error + | ^^^ PYI013 +6 | +7 | class OneAttributeClass2: + | + = help: Remove unnecessary `...` + +ℹ Fix +2 2 | +3 3 | class OneAttributeClass: +4 4 | value: int +5 |- ... # Error +6 5 | +7 6 | class OneAttributeClass2: +8 7 | ... # Error + +PYI013.pyi:8:5: PYI013 [*] Non-empty class body must not contain `...` + | +7 | class OneAttributeClass2: +8 | ... # Error + | ^^^ PYI013 +9 | value: int + | + = help: Remove unnecessary `...` + +ℹ Fix +5 5 | ... # Error +6 6 | +7 7 | class OneAttributeClass2: +8 |- ... # Error +9 8 | value: int +10 9 | +11 10 | class MyClass: + +PYI013.pyi:12:5: PYI013 [*] Non-empty class body must not contain `...` + | +11 | class MyClass: +12 | ... + | ^^^ PYI013 +13 | value: int + | + = help: Remove unnecessary `...` + +ℹ Fix +9 9 | value: int +10 10 | +11 11 | class MyClass: +12 |- ... +13 12 | value: int +14 13 | +15 14 | class TwoEllipsesClass: + +PYI013.pyi:16:5: PYI013 [*] Non-empty class body must not contain `...` + | +15 | class TwoEllipsesClass: +16 | ... + | ^^^ PYI013 +17 | ... # Error + | + = help: Remove unnecessary `...` + +ℹ Fix +13 13 | value: int +14 14 | +15 15 | class TwoEllipsesClass: +16 |- ... +17 16 | ... # Error +18 17 | +19 18 | class DocstringClass: + +PYI013.pyi:17:5: PYI013 [*] Non-empty class body must not contain `...` + | +15 | class TwoEllipsesClass: +16 | ... +17 | ... # Error + | ^^^ PYI013 +18 | +19 | class DocstringClass: + | + = help: Remove unnecessary `...` + +ℹ Fix +14 14 | +15 15 | class TwoEllipsesClass: +16 16 | ... +17 |- ... # Error +18 17 | +19 18 | class DocstringClass: +20 19 | """ + +PYI013.pyi:24:5: PYI013 [*] Non-empty class body must not contain `...` + | +22 | """ +23 | +24 | ... # Error + | ^^^ PYI013 +25 | +26 | class NonEmptyChild(Exception): + | + = help: Remove unnecessary `...` + +ℹ Fix +21 21 | My body only contains an ellipsis. +22 22 | """ +23 23 | +24 |- ... # Error +25 24 | +26 25 | class NonEmptyChild(Exception): +27 26 | value: int + +PYI013.pyi:28:5: PYI013 [*] Non-empty class body must not contain `...` + | +26 | class NonEmptyChild(Exception): +27 | value: int +28 | ... # Error + | ^^^ PYI013 +29 | +30 | class NonEmptyChild2(Exception): + | + = help: Remove unnecessary `...` + +ℹ Fix +25 25 | +26 26 | class NonEmptyChild(Exception): +27 27 | value: int +28 |- ... # Error +29 28 | +30 29 | class NonEmptyChild2(Exception): +31 30 | ... # Error + +PYI013.pyi:31:5: PYI013 [*] Non-empty class body must not contain `...` + | +30 | class NonEmptyChild2(Exception): +31 | ... # Error + | ^^^ PYI013 +32 | value: int + | + = help: Remove unnecessary `...` + +ℹ Fix +28 28 | ... # Error +29 29 | +30 30 | class NonEmptyChild2(Exception): +31 |- ... # Error +32 31 | value: int +33 32 | +34 33 | class NonEmptyWithInit: + +PYI013.pyi:36:5: PYI013 [*] Non-empty class body must not contain `...` + | +34 | class NonEmptyWithInit: +35 | value: int +36 | ... # Error + | ^^^ PYI013 +37 | +38 | def __init__(): + | + = help: Remove unnecessary `...` + +ℹ Fix +33 33 | +34 34 | class NonEmptyWithInit: +35 35 | value: int +36 |- ... # Error +37 36 | +38 37 | def __init__(): +39 38 | pass + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI014_PYI014.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI014_PYI014.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI014_PYI014.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI014_PYI014.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI014_PYI014.pyi.snap new file mode 100644 index 0000000000..f16400fffc --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI014_PYI014.pyi.snap @@ -0,0 +1,315 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI014.pyi:3:7: PYI014 [*] Only simple default values allowed for arguments + | +1 | def f12( +2 | x, +3 | y=os.pathsep, # Error PYI014 + | ^^^^^^^^^^ PYI014 +4 | ) -> None: ... +5 | def f11(*, x="x") -> None: ... # OK + | + = help: Replace default value with `...` + +ℹ Suggested fix +1 1 | def f12( +2 2 | x, +3 |- y=os.pathsep, # Error PYI014 + 3 |+ y=..., # Error PYI014 +4 4 | ) -> None: ... +5 5 | def f11(*, x="x") -> None: ... # OK +6 6 | def f13( + +PYI014.pyi:29:7: PYI014 [*] Only simple default values allowed for arguments + | +27 | def f151(x={1: 2}) -> None: ... +28 | def f152( +29 | x={ # Error PYI014 + | _______^ +30 | | 1: 2, +31 | | **{3: 4}, +32 | | } + | |_____^ PYI014 +33 | ) -> None: ... +34 | def f153( + | + = help: Replace default value with `...` + +ℹ Suggested fix +26 26 | ) -> None: ... +27 27 | def f151(x={1: 2}) -> None: ... +28 28 | def f152( +29 |- x={ # Error PYI014 +30 |- 1: 2, +31 |- **{3: 4}, +32 |- } + 29 |+ x=... +33 30 | ) -> None: ... +34 31 | def f153( +35 32 | x=[ # Error PYI014 + +PYI014.pyi:35:7: PYI014 [*] Only simple default values allowed for arguments + | +33 | ) -> None: ... +34 | def f153( +35 | x=[ # Error PYI014 + | _______^ +36 | | 1, +37 | | 2, +38 | | 3, +39 | | 4, +40 | | 5, +41 | | 6, +42 | | 7, +43 | | 8, +44 | | 9, +45 | | 10, +46 | | 11, +47 | | ] + | |_____^ PYI014 +48 | ) -> None: ... +49 | def f154( + | + = help: Replace default value with `...` + +ℹ Suggested fix +32 32 | } +33 33 | ) -> None: ... +34 34 | def f153( +35 |- x=[ # Error PYI014 +36 |- 1, +37 |- 2, +38 |- 3, +39 |- 4, +40 |- 5, +41 |- 6, +42 |- 7, +43 |- 8, +44 |- 9, +45 |- 10, +46 |- 11, +47 |- ] + 35 |+ x=... +48 36 | ) -> None: ... +49 37 | def f154( +50 38 | x=( # Error PYI014 + +PYI014.pyi:50:7: PYI014 [*] Only simple default values allowed for arguments + | +48 | ) -> None: ... +49 | def f154( +50 | x=( # Error PYI014 + | _______^ +51 | | "foo", +52 | | ("bar", "baz"), +53 | | ) + | |_____^ PYI014 +54 | ) -> None: ... +55 | def f141( + | + = help: Replace default value with `...` + +ℹ Suggested fix +47 47 | ] +48 48 | ) -> None: ... +49 49 | def f154( +50 |- x=( # Error PYI014 +51 |- "foo", +52 |- ("bar", "baz"), +53 |- ) + 50 |+ x=... +54 51 | ) -> None: ... +55 52 | def f141( +56 53 | x=[*range(10)], # Error PYI014 + +PYI014.pyi:56:7: PYI014 [*] Only simple default values allowed for arguments + | +54 | ) -> None: ... +55 | def f141( +56 | x=[*range(10)], # Error PYI014 + | ^^^^^^^^^^^^ PYI014 +57 | ) -> None: ... +58 | def f142( + | + = help: Replace default value with `...` + +ℹ Suggested fix +53 53 | ) +54 54 | ) -> None: ... +55 55 | def f141( +56 |- x=[*range(10)], # Error PYI014 + 56 |+ x=..., # Error PYI014 +57 57 | ) -> None: ... +58 58 | def f142( +59 59 | x=list(range(10)), # Error PYI014 + +PYI014.pyi:59:7: PYI014 [*] Only simple default values allowed for arguments + | +57 | ) -> None: ... +58 | def f142( +59 | x=list(range(10)), # Error PYI014 + | ^^^^^^^^^^^^^^^ PYI014 +60 | ) -> None: ... +61 | def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: ... # Error PYI014 + | + = help: Replace default value with `...` + +ℹ Suggested fix +56 56 | x=[*range(10)], # Error PYI014 +57 57 | ) -> None: ... +58 58 | def f142( +59 |- x=list(range(10)), # Error PYI014 + 59 |+ x=..., # Error PYI014 +60 60 | ) -> None: ... +61 61 | def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: ... # Error PYI014 +62 62 | def f17( + +PYI014.pyi:61:11: PYI014 [*] Only simple default values allowed for arguments + | +59 | x=list(range(10)), # Error PYI014 +60 | ) -> None: ... +61 | def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: ... # Error PYI014 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI014 +62 | def f17( +63 | x="foo" + "bar", # Error PYI014 + | + = help: Replace default value with `...` + +ℹ Suggested fix +58 58 | def f142( +59 59 | x=list(range(10)), # Error PYI014 +60 60 | ) -> None: ... +61 |-def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: ... # Error PYI014 + 61 |+def f16(x=...) -> None: ... # Error PYI014 +62 62 | def f17( +63 63 | x="foo" + "bar", # Error PYI014 +64 64 | ) -> None: ... + +PYI014.pyi:63:7: PYI014 [*] Only simple default values allowed for arguments + | +61 | def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: ... # Error PYI014 +62 | def f17( +63 | x="foo" + "bar", # Error PYI014 + | ^^^^^^^^^^^^^ PYI014 +64 | ) -> None: ... +65 | def f18( + | + = help: Replace default value with `...` + +ℹ Suggested fix +60 60 | ) -> None: ... +61 61 | def f16(x=frozenset({b"foo", b"bar", b"baz"})) -> None: ... # Error PYI014 +62 62 | def f17( +63 |- x="foo" + "bar", # Error PYI014 + 63 |+ x=..., # Error PYI014 +64 64 | ) -> None: ... +65 65 | def f18( +66 66 | x=b"foo" + b"bar", # Error PYI014 + +PYI014.pyi:66:7: PYI014 [*] Only simple default values allowed for arguments + | +64 | ) -> None: ... +65 | def f18( +66 | x=b"foo" + b"bar", # Error PYI014 + | ^^^^^^^^^^^^^^^ PYI014 +67 | ) -> None: ... +68 | def f19( + | + = help: Replace default value with `...` + +ℹ Suggested fix +63 63 | x="foo" + "bar", # Error PYI014 +64 64 | ) -> None: ... +65 65 | def f18( +66 |- x=b"foo" + b"bar", # Error PYI014 + 66 |+ x=..., # Error PYI014 +67 67 | ) -> None: ... +68 68 | def f19( +69 69 | x="foo" + 4, # Error PYI014 + +PYI014.pyi:69:7: PYI014 [*] Only simple default values allowed for arguments + | +67 | ) -> None: ... +68 | def f19( +69 | x="foo" + 4, # Error PYI014 + | ^^^^^^^^^ PYI014 +70 | ) -> None: ... +71 | def f20( + | + = help: Replace default value with `...` + +ℹ Suggested fix +66 66 | x=b"foo" + b"bar", # Error PYI014 +67 67 | ) -> None: ... +68 68 | def f19( +69 |- x="foo" + 4, # Error PYI014 + 69 |+ x=..., # Error PYI014 +70 70 | ) -> None: ... +71 71 | def f20( +72 72 | x=5 + 5, # Error PYI014 + +PYI014.pyi:72:7: PYI014 [*] Only simple default values allowed for arguments + | +70 | ) -> None: ... +71 | def f20( +72 | x=5 + 5, # Error PYI014 + | ^^^^^ PYI014 +73 | ) -> None: ... +74 | def f21( + | + = help: Replace default value with `...` + +ℹ Suggested fix +69 69 | x="foo" + 4, # Error PYI014 +70 70 | ) -> None: ... +71 71 | def f20( +72 |- x=5 + 5, # Error PYI014 + 72 |+ x=..., # Error PYI014 +73 73 | ) -> None: ... +74 74 | def f21( +75 75 | x=3j - 3j, # Error PYI014 + +PYI014.pyi:75:7: PYI014 [*] Only simple default values allowed for arguments + | +73 | ) -> None: ... +74 | def f21( +75 | x=3j - 3j, # Error PYI014 + | ^^^^^^^ PYI014 +76 | ) -> None: ... +77 | def f22( + | + = help: Replace default value with `...` + +ℹ Suggested fix +72 72 | x=5 + 5, # Error PYI014 +73 73 | ) -> None: ... +74 74 | def f21( +75 |- x=3j - 3j, # Error PYI014 + 75 |+ x=..., # Error PYI014 +76 76 | ) -> None: ... +77 77 | def f22( +78 78 | x=-42.5j + 4.3j, # Error PYI014 + +PYI014.pyi:78:7: PYI014 [*] Only simple default values allowed for arguments + | +76 | ) -> None: ... +77 | def f22( +78 | x=-42.5j + 4.3j, # Error PYI014 + | ^^^^^^^^^^^^^ PYI014 +79 | ) -> None: ... +80 | def f23( + | + = help: Replace default value with `...` + +ℹ Suggested fix +75 75 | x=3j - 3j, # Error PYI014 +76 76 | ) -> None: ... +77 77 | def f22( +78 |- x=-42.5j + 4.3j, # Error PYI014 + 78 |+ x=..., # Error PYI014 +79 79 | ) -> None: ... +80 80 | def f23( +81 81 | x=True, # OK + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI015_PYI015.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI015_PYI015.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI015_PYI015.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..a083c72f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI015_PYI015.pyi.snap @@ -0,0 +1,233 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI015.pyi:44:23: PYI015 [*] Only simple default values allowed for assignments + | +43 | # We *should* emit Y015 for more complex default values +44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI015 +45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments +46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments + | + = help: Replace default value with `...` + +ℹ Suggested fix +41 41 | field22: Final = {"foo": 5} +42 42 | +43 43 | # We *should* emit Y015 for more complex default values +44 |-field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments + 44 |+field221: list[int] = ... # Y015 Only simple default values are allowed for assignments +45 45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments +46 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments +47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments + +PYI015.pyi:45:23: PYI015 [*] Only simple default values allowed for assignments + | +43 | # We *should* emit Y015 for more complex default values +44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments +45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments + | ^^^^^^^^^^^^ PYI015 +46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments +47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments + | + = help: Replace default value with `...` + +ℹ Suggested fix +42 42 | +43 43 | # We *should* emit Y015 for more complex default values +44 44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments +45 |-field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments + 45 |+field223: list[int] = ... # Y015 Only simple default values are allowed for assignments +46 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments +47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments +48 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments + +PYI015.pyi:46:23: PYI015 [*] Only simple default values allowed for assignments + | +44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments +45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments +46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments + | ^^^^^^^^^^^^^^^ PYI015 +47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments +48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments + | + = help: Replace default value with `...` + +ℹ Suggested fix +43 43 | # We *should* emit Y015 for more complex default values +44 44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments +45 45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments +46 |-field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments + 46 |+field224: list[int] = ... # Y015 Only simple default values are allowed for assignments +47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments +48 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments +49 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments + +PYI015.pyi:47:26: PYI015 [*] Only simple default values allowed for assignments + | +45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments +46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments +47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments + | ^^^^^^^^^^ PYI015 +48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments +49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments + | + = help: Replace default value with `...` + +ℹ Suggested fix +44 44 | field221: list[int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] # Y015 Only simple default values are allowed for assignments +45 45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments +46 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments +47 |-field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments + 47 |+field225: list[object] = ... # Y015 Only simple default values are allowed for assignments +48 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments +49 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments +50 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments + +PYI015.pyi:48:47: PYI015 [*] Only simple default values allowed for assignments + | +46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments +47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments +48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments + | ^^^^^^^^^^^^^^^^^^^^^^^ PYI015 +49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments +50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments + | + = help: Replace default value with `...` + +ℹ Suggested fix +45 45 | field223: list[int] = [*range(10)] # Y015 Only simple default values are allowed for assignments +46 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments +47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments +48 |-field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments + 48 |+field226: tuple[str | tuple[str, ...], ...] = ... # Y015 Only simple default values are allowed for assignments +49 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments +50 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments +51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node + +PYI015.pyi:49:31: PYI015 [*] Only simple default values allowed for assignments + | +47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments +48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments +49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments + | ^^^^^^^^^^^^^^^^^^^^^^^ PYI015 +50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments +51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node + | + = help: Replace default value with `...` + +ℹ Suggested fix +46 46 | field224: list[int] = list(range(10)) # Y015 Only simple default values are allowed for assignments +47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments +48 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments +49 |-field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments + 49 |+field227: dict[str, object] = ... # Y015 Only simple default values are allowed for assignments +50 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments +51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node +52 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments + +PYI015.pyi:50:37: PYI015 [*] Only simple default values allowed for assignments + | +48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments +49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments +50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments + | ^^^^^^^^^^^ PYI015 +51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node +52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments + | + = help: Replace default value with `...` + +ℹ Suggested fix +47 47 | field225: list[object] = [{}, 1, 2] # Y015 Only simple default values are allowed for assignments +48 48 | field226: tuple[str | tuple[str, ...], ...] = ("foo", ("foo", "bar")) # Y015 Only simple default values are allowed for assignments +49 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments +50 |-field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments + 50 |+field228: dict[str, list[object]] = ... # Y015 Only simple default values are allowed for assignments +51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node +52 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments +53 53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments + +PYI015.pyi:52:28: PYI015 [*] Only simple default values allowed for assignments + | +50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments +51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node +52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments + | ^^^^^^^^^^^^^^^^ PYI015 +53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments +54 | field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments + | + = help: Replace default value with `...` + +ℹ Suggested fix +49 49 | field227: dict[str, object] = {"foo": {"foo": "bar"}} # Y015 Only simple default values are allowed for assignments +50 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments +51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node +52 |-field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments + 52 |+field229: dict[int, int] = ... # Y015 Only simple default values are allowed for assignments +53 53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments +54 54 | field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments +55 55 | field25 = 5 * 5 # Y015 Only simple default values are allowed for assignments + +PYI015.pyi:53:11: PYI015 [*] Only simple default values allowed for assignments + | +51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node +52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments +53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments + | ^^^^^^^^^^^^^ PYI015 +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 + | + = help: Replace default value with `...` + +ℹ Suggested fix +50 50 | field228: dict[str, list[object]] = {"foo": []} # Y015 Only simple default values are allowed for assignments +51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node +52 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments +53 |-field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments + 53 |+field23 = ... # Y015 Only simple default values are allowed for assignments +54 54 | field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments +55 55 | field25 = 5 * 5 # Y015 Only simple default values are allowed for assignments +56 56 | + +PYI015.pyi:54:11: PYI015 [*] Only simple default values allowed for assignments + | +52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments +53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments +54 | field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments + | ^^^^^^^^^^^^^^^ PYI015 +55 | field25 = 5 * 5 # Y015 Only simple default values are allowed for assignments + | + = help: Replace default value with `...` + +ℹ Suggested fix +51 51 | # When parsed, this case results in `None` being placed in the `.keys` list for the `ast.Dict` node +52 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments +53 53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments +54 |-field24 = b"foo" + b"bar" # Y015 Only simple default values are allowed for assignments + 54 |+field24 = ... # Y015 Only simple default values are allowed for assignments +55 55 | field25 = 5 * 5 # Y015 Only simple default values are allowed for assignments +56 56 | +57 57 | # We shouldn't emit Y015 within functions + +PYI015.pyi:55:11: PYI015 [*] Only simple default values allowed for assignments + | +53 | field23 = "foo" + "bar" # Y015 Only simple default values are 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 | +57 | # We shouldn't emit Y015 within functions + | + = help: Replace default value with `...` + +ℹ Suggested fix +52 52 | field229: dict[int, int] = {1: 2, **{3: 4}} # Y015 Only simple default values are allowed for assignments +53 53 | field23 = "foo" + "bar" # Y015 Only simple default values are allowed for assignments +54 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 + 55 |+field25 = ... # Y015 Only simple default values are allowed for assignments +56 56 | +57 57 | # We shouldn't emit Y015 within functions +58 58 | def f(): + + 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 new file mode 100644 index 0000000000..9d0c461dc7 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.py.snap @@ -0,0 +1,543 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +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 | +9 | # Should emit for union types in arguments. + | + = help: Remove duplicate union member `str` + +ℹ Fix +4 4 | field1: str +5 5 | +6 6 | # Should emit for duplicate field types. +7 |-field2: str | str # PYI016: Duplicate union member `str` + 7 |+field2: str # PYI016: Duplicate union member `str` +8 8 | +9 9 | # Should emit for union types in arguments. +10 10 | def func1(arg1: int | int): # PYI016: Duplicate union member `int` + +PYI016.py:10:23: PYI016 [*] Duplicate union member `int` + | + 9 | # Should emit for union types in arguments. +10 | def func1(arg1: int | int): # PYI016: Duplicate union member `int` + | ^^^ PYI016 +11 | print(arg1) + | + = help: Remove duplicate union member `int` + +ℹ Fix +7 7 | field2: str | str # PYI016: Duplicate union member `str` +8 8 | +9 9 | # Should emit for union types in arguments. +10 |-def func1(arg1: int | int): # PYI016: Duplicate union member `int` + 10 |+def func1(arg1: int): # PYI016: Duplicate union member `int` +11 11 | print(arg1) +12 12 | +13 13 | # Should emit for unions in return types. + +PYI016.py:14:22: PYI016 [*] Duplicate union member `str` + | +13 | # Should emit for unions in return types. +14 | def func2() -> str | str: # PYI016: Duplicate union member `str` + | ^^^ PYI016 +15 | return "my string" + | + = help: Remove duplicate union member `str` + +ℹ Fix +11 11 | print(arg1) +12 12 | +13 13 | # Should emit for unions in return types. +14 |-def func2() -> str | str: # PYI016: Duplicate union member `str` + 14 |+def func2() -> str: # PYI016: Duplicate union member `str` +15 15 | return "my string" +16 16 | +17 17 | # Should emit in longer unions, even if not directly adjacent. + +PYI016.py:18:15: PYI016 [*] Duplicate union member `str` + | +17 | # Should emit in longer unions, even if not directly adjacent. +18 | field3: str | str | int # PYI016: Duplicate union member `str` + | ^^^ PYI016 +19 | field4: int | int | str # PYI016: Duplicate union member `int` +20 | field5: str | int | str # PYI016: Duplicate union member `str` + | + = help: Remove duplicate union member `str` + +ℹ Fix +15 15 | return "my string" +16 16 | +17 17 | # Should emit in longer unions, even if not directly adjacent. +18 |-field3: str | str | int # PYI016: Duplicate union member `str` + 18 |+field3: str | int # PYI016: Duplicate union member `str` +19 19 | field4: int | int | str # PYI016: Duplicate union member `int` +20 20 | field5: str | int | str # PYI016: Duplicate union member `str` +21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` + +PYI016.py:19:15: PYI016 [*] Duplicate union member `int` + | +17 | # Should emit in longer unions, even if not directly adjacent. +18 | field3: str | str | int # PYI016: Duplicate union member `str` +19 | field4: int | int | str # PYI016: Duplicate union member `int` + | ^^^ PYI016 +20 | field5: str | int | str # PYI016: Duplicate union member `str` +21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` + | + = help: Remove duplicate union member `int` + +ℹ Fix +16 16 | +17 17 | # Should emit in longer unions, even if not directly adjacent. +18 18 | field3: str | str | int # PYI016: Duplicate union member `str` +19 |-field4: int | int | str # PYI016: Duplicate union member `int` + 19 |+field4: int | str # PYI016: Duplicate union member `int` +20 20 | field5: str | int | str # PYI016: Duplicate union member `str` +21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` +22 22 | + +PYI016.py:20:21: PYI016 [*] Duplicate union member `str` + | +18 | field3: str | str | int # PYI016: Duplicate union member `str` +19 | field4: int | int | str # PYI016: Duplicate union member `int` +20 | field5: str | int | str # PYI016: Duplicate union member `str` + | ^^^ PYI016 +21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` + | + = help: Remove duplicate union member `str` + +ℹ Fix +17 17 | # Should emit in longer unions, even if not directly adjacent. +18 18 | field3: str | str | int # PYI016: Duplicate union member `str` +19 19 | field4: int | int | str # PYI016: Duplicate union member `int` +20 |-field5: str | int | str # PYI016: Duplicate union member `str` + 20 |+field5: str | int # PYI016: Duplicate union member `str` +21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` +22 22 | +23 23 | # Shouldn't emit for non-type unions. + +PYI016.py:21:28: PYI016 [*] Duplicate union member `int` + | +19 | field4: int | int | str # 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 | +23 | # Shouldn't emit for non-type unions. + | + = help: Remove duplicate union member `int` + +ℹ Fix +18 18 | field3: str | str | int # PYI016: Duplicate union member `str` +19 19 | field4: int | int | str # PYI016: Duplicate union member `int` +20 20 | field5: str | int | str # PYI016: Duplicate union member `str` +21 |-field6: int | bool | str | int # PYI016: Duplicate union member `int` + 21 |+field6: int | bool | str # PYI016: Duplicate union member `int` +22 22 | +23 23 | # Shouldn't emit for non-type unions. +24 24 | field7 = str | str + +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 | +29 | # Should handle user brackets when fixing. + | + = help: Remove duplicate union member `int` + +ℹ Fix +24 24 | field7 = str | str +25 25 | +26 26 | # Should emit for strangely-bracketed unions. +27 |-field8: int | (str | int) # PYI016: Duplicate union member `int` + 27 |+field8: int | (str) # PYI016: Duplicate union member `int` +28 28 | +29 29 | # Should handle user brackets when fixing. +30 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` + +PYI016.py:30:16: PYI016 [*] Duplicate union member `int` + | +29 | # Should handle user brackets when fixing. +30 | field9: int | (int | str) # PYI016: Duplicate union member `int` + | ^^^ PYI016 +31 | field10: (str | int) | str # PYI016: Duplicate union member `str` + | + = help: Remove duplicate union member `int` + +ℹ Fix +27 27 | field8: int | (str | int) # PYI016: Duplicate union member `int` +28 28 | +29 29 | # Should handle user brackets when fixing. +30 |-field9: int | (int | str) # PYI016: Duplicate union member `int` + 30 |+field9: int | (str) # PYI016: Duplicate union member `int` +31 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` +32 32 | +33 33 | # Should emit for nested unions. + +PYI016.py:31:24: PYI016 [*] Duplicate union member `str` + | +29 | # Should handle user brackets when fixing. +30 | field9: int | (int | str) # PYI016: Duplicate union member `int` +31 | field10: (str | int) | str # PYI016: Duplicate union member `str` + | ^^^ PYI016 +32 | +33 | # Should emit for nested unions. + | + = help: Remove duplicate union member `str` + +ℹ Fix +28 28 | +29 29 | # Should handle user brackets when fixing. +30 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` +31 |-field10: (str | int) | str # PYI016: Duplicate union member `str` + 31 |+field10: str | int # PYI016: Duplicate union member `str` +32 32 | +33 33 | # Should emit for nested unions. +34 34 | field11: dict[int | int, str] + +PYI016.py:34:21: PYI016 [*] Duplicate union member `int` + | +33 | # Should emit for nested unions. +34 | field11: dict[int | int, str] + | ^^^ PYI016 +35 | +36 | # Should emit for unions with more than two cases + | + = help: Remove duplicate union member `int` + +ℹ Fix +31 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` +32 32 | +33 33 | # Should emit for nested unions. +34 |-field11: dict[int | int, str] + 34 |+field11: dict[int, str] +35 35 | +36 36 | # Should emit for unions with more than two cases +37 37 | field12: int | int | int # Error + +PYI016.py:37:16: PYI016 [*] Duplicate union member `int` + | +36 | # Should emit for unions with more than two cases +37 | field12: int | int | int # Error + | ^^^ PYI016 +38 | field13: int | int | int | int # Error + | + = help: Remove duplicate union member `int` + +ℹ Fix +34 34 | field11: dict[int | int, str] +35 35 | +36 36 | # Should emit for unions with more than two cases +37 |-field12: int | int | int # Error + 37 |+field12: int | int # Error +38 38 | field13: int | int | int | int # Error +39 39 | +40 40 | # Should emit for unions with more than two cases, even if not directly adjacent + +PYI016.py:37:22: PYI016 [*] Duplicate union member `int` + | +36 | # Should emit for unions with more than two cases +37 | field12: int | int | int # Error + | ^^^ PYI016 +38 | field13: int | int | int | int # Error + | + = help: Remove duplicate union member `int` + +ℹ Fix +34 34 | field11: dict[int | int, str] +35 35 | +36 36 | # Should emit for unions with more than two cases +37 |-field12: int | int | int # Error + 37 |+field12: int | int # Error +38 38 | field13: int | int | int | int # Error +39 39 | +40 40 | # Should emit for unions with more than two cases, even if not directly adjacent + +PYI016.py:38:16: PYI016 [*] Duplicate union member `int` + | +36 | # Should emit for unions with more than two cases +37 | field12: int | int | int # Error +38 | field13: int | int | int | int # Error + | ^^^ PYI016 +39 | +40 | # Should emit for unions with more than two cases, even if not directly adjacent + | + = help: Remove duplicate union member `int` + +ℹ Fix +35 35 | +36 36 | # Should emit for unions with more than two cases +37 37 | field12: int | int | int # Error +38 |-field13: int | int | int | int # Error + 38 |+field13: int | int | int # Error +39 39 | +40 40 | # Should emit for unions with more than two cases, even if not directly adjacent +41 41 | field14: int | int | str | int # Error + +PYI016.py:38:22: PYI016 [*] Duplicate union member `int` + | +36 | # Should emit for unions with more than two cases +37 | field12: int | int | int # Error +38 | field13: int | int | int | int # Error + | ^^^ PYI016 +39 | +40 | # Should emit for unions with more than two cases, even if not directly adjacent + | + = help: Remove duplicate union member `int` + +ℹ Fix +35 35 | +36 36 | # Should emit for unions with more than two cases +37 37 | field12: int | int | int # Error +38 |-field13: int | int | int | int # Error + 38 |+field13: int | int | int # Error +39 39 | +40 40 | # Should emit for unions with more than two cases, even if not directly adjacent +41 41 | field14: int | int | str | int # Error + +PYI016.py:38:28: PYI016 [*] Duplicate union member `int` + | +36 | # Should emit for unions with more than two cases +37 | field12: int | int | int # Error +38 | field13: int | int | int | int # Error + | ^^^ PYI016 +39 | +40 | # Should emit for unions with more than two cases, even if not directly adjacent + | + = help: Remove duplicate union member `int` + +ℹ Fix +35 35 | +36 36 | # Should emit for unions with more than two cases +37 37 | field12: int | int | int # Error +38 |-field13: int | int | int | int # Error + 38 |+field13: int | int | int # Error +39 39 | +40 40 | # Should emit for unions with more than two cases, even if not directly adjacent +41 41 | field14: int | int | str | int # Error + +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 | +43 | # Should emit for duplicate literal types; also covered by PYI030 + | + = help: Remove duplicate union member `int` + +ℹ Fix +38 38 | field13: int | int | int | int # Error +39 39 | +40 40 | # Should emit for unions with more than two cases, even if not directly adjacent +41 |-field14: int | int | str | int # Error + 41 |+field14: int | str | int # Error +42 42 | +43 43 | # Should emit for duplicate literal types; also covered by PYI030 +44 44 | field15: typing.Literal[1] | typing.Literal[1] # Error + +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 | +43 | # Should emit for duplicate literal types; also covered by PYI030 + | + = help: Remove duplicate union member `int` + +ℹ Fix +38 38 | field13: int | int | int | int # Error +39 39 | +40 40 | # Should emit for unions with more than two cases, even if not directly adjacent +41 |-field14: int | int | str | int # Error + 41 |+field14: int | int | str # Error +42 42 | +43 43 | # Should emit for duplicate literal types; also covered by PYI030 +44 44 | field15: typing.Literal[1] | typing.Literal[1] # Error + +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 | +46 | # Shouldn't emit if in new parent type + | + = help: Remove duplicate union member `typing.Literal[1]` + +ℹ Fix +41 41 | field14: int | int | str | int # Error +42 42 | +43 43 | # Should emit for duplicate literal types; also covered by PYI030 +44 |-field15: typing.Literal[1] | typing.Literal[1] # Error + 44 |+field15: typing.Literal[1] # Error +45 45 | +46 46 | # Shouldn't emit if in new parent type +47 47 | field16: int | dict[int, str] # OK + +PYI016.py:57:5: PYI016 Duplicate union member `set[int]` + | +55 | int # foo +56 | ], +57 | set[ + | _____^ +58 | | int # bar +59 | | ], + | |_____^ PYI016 +60 | ] # Error, newline and comment will not be emitted in message + | + = help: Remove duplicate union member `set[int]` + +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 | +65 | # Should emit in cases with nested `typing.Union` + | + = help: Remove duplicate union member `int` + +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 | +68 | # Should emit in cases with mixed `typing.Union` and `|` + | + = help: Remove duplicate union member `int` + +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 | +71 | # Should emit only once in cases with multiple nested `typing.Union` + | + = help: Remove duplicate union member `int` + +ℹ Fix +66 66 | field20: typing.Union[int, typing.Union[int, str]] # Error +67 67 | +68 68 | # Should emit in cases with mixed `typing.Union` and `|` +69 |-field21: typing.Union[int, int | str] # Error + 69 |+field21: typing.Union[int, str] # Error +70 70 | +71 71 | # Should emit only once in cases with multiple nested `typing.Union` +72 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error + +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 | +74 | # Should emit in cases with newlines + | + = help: Remove duplicate union member `int` + +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 | +74 | # Should emit in cases with newlines + | + = help: Remove duplicate union member `int` + +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 | +74 | # Should emit in cases with newlines + | + = help: Remove duplicate union member `int` + +PYI016.py:76:12: PYI016 [*] Duplicate union member `set[int]` + | +74 | # Should emit in cases with newlines +75 | field23: set[ # foo +76 | int] | set[int] + | ^^^^^^^^ PYI016 +77 | +78 | # Should emit twice (once for each `int` in the nested union, both of which are + | + = help: Remove duplicate union member `set[int]` + +ℹ Fix +73 73 | +74 74 | # Should emit in cases with newlines +75 75 | field23: set[ # foo +76 |- int] | set[int] + 76 |+ int] +77 77 | +78 78 | # Should emit twice (once for each `int` in the nested union, both of which are +79 79 | # duplicates of the outer `int`), but not three times (which would indicate that + +PYI016.py:81:41: PYI016 Duplicate union member `int` + | +79 | # duplicates of the outer `int`), but not three times (which would indicate that +80 | # we incorrectly re-checked the nested union). +81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` + | ^^^ PYI016 +82 | +83 | # Should emit twice (once for each `int` in the nested union, both of which are + | + = help: Remove duplicate union member `int` + +PYI016.py:81:46: PYI016 Duplicate union member `int` + | +79 | # duplicates of the outer `int`), but not three times (which would indicate that +80 | # we incorrectly re-checked the nested union). +81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` + | ^^^ PYI016 +82 | +83 | # Should emit twice (once for each `int` in the nested union, both of which are + | + = help: Remove duplicate union member `int` + +PYI016.py:86:28: PYI016 [*] Duplicate union member `int` + | +84 | # duplicates of the outer `int`), but not three times (which would indicate that +85 | # we incorrectly re-checked the nested union). +86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` + | ^^^ PYI016 + | + = help: Remove duplicate union member `int` + +ℹ Fix +83 83 | # Should emit twice (once for each `int` in the nested union, both of which are +84 84 | # duplicates of the outer `int`), but not three times (which would indicate that +85 85 | # we incorrectly re-checked the nested union). +86 |-field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` + 86 |+field25: typing.Union[int, int] # PYI016: Duplicate union member `int` + +PYI016.py:86:34: PYI016 [*] Duplicate union member `int` + | +84 | # duplicates of the outer `int`), but not three times (which would indicate that +85 | # we incorrectly re-checked the nested union). +86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` + | ^^^ PYI016 + | + = help: Remove duplicate union member `int` + +ℹ Fix +83 83 | # Should emit twice (once for each `int` in the nested union, both of which are +84 84 | # duplicates of the outer `int`), but not three times (which would indicate that +85 85 | # we incorrectly re-checked the nested union). +86 |-field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` + 86 |+field25: typing.Union[int, int] # PYI016: 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 new file mode 100644 index 0000000000..a6cc7428c8 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI016_PYI016.pyi.snap @@ -0,0 +1,543 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +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 | +9 | # Should emit for union types in arguments. + | + = help: Remove duplicate union member `str` + +ℹ Fix +4 4 | field1: str +5 5 | +6 6 | # Should emit for duplicate field types. +7 |-field2: str | str # PYI016: Duplicate union member `str` + 7 |+field2: str # PYI016: Duplicate union member `str` +8 8 | +9 9 | # Should emit for union types in arguments. +10 10 | def func1(arg1: int | int): # PYI016: Duplicate union member `int` + +PYI016.pyi:10:23: PYI016 [*] Duplicate union member `int` + | + 9 | # Should emit for union types in arguments. +10 | def func1(arg1: int | int): # PYI016: Duplicate union member `int` + | ^^^ PYI016 +11 | print(arg1) + | + = help: Remove duplicate union member `int` + +ℹ Fix +7 7 | field2: str | str # PYI016: Duplicate union member `str` +8 8 | +9 9 | # Should emit for union types in arguments. +10 |-def func1(arg1: int | int): # PYI016: Duplicate union member `int` + 10 |+def func1(arg1: int): # PYI016: Duplicate union member `int` +11 11 | print(arg1) +12 12 | +13 13 | # Should emit for unions in return types. + +PYI016.pyi:14:22: PYI016 [*] Duplicate union member `str` + | +13 | # Should emit for unions in return types. +14 | def func2() -> str | str: # PYI016: Duplicate union member `str` + | ^^^ PYI016 +15 | return "my string" + | + = help: Remove duplicate union member `str` + +ℹ Fix +11 11 | print(arg1) +12 12 | +13 13 | # Should emit for unions in return types. +14 |-def func2() -> str | str: # PYI016: Duplicate union member `str` + 14 |+def func2() -> str: # PYI016: Duplicate union member `str` +15 15 | return "my string" +16 16 | +17 17 | # Should emit in longer unions, even if not directly adjacent. + +PYI016.pyi:18:15: PYI016 [*] Duplicate union member `str` + | +17 | # Should emit in longer unions, even if not directly adjacent. +18 | field3: str | str | int # PYI016: Duplicate union member `str` + | ^^^ PYI016 +19 | field4: int | int | str # PYI016: Duplicate union member `int` +20 | field5: str | int | str # PYI016: Duplicate union member `str` + | + = help: Remove duplicate union member `str` + +ℹ Fix +15 15 | return "my string" +16 16 | +17 17 | # Should emit in longer unions, even if not directly adjacent. +18 |-field3: str | str | int # PYI016: Duplicate union member `str` + 18 |+field3: str | int # PYI016: Duplicate union member `str` +19 19 | field4: int | int | str # PYI016: Duplicate union member `int` +20 20 | field5: str | int | str # PYI016: Duplicate union member `str` +21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` + +PYI016.pyi:19:15: PYI016 [*] Duplicate union member `int` + | +17 | # Should emit in longer unions, even if not directly adjacent. +18 | field3: str | str | int # PYI016: Duplicate union member `str` +19 | field4: int | int | str # PYI016: Duplicate union member `int` + | ^^^ PYI016 +20 | field5: str | int | str # PYI016: Duplicate union member `str` +21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` + | + = help: Remove duplicate union member `int` + +ℹ Fix +16 16 | +17 17 | # Should emit in longer unions, even if not directly adjacent. +18 18 | field3: str | str | int # PYI016: Duplicate union member `str` +19 |-field4: int | int | str # PYI016: Duplicate union member `int` + 19 |+field4: int | str # PYI016: Duplicate union member `int` +20 20 | field5: str | int | str # PYI016: Duplicate union member `str` +21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` +22 22 | + +PYI016.pyi:20:21: PYI016 [*] Duplicate union member `str` + | +18 | field3: str | str | int # PYI016: Duplicate union member `str` +19 | field4: int | int | str # PYI016: Duplicate union member `int` +20 | field5: str | int | str # PYI016: Duplicate union member `str` + | ^^^ PYI016 +21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` + | + = help: Remove duplicate union member `str` + +ℹ Fix +17 17 | # Should emit in longer unions, even if not directly adjacent. +18 18 | field3: str | str | int # PYI016: Duplicate union member `str` +19 19 | field4: int | int | str # PYI016: Duplicate union member `int` +20 |-field5: str | int | str # PYI016: Duplicate union member `str` + 20 |+field5: str | int # PYI016: Duplicate union member `str` +21 21 | field6: int | bool | str | int # PYI016: Duplicate union member `int` +22 22 | +23 23 | # Shouldn't emit for non-type unions. + +PYI016.pyi:21:28: PYI016 [*] Duplicate union member `int` + | +19 | field4: int | int | str # 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 | +23 | # Shouldn't emit for non-type unions. + | + = help: Remove duplicate union member `int` + +ℹ Fix +18 18 | field3: str | str | int # PYI016: Duplicate union member `str` +19 19 | field4: int | int | str # PYI016: Duplicate union member `int` +20 20 | field5: str | int | str # PYI016: Duplicate union member `str` +21 |-field6: int | bool | str | int # PYI016: Duplicate union member `int` + 21 |+field6: int | bool | str # PYI016: Duplicate union member `int` +22 22 | +23 23 | # Shouldn't emit for non-type unions. +24 24 | field7 = str | str + +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 | +29 | # Should handle user brackets when fixing. + | + = help: Remove duplicate union member `int` + +ℹ Fix +24 24 | field7 = str | str +25 25 | +26 26 | # Should emit for strangely-bracketed unions. +27 |-field8: int | (str | int) # PYI016: Duplicate union member `int` + 27 |+field8: int | (str) # PYI016: Duplicate union member `int` +28 28 | +29 29 | # Should handle user brackets when fixing. +30 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` + +PYI016.pyi:30:16: PYI016 [*] Duplicate union member `int` + | +29 | # Should handle user brackets when fixing. +30 | field9: int | (int | str) # PYI016: Duplicate union member `int` + | ^^^ PYI016 +31 | field10: (str | int) | str # PYI016: Duplicate union member `str` + | + = help: Remove duplicate union member `int` + +ℹ Fix +27 27 | field8: int | (str | int) # PYI016: Duplicate union member `int` +28 28 | +29 29 | # Should handle user brackets when fixing. +30 |-field9: int | (int | str) # PYI016: Duplicate union member `int` + 30 |+field9: int | (str) # PYI016: Duplicate union member `int` +31 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` +32 32 | +33 33 | # Should emit for nested unions. + +PYI016.pyi:31:24: PYI016 [*] Duplicate union member `str` + | +29 | # Should handle user brackets when fixing. +30 | field9: int | (int | str) # PYI016: Duplicate union member `int` +31 | field10: (str | int) | str # PYI016: Duplicate union member `str` + | ^^^ PYI016 +32 | +33 | # Should emit for nested unions. + | + = help: Remove duplicate union member `str` + +ℹ Fix +28 28 | +29 29 | # Should handle user brackets when fixing. +30 30 | field9: int | (int | str) # PYI016: Duplicate union member `int` +31 |-field10: (str | int) | str # PYI016: Duplicate union member `str` + 31 |+field10: str | int # PYI016: Duplicate union member `str` +32 32 | +33 33 | # Should emit for nested unions. +34 34 | field11: dict[int | int, str] + +PYI016.pyi:34:21: PYI016 [*] Duplicate union member `int` + | +33 | # Should emit for nested unions. +34 | field11: dict[int | int, str] + | ^^^ PYI016 +35 | +36 | # Should emit for unions with more than two cases + | + = help: Remove duplicate union member `int` + +ℹ Fix +31 31 | field10: (str | int) | str # PYI016: Duplicate union member `str` +32 32 | +33 33 | # Should emit for nested unions. +34 |-field11: dict[int | int, str] + 34 |+field11: dict[int, str] +35 35 | +36 36 | # Should emit for unions with more than two cases +37 37 | field12: int | int | int # Error + +PYI016.pyi:37:16: PYI016 [*] Duplicate union member `int` + | +36 | # Should emit for unions with more than two cases +37 | field12: int | int | int # Error + | ^^^ PYI016 +38 | field13: int | int | int | int # Error + | + = help: Remove duplicate union member `int` + +ℹ Fix +34 34 | field11: dict[int | int, str] +35 35 | +36 36 | # Should emit for unions with more than two cases +37 |-field12: int | int | int # Error + 37 |+field12: int | int # Error +38 38 | field13: int | int | int | int # Error +39 39 | +40 40 | # Should emit for unions with more than two cases, even if not directly adjacent + +PYI016.pyi:37:22: PYI016 [*] Duplicate union member `int` + | +36 | # Should emit for unions with more than two cases +37 | field12: int | int | int # Error + | ^^^ PYI016 +38 | field13: int | int | int | int # Error + | + = help: Remove duplicate union member `int` + +ℹ Fix +34 34 | field11: dict[int | int, str] +35 35 | +36 36 | # Should emit for unions with more than two cases +37 |-field12: int | int | int # Error + 37 |+field12: int | int # Error +38 38 | field13: int | int | int | int # Error +39 39 | +40 40 | # Should emit for unions with more than two cases, even if not directly adjacent + +PYI016.pyi:38:16: PYI016 [*] Duplicate union member `int` + | +36 | # Should emit for unions with more than two cases +37 | field12: int | int | int # Error +38 | field13: int | int | int | int # Error + | ^^^ PYI016 +39 | +40 | # Should emit for unions with more than two cases, even if not directly adjacent + | + = help: Remove duplicate union member `int` + +ℹ Fix +35 35 | +36 36 | # Should emit for unions with more than two cases +37 37 | field12: int | int | int # Error +38 |-field13: int | int | int | int # Error + 38 |+field13: int | int | int # Error +39 39 | +40 40 | # Should emit for unions with more than two cases, even if not directly adjacent +41 41 | field14: int | int | str | int # Error + +PYI016.pyi:38:22: PYI016 [*] Duplicate union member `int` + | +36 | # Should emit for unions with more than two cases +37 | field12: int | int | int # Error +38 | field13: int | int | int | int # Error + | ^^^ PYI016 +39 | +40 | # Should emit for unions with more than two cases, even if not directly adjacent + | + = help: Remove duplicate union member `int` + +ℹ Fix +35 35 | +36 36 | # Should emit for unions with more than two cases +37 37 | field12: int | int | int # Error +38 |-field13: int | int | int | int # Error + 38 |+field13: int | int | int # Error +39 39 | +40 40 | # Should emit for unions with more than two cases, even if not directly adjacent +41 41 | field14: int | int | str | int # Error + +PYI016.pyi:38:28: PYI016 [*] Duplicate union member `int` + | +36 | # Should emit for unions with more than two cases +37 | field12: int | int | int # Error +38 | field13: int | int | int | int # Error + | ^^^ PYI016 +39 | +40 | # Should emit for unions with more than two cases, even if not directly adjacent + | + = help: Remove duplicate union member `int` + +ℹ Fix +35 35 | +36 36 | # Should emit for unions with more than two cases +37 37 | field12: int | int | int # Error +38 |-field13: int | int | int | int # Error + 38 |+field13: int | int | int # Error +39 39 | +40 40 | # Should emit for unions with more than two cases, even if not directly adjacent +41 41 | field14: int | int | str | int # Error + +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 | +43 | # Should emit for duplicate literal types; also covered by PYI030 + | + = help: Remove duplicate union member `int` + +ℹ Fix +38 38 | field13: int | int | int | int # Error +39 39 | +40 40 | # Should emit for unions with more than two cases, even if not directly adjacent +41 |-field14: int | int | str | int # Error + 41 |+field14: int | str | int # Error +42 42 | +43 43 | # Should emit for duplicate literal types; also covered by PYI030 +44 44 | field15: typing.Literal[1] | typing.Literal[1] # Error + +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 | +43 | # Should emit for duplicate literal types; also covered by PYI030 + | + = help: Remove duplicate union member `int` + +ℹ Fix +38 38 | field13: int | int | int | int # Error +39 39 | +40 40 | # Should emit for unions with more than two cases, even if not directly adjacent +41 |-field14: int | int | str | int # Error + 41 |+field14: int | int | str # Error +42 42 | +43 43 | # Should emit for duplicate literal types; also covered by PYI030 +44 44 | field15: typing.Literal[1] | typing.Literal[1] # Error + +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 | +46 | # Shouldn't emit if in new parent type + | + = help: Remove duplicate union member `typing.Literal[1]` + +ℹ Fix +41 41 | field14: int | int | str | int # Error +42 42 | +43 43 | # Should emit for duplicate literal types; also covered by PYI030 +44 |-field15: typing.Literal[1] | typing.Literal[1] # Error + 44 |+field15: typing.Literal[1] # Error +45 45 | +46 46 | # Shouldn't emit if in new parent type +47 47 | field16: int | dict[int, str] # OK + +PYI016.pyi:57:5: PYI016 Duplicate union member `set[int]` + | +55 | int # foo +56 | ], +57 | set[ + | _____^ +58 | | int # bar +59 | | ], + | |_____^ PYI016 +60 | ] # Error, newline and comment will not be emitted in message + | + = help: Remove duplicate union member `set[int]` + +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 | +65 | # Should emit in cases with nested `typing.Union` + | + = help: Remove duplicate union member `int` + +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 | +68 | # Should emit in cases with mixed `typing.Union` and `|` + | + = help: Remove duplicate union member `int` + +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 | +71 | # Should emit only once in cases with multiple nested `typing.Union` + | + = help: Remove duplicate union member `int` + +ℹ Fix +66 66 | field20: typing.Union[int, typing.Union[int, str]] # Error +67 67 | +68 68 | # Should emit in cases with mixed `typing.Union` and `|` +69 |-field21: typing.Union[int, int | str] # Error + 69 |+field21: typing.Union[int, str] # Error +70 70 | +71 71 | # Should emit only once in cases with multiple nested `typing.Union` +72 72 | field22: typing.Union[int, typing.Union[int, typing.Union[int, int]]] # Error + +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 | +74 | # Should emit in cases with newlines + | + = help: Remove duplicate union member `int` + +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 | +74 | # Should emit in cases with newlines + | + = help: Remove duplicate union member `int` + +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 | +74 | # Should emit in cases with newlines + | + = help: Remove duplicate union member `int` + +PYI016.pyi:76:12: PYI016 [*] Duplicate union member `set[int]` + | +74 | # Should emit in cases with newlines +75 | field23: set[ # foo +76 | int] | set[int] + | ^^^^^^^^ PYI016 +77 | +78 | # Should emit twice (once for each `int` in the nested union, both of which are + | + = help: Remove duplicate union member `set[int]` + +ℹ Fix +73 73 | +74 74 | # Should emit in cases with newlines +75 75 | field23: set[ # foo +76 |- int] | set[int] + 76 |+ int] +77 77 | +78 78 | # Should emit twice (once for each `int` in the nested union, both of which are +79 79 | # duplicates of the outer `int`), but not three times (which would indicate that + +PYI016.pyi:81:41: PYI016 Duplicate union member `int` + | +79 | # duplicates of the outer `int`), but not three times (which would indicate that +80 | # we incorrectly re-checked the nested union). +81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` + | ^^^ PYI016 +82 | +83 | # Should emit twice (once for each `int` in the nested union, both of which are + | + = help: Remove duplicate union member `int` + +PYI016.pyi:81:46: PYI016 Duplicate union member `int` + | +79 | # duplicates of the outer `int`), but not three times (which would indicate that +80 | # we incorrectly re-checked the nested union). +81 | field24: typing.Union[int, typing.Union[int, int]] # PYI016: Duplicate union member `int` + | ^^^ PYI016 +82 | +83 | # Should emit twice (once for each `int` in the nested union, both of which are + | + = help: Remove duplicate union member `int` + +PYI016.pyi:86:28: PYI016 [*] Duplicate union member `int` + | +84 | # duplicates of the outer `int`), but not three times (which would indicate that +85 | # we incorrectly re-checked the nested union). +86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` + | ^^^ PYI016 + | + = help: Remove duplicate union member `int` + +ℹ Fix +83 83 | # Should emit twice (once for each `int` in the nested union, both of which are +84 84 | # duplicates of the outer `int`), but not three times (which would indicate that +85 85 | # we incorrectly re-checked the nested union). +86 |-field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` + 86 |+field25: typing.Union[int, int] # PYI016: Duplicate union member `int` + +PYI016.pyi:86:34: PYI016 [*] Duplicate union member `int` + | +84 | # duplicates of the outer `int`), but not three times (which would indicate that +85 | # we incorrectly re-checked the nested union). +86 | field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` + | ^^^ PYI016 + | + = help: Remove duplicate union member `int` + +ℹ Fix +83 83 | # Should emit twice (once for each `int` in the nested union, both of which are +84 84 | # duplicates of the outer `int`), but not three times (which would indicate that +85 85 | # we incorrectly re-checked the nested union). +86 |-field25: typing.Union[int, int | int] # PYI016: Duplicate union member `int` + 86 |+field25: typing.Union[int, int] # PYI016: Duplicate union member `int` + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI017_PYI017.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI017_PYI017.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI017_PYI017.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..497a4e5cf6 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI017_PYI017.pyi.snap @@ -0,0 +1,44 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI017.pyi:4:1: PYI017 Stubs should not contain assignments to attributes or multiple targets + | +2 | a = var # OK +3 | +4 | b = c = int # PYI017 + | ^^^^^^^^^^^ PYI017 +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 | +6 | a.b = int # PYI017 + | ^^^^^^^^^ PYI017 +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 | + 8 | d, e = int, str # PYI017 + | ^^^^^^^^^^^^^^^ PYI017 + 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 | +10 | f, g, h = int, str, TypeVar("T") # PYI017 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI017 +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 new file mode 100644 index 0000000000..878d32f43d --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI018_PYI018.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI018.py:4:1: PYI018 Private TypeVar `_T` is never used + | +2 | from typing import TypeVar +3 | +4 | _T = typing.TypeVar("_T") + | ^^ PYI018 +5 | _P = TypeVar("_P") + | + +PYI018.py:5:1: PYI018 Private TypeVar `_P` is never used + | +4 | _T = typing.TypeVar("_T") +5 | _P = TypeVar("_P") + | ^^ PYI018 +6 | +7 | # 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 new file mode 100644 index 0000000000..d82b93d9b1 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI018_PYI018.pyi.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI018.pyi:4:1: PYI018 Private TypeVar `_T` is never used + | +2 | from typing import TypeVar +3 | +4 | _T = typing.TypeVar("_T") + | ^^ PYI018 +5 | _P = TypeVar("_P") + | + +PYI018.pyi:5:1: PYI018 Private TypeVar `_P` is never used + | +4 | _T = typing.TypeVar("_T") +5 | _P = TypeVar("_P") + | ^^ PYI018 +6 | +7 | # 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 new file mode 100644 index 0000000000..c40006ed27 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019.py.snap @@ -0,0 +1,45 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI019.py:7:62: PYI019 Methods like `__new__` should return `typing.Self` instead of a custom `TypeVar` + | +6 | class BadClass: +7 | def __new__(cls: type[_S], *args: str, **kwargs: int) -> _S: ... # PYI019 + | ^^ PYI019 + | + +PYI019.py:10:54: PYI019 Methods like `bad_instance_method` should return `typing.Self` instead of a custom `TypeVar` + | +10 | def bad_instance_method(self: _S, arg: bytes) -> _S: ... # PYI019 + | ^^ PYI019 + | + +PYI019.py:14:54: PYI019 Methods like `bad_class_method` should return `typing.Self` instead of a custom `TypeVar` + | +13 | @classmethod +14 | def bad_class_method(cls: type[_S], arg: int) -> _S: ... # PYI019 + | ^^ PYI019 + | + +PYI019.py:18:55: PYI019 Methods like `bad_posonly_class_method` should return `typing.Self` instead of a custom `TypeVar` + | +17 | @classmethod +18 | def bad_posonly_class_method(cls: type[_S], /) -> _S: ... # PYI019 + | ^^ PYI019 + | + +PYI019.py:39:63: PYI019 Methods like `__new__` should return `typing.Self` instead of a custom `TypeVar` + | +37 | # Python > 3.12 +38 | class PEP695BadDunderNew[T]: +39 | def __new__[S](cls: type[S], *args: Any, ** kwargs: Any) -> S: ... # PYI019 + | ^ PYI019 + | + +PYI019.py:42:46: PYI019 Methods like `generic_instance_method` should return `typing.Self` instead of a custom `TypeVar` + | +42 | def generic_instance_method[S](self: S) -> S: ... # PYI019 + | ^ 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 new file mode 100644 index 0000000000..979abf618f --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI019_PYI019.pyi.snap @@ -0,0 +1,45 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI019.pyi:7:62: PYI019 Methods like `__new__` should return `typing.Self` instead of a custom `TypeVar` + | +6 | class BadClass: +7 | def __new__(cls: type[_S], *args: str, **kwargs: int) -> _S: ... # PYI019 + | ^^ PYI019 + | + +PYI019.pyi:10:54: PYI019 Methods like `bad_instance_method` should return `typing.Self` instead of a custom `TypeVar` + | +10 | def bad_instance_method(self: _S, arg: bytes) -> _S: ... # PYI019 + | ^^ PYI019 + | + +PYI019.pyi:14:54: PYI019 Methods like `bad_class_method` should return `typing.Self` instead of a custom `TypeVar` + | +13 | @classmethod +14 | def bad_class_method(cls: type[_S], arg: int) -> _S: ... # PYI019 + | ^^ PYI019 + | + +PYI019.pyi:18:55: PYI019 Methods like `bad_posonly_class_method` should return `typing.Self` instead of a custom `TypeVar` + | +17 | @classmethod +18 | def bad_posonly_class_method(cls: type[_S], /) -> _S: ... # PYI019 + | ^^ PYI019 + | + +PYI019.pyi:39:63: PYI019 Methods like `__new__` should return `typing.Self` instead of a custom `TypeVar` + | +37 | # Python > 3.12 +38 | class PEP695BadDunderNew[T]: +39 | def __new__[S](cls: type[S], *args: Any, ** kwargs: Any) -> S: ... # PYI019 + | ^ PYI019 + | + +PYI019.pyi:42:46: PYI019 Methods like `generic_instance_method` should return `typing.Self` instead of a custom `TypeVar` + | +42 | def generic_instance_method[S](self: S) -> S: ... # PYI019 + | ^ PYI019 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI020_PYI020.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI020_PYI020.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI020_PYI020.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..b1f0e17403 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI020_PYI020.pyi.snap @@ -0,0 +1,187 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI020.pyi:7:10: PYI020 [*] Quoted annotations should not be included in stubs + | +5 | import typing_extensions +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 +9 | _T = TypeVar("_T", bound="int") # Y020 Quoted annotations should never be used in stubs + | + = help: Remove quotes + +ℹ Fix +4 4 | +5 5 | import typing_extensions +6 6 | +7 |-def f(x: "int"): ... # Y020 Quoted annotations should never be used in stubs + 7 |+def f(x: int): ... # Y020 Quoted annotations should never be used in stubs +8 8 | def g(x: list["int"]): ... # Y020 Quoted annotations should never be used in stubs +9 9 | _T = TypeVar("_T", bound="int") # Y020 Quoted annotations should never be used in stubs +10 10 | + +PYI020.pyi:8:15: PYI020 [*] Quoted annotations should not be included in stubs + | +7 | def f(x: "int"): ... # Y020 Quoted annotations should never be used in stubs +8 | def g(x: list["int"]): ... # Y020 Quoted annotations should never be used in stubs + | ^^^^^ PYI020 +9 | _T = TypeVar("_T", bound="int") # Y020 Quoted annotations should never be used in stubs + | + = help: Remove quotes + +ℹ Fix +5 5 | import typing_extensions +6 6 | +7 7 | def f(x: "int"): ... # Y020 Quoted annotations should never be used in stubs +8 |-def g(x: list["int"]): ... # Y020 Quoted annotations should never be used in stubs + 8 |+def g(x: list[int]): ... # Y020 Quoted annotations should never be used in stubs +9 9 | _T = TypeVar("_T", bound="int") # Y020 Quoted annotations should never be used in stubs +10 10 | +11 11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ... + +PYI020.pyi:9:26: PYI020 [*] Quoted annotations should not be included in stubs + | + 7 | def f(x: "int"): ... # Y020 Quoted annotations should never be used 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 | +11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ... + | + = help: Remove quotes + +ℹ Fix +6 6 | +7 7 | def f(x: "int"): ... # Y020 Quoted annotations should never be used in stubs +8 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 + 9 |+_T = TypeVar("_T", bound=int) # Y020 Quoted annotations should never be used in stubs +10 10 | +11 11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ... +12 12 | + +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 | +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 + | + = help: Remove quotes + +ℹ Fix +10 10 | +11 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 + 13 |+def j() -> int: ... # Y020 Quoted annotations should never be used in stubs +14 14 | Alias: TypeAlias = list["int"] # Y020 Quoted annotations should never be used in stubs +15 15 | +16 16 | class Child(list["int"]): # Y020 Quoted annotations should never be used in stubs + +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 | +16 | class Child(list["int"]): # Y020 Quoted annotations should never be used in stubs + | + = help: Remove quotes + +ℹ Fix +11 11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ... +12 12 | +13 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 + 14 |+Alias: TypeAlias = list[int] # Y020 Quoted annotations should never be used in stubs +15 15 | +16 16 | class Child(list["int"]): # Y020 Quoted annotations should never be used in stubs +17 17 | """Documented and guaranteed useful.""" # Y021 Docstrings 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 | +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 + | + = help: Remove quotes + +ℹ Fix +13 13 | def j() -> "int": ... # Y020 Quoted annotations should never be used in stubs +14 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 + 16 |+class Child(list[int]): # Y020 Quoted annotations should never be used in stubs +17 17 | """Documented and guaranteed useful.""" # Y021 Docstrings should not be included in stubs +18 18 | +19 19 | if sys.platform == "linux": + +PYI020.pyi:20:8: PYI020 [*] Quoted annotations should not be included in stubs + | +19 | if sys.platform == "linux": +20 | f: "int" # Y020 Quoted annotations should never be used in stubs + | ^^^^^ PYI020 +21 | elif sys.platform == "win32": +22 | f: "str" # Y020 Quoted annotations should never be used in stubs + | + = help: Remove quotes + +ℹ Fix +17 17 | """Documented and guaranteed useful.""" # Y021 Docstrings should not be included in stubs +18 18 | +19 19 | if sys.platform == "linux": +20 |- f: "int" # Y020 Quoted annotations should never be used in stubs + 20 |+ f: int # Y020 Quoted annotations should never be used in stubs +21 21 | elif sys.platform == "win32": +22 22 | f: "str" # Y020 Quoted annotations should never be used in stubs +23 23 | else: + +PYI020.pyi:22:8: PYI020 [*] Quoted annotations should not be included in stubs + | +20 | f: "int" # Y020 Quoted annotations should never be used in stubs +21 | elif sys.platform == "win32": +22 | f: "str" # Y020 Quoted annotations should never be used in stubs + | ^^^^^ PYI020 +23 | else: +24 | f: "bytes" # Y020 Quoted annotations should never be used in stubs + | + = help: Remove quotes + +ℹ Fix +19 19 | if sys.platform == "linux": +20 20 | f: "int" # Y020 Quoted annotations should never be used in stubs +21 21 | elif sys.platform == "win32": +22 |- f: "str" # Y020 Quoted annotations should never be used in stubs + 22 |+ f: str # Y020 Quoted annotations should never be used in stubs +23 23 | else: +24 24 | f: "bytes" # Y020 Quoted annotations should never be used in stubs +25 25 | + +PYI020.pyi:24:8: PYI020 [*] Quoted annotations should not be included in stubs + | +22 | f: "str" # Y020 Quoted annotations should never be used in stubs +23 | else: +24 | f: "bytes" # Y020 Quoted annotations should never be used in stubs + | ^^^^^^^ PYI020 +25 | +26 | # These two shouldn't trigger Y020 -- empty strings can't be "quoted annotations" + | + = help: Remove quotes + +ℹ Fix +21 21 | elif sys.platform == "win32": +22 22 | f: "str" # Y020 Quoted annotations should never be used in stubs +23 23 | else: +24 |- f: "bytes" # Y020 Quoted annotations should never be used in stubs + 24 |+ f: bytes # Y020 Quoted annotations should never be used in stubs +25 25 | +26 26 | # These two shouldn't trigger Y020 -- empty strings can't be "quoted annotations" +27 27 | k = "" # Y052 Need type annotation for "k" + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI021_PYI021.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI021_PYI021.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI021_PYI021.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..618a337526 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI021_PYI021.pyi.snap @@ -0,0 +1,30 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI021.pyi:1:1: PYI021 Docstrings should not be included in stubs + | +1 | """foo""" # ERROR PYI021 + | ^^^^^^^^^ PYI021 +2 | +3 | def foo(): + | + +PYI021.pyi:4:5: PYI021 Docstrings should not be included in stubs + | +3 | def foo(): +4 | """foo""" # ERROR PYI021 + | ^^^^^^^^^ PYI021 +5 | +6 | class Bar: + | + +PYI021.pyi:7:5: PYI021 Docstrings should not be included in stubs + | +6 | class Bar: +7 | """bar""" # ERROR PYI021 + | ^^^^^^^^^ PYI021 +8 | +9 | def bar(): + | + + 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 new file mode 100644 index 0000000000..4f25453dce --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI024_PYI024.py.snap @@ -0,0 +1,37 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI024.py:3:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` + | +1 | import collections +2 | +3 | person: collections.namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" + | ^^^^^^^^^^^^^^^^^^^^^^ PYI024 +4 | +5 | from collections import namedtuple + | + = help: Replace with `typing.NamedTuple` + +PYI024.py:7:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` + | +5 | from collections import namedtuple +6 | +7 | person: namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" + | ^^^^^^^^^^ PYI024 +8 | +9 | person = namedtuple( + | + = help: Replace with `typing.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 | + 9 | person = namedtuple( + | ^^^^^^^^^^ PYI024 +10 | "Person", ["name", "age"] +11 | ) # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" + | + = help: Replace with `typing.NamedTuple` + + 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 new file mode 100644 index 0000000000..6c28b654a4 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI024_PYI024.pyi.snap @@ -0,0 +1,37 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI024.pyi:3:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` + | +1 | import collections +2 | +3 | person: collections.namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" + | ^^^^^^^^^^^^^^^^^^^^^^ PYI024 +4 | +5 | from collections import namedtuple + | + = help: Replace with `typing.NamedTuple` + +PYI024.pyi:7:9: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` + | +5 | from collections import namedtuple +6 | +7 | person: namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" + | ^^^^^^^^^^ PYI024 +8 | +9 | person = namedtuple( + | + = help: Replace with `typing.NamedTuple` + +PYI024.pyi:9:10: PYI024 Use `typing.NamedTuple` instead of `collections.namedtuple` + | + 7 | person: namedtuple # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" + 8 | + 9 | person = namedtuple( + | ^^^^^^^^^^ PYI024 +10 | "Person", ["name", "age"] +11 | ) # Y024 Use "typing.NamedTuple" instead of "collections.namedtuple" + | + = help: Replace with `typing.NamedTuple` + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025.py.snap new file mode 100644 index 0000000000..2bebd50a8d --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025.py.snap @@ -0,0 +1,46 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI025.py:10:33: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin + | + 9 | def f(): +10 | from collections.abc import Set # PYI025 + | ^^^ PYI025 + | + = help: Alias `Set` to `AbstractSet` + +ℹ Suggested fix +7 7 | +8 8 | +9 9 | def f(): +10 |- from collections.abc import Set # PYI025 + 10 |+ from collections.abc import Set as AbstractSet # PYI025 +11 11 | +12 12 | +13 13 | def f(): + +PYI025.py:14:51: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin + | +13 | def f(): +14 | from collections.abc import Container, Sized, Set, ValuesView # PYI025 + | ^^^ PYI025 +15 | +16 | GLOBAL: Set[int] = set() + | + = help: Alias `Set` to `AbstractSet` + +ℹ Suggested fix +11 11 | +12 12 | +13 13 | def f(): +14 |- from collections.abc import Container, Sized, Set, ValuesView # PYI025 + 14 |+ from collections.abc import Container, Sized, Set as AbstractSet, ValuesView # PYI025 +15 15 | +16 |- GLOBAL: Set[int] = set() + 16 |+ GLOBAL: AbstractSet[int] = set() +17 17 | +18 18 | class Class: +19 |- member: Set[int] + 19 |+ member: AbstractSet[int] + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025.pyi.snap new file mode 100644 index 0000000000..51afedd7f8 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI025_PYI025.pyi.snap @@ -0,0 +1,149 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI025.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 | +10 | def f(): + | + = help: Alias `Set` to `AbstractSet` + +ℹ Suggested fix +5 5 | from collections.abc import Container, Sized, Set as AbstractSet, ValuesView # Ok +6 6 | +7 7 | def f(): +8 |- from collections.abc import Set # PYI025 + 8 |+ from collections.abc import Set as AbstractSet # PYI025 +9 9 | +10 10 | def f(): +11 11 | from collections.abc import Container, Sized, Set, ValuesView # PYI025 + +PYI025.pyi:11:51: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin + | +10 | def f(): +11 | from collections.abc import Container, Sized, Set, ValuesView # PYI025 + | ^^^ PYI025 +12 | +13 | def f(): + | + = help: Alias `Set` to `AbstractSet` + +ℹ Suggested fix +8 8 | from collections.abc import Set # PYI025 +9 9 | +10 10 | def f(): +11 |- from collections.abc import Container, Sized, Set, ValuesView # PYI025 + 11 |+ from collections.abc import Container, Sized, Set as AbstractSet, ValuesView # PYI025 +12 12 | +13 13 | def f(): +14 14 | """Test: local symbol renaming.""" + +PYI025.pyi:16:37: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin + | +14 | """Test: local symbol renaming.""" +15 | if True: +16 | from collections.abc import Set + | ^^^ PYI025 +17 | else: +18 | Set = 1 + | + = help: Alias `Set` to `AbstractSet` + +ℹ Suggested fix +13 13 | def f(): +14 14 | """Test: local symbol renaming.""" +15 15 | if True: +16 |- from collections.abc import Set + 16 |+ from collections.abc import Set as AbstractSet +17 17 | else: +18 |- Set = 1 + 18 |+ AbstractSet = 1 +19 19 | +20 20 | x: Set = set() +21 21 | +22 22 | x: Set +23 23 | +24 |- del Set + 24 |+ del AbstractSet +25 25 | +26 26 | def f(): +27 |- print(Set) + 27 |+ print(AbstractSet) +28 28 | +29 29 | def Set(): +30 30 | pass + +PYI025.pyi:33:29: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin + | +31 | print(Set) +32 | +33 | from collections.abc import Set + | ^^^ PYI025 +34 | +35 | def f(): + | + = help: Alias `Set` to `AbstractSet` + +ℹ Suggested fix +17 17 | else: +18 18 | Set = 1 +19 19 | +20 |- x: Set = set() + 20 |+ x: AbstractSet = set() +21 21 | +22 |- x: Set + 22 |+ x: AbstractSet +23 23 | +24 24 | del Set +25 25 | +-------------------------------------------------------------------------------- +30 30 | pass +31 31 | print(Set) +32 32 | +33 |-from collections.abc import Set + 33 |+from collections.abc import Set as AbstractSet +34 34 | +35 35 | def f(): +36 36 | """Test: global symbol renaming.""" +37 |- global Set + 37 |+ global AbstractSet +38 38 | +39 |- Set = 1 +40 |- print(Set) + 39 |+ AbstractSet = 1 + 40 |+ print(AbstractSet) +41 41 | +42 42 | def f(): +43 43 | """Test: nonlocal symbol renaming.""" + +PYI025.pyi:44:33: PYI025 [*] Use `from collections.abc import Set as AbstractSet` to avoid confusion with the `set` builtin + | +42 | def f(): +43 | """Test: nonlocal symbol renaming.""" +44 | from collections.abc import Set + | ^^^ PYI025 +45 | +46 | def g(): + | + = help: Alias `Set` to `AbstractSet` + +ℹ Suggested fix +41 41 | +42 42 | def f(): +43 43 | """Test: nonlocal symbol renaming.""" +44 |- from collections.abc import Set + 44 |+ from collections.abc import Set as AbstractSet +45 45 | +46 46 | def g(): +47 |- nonlocal Set + 47 |+ nonlocal AbstractSet +48 48 | +49 |- Set = 1 +50 |- print(Set) + 49 |+ AbstractSet = 1 + 50 |+ print(AbstractSet) + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI026_PYI026.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI026_PYI026.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI026_PYI026.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..b4c117f2ec --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI026_PYI026.pyi.snap @@ -0,0 +1,117 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI026.pyi:3:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `NewAny: TypeAlias = Any` + | +1 | from typing import Literal, Any +2 | +3 | NewAny = Any + | ^^^^^^ PYI026 +4 | OptionalStr = typing.Optional[str] +5 | Foo = Literal["foo"] + | + = help: Add `TypeAlias` annotation + +ℹ Suggested fix +1 |-from typing import Literal, Any + 1 |+from typing import Literal, Any, TypeAlias +2 2 | +3 |-NewAny = Any + 3 |+NewAny: TypeAlias = Any +4 4 | OptionalStr = typing.Optional[str] +5 5 | Foo = Literal["foo"] +6 6 | IntOrStr = int | str + +PYI026.pyi:4:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `OptionalStr: TypeAlias = typing.Optional[str]` + | +3 | NewAny = Any +4 | OptionalStr = typing.Optional[str] + | ^^^^^^^^^^^ PYI026 +5 | Foo = Literal["foo"] +6 | IntOrStr = int | str + | + = help: Add `TypeAlias` annotation + +ℹ Suggested fix +1 |-from typing import Literal, Any + 1 |+from typing import Literal, Any, TypeAlias +2 2 | +3 3 | NewAny = Any +4 |-OptionalStr = typing.Optional[str] + 4 |+OptionalStr: TypeAlias = typing.Optional[str] +5 5 | Foo = Literal["foo"] +6 6 | IntOrStr = int | str +7 7 | AliasNone = None + +PYI026.pyi:5:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `Foo: TypeAlias = Literal["foo"]` + | +3 | NewAny = Any +4 | OptionalStr = typing.Optional[str] +5 | Foo = Literal["foo"] + | ^^^ PYI026 +6 | IntOrStr = int | str +7 | AliasNone = None + | + = help: Add `TypeAlias` annotation + +ℹ Suggested fix +1 |-from typing import Literal, Any + 1 |+from typing import Literal, Any, TypeAlias +2 2 | +3 3 | NewAny = Any +4 4 | OptionalStr = typing.Optional[str] +5 |-Foo = Literal["foo"] + 5 |+Foo: TypeAlias = Literal["foo"] +6 6 | IntOrStr = int | str +7 7 | AliasNone = None +8 8 | + +PYI026.pyi:6:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `IntOrStr: TypeAlias = int | str` + | +4 | OptionalStr = typing.Optional[str] +5 | Foo = Literal["foo"] +6 | IntOrStr = int | str + | ^^^^^^^^ PYI026 +7 | AliasNone = None + | + = help: Add `TypeAlias` annotation + +ℹ Suggested fix +1 |-from typing import Literal, Any + 1 |+from typing import Literal, Any, TypeAlias +2 2 | +3 3 | NewAny = Any +4 4 | OptionalStr = typing.Optional[str] +5 5 | Foo = Literal["foo"] +6 |-IntOrStr = int | str + 6 |+IntOrStr: TypeAlias = int | str +7 7 | AliasNone = None +8 8 | +9 9 | NewAny: typing.TypeAlias = Any + +PYI026.pyi:7:1: PYI026 [*] Use `typing.TypeAlias` for type alias, e.g., `AliasNone: TypeAlias = None` + | +5 | Foo = Literal["foo"] +6 | IntOrStr = int | str +7 | AliasNone = None + | ^^^^^^^^^ PYI026 +8 | +9 | NewAny: typing.TypeAlias = Any + | + = help: Add `TypeAlias` annotation + +ℹ Suggested fix +1 |-from typing import Literal, Any + 1 |+from typing import Literal, Any, TypeAlias +2 2 | +3 3 | NewAny = Any +4 4 | OptionalStr = typing.Optional[str] +5 5 | Foo = Literal["foo"] +6 6 | IntOrStr = int | str +7 |-AliasNone = None + 7 |+AliasNone: TypeAlias = None +8 8 | +9 9 | NewAny: typing.TypeAlias = Any +10 10 | OptionalStr: TypeAlias = typing.Optional[str] + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI029_PYI029.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI029_PYI029.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI029_PYI029.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..69f694dc8e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI029_PYI029.pyi.snap @@ -0,0 +1,62 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +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 | +12 | class ShouldRemove: + | + = help: Remove definition of `str` + +ℹ Fix +7 7 | def __repr__(self, *, foo) -> str: ... +8 8 | +9 9 | class ShouldRemoveSingle: +10 |- def __str__(self) -> builtins.str: ... # Error: PYI029 + 10 |+ pass # Error: PYI029 +11 11 | +12 12 | class ShouldRemove: +13 13 | def __repr__(self) -> str: ... # Error: PYI029 + +PYI029.pyi:13:9: PYI029 [*] Defining `__repr__` in a stub is almost always redundant + | +12 | class ShouldRemove: +13 | def __repr__(self) -> str: ... # Error: PYI029 + | ^^^^^^^^ PYI029 +14 | def __str__(self) -> builtins.str: ... # Error: PYI029 + | + = help: Remove definition of `repr` + +ℹ Fix +10 10 | def __str__(self) -> builtins.str: ... # Error: PYI029 +11 11 | +12 12 | class ShouldRemove: +13 |- def __repr__(self) -> str: ... # Error: PYI029 +14 13 | def __str__(self) -> builtins.str: ... # Error: PYI029 +15 14 | +16 15 | class NoReturnSpecified: + +PYI029.pyi:14:9: PYI029 [*] Defining `__str__` in a stub is almost always redundant + | +12 | class ShouldRemove: +13 | def __repr__(self) -> str: ... # Error: PYI029 +14 | def __str__(self) -> builtins.str: ... # Error: PYI029 + | ^^^^^^^ PYI029 +15 | +16 | class NoReturnSpecified: + | + = help: Remove definition of `str` + +ℹ Fix +11 11 | +12 12 | class ShouldRemove: +13 13 | def __repr__(self) -> str: ... # Error: PYI029 +14 |- def __str__(self) -> builtins.str: ... # Error: PYI029 +15 14 | +16 15 | class NoReturnSpecified: +17 16 | def __str__(self): ... + + 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 new file mode 100644 index 0000000000..8f6838bde1 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.py.snap @@ -0,0 +1,110 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +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 | +11 | # Should emit for union types in arguments. + | + +PYI030.py:12:17: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +11 | # Should emit for union types in arguments. +12 | def func1(arg1: Literal[1] | Literal[2]): # Error + | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +13 | print(arg1) + | + +PYI030.py:17:16: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +16 | # Should emit for unions in return types. +17 | def func2() -> Literal[1] | Literal[2]: # Error + | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +18 | return "my Literal[1]ing" + | + +PYI030.py:22:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +21 | # Should emit in longer unions, even if not directly adjacent. +22 | field3: Literal[1] | Literal[2] | str # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +23 | field4: str | Literal[1] | Literal[2] # Error +24 | field5: Literal[1] | str | Literal[2] # Error + | + +PYI030.py:23:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +21 | # Should emit in longer unions, even if not directly adjacent. +22 | field3: Literal[1] | Literal[2] | str # Error +23 | field4: str | Literal[1] | Literal[2] # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +24 | field5: Literal[1] | str | Literal[2] # Error +25 | field6: Literal[1] | bool | Literal[2] | str # Error + | + +PYI030.py:24:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +22 | field3: Literal[1] | Literal[2] | str # Error +23 | field4: str | Literal[1] | Literal[2] # Error +24 | field5: Literal[1] | str | Literal[2] # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +25 | field6: Literal[1] | bool | Literal[2] | str # Error + | + +PYI030.py:25:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +23 | field4: str | Literal[1] | Literal[2] # Error +24 | field5: Literal[1] | str | Literal[2] # Error +25 | field6: Literal[1] | bool | Literal[2] | str # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +26 | +27 | # Should emit for non-type unions. + | + +PYI030.py:28:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +27 | # Should emit for non-type unions. +28 | field7 = Literal[1] | Literal[2] # Error + | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +29 | +30 | # Should emit for parenthesized unions. + | + +PYI030.py:31:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +30 | # Should emit for parenthesized unions. +31 | field8: Literal[1] | (Literal[2] | str) # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +32 | +33 | # Should handle user parentheses when fixing. + | + +PYI030.py:34:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +33 | # Should handle user parentheses when fixing. +34 | field9: Literal[1] | (Literal[2] | str) # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +35 | field10: (Literal[1] | str) | Literal[2] # Error + | + +PYI030.py:35:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +33 | # Should handle user parentheses when fixing. +34 | field9: Literal[1] | (Literal[2] | str) # Error +35 | field10: (Literal[1] | str) | Literal[2] # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +36 | +37 | # Should emit for union in generic parent type. + | + +PYI030.py:38:15: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +37 | # Should emit for union in generic parent type. +38 | field11: dict[Literal[1] | Literal[2], str] # Error + | ^^^^^^^^^^^^^^^^^^^^^^^ 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 new file mode 100644 index 0000000000..6e9214a8a4 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI030_PYI030.pyi.snap @@ -0,0 +1,233 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +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 | +11 | # Should emit for union types in arguments. + | + +PYI030.pyi:12:17: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +11 | # Should emit for union types in arguments. +12 | def func1(arg1: Literal[1] | Literal[2]): # Error + | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +13 | print(arg1) + | + +PYI030.pyi:17:16: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +16 | # Should emit for unions in return types. +17 | def func2() -> Literal[1] | Literal[2]: # Error + | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +18 | return "my Literal[1]ing" + | + +PYI030.pyi:22:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +21 | # Should emit in longer unions, even if not directly adjacent. +22 | field3: Literal[1] | Literal[2] | str # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +23 | field4: str | Literal[1] | Literal[2] # Error +24 | field5: Literal[1] | str | Literal[2] # Error + | + +PYI030.pyi:23:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +21 | # Should emit in longer unions, even if not directly adjacent. +22 | field3: Literal[1] | Literal[2] | str # Error +23 | field4: str | Literal[1] | Literal[2] # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +24 | field5: Literal[1] | str | Literal[2] # Error +25 | field6: Literal[1] | bool | Literal[2] | str # Error + | + +PYI030.pyi:24:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +22 | field3: Literal[1] | Literal[2] | str # Error +23 | field4: str | Literal[1] | Literal[2] # Error +24 | field5: Literal[1] | str | Literal[2] # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +25 | field6: Literal[1] | bool | Literal[2] | str # Error + | + +PYI030.pyi:25:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +23 | field4: str | Literal[1] | Literal[2] # Error +24 | field5: Literal[1] | str | Literal[2] # Error +25 | field6: Literal[1] | bool | Literal[2] | str # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +26 | +27 | # Should emit for non-type unions. + | + +PYI030.pyi:28:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +27 | # Should emit for non-type unions. +28 | field7 = Literal[1] | Literal[2] # Error + | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +29 | +30 | # Should emit for parenthesized unions. + | + +PYI030.pyi:31:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +30 | # Should emit for parenthesized unions. +31 | field8: Literal[1] | (Literal[2] | str) # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +32 | +33 | # Should handle user parentheses when fixing. + | + +PYI030.pyi:34:9: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +33 | # Should handle user parentheses when fixing. +34 | field9: Literal[1] | (Literal[2] | str) # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +35 | field10: (Literal[1] | str) | Literal[2] # Error + | + +PYI030.pyi:35:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +33 | # Should handle user parentheses when fixing. +34 | field9: Literal[1] | (Literal[2] | str) # Error +35 | field10: (Literal[1] | str) | Literal[2] # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +36 | +37 | # Should emit for union in generic parent type. + | + +PYI030.pyi:38:15: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +37 | # Should emit for union in generic parent type. +38 | field11: dict[Literal[1] | Literal[2], str] # Error + | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +39 | +40 | # Should emit for unions with more than two cases + | + +PYI030.pyi:41:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3]` + | +40 | # Should emit for unions with more than two cases +41 | field12: Literal[1] | Literal[2] | Literal[3] # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +42 | field13: Literal[1] | Literal[2] | Literal[3] | Literal[4] # Error + | + +PYI030.pyi:42:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` + | +40 | # Should emit for unions with more than two cases +41 | field12: Literal[1] | Literal[2] | Literal[3] # Error +42 | field13: Literal[1] | Literal[2] | Literal[3] | Literal[4] # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +43 | +44 | # Should emit for unions with more than two cases, even if not directly adjacent + | + +PYI030.pyi:45:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3]` + | +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 | +47 | # Should emit for unions with mixed literal internal types + | + +PYI030.pyi:48:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, "foo", True]` + | +47 | # Should emit for unions with mixed literal internal types +48 | field15: Literal[1] | Literal["foo"] | Literal[True] # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +49 | +50 | # Shouldn't emit for duplicate field types with same value; covered by Y016 + | + +PYI030.pyi:51:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 1]` + | +50 | # Shouldn't emit for duplicate field types with same value; covered by Y016 +51 | field16: Literal[1] | Literal[1] # OK + | ^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +52 | +53 | # Shouldn't emit if in new parent type + | + +PYI030.pyi:60:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +59 | # Should respect name of literal type used +60 | field19: typing.Literal[1] | typing.Literal[2] # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +61 | +62 | # Should emit in cases with newlines + | + +PYI030.pyi:63:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +62 | # Should emit in cases with newlines +63 | field20: typing.Union[ + | __________^ +64 | | Literal[ +65 | | 1 # test +66 | | ], +67 | | Literal[2], +68 | | ] # Error, newline and comment will not be emitted in message + | |_^ PYI030 +69 | +70 | # Should handle multiple unions with multiple members + | + +PYI030.pyi:71:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` + | +70 | # Should handle multiple unions with multiple members +71 | field21: Literal[1, 2] | Literal[3, 4] # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +72 | +73 | # Should emit in cases with `typing.Union` instead of `|` + | + +PYI030.pyi:74:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +73 | # Should emit in cases with `typing.Union` instead of `|` +74 | field22: typing.Union[Literal[1], Literal[2]] # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +75 | +76 | # Should emit in cases with `typing_extensions.Literal` + | + +PYI030.pyi:77:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +76 | # Should emit in cases with `typing_extensions.Literal` +77 | field23: typing_extensions.Literal[1] | typing_extensions.Literal[2] # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +78 | +79 | # Should emit in cases with nested `typing.Union` + | + +PYI030.pyi:80:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +79 | # Should emit in cases with nested `typing.Union` +80 | field24: typing.Union[Literal[1], typing.Union[Literal[2], str]] # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +81 | +82 | # Should emit in cases with mixed `typing.Union` and `|` + | + +PYI030.pyi:83:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2]` + | +82 | # Should emit in cases with mixed `typing.Union` and `|` +83 | field25: typing.Union[Literal[1], Literal[2] | str] # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI030 +84 | +85 | # Should emit only once in cases with multiple nested `typing.Union` + | + +PYI030.pyi:86:10: PYI030 Multiple literal members in a union. Use a single literal, e.g. `Literal[1, 2, 3, 4]` + | +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 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.py.snap new file mode 100644 index 0000000000..88482baa6e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.py.snap @@ -0,0 +1,42 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI032.py:6:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to `__eq__` + | +5 | class Bad: +6 | def __eq__(self, other: Any) -> bool: ... # Y032 + | ^^^ PYI032 +7 | def __ne__(self, other: typing.Any) -> typing.Any: ... # Y032 + | + = help: Replace with `object` + +ℹ Fix +3 3 | +4 4 | +5 5 | class Bad: +6 |- def __eq__(self, other: Any) -> bool: ... # Y032 + 6 |+ def __eq__(self, other: object) -> bool: ... # Y032 +7 7 | def __ne__(self, other: typing.Any) -> typing.Any: ... # Y032 +8 8 | +9 9 | + +PYI032.py:7:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to `__ne__` + | +5 | class Bad: +6 | def __eq__(self, other: Any) -> bool: ... # Y032 +7 | def __ne__(self, other: typing.Any) -> typing.Any: ... # Y032 + | ^^^^^^^^^^ PYI032 + | + = help: Replace with `object` + +ℹ Fix +4 4 | +5 5 | class Bad: +6 6 | def __eq__(self, other: Any) -> bool: ... # Y032 +7 |- def __ne__(self, other: typing.Any) -> typing.Any: ... # Y032 + 7 |+ def __ne__(self, other: object) -> typing.Any: ... # Y032 +8 8 | +9 9 | +10 10 | class Good: + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.pyi.snap new file mode 100644 index 0000000000..f79803bb72 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI032_PYI032.pyi.snap @@ -0,0 +1,42 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI032.pyi:6:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to `__eq__` + | +5 | class Bad: +6 | def __eq__(self, other: Any) -> bool: ... # Y032 + | ^^^ PYI032 +7 | def __ne__(self, other: typing.Any) -> typing.Any: ... # Y032 + | + = help: Replace with `object` + +ℹ Fix +3 3 | +4 4 | +5 5 | class Bad: +6 |- def __eq__(self, other: Any) -> bool: ... # Y032 + 6 |+ def __eq__(self, other: object) -> bool: ... # Y032 +7 7 | def __ne__(self, other: typing.Any) -> typing.Any: ... # Y032 +8 8 | +9 9 | + +PYI032.pyi:7:29: PYI032 [*] Prefer `object` to `Any` for the second parameter to `__ne__` + | +5 | class Bad: +6 | def __eq__(self, other: Any) -> bool: ... # Y032 +7 | def __ne__(self, other: typing.Any) -> typing.Any: ... # Y032 + | ^^^^^^^^^^ PYI032 + | + = help: Replace with `object` + +ℹ Fix +4 4 | +5 5 | class Bad: +6 6 | def __eq__(self, other: Any) -> bool: ... # Y032 +7 |- def __ne__(self, other: typing.Any) -> typing.Any: ... # Y032 + 7 |+ def __ne__(self, other: object) -> typing.Any: ... # Y032 +8 8 | +9 9 | +10 10 | class Good: + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI033_PYI033.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI033_PYI033.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI033_PYI033.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..9e6ec21774 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI033_PYI033.pyi.snap @@ -0,0 +1,106 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +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") + | + +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") + | + +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") + | + +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") + | + +PYI033.pyi:10:20: PYI033 Don't use type comments in stub file + | + 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") +10 | E: TypeAlias = None# type: int # Y033 Do not use type comments in stubs (e.g. use "x: int" instead of "x = ... # type: int") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 +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.pyi:11:20: PYI033 Don't use type comments in stub file + | + 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") +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 | +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 | ): ... + | + +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 | ): ... + | + +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 + | + +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 | +31 | class Bar: + | + +PYI033.pyi:32:26: PYI033 Don't use type comments in stub file + | +31 | class Bar: +32 | N: TypeAlias = None # type: can't parse me either! + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI033 +33 | # This whole line is commented out and indented # type: str + | + + 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 new file mode 100644 index 0000000000..9b00478bf5 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.py.snap @@ -0,0 +1,92 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI034.py:19:9: PYI034 `__new__` methods in classes like `Bad` usually return `self` at runtime + | +17 | object +18 | ): # Y040 Do not inherit from "object" explicitly, as it is redundant in Python 3 +19 | def __new__(cls, *args: Any, **kwargs: Any) -> Bad: + | ^^^^^^^ PYI034 +20 | ... # 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: ..." + | + = help: Consider using `typing_extensions.Self` as return type + +PYI034.py:34:9: PYI034 `__enter__` methods in classes like `Bad` usually return `self` at runtime + | +32 | ... # Y032 Prefer "object" to "Any" for the second parameter in "__ne__" methods +33 | +34 | def __enter__(self) -> Bad: + | ^^^^^^^^^ PYI034 +35 | ... # 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: ..." + | + = help: Consider using `typing_extensions.Self` as return type + +PYI034.py:37:15: PYI034 `__aenter__` methods in classes like `Bad` usually return `self` at runtime + | +35 | ... # 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: ..." +36 | +37 | async def __aenter__(self) -> Bad: + | ^^^^^^^^^^ PYI034 +38 | ... # 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: ..." + | + = help: Consider using `typing_extensions.Self` as return type + +PYI034.py:40:9: PYI034 `__iadd__` methods in classes like `Bad` usually return `self` at runtime + | +38 | ... # 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: ..." +39 | +40 | def __iadd__(self, other: Bad) -> Bad: + | ^^^^^^^^ PYI034 +41 | ... # 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: ..." + | + = help: Consider using `typing_extensions.Self` as return type + +PYI034.py:163:9: PYI034 `__iter__` methods in classes like `BadIterator1` usually return `self` at runtime + | +162 | class BadIterator1(Iterator[int]): +163 | def __iter__(self) -> Iterator[int]: + | ^^^^^^^^ PYI034 +164 | ... # 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: ..." + | + = help: Consider using `typing_extensions.Self` as return type + +PYI034.py:170:9: PYI034 `__iter__` methods in classes like `BadIterator2` usually return `self` at runtime + | +168 | typing.Iterator[int] +169 | ): # Y022 Use "collections.abc.Iterator[T]" instead of "typing.Iterator[T]" (PEP 585 syntax) +170 | def __iter__(self) -> Iterator[int]: + | ^^^^^^^^ PYI034 +171 | ... # 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: ..." + | + = help: Consider using `typing_extensions.Self` as return type + +PYI034.py:177:9: PYI034 `__iter__` methods in classes like `BadIterator3` usually return `self` at runtime + | +175 | typing.Iterator[int] +176 | ): # Y022 Use "collections.abc.Iterator[T]" instead of "typing.Iterator[T]" (PEP 585 syntax) +177 | def __iter__(self) -> collections.abc.Iterator[int]: + | ^^^^^^^^ PYI034 +178 | ... # 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: ..." + | + = help: Consider using `typing_extensions.Self` as return type + +PYI034.py:183:9: PYI034 `__iter__` methods in classes like `BadIterator4` usually return `self` at runtime + | +181 | class BadIterator4(Iterator[int]): +182 | # Note: *Iterable*, not *Iterator*, returned! +183 | def __iter__(self) -> Iterable[int]: + | ^^^^^^^^ PYI034 +184 | ... # 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: ..." + | + = help: Consider using `typing_extensions.Self` as return type + +PYI034.py:193:9: PYI034 `__aiter__` methods in classes like `BadAsyncIterator` usually return `self` at runtime + | +192 | class BadAsyncIterator(collections.abc.AsyncIterator[str]): +193 | def __aiter__(self) -> typing.AsyncIterator[str]: + | ^^^^^^^^^ PYI034 +194 | ... # 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) + | + = help: Consider using `typing_extensions.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 new file mode 100644 index 0000000000..416d321a77 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI034_PYI034.pyi.snap @@ -0,0 +1,101 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI034.pyi:18:9: PYI034 `__new__` methods in classes like `Bad` usually return `self` at runtime + | +16 | object +17 | ): # Y040 Do not inherit from "object" explicitly, as it is redundant in Python 3 +18 | def __new__( + | ^^^^^^^ PYI034 +19 | cls, *args: Any, **kwargs: Any +20 | ) -> 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: ..." + | + = help: Consider using `typing_extensions.Self` as return type + +PYI034.pyi:33:9: PYI034 `__enter__` methods in classes like `Bad` usually return `self` at runtime + | +31 | self, other: typing.Any +32 | ) -> typing.Any: ... # Y032 Prefer "object" to "Any" for the second parameter in "__ne__" methods +33 | def __enter__( + | ^^^^^^^^^ PYI034 +34 | self, +35 | ) -> 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: ..." + | + = help: Consider using `typing_extensions.Self` as return type + +PYI034.pyi:36:15: PYI034 `__aenter__` methods in classes like `Bad` usually return `self` at runtime + | +34 | self, +35 | ) -> 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: ..." +36 | async def __aenter__( + | ^^^^^^^^^^ PYI034 +37 | self, +38 | ) -> 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: ..." + | + = help: Consider using `typing_extensions.Self` as return type + +PYI034.pyi:39:9: PYI034 `__iadd__` methods in classes like `Bad` usually return `self` at runtime + | +37 | self, +38 | ) -> 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: ..." +39 | def __iadd__( + | ^^^^^^^^ PYI034 +40 | self, other: Bad +41 | ) -> 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: ..." + | + = help: Consider using `typing_extensions.Self` as return type + +PYI034.pyi:102:9: PYI034 `__iter__` methods in classes like `BadIterator1` usually return `self` at runtime + | +101 | class BadIterator1(Iterator[int]): +102 | def __iter__( + | ^^^^^^^^ PYI034 +103 | self, +104 | ) -> Iterator[ + | + = help: Consider using `typing_extensions.Self` as return type + +PYI034.pyi:111:9: PYI034 `__iter__` methods in classes like `BadIterator2` usually return `self` at runtime + | +109 | typing.Iterator[int] +110 | ): # Y022 Use "collections.abc.Iterator[T]" instead of "typing.Iterator[T]" (PEP 585 syntax) +111 | def __iter__( + | ^^^^^^^^ PYI034 +112 | self, +113 | ) -> Iterator[ + | + = help: Consider using `typing_extensions.Self` as return type + +PYI034.pyi:120:9: PYI034 `__iter__` methods in classes like `BadIterator3` usually return `self` at runtime + | +118 | typing.Iterator[int] +119 | ): # Y022 Use "collections.abc.Iterator[T]" instead of "typing.Iterator[T]" (PEP 585 syntax) +120 | def __iter__( + | ^^^^^^^^ PYI034 +121 | self, +122 | ) -> collections.abc.Iterator[ + | + = help: Consider using `typing_extensions.Self` as return type + +PYI034.pyi:128:9: PYI034 `__iter__` methods in classes like `BadIterator4` usually return `self` at runtime + | +126 | class BadIterator4(Iterator[int]): +127 | # Note: *Iterable*, not *Iterator*, returned! +128 | def __iter__( + | ^^^^^^^^ PYI034 +129 | self, +130 | ) -> Iterable[ + | + = help: Consider using `typing_extensions.Self` as return type + +PYI034.pyi:142:9: PYI034 `__aiter__` methods in classes like `BadAsyncIterator` usually return `self` at runtime + | +141 | class BadAsyncIterator(collections.abc.AsyncIterator[str]): +142 | def __aiter__( + | ^^^^^^^^^ PYI034 +143 | self, +144 | ) -> typing.AsyncIterator[ + | + = help: Consider using `typing_extensions.Self` as return type + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI035_PYI035.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI035_PYI035.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI035_PYI035.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..916bdb443a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI035_PYI035.pyi.snap @@ -0,0 +1,31 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +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 | +3 | __all__: list[str] = ["foo"] + | + +PYI035.pyi:7:5: PYI035 `__match_args__` in a stub file must have a value, as it has the same semantics as `__match_args__` at runtime + | +5 | class Foo: +6 | __all__: list[str] +7 | __match_args__: tuple[str, ...] # Error: PYI035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI035 +8 | __slots__: tuple[str, ...] # Error: PYI035 + | + +PYI035.pyi:8:5: PYI035 `__slots__` in a stub file must have a value, as it has the same semantics as `__slots__` at runtime + | + 6 | __all__: list[str] + 7 | __match_args__: tuple[str, ...] # Error: PYI035 + 8 | __slots__: tuple[str, ...] # Error: PYI035 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI035 + 9 | +10 | class Bar: + | + + 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 new file mode 100644 index 0000000000..026a12083b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.py.snap @@ -0,0 +1,161 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI036.py:54:31: PYI036 [*] Star-args in `__exit__` should be annotated with `object` + | +53 | class BadOne: +54 | def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation + | ^^^ PYI036 +55 | async def __aexit__(self) -> None: ... # PYI036: Missing args + | + = help: Annotate star-args with `object` + +ℹ Fix +51 51 | +52 52 | +53 53 | class BadOne: +54 |- def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation + 54 |+ def __exit__(self, *args: object) -> None: ... # PYI036: Bad star-args annotation +55 55 | async def __aexit__(self) -> None: ... # PYI036: Missing args +56 56 | +57 57 | class BadTwo: + +PYI036.py:55:24: PYI036 If there are no star-args, `__aexit__` should have at least 3 non-keyword-only args (excluding `self`) + | +53 | class BadOne: +54 | def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation +55 | async def __aexit__(self) -> None: ... # PYI036: Missing args + | ^^^^^^ PYI036 +56 | +57 | class BadTwo: + | + +PYI036.py:58:38: PYI036 All arguments after the first four in `__exit__` must have a default value + | +57 | class BadTwo: +58 | def __exit__(self, typ, exc, tb, weird_extra_arg) -> None: ... # PYI036: Extra arg must have default + | ^^^^^^^^^^^^^^^ PYI036 +59 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg) -> None: ...# PYI036: Extra arg must have default + | + +PYI036.py:59:48: PYI036 All keyword-only arguments in `__aexit__` must have a default value + | +57 | class BadTwo: +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 | +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 + | ^^^^^^^^^^^^^^^^^^^ PYI036 +63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI036: Second arg has bad annotation + | + +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 + | ^^^^^^^^^^^^^ PYI036 +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 + | ^^^^^^^^^^^^^ PYI036 +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 + | + +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: + | + +PYI036.py:70:29: PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` + | +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 + | + +PYI036.py:70:58: PYI036 [*] Star-args in `__exit__` should be annotated with `object` + | +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 + | + = help: Annotate star-args with `object` + +ℹ Fix +67 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 +68 68 | +69 69 | class BadFive: +70 |- def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation + 70 |+ def __exit__(self, typ: BaseException | None, *args: object) -> bool: ... # PYI036: Bad star-args annotation +71 71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotation +72 72 | +73 73 | class BadSix: + +PYI036.py:71:74: PYI036 [*] Star-args in `__aexit__` should be annotated with `object` + | +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 + | ^^^ PYI036 +72 | +73 | class BadSix: + | + = help: Annotate star-args with `object` + +ℹ Fix +68 68 | +69 69 | class BadFive: +70 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: object) -> Awaitable[None]: ... # PYI036: Bad star-args annotation +72 72 | +73 73 | class BadSix: +74 74 | def __exit__(self, typ, exc, tb, weird_extra_arg, extra_arg2 = None) -> None: ... # PYI036: Extra arg must have default + +PYI036.py:74:38: PYI036 All arguments after the first four in `__exit__` must have a default value + | +73 | class BadSix: +74 | def __exit__(self, typ, exc, tb, weird_extra_arg, extra_arg2 = None) -> None: ... # PYI036: Extra arg must have default + | ^^^^^^^^^^^^^^^ PYI036 +75 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg) -> None: ... # PYI036: kwargs must have default + | + +PYI036.py:75:48: PYI036 All keyword-only arguments in `__aexit__` must have a default value + | +73 | class BadSix: +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 + | + + 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 new file mode 100644 index 0000000000..f6b9e0b86c --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI036_PYI036.pyi.snap @@ -0,0 +1,171 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI036.pyi:54:31: PYI036 [*] Star-args in `__exit__` should be annotated with `object` + | +53 | class BadOne: +54 | def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation + | ^^^ PYI036 +55 | async def __aexit__(self) -> None: ... # PYI036: Missing args + | + = help: Annotate star-args with `object` + +ℹ Fix +51 51 | +52 52 | +53 53 | class BadOne: +54 |- def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation + 54 |+ def __exit__(self, *args: object) -> None: ... # PYI036: Bad star-args annotation +55 55 | async def __aexit__(self) -> None: ... # PYI036: Missing args +56 56 | +57 57 | class BadTwo: + +PYI036.pyi:55:24: PYI036 If there are no star-args, `__aexit__` should have at least 3 non-keyword-only args (excluding `self`) + | +53 | class BadOne: +54 | def __exit__(self, *args: Any) -> None: ... # PYI036: Bad star-args annotation +55 | async def __aexit__(self) -> None: ... # PYI036: Missing args + | ^^^^^^ PYI036 +56 | +57 | class BadTwo: + | + +PYI036.pyi:58:38: PYI036 All arguments after the first four in `__exit__` must have a default value + | +57 | class BadTwo: +58 | def __exit__(self, typ, exc, tb, weird_extra_arg) -> None: ... # PYI036: Extra arg must have default + | ^^^^^^^^^^^^^^^ PYI036 +59 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg1, weird_extra_arg2) -> None: ...# PYI036: kwargs must have default + | + +PYI036.pyi:59:48: PYI036 All keyword-only arguments in `__aexit__` must have a default value + | +57 | class BadTwo: +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 | +61 | class BadThree: + | + +PYI036.pyi:59:66: PYI036 All keyword-only arguments in `__aexit__` must have a default value + | +57 | class BadTwo: +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 | +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 + | ^^^^^^^^^^^^^^^^^^^ PYI036 +63 | async def __aexit__(self, __typ: type[BaseException] | None, __exc: BaseException, __tb: TracebackType) -> bool | None: ... # PYI036: Second arg has bad annotation + | + +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 + | ^^^^^^^^^^^^^ PYI036 +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 + | ^^^^^^^^^^^^^ PYI036 +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 + | + +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: + | + +PYI036.pyi:70:29: PYI036 The first argument in `__exit__` should be annotated with `object` or `type[BaseException] | None` + | +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 + | + +PYI036.pyi:70:58: PYI036 [*] Star-args in `__exit__` should be annotated with `object` + | +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 + | + = help: Annotate star-args with `object` + +ℹ Fix +67 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 +68 68 | +69 69 | class BadFive: +70 |- def __exit__(self, typ: BaseException | None, *args: list[str]) -> bool: ... # PYI036: Bad star-args annotation + 70 |+ def __exit__(self, typ: BaseException | None, *args: object) -> bool: ... # PYI036: Bad star-args annotation +71 71 | async def __aexit__(self, /, typ: type[BaseException] | None, *args: Any) -> Awaitable[None]: ... # PYI036: Bad star-args annotation +72 72 | +73 73 | class BadSix: + +PYI036.pyi:71:74: PYI036 [*] Star-args in `__aexit__` should be annotated with `object` + | +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 + | ^^^ PYI036 +72 | +73 | class BadSix: + | + = help: Annotate star-args with `object` + +ℹ Fix +68 68 | +69 69 | class BadFive: +70 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: object) -> Awaitable[None]: ... # PYI036: Bad star-args annotation +72 72 | +73 73 | class BadSix: +74 74 | def __exit__(self, typ, exc, tb, weird_extra_arg, extra_arg2 = None) -> None: ... # PYI036: Extra arg must have default + +PYI036.pyi:74:38: PYI036 All arguments after the first four in `__exit__` must have a default value + | +73 | class BadSix: +74 | def __exit__(self, typ, exc, tb, weird_extra_arg, extra_arg2 = None) -> None: ... # PYI036: Extra arg must have default + | ^^^^^^^^^^^^^^^ PYI036 +75 | async def __aexit__(self, typ, exc, tb, *, weird_extra_arg) -> None: ... # PYI036: kwargs must have default + | + +PYI036.pyi:75:48: PYI036 All keyword-only arguments in `__aexit__` must have a default value + | +73 | class BadSix: +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 + | + + 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 new file mode 100644 index 0000000000..e1721adde5 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041.py.snap @@ -0,0 +1,50 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI041.py:22:14: PYI041 Use `float` instead of `int | float` + | +22 | def f0(arg1: float | int) -> None: + | ^^^^^^^^^^^ PYI041 +23 | ... + | + +PYI041.py:26:30: PYI041 Use `complex` instead of `float | complex` + | +26 | def f1(arg1: float, *, arg2: float | list[str] | type[bool] | complex) -> None: + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 +27 | ... + | + +PYI041.py:30:28: PYI041 Use `float` instead of `int | float` + | +30 | def f2(arg1: int, /, arg2: int | int | float) -> None: + | ^^^^^^^^^^^^^^^^^ PYI041 +31 | ... + | + +PYI041.py:38:24: PYI041 Use `float` instead of `int | float` + | +38 | async def f4(**kwargs: int | int | float) -> None: + | ^^^^^^^^^^^^^^^^^ PYI041 +39 | ... + | + +PYI041.py:46:24: PYI041 Use `complex` instead of `float | complex` + | +44 | ... +45 | +46 | def bad(self, arg: int | float | complex) -> None: + | ^^^^^^^^^^^^^^^^^^^^^ PYI041 +47 | ... + | + +PYI041.py:46:24: PYI041 Use `complex` instead of `int | complex` + | +44 | ... +45 | +46 | def bad(self, arg: int | float | complex) -> None: + | ^^^^^^^^^^^^^^^^^^^^^ PYI041 +47 | ... + | + + 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 new file mode 100644 index 0000000000..914faa5156 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI041_PYI041.pyi.snap @@ -0,0 +1,44 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI041.pyi:21:14: PYI041 Use `float` instead of `int | float` + | +21 | def f0(arg1: float | int) -> None: ... # PYI041 + | ^^^^^^^^^^^ PYI041 + | + +PYI041.pyi:24:30: PYI041 Use `complex` instead of `float | complex` + | +24 | def f1(arg1: float, *, arg2: float | list[str] | type[bool] | complex) -> None: ... # PYI041 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI041 + | + +PYI041.pyi:27:28: PYI041 Use `float` instead of `int | float` + | +27 | def f2(arg1: int, /, arg2: int | int | float) -> None: ... # PYI041 + | ^^^^^^^^^^^^^^^^^ PYI041 + | + +PYI041.pyi:33:24: PYI041 Use `float` instead of `int | float` + | +33 | async def f4(**kwargs: int | int | float) -> None: ... # PYI041 + | ^^^^^^^^^^^^^^^^^ PYI041 + | + +PYI041.pyi:39:24: PYI041 Use `complex` instead of `float | complex` + | +37 | def good(self, arg: int) -> None: ... +38 | +39 | def bad(self, arg: int | float | complex) -> None: ... # PYI041 + | ^^^^^^^^^^^^^^^^^^^^^ PYI041 + | + +PYI041.pyi:39:24: PYI041 Use `complex` instead of `int | complex` + | +37 | def good(self, arg: int) -> None: ... +38 | +39 | def bad(self, arg: int | float | complex) -> None: ... # PYI041 + | ^^^^^^^^^^^^^^^^^^^^^ PYI041 + | + + 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 new file mode 100644 index 0000000000..1f80b9c9af --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI042_PYI042.py.snap @@ -0,0 +1,32 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI042.py:10:1: PYI042 Type alias `just_literals_pipe_union` should be CamelCase + | + 8 | ) + 9 | +10 | just_literals_pipe_union: TypeAlias = ( + | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI042 +11 | Literal[True] | Literal["idk"] +12 | ) # PYI042, since not camel case + | + +PYI042.py:19:1: PYI042 Type alias `snake_case_alias1` should be CamelCase + | +17 | _PrivateAliasS2: TypeAlias = Annotated[str, "also okay"] +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 +21 | Snake_case_alias: TypeAlias = int | float # PYI042, since not camel case + | + +PYI042.py:20:1: PYI042 Type alias `_snake_case_alias2` should be CamelCase + | +19 | snake_case_alias1: TypeAlias = str | int # PYI042, since not camel case +20 | _snake_case_alias2: TypeAlias = Literal["whatever"] # PYI042, since not camel case + | ^^^^^^^^^^^^^^^^^^ PYI042 +21 | Snake_case_alias: TypeAlias = int | float # 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 new file mode 100644 index 0000000000..ab3c2fe98e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI042_PYI042.pyi.snap @@ -0,0 +1,32 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI042.pyi:10:1: PYI042 Type alias `just_literals_pipe_union` should be CamelCase + | + 8 | ) + 9 | +10 | just_literals_pipe_union: TypeAlias = ( + | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI042 +11 | Literal[True] | Literal["idk"] +12 | ) # PYI042, since not camel case + | + +PYI042.pyi:19:1: PYI042 Type alias `snake_case_alias1` should be CamelCase + | +17 | _PrivateAliasS2: TypeAlias = Annotated[str, "also okay"] +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 +21 | Snake_case_alias: TypeAlias = int | float # PYI042, since not camel case + | + +PYI042.pyi:20:1: PYI042 Type alias `_snake_case_alias2` should be CamelCase + | +19 | snake_case_alias1: TypeAlias = str | int # PYI042, since not camel case +20 | _snake_case_alias2: TypeAlias = Literal["whatever"] # PYI042, since not camel case + | ^^^^^^^^^^^^^^^^^^ PYI042 +21 | Snake_case_alias: TypeAlias = int | float # 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 new file mode 100644 index 0000000000..3dfc9c819b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI043_PYI043.py.snap @@ -0,0 +1,33 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +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 | +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 +12 | _PrivateAliasT3: TypeAlias = Literal[ + | + +PYI043.py:11:1: PYI043 Private type alias `_PrivateAliasT2` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) + | +10 | _PrivateAliasT: TypeAlias = str | int # PYI043, since this ends in a T +11 | _PrivateAliasT2: TypeAlias = typing.Any # PYI043, since this ends in a T + | ^^^^^^^^^^^^^^^ PYI043 +12 | _PrivateAliasT3: TypeAlias = Literal[ +13 | "not", "a", "chance" + | + +PYI043.py:12:1: PYI043 Private type alias `_PrivateAliasT3` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) + | +10 | _PrivateAliasT: TypeAlias = str | int # PYI043, since this ends in a T +11 | _PrivateAliasT2: TypeAlias = typing.Any # PYI043, since this ends in a T +12 | _PrivateAliasT3: TypeAlias = Literal[ + | ^^^^^^^^^^^^^^^ PYI043 +13 | "not", "a", "chance" +14 | ] # 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 new file mode 100644 index 0000000000..f856dc86ad --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI043_PYI043.pyi.snap @@ -0,0 +1,33 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +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 | +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 +12 | _PrivateAliasT3: TypeAlias = Literal[ + | + +PYI043.pyi:11:1: PYI043 Private type alias `_PrivateAliasT2` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) + | +10 | _PrivateAliasT: TypeAlias = str | int # PYI043, since this ends in a T +11 | _PrivateAliasT2: TypeAlias = typing.Any # PYI043, since this ends in a T + | ^^^^^^^^^^^^^^^ PYI043 +12 | _PrivateAliasT3: TypeAlias = Literal[ +13 | "not", "a", "chance" + | + +PYI043.pyi:12:1: PYI043 Private type alias `_PrivateAliasT3` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`) + | +10 | _PrivateAliasT: TypeAlias = str | int # PYI043, since this ends in a T +11 | _PrivateAliasT2: TypeAlias = typing.Any # PYI043, since this ends in a T +12 | _PrivateAliasT3: TypeAlias = Literal[ + | ^^^^^^^^^^^^^^^ PYI043 +13 | "not", "a", "chance" +14 | ] # 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.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI044_PYI044.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI044_PYI044.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..b69b3048f7 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI044_PYI044.pyi.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +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 + | +1 | # Bad import. +2 | from __future__ import annotations # PYI044. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI044 +3 | +4 | # Good imports. + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI045_PYI045.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI045_PYI045.py.snap new file mode 100644 index 0000000000..54d3502134 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI045_PYI045.py.snap @@ -0,0 +1,60 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI045.py:12:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + | +11 | class TypingIterableTReturn: +12 | def __iter__(self) -> typing.Iterable[int]: + | ^^^^^^^^^^^^^^^^^^^^ PYI045 +13 | ... + | + +PYI045.py:20:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + | +19 | class TypingIterableReturn: +20 | def __iter__(self) -> typing.Iterable: + | ^^^^^^^^^^^^^^^ PYI045 +21 | ... + | + +PYI045.py:28:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + | +27 | class CollectionsIterableTReturn: +28 | def __iter__(self) -> collections.abc.Iterable[int]: + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI045 +29 | ... + | + +PYI045.py:36:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + | +35 | class CollectionsIterableReturn: +36 | def __iter__(self) -> collections.abc.Iterable: + | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI045 +37 | ... + | + +PYI045.py:44:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + | +43 | class IterableReturn: +44 | def __iter__(self) -> Iterable: + | ^^^^^^^^ PYI045 +45 | ... + | + +PYI045.py:79:28: PYI045 `__aiter__` methods should return an `AsyncIterator`, not an `AsyncIterable` + | +78 | class TypingAsyncIterableTReturn: +79 | def __aiter__(self) -> typing.AsyncIterable[int]: + | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI045 +80 | ... + | + +PYI045.py:84:28: PYI045 `__aiter__` methods should return an `AsyncIterator`, not an `AsyncIterable` + | +83 | class TypingAsyncIterableReturn: +84 | def __aiter__(self) -> typing.AsyncIterable: + | ^^^^^^^^^^^^^^^^^^^^ PYI045 +85 | ... + | + + 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 new file mode 100644 index 0000000000..475a3f2d2a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI045_PYI045.pyi.snap @@ -0,0 +1,61 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI045.pyi:9:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + | + 8 | class TypingIterableTReturn: + 9 | def __iter__(self) -> typing.Iterable[int]: ... # Error: PYI045 + | ^^^^^^^^^^^^^^^^^^^^ PYI045 +10 | def not_iter(self) -> typing.Iterable[int]: ... + | + +PYI045.pyi:13:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + | +12 | class TypingIterableReturn: +13 | def __iter__(self) -> typing.Iterable: ... # Error: PYI045 + | ^^^^^^^^^^^^^^^ PYI045 +14 | def not_iter(self) -> typing.Iterable: ... + | + +PYI045.pyi:17:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + | +16 | class CollectionsIterableTReturn: +17 | def __iter__(self) -> collections.abc.Iterable[int]: ... # Error: PYI045 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI045 +18 | def not_iter(self) -> collections.abc.Iterable[int]: ... + | + +PYI045.pyi:21:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + | +20 | class CollectionsIterableReturn: +21 | def __iter__(self) -> collections.abc.Iterable: ... # Error: PYI045 + | ^^^^^^^^^^^^^^^^^^^^^^^^ PYI045 +22 | def not_iter(self) -> collections.abc.Iterable: ... + | + +PYI045.pyi:25:27: PYI045 `__iter__` methods should return an `Iterator`, not an `Iterable` + | +24 | class IterableReturn: +25 | def __iter__(self) -> Iterable: ... # Error: PYI045 + | ^^^^^^^^ PYI045 +26 | +27 | class IteratorReturn: + | + +PYI045.pyi:46:28: PYI045 `__aiter__` methods should return an `AsyncIterator`, not an `AsyncIterable` + | +45 | class TypingAsyncIterableTReturn: +46 | def __aiter__(self) -> typing.AsyncIterable[int]: ... # Error: PYI045 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ PYI045 +47 | +48 | class TypingAsyncIterableReturn: + | + +PYI045.pyi:49:28: PYI045 `__aiter__` methods should return an `AsyncIterator`, not an `AsyncIterable` + | +48 | class TypingAsyncIterableReturn: +49 | def __aiter__(self) -> typing.AsyncIterable: ... # Error: PYI045 + | ^^^^^^^^^^^^^^^^^^^^ PYI045 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI046_PYI046.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI046_PYI046.py.snap new file mode 100644 index 0000000000..89c8e24038 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI046_PYI046.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI046.py:5:7: PYI046 Private protocol `_Foo` is never used + | +5 | class _Foo(Protocol): + | ^^^^ PYI046 +6 | bar: int + | + +PYI046.py:9:7: PYI046 Private protocol `_Bar` is never used + | + 9 | class _Bar(typing.Protocol): + | ^^^^ PYI046 +10 | bar: int + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI046_PYI046.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI046_PYI046.pyi.snap new file mode 100644 index 0000000000..83f52186ba --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI046_PYI046.pyi.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI046.pyi:5:7: PYI046 Private protocol `_Foo` is never used + | +5 | class _Foo(object, Protocol): + | ^^^^ PYI046 +6 | bar: int + | + +PYI046.pyi:9:7: PYI046 Private protocol `_Bar` is never used + | + 9 | class _Bar(typing.Protocol): + | ^^^^ PYI046 +10 | bar: int + | + + 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 new file mode 100644 index 0000000000..f6bf21b1ed --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI047_PYI047.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI047.py:6:1: PYI047 Private TypeAlias `_UnusedPrivateTypeAlias` is never used + | +6 | _UnusedPrivateTypeAlias: TypeAlias = int | None + | ^^^^^^^^^^^^^^^^^^^^^^^ PYI047 +7 | _T: typing.TypeAlias = str + | + +PYI047.py:7:1: PYI047 Private TypeAlias `_T` is never used + | +6 | _UnusedPrivateTypeAlias: TypeAlias = int | None +7 | _T: typing.TypeAlias = str + | ^^ PYI047 +8 | +9 | # OK + | + + 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 new file mode 100644 index 0000000000..1eae7ab37c --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI047_PYI047.pyi.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI047.pyi:6:1: PYI047 Private TypeAlias `_UnusedPrivateTypeAlias` is never used + | +6 | _UnusedPrivateTypeAlias: TypeAlias = int | None + | ^^^^^^^^^^^^^^^^^^^^^^^ PYI047 +7 | _T: typing.TypeAlias = str + | + +PYI047.pyi:7:1: PYI047 Private TypeAlias `_T` is never used + | +6 | _UnusedPrivateTypeAlias: TypeAlias = int | None +7 | _T: typing.TypeAlias = str + | ^^ PYI047 +8 | +9 | # OK + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI048_PYI048.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI048_PYI048.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI048_PYI048.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..adad4a83f7 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI048_PYI048.pyi.snap @@ -0,0 +1,34 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI048.pyi:8:5: PYI048 Function body must contain exactly one statement + | + 6 | """oof""" # OK + 7 | + 8 | def oof(): # ERROR PYI048 + | ^^^ PYI048 + 9 | """oof""" +10 | print("foo") + | + +PYI048.pyi:12:5: PYI048 Function body must contain exactly one statement + | +10 | print("foo") +11 | +12 | def foo(): # ERROR PYI048 + | ^^^ PYI048 +13 | """foo""" +14 | print("foo") + | + +PYI048.pyi:17:5: PYI048 Function body must contain exactly one statement + | +15 | print("foo") +16 | +17 | def buzz(): # ERROR PYI048 + | ^^^^ PYI048 +18 | print("fizz") +19 | print("buzz") + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI049_PYI049.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI049_PYI049.py.snap new file mode 100644 index 0000000000..1136db117e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI049_PYI049.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI049.py:5:7: PYI049 Private TypedDict `_UnusedTypedDict` is never used + | +5 | class _UnusedTypedDict(TypedDict): + | ^^^^^^^^^^^^^^^^ PYI049 +6 | foo: str + | + +PYI049.py:9:7: PYI049 Private TypedDict `_UnusedTypedDict2` is never used + | + 9 | class _UnusedTypedDict2(typing.TypedDict): + | ^^^^^^^^^^^^^^^^^ PYI049 +10 | bar: int + | + + 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 new file mode 100644 index 0000000000..16c5dc5b5a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI049_PYI049.pyi.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI049.pyi:6:7: PYI049 Private TypedDict `_UnusedTypedDict` is never used + | +6 | class _UnusedTypedDict(TypedDict): + | ^^^^^^^^^^^^^^^^ PYI049 +7 | foo: str + | + +PYI049.pyi:10:7: PYI049 Private TypedDict `_UnusedTypedDict2` is never used + | +10 | class _UnusedTypedDict2(typing.TypedDict): + | ^^^^^^^^^^^^^^^^^ PYI049 +11 | bar: int + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI050_PYI050.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI050_PYI050.py.snap new file mode 100644 index 0000000000..11b5d19b5e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI050_PYI050.py.snap @@ -0,0 +1,25 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI050.py:13:24: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + | +13 | def foo_no_return(arg: NoReturn): + | ^^^^^^^^ PYI050 +14 | ... + | + +PYI050.py:23:44: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + | +23 | def foo_no_return_kwarg(arg: int, *, arg2: NoReturn): + | ^^^^^^^^ PYI050 +24 | ... + | + +PYI050.py:27:47: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + | +27 | def foo_no_return_pos_only(arg: int, /, arg2: NoReturn): + | ^^^^^^^^ PYI050 +28 | ... + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI050_PYI050.pyi.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI050_PYI050.pyi.snap new file mode 100644 index 0000000000..a0cb503548 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI050_PYI050.pyi.snap @@ -0,0 +1,33 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI050.pyi:6:24: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + | +4 | def foo(arg): ... +5 | def foo_int(arg: int): ... +6 | def foo_no_return(arg: NoReturn): ... # Error: PYI050 + | ^^^^^^^^ PYI050 +7 | def foo_no_return_typing_extensions( +8 | arg: typing_extensions.NoReturn, + | + +PYI050.pyi:10:44: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + | + 8 | arg: typing_extensions.NoReturn, + 9 | ): ... # Error: PYI050 +10 | def foo_no_return_kwarg(arg: int, *, arg2: NoReturn): ... # Error: PYI050 + | ^^^^^^^^ PYI050 +11 | def foo_no_return_pos_only(arg: int, /, arg2: NoReturn): ... # Error: PYI050 +12 | def foo_never(arg: Never): ... + | + +PYI050.pyi:11:47: PYI050 Prefer `typing.Never` over `NoReturn` for argument annotations + | + 9 | ): ... # Error: PYI050 +10 | def foo_no_return_kwarg(arg: int, *, arg2: NoReturn): ... # Error: PYI050 +11 | def foo_no_return_pos_only(arg: int, /, arg2: NoReturn): ... # Error: PYI050 + | ^^^^^^^^ PYI050 +12 | def foo_never(arg: Never): ... + | + + 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 new file mode 100644 index 0000000000..1e67d47c63 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI051_PYI051.py.snap @@ -0,0 +1,90 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI051.py:4:18: PYI051 `Literal["foo"]` is redundant in a union with `str` + | +2 | from typing import Literal, TypeAlias, Union +3 | +4 | A: str | Literal["foo"] + | ^^^^^ PYI051 +5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] +6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] + | + +PYI051.py:5:37: PYI051 `Literal[b"bar"]` is redundant in a union with `bytes` + | +4 | A: str | Literal["foo"] +5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] + | ^^^^^^ PYI051 +6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] +7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] + | + +PYI051.py:5:45: PYI051 `Literal[b"foo"]` is redundant in a union with `bytes` + | +4 | A: str | Literal["foo"] +5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] + | ^^^^^^ PYI051 +6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] +7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] + | + +PYI051.py:6:37: PYI051 `Literal[5]` is redundant in a union with `int` + | +4 | A: str | Literal["foo"] +5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] +6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] + | ^ PYI051 +7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] + | + +PYI051.py:6:67: PYI051 `Literal["foo"]` is redundant in a union with `str` + | +4 | A: str | Literal["foo"] +5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] +6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] + | ^^^^^ PYI051 +7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] + | + +PYI051.py:7:37: PYI051 `Literal[b"str_bytes"]` is redundant in a union with `bytes` + | +5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] +6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] +7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] + | ^^^^^^^^^^^^ PYI051 +8 | +9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... + | + +PYI051.py:7:51: PYI051 `Literal[42]` is redundant in a union with `int` + | +5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] +6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] +7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] + | ^^ PYI051 +8 | +9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... + | + +PYI051.py:9:31: PYI051 `Literal[1J]` is redundant in a union with `complex` + | + 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] + 8 | + 9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... + | ^^ PYI051 +10 | +11 | # OK + | + +PYI051.py:9:53: PYI051 `Literal[3.14]` is redundant in a union with `float` + | + 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] + 8 | + 9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... + | ^^^^ PYI051 +10 | +11 | # 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 new file mode 100644 index 0000000000..b5da422a00 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI051_PYI051.pyi.snap @@ -0,0 +1,90 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI051.pyi:4:18: PYI051 `Literal["foo"]` is redundant in a union with `str` + | +2 | from typing import Literal, TypeAlias, Union +3 | +4 | A: str | Literal["foo"] + | ^^^^^ PYI051 +5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] +6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] + | + +PYI051.pyi:5:37: PYI051 `Literal[b"bar"]` is redundant in a union with `bytes` + | +4 | A: str | Literal["foo"] +5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] + | ^^^^^^ PYI051 +6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] +7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] + | + +PYI051.pyi:5:45: PYI051 `Literal[b"foo"]` is redundant in a union with `bytes` + | +4 | A: str | Literal["foo"] +5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] + | ^^^^^^ PYI051 +6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] +7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] + | + +PYI051.pyi:6:37: PYI051 `Literal[5]` is redundant in a union with `int` + | +4 | A: str | Literal["foo"] +5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] +6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] + | ^ PYI051 +7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] + | + +PYI051.pyi:6:67: PYI051 `Literal["foo"]` is redundant in a union with `str` + | +4 | A: str | Literal["foo"] +5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] +6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] + | ^^^^^ PYI051 +7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] + | + +PYI051.pyi:7:37: PYI051 `Literal[b"str_bytes"]` is redundant in a union with `bytes` + | +5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] +6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] +7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] + | ^^^^^^^^^^^^ PYI051 +8 | +9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... + | + +PYI051.pyi:7:51: PYI051 `Literal[42]` is redundant in a union with `int` + | +5 | B: TypeAlias = typing.Union[Literal[b"bar", b"foo"], bytes, str] +6 | C: TypeAlias = typing.Union[Literal[5], int, typing.Union[Literal["foo"], str]] +7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] + | ^^ PYI051 +8 | +9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... + | + +PYI051.pyi:9:31: PYI051 `Literal[1J]` is redundant in a union with `complex` + | + 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] + 8 | + 9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... + | ^^ PYI051 +10 | +11 | # OK + | + +PYI051.pyi:9:53: PYI051 `Literal[3.14]` is redundant in a union with `float` + | + 7 | D: TypeAlias = typing.Union[Literal[b"str_bytes", 42], bytes, int] + 8 | + 9 | def func(x: complex | Literal[1J], y: Union[Literal[3.14], float]): ... + | ^^^^ PYI051 +10 | +11 | # OK + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI052_PYI052.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI052_PYI052.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI052_PYI052.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..30f0ccedef --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI052_PYI052.pyi.snap @@ -0,0 +1,134 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +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" + | ^ PYI052 +15 | field6 = 0 # Y052 Need type annotation for "field6" +16 | field7 = b"" # Y052 Need type annotation for "field7" + | + +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" +15 | field6 = 0 # Y052 Need type annotation for "field6" + | ^ PYI052 +16 | field7 = b"" # Y052 Need type annotation for "field7" +17 | field71 = "foo" # Y052 Need type annotation for "field71" + | + +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" +15 | field6 = 0 # Y052 Need type annotation for "field6" +16 | field7 = b"" # Y052 Need type annotation for "field7" + | ^^^ PYI052 +17 | field71 = "foo" # Y052 Need type annotation for "field71" +18 | field72: str = "foo" + | + +PYI052.pyi:17:11: PYI052 Need type annotation for `field71` + | +15 | field6 = 0 # Y052 Need type annotation for "field6" +16 | field7 = b"" # Y052 Need type annotation for "field7" +17 | field71 = "foo" # Y052 Need type annotation for "field71" + | ^^^^^ PYI052 +18 | field72: str = "foo" +19 | field8 = False # Y052 Need type annotation for "field8" + | + +PYI052.pyi:19:10: PYI052 Need type annotation for `field8` + | +17 | field71 = "foo" # Y052 Need type annotation for "field71" +18 | field72: str = "foo" +19 | field8 = False # Y052 Need type annotation for "field8" + | ^^^^^ PYI052 +20 | field81 = -1 # Y052 Need type annotation for "field81" +21 | field82: float = -98.43 + | + +PYI052.pyi:20:11: PYI052 Need type annotation for `field81` + | +18 | field72: str = "foo" +19 | field8 = False # Y052 Need type annotation for "field8" +20 | field81 = -1 # Y052 Need type annotation for "field81" + | ^^ PYI052 +21 | field82: float = -98.43 +22 | field83 = -42j # Y052 Need type annotation for "field83" + | + +PYI052.pyi:22:11: PYI052 Need type annotation for `field83` + | +20 | field81 = -1 # Y052 Need type annotation for "field81" +21 | field82: float = -98.43 +22 | field83 = -42j # Y052 Need type annotation for "field83" + | ^^^^ PYI052 +23 | field84 = 5 + 42j # Y052 Need type annotation for "field84" +24 | field85 = -5 - 42j # Y052 Need type annotation for "field85" + | + +PYI052.pyi:23:11: PYI052 Need type annotation for `field84` + | +21 | field82: float = -98.43 +22 | field83 = -42j # Y052 Need type annotation for "field83" +23 | field84 = 5 + 42j # Y052 Need type annotation for "field84" + | ^^^^^^^ PYI052 +24 | field85 = -5 - 42j # Y052 Need type annotation for "field85" +25 | field9 = None # Y026 Use typing_extensions.TypeAlias for type aliases, e.g. "field9: TypeAlias = None" + | + +PYI052.pyi:24:11: PYI052 Need type annotation for `field85` + | +22 | field83 = -42j # Y052 Need type annotation for "field83" +23 | field84 = 5 + 42j # Y052 Need type annotation for "field84" +24 | field85 = -5 - 42j # Y052 Need type annotation for "field85" + | ^^^^^^^^ PYI052 +25 | field9 = None # Y026 Use typing_extensions.TypeAlias for type aliases, e.g. "field9: TypeAlias = None" +26 | Field95: TypeAlias = None + | + +PYI052.pyi:33:11: PYI052 Need type annotation for `field19` + | +31 | Field100 = TypeVarTuple('Field100') +32 | Field101 = ParamSpec('Field101') +33 | field19 = [1, 2, 3] # Y052 Need type annotation for "field19" + | ^^^^^^^^^ PYI052 +34 | field191: list[int] = [1, 2, 3] +35 | field20 = (1, 2, 3) # Y052 Need type annotation for "field20" + | + +PYI052.pyi:35:11: PYI052 Need type annotation for `field20` + | +33 | field19 = [1, 2, 3] # Y052 Need type annotation for "field19" +34 | field191: list[int] = [1, 2, 3] +35 | field20 = (1, 2, 3) # Y052 Need type annotation for "field20" + | ^^^^^^^^^ PYI052 +36 | field201: tuple[int, ...] = (1, 2, 3) +37 | field21 = {1, 2, 3} # Y052 Need type annotation for "field21" + | + +PYI052.pyi:37:11: PYI052 Need type annotation for `field21` + | +35 | field20 = (1, 2, 3) # Y052 Need type annotation for "field20" +36 | field201: tuple[int, ...] = (1, 2, 3) +37 | field21 = {1, 2, 3} # Y052 Need type annotation for "field21" + | ^^^^^^^^^ PYI052 +38 | field211: set[int] = {1, 2, 3} +39 | field212 = {"foo": "bar"} # Y052 Need type annotation for "field212" + | + +PYI052.pyi:39:12: PYI052 Need type annotation for `field212` + | +37 | field21 = {1, 2, 3} # Y052 Need type annotation for "field21" +38 | field211: set[int] = {1, 2, 3} +39 | field212 = {"foo": "bar"} # Y052 Need type annotation for "field212" + | ^^^^^^^^^^^^^^ PYI052 +40 | field213: dict[str, str] = {"foo": "bar"} +41 | field22: Final = {"foo": 5} + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI053_PYI053.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI053_PYI053.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI053_PYI053.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..5b9f3aa1a1 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI053_PYI053.pyi.snap @@ -0,0 +1,107 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI053.pyi:3:14: PYI053 [*] String and bytes literals longer than 50 characters are not permitted + | +1 | def f1(x: str = "50 character stringggggggggggggggggggggggggggggggg") -> None: ... # OK +2 | def f2( +3 | x: str = "51 character stringgggggggggggggggggggggggggggggggg", # Error: PYI053 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 +4 | ) -> None: ... +5 | def f3( + | + = help: Replace with `...` + +ℹ Suggested fix +1 1 | def f1(x: str = "50 character stringggggggggggggggggggggggggggggggg") -> None: ... # OK +2 2 | def f2( +3 |- x: str = "51 character stringgggggggggggggggggggggggggggggggg", # Error: PYI053 + 3 |+ x: str = ..., # Error: PYI053 +4 4 | ) -> None: ... +5 5 | def f3( +6 6 | x: str = "50 character stringgggggggggggggggggggggggggggggg\U0001f600", # OK + +PYI053.pyi:9:14: PYI053 [*] String and bytes literals longer than 50 characters are not permitted + | + 7 | ) -> None: ... + 8 | def f4( + 9 | x: str = "51 character stringggggggggggggggggggggggggggggggg\U0001f600", # Error: PYI053 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 +10 | ) -> None: ... +11 | def f5( + | + = help: Replace with `...` + +ℹ Suggested fix +6 6 | x: str = "50 character stringgggggggggggggggggggggggggggggg\U0001f600", # OK +7 7 | ) -> None: ... +8 8 | def f4( +9 |- x: str = "51 character stringggggggggggggggggggggggggggggggg\U0001f600", # Error: PYI053 + 9 |+ x: str = ..., # Error: PYI053 +10 10 | ) -> None: ... +11 11 | def f5( +12 12 | x: bytes = b"50 character byte stringgggggggggggggggggggggggggg", # OK + +PYI053.pyi:21:16: PYI053 [*] String and bytes literals longer than 50 characters are not permitted + | +19 | ) -> None: ... +20 | def f8( +21 | x: bytes = b"51 character byte stringgggggggggggggggggggggggggg\xff", # Error: PYI053 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 +22 | ) -> None: ... + | + = help: Replace with `...` + +ℹ Suggested fix +18 18 | x: bytes = b"50 character byte stringggggggggggggggggggggggggg\xff", # OK +19 19 | ) -> None: ... +20 20 | def f8( +21 |- x: bytes = b"51 character byte stringgggggggggggggggggggggggggg\xff", # Error: PYI053 + 21 |+ x: bytes = ..., # Error: PYI053 +22 22 | ) -> None: ... +23 23 | +24 24 | foo: str = "50 character stringggggggggggggggggggggggggggggggg" # OK + +PYI053.pyi:26:12: PYI053 [*] String and bytes literals longer than 50 characters are not permitted + | +24 | foo: str = "50 character stringggggggggggggggggggggggggggggggg" # OK +25 | +26 | bar: str = "51 character stringgggggggggggggggggggggggggggggggg" # Error: PYI053 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 +27 | +28 | baz: bytes = b"50 character byte stringgggggggggggggggggggggggggg" # OK + | + = help: Replace with `...` + +ℹ Suggested fix +23 23 | +24 24 | foo: str = "50 character stringggggggggggggggggggggggggggggggg" # OK +25 25 | +26 |-bar: str = "51 character stringgggggggggggggggggggggggggggggggg" # Error: PYI053 + 26 |+bar: str = ... # Error: PYI053 +27 27 | +28 28 | baz: bytes = b"50 character byte stringgggggggggggggggggggggggggg" # OK +29 29 | + +PYI053.pyi:30:14: PYI053 [*] String and bytes literals longer than 50 characters are not permitted + | +28 | baz: bytes = b"50 character byte stringgggggggggggggggggggggggggg" # OK +29 | +30 | qux: bytes = b"51 character byte stringggggggggggggggggggggggggggg\xff" # Error: PYI053 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI053 +31 | +32 | class Demo: + | + = help: Replace with `...` + +ℹ Suggested fix +27 27 | +28 28 | baz: bytes = b"50 character byte stringgggggggggggggggggggggggggg" # OK +29 29 | +30 |-qux: bytes = b"51 character byte stringggggggggggggggggggggggggggg\xff" # Error: PYI053 + 30 |+qux: bytes = ... # Error: PYI053 +31 31 | +32 32 | class Demo: +33 33 | """Docstrings are excluded from this rule. Some padding.""" # OK + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI054_PYI054.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI054_PYI054.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI054_PYI054.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..7db8611cad --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI054_PYI054.pyi.snap @@ -0,0 +1,161 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI054.pyi:2:16: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted + | +1 | field01: int = 0xFFFFFFFF +2 | field02: int = 0xFFFFFFFFF # Error: PYI054 + | ^^^^^^^^^^^ PYI054 +3 | field03: int = -0xFFFFFFFF +4 | field04: int = -0xFFFFFFFFF # Error: PYI054 + | + = help: Replace with `...` + +ℹ Suggested fix +1 1 | field01: int = 0xFFFFFFFF +2 |-field02: int = 0xFFFFFFFFF # Error: PYI054 + 2 |+field02: int = ... # Error: PYI054 +3 3 | field03: int = -0xFFFFFFFF +4 4 | field04: int = -0xFFFFFFFFF # Error: PYI054 +5 5 | + +PYI054.pyi:4:17: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted + | +2 | field02: int = 0xFFFFFFFFF # Error: PYI054 +3 | field03: int = -0xFFFFFFFF +4 | field04: int = -0xFFFFFFFFF # Error: PYI054 + | ^^^^^^^^^^^ PYI054 +5 | +6 | field05: int = 1234567890 + | + = help: Replace with `...` + +ℹ Suggested fix +1 1 | field01: int = 0xFFFFFFFF +2 2 | field02: int = 0xFFFFFFFFF # Error: PYI054 +3 3 | field03: int = -0xFFFFFFFF +4 |-field04: int = -0xFFFFFFFFF # Error: PYI054 + 4 |+field04: int = -... # Error: PYI054 +5 5 | +6 6 | field05: int = 1234567890 +7 7 | field06: int = 12_456_890 + +PYI054.pyi:8:16: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted + | + 6 | field05: int = 1234567890 + 7 | field06: int = 12_456_890 + 8 | field07: int = 12345678901 # Error: PYI054 + | ^^^^^^^^^^^ PYI054 + 9 | field08: int = -1234567801 +10 | field09: int = -234_567_890 # Error: PYI054 + | + = help: Replace with `...` + +ℹ Suggested fix +5 5 | +6 6 | field05: int = 1234567890 +7 7 | field06: int = 12_456_890 +8 |-field07: int = 12345678901 # Error: PYI054 + 8 |+field07: int = ... # Error: PYI054 +9 9 | field08: int = -1234567801 +10 10 | field09: int = -234_567_890 # Error: PYI054 +11 11 | + +PYI054.pyi:10:17: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted + | + 8 | field07: int = 12345678901 # Error: PYI054 + 9 | field08: int = -1234567801 +10 | field09: int = -234_567_890 # Error: PYI054 + | ^^^^^^^^^^^ PYI054 +11 | +12 | field10: float = 123.456789 + | + = help: Replace with `...` + +ℹ Suggested fix +7 7 | field06: int = 12_456_890 +8 8 | field07: int = 12345678901 # Error: PYI054 +9 9 | field08: int = -1234567801 +10 |-field09: int = -234_567_890 # Error: PYI054 + 10 |+field09: int = -... # Error: PYI054 +11 11 | +12 12 | field10: float = 123.456789 +13 13 | field11: float = 123.4567890 # Error: PYI054 + +PYI054.pyi:13:18: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted + | +12 | field10: float = 123.456789 +13 | field11: float = 123.4567890 # Error: PYI054 + | ^^^^^^^^^^^ PYI054 +14 | field12: float = -123.456789 +15 | field13: float = -123.567_890 # Error: PYI054 + | + = help: Replace with `...` + +ℹ Suggested fix +10 10 | field09: int = -234_567_890 # Error: PYI054 +11 11 | +12 12 | field10: float = 123.456789 +13 |-field11: float = 123.4567890 # Error: PYI054 + 13 |+field11: float = ... # Error: PYI054 +14 14 | field12: float = -123.456789 +15 15 | field13: float = -123.567_890 # Error: PYI054 +16 16 | + +PYI054.pyi:15:19: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted + | +13 | field11: float = 123.4567890 # Error: PYI054 +14 | field12: float = -123.456789 +15 | field13: float = -123.567_890 # Error: PYI054 + | ^^^^^^^^^^^ PYI054 +16 | +17 | field14: complex = 1e1234567j + | + = help: Replace with `...` + +ℹ Suggested fix +12 12 | field10: float = 123.456789 +13 13 | field11: float = 123.4567890 # Error: PYI054 +14 14 | field12: float = -123.456789 +15 |-field13: float = -123.567_890 # Error: PYI054 + 15 |+field13: float = -... # Error: PYI054 +16 16 | +17 17 | field14: complex = 1e1234567j +18 18 | field15: complex = 1e12345678j # Error: PYI054 + +PYI054.pyi:18:20: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted + | +17 | field14: complex = 1e1234567j +18 | field15: complex = 1e12345678j # Error: PYI054 + | ^^^^^^^^^^^ PYI054 +19 | field16: complex = -1e1234567j +20 | field17: complex = 1e123456789j # Error: PYI054 + | + = help: Replace with `...` + +ℹ Suggested fix +15 15 | field13: float = -123.567_890 # Error: PYI054 +16 16 | +17 17 | field14: complex = 1e1234567j +18 |-field15: complex = 1e12345678j # Error: PYI054 + 18 |+field15: complex = ... # Error: PYI054 +19 19 | field16: complex = -1e1234567j +20 20 | field17: complex = 1e123456789j # Error: PYI054 + +PYI054.pyi:20:20: PYI054 [*] Numeric literals with a string representation longer than ten characters are not permitted + | +18 | field15: complex = 1e12345678j # Error: PYI054 +19 | field16: complex = -1e1234567j +20 | field17: complex = 1e123456789j # Error: PYI054 + | ^^^^^^^^^^^^ PYI054 + | + = help: Replace with `...` + +ℹ Suggested fix +17 17 | field14: complex = 1e1234567j +18 18 | field15: complex = 1e12345678j # Error: PYI054 +19 19 | field16: complex = -1e1234567j +20 |-field17: complex = 1e123456789j # Error: PYI054 + 20 |+field17: complex = ... # Error: PYI054 + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.py.snap new file mode 100644 index 0000000000..8addf09918 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI055.py:31:11: PYI055 Multiple `type` members in a union. Combine them into one, e.g., `type[requests_mock.Mocker | httpretty]`. + | +29 | def func(): +30 | # PYI055 +31 | item: type[requests_mock.Mocker] | type[httpretty] = requests_mock.Mocker + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | + + 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 new file mode 100644 index 0000000000..f28020e400 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI055_PYI055.pyi.snap @@ -0,0 +1,79 @@ +--- +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 | +4 | w: builtins.type[int] | builtins.type[str] | builtins.type[complex] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 +5 | x: type[int] | type[str] | type[float] +6 | y: builtins.type[int] | type[str] | builtins.type[complex] + | + +PYI055.pyi:5:4: PYI055 Multiple `type` members in a union. Combine them into one, e.g., `type[int | str | float]`. + | +4 | w: builtins.type[int] | builtins.type[str] | builtins.type[complex] +5 | x: type[int] | type[str] | type[float] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 +6 | y: builtins.type[int] | type[str] | builtins.type[complex] +7 | z: Union[type[float], type[complex]] + | + +PYI055.pyi:6:4: PYI055 Multiple `type` members in a union. Combine them into one, e.g., `type[int | str | complex]`. + | +4 | w: builtins.type[int] | builtins.type[str] | builtins.type[complex] +5 | x: type[int] | type[str] | type[float] +6 | y: builtins.type[int] | type[str] | builtins.type[complex] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 +7 | z: Union[type[float], type[complex]] +8 | z: Union[type[float, int], type[complex]] + | + +PYI055.pyi:7:4: PYI055 Multiple `type` members in a union. Combine them into one, e.g., `type[Union[float, complex]]`. + | +5 | x: type[int] | type[str] | type[float] +6 | y: builtins.type[int] | type[str] | builtins.type[complex] +7 | z: Union[type[float], type[complex]] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 +8 | z: Union[type[float, int], type[complex]] + | + +PYI055.pyi:8:4: PYI055 Multiple `type` members in a union. Combine them into one, e.g., `type[Union[float, int, complex]]`. + | + 6 | y: builtins.type[int] | type[str] | builtins.type[complex] + 7 | z: Union[type[float], type[complex]] + 8 | z: Union[type[float, int], type[complex]] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + 9 | +10 | def func(arg: type[int] | str | type[float]) -> None: ... + | + +PYI055.pyi:10:15: PYI055 Multiple `type` members in a union. Combine them into one, e.g., `type[int | float]`. + | + 8 | z: Union[type[float, int], type[complex]] + 9 | +10 | def func(arg: type[int] | str | type[float]) -> None: ... + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 +11 | +12 | # OK + | + +PYI055.pyi:20:7: PYI055 Multiple `type` members in a union. Combine them into one, e.g., `type[requests_mock.Mocker | httpretty]`. + | +19 | # OK +20 | item: type[requests_mock.Mocker] | type[httpretty] = requests_mock.Mocker + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 +21 | +22 | def func(): + | + +PYI055.pyi:24:11: PYI055 Multiple `type` members in a union. Combine them into one, e.g., `type[requests_mock.Mocker | httpretty]`. + | +22 | def func(): +23 | # PYI055 +24 | item: type[requests_mock.Mocker] | type[httpretty] = requests_mock.Mocker + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PYI055 + | + + 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 new file mode 100644 index 0000000000..850ee67d1f --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI056_PYI056.py.snap @@ -0,0 +1,32 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI056.py:4:1: PYI056 Calling `.append()` on `__all__` may not be supported by all type checkers (use `+=` instead) + | +3 | # Errors +4 | __all__.append("D") + | ^^^^^^^^^^^^^^ PYI056 +5 | __all__.extend(["E", "Foo"]) +6 | __all__.remove("A") + | + +PYI056.py:5:1: PYI056 Calling `.extend()` on `__all__` may not be supported by all type checkers (use `+=` instead) + | +3 | # Errors +4 | __all__.append("D") +5 | __all__.extend(["E", "Foo"]) + | ^^^^^^^^^^^^^^ PYI056 +6 | __all__.remove("A") + | + +PYI056.py:6:1: PYI056 Calling `.remove()` on `__all__` may not be supported by all type checkers (use `+=` instead) + | +4 | __all__.append("D") +5 | __all__.extend(["E", "Foo"]) +6 | __all__.remove("A") + | ^^^^^^^^^^^^^^ PYI056 +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 new file mode 100644 index 0000000000..fbc462d426 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__PYI056_PYI056.pyi.snap @@ -0,0 +1,32 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI056.pyi:4:1: PYI056 Calling `.append()` on `__all__` may not be supported by all type checkers (use `+=` instead) + | +3 | # Errors +4 | __all__.append("D") + | ^^^^^^^^^^^^^^ PYI056 +5 | __all__.extend(["E", "Foo"]) +6 | __all__.remove("A") + | + +PYI056.pyi:5:1: PYI056 Calling `.extend()` on `__all__` may not be supported by all type checkers (use `+=` instead) + | +3 | # Errors +4 | __all__.append("D") +5 | __all__.extend(["E", "Foo"]) + | ^^^^^^^^^^^^^^ PYI056 +6 | __all__.remove("A") + | + +PYI056.pyi:6:1: PYI056 Calling `.remove()` on `__all__` may not be supported by all type checkers (use `+=` instead) + | +4 | __all__.append("D") +5 | __all__.extend(["E", "Foo"]) +6 | __all__.remove("A") + | ^^^^^^^^^^^^^^ PYI056 +7 | +8 | # OK + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI026_PYI026.py.snap b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI026_PYI026.py.snap new file mode 100644 index 0000000000..f0a4f44d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI026_PYI026.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- + 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 new file mode 100644 index 0000000000..f8db4ff1b2 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pyi/snapshots/ruff_linter__rules__flake8_pyi__tests__py38_PYI026_PYI026.pyi.snap @@ -0,0 +1,117 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pyi/mod.rs +--- +PYI026.pyi:3:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `NewAny: TypeAlias = Any` + | +1 | from typing import Literal, Any +2 | +3 | NewAny = Any + | ^^^^^^ PYI026 +4 | OptionalStr = typing.Optional[str] +5 | Foo = Literal["foo"] + | + = help: Add `TypeAlias` annotation + +ℹ Suggested fix +1 1 | from typing import Literal, Any + 2 |+import typing_extensions +2 3 | +3 |-NewAny = Any + 4 |+NewAny: typing_extensions.TypeAlias = Any +4 5 | OptionalStr = typing.Optional[str] +5 6 | Foo = Literal["foo"] +6 7 | IntOrStr = int | str + +PYI026.pyi:4:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `OptionalStr: TypeAlias = typing.Optional[str]` + | +3 | NewAny = Any +4 | OptionalStr = typing.Optional[str] + | ^^^^^^^^^^^ PYI026 +5 | Foo = Literal["foo"] +6 | IntOrStr = int | str + | + = help: Add `TypeAlias` annotation + +ℹ Suggested fix +1 1 | from typing import Literal, Any + 2 |+import typing_extensions +2 3 | +3 4 | NewAny = Any +4 |-OptionalStr = typing.Optional[str] + 5 |+OptionalStr: typing_extensions.TypeAlias = typing.Optional[str] +5 6 | Foo = Literal["foo"] +6 7 | IntOrStr = int | str +7 8 | AliasNone = None + +PYI026.pyi:5:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `Foo: TypeAlias = Literal["foo"]` + | +3 | NewAny = Any +4 | OptionalStr = typing.Optional[str] +5 | Foo = Literal["foo"] + | ^^^ PYI026 +6 | IntOrStr = int | str +7 | AliasNone = None + | + = help: Add `TypeAlias` annotation + +ℹ Suggested fix +1 1 | from typing import Literal, Any + 2 |+import typing_extensions +2 3 | +3 4 | NewAny = Any +4 5 | OptionalStr = typing.Optional[str] +5 |-Foo = Literal["foo"] + 6 |+Foo: typing_extensions.TypeAlias = Literal["foo"] +6 7 | IntOrStr = int | str +7 8 | AliasNone = None +8 9 | + +PYI026.pyi:6:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `IntOrStr: TypeAlias = int | str` + | +4 | OptionalStr = typing.Optional[str] +5 | Foo = Literal["foo"] +6 | IntOrStr = int | str + | ^^^^^^^^ PYI026 +7 | AliasNone = None + | + = help: Add `TypeAlias` annotation + +ℹ Suggested fix +1 1 | from typing import Literal, Any + 2 |+import typing_extensions +2 3 | +3 4 | NewAny = Any +4 5 | OptionalStr = typing.Optional[str] +5 6 | Foo = Literal["foo"] +6 |-IntOrStr = int | str + 7 |+IntOrStr: typing_extensions.TypeAlias = int | str +7 8 | AliasNone = None +8 9 | +9 10 | NewAny: typing.TypeAlias = Any + +PYI026.pyi:7:1: PYI026 [*] Use `typing_extensions.TypeAlias` for type alias, e.g., `AliasNone: TypeAlias = None` + | +5 | Foo = Literal["foo"] +6 | IntOrStr = int | str +7 | AliasNone = None + | ^^^^^^^^^ PYI026 +8 | +9 | NewAny: typing.TypeAlias = Any + | + = help: Add `TypeAlias` annotation + +ℹ Suggested fix +1 1 | from typing import Literal, Any + 2 |+import typing_extensions +2 3 | +3 4 | NewAny = Any +4 5 | OptionalStr = typing.Optional[str] +5 6 | Foo = Literal["foo"] +6 7 | IntOrStr = int | str +7 |-AliasNone = None + 8 |+AliasNone: typing_extensions.TypeAlias = None +8 9 | +9 10 | NewAny: typing.TypeAlias = Any +10 11 | OptionalStr: TypeAlias = typing.Optional[str] + + diff --git a/crates/ruff/src/rules/flake8_pytest_style/mod.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pytest_style/mod.rs rename to crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/assertion.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/assertion.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pytest_style/rules/assertion.rs rename to crates/ruff_linter/src/rules/flake8_pytest_style/rules/assertion.rs diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/fail.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/fail.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pytest_style/rules/fail.rs rename to crates/ruff_linter/src/rules/flake8_pytest_style/rules/fail.rs diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/fixture.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/fixture.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pytest_style/rules/fixture.rs rename to crates/ruff_linter/src/rules/flake8_pytest_style/rules/fixture.rs diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/helpers.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/helpers.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pytest_style/rules/helpers.rs rename to crates/ruff_linter/src/rules/flake8_pytest_style/rules/helpers.rs diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/imports.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/imports.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pytest_style/rules/imports.rs rename to crates/ruff_linter/src/rules/flake8_pytest_style/rules/imports.rs diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/marks.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/marks.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pytest_style/rules/marks.rs rename to crates/ruff_linter/src/rules/flake8_pytest_style/rules/marks.rs diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pytest_style/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_pytest_style/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/parametrize.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pytest_style/rules/parametrize.rs rename to crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/patch.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/patch.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pytest_style/rules/patch.rs rename to crates/ruff_linter/src/rules/flake8_pytest_style/rules/patch.rs diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/raises.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/raises.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pytest_style/rules/raises.rs rename to crates/ruff_linter/src/rules/flake8_pytest_style/rules/raises.rs diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/unittest_assert.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pytest_style/rules/unittest_assert.rs rename to crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs diff --git a/crates/ruff/src/rules/flake8_pytest_style/settings.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/settings.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pytest_style/settings.rs rename to crates/ruff_linter/src/rules/flake8_pytest_style/settings.rs 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 new file mode 100644 index 0000000000..6a1c478525 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_default.snap @@ -0,0 +1,61 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT001.py:9:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` + | + 9 | @pytest.fixture + | ^^^^^^^^^^^^^^^ PT001 +10 | def no_parentheses(): +11 | return 42 + | + = help: Add parentheses + +ℹ Fix +6 6 | # `import pytest` +7 7 | +8 8 | +9 |-@pytest.fixture + 9 |+@pytest.fixture() +10 10 | def no_parentheses(): +11 11 | return 42 +12 12 | + +PT001.py:34:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` + | +34 | @fixture + | ^^^^^^^^ PT001 +35 | def imported_from_no_parentheses(): +36 | return 42 + | + = help: Add parentheses + +ℹ Fix +31 31 | # `from pytest import fixture` +32 32 | +33 33 | +34 |-@fixture + 34 |+@fixture() +35 35 | def imported_from_no_parentheses(): +36 36 | return 42 +37 37 | + +PT001.py:59:1: PT001 [*] Use `@pytest.fixture()` over `@pytest.fixture` + | +59 | @aliased + | ^^^^^^^^ PT001 +60 | def aliased_no_parentheses(): +61 | return 42 + | + = help: Add parentheses + +ℹ Fix +56 56 | # `from pytest import fixture as aliased` +57 57 | +58 58 | +59 |-@aliased + 59 |+@aliased() +60 60 | def aliased_no_parentheses(): +61 61 | return 42 +62 62 | + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_no_parentheses.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_no_parentheses.snap new file mode 100644 index 0000000000..8605c4d420 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT001_no_parentheses.snap @@ -0,0 +1,129 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT001.py:14:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` + | +14 | @pytest.fixture() + | ^^^^^^^^^^^^^^^^^ PT001 +15 | def parentheses_no_params(): +16 | return 42 + | + = help: Remove parentheses + +ℹ Fix +11 11 | return 42 +12 12 | +13 13 | +14 |-@pytest.fixture() + 14 |+@pytest.fixture +15 15 | def parentheses_no_params(): +16 16 | return 42 +17 17 | + +PT001.py:24:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` + | +24 | / @pytest.fixture( +25 | | +26 | | ) + | |_^ PT001 +27 | def parentheses_no_params_multiline(): +28 | return 42 + | + = help: Remove parentheses + +ℹ Fix +21 21 | return 42 +22 22 | +23 23 | +24 |-@pytest.fixture( +25 |- +26 |-) + 24 |+@pytest.fixture +27 25 | def parentheses_no_params_multiline(): +28 26 | return 42 +29 27 | + +PT001.py:39:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` + | +39 | @fixture() + | ^^^^^^^^^^ PT001 +40 | def imported_from_parentheses_no_params(): +41 | return 42 + | + = help: Remove parentheses + +ℹ Fix +36 36 | return 42 +37 37 | +38 38 | +39 |-@fixture() + 39 |+@fixture +40 40 | def imported_from_parentheses_no_params(): +41 41 | return 42 +42 42 | + +PT001.py:49:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` + | +49 | / @fixture( +50 | | +51 | | ) + | |_^ PT001 +52 | def imported_from_parentheses_no_params_multiline(): +53 | return 42 + | + = help: Remove parentheses + +ℹ Fix +46 46 | return 42 +47 47 | +48 48 | +49 |-@fixture( +50 |- +51 |-) + 49 |+@fixture +52 50 | def imported_from_parentheses_no_params_multiline(): +53 51 | return 42 +54 52 | + +PT001.py:64:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` + | +64 | @aliased() + | ^^^^^^^^^^ PT001 +65 | def aliased_parentheses_no_params(): +66 | return 42 + | + = help: Remove parentheses + +ℹ Fix +61 61 | return 42 +62 62 | +63 63 | +64 |-@aliased() + 64 |+@aliased +65 65 | def aliased_parentheses_no_params(): +66 66 | return 42 +67 67 | + +PT001.py:74:1: PT001 [*] Use `@pytest.fixture` over `@pytest.fixture()` + | +74 | / @aliased( +75 | | +76 | | ) + | |_^ PT001 +77 | def aliased_parentheses_no_params_multiline(): +78 | return 42 + | + = help: Remove parentheses + +ℹ Fix +71 71 | return 42 +72 72 | +73 73 | +74 |-@aliased( +75 |- +76 |-) + 74 |+@aliased +77 75 | def aliased_parentheses_no_params_multiline(): +78 76 | return 42 + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT002.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT002.snap new file mode 100644 index 0000000000..4185534912 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT002.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT002.py:14:1: PT002 Configuration for fixture `my_fixture` specified via positional args, use kwargs + | +14 | @pytest.fixture("module") + | ^^^^^^^^^^^^^^^^^^^^^^^^^ PT002 +15 | def my_fixture(): # Error only args +16 | return 0 + | + +PT002.py:19:1: PT002 Configuration for fixture `my_fixture` specified via positional args, use kwargs + | +19 | @pytest.fixture("module", autouse=True) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT002 +20 | def my_fixture(): # Error mixed +21 | return 0 + | + + 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 new file mode 100644 index 0000000000..ceb7e0f5b1 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT003.snap @@ -0,0 +1,164 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT003.py:14:17: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` + | +14 | @pytest.fixture(scope="function") + | ^^^^^^^^^^^^^^^^ PT003 +15 | def error(): +16 | ... + | + = help: Remove implied `scope` argument + +ℹ Suggested fix +11 11 | ... +12 12 | +13 13 | +14 |-@pytest.fixture(scope="function") + 14 |+@pytest.fixture() +15 15 | def error(): +16 16 | ... +17 17 | + +PT003.py:19:17: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` + | +19 | @pytest.fixture(scope="function", name="my_fixture") + | ^^^^^^^^^^^^^^^^ PT003 +20 | def error_multiple_args(): +21 | ... + | + = help: Remove implied `scope` argument + +ℹ Suggested fix +16 16 | ... +17 17 | +18 18 | +19 |-@pytest.fixture(scope="function", name="my_fixture") + 19 |+@pytest.fixture(name="my_fixture") +20 20 | def error_multiple_args(): +21 21 | ... +22 22 | + +PT003.py:24:36: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` + | +24 | @pytest.fixture(name="my_fixture", scope="function") + | ^^^^^^^^^^^^^^^^ PT003 +25 | def error_multiple_args(): +26 | ... + | + = help: Remove implied `scope` argument + +ℹ Suggested fix +21 21 | ... +22 22 | +23 23 | +24 |-@pytest.fixture(name="my_fixture", scope="function") + 24 |+@pytest.fixture(name="my_fixture") +25 25 | def error_multiple_args(): +26 26 | ... +27 27 | + +PT003.py:29:36: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` + | +29 | @pytest.fixture(name="my_fixture", scope="function", **kwargs) + | ^^^^^^^^^^^^^^^^ PT003 +30 | def error_second_arg(): +31 | ... + | + = help: Remove implied `scope` argument + +ℹ Suggested fix +26 26 | ... +27 27 | +28 28 | +29 |-@pytest.fixture(name="my_fixture", scope="function", **kwargs) + 29 |+@pytest.fixture(name="my_fixture", **kwargs) +30 30 | def error_second_arg(): +31 31 | ... +32 32 | + +PT003.py:37:31: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` + | +35 | # tests the general case as we use a helper function that should +36 | # work for all cases. +37 | @pytest.fixture("my_fixture", scope="function") + | ^^^^^^^^^^^^^^^^ PT003 +38 | def error_arg(): +39 | ... + | + = help: Remove implied `scope` argument + +ℹ Suggested fix +34 34 | # pytest.fixture does not take positional arguments, however this +35 35 | # tests the general case as we use a helper function that should +36 36 | # work for all cases. +37 |-@pytest.fixture("my_fixture", scope="function") + 37 |+@pytest.fixture("my_fixture") +38 38 | def error_arg(): +39 39 | ... +40 40 | + +PT003.py:43:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` + | +42 | @pytest.fixture( +43 | scope="function", + | ^^^^^^^^^^^^^^^^ PT003 +44 | name="my_fixture", +45 | ) + | + = help: Remove implied `scope` argument + +ℹ Suggested fix +40 40 | +41 41 | +42 42 | @pytest.fixture( +43 |- scope="function", +44 43 | name="my_fixture", +45 44 | ) +46 45 | def error_multiple_args(): + +PT003.py:52:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` + | +50 | @pytest.fixture( +51 | name="my_fixture", +52 | scope="function", + | ^^^^^^^^^^^^^^^^ PT003 +53 | ) +54 | def error_multiple_args(): + | + = help: Remove implied `scope` argument + +ℹ Suggested fix +49 49 | +50 50 | @pytest.fixture( +51 51 | name="my_fixture", +52 |- scope="function", +53 52 | ) +54 53 | def error_multiple_args(): +55 54 | ... + +PT003.py:66:5: PT003 [*] `scope='function'` is implied in `@pytest.fixture()` + | +64 | # another comment ,) +65 | +66 | scope=\ + | _____^ +67 | | "function" # some comment ), + | |__________________^ PT003 +68 | , + | + = help: Remove implied `scope` argument + +ℹ Suggested fix +63 63 | +64 64 | # another comment ,) +65 65 | +66 |- scope=\ +67 |- "function" # some comment ), +68 |- , +69 |- +70 66 | name2=name, name3="my_fixture", **kwargs +71 67 | ) +72 68 | def error_multiple_args(): + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT004.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT004.snap new file mode 100644 index 0000000000..4617a063c5 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT004.snap @@ -0,0 +1,21 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT004.py:51:5: PT004 Fixture `patch_something` does not return anything, add leading underscore + | +50 | @pytest.fixture() +51 | def patch_something(mocker): # Error simple + | ^^^^^^^^^^^^^^^ PT004 +52 | mocker.patch("some.thing") + | + +PT004.py:56:5: PT004 Fixture `activate_context` does not return anything, add leading underscore + | +55 | @pytest.fixture() +56 | def activate_context(): # Error with yield + | ^^^^^^^^^^^^^^^^ PT004 +57 | with context: +58 | yield + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT005.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT005.snap new file mode 100644 index 0000000000..40023ff641 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT005.snap @@ -0,0 +1,30 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT005.py:41:5: PT005 Fixture `_my_fixture` returns a value, remove leading underscore + | +40 | @pytest.fixture() +41 | def _my_fixture(mocker): # Error with return + | ^^^^^^^^^^^ PT005 +42 | return 0 + | + +PT005.py:46:5: PT005 Fixture `_activate_context` returns a value, remove leading underscore + | +45 | @pytest.fixture() +46 | def _activate_context(): # Error with yield + | ^^^^^^^^^^^^^^^^^ PT005 +47 | with get_context() as context: +48 | yield context + | + +PT005.py:52:5: PT005 Fixture `_activate_context` returns a value, remove leading underscore + | +51 | @pytest.fixture() +52 | def _activate_context(): # Error with conditional yield from + | ^^^^^^^^^^^^^^^^^ PT005 +53 | if some_condition: +54 | with get_context() as context: + | + + 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 new file mode 100644 index 0000000000..1399986a40 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_csv.snap @@ -0,0 +1,98 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT006.py:24:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` + | +24 | @pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) + | ^^^^^^^^^^^^^^^^^^^^ PT006 +25 | def test_tuple(param1, param2): +26 | ... + | + = help: Use a `csv` for parameter names + +ℹ Suggested fix +21 21 | ... +22 22 | +23 23 | +24 |-@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) + 24 |+@pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) +25 25 | def test_tuple(param1, param2): +26 26 | ... +27 27 | + +PT006.py:29:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` + | +29 | @pytest.mark.parametrize(("param1",), [1, 2, 3]) + | ^^^^^^^^^^^ PT006 +30 | def test_tuple_one_elem(param1, param2): +31 | ... + | + = help: Use a `csv` for parameter names + +ℹ Fix +26 26 | ... +27 27 | +28 28 | +29 |-@pytest.mark.parametrize(("param1",), [1, 2, 3]) + 29 |+@pytest.mark.parametrize("param1", [1, 2, 3]) +30 30 | def test_tuple_one_elem(param1, param2): +31 31 | ... +32 32 | + +PT006.py:34:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` + | +34 | @pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) + | ^^^^^^^^^^^^^^^^^^^^ PT006 +35 | def test_list(param1, param2): +36 | ... + | + = help: Use a `csv` for parameter names + +ℹ Suggested fix +31 31 | ... +32 32 | +33 33 | +34 |-@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) + 34 |+@pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) +35 35 | def test_list(param1, param2): +36 36 | ... +37 37 | + +PT006.py:39:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` + | +39 | @pytest.mark.parametrize(["param1"], [1, 2, 3]) + | ^^^^^^^^^^ PT006 +40 | def test_list_one_elem(param1, param2): +41 | ... + | + = help: Use a `csv` for parameter names + +ℹ Fix +36 36 | ... +37 37 | +38 38 | +39 |-@pytest.mark.parametrize(["param1"], [1, 2, 3]) + 39 |+@pytest.mark.parametrize("param1", [1, 2, 3]) +40 40 | def test_list_one_elem(param1, param2): +41 41 | ... +42 42 | + +PT006.py:44:26: PT006 Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` + | +44 | @pytest.mark.parametrize([some_expr, another_expr], [1, 2, 3]) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 +45 | def test_list_expressions(param1, param2): +46 | ... + | + = help: Use a `csv` for parameter names + +PT006.py:49:26: PT006 Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` + | +49 | @pytest.mark.parametrize([some_expr, "param2"], [1, 2, 3]) + | ^^^^^^^^^^^^^^^^^^^^^ PT006 +50 | def test_list_mixed_expr_literal(param1, param2): +51 | ... + | + = help: Use a `csv` for parameter names + + 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 new file mode 100644 index 0000000000..c9e8b5e0c5 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_default.snap @@ -0,0 +1,231 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT006.py:9:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` + | + 9 | @pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) + | ^^^^^^^^^^^^^^^ PT006 +10 | def test_csv(param1, param2): +11 | ... + | + = help: Use a `tuple` for parameter names + +ℹ Suggested fix +6 6 | ... +7 7 | +8 8 | +9 |-@pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) + 9 |+@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) +10 10 | def test_csv(param1, param2): +11 11 | ... +12 12 | + +PT006.py:14:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` + | +14 | @pytest.mark.parametrize(" param1, , param2 , ", [(1, 2), (3, 4)]) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 +15 | def test_csv_with_whitespace(param1, param2): +16 | ... + | + = help: Use a `tuple` for parameter names + +ℹ Suggested fix +11 11 | ... +12 12 | +13 13 | +14 |-@pytest.mark.parametrize(" param1, , param2 , ", [(1, 2), (3, 4)]) + 14 |+@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) +15 15 | def test_csv_with_whitespace(param1, param2): +16 16 | ... +17 17 | + +PT006.py:19:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` + | +19 | @pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) + | ^^^^^^^^^^^^^^^ PT006 +20 | def test_csv_bad_quotes(param1, param2): +21 | ... + | + = help: Use a `tuple` for parameter names + +ℹ Suggested fix +16 16 | ... +17 17 | +18 18 | +19 |-@pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) + 19 |+@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) +20 20 | def test_csv_bad_quotes(param1, param2): +21 21 | ... +22 22 | + +PT006.py:29:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` + | +29 | @pytest.mark.parametrize(("param1",), [1, 2, 3]) + | ^^^^^^^^^^^ PT006 +30 | def test_tuple_one_elem(param1, param2): +31 | ... + | + = help: Use a `csv` for parameter names + +ℹ Fix +26 26 | ... +27 27 | +28 28 | +29 |-@pytest.mark.parametrize(("param1",), [1, 2, 3]) + 29 |+@pytest.mark.parametrize("param1", [1, 2, 3]) +30 30 | def test_tuple_one_elem(param1, param2): +31 31 | ... +32 32 | + +PT006.py:34:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` + | +34 | @pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) + | ^^^^^^^^^^^^^^^^^^^^ PT006 +35 | def test_list(param1, param2): +36 | ... + | + = help: Use a `tuple` for parameter names + +ℹ Suggested fix +31 31 | ... +32 32 | +33 33 | +34 |-@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) + 34 |+@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) +35 35 | def test_list(param1, param2): +36 36 | ... +37 37 | + +PT006.py:39:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` + | +39 | @pytest.mark.parametrize(["param1"], [1, 2, 3]) + | ^^^^^^^^^^ PT006 +40 | def test_list_one_elem(param1, param2): +41 | ... + | + = help: Use a `csv` for parameter names + +ℹ Fix +36 36 | ... +37 37 | +38 38 | +39 |-@pytest.mark.parametrize(["param1"], [1, 2, 3]) + 39 |+@pytest.mark.parametrize("param1", [1, 2, 3]) +40 40 | def test_list_one_elem(param1, param2): +41 41 | ... +42 42 | + +PT006.py:44:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` + | +44 | @pytest.mark.parametrize([some_expr, another_expr], [1, 2, 3]) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 +45 | def test_list_expressions(param1, param2): +46 | ... + | + = help: Use a `tuple` for parameter names + +ℹ Suggested fix +41 41 | ... +42 42 | +43 43 | +44 |-@pytest.mark.parametrize([some_expr, another_expr], [1, 2, 3]) + 44 |+@pytest.mark.parametrize((some_expr, another_expr), [1, 2, 3]) +45 45 | def test_list_expressions(param1, param2): +46 46 | ... +47 47 | + +PT006.py:49:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` + | +49 | @pytest.mark.parametrize([some_expr, "param2"], [1, 2, 3]) + | ^^^^^^^^^^^^^^^^^^^^^ PT006 +50 | def test_list_mixed_expr_literal(param1, param2): +51 | ... + | + = help: Use a `tuple` for parameter names + +ℹ Suggested fix +46 46 | ... +47 47 | +48 48 | +49 |-@pytest.mark.parametrize([some_expr, "param2"], [1, 2, 3]) + 49 |+@pytest.mark.parametrize((some_expr, "param2"), [1, 2, 3]) +50 50 | def test_list_mixed_expr_literal(param1, param2): +51 51 | ... +52 52 | + +PT006.py:54:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` + | +54 | @pytest.mark.parametrize(("param1, " "param2, " "param3"), [(1, 2, 3), (4, 5, 6)]) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 +55 | def test_implicit_str_concat_with_parens(param1, param2, param3): +56 | ... + | + = help: Use a `tuple` for parameter names + +ℹ Suggested fix +51 51 | ... +52 52 | +53 53 | +54 |-@pytest.mark.parametrize(("param1, " "param2, " "param3"), [(1, 2, 3), (4, 5, 6)]) + 54 |+@pytest.mark.parametrize(("param1", "param2", "param3"), [(1, 2, 3), (4, 5, 6)]) +55 55 | def test_implicit_str_concat_with_parens(param1, param2, param3): +56 56 | ... +57 57 | + +PT006.py:59:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` + | +59 | @pytest.mark.parametrize("param1, " "param2, " "param3", [(1, 2, 3), (4, 5, 6)]) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 +60 | def test_implicit_str_concat_no_parens(param1, param2, param3): +61 | ... + | + = help: Use a `tuple` for parameter names + +ℹ Suggested fix +56 56 | ... +57 57 | +58 58 | +59 |-@pytest.mark.parametrize("param1, " "param2, " "param3", [(1, 2, 3), (4, 5, 6)]) + 59 |+@pytest.mark.parametrize(("param1", "param2", "param3"), [(1, 2, 3), (4, 5, 6)]) +60 60 | def test_implicit_str_concat_no_parens(param1, param2, param3): +61 61 | ... +62 62 | + +PT006.py:64:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` + | +64 | @pytest.mark.parametrize((("param1, " "param2, " "param3")), [(1, 2, 3), (4, 5, 6)]) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 +65 | def test_implicit_str_concat_with_multi_parens(param1, param2, param3): +66 | ... + | + = help: Use a `tuple` for parameter names + +ℹ Suggested fix +61 61 | ... +62 62 | +63 63 | +64 |-@pytest.mark.parametrize((("param1, " "param2, " "param3")), [(1, 2, 3), (4, 5, 6)]) + 64 |+@pytest.mark.parametrize(("param1", "param2", "param3"), [(1, 2, 3), (4, 5, 6)]) +65 65 | def test_implicit_str_concat_with_multi_parens(param1, param2, param3): +66 66 | ... +67 67 | + +PT006.py:69:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `tuple` + | +69 | @pytest.mark.parametrize(("param1,param2"), [(1, 2), (3, 4)]) + | ^^^^^^^^^^^^^^^^^ PT006 +70 | def test_csv_with_parens(param1, param2): +71 | ... + | + = help: Use a `tuple` for parameter names + +ℹ Suggested fix +66 66 | ... +67 67 | +68 68 | +69 |-@pytest.mark.parametrize(("param1,param2"), [(1, 2), (3, 4)]) + 69 |+@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) +70 70 | def test_csv_with_parens(param1, param2): +71 71 | ... + + 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 new file mode 100644 index 0000000000..bdce72095b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT006_list.snap @@ -0,0 +1,193 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT006.py:9:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list` + | + 9 | @pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) + | ^^^^^^^^^^^^^^^ PT006 +10 | def test_csv(param1, param2): +11 | ... + | + = help: Use a `list` for parameter names + +ℹ Suggested fix +6 6 | ... +7 7 | +8 8 | +9 |-@pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) + 9 |+@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) +10 10 | def test_csv(param1, param2): +11 11 | ... +12 12 | + +PT006.py:14:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list` + | +14 | @pytest.mark.parametrize(" param1, , param2 , ", [(1, 2), (3, 4)]) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 +15 | def test_csv_with_whitespace(param1, param2): +16 | ... + | + = help: Use a `list` for parameter names + +ℹ Suggested fix +11 11 | ... +12 12 | +13 13 | +14 |-@pytest.mark.parametrize(" param1, , param2 , ", [(1, 2), (3, 4)]) + 14 |+@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) +15 15 | def test_csv_with_whitespace(param1, param2): +16 16 | ... +17 17 | + +PT006.py:19:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list` + | +19 | @pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) + | ^^^^^^^^^^^^^^^ PT006 +20 | def test_csv_bad_quotes(param1, param2): +21 | ... + | + = help: Use a `list` for parameter names + +ℹ Suggested fix +16 16 | ... +17 17 | +18 18 | +19 |-@pytest.mark.parametrize("param1,param2", [(1, 2), (3, 4)]) + 19 |+@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) +20 20 | def test_csv_bad_quotes(param1, param2): +21 21 | ... +22 22 | + +PT006.py:24:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list` + | +24 | @pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) + | ^^^^^^^^^^^^^^^^^^^^ PT006 +25 | def test_tuple(param1, param2): +26 | ... + | + = help: Use a `list` for parameter names + +ℹ Suggested fix +21 21 | ... +22 22 | +23 23 | +24 |-@pytest.mark.parametrize(("param1", "param2"), [(1, 2), (3, 4)]) + 24 |+@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) +25 25 | def test_tuple(param1, param2): +26 26 | ... +27 27 | + +PT006.py:29:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` + | +29 | @pytest.mark.parametrize(("param1",), [1, 2, 3]) + | ^^^^^^^^^^^ PT006 +30 | def test_tuple_one_elem(param1, param2): +31 | ... + | + = help: Use a `csv` for parameter names + +ℹ Fix +26 26 | ... +27 27 | +28 28 | +29 |-@pytest.mark.parametrize(("param1",), [1, 2, 3]) + 29 |+@pytest.mark.parametrize("param1", [1, 2, 3]) +30 30 | def test_tuple_one_elem(param1, param2): +31 31 | ... +32 32 | + +PT006.py:39:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `csv` + | +39 | @pytest.mark.parametrize(["param1"], [1, 2, 3]) + | ^^^^^^^^^^ PT006 +40 | def test_list_one_elem(param1, param2): +41 | ... + | + = help: Use a `csv` for parameter names + +ℹ Fix +36 36 | ... +37 37 | +38 38 | +39 |-@pytest.mark.parametrize(["param1"], [1, 2, 3]) + 39 |+@pytest.mark.parametrize("param1", [1, 2, 3]) +40 40 | def test_list_one_elem(param1, param2): +41 41 | ... +42 42 | + +PT006.py:54:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list` + | +54 | @pytest.mark.parametrize(("param1, " "param2, " "param3"), [(1, 2, 3), (4, 5, 6)]) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 +55 | def test_implicit_str_concat_with_parens(param1, param2, param3): +56 | ... + | + = help: Use a `list` for parameter names + +ℹ Suggested fix +51 51 | ... +52 52 | +53 53 | +54 |-@pytest.mark.parametrize(("param1, " "param2, " "param3"), [(1, 2, 3), (4, 5, 6)]) + 54 |+@pytest.mark.parametrize(["param1", "param2", "param3"], [(1, 2, 3), (4, 5, 6)]) +55 55 | def test_implicit_str_concat_with_parens(param1, param2, param3): +56 56 | ... +57 57 | + +PT006.py:59:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list` + | +59 | @pytest.mark.parametrize("param1, " "param2, " "param3", [(1, 2, 3), (4, 5, 6)]) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 +60 | def test_implicit_str_concat_no_parens(param1, param2, param3): +61 | ... + | + = help: Use a `list` for parameter names + +ℹ Suggested fix +56 56 | ... +57 57 | +58 58 | +59 |-@pytest.mark.parametrize("param1, " "param2, " "param3", [(1, 2, 3), (4, 5, 6)]) + 59 |+@pytest.mark.parametrize(["param1", "param2", "param3"], [(1, 2, 3), (4, 5, 6)]) +60 60 | def test_implicit_str_concat_no_parens(param1, param2, param3): +61 61 | ... +62 62 | + +PT006.py:64:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list` + | +64 | @pytest.mark.parametrize((("param1, " "param2, " "param3")), [(1, 2, 3), (4, 5, 6)]) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT006 +65 | def test_implicit_str_concat_with_multi_parens(param1, param2, param3): +66 | ... + | + = help: Use a `list` for parameter names + +ℹ Suggested fix +61 61 | ... +62 62 | +63 63 | +64 |-@pytest.mark.parametrize((("param1, " "param2, " "param3")), [(1, 2, 3), (4, 5, 6)]) + 64 |+@pytest.mark.parametrize(["param1", "param2", "param3"], [(1, 2, 3), (4, 5, 6)]) +65 65 | def test_implicit_str_concat_with_multi_parens(param1, param2, param3): +66 66 | ... +67 67 | + +PT006.py:69:26: PT006 [*] Wrong name(s) type in `@pytest.mark.parametrize`, expected `list` + | +69 | @pytest.mark.parametrize(("param1,param2"), [(1, 2), (3, 4)]) + | ^^^^^^^^^^^^^^^^^ PT006 +70 | def test_csv_with_parens(param1, param2): +71 | ... + | + = help: Use a `list` for parameter names + +ℹ Suggested fix +66 66 | ... +67 67 | +68 68 | +69 |-@pytest.mark.parametrize(("param1,param2"), [(1, 2), (3, 4)]) + 69 |+@pytest.mark.parametrize(["param1", "param2"], [(1, 2), (3, 4)]) +70 70 | def test_csv_with_parens(param1, param2): +71 71 | ... + + 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 new file mode 100644 index 0000000000..9e1c4d1307 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_lists.snap @@ -0,0 +1,107 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT007.py:4:35: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` + | +4 | @pytest.mark.parametrize("param", (1, 2)) + | ^^^^^^ PT007 +5 | def test_tuple(param): +6 | ... + | + +PT007.py:11:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` + | + 9 | @pytest.mark.parametrize( +10 | ("param1", "param2"), +11 | ( + | _____^ +12 | | (1, 2), +13 | | (3, 4), +14 | | ), + | |_____^ PT007 +15 | ) +16 | def test_tuple_of_tuples(param1, param2): + | + +PT007.py:12:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` + | +10 | ("param1", "param2"), +11 | ( +12 | (1, 2), + | ^^^^^^ PT007 +13 | (3, 4), +14 | ), + | + +PT007.py:13:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` + | +11 | ( +12 | (1, 2), +13 | (3, 4), + | ^^^^^^ PT007 +14 | ), +15 | ) + | + +PT007.py:22:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` + | +20 | @pytest.mark.parametrize( +21 | ("param1", "param2"), +22 | ( + | _____^ +23 | | [1, 2], +24 | | [3, 4], +25 | | ), + | |_____^ PT007 +26 | ) +27 | def test_tuple_of_lists(param1, param2): + | + +PT007.py:39:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` + | +37 | ("param1", "param2"), +38 | [ +39 | (1, 2), + | ^^^^^^ PT007 +40 | (3, 4), +41 | ], + | + +PT007.py:40:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` + | +38 | [ +39 | (1, 2), +40 | (3, 4), + | ^^^^^^ PT007 +41 | ], +42 | ) + | + +PT007.py:81:38: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` + | +80 | @pytest.mark.parametrize("a", [1, 2]) +81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) + | ^^^^^^^^^^^^^^^^ PT007 +82 | def test_multiple_decorators(a, b, c): +83 | pass + | + +PT007.py:81:39: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` + | +80 | @pytest.mark.parametrize("a", [1, 2]) +81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) + | ^^^^^^ PT007 +82 | def test_multiple_decorators(a, b, c): +83 | pass + | + +PT007.py:81:47: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `list` + | +80 | @pytest.mark.parametrize("a", [1, 2]) +81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) + | ^^^^^^ PT007 +82 | def test_multiple_decorators(a, b, c): +83 | pass + | + + 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 new file mode 100644 index 0000000000..bbb1555c40 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_list_of_tuples.snap @@ -0,0 +1,109 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT007.py:4:35: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` + | +4 | @pytest.mark.parametrize("param", (1, 2)) + | ^^^^^^ PT007 +5 | def test_tuple(param): +6 | ... + | + +PT007.py:11:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` + | + 9 | @pytest.mark.parametrize( +10 | ("param1", "param2"), +11 | ( + | _____^ +12 | | (1, 2), +13 | | (3, 4), +14 | | ), + | |_____^ PT007 +15 | ) +16 | def test_tuple_of_tuples(param1, param2): + | + +PT007.py:22:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` + | +20 | @pytest.mark.parametrize( +21 | ("param1", "param2"), +22 | ( + | _____^ +23 | | [1, 2], +24 | | [3, 4], +25 | | ), + | |_____^ PT007 +26 | ) +27 | def test_tuple_of_lists(param1, param2): + | + +PT007.py:23:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` + | +21 | ("param1", "param2"), +22 | ( +23 | [1, 2], + | ^^^^^^ PT007 +24 | [3, 4], +25 | ), + | + +PT007.py:24:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` + | +22 | ( +23 | [1, 2], +24 | [3, 4], + | ^^^^^^ PT007 +25 | ), +26 | ) + | + +PT007.py:50:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` + | +48 | ("param1", "param2"), +49 | [ +50 | [1, 2], + | ^^^^^^ PT007 +51 | [3, 4], +52 | ], + | + +PT007.py:51:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` + | +49 | [ +50 | [1, 2], +51 | [3, 4], + | ^^^^^^ PT007 +52 | ], +53 | ) + | + +PT007.py:61:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` + | +59 | "param1,param2", +60 | [ +61 | [1, 2], + | ^^^^^^ PT007 +62 | [3, 4], +63 | ], + | + +PT007.py:62:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` + | +60 | [ +61 | [1, 2], +62 | [3, 4], + | ^^^^^^ PT007 +63 | ], +64 | ) + | + +PT007.py:81:38: PT007 Wrong values type in `@pytest.mark.parametrize` expected `list` of `tuple` + | +80 | @pytest.mark.parametrize("a", [1, 2]) +81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) + | ^^^^^^^^^^^^^^^^ PT007 +82 | def test_multiple_decorators(a, b, c): +83 | pass + | + + 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 new file mode 100644 index 0000000000..f0745c5ea7 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_lists.snap @@ -0,0 +1,134 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT007.py:12:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` + | +10 | ("param1", "param2"), +11 | ( +12 | (1, 2), + | ^^^^^^ PT007 +13 | (3, 4), +14 | ), + | + +PT007.py:13:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` + | +11 | ( +12 | (1, 2), +13 | (3, 4), + | ^^^^^^ PT007 +14 | ), +15 | ) + | + +PT007.py:31:35: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` + | +31 | @pytest.mark.parametrize("param", [1, 2]) + | ^^^^^^ PT007 +32 | def test_list(param): +33 | ... + | + +PT007.py:38:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` + | +36 | @pytest.mark.parametrize( +37 | ("param1", "param2"), +38 | [ + | _____^ +39 | | (1, 2), +40 | | (3, 4), +41 | | ], + | |_____^ PT007 +42 | ) +43 | def test_list_of_tuples(param1, param2): + | + +PT007.py:39:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` + | +37 | ("param1", "param2"), +38 | [ +39 | (1, 2), + | ^^^^^^ PT007 +40 | (3, 4), +41 | ], + | + +PT007.py:40:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` + | +38 | [ +39 | (1, 2), +40 | (3, 4), + | ^^^^^^ PT007 +41 | ], +42 | ) + | + +PT007.py:49:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` + | +47 | @pytest.mark.parametrize( +48 | ("param1", "param2"), +49 | [ + | _____^ +50 | | [1, 2], +51 | | [3, 4], +52 | | ], + | |_____^ PT007 +53 | ) +54 | def test_list_of_lists(param1, param2): + | + +PT007.py:60:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` + | +58 | @pytest.mark.parametrize( +59 | "param1,param2", +60 | [ + | _____^ +61 | | [1, 2], +62 | | [3, 4], +63 | | ], + | |_____^ PT007 +64 | ) +65 | def test_csv_name_list_of_lists(param1, param2): + | + +PT007.py:71:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` + | +69 | @pytest.mark.parametrize( +70 | "param", +71 | [ + | _____^ +72 | | [1, 2], +73 | | [3, 4], +74 | | ], + | |_____^ PT007 +75 | ) +76 | def test_single_list_of_lists(param): + | + +PT007.py:80:31: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` + | +80 | @pytest.mark.parametrize("a", [1, 2]) + | ^^^^^^ PT007 +81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) +82 | def test_multiple_decorators(a, b, c): + | + +PT007.py:81:39: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` + | +80 | @pytest.mark.parametrize("a", [1, 2]) +81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) + | ^^^^^^ PT007 +82 | def test_multiple_decorators(a, b, c): +83 | pass + | + +PT007.py:81:47: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `list` + | +80 | @pytest.mark.parametrize("a", [1, 2]) +81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) + | ^^^^^^ PT007 +82 | def test_multiple_decorators(a, b, c): +83 | pass + | + + 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 new file mode 100644 index 0000000000..11260be581 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT007_tuple_of_tuples.snap @@ -0,0 +1,136 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT007.py:23:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` + | +21 | ("param1", "param2"), +22 | ( +23 | [1, 2], + | ^^^^^^ PT007 +24 | [3, 4], +25 | ), + | + +PT007.py:24:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` + | +22 | ( +23 | [1, 2], +24 | [3, 4], + | ^^^^^^ PT007 +25 | ), +26 | ) + | + +PT007.py:31:35: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` + | +31 | @pytest.mark.parametrize("param", [1, 2]) + | ^^^^^^ PT007 +32 | def test_list(param): +33 | ... + | + +PT007.py:38:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` + | +36 | @pytest.mark.parametrize( +37 | ("param1", "param2"), +38 | [ + | _____^ +39 | | (1, 2), +40 | | (3, 4), +41 | | ], + | |_____^ PT007 +42 | ) +43 | def test_list_of_tuples(param1, param2): + | + +PT007.py:49:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` + | +47 | @pytest.mark.parametrize( +48 | ("param1", "param2"), +49 | [ + | _____^ +50 | | [1, 2], +51 | | [3, 4], +52 | | ], + | |_____^ PT007 +53 | ) +54 | def test_list_of_lists(param1, param2): + | + +PT007.py:50:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` + | +48 | ("param1", "param2"), +49 | [ +50 | [1, 2], + | ^^^^^^ PT007 +51 | [3, 4], +52 | ], + | + +PT007.py:51:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` + | +49 | [ +50 | [1, 2], +51 | [3, 4], + | ^^^^^^ PT007 +52 | ], +53 | ) + | + +PT007.py:60:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` + | +58 | @pytest.mark.parametrize( +59 | "param1,param2", +60 | [ + | _____^ +61 | | [1, 2], +62 | | [3, 4], +63 | | ], + | |_____^ PT007 +64 | ) +65 | def test_csv_name_list_of_lists(param1, param2): + | + +PT007.py:61:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` + | +59 | "param1,param2", +60 | [ +61 | [1, 2], + | ^^^^^^ PT007 +62 | [3, 4], +63 | ], + | + +PT007.py:62:9: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` + | +60 | [ +61 | [1, 2], +62 | [3, 4], + | ^^^^^^ PT007 +63 | ], +64 | ) + | + +PT007.py:71:5: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` + | +69 | @pytest.mark.parametrize( +70 | "param", +71 | [ + | _____^ +72 | | [1, 2], +73 | | [3, 4], +74 | | ], + | |_____^ PT007 +75 | ) +76 | def test_single_list_of_lists(param): + | + +PT007.py:80:31: PT007 Wrong values type in `@pytest.mark.parametrize` expected `tuple` of `tuple` + | +80 | @pytest.mark.parametrize("a", [1, 2]) + | ^^^^^^ PT007 +81 | @pytest.mark.parametrize(("b", "c"), ((3, 4), (5, 6))) +82 | def test_multiple_decorators(a, b, c): + | + + 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 new file mode 100644 index 0000000000..9a09810de5 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT008.snap @@ -0,0 +1,116 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT008.py:35:1: PT008 Use `return_value=` instead of patching with `lambda` + | +33 | # Error +34 | +35 | mocker.patch("module.name", lambda: None) + | ^^^^^^^^^^^^ PT008 +36 | module_mocker.patch("module.name", lambda: None) +37 | mocker.patch.object(obj, "attr", lambda: None) + | + +PT008.py:36:1: PT008 Use `return_value=` instead of patching with `lambda` + | +35 | mocker.patch("module.name", lambda: None) +36 | module_mocker.patch("module.name", lambda: None) + | ^^^^^^^^^^^^^^^^^^^ PT008 +37 | mocker.patch.object(obj, "attr", lambda: None) +38 | module_mocker.patch.object(obj, "attr", lambda: None) + | + +PT008.py:37:1: PT008 Use `return_value=` instead of patching with `lambda` + | +35 | mocker.patch("module.name", lambda: None) +36 | module_mocker.patch("module.name", lambda: None) +37 | mocker.patch.object(obj, "attr", lambda: None) + | ^^^^^^^^^^^^^^^^^^^ PT008 +38 | module_mocker.patch.object(obj, "attr", lambda: None) + | + +PT008.py:38:1: PT008 Use `return_value=` instead of patching with `lambda` + | +36 | module_mocker.patch("module.name", lambda: None) +37 | mocker.patch.object(obj, "attr", lambda: None) +38 | module_mocker.patch.object(obj, "attr", lambda: None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PT008 +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 | +40 | mocker.patch("module.name", lambda x, y: None) + | ^^^^^^^^^^^^ PT008 +41 | module_mocker.patch("module.name", lambda x, y: None) +42 | mocker.patch.object(obj, "attr", lambda x, y: None) + | + +PT008.py:41:1: PT008 Use `return_value=` instead of patching with `lambda` + | +40 | mocker.patch("module.name", lambda x, y: None) +41 | module_mocker.patch("module.name", lambda x, y: None) + | ^^^^^^^^^^^^^^^^^^^ PT008 +42 | mocker.patch.object(obj, "attr", lambda x, y: None) +43 | module_mocker.patch.object(obj, "attr", lambda x, y: None) + | + +PT008.py:42:1: PT008 Use `return_value=` instead of patching with `lambda` + | +40 | mocker.patch("module.name", lambda x, y: None) +41 | module_mocker.patch("module.name", lambda x, y: None) +42 | mocker.patch.object(obj, "attr", lambda x, y: None) + | ^^^^^^^^^^^^^^^^^^^ PT008 +43 | module_mocker.patch.object(obj, "attr", lambda x, y: None) + | + +PT008.py:43:1: PT008 Use `return_value=` instead of patching with `lambda` + | +41 | module_mocker.patch("module.name", lambda x, y: None) +42 | mocker.patch.object(obj, "attr", lambda x, y: None) +43 | module_mocker.patch.object(obj, "attr", lambda x, y: None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PT008 +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 | +45 | mocker.patch("module.name", lambda *args, **kwargs: None) + | ^^^^^^^^^^^^ PT008 +46 | module_mocker.patch("module.name", lambda *args, **kwargs: None) +47 | mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) + | + +PT008.py:46:1: PT008 Use `return_value=` instead of patching with `lambda` + | +45 | mocker.patch("module.name", lambda *args, **kwargs: None) +46 | module_mocker.patch("module.name", lambda *args, **kwargs: None) + | ^^^^^^^^^^^^^^^^^^^ PT008 +47 | mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) +48 | module_mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) + | + +PT008.py:47:1: PT008 Use `return_value=` instead of patching with `lambda` + | +45 | mocker.patch("module.name", lambda *args, **kwargs: None) +46 | module_mocker.patch("module.name", lambda *args, **kwargs: None) +47 | mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) + | ^^^^^^^^^^^^^^^^^^^ PT008 +48 | module_mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) + | + +PT008.py:48:1: PT008 Use `return_value=` instead of patching with `lambda` + | +46 | module_mocker.patch("module.name", lambda *args, **kwargs: None) +47 | mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) +48 | module_mocker.patch.object(obj, "attr", lambda *args, **kwargs: None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PT008 + | + + 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 new file mode 100644 index 0000000000..9b4b7fc1e4 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT009.snap @@ -0,0 +1,663 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT009.py:11:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` + | + 9 | expr = 1 +10 | msg = "Must be True" +11 | self.assertTrue(expr) # Error + | ^^^^^^^^^^^^^^^ PT009 +12 | self.assertTrue(expr=expr) # Error +13 | self.assertTrue(expr, msg) # Error + | + = help: Replace `assertTrue(...)` with `assert ...` + +ℹ Suggested fix +8 8 | def test_assert_true(self): +9 9 | expr = 1 +10 10 | msg = "Must be True" +11 |- self.assertTrue(expr) # Error + 11 |+ assert expr # Error +12 12 | self.assertTrue(expr=expr) # Error +13 13 | self.assertTrue(expr, msg) # Error +14 14 | self.assertTrue(expr=expr, msg=msg) # Error + +PT009.py:12:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` + | +10 | msg = "Must be True" +11 | self.assertTrue(expr) # Error +12 | self.assertTrue(expr=expr) # Error + | ^^^^^^^^^^^^^^^ PT009 +13 | self.assertTrue(expr, msg) # Error +14 | self.assertTrue(expr=expr, msg=msg) # Error + | + = help: Replace `assertTrue(...)` with `assert ...` + +ℹ Suggested fix +9 9 | expr = 1 +10 10 | msg = "Must be True" +11 11 | self.assertTrue(expr) # Error +12 |- self.assertTrue(expr=expr) # Error + 12 |+ assert expr # Error +13 13 | self.assertTrue(expr, msg) # Error +14 14 | self.assertTrue(expr=expr, msg=msg) # Error +15 15 | self.assertTrue(msg=msg, expr=expr) # Error + +PT009.py:13:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` + | +11 | self.assertTrue(expr) # Error +12 | self.assertTrue(expr=expr) # Error +13 | self.assertTrue(expr, msg) # Error + | ^^^^^^^^^^^^^^^ PT009 +14 | self.assertTrue(expr=expr, msg=msg) # Error +15 | self.assertTrue(msg=msg, expr=expr) # Error + | + = help: Replace `assertTrue(...)` with `assert ...` + +ℹ Suggested fix +10 10 | msg = "Must be True" +11 11 | self.assertTrue(expr) # Error +12 12 | self.assertTrue(expr=expr) # Error +13 |- self.assertTrue(expr, msg) # Error + 13 |+ assert expr, msg # Error +14 14 | self.assertTrue(expr=expr, msg=msg) # Error +15 15 | self.assertTrue(msg=msg, expr=expr) # Error +16 16 | self.assertTrue(*(expr, msg)) # Error, unfixable + +PT009.py:14:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` + | +12 | self.assertTrue(expr=expr) # Error +13 | self.assertTrue(expr, msg) # Error +14 | self.assertTrue(expr=expr, msg=msg) # Error + | ^^^^^^^^^^^^^^^ PT009 +15 | self.assertTrue(msg=msg, expr=expr) # Error +16 | self.assertTrue(*(expr, msg)) # Error, unfixable + | + = help: Replace `assertTrue(...)` with `assert ...` + +ℹ Suggested fix +11 11 | self.assertTrue(expr) # Error +12 12 | self.assertTrue(expr=expr) # Error +13 13 | self.assertTrue(expr, msg) # Error +14 |- self.assertTrue(expr=expr, msg=msg) # Error + 14 |+ assert expr, msg # Error +15 15 | self.assertTrue(msg=msg, expr=expr) # Error +16 16 | self.assertTrue(*(expr, msg)) # Error, unfixable +17 17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable + +PT009.py:15:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` + | +13 | self.assertTrue(expr, msg) # Error +14 | self.assertTrue(expr=expr, msg=msg) # Error +15 | self.assertTrue(msg=msg, expr=expr) # Error + | ^^^^^^^^^^^^^^^ PT009 +16 | self.assertTrue(*(expr, msg)) # Error, unfixable +17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable + | + = help: Replace `assertTrue(...)` with `assert ...` + +ℹ Suggested fix +12 12 | self.assertTrue(expr=expr) # Error +13 13 | self.assertTrue(expr, msg) # Error +14 14 | self.assertTrue(expr=expr, msg=msg) # Error +15 |- self.assertTrue(msg=msg, expr=expr) # Error + 15 |+ assert expr, msg # Error +16 16 | self.assertTrue(*(expr, msg)) # Error, unfixable +17 17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable +18 18 | self.assertTrue(msg=msg, expr=expr, unexpected_arg=False) # Error, unfixable + +PT009.py:16:9: PT009 Use a regular `assert` instead of unittest-style `assertTrue` + | +14 | self.assertTrue(expr=expr, msg=msg) # Error +15 | self.assertTrue(msg=msg, expr=expr) # Error +16 | self.assertTrue(*(expr, msg)) # Error, unfixable + | ^^^^^^^^^^^^^^^ PT009 +17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable +18 | self.assertTrue(msg=msg, expr=expr, unexpected_arg=False) # Error, unfixable + | + = help: Replace `assertTrue(...)` with `assert ...` + +PT009.py:17:9: PT009 Use a regular `assert` instead of unittest-style `assertTrue` + | +15 | self.assertTrue(msg=msg, expr=expr) # Error +16 | self.assertTrue(*(expr, msg)) # Error, unfixable +17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable + | ^^^^^^^^^^^^^^^ PT009 +18 | self.assertTrue(msg=msg, expr=expr, unexpected_arg=False) # Error, unfixable +19 | self.assertTrue(msg=msg) # Error, unfixable + | + = help: Replace `assertTrue(...)` with `assert ...` + +PT009.py:18:9: PT009 Use a regular `assert` instead of unittest-style `assertTrue` + | +16 | self.assertTrue(*(expr, msg)) # Error, unfixable +17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable +18 | self.assertTrue(msg=msg, expr=expr, unexpected_arg=False) # Error, unfixable + | ^^^^^^^^^^^^^^^ PT009 +19 | self.assertTrue(msg=msg) # Error, unfixable +20 | ( + | + = help: Replace `assertTrue(...)` with `assert ...` + +PT009.py:19:9: PT009 Use a regular `assert` instead of unittest-style `assertTrue` + | +17 | self.assertTrue(**{"expr": expr, "msg": msg}) # Error, unfixable +18 | self.assertTrue(msg=msg, expr=expr, unexpected_arg=False) # Error, unfixable +19 | self.assertTrue(msg=msg) # Error, unfixable + | ^^^^^^^^^^^^^^^ PT009 +20 | ( +21 | self.assertIsNotNone(value) # Error, unfixable + | + = help: Replace `assertTrue(...)` with `assert ...` + +PT009.py:21:13: PT009 Use a regular `assert` instead of unittest-style `assertIsNotNone` + | +19 | self.assertTrue(msg=msg) # Error, unfixable +20 | ( +21 | self.assertIsNotNone(value) # Error, unfixable + | ^^^^^^^^^^^^^^^^^^^^ PT009 +22 | if expect_condition +23 | else self.assertIsNone(value) # Error, unfixable + | + = help: Replace `assertIsNotNone(...)` with `assert ...` + +PT009.py:23:18: PT009 Use a regular `assert` instead of unittest-style `assertIsNone` + | +21 | self.assertIsNotNone(value) # Error, unfixable +22 | if expect_condition +23 | else self.assertIsNone(value) # Error, unfixable + | ^^^^^^^^^^^^^^^^^ PT009 +24 | ) +25 | return self.assertEqual(True, False) # Error, unfixable + | + = help: Replace `assertIsNone(...)` with `assert ...` + +PT009.py:25:16: PT009 Use a regular `assert` instead of unittest-style `assertEqual` + | +23 | else self.assertIsNone(value) # Error, unfixable +24 | ) +25 | return self.assertEqual(True, False) # Error, unfixable + | ^^^^^^^^^^^^^^^^ PT009 +26 | +27 | def test_assert_false(self): + | + = help: Replace `assertEqual(...)` with `assert ...` + +PT009.py:28:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertFalse` + | +27 | def test_assert_false(self): +28 | self.assertFalse(True) # Error + | ^^^^^^^^^^^^^^^^ PT009 +29 | +30 | def test_assert_equal(self): + | + = help: Replace `assertFalse(...)` with `assert ...` + +ℹ Suggested fix +25 25 | return self.assertEqual(True, False) # Error, unfixable +26 26 | +27 27 | def test_assert_false(self): +28 |- self.assertFalse(True) # Error + 28 |+ assert not True # Error +29 29 | +30 30 | def test_assert_equal(self): +31 31 | self.assertEqual(1, 2) # Error + +PT009.py:31:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertEqual` + | +30 | def test_assert_equal(self): +31 | self.assertEqual(1, 2) # Error + | ^^^^^^^^^^^^^^^^ PT009 +32 | +33 | def test_assert_not_equal(self): + | + = help: Replace `assertEqual(...)` with `assert ...` + +ℹ Suggested fix +28 28 | self.assertFalse(True) # Error +29 29 | +30 30 | def test_assert_equal(self): +31 |- self.assertEqual(1, 2) # Error + 31 |+ assert 1 == 2 # Error +32 32 | +33 33 | def test_assert_not_equal(self): +34 34 | self.assertNotEqual(1, 1) # Error + +PT009.py:34:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotEqual` + | +33 | def test_assert_not_equal(self): +34 | self.assertNotEqual(1, 1) # Error + | ^^^^^^^^^^^^^^^^^^^ PT009 +35 | +36 | def test_assert_greater(self): + | + = help: Replace `assertNotEqual(...)` with `assert ...` + +ℹ Suggested fix +31 31 | self.assertEqual(1, 2) # Error +32 32 | +33 33 | def test_assert_not_equal(self): +34 |- self.assertNotEqual(1, 1) # Error + 34 |+ assert 1 != 1 # Error +35 35 | +36 36 | def test_assert_greater(self): +37 37 | self.assertGreater(1, 2) # Error + +PT009.py:37:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertGreater` + | +36 | def test_assert_greater(self): +37 | self.assertGreater(1, 2) # Error + | ^^^^^^^^^^^^^^^^^^ PT009 +38 | +39 | def test_assert_greater_equal(self): + | + = help: Replace `assertGreater(...)` with `assert ...` + +ℹ Suggested fix +34 34 | self.assertNotEqual(1, 1) # Error +35 35 | +36 36 | def test_assert_greater(self): +37 |- self.assertGreater(1, 2) # Error + 37 |+ assert 1 > 2 # Error +38 38 | +39 39 | def test_assert_greater_equal(self): +40 40 | self.assertGreaterEqual(1, 2) # Error + +PT009.py:40:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertGreaterEqual` + | +39 | def test_assert_greater_equal(self): +40 | self.assertGreaterEqual(1, 2) # Error + | ^^^^^^^^^^^^^^^^^^^^^^^ PT009 +41 | +42 | def test_assert_less(self): + | + = help: Replace `assertGreaterEqual(...)` with `assert ...` + +ℹ Suggested fix +37 37 | self.assertGreater(1, 2) # Error +38 38 | +39 39 | def test_assert_greater_equal(self): +40 |- self.assertGreaterEqual(1, 2) # Error + 40 |+ assert 1 >= 2 # Error +41 41 | +42 42 | def test_assert_less(self): +43 43 | self.assertLess(2, 1) # Error + +PT009.py:43:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertLess` + | +42 | def test_assert_less(self): +43 | self.assertLess(2, 1) # Error + | ^^^^^^^^^^^^^^^ PT009 +44 | +45 | def test_assert_less_equal(self): + | + = help: Replace `assertLess(...)` with `assert ...` + +ℹ Suggested fix +40 40 | self.assertGreaterEqual(1, 2) # Error +41 41 | +42 42 | def test_assert_less(self): +43 |- self.assertLess(2, 1) # Error + 43 |+ assert 2 < 1 # Error +44 44 | +45 45 | def test_assert_less_equal(self): +46 46 | self.assertLessEqual(1, 2) # Error + +PT009.py:46:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertLessEqual` + | +45 | def test_assert_less_equal(self): +46 | self.assertLessEqual(1, 2) # Error + | ^^^^^^^^^^^^^^^^^^^^ PT009 +47 | +48 | def test_assert_in(self): + | + = help: Replace `assertLessEqual(...)` with `assert ...` + +ℹ Suggested fix +43 43 | self.assertLess(2, 1) # Error +44 44 | +45 45 | def test_assert_less_equal(self): +46 |- self.assertLessEqual(1, 2) # Error + 46 |+ assert 1 <= 2 # Error +47 47 | +48 48 | def test_assert_in(self): +49 49 | self.assertIn(1, [2, 3]) # Error + +PT009.py:49:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIn` + | +48 | def test_assert_in(self): +49 | self.assertIn(1, [2, 3]) # Error + | ^^^^^^^^^^^^^ PT009 +50 | +51 | def test_assert_not_in(self): + | + = help: Replace `assertIn(...)` with `assert ...` + +ℹ Suggested fix +46 46 | self.assertLessEqual(1, 2) # Error +47 47 | +48 48 | def test_assert_in(self): +49 |- self.assertIn(1, [2, 3]) # Error + 49 |+ assert 1 in [2, 3] # Error +50 50 | +51 51 | def test_assert_not_in(self): +52 52 | self.assertNotIn(2, [2, 3]) # Error + +PT009.py:52:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotIn` + | +51 | def test_assert_not_in(self): +52 | self.assertNotIn(2, [2, 3]) # Error + | ^^^^^^^^^^^^^^^^ PT009 +53 | +54 | def test_assert_is_none(self): + | + = help: Replace `assertNotIn(...)` with `assert ...` + +ℹ Suggested fix +49 49 | self.assertIn(1, [2, 3]) # Error +50 50 | +51 51 | def test_assert_not_in(self): +52 |- self.assertNotIn(2, [2, 3]) # Error + 52 |+ assert 2 not in [2, 3] # Error +53 53 | +54 54 | def test_assert_is_none(self): +55 55 | self.assertIsNone(0) # Error + +PT009.py:55:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIsNone` + | +54 | def test_assert_is_none(self): +55 | self.assertIsNone(0) # Error + | ^^^^^^^^^^^^^^^^^ PT009 +56 | +57 | def test_assert_is_not_none(self): + | + = help: Replace `assertIsNone(...)` with `assert ...` + +ℹ Suggested fix +52 52 | self.assertNotIn(2, [2, 3]) # Error +53 53 | +54 54 | def test_assert_is_none(self): +55 |- self.assertIsNone(0) # Error + 55 |+ assert 0 is None # Error +56 56 | +57 57 | def test_assert_is_not_none(self): +58 58 | self.assertIsNotNone(0) # Error + +PT009.py:58:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIsNotNone` + | +57 | def test_assert_is_not_none(self): +58 | self.assertIsNotNone(0) # Error + | ^^^^^^^^^^^^^^^^^^^^ PT009 +59 | +60 | def test_assert_is(self): + | + = help: Replace `assertIsNotNone(...)` with `assert ...` + +ℹ Suggested fix +55 55 | self.assertIsNone(0) # Error +56 56 | +57 57 | def test_assert_is_not_none(self): +58 |- self.assertIsNotNone(0) # Error + 58 |+ assert 0 is not None # Error +59 59 | +60 60 | def test_assert_is(self): +61 61 | self.assertIs([], []) # Error + +PT009.py:61:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIs` + | +60 | def test_assert_is(self): +61 | self.assertIs([], []) # Error + | ^^^^^^^^^^^^^ PT009 +62 | +63 | def test_assert_is_not(self): + | + = help: Replace `assertIs(...)` with `assert ...` + +ℹ Suggested fix +58 58 | self.assertIsNotNone(0) # Error +59 59 | +60 60 | def test_assert_is(self): +61 |- self.assertIs([], []) # Error + 61 |+ assert [] is [] # Error +62 62 | +63 63 | def test_assert_is_not(self): +64 64 | self.assertIsNot(1, 1) # Error + +PT009.py:64:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIsNot` + | +63 | def test_assert_is_not(self): +64 | self.assertIsNot(1, 1) # Error + | ^^^^^^^^^^^^^^^^ PT009 +65 | +66 | def test_assert_is_instance(self): + | + = help: Replace `assertIsNot(...)` with `assert ...` + +ℹ Suggested fix +61 61 | self.assertIs([], []) # Error +62 62 | +63 63 | def test_assert_is_not(self): +64 |- self.assertIsNot(1, 1) # Error + 64 |+ assert 1 is not 1 # Error +65 65 | +66 66 | def test_assert_is_instance(self): +67 67 | self.assertIsInstance(1, str) # Error + +PT009.py:67:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertIsInstance` + | +66 | def test_assert_is_instance(self): +67 | self.assertIsInstance(1, str) # Error + | ^^^^^^^^^^^^^^^^^^^^^ PT009 +68 | +69 | def test_assert_is_not_instance(self): + | + = help: Replace `assertIsInstance(...)` with `assert ...` + +ℹ Suggested fix +64 64 | self.assertIsNot(1, 1) # Error +65 65 | +66 66 | def test_assert_is_instance(self): +67 |- self.assertIsInstance(1, str) # Error + 67 |+ assert isinstance(1, str) # Error +68 68 | +69 69 | def test_assert_is_not_instance(self): +70 70 | self.assertNotIsInstance(1, int) # Error + +PT009.py:70:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotIsInstance` + | +69 | def test_assert_is_not_instance(self): +70 | self.assertNotIsInstance(1, int) # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^ PT009 +71 | +72 | def test_assert_regex(self): + | + = help: Replace `assertNotIsInstance(...)` with `assert ...` + +ℹ Suggested fix +67 67 | self.assertIsInstance(1, str) # Error +68 68 | +69 69 | def test_assert_is_not_instance(self): +70 |- self.assertNotIsInstance(1, int) # Error + 70 |+ assert not isinstance(1, int) # Error +71 71 | +72 72 | def test_assert_regex(self): +73 73 | self.assertRegex("abc", r"def") # Error + +PT009.py:73:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertRegex` + | +72 | def test_assert_regex(self): +73 | self.assertRegex("abc", r"def") # Error + | ^^^^^^^^^^^^^^^^ PT009 +74 | +75 | def test_assert_not_regex(self): + | + = help: Replace `assertRegex(...)` with `assert ...` + +ℹ Suggested fix +70 70 | self.assertNotIsInstance(1, int) # Error +71 71 | +72 72 | def test_assert_regex(self): +73 |- self.assertRegex("abc", r"def") # Error + 73 |+ assert re.search("def", "abc") # Error +74 74 | +75 75 | def test_assert_not_regex(self): +76 76 | self.assertNotRegex("abc", r"abc") # Error + +PT009.py:76:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotRegex` + | +75 | def test_assert_not_regex(self): +76 | self.assertNotRegex("abc", r"abc") # Error + | ^^^^^^^^^^^^^^^^^^^ PT009 +77 | +78 | def test_assert_regexp_matches(self): + | + = help: Replace `assertNotRegex(...)` with `assert ...` + +ℹ Suggested fix +73 73 | self.assertRegex("abc", r"def") # Error +74 74 | +75 75 | def test_assert_not_regex(self): +76 |- self.assertNotRegex("abc", r"abc") # Error + 76 |+ assert not re.search("abc", "abc") # Error +77 77 | +78 78 | def test_assert_regexp_matches(self): +79 79 | self.assertRegexpMatches("abc", r"def") # Error + +PT009.py:79:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertRegexpMatches` + | +78 | def test_assert_regexp_matches(self): +79 | self.assertRegexpMatches("abc", r"def") # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^ PT009 +80 | +81 | def test_assert_not_regexp_matches(self): + | + = help: Replace `assertRegexpMatches(...)` with `assert ...` + +ℹ Suggested fix +76 76 | self.assertNotRegex("abc", r"abc") # Error +77 77 | +78 78 | def test_assert_regexp_matches(self): +79 |- self.assertRegexpMatches("abc", r"def") # Error + 79 |+ assert re.search("def", "abc") # Error +80 80 | +81 81 | def test_assert_not_regexp_matches(self): +82 82 | self.assertNotRegex("abc", r"abc") # Error + +PT009.py:82:9: PT009 [*] Use a regular `assert` instead of unittest-style `assertNotRegex` + | +81 | def test_assert_not_regexp_matches(self): +82 | self.assertNotRegex("abc", r"abc") # Error + | ^^^^^^^^^^^^^^^^^^^ PT009 +83 | +84 | def test_fail_if(self): + | + = help: Replace `assertNotRegex(...)` with `assert ...` + +ℹ Suggested fix +79 79 | self.assertRegexpMatches("abc", r"def") # Error +80 80 | +81 81 | def test_assert_not_regexp_matches(self): +82 |- self.assertNotRegex("abc", r"abc") # Error + 82 |+ assert not re.search("abc", "abc") # Error +83 83 | +84 84 | def test_fail_if(self): +85 85 | self.failIf("abc") # Error + +PT009.py:85:9: PT009 [*] Use a regular `assert` instead of unittest-style `failIf` + | +84 | def test_fail_if(self): +85 | self.failIf("abc") # Error + | ^^^^^^^^^^^ PT009 +86 | +87 | def test_fail_unless(self): + | + = help: Replace `failIf(...)` with `assert ...` + +ℹ Suggested fix +82 82 | self.assertNotRegex("abc", r"abc") # Error +83 83 | +84 84 | def test_fail_if(self): +85 |- self.failIf("abc") # Error + 85 |+ assert not "abc" # Error +86 86 | +87 87 | def test_fail_unless(self): +88 88 | self.failUnless("abc") # Error + +PT009.py:88:9: PT009 [*] Use a regular `assert` instead of unittest-style `failUnless` + | +87 | def test_fail_unless(self): +88 | self.failUnless("abc") # Error + | ^^^^^^^^^^^^^^^ PT009 +89 | +90 | def test_fail_unless_equal(self): + | + = help: Replace `failUnless(...)` with `assert ...` + +ℹ Suggested fix +85 85 | self.failIf("abc") # Error +86 86 | +87 87 | def test_fail_unless(self): +88 |- self.failUnless("abc") # Error + 88 |+ assert "abc" # Error +89 89 | +90 90 | def test_fail_unless_equal(self): +91 91 | self.failUnlessEqual(1, 2) # Error + +PT009.py:91:9: PT009 [*] Use a regular `assert` instead of unittest-style `failUnlessEqual` + | +90 | def test_fail_unless_equal(self): +91 | self.failUnlessEqual(1, 2) # Error + | ^^^^^^^^^^^^^^^^^^^^ PT009 +92 | +93 | def test_fail_if_equal(self): + | + = help: Replace `failUnlessEqual(...)` with `assert ...` + +ℹ Suggested fix +88 88 | self.failUnless("abc") # Error +89 89 | +90 90 | def test_fail_unless_equal(self): +91 |- self.failUnlessEqual(1, 2) # Error + 91 |+ assert 1 == 2 # Error +92 92 | +93 93 | def test_fail_if_equal(self): +94 94 | self.failIfEqual(1, 2) # Error + +PT009.py:94:9: PT009 [*] Use a regular `assert` instead of unittest-style `failIfEqual` + | +93 | def test_fail_if_equal(self): +94 | self.failIfEqual(1, 2) # Error + | ^^^^^^^^^^^^^^^^ PT009 + | + = help: Replace `failIfEqual(...)` with `assert ...` + +ℹ Suggested fix +91 91 | self.failUnlessEqual(1, 2) # Error +92 92 | +93 93 | def test_fail_if_equal(self): +94 |- self.failIfEqual(1, 2) # Error + 94 |+ assert 1 != 2 # Error +95 95 | +96 96 | +97 97 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459517 + +PT009.py:98:2: PT009 [*] Use a regular `assert` instead of unittest-style `assertTrue` + | + 97 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459517 + 98 | (self.assertTrue( + | ^^^^^^^^^^^^^^^ PT009 + 99 | "piAx_piAy_beta[r][x][y] = {17}".format( +100 | self.model.piAx_piAy_beta[r][x][y]))) + | + = help: Replace `assertTrue(...)` with `assert ...` + +ℹ Suggested fix +95 95 | +96 96 | +97 97 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459517 +98 |-(self.assertTrue( +99 |- "piAx_piAy_beta[r][x][y] = {17}".format( +100 |- self.model.piAx_piAy_beta[r][x][y]))) + 98 |+assert "piAx_piAy_beta[r][x][y] = {17}".format(self.model.piAx_piAy_beta[r][x][y]) + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT010.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT010.snap new file mode 100644 index 0000000000..b4a70fd896 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT010.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT010.py:5:10: PT010 set the expected exception in `pytest.raises()` + | +4 | def test_ok(): +5 | with pytest.raises(): + | ^^^^^^^^^^^^^ PT010 +6 | pass + | + + 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 new file mode 100644 index 0000000000..3f83b28f69 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_default.snap @@ -0,0 +1,47 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT011.py:18:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + | +17 | def test_error_no_argument_given(): +18 | with pytest.raises(ValueError): + | ^^^^^^^^^^ PT011 +19 | raise ValueError("Can't divide 1 by 0") + | + +PT011.py:21:24: PT011 `pytest.raises(socket.error)` is too broad, set the `match` parameter or use a more specific exception + | +19 | raise ValueError("Can't divide 1 by 0") +20 | +21 | with pytest.raises(socket.error): + | ^^^^^^^^^^^^ PT011 +22 | raise ValueError("Can't divide 1 by 0") + | + +PT011.py:32:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + | +31 | def test_error_match_is_empty(): +32 | with pytest.raises(ValueError, match=None): + | ^^^^^^^^^^ PT011 +33 | raise ValueError("Can't divide 1 by 0") + | + +PT011.py:35:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + | +33 | raise ValueError("Can't divide 1 by 0") +34 | +35 | with pytest.raises(ValueError, match=""): + | ^^^^^^^^^^ PT011 +36 | raise ValueError("Can't divide 1 by 0") + | + +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 | +38 | with pytest.raises(ValueError, match=f""): + | ^^^^^^^^^^ PT011 +39 | 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 new file mode 100644 index 0000000000..9c0e5b1466 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_extend_broad_exceptions.snap @@ -0,0 +1,55 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT011.py:13:24: PT011 `pytest.raises(ZeroDivisionError)` is too broad, set the `match` parameter or use a more specific exception + | +12 | def test_ok_different_error_from_config(): +13 | with pytest.raises(ZeroDivisionError): + | ^^^^^^^^^^^^^^^^^ PT011 +14 | raise ZeroDivisionError("Can't divide by 0") + | + +PT011.py:18:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + | +17 | def test_error_no_argument_given(): +18 | with pytest.raises(ValueError): + | ^^^^^^^^^^ PT011 +19 | raise ValueError("Can't divide 1 by 0") + | + +PT011.py:21:24: PT011 `pytest.raises(socket.error)` is too broad, set the `match` parameter or use a more specific exception + | +19 | raise ValueError("Can't divide 1 by 0") +20 | +21 | with pytest.raises(socket.error): + | ^^^^^^^^^^^^ PT011 +22 | raise ValueError("Can't divide 1 by 0") + | + +PT011.py:32:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + | +31 | def test_error_match_is_empty(): +32 | with pytest.raises(ValueError, match=None): + | ^^^^^^^^^^ PT011 +33 | raise ValueError("Can't divide 1 by 0") + | + +PT011.py:35:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + | +33 | raise ValueError("Can't divide 1 by 0") +34 | +35 | with pytest.raises(ValueError, match=""): + | ^^^^^^^^^^ PT011 +36 | raise ValueError("Can't divide 1 by 0") + | + +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 | +38 | with pytest.raises(ValueError, match=f""): + | ^^^^^^^^^^ PT011 +39 | 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 new file mode 100644 index 0000000000..92dffb921c --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_glob_all.snap @@ -0,0 +1,73 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT011.py:13:24: PT011 `pytest.raises(ZeroDivisionError)` is too broad, set the `match` parameter or use a more specific exception + | +12 | def test_ok_different_error_from_config(): +13 | with pytest.raises(ZeroDivisionError): + | ^^^^^^^^^^^^^^^^^ PT011 +14 | raise ZeroDivisionError("Can't divide by 0") + | + +PT011.py:18:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + | +17 | def test_error_no_argument_given(): +18 | with pytest.raises(ValueError): + | ^^^^^^^^^^ PT011 +19 | raise ValueError("Can't divide 1 by 0") + | + +PT011.py:21:24: PT011 `pytest.raises(socket.error)` is too broad, set the `match` parameter or use a more specific exception + | +19 | raise ValueError("Can't divide 1 by 0") +20 | +21 | with pytest.raises(socket.error): + | ^^^^^^^^^^^^ PT011 +22 | raise ValueError("Can't divide 1 by 0") + | + +PT011.py:24:24: PT011 `pytest.raises(pickle.PicklingError)` is too broad, set the `match` parameter or use a more specific exception + | +22 | raise ValueError("Can't divide 1 by 0") +23 | +24 | with pytest.raises(PicklingError): + | ^^^^^^^^^^^^^ PT011 +25 | raise PicklingError("Can't pickle") + | + +PT011.py:27:24: PT011 `pytest.raises(pickle.UnpicklingError)` is too broad, set the `match` parameter or use a more specific exception + | +25 | raise PicklingError("Can't pickle") +26 | +27 | with pytest.raises(UnpicklingError): + | ^^^^^^^^^^^^^^^ PT011 +28 | raise UnpicklingError("Can't unpickle") + | + +PT011.py:32:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + | +31 | def test_error_match_is_empty(): +32 | with pytest.raises(ValueError, match=None): + | ^^^^^^^^^^ PT011 +33 | raise ValueError("Can't divide 1 by 0") + | + +PT011.py:35:24: PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception + | +33 | raise ValueError("Can't divide 1 by 0") +34 | +35 | with pytest.raises(ValueError, match=""): + | ^^^^^^^^^^ PT011 +36 | raise ValueError("Can't divide 1 by 0") + | + +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 | +38 | with pytest.raises(ValueError, match=f""): + | ^^^^^^^^^^ PT011 +39 | 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 new file mode 100644 index 0000000000..bdc704d4e9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_glob_prefix.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT011.py:24:24: PT011 `pytest.raises(pickle.PicklingError)` is too broad, set the `match` parameter or use a more specific exception + | +22 | raise ValueError("Can't divide 1 by 0") +23 | +24 | with pytest.raises(PicklingError): + | ^^^^^^^^^^^^^ PT011 +25 | raise PicklingError("Can't pickle") + | + +PT011.py:27:24: PT011 `pytest.raises(pickle.UnpicklingError)` is too broad, set the `match` parameter or use a more specific exception + | +25 | raise PicklingError("Can't pickle") +26 | +27 | with pytest.raises(UnpicklingError): + | ^^^^^^^^^^^^^^^ PT011 +28 | raise UnpicklingError("Can't unpickle") + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_replace_broad_exceptions.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_replace_broad_exceptions.snap new file mode 100644 index 0000000000..9ffc1874a3 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT011_replace_broad_exceptions.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT011.py:13:24: PT011 `pytest.raises(ZeroDivisionError)` is too broad, set the `match` parameter or use a more specific exception + | +12 | def test_ok_different_error_from_config(): +13 | with pytest.raises(ZeroDivisionError): + | ^^^^^^^^^^^^^^^^^ PT011 +14 | raise ZeroDivisionError("Can't divide by 0") + | + + 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 new file mode 100644 index 0000000000..3a9d77b806 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT012.snap @@ -0,0 +1,89 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +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): + | _____^ +43 | | len([]) +44 | | [].size + | |_______________^ PT012 + | + +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): + | _____^ +49 | | if True: +50 | | [].size + | |___________________^ PT012 +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): + | _____^ +53 | | for i in []: +54 | | [].size + | |___________________^ PT012 +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): + | _____^ +57 | | async for i in []: +58 | | [].size + | |___________________^ PT012 +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): + | _____^ +61 | | while True: +62 | | [].size + | |___________________^ PT012 +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): + | _____^ +65 | | async with context_manager_under_test(): +66 | | if True: +67 | | raise Exception + | |_______________________________^ PT012 + | + +PT012.py:71:5: PT012 `pytest.raises()` block should contain a single simple statement + | +70 | def test_error_try(): +71 | with pytest.raises(AttributeError): + | _____^ +72 | | try: +73 | | [].size +74 | | except: +75 | | raise + | |_________________^ PT012 + | + + 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 new file mode 100644 index 0000000000..abf2676ca0 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT013.snap @@ -0,0 +1,30 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT013.py:11:1: PT013 Found incorrect import of pytest, use simple `import pytest` instead + | + 9 | # Error +10 | +11 | import pytest as other_name + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT013 +12 | from pytest import fixture +13 | from pytest import fixture as other_name + | + +PT013.py:12:1: PT013 Found incorrect import of pytest, use simple `import pytest` instead + | +11 | import pytest as other_name +12 | from pytest import fixture + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PT013 +13 | from pytest import fixture as other_name + | + +PT013.py:13:1: PT013 Found incorrect import of pytest, use simple `import pytest` instead + | +11 | import pytest as other_name +12 | from pytest import fixture +13 | from pytest import fixture as other_name + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT013 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT014.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT014.snap new file mode 100644 index 0000000000..2e05167b05 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT014.snap @@ -0,0 +1,169 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT014.py:4:35: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.parametrize` + | +4 | @pytest.mark.parametrize("x", [1, 1, 2]) + | ^ PT014 +5 | def test_error_literal(x): +6 | ... + | + = help: Remove duplicate test case + +ℹ Suggested fix +1 1 | import pytest +2 2 | +3 3 | +4 |-@pytest.mark.parametrize("x", [1, 1, 2]) + 4 |+@pytest.mark.parametrize("x", [1, 2]) +5 5 | def test_error_literal(x): +6 6 | ... +7 7 | + +PT014.py:14:35: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.parametrize` + | +14 | @pytest.mark.parametrize("x", [a, a, b, b, b, c]) + | ^ PT014 +15 | def test_error_expr_simple(x): +16 | ... + | + = help: Remove duplicate test case + +ℹ Suggested fix +11 11 | c = 3 +12 12 | +13 13 | +14 |-@pytest.mark.parametrize("x", [a, a, b, b, b, c]) + 14 |+@pytest.mark.parametrize("x", [a, b, b, b, c]) +15 15 | def test_error_expr_simple(x): +16 16 | ... +17 17 | + +PT014.py:14:41: PT014 [*] Duplicate of test case at index 2 in `@pytest_mark.parametrize` + | +14 | @pytest.mark.parametrize("x", [a, a, b, b, b, c]) + | ^ PT014 +15 | def test_error_expr_simple(x): +16 | ... + | + = help: Remove duplicate test case + +ℹ Suggested fix +11 11 | c = 3 +12 12 | +13 13 | +14 |-@pytest.mark.parametrize("x", [a, a, b, b, b, c]) + 14 |+@pytest.mark.parametrize("x", [a, a, b, b, c]) +15 15 | def test_error_expr_simple(x): +16 16 | ... +17 17 | + +PT014.py:14:44: PT014 [*] Duplicate of test case at index 2 in `@pytest_mark.parametrize` + | +14 | @pytest.mark.parametrize("x", [a, a, b, b, b, c]) + | ^ PT014 +15 | def test_error_expr_simple(x): +16 | ... + | + = help: Remove duplicate test case + +ℹ Suggested fix +11 11 | c = 3 +12 12 | +13 13 | +14 |-@pytest.mark.parametrize("x", [a, a, b, b, b, c]) + 14 |+@pytest.mark.parametrize("x", [a, a, b, b, c]) +15 15 | def test_error_expr_simple(x): +16 16 | ... +17 17 | + +PT014.py:24:9: PT014 Duplicate of test case at index 0 in `@pytest_mark.parametrize` + | +22 | (a, b), +23 | # comment +24 | (a, b), + | ^^^^^^ PT014 +25 | (b, c), +26 | ], + | + = help: Remove duplicate test case + +PT014.py:32:39: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.parametrize` + | +32 | @pytest.mark.parametrize("x", [a, b, (a), c, ((a))]) + | ^ PT014 +33 | def test_error_parentheses(x): +34 | ... + | + = help: Remove duplicate test case + +ℹ Suggested fix +29 29 | ... +30 30 | +31 31 | +32 |-@pytest.mark.parametrize("x", [a, b, (a), c, ((a))]) + 32 |+@pytest.mark.parametrize("x", [a, b, c, ((a))]) +33 33 | def test_error_parentheses(x): +34 34 | ... +35 35 | + +PT014.py:32:48: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.parametrize` + | +32 | @pytest.mark.parametrize("x", [a, b, (a), c, ((a))]) + | ^ PT014 +33 | def test_error_parentheses(x): +34 | ... + | + = help: Remove duplicate test case + +ℹ Suggested fix +29 29 | ... +30 30 | +31 31 | +32 |-@pytest.mark.parametrize("x", [a, b, (a), c, ((a))]) + 32 |+@pytest.mark.parametrize("x", [a, b, (a), c]) +33 33 | def test_error_parentheses(x): +34 34 | ... +35 35 | + +PT014.py:42:10: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.parametrize` + | +40 | a, +41 | b, +42 | (a), + | ^ PT014 +43 | c, +44 | ((a)), + | + = help: Remove duplicate test case + +ℹ Suggested fix +39 39 | [ +40 40 | a, +41 41 | b, +42 |- (a), +43 42 | c, +44 43 | ((a)), +45 44 | ], + +PT014.py:44:11: PT014 [*] Duplicate of test case at index 0 in `@pytest_mark.parametrize` + | +42 | (a), +43 | c, +44 | ((a)), + | ^ PT014 +45 | ], +46 | ) + | + = help: Remove duplicate test case + +ℹ Suggested fix +41 41 | b, +42 42 | (a), +43 43 | c, +44 |- ((a)), +45 44 | ], +46 45 | ) +47 46 | def test_error_parentheses_trailing_comma(x): + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT015.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT015.snap new file mode 100644 index 0000000000..6bd15c3a12 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT015.snap @@ -0,0 +1,170 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT015.py:9:5: PT015 Assertion always fails, replace with `pytest.fail()` + | + 8 | def test_error(): + 9 | assert None + | ^^^^^^^^^^^ PT015 +10 | assert False +11 | assert 0 + | + +PT015.py:10:5: PT015 Assertion always fails, replace with `pytest.fail()` + | + 8 | def test_error(): + 9 | assert None +10 | assert False + | ^^^^^^^^^^^^ PT015 +11 | assert 0 +12 | assert 0.0 + | + +PT015.py:11:5: PT015 Assertion always fails, replace with `pytest.fail()` + | + 9 | assert None +10 | assert False +11 | assert 0 + | ^^^^^^^^ PT015 +12 | assert 0.0 +13 | assert "" + | + +PT015.py:12:5: PT015 Assertion always fails, replace with `pytest.fail()` + | +10 | assert False +11 | assert 0 +12 | assert 0.0 + | ^^^^^^^^^^ PT015 +13 | assert "" +14 | assert f"" + | + +PT015.py:13:5: PT015 Assertion always fails, replace with `pytest.fail()` + | +11 | assert 0 +12 | assert 0.0 +13 | assert "" + | ^^^^^^^^^ PT015 +14 | assert f"" +15 | assert [] + | + +PT015.py:14:5: PT015 Assertion always fails, replace with `pytest.fail()` + | +12 | assert 0.0 +13 | assert "" +14 | assert f"" + | ^^^^^^^^^^ PT015 +15 | assert [] +16 | assert () + | + +PT015.py:15:5: PT015 Assertion always fails, replace with `pytest.fail()` + | +13 | assert "" +14 | assert f"" +15 | assert [] + | ^^^^^^^^^ PT015 +16 | assert () +17 | assert {} + | + +PT015.py:16:5: PT015 Assertion always fails, replace with `pytest.fail()` + | +14 | assert f"" +15 | assert [] +16 | assert () + | ^^^^^^^^^ PT015 +17 | assert {} +18 | assert list() + | + +PT015.py:17:5: PT015 Assertion always fails, replace with `pytest.fail()` + | +15 | assert [] +16 | assert () +17 | assert {} + | ^^^^^^^^^ PT015 +18 | assert list() +19 | assert set() + | + +PT015.py:18:5: PT015 Assertion always fails, replace with `pytest.fail()` + | +16 | assert () +17 | assert {} +18 | assert list() + | ^^^^^^^^^^^^^ PT015 +19 | assert set() +20 | assert tuple() + | + +PT015.py:19:5: PT015 Assertion always fails, replace with `pytest.fail()` + | +17 | assert {} +18 | assert list() +19 | assert set() + | ^^^^^^^^^^^^ PT015 +20 | assert tuple() +21 | assert dict() + | + +PT015.py:20:5: PT015 Assertion always fails, replace with `pytest.fail()` + | +18 | assert list() +19 | assert set() +20 | assert tuple() + | ^^^^^^^^^^^^^^ PT015 +21 | assert dict() +22 | assert frozenset() + | + +PT015.py:21:5: PT015 Assertion always fails, replace with `pytest.fail()` + | +19 | assert set() +20 | assert tuple() +21 | assert dict() + | ^^^^^^^^^^^^^ PT015 +22 | assert frozenset() +23 | assert list([]) + | + +PT015.py:22:5: PT015 Assertion always fails, replace with `pytest.fail()` + | +20 | assert tuple() +21 | assert dict() +22 | assert frozenset() + | ^^^^^^^^^^^^^^^^^^ PT015 +23 | assert list([]) +24 | assert set(set()) + | + +PT015.py:23:5: PT015 Assertion always fails, replace with `pytest.fail()` + | +21 | assert dict() +22 | assert frozenset() +23 | assert list([]) + | ^^^^^^^^^^^^^^^ PT015 +24 | assert set(set()) +25 | assert tuple("") + | + +PT015.py:24:5: PT015 Assertion always fails, replace with `pytest.fail()` + | +22 | assert frozenset() +23 | assert list([]) +24 | assert set(set()) + | ^^^^^^^^^^^^^^^^^ PT015 +25 | assert tuple("") + | + +PT015.py:25:5: PT015 Assertion always fails, replace with `pytest.fail()` + | +23 | assert list([]) +24 | assert set(set()) +25 | assert tuple("") + | ^^^^^^^^^^^^^^^^ PT015 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT016.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT016.snap new file mode 100644 index 0000000000..4586ae4494 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT016.snap @@ -0,0 +1,71 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT016.py:19:5: PT016 No message passed to `pytest.fail()` + | +17 | # Errors +18 | def f(): +19 | pytest.fail() + | ^^^^^^^^^^^ PT016 +20 | pytest.fail("") +21 | pytest.fail(f"") + | + +PT016.py:20:5: PT016 No message passed to `pytest.fail()` + | +18 | def f(): +19 | pytest.fail() +20 | pytest.fail("") + | ^^^^^^^^^^^ PT016 +21 | pytest.fail(f"") +22 | pytest.fail(msg="") + | + +PT016.py:21:5: PT016 No message passed to `pytest.fail()` + | +19 | pytest.fail() +20 | pytest.fail("") +21 | pytest.fail(f"") + | ^^^^^^^^^^^ PT016 +22 | pytest.fail(msg="") +23 | pytest.fail(msg=f"") + | + +PT016.py:22:5: PT016 No message passed to `pytest.fail()` + | +20 | pytest.fail("") +21 | pytest.fail(f"") +22 | pytest.fail(msg="") + | ^^^^^^^^^^^ PT016 +23 | pytest.fail(msg=f"") +24 | pytest.fail(reason="") + | + +PT016.py:23:5: PT016 No message passed to `pytest.fail()` + | +21 | pytest.fail(f"") +22 | pytest.fail(msg="") +23 | pytest.fail(msg=f"") + | ^^^^^^^^^^^ PT016 +24 | pytest.fail(reason="") +25 | pytest.fail(reason=f"") + | + +PT016.py:24:5: PT016 No message passed to `pytest.fail()` + | +22 | pytest.fail(msg="") +23 | pytest.fail(msg=f"") +24 | pytest.fail(reason="") + | ^^^^^^^^^^^ PT016 +25 | pytest.fail(reason=f"") + | + +PT016.py:25:5: PT016 No message passed to `pytest.fail()` + | +23 | pytest.fail(msg=f"") +24 | pytest.fail(reason="") +25 | pytest.fail(reason=f"") + | ^^^^^^^^^^^ PT016 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT017.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT017.snap new file mode 100644 index 0000000000..3bfc17a4b2 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT017.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT017.py:19:9: PT017 Found assertion on exception `e` in `except` block, use `pytest.raises()` instead + | +17 | something() +18 | except Exception as e: +19 | assert e.message, "blah blah" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT017 + | + + 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 new file mode 100644 index 0000000000..c32ecf025b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT018.snap @@ -0,0 +1,417 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT018.py:14:5: PT018 [*] Assertion should be broken down into multiple parts + | +13 | def test_error(): +14 | assert something and something_else + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 +15 | assert something and something_else and something_third +16 | assert something and not something_else + | + = help: Break down assertion into multiple parts + +ℹ Suggested fix +11 11 | +12 12 | +13 13 | def test_error(): +14 |- assert something and something_else + 14 |+ assert something + 15 |+ assert something_else +15 16 | assert something and something_else and something_third +16 17 | assert something and not something_else +17 18 | assert something and (something_else or something_third) + +PT018.py:15:5: PT018 [*] Assertion should be broken down into multiple parts + | +13 | def test_error(): +14 | assert something and something_else +15 | assert something and something_else and something_third + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 +16 | assert something and not something_else +17 | assert something and (something_else or something_third) + | + = help: Break down assertion into multiple parts + +ℹ Suggested fix +12 12 | +13 13 | def test_error(): +14 14 | assert something and something_else +15 |- assert something and something_else and something_third + 15 |+ assert something and something_else + 16 |+ assert something_third +16 17 | assert something and not something_else +17 18 | assert something and (something_else or something_third) +18 19 | assert not something and something_else + +PT018.py:16:5: PT018 [*] Assertion should be broken down into multiple parts + | +14 | assert something and something_else +15 | assert something and something_else and something_third +16 | assert something and not something_else + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 +17 | assert something and (something_else or something_third) +18 | assert not something and something_else + | + = help: Break down assertion into multiple parts + +ℹ Suggested fix +13 13 | def test_error(): +14 14 | assert something and something_else +15 15 | assert something and something_else and something_third +16 |- assert something and not something_else + 16 |+ assert something + 17 |+ assert not something_else +17 18 | assert something and (something_else or something_third) +18 19 | assert not something and something_else +19 20 | assert not (something or something_else) + +PT018.py:17:5: PT018 [*] Assertion should be broken down into multiple parts + | +15 | assert something and something_else and something_third +16 | assert something and not something_else +17 | assert something and (something_else or something_third) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 +18 | assert not something and something_else +19 | assert not (something or something_else) + | + = help: Break down assertion into multiple parts + +ℹ Suggested fix +14 14 | assert something and something_else +15 15 | assert something and something_else and something_third +16 16 | assert something and not something_else +17 |- assert something and (something_else or something_third) + 17 |+ assert something + 18 |+ assert (something_else or something_third) +18 19 | assert not something and something_else +19 20 | assert not (something or something_else) +20 21 | assert not (something or something_else or something_third) + +PT018.py:18:5: PT018 [*] Assertion should be broken down into multiple parts + | +16 | assert something and not something_else +17 | assert something and (something_else or something_third) +18 | assert not something and something_else + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 +19 | assert not (something or something_else) +20 | assert not (something or something_else or something_third) + | + = help: Break down assertion into multiple parts + +ℹ Suggested fix +15 15 | assert something and something_else and something_third +16 16 | assert something and not something_else +17 17 | assert something and (something_else or something_third) +18 |- assert not something and something_else + 18 |+ assert not something + 19 |+ assert something_else +19 20 | assert not (something or something_else) +20 21 | assert not (something or something_else or something_third) +21 22 | assert something and something_else == """error + +PT018.py:19:5: PT018 [*] Assertion should be broken down into multiple parts + | +17 | assert something and (something_else or something_third) +18 | assert not something and something_else +19 | assert not (something or something_else) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 +20 | assert not (something or something_else or something_third) +21 | assert something and something_else == """error + | + = help: Break down assertion into multiple parts + +ℹ Suggested fix +16 16 | assert something and not something_else +17 17 | assert something and (something_else or something_third) +18 18 | assert not something and something_else +19 |- assert not (something or something_else) + 19 |+ assert not something + 20 |+ assert not something_else +20 21 | assert not (something or something_else or something_third) +21 22 | assert something and something_else == """error +22 23 | message + +PT018.py:20:5: PT018 [*] Assertion should be broken down into multiple parts + | +18 | assert not something and something_else +19 | assert not (something or something_else) +20 | assert not (something or something_else or something_third) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 +21 | assert something and something_else == """error +22 | message + | + = help: Break down assertion into multiple parts + +ℹ Suggested fix +17 17 | assert something and (something_else or something_third) +18 18 | assert not something and something_else +19 19 | assert not (something or something_else) +20 |- assert not (something or something_else or something_third) + 20 |+ assert not (something or something_else) + 21 |+ assert not something_third +21 22 | assert something and something_else == """error +22 23 | message +23 24 | """ + +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 + | _____^ +22 | | message +23 | | """ + | |_______^ PT018 +24 | assert ( +25 | something + | + = help: Break down assertion into multiple parts + +ℹ Suggested fix +18 18 | assert not something and something_else +19 19 | assert not (something or something_else) +20 20 | assert not (something or something_else or something_third) +21 |- assert something and something_else == """error + 21 |+ assert something + 22 |+ assert something_else == """error +22 23 | message +23 24 | """ +24 25 | assert ( + +PT018.py:24:5: PT018 [*] Assertion should be broken down into multiple parts + | +22 | message +23 | """ +24 | assert ( + | _____^ +25 | | something +26 | | and something_else +27 | | == """error +28 | | message +29 | | """ +30 | | ) + | |_____^ PT018 +31 | +32 | # recursive case + | + = help: Break down assertion into multiple parts + +ℹ Suggested fix +21 21 | assert something and something_else == """error +22 22 | message +23 23 | """ + 24 |+ assert something +24 25 | assert ( +25 |- something +26 |- and something_else + 26 |+ something_else +27 27 | == """error +28 28 | message +29 29 | """ + +PT018.py:33:5: PT018 [*] Assertion should be broken down into multiple parts + | +32 | # recursive case +33 | assert not (a or not (b or c)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 +34 | assert not (a or not (b and c)) + | + = help: Break down assertion into multiple parts + +ℹ Suggested fix +30 30 | ) +31 31 | +32 32 | # recursive case +33 |- assert not (a or not (b or c)) + 33 |+ assert not a + 34 |+ assert (b or c) +34 35 | assert not (a or not (b and c)) +35 36 | +36 37 | # detected, but no autofix for messages + +PT018.py:34:5: PT018 [*] Assertion should be broken down into multiple parts + | +32 | # recursive case +33 | assert not (a or not (b or c)) +34 | assert not (a or not (b and c)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 +35 | +36 | # detected, but no autofix for messages + | + = help: Break down assertion into multiple parts + +ℹ Suggested fix +31 31 | +32 32 | # recursive case +33 33 | assert not (a or not (b or c)) +34 |- assert not (a or not (b and c)) + 34 |+ assert not a + 35 |+ assert (b and c) +35 36 | +36 37 | # detected, but no autofix for messages +37 38 | assert something and something_else, "error message" + +PT018.py:37:5: PT018 Assertion should be broken down into multiple parts + | +36 | # detected, but no autofix for messages +37 | assert something and something_else, "error message" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 +38 | assert not (something or something_else and something_third), "with message" +39 | # detected, but no autofix for mixed conditions (e.g. `a or b and c`) + | + = help: Break down assertion into multiple parts + +PT018.py:38:5: PT018 Assertion should be broken down into multiple parts + | +36 | # detected, but no autofix for messages +37 | assert something and something_else, "error message" +38 | assert not (something or something_else and something_third), "with message" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 +39 | # detected, but no autofix for mixed conditions (e.g. `a or b and c`) +40 | assert not (something or something_else and something_third) + | + = help: Break down assertion into multiple parts + +PT018.py:40:5: PT018 Assertion should be broken down into multiple parts + | +38 | assert not (something or something_else and something_third), "with message" +39 | # detected, but no autofix for mixed conditions (e.g. `a or b and c`) +40 | assert not (something or something_else and something_third) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | + = help: Break down assertion into multiple parts + +PT018.py:44:1: PT018 [*] Assertion should be broken down into multiple parts + | +43 | assert something # OK +44 | assert something and something_else # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 +45 | assert something and something_else and something_third # Error + | + = help: Break down assertion into multiple parts + +ℹ Suggested fix +41 41 | +42 42 | +43 43 | assert something # OK +44 |-assert something and something_else # Error + 44 |+assert something + 45 |+assert something_else +45 46 | assert something and something_else and something_third # Error +46 47 | +47 48 | + +PT018.py:45:1: PT018 [*] Assertion should be broken down into multiple parts + | +43 | assert something # OK +44 | assert something and something_else # Error +45 | assert something and something_else and something_third # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | + = help: Break down assertion into multiple parts + +ℹ Suggested fix +42 42 | +43 43 | assert something # OK +44 44 | assert something and something_else # Error +45 |-assert something and something_else and something_third # Error + 45 |+assert something and something_else + 46 |+assert something_third +46 47 | +47 48 | +48 49 | def test_multiline(): + +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 | +51 | x = 1; assert something and something_else + | + = help: Break down assertion 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 | +51 | x = 1; assert something and something_else + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 +52 | +53 | x = 1; \ + | + = help: Break down assertion into multiple parts + +PT018.py:54:9: PT018 Assertion should be broken down into multiple parts + | +53 | x = 1; \ +54 | assert something and something_else + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT018 + | + = help: Break down assertion into multiple parts + +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 ( + | _____^ +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 | +65 | assert (not ( + | + = help: Break down assertion into multiple parts + +ℹ Suggested fix +59 59 | assert not ( +60 60 | self.find_graph_output(node.output[0]) +61 61 | or self.find_graph_input(node.input[0]) +62 |- or self.find_graph_output(node.input[0]) +63 62 | ) + 63 |+ assert not ( + 64 |+ self.find_graph_output(node.input[0]) + 65 |+ ) +64 66 | +65 67 | assert (not ( +66 68 | self.find_graph_output(node.output[0]) + +PT018.py:65:5: PT018 [*] Assertion should be broken down into multiple parts + | +63 | ) +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 | +71 | assert (not self.find_graph_output(node.output[0]) or + | + = help: Break down assertion into multiple parts + +ℹ Suggested fix +62 62 | or self.find_graph_output(node.input[0]) +63 63 | ) +64 64 | +65 |- assert (not ( + 65 |+ assert not ( +66 66 | self.find_graph_output(node.output[0]) +67 67 | or self.find_graph_input(node.input[0]) +68 |- or self.find_graph_output(node.input[0]) +69 |- )) + 68 |+ ) + 69 |+ assert not ( + 70 |+ self.find_graph_output(node.input[0]) + 71 |+ ) +70 72 | +71 73 | assert (not self.find_graph_output(node.output[0]) or +72 74 | self.find_graph_input(node.input[0])) + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT019.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT019.snap new file mode 100644 index 0000000000..fefca3d139 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT019.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT019.py:9:14: PT019 Fixture `_fixture` without value is injected as parameter, use `@pytest.mark.usefixtures` instead + | + 9 | def test_xxx(_fixture): # Error arg + | ^^^^^^^^ PT019 +10 | pass + | + +PT019.py:13:17: PT019 Fixture `_fixture` without value is injected as parameter, use `@pytest.mark.usefixtures` instead + | +13 | def test_xxx(*, _fixture): # Error kwonly + | ^^^^^^^^ PT019 +14 | pass + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT020.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT020.snap new file mode 100644 index 0000000000..c3c1b68e63 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT020.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT020.py:14:1: PT020 `@pytest.yield_fixture` is deprecated, use `@pytest.fixture` + | +14 | @pytest.yield_fixture() + | ^^^^^^^^^^^^^^^^^^^^^^^ PT020 +15 | def error_without_parens(): +16 | return 0 + | + +PT020.py:19:1: PT020 `@pytest.yield_fixture` is deprecated, use `@pytest.fixture` + | +19 | @pytest.yield_fixture + | ^^^^^^^^^^^^^^^^^^^^^ PT020 +20 | def error_with_parens(): +21 | return 0 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT021.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT021.snap new file mode 100644 index 0000000000..2873de7aec --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT021.snap @@ -0,0 +1,23 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT021.py:49:5: PT021 Use `yield` instead of `request.addfinalizer` + | +47 | def my_fixture(request): # Error return +48 | resource = acquire_resource() +49 | request.addfinalizer(resource.release) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT021 +50 | return resource + | + +PT021.py:56:5: PT021 Use `yield` instead of `request.addfinalizer` + | +54 | def my_fixture(request): # Error yield +55 | resource = acquire_resource() +56 | request.addfinalizer(resource.release) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT021 +57 | yield resource +58 | resource # prevent PT022 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT022.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT022.snap new file mode 100644 index 0000000000..ea497c7f5a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT022.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT022.py:17:5: PT022 [*] No teardown in fixture `error`, use `return` instead of `yield` + | +15 | def error(): +16 | resource = acquire_resource() +17 | yield resource + | ^^^^^^^^^^^^^^ PT022 + | + = help: Replace `yield` with `return` + +ℹ Fix +14 14 | @pytest.fixture() +15 15 | def error(): +16 16 | resource = acquire_resource() +17 |- yield resource + 17 |+ return resource + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_default.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_default.snap new file mode 100644 index 0000000000..f5da889e9e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_default.snap @@ -0,0 +1,103 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT023.py:12:1: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` + | +12 | @pytest.mark.foo + | ^^^^^^^^^^^^^^^^ PT023 +13 | def test_something(): +14 | pass + | + = help: Add/remove parentheses + +ℹ Fix +9 9 | # Without parentheses +10 10 | +11 11 | +12 |-@pytest.mark.foo + 12 |+@pytest.mark.foo() +13 13 | def test_something(): +14 14 | pass +15 15 | + +PT023.py:17:1: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` + | +17 | @pytest.mark.foo + | ^^^^^^^^^^^^^^^^ PT023 +18 | class TestClass: +19 | def test_something(): + | + = help: Add/remove parentheses + +ℹ Fix +14 14 | pass +15 15 | +16 16 | +17 |-@pytest.mark.foo + 17 |+@pytest.mark.foo() +18 18 | class TestClass: +19 19 | def test_something(): +20 20 | pass + +PT023.py:24:5: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` + | +23 | class TestClass: +24 | @pytest.mark.foo + | ^^^^^^^^^^^^^^^^ PT023 +25 | def test_something(): +26 | pass + | + = help: Add/remove parentheses + +ℹ Fix +21 21 | +22 22 | +23 23 | class TestClass: +24 |- @pytest.mark.foo + 24 |+ @pytest.mark.foo() +25 25 | def test_something(): +26 26 | pass +27 27 | + +PT023.py:30:5: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` + | +29 | class TestClass: +30 | @pytest.mark.foo + | ^^^^^^^^^^^^^^^^ PT023 +31 | class TestNestedClass: +32 | def test_something(): + | + = help: Add/remove parentheses + +ℹ Fix +27 27 | +28 28 | +29 29 | class TestClass: +30 |- @pytest.mark.foo + 30 |+ @pytest.mark.foo() +31 31 | class TestNestedClass: +32 32 | def test_something(): +33 33 | pass + +PT023.py:38:9: PT023 [*] Use `@pytest.mark.foo()` over `@pytest.mark.foo` + | +36 | class TestClass: +37 | class TestNestedClass: +38 | @pytest.mark.foo + | ^^^^^^^^^^^^^^^^ PT023 +39 | def test_something(): +40 | pass + | + = help: Add/remove parentheses + +ℹ Fix +35 35 | +36 36 | class TestClass: +37 37 | class TestNestedClass: +38 |- @pytest.mark.foo + 38 |+ @pytest.mark.foo() +39 39 | def test_something(): +40 40 | pass +41 41 | + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_no_parentheses.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_no_parentheses.snap new file mode 100644 index 0000000000..f9715a74f8 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT023_no_parentheses.snap @@ -0,0 +1,102 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT023.py:46:1: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` + | +46 | @pytest.mark.foo() + | ^^^^^^^^^^^^^^^^^^ PT023 +47 | def test_something(): +48 | pass + | + = help: Add/remove parentheses + +ℹ Fix +43 43 | # With parentheses +44 44 | +45 45 | +46 |-@pytest.mark.foo() + 46 |+@pytest.mark.foo +47 47 | def test_something(): +48 48 | pass +49 49 | + +PT023.py:51:1: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` + | +51 | @pytest.mark.foo() + | ^^^^^^^^^^^^^^^^^^ PT023 +52 | class TestClass: +53 | def test_something(): + | + = help: Add/remove parentheses + +ℹ Fix +48 48 | pass +49 49 | +50 50 | +51 |-@pytest.mark.foo() + 51 |+@pytest.mark.foo +52 52 | class TestClass: +53 53 | def test_something(): +54 54 | pass + +PT023.py:58:5: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` + | +57 | class TestClass: +58 | @pytest.mark.foo() + | ^^^^^^^^^^^^^^^^^^ PT023 +59 | def test_something(): +60 | pass + | + = help: Add/remove parentheses + +ℹ Fix +55 55 | +56 56 | +57 57 | class TestClass: +58 |- @pytest.mark.foo() + 58 |+ @pytest.mark.foo +59 59 | def test_something(): +60 60 | pass +61 61 | + +PT023.py:64:5: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` + | +63 | class TestClass: +64 | @pytest.mark.foo() + | ^^^^^^^^^^^^^^^^^^ PT023 +65 | class TestNestedClass: +66 | def test_something(): + | + = help: Add/remove parentheses + +ℹ Fix +61 61 | +62 62 | +63 63 | class TestClass: +64 |- @pytest.mark.foo() + 64 |+ @pytest.mark.foo +65 65 | class TestNestedClass: +66 66 | def test_something(): +67 67 | pass + +PT023.py:72:9: PT023 [*] Use `@pytest.mark.foo` over `@pytest.mark.foo()` + | +70 | class TestClass: +71 | class TestNestedClass: +72 | @pytest.mark.foo() + | ^^^^^^^^^^^^^^^^^^ PT023 +73 | def test_something(): +74 | pass + | + = help: Add/remove parentheses + +ℹ Fix +69 69 | +70 70 | class TestClass: +71 71 | class TestNestedClass: +72 |- @pytest.mark.foo() + 72 |+ @pytest.mark.foo +73 73 | def test_something(): +74 74 | pass + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT024.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT024.snap new file mode 100644 index 0000000000..8a872364cd --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT024.snap @@ -0,0 +1,77 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT024.py:14:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures + | +14 | @pytest.mark.asyncio() + | ^^^^^^^^^^^^^^^^^^^^^^ PT024 +15 | @pytest.fixture() +16 | async def my_fixture(): # Error before + | + = help: Remove `pytest.mark.asyncio` + +ℹ Fix +11 11 | pass +12 12 | +13 13 | +14 |-@pytest.mark.asyncio() +15 14 | @pytest.fixture() +16 15 | async def my_fixture(): # Error before +17 16 | return 0 + +PT024.py:20:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures + | +20 | @pytest.mark.asyncio + | ^^^^^^^^^^^^^^^^^^^^ PT024 +21 | @pytest.fixture() +22 | async def my_fixture(): # Error before no parens + | + = help: Remove `pytest.mark.asyncio` + +ℹ Fix +17 17 | return 0 +18 18 | +19 19 | +20 |-@pytest.mark.asyncio +21 20 | @pytest.fixture() +22 21 | async def my_fixture(): # Error before no parens +23 22 | return 0 + +PT024.py:27:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures + | +26 | @pytest.fixture() +27 | @pytest.mark.asyncio() + | ^^^^^^^^^^^^^^^^^^^^^^ PT024 +28 | async def my_fixture(): # Error after +29 | return 0 + | + = help: Remove `pytest.mark.asyncio` + +ℹ Fix +24 24 | +25 25 | +26 26 | @pytest.fixture() +27 |-@pytest.mark.asyncio() +28 27 | async def my_fixture(): # Error after +29 28 | return 0 +30 29 | + +PT024.py:33:1: PT024 [*] `pytest.mark.asyncio` is unnecessary for fixtures + | +32 | @pytest.fixture() +33 | @pytest.mark.asyncio + | ^^^^^^^^^^^^^^^^^^^^ PT024 +34 | async def my_fixture(): # Error after no parens +35 | return 0 + | + = help: Remove `pytest.mark.asyncio` + +ℹ Fix +30 30 | +31 31 | +32 32 | @pytest.fixture() +33 |-@pytest.mark.asyncio +34 33 | async def my_fixture(): # Error after no parens +35 34 | return 0 + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT025.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT025.snap new file mode 100644 index 0000000000..5d4297f9c8 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT025.snap @@ -0,0 +1,40 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT025.py:9:1: PT025 [*] `pytest.mark.usefixtures` has no effect on fixtures + | + 9 | @pytest.mark.usefixtures("a") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT025 +10 | @pytest.fixture() +11 | def my_fixture(): # Error before + | + = help: Remove `pytest.mark.usefixtures` + +ℹ Fix +6 6 | pass +7 7 | +8 8 | +9 |-@pytest.mark.usefixtures("a") +10 9 | @pytest.fixture() +11 10 | def my_fixture(): # Error before +12 11 | return 0 + +PT025.py:16:1: PT025 [*] `pytest.mark.usefixtures` has no effect on fixtures + | +15 | @pytest.fixture() +16 | @pytest.mark.usefixtures("a") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PT025 +17 | def my_fixture(): # Error after +18 | return 0 + | + = help: Remove `pytest.mark.usefixtures` + +ℹ Fix +13 13 | +14 14 | +15 15 | @pytest.fixture() +16 |-@pytest.mark.usefixtures("a") +17 16 | def my_fixture(): # Error after +18 17 | return 0 + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT026.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT026.snap new file mode 100644 index 0000000000..4bf726cece --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT026.snap @@ -0,0 +1,41 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT026.py:19:1: PT026 [*] Useless `pytest.mark.usefixtures` without parameters + | +19 | @pytest.mark.usefixtures() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PT026 +20 | def test_error_with_parens(): +21 | pass + | + = help: Remove `usefixtures` decorator or pass parameters + +ℹ Suggested fix +16 16 | pass +17 17 | +18 18 | +19 |-@pytest.mark.usefixtures() + 19 |+ +20 20 | def test_error_with_parens(): +21 21 | pass +22 22 | + +PT026.py:24:1: PT026 [*] Useless `pytest.mark.usefixtures` without parameters + | +24 | @pytest.mark.usefixtures + | ^^^^^^^^^^^^^^^^^^^^^^^^ PT026 +25 | def test_error_no_parens(): +26 | pass + | + = help: Remove `usefixtures` decorator or pass parameters + +ℹ Suggested fix +21 21 | pass +22 22 | +23 23 | +24 |-@pytest.mark.usefixtures + 24 |+ +25 25 | def test_error_no_parens(): +26 26 | pass + + 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 new file mode 100644 index 0000000000..dd48d60163 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_0.snap @@ -0,0 +1,248 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT027_0.py:6:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` + | +4 | class Test(unittest.TestCase): +5 | def test_errors(self): +6 | with self.assertRaises(ValueError): + | ^^^^^^^^^^^^^^^^^ PT027 +7 | raise ValueError +8 | with self.assertRaises(expected_exception=ValueError): + | + = help: Replace `assertRaises` with `pytest.raises` + +ℹ Suggested fix +1 1 | import unittest + 2 |+import pytest +2 3 | +3 4 | +4 5 | class Test(unittest.TestCase): +5 6 | def test_errors(self): +6 |- with self.assertRaises(ValueError): + 7 |+ with pytest.raises(ValueError): +7 8 | raise ValueError +8 9 | with self.assertRaises(expected_exception=ValueError): +9 10 | raise ValueError + +PT027_0.py:8:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` + | +6 | with self.assertRaises(ValueError): +7 | raise ValueError +8 | with self.assertRaises(expected_exception=ValueError): + | ^^^^^^^^^^^^^^^^^ PT027 +9 | raise ValueError + | + = help: Replace `assertRaises` with `pytest.raises` + +ℹ Suggested fix +1 1 | import unittest + 2 |+import pytest +2 3 | +3 4 | +4 5 | class Test(unittest.TestCase): +5 6 | def test_errors(self): +6 7 | with self.assertRaises(ValueError): +7 8 | raise ValueError +8 |- with self.assertRaises(expected_exception=ValueError): + 9 |+ with pytest.raises(ValueError): +9 10 | raise ValueError +10 11 | +11 12 | with self.failUnlessRaises(ValueError): + +PT027_0.py:11:14: PT027 [*] Use `pytest.raises` instead of unittest-style `failUnlessRaises` + | + 9 | raise ValueError +10 | +11 | with self.failUnlessRaises(ValueError): + | ^^^^^^^^^^^^^^^^^^^^^ PT027 +12 | raise ValueError + | + = help: Replace `failUnlessRaises` with `pytest.raises` + +ℹ Suggested fix +1 1 | import unittest + 2 |+import pytest +2 3 | +3 4 | +4 5 | class Test(unittest.TestCase): +-------------------------------------------------------------------------------- +8 9 | with self.assertRaises(expected_exception=ValueError): +9 10 | raise ValueError +10 11 | +11 |- with self.failUnlessRaises(ValueError): + 12 |+ with pytest.raises(ValueError): +12 13 | raise ValueError +13 14 | +14 15 | with self.assertRaisesRegex(ValueError, "test"): + +PT027_0.py:14:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` + | +12 | raise ValueError +13 | +14 | with self.assertRaisesRegex(ValueError, "test"): + | ^^^^^^^^^^^^^^^^^^^^^^ PT027 +15 | raise ValueError("test") + | + = help: Replace `assertRaisesRegex` with `pytest.raises` + +ℹ Suggested fix +1 1 | import unittest + 2 |+import pytest +2 3 | +3 4 | +4 5 | class Test(unittest.TestCase): +-------------------------------------------------------------------------------- +11 12 | with self.failUnlessRaises(ValueError): +12 13 | raise ValueError +13 14 | +14 |- with self.assertRaisesRegex(ValueError, "test"): + 15 |+ with pytest.raises(ValueError, match="test"): +15 16 | raise ValueError("test") +16 17 | +17 18 | with self.assertRaisesRegex(ValueError, expected_regex="test"): + +PT027_0.py:17:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` + | +15 | raise ValueError("test") +16 | +17 | with self.assertRaisesRegex(ValueError, expected_regex="test"): + | ^^^^^^^^^^^^^^^^^^^^^^ PT027 +18 | raise ValueError("test") + | + = help: Replace `assertRaisesRegex` with `pytest.raises` + +ℹ Suggested fix +1 1 | import unittest + 2 |+import pytest +2 3 | +3 4 | +4 5 | class Test(unittest.TestCase): +-------------------------------------------------------------------------------- +14 15 | with self.assertRaisesRegex(ValueError, "test"): +15 16 | raise ValueError("test") +16 17 | +17 |- with self.assertRaisesRegex(ValueError, expected_regex="test"): + 18 |+ with pytest.raises(ValueError, match="test"): +18 19 | raise ValueError("test") +19 20 | +20 21 | with self.assertRaisesRegex( + +PT027_0.py:20:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` + | +18 | raise ValueError("test") +19 | +20 | with self.assertRaisesRegex( + | ^^^^^^^^^^^^^^^^^^^^^^ PT027 +21 | expected_exception=ValueError, expected_regex="test" +22 | ): + | + = help: Replace `assertRaisesRegex` with `pytest.raises` + +ℹ Suggested fix +1 1 | import unittest + 2 |+import pytest +2 3 | +3 4 | +4 5 | class Test(unittest.TestCase): +-------------------------------------------------------------------------------- +17 18 | with self.assertRaisesRegex(ValueError, expected_regex="test"): +18 19 | raise ValueError("test") +19 20 | +20 |- with self.assertRaisesRegex( +21 |- expected_exception=ValueError, expected_regex="test" +22 |- ): + 21 |+ with pytest.raises(ValueError, match="test"): +23 22 | raise ValueError("test") +24 23 | +25 24 | with self.assertRaisesRegex( + +PT027_0.py:25:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegex` + | +23 | raise ValueError("test") +24 | +25 | with self.assertRaisesRegex( + | ^^^^^^^^^^^^^^^^^^^^^^ PT027 +26 | expected_regex="test", expected_exception=ValueError +27 | ): + | + = help: Replace `assertRaisesRegex` with `pytest.raises` + +ℹ Suggested fix +1 1 | import unittest + 2 |+import pytest +2 3 | +3 4 | +4 5 | class Test(unittest.TestCase): +-------------------------------------------------------------------------------- +22 23 | ): +23 24 | raise ValueError("test") +24 25 | +25 |- with self.assertRaisesRegex( +26 |- expected_regex="test", expected_exception=ValueError +27 |- ): + 26 |+ with pytest.raises(ValueError, match="test"): +28 27 | raise ValueError("test") +29 28 | +30 29 | with self.assertRaisesRegexp(ValueError, "test"): + +PT027_0.py:30:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaisesRegexp` + | +28 | raise ValueError("test") +29 | +30 | with self.assertRaisesRegexp(ValueError, "test"): + | ^^^^^^^^^^^^^^^^^^^^^^^ PT027 +31 | raise ValueError("test") + | + = help: Replace `assertRaisesRegexp` with `pytest.raises` + +ℹ Suggested fix +1 1 | import unittest + 2 |+import pytest +2 3 | +3 4 | +4 5 | class Test(unittest.TestCase): +-------------------------------------------------------------------------------- +27 28 | ): +28 29 | raise ValueError("test") +29 30 | +30 |- with self.assertRaisesRegexp(ValueError, "test"): + 31 |+ with pytest.raises(ValueError, match="test"): +31 32 | raise ValueError("test") +32 33 | +33 34 | def test_unfixable_errors(self): + +PT027_0.py:34:14: PT027 Use `pytest.raises` instead of unittest-style `assertRaises` + | +33 | def test_unfixable_errors(self): +34 | with self.assertRaises(ValueError, msg="msg"): + | ^^^^^^^^^^^^^^^^^ PT027 +35 | raise ValueError + | + = help: Replace `assertRaises` with `pytest.raises` + +PT027_0.py:37:14: PT027 Use `pytest.raises` instead of unittest-style `assertRaises` + | +35 | raise ValueError +36 | +37 | with self.assertRaises( + | ^^^^^^^^^^^^^^^^^ PT027 +38 | # comment +39 | ValueError + | + = help: Replace `assertRaises` with `pytest.raises` + +PT027_0.py:44:13: PT027 Use `pytest.raises` instead of unittest-style `assertRaises` + | +43 | with ( +44 | self + | _____________^ +45 | | # comment +46 | | .assertRaises(ValueError) + | |_________________________^ PT027 +47 | ): +48 | raise ValueError + | + = help: Replace `assertRaises` with `pytest.raises` + + diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_1.snap b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_1.snap new file mode 100644 index 0000000000..3886db7a54 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/snapshots/ruff_linter__rules__flake8_pytest_style__tests__PT027_1.snap @@ -0,0 +1,21 @@ +--- +source: crates/ruff_linter/src/rules/flake8_pytest_style/mod.rs +--- +PT027_1.py:11:14: PT027 [*] Use `pytest.raises` instead of unittest-style `assertRaises` + | +10 | def test_errors(self): +11 | with self.assertRaises(ValueError): + | ^^^^^^^^^^^^^^^^^ PT027 +12 | raise ValueError + | + = help: Replace `assertRaises` with `pytest.raises` + +ℹ Suggested fix +8 8 | raise ValueError +9 9 | +10 10 | def test_errors(self): +11 |- with self.assertRaises(ValueError): + 11 |+ with pytest.raises(ValueError): +12 12 | raise ValueError + + diff --git a/crates/ruff/src/rules/flake8_pytest_style/types.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/types.rs similarity index 100% rename from crates/ruff/src/rules/flake8_pytest_style/types.rs rename to crates/ruff_linter/src/rules/flake8_pytest_style/types.rs diff --git a/crates/ruff/src/rules/flake8_quotes/mod.rs b/crates/ruff_linter/src/rules/flake8_quotes/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_quotes/mod.rs rename to crates/ruff_linter/src/rules/flake8_quotes/mod.rs diff --git a/crates/ruff/src/rules/flake8_quotes/rules/from_tokens.rs b/crates/ruff_linter/src/rules/flake8_quotes/rules/from_tokens.rs similarity index 100% rename from crates/ruff/src/rules/flake8_quotes/rules/from_tokens.rs rename to crates/ruff_linter/src/rules/flake8_quotes/rules/from_tokens.rs diff --git a/crates/ruff/src/rules/flake8_quotes/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_quotes/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_quotes/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_quotes/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_quotes/settings.rs b/crates/ruff_linter/src/rules/flake8_quotes/settings.rs similarity index 100% rename from crates/ruff/src/rules/flake8_quotes/settings.rs rename to crates/ruff_linter/src/rules/flake8_quotes/settings.rs 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 new file mode 100644 index 0000000000..60e045893e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles.py.snap @@ -0,0 +1,131 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +docstring_doubles.py:5:1: Q001 [*] Double quote multiline found but single quotes preferred + | +3 | """ +4 | +5 | / """ +6 | | this is not a docstring +7 | | """ + | |___^ Q001 +8 | +9 | l = [] + | + = help: Replace double multiline quotes with single quotes + +ℹ Fix +2 2 | Double quotes multiline module docstring +3 3 | """ +4 4 | +5 |-""" + 5 |+''' +6 6 | this is not a docstring +7 |-""" + 7 |+''' +8 8 | +9 9 | l = [] +10 10 | + +docstring_doubles.py:16:5: Q001 [*] Double quote multiline found but single quotes preferred + | +14 | """ +15 | +16 | """ + | _____^ +17 | | this is not a docstring +18 | | """ + | |_______^ Q001 +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 + +ℹ Fix +13 13 | Double quotes multiline class docstring +14 14 | """ +15 15 | +16 |- """ + 16 |+ ''' +17 17 | this is not a docstring +18 |- """ + 18 |+ ''' +19 19 | +20 20 | # The colon in the list indexing below is an edge case for the docstring scanner +21 21 | def f(self, bar=""" + +docstring_doubles.py:21:21: Q001 [*] Double quote multiline found but single quotes preferred + | +20 | # The colon in the list indexing below is an edge case for the docstring scanner +21 | def f(self, bar=""" + | _____________________^ +22 | | definitely not a docstring""", + | |_____________________________________^ Q001 +23 | val=l[Cls():3]): +24 | """ + | + = help: Replace double multiline quotes with single quotes + +ℹ Fix +18 18 | """ +19 19 | +20 20 | # The colon in the list indexing below is an edge case for the docstring scanner +21 |- def f(self, bar=""" +22 |- definitely not a docstring""", + 21 |+ def f(self, bar=''' + 22 |+ definitely not a docstring''', +23 23 | val=l[Cls():3]): +24 24 | """ +25 25 | Double quotes multiline function docstring + +docstring_doubles.py:30:9: Q001 [*] Double quote multiline found but single quotes preferred + | +28 | some_expression = 'hello world' +29 | +30 | """ + | _________^ +31 | | this is not a docstring +32 | | """ + | |___________^ Q001 +33 | +34 | if l: + | + = help: Replace double multiline quotes with single quotes + +ℹ Fix +27 27 | +28 28 | some_expression = 'hello world' +29 29 | +30 |- """ + 30 |+ ''' +31 31 | this is not a docstring +32 |- """ + 32 |+ ''' +33 33 | +34 34 | if l: +35 35 | """ + +docstring_doubles.py:35:13: Q001 [*] Double quote multiline found but single quotes preferred + | +34 | if l: +35 | """ + | _____________^ +36 | | Looks like a docstring, but in reality it isn't - only modules, classes and functions +37 | | """ + | |_______________^ Q001 +38 | pass + | + = help: Replace double multiline quotes with single quotes + +ℹ Fix +32 32 | """ +33 33 | +34 34 | if l: +35 |- """ + 35 |+ ''' +36 36 | Looks like a docstring, but in reality it isn't - only modules, classes and functions +37 |- """ + 37 |+ ''' +38 38 | pass + + 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 new file mode 100644 index 0000000000..07da9b1275 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_class.py.snap @@ -0,0 +1,45 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +docstring_doubles_class.py:3:5: Q001 [*] Double quote multiline found but single quotes preferred + | +1 | class SingleLineDocstrings(): +2 | """ Double quotes single line class docstring """ +3 | """ Not a docstring """ + | ^^^^^^^^^^^^^^^^^^^^^^^ Q001 +4 | +5 | def foo(self, bar="""not a docstring"""): + | + = help: Replace double multiline quotes with single quotes + +ℹ Fix +1 1 | class SingleLineDocstrings(): +2 2 | """ Double quotes single line class docstring """ +3 |- """ Not a docstring """ + 3 |+ ''' Not a docstring ''' +4 4 | +5 5 | def foo(self, bar="""not a docstring"""): +6 6 | """ Double quotes single line method docstring""" + +docstring_doubles_class.py:5:23: Q001 [*] Double quote multiline found but single quotes preferred + | +3 | """ Not a docstring """ +4 | +5 | def foo(self, bar="""not a docstring"""): + | ^^^^^^^^^^^^^^^^^^^^^ Q001 +6 | """ Double quotes single line method docstring""" +7 | pass + | + = help: Replace double multiline quotes with single quotes + +ℹ Fix +2 2 | """ Double quotes single line class docstring """ +3 3 | """ Not a docstring """ +4 4 | +5 |- def foo(self, bar="""not a docstring"""): + 5 |+ def foo(self, bar='''not a docstring'''): +6 6 | """ Double quotes single line method docstring""" +7 7 | pass +8 8 | + + diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_function.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_function.py.snap new file mode 100644 index 0000000000..7fc768037e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_function.py.snap @@ -0,0 +1,106 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +docstring_doubles_function.py:3:5: Q001 [*] Double quote multiline found but single quotes preferred + | +1 | def foo(): +2 | """function without params, single line docstring""" +3 | """ not a docstring""" + | ^^^^^^^^^^^^^^^^^^^^^^ Q001 +4 | return + | + = help: Replace double multiline quotes with single quotes + +ℹ Fix +1 1 | def foo(): +2 2 | """function without params, single line docstring""" +3 |- """ not a docstring""" + 3 |+ ''' not a docstring''' +4 4 | return +5 5 | +6 6 | + +docstring_doubles_function.py:11:5: Q001 [*] Double quote multiline found but single quotes preferred + | + 9 | function without params, multiline docstring +10 | """ +11 | """ not a docstring""" + | ^^^^^^^^^^^^^^^^^^^^^^ Q001 +12 | return + | + = help: Replace double multiline quotes with single quotes + +ℹ Fix +8 8 | """ +9 9 | function without params, multiline docstring +10 10 | """ +11 |- """ not a docstring""" + 11 |+ ''' not a docstring''' +12 12 | return +13 13 | +14 14 | + +docstring_doubles_function.py:15:39: Q001 [*] Double quote multiline found but single quotes preferred + | +15 | def fun_with_params_no_docstring(a, b=""" + | _______________________________________^ +16 | | not a +17 | | """ """docstring"""): + | |___^ Q001 +18 | pass + | + = help: Replace double multiline quotes with single quotes + +ℹ Fix +12 12 | return +13 13 | +14 14 | +15 |-def fun_with_params_no_docstring(a, b=""" + 15 |+def fun_with_params_no_docstring(a, b=''' +16 16 | not a +17 |-""" """docstring"""): + 17 |+''' """docstring"""): +18 18 | pass +19 19 | +20 20 | + +docstring_doubles_function.py:17:5: Q001 [*] Double quote multiline found but single quotes preferred + | +15 | def fun_with_params_no_docstring(a, b=""" +16 | not a +17 | """ """docstring"""): + | ^^^^^^^^^^^^^^^ Q001 +18 | pass + | + = help: Replace double multiline quotes with single quotes + +ℹ Fix +14 14 | +15 15 | def fun_with_params_no_docstring(a, b=""" +16 16 | not a +17 |-""" """docstring"""): + 17 |+""" '''docstring'''): +18 18 | pass +19 19 | +20 20 | + +docstring_doubles_function.py:22:5: Q001 [*] Double quote multiline found but single quotes preferred + | +21 | def fun_with_params_no_docstring2(a, b=c[foo():], c=\ +22 | """ not a docstring """): + | ^^^^^^^^^^^^^^^^^^^^^^^ Q001 +23 | pass + | + = help: Replace double multiline quotes with single quotes + +ℹ Fix +19 19 | +20 20 | +21 21 | def fun_with_params_no_docstring2(a, b=c[foo():], c=\ +22 |- """ not a docstring """): + 22 |+ ''' not a docstring '''): +23 23 | pass +24 24 | +25 25 | + + diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_multiline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_multiline.py.snap new file mode 100644 index 0000000000..5d69c266af --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_doubles_module_multiline.py.snap @@ -0,0 +1,51 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +docstring_doubles_module_multiline.py:4:1: Q001 [*] Double quote multiline found but single quotes preferred + | +2 | Double quotes multiline module docstring +3 | """ +4 | / """ +5 | | this is not a docstring +6 | | """ + | |___^ Q001 +7 | def foo(): +8 | pass + | + = help: Replace double multiline quotes with single quotes + +ℹ Fix +1 1 | """ +2 2 | Double quotes multiline module docstring +3 3 | """ +4 |-""" + 4 |+''' +5 5 | this is not a docstring +6 |-""" + 6 |+''' +7 7 | def foo(): +8 8 | pass +9 9 | """ + +docstring_doubles_module_multiline.py:9:1: Q001 [*] Double quote multiline found but single quotes preferred + | + 7 | def foo(): + 8 | pass + 9 | / """ +10 | | this is not a docstring +11 | | """ + | |___^ Q001 + | + = help: Replace double multiline quotes with single quotes + +ℹ Fix +6 6 | """ +7 7 | def foo(): +8 8 | pass +9 |-""" + 9 |+''' +10 10 | this is not a docstring +11 |-""" + 11 |+''' + + 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 new file mode 100644 index 0000000000..5a80dfc1bc --- /dev/null +++ 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 @@ -0,0 +1,38 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +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 | +4 | def foo(): + | + = help: Replace double multiline quotes with single quotes + +ℹ Fix +1 1 | """ Double quotes singleline module docstring """ +2 |-""" this is not a docstring """ + 2 |+''' this is not a docstring ''' +3 3 | +4 4 | def foo(): +5 5 | pass + +docstring_doubles_module_singleline.py:6:1: Q001 [*] Double quote multiline found but single quotes preferred + | +4 | def foo(): +5 | pass +6 | """ this is not a docstring """ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q001 + | + = help: Replace double multiline quotes with single quotes + +ℹ Fix +3 3 | +4 4 | def foo(): +5 5 | pass +6 |-""" this is not a docstring """ + 6 |+''' this is not a docstring ''' + + 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 new file mode 100644 index 0000000000..6d0eeeb2e5 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles.py.snap @@ -0,0 +1,79 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +docstring_singles.py:1:1: Q002 [*] Single quote docstring found but double quotes preferred + | +1 | / ''' +2 | | Single quotes multiline module docstring +3 | | ''' + | |___^ Q002 +4 | +5 | ''' + | + = help: Replace single quotes docstring with double quotes + +ℹ Fix +1 |-''' + 1 |+""" +2 2 | Single quotes multiline module docstring +3 |-''' + 3 |+""" +4 4 | +5 5 | ''' +6 6 | this is not a docstring + +docstring_singles.py:14:5: Q002 [*] Single quote docstring found but double quotes preferred + | +12 | class params \t not a docstring +13 | ''')): +14 | ''' + | _____^ +15 | | Single quotes multiline class docstring +16 | | ''' + | |_______^ Q002 +17 | +18 | ''' + | + = help: Replace single quotes docstring with double quotes + +ℹ Fix +11 11 | class Cls(MakeKlass(''' +12 12 | class params \t not a docstring +13 13 | ''')): +14 |- ''' + 14 |+ """ +15 15 | Single quotes multiline class docstring +16 |- ''' + 16 |+ """ +17 17 | +18 18 | ''' +19 19 | this is not a docstring + +docstring_singles.py:26:9: Q002 [*] Single quote docstring found but double quotes preferred + | +24 | definitely not a docstring''', +25 | val=l[Cls():3]): +26 | ''' + | _________^ +27 | | Single quotes multiline function docstring +28 | | ''' + | |___________^ Q002 +29 | +30 | some_expression = 'hello world' + | + = help: Replace single quotes docstring with double quotes + +ℹ Fix +23 23 | def f(self, bar=''' +24 24 | definitely not a docstring''', +25 25 | val=l[Cls():3]): +26 |- ''' + 26 |+ """ +27 27 | Single quotes multiline function docstring +28 |- ''' + 28 |+ """ +29 29 | +30 30 | some_expression = 'hello world' +31 31 | + + 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 new file mode 100644 index 0000000000..45ee206e4d --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_class.py.snap @@ -0,0 +1,56 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +docstring_singles_class.py:2:5: Q002 [*] Single quote docstring found but double quotes preferred + | +1 | class SingleLineDocstrings(): +2 | ''' Double quotes single line class docstring ''' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 +3 | ''' Not a docstring ''' + | + = help: Replace single quotes docstring with double quotes + +ℹ Fix +1 1 | class SingleLineDocstrings(): +2 |- ''' Double quotes single line class docstring ''' + 2 |+ """ Double quotes single line class docstring """ +3 3 | ''' Not a docstring ''' +4 4 | +5 5 | def foo(self, bar='''not a docstring'''): + +docstring_singles_class.py:6:9: Q002 [*] Single quote docstring found but double quotes preferred + | +5 | def foo(self, bar='''not a docstring'''): +6 | ''' Double quotes single line method docstring''' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 +7 | pass + | + = help: Replace single quotes docstring with double quotes + +ℹ Fix +3 3 | ''' Not a docstring ''' +4 4 | +5 5 | def foo(self, bar='''not a docstring'''): +6 |- ''' Double quotes single line method docstring''' + 6 |+ """ Double quotes single line method docstring""" +7 7 | pass +8 8 | +9 9 | class Nested(foo()[:]): ''' inline docstring '''; pass + +docstring_singles_class.py:9:29: Q002 [*] Single quote docstring found but double quotes preferred + | +7 | pass +8 | +9 | class Nested(foo()[:]): ''' inline docstring '''; pass + | ^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | + = help: Replace single quotes docstring with double quotes + +ℹ Fix +6 6 | ''' Double quotes single line method docstring''' +7 7 | pass +8 8 | +9 |- class Nested(foo()[:]): ''' inline docstring '''; pass + 9 |+ class Nested(foo()[:]): """ inline docstring """; pass + + 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 new file mode 100644 index 0000000000..7ea3ad52f3 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_function.py.snap @@ -0,0 +1,66 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +docstring_singles_function.py:2:5: Q002 [*] Single quote docstring found but double quotes preferred + | +1 | def foo(): +2 | '''function without params, single line docstring''' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 +3 | ''' not a docstring''' +4 | return + | + = help: Replace single quotes docstring with double quotes + +ℹ Fix +1 1 | def foo(): +2 |- '''function without params, single line docstring''' + 2 |+ """function without params, single line docstring""" +3 3 | ''' not a docstring''' +4 4 | return +5 5 | + +docstring_singles_function.py:8:5: Q002 [*] Single quote docstring found but double quotes preferred + | + 7 | def foo2(): + 8 | ''' + | _____^ + 9 | | function without params, multiline docstring +10 | | ''' + | |_______^ Q002 +11 | ''' not a docstring''' +12 | return + | + = help: Replace single quotes docstring with double quotes + +ℹ Fix +5 5 | +6 6 | +7 7 | def foo2(): +8 |- ''' + 8 |+ """ +9 9 | function without params, multiline docstring +10 |- ''' + 10 |+ """ +11 11 | ''' not a docstring''' +12 12 | return +13 13 | + +docstring_singles_function.py:27:5: Q002 [*] Single quote docstring found but double quotes preferred + | +26 | def function_with_single_docstring(a): +27 | 'Single line docstring' + | ^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | + = help: Replace single quotes docstring with double quotes + +ℹ Fix +24 24 | +25 25 | +26 26 | def function_with_single_docstring(a): +27 |- 'Single line docstring' + 27 |+ "Single line docstring" +28 28 | +29 29 | +30 30 | def double_inside_single(a): + + diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_multiline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_multiline.py.snap new file mode 100644 index 0000000000..72e2913867 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_multiline.py.snap @@ -0,0 +1,25 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +docstring_singles_module_multiline.py:1:1: Q002 [*] Single quote docstring found but double quotes preferred + | +1 | / ''' +2 | | Double quotes multiline module docstring +3 | | ''' + | |___^ Q002 +4 | ''' +5 | this is not a docstring + | + = help: Replace single quotes docstring with double quotes + +ℹ Fix +1 |-''' + 1 |+""" +2 2 | Double quotes multiline module docstring +3 |-''' + 3 |+""" +4 4 | ''' +5 5 | this is not a docstring +6 6 | ''' + + diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_singleline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_singleline.py.snap new file mode 100644 index 0000000000..32eb4bc1e4 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_doubles_over_docstring_singles_module_singleline.py.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +docstring_singles_module_singleline.py:1:1: Q002 [*] Single quote docstring found but double quotes preferred + | +1 | ''' Double quotes singleline module docstring ''' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 +2 | ''' this is not a docstring ''' + | + = help: Replace single quotes docstring with double quotes + +ℹ Fix +1 |-''' Double quotes singleline module docstring ''' + 1 |+""" Double quotes singleline module docstring """ +2 2 | ''' this is not a docstring ''' +3 3 | +4 4 | def foo(): + + 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 new file mode 100644 index 0000000000..a81aba31aa --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles.py.snap @@ -0,0 +1,78 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +docstring_doubles.py:1:1: Q002 [*] Double quote docstring found but single quotes preferred + | +1 | / """ +2 | | Double quotes multiline module docstring +3 | | """ + | |___^ Q002 +4 | +5 | """ + | + = help: Replace double quotes docstring with single quotes + +ℹ Fix +1 |-""" + 1 |+''' +2 2 | Double quotes multiline module docstring +3 |-""" + 3 |+''' +4 4 | +5 5 | """ +6 6 | this is not a docstring + +docstring_doubles.py:12:5: Q002 [*] Double quote docstring found but single quotes preferred + | +11 | class Cls: +12 | """ + | _____^ +13 | | Double quotes multiline class docstring +14 | | """ + | |_______^ Q002 +15 | +16 | """ + | + = help: Replace double quotes docstring with single quotes + +ℹ Fix +9 9 | l = [] +10 10 | +11 11 | class Cls: +12 |- """ + 12 |+ ''' +13 13 | Double quotes multiline class docstring +14 |- """ + 14 |+ ''' +15 15 | +16 16 | """ +17 17 | this is not a docstring + +docstring_doubles.py:24:9: Q002 [*] Double quote docstring found but single quotes preferred + | +22 | definitely not a docstring""", +23 | val=l[Cls():3]): +24 | """ + | _________^ +25 | | Double quotes multiline function docstring +26 | | """ + | |___________^ Q002 +27 | +28 | some_expression = 'hello world' + | + = help: Replace double quotes docstring with single quotes + +ℹ Fix +21 21 | def f(self, bar=""" +22 22 | definitely not a docstring""", +23 23 | val=l[Cls():3]): +24 |- """ + 24 |+ ''' +25 25 | Double quotes multiline function docstring +26 |- """ + 26 |+ ''' +27 27 | +28 28 | some_expression = 'hello world' +29 29 | + + 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 new file mode 100644 index 0000000000..8e33030efa --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_class.py.snap @@ -0,0 +1,56 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +docstring_doubles_class.py:2:5: Q002 [*] Double quote docstring found but single quotes preferred + | +1 | class SingleLineDocstrings(): +2 | """ Double quotes single line class docstring """ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 +3 | """ Not a docstring """ + | + = help: Replace double quotes docstring with single quotes + +ℹ Fix +1 1 | class SingleLineDocstrings(): +2 |- """ Double quotes single line class docstring """ + 2 |+ ''' Double quotes single line class docstring ''' +3 3 | """ Not a docstring """ +4 4 | +5 5 | def foo(self, bar="""not a docstring"""): + +docstring_doubles_class.py:6:9: Q002 [*] Double quote docstring found but single quotes preferred + | +5 | def foo(self, bar="""not a docstring"""): +6 | """ Double quotes single line method docstring""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 +7 | pass + | + = help: Replace double quotes docstring with single quotes + +ℹ Fix +3 3 | """ Not a docstring """ +4 4 | +5 5 | def foo(self, bar="""not a docstring"""): +6 |- """ Double quotes single line method docstring""" + 6 |+ ''' Double quotes single line method docstring''' +7 7 | pass +8 8 | +9 9 | class Nested(foo()[:]): """ inline docstring """; pass + +docstring_doubles_class.py:9:29: Q002 [*] Double quote docstring found but single quotes preferred + | +7 | pass +8 | +9 | class Nested(foo()[:]): """ inline docstring """; pass + | ^^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | + = help: Replace double quotes docstring with single quotes + +ℹ Fix +6 6 | """ Double quotes single line method docstring""" +7 7 | pass +8 8 | +9 |- class Nested(foo()[:]): """ inline docstring """; pass + 9 |+ class Nested(foo()[:]): ''' inline docstring '''; pass + + 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 new file mode 100644 index 0000000000..c80757cb19 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_function.py.snap @@ -0,0 +1,66 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +docstring_doubles_function.py:2:5: Q002 [*] Double quote docstring found but single quotes preferred + | +1 | def foo(): +2 | """function without params, single line docstring""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 +3 | """ not a docstring""" +4 | return + | + = help: Replace double quotes docstring with single quotes + +ℹ Fix +1 1 | def foo(): +2 |- """function without params, single line docstring""" + 2 |+ '''function without params, single line docstring''' +3 3 | """ not a docstring""" +4 4 | return +5 5 | + +docstring_doubles_function.py:8:5: Q002 [*] Double quote docstring found but single quotes preferred + | + 7 | def foo2(): + 8 | """ + | _____^ + 9 | | function without params, multiline docstring +10 | | """ + | |_______^ Q002 +11 | """ not a docstring""" +12 | return + | + = help: Replace double quotes docstring with single quotes + +ℹ Fix +5 5 | +6 6 | +7 7 | def foo2(): +8 |- """ + 8 |+ ''' +9 9 | function without params, multiline docstring +10 |- """ + 10 |+ ''' +11 11 | """ not a docstring""" +12 12 | return +13 13 | + +docstring_doubles_function.py:27:5: Q002 [*] Double quote docstring found but single quotes preferred + | +26 | def function_with_single_docstring(a): +27 | "Single line docstring" + | ^^^^^^^^^^^^^^^^^^^^^^^ Q002 + | + = help: Replace double quotes docstring with single quotes + +ℹ Fix +24 24 | +25 25 | +26 26 | def function_with_single_docstring(a): +27 |- "Single line docstring" + 27 |+ 'Single line docstring' +28 28 | +29 29 | +30 30 | def double_inside_single(a): + + diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_multiline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_multiline.py.snap new file mode 100644 index 0000000000..92a6a19370 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_multiline.py.snap @@ -0,0 +1,25 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +docstring_doubles_module_multiline.py:1:1: Q002 [*] Double quote docstring found but single quotes preferred + | +1 | / """ +2 | | Double quotes multiline module docstring +3 | | """ + | |___^ Q002 +4 | """ +5 | this is not a docstring + | + = help: Replace double quotes docstring with single quotes + +ℹ Fix +1 |-""" + 1 |+''' +2 2 | Double quotes multiline module docstring +3 |-""" + 3 |+''' +4 4 | """ +5 5 | this is not a docstring +6 6 | """ + + diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_singleline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_singleline.py.snap new file mode 100644 index 0000000000..b9cc166967 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_doubles_module_singleline.py.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +docstring_doubles_module_singleline.py:1:1: Q002 [*] Double quote docstring found but single quotes preferred + | +1 | """ Double quotes singleline module docstring """ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q002 +2 | """ this is not a docstring """ + | + = help: Replace double quotes docstring with single quotes + +ℹ Fix +1 |-""" Double quotes singleline module docstring """ + 1 |+''' Double quotes singleline module docstring ''' +2 2 | """ this is not a docstring """ +3 3 | +4 4 | def foo(): + + 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 new file mode 100644 index 0000000000..4d00a36af6 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles.py.snap @@ -0,0 +1,158 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +docstring_singles.py:5:1: Q001 [*] Single quote multiline found but double quotes preferred + | +3 | ''' +4 | +5 | / ''' +6 | | this is not a docstring +7 | | ''' + | |___^ Q001 +8 | +9 | l = [] + | + = help: Replace single multiline quotes with double quotes + +ℹ Fix +2 2 | Single quotes multiline module docstring +3 3 | ''' +4 4 | +5 |-''' + 5 |+""" +6 6 | this is not a docstring +7 |-''' + 7 |+""" +8 8 | +9 9 | l = [] +10 10 | + +docstring_singles.py:11:21: Q001 [*] Single quote multiline found but double quotes preferred + | + 9 | l = [] +10 | +11 | class Cls(MakeKlass(''' + | _____________________^ +12 | | class params \t not a docstring +13 | | ''')): + | |___^ Q001 +14 | ''' +15 | Single quotes multiline class docstring + | + = help: Replace single multiline quotes with double quotes + +ℹ Fix +8 8 | +9 9 | l = [] +10 10 | +11 |-class Cls(MakeKlass(''' + 11 |+class Cls(MakeKlass(""" +12 12 | class params \t not a docstring +13 |-''')): + 13 |+""")): +14 14 | ''' +15 15 | Single quotes multiline class docstring +16 16 | ''' + +docstring_singles.py:18:5: Q001 [*] Single quote multiline found but double quotes preferred + | +16 | ''' +17 | +18 | ''' + | _____^ +19 | | this is not a docstring +20 | | ''' + | |_______^ Q001 +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 + +ℹ Fix +15 15 | Single quotes multiline class docstring +16 16 | ''' +17 17 | +18 |- ''' + 18 |+ """ +19 19 | this is not a docstring +20 |- ''' + 20 |+ """ +21 21 | +22 22 | # The colon in the list indexing below is an edge case for the docstring scanner +23 23 | def f(self, bar=''' + +docstring_singles.py:23:21: Q001 [*] Single quote multiline found but double quotes preferred + | +22 | # The colon in the list indexing below is an edge case for the docstring scanner +23 | def f(self, bar=''' + | _____________________^ +24 | | definitely not a docstring''', + | |_____________________________________^ Q001 +25 | val=l[Cls():3]): +26 | ''' + | + = help: Replace single multiline quotes with double quotes + +ℹ Fix +20 20 | ''' +21 21 | +22 22 | # The colon in the list indexing below is an edge case for the docstring scanner +23 |- def f(self, bar=''' +24 |- definitely not a docstring''', + 23 |+ def f(self, bar=""" + 24 |+ definitely not a docstring""", +25 25 | val=l[Cls():3]): +26 26 | ''' +27 27 | Single quotes multiline function docstring + +docstring_singles.py:32:9: Q001 [*] Single quote multiline found but double quotes preferred + | +30 | some_expression = 'hello world' +31 | +32 | ''' + | _________^ +33 | | this is not a docstring +34 | | ''' + | |___________^ Q001 +35 | +36 | if l: + | + = help: Replace single multiline quotes with double quotes + +ℹ Fix +29 29 | +30 30 | some_expression = 'hello world' +31 31 | +32 |- ''' + 32 |+ """ +33 33 | this is not a docstring +34 |- ''' + 34 |+ """ +35 35 | +36 36 | if l: +37 37 | ''' + +docstring_singles.py:37:13: Q001 [*] Single quote multiline found but double quotes preferred + | +36 | if l: +37 | ''' + | _____________^ +38 | | Looks like a docstring, but in reality it isn't - only modules, classes and functions +39 | | ''' + | |_______________^ Q001 +40 | pass + | + = help: Replace single multiline quotes with double quotes + +ℹ Fix +34 34 | ''' +35 35 | +36 36 | if l: +37 |- ''' + 37 |+ """ +38 38 | Looks like a docstring, but in reality it isn't - only modules, classes and functions +39 |- ''' + 39 |+ """ +40 40 | pass + + 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 new file mode 100644 index 0000000000..a3678ef54f --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_class.py.snap @@ -0,0 +1,45 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +docstring_singles_class.py:3:5: Q001 [*] Single quote multiline found but double quotes preferred + | +1 | class SingleLineDocstrings(): +2 | ''' Double quotes single line class docstring ''' +3 | ''' Not a docstring ''' + | ^^^^^^^^^^^^^^^^^^^^^^^ Q001 +4 | +5 | def foo(self, bar='''not a docstring'''): + | + = help: Replace single multiline quotes with double quotes + +ℹ Fix +1 1 | class SingleLineDocstrings(): +2 2 | ''' Double quotes single line class docstring ''' +3 |- ''' Not a docstring ''' + 3 |+ """ Not a docstring """ +4 4 | +5 5 | def foo(self, bar='''not a docstring'''): +6 6 | ''' Double quotes single line method docstring''' + +docstring_singles_class.py:5:23: Q001 [*] Single quote multiline found but double quotes preferred + | +3 | ''' Not a docstring ''' +4 | +5 | def foo(self, bar='''not a docstring'''): + | ^^^^^^^^^^^^^^^^^^^^^ Q001 +6 | ''' Double quotes single line method docstring''' +7 | pass + | + = help: Replace single multiline quotes with double quotes + +ℹ Fix +2 2 | ''' Double quotes single line class docstring ''' +3 3 | ''' Not a docstring ''' +4 4 | +5 |- def foo(self, bar='''not a docstring'''): + 5 |+ def foo(self, bar="""not a docstring"""): +6 6 | ''' Double quotes single line method docstring''' +7 7 | pass +8 8 | + + diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_function.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_function.py.snap new file mode 100644 index 0000000000..14a97a1099 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_function.py.snap @@ -0,0 +1,106 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +docstring_singles_function.py:3:5: Q001 [*] Single quote multiline found but double quotes preferred + | +1 | def foo(): +2 | '''function without params, single line docstring''' +3 | ''' not a docstring''' + | ^^^^^^^^^^^^^^^^^^^^^^ Q001 +4 | return + | + = help: Replace single multiline quotes with double quotes + +ℹ Fix +1 1 | def foo(): +2 2 | '''function without params, single line docstring''' +3 |- ''' not a docstring''' + 3 |+ """ not a docstring""" +4 4 | return +5 5 | +6 6 | + +docstring_singles_function.py:11:5: Q001 [*] Single quote multiline found but double quotes preferred + | + 9 | function without params, multiline docstring +10 | ''' +11 | ''' not a docstring''' + | ^^^^^^^^^^^^^^^^^^^^^^ Q001 +12 | return + | + = help: Replace single multiline quotes with double quotes + +ℹ Fix +8 8 | ''' +9 9 | function without params, multiline docstring +10 10 | ''' +11 |- ''' not a docstring''' + 11 |+ """ not a docstring""" +12 12 | return +13 13 | +14 14 | + +docstring_singles_function.py:15:39: Q001 [*] Single quote multiline found but double quotes preferred + | +15 | def fun_with_params_no_docstring(a, b=''' + | _______________________________________^ +16 | | not a +17 | | ''' '''docstring'''): + | |___^ Q001 +18 | pass + | + = help: Replace single multiline quotes with double quotes + +ℹ Fix +12 12 | return +13 13 | +14 14 | +15 |-def fun_with_params_no_docstring(a, b=''' + 15 |+def fun_with_params_no_docstring(a, b=""" +16 16 | not a +17 |-''' '''docstring'''): + 17 |+""" '''docstring'''): +18 18 | pass +19 19 | +20 20 | + +docstring_singles_function.py:17:5: Q001 [*] Single quote multiline found but double quotes preferred + | +15 | def fun_with_params_no_docstring(a, b=''' +16 | not a +17 | ''' '''docstring'''): + | ^^^^^^^^^^^^^^^ Q001 +18 | pass + | + = help: Replace single multiline quotes with double quotes + +ℹ Fix +14 14 | +15 15 | def fun_with_params_no_docstring(a, b=''' +16 16 | not a +17 |-''' '''docstring'''): + 17 |+''' """docstring"""): +18 18 | pass +19 19 | +20 20 | + +docstring_singles_function.py:22:5: Q001 [*] Single quote multiline found but double quotes preferred + | +21 | def fun_with_params_no_docstring2(a, b=c[foo():], c=\ +22 | ''' not a docstring '''): + | ^^^^^^^^^^^^^^^^^^^^^^^ Q001 +23 | pass + | + = help: Replace single multiline quotes with double quotes + +ℹ Fix +19 19 | +20 20 | +21 21 | def fun_with_params_no_docstring2(a, b=c[foo():], c=\ +22 |- ''' not a docstring '''): + 22 |+ """ not a docstring """): +23 23 | pass +24 24 | +25 25 | + + diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_multiline.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_multiline.py.snap new file mode 100644 index 0000000000..38a0beb4ce --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_docstring_singles_over_docstring_singles_module_multiline.py.snap @@ -0,0 +1,51 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +docstring_singles_module_multiline.py:4:1: Q001 [*] Single quote multiline found but double quotes preferred + | +2 | Double quotes multiline module docstring +3 | ''' +4 | / ''' +5 | | this is not a docstring +6 | | ''' + | |___^ Q001 +7 | def foo(): +8 | pass + | + = help: Replace single multiline quotes with double quotes + +ℹ Fix +1 1 | ''' +2 2 | Double quotes multiline module docstring +3 3 | ''' +4 |-''' + 4 |+""" +5 5 | this is not a docstring +6 |-''' + 6 |+""" +7 7 | def foo(): +8 8 | pass +9 9 | ''' + +docstring_singles_module_multiline.py:9:1: Q001 [*] Single quote multiline found but double quotes preferred + | + 7 | def foo(): + 8 | pass + 9 | / ''' +10 | | this is not a docstring +11 | | ''' + | |___^ Q001 + | + = help: Replace single multiline quotes with double quotes + +ℹ Fix +6 6 | ''' +7 7 | def foo(): +8 8 | pass +9 |-''' + 9 |+""" +10 10 | this is not a docstring +11 |-''' + 11 |+""" + + 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 new file mode 100644 index 0000000000..beb76e195b --- /dev/null +++ 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 @@ -0,0 +1,38 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +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 | +4 | def foo(): + | + = help: Replace single multiline quotes with double quotes + +ℹ Fix +1 1 | ''' Double quotes singleline module docstring ''' +2 |-''' this is not a docstring ''' + 2 |+""" this is not a docstring """ +3 3 | +4 4 | def foo(): +5 5 | pass + +docstring_singles_module_singleline.py:6:1: Q001 [*] Single quote multiline found but double quotes preferred + | +4 | def foo(): +5 | pass +6 | ''' this is not a docstring ''' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q001 + | + = help: Replace single multiline quotes with double quotes + +ℹ Fix +3 3 | +4 4 | def foo(): +5 5 | pass +6 |-''' this is not a docstring ''' + 6 |+""" this is not a docstring """ + + diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles.py.snap new file mode 100644 index 0000000000..01befe313e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles.py.snap @@ -0,0 +1,54 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +singles.py:1:25: Q000 [*] Single quotes found but double quotes preferred + | +1 | this_should_be_linted = 'single quote string' + | ^^^^^^^^^^^^^^^^^^^^^ Q000 +2 | this_should_be_linted = u'double quote string' +3 | this_should_be_linted = f'double quote string' + | + = help: Replace single quotes with double quotes + +ℹ Fix +1 |-this_should_be_linted = 'single quote string' + 1 |+this_should_be_linted = "single quote string" +2 2 | this_should_be_linted = u'double quote string' +3 3 | this_should_be_linted = f'double quote string' +4 4 | this_should_be_linted = f'double {"quote"} string' + +singles.py:2:25: Q000 [*] Single quotes found but double quotes preferred + | +1 | this_should_be_linted = 'single quote string' +2 | this_should_be_linted = u'double quote string' + | ^^^^^^^^^^^^^^^^^^^^^^ Q000 +3 | this_should_be_linted = f'double quote string' +4 | this_should_be_linted = f'double {"quote"} string' + | + = help: Replace single quotes with double quotes + +ℹ Fix +1 1 | this_should_be_linted = 'single quote string' +2 |-this_should_be_linted = u'double quote string' + 2 |+this_should_be_linted = u"double quote string" +3 3 | this_should_be_linted = f'double quote string' +4 4 | this_should_be_linted = f'double {"quote"} string' + +singles.py:3:25: Q000 [*] Single quotes found but double quotes preferred + | +1 | this_should_be_linted = 'single quote string' +2 | this_should_be_linted = u'double quote string' +3 | this_should_be_linted = f'double quote string' + | ^^^^^^^^^^^^^^^^^^^^^^ Q000 +4 | this_should_be_linted = f'double {"quote"} string' + | + = help: Replace single quotes with double quotes + +ℹ Fix +1 1 | this_should_be_linted = 'single quote string' +2 2 | this_should_be_linted = u'double quote string' +3 |-this_should_be_linted = f'double quote string' + 3 |+this_should_be_linted = f"double quote string" +4 4 | this_should_be_linted = f'double {"quote"} string' + + 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 new file mode 100644 index 0000000000..a05a28bb5a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_escaped.py.snap @@ -0,0 +1,38 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +singles_escaped.py:1:26: Q003 [*] Change outer quotes to avoid escaping inner quotes + | +1 | this_should_raise_Q003 = "This is a \"string\"" + | ^^^^^^^^^^^^^^^^^^^^^^ Q003 +2 | this_is_fine = "'This' is a \"string\"" +3 | this_is_fine = 'This is a "string"' + | + = help: Change outer quotes to avoid escaping inner quotes + +ℹ Fix +1 |-this_should_raise_Q003 = "This is a \"string\"" + 1 |+this_should_raise_Q003 = 'This is a "string"' +2 2 | this_is_fine = "'This' is a \"string\"" +3 3 | this_is_fine = 'This is a "string"' +4 4 | this_is_fine = '\'This\' is a "string"' + +singles_escaped.py:9:5: Q003 [*] Change outer quotes to avoid escaping inner quotes + | + 7 | this_should_raise = ( + 8 | "This is a" + 9 | "\"string\"" + | ^^^^^^^^^^^^ Q003 +10 | ) + | + = help: Change outer quotes to avoid escaping inner quotes + +ℹ Fix +6 6 | this_is_fine = R"This is a \"string\"" +7 7 | this_should_raise = ( +8 8 | "This is a" +9 |- "\"string\"" + 9 |+ '"string"' +10 10 | ) + + diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_implicit.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_implicit.py.snap new file mode 100644 index 0000000000..e7f0de50e4 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_implicit.py.snap @@ -0,0 +1,139 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +singles_implicit.py:2:5: Q000 [*] Single quotes found but double quotes preferred + | +1 | x = ( +2 | 'This' + | ^^^^^^ Q000 +3 | 'is' +4 | 'not' + | + = help: Replace single quotes with double quotes + +ℹ Fix +1 1 | x = ( +2 |- 'This' + 2 |+ "This" +3 3 | 'is' +4 4 | 'not' +5 5 | ) + +singles_implicit.py:3:5: Q000 [*] Single quotes found but double quotes preferred + | +1 | x = ( +2 | 'This' +3 | 'is' + | ^^^^ Q000 +4 | 'not' +5 | ) + | + = help: Replace single quotes with double quotes + +ℹ Fix +1 1 | x = ( +2 2 | 'This' +3 |- 'is' + 3 |+ "is" +4 4 | 'not' +5 5 | ) +6 6 | + +singles_implicit.py:4:5: Q000 [*] Single quotes found but double quotes preferred + | +2 | 'This' +3 | 'is' +4 | 'not' + | ^^^^^ Q000 +5 | ) + | + = help: Replace single quotes with double quotes + +ℹ Fix +1 1 | x = ( +2 2 | 'This' +3 3 | 'is' +4 |- 'not' + 4 |+ "not" +5 5 | ) +6 6 | +7 7 | x = ( + +singles_implicit.py:8:5: Q000 [*] Single quotes found but double quotes preferred + | + 7 | x = ( + 8 | 'This' \ + | ^^^^^^ Q000 + 9 | 'is' \ +10 | 'not' + | + = help: Replace single quotes with double quotes + +ℹ Fix +5 5 | ) +6 6 | +7 7 | x = ( +8 |- 'This' \ + 8 |+ "This" \ +9 9 | 'is' \ +10 10 | 'not' +11 11 | ) + +singles_implicit.py:9:5: Q000 [*] Single quotes found but double quotes preferred + | + 7 | x = ( + 8 | 'This' \ + 9 | 'is' \ + | ^^^^ Q000 +10 | 'not' +11 | ) + | + = help: Replace single quotes with double quotes + +ℹ Fix +6 6 | +7 7 | x = ( +8 8 | 'This' \ +9 |- 'is' \ + 9 |+ "is" \ +10 10 | 'not' +11 11 | ) +12 12 | + +singles_implicit.py:10:5: Q000 [*] Single quotes found but double quotes preferred + | + 8 | 'This' \ + 9 | 'is' \ +10 | 'not' + | ^^^^^ Q000 +11 | ) + | + = help: Replace single quotes with double quotes + +ℹ Fix +7 7 | x = ( +8 8 | 'This' \ +9 9 | 'is' \ +10 |- 'not' + 10 |+ "not" +11 11 | ) +12 12 | +13 13 | x = ( + +singles_implicit.py:27:1: Q000 [*] Single quotes found but double quotes preferred + | +25 | if True: +26 | 'This can use "single" quotes' +27 | 'But this needs to be changed' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q000 + | + = help: Replace single quotes with double quotes + +ℹ Fix +24 24 | +25 25 | if True: +26 26 | 'This can use "single" quotes' +27 |-'But this needs to be changed' + 27 |+"But this needs to be changed" + + 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 new file mode 100644 index 0000000000..4ba380293e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_multiline_string.py.snap @@ -0,0 +1,26 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +singles_multiline_string.py:1:5: Q001 [*] Single quote multiline found but double quotes preferred + | +1 | s = ''' This 'should' + | _____^ +2 | | be +3 | | 'linted' ''' + | |____________^ Q001 +4 | +5 | s = """ This 'should' + | + = help: Replace single multiline quotes with double quotes + +ℹ Fix +1 |-s = ''' This 'should' + 1 |+s = """ This 'should' +2 2 | be +3 |-'linted' ''' + 3 |+'linted' """ +4 4 | +5 5 | s = """ This 'should' +6 6 | 'not' be + + diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_noqa.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_noqa.py.snap new file mode 100644 index 0000000000..a5e579090a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_noqa.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_wrapped.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_wrapped.py.snap new file mode 100644 index 0000000000..a5e579090a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_doubles_over_singles_wrapped.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles.py.snap new file mode 100644 index 0000000000..1d0c054202 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles.py.snap @@ -0,0 +1,54 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +doubles.py:1:25: Q000 [*] Double quotes found but single quotes preferred + | +1 | this_should_be_linted = "double quote string" + | ^^^^^^^^^^^^^^^^^^^^^ Q000 +2 | this_should_be_linted = u"double quote string" +3 | this_should_be_linted = f"double quote string" + | + = help: Replace double quotes with single quotes + +ℹ Fix +1 |-this_should_be_linted = "double quote string" + 1 |+this_should_be_linted = 'double quote string' +2 2 | this_should_be_linted = u"double quote string" +3 3 | this_should_be_linted = f"double quote string" +4 4 | this_should_be_linted = f"double {'quote'} string" + +doubles.py:2:25: Q000 [*] Double quotes found but single quotes preferred + | +1 | this_should_be_linted = "double quote string" +2 | this_should_be_linted = u"double quote string" + | ^^^^^^^^^^^^^^^^^^^^^^ Q000 +3 | this_should_be_linted = f"double quote string" +4 | this_should_be_linted = f"double {'quote'} string" + | + = help: Replace double quotes with single quotes + +ℹ Fix +1 1 | this_should_be_linted = "double quote string" +2 |-this_should_be_linted = u"double quote string" + 2 |+this_should_be_linted = u'double quote string' +3 3 | this_should_be_linted = f"double quote string" +4 4 | this_should_be_linted = f"double {'quote'} string" + +doubles.py:3:25: Q000 [*] Double quotes found but single quotes preferred + | +1 | this_should_be_linted = "double quote string" +2 | this_should_be_linted = u"double quote string" +3 | this_should_be_linted = f"double quote string" + | ^^^^^^^^^^^^^^^^^^^^^^ Q000 +4 | this_should_be_linted = f"double {'quote'} string" + | + = help: Replace double quotes with single quotes + +ℹ Fix +1 1 | this_should_be_linted = "double quote string" +2 2 | this_should_be_linted = u"double quote string" +3 |-this_should_be_linted = f"double quote string" + 3 |+this_should_be_linted = f'double quote string' +4 4 | this_should_be_linted = f"double {'quote'} string" + + 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 new file mode 100644 index 0000000000..ccc63c71d3 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_escaped.py.snap @@ -0,0 +1,56 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +doubles_escaped.py:1:26: Q003 [*] Change outer quotes to avoid escaping inner quotes + | +1 | this_should_raise_Q003 = 'This is a \'string\'' + | ^^^^^^^^^^^^^^^^^^^^^^ Q003 +2 | this_should_raise_Q003 = 'This is \\ a \\\'string\'' +3 | this_is_fine = '"This" is a \'string\'' + | + = help: Change outer quotes to avoid escaping inner quotes + +ℹ Fix +1 |-this_should_raise_Q003 = 'This is a \'string\'' + 1 |+this_should_raise_Q003 = "This is a 'string'" +2 2 | this_should_raise_Q003 = 'This is \\ a \\\'string\'' +3 3 | this_is_fine = '"This" is a \'string\'' +4 4 | this_is_fine = "This is a 'string'" + +doubles_escaped.py:2:26: Q003 [*] Change outer quotes to avoid escaping inner quotes + | +1 | this_should_raise_Q003 = 'This is a \'string\'' +2 | this_should_raise_Q003 = 'This is \\ a \\\'string\'' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q003 +3 | this_is_fine = '"This" is a \'string\'' +4 | this_is_fine = "This is a 'string'" + | + = help: Change outer quotes to avoid escaping inner quotes + +ℹ Fix +1 1 | this_should_raise_Q003 = 'This is a \'string\'' +2 |-this_should_raise_Q003 = 'This is \\ a \\\'string\'' + 2 |+this_should_raise_Q003 = "This is \\ a \\'string'" +3 3 | this_is_fine = '"This" is a \'string\'' +4 4 | this_is_fine = "This is a 'string'" +5 5 | this_is_fine = "\"This\" is a 'string'" + +doubles_escaped.py:10:5: Q003 [*] Change outer quotes to avoid escaping inner quotes + | + 8 | this_should_raise = ( + 9 | 'This is a' +10 | '\'string\'' + | ^^^^^^^^^^^^ Q003 +11 | ) + | + = help: Change outer quotes to avoid escaping inner quotes + +ℹ Fix +7 7 | this_is_fine = R'This is a \'string\'' +8 8 | this_should_raise = ( +9 9 | 'This is a' +10 |- '\'string\'' + 10 |+ "'string'" +11 11 | ) + + diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_implicit.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_implicit.py.snap new file mode 100644 index 0000000000..bb6f91c98f --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_implicit.py.snap @@ -0,0 +1,139 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +doubles_implicit.py:2:5: Q000 [*] Double quotes found but single quotes preferred + | +1 | x = ( +2 | "This" + | ^^^^^^ Q000 +3 | "is" +4 | "not" + | + = help: Replace double quotes with single quotes + +ℹ Fix +1 1 | x = ( +2 |- "This" + 2 |+ 'This' +3 3 | "is" +4 4 | "not" +5 5 | ) + +doubles_implicit.py:3:5: Q000 [*] Double quotes found but single quotes preferred + | +1 | x = ( +2 | "This" +3 | "is" + | ^^^^ Q000 +4 | "not" +5 | ) + | + = help: Replace double quotes with single quotes + +ℹ Fix +1 1 | x = ( +2 2 | "This" +3 |- "is" + 3 |+ 'is' +4 4 | "not" +5 5 | ) +6 6 | + +doubles_implicit.py:4:5: Q000 [*] Double quotes found but single quotes preferred + | +2 | "This" +3 | "is" +4 | "not" + | ^^^^^ Q000 +5 | ) + | + = help: Replace double quotes with single quotes + +ℹ Fix +1 1 | x = ( +2 2 | "This" +3 3 | "is" +4 |- "not" + 4 |+ 'not' +5 5 | ) +6 6 | +7 7 | x = ( + +doubles_implicit.py:8:5: Q000 [*] Double quotes found but single quotes preferred + | + 7 | x = ( + 8 | "This" \ + | ^^^^^^ Q000 + 9 | "is" \ +10 | "not" + | + = help: Replace double quotes with single quotes + +ℹ Fix +5 5 | ) +6 6 | +7 7 | x = ( +8 |- "This" \ + 8 |+ 'This' \ +9 9 | "is" \ +10 10 | "not" +11 11 | ) + +doubles_implicit.py:9:5: Q000 [*] Double quotes found but single quotes preferred + | + 7 | x = ( + 8 | "This" \ + 9 | "is" \ + | ^^^^ Q000 +10 | "not" +11 | ) + | + = help: Replace double quotes with single quotes + +ℹ Fix +6 6 | +7 7 | x = ( +8 8 | "This" \ +9 |- "is" \ + 9 |+ 'is' \ +10 10 | "not" +11 11 | ) +12 12 | + +doubles_implicit.py:10:5: Q000 [*] Double quotes found but single quotes preferred + | + 8 | "This" \ + 9 | "is" \ +10 | "not" + | ^^^^^ Q000 +11 | ) + | + = help: Replace double quotes with single quotes + +ℹ Fix +7 7 | x = ( +8 8 | "This" \ +9 9 | "is" \ +10 |- "not" + 10 |+ 'not' +11 11 | ) +12 12 | +13 13 | x = ( + +doubles_implicit.py:27:1: Q000 [*] Double quotes found but single quotes preferred + | +25 | if True: +26 | "This can use 'double' quotes" +27 | "But this needs to be changed" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Q000 + | + = help: Replace double quotes with single quotes + +ℹ Fix +24 24 | +25 25 | if True: +26 26 | "This can use 'double' quotes" +27 |-"But this needs to be changed" + 27 |+'But this needs to be changed' + + 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 new file mode 100644 index 0000000000..29814f8c71 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_multiline_string.py.snap @@ -0,0 +1,26 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- +doubles_multiline_string.py:1:5: Q001 [*] Double quote multiline found but single quotes preferred + | +1 | s = """ This "should" + | _____^ +2 | | be +3 | | "linted" """ + | |____________^ Q001 +4 | +5 | s = ''' This "should" + | + = help: Replace double multiline quotes with single quotes + +ℹ Fix +1 |-s = """ This "should" + 1 |+s = ''' This "should" +2 2 | be +3 |-"linted" """ + 3 |+"linted" ''' +4 4 | +5 5 | s = ''' This "should" +6 6 | "not" be + + diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_noqa.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_noqa.py.snap new file mode 100644 index 0000000000..a5e579090a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_noqa.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_wrapped.py.snap b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_wrapped.py.snap new file mode 100644 index 0000000000..a5e579090a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_quotes/snapshots/ruff_linter__rules__flake8_quotes__tests__require_singles_over_doubles_wrapped.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_quotes/mod.rs +--- + diff --git a/crates/ruff/src/rules/flake8_raise/mod.rs b/crates/ruff_linter/src/rules/flake8_raise/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_raise/mod.rs rename to crates/ruff_linter/src/rules/flake8_raise/mod.rs diff --git a/crates/ruff/src/rules/flake8_raise/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_raise/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_raise/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_raise/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_raise/rules/unnecessary_paren_on_raise_exception.rs b/crates/ruff_linter/src/rules/flake8_raise/rules/unnecessary_paren_on_raise_exception.rs similarity index 100% rename from crates/ruff/src/rules/flake8_raise/rules/unnecessary_paren_on_raise_exception.rs rename to crates/ruff_linter/src/rules/flake8_raise/rules/unnecessary_paren_on_raise_exception.rs 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 new file mode 100644 index 0000000000..4a87268b61 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_raise/snapshots/ruff_linter__rules__flake8_raise__tests__unnecessary-paren-on-raise-exception_RSE102.py.snap @@ -0,0 +1,258 @@ +--- +source: crates/ruff_linter/src/rules/flake8_raise/mod.rs +--- +RSE102.py:5:21: RSE102 [*] Unnecessary parentheses on raised exception + | +3 | except TypeError: +4 | # RSE102 +5 | raise ValueError() + | ^^ RSE102 +6 | +7 | try: + | + = help: Remove unnecessary parentheses + +ℹ Fix +2 2 | y = 6 + "7" +3 3 | except TypeError: +4 4 | # RSE102 +5 |- raise ValueError() + 5 |+ raise ValueError +6 6 | +7 7 | try: +8 8 | x = 1 / 0 + +RSE102.py:13:16: RSE102 [*] Unnecessary parentheses on raised exception + | +12 | # RSE102 +13 | raise TypeError() + | ^^ RSE102 +14 | +15 | # RSE102 + | + = help: Remove unnecessary parentheses + +ℹ Fix +10 10 | raise +11 11 | +12 12 | # RSE102 +13 |-raise TypeError() + 13 |+raise TypeError +14 14 | +15 15 | # RSE102 +16 16 | raise TypeError () + +RSE102.py:16:17: RSE102 [*] Unnecessary parentheses on raised exception + | +15 | # RSE102 +16 | raise TypeError () + | ^^ RSE102 +17 | +18 | # RSE102 + | + = help: Remove unnecessary parentheses + +ℹ Fix +13 13 | raise TypeError() +14 14 | +15 15 | # RSE102 +16 |-raise TypeError () + 16 |+raise TypeError +17 17 | +18 18 | # RSE102 +19 19 | raise TypeError \ + +RSE102.py:20:5: RSE102 [*] Unnecessary parentheses on raised exception + | +18 | # RSE102 +19 | raise TypeError \ +20 | () + | ^^ RSE102 +21 | +22 | # RSE102 + | + = help: Remove unnecessary parentheses + +ℹ Fix +17 17 | +18 18 | # RSE102 +19 19 | raise TypeError \ +20 |- () + 20 |+ +21 21 | +22 22 | # RSE102 +23 23 | raise TypeError \ + +RSE102.py:24:5: RSE102 [*] Unnecessary parentheses on raised exception + | +22 | # RSE102 +23 | raise TypeError \ +24 | (); + | ^^ RSE102 +25 | +26 | # RSE102 + | + = help: Remove unnecessary parentheses + +ℹ Fix +21 21 | +22 22 | # RSE102 +23 23 | raise TypeError \ +24 |- (); + 24 |+ ; +25 25 | +26 26 | # RSE102 +27 27 | raise TypeError( + +RSE102.py:27:16: RSE102 [*] Unnecessary parentheses on raised exception + | +26 | # RSE102 +27 | raise TypeError( + | ________________^ +28 | | +29 | | ) + | |_^ RSE102 +30 | +31 | # RSE102 + | + = help: Remove unnecessary parentheses + +ℹ Fix +24 24 | (); +25 25 | +26 26 | # RSE102 +27 |-raise TypeError( +28 |- +29 |-) + 27 |+raise TypeError +30 28 | +31 29 | # RSE102 +32 30 | raise (TypeError) ( + +RSE102.py:32:19: RSE102 [*] Unnecessary parentheses on raised exception + | +31 | # RSE102 +32 | raise (TypeError) ( + | ___________________^ +33 | | +34 | | ) + | |_^ RSE102 +35 | +36 | # RSE102 + | + = help: Remove unnecessary parentheses + +ℹ Fix +29 29 | ) +30 30 | +31 31 | # RSE102 +32 |-raise (TypeError) ( +33 |- +34 |-) + 32 |+raise (TypeError) +35 33 | +36 34 | # RSE102 +37 35 | raise TypeError( + +RSE102.py:37:16: RSE102 [*] Unnecessary parentheses on raised exception + | +36 | # RSE102 +37 | raise TypeError( + | ________________^ +38 | | # Hello, world! +39 | | ) + | |_^ RSE102 +40 | +41 | # OK + | + = help: Remove unnecessary parentheses + +ℹ Fix +34 34 | ) +35 35 | +36 36 | # RSE102 +37 |-raise TypeError( +38 |- # Hello, world! +39 |-) + 37 |+raise TypeError +40 38 | +41 39 | # OK +42 40 | raise AssertionError + +RSE102.py:74:17: RSE102 [*] Unnecessary parentheses on raised exception + | +73 | # RSE102 +74 | raise IndexError()from ZeroDivisionError + | ^^ RSE102 +75 | +76 | raise IndexError()\ + | + = help: Remove unnecessary parentheses + +ℹ Fix +71 71 | +72 72 | +73 73 | # RSE102 +74 |-raise IndexError()from ZeroDivisionError + 74 |+raise IndexError from ZeroDivisionError +75 75 | +76 76 | raise IndexError()\ +77 77 | from ZeroDivisionError + +RSE102.py:76:17: RSE102 [*] Unnecessary parentheses on raised exception + | +74 | raise IndexError()from ZeroDivisionError +75 | +76 | raise IndexError()\ + | ^^ RSE102 +77 | from ZeroDivisionError + | + = help: Remove unnecessary parentheses + +ℹ Fix +73 73 | # RSE102 +74 74 | raise IndexError()from ZeroDivisionError +75 75 | +76 |-raise IndexError()\ + 76 |+raise IndexError\ +77 77 | from ZeroDivisionError +78 78 | +79 79 | raise IndexError() from ZeroDivisionError + +RSE102.py:79:17: RSE102 [*] Unnecessary parentheses on raised exception + | +77 | from ZeroDivisionError +78 | +79 | raise IndexError() from ZeroDivisionError + | ^^ RSE102 +80 | +81 | raise IndexError(); + | + = help: Remove unnecessary parentheses + +ℹ Fix +76 76 | raise IndexError()\ +77 77 | from ZeroDivisionError +78 78 | +79 |-raise IndexError() from ZeroDivisionError + 79 |+raise IndexError from ZeroDivisionError +80 80 | +81 81 | raise IndexError(); + +RSE102.py:81:17: RSE102 [*] Unnecessary parentheses on raised exception + | +79 | raise IndexError() from ZeroDivisionError +80 | +81 | raise IndexError(); + | ^^ RSE102 + | + = help: Remove unnecessary parentheses + +ℹ Fix +78 78 | +79 79 | raise IndexError() from ZeroDivisionError +80 80 | +81 |-raise IndexError(); + 81 |+raise IndexError; + + diff --git a/crates/ruff/src/rules/flake8_return/branch.rs b/crates/ruff_linter/src/rules/flake8_return/branch.rs similarity index 100% rename from crates/ruff/src/rules/flake8_return/branch.rs rename to crates/ruff_linter/src/rules/flake8_return/branch.rs diff --git a/crates/ruff/src/rules/flake8_return/helpers.rs b/crates/ruff_linter/src/rules/flake8_return/helpers.rs similarity index 100% rename from crates/ruff/src/rules/flake8_return/helpers.rs rename to crates/ruff_linter/src/rules/flake8_return/helpers.rs diff --git a/crates/ruff/src/rules/flake8_return/mod.rs b/crates/ruff_linter/src/rules/flake8_return/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_return/mod.rs rename to crates/ruff_linter/src/rules/flake8_return/mod.rs diff --git a/crates/ruff/src/rules/flake8_return/rules/function.rs b/crates/ruff_linter/src/rules/flake8_return/rules/function.rs similarity index 100% rename from crates/ruff/src/rules/flake8_return/rules/function.rs rename to crates/ruff_linter/src/rules/flake8_return/rules/function.rs diff --git a/crates/ruff/src/rules/flake8_return/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_return/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_return/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_return/rules/mod.rs 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 new file mode 100644 index 0000000000..2fc27bd29d --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET501_RET501.py.snap @@ -0,0 +1,39 @@ +--- +source: crates/ruff_linter/src/rules/flake8_return/mod.rs +--- +RET501.py:4:5: RET501 [*] Do not explicitly `return None` in function if it is the only possible return value + | +2 | if not y: +3 | return +4 | return None # error + | ^^^^^^^^^^^ RET501 + | + = help: Remove explicit `return None` + +ℹ Fix +1 1 | def x(y): +2 2 | if not y: +3 3 | return +4 |- return None # error + 4 |+ return # error +5 5 | +6 6 | +7 7 | class BaseCache: + +RET501.py:14:9: RET501 [*] Do not explicitly `return None` in function if it is the only possible return value + | +12 | def get(self, key: str) -> None: +13 | print(f"{key} not found") +14 | return None + | ^^^^^^^^^^^ RET501 + | + = help: Remove explicit `return None` + +ℹ Fix +11 11 | +12 12 | def get(self, key: str) -> None: +13 13 | print(f"{key} not found") +14 |- return None + 14 |+ return + + diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET502_RET502.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET502_RET502.py.snap new file mode 100644 index 0000000000..9946d7b361 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET502_RET502.py.snap @@ -0,0 +1,23 @@ +--- +source: crates/ruff_linter/src/rules/flake8_return/mod.rs +--- +RET502.py:3:9: RET502 [*] Do not implicitly `return None` in function able to return non-`None` value + | +1 | def x(y): +2 | if not y: +3 | return # error + | ^^^^^^ RET502 +4 | return 1 + | + = help: Add explicit `None` return value + +ℹ Fix +1 1 | def x(y): +2 2 | if not y: +3 |- return # error + 3 |+ return None # error +4 4 | return 1 +5 5 | +6 6 | + + 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 new file mode 100644 index 0000000000..c3a4baa569 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET503_RET503.py.snap @@ -0,0 +1,403 @@ +--- +source: crates/ruff_linter/src/rules/flake8_return/mod.rs +--- +RET503.py:20:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +18 | # if/elif/else +19 | def x(y): +20 | if not y: + | _____^ +21 | | return 1 + | |________________^ RET503 +22 | # error + | + = help: Add explicit `return` statement + +ℹ Suggested fix +19 19 | def x(y): +20 20 | if not y: +21 21 | return 1 + 22 |+ return None +22 23 | # error +23 24 | +24 25 | + +RET503.py:27:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +25 | def x(y): +26 | if not y: +27 | print() # error + | ^^^^^^^ RET503 +28 | else: +29 | return 2 + | + = help: Add explicit `return` statement + +ℹ Suggested fix +25 25 | def x(y): +26 26 | if not y: +27 27 | print() # error + 28 |+ return None +28 29 | else: +29 30 | return 2 +30 31 | + +RET503.py:36:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +34 | return 1 +35 | +36 | print() # error + | ^^^^^^^ RET503 + | + = help: Add explicit `return` statement + +ℹ Suggested fix +34 34 | return 1 +35 35 | +36 36 | print() # error + 37 |+ return None +37 38 | +38 39 | +39 40 | # for + +RET503.py:41:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +39 | # for +40 | def x(y): +41 | for i in range(10): + | _____^ +42 | | if i > 10: +43 | | return i + | |____________________^ RET503 +44 | # error + | + = help: Add explicit `return` statement + +ℹ Suggested fix +41 41 | for i in range(10): +42 42 | if i > 10: +43 43 | return i + 44 |+ return None +44 45 | # error +45 46 | +46 47 | + +RET503.py:52:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +50 | return i +51 | else: +52 | print() # error + | ^^^^^^^ RET503 + | + = help: Add explicit `return` statement + +ℹ Suggested fix +50 50 | return i +51 51 | else: +52 52 | print() # error + 53 |+ return None +53 54 | +54 55 | +55 56 | # A nonexistent function + +RET503.py:59:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +57 | if x > 0: +58 | return False +59 | no_such_function() # error + | ^^^^^^^^^^^^^^^^^^ RET503 + | + = help: Add explicit `return` statement + +ℹ Suggested fix +57 57 | if x > 0: +58 58 | return False +59 59 | no_such_function() # error + 60 |+ return None +60 61 | +61 62 | +62 63 | # A function that does return the control + +RET503.py:66:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +64 | if x > 0: +65 | return False +66 | print("", end="") # error + | ^^^^^^^^^^^^^^^^^ RET503 + | + = help: Add explicit `return` statement + +ℹ Suggested fix +64 64 | if x > 0: +65 65 | return False +66 66 | print("", end="") # error + 67 |+ return None +67 68 | +68 69 | +69 70 | ### + +RET503.py:82:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +80 | # last line in while loop +81 | def x(y): +82 | while i > 0: + | _____^ +83 | | if y > 0: +84 | | return 1 +85 | | y += 1 + | |______________^ RET503 + | + = help: Add explicit `return` statement + +ℹ Suggested fix +83 83 | if y > 0: +84 84 | return 1 +85 85 | y += 1 + 86 |+ return None +86 87 | +87 88 | +88 89 | # exclude empty functions + +RET503.py:113:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +111 | # return value within loop +112 | def bar1(x, y, z): +113 | for i in x: + | _____^ +114 | | if i > y: +115 | | break +116 | | return z + | |________________^ RET503 + | + = help: Add explicit `return` statement + +ℹ Suggested fix +114 114 | if i > y: +115 115 | break +116 116 | return z + 117 |+ return None +117 118 | +118 119 | +119 120 | def bar3(x, y, z): + +RET503.py:120:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +119 | def bar3(x, y, z): +120 | for i in x: + | _____^ +121 | | if i > y: +122 | | if z: +123 | | break +124 | | else: +125 | | return z +126 | | return None + | |___________________^ RET503 + | + = help: Add explicit `return` statement + +ℹ Suggested fix +124 124 | else: +125 125 | return z +126 126 | return None + 127 |+ return None +127 128 | +128 129 | +129 130 | def bar1(x, y, z): + +RET503.py:130:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +129 | def bar1(x, y, z): +130 | for i in x: + | _____^ +131 | | if i < y: +132 | | continue +133 | | return z + | |________________^ RET503 + | + = help: Add explicit `return` statement + +ℹ Suggested fix +131 131 | if i < y: +132 132 | continue +133 133 | return z + 134 |+ return None +134 135 | +135 136 | +136 137 | def bar3(x, y, z): + +RET503.py:137:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +136 | def bar3(x, y, z): +137 | for i in x: + | _____^ +138 | | if i < y: +139 | | if z: +140 | | continue +141 | | else: +142 | | return z +143 | | return None + | |___________________^ RET503 + | + = help: Add explicit `return` statement + +ℹ Suggested fix +141 141 | else: +142 142 | return z +143 143 | return None + 144 |+ return None +144 145 | +145 146 | +146 147 | def prompts(self, foo): + +RET503.py:274:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +272 | return False +273 | +274 | for value in values: + | _____^ +275 | | print(value) + | |____________________^ RET503 + | + = help: Add explicit `return` statement + +ℹ Suggested fix +273 273 | +274 274 | for value in values: +275 275 | print(value) + 276 |+ return None +276 277 | +277 278 | +278 279 | def while_true(): + +RET503.py:291:13: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +289 | return 1 +290 | case 1: +291 | print() # error + | ^^^^^^^ RET503 + | + = help: Add explicit `return` statement + +ℹ Suggested fix +289 289 | return 1 +290 290 | case 1: +291 291 | print() # error + 292 |+ return None +292 293 | +293 294 | +294 295 | def foo(baz: str) -> str: + +RET503.py:300:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +298 | def end_of_statement(): +299 | def example(): +300 | if True: + | _________^ +301 | | return "" + | |_____________________^ RET503 + | + = help: Add explicit `return` statement + +ℹ Suggested fix +299 299 | def example(): +300 300 | if True: +301 301 | return "" + 302 |+ return None +302 303 | +303 304 | +304 305 | def example(): + +RET503.py:305:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +304 | def example(): +305 | if True: + | _________^ +306 | | return "" + | |_____________________^ RET503 + | + = help: Add explicit `return` statement + +ℹ Suggested fix +304 304 | def example(): +305 305 | if True: +306 306 | return "" + 307 |+ return None +307 308 | +308 309 | +309 310 | def example(): + +RET503.py:310:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +309 | def example(): +310 | if True: + | _________^ +311 | | return "" # type: ignore + | |_____________________^ RET503 + | + = help: Add explicit `return` statement + +ℹ Suggested fix +309 309 | def example(): +310 310 | if True: +311 311 | return "" # type: ignore + 312 |+ return None +312 313 | +313 314 | +314 315 | def example(): + +RET503.py:315:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +314 | def example(): +315 | if True: + | _________^ +316 | | return "" ; + | |_____________________^ RET503 + | + = help: Add explicit `return` statement + +ℹ Suggested fix +314 314 | def example(): +315 315 | if True: +316 316 | return "" ; + 317 |+ return None +317 318 | +318 319 | +319 320 | def example(): + +RET503.py:320:9: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +319 | def example(): +320 | if True: + | _________^ +321 | | return "" \ + | |_____________________^ RET503 +322 | ; # type: ignore + | + = help: Add explicit `return` statement + +ℹ Suggested fix +320 320 | if True: +321 321 | return "" \ +322 322 | ; # type: ignore + 323 |+ return None +323 324 | +324 325 | +325 326 | def end_of_file(): + +RET503.py:328:5: RET503 [*] Missing explicit `return` at the end of function able to return non-`None` value + | +326 | if False: +327 | return 1 +328 | x = 2 \ + | ^^^^^ RET503 + | + = help: Add explicit `return` statement + +ℹ Suggested fix +326 326 | if False: +327 327 | return 1 +328 328 | x = 2 \ + 329 |+ + 330 |+ return None + + diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET504_RET504.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET504_RET504.py.snap new file mode 100644 index 0000000000..0d2fea7fe3 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET504_RET504.py.snap @@ -0,0 +1,221 @@ +--- +source: crates/ruff_linter/src/rules/flake8_return/mod.rs +--- +RET504.py:6:12: RET504 [*] Unnecessary assignment to `a` before `return` statement + | +4 | def x(): +5 | a = 1 +6 | return a # RET504 + | ^ RET504 + | + = help: Remove unnecessary assignment + +ℹ Suggested fix +2 2 | # Errors +3 3 | ### +4 4 | def x(): +5 |- a = 1 +6 |- return a # RET504 + 5 |+ return 1 +7 6 | +8 7 | +9 8 | # Can be refactored false positives + +RET504.py:23:12: RET504 [*] Unnecessary assignment to `formatted` before `return` statement + | +21 | # clean up after any blank components +22 | formatted = formatted.replace("()", "").replace(" ", " ").strip() +23 | return formatted + | ^^^^^^^^^ RET504 + | + = help: Remove unnecessary assignment + +ℹ Suggested fix +19 19 | def x(): +20 20 | formatted = _USER_AGENT_FORMATTER.format(format_string, **values) +21 21 | # clean up after any blank components +22 |- formatted = formatted.replace("()", "").replace(" ", " ").strip() +23 |- return formatted + 22 |+ return formatted.replace("()", "").replace(" ", " ").strip() +24 23 | +25 24 | +26 25 | # https://github.com/afonasev/flake8-return/issues/47#issue-641117366 + +RET504.py:246:12: RET504 [*] Unnecessary assignment to `queryset` before `return` statement + | +244 | queryset = Model.filter(a=1) +245 | queryset = queryset.filter(c=3) +246 | return queryset + | ^^^^^^^^ RET504 + | + = help: Remove unnecessary assignment + +ℹ Suggested fix +242 242 | +243 243 | def get_queryset(): +244 244 | queryset = Model.filter(a=1) +245 |- queryset = queryset.filter(c=3) +246 |- return queryset + 245 |+ return queryset.filter(c=3) +247 246 | +248 247 | +249 248 | def get_queryset(): + +RET504.py:251:12: RET504 [*] Unnecessary assignment to `queryset` before `return` statement + | +249 | def get_queryset(): +250 | queryset = Model.filter(a=1) +251 | return queryset # RET504 + | ^^^^^^^^ RET504 + | + = help: Remove unnecessary assignment + +ℹ Suggested fix +247 247 | +248 248 | +249 249 | def get_queryset(): +250 |- queryset = Model.filter(a=1) +251 |- return queryset # RET504 + 250 |+ return Model.filter(a=1) +252 251 | +253 252 | +254 253 | # Function arguments + +RET504.py:269:12: RET504 [*] Unnecessary assignment to `val` before `return` statement + | +267 | return val +268 | val = 1 +269 | return val # RET504 + | ^^^ RET504 + | + = help: Remove unnecessary assignment + +ℹ Suggested fix +265 265 | def str_to_bool(val): +266 266 | if isinstance(val, bool): +267 267 | return val +268 |- val = 1 +269 |- return val # RET504 + 268 |+ return 1 +270 269 | +271 270 | +272 271 | def str_to_bool(val): + +RET504.py:321:12: RET504 [*] Unnecessary assignment to `x` before `return` statement + | +319 | with open("foo.txt", "r") as f: +320 | x = f.read() +321 | return x # RET504 + | ^ RET504 + | + = help: Remove unnecessary assignment + +ℹ Suggested fix +317 317 | # `with` statements +318 318 | def foo(): +319 319 | with open("foo.txt", "r") as f: +320 |- x = f.read() +321 |- return x # RET504 + 320 |+ return f.read() +322 321 | +323 322 | +324 323 | def foo(): + +RET504.py:342:12: RET504 [*] Unnecessary assignment to `b` before `return` statement + | +340 | a = 1 +341 | b=a +342 | return b # RET504 + | ^ RET504 + | + = help: Remove unnecessary assignment + +ℹ Suggested fix +338 338 | # Autofix cases +339 339 | def foo(): +340 340 | a = 1 +341 |- b=a +342 |- return b # RET504 + 341 |+ return a +343 342 | +344 343 | +345 344 | def foo(): + +RET504.py:348:12: RET504 [*] Unnecessary assignment to `b` before `return` statement + | +346 | a = 1 +347 | b =a +348 | return b # RET504 + | ^ RET504 + | + = help: Remove unnecessary assignment + +ℹ Suggested fix +344 344 | +345 345 | def foo(): +346 346 | a = 1 +347 |- b =a +348 |- return b # RET504 + 347 |+ return a +349 348 | +350 349 | +351 350 | def foo(): + +RET504.py:354:12: RET504 [*] Unnecessary assignment to `b` before `return` statement + | +352 | a = 1 +353 | b= a +354 | return b # RET504 + | ^ RET504 + | + = help: Remove unnecessary assignment + +ℹ Suggested fix +350 350 | +351 351 | def foo(): +352 352 | a = 1 +353 |- b= a +354 |- return b # RET504 + 353 |+ return a +355 354 | +356 355 | +357 356 | def foo(): + +RET504.py:359:12: RET504 [*] Unnecessary assignment to `a` before `return` statement + | +357 | def foo(): +358 | a = 1 # Comment +359 | return a + | ^ RET504 + | + = help: Remove unnecessary assignment + +ℹ Suggested fix +355 355 | +356 356 | +357 357 | def foo(): +358 |- a = 1 # Comment +359 |- return a + 358 |+ return 1 # Comment +360 359 | +361 360 | +362 361 | # Regression test for: https://github.com/astral-sh/ruff/issues/7098 + +RET504.py:365:12: RET504 [*] Unnecessary assignment to `D` before `return` statement + | +363 | def mavko_debari(P_kbar): +364 | D=0.4853881 + 3.6006116*P - 0.0117368*(P-1.3822)**2 +365 | return D + | ^ RET504 + | + = help: Remove unnecessary assignment + +ℹ Suggested fix +361 361 | +362 362 | # Regression test for: https://github.com/astral-sh/ruff/issues/7098 +363 363 | def mavko_debari(P_kbar): +364 |- D=0.4853881 + 3.6006116*P - 0.0117368*(P-1.3822)**2 +365 |- return D + 364 |+ return 0.4853881 + 3.6006116*P - 0.0117368*(P-1.3822)**2 + + 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 new file mode 100644 index 0000000000..6a694dcadc --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET505_RET505.py.snap @@ -0,0 +1,84 @@ +--- +source: crates/ruff_linter/src/rules/flake8_return/mod.rs +--- +RET505.py:8:5: RET505 Unnecessary `elif` after `return` statement + | + 6 | a = 1 + 7 | return y + 8 | elif z: + | ^^^^ RET505 + 9 | b = 2 +10 | return w + | + +RET505.py:23:5: RET505 Unnecessary `elif` after `return` statement + | +21 | b = 2 +22 | return +23 | elif z: + | ^^^^ RET505 +24 | c = 2 +25 | else: + | + +RET505.py:41:5: RET505 Unnecessary `elif` after `return` statement + | +39 | a = 1 +40 | return y +41 | elif z: + | ^^^^ RET505 +42 | b = 2 +43 | return w + | + +RET505.py:53:5: RET505 Unnecessary `else` after `return` statement + | +51 | a = 1 +52 | return y +53 | else: + | ^^^^ RET505 +54 | b = 2 +55 | return z + | + +RET505.py:64:9: RET505 Unnecessary `else` after `return` statement + | +62 | b = 2 +63 | return y +64 | else: + | ^^^^ RET505 +65 | c = 3 +66 | return x + | + +RET505.py:79:5: RET505 Unnecessary `else` after `return` statement + | +77 | b = 2 +78 | return +79 | else: + | ^^^^ RET505 +80 | c = 3 +81 | return + | + +RET505.py:89:9: RET505 Unnecessary `else` after `return` statement + | +87 | a = 4 +88 | return +89 | else: + | ^^^^ RET505 +90 | b = 2 +91 | else: + | + +RET505.py:99:5: RET505 Unnecessary `else` after `return` statement + | + 97 | if x: # [no-else-return] + 98 | return True + 99 | else: + | ^^^^ RET505 +100 | try: +101 | return False + | + + diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET506_RET506.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET506_RET506.py.snap new file mode 100644 index 0000000000..cc9b6eafa9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET506_RET506.py.snap @@ -0,0 +1,74 @@ +--- +source: crates/ruff_linter/src/rules/flake8_return/mod.rs +--- +RET506.py:8:5: RET506 Unnecessary `elif` after `raise` statement + | + 6 | a = 1 + 7 | raise Exception(y) + 8 | elif z: + | ^^^^ RET506 + 9 | b = 2 +10 | raise Exception(w) + | + +RET506.py:23:5: RET506 Unnecessary `elif` after `raise` statement + | +21 | b = 2 +22 | raise Exception(x) +23 | elif z: + | ^^^^ RET506 +24 | raise Exception(y) +25 | else: + | + +RET506.py:34:5: RET506 Unnecessary `else` after `raise` statement + | +32 | a = 1 +33 | raise Exception(y) +34 | else: + | ^^^^ RET506 +35 | b = 2 +36 | raise Exception(z) + | + +RET506.py:45:9: RET506 Unnecessary `else` after `raise` statement + | +43 | b = 2 +44 | raise Exception(y) +45 | else: + | ^^^^ RET506 +46 | c = 3 +47 | raise Exception(x) + | + +RET506.py:60:5: RET506 Unnecessary `else` after `raise` statement + | +58 | b = 2 +59 | raise Exception(x) +60 | else: + | ^^^^ RET506 +61 | c = 3 +62 | raise Exception(y) + | + +RET506.py:70:9: RET506 Unnecessary `else` after `raise` statement + | +68 | a = 4 +69 | raise Exception(x) +70 | else: + | ^^^^ RET506 +71 | b = 2 +72 | else: + | + +RET506.py:80:5: RET506 Unnecessary `else` after `raise` statement + | +78 | if x: # [no-else-raise] +79 | raise Exception(True) +80 | else: + | ^^^^ RET506 +81 | try: +82 | raise Exception(False) + | + + diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET507_RET507.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET507_RET507.py.snap new file mode 100644 index 0000000000..5776623e37 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET507_RET507.py.snap @@ -0,0 +1,73 @@ +--- +source: crates/ruff_linter/src/rules/flake8_return/mod.rs +--- +RET507.py:8:9: RET507 Unnecessary `elif` after `continue` statement + | + 6 | if i < y: # [no-else-continue] + 7 | continue + 8 | elif i < w: + | ^^^^ RET507 + 9 | continue +10 | else: + | + +RET507.py:22:9: RET507 Unnecessary `elif` after `continue` statement + | +20 | b = 2 +21 | continue +22 | elif z: + | ^^^^ RET507 +23 | c = 2 +24 | else: + | + +RET507.py:36:9: RET507 Unnecessary `else` after `continue` statement + | +34 | if i < y: # [no-else-continue] +35 | continue +36 | else: + | ^^^^ RET507 +37 | a = z + | + +RET507.py:47:13: RET507 Unnecessary `else` after `continue` statement + | +45 | b = 2 +46 | continue +47 | else: + | ^^^^ RET507 +48 | c = 3 +49 | continue + | + +RET507.py:63:9: RET507 Unnecessary `else` after `continue` statement + | +61 | b = 2 +62 | continue +63 | else: + | ^^^^ RET507 +64 | c = 3 +65 | continue + | + +RET507.py:74:13: RET507 Unnecessary `else` after `continue` statement + | +72 | a = 4 +73 | continue +74 | else: + | ^^^^ RET507 +75 | b = 2 +76 | else: + | + +RET507.py:85:9: RET507 Unnecessary `else` after `continue` statement + | +83 | if x: # [no-else-continue] +84 | continue +85 | else: + | ^^^^ RET507 +86 | try: +87 | return + | + + diff --git a/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET508_RET508.py.snap b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET508_RET508.py.snap new file mode 100644 index 0000000000..c5255d93d9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_return/snapshots/ruff_linter__rules__flake8_return__tests__RET508_RET508.py.snap @@ -0,0 +1,82 @@ +--- +source: crates/ruff_linter/src/rules/flake8_return/mod.rs +--- +RET508.py:8:9: RET508 Unnecessary `elif` after `break` statement + | + 6 | if i > y: # [no-else-break] + 7 | break + 8 | elif i > w: + | ^^^^ RET508 + 9 | break +10 | else: + | + +RET508.py:22:9: RET508 Unnecessary `elif` after `break` statement + | +20 | b = 2 +21 | break +22 | elif z: + | ^^^^ RET508 +23 | c = 2 +24 | else: + | + +RET508.py:33:9: RET508 Unnecessary `else` after `break` statement + | +31 | if i > y: # [no-else-break] +32 | break +33 | else: + | ^^^^ RET508 +34 | a = z + | + +RET508.py:44:13: RET508 Unnecessary `else` after `break` statement + | +42 | b = 2 +43 | break +44 | else: + | ^^^^ RET508 +45 | c = 3 +46 | break + | + +RET508.py:60:9: RET508 Unnecessary `else` after `break` statement + | +58 | b = 2 +59 | break +60 | else: + | ^^^^ RET508 +61 | c = 3 +62 | break + | + +RET508.py:71:13: RET508 Unnecessary `else` after `break` statement + | +69 | a = 4 +70 | break +71 | else: + | ^^^^ RET508 +72 | b = 2 +73 | else: + | + +RET508.py:82:9: RET508 Unnecessary `else` after `break` statement + | +80 | if x: # [no-else-break] +81 | break +82 | else: + | ^^^^ RET508 +83 | try: +84 | return + | + +RET508.py:158:13: RET508 Unnecessary `else` after `break` statement + | +156 | if i > w: +157 | break +158 | else: + | ^^^^ RET508 +159 | a = z + | + + diff --git a/crates/ruff/src/rules/flake8_return/visitor.rs b/crates/ruff_linter/src/rules/flake8_return/visitor.rs similarity index 100% rename from crates/ruff/src/rules/flake8_return/visitor.rs rename to crates/ruff_linter/src/rules/flake8_return/visitor.rs diff --git a/crates/ruff/src/rules/flake8_self/mod.rs b/crates/ruff_linter/src/rules/flake8_self/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_self/mod.rs rename to crates/ruff_linter/src/rules/flake8_self/mod.rs diff --git a/crates/ruff/src/rules/flake8_self/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_self/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_self/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_self/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_self/rules/private_member_access.rs b/crates/ruff_linter/src/rules/flake8_self/rules/private_member_access.rs similarity index 100% rename from crates/ruff/src/rules/flake8_self/rules/private_member_access.rs rename to crates/ruff_linter/src/rules/flake8_self/rules/private_member_access.rs diff --git a/crates/ruff/src/rules/flake8_self/settings.rs b/crates/ruff_linter/src/rules/flake8_self/settings.rs similarity index 100% rename from crates/ruff/src/rules/flake8_self/settings.rs rename to crates/ruff_linter/src/rules/flake8_self/settings.rs diff --git a/crates/ruff_linter/src/rules/flake8_self/snapshots/ruff_linter__rules__flake8_self__tests__ignore_names.snap b/crates/ruff_linter/src/rules/flake8_self/snapshots/ruff_linter__rules__flake8_self__tests__ignore_names.snap new file mode 100644 index 0000000000..f3f6136634 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_self/snapshots/ruff_linter__rules__flake8_self__tests__ignore_names.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/flake8_self/mod.rs +--- +SLF001_extended.py:6:5: SLF001 Private member accessed: `_asdict` + | +5 | def foo(obj): +6 | obj._asdict # SLF001 + | ^^^^^^^^^^^ SLF001 + | + +SLF001_extended.py:10:5: SLF001 Private member accessed: `_bar` + | + 9 | def foo(obj): +10 | obj._bar # SLF001 + | ^^^^^^^^ SLF001 + | + + 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 new file mode 100644 index 0000000000..2399883e42 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_self/snapshots/ruff_linter__rules__flake8_self__tests__private-member-access_SLF001.py.snap @@ -0,0 +1,111 @@ +--- +source: crates/ruff_linter/src/rules/flake8_self/mod.rs +--- +SLF001.py:34:12: SLF001 Private member accessed: `_private` + | +33 | def get_bar(): +34 | if self.bar._private: # SLF001 + | ^^^^^^^^^^^^^^^^^ SLF001 +35 | return None +36 | if self.bar()._private: # SLF001 + | + +SLF001.py:36:12: SLF001 Private member accessed: `_private` + | +34 | if self.bar._private: # SLF001 +35 | return None +36 | if self.bar()._private: # SLF001 + | ^^^^^^^^^^^^^^^^^^^ SLF001 +37 | return None +38 | if Bar._private_thing: # SLF001 + | + +SLF001.py:38:12: SLF001 Private member accessed: `_private_thing` + | +36 | if self.bar()._private: # SLF001 +37 | return None +38 | if Bar._private_thing: # SLF001 + | ^^^^^^^^^^^^^^^^^^ SLF001 +39 | return None +40 | if Foo._private_thing: + | + +SLF001.py:43:12: SLF001 Private member accessed: `_private_thing` + | +41 | return None +42 | Foo = Bar() +43 | if Foo._private_thing: # SLF001 + | ^^^^^^^^^^^^^^^^^^ SLF001 +44 | return None +45 | return self.bar + | + +SLF001.py:62:7: SLF001 Private member accessed: `_private_thing` + | +60 | foo = Foo() +61 | +62 | print(foo._private_thing) # SLF001 + | ^^^^^^^^^^^^^^^^^^ SLF001 +63 | print(foo.__really_private_thing) # SLF001 +64 | print(foo._private_func()) # SLF001 + | + +SLF001.py:63:7: SLF001 Private member accessed: `__really_private_thing` + | +62 | print(foo._private_thing) # SLF001 +63 | print(foo.__really_private_thing) # SLF001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ SLF001 +64 | print(foo._private_func()) # SLF001 +65 | print(foo.__really_private_func(1)) # SLF001 + | + +SLF001.py:64:7: SLF001 Private member accessed: `_private_func` + | +62 | print(foo._private_thing) # SLF001 +63 | print(foo.__really_private_thing) # SLF001 +64 | print(foo._private_func()) # SLF001 + | ^^^^^^^^^^^^^^^^^ SLF001 +65 | print(foo.__really_private_func(1)) # SLF001 +66 | print(foo.bar._private) # SLF001 + | + +SLF001.py:65:7: SLF001 Private member accessed: `__really_private_func` + | +63 | print(foo.__really_private_thing) # SLF001 +64 | print(foo._private_func()) # SLF001 +65 | print(foo.__really_private_func(1)) # SLF001 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SLF001 +66 | print(foo.bar._private) # SLF001 +67 | print(foo()._private_thing) # SLF001 + | + +SLF001.py:66:7: SLF001 Private member accessed: `_private` + | +64 | print(foo._private_func()) # SLF001 +65 | print(foo.__really_private_func(1)) # SLF001 +66 | print(foo.bar._private) # SLF001 + | ^^^^^^^^^^^^^^^^ SLF001 +67 | print(foo()._private_thing) # SLF001 +68 | print(foo()._private_thing__) # SLF001 + | + +SLF001.py:67:7: SLF001 Private member accessed: `_private_thing` + | +65 | print(foo.__really_private_func(1)) # SLF001 +66 | print(foo.bar._private) # SLF001 +67 | print(foo()._private_thing) # SLF001 + | ^^^^^^^^^^^^^^^^^^^^ SLF001 +68 | print(foo()._private_thing__) # SLF001 + | + +SLF001.py:68:7: SLF001 Private member accessed: `_private_thing__` + | +66 | print(foo.bar._private) # SLF001 +67 | print(foo()._private_thing) # SLF001 +68 | print(foo()._private_thing__) # SLF001 + | ^^^^^^^^^^^^^^^^^^^^^^ SLF001 +69 | +70 | print(foo.public_thing) + | + + diff --git a/crates/ruff/src/rules/flake8_simplify/mod.rs b/crates/ruff_linter/src/rules/flake8_simplify/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_simplify/mod.rs rename to crates/ruff_linter/src/rules/flake8_simplify/mod.rs diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_bool_op.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs similarity index 100% rename from crates/ruff/src/rules/flake8_simplify/rules/ast_bool_op.rs rename to crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_expr.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_expr.rs similarity index 100% rename from crates/ruff/src/rules/flake8_simplify/rules/ast_expr.rs rename to crates/ruff_linter/src/rules/flake8_simplify/rules/ast_expr.rs diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_if.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_if.rs similarity index 100% rename from crates/ruff/src/rules/flake8_simplify/rules/ast_if.rs rename to crates/ruff_linter/src/rules/flake8_simplify/rules/ast_if.rs diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_ifexp.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_ifexp.rs similarity index 100% rename from crates/ruff/src/rules/flake8_simplify/rules/ast_ifexp.rs rename to crates/ruff_linter/src/rules/flake8_simplify/rules/ast_ifexp.rs diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_unary_op.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs similarity index 100% rename from crates/ruff/src/rules/flake8_simplify/rules/ast_unary_op.rs rename to crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_with.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_with.rs similarity index 100% rename from crates/ruff/src/rules/flake8_simplify/rules/ast_with.rs rename to crates/ruff_linter/src/rules/flake8_simplify/rules/ast_with.rs diff --git a/crates/ruff/src/rules/flake8_simplify/rules/fix_if.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/fix_if.rs similarity index 100% rename from crates/ruff/src/rules/flake8_simplify/rules/fix_if.rs rename to crates/ruff_linter/src/rules/flake8_simplify/rules/fix_if.rs diff --git a/crates/ruff/src/rules/flake8_simplify/rules/fix_with.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/fix_with.rs similarity index 100% rename from crates/ruff/src/rules/flake8_simplify/rules/fix_with.rs rename to crates/ruff_linter/src/rules/flake8_simplify/rules/fix_with.rs diff --git a/crates/ruff/src/rules/flake8_simplify/rules/key_in_dict.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/key_in_dict.rs similarity index 100% rename from crates/ruff/src/rules/flake8_simplify/rules/key_in_dict.rs rename to crates/ruff_linter/src/rules/flake8_simplify/rules/key_in_dict.rs diff --git a/crates/ruff/src/rules/flake8_simplify/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_simplify/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_simplify/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_simplify/rules/open_file_with_context_handler.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/open_file_with_context_handler.rs similarity index 100% rename from crates/ruff/src/rules/flake8_simplify/rules/open_file_with_context_handler.rs rename to crates/ruff_linter/src/rules/flake8_simplify/rules/open_file_with_context_handler.rs diff --git a/crates/ruff/src/rules/flake8_simplify/rules/reimplemented_builtin.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs similarity index 100% rename from crates/ruff/src/rules/flake8_simplify/rules/reimplemented_builtin.rs rename to crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs diff --git a/crates/ruff/src/rules/flake8_simplify/rules/return_in_try_except_finally.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/return_in_try_except_finally.rs similarity index 100% rename from crates/ruff/src/rules/flake8_simplify/rules/return_in_try_except_finally.rs rename to crates/ruff_linter/src/rules/flake8_simplify/rules/return_in_try_except_finally.rs diff --git a/crates/ruff/src/rules/flake8_simplify/rules/suppressible_exception.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/suppressible_exception.rs similarity index 100% rename from crates/ruff/src/rules/flake8_simplify/rules/suppressible_exception.rs rename to crates/ruff_linter/src/rules/flake8_simplify/rules/suppressible_exception.rs diff --git a/crates/ruff/src/rules/flake8_simplify/rules/yoda_conditions.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/yoda_conditions.rs similarity index 100% rename from crates/ruff/src/rules/flake8_simplify/rules/yoda_conditions.rs rename to crates/ruff_linter/src/rules/flake8_simplify/rules/yoda_conditions.rs 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 new file mode 100644 index 0000000000..1368303ffa --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM101_SIM101.py.snap @@ -0,0 +1,149 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM101.py:1:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call + | +1 | if isinstance(a, int) or isinstance(a, float): # SIM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 +2 | pass + | + = help: Merge `isinstance` calls for `a` + +ℹ Suggested fix +1 |-if isinstance(a, int) or isinstance(a, float): # SIM101 + 1 |+if isinstance(a, (int, float)): # SIM101 +2 2 | pass +3 3 | +4 4 | if isinstance(a, (int, float)) or isinstance(a, bool): # SIM101 + +SIM101.py:4:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call + | +2 | pass +3 | +4 | if isinstance(a, (int, float)) or isinstance(a, bool): # SIM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 +5 | pass + | + = help: Merge `isinstance` calls for `a` + +ℹ Suggested fix +1 1 | if isinstance(a, int) or isinstance(a, float): # SIM101 +2 2 | pass +3 3 | +4 |-if isinstance(a, (int, float)) or isinstance(a, bool): # SIM101 + 4 |+if isinstance(a, (int, float, bool)): # SIM101 +5 5 | pass +6 6 | +7 7 | if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool): # SIM101 + +SIM101.py:7:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call + | +5 | pass +6 | +7 | if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool): # SIM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 +8 | pass + | + = help: Merge `isinstance` calls for `a` + +ℹ Suggested fix +4 4 | if isinstance(a, (int, float)) or isinstance(a, bool): # SIM101 +5 5 | pass +6 6 | +7 |-if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool): # SIM101 + 7 |+if isinstance(a, (int, float)) or isinstance(b, bool): # SIM101 +8 8 | pass +9 9 | +10 10 | if isinstance(b, bool) or isinstance(a, int) or isinstance(a, float): # SIM101 + +SIM101.py:10:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call + | + 8 | pass + 9 | +10 | if isinstance(b, bool) or isinstance(a, int) or isinstance(a, float): # SIM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 +11 | pass + | + = help: Merge `isinstance` calls for `a` + +ℹ Suggested fix +7 7 | if isinstance(a, int) or isinstance(a, float) or isinstance(b, bool): # SIM101 +8 8 | pass +9 9 | +10 |-if isinstance(b, bool) or isinstance(a, int) or isinstance(a, float): # SIM101 + 10 |+if isinstance(a, (int, float)) or isinstance(b, bool): # SIM101 +11 11 | pass +12 12 | +13 13 | if isinstance(a, int) or isinstance(b, bool) or isinstance(a, float): # SIM101 + +SIM101.py:13:4: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call + | +11 | pass +12 | +13 | if isinstance(a, int) or isinstance(b, bool) or isinstance(a, float): # SIM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 +14 | pass + | + = help: Merge `isinstance` calls for `a` + +ℹ Suggested fix +10 10 | if isinstance(b, bool) or isinstance(a, int) or isinstance(a, float): # SIM101 +11 11 | pass +12 12 | +13 |-if isinstance(a, int) or isinstance(b, bool) or isinstance(a, float): # SIM101 + 13 |+if isinstance(a, (int, float)) or isinstance(b, bool): # SIM101 +14 14 | pass +15 15 | +16 16 | if (isinstance(a, int) or isinstance(a, float)) and isinstance(b, bool): # SIM101 + +SIM101.py:16:5: SIM101 [*] Multiple `isinstance` calls for `a`, merge into a single call + | +14 | pass +15 | +16 | if (isinstance(a, int) or isinstance(a, float)) and isinstance(b, bool): # SIM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 +17 | pass + | + = help: Merge `isinstance` calls for `a` + +ℹ Suggested fix +13 13 | if isinstance(a, int) or isinstance(b, bool) or isinstance(a, float): # SIM101 +14 14 | pass +15 15 | +16 |-if (isinstance(a, int) or isinstance(a, float)) and isinstance(b, bool): # SIM101 + 16 |+if (isinstance(a, (int, float))) and isinstance(b, bool): # SIM101 +17 17 | pass +18 18 | +19 19 | if isinstance(a.b, int) or isinstance(a.b, float): # SIM101 + +SIM101.py:19:4: SIM101 [*] Multiple `isinstance` calls for expression, merge into a single call + | +17 | pass +18 | +19 | if isinstance(a.b, int) or isinstance(a.b, float): # SIM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 +20 | pass + | + = help: Merge `isinstance` calls + +ℹ Suggested fix +16 16 | if (isinstance(a, int) or isinstance(a, float)) and isinstance(b, bool): # SIM101 +17 17 | pass +18 18 | +19 |-if isinstance(a.b, int) or isinstance(a.b, float): # SIM101 + 19 |+if isinstance(a.b, (int, float)): # SIM101 +20 20 | pass +21 21 | +22 22 | if isinstance(a(), int) or isinstance(a(), float): # SIM101 + +SIM101.py:22:4: SIM101 Multiple `isinstance` calls for expression, merge into a single call + | +20 | pass +21 | +22 | if isinstance(a(), int) or isinstance(a(), float): # SIM101 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM101 +23 | pass + | + = help: Merge `isinstance` calls + + 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 new file mode 100644 index 0000000000..8f373fc0be --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM102_SIM102.py.snap @@ -0,0 +1,357 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM102.py:2:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements + | +1 | # SIM102 +2 | / if a: +3 | | if b: + | |_________^ SIM102 +4 | c + | + = help: Combine `if` statements using `and` + +ℹ Suggested fix +1 1 | # SIM102 +2 |-if a: +3 |- if b: +4 |- c + 2 |+if a and b: + 3 |+ c +5 4 | +6 5 | # SIM102 +7 6 | if a: + +SIM102.py:7:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements + | + 6 | # SIM102 + 7 | / if a: + 8 | | if b: + 9 | | if c: + | |_____________^ SIM102 +10 | d + | + = help: Combine `if` statements using `and` + +ℹ Suggested fix +4 4 | c +5 5 | +6 6 | # SIM102 +7 |-if a: +8 |- if b: +9 |- if c: +10 |- d + 7 |+if a and b: + 8 |+ if c: + 9 |+ d +11 10 | +12 11 | # SIM102 +13 12 | if a: + +SIM102.py:8:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements + | + 6 | # SIM102 + 7 | if a: + 8 | if b: + | _____^ + 9 | | if c: + | |_____________^ SIM102 +10 | d + | + = help: Combine `if` statements using `and` + +ℹ Suggested fix +5 5 | +6 6 | # SIM102 +7 7 | if a: +8 |- if b: +9 |- if c: +10 |- d + 8 |+ if b and c: + 9 |+ d +11 10 | +12 11 | # SIM102 +13 12 | if a: + +SIM102.py:15:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements + | +13 | if a: +14 | pass +15 | / elif b: +16 | | if c: + | |_________^ SIM102 +17 | d + | + = help: Combine `if` statements using `and` + +ℹ Suggested fix +12 12 | # SIM102 +13 13 | if a: +14 14 | pass +15 |-elif b: +16 |- if c: +17 |- d + 15 |+elif b and c: + 16 |+ d +18 17 | +19 18 | # SIM102 +20 19 | if a: + +SIM102.py:20:1: SIM102 Use a single `if` statement instead of nested `if` statements + | +19 | # SIM102 +20 | / if a: +21 | | # Unfixable due to placement of this comment. +22 | | if b: + | |_________^ SIM102 +23 | c + | + = help: Combine `if` statements using `and` + +SIM102.py:26:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements + | +25 | # SIM102 +26 | / if a: +27 | | if b: + | |_________^ SIM102 +28 | # Fixable due to placement of this comment. +29 | c + | + = help: Combine `if` statements using `and` + +ℹ Suggested fix +23 23 | c +24 24 | +25 25 | # SIM102 +26 |-if a: +27 |- if b: +28 |- # Fixable due to placement of this comment. +29 |- c + 26 |+if a and b: + 27 |+ # Fixable due to placement of this comment. + 28 |+ c +30 29 | +31 30 | # OK +32 31 | if a: + +SIM102.py:51:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements + | +49 | while x > 0: +50 | # SIM102 +51 | if y > 0: + | _____^ +52 | | if z > 0: + | |_________________^ SIM102 +53 | """this +54 | is valid""" + | + = help: Combine `if` statements using `and` + +ℹ Suggested fix +48 48 | +49 49 | while x > 0: +50 50 | # SIM102 +51 |- if y > 0: +52 |- if z > 0: +53 |- """this + 51 |+ if y > 0 and z > 0: + 52 |+ """this +54 53 | is valid""" +55 54 | +56 |- """the indentation on + 55 |+ """the indentation on +57 56 | this line is significant""" +58 57 | +59 |- "this is" \ + 58 |+ "this is" \ +60 59 | "allowed too" +61 60 | +62 |- ("so is" + 61 |+ ("so is" +63 62 | "this for some reason") +64 63 | +65 64 | + +SIM102.py:67:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements + | +66 | # SIM102 +67 | / if x > 0: +68 | | if y > 0: + | |_____________^ SIM102 +69 | """this +70 | is valid""" + | + = help: Combine `if` statements using `and` + +ℹ Suggested fix +64 64 | +65 65 | +66 66 | # SIM102 +67 |-if x > 0: +68 |- if y > 0: +69 |- """this + 67 |+if x > 0 and y > 0: + 68 |+ """this +70 69 | is valid""" +71 70 | +72 |- """the indentation on + 71 |+ """the indentation on +73 72 | this line is significant""" +74 73 | +75 |- "this is" \ + 74 |+ "this is" \ +76 75 | "allowed too" +77 76 | +78 |- ("so is" + 77 |+ ("so is" +79 78 | "this for some reason") +80 79 | +81 80 | while x > 0: + +SIM102.py:83:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements + | +81 | while x > 0: +82 | # SIM102 +83 | if node.module: + | _____^ +84 | | if node.module == "multiprocessing" or node.module.startswith( +85 | | "multiprocessing." +86 | | ): + | |__________^ SIM102 +87 | print("Bad module!") + | + = help: Combine `if` statements using `and` + +ℹ Suggested fix +80 80 | +81 81 | while x > 0: +82 82 | # SIM102 +83 |- if node.module: +84 |- if node.module == "multiprocessing" or node.module.startswith( +85 |- "multiprocessing." +86 |- ): +87 |- print("Bad module!") + 83 |+ if node.module and (node.module == "multiprocessing" or node.module.startswith( + 84 |+ "multiprocessing." + 85 |+ )): + 86 |+ print("Bad module!") +88 87 | +89 88 | # SIM102 (auto-fixable) +90 89 | if node.module012345678: + +SIM102.py:90:1: SIM102 [*] Use a single `if` statement instead of nested `if` statements + | +89 | # SIM102 (auto-fixable) +90 | / if node.module012345678: +91 | | if node.module == "multiprocß9💣2ℝ" or node.module.startswith( +92 | | "multiprocessing." +93 | | ): + | |______^ SIM102 +94 | print("Bad module!") + | + = help: Combine `if` statements using `and` + +ℹ Suggested fix +87 87 | print("Bad module!") +88 88 | +89 89 | # SIM102 (auto-fixable) +90 |-if node.module012345678: +91 |- if node.module == "multiprocß9💣2ℝ" or node.module.startswith( +92 |- "multiprocessing." +93 |- ): +94 |- print("Bad module!") + 90 |+if node.module012345678 and (node.module == "multiprocß9💣2ℝ" or node.module.startswith( + 91 |+ "multiprocessing." + 92 |+)): + 93 |+ print("Bad module!") +95 94 | +96 95 | # SIM102 (not auto-fixable) +97 96 | if node.module0123456789: + +SIM102.py:97:1: SIM102 Use a single `if` statement instead of nested `if` statements + | + 96 | # SIM102 (not auto-fixable) + 97 | / if node.module0123456789: + 98 | | if node.module == "multiprocß9💣2ℝ" or node.module.startswith( + 99 | | "multiprocessing." +100 | | ): + | |______^ SIM102 +101 | print("Bad module!") + | + = help: Combine `if` statements using `and` + +SIM102.py:106:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements + | +104 | # Regression test for https://github.com/apache/airflow/blob/145b16caaa43f0c42bffd97344df916c602cddde/airflow/configuration.py#L1161 +105 | if a: +106 | if b: + | _____^ +107 | | if c: + | |_____________^ SIM102 +108 | print("if") +109 | elif d: + | + = help: Combine `if` statements using `and` + +ℹ Suggested fix +103 103 | # SIM102 +104 104 | # Regression test for https://github.com/apache/airflow/blob/145b16caaa43f0c42bffd97344df916c602cddde/airflow/configuration.py#L1161 +105 105 | if a: +106 |- if b: +107 |- if c: +108 |- print("if") + 106 |+ if b and c: + 107 |+ print("if") +109 108 | elif d: +110 109 | print("elif") +111 110 | + +SIM102.py:132:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements + | +130 | if a: +131 | # SIM 102 +132 | if b: + | _____^ +133 | | if c: + | |_____________^ SIM102 +134 | print("foo") +135 | else: + | + = help: Combine `if` statements using `and` + +ℹ Suggested fix +129 129 | # OK +130 130 | if a: +131 131 | # SIM 102 +132 |- if b: +133 |- if c: +134 |- print("foo") + 132 |+ if b and c: + 133 |+ print("foo") +135 134 | else: +136 135 | print("bar") +137 136 | + +SIM102.py:165:5: SIM102 [*] Use a single `if` statement instead of nested `if` statements + | +163 | if a: +164 | pass +165 | elif b: + | _____^ +166 | | if c: + | |_____________^ SIM102 +167 | d + | + = help: Combine `if` statements using `and` + +ℹ Suggested fix +162 162 | def f(): +163 163 | if a: +164 164 | pass +165 |- elif b: +166 |- if c: +167 |- d + 165 |+ elif b and c: + 166 |+ 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 new file mode 100644 index 0000000000..b6eb3af562 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM103_SIM103.py.snap @@ -0,0 +1,133 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM103.py:3:5: SIM103 [*] Return the condition `a` directly + | +1 | def f(): +2 | # SIM103 +3 | if a: + | _____^ +4 | | return True +5 | | else: +6 | | return False + | |____________________^ SIM103 + | + = help: Replace with `return a` + +ℹ Suggested fix +1 1 | def f(): +2 2 | # SIM103 +3 |- if a: +4 |- return True +5 |- else: +6 |- return False + 3 |+ return bool(a) +7 4 | +8 5 | +9 6 | def f(): + +SIM103.py:11:5: SIM103 [*] Return the condition `a == b` directly + | + 9 | def f(): +10 | # SIM103 +11 | if a == b: + | _____^ +12 | | return True +13 | | else: +14 | | return False + | |____________________^ SIM103 + | + = help: Replace with `return a == b` + +ℹ Suggested fix +8 8 | +9 9 | def f(): +10 10 | # SIM103 +11 |- if a == b: +12 |- return True +13 |- else: +14 |- return False + 11 |+ return a == b +15 12 | +16 13 | +17 14 | def f(): + +SIM103.py:21:5: SIM103 [*] Return the condition `b` directly + | +19 | if a: +20 | return 1 +21 | elif b: + | _____^ +22 | | return True +23 | | else: +24 | | return False + | |____________________^ SIM103 + | + = help: Replace with `return b` + +ℹ Suggested fix +18 18 | # SIM103 +19 19 | if a: +20 20 | return 1 +21 |- elif b: +22 |- return True +23 |- else: +24 |- return False + 21 |+ return bool(b) +25 22 | +26 23 | +27 24 | def f(): + +SIM103.py:32:9: SIM103 [*] Return the condition `b` directly + | +30 | return 1 +31 | else: +32 | if b: + | _________^ +33 | | return True +34 | | else: +35 | | return False + | |________________________^ SIM103 + | + = help: Replace with `return b` + +ℹ Suggested fix +29 29 | if a: +30 30 | return 1 +31 31 | else: +32 |- if b: +33 |- return True +34 |- else: +35 |- return False + 32 |+ return bool(b) +36 33 | +37 34 | +38 35 | def f(): + +SIM103.py:57:5: SIM103 Return the condition `a` directly + | +55 | def f(): +56 | # SIM103 (but not fixable) +57 | if a: + | _____^ +58 | | return False +59 | | else: +60 | | return True + | |___________________^ SIM103 + | + = help: Replace with `return a` + +SIM103.py:83:5: SIM103 Return the condition `a` directly + | +81 | def bool(): +82 | return False +83 | if a: + | _____^ +84 | | return True +85 | | else: +86 | | return False + | |____________________^ SIM103 + | + = help: Replace with `return a` + + 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 new file mode 100644 index 0000000000..747d835818 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_0.py.snap @@ -0,0 +1,294 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM105_0.py:6:1: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` + | +5 | # SIM105 +6 | / try: +7 | | foo() +8 | | except ValueError: +9 | | pass + | |________^ SIM105 + | + = help: Replace with `contextlib.suppress(ValueError)` + +ℹ Suggested fix + 1 |+import contextlib +1 2 | def foo(): +2 3 | pass +3 4 | +4 5 | +5 6 | # SIM105 +6 |-try: + 7 |+with contextlib.suppress(ValueError): +7 8 | foo() +8 |-except ValueError: +9 |- pass +10 9 | +11 10 | +12 11 | # SIM105 + +SIM105_0.py:13:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` + | +12 | # SIM105 +13 | / try: +14 | | foo() +15 | | except (ValueError, OSError): +16 | | pass + | |________^ SIM105 +17 | +18 | # SIM105 + | + = help: Replace with `contextlib.suppress(ValueError, OSError)` + +ℹ Suggested fix + 1 |+import contextlib +1 2 | def foo(): +2 3 | pass +3 4 | +-------------------------------------------------------------------------------- +10 11 | +11 12 | +12 13 | # SIM105 +13 |-try: + 14 |+with contextlib.suppress(ValueError, OSError): +14 15 | foo() +15 |-except (ValueError, OSError): +16 |- pass +17 16 | +18 17 | # SIM105 +19 18 | try: + +SIM105_0.py:19:1: SIM105 [*] Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` + | +18 | # SIM105 +19 | / try: +20 | | foo() +21 | | except (ValueError, OSError) as e: +22 | | pass + | |________^ SIM105 +23 | +24 | # SIM105 + | + = help: Replace with `contextlib.suppress(ValueError, OSError)` + +ℹ Suggested fix + 1 |+import contextlib +1 2 | def foo(): +2 3 | pass +3 4 | +-------------------------------------------------------------------------------- +16 17 | pass +17 18 | +18 19 | # SIM105 +19 |-try: + 20 |+with contextlib.suppress(ValueError, OSError): +20 21 | foo() +21 |-except (ValueError, OSError) as e: +22 |- pass +23 22 | +24 23 | # SIM105 +25 24 | try: + +SIM105_0.py:25:1: SIM105 [*] Use `contextlib.suppress(Exception)` instead of `try`-`except`-`pass` + | +24 | # SIM105 +25 | / try: +26 | | foo() +27 | | except: +28 | | pass + | |________^ SIM105 +29 | +30 | # SIM105 + | + = help: Replace with `contextlib.suppress(Exception)` + +ℹ Suggested fix + 1 |+import contextlib +1 2 | def foo(): +2 3 | pass +3 4 | +-------------------------------------------------------------------------------- +22 23 | pass +23 24 | +24 25 | # SIM105 +25 |-try: + 26 |+with contextlib.suppress(Exception): +26 27 | foo() +27 |-except: +28 |- pass +29 28 | +30 29 | # SIM105 +31 30 | try: + +SIM105_0.py:31:1: SIM105 [*] Use `contextlib.suppress(a.Error, b.Error)` instead of `try`-`except`-`pass` + | +30 | # SIM105 +31 | / try: +32 | | foo() +33 | | except (a.Error, b.Error): +34 | | pass + | |________^ SIM105 +35 | +36 | # OK + | + = help: Replace with `contextlib.suppress(a.Error, b.Error)` + +ℹ Suggested fix + 1 |+import contextlib +1 2 | def foo(): +2 3 | pass +3 4 | +-------------------------------------------------------------------------------- +28 29 | pass +29 30 | +30 31 | # SIM105 +31 |-try: + 32 |+with contextlib.suppress(a.Error, b.Error): +32 33 | foo() +33 |-except (a.Error, b.Error): +34 |- pass +35 34 | +36 35 | # OK +37 36 | try: + +SIM105_0.py:85:5: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` + | +83 | def with_ellipsis(): +84 | # OK +85 | try: + | _____^ +86 | | foo() +87 | | except ValueError: +88 | | ... + | |___________^ SIM105 + | + = help: Replace with `contextlib.suppress(ValueError)` + +ℹ Suggested fix + 1 |+import contextlib +1 2 | def foo(): +2 3 | pass +3 4 | +-------------------------------------------------------------------------------- +82 83 | +83 84 | def with_ellipsis(): +84 85 | # OK +85 |- try: + 86 |+ with contextlib.suppress(ValueError): +86 87 | foo() +87 |- except ValueError: +88 |- ... +89 88 | +90 89 | +91 90 | def with_ellipsis_and_return(): + +SIM105_0.py:100:5: SIM105 Use `contextlib.suppress(ValueError, OSError)` instead of `try`-`except`-`pass` + | + 99 | def with_comment(): +100 | try: + | _____^ +101 | | foo() +102 | | except (ValueError, OSError): +103 | | pass # Trailing comment. + | |____________^ SIM105 +104 | +105 | try: + | + = help: Replace with `contextlib.suppress(ValueError, OSError)` + +SIM105_0.py:117:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass` + | +115 | # Regression test for: https://github.com/astral-sh/ruff/issues/7123 +116 | def write_models(directory, Models): +117 | try: + | _____^ +118 | | os.makedirs(model_dir); +119 | | except OSError: +120 | | pass; + | |____________^ SIM105 +121 | +122 | try: os.makedirs(model_dir); + | + = help: Replace with `contextlib.suppress(OSError)` + +ℹ Suggested fix + 1 |+import contextlib +1 2 | def foo(): +2 3 | pass +3 4 | +-------------------------------------------------------------------------------- +114 115 | +115 116 | # Regression test for: https://github.com/astral-sh/ruff/issues/7123 +116 117 | def write_models(directory, Models): +117 |- try: + 118 |+ with contextlib.suppress(OSError): +118 119 | os.makedirs(model_dir); +119 |- except OSError: +120 |- pass; +121 120 | +122 121 | try: os.makedirs(model_dir); +123 122 | except OSError: + +SIM105_0.py:122:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass` + | +120 | pass; +121 | +122 | try: os.makedirs(model_dir); + | _____^ +123 | | except OSError: +124 | | pass; + | |____________^ SIM105 +125 | +126 | try: os.makedirs(model_dir); + | + = help: Replace with `contextlib.suppress(OSError)` + +ℹ Suggested fix + 1 |+import contextlib +1 2 | def foo(): +2 3 | pass +3 4 | +-------------------------------------------------------------------------------- +119 120 | except OSError: +120 121 | pass; +121 122 | +122 |- try: os.makedirs(model_dir); +123 |- except OSError: +124 |- pass; + 123 |+ with contextlib.suppress(OSError): os.makedirs(model_dir); +125 124 | +126 125 | try: os.makedirs(model_dir); +127 126 | except OSError: + +SIM105_0.py:126:5: SIM105 [*] Use `contextlib.suppress(OSError)` instead of `try`-`except`-`pass` + | +124 | pass; +125 | +126 | try: os.makedirs(model_dir); + | _____^ +127 | | except OSError: +128 | | pass; \ + | |____________^ SIM105 +129 | \ +130 | # + | + = help: Replace with `contextlib.suppress(OSError)` + +ℹ Suggested fix + 1 |+import contextlib +1 2 | def foo(): +2 3 | pass +3 4 | +-------------------------------------------------------------------------------- +123 124 | except OSError: +124 125 | pass; +125 126 | +126 |- try: os.makedirs(model_dir); +127 |- except OSError: +128 |- pass; \ + 127 |+ with contextlib.suppress(OSError): os.makedirs(model_dir); +129 128 | \ +130 129 | # + + diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_1.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_1.py.snap new file mode 100644 index 0000000000..e7eba1d76e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_1.py.snap @@ -0,0 +1,27 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM105_1.py:5:1: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` + | +4 | # SIM105 +5 | / try: +6 | | math.sqrt(-1) +7 | | except ValueError: +8 | | pass + | |________^ SIM105 + | + = help: Replace with `contextlib.suppress(ValueError)` + +ℹ Suggested fix +1 1 | """Case: There's a random import, so it should add `contextlib` after it.""" +2 2 | import math + 3 |+import contextlib +3 4 | +4 5 | # SIM105 +5 |-try: + 6 |+with contextlib.suppress(ValueError): +6 7 | math.sqrt(-1) +7 |-except ValueError: +8 |- pass + + diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_2.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_2.py.snap new file mode 100644 index 0000000000..adf563480a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_2.py.snap @@ -0,0 +1,25 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM105_2.py:10:1: SIM105 [*] Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` + | + 9 | # SIM105 +10 | / try: +11 | | foo() +12 | | except ValueError: +13 | | pass + | |________^ SIM105 + | + = help: Replace with `contextlib.suppress(ValueError)` + +ℹ Suggested fix +7 7 | +8 8 | +9 9 | # SIM105 +10 |-try: + 10 |+with contextlib.suppress(ValueError): +11 11 | foo() +12 |-except ValueError: +13 |- pass + + 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 new file mode 100644 index 0000000000..b2ba1e9f87 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM105_SIM105_3.py.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM105_3.py:10:5: SIM105 Use `contextlib.suppress(ValueError)` instead of `try`-`except`-`pass` + | + 8 | def bar(): + 9 | # SIM105 +10 | try: + | _____^ +11 | | foo() +12 | | except ValueError: +13 | | pass + | |____________^ SIM105 + | + = help: Replace with `contextlib.suppress(ValueError)` + + diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM107_SIM107.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM107_SIM107.py.snap new file mode 100644 index 0000000000..c878e47f24 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM107_SIM107.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM107.py:9:9: SIM107 Don't use `return` in `try`-`except` and `finally` + | +7 | return "2" +8 | finally: +9 | return "3" + | ^^^^^^^^^^ SIM107 + | + + 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 new file mode 100644 index 0000000000..c4aad0339a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM108_SIM108.py.snap @@ -0,0 +1,122 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM108.py:2:1: SIM108 [*] Use ternary operator `b = c if a else d` instead of `if`-`else`-block + | +1 | # SIM108 +2 | / if a: +3 | | b = c +4 | | else: +5 | | b = d + | |_________^ SIM108 +6 | +7 | # OK + | + = help: Replace `if`-`else`-block with `b = c if a else d` + +ℹ Suggested fix +1 1 | # SIM108 +2 |-if a: +3 |- b = c +4 |-else: +5 |- b = d + 2 |+b = c if a else d +6 3 | +7 4 | # OK +8 5 | b = c if a else d + +SIM108.py:30:5: SIM108 [*] Use ternary operator `b = 1 if a else 2` instead of `if`-`else`-block + | +28 | pass +29 | else: +30 | if a: + | _____^ +31 | | b = 1 +32 | | else: +33 | | b = 2 + | |_____________^ SIM108 + | + = help: Replace `if`-`else`-block with `b = 1 if a else 2` + +ℹ Suggested fix +27 27 | if True: +28 28 | pass +29 29 | else: +30 |- if a: +31 |- b = 1 +32 |- else: +33 |- b = 2 + 30 |+ b = 1 if a else 2 +34 31 | +35 32 | +36 33 | import sys + +SIM108.py:58:1: SIM108 Use ternary operator `abc = x if x > 0 else -x` instead of `if`-`else`-block + | +57 | # SIM108 (without fix due to comments) +58 | / if x > 0: +59 | | # test test +60 | | abc = x +61 | | else: +62 | | # test test test +63 | | abc = -x + | |____________^ SIM108 + | + = help: Replace `if`-`else`-block with `abc = x if x > 0 else -x` + +SIM108.py:82:1: SIM108 [*] Use ternary operator `b = "cccccccccccccccccccccccccccccccccß" if a else "ddddddddddddddddddddddddddddddddd💣"` instead of `if`-`else`-block + | +81 | # SIM108 +82 | / if a: +83 | | b = "cccccccccccccccccccccccccccccccccß" +84 | | else: +85 | | b = "ddddddddddddddddddddddddddddddddd💣" + | |_____________________________________________^ SIM108 + | + = help: Replace `if`-`else`-block with `b = "cccccccccccccccccccccccccccccccccß" if a else "ddddddddddddddddddddddddddddddddd💣"` + +ℹ Suggested fix +79 79 | +80 80 | +81 81 | # SIM108 +82 |-if a: +83 |- b = "cccccccccccccccccccccccccccccccccß" +84 |-else: +85 |- b = "ddddddddddddddddddddddddddddddddd💣" + 82 |+b = "cccccccccccccccccccccccccccccccccß" if a else "ddddddddddddddddddddddddddddddddd💣" +86 83 | +87 84 | +88 85 | # OK (too long) + +SIM108.py:105:1: SIM108 Use ternary operator `exitcode = 0 if True else 1` instead of `if`-`else`-block + | +104 | # SIM108 (without fix due to trailing comment) +105 | / if True: +106 | | exitcode = 0 +107 | | else: +108 | | exitcode = 1 # Trailing comment + | |________________^ SIM108 + | + = help: Replace `if`-`else`-block with `exitcode = 0 if True else 1` + +SIM108.py:112:1: SIM108 Use ternary operator `x = 3 if True else 5` instead of `if`-`else`-block + | +111 | # SIM108 +112 | / if True: x = 3 # Foo +113 | | else: x = 5 + | |___________^ SIM108 + | + = help: Replace `if`-`else`-block with `x = 3 if True else 5` + +SIM108.py:117:1: SIM108 Use ternary operator `x = 3 if True else 5` instead of `if`-`else`-block + | +116 | # SIM108 +117 | / if True: # Foo +118 | | x = 3 +119 | | else: +120 | | x = 5 + | |_________^ SIM108 + | + = help: Replace `if`-`else`-block with `x = 3 if True else 5` + + diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM109_SIM109.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM109_SIM109.py.snap new file mode 100644 index 0000000000..fd8700afba --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM109_SIM109.py.snap @@ -0,0 +1,78 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM109.py:2:4: SIM109 [*] Use `a in (b, c)` instead of multiple equality comparisons + | +1 | # SIM109 +2 | if a == b or a == c: + | ^^^^^^^^^^^^^^^^ SIM109 +3 | d + | + = help: Replace with `a in (b, c)` + +ℹ Suggested fix +1 1 | # SIM109 +2 |-if a == b or a == c: + 2 |+if a in (b, c): +3 3 | d +4 4 | +5 5 | # SIM109 + +SIM109.py:6:5: SIM109 [*] Use `a in (b, c)` instead of multiple equality comparisons + | +5 | # SIM109 +6 | if (a == b or a == c) and None: + | ^^^^^^^^^^^^^^^^ SIM109 +7 | d + | + = help: Replace with `a in (b, c)` + +ℹ Suggested fix +3 3 | d +4 4 | +5 5 | # SIM109 +6 |-if (a == b or a == c) and None: + 6 |+if (a in (b, c)) and None: +7 7 | d +8 8 | +9 9 | # SIM109 + +SIM109.py:10:4: SIM109 [*] Use `a in (b, c)` instead of multiple equality comparisons + | + 9 | # SIM109 +10 | if a == b or a == c or None: + | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM109 +11 | d + | + = help: Replace with `a in (b, c)` + +ℹ Suggested fix +7 7 | d +8 8 | +9 9 | # SIM109 +10 |-if a == b or a == c or None: + 10 |+if a in (b, c) or None: +11 11 | d +12 12 | +13 13 | # SIM109 + +SIM109.py:14:4: SIM109 [*] Use `a in (b, c)` instead of multiple equality comparisons + | +13 | # SIM109 +14 | if a == b or None or a == c: + | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM109 +15 | d + | + = help: Replace with `a in (b, c)` + +ℹ Suggested fix +11 11 | d +12 12 | +13 13 | # SIM109 +14 |-if a == b or None or a == c: + 14 |+if a in (b, c) or None: +15 15 | d +16 16 | +17 17 | # OK + + 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 new file mode 100644 index 0000000000..1473e4bfda --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM110.py.snap @@ -0,0 +1,320 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +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: + | _____^ +4 | | if check(x): +5 | | return True +6 | | return False + | |________________^ SIM110 + | + = help: Replace with `return any(check(x) for x in iterable)` + +ℹ Suggested fix +1 1 | def f(): +2 2 | # SIM110 +3 |- for x in iterable: +4 |- if check(x): +5 |- return True +6 |- return False + 3 |+ return any(check(x) for x in iterable) +7 4 | +8 5 | +9 6 | def f(): + +SIM110.py:25:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop + | +23 | def f(): +24 | # SIM111 +25 | for x in iterable: + | _____^ +26 | | if check(x): +27 | | return False +28 | | return True + | |_______________^ SIM110 + | + = help: Replace with `return all(not check(x) for x in iterable)` + +ℹ Suggested fix +22 22 | +23 23 | def f(): +24 24 | # SIM111 +25 |- for x in iterable: +26 |- if check(x): +27 |- return False +28 |- return True + 25 |+ return all(not check(x) for x in iterable) +29 26 | +30 27 | +31 28 | def f(): + +SIM110.py:33:5: SIM110 [*] Use `return all(x.is_empty() for x in iterable)` instead of `for` loop + | +31 | def f(): +32 | # SIM111 +33 | for x in iterable: + | _____^ +34 | | if not x.is_empty(): +35 | | return False +36 | | return True + | |_______________^ SIM110 + | + = help: Replace with `return all(x.is_empty() for x in iterable)` + +ℹ Suggested fix +30 30 | +31 31 | def f(): +32 32 | # SIM111 +33 |- for x in iterable: +34 |- if not x.is_empty(): +35 |- return False +36 |- return True + 33 |+ return all(x.is_empty() for x in iterable) +37 34 | +38 35 | +39 36 | def f(): + +SIM110.py:55:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop + | +53 | def f(): +54 | # SIM110 +55 | for x in iterable: + | _____^ +56 | | if check(x): +57 | | return True +58 | | else: +59 | | return False + | |____________________^ SIM110 + | + = help: Replace with `return any(check(x) for x in iterable)` + +ℹ Suggested fix +52 52 | +53 53 | def f(): +54 54 | # SIM110 +55 |- for x in iterable: +56 |- if check(x): +57 |- return True +58 |- else: +59 |- return False + 55 |+ return any(check(x) for x in iterable) +60 56 | +61 57 | +62 58 | def f(): + +SIM110.py:64:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop + | +62 | def f(): +63 | # SIM111 +64 | for x in iterable: + | _____^ +65 | | if check(x): +66 | | return False +67 | | else: +68 | | return True + | |___________________^ SIM110 + | + = help: Replace with `return all(not check(x) for x in iterable)` + +ℹ Suggested fix +61 61 | +62 62 | def f(): +63 63 | # SIM111 +64 |- for x in iterable: +65 |- if check(x): +66 |- return False +67 |- else: +68 |- return True + 64 |+ return all(not check(x) for x in iterable) +69 65 | +70 66 | +71 67 | def f(): + +SIM110.py:73:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop + | +71 | def f(): +72 | # SIM110 +73 | for x in iterable: + | _____^ +74 | | if check(x): +75 | | return True +76 | | else: +77 | | return False + | |____________________^ SIM110 +78 | return True + | + = help: Replace with `return any(check(x) for x in iterable)` + +ℹ Suggested fix +70 70 | +71 71 | def f(): +72 72 | # SIM110 +73 |- for x in iterable: +74 |- if check(x): +75 |- return True +76 |- else: +77 |- return False + 73 |+ return any(check(x) for x in iterable) +78 74 | return True +79 75 | +80 76 | + +SIM110.py:83:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop + | +81 | def f(): +82 | # SIM111 +83 | for x in iterable: + | _____^ +84 | | if check(x): +85 | | return False +86 | | else: +87 | | return True + | |___________________^ SIM110 +88 | return False + | + = help: Replace with `return all(not check(x) for x in iterable)` + +ℹ Suggested fix +80 80 | +81 81 | def f(): +82 82 | # SIM111 +83 |- for x in iterable: +84 |- if check(x): +85 |- return False +86 |- else: +87 |- return True + 83 |+ return all(not check(x) for x in iterable) +88 84 | return False +89 85 | +90 86 | + +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: + | _____^ +125 | | if check(x): +126 | | return True +127 | | return False + | |________________^ SIM110 + | + = help: Replace with `return any(check(x) for x in iterable)` + +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: + | _____^ +135 | | if check(x): +136 | | return False +137 | | return True + | |_______________^ SIM110 + | + = help: Replace with `return all(not check(x) for x in iterable)` + +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: + | _____^ +145 | | if check(x): +146 | | return True +147 | | return False + | |________________^ SIM110 + | + = help: Replace with `return any(check(x) for x in iterable)` + +ℹ Suggested fix +141 141 | x = 1 +142 142 | +143 143 | # SIM110 +144 |- for x in iterable: +145 |- if check(x): +146 |- return True +147 |- return False + 144 |+ return any(check(x) for x in iterable) +148 145 | +149 146 | +150 147 | def f(): + +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: + | _____^ +155 | | if check(x): +156 | | return False +157 | | return True + | |_______________^ SIM110 + | + = help: Replace with `return all(not check(x) for x in iterable)` + +ℹ Suggested fix +151 151 | x = 1 +152 152 | +153 153 | # SIM111 +154 |- for x in iterable: +155 |- if check(x): +156 |- return False +157 |- return True + 154 |+ return all(not check(x) for x in iterable) +158 155 | +159 156 | +160 157 | def f(): + +SIM110.py:162:5: SIM110 [*] Use `return any(x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ")` instead of `for` loop + | +160 | def f(): +161 | # SIM110 +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 + | |________________^ SIM110 + | + = help: Replace with `return any(x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ")` + +ℹ Suggested fix +159 159 | +160 160 | def f(): +161 161 | # SIM110 +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 + 162 |+ return any(x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ") +166 163 | +167 164 | +168 165 | def f(): + +SIM110.py:184:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop + | +182 | async def f(): +183 | # SIM110 +184 | for x in iterable: + | _____^ +185 | | if check(x): +186 | | return True +187 | | return False + | |________________^ SIM110 + | + = help: Replace with `return any(check(x) for x in iterable)` + +ℹ Suggested fix +181 181 | +182 182 | async def f(): +183 183 | # SIM110 +184 |- for x in iterable: +185 |- if check(x): +186 |- return True +187 |- return False + 184 |+ return any(check(x) for x in 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 new file mode 100644 index 0000000000..85c7002246 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM110_SIM111.py.snap @@ -0,0 +1,349 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +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: + | _____^ +4 | | if check(x): +5 | | return True +6 | | return False + | |________________^ SIM110 + | + = help: Replace with `return any(check(x) for x in iterable)` + +ℹ Suggested fix +1 1 | def f(): +2 2 | # SIM110 +3 |- for x in iterable: +4 |- if check(x): +5 |- return True +6 |- return False + 3 |+ return any(check(x) for x in iterable) +7 4 | +8 5 | +9 6 | def f(): + +SIM111.py:25:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop + | +23 | def f(): +24 | # SIM111 +25 | for x in iterable: + | _____^ +26 | | if check(x): +27 | | return False +28 | | return True + | |_______________^ SIM110 + | + = help: Replace with `return all(not check(x) for x in iterable)` + +ℹ Suggested fix +22 22 | +23 23 | def f(): +24 24 | # SIM111 +25 |- for x in iterable: +26 |- if check(x): +27 |- return False +28 |- return True + 25 |+ return all(not check(x) for x in iterable) +29 26 | +30 27 | +31 28 | def f(): + +SIM111.py:33:5: SIM110 [*] Use `return all(x.is_empty() for x in iterable)` instead of `for` loop + | +31 | def f(): +32 | # SIM111 +33 | for x in iterable: + | _____^ +34 | | if not x.is_empty(): +35 | | return False +36 | | return True + | |_______________^ SIM110 + | + = help: Replace with `return all(x.is_empty() for x in iterable)` + +ℹ Suggested fix +30 30 | +31 31 | def f(): +32 32 | # SIM111 +33 |- for x in iterable: +34 |- if not x.is_empty(): +35 |- return False +36 |- return True + 33 |+ return all(x.is_empty() for x in iterable) +37 34 | +38 35 | +39 36 | def f(): + +SIM111.py:55:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop + | +53 | def f(): +54 | # SIM110 +55 | for x in iterable: + | _____^ +56 | | if check(x): +57 | | return True +58 | | else: +59 | | return False + | |____________________^ SIM110 + | + = help: Replace with `return any(check(x) for x in iterable)` + +ℹ Suggested fix +52 52 | +53 53 | def f(): +54 54 | # SIM110 +55 |- for x in iterable: +56 |- if check(x): +57 |- return True +58 |- else: +59 |- return False + 55 |+ return any(check(x) for x in iterable) +60 56 | +61 57 | +62 58 | def f(): + +SIM111.py:64:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop + | +62 | def f(): +63 | # SIM111 +64 | for x in iterable: + | _____^ +65 | | if check(x): +66 | | return False +67 | | else: +68 | | return True + | |___________________^ SIM110 + | + = help: Replace with `return all(not check(x) for x in iterable)` + +ℹ Suggested fix +61 61 | +62 62 | def f(): +63 63 | # SIM111 +64 |- for x in iterable: +65 |- if check(x): +66 |- return False +67 |- else: +68 |- return True + 64 |+ return all(not check(x) for x in iterable) +69 65 | +70 66 | +71 67 | def f(): + +SIM111.py:73:5: SIM110 [*] Use `return any(check(x) for x in iterable)` instead of `for` loop + | +71 | def f(): +72 | # SIM110 +73 | for x in iterable: + | _____^ +74 | | if check(x): +75 | | return True +76 | | else: +77 | | return False + | |____________________^ SIM110 +78 | return True + | + = help: Replace with `return any(check(x) for x in iterable)` + +ℹ Suggested fix +70 70 | +71 71 | def f(): +72 72 | # SIM110 +73 |- for x in iterable: +74 |- if check(x): +75 |- return True +76 |- else: +77 |- return False + 73 |+ return any(check(x) for x in iterable) +78 74 | return True +79 75 | +80 76 | + +SIM111.py:83:5: SIM110 [*] Use `return all(not check(x) for x in iterable)` instead of `for` loop + | +81 | def f(): +82 | # SIM111 +83 | for x in iterable: + | _____^ +84 | | if check(x): +85 | | return False +86 | | else: +87 | | return True + | |___________________^ SIM110 +88 | return False + | + = help: Replace with `return all(not check(x) for x in iterable)` + +ℹ Suggested fix +80 80 | +81 81 | def f(): +82 82 | # SIM111 +83 |- for x in iterable: +84 |- if check(x): +85 |- return False +86 |- else: +87 |- return True + 83 |+ return all(not check(x) for x in iterable) +88 84 | return False +89 85 | +90 86 | + +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: + | _____^ +125 | | if check(x): +126 | | return True +127 | | return False + | |________________^ SIM110 + | + = help: Replace with `return any(check(x) for x in iterable)` + +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: + | _____^ +135 | | if check(x): +136 | | return False +137 | | return True + | |_______________^ SIM110 + | + = help: Replace with `return all(not check(x) for x in iterable)` + +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: + | _____^ +145 | | if check(x): +146 | | return True +147 | | return False + | |________________^ SIM110 + | + = help: Replace with `return any(check(x) for x in iterable)` + +ℹ Suggested fix +141 141 | x = 1 +142 142 | +143 143 | # SIM110 +144 |- for x in iterable: +145 |- if check(x): +146 |- return True +147 |- return False + 144 |+ return any(check(x) for x in iterable) +148 145 | +149 146 | +150 147 | def f(): + +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: + | _____^ +155 | | if check(x): +156 | | return False +157 | | return True + | |_______________^ SIM110 + | + = help: Replace with `return all(not check(x) for x in iterable)` + +ℹ Suggested fix +151 151 | x = 1 +152 152 | +153 153 | # SIM111 +154 |- for x in iterable: +155 |- if check(x): +156 |- return False +157 |- return True + 154 |+ return all(not check(x) for x in iterable) +158 155 | +159 156 | +160 157 | def f(): + +SIM111.py:162:5: SIM110 [*] Use `return all(x in y for x in iterable)` instead of `for` loop + | +160 | def f(): +161 | # SIM111 +162 | for x in iterable: + | _____^ +163 | | if x not in y: +164 | | return False +165 | | return True + | |_______________^ SIM110 + | + = help: Replace with `return all(x in y for x in iterable)` + +ℹ Suggested fix +159 159 | +160 160 | def f(): +161 161 | # SIM111 +162 |- for x in iterable: +163 |- if x not in y: +164 |- return False +165 |- return True + 162 |+ return all(x in y for x in iterable) +166 163 | +167 164 | +168 165 | def f(): + +SIM111.py:170:5: SIM110 [*] Use `return all(x <= y for x in iterable)` instead of `for` loop + | +168 | def f(): +169 | # SIM111 +170 | for x in iterable: + | _____^ +171 | | if x > y: +172 | | return False +173 | | return True + | |_______________^ SIM110 + | + = help: Replace with `return all(x <= y for x in iterable)` + +ℹ Suggested fix +167 167 | +168 168 | def f(): +169 169 | # SIM111 +170 |- for x in iterable: +171 |- if x > y: +172 |- return False +173 |- return True + 170 |+ return all(x <= y for x in iterable) +174 171 | +175 172 | +176 173 | def f(): + +SIM111.py:178:5: SIM110 [*] Use `return all(not x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9")` instead of `for` loop + | +176 | def f(): +177 | # SIM111 +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 + | |_______________^ SIM110 + | + = help: Replace with `return all(not x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9")` + +ℹ Suggested fix +175 175 | +176 176 | def f(): +177 177 | # SIM111 +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 + 178 |+ return all(not x.isdigit() for x in "012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9") +182 179 | +183 180 | +184 181 | def f(): + + 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 new file mode 100644 index 0000000000..f19564b216 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM112_SIM112.py.snap @@ -0,0 +1,119 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM112.py:4:12: SIM112 [*] Use capitalized environment variable `FOO` instead of `foo` + | +3 | # Bad +4 | os.environ['foo'] + | ^^^^^ SIM112 +5 | +6 | os.environ.get('foo') + | + = help: Replace `foo` with `FOO` + +ℹ Suggested fix +1 1 | import os +2 2 | +3 3 | # Bad +4 |-os.environ['foo'] + 4 |+os.environ['FOO'] +5 5 | +6 6 | os.environ.get('foo') +7 7 | + +SIM112.py:6:16: SIM112 Use capitalized environment variable `FOO` instead of `foo` + | +4 | os.environ['foo'] +5 | +6 | os.environ.get('foo') + | ^^^^^ SIM112 +7 | +8 | os.environ.get('foo', 'bar') + | + = help: Replace `foo` with `FOO` + +SIM112.py:8:16: SIM112 Use capitalized environment variable `FOO` instead of `foo` + | + 6 | os.environ.get('foo') + 7 | + 8 | os.environ.get('foo', 'bar') + | ^^^^^ SIM112 + 9 | +10 | os.getenv('foo') + | + = help: Replace `foo` with `FOO` + +SIM112.py:10:11: SIM112 Use capitalized environment variable `FOO` instead of `foo` + | + 8 | os.environ.get('foo', 'bar') + 9 | +10 | os.getenv('foo') + | ^^^^^ SIM112 +11 | +12 | env = os.environ.get('foo') + | + = help: Replace `foo` with `FOO` + +SIM112.py:12:22: SIM112 Use capitalized environment variable `FOO` instead of `foo` + | +10 | os.getenv('foo') +11 | +12 | env = os.environ.get('foo') + | ^^^^^ SIM112 +13 | +14 | env = os.environ['foo'] + | + = help: Replace `foo` with `FOO` + +SIM112.py:14:18: SIM112 [*] Use capitalized environment variable `FOO` instead of `foo` + | +12 | env = os.environ.get('foo') +13 | +14 | env = os.environ['foo'] + | ^^^^^ SIM112 +15 | +16 | if env := os.environ.get('foo'): + | + = help: Replace `foo` with `FOO` + +ℹ Suggested fix +11 11 | +12 12 | env = os.environ.get('foo') +13 13 | +14 |-env = os.environ['foo'] + 14 |+env = os.environ['FOO'] +15 15 | +16 16 | if env := os.environ.get('foo'): +17 17 | pass + +SIM112.py:16:26: SIM112 Use capitalized environment variable `FOO` instead of `foo` + | +14 | env = os.environ['foo'] +15 | +16 | if env := os.environ.get('foo'): + | ^^^^^ SIM112 +17 | pass + | + = help: Replace `foo` with `FOO` + +SIM112.py:19:22: SIM112 [*] Use capitalized environment variable `FOO` instead of `foo` + | +17 | pass +18 | +19 | if env := os.environ['foo']: + | ^^^^^ SIM112 +20 | pass + | + = help: Replace `foo` with `FOO` + +ℹ Suggested fix +16 16 | if env := os.environ.get('foo'): +17 17 | pass +18 18 | +19 |-if env := os.environ['foo']: + 19 |+if env := os.environ['FOO']: +20 20 | pass +21 21 | +22 22 | + + 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 new file mode 100644 index 0000000000..48c0df9aad --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM114_SIM114.py.snap @@ -0,0 +1,167 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM114.py:2:1: SIM114 Combine `if` branches using logical `or` operator + | +1 | # Errors +2 | / if a: +3 | | b +4 | | elif c: +5 | | b + | |_____^ SIM114 +6 | +7 | if x == 1: + | + +SIM114.py:7:1: SIM114 Combine `if` branches using logical `or` operator + | + 5 | b + 6 | + 7 | / if x == 1: + 8 | | for _ in range(20): + 9 | | print("hello") +10 | | elif x == 2: +11 | | for _ in range(20): +12 | | print("hello") + | |______________________^ SIM114 +13 | +14 | if x == 1: + | + +SIM114.py:14:1: SIM114 Combine `if` branches using logical `or` operator + | +12 | print("hello") +13 | +14 | / if x == 1: +15 | | if True: +16 | | for _ in range(20): +17 | | print("hello") +18 | | elif x == 2: +19 | | if True: +20 | | for _ in range(20): +21 | | print("hello") + | |__________________________^ SIM114 +22 | +23 | if x == 1: + | + +SIM114.py:23:1: SIM114 Combine `if` branches using logical `or` operator + | +21 | print("hello") +22 | +23 | / if x == 1: +24 | | if True: +25 | | for _ in range(20): +26 | | print("hello") +27 | | elif False: +28 | | for _ in range(20): +29 | | print("hello") +30 | | elif x == 2: +31 | | if True: +32 | | for _ in range(20): +33 | | print("hello") +34 | | elif False: +35 | | for _ in range(20): +36 | | print("hello") + | |__________________________^ SIM114 +37 | +38 | if ( + | + +SIM114.py:24:5: SIM114 Combine `if` branches using logical `or` operator + | +23 | if x == 1: +24 | if True: + | _____^ +25 | | for _ in range(20): +26 | | print("hello") +27 | | elif False: +28 | | for _ in range(20): +29 | | print("hello") + | |__________________________^ SIM114 +30 | elif x == 2: +31 | if True: + | + +SIM114.py:31:5: SIM114 Combine `if` branches using logical `or` operator + | +29 | print("hello") +30 | elif x == 2: +31 | if True: + | _____^ +32 | | for _ in range(20): +33 | | print("hello") +34 | | elif False: +35 | | for _ in range(20): +36 | | print("hello") + | |__________________________^ SIM114 +37 | +38 | if ( + | + +SIM114.py:38:1: SIM114 Combine `if` branches using logical `or` operator + | +36 | print("hello") +37 | +38 | / if ( +39 | | x == 1 +40 | | and y == 2 +41 | | and z == 3 +42 | | and a == 4 +43 | | and b == 5 +44 | | and c == 6 +45 | | and d == 7 +46 | | and e == 8 +47 | | and f == 9 +48 | | and g == 10 +49 | | and h == 11 +50 | | and i == 12 +51 | | and j == 13 +52 | | and k == 14 +53 | | ): +54 | | pass +55 | | elif 1 == 2: +56 | | pass + | |________^ SIM114 +57 | +58 | if result.eofs == "O": + | + +SIM114.py:62:1: SIM114 Combine `if` branches using logical `or` operator + | +60 | elif result.eofs == "S": +61 | skipped = 1 +62 | / elif result.eofs == "F": +63 | | errors = 1 +64 | | elif result.eofs == "E": +65 | | errors = 1 + | |______________^ SIM114 + | + +SIM114.py:109:5: SIM114 Combine `if` branches using logical `or` operator + | +107 | a = True +108 | b = False +109 | if a > b: # end-of-line + | _____^ +110 | | return 3 +111 | | elif a == b: +112 | | return 3 + | |________________^ SIM114 +113 | elif a < b: # end-of-line +114 | return 4 + | + +SIM114.py:113:5: SIM114 Combine `if` branches using logical `or` operator + | +111 | elif a == b: +112 | return 3 +113 | elif a < b: # end-of-line + | _____^ +114 | | return 4 +115 | | elif b is None: +116 | | return 4 + | |________________^ SIM114 + | + + 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 new file mode 100644 index 0000000000..263ec17559 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM115_SIM115.py.snap @@ -0,0 +1,63 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM115.py:8:5: SIM115 Use context handler for opening files + | + 7 | # SIM115 + 8 | f = open("foo.txt") + | ^^^^ SIM115 + 9 | f = Path("foo.txt").open() +10 | f = pathlib.Path("foo.txt").open() + | + +SIM115.py:9:5: SIM115 Use context handler for opening files + | + 7 | # SIM115 + 8 | f = open("foo.txt") + 9 | f = Path("foo.txt").open() + | ^^^^^^^^^^^^^^^^^^^^ SIM115 +10 | f = pathlib.Path("foo.txt").open() +11 | f = pl.Path("foo.txt").open() + | + +SIM115.py:10:5: SIM115 Use context handler for opening files + | + 8 | f = open("foo.txt") + 9 | f = Path("foo.txt").open() +10 | f = pathlib.Path("foo.txt").open() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM115 +11 | f = pl.Path("foo.txt").open() +12 | f = P("foo.txt").open() + | + +SIM115.py:11:5: SIM115 Use context handler for opening files + | + 9 | f = Path("foo.txt").open() +10 | f = pathlib.Path("foo.txt").open() +11 | f = pl.Path("foo.txt").open() + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM115 +12 | f = P("foo.txt").open() +13 | data = f.read() + | + +SIM115.py:12:5: SIM115 Use context handler for opening files + | +10 | f = pathlib.Path("foo.txt").open() +11 | f = pl.Path("foo.txt").open() +12 | f = P("foo.txt").open() + | ^^^^^^^^^^^^^^^^^ SIM115 +13 | data = f.read() +14 | f.close() + | + +SIM115.py:39:9: SIM115 Use context handler for opening files + | +37 | # SIM115 +38 | with contextlib.ExitStack(): +39 | f = open("filename") + | ^^^^ SIM115 +40 | +41 | # OK + | + + 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 new file mode 100644 index 0000000000..f1045b10c4 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM116_SIM116.py.snap @@ -0,0 +1,112 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM116.py:5:1: SIM116 Use a dictionary instead of consecutive `if` statements + | + 4 | # SIM116 + 5 | / if a == "foo": + 6 | | return "bar" + 7 | | elif a == "bar": + 8 | | return "baz" + 9 | | elif a == "boo": +10 | | return "ooh" +11 | | else: +12 | | return 42 + | |_____________^ SIM116 +13 | +14 | # SIM116 + | + +SIM116.py:15:1: SIM116 Use a dictionary instead of consecutive `if` statements + | +14 | # SIM116 +15 | / if a == 1: +16 | | return (1, 2, 3) +17 | | elif a == 2: +18 | | return (4, 5, 6) +19 | | elif a == 3: +20 | | return (7, 8, 9) +21 | | else: +22 | | return (10, 11, 12) + | |_______________________^ SIM116 +23 | +24 | # SIM116 + | + +SIM116.py:25:1: SIM116 Use a dictionary instead of consecutive `if` statements + | +24 | # SIM116 +25 | / if a == 1: +26 | | return (1, 2, 3) +27 | | elif a == 2: +28 | | return (4, 5, 6) +29 | | elif a == 3: +30 | | return (7, 8, 9) + | |____________________^ SIM116 +31 | +32 | # SIM116 + | + +SIM116.py:33:1: SIM116 Use a dictionary instead of consecutive `if` statements + | +32 | # SIM116 +33 | / if a == "hello 'sir'": +34 | | return (1, 2, 3) +35 | | elif a == 'goodbye "mam"': +36 | | return (4, 5, 6) +37 | | elif a == """Fairwell 'mister'""": +38 | | return (7, 8, 9) +39 | | else: +40 | | return (10, 11, 12) + | |_______________________^ SIM116 +41 | +42 | # SIM116 + | + +SIM116.py:43:1: SIM116 Use a dictionary instead of consecutive `if` statements + | +42 | # SIM116 +43 | / if a == b"one": +44 | | return 1 +45 | | elif a == b"two": +46 | | return 2 +47 | | elif a == b"three": +48 | | return 3 + | |____________^ SIM116 +49 | +50 | # SIM116 + | + +SIM116.py:51:1: SIM116 Use a dictionary instead of consecutive `if` statements + | +50 | # SIM116 +51 | / if a == "hello 'sir'": +52 | | return ("hello'", 'hi"', 3) +53 | | elif a == 'goodbye "mam"': +54 | | return (4, 5, 6) +55 | | elif a == """Fairwell 'mister'""": +56 | | return (7, 8, 9) +57 | | else: +58 | | return (10, 11, 12) + | |_______________________^ SIM116 +59 | +60 | # OK + | + +SIM116.py:79:1: SIM116 Use a dictionary instead of consecutive `if` statements + | +78 | # SIM116 +79 | / if func_name == "create": +80 | | return "A" +81 | | elif func_name == "modify": +82 | | return "M" +83 | | elif func_name == "remove": +84 | | return "D" +85 | | elif func_name == "move": +86 | | return "MV" + | |_______________^ SIM116 +87 | +88 | # OK + | + + 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 new file mode 100644 index 0000000000..d2b6f1de2b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM117_SIM117.py.snap @@ -0,0 +1,287 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM117.py:2:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + | +1 | # SIM117 +2 | / with A() as a: +3 | | with B() as b: + | |__________________^ SIM117 +4 | print("hello") + | + = help: Combine `with` statements + +ℹ Suggested fix +1 1 | # SIM117 +2 |-with A() as a: +3 |- with B() as b: +4 |- print("hello") + 2 |+with A() as a, B() as b: + 3 |+ print("hello") +5 4 | +6 5 | # SIM117 +7 6 | with A(): + +SIM117.py:7:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + | + 6 | # SIM117 + 7 | / with A(): + 8 | | with B(): + | |_____________^ SIM117 + 9 | with C(): +10 | print("hello") + | + = help: Combine `with` statements + +ℹ Suggested fix +4 4 | print("hello") +5 5 | +6 6 | # SIM117 +7 |-with A(): +8 |- with B(): +9 |- with C(): +10 |- print("hello") + 7 |+with A(), B(): + 8 |+ with C(): + 9 |+ print("hello") +11 10 | +12 11 | # SIM117 +13 12 | with A() as a: + +SIM117.py:13:1: SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements + | +12 | # SIM117 +13 | / with A() as a: +14 | | # Unfixable due to placement of this comment. +15 | | with B() as b: + | |__________________^ SIM117 +16 | print("hello") + | + = help: Combine `with` statements + +SIM117.py:19:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + | +18 | # SIM117 +19 | / with A() as a: +20 | | with B() as b: + | |__________________^ SIM117 +21 | # Fixable due to placement of this comment. +22 | print("hello") + | + = help: Combine `with` statements + +ℹ Suggested fix +16 16 | print("hello") +17 17 | +18 18 | # SIM117 +19 |-with A() as a: +20 |- with B() as b: +21 |- # Fixable due to placement of this comment. +22 |- print("hello") + 19 |+with A() as a, B() as b: + 20 |+ # Fixable due to placement of this comment. + 21 |+ print("hello") +23 22 | +24 23 | # OK +25 24 | with A() as a: + +SIM117.py:47:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + | +46 | # SIM117 +47 | / async with A() as a: +48 | | async with B() as b: + | |________________________^ SIM117 +49 | print("hello") + | + = help: Combine `with` statements + +ℹ Suggested fix +44 44 | print("hello") +45 45 | +46 46 | # SIM117 +47 |-async with A() as a: +48 |- async with B() as b: +49 |- print("hello") + 47 |+async with A() as a, B() as b: + 48 |+ print("hello") +50 49 | +51 50 | while True: +52 51 | # SIM117 + +SIM117.py:53:5: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + | +51 | while True: +52 | # SIM117 +53 | with A() as a: + | _____^ +54 | | with B() as b: + | |______________________^ SIM117 +55 | """this +56 | is valid""" + | + = help: Combine `with` statements + +ℹ Suggested fix +50 50 | +51 51 | while True: +52 52 | # SIM117 +53 |- with A() as a: +54 |- with B() as b: +55 |- """this + 53 |+ with A() as a, B() as b: + 54 |+ """this +56 55 | is valid""" +57 56 | +58 |- """the indentation on + 57 |+ """the indentation on +59 58 | this line is significant""" +60 59 | +61 |- "this is" \ + 60 |+ "this is" \ +62 61 | "allowed too" +63 62 | +64 |- ("so is" + 63 |+ ("so is" +65 64 | "this for some reason") +66 65 | +67 66 | # SIM117 + +SIM117.py:68:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + | +67 | # SIM117 +68 | / with ( +69 | | A() as a, +70 | | B() as b, +71 | | ): +72 | | with C() as c: + | |__________________^ SIM117 +73 | print("hello") + | + = help: Combine `with` statements + +ℹ Suggested fix +67 67 | # SIM117 +68 68 | with ( +69 69 | A() as a, +70 |- B() as b, + 70 |+ B() as b,C() as c +71 71 | ): +72 |- with C() as c: +73 |- print("hello") + 72 |+ print("hello") +74 73 | +75 74 | # SIM117 +76 75 | with A() as a: + +SIM117.py:76:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + | +75 | # SIM117 +76 | / with A() as a: +77 | | with ( +78 | | B() as b, +79 | | C() as c, +80 | | ): + | |______^ SIM117 +81 | print("hello") + | + = help: Combine `with` statements + +ℹ Suggested fix +73 73 | print("hello") +74 74 | +75 75 | # SIM117 +76 |-with A() as a: +77 |- with ( +78 |- B() as b, +79 |- C() as c, +80 |- ): +81 |- print("hello") + 76 |+with ( + 77 |+ A() as a, B() as b, + 78 |+ C() as c, + 79 |+): + 80 |+ print("hello") +82 81 | +83 82 | # SIM117 +84 83 | with ( + +SIM117.py:84:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + | +83 | # SIM117 +84 | / with ( +85 | | A() as a, +86 | | B() as b, +87 | | ): +88 | | with ( +89 | | C() as c, +90 | | D() as d, +91 | | ): + | |______^ SIM117 +92 | print("hello") + | + = help: Combine `with` statements + +ℹ Suggested fix +83 83 | # SIM117 +84 84 | with ( +85 85 | A() as a, +86 |- B() as b, + 86 |+ B() as b,C() as c, + 87 |+ D() as d, +87 88 | ): +88 |- with ( +89 |- C() as c, +90 |- D() as d, +91 |- ): +92 |- print("hello") + 89 |+ print("hello") +93 90 | +94 91 | # SIM117 (auto-fixable) +95 92 | with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as a: + +SIM117.py:95:1: SIM117 [*] Use a single `with` statement with multiple contexts instead of nested `with` statements + | +94 | # SIM117 (auto-fixable) +95 | / with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as a: +96 | | with B("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as b: + | |__________________________________________________^ SIM117 +97 | print("hello") + | + = help: Combine `with` statements + +ℹ Suggested fix +92 92 | print("hello") +93 93 | +94 94 | # SIM117 (auto-fixable) +95 |-with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as a: +96 |- with B("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as b: +97 |- print("hello") + 95 |+with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as a, B("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as b: + 96 |+ print("hello") +98 97 | +99 98 | # SIM117 (not auto-fixable too long) +100 99 | with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ890") as a: + +SIM117.py:100:1: SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements + | + 99 | # SIM117 (not auto-fixable too long) +100 | / with A("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ890") as a: +101 | | with B("01ß9💣2ℝ8901ß9💣2ℝ8901ß9💣2ℝ89") as b: + | |__________________________________________________^ SIM117 +102 | print("hello") + | + = help: Combine `with` statements + +SIM117.py:106:5: SIM117 Use a single `with` statement with multiple contexts instead of nested `with` statements + | +104 | # From issue #3025. +105 | async def main(): +106 | async with A() as a: # SIM117. + | _____^ +107 | | async with B() as b: + | |____________________________^ SIM117 +108 | print("async-inside!") + | + = help: Combine `with` statements + + 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 new file mode 100644 index 0000000000..a95f802966 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM118_SIM118.py.snap @@ -0,0 +1,396 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM118.py:1:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + | +1 | key in obj.keys() # SIM118 + | ^^^^^^^^^^^^^^^^^ SIM118 +2 | +3 | key not in obj.keys() # SIM118 + | + = help: Remove `.keys()` + +ℹ Suggested fix +1 |-key in obj.keys() # SIM118 + 1 |+key in obj # SIM118 +2 2 | +3 3 | key not in obj.keys() # SIM118 +4 4 | + +SIM118.py:3:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` + | +1 | key in obj.keys() # SIM118 +2 | +3 | key not in obj.keys() # SIM118 + | ^^^^^^^^^^^^^^^^^^^^^ SIM118 +4 | +5 | foo["bar"] in obj.keys() # SIM118 + | + = help: Remove `.keys()` + +ℹ Suggested fix +1 1 | key in obj.keys() # SIM118 +2 2 | +3 |-key not in obj.keys() # SIM118 + 3 |+key not in obj # SIM118 +4 4 | +5 5 | foo["bar"] in obj.keys() # SIM118 +6 6 | + +SIM118.py:5:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + | +3 | key not in obj.keys() # SIM118 +4 | +5 | foo["bar"] in obj.keys() # SIM118 + | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 +6 | +7 | foo["bar"] not in obj.keys() # SIM118 + | + = help: Remove `.keys()` + +ℹ Suggested fix +2 2 | +3 3 | key not in obj.keys() # SIM118 +4 4 | +5 |-foo["bar"] in obj.keys() # SIM118 + 5 |+foo["bar"] in obj # SIM118 +6 6 | +7 7 | foo["bar"] not in obj.keys() # SIM118 +8 8 | + +SIM118.py:7:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` + | +5 | foo["bar"] in obj.keys() # SIM118 +6 | +7 | foo["bar"] not in obj.keys() # SIM118 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 +8 | +9 | foo['bar'] in obj.keys() # SIM118 + | + = help: Remove `.keys()` + +ℹ Suggested fix +4 4 | +5 5 | foo["bar"] in obj.keys() # SIM118 +6 6 | +7 |-foo["bar"] not in obj.keys() # SIM118 + 7 |+foo["bar"] not in obj # SIM118 +8 8 | +9 9 | foo['bar'] in obj.keys() # SIM118 +10 10 | + +SIM118.py:9:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + | + 7 | foo["bar"] not in obj.keys() # SIM118 + 8 | + 9 | foo['bar'] in obj.keys() # SIM118 + | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 +10 | +11 | foo['bar'] not in obj.keys() # SIM118 + | + = help: Remove `.keys()` + +ℹ Suggested fix +6 6 | +7 7 | foo["bar"] not in obj.keys() # SIM118 +8 8 | +9 |-foo['bar'] in obj.keys() # SIM118 + 9 |+foo['bar'] in obj # SIM118 +10 10 | +11 11 | foo['bar'] not in obj.keys() # SIM118 +12 12 | + +SIM118.py:11:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` + | + 9 | foo['bar'] in obj.keys() # SIM118 +10 | +11 | foo['bar'] not in obj.keys() # SIM118 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 +12 | +13 | foo() in obj.keys() # SIM118 + | + = help: Remove `.keys()` + +ℹ Suggested fix +8 8 | +9 9 | foo['bar'] in obj.keys() # SIM118 +10 10 | +11 |-foo['bar'] not in obj.keys() # SIM118 + 11 |+foo['bar'] not in obj # SIM118 +12 12 | +13 13 | foo() in obj.keys() # SIM118 +14 14 | + +SIM118.py:13:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + | +11 | foo['bar'] not in obj.keys() # SIM118 +12 | +13 | foo() in obj.keys() # SIM118 + | ^^^^^^^^^^^^^^^^^^^ SIM118 +14 | +15 | foo() not in obj.keys() # SIM118 + | + = help: Remove `.keys()` + +ℹ Suggested fix +10 10 | +11 11 | foo['bar'] not in obj.keys() # SIM118 +12 12 | +13 |-foo() in obj.keys() # SIM118 + 13 |+foo() in obj # SIM118 +14 14 | +15 15 | foo() not in obj.keys() # SIM118 +16 16 | + +SIM118.py:15:1: SIM118 [*] Use `key not in dict` instead of `key not in dict.keys()` + | +13 | foo() in obj.keys() # SIM118 +14 | +15 | foo() not in obj.keys() # SIM118 + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM118 +16 | +17 | for key in obj.keys(): # SIM118 + | + = help: Remove `.keys()` + +ℹ Suggested fix +12 12 | +13 13 | foo() in obj.keys() # SIM118 +14 14 | +15 |-foo() not in obj.keys() # SIM118 + 15 |+foo() not in obj # SIM118 +16 16 | +17 17 | for key in obj.keys(): # SIM118 +18 18 | pass + +SIM118.py:17:5: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + | +15 | foo() not in obj.keys() # SIM118 +16 | +17 | for key in obj.keys(): # SIM118 + | ^^^^^^^^^^^^^^^^^ SIM118 +18 | pass + | + = help: Remove `.keys()` + +ℹ Suggested fix +14 14 | +15 15 | foo() not in obj.keys() # SIM118 +16 16 | +17 |-for key in obj.keys(): # SIM118 + 17 |+for key in obj: # SIM118 +18 18 | pass +19 19 | +20 20 | for key in list(obj.keys()): + +SIM118.py:24:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + | +22 | del obj[key] +23 | +24 | [k for k in obj.keys()] # SIM118 + | ^^^^^^^^^^^^^^^ SIM118 +25 | +26 | {k for k in obj.keys()} # SIM118 + | + = help: Remove `.keys()` + +ℹ Suggested fix +21 21 | if some_property(key): +22 22 | del obj[key] +23 23 | +24 |-[k for k in obj.keys()] # SIM118 + 24 |+[k for k in obj] # SIM118 +25 25 | +26 26 | {k for k in obj.keys()} # SIM118 +27 27 | + +SIM118.py:26:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + | +24 | [k for k in obj.keys()] # SIM118 +25 | +26 | {k for k in obj.keys()} # SIM118 + | ^^^^^^^^^^^^^^^ SIM118 +27 | +28 | {k: k for k in obj.keys()} # SIM118 + | + = help: Remove `.keys()` + +ℹ Suggested fix +23 23 | +24 24 | [k for k in obj.keys()] # SIM118 +25 25 | +26 |-{k for k in obj.keys()} # SIM118 + 26 |+{k for k in obj} # SIM118 +27 27 | +28 28 | {k: k for k in obj.keys()} # SIM118 +29 29 | + +SIM118.py:28:11: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + | +26 | {k for k in obj.keys()} # SIM118 +27 | +28 | {k: k for k in obj.keys()} # SIM118 + | ^^^^^^^^^^^^^^^ SIM118 +29 | +30 | (k for k in obj.keys()) # SIM118 + | + = help: Remove `.keys()` + +ℹ Suggested fix +25 25 | +26 26 | {k for k in obj.keys()} # SIM118 +27 27 | +28 |-{k: k for k in obj.keys()} # SIM118 + 28 |+{k: k for k in obj} # SIM118 +29 29 | +30 30 | (k for k in obj.keys()) # SIM118 +31 31 | + +SIM118.py:30:8: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + | +28 | {k: k for k in obj.keys()} # SIM118 +29 | +30 | (k for k in obj.keys()) # SIM118 + | ^^^^^^^^^^^^^^^ SIM118 +31 | +32 | key in (obj or {}).keys() # SIM118 + | + = help: Remove `.keys()` + +ℹ Suggested fix +27 27 | +28 28 | {k: k for k in obj.keys()} # SIM118 +29 29 | +30 |-(k for k in obj.keys()) # SIM118 + 30 |+(k for k in obj) # SIM118 +31 31 | +32 32 | key in (obj or {}).keys() # SIM118 +33 33 | + +SIM118.py:32:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + | +30 | (k for k in obj.keys()) # SIM118 +31 | +32 | key in (obj or {}).keys() # SIM118 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 +33 | +34 | (key) in (obj or {}).keys() # SIM118 + | + = help: Remove `.keys()` + +ℹ Suggested fix +29 29 | +30 30 | (k for k in obj.keys()) # SIM118 +31 31 | +32 |-key in (obj or {}).keys() # SIM118 + 32 |+key in (obj or {}) # SIM118 +33 33 | +34 34 | (key) in (obj or {}).keys() # SIM118 +35 35 | + +SIM118.py:34:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + | +32 | key in (obj or {}).keys() # SIM118 +33 | +34 | (key) in (obj or {}).keys() # SIM118 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM118 +35 | +36 | from typing import KeysView + | + = help: Remove `.keys()` + +ℹ Suggested fix +31 31 | +32 32 | key in (obj or {}).keys() # SIM118 +33 33 | +34 |-(key) in (obj or {}).keys() # SIM118 + 34 |+(key) in (obj or {}) # SIM118 +35 35 | +36 36 | from typing import KeysView +37 37 | + +SIM118.py:48:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + | +47 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 +48 | key in obj.keys()and foo + | ^^^^^^^^^^^^^^^^^ SIM118 +49 | (key in obj.keys())and foo +50 | key in (obj.keys())and foo + | + = help: Remove `.keys()` + +ℹ Suggested fix +45 45 | +46 46 | +47 47 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 +48 |-key in obj.keys()and foo + 48 |+key in obj and foo +49 49 | (key in obj.keys())and foo +50 50 | key in (obj.keys())and foo +51 51 | + +SIM118.py:49:2: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + | +47 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 +48 | key in obj.keys()and foo +49 | (key in obj.keys())and foo + | ^^^^^^^^^^^^^^^^^ SIM118 +50 | key in (obj.keys())and foo + | + = help: Remove `.keys()` + +ℹ Suggested fix +46 46 | +47 47 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 +48 48 | key in obj.keys()and foo +49 |-(key in obj.keys())and foo + 49 |+(key in obj)and foo +50 50 | key in (obj.keys())and foo +51 51 | +52 52 | # Regression test for: https://github.com/astral-sh/ruff/issues/7200 + +SIM118.py:50:1: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + | +48 | key in obj.keys()and foo +49 | (key in obj.keys())and foo +50 | key in (obj.keys())and foo + | ^^^^^^^^^^^^^^^^^^^ SIM118 +51 | +52 | # Regression test for: https://github.com/astral-sh/ruff/issues/7200 + | + = help: Remove `.keys()` + +ℹ Suggested fix +47 47 | # Regression test for: https://github.com/astral-sh/ruff/issues/7124 +48 48 | key in obj.keys()and foo +49 49 | (key in obj.keys())and foo +50 |-key in (obj.keys())and foo + 50 |+key in (obj)and foo +51 51 | +52 52 | # Regression test for: https://github.com/astral-sh/ruff/issues/7200 +53 53 | for key in ( + +SIM118.py:53:5: SIM118 [*] Use `key in dict` instead of `key in dict.keys()` + | +52 | # Regression test for: https://github.com/astral-sh/ruff/issues/7200 +53 | for key in ( + | _____^ +54 | | self.experiment.surveys[0] +55 | | .stations[0] +56 | | .keys() +57 | | ): + | |_^ SIM118 +58 | continue + | + = help: Remove `.keys()` + +ℹ Suggested fix +53 53 | for key in ( +54 54 | self.experiment.surveys[0] +55 55 | .stations[0] +56 |- .keys() + 56 |+ +57 57 | ): +58 58 | continue + + diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM201_SIM201.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM201_SIM201.py.snap new file mode 100644 index 0000000000..52aeeffe4d --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM201_SIM201.py.snap @@ -0,0 +1,59 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM201.py:2:4: SIM201 [*] Use `a != b` instead of `not a == b` + | +1 | # SIM201 +2 | if not a == b: + | ^^^^^^^^^^ SIM201 +3 | pass + | + = help: Replace with `!=` operator + +ℹ Fix +1 1 | # SIM201 +2 |-if not a == b: + 2 |+if a != b: +3 3 | pass +4 4 | +5 5 | # SIM201 + +SIM201.py:6:4: SIM201 [*] Use `a != b + c` instead of `not a == b + c` + | +5 | # SIM201 +6 | if not a == (b + c): + | ^^^^^^^^^^^^^^^^ SIM201 +7 | pass + | + = help: Replace with `!=` operator + +ℹ Fix +3 3 | pass +4 4 | +5 5 | # SIM201 +6 |-if not a == (b + c): + 6 |+if a != b + c: +7 7 | pass +8 8 | +9 9 | # SIM201 + +SIM201.py:10:4: SIM201 [*] Use `a + b != c` instead of `not a + b == c` + | + 9 | # SIM201 +10 | if not (a + b) == c: + | ^^^^^^^^^^^^^^^^ SIM201 +11 | pass + | + = help: Replace with `!=` operator + +ℹ Fix +7 7 | pass +8 8 | +9 9 | # SIM201 +10 |-if not (a + b) == c: + 10 |+if a + b != c: +11 11 | pass +12 12 | +13 13 | # OK + + diff --git a/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM202_SIM202.py.snap b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM202_SIM202.py.snap new file mode 100644 index 0000000000..739679e4de --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM202_SIM202.py.snap @@ -0,0 +1,59 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM202.py:2:4: SIM202 [*] Use `a == b` instead of `not a != b` + | +1 | # SIM202 +2 | if not a != b: + | ^^^^^^^^^^ SIM202 +3 | pass + | + = help: Replace with `==` operator + +ℹ Suggested fix +1 1 | # SIM202 +2 |-if not a != b: + 2 |+if a == b: +3 3 | pass +4 4 | +5 5 | # SIM202 + +SIM202.py:6:4: SIM202 [*] Use `a == b + c` instead of `not a != b + c` + | +5 | # SIM202 +6 | if not a != (b + c): + | ^^^^^^^^^^^^^^^^ SIM202 +7 | pass + | + = help: Replace with `==` operator + +ℹ Suggested fix +3 3 | pass +4 4 | +5 5 | # SIM202 +6 |-if not a != (b + c): + 6 |+if a == b + c: +7 7 | pass +8 8 | +9 9 | # SIM202 + +SIM202.py:10:4: SIM202 [*] Use `a + b == c` instead of `not a + b != c` + | + 9 | # SIM202 +10 | if not (a + b) != c: + | ^^^^^^^^^^^^^^^^ SIM202 +11 | pass + | + = help: Replace with `==` operator + +ℹ Suggested fix +7 7 | pass +8 8 | +9 9 | # SIM202 +10 |-if not (a + b) != c: + 10 |+if a + b == c: +11 11 | pass +12 12 | +13 13 | # OK + + 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 new file mode 100644 index 0000000000..f1b5030c02 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM208_SIM208.py.snap @@ -0,0 +1,99 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM208.py:1:4: SIM208 [*] Use `a` instead of `not (not a)` + | +1 | if not (not a): # SIM208 + | ^^^^^^^^^^^ SIM208 +2 | pass + | + = help: Replace with `a` + +ℹ Suggested fix +1 |-if not (not a): # SIM208 + 1 |+if a: # SIM208 +2 2 | pass +3 3 | +4 4 | if not (not (a == b)): # SIM208 + +SIM208.py:4:4: SIM208 [*] Use `a == b` instead of `not (not a == b)` + | +2 | pass +3 | +4 | if not (not (a == b)): # SIM208 + | ^^^^^^^^^^^^^^^^^^ SIM208 +5 | pass + | + = help: Replace with `a == b` + +ℹ Suggested fix +1 1 | if not (not a): # SIM208 +2 2 | pass +3 3 | +4 |-if not (not (a == b)): # SIM208 + 4 |+if a == b: # SIM208 +5 5 | pass +6 6 | +7 7 | if not a: # OK + +SIM208.py:16:5: SIM208 [*] Use `b` instead of `not (not b)` + | +14 | pass +15 | +16 | a = not not b # SIM208 + | ^^^^^^^^^ SIM208 +17 | +18 | f(not not a) # SIM208 + | + = help: Replace with `b` + +ℹ Suggested fix +13 13 | if not a != b: # OK +14 14 | pass +15 15 | +16 |-a = not not b # SIM208 + 16 |+a = bool(b) # SIM208 +17 17 | +18 18 | f(not not a) # SIM208 +19 19 | + +SIM208.py:18:3: SIM208 [*] Use `a` instead of `not (not a)` + | +16 | a = not not b # SIM208 +17 | +18 | f(not not a) # SIM208 + | ^^^^^^^^^ SIM208 +19 | +20 | if 1 + (not (not a)): # SIM208 + | + = help: Replace with `a` + +ℹ Suggested fix +15 15 | +16 16 | a = not not b # SIM208 +17 17 | +18 |-f(not not a) # SIM208 + 18 |+f(bool(a)) # SIM208 +19 19 | +20 20 | if 1 + (not (not a)): # SIM208 +21 21 | pass + +SIM208.py:20:9: SIM208 [*] Use `a` instead of `not (not a)` + | +18 | f(not not a) # SIM208 +19 | +20 | if 1 + (not (not a)): # SIM208 + | ^^^^^^^^^^^ SIM208 +21 | pass + | + = help: Replace with `a` + +ℹ Suggested fix +17 17 | +18 18 | f(not not a) # SIM208 +19 19 | +20 |-if 1 + (not (not a)): # SIM208 + 20 |+if 1 + (bool(a)): # SIM208 +21 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 new file mode 100644 index 0000000000..7f7cfde237 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM210_SIM210.py.snap @@ -0,0 +1,89 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM210.py:1:5: SIM210 [*] Use `bool(...)` instead of `True if ... else False` + | +1 | a = True if b else False # SIM210 + | ^^^^^^^^^^^^^^^^^^^^ SIM210 +2 | +3 | a = True if b != c else False # SIM210 + | + = help: Replace with `bool(...) + +ℹ Suggested fix +1 |-a = True if b else False # SIM210 + 1 |+a = bool(b) # SIM210 +2 2 | +3 3 | a = True if b != c else False # SIM210 +4 4 | + +SIM210.py:3:5: SIM210 [*] Remove unnecessary `True if ... else False` + | +1 | a = True if b else False # SIM210 +2 | +3 | a = True if b != c else False # SIM210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM210 +4 | +5 | a = True if b + c else False # SIM210 + | + = help: Remove unnecessary `True if ... else False` + +ℹ Suggested fix +1 1 | a = True if b else False # SIM210 +2 2 | +3 |-a = True if b != c else False # SIM210 + 3 |+a = b != c # SIM210 +4 4 | +5 5 | a = True if b + c else False # SIM210 +6 6 | + +SIM210.py:5:5: SIM210 [*] Use `bool(...)` instead of `True if ... else False` + | +3 | a = True if b != c else False # SIM210 +4 | +5 | a = True if b + c else False # SIM210 + | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM210 +6 | +7 | a = False if b else True # OK + | + = help: Replace with `bool(...) + +ℹ Suggested fix +2 2 | +3 3 | a = True if b != c else False # SIM210 +4 4 | +5 |-a = True if b + c else False # SIM210 + 5 |+a = bool(b + c) # SIM210 +6 6 | +7 7 | a = False if b else True # OK +8 8 | + +SIM210.py:15:9: SIM210 Use `bool(...)` instead of `True if ... else False` + | +13 | return False +14 | +15 | a = True if b else False + | ^^^^^^^^^^^^^^^^^^^^ SIM210 + | + = help: Replace with `bool(...) + +SIM210.py:19:11: SIM210 [*] Remove unnecessary `True if ... else False` + | +18 | # Regression test for: https://github.com/astral-sh/ruff/issues/7076 +19 | samesld = True if (psl.privatesuffix(urlparse(response.url).netloc) == + | ___________^ +20 | | psl.privatesuffix(src.netloc)) else False + | |____________________________________________________________________________^ SIM210 + | + = help: Remove unnecessary `True if ... else False` + +ℹ Suggested fix +16 16 | +17 17 | +18 18 | # Regression test for: https://github.com/astral-sh/ruff/issues/7076 +19 |-samesld = True if (psl.privatesuffix(urlparse(response.url).netloc) == +20 |- psl.privatesuffix(src.netloc)) else False + 19 |+samesld = (psl.privatesuffix(urlparse(response.url).netloc) == + 20 |+ psl.privatesuffix(src.netloc)) + + 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 new file mode 100644 index 0000000000..359b5384bc --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM211_SIM211.py.snap @@ -0,0 +1,60 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM211.py:1:5: SIM211 [*] Use `not ...` instead of `False if ... else True` + | +1 | a = False if b else True # SIM211 + | ^^^^^^^^^^^^^^^^^^^^ SIM211 +2 | +3 | a = False if b != c else True # SIM211 + | + = help: Replace with `not ...` + +ℹ Suggested fix +1 |-a = False if b else True # SIM211 + 1 |+a = not b # SIM211 +2 2 | +3 3 | a = False if b != c else True # SIM211 +4 4 | + +SIM211.py:3:5: SIM211 [*] Use `not ...` instead of `False if ... else True` + | +1 | a = False if b else True # SIM211 +2 | +3 | a = False if b != c else True # SIM211 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM211 +4 | +5 | a = False if b + c else True # SIM211 + | + = help: Replace with `not ...` + +ℹ Suggested fix +1 1 | a = False if b else True # SIM211 +2 2 | +3 |-a = False if b != c else True # SIM211 + 3 |+a = not b != c # SIM211 +4 4 | +5 5 | a = False if b + c else True # SIM211 +6 6 | + +SIM211.py:5:5: SIM211 [*] Use `not ...` instead of `False if ... else True` + | +3 | a = False if b != c else True # SIM211 +4 | +5 | a = False if b + c else True # SIM211 + | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM211 +6 | +7 | a = True if b else False # OK + | + = help: Replace with `not ...` + +ℹ Suggested fix +2 2 | +3 3 | a = False if b != c else True # SIM211 +4 4 | +5 |-a = False if b + c else True # SIM211 + 5 |+a = not b + c # SIM211 +6 6 | +7 7 | a = True if b else False # OK + + 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 new file mode 100644 index 0000000000..956cc50036 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM212_SIM212.py.snap @@ -0,0 +1,40 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +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 | +3 | c = b + c if not a else a # SIM212 + | + = help: Replace with `a if a else b` + +ℹ Suggested fix +1 |-c = b if not a else a # SIM212 + 1 |+c = a if a else b # SIM212 +2 2 | +3 3 | c = b + c if not a else a # SIM212 +4 4 | + +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 | +3 | c = b + c if not a else a # SIM212 + | ^^^^^^^^^^^^^^^^^^^^^ SIM212 +4 | +5 | c = b if not x else a # OK + | + = help: Replace with `a if a else b + c` + +ℹ Suggested fix +1 1 | c = b if not a else a # SIM212 +2 2 | +3 |-c = b + c if not a else a # SIM212 + 3 |+c = a if a else b + c # SIM212 +4 4 | +5 5 | c = b if not x else a # OK +6 6 | + + 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 new file mode 100644 index 0000000000..bf50be1050 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM220_SIM220.py.snap @@ -0,0 +1,59 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM220.py:1:4: SIM220 [*] Use `False` instead of `a and not a` + | +1 | if a and not a: + | ^^^^^^^^^^^ SIM220 +2 | pass + | + = help: Replace with `False` + +ℹ Suggested fix +1 |-if a and not a: + 1 |+if False: +2 2 | pass +3 3 | +4 4 | if (a and not a) and b: + +SIM220.py:4:5: SIM220 [*] Use `False` instead of `a and not a` + | +2 | pass +3 | +4 | if (a and not a) and b: + | ^^^^^^^^^^^ SIM220 +5 | pass + | + = help: Replace with `False` + +ℹ Suggested fix +1 1 | if a and not a: +2 2 | pass +3 3 | +4 |-if (a and not a) and b: + 4 |+if (False) and b: +5 5 | pass +6 6 | +7 7 | if (a and not a) or b: + +SIM220.py:7:5: SIM220 [*] Use `False` instead of `a and not a` + | +5 | pass +6 | +7 | if (a and not a) or b: + | ^^^^^^^^^^^ SIM220 +8 | pass + | + = help: Replace with `False` + +ℹ Suggested fix +4 4 | if (a and not a) and b: +5 5 | pass +6 6 | +7 |-if (a and not a) or b: + 7 |+if (False) or b: +8 8 | pass +9 9 | +10 10 | if a: + + 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 new file mode 100644 index 0000000000..cb3d53dfe7 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM221_SIM221.py.snap @@ -0,0 +1,59 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM221.py:1:4: SIM221 [*] Use `True` instead of `a or not a` + | +1 | if a or not a: + | ^^^^^^^^^^ SIM221 +2 | pass + | + = help: Replace with `True` + +ℹ Suggested fix +1 |-if a or not a: + 1 |+if True: +2 2 | pass +3 3 | +4 4 | if (a or not a) or b: + +SIM221.py:4:5: SIM221 [*] Use `True` instead of `a or not a` + | +2 | pass +3 | +4 | if (a or not a) or b: + | ^^^^^^^^^^ SIM221 +5 | pass + | + = help: Replace with `True` + +ℹ Suggested fix +1 1 | if a or not a: +2 2 | pass +3 3 | +4 |-if (a or not a) or b: + 4 |+if (True) or b: +5 5 | pass +6 6 | +7 7 | if (a or not a) and b: + +SIM221.py:7:5: SIM221 [*] Use `True` instead of `a or not a` + | +5 | pass +6 | +7 | if (a or not a) and b: + | ^^^^^^^^^^ SIM221 +8 | pass + | + = help: Replace with `True` + +ℹ Suggested fix +4 4 | if (a or not a) or b: +5 5 | pass +6 6 | +7 |-if (a or not a) and b: + 7 |+if (True) and b: +8 8 | pass +9 9 | +10 10 | if a: + + 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 new file mode 100644 index 0000000000..02d93e42fc --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM222_SIM222.py.snap @@ -0,0 +1,1044 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM222.py:1:4: SIM222 [*] Use `True` instead of `... or True` + | +1 | if a or True: # SIM222 + | ^^^^^^^^^ SIM222 +2 | pass + | + = help: Replace with `True` + +ℹ Suggested fix +1 |-if a or True: # SIM222 + 1 |+if True: # SIM222 +2 2 | pass +3 3 | +4 4 | if (a or b) or True: # SIM222 + +SIM222.py:4:4: SIM222 [*] Use `True` instead of `... or True` + | +2 | pass +3 | +4 | if (a or b) or True: # SIM222 + | ^^^^^^^^^^^^^^^^ SIM222 +5 | pass + | + = help: Replace with `True` + +ℹ Suggested fix +1 1 | if a or True: # SIM222 +2 2 | pass +3 3 | +4 |-if (a or b) or True: # SIM222 + 4 |+if True: # SIM222 +5 5 | pass +6 6 | +7 7 | if a or (b or True): # SIM222 + +SIM222.py:7:10: SIM222 [*] Use `True` instead of `... or True` + | +5 | pass +6 | +7 | if a or (b or True): # SIM222 + | ^^^^^^^^^ SIM222 +8 | pass + | + = help: Replace with `True` + +ℹ Suggested fix +4 4 | if (a or b) or True: # SIM222 +5 5 | pass +6 6 | +7 |-if a or (b or True): # SIM222 + 7 |+if a or (True): # SIM222 +8 8 | pass +9 9 | +10 10 | if a and True: # OK + +SIM222.py:24:16: SIM222 [*] Use `True` instead of `True or ...` + | +22 | pass +23 | +24 | if a or f() or True or g() or b: # SIM222 + | ^^^^^^^^^^^^^^^^ SIM222 +25 | pass + | + = help: Replace with `True` + +ℹ Suggested fix +21 21 | if a or f() or b or g() or True: # OK +22 22 | pass +23 23 | +24 |-if a or f() or True or g() or b: # SIM222 + 24 |+if a or f() or True: # SIM222 +25 25 | pass +26 26 | +27 27 | if True or f() or a or g() or b: # SIM222 + +SIM222.py:27:4: SIM222 [*] Use `True` instead of `True or ...` + | +25 | pass +26 | +27 | if True or f() or a or g() or b: # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +28 | pass + | + = help: Replace with `True` + +ℹ Suggested fix +24 24 | if a or f() or True or g() or b: # SIM222 +25 25 | pass +26 26 | +27 |-if True or f() or a or g() or b: # SIM222 + 27 |+if True: # SIM222 +28 28 | pass +29 29 | +30 30 | if a or True or f() or b or g(): # SIM222 + +SIM222.py:30:4: SIM222 [*] Use `True` instead of `... or True or ...` + | +28 | pass +29 | +30 | if a or True or f() or b or g(): # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +31 | pass + | + = help: Replace with `True` + +ℹ Suggested fix +27 27 | if True or f() or a or g() or b: # SIM222 +28 28 | pass +29 29 | +30 |-if a or True or f() or b or g(): # SIM222 + 30 |+if True: # SIM222 +31 31 | pass +32 32 | +33 33 | + +SIM222.py:47:6: SIM222 [*] Use `True` instead of `... or True` + | +47 | a or "" or True # SIM222 + | ^^^^^^^^^^ SIM222 +48 | +49 | a or "foo" or True or "bar" # SIM222 + | + = help: Replace with `True` + +ℹ Suggested fix +44 44 | pass +45 45 | +46 46 | +47 |-a or "" or True # SIM222 + 47 |+a or True # SIM222 +48 48 | +49 49 | a or "foo" or True or "bar" # SIM222 +50 50 | + +SIM222.py:49:6: SIM222 [*] Use `"foo"` instead of `"foo" or ...` + | +47 | a or "" or True # SIM222 +48 | +49 | a or "foo" or True or "bar" # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^ SIM222 +50 | +51 | a or 0 or True # SIM222 + | + = help: Replace with `"foo"` + +ℹ Suggested fix +46 46 | +47 47 | a or "" or True # SIM222 +48 48 | +49 |-a or "foo" or True or "bar" # SIM222 + 49 |+a or "foo" # SIM222 +50 50 | +51 51 | a or 0 or True # SIM222 +52 52 | + +SIM222.py:51:6: SIM222 [*] Use `True` instead of `... or True` + | +49 | a or "foo" or True or "bar" # SIM222 +50 | +51 | a or 0 or True # SIM222 + | ^^^^^^^^^ SIM222 +52 | +53 | a or 1 or True or 2 # SIM222 + | + = help: Replace with `True` + +ℹ Suggested fix +48 48 | +49 49 | a or "foo" or True or "bar" # SIM222 +50 50 | +51 |-a or 0 or True # SIM222 + 51 |+a or True # SIM222 +52 52 | +53 53 | a or 1 or True or 2 # SIM222 +54 54 | + +SIM222.py:53:6: SIM222 [*] Use `1` instead of `1 or ...` + | +51 | a or 0 or True # SIM222 +52 | +53 | a or 1 or True or 2 # SIM222 + | ^^^^^^^^^^^^^^ SIM222 +54 | +55 | a or 0.0 or True # SIM222 + | + = help: Replace with `1` + +ℹ Suggested fix +50 50 | +51 51 | a or 0 or True # SIM222 +52 52 | +53 |-a or 1 or True or 2 # SIM222 + 53 |+a or 1 # SIM222 +54 54 | +55 55 | a or 0.0 or True # SIM222 +56 56 | + +SIM222.py:55:6: SIM222 [*] Use `True` instead of `... or True` + | +53 | a or 1 or True or 2 # SIM222 +54 | +55 | a or 0.0 or True # SIM222 + | ^^^^^^^^^^^ SIM222 +56 | +57 | a or 0.1 or True or 0.2 # SIM222 + | + = help: Replace with `True` + +ℹ Suggested fix +52 52 | +53 53 | a or 1 or True or 2 # SIM222 +54 54 | +55 |-a or 0.0 or True # SIM222 + 55 |+a or True # SIM222 +56 56 | +57 57 | a or 0.1 or True or 0.2 # SIM222 +58 58 | + +SIM222.py:57:6: SIM222 [*] Use `0.1` instead of `0.1 or ...` + | +55 | a or 0.0 or True # SIM222 +56 | +57 | a or 0.1 or True or 0.2 # SIM222 + | ^^^^^^^^^^^^^^^^^^ SIM222 +58 | +59 | a or [] or True # SIM222 + | + = help: Replace with `0.1` + +ℹ Suggested fix +54 54 | +55 55 | a or 0.0 or True # SIM222 +56 56 | +57 |-a or 0.1 or True or 0.2 # SIM222 + 57 |+a or 0.1 # SIM222 +58 58 | +59 59 | a or [] or True # SIM222 +60 60 | + +SIM222.py:59:6: SIM222 [*] Use `True` instead of `... or True` + | +57 | a or 0.1 or True or 0.2 # SIM222 +58 | +59 | a or [] or True # SIM222 + | ^^^^^^^^^^ SIM222 +60 | +61 | a or list([]) or True # SIM222 + | + = help: Replace with `True` + +ℹ Suggested fix +56 56 | +57 57 | a or 0.1 or True or 0.2 # SIM222 +58 58 | +59 |-a or [] or True # SIM222 + 59 |+a or True # SIM222 +60 60 | +61 61 | a or list([]) or True # SIM222 +62 62 | + +SIM222.py:61:6: SIM222 [*] Use `True` instead of `... or True` + | +59 | a or [] or True # SIM222 +60 | +61 | a or list([]) or True # SIM222 + | ^^^^^^^^^^^^^^^^ SIM222 +62 | +63 | a or [1] or True or [2] # SIM222 + | + = help: Replace with `True` + +ℹ Suggested fix +58 58 | +59 59 | a or [] or True # SIM222 +60 60 | +61 |-a or list([]) or True # SIM222 + 61 |+a or True # SIM222 +62 62 | +63 63 | a or [1] or True or [2] # SIM222 +64 64 | + +SIM222.py:63:6: SIM222 [*] Use `[1]` instead of `[1] or ...` + | +61 | a or list([]) or True # SIM222 +62 | +63 | a or [1] or True or [2] # SIM222 + | ^^^^^^^^^^^^^^^^^^ SIM222 +64 | +65 | a or list([1]) or True or list([2]) # SIM222 + | + = help: Replace with `[1]` + +ℹ Suggested fix +60 60 | +61 61 | a or list([]) or True # SIM222 +62 62 | +63 |-a or [1] or True or [2] # SIM222 + 63 |+a or [1] # SIM222 +64 64 | +65 65 | a or list([1]) or True or list([2]) # SIM222 +66 66 | + +SIM222.py:65:6: SIM222 [*] Use `list([1])` instead of `list([1]) or ...` + | +63 | a or [1] or True or [2] # SIM222 +64 | +65 | a or list([1]) or True or list([2]) # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +66 | +67 | a or {} or True # SIM222 + | + = help: Replace with `list([1])` + +ℹ Suggested fix +62 62 | +63 63 | a or [1] or True or [2] # SIM222 +64 64 | +65 |-a or list([1]) or True or list([2]) # SIM222 + 65 |+a or list([1]) # SIM222 +66 66 | +67 67 | a or {} or True # SIM222 +68 68 | + +SIM222.py:67:6: SIM222 [*] Use `True` instead of `... or True` + | +65 | a or list([1]) or True or list([2]) # SIM222 +66 | +67 | a or {} or True # SIM222 + | ^^^^^^^^^^ SIM222 +68 | +69 | a or dict() or True # SIM222 + | + = help: Replace with `True` + +ℹ Suggested fix +64 64 | +65 65 | a or list([1]) or True or list([2]) # SIM222 +66 66 | +67 |-a or {} or True # SIM222 + 67 |+a or True # SIM222 +68 68 | +69 69 | a or dict() or True # SIM222 +70 70 | + +SIM222.py:69:6: SIM222 [*] Use `True` instead of `... or True` + | +67 | a or {} or True # SIM222 +68 | +69 | a or dict() or True # SIM222 + | ^^^^^^^^^^^^^^ SIM222 +70 | +71 | a or {1: 1} or True or {2: 2} # SIM222 + | + = help: Replace with `True` + +ℹ Suggested fix +66 66 | +67 67 | a or {} or True # SIM222 +68 68 | +69 |-a or dict() or True # SIM222 + 69 |+a or True # SIM222 +70 70 | +71 71 | a or {1: 1} or True or {2: 2} # SIM222 +72 72 | + +SIM222.py:71:6: SIM222 [*] Use `{1: 1}` instead of `{1: 1} or ...` + | +69 | a or dict() or True # SIM222 +70 | +71 | a or {1: 1} or True or {2: 2} # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +72 | +73 | a or dict({1: 1}) or True or dict({2: 2}) # SIM222 + | + = help: Replace with `{1: 1}` + +ℹ Suggested fix +68 68 | +69 69 | a or dict() or True # SIM222 +70 70 | +71 |-a or {1: 1} or True or {2: 2} # SIM222 + 71 |+a or {1: 1} # SIM222 +72 72 | +73 73 | a or dict({1: 1}) or True or dict({2: 2}) # SIM222 +74 74 | + +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 | +73 | a or dict({1: 1}) or True or dict({2: 2}) # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +74 | +75 | a or set() or True # SIM222 + | + = help: Replace with `dict({1: 1})` + +ℹ Suggested fix +70 70 | +71 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 + 73 |+a or dict({1: 1}) # SIM222 +74 74 | +75 75 | a or set() or True # SIM222 +76 76 | + +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 | +75 | a or set() or True # SIM222 + | ^^^^^^^^^^^^^ SIM222 +76 | +77 | a or set(set()) or True # SIM222 + | + = help: Replace with `True` + +ℹ Suggested fix +72 72 | +73 73 | a or dict({1: 1}) or True or dict({2: 2}) # SIM222 +74 74 | +75 |-a or set() or True # SIM222 + 75 |+a or True # SIM222 +76 76 | +77 77 | a or set(set()) or True # SIM222 +78 78 | + +SIM222.py:77:6: SIM222 [*] Use `True` instead of `... or True` + | +75 | a or set() or True # SIM222 +76 | +77 | a or set(set()) or True # SIM222 + | ^^^^^^^^^^^^^^^^^^ SIM222 +78 | +79 | a or {1} or True or {2} # SIM222 + | + = help: Replace with `True` + +ℹ Suggested fix +74 74 | +75 75 | a or set() or True # SIM222 +76 76 | +77 |-a or set(set()) or True # SIM222 + 77 |+a or True # SIM222 +78 78 | +79 79 | a or {1} or True or {2} # SIM222 +80 80 | + +SIM222.py:79:6: SIM222 [*] Use `{1}` instead of `{1} or ...` + | +77 | a or set(set()) or True # SIM222 +78 | +79 | a or {1} or True or {2} # SIM222 + | ^^^^^^^^^^^^^^^^^^ SIM222 +80 | +81 | a or set({1}) or True or set({2}) # SIM222 + | + = help: Replace with `{1}` + +ℹ Suggested fix +76 76 | +77 77 | a or set(set()) or True # SIM222 +78 78 | +79 |-a or {1} or True or {2} # SIM222 + 79 |+a or {1} # SIM222 +80 80 | +81 81 | a or set({1}) or True or set({2}) # SIM222 +82 82 | + +SIM222.py:81:6: SIM222 [*] Use `set({1})` instead of `set({1}) or ...` + | +79 | a or {1} or True or {2} # SIM222 +80 | +81 | a or set({1}) or True or set({2}) # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +82 | +83 | a or () or True # SIM222 + | + = help: Replace with `set({1})` + +ℹ Suggested fix +78 78 | +79 79 | a or {1} or True or {2} # SIM222 +80 80 | +81 |-a or set({1}) or True or set({2}) # SIM222 + 81 |+a or set({1}) # SIM222 +82 82 | +83 83 | a or () or True # SIM222 +84 84 | + +SIM222.py:83:6: SIM222 [*] Use `True` instead of `... or True` + | +81 | a or set({1}) or True or set({2}) # SIM222 +82 | +83 | a or () or True # SIM222 + | ^^^^^^^^^^ SIM222 +84 | +85 | a or tuple(()) or True # SIM222 + | + = help: Replace with `True` + +ℹ Suggested fix +80 80 | +81 81 | a or set({1}) or True or set({2}) # SIM222 +82 82 | +83 |-a or () or True # SIM222 + 83 |+a or True # SIM222 +84 84 | +85 85 | a or tuple(()) or True # SIM222 +86 86 | + +SIM222.py:85:6: SIM222 [*] Use `True` instead of `... or True` + | +83 | a or () or True # SIM222 +84 | +85 | a or tuple(()) or True # SIM222 + | ^^^^^^^^^^^^^^^^^ SIM222 +86 | +87 | a or (1,) or True or (2,) # SIM222 + | + = help: Replace with `True` + +ℹ Suggested fix +82 82 | +83 83 | a or () or True # SIM222 +84 84 | +85 |-a or tuple(()) or True # SIM222 + 85 |+a or True # SIM222 +86 86 | +87 87 | a or (1,) or True or (2,) # SIM222 +88 88 | + +SIM222.py:87:6: SIM222 [*] Use `(1,)` instead of `(1,) or ...` + | +85 | a or tuple(()) or True # SIM222 +86 | +87 | a or (1,) or True or (2,) # SIM222 + | ^^^^^^^^^^^^^^^^^^^^ SIM222 +88 | +89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 + | + = help: Replace with `(1,)` + +ℹ Suggested fix +84 84 | +85 85 | a or tuple(()) or True # SIM222 +86 86 | +87 |-a or (1,) or True or (2,) # SIM222 + 87 |+a or (1,) # SIM222 +88 88 | +89 89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 +90 90 | + +SIM222.py:89:6: SIM222 [*] Use `tuple((1,))` instead of `tuple((1,)) or ...` + | +87 | a or (1,) or True or (2,) # SIM222 +88 | +89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +90 | +91 | a or frozenset() or True # SIM222 + | + = help: Replace with `tuple((1,))` + +ℹ Suggested fix +86 86 | +87 87 | a or (1,) or True or (2,) # SIM222 +88 88 | +89 |-a or tuple((1,)) or True or tuple((2,)) # SIM222 + 89 |+a or tuple((1,)) # SIM222 +90 90 | +91 91 | a or frozenset() or True # SIM222 +92 92 | + +SIM222.py:91:6: SIM222 [*] Use `True` instead of `... or True` + | +89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 +90 | +91 | a or frozenset() or True # SIM222 + | ^^^^^^^^^^^^^^^^^^^ SIM222 +92 | +93 | a or frozenset(frozenset()) or True # SIM222 + | + = help: Replace with `True` + +ℹ Suggested fix +88 88 | +89 89 | a or tuple((1,)) or True or tuple((2,)) # SIM222 +90 90 | +91 |-a or frozenset() or True # SIM222 + 91 |+a or True # SIM222 +92 92 | +93 93 | a or frozenset(frozenset()) or True # SIM222 +94 94 | + +SIM222.py:93:6: SIM222 [*] Use `True` instead of `... or True` + | +91 | a or frozenset() or True # SIM222 +92 | +93 | a or frozenset(frozenset()) or True # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +94 | +95 | a or frozenset({1}) or True or frozenset({2}) # SIM222 + | + = help: Replace with `True` + +ℹ Suggested fix +90 90 | +91 91 | a or frozenset() or True # SIM222 +92 92 | +93 |-a or frozenset(frozenset()) or True # SIM222 + 93 |+a or True # SIM222 +94 94 | +95 95 | a or frozenset({1}) or True or frozenset({2}) # SIM222 +96 96 | + +SIM222.py:95:6: SIM222 [*] Use `frozenset({1})` instead of `frozenset({1}) or ...` + | +93 | a or frozenset(frozenset()) or True # SIM222 +94 | +95 | a or frozenset({1}) or True or frozenset({2}) # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +96 | +97 | a or frozenset(frozenset({1})) or True or frozenset(frozenset({2})) # SIM222 + | + = help: Replace with `frozenset({1})` + +ℹ Suggested fix +92 92 | +93 93 | a or frozenset(frozenset()) or True # SIM222 +94 94 | +95 |-a or frozenset({1}) or True or frozenset({2}) # SIM222 + 95 |+a or frozenset({1}) # SIM222 +96 96 | +97 97 | a or frozenset(frozenset({1})) or True or frozenset(frozenset({2})) # SIM222 +98 98 | + +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 | +97 | a or frozenset(frozenset({1})) or True or frozenset(frozenset({2})) # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM222 + | + = help: Replace with `frozenset(frozenset({1}))` + +ℹ Suggested fix +94 94 | +95 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 + 97 |+a or frozenset(frozenset({1})) # SIM222 +98 98 | +99 99 | +100 100 | # Inside test `a` is simplified. + +SIM222.py:102:6: SIM222 [*] Use `True` instead of `... or True or ...` + | +100 | # Inside test `a` is simplified. +101 | +102 | bool(a or [1] or True or [2]) # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +103 | +104 | assert a or [1] or True or [2] # SIM222 + | + = help: Replace with `True` + +ℹ Suggested fix +99 99 | +100 100 | # Inside test `a` is simplified. +101 101 | +102 |-bool(a or [1] or True or [2]) # SIM222 + 102 |+bool(True) # SIM222 +103 103 | +104 104 | assert a or [1] or True or [2] # SIM222 +105 105 | + +SIM222.py:104:8: SIM222 [*] Use `True` instead of `... or True or ...` + | +102 | bool(a or [1] or True or [2]) # SIM222 +103 | +104 | assert a or [1] or True or [2] # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +105 | +106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 + | + = help: Replace with `True` + +ℹ Suggested fix +101 101 | +102 102 | bool(a or [1] or True or [2]) # SIM222 +103 103 | +104 |-assert a or [1] or True or [2] # SIM222 + 104 |+assert True # SIM222 +105 105 | +106 106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 +107 107 | pass + +SIM222.py:106:5: SIM222 [*] Use `True` instead of `... or True or ...` + | +104 | assert a or [1] or True or [2] # SIM222 +105 | +106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +107 | pass + | + = help: Replace with `True` + +ℹ Suggested fix +103 103 | +104 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 + 106 |+if (True) and (a or [1] or True or [2]): # SIM222 +107 107 | pass +108 108 | +109 109 | 0 if a or [1] or True or [2] else 1 # SIM222 + +SIM222.py:106:35: SIM222 [*] Use `True` instead of `... or True or ...` + | +104 | assert a or [1] or True or [2] # SIM222 +105 | +106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +107 | pass + | + = help: Replace with `True` + +ℹ Suggested fix +103 103 | +104 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 + 106 |+if (a or [1] or True or [2]) and (True): # SIM222 +107 107 | pass +108 108 | +109 109 | 0 if a or [1] or True or [2] else 1 # SIM222 + +SIM222.py:109:6: SIM222 [*] Use `True` instead of `... or True or ...` + | +107 | pass +108 | +109 | 0 if a or [1] or True or [2] else 1 # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +110 | +111 | while a or [1] or True or [2]: # SIM222 + | + = help: Replace with `True` + +ℹ Suggested fix +106 106 | if (a or [1] or True or [2]) and (a or [1] or True or [2]): # SIM222 +107 107 | pass +108 108 | +109 |-0 if a or [1] or True or [2] else 1 # SIM222 + 109 |+0 if True else 1 # SIM222 +110 110 | +111 111 | while a or [1] or True or [2]: # SIM222 +112 112 | pass + +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 | +111 | while a or [1] or True or [2]: # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +112 | pass + | + = help: Replace with `True` + +ℹ Suggested fix +108 108 | +109 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 + 111 |+while True: # SIM222 +112 112 | pass +113 113 | +114 114 | [ + +SIM222.py:118:8: SIM222 [*] Use `True` instead of `... or True or ...` + | +116 | for a in range(10) +117 | for b in range(10) +118 | if a or [1] or True or [2] # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +119 | if b or [1] or True or [2] # SIM222 +120 | ] + | + = help: Replace with `True` + +ℹ Suggested fix +115 115 | 0 +116 116 | for a in range(10) +117 117 | for b in range(10) +118 |- if a or [1] or True or [2] # SIM222 + 118 |+ if True # SIM222 +119 119 | if b or [1] or True or [2] # SIM222 +120 120 | ] +121 121 | + +SIM222.py:119:8: SIM222 [*] Use `True` instead of `... or True or ...` + | +117 | for b in range(10) +118 | if a or [1] or True or [2] # SIM222 +119 | if b or [1] or True or [2] # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +120 | ] + | + = help: Replace with `True` + +ℹ Suggested fix +116 116 | for a in range(10) +117 117 | for b in range(10) +118 118 | if a or [1] or True or [2] # SIM222 +119 |- if b or [1] or True or [2] # SIM222 + 119 |+ if True # SIM222 +120 120 | ] +121 121 | +122 122 | { + +SIM222.py:126:8: SIM222 [*] Use `True` instead of `... or True or ...` + | +124 | for a in range(10) +125 | for b in range(10) +126 | if a or [1] or True or [2] # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +127 | if b or [1] or True or [2] # SIM222 +128 | } + | + = help: Replace with `True` + +ℹ Suggested fix +123 123 | 0 +124 124 | for a in range(10) +125 125 | for b in range(10) +126 |- if a or [1] or True or [2] # SIM222 + 126 |+ if True # SIM222 +127 127 | if b or [1] or True or [2] # SIM222 +128 128 | } +129 129 | + +SIM222.py:127:8: SIM222 [*] Use `True` instead of `... or True or ...` + | +125 | for b in range(10) +126 | if a or [1] or True or [2] # SIM222 +127 | if b or [1] or True or [2] # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +128 | } + | + = help: Replace with `True` + +ℹ Suggested fix +124 124 | for a in range(10) +125 125 | for b in range(10) +126 126 | if a or [1] or True or [2] # SIM222 +127 |- if b or [1] or True or [2] # SIM222 + 127 |+ if True # SIM222 +128 128 | } +129 129 | +130 130 | { + +SIM222.py:134:8: SIM222 [*] Use `True` instead of `... or True or ...` + | +132 | for a in range(10) +133 | for b in range(10) +134 | if a or [1] or True or [2] # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +135 | if b or [1] or True or [2] # SIM222 +136 | } + | + = help: Replace with `True` + +ℹ Suggested fix +131 131 | 0: 0 +132 132 | for a in range(10) +133 133 | for b in range(10) +134 |- if a or [1] or True or [2] # SIM222 + 134 |+ if True # SIM222 +135 135 | if b or [1] or True or [2] # SIM222 +136 136 | } +137 137 | + +SIM222.py:135:8: SIM222 [*] Use `True` instead of `... or True or ...` + | +133 | for b in range(10) +134 | if a or [1] or True or [2] # SIM222 +135 | if b or [1] or True or [2] # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +136 | } + | + = help: Replace with `True` + +ℹ Suggested fix +132 132 | for a in range(10) +133 133 | for b in range(10) +134 134 | if a or [1] or True or [2] # SIM222 +135 |- if b or [1] or True or [2] # SIM222 + 135 |+ if True # SIM222 +136 136 | } +137 137 | +138 138 | ( + +SIM222.py:142:8: SIM222 [*] Use `True` instead of `... or True or ...` + | +140 | for a in range(10) +141 | for b in range(10) +142 | if a or [1] or True or [2] # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +143 | if b or [1] or True or [2] # SIM222 +144 | ) + | + = help: Replace with `True` + +ℹ Suggested fix +139 139 | 0 +140 140 | for a in range(10) +141 141 | for b in range(10) +142 |- if a or [1] or True or [2] # SIM222 + 142 |+ if True # SIM222 +143 143 | if b or [1] or True or [2] # SIM222 +144 144 | ) +145 145 | + +SIM222.py:143:8: SIM222 [*] Use `True` instead of `... or True or ...` + | +141 | for b in range(10) +142 | if a or [1] or True or [2] # SIM222 +143 | if b or [1] or True or [2] # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM222 +144 | ) + | + = help: Replace with `True` + +ℹ Suggested fix +140 140 | for a in range(10) +141 141 | for b in range(10) +142 142 | if a or [1] or True or [2] # SIM222 +143 |- if b or [1] or True or [2] # SIM222 + 143 |+ if True # SIM222 +144 144 | ) +145 145 | +146 146 | # Outside test `a` is not simplified. + +SIM222.py:148:6: SIM222 [*] Use `[1]` instead of `[1] or ...` + | +146 | # Outside test `a` is not simplified. +147 | +148 | a or [1] or True or [2] # SIM222 + | ^^^^^^^^^^^^^^^^^^ SIM222 +149 | +150 | if (a or [1] or True or [2]) == (a or [1]): # SIM222 + | + = help: Replace with `[1]` + +ℹ Suggested fix +145 145 | +146 146 | # Outside test `a` is not simplified. +147 147 | +148 |-a or [1] or True or [2] # SIM222 + 148 |+a or [1] # SIM222 +149 149 | +150 150 | if (a or [1] or True or [2]) == (a or [1]): # SIM222 +151 151 | pass + +SIM222.py:150:10: SIM222 [*] Use `[1]` instead of `[1] or ...` + | +148 | a or [1] or True or [2] # SIM222 +149 | +150 | if (a or [1] or True or [2]) == (a or [1]): # SIM222 + | ^^^^^^^^^^^^^^^^^^ SIM222 +151 | pass + | + = help: Replace with `[1]` + +ℹ Suggested fix +147 147 | +148 148 | a or [1] or True or [2] # SIM222 +149 149 | +150 |-if (a or [1] or True or [2]) == (a or [1]): # SIM222 + 150 |+if (a or [1]) == (a or [1]): # SIM222 +151 151 | pass +152 152 | +153 153 | if f(a or [1] or True or [2]): # SIM222 + +SIM222.py:153:11: SIM222 [*] Use `[1]` instead of `[1] or ...` + | +151 | pass +152 | +153 | if f(a or [1] or True or [2]): # SIM222 + | ^^^^^^^^^^^^^^^^^^ SIM222 +154 | pass + | + = help: Replace with `[1]` + +ℹ Suggested fix +150 150 | if (a or [1] or True or [2]) == (a or [1]): # SIM222 +151 151 | pass +152 152 | +153 |-if f(a or [1] or True or [2]): # SIM222 + 153 |+if f(a or [1]): # SIM222 +154 154 | pass +155 155 | +156 156 | # Regression test for: https://github.com/astral-sh/ruff/issues/7099 + +SIM222.py:157:30: SIM222 [*] Use `(int, int, int)` instead of `(int, int, int) or ...` + | +156 | # Regression test for: https://github.com/astral-sh/ruff/issues/7099 +157 | def secondToTime(s0: int) -> (int, int, int) or str: + | ^^^^^^^^^^^^^^^^^^^^^^ SIM222 +158 | m, s = divmod(s0, 60) + | + = help: Replace with `(int, int, int)` + +ℹ Suggested fix +154 154 | pass +155 155 | +156 156 | # Regression test for: https://github.com/astral-sh/ruff/issues/7099 +157 |-def secondToTime(s0: int) -> (int, int, int) or str: + 157 |+def secondToTime(s0: int) -> (int, int, int): +158 158 | m, s = divmod(s0, 60) +159 159 | +160 160 | + +SIM222.py:161:31: SIM222 [*] Use `(int, int, int)` instead of `(int, int, int) or ...` + | +161 | def secondToTime(s0: int) -> ((int, int, int) or str): + | ^^^^^^^^^^^^^^^^^^^^^^ SIM222 +162 | m, s = divmod(s0, 60) + | + = help: Replace with `(int, int, int)` + +ℹ Suggested fix +158 158 | m, s = divmod(s0, 60) +159 159 | +160 160 | +161 |-def secondToTime(s0: int) -> ((int, int, int) or str): + 161 |+def secondToTime(s0: int) -> ((int, int, int)): +162 162 | m, s = divmod(s0, 60) + + 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 new file mode 100644 index 0000000000..4454bf4851 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM223_SIM223.py.snap @@ -0,0 +1,1007 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM223.py:1:4: SIM223 [*] Use `False` instead of `... and False` + | +1 | if a and False: # SIM223 + | ^^^^^^^^^^^ SIM223 +2 | pass + | + = help: Replace with `False` + +ℹ Suggested fix +1 |-if a and False: # SIM223 + 1 |+if False: # SIM223 +2 2 | pass +3 3 | +4 4 | if (a or b) and False: # SIM223 + +SIM223.py:4:4: SIM223 [*] Use `False` instead of `... and False` + | +2 | pass +3 | +4 | if (a or b) and False: # SIM223 + | ^^^^^^^^^^^^^^^^^^ SIM223 +5 | pass + | + = help: Replace with `False` + +ℹ Suggested fix +1 1 | if a and False: # SIM223 +2 2 | pass +3 3 | +4 |-if (a or b) and False: # SIM223 + 4 |+if False: # SIM223 +5 5 | pass +6 6 | +7 7 | if a or (b and False): # SIM223 + +SIM223.py:7:10: SIM223 [*] Use `False` instead of `... and False` + | +5 | pass +6 | +7 | if a or (b and False): # SIM223 + | ^^^^^^^^^^^ SIM223 +8 | pass + | + = help: Replace with `False` + +ℹ Suggested fix +4 4 | if (a or b) and False: # SIM223 +5 5 | pass +6 6 | +7 |-if a or (b and False): # SIM223 + 7 |+if a or (False): # SIM223 +8 8 | pass +9 9 | +10 10 | if a or False: + +SIM223.py:19:18: SIM223 [*] Use `False` instead of `False and ...` + | +17 | pass +18 | +19 | if a and f() and False and g() and b: # SIM223 + | ^^^^^^^^^^^^^^^^^^^ SIM223 +20 | pass + | + = help: Replace with `False` + +ℹ Suggested fix +16 16 | if a and f() and b and g() and False: # OK +17 17 | pass +18 18 | +19 |-if a and f() and False and g() and b: # SIM223 + 19 |+if a and f() and False: # SIM223 +20 20 | pass +21 21 | +22 22 | if False and f() and a and g() and b: # SIM223 + +SIM223.py:22:4: SIM223 [*] Use `False` instead of `False and ...` + | +20 | pass +21 | +22 | if False and f() and a and g() and b: # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +23 | pass + | + = help: Replace with `False` + +ℹ Suggested fix +19 19 | if a and f() and False and g() and b: # SIM223 +20 20 | pass +21 21 | +22 |-if False and f() and a and g() and b: # SIM223 + 22 |+if False: # SIM223 +23 23 | pass +24 24 | +25 25 | if a and False and f() and b and g(): # SIM223 + +SIM223.py:25:4: SIM223 [*] Use `False` instead of `... and False and ...` + | +23 | pass +24 | +25 | if a and False and f() and b and g(): # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +26 | pass + | + = help: Replace with `False` + +ℹ Suggested fix +22 22 | if False and f() and a and g() and b: # SIM223 +23 23 | pass +24 24 | +25 |-if a and False and f() and b and g(): # SIM223 + 25 |+if False: # SIM223 +26 26 | pass +27 27 | +28 28 | + +SIM223.py:42:7: SIM223 [*] Use `""` instead of `"" and ...` + | +42 | a and "" and False # SIM223 + | ^^^^^^^^^^^^ SIM223 +43 | +44 | a and "foo" and False and "bar" # SIM223 + | + = help: Replace with `""` + +ℹ Suggested fix +39 39 | pass +40 40 | +41 41 | +42 |-a and "" and False # SIM223 + 42 |+a and "" # SIM223 +43 43 | +44 44 | a and "foo" and False and "bar" # SIM223 +45 45 | + +SIM223.py:44:7: SIM223 [*] Use `False` instead of `... and False and ...` + | +42 | a and "" and False # SIM223 +43 | +44 | a and "foo" and False and "bar" # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +45 | +46 | a and 0 and False # SIM223 + | + = help: Replace with `False` + +ℹ Suggested fix +41 41 | +42 42 | a and "" and False # SIM223 +43 43 | +44 |-a and "foo" and False and "bar" # SIM223 + 44 |+a and False # SIM223 +45 45 | +46 46 | a and 0 and False # SIM223 +47 47 | + +SIM223.py:46:7: SIM223 [*] Use `0` instead of `0 and ...` + | +44 | a and "foo" and False and "bar" # SIM223 +45 | +46 | a and 0 and False # SIM223 + | ^^^^^^^^^^^ SIM223 +47 | +48 | a and 1 and False and 2 # SIM223 + | + = help: Replace with `0` + +ℹ Suggested fix +43 43 | +44 44 | a and "foo" and False and "bar" # SIM223 +45 45 | +46 |-a and 0 and False # SIM223 + 46 |+a and 0 # SIM223 +47 47 | +48 48 | a and 1 and False and 2 # SIM223 +49 49 | + +SIM223.py:48:7: SIM223 [*] Use `False` instead of `... and False and ...` + | +46 | a and 0 and False # SIM223 +47 | +48 | a and 1 and False and 2 # SIM223 + | ^^^^^^^^^^^^^^^^^ SIM223 +49 | +50 | a and 0.0 and False # SIM223 + | + = help: Replace with `False` + +ℹ Suggested fix +45 45 | +46 46 | a and 0 and False # SIM223 +47 47 | +48 |-a and 1 and False and 2 # SIM223 + 48 |+a and False # SIM223 +49 49 | +50 50 | a and 0.0 and False # SIM223 +51 51 | + +SIM223.py:50:7: SIM223 [*] Use `0.0` instead of `0.0 and ...` + | +48 | a and 1 and False and 2 # SIM223 +49 | +50 | a and 0.0 and False # SIM223 + | ^^^^^^^^^^^^^ SIM223 +51 | +52 | a and 0.1 and False and 0.2 # SIM223 + | + = help: Replace with `0.0` + +ℹ Suggested fix +47 47 | +48 48 | a and 1 and False and 2 # SIM223 +49 49 | +50 |-a and 0.0 and False # SIM223 + 50 |+a and 0.0 # SIM223 +51 51 | +52 52 | a and 0.1 and False and 0.2 # SIM223 +53 53 | + +SIM223.py:52:7: SIM223 [*] Use `False` instead of `... and False and ...` + | +50 | a and 0.0 and False # SIM223 +51 | +52 | a and 0.1 and False and 0.2 # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^ SIM223 +53 | +54 | a and [] and False # SIM223 + | + = help: Replace with `False` + +ℹ Suggested fix +49 49 | +50 50 | a and 0.0 and False # SIM223 +51 51 | +52 |-a and 0.1 and False and 0.2 # SIM223 + 52 |+a and False # SIM223 +53 53 | +54 54 | a and [] and False # SIM223 +55 55 | + +SIM223.py:54:7: SIM223 [*] Use `[]` instead of `[] and ...` + | +52 | a and 0.1 and False and 0.2 # SIM223 +53 | +54 | a and [] and False # SIM223 + | ^^^^^^^^^^^^ SIM223 +55 | +56 | a and list([]) and False # SIM223 + | + = help: Replace with `[]` + +ℹ Suggested fix +51 51 | +52 52 | a and 0.1 and False and 0.2 # SIM223 +53 53 | +54 |-a and [] and False # SIM223 + 54 |+a and [] # SIM223 +55 55 | +56 56 | a and list([]) and False # SIM223 +57 57 | + +SIM223.py:56:7: SIM223 [*] Use `list([])` instead of `list([]) and ...` + | +54 | a and [] and False # SIM223 +55 | +56 | a and list([]) and False # SIM223 + | ^^^^^^^^^^^^^^^^^^ SIM223 +57 | +58 | a and [1] and False and [2] # SIM223 + | + = help: Replace with `list([])` + +ℹ Suggested fix +53 53 | +54 54 | a and [] and False # SIM223 +55 55 | +56 |-a and list([]) and False # SIM223 + 56 |+a and list([]) # SIM223 +57 57 | +58 58 | a and [1] and False and [2] # SIM223 +59 59 | + +SIM223.py:58:7: SIM223 [*] Use `False` instead of `... and False and ...` + | +56 | a and list([]) and False # SIM223 +57 | +58 | a and [1] and False and [2] # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^ SIM223 +59 | +60 | a and list([1]) and False and list([2]) # SIM223 + | + = help: Replace with `False` + +ℹ Suggested fix +55 55 | +56 56 | a and list([]) and False # SIM223 +57 57 | +58 |-a and [1] and False and [2] # SIM223 + 58 |+a and False # SIM223 +59 59 | +60 60 | a and list([1]) and False and list([2]) # SIM223 +61 61 | + +SIM223.py:60:7: SIM223 [*] Use `False` instead of `... and False and ...` + | +58 | a and [1] and False and [2] # SIM223 +59 | +60 | a and list([1]) and False and list([2]) # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +61 | +62 | a and {} and False # SIM223 + | + = help: Replace with `False` + +ℹ Suggested fix +57 57 | +58 58 | a and [1] and False and [2] # SIM223 +59 59 | +60 |-a and list([1]) and False and list([2]) # SIM223 + 60 |+a and False # SIM223 +61 61 | +62 62 | a and {} and False # SIM223 +63 63 | + +SIM223.py:62:7: SIM223 [*] Use `{}` instead of `{} and ...` + | +60 | a and list([1]) and False and list([2]) # SIM223 +61 | +62 | a and {} and False # SIM223 + | ^^^^^^^^^^^^ SIM223 +63 | +64 | a and dict() and False # SIM223 + | + = help: Replace with `{}` + +ℹ Suggested fix +59 59 | +60 60 | a and list([1]) and False and list([2]) # SIM223 +61 61 | +62 |-a and {} and False # SIM223 + 62 |+a and {} # SIM223 +63 63 | +64 64 | a and dict() and False # SIM223 +65 65 | + +SIM223.py:64:7: SIM223 [*] Use `dict()` instead of `dict() and ...` + | +62 | a and {} and False # SIM223 +63 | +64 | a and dict() and False # SIM223 + | ^^^^^^^^^^^^^^^^ SIM223 +65 | +66 | a and {1: 1} and False and {2: 2} # SIM223 + | + = help: Replace with `dict()` + +ℹ Suggested fix +61 61 | +62 62 | a and {} and False # SIM223 +63 63 | +64 |-a and dict() and False # SIM223 + 64 |+a and dict() # SIM223 +65 65 | +66 66 | a and {1: 1} and False and {2: 2} # SIM223 +67 67 | + +SIM223.py:66:7: SIM223 [*] Use `False` instead of `... and False and ...` + | +64 | a and dict() and False # SIM223 +65 | +66 | a and {1: 1} and False and {2: 2} # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +67 | +68 | a and dict({1: 1}) and False and dict({2: 2}) # SIM223 + | + = help: Replace with `False` + +ℹ Suggested fix +63 63 | +64 64 | a and dict() and False # SIM223 +65 65 | +66 |-a and {1: 1} and False and {2: 2} # SIM223 + 66 |+a and False # SIM223 +67 67 | +68 68 | a and dict({1: 1}) and False and dict({2: 2}) # SIM223 +69 69 | + +SIM223.py:68:7: SIM223 [*] Use `False` instead of `... and False and ...` + | +66 | a and {1: 1} and False and {2: 2} # SIM223 +67 | +68 | a and dict({1: 1}) and False and dict({2: 2}) # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +69 | +70 | a and set() and False # SIM223 + | + = help: Replace with `False` + +ℹ Suggested fix +65 65 | +66 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 + 68 |+a and False # SIM223 +69 69 | +70 70 | a and set() and False # SIM223 +71 71 | + +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 | +70 | a and set() and False # SIM223 + | ^^^^^^^^^^^^^^^ SIM223 +71 | +72 | a and set(set()) and False # SIM223 + | + = help: Replace with `set()` + +ℹ Suggested fix +67 67 | +68 68 | a and dict({1: 1}) and False and dict({2: 2}) # SIM223 +69 69 | +70 |-a and set() and False # SIM223 + 70 |+a and set() # SIM223 +71 71 | +72 72 | a and set(set()) and False # SIM223 +73 73 | + +SIM223.py:72:7: SIM223 [*] Use `set(set())` instead of `set(set()) and ...` + | +70 | a and set() and False # SIM223 +71 | +72 | a and set(set()) and False # SIM223 + | ^^^^^^^^^^^^^^^^^^^^ SIM223 +73 | +74 | a and {1} and False and {2} # SIM223 + | + = help: Replace with `set(set())` + +ℹ Suggested fix +69 69 | +70 70 | a and set() and False # SIM223 +71 71 | +72 |-a and set(set()) and False # SIM223 + 72 |+a and set(set()) # SIM223 +73 73 | +74 74 | a and {1} and False and {2} # SIM223 +75 75 | + +SIM223.py:74:7: SIM223 [*] Use `False` instead of `... and False and ...` + | +72 | a and set(set()) and False # SIM223 +73 | +74 | a and {1} and False and {2} # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^ SIM223 +75 | +76 | a and set({1}) and False and set({2}) # SIM223 + | + = help: Replace with `False` + +ℹ Suggested fix +71 71 | +72 72 | a and set(set()) and False # SIM223 +73 73 | +74 |-a and {1} and False and {2} # SIM223 + 74 |+a and False # SIM223 +75 75 | +76 76 | a and set({1}) and False and set({2}) # SIM223 +77 77 | + +SIM223.py:76:7: SIM223 [*] Use `False` instead of `... and False and ...` + | +74 | a and {1} and False and {2} # SIM223 +75 | +76 | a and set({1}) and False and set({2}) # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +77 | +78 | a and () and False # SIM222 + | + = help: Replace with `False` + +ℹ Suggested fix +73 73 | +74 74 | a and {1} and False and {2} # SIM223 +75 75 | +76 |-a and set({1}) and False and set({2}) # SIM223 + 76 |+a and False # SIM223 +77 77 | +78 78 | a and () and False # SIM222 +79 79 | + +SIM223.py:78:7: SIM223 [*] Use `()` instead of `() and ...` + | +76 | a and set({1}) and False and set({2}) # SIM223 +77 | +78 | a and () and False # SIM222 + | ^^^^^^^^^^^^ SIM223 +79 | +80 | a and tuple(()) and False # SIM222 + | + = help: Replace with `()` + +ℹ Suggested fix +75 75 | +76 76 | a and set({1}) and False and set({2}) # SIM223 +77 77 | +78 |-a and () and False # SIM222 + 78 |+a and () # SIM222 +79 79 | +80 80 | a and tuple(()) and False # SIM222 +81 81 | + +SIM223.py:80:7: SIM223 [*] Use `tuple(())` instead of `tuple(()) and ...` + | +78 | a and () and False # SIM222 +79 | +80 | a and tuple(()) and False # SIM222 + | ^^^^^^^^^^^^^^^^^^^ SIM223 +81 | +82 | a and (1,) and False and (2,) # SIM222 + | + = help: Replace with `tuple(())` + +ℹ Suggested fix +77 77 | +78 78 | a and () and False # SIM222 +79 79 | +80 |-a and tuple(()) and False # SIM222 + 80 |+a and tuple(()) # SIM222 +81 81 | +82 82 | a and (1,) and False and (2,) # SIM222 +83 83 | + +SIM223.py:82:7: SIM223 [*] Use `False` instead of `... and False and ...` + | +80 | a and tuple(()) and False # SIM222 +81 | +82 | a and (1,) and False and (2,) # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +83 | +84 | a and tuple((1,)) and False and tuple((2,)) # SIM222 + | + = help: Replace with `False` + +ℹ Suggested fix +79 79 | +80 80 | a and tuple(()) and False # SIM222 +81 81 | +82 |-a and (1,) and False and (2,) # SIM222 + 82 |+a and False # SIM222 +83 83 | +84 84 | a and tuple((1,)) and False and tuple((2,)) # SIM222 +85 85 | + +SIM223.py:84:7: SIM223 [*] Use `False` instead of `... and False and ...` + | +82 | a and (1,) and False and (2,) # SIM222 +83 | +84 | a and tuple((1,)) and False and tuple((2,)) # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +85 | +86 | a and frozenset() and False # SIM222 + | + = help: Replace with `False` + +ℹ Suggested fix +81 81 | +82 82 | a and (1,) and False and (2,) # SIM222 +83 83 | +84 |-a and tuple((1,)) and False and tuple((2,)) # SIM222 + 84 |+a and False # SIM222 +85 85 | +86 86 | a and frozenset() and False # SIM222 +87 87 | + +SIM223.py:86:7: SIM223 [*] Use `frozenset()` instead of `frozenset() and ...` + | +84 | a and tuple((1,)) and False and tuple((2,)) # SIM222 +85 | +86 | a and frozenset() and False # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^ SIM223 +87 | +88 | a and frozenset(frozenset()) and False # SIM222 + | + = help: Replace with `frozenset()` + +ℹ Suggested fix +83 83 | +84 84 | a and tuple((1,)) and False and tuple((2,)) # SIM222 +85 85 | +86 |-a and frozenset() and False # SIM222 + 86 |+a and frozenset() # SIM222 +87 87 | +88 88 | a and frozenset(frozenset()) and False # SIM222 +89 89 | + +SIM223.py:88:7: SIM223 [*] Use `frozenset(frozenset())` instead of `frozenset(frozenset()) and ...` + | +86 | a and frozenset() and False # SIM222 +87 | +88 | a and frozenset(frozenset()) and False # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +89 | +90 | a and frozenset({1}) and False and frozenset({2}) # SIM222 + | + = help: Replace with `frozenset(frozenset())` + +ℹ Suggested fix +85 85 | +86 86 | a and frozenset() and False # SIM222 +87 87 | +88 |-a and frozenset(frozenset()) and False # SIM222 + 88 |+a and frozenset(frozenset()) # SIM222 +89 89 | +90 90 | a and frozenset({1}) and False and frozenset({2}) # SIM222 +91 91 | + +SIM223.py:90:7: SIM223 [*] Use `False` instead of `... and False and ...` + | +88 | a and frozenset(frozenset()) and False # SIM222 +89 | +90 | a and frozenset({1}) and False and frozenset({2}) # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +91 | +92 | a and frozenset(frozenset({1})) and False and frozenset(frozenset({2})) # SIM222 + | + = help: Replace with `False` + +ℹ Suggested fix +87 87 | +88 88 | a and frozenset(frozenset()) and False # SIM222 +89 89 | +90 |-a and frozenset({1}) and False and frozenset({2}) # SIM222 + 90 |+a and False # SIM222 +91 91 | +92 92 | a and frozenset(frozenset({1})) and False and frozenset(frozenset({2})) # SIM222 +93 93 | + +SIM223.py:92:7: SIM223 [*] Use `False` instead of `... and False and ...` + | +90 | a and frozenset({1}) and False and frozenset({2}) # SIM222 +91 | +92 | a and frozenset(frozenset({1})) and False and frozenset(frozenset({2})) # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 + | + = help: Replace with `False` + +ℹ Suggested fix +89 89 | +90 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 + 92 |+a and False # SIM222 +93 93 | +94 94 | +95 95 | # Inside test `a` is simplified. + +SIM223.py:97:6: SIM223 [*] Use `False` instead of `... and False and ...` + | +95 | # Inside test `a` is simplified. +96 | +97 | bool(a and [] and False and []) # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +98 | +99 | assert a and [] and False and [] # SIM223 + | + = help: Replace with `False` + +ℹ Suggested fix +94 94 | +95 95 | # Inside test `a` is simplified. +96 96 | +97 |-bool(a and [] and False and []) # SIM223 + 97 |+bool(False) # SIM223 +98 98 | +99 99 | assert a and [] and False and [] # SIM223 +100 100 | + +SIM223.py:99:8: SIM223 [*] Use `False` instead of `... and False and ...` + | + 97 | bool(a and [] and False and []) # SIM223 + 98 | + 99 | assert a and [] and False and [] # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +100 | +101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 + | + = help: Replace with `False` + +ℹ Suggested fix +96 96 | +97 97 | bool(a and [] and False and []) # SIM223 +98 98 | +99 |-assert a and [] and False and [] # SIM223 + 99 |+assert False # SIM223 +100 100 | +101 101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 +102 102 | pass + +SIM223.py:101:5: SIM223 [*] Use `False` instead of `... and False and ...` + | + 99 | assert a and [] and False and [] # SIM223 +100 | +101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +102 | pass + | + = help: Replace with `False` + +ℹ Suggested fix +98 98 | +99 99 | assert a and [] and False and [] # SIM223 +100 100 | +101 |-if (a and [] and False and []) or (a and [] and False and []): # SIM223 + 101 |+if (False) or (a and [] and False and []): # SIM223 +102 102 | pass +103 103 | +104 104 | 0 if a and [] and False and [] else 1 # SIM222 + +SIM223.py:101:36: SIM223 [*] Use `False` instead of `... and False and ...` + | + 99 | assert a and [] and False and [] # SIM223 +100 | +101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +102 | pass + | + = help: Replace with `False` + +ℹ Suggested fix +98 98 | +99 99 | assert a and [] and False and [] # SIM223 +100 100 | +101 |-if (a and [] and False and []) or (a and [] and False and []): # SIM223 + 101 |+if (a and [] and False and []) or (False): # SIM223 +102 102 | pass +103 103 | +104 104 | 0 if a and [] and False and [] else 1 # SIM222 + +SIM223.py:104:6: SIM223 [*] Use `False` instead of `... and False and ...` + | +102 | pass +103 | +104 | 0 if a and [] and False and [] else 1 # SIM222 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +105 | +106 | while a and [] and False and []: # SIM223 + | + = help: Replace with `False` + +ℹ Suggested fix +101 101 | if (a and [] and False and []) or (a and [] and False and []): # SIM223 +102 102 | pass +103 103 | +104 |-0 if a and [] and False and [] else 1 # SIM222 + 104 |+0 if False else 1 # SIM222 +105 105 | +106 106 | while a and [] and False and []: # SIM223 +107 107 | pass + +SIM223.py:106:7: SIM223 [*] Use `False` instead of `... and False and ...` + | +104 | 0 if a and [] and False and [] else 1 # SIM222 +105 | +106 | while a and [] and False and []: # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +107 | pass + | + = help: Replace with `False` + +ℹ Suggested fix +103 103 | +104 104 | 0 if a and [] and False and [] else 1 # SIM222 +105 105 | +106 |-while a and [] and False and []: # SIM223 + 106 |+while False: # SIM223 +107 107 | pass +108 108 | +109 109 | [ + +SIM223.py:113:8: SIM223 [*] Use `False` instead of `... and False and ...` + | +111 | for a in range(10) +112 | for b in range(10) +113 | if a and [] and False and [] # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +114 | if b and [] and False and [] # SIM223 +115 | ] + | + = help: Replace with `False` + +ℹ Suggested fix +110 110 | 0 +111 111 | for a in range(10) +112 112 | for b in range(10) +113 |- if a and [] and False and [] # SIM223 + 113 |+ if False # SIM223 +114 114 | if b and [] and False and [] # SIM223 +115 115 | ] +116 116 | + +SIM223.py:114:8: SIM223 [*] Use `False` instead of `... and False and ...` + | +112 | for b in range(10) +113 | if a and [] and False and [] # SIM223 +114 | if b and [] and False and [] # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +115 | ] + | + = help: Replace with `False` + +ℹ Suggested fix +111 111 | for a in range(10) +112 112 | for b in range(10) +113 113 | if a and [] and False and [] # SIM223 +114 |- if b and [] and False and [] # SIM223 + 114 |+ if False # SIM223 +115 115 | ] +116 116 | +117 117 | { + +SIM223.py:121:8: SIM223 [*] Use `False` instead of `... and False and ...` + | +119 | for a in range(10) +120 | for b in range(10) +121 | if a and [] and False and [] # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +122 | if b and [] and False and [] # SIM223 +123 | } + | + = help: Replace with `False` + +ℹ Suggested fix +118 118 | 0 +119 119 | for a in range(10) +120 120 | for b in range(10) +121 |- if a and [] and False and [] # SIM223 + 121 |+ if False # SIM223 +122 122 | if b and [] and False and [] # SIM223 +123 123 | } +124 124 | + +SIM223.py:122:8: SIM223 [*] Use `False` instead of `... and False and ...` + | +120 | for b in range(10) +121 | if a and [] and False and [] # SIM223 +122 | if b and [] and False and [] # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +123 | } + | + = help: Replace with `False` + +ℹ Suggested fix +119 119 | for a in range(10) +120 120 | for b in range(10) +121 121 | if a and [] and False and [] # SIM223 +122 |- if b and [] and False and [] # SIM223 + 122 |+ if False # SIM223 +123 123 | } +124 124 | +125 125 | { + +SIM223.py:129:8: SIM223 [*] Use `False` instead of `... and False and ...` + | +127 | for a in range(10) +128 | for b in range(10) +129 | if a and [] and False and [] # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +130 | if b and [] and False and [] # SIM223 +131 | } + | + = help: Replace with `False` + +ℹ Suggested fix +126 126 | 0: 0 +127 127 | for a in range(10) +128 128 | for b in range(10) +129 |- if a and [] and False and [] # SIM223 + 129 |+ if False # SIM223 +130 130 | if b and [] and False and [] # SIM223 +131 131 | } +132 132 | + +SIM223.py:130:8: SIM223 [*] Use `False` instead of `... and False and ...` + | +128 | for b in range(10) +129 | if a and [] and False and [] # SIM223 +130 | if b and [] and False and [] # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +131 | } + | + = help: Replace with `False` + +ℹ Suggested fix +127 127 | for a in range(10) +128 128 | for b in range(10) +129 129 | if a and [] and False and [] # SIM223 +130 |- if b and [] and False and [] # SIM223 + 130 |+ if False # SIM223 +131 131 | } +132 132 | +133 133 | ( + +SIM223.py:137:8: SIM223 [*] Use `False` instead of `... and False and ...` + | +135 | for a in range(10) +136 | for b in range(10) +137 | if a and [] and False and [] # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +138 | if b and [] and False and [] # SIM223 +139 | ) + | + = help: Replace with `False` + +ℹ Suggested fix +134 134 | 0 +135 135 | for a in range(10) +136 136 | for b in range(10) +137 |- if a and [] and False and [] # SIM223 + 137 |+ if False # SIM223 +138 138 | if b and [] and False and [] # SIM223 +139 139 | ) +140 140 | + +SIM223.py:138:8: SIM223 [*] Use `False` instead of `... and False and ...` + | +136 | for b in range(10) +137 | if a and [] and False and [] # SIM223 +138 | if b and [] and False and [] # SIM223 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ SIM223 +139 | ) + | + = help: Replace with `False` + +ℹ Suggested fix +135 135 | for a in range(10) +136 136 | for b in range(10) +137 137 | if a and [] and False and [] # SIM223 +138 |- if b and [] and False and [] # SIM223 + 138 |+ if False # SIM223 +139 139 | ) +140 140 | +141 141 | # Outside test `a` is not simplified. + +SIM223.py:143:7: SIM223 [*] Use `[]` instead of `[] and ...` + | +141 | # Outside test `a` is not simplified. +142 | +143 | a and [] and False and [] # SIM223 + | ^^^^^^^^^^^^^^^^^^^ SIM223 +144 | +145 | if (a and [] and False and []) == (a and []): # SIM223 + | + = help: Replace with `[]` + +ℹ Suggested fix +140 140 | +141 141 | # Outside test `a` is not simplified. +142 142 | +143 |-a and [] and False and [] # SIM223 + 143 |+a and [] # SIM223 +144 144 | +145 145 | if (a and [] and False and []) == (a and []): # SIM223 +146 146 | pass + +SIM223.py:145:11: SIM223 [*] Use `[]` instead of `[] and ...` + | +143 | a and [] and False and [] # SIM223 +144 | +145 | if (a and [] and False and []) == (a and []): # SIM223 + | ^^^^^^^^^^^^^^^^^^^ SIM223 +146 | pass + | + = help: Replace with `[]` + +ℹ Suggested fix +142 142 | +143 143 | a and [] and False and [] # SIM223 +144 144 | +145 |-if (a and [] and False and []) == (a and []): # SIM223 + 145 |+if (a and []) == (a and []): # SIM223 +146 146 | pass +147 147 | +148 148 | if f(a and [] and False and []): # SIM223 + +SIM223.py:148:12: SIM223 [*] Use `[]` instead of `[] and ...` + | +146 | pass +147 | +148 | if f(a and [] and False and []): # SIM223 + | ^^^^^^^^^^^^^^^^^^^ SIM223 +149 | pass + | + = help: Replace with `[]` + +ℹ Suggested fix +145 145 | if (a and [] and False and []) == (a and []): # SIM223 +146 146 | pass +147 147 | +148 |-if f(a and [] and False and []): # SIM223 + 148 |+if f(a and []): # SIM223 +149 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 new file mode 100644 index 0000000000..6673d7a6a1 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM300_SIM300.py.snap @@ -0,0 +1,356 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM300.py:2:1: SIM300 [*] Yoda conditions are discouraged, use `compare == "yoda"` instead + | +1 | # Errors +2 | "yoda" == compare # SIM300 + | ^^^^^^^^^^^^^^^^^ SIM300 +3 | "yoda" == compare # SIM300 +4 | 42 == age # SIM300 + | + = help: Replace Yoda condition with `compare == "yoda"` + +ℹ Fix +1 1 | # Errors +2 |-"yoda" == compare # SIM300 + 2 |+compare == "yoda" # SIM300 +3 3 | "yoda" == compare # SIM300 +4 4 | 42 == age # SIM300 +5 5 | ("a", "b") == compare # SIM300 + +SIM300.py:3:1: SIM300 [*] Yoda conditions are discouraged, use `compare == "yoda"` instead + | +1 | # Errors +2 | "yoda" == compare # SIM300 +3 | "yoda" == compare # SIM300 + | ^^^^^^^^^^^^^^^^^ SIM300 +4 | 42 == age # SIM300 +5 | ("a", "b") == compare # SIM300 + | + = help: Replace Yoda condition with `compare == "yoda"` + +ℹ Fix +1 1 | # Errors +2 2 | "yoda" == compare # SIM300 +3 |-"yoda" == compare # SIM300 + 3 |+compare == "yoda" # SIM300 +4 4 | 42 == age # SIM300 +5 5 | ("a", "b") == compare # SIM300 +6 6 | "yoda" <= compare # SIM300 + +SIM300.py:4:1: SIM300 [*] Yoda conditions are discouraged, use `age == 42` instead + | +2 | "yoda" == compare # SIM300 +3 | "yoda" == compare # SIM300 +4 | 42 == age # SIM300 + | ^^^^^^^^^ SIM300 +5 | ("a", "b") == compare # SIM300 +6 | "yoda" <= compare # SIM300 + | + = help: Replace Yoda condition with `age == 42` + +ℹ Fix +1 1 | # Errors +2 2 | "yoda" == compare # SIM300 +3 3 | "yoda" == compare # SIM300 +4 |-42 == age # SIM300 + 4 |+age == 42 # SIM300 +5 5 | ("a", "b") == compare # SIM300 +6 6 | "yoda" <= compare # SIM300 +7 7 | "yoda" < compare # SIM300 + +SIM300.py:5:1: SIM300 [*] Yoda conditions are discouraged, use `compare == ("a", "b")` instead + | +3 | "yoda" == compare # SIM300 +4 | 42 == age # SIM300 +5 | ("a", "b") == compare # SIM300 + | ^^^^^^^^^^^^^^^^^^^^^ SIM300 +6 | "yoda" <= compare # SIM300 +7 | "yoda" < compare # SIM300 + | + = help: Replace Yoda condition with `compare == ("a", "b")` + +ℹ Fix +2 2 | "yoda" == compare # SIM300 +3 3 | "yoda" == compare # SIM300 +4 4 | 42 == age # SIM300 +5 |-("a", "b") == compare # SIM300 + 5 |+compare == ("a", "b") # SIM300 +6 6 | "yoda" <= compare # SIM300 +7 7 | "yoda" < compare # SIM300 +8 8 | 42 > age # SIM300 + +SIM300.py:6:1: SIM300 [*] Yoda conditions are discouraged, use `compare >= "yoda"` instead + | +4 | 42 == age # SIM300 +5 | ("a", "b") == compare # SIM300 +6 | "yoda" <= compare # SIM300 + | ^^^^^^^^^^^^^^^^^ SIM300 +7 | "yoda" < compare # SIM300 +8 | 42 > age # SIM300 + | + = help: Replace Yoda condition with `compare >= "yoda"` + +ℹ Fix +3 3 | "yoda" == compare # SIM300 +4 4 | 42 == age # SIM300 +5 5 | ("a", "b") == compare # SIM300 +6 |-"yoda" <= compare # SIM300 + 6 |+compare >= "yoda" # SIM300 +7 7 | "yoda" < compare # SIM300 +8 8 | 42 > age # SIM300 +9 9 | -42 > age # SIM300 + +SIM300.py:7:1: SIM300 [*] Yoda conditions are discouraged, use `compare > "yoda"` instead + | +5 | ("a", "b") == compare # SIM300 +6 | "yoda" <= compare # SIM300 +7 | "yoda" < compare # SIM300 + | ^^^^^^^^^^^^^^^^ SIM300 +8 | 42 > age # SIM300 +9 | -42 > age # SIM300 + | + = help: Replace Yoda condition with `compare > "yoda"` + +ℹ Fix +4 4 | 42 == age # SIM300 +5 5 | ("a", "b") == compare # SIM300 +6 6 | "yoda" <= compare # SIM300 +7 |-"yoda" < compare # SIM300 + 7 |+compare > "yoda" # SIM300 +8 8 | 42 > age # SIM300 +9 9 | -42 > age # SIM300 +10 10 | +42 > age # SIM300 + +SIM300.py:8:1: SIM300 [*] Yoda conditions are discouraged, use `age < 42` instead + | + 6 | "yoda" <= compare # SIM300 + 7 | "yoda" < compare # SIM300 + 8 | 42 > age # SIM300 + | ^^^^^^^^ SIM300 + 9 | -42 > age # SIM300 +10 | +42 > age # SIM300 + | + = help: Replace Yoda condition with `age < 42` + +ℹ Fix +5 5 | ("a", "b") == compare # SIM300 +6 6 | "yoda" <= compare # SIM300 +7 7 | "yoda" < compare # SIM300 +8 |-42 > age # SIM300 + 8 |+age < 42 # SIM300 +9 9 | -42 > age # SIM300 +10 10 | +42 > age # SIM300 +11 11 | YODA == age # SIM300 + +SIM300.py:9:1: SIM300 [*] Yoda conditions are discouraged, use `age < -42` instead + | + 7 | "yoda" < compare # SIM300 + 8 | 42 > age # SIM300 + 9 | -42 > age # SIM300 + | ^^^^^^^^^ SIM300 +10 | +42 > age # SIM300 +11 | YODA == age # SIM300 + | + = help: Replace Yoda condition with `age < -42` + +ℹ Fix +6 6 | "yoda" <= compare # SIM300 +7 7 | "yoda" < compare # SIM300 +8 8 | 42 > age # SIM300 +9 |--42 > age # SIM300 + 9 |+age < -42 # SIM300 +10 10 | +42 > age # SIM300 +11 11 | YODA == age # SIM300 +12 12 | YODA > age # SIM300 + +SIM300.py:10:1: SIM300 [*] Yoda conditions are discouraged, use `age < +42` instead + | + 8 | 42 > age # SIM300 + 9 | -42 > age # SIM300 +10 | +42 > age # SIM300 + | ^^^^^^^^^ SIM300 +11 | YODA == age # SIM300 +12 | YODA > age # SIM300 + | + = help: Replace Yoda condition with `age < +42` + +ℹ Fix +7 7 | "yoda" < compare # SIM300 +8 8 | 42 > age # SIM300 +9 9 | -42 > age # SIM300 +10 |-+42 > age # SIM300 + 10 |+age < +42 # SIM300 +11 11 | YODA == age # SIM300 +12 12 | YODA > age # SIM300 +13 13 | YODA >= age # SIM300 + +SIM300.py:11:1: SIM300 [*] Yoda conditions are discouraged, use `age == YODA` instead + | + 9 | -42 > age # SIM300 +10 | +42 > age # SIM300 +11 | YODA == age # SIM300 + | ^^^^^^^^^^^ SIM300 +12 | YODA > age # SIM300 +13 | YODA >= age # SIM300 + | + = help: Replace Yoda condition with `age == YODA` + +ℹ Fix +8 8 | 42 > age # SIM300 +9 9 | -42 > age # SIM300 +10 10 | +42 > age # SIM300 +11 |-YODA == age # SIM300 + 11 |+age == YODA # SIM300 +12 12 | YODA > age # SIM300 +13 13 | YODA >= age # SIM300 +14 14 | JediOrder.YODA == age # SIM300 + +SIM300.py:12:1: SIM300 [*] Yoda conditions are discouraged, use `age < YODA` instead + | +10 | +42 > age # SIM300 +11 | YODA == age # SIM300 +12 | YODA > age # SIM300 + | ^^^^^^^^^^ SIM300 +13 | YODA >= age # SIM300 +14 | JediOrder.YODA == age # SIM300 + | + = help: Replace Yoda condition with `age < YODA` + +ℹ Fix +9 9 | -42 > age # SIM300 +10 10 | +42 > age # SIM300 +11 11 | YODA == age # SIM300 +12 |-YODA > age # SIM300 + 12 |+age < YODA # SIM300 +13 13 | YODA >= age # SIM300 +14 14 | JediOrder.YODA == age # SIM300 +15 15 | 0 < (number - 100) # SIM300 + +SIM300.py:13:1: SIM300 [*] Yoda conditions are discouraged, use `age <= YODA` instead + | +11 | YODA == age # SIM300 +12 | YODA > age # SIM300 +13 | YODA >= age # SIM300 + | ^^^^^^^^^^^ SIM300 +14 | JediOrder.YODA == age # SIM300 +15 | 0 < (number - 100) # SIM300 + | + = help: Replace Yoda condition with `age <= YODA` + +ℹ Fix +10 10 | +42 > age # SIM300 +11 11 | YODA == age # SIM300 +12 12 | YODA > age # SIM300 +13 |-YODA >= age # SIM300 + 13 |+age <= YODA # SIM300 +14 14 | JediOrder.YODA == age # SIM300 +15 15 | 0 < (number - 100) # SIM300 +16 16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 + +SIM300.py:14:1: SIM300 [*] Yoda conditions are discouraged, use `age == JediOrder.YODA` instead + | +12 | YODA > age # SIM300 +13 | YODA >= age # SIM300 +14 | JediOrder.YODA == age # SIM300 + | ^^^^^^^^^^^^^^^^^^^^^ SIM300 +15 | 0 < (number - 100) # SIM300 +16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 + | + = help: Replace Yoda condition with `age == JediOrder.YODA` + +ℹ Fix +11 11 | YODA == age # SIM300 +12 12 | YODA > age # SIM300 +13 13 | YODA >= age # SIM300 +14 |-JediOrder.YODA == age # SIM300 + 14 |+age == JediOrder.YODA # SIM300 +15 15 | 0 < (number - 100) # SIM300 +16 16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 +17 17 | B 0` instead + | +13 | YODA >= age # SIM300 +14 | JediOrder.YODA == age # SIM300 +15 | 0 < (number - 100) # SIM300 + | ^^^^^^^^^^^^^^^^^^ SIM300 +16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 +17 | B 0` + +ℹ Fix +12 12 | YODA > age # SIM300 +13 13 | YODA >= age # SIM300 +14 14 | JediOrder.YODA == age # SIM300 +15 |-0 < (number - 100) # SIM300 + 15 |+(number - 100) > 0 # SIM300 +16 16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 +17 17 | B (60 * 60) # SIM300 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM300 +17 | B= age # SIM300 +14 14 | JediOrder.YODA == age # SIM300 +15 15 | 0 < (number - 100) # SIM300 +16 |-SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 + 16 |+(60 * 60) < SomeClass().settings.SOME_CONSTANT_VALUE # SIM300 +17 17 | B B` instead + | +15 | 0 < (number - 100) # SIM300 +16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 +17 | B B` + +ℹ Fix +14 14 | JediOrder.YODA == age # SIM300 +15 15 | 0 < (number - 100) # SIM300 +16 16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 +17 |-B B or B +18 18 | B or(B) (B)` instead + | +16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 +17 | B (B)` + +ℹ Fix +15 15 | 0 < (number - 100) # SIM300 +16 16 | SomeClass().settings.SOME_CONSTANT_VALUE > (60 * 60) # SIM300 +17 17 | B (B) +19 19 | +20 20 | # OK +21 21 | compare == "yoda" + + 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 new file mode 100644 index 0000000000..8c5f552fbc --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM401_SIM401.py.snap @@ -0,0 +1,162 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM401.py:6:1: SIM401 [*] Use `var = a_dict.get(key, "default1")` instead of an `if` block + | + 5 | # SIM401 (pattern-1) + 6 | / if key in a_dict: + 7 | | var = a_dict[key] + 8 | | else: + 9 | | var = "default1" + | |____________________^ SIM401 +10 | +11 | # SIM401 (pattern-2) + | + = help: Replace with `var = a_dict.get(key, "default1")` + +ℹ Suggested fix +3 3 | ### +4 4 | +5 5 | # SIM401 (pattern-1) +6 |-if key in a_dict: +7 |- var = a_dict[key] +8 |-else: +9 |- var = "default1" + 6 |+var = a_dict.get(key, "default1") +10 7 | +11 8 | # SIM401 (pattern-2) +12 9 | if key not in a_dict: + +SIM401.py:12:1: SIM401 [*] Use `var = a_dict.get(key, "default2")` instead of an `if` block + | +11 | # SIM401 (pattern-2) +12 | / if key not in a_dict: +13 | | var = "default2" +14 | | else: +15 | | var = a_dict[key] + | |_____________________^ SIM401 +16 | +17 | # OK (default contains effect) + | + = help: Replace with `var = a_dict.get(key, "default2")` + +ℹ Suggested fix +9 9 | var = "default1" +10 10 | +11 11 | # SIM401 (pattern-2) +12 |-if key not in a_dict: +13 |- var = "default2" +14 |-else: +15 |- var = a_dict[key] + 12 |+var = a_dict.get(key, "default2") +16 13 | +17 14 | # OK (default contains effect) +18 15 | if key in a_dict: + +SIM401.py:24:1: SIM401 [*] Use `var = a_dict.get(keys[idx], "default")` instead of an `if` block + | +23 | # SIM401 (complex expression in key) +24 | / if keys[idx] in a_dict: +25 | | var = a_dict[keys[idx]] +26 | | else: +27 | | var = "default" + | |___________________^ SIM401 +28 | +29 | # SIM401 (complex expression in dict) + | + = help: Replace with `var = a_dict.get(keys[idx], "default")` + +ℹ Suggested fix +21 21 | var = val1 + val2 +22 22 | +23 23 | # SIM401 (complex expression in key) +24 |-if keys[idx] in a_dict: +25 |- var = a_dict[keys[idx]] +26 |-else: +27 |- var = "default" + 24 |+var = a_dict.get(keys[idx], "default") +28 25 | +29 26 | # SIM401 (complex expression in dict) +30 27 | if key in dicts[idx]: + +SIM401.py:30:1: SIM401 [*] Use `var = dicts[idx].get(key, "default")` instead of an `if` block + | +29 | # SIM401 (complex expression in dict) +30 | / if key in dicts[idx]: +31 | | var = dicts[idx][key] +32 | | else: +33 | | var = "default" + | |___________________^ SIM401 +34 | +35 | # SIM401 (complex expression in var) + | + = help: Replace with `var = dicts[idx].get(key, "default")` + +ℹ Suggested fix +27 27 | var = "default" +28 28 | +29 29 | # SIM401 (complex expression in dict) +30 |-if key in dicts[idx]: +31 |- var = dicts[idx][key] +32 |-else: +33 |- var = "default" + 30 |+var = dicts[idx].get(key, "default") +34 31 | +35 32 | # SIM401 (complex expression in var) +36 33 | if key in a_dict: + +SIM401.py:36:1: SIM401 [*] Use `vars[idx] = a_dict.get(key, "defaultß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789")` instead of an `if` block + | +35 | # SIM401 (complex expression in var) +36 | / if key in a_dict: +37 | | vars[idx] = a_dict[key] +38 | | else: +39 | | vars[idx] = "defaultß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789" + | |___________________________________________________________________________^ SIM401 +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")` + +ℹ Suggested fix +33 33 | var = "default" +34 34 | +35 35 | # SIM401 (complex expression in var) +36 |-if key in a_dict: +37 |- vars[idx] = a_dict[key] +38 |-else: +39 |- vars[idx] = "defaultß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789" + 36 |+vars[idx] = a_dict.get(key, "defaultß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789ß9💣2ℝ6789") +40 37 | +41 38 | # SIM401 +42 39 | if foo(): + +SIM401.py:45:5: SIM401 [*] Use `vars[idx] = a_dict.get(key, "default")` instead of an `if` block + | +43 | pass +44 | else: +45 | if key in a_dict: + | _____^ +46 | | vars[idx] = a_dict[key] +47 | | else: +48 | | vars[idx] = "default" + | |_____________________________^ SIM401 +49 | +50 | ### + | + = help: Replace with `vars[idx] = a_dict.get(key, "default")` + +ℹ Suggested fix +42 42 | if foo(): +43 43 | pass +44 44 | else: +45 |- if key in a_dict: +46 |- vars[idx] = a_dict[key] +47 |- else: +48 |- vars[idx] = "default" + 45 |+ vars[idx] = a_dict.get(key, "default") +49 46 | +50 47 | ### +51 48 | # Negative cases + + 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 new file mode 100644 index 0000000000..840124a763 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_simplify/snapshots/ruff_linter__rules__flake8_simplify__tests__SIM910_SIM910.py.snap @@ -0,0 +1,96 @@ +--- +source: crates/ruff_linter/src/rules/flake8_simplify/mod.rs +--- +SIM910.py:2:1: SIM910 [*] Use `{}.get(key)` instead of `{}.get(key, None)` + | +1 | # SIM910 +2 | {}.get(key, None) + | ^^^^^^^^^^^^^^^^^ SIM910 +3 | +4 | # SIM910 + | + = help: Replace `{}.get(key, None)` with `{}.get(key)` + +ℹ Fix +1 1 | # SIM910 +2 |-{}.get(key, None) + 2 |+{}.get(key) +3 3 | +4 4 | # SIM910 +5 5 | {}.get("key", None) + +SIM910.py:5:1: SIM910 [*] Use `{}.get("key")` instead of `{}.get("key", None)` + | +4 | # SIM910 +5 | {}.get("key", None) + | ^^^^^^^^^^^^^^^^^^^ SIM910 +6 | +7 | # OK + | + = help: Replace `{}.get("key", None)` with `{}.get("key")` + +ℹ Fix +2 2 | {}.get(key, None) +3 3 | +4 4 | # SIM910 +5 |-{}.get("key", None) + 5 |+{}.get("key") +6 6 | +7 7 | # OK +8 8 | {}.get(key) + +SIM910.py:20:9: SIM910 [*] Use `{}.get(key)` instead of `{}.get(key, None)` + | +19 | # SIM910 +20 | if a := {}.get(key, None): + | ^^^^^^^^^^^^^^^^^ SIM910 +21 | pass + | + = help: Replace `{}.get(key, None)` with `{}.get(key)` + +ℹ Fix +17 17 | {}.get("key", False) +18 18 | +19 19 | # SIM910 +20 |-if a := {}.get(key, None): + 20 |+if a := {}.get(key): +21 21 | pass +22 22 | +23 23 | # SIM910 + +SIM910.py:24:5: SIM910 [*] Use `{}.get(key)` instead of `{}.get(key, None)` + | +23 | # SIM910 +24 | a = {}.get(key, None) + | ^^^^^^^^^^^^^^^^^ SIM910 +25 | +26 | # SIM910 + | + = help: Replace `{}.get(key, None)` with `{}.get(key)` + +ℹ Fix +21 21 | pass +22 22 | +23 23 | # SIM910 +24 |-a = {}.get(key, None) + 24 |+a = {}.get(key) +25 25 | +26 26 | # SIM910 +27 27 | ({}).get(key, None) + +SIM910.py:27:1: SIM910 [*] Use `({}).get(key)` instead of `({}).get(key, None)` + | +26 | # SIM910 +27 | ({}).get(key, None) + | ^^^^^^^^^^^^^^^^^^^ SIM910 + | + = help: Replace `({}).get(key, None)` with `({}).get(key)` + +ℹ Fix +24 24 | a = {}.get(key, None) +25 25 | +26 26 | # SIM910 +27 |-({}).get(key, None) + 27 |+({}).get(key) + + diff --git a/crates/ruff/src/rules/flake8_slots/mod.rs b/crates/ruff_linter/src/rules/flake8_slots/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_slots/mod.rs rename to crates/ruff_linter/src/rules/flake8_slots/mod.rs diff --git a/crates/ruff/src/rules/flake8_slots/rules/helpers.rs b/crates/ruff_linter/src/rules/flake8_slots/rules/helpers.rs similarity index 100% rename from crates/ruff/src/rules/flake8_slots/rules/helpers.rs rename to crates/ruff_linter/src/rules/flake8_slots/rules/helpers.rs diff --git a/crates/ruff/src/rules/flake8_slots/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_slots/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_slots/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_slots/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_slots/rules/no_slots_in_namedtuple_subclass.rs b/crates/ruff_linter/src/rules/flake8_slots/rules/no_slots_in_namedtuple_subclass.rs similarity index 100% rename from crates/ruff/src/rules/flake8_slots/rules/no_slots_in_namedtuple_subclass.rs rename to crates/ruff_linter/src/rules/flake8_slots/rules/no_slots_in_namedtuple_subclass.rs diff --git a/crates/ruff/src/rules/flake8_slots/rules/no_slots_in_str_subclass.rs b/crates/ruff_linter/src/rules/flake8_slots/rules/no_slots_in_str_subclass.rs similarity index 100% rename from crates/ruff/src/rules/flake8_slots/rules/no_slots_in_str_subclass.rs rename to crates/ruff_linter/src/rules/flake8_slots/rules/no_slots_in_str_subclass.rs diff --git a/crates/ruff/src/rules/flake8_slots/rules/no_slots_in_tuple_subclass.rs b/crates/ruff_linter/src/rules/flake8_slots/rules/no_slots_in_tuple_subclass.rs similarity index 100% rename from crates/ruff/src/rules/flake8_slots/rules/no_slots_in_tuple_subclass.rs rename to crates/ruff_linter/src/rules/flake8_slots/rules/no_slots_in_tuple_subclass.rs diff --git a/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT000_SLOT000.py.snap b/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT000_SLOT000.py.snap new file mode 100644 index 0000000000..b98bc9ca9f --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT000_SLOT000.py.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/flake8_slots/mod.rs +--- +SLOT000.py:1:7: SLOT000 Subclasses of `str` should define `__slots__` + | +1 | class Bad(str): # SLOT000 + | ^^^ SLOT000 +2 | pass + | + + 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 new file mode 100644 index 0000000000..7aa7763e2a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT001_SLOT001.py.snap @@ -0,0 +1,25 @@ +--- +source: crates/ruff_linter/src/rules/flake8_slots/mod.rs +--- +SLOT001.py:1:7: SLOT001 Subclasses of `tuple` should define `__slots__` + | +1 | class Bad(tuple): # SLOT001 + | ^^^ SLOT001 +2 | pass + | + +SLOT001.py:12:7: SLOT001 Subclasses of `tuple` should define `__slots__` + | +12 | class Bad(Tuple): # SLOT001 + | ^^^ SLOT001 +13 | pass + | + +SLOT001.py:16:7: SLOT001 Subclasses of `tuple` should define `__slots__` + | +16 | class Bad(Tuple[str, int, float]): # SLOT001 + | ^^^ SLOT001 +17 | pass + | + + diff --git a/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT002_SLOT002.py.snap b/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT002_SLOT002.py.snap new file mode 100644 index 0000000000..4ee1ad407b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_slots/snapshots/ruff_linter__rules__flake8_slots__tests__SLOT002_SLOT002.py.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/flake8_slots/mod.rs +--- +SLOT002.py:5:7: SLOT002 Subclasses of `collections.namedtuple()` should define `__slots__` + | +5 | class Bad(namedtuple("foo", ["str", "int"])): # SLOT002 + | ^^^ SLOT002 +6 | pass + | + + diff --git a/crates/ruff/src/rules/flake8_tidy_imports/matchers.rs b/crates/ruff_linter/src/rules/flake8_tidy_imports/matchers.rs similarity index 100% rename from crates/ruff/src/rules/flake8_tidy_imports/matchers.rs rename to crates/ruff_linter/src/rules/flake8_tidy_imports/matchers.rs diff --git a/crates/ruff/src/rules/flake8_tidy_imports/mod.rs b/crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_tidy_imports/mod.rs rename to crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs diff --git a/crates/ruff/src/rules/flake8_tidy_imports/rules/banned_api.rs b/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_api.rs similarity index 100% rename from crates/ruff/src/rules/flake8_tidy_imports/rules/banned_api.rs rename to crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_api.rs diff --git a/crates/ruff/src/rules/flake8_tidy_imports/rules/banned_module_level_imports.rs b/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_module_level_imports.rs similarity index 100% rename from crates/ruff/src/rules/flake8_tidy_imports/rules/banned_module_level_imports.rs rename to crates/ruff_linter/src/rules/flake8_tidy_imports/rules/banned_module_level_imports.rs diff --git a/crates/ruff/src/rules/flake8_tidy_imports/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_tidy_imports/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_tidy_imports/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_tidy_imports/rules/relative_imports.rs b/crates/ruff_linter/src/rules/flake8_tidy_imports/rules/relative_imports.rs similarity index 100% rename from crates/ruff/src/rules/flake8_tidy_imports/rules/relative_imports.rs rename to crates/ruff_linter/src/rules/flake8_tidy_imports/rules/relative_imports.rs diff --git a/crates/ruff/src/rules/flake8_tidy_imports/settings.rs b/crates/ruff_linter/src/rules/flake8_tidy_imports/settings.rs similarity index 100% rename from crates/ruff/src/rules/flake8_tidy_imports/settings.rs rename to crates/ruff_linter/src/rules/flake8_tidy_imports/settings.rs diff --git a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_all_imports.snap b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_all_imports.snap new file mode 100644 index 0000000000..533d76bc35 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_all_imports.snap @@ -0,0 +1,192 @@ +--- +source: crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs +--- +TID252.py:7:1: TID252 Relative imports are banned + | +6 | # TID252 +7 | from . import sibling + | ^^^^^^^^^^^^^^^^^^^^^ TID252 +8 | from .sibling import example +9 | from .. import parent + | + = help: Replace relative imports with absolute imports + +TID252.py:8:1: TID252 Relative imports are banned + | + 6 | # TID252 + 7 | from . import sibling + 8 | from .sibling import example + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + 9 | from .. import parent +10 | from ..parent import example + | + = help: Replace relative imports with absolute imports + +TID252.py:9:1: TID252 Relative imports are banned + | + 7 | from . import sibling + 8 | from .sibling import example + 9 | from .. import parent + | ^^^^^^^^^^^^^^^^^^^^^ TID252 +10 | from ..parent import example +11 | from ... import grandparent + | + = help: Replace relative imports with absolute imports + +TID252.py:10:1: TID252 Relative imports are banned + | + 8 | from .sibling import example + 9 | from .. import parent +10 | from ..parent import example + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +11 | from ... import grandparent +12 | from ...grandparent import example + | + = help: Replace relative imports with absolute imports + +TID252.py:11:1: TID252 Relative imports are banned + | + 9 | from .. import parent +10 | from ..parent import example +11 | from ... import grandparent + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +12 | from ...grandparent import example +13 | from .parent import hello + | + = help: Replace relative imports with absolute imports + +TID252.py:12:1: TID252 Relative imports are banned + | +10 | from ..parent import example +11 | from ... import grandparent +12 | from ...grandparent import example + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +13 | from .parent import hello +14 | from .\ + | + = help: Replace relative imports with absolute imports + +TID252.py:13:1: TID252 Relative imports are banned + | +11 | from ... import grandparent +12 | from ...grandparent import example +13 | from .parent import hello + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +14 | from .\ +15 | parent import \ + | + = help: Replace relative imports with absolute imports + +TID252.py:14:1: TID252 Relative imports are banned + | +12 | from ...grandparent import example +13 | from .parent import hello +14 | / from .\ +15 | | parent import \ +16 | | hello_world + | |___________________^ TID252 +17 | from \ +18 | ..parent\ + | + = help: Replace relative imports with absolute imports + +TID252.py:17:1: TID252 Relative imports are banned + | +15 | parent import \ +16 | hello_world +17 | / from \ +18 | | ..parent\ +19 | | import \ +20 | | world_hello + | |_______________^ TID252 +21 | from ..... import ultragrantparent +22 | from ...... import ultragrantparent + | + = help: Replace relative imports with absolute imports + +TID252.py:21:1: TID252 Relative imports are banned + | +19 | import \ +20 | world_hello +21 | from ..... import ultragrantparent + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +22 | from ...... import ultragrantparent +23 | from ....... import ultragrantparent + | + = help: Replace relative imports with absolute imports + +TID252.py:22:1: TID252 Relative imports are banned + | +20 | world_hello +21 | from ..... import ultragrantparent +22 | from ...... import ultragrantparent + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +23 | from ....... import ultragrantparent +24 | from ......... import ultragrantparent + | + = help: Replace relative imports with absolute imports + +TID252.py:23:1: TID252 Relative imports are banned + | +21 | from ..... import ultragrantparent +22 | from ...... import ultragrantparent +23 | from ....... import ultragrantparent + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +24 | from ......... import ultragrantparent +25 | from ........................... import ultragrantparent + | + = help: Replace relative imports with absolute imports + +TID252.py:24:1: TID252 Relative imports are banned + | +22 | from ...... import ultragrantparent +23 | from ....... import ultragrantparent +24 | from ......... import ultragrantparent + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +25 | from ........................... import ultragrantparent +26 | from .....parent import ultragrantparent + | + = help: Replace relative imports with absolute imports + +TID252.py:25:1: TID252 Relative imports are banned + | +23 | from ....... import ultragrantparent +24 | from ......... import ultragrantparent +25 | from ........................... import ultragrantparent + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +26 | from .....parent import ultragrantparent +27 | from .........parent import ultragrantparent + | + = help: Replace relative imports with absolute imports + +TID252.py:26:1: TID252 Relative imports are banned + | +24 | from ......... import ultragrantparent +25 | from ........................... import ultragrantparent +26 | from .....parent import ultragrantparent + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +27 | from .........parent import ultragrantparent +28 | from ...........................parent import ultragrantparent + | + = help: Replace relative imports with absolute imports + +TID252.py:27:1: TID252 Relative imports are banned + | +25 | from ........................... import ultragrantparent +26 | from .....parent import ultragrantparent +27 | from .........parent import ultragrantparent + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +28 | from ...........................parent import ultragrantparent + | + = help: Replace relative imports with absolute imports + +TID252.py:28:1: TID252 Relative imports are banned + | +26 | from .....parent import ultragrantparent +27 | from .........parent import ultragrantparent +28 | from ...........................parent import ultragrantparent + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | + = help: Replace relative imports with absolute imports + + diff --git a/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_parent_imports.snap b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_parent_imports.snap new file mode 100644 index 0000000000..dfc4b9f745 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_parent_imports.snap @@ -0,0 +1,147 @@ +--- +source: crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs +--- +TID252.py:9:1: TID252 Relative imports from parent modules are banned + | + 7 | from . import sibling + 8 | from .sibling import example + 9 | from .. import parent + | ^^^^^^^^^^^^^^^^^^^^^ TID252 +10 | from ..parent import example +11 | from ... import grandparent + | + = help: Replace relative imports from parent modules with absolute imports + +TID252.py:10:1: TID252 Relative imports from parent modules are banned + | + 8 | from .sibling import example + 9 | from .. import parent +10 | from ..parent import example + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +11 | from ... import grandparent +12 | from ...grandparent import example + | + = help: Replace relative imports from parent modules with absolute imports + +TID252.py:11:1: TID252 Relative imports from parent modules are banned + | + 9 | from .. import parent +10 | from ..parent import example +11 | from ... import grandparent + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +12 | from ...grandparent import example +13 | from .parent import hello + | + = help: Replace relative imports from parent modules with absolute imports + +TID252.py:12:1: TID252 Relative imports from parent modules are banned + | +10 | from ..parent import example +11 | from ... import grandparent +12 | from ...grandparent import example + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +13 | from .parent import hello +14 | from .\ + | + = help: Replace relative imports from parent modules with absolute imports + +TID252.py:17:1: TID252 Relative imports from parent modules are banned + | +15 | parent import \ +16 | hello_world +17 | / from \ +18 | | ..parent\ +19 | | import \ +20 | | world_hello + | |_______________^ TID252 +21 | from ..... import ultragrantparent +22 | from ...... import ultragrantparent + | + = help: Replace relative imports from parent modules with absolute imports + +TID252.py:21:1: TID252 Relative imports from parent modules are banned + | +19 | import \ +20 | world_hello +21 | from ..... import ultragrantparent + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +22 | from ...... import ultragrantparent +23 | from ....... import ultragrantparent + | + = help: Replace relative imports from parent modules with absolute imports + +TID252.py:22:1: TID252 Relative imports from parent modules are banned + | +20 | world_hello +21 | from ..... import ultragrantparent +22 | from ...... import ultragrantparent + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +23 | from ....... import ultragrantparent +24 | from ......... import ultragrantparent + | + = help: Replace relative imports from parent modules with absolute imports + +TID252.py:23:1: TID252 Relative imports from parent modules are banned + | +21 | from ..... import ultragrantparent +22 | from ...... import ultragrantparent +23 | from ....... import ultragrantparent + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +24 | from ......... import ultragrantparent +25 | from ........................... import ultragrantparent + | + = help: Replace relative imports from parent modules with absolute imports + +TID252.py:24:1: TID252 Relative imports from parent modules are banned + | +22 | from ...... import ultragrantparent +23 | from ....... import ultragrantparent +24 | from ......... import ultragrantparent + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +25 | from ........................... import ultragrantparent +26 | from .....parent import ultragrantparent + | + = help: Replace relative imports from parent modules with absolute imports + +TID252.py:25:1: TID252 Relative imports from parent modules are banned + | +23 | from ....... import ultragrantparent +24 | from ......... import ultragrantparent +25 | from ........................... import ultragrantparent + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +26 | from .....parent import ultragrantparent +27 | from .........parent import ultragrantparent + | + = help: Replace relative imports from parent modules with absolute imports + +TID252.py:26:1: TID252 Relative imports from parent modules are banned + | +24 | from ......... import ultragrantparent +25 | from ........................... import ultragrantparent +26 | from .....parent import ultragrantparent + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +27 | from .........parent import ultragrantparent +28 | from ...........................parent import ultragrantparent + | + = help: Replace relative imports from parent modules with absolute imports + +TID252.py:27:1: TID252 Relative imports from parent modules are banned + | +25 | from ........................... import ultragrantparent +26 | from .....parent import ultragrantparent +27 | from .........parent import ultragrantparent + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +28 | from ...........................parent import ultragrantparent + | + = help: Replace relative imports from parent modules with absolute imports + +TID252.py:28:1: TID252 Relative imports from parent modules are banned + | +26 | from .....parent import ultragrantparent +27 | from .........parent import ultragrantparent +28 | from ...........................parent import ultragrantparent + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | + = help: Replace relative imports from parent modules with absolute imports + + 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 new file mode 100644 index 0000000000..db5e80f0a7 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__ban_parent_imports_package.snap @@ -0,0 +1,132 @@ +--- +source: crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs +--- +application.py:5:1: TID252 Relative imports from parent modules are banned + | +3 | import attrs +4 | +5 | from ....import unknown + | ^^^^^^^^^^^^^^^^^^^^^^^ TID252 +6 | from ..protocol import commands, definitions, responses +7 | from ..server import example + | + = help: Replace relative imports from parent modules with absolute imports + +application.py:6:1: TID252 [*] Relative imports from parent modules are banned + | +5 | from ....import unknown +6 | from ..protocol import commands, definitions, responses + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +7 | from ..server import example +8 | from .. import server + | + = help: Replace relative imports from parent modules with absolute imports + +ℹ Suggested fix +3 3 | import attrs +4 4 | +5 5 | from ....import unknown +6 |-from ..protocol import commands, definitions, responses + 6 |+from my_package.sublib.protocol import commands, definitions, responses +7 7 | from ..server import example +8 8 | from .. import server +9 9 | from . import logger, models + +application.py:6:1: TID252 [*] Relative imports from parent modules are banned + | +5 | from ....import unknown +6 | from ..protocol import commands, definitions, responses + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +7 | from ..server import example +8 | from .. import server + | + = help: Replace relative imports from parent modules with absolute imports + +ℹ Suggested fix +3 3 | import attrs +4 4 | +5 5 | from ....import unknown +6 |-from ..protocol import commands, definitions, responses + 6 |+from my_package.sublib.protocol import commands, definitions, responses +7 7 | from ..server import example +8 8 | from .. import server +9 9 | from . import logger, models + +application.py:6:1: TID252 [*] Relative imports from parent modules are banned + | +5 | from ....import unknown +6 | from ..protocol import commands, definitions, responses + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +7 | from ..server import example +8 | from .. import server + | + = help: Replace relative imports from parent modules with absolute imports + +ℹ Suggested fix +3 3 | import attrs +4 4 | +5 5 | from ....import unknown +6 |-from ..protocol import commands, definitions, responses + 6 |+from my_package.sublib.protocol import commands, definitions, responses +7 7 | from ..server import example +8 8 | from .. import server +9 9 | from . import logger, models + +application.py:7:1: TID252 [*] Relative imports from parent modules are banned + | +5 | from ....import unknown +6 | from ..protocol import commands, definitions, responses +7 | from ..server import example + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 +8 | from .. import server +9 | from . import logger, models + | + = help: Replace relative imports from parent modules with absolute imports + +ℹ Suggested fix +4 4 | +5 5 | from ....import unknown +6 6 | from ..protocol import commands, definitions, responses +7 |-from ..server import example + 7 |+from my_package.sublib.server import example +8 8 | from .. import server +9 9 | from . import logger, models +10 10 | from ..protocol.UpperCaseModule import some_function + +application.py:8:1: TID252 [*] Relative imports from parent modules are banned + | + 6 | from ..protocol import commands, definitions, responses + 7 | from ..server import example + 8 | from .. import server + | ^^^^^^^^^^^^^^^^^^^^^ TID252 + 9 | from . import logger, models +10 | from ..protocol.UpperCaseModule import some_function + | + = help: Replace relative imports from parent modules with absolute imports + +ℹ Suggested fix +5 5 | from ....import unknown +6 6 | from ..protocol import commands, definitions, responses +7 7 | from ..server import example +8 |-from .. import server + 8 |+from my_package.sublib import server +9 9 | from . import logger, models +10 10 | from ..protocol.UpperCaseModule import some_function + +application.py:10:1: TID252 [*] Relative imports from parent modules are banned + | + 8 | from .. import server + 9 | from . import logger, models +10 | from ..protocol.UpperCaseModule import some_function + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID252 + | + = help: Replace relative imports from parent modules with absolute imports + +ℹ Suggested fix +7 7 | from ..server import example +8 8 | from .. import server +9 9 | from . import logger, models +10 |-from ..protocol.UpperCaseModule import some_function + 10 |+from my_package.sublib.protocol.UpperCaseModule import some_function + + 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 new file mode 100644 index 0000000000..9e54f52400 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_api.snap @@ -0,0 +1,120 @@ +--- +source: crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs +--- +TID251.py:2:8: TID251 `cgi` is banned: The cgi module is deprecated. + | +1 | ## Banned modules ## +2 | import cgi + | ^^^ TID251 +3 | +4 | from cgi import * + | + +TID251.py:4:1: TID251 `cgi` is banned: The cgi module is deprecated. + | +2 | import cgi +3 | +4 | from cgi import * + | ^^^^^^^^^^^^^^^^^ TID251 +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 | +6 | from cgi import a, b, c + | ^^^^^^^^^^^^^^^^^^^^^^^ TID251 +7 | +8 | # banning a module also bans any submodules + | + +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 | +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 | +11 | from cgi.foo import bar + | ^^^^^^^^^^^^^^^^^^^^^^^ TID251 +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 | +13 | from cgi.foo.bar import * + | ^^^^^^^^^^^^^^^^^^^^^^^^^ TID251 +14 | +15 | ## Banned module members ## + | + +TID251.py:17:20: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. + | +15 | ## Banned module members ## +16 | +17 | from typing import TypedDict + | ^^^^^^^^^ TID251 +18 | +19 | import typing + | + +TID251.py:22:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. + | +21 | # attribute access is checked +22 | typing.TypedDict + | ^^^^^^^^^^^^^^^^ TID251 +23 | +24 | typing.TypedDict.anything + | + +TID251.py:24:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. + | +22 | typing.TypedDict +23 | +24 | typing.TypedDict.anything + | ^^^^^^^^^^^^^^^^ TID251 +25 | +26 | # function calls are checked + | + +TID251.py:27:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. + | +26 | # function calls are checked +27 | typing.TypedDict() + | ^^^^^^^^^^^^^^^^ TID251 +28 | +29 | typing.TypedDict.anything() + | + +TID251.py:29:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. + | +27 | typing.TypedDict() +28 | +29 | typing.TypedDict.anything() + | ^^^^^^^^^^^^^^^^ TID251 +30 | +31 | # import aliases are resolved + | + +TID251.py:33:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.TypedDict instead. + | +31 | # import aliases are resolved +32 | import typing as totally_not_typing +33 | totally_not_typing.TypedDict + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID251 +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 new file mode 100644 index 0000000000..14eb7a6345 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_api_package.snap @@ -0,0 +1,31 @@ +--- +source: crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs +--- +application.py:3:8: TID251 `attrs` is banned: The attrs module is deprecated. + | +1 | from typing import TYPE_CHECKING, Any, ClassVar +2 | +3 | import attrs + | ^^^^^ TID251 +4 | +5 | from ....import unknown + | + +application.py:6:1: TID251 `my_package.sublib.protocol` is banned: The protocol module is deprecated. + | +5 | from ....import unknown +6 | from ..protocol import commands, definitions, responses + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID251 +7 | from ..server import example +8 | from .. import server + | + +application.py:10:1: TID251 `my_package.sublib.protocol` is banned: The protocol module is deprecated. + | + 8 | from .. import server + 9 | from . import logger, models +10 | from ..protocol.UpperCaseModule import some_function + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID251 + | + + 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 new file mode 100644 index 0000000000..dbabca1e24 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_tidy_imports/snapshots/ruff_linter__rules__flake8_tidy_imports__tests__banned_module_level_imports.snap @@ -0,0 +1,81 @@ +--- +source: crates/ruff_linter/src/rules/flake8_tidy_imports/mod.rs +--- +TID253.py:2:8: TID253 `torch` is banned at the module level + | +1 | ## Banned modules ## +2 | import torch + | ^^^^^ TID253 +3 | +4 | from torch import * + | + +TID253.py:4:1: TID253 `torch` is banned at the module level + | +2 | import torch +3 | +4 | from torch import * + | ^^^^^^^^^^^^^^^^^^^ TID253 +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 | +6 | from tensorflow import a, b, c + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID253 +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 | + 8 | import torch as torch_wearing_a_trenchcoat + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID253 + 9 | +10 | # this should count as module level + | + +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 | +13 | # banning a module also bans any submodules + | + +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 | +16 | from tensorflow.foo import bar + | + +TID253.py:16:1: TID253 `tensorflow` is banned at the module level + | +14 | import torch.foo.bar +15 | +16 | from tensorflow.foo import bar + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID253 +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 | +18 | from torch.foo.bar import * + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID253 +19 | +20 | # unlike TID251, inline imports are *not* banned + | + + diff --git a/crates/ruff/src/rules/flake8_todos/mod.rs b/crates/ruff_linter/src/rules/flake8_todos/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_todos/mod.rs rename to crates/ruff_linter/src/rules/flake8_todos/mod.rs diff --git a/crates/ruff/src/rules/flake8_todos/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_todos/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_todos/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_todos/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_todos/rules/todos.rs b/crates/ruff_linter/src/rules/flake8_todos/rules/todos.rs similarity index 100% rename from crates/ruff/src/rules/flake8_todos/rules/todos.rs rename to crates/ruff_linter/src/rules/flake8_todos/rules/todos.rs diff --git a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__invalid-todo-capitalization_TD006.py.snap b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__invalid-todo-capitalization_TD006.py.snap new file mode 100644 index 0000000000..4fe1612384 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__invalid-todo-capitalization_TD006.py.snap @@ -0,0 +1,58 @@ +--- +source: crates/ruff_linter/src/rules/flake8_todos/mod.rs +--- +TD006.py:4:3: TD006 [*] Invalid TODO capitalization: `ToDo` should be `TODO` + | +2 | # TODO (evanrittenhouse): this is a valid TODO +3 | # TDO006 - error +4 | # ToDo (evanrittenhouse): invalid capitalization + | ^^^^ TD006 +5 | # todo (evanrittenhouse): another invalid capitalization +6 | # foo # todo: invalid capitalization + | + = help: Replace `ToDo` with `TODO` + +ℹ Fix +1 1 | # TDO006 - accepted +2 2 | # TODO (evanrittenhouse): this is a valid TODO +3 3 | # TDO006 - error +4 |-# ToDo (evanrittenhouse): invalid capitalization + 4 |+# TODO (evanrittenhouse): invalid capitalization +5 5 | # todo (evanrittenhouse): another invalid capitalization +6 6 | # foo # todo: invalid capitalization + +TD006.py:5:3: TD006 [*] Invalid TODO capitalization: `todo` should be `TODO` + | +3 | # TDO006 - error +4 | # ToDo (evanrittenhouse): invalid capitalization +5 | # todo (evanrittenhouse): another invalid capitalization + | ^^^^ TD006 +6 | # foo # todo: invalid capitalization + | + = help: Replace `todo` with `TODO` + +ℹ Fix +2 2 | # TODO (evanrittenhouse): this is a valid TODO +3 3 | # TDO006 - error +4 4 | # ToDo (evanrittenhouse): invalid capitalization +5 |-# todo (evanrittenhouse): another invalid capitalization + 5 |+# TODO (evanrittenhouse): another invalid capitalization +6 6 | # foo # todo: invalid capitalization + +TD006.py:6:9: TD006 [*] Invalid TODO capitalization: `todo` should be `TODO` + | +4 | # ToDo (evanrittenhouse): invalid capitalization +5 | # todo (evanrittenhouse): another invalid capitalization +6 | # foo # todo: invalid capitalization + | ^^^^ TD006 + | + = help: Replace `todo` with `TODO` + +ℹ Fix +3 3 | # TDO006 - error +4 4 | # ToDo (evanrittenhouse): invalid capitalization +5 5 | # todo (evanrittenhouse): another invalid capitalization +6 |-# foo # todo: invalid capitalization + 6 |+# foo # TODO: invalid capitalization + + diff --git a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__invalid-todo-tag_TD001.py.snap b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__invalid-todo-tag_TD001.py.snap new file mode 100644 index 0000000000..1fec01f216 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__invalid-todo-tag_TD001.py.snap @@ -0,0 +1,30 @@ +--- +source: crates/ruff_linter/src/rules/flake8_todos/mod.rs +--- +TD001.py:7:3: TD001 Invalid TODO tag: `XXX` + | +6 | # T001 - errors +7 | # XXX (evanrittenhouse): this is not fine + | ^^^ TD001 +8 | # FIXME (evanrittenhouse): this is not fine +9 | # foo # XXX: this isn't fine either + | + +TD001.py:8:3: TD001 Invalid TODO tag: `FIXME` + | +6 | # T001 - errors +7 | # XXX (evanrittenhouse): this is not fine +8 | # FIXME (evanrittenhouse): this is not fine + | ^^^^^ TD001 +9 | # foo # XXX: this isn't fine either + | + +TD001.py:9:9: TD001 Invalid TODO tag: `XXX` + | +7 | # XXX (evanrittenhouse): this is not fine +8 | # FIXME (evanrittenhouse): this is not fine +9 | # foo # XXX: this isn't fine either + | ^^^ TD001 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-space-after-todo-colon_TD007.py.snap b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-space-after-todo-colon_TD007.py.snap new file mode 100644 index 0000000000..f786677cea --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-space-after-todo-colon_TD007.py.snap @@ -0,0 +1,53 @@ +--- +source: crates/ruff_linter/src/rules/flake8_todos/mod.rs +--- +TD007.py:5:3: TD007 Missing space after colon in TODO + | +3 | # TODO: so does this +4 | # T007 - errors +5 | # TODO(evanrittenhouse):this has no space after a colon + | ^^^^ TD007 +6 | # TODO (evanrittenhouse):this doesn't either +7 | # TODO:neither does this + | + +TD007.py:6:3: TD007 Missing space after colon in TODO + | +4 | # T007 - errors +5 | # TODO(evanrittenhouse):this has no space after a colon +6 | # TODO (evanrittenhouse):this doesn't either + | ^^^^ TD007 +7 | # TODO:neither does this +8 | # FIXME:and lastly neither does this + | + +TD007.py:7:3: TD007 Missing space after colon in TODO + | +5 | # TODO(evanrittenhouse):this has no space after a colon +6 | # TODO (evanrittenhouse):this doesn't either +7 | # TODO:neither does this + | ^^^^ TD007 +8 | # FIXME:and lastly neither does this +9 | # foo # TODO:this is really the last one + | + +TD007.py:8:3: TD007 Missing space after colon in TODO + | + 6 | # TODO (evanrittenhouse):this doesn't either + 7 | # TODO:neither does this + 8 | # FIXME:and lastly neither does this + | ^^^^^ TD007 + 9 | # foo # TODO:this is really the last one +10 | # TODO this colon doesn't terminate the tag, so don't check it. https://www.google.com + | + +TD007.py:9:9: TD007 Missing space after colon in TODO + | + 7 | # TODO:neither does this + 8 | # FIXME:and lastly neither does this + 9 | # foo # TODO:this is really the last one + | ^^^^ TD007 +10 | # TODO this colon doesn't terminate the tag, so don't check it. https://www.google.com + | + + diff --git a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-author_TD002.py.snap b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-author_TD002.py.snap new file mode 100644 index 0000000000..6c6e46881b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-author_TD002.py.snap @@ -0,0 +1,41 @@ +--- +source: crates/ruff_linter/src/rules/flake8_todos/mod.rs +--- +TD002.py:11:3: TD002 Missing author in TODO; try: `# TODO(): ...` or `# TODO @: ...` + | + 9 | # TODO @mayrholu and more: this has an author +10 | # T002 - errors +11 | # TODO: this has no author + | ^^^^ TD002 +12 | # FIXME: neither does this +13 | # TODO : and neither does this + | + +TD002.py:12:3: TD002 Missing author in TODO; try: `# TODO(): ...` or `# TODO @: ...` + | +10 | # T002 - errors +11 | # TODO: this has no author +12 | # FIXME: neither does this + | ^^^^^ TD002 +13 | # TODO : and neither does this +14 | # foo # TODO: this doesn't either + | + +TD002.py:13:3: TD002 Missing author in TODO; try: `# TODO(): ...` or `# TODO @: ...` + | +11 | # TODO: this has no author +12 | # FIXME: neither does this +13 | # TODO : and neither does this + | ^^^^ TD002 +14 | # foo # TODO: this doesn't either + | + +TD002.py:14:9: TD002 Missing author in TODO; try: `# TODO(): ...` or `# TODO @: ...` + | +12 | # FIXME: neither does this +13 | # TODO : and neither does this +14 | # foo # TODO: this doesn't either + | ^^^^ TD002 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-colon_TD004.py.snap b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-colon_TD004.py.snap new file mode 100644 index 0000000000..2017416133 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-colon_TD004.py.snap @@ -0,0 +1,51 @@ +--- +source: crates/ruff_linter/src/rules/flake8_todos/mod.rs +--- +TD004.py:4:3: TD004 Missing colon in TODO + | +2 | # TODO(evanrittenhouse): this has a colon +3 | # T004 - errors +4 | # TODO this has no colon + | ^^^^ TD004 +5 | # TODO(evanrittenhouse 😀) this has no colon +6 | # FIXME add a colon + | + +TD004.py:5:3: TD004 Missing colon in TODO + | +3 | # T004 - errors +4 | # TODO this has no colon +5 | # TODO(evanrittenhouse 😀) this has no colon + | ^^^^ TD004 +6 | # FIXME add a colon +7 | # foo # TODO add a colon + | + +TD004.py:6:3: TD004 Missing colon in TODO + | +4 | # TODO this has no colon +5 | # TODO(evanrittenhouse 😀) this has no colon +6 | # FIXME add a colon + | ^^^^^ TD004 +7 | # foo # TODO add a colon +8 | # TODO this has a colon but it doesn't terminate the tag, so this should throw. https://www.google.com + | + +TD004.py:7:9: TD004 Missing colon in TODO + | +5 | # TODO(evanrittenhouse 😀) this has no colon +6 | # FIXME add a colon +7 | # foo # TODO add a colon + | ^^^^ TD004 +8 | # TODO this has a colon but it doesn't terminate the tag, so this should throw. https://www.google.com + | + +TD004.py:8:3: TD004 Missing colon in TODO + | +6 | # FIXME add a colon +7 | # foo # TODO add a colon +8 | # TODO this has a colon but it doesn't terminate the tag, so this should throw. https://www.google.com + | ^^^^ TD004 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-description_TD005.py.snap b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-description_TD005.py.snap new file mode 100644 index 0000000000..c965f640e5 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-description_TD005.py.snap @@ -0,0 +1,41 @@ +--- +source: crates/ruff_linter/src/rules/flake8_todos/mod.rs +--- +TD005.py:4:3: TD005 Missing issue description after `TODO` + | +2 | # TODO(evanrittenhouse): this has text, while the errors do not +3 | # T005 - errors +4 | # TODO(evanrittenhouse): + | ^^^^ TD005 +5 | # TODO(evanrittenhouse) +6 | # FIXME + | + +TD005.py:5:3: TD005 Missing issue description after `TODO` + | +3 | # T005 - errors +4 | # TODO(evanrittenhouse): +5 | # TODO(evanrittenhouse) + | ^^^^ TD005 +6 | # FIXME +7 | # foo # TODO + | + +TD005.py:6:3: TD005 Missing issue description after `TODO` + | +4 | # TODO(evanrittenhouse): +5 | # TODO(evanrittenhouse) +6 | # FIXME + | ^^^^^ TD005 +7 | # foo # TODO + | + +TD005.py:7:9: TD005 Missing issue description after `TODO` + | +5 | # TODO(evanrittenhouse) +6 | # FIXME +7 | # foo # TODO + | ^^^^ TD005 + | + + 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 new file mode 100644 index 0000000000..cded21ee12 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_todos/snapshots/ruff_linter__rules__flake8_todos__tests__missing-todo-link_TD003.py.snap @@ -0,0 +1,50 @@ +--- +source: crates/ruff_linter/src/rules/flake8_todos/mod.rs +--- +TD003.py:9:3: TD003 Missing issue link on the line following this TODO + | + 8 | # TDO003 - errors + 9 | # TODO: this comment has no + | ^^^^ TD003 +10 | # link after it + | + +TD003.py:12:3: TD003 Missing issue link on the line following this TODO + | +10 | # link after it +11 | +12 | # TODO: here's a TODO with no link after it + | ^^^^ TD003 +13 | def foo(x): +14 | return x + | + +TD003.py:25:3: TD003 Missing issue link on the line following this TODO + | +23 | # TDO-3870 +24 | +25 | # TODO: here's a TODO without an issue link + | ^^^^ TD003 +26 | # TODO: followed by a new TODO with an issue link +27 | # TDO-3870 + | + +TD003.py:29:9: TD003 Missing issue link on the line following this TODO + | +27 | # TDO-3870 +28 | +29 | # foo # TODO: no link! + | ^^^^ TD003 +30 | +31 | # TODO: here's a TODO on the last line with no link + | + +TD003.py:31:3: TD003 Missing issue link on the line following this TODO + | +29 | # foo # TODO: no link! +30 | +31 | # TODO: here's a TODO on the last line with no link + | ^^^^ TD003 + | + + diff --git a/crates/ruff/src/rules/flake8_type_checking/helpers.rs b/crates/ruff_linter/src/rules/flake8_type_checking/helpers.rs similarity index 100% rename from crates/ruff/src/rules/flake8_type_checking/helpers.rs rename to crates/ruff_linter/src/rules/flake8_type_checking/helpers.rs diff --git a/crates/ruff/src/rules/flake8_type_checking/mod.rs b/crates/ruff_linter/src/rules/flake8_type_checking/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_type_checking/mod.rs rename to crates/ruff_linter/src/rules/flake8_type_checking/mod.rs diff --git a/crates/ruff/src/rules/flake8_type_checking/rules/empty_type_checking_block.rs b/crates/ruff_linter/src/rules/flake8_type_checking/rules/empty_type_checking_block.rs similarity index 100% rename from crates/ruff/src/rules/flake8_type_checking/rules/empty_type_checking_block.rs rename to crates/ruff_linter/src/rules/flake8_type_checking/rules/empty_type_checking_block.rs diff --git a/crates/ruff/src/rules/flake8_type_checking/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_type_checking/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_type_checking/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_type_checking/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs b/crates/ruff_linter/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs similarity index 100% rename from crates/ruff/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs rename to crates/ruff_linter/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs diff --git a/crates/ruff/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs b/crates/ruff_linter/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs similarity index 100% rename from crates/ruff/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs rename to crates/ruff_linter/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs diff --git a/crates/ruff/src/rules/flake8_type_checking/settings.rs b/crates/ruff_linter/src/rules/flake8_type_checking/settings.rs similarity index 100% rename from crates/ruff/src/rules/flake8_type_checking/settings.rs rename to crates/ruff_linter/src/rules/flake8_type_checking/settings.rs diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__empty-type-checking-block_TCH005.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__empty-type-checking-block_TCH005.py.snap new file mode 100644 index 0000000000..861243885f --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__empty-type-checking-block_TCH005.py.snap @@ -0,0 +1,99 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +TCH005.py:4:5: TCH005 [*] Found empty type-checking block + | +3 | if TYPE_CHECKING: +4 | pass # TCH005 + | ^^^^ TCH005 + | + = help: Delete empty type-checking block + +ℹ Fix +1 1 | from typing import TYPE_CHECKING, List +2 2 | +3 |-if TYPE_CHECKING: +4 |- pass # TCH005 +5 3 | +6 4 | +7 5 | if False: + +TCH005.py:8:5: TCH005 [*] Found empty type-checking block + | + 7 | if False: + 8 | pass # TCH005 + | ^^^^ TCH005 + 9 | +10 | if 0: + | + = help: Delete empty type-checking block + +ℹ Fix +4 4 | pass # TCH005 +5 5 | +6 6 | +7 |-if False: +8 |- pass # TCH005 +9 7 | +10 8 | if 0: +11 9 | pass # TCH005 + +TCH005.py:11:5: TCH005 [*] Found empty type-checking block + | +10 | if 0: +11 | pass # TCH005 + | ^^^^ TCH005 + | + = help: Delete empty type-checking block + +ℹ Fix +7 7 | if False: +8 8 | pass # TCH005 +9 9 | +10 |-if 0: +11 |- pass # TCH005 +12 10 | +13 11 | +14 12 | def example(): + +TCH005.py:16:9: TCH005 [*] Found empty type-checking block + | +14 | def example(): +15 | if TYPE_CHECKING: +16 | pass # TCH005 + | ^^^^ TCH005 +17 | return + | + = help: Delete empty type-checking block + +ℹ Fix +12 12 | +13 13 | +14 14 | def example(): +15 |- if TYPE_CHECKING: +16 |- pass # TCH005 +17 15 | return +18 16 | +19 17 | + +TCH005.py:22:9: TCH005 [*] Found empty type-checking block + | +20 | class Test: +21 | if TYPE_CHECKING: +22 | pass # TCH005 + | ^^^^ TCH005 +23 | x = 2 + | + = help: Delete empty type-checking block + +ℹ Fix +18 18 | +19 19 | +20 20 | class Test: +21 |- if TYPE_CHECKING: +22 |- pass # TCH005 +23 21 | x = 2 +24 22 | +25 23 | + + 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 new file mode 100644 index 0000000000..e80bedfc54 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__exempt_modules.snap @@ -0,0 +1,30 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +exempt_modules.py:14:12: TCH002 [*] Move third-party import `flask` into a type-checking block + | +13 | def f(): +14 | import flask + | ^^^^^ TCH002 +15 | +16 | x: flask + | + = help: Move into type-checking block + +ℹ Suggested fix + 1 |+from typing import TYPE_CHECKING + 2 |+ + 3 |+if TYPE_CHECKING: + 4 |+ import flask +1 5 | def f(): +2 6 | import pandas as pd +3 7 | +-------------------------------------------------------------------------------- +11 15 | +12 16 | +13 17 | def f(): +14 |- import flask +15 18 | +16 19 | x: flask + + diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__import_from.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__import_from.snap new file mode 100644 index 0000000000..1b427e0f3a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__import_from.snap @@ -0,0 +1,31 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +:5:5: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + | +4 | from pandas import ( +5 | DataFrame, # DataFrame + | ^^^^^^^^^ TCH002 +6 | Series, # Series +7 | ) + | + = help: Move into type-checking block + +ℹ Suggested fix +2 2 | from __future__ import annotations +3 3 | +4 4 | from pandas import ( +5 |- DataFrame, # DataFrame +6 5 | Series, # Series +7 6 | ) + 7 |+from typing import TYPE_CHECKING + 8 |+ + 9 |+if TYPE_CHECKING: + 10 |+ from pandas import ( + 11 |+ DataFrame, # DataFrame + 12 |+ ) +8 13 | +9 14 | def f(x: DataFrame): +10 15 | pass + + diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__import_from_type_checking_block.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__import_from_type_checking_block.snap new file mode 100644 index 0000000000..ac5b0d17f9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__import_from_type_checking_block.snap @@ -0,0 +1,30 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +:7:5: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + | +6 | from pandas import ( +7 | DataFrame, # DataFrame + | ^^^^^^^^^ TCH002 +8 | Series, # Series +9 | ) + | + = help: Move into type-checking block + +ℹ Suggested fix +4 4 | from typing import TYPE_CHECKING +5 5 | +6 6 | from pandas import ( +7 |- DataFrame, # DataFrame +8 7 | Series, # Series +9 8 | ) +10 9 | +11 10 | if TYPE_CHECKING: + 11 |+ from pandas import ( + 12 |+ DataFrame, # DataFrame + 13 |+ ) +12 14 | import os +13 15 | +14 16 | def f(x: DataFrame): + + diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_members.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_members.snap new file mode 100644 index 0000000000..4256b3199e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_members.snap @@ -0,0 +1,60 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +:7:5: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + | +6 | from pandas import ( +7 | DataFrame, # DataFrame + | ^^^^^^^^^ TCH002 +8 | Series, # Series +9 | ) + | + = help: Move into type-checking block + +ℹ Suggested fix +3 3 | +4 4 | from typing import TYPE_CHECKING +5 5 | +6 |-from pandas import ( +7 |- DataFrame, # DataFrame +8 |- Series, # Series +9 |-) +10 6 | + 7 |+if TYPE_CHECKING: + 8 |+ from pandas import ( + 9 |+ DataFrame, # DataFrame + 10 |+ Series, # Series + 11 |+ ) + 12 |+ +11 13 | def f(x: DataFrame, y: Series): +12 14 | pass + +:8:5: TCH002 [*] Move third-party import `pandas.Series` into a type-checking block + | +6 | from pandas import ( +7 | DataFrame, # DataFrame +8 | Series, # Series + | ^^^^^^ TCH002 +9 | ) + | + = help: Move into type-checking block + +ℹ Suggested fix +3 3 | +4 4 | from typing import TYPE_CHECKING +5 5 | +6 |-from pandas import ( +7 |- DataFrame, # DataFrame +8 |- Series, # Series +9 |-) +10 6 | + 7 |+if TYPE_CHECKING: + 8 |+ from pandas import ( + 9 |+ DataFrame, # DataFrame + 10 |+ Series, # Series + 11 |+ ) + 12 |+ +11 13 | def f(x: DataFrame, y: Series): +12 14 | pass + + 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 new file mode 100644 index 0000000000..c293b6fe55 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_different_types.snap @@ -0,0 +1,52 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +:6:8: TCH003 [*] Move standard library import `os` into a type-checking block + | +4 | from typing import TYPE_CHECKING +5 | +6 | import os, pandas + | ^^ TCH003 +7 | +8 | def f(x: os, y: pandas): + | + = help: Move into type-checking block + +ℹ Suggested fix +3 3 | +4 4 | from typing import TYPE_CHECKING +5 5 | +6 |-import os, pandas + 6 |+import pandas + 7 |+ + 8 |+if TYPE_CHECKING: + 9 |+ import os +7 10 | +8 11 | def f(x: os, y: pandas): +9 12 | pass + +:6:12: TCH002 [*] Move third-party import `pandas` into a type-checking block + | +4 | from typing import TYPE_CHECKING +5 | +6 | import os, pandas + | ^^^^^^ TCH002 +7 | +8 | def f(x: os, y: pandas): + | + = help: Move into type-checking block + +ℹ Suggested fix +3 3 | +4 4 | from typing import TYPE_CHECKING +5 5 | +6 |-import os, pandas + 6 |+import os + 7 |+ + 8 |+if TYPE_CHECKING: + 9 |+ import pandas +7 10 | +8 11 | def f(x: os, y: pandas): +9 12 | pass + + 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 new file mode 100644 index 0000000000..fa23f5d87a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__multiple_modules_same_type.snap @@ -0,0 +1,50 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +:6:8: TCH003 [*] Move standard library import `os` into a type-checking block + | +4 | from typing import TYPE_CHECKING +5 | +6 | import os, sys + | ^^ TCH003 +7 | +8 | def f(x: os, y: sys): + | + = help: Move into type-checking block + +ℹ Suggested fix +3 3 | +4 4 | from typing import TYPE_CHECKING +5 5 | +6 |-import os, sys +7 6 | + 7 |+if TYPE_CHECKING: + 8 |+ import os, sys + 9 |+ +8 10 | def f(x: os, y: sys): +9 11 | pass + +:6:12: TCH003 [*] Move standard library import `sys` into a type-checking block + | +4 | from typing import TYPE_CHECKING +5 | +6 | import os, sys + | ^^^ TCH003 +7 | +8 | def f(x: os, y: sys): + | + = help: Move into type-checking block + +ℹ Suggested fix +3 3 | +4 4 | from typing import TYPE_CHECKING +5 5 | +6 |-import os, sys +7 6 | + 7 |+if TYPE_CHECKING: + 8 |+ import os, sys + 9 |+ +8 10 | def f(x: os, y: sys): +9 11 | pass + + 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 new file mode 100644 index 0000000000..16a94fdcad --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__no_typing_import.snap @@ -0,0 +1,28 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +:4:18: TCH002 [*] Move third-party import `pandas` into a type-checking block + | +2 | from __future__ import annotations +3 | +4 | import pandas as pd + | ^^ TCH002 +5 | +6 | def f(x: pd.DataFrame): + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | +2 2 | from __future__ import annotations +3 3 | +4 |-import pandas as pd + 4 |+from typing import TYPE_CHECKING + 5 |+ + 6 |+if TYPE_CHECKING: + 7 |+ import pandas as pd +5 8 | +6 9 | def f(x: pd.DataFrame): +7 10 | pass + + 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_TCH004_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_TCH004_1.py.snap new file mode 100644 index 0000000000..ce1d06b0cf --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_1.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +TCH004_1.py:4:26: TCH004 [*] Move import `datetime.datetime` out of type-checking block. Import is used for more than type hinting. + | +3 | if TYPE_CHECKING: +4 | from datetime import datetime + | ^^^^^^^^ TCH004 +5 | x = datetime + | + = help: Move out of type-checking block + +ℹ Suggested fix +1 1 | from typing import TYPE_CHECKING + 2 |+from datetime import datetime +2 3 | +3 4 | if TYPE_CHECKING: +4 |- from datetime import datetime + 5 |+ pass +5 6 | x = datetime + + 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_TCH004_10.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_TCH004_10.py.snap new file mode 100644 index 0000000000..6c5ead2742 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_10.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- + 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_TCH004_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_TCH004_11.py.snap new file mode 100644 index 0000000000..66a8bb5b57 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_11.py.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +TCH004_11.py:4:24: TCH004 [*] 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 + | ^^^^ TCH004 +5 | +6 | __all__ = ("List",) + | + = help: Move out of type-checking block + +ℹ Suggested fix +1 1 | from typing import TYPE_CHECKING + 2 |+from typing import List +2 3 | +3 4 | if TYPE_CHECKING: +4 |- from typing import List + 5 |+ pass +5 6 | +6 7 | __all__ = ("List",) + + 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_TCH004_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_TCH004_12.py.snap new file mode 100644 index 0000000000..2e6d2751e9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_12.py.snap @@ -0,0 +1,26 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +TCH004_12.py:6:33: TCH004 [*] 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 + | ^^^^^^^^ TCH004 +7 | +8 | AnyCallable: TypeAlias = Callable[..., Any] + | + = help: Move out of type-checking block + +ℹ Suggested fix +1 1 | from __future__ import annotations +2 2 | +3 3 | from typing import Any, TYPE_CHECKING, TypeAlias + 4 |+from collections.abc import Callable +4 5 | +5 6 | if TYPE_CHECKING: +6 |- from collections.abc import Callable + 7 |+ pass +7 8 | +8 9 | AnyCallable: TypeAlias = Callable[..., Any] + + 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_TCH004_13.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_TCH004_13.py.snap new file mode 100644 index 0000000000..6c5ead2742 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_13.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- + 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_TCH004_14.pyi.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_14.pyi.snap new file mode 100644 index 0000000000..6c5ead2742 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_14.pyi.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- + 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_TCH004_2.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_TCH004_2.py.snap new file mode 100644 index 0000000000..b2090156ef --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_2.py.snap @@ -0,0 +1,23 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +TCH004_2.py:4:26: TCH004 [*] Move import `datetime.date` out of type-checking block. Import is used for more than type hinting. + | +3 | if TYPE_CHECKING: +4 | from datetime import date + | ^^^^ TCH004 + | + = help: Move out of type-checking block + +ℹ Suggested fix +1 1 | from typing import TYPE_CHECKING + 2 |+from datetime import date +2 3 | +3 4 | if TYPE_CHECKING: +4 |- from datetime import date + 5 |+ pass +5 6 | +6 7 | +7 8 | def example(): + + 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_TCH004_3.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_TCH004_3.py.snap new file mode 100644 index 0000000000..6c5ead2742 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_3.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- + 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_TCH004_4.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_TCH004_4.py.snap new file mode 100644 index 0000000000..1a3ecb0c2c --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_4.py.snap @@ -0,0 +1,23 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +TCH004_4.py:4:24: TCH004 [*] Move import `typing.Any` out of type-checking block. Import is used for more than type hinting. + | +3 | if TYPE_CHECKING: +4 | from typing import Any + | ^^^ TCH004 + | + = help: Move out of type-checking block + +ℹ Suggested fix +1 1 | from typing import TYPE_CHECKING, Type + 2 |+from typing import Any +2 3 | +3 4 | if TYPE_CHECKING: +4 |- from typing import Any + 5 |+ pass +5 6 | +6 7 | +7 8 | def example(*args: Any, **kwargs: Any): + + 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_TCH004_5.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_TCH004_5.py.snap new file mode 100644 index 0000000000..4bded770e5 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_5.py.snap @@ -0,0 +1,61 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +TCH004_5.py:4:24: TCH004 [*] 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, Sequence, Set + | ^^^^ TCH004 + | + = help: Move out of type-checking block + +ℹ Suggested fix +1 1 | from typing import TYPE_CHECKING + 2 |+from typing import List, Sequence, Set +2 3 | +3 4 | if TYPE_CHECKING: +4 |- from typing import List, Sequence, Set + 5 |+ pass +5 6 | +6 7 | +7 8 | def example(a: List[int], /, b: Sequence[int], *, c: Set[int]): + +TCH004_5.py:4:30: TCH004 [*] Move import `typing.Sequence` out of type-checking block. Import is used for more than type hinting. + | +3 | if TYPE_CHECKING: +4 | from typing import List, Sequence, Set + | ^^^^^^^^ TCH004 + | + = help: Move out of type-checking block + +ℹ Suggested fix +1 1 | from typing import TYPE_CHECKING + 2 |+from typing import List, Sequence, Set +2 3 | +3 4 | if TYPE_CHECKING: +4 |- from typing import List, Sequence, Set + 5 |+ pass +5 6 | +6 7 | +7 8 | def example(a: List[int], /, b: Sequence[int], *, c: Set[int]): + +TCH004_5.py:4:40: TCH004 [*] Move import `typing.Set` out of type-checking block. Import is used for more than type hinting. + | +3 | if TYPE_CHECKING: +4 | from typing import List, Sequence, Set + | ^^^ TCH004 + | + = help: Move out of type-checking block + +ℹ Suggested fix +1 1 | from typing import TYPE_CHECKING + 2 |+from typing import List, Sequence, Set +2 3 | +3 4 | if TYPE_CHECKING: +4 |- from typing import List, Sequence, Set + 5 |+ pass +5 6 | +6 7 | +7 8 | def example(a: List[int], /, b: Sequence[int], *, c: Set[int]): + + 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_TCH004_6.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_TCH004_6.py.snap new file mode 100644 index 0000000000..6c5ead2742 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_6.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- + 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_TCH004_7.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_TCH004_7.py.snap new file mode 100644 index 0000000000..6c5ead2742 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_7.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- + 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_TCH004_8.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_TCH004_8.py.snap new file mode 100644 index 0000000000..6c5ead2742 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_8.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- + 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_TCH004_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_TCH004_9.py.snap new file mode 100644 index 0000000000..3af36dde40 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__runtime-import-in-type-checking-block_TCH004_9.py.snap @@ -0,0 +1,46 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +TCH004_9.py:4:24: TCH004 [*] 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 + | ^^^^^ TCH004 +5 | +6 | x: Tuple + | + = help: Move out of type-checking block + +ℹ Suggested fix +1 1 | from typing import TYPE_CHECKING + 2 |+from typing import Tuple, List +2 3 | +3 4 | if TYPE_CHECKING: +4 |- from typing import Tuple, List, Dict + 5 |+ from typing import Dict +5 6 | +6 7 | x: Tuple +7 8 | + +TCH004_9.py:4:31: TCH004 [*] 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 Tuple, List, Dict + | ^^^^ TCH004 +5 | +6 | x: Tuple + | + = help: Move out of type-checking block + +ℹ Suggested fix +1 1 | from typing import TYPE_CHECKING + 2 |+from typing import Tuple, List +2 3 | +3 4 | if TYPE_CHECKING: +4 |- from typing import Tuple, List, Dict + 5 |+ from typing import Dict +5 6 | +6 7 | x: Tuple +7 8 | + + 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 new file mode 100644 index 0000000000..263990b605 --- /dev/null +++ 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 @@ -0,0 +1,74 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +runtime_evaluated_base_classes_1.py:10:12: TCH004 [*] Move import `datetime` out of type-checking block. Import is used for more than type hinting. + | + 9 | if TYPE_CHECKING: +10 | import datetime # TCH004 + | ^^^^^^^^ TCH004 +11 | from array import array # TCH004 + | + = help: Move out of type-checking block + +ℹ Suggested fix +5 5 | +6 6 | import pydantic +7 7 | from pydantic import BaseModel + 8 |+import datetime +8 9 | +9 10 | if TYPE_CHECKING: +10 |- import datetime # TCH004 +11 11 | from array import array # TCH004 +12 12 | +13 13 | import pandas # TCH004 + +runtime_evaluated_base_classes_1.py:11:23: TCH004 [*] Move import `array.array` out of type-checking block. Import is used for more than type hinting. + | + 9 | if TYPE_CHECKING: +10 | import datetime # TCH004 +11 | from array import array # TCH004 + | ^^^^^ TCH004 +12 | +13 | import pandas # TCH004 + | + = help: Move out of type-checking block + +ℹ Suggested fix +5 5 | +6 6 | import pydantic +7 7 | from pydantic import BaseModel + 8 |+from array import array +8 9 | +9 10 | if TYPE_CHECKING: +10 11 | import datetime # TCH004 +11 |- from array import array # TCH004 +12 12 | +13 13 | import pandas # TCH004 +14 14 | import pyproj + +runtime_evaluated_base_classes_1.py:13:12: TCH004 [*] Move import `pandas` out of type-checking block. Import is used for more than type hinting. + | +11 | from array import array # TCH004 +12 | +13 | import pandas # TCH004 + | ^^^^^^ TCH004 +14 | import pyproj + | + = help: Move out of type-checking block + +ℹ Suggested fix +5 5 | +6 6 | import pydantic +7 7 | from pydantic import BaseModel + 8 |+import pandas +8 9 | +9 10 | if TYPE_CHECKING: +10 11 | import datetime # TCH004 +11 12 | from array import array # TCH004 +12 13 | +13 |- import pandas # TCH004 +14 14 | import pyproj +15 15 | +16 16 | + + 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 new file mode 100644 index 0000000000..c472d3f9d8 --- /dev/null +++ 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 @@ -0,0 +1,74 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +runtime_evaluated_decorators_1.py:12:12: TCH004 [*] Move import `datetime` out of type-checking block. Import is used for more than type hinting. + | +11 | if TYPE_CHECKING: +12 | import datetime # TCH004 + | ^^^^^^^^ TCH004 +13 | from array import array # TCH004 + | + = help: Move out of type-checking block + +ℹ Suggested fix +7 7 | from attrs import frozen +8 8 | +9 9 | import numpy + 10 |+import datetime +10 11 | +11 12 | if TYPE_CHECKING: +12 |- import datetime # TCH004 +13 13 | from array import array # TCH004 +14 14 | +15 15 | import pandas # TCH004 + +runtime_evaluated_decorators_1.py:13:23: TCH004 [*] Move import `array.array` out of type-checking block. Import is used for more than type hinting. + | +11 | if TYPE_CHECKING: +12 | import datetime # TCH004 +13 | from array import array # TCH004 + | ^^^^^ TCH004 +14 | +15 | import pandas # TCH004 + | + = help: Move out of type-checking block + +ℹ Suggested fix +7 7 | from attrs import frozen +8 8 | +9 9 | import numpy + 10 |+from array import array +10 11 | +11 12 | if TYPE_CHECKING: +12 13 | import datetime # TCH004 +13 |- from array import array # TCH004 +14 14 | +15 15 | import pandas # TCH004 +16 16 | import pyproj + +runtime_evaluated_decorators_1.py:15:12: TCH004 [*] Move import `pandas` out of type-checking block. Import is used for more than type hinting. + | +13 | from array import array # TCH004 +14 | +15 | import pandas # TCH004 + | ^^^^^^ TCH004 +16 | import pyproj + | + = help: Move out of type-checking block + +ℹ Suggested fix +7 7 | from attrs import frozen +8 8 | +9 9 | import numpy + 10 |+import pandas +10 11 | +11 12 | if TYPE_CHECKING: +12 13 | import datetime # TCH004 +13 14 | from array import array # TCH004 +14 15 | +15 |- import pandas # TCH004 +16 16 | import pyproj +17 17 | +18 18 | + + diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict.snap new file mode 100644 index 0000000000..835a51bce3 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__strict.snap @@ -0,0 +1,233 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +strict.py:27:21: TCH002 [*] Move third-party import `pkg.A` into a type-checking block + | +25 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime. +26 | import pkg +27 | from pkg import A + | ^ TCH002 +28 | +29 | def test(value: A): + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | from __future__ import annotations + 2 |+from typing import TYPE_CHECKING + 3 |+ + 4 |+if TYPE_CHECKING: + 5 |+ from pkg import A +2 6 | +3 7 | +4 8 | def f(): +-------------------------------------------------------------------------------- +24 28 | def f(): +25 29 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime. +26 30 | import pkg +27 |- from pkg import A +28 31 | +29 32 | def test(value: A): +30 33 | return pkg.B() + +strict.py:35:21: TCH002 [*] Move third-party import `pkg.A` into a type-checking block + | +33 | def f(): +34 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime. +35 | from pkg import A, B + | ^ TCH002 +36 | +37 | def test(value: A): + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | from __future__ import annotations + 2 |+from typing import TYPE_CHECKING + 3 |+ + 4 |+if TYPE_CHECKING: + 5 |+ from pkg import A +2 6 | +3 7 | +4 8 | def f(): +-------------------------------------------------------------------------------- +32 36 | +33 37 | def f(): +34 38 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime. +35 |- from pkg import A, B + 39 |+ from pkg import B +36 40 | +37 41 | def test(value: A): +38 42 | return B() + +strict.py:54:25: TCH002 [*] Move third-party import `pkg.bar.A` into a type-checking block + | +52 | # In un-strict mode, this _should_ raise an error, since `pkg.bar` isn't used at runtime +53 | import pkg +54 | from pkg.bar import A + | ^ TCH002 +55 | +56 | def test(value: A): + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | from __future__ import annotations + 2 |+from typing import TYPE_CHECKING + 3 |+ + 4 |+if TYPE_CHECKING: + 5 |+ from pkg.bar import A +2 6 | +3 7 | +4 8 | def f(): +-------------------------------------------------------------------------------- +51 55 | def f(): +52 56 | # In un-strict mode, this _should_ raise an error, since `pkg.bar` isn't used at runtime +53 57 | import pkg +54 |- from pkg.bar import A +55 58 | +56 59 | def test(value: A): +57 60 | return pkg.B() + +strict.py:62:12: TCH002 [*] Move third-party import `pkg` into a type-checking block + | +60 | def f(): +61 | # In un-strict mode, this shouldn't raise an error, since `pkg.bar` is used at runtime. +62 | import pkg + | ^^^ TCH002 +63 | import pkg.bar as B + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | from __future__ import annotations + 2 |+from typing import TYPE_CHECKING + 3 |+ + 4 |+if TYPE_CHECKING: + 5 |+ import pkg +2 6 | +3 7 | +4 8 | def f(): +-------------------------------------------------------------------------------- +59 63 | +60 64 | def f(): +61 65 | # In un-strict mode, this shouldn't raise an error, since `pkg.bar` is used at runtime. +62 |- import pkg +63 66 | import pkg.bar as B +64 67 | +65 68 | def test(value: pkg.A): + +strict.py:71:23: TCH002 [*] Move third-party import `pkg.foo` into a type-checking block + | +69 | def f(): +70 | # In un-strict mode, this shouldn't raise an error, since `pkg.foo.bar` is used at runtime. +71 | import pkg.foo as F + | ^ TCH002 +72 | import pkg.foo.bar as B + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | from __future__ import annotations + 2 |+from typing import TYPE_CHECKING + 3 |+ + 4 |+if TYPE_CHECKING: + 5 |+ import pkg.foo as F +2 6 | +3 7 | +4 8 | def f(): +-------------------------------------------------------------------------------- +68 72 | +69 73 | def f(): +70 74 | # In un-strict mode, this shouldn't raise an error, since `pkg.foo.bar` is used at runtime. +71 |- import pkg.foo as F +72 75 | import pkg.foo.bar as B +73 76 | +74 77 | def test(value: F.Foo): + +strict.py:80:12: TCH002 [*] Move third-party import `pkg` into a type-checking block + | +78 | def f(): +79 | # In un-strict mode, this shouldn't raise an error, since `pkg.foo.bar` is used at runtime. +80 | import pkg + | ^^^ TCH002 +81 | import pkg.foo.bar as B + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | from __future__ import annotations + 2 |+from typing import TYPE_CHECKING + 3 |+ + 4 |+if TYPE_CHECKING: + 5 |+ import pkg +2 6 | +3 7 | +4 8 | def f(): +-------------------------------------------------------------------------------- +77 81 | +78 82 | def f(): +79 83 | # In un-strict mode, this shouldn't raise an error, since `pkg.foo.bar` is used at runtime. +80 |- import pkg +81 84 | import pkg.foo.bar as B +82 85 | +83 86 | def test(value: pkg.A): + +strict.py:91:12: TCH002 [*] Move third-party import `pkg` into a type-checking block + | +89 | # Note that `pkg` is a prefix of `pkgfoo` which are both different modules. This is +90 | # testing the implementation. +91 | import pkg + | ^^^ TCH002 +92 | import pkgfoo.bar as B + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | from __future__ import annotations + 2 |+from typing import TYPE_CHECKING + 3 |+ + 4 |+if TYPE_CHECKING: + 5 |+ import pkg +2 6 | +3 7 | +4 8 | def f(): +-------------------------------------------------------------------------------- +88 92 | # In un-strict mode, this _should_ raise an error, since `pkg` isn't used at runtime. +89 93 | # Note that `pkg` is a prefix of `pkgfoo` which are both different modules. This is +90 94 | # testing the implementation. +91 |- import pkg +92 95 | import pkgfoo.bar as B +93 96 | +94 97 | def test(value: pkg.A): + +strict.py:101:23: TCH002 [*] Move third-party import `pkg.foo` into a type-checking block + | + 99 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime. +100 | import pkg.bar as B +101 | import pkg.foo as F + | ^ TCH002 +102 | +103 | def test(value: F.Foo): + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | from __future__ import annotations + 2 |+from typing import TYPE_CHECKING + 3 |+ + 4 |+if TYPE_CHECKING: + 5 |+ import pkg.foo as F +2 6 | +3 7 | +4 8 | def f(): +-------------------------------------------------------------------------------- +98 102 | def f(): +99 103 | # In un-strict mode, this shouldn't raise an error, since `pkg` is used at runtime. +100 104 | import pkg.bar as B +101 |- import pkg.foo as F +102 105 | +103 106 | def test(value: F.Foo): +104 107 | return B.Bar() + + 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 new file mode 100644 index 0000000000..f97e331017 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_after_usage.snap @@ -0,0 +1,28 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +:6:18: TCH002 [*] Move third-party import `pandas` into a type-checking block + | +4 | from typing import TYPE_CHECKING +5 | +6 | import pandas as pd + | ^^ TCH002 +7 | +8 | def f(x: pd.DataFrame): + | + = help: Move into type-checking block + +ℹ Suggested fix +3 3 | +4 4 | from typing import TYPE_CHECKING +5 5 | +6 |-import pandas as pd +7 6 | + 7 |+if TYPE_CHECKING: + 8 |+ import pandas as pd + 9 |+ +8 10 | def f(x: pd.DataFrame): +9 11 | pass +10 12 | + + 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 new file mode 100644 index 0000000000..d554a00b16 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_comment.snap @@ -0,0 +1,28 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +:6:18: TCH002 [*] Move third-party import `pandas` into a type-checking block + | +4 | from typing import TYPE_CHECKING +5 | +6 | import pandas as pd + | ^^ TCH002 +7 | +8 | if TYPE_CHECKING: + | + = help: Move into type-checking block + +ℹ Suggested fix +3 3 | +4 4 | from typing import TYPE_CHECKING +5 5 | +6 |-import pandas as pd +7 6 | +8 7 | if TYPE_CHECKING: +9 8 | # This is a comment. + 9 |+ import pandas as pd +10 10 | import os +11 11 | +12 12 | def f(x: pd.DataFrame): + + 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 new file mode 100644 index 0000000000..027b2a6826 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_inline.snap @@ -0,0 +1,27 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +:6:18: TCH002 [*] Move third-party import `pandas` into a type-checking block + | +4 | from typing import TYPE_CHECKING +5 | +6 | import pandas as pd + | ^^ TCH002 +7 | +8 | if TYPE_CHECKING: import os + | + = help: Move into type-checking block + +ℹ Suggested fix +3 3 | +4 4 | from typing import TYPE_CHECKING +5 5 | +6 |-import pandas as pd +7 6 | +8 |-if TYPE_CHECKING: import os + 7 |+if TYPE_CHECKING: import pandas as pd; import os +9 8 | +10 9 | def f(x: pd.DataFrame): +11 10 | pass + + 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 new file mode 100644 index 0000000000..60a5c92f63 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__type_checking_block_own_line.snap @@ -0,0 +1,27 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +:6:18: TCH002 [*] Move third-party import `pandas` into a type-checking block + | +4 | from typing import TYPE_CHECKING +5 | +6 | import pandas as pd + | ^^ TCH002 +7 | +8 | if TYPE_CHECKING: + | + = help: Move into type-checking block + +ℹ Suggested fix +3 3 | +4 4 | from typing import TYPE_CHECKING +5 5 | +6 |-import pandas as pd +7 6 | +8 7 | if TYPE_CHECKING: + 8 |+ import pandas as pd +9 9 | import os +10 10 | +11 11 | def f(x: pd.DataFrame): + + diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-first-party-import_TCH001.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-first-party-import_TCH001.py.snap new file mode 100644 index 0000000000..8a486f94ba --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-first-party-import_TCH001.py.snap @@ -0,0 +1,34 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +TCH001.py:20:19: TCH001 [*] Move application import `.TYP001` into a type-checking block + | +19 | def f(): +20 | from . import TYP001 + | ^^^^^^ TCH001 +21 | +22 | x: TYP001 + | + = help: Move into type-checking block + +ℹ Suggested fix +2 2 | +3 3 | For typing-only import detection tests, see `TCH002.py`. +4 4 | """ + 5 |+from typing import TYPE_CHECKING + 6 |+ + 7 |+if TYPE_CHECKING: + 8 |+ from . import TYP001 +5 9 | +6 10 | +7 11 | def f(): +-------------------------------------------------------------------------------- +17 21 | +18 22 | +19 23 | def f(): +20 |- from . import TYP001 +21 24 | +22 25 | x: TYP001 +23 26 | + + diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_TCH003.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_TCH003.py.snap new file mode 100644 index 0000000000..f1e2a0bfe2 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_TCH003.py.snap @@ -0,0 +1,30 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +TCH003.py:8:12: TCH003 [*] Move standard library import `os` into a type-checking block + | + 7 | def f(): + 8 | import os + | ^^ TCH003 + 9 | +10 | x: os + | + = help: Move into type-checking block + +ℹ Suggested fix +2 2 | +3 3 | For typing-only import detection tests, see `TCH002.py`. +4 4 | """ + 5 |+from typing import TYPE_CHECKING + 6 |+ + 7 |+if TYPE_CHECKING: + 8 |+ import os +5 9 | +6 10 | +7 11 | def f(): +8 |- import os +9 12 | +10 13 | x: os +11 14 | + + 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 new file mode 100644 index 0000000000..8e151b89da --- /dev/null +++ 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 @@ -0,0 +1,31 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +runtime_evaluated_base_classes_3.py:5:18: TCH003 [*] Move standard library import `uuid.UUID` into a type-checking block + | +3 | import datetime +4 | import pathlib +5 | from uuid import UUID # TCH003 + | ^^^^ TCH003 +6 | +7 | import pydantic + | + = help: Move into type-checking block + +ℹ Suggested fix +2 2 | +3 3 | import datetime +4 4 | import pathlib +5 |-from uuid import UUID # TCH003 +6 5 | +7 6 | import pydantic +8 7 | from pydantic import BaseModel + 8 |+from typing import TYPE_CHECKING + 9 |+ + 10 |+if TYPE_CHECKING: + 11 |+ from uuid import UUID +9 12 | +10 13 | +11 14 | class A(pydantic.BaseModel): + + 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_4.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_4.py.snap new file mode 100644 index 0000000000..6c5ead2742 --- /dev/null +++ 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_4.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- + 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_decorators_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_decorators_3.py.snap new file mode 100644 index 0000000000..99dade0f99 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_runtime_evaluated_decorators_3.py.snap @@ -0,0 +1,31 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +runtime_evaluated_decorators_3.py:6:18: TCH003 [*] Move standard library import `uuid.UUID` into a type-checking block + | +4 | from array import array +5 | from dataclasses import dataclass +6 | from uuid import UUID # TCH003 + | ^^^^ TCH003 +7 | +8 | import attrs + | + = help: Move into type-checking block + +ℹ Suggested fix +3 3 | import datetime +4 4 | from array import array +5 5 | from dataclasses import dataclass +6 |-from uuid import UUID # TCH003 +7 6 | +8 7 | import attrs +9 8 | from attrs import frozen + 9 |+from typing import TYPE_CHECKING + 10 |+ + 11 |+if TYPE_CHECKING: + 12 |+ from uuid import UUID +10 13 | +11 14 | +12 15 | @attrs.define(auto_attribs=True) + + diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_snapshot.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_snapshot.py.snap new file mode 100644 index 0000000000..6c5ead2742 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-standard-library-import_snapshot.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_TCH002.py.snap b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_TCH002.py.snap new file mode 100644 index 0000000000..5f1ea76784 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing-only-third-party-import_TCH002.py.snap @@ -0,0 +1,252 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +TCH002.py:5:22: TCH002 [*] Move third-party import `pandas` into a type-checking block + | +4 | def f(): +5 | import pandas as pd # TCH002 + | ^^ TCH002 +6 | +7 | x: pd.DataFrame + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | """Tests to determine accurate detection of typing-only imports.""" + 2 |+from typing import TYPE_CHECKING + 3 |+ + 4 |+if TYPE_CHECKING: + 5 |+ import pandas as pd +2 6 | +3 7 | +4 8 | def f(): +5 |- import pandas as pd # TCH002 +6 9 | +7 10 | x: pd.DataFrame +8 11 | + +TCH002.py:11:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + | +10 | def f(): +11 | from pandas import DataFrame # TCH002 + | ^^^^^^^^^ TCH002 +12 | +13 | x: DataFrame + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | """Tests to determine accurate detection of typing-only imports.""" + 2 |+from typing import TYPE_CHECKING + 3 |+ + 4 |+if TYPE_CHECKING: + 5 |+ from pandas import DataFrame +2 6 | +3 7 | +4 8 | def f(): +-------------------------------------------------------------------------------- +8 12 | +9 13 | +10 14 | def f(): +11 |- from pandas import DataFrame # TCH002 +12 15 | +13 16 | x: DataFrame +14 17 | + +TCH002.py:17:37: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + | +16 | def f(): +17 | from pandas import DataFrame as df # TCH002 + | ^^ TCH002 +18 | +19 | x: df + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | """Tests to determine accurate detection of typing-only imports.""" + 2 |+from typing import TYPE_CHECKING + 3 |+ + 4 |+if TYPE_CHECKING: + 5 |+ from pandas import DataFrame as df +2 6 | +3 7 | +4 8 | def f(): +-------------------------------------------------------------------------------- +14 18 | +15 19 | +16 20 | def f(): +17 |- from pandas import DataFrame as df # TCH002 +18 21 | +19 22 | x: df +20 23 | + +TCH002.py:23:22: TCH002 [*] Move third-party import `pandas` into a type-checking block + | +22 | def f(): +23 | import pandas as pd # TCH002 + | ^^ TCH002 +24 | +25 | x: pd.DataFrame = 1 + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | """Tests to determine accurate detection of typing-only imports.""" + 2 |+from typing import TYPE_CHECKING + 3 |+ + 4 |+if TYPE_CHECKING: + 5 |+ import pandas as pd +2 6 | +3 7 | +4 8 | def f(): +-------------------------------------------------------------------------------- +20 24 | +21 25 | +22 26 | def f(): +23 |- import pandas as pd # TCH002 +24 27 | +25 28 | x: pd.DataFrame = 1 +26 29 | + +TCH002.py:29:24: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + | +28 | def f(): +29 | from pandas import DataFrame # TCH002 + | ^^^^^^^^^ TCH002 +30 | +31 | x: DataFrame = 2 + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | """Tests to determine accurate detection of typing-only imports.""" + 2 |+from typing import TYPE_CHECKING + 3 |+ + 4 |+if TYPE_CHECKING: + 5 |+ from pandas import DataFrame +2 6 | +3 7 | +4 8 | def f(): +-------------------------------------------------------------------------------- +26 30 | +27 31 | +28 32 | def f(): +29 |- from pandas import DataFrame # TCH002 +30 33 | +31 34 | x: DataFrame = 2 +32 35 | + +TCH002.py:35:37: TCH002 [*] Move third-party import `pandas.DataFrame` into a type-checking block + | +34 | def f(): +35 | from pandas import DataFrame as df # TCH002 + | ^^ TCH002 +36 | +37 | x: df = 3 + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | """Tests to determine accurate detection of typing-only imports.""" + 2 |+from typing import TYPE_CHECKING + 3 |+ + 4 |+if TYPE_CHECKING: + 5 |+ from pandas import DataFrame as df +2 6 | +3 7 | +4 8 | def f(): +-------------------------------------------------------------------------------- +32 36 | +33 37 | +34 38 | def f(): +35 |- from pandas import DataFrame as df # TCH002 +36 39 | +37 40 | x: df = 3 +38 41 | + +TCH002.py:41:22: TCH002 [*] Move third-party import `pandas` into a type-checking block + | +40 | def f(): +41 | import pandas as pd # TCH002 + | ^^ TCH002 +42 | +43 | x: "pd.DataFrame" = 1 + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | """Tests to determine accurate detection of typing-only imports.""" + 2 |+from typing import TYPE_CHECKING + 3 |+ + 4 |+if TYPE_CHECKING: + 5 |+ import pandas as pd +2 6 | +3 7 | +4 8 | def f(): +-------------------------------------------------------------------------------- +38 42 | +39 43 | +40 44 | def f(): +41 |- import pandas as pd # TCH002 +42 45 | +43 46 | x: "pd.DataFrame" = 1 +44 47 | + +TCH002.py:47:22: TCH002 [*] Move third-party import `pandas` into a type-checking block + | +46 | def f(): +47 | import pandas as pd # TCH002 + | ^^ TCH002 +48 | +49 | x = dict["pd.DataFrame", "pd.DataFrame"] + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | """Tests to determine accurate detection of typing-only imports.""" + 2 |+from typing import TYPE_CHECKING + 3 |+ + 4 |+if TYPE_CHECKING: + 5 |+ import pandas as pd +2 6 | +3 7 | +4 8 | def f(): +-------------------------------------------------------------------------------- +44 48 | +45 49 | +46 50 | def f(): +47 |- import pandas as pd # TCH002 +48 51 | +49 52 | x = dict["pd.DataFrame", "pd.DataFrame"] +50 53 | + +TCH002.py:172:24: TCH002 [*] Move third-party import `module.Member` into a type-checking block + | +170 | global Member +171 | +172 | from module import Member + | ^^^^^^ TCH002 +173 | +174 | x: Member = 1 + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | """Tests to determine accurate detection of typing-only imports.""" + 2 |+from typing import TYPE_CHECKING + 3 |+ + 4 |+if TYPE_CHECKING: + 5 |+ from module import Member +2 6 | +3 7 | +4 8 | def f(): +-------------------------------------------------------------------------------- +169 173 | def f(): +170 174 | global Member +171 175 | +172 |- from module import Member +173 176 | +174 177 | x: Member = 1 + + 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 new file mode 100644 index 0000000000..ac865d383c --- /dev/null +++ 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 @@ -0,0 +1,58 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +runtime_evaluated_base_classes_2.py:3:21: TCH002 [*] Move third-party import `geopandas` into a type-checking block + | +1 | from __future__ import annotations +2 | +3 | import geopandas as gpd # TCH002 + | ^^^ TCH002 +4 | import pydantic +5 | import pyproj # TCH002 + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | from __future__ import annotations +2 2 | +3 |-import geopandas as gpd # TCH002 +4 3 | import pydantic +5 4 | import pyproj # TCH002 +6 5 | from pydantic import BaseModel +7 6 | +8 7 | import numpy + 8 |+from typing import TYPE_CHECKING + 9 |+ + 10 |+if TYPE_CHECKING: + 11 |+ import geopandas as gpd +9 12 | +10 13 | +11 14 | class A(BaseModel): + +runtime_evaluated_base_classes_2.py:5:8: TCH002 [*] Move third-party import `pyproj` into a type-checking block + | +3 | import geopandas as gpd # TCH002 +4 | import pydantic +5 | import pyproj # TCH002 + | ^^^^^^ TCH002 +6 | from pydantic import BaseModel + | + = help: Move into type-checking block + +ℹ Suggested fix +2 2 | +3 3 | import geopandas as gpd # TCH002 +4 4 | import pydantic +5 |-import pyproj # TCH002 +6 5 | from pydantic import BaseModel +7 6 | +8 7 | import numpy + 8 |+from typing import TYPE_CHECKING + 9 |+ + 10 |+if TYPE_CHECKING: + 11 |+ import pyproj +9 12 | +10 13 | +11 14 | class A(BaseModel): + + 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 new file mode 100644 index 0000000000..dafbc94d64 --- /dev/null +++ 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 @@ -0,0 +1,26 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +runtime_evaluated_decorators_2.py:10:8: TCH002 [*] Move third-party import `numpy` into a type-checking block + | + 8 | from attrs import frozen + 9 | +10 | import numpy # TCH002 + | ^^^^^ TCH002 + | + = help: Move into type-checking block + +ℹ Suggested fix +7 7 | import pyproj +8 8 | from attrs import frozen +9 9 | +10 |-import numpy # TCH002 + 10 |+from typing import TYPE_CHECKING + 11 |+ + 12 |+if TYPE_CHECKING: + 13 |+ import numpy +11 14 | +12 15 | +13 16 | @attrs.define(auto_attribs=True) + + 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 new file mode 100644 index 0000000000..496d0f5587 --- /dev/null +++ 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 @@ -0,0 +1,61 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +strict.py:54:25: TCH002 [*] Move third-party import `pkg.bar.A` into a type-checking block + | +52 | # In un-strict mode, this _should_ raise an error, since `pkg.bar` isn't used at runtime +53 | import pkg +54 | from pkg.bar import A + | ^ TCH002 +55 | +56 | def test(value: A): + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | from __future__ import annotations + 2 |+from typing import TYPE_CHECKING + 3 |+ + 4 |+if TYPE_CHECKING: + 5 |+ from pkg.bar import A +2 6 | +3 7 | +4 8 | def f(): +-------------------------------------------------------------------------------- +51 55 | def f(): +52 56 | # In un-strict mode, this _should_ raise an error, since `pkg.bar` isn't used at runtime +53 57 | import pkg +54 |- from pkg.bar import A +55 58 | +56 59 | def test(value: A): +57 60 | return pkg.B() + +strict.py:91:12: TCH002 [*] Move third-party import `pkg` into a type-checking block + | +89 | # Note that `pkg` is a prefix of `pkgfoo` which are both different modules. This is +90 | # testing the implementation. +91 | import pkg + | ^^^ TCH002 +92 | import pkgfoo.bar as B + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | from __future__ import annotations + 2 |+from typing import TYPE_CHECKING + 3 |+ + 4 |+if TYPE_CHECKING: + 5 |+ import pkg +2 6 | +3 7 | +4 8 | def f(): +-------------------------------------------------------------------------------- +88 92 | # In un-strict mode, this _should_ raise an error, since `pkg` isn't used at runtime. +89 93 | # Note that `pkg` is a prefix of `pkgfoo` which are both different modules. This is +90 94 | # testing the implementation. +91 |- import pkg +92 95 | import pkgfoo.bar as B +93 96 | +94 97 | def test(value: pkg.A): + + 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 new file mode 100644 index 0000000000..df0299e8a7 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_package_import.snap @@ -0,0 +1,29 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +:4:18: TCH002 [*] Move third-party import `pandas` into a type-checking block + | +2 | from __future__ import annotations +3 | +4 | import pandas as pd + | ^^ TCH002 +5 | +6 | from typing import TYPE_CHECKING + | + = help: Move into type-checking block + +ℹ Suggested fix +1 1 | +2 2 | from __future__ import annotations +3 3 | +4 |-import pandas as pd +5 4 | +6 5 | from typing import TYPE_CHECKING +7 6 | + 7 |+if TYPE_CHECKING: + 8 |+ import pandas as pd + 9 |+ +8 10 | def f(x: pd.DataFrame): +9 11 | pass + + 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 new file mode 100644 index 0000000000..03cb3c36fe --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_after_usage.snap @@ -0,0 +1,15 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +:4:18: TCH002 Move third-party import `pandas` into a type-checking block + | +2 | from __future__ import annotations +3 | +4 | import pandas as pd + | ^^ TCH002 +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 new file mode 100644 index 0000000000..361042da6b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_type_checking/snapshots/ruff_linter__rules__flake8_type_checking__tests__typing_import_before_package_import.snap @@ -0,0 +1,27 @@ +--- +source: crates/ruff_linter/src/rules/flake8_type_checking/mod.rs +--- +:6:18: TCH002 [*] Move third-party import `pandas` into a type-checking block + | +4 | from typing import TYPE_CHECKING +5 | +6 | import pandas as pd + | ^^ TCH002 +7 | +8 | def f(x: pd.DataFrame): + | + = help: Move into type-checking block + +ℹ Suggested fix +3 3 | +4 4 | from typing import TYPE_CHECKING +5 5 | +6 |-import pandas as pd +7 6 | + 7 |+if TYPE_CHECKING: + 8 |+ import pandas as pd + 9 |+ +8 10 | def f(x: pd.DataFrame): +9 11 | pass + + diff --git a/crates/ruff/src/rules/flake8_unused_arguments/helpers.rs b/crates/ruff_linter/src/rules/flake8_unused_arguments/helpers.rs similarity index 100% rename from crates/ruff/src/rules/flake8_unused_arguments/helpers.rs rename to crates/ruff_linter/src/rules/flake8_unused_arguments/helpers.rs diff --git a/crates/ruff/src/rules/flake8_unused_arguments/mod.rs b/crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_unused_arguments/mod.rs rename to crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs diff --git a/crates/ruff/src/rules/flake8_unused_arguments/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_unused_arguments/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_unused_arguments/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_unused_arguments/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_unused_arguments/rules/unused_arguments.rs b/crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs similarity index 100% rename from crates/ruff/src/rules/flake8_unused_arguments/rules/unused_arguments.rs rename to crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs diff --git a/crates/ruff/src/rules/flake8_unused_arguments/settings.rs b/crates/ruff_linter/src/rules/flake8_unused_arguments/settings.rs similarity index 100% rename from crates/ruff/src/rules/flake8_unused_arguments/settings.rs rename to crates/ruff_linter/src/rules/flake8_unused_arguments/settings.rs diff --git a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG001_ARG.py.snap b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG001_ARG.py.snap new file mode 100644 index 0000000000..c5b77b6f82 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG001_ARG.py.snap @@ -0,0 +1,64 @@ +--- +source: crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs +--- +ARG.py:9:7: ARG001 Unused function argument: `self` + | + 7 | # Unused arguments on functions. + 8 | ### + 9 | def f(self, x): + | ^^^^ ARG001 +10 | print("Hello, world!") + | + +ARG.py:9:13: ARG001 Unused function argument: `x` + | + 7 | # Unused arguments on functions. + 8 | ### + 9 | def f(self, x): + | ^ ARG001 +10 | print("Hello, world!") + | + +ARG.py:13:7: ARG001 Unused function argument: `cls` + | +13 | def f(cls, x): + | ^^^ ARG001 +14 | print("Hello, world!") + | + +ARG.py:13:12: ARG001 Unused function argument: `x` + | +13 | def f(cls, x): + | ^ ARG001 +14 | print("Hello, world!") + | + +ARG.py:17:7: ARG001 Unused function argument: `self` + | +17 | def f(self, x): + | ^^^^ ARG001 +18 | ... + | + +ARG.py:17:13: ARG001 Unused function argument: `x` + | +17 | def f(self, x): + | ^ ARG001 +18 | ... + | + +ARG.py:21:7: ARG001 Unused function argument: `cls` + | +21 | def f(cls, x): + | ^^^ ARG001 +22 | ... + | + +ARG.py:21:12: ARG001 Unused function argument: `x` + | +21 | def f(cls, x): + | ^ ARG001 +22 | ... + | + + 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 new file mode 100644 index 0000000000..e235a37a53 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG002_ARG.py.snap @@ -0,0 +1,40 @@ +--- +source: crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs +--- +ARG.py:37:17: ARG002 Unused method argument: `x` + | +35 | # Unused arguments. +36 | ### +37 | def f(self, x): + | ^ ARG002 +38 | print("Hello, world!") + | + +ARG.py:40:20: ARG002 Unused method argument: `x` + | +38 | print("Hello, world!") +39 | +40 | def f(self, /, x): + | ^ ARG002 +41 | print("Hello, world!") + | + +ARG.py:43:16: ARG002 Unused method argument: `x` + | +41 | print("Hello, world!") +42 | +43 | def f(cls, x): + | ^ ARG002 +44 | print("Hello, world!") + | + +ARG.py:192:24: ARG002 Unused method argument: `x` + | +190 | ### +191 | class C: +192 | def __init__(self, x) -> None: + | ^ ARG002 +193 | print("Hello, world!") + | + + diff --git a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG003_ARG.py.snap b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG003_ARG.py.snap new file mode 100644 index 0000000000..39f89b091b --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG003_ARG.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs +--- +ARG.py:47:16: ARG003 Unused class method argument: `x` + | +46 | @classmethod +47 | def f(cls, x): + | ^ ARG003 +48 | print("Hello, world!") + | + + diff --git a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG004_ARG.py.snap b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG004_ARG.py.snap new file mode 100644 index 0000000000..b1b046fe91 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG004_ARG.py.snap @@ -0,0 +1,28 @@ +--- +source: crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs +--- +ARG.py:51:11: ARG004 Unused static method argument: `cls` + | +50 | @staticmethod +51 | def f(cls, x): + | ^^^ ARG004 +52 | print("Hello, world!") + | + +ARG.py:51:16: ARG004 Unused static method argument: `x` + | +50 | @staticmethod +51 | def f(cls, x): + | ^ ARG004 +52 | print("Hello, world!") + | + +ARG.py:55:11: ARG004 Unused static method argument: `x` + | +54 | @staticmethod +55 | def f(x): + | ^ ARG004 +56 | print("Hello, world!") + | + + 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 new file mode 100644 index 0000000000..3a8fb2cf56 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG005_ARG.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs +--- +ARG.py:28:8: ARG005 Unused lambda argument: `x` + | +26 | # Unused arguments on lambdas. +27 | ### +28 | lambda x: print("Hello, world!") + | ^ ARG005 +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 new file mode 100644 index 0000000000..e8d246aa94 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__enforce_variadic_names.snap @@ -0,0 +1,98 @@ +--- +source: crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs +--- +ignore_variadic_names.py:1:7: ARG001 Unused function argument: `a` + | +1 | def f(a, b): + | ^ ARG001 +2 | print("Hello, world!") + | + +ignore_variadic_names.py:1:10: ARG001 Unused function argument: `b` + | +1 | def f(a, b): + | ^ ARG001 +2 | print("Hello, world!") + | + +ignore_variadic_names.py:5:7: ARG001 Unused function argument: `a` + | +5 | def f(a, b, *args, **kwargs): + | ^ ARG001 +6 | print("Hello, world!") + | + +ignore_variadic_names.py:5:10: ARG001 Unused function argument: `b` + | +5 | def f(a, b, *args, **kwargs): + | ^ ARG001 +6 | print("Hello, world!") + | + +ignore_variadic_names.py:5:14: ARG001 Unused function argument: `args` + | +5 | def f(a, b, *args, **kwargs): + | ^^^^ ARG001 +6 | print("Hello, world!") + | + +ignore_variadic_names.py:5:22: ARG001 Unused function argument: `kwargs` + | +5 | def f(a, b, *args, **kwargs): + | ^^^^^^ ARG001 +6 | print("Hello, world!") + | + +ignore_variadic_names.py:10:17: ARG002 Unused method argument: `a` + | + 9 | class C: +10 | def f(self, a, b): + | ^ ARG002 +11 | print("Hello, world!") + | + +ignore_variadic_names.py:10:20: ARG002 Unused method argument: `b` + | + 9 | class C: +10 | def f(self, a, b): + | ^ ARG002 +11 | print("Hello, world!") + | + +ignore_variadic_names.py:13:17: ARG002 Unused method argument: `a` + | +11 | print("Hello, world!") +12 | +13 | def f(self, a, b, *args, **kwargs): + | ^ ARG002 +14 | print("Hello, world!") + | + +ignore_variadic_names.py:13:20: ARG002 Unused method argument: `b` + | +11 | print("Hello, world!") +12 | +13 | def f(self, a, b, *args, **kwargs): + | ^ ARG002 +14 | print("Hello, world!") + | + +ignore_variadic_names.py:13:24: ARG002 Unused method argument: `args` + | +11 | print("Hello, world!") +12 | +13 | def f(self, a, b, *args, **kwargs): + | ^^^^ ARG002 +14 | print("Hello, world!") + | + +ignore_variadic_names.py:13:32: ARG002 Unused method argument: `kwargs` + | +11 | print("Hello, world!") +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 new file mode 100644 index 0000000000..d22cfbe1f5 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ignore_variadic_names.snap @@ -0,0 +1,66 @@ +--- +source: crates/ruff_linter/src/rules/flake8_unused_arguments/mod.rs +--- +ignore_variadic_names.py:1:7: ARG001 Unused function argument: `a` + | +1 | def f(a, b): + | ^ ARG001 +2 | print("Hello, world!") + | + +ignore_variadic_names.py:1:10: ARG001 Unused function argument: `b` + | +1 | def f(a, b): + | ^ ARG001 +2 | print("Hello, world!") + | + +ignore_variadic_names.py:5:7: ARG001 Unused function argument: `a` + | +5 | def f(a, b, *args, **kwargs): + | ^ ARG001 +6 | print("Hello, world!") + | + +ignore_variadic_names.py:5:10: ARG001 Unused function argument: `b` + | +5 | def f(a, b, *args, **kwargs): + | ^ ARG001 +6 | print("Hello, world!") + | + +ignore_variadic_names.py:10:17: ARG002 Unused method argument: `a` + | + 9 | class C: +10 | def f(self, a, b): + | ^ ARG002 +11 | print("Hello, world!") + | + +ignore_variadic_names.py:10:20: ARG002 Unused method argument: `b` + | + 9 | class C: +10 | def f(self, a, b): + | ^ ARG002 +11 | print("Hello, world!") + | + +ignore_variadic_names.py:13:17: ARG002 Unused method argument: `a` + | +11 | print("Hello, world!") +12 | +13 | def f(self, a, b, *args, **kwargs): + | ^ ARG002 +14 | print("Hello, world!") + | + +ignore_variadic_names.py:13:20: ARG002 Unused method argument: `b` + | +11 | print("Hello, world!") +12 | +13 | def f(self, a, b, *args, **kwargs): + | ^ ARG002 +14 | print("Hello, world!") + | + + diff --git a/crates/ruff/src/rules/flake8_use_pathlib/mod.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_use_pathlib/mod.rs rename to crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs diff --git a/crates/ruff/src/rules/flake8_use_pathlib/rules/glob_rule.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/glob_rule.rs similarity index 100% rename from crates/ruff/src/rules/flake8_use_pathlib/rules/glob_rule.rs rename to crates/ruff_linter/src/rules/flake8_use_pathlib/rules/glob_rule.rs diff --git a/crates/ruff/src/rules/flake8_use_pathlib/rules/mod.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flake8_use_pathlib/rules/mod.rs rename to crates/ruff_linter/src/rules/flake8_use_pathlib/rules/mod.rs diff --git a/crates/ruff/src/rules/flake8_use_pathlib/rules/os_path_getatime.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getatime.rs similarity index 100% rename from crates/ruff/src/rules/flake8_use_pathlib/rules/os_path_getatime.rs rename to crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getatime.rs diff --git a/crates/ruff/src/rules/flake8_use_pathlib/rules/os_path_getctime.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getctime.rs similarity index 100% rename from crates/ruff/src/rules/flake8_use_pathlib/rules/os_path_getctime.rs rename to crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getctime.rs diff --git a/crates/ruff/src/rules/flake8_use_pathlib/rules/os_path_getmtime.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getmtime.rs similarity index 100% rename from crates/ruff/src/rules/flake8_use_pathlib/rules/os_path_getmtime.rs rename to crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getmtime.rs diff --git a/crates/ruff/src/rules/flake8_use_pathlib/rules/os_path_getsize.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getsize.rs similarity index 100% rename from crates/ruff/src/rules/flake8_use_pathlib/rules/os_path_getsize.rs rename to crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_path_getsize.rs diff --git a/crates/ruff/src/rules/flake8_use_pathlib/rules/os_sep_split.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_sep_split.rs similarity index 100% rename from crates/ruff/src/rules/flake8_use_pathlib/rules/os_sep_split.rs rename to crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_sep_split.rs diff --git a/crates/ruff/src/rules/flake8_use_pathlib/rules/path_constructor_current_directory.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/path_constructor_current_directory.rs similarity index 100% rename from crates/ruff/src/rules/flake8_use_pathlib/rules/path_constructor_current_directory.rs rename to crates/ruff_linter/src/rules/flake8_use_pathlib/rules/path_constructor_current_directory.rs diff --git a/crates/ruff/src/rules/flake8_use_pathlib/rules/replaceable_by_pathlib.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/rules/replaceable_by_pathlib.rs similarity index 100% rename from crates/ruff/src/rules/flake8_use_pathlib/rules/replaceable_by_pathlib.rs rename to crates/ruff_linter/src/rules/flake8_use_pathlib/rules/replaceable_by_pathlib.rs 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 new file mode 100644 index 0000000000..d69400baf7 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH124_py_path_1.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs +--- +py_path_1.py:3:5: PTH124 `py.path` is in maintenance mode, use `pathlib` instead + | +1 | import py +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 new file mode 100644 index 0000000000..a5f1a2cf92 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH124_py_path_2.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs +--- +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 | +3 | p = path("/foo") + | ^^^^ PTH124 + | + + 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 new file mode 100644 index 0000000000..fe9b16dcfc --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH201_PTH201.py.snap @@ -0,0 +1,86 @@ +--- +source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs +--- +PTH201.py:5:10: PTH201 [*] Do not pass the current directory explicitly to `Path` + | +4 | # match +5 | _ = Path(".") + | ^^^ PTH201 +6 | _ = pth(".") +7 | _ = PurePath(".") + | + = help: Remove the current directory argument + +ℹ Fix +2 2 | from pathlib import Path as pth +3 3 | +4 4 | # match +5 |-_ = Path(".") + 5 |+_ = Path() +6 6 | _ = pth(".") +7 7 | _ = PurePath(".") +8 8 | _ = Path("") + +PTH201.py:6:9: PTH201 [*] Do not pass the current directory explicitly to `Path` + | +4 | # match +5 | _ = Path(".") +6 | _ = pth(".") + | ^^^ PTH201 +7 | _ = PurePath(".") +8 | _ = Path("") + | + = help: Remove the current directory argument + +ℹ Fix +3 3 | +4 4 | # match +5 5 | _ = Path(".") +6 |-_ = pth(".") + 6 |+_ = pth() +7 7 | _ = PurePath(".") +8 8 | _ = Path("") +9 9 | + +PTH201.py:7:14: PTH201 [*] Do not pass the current directory explicitly to `Path` + | +5 | _ = Path(".") +6 | _ = pth(".") +7 | _ = PurePath(".") + | ^^^ PTH201 +8 | _ = Path("") + | + = help: Remove the current directory argument + +ℹ Fix +4 4 | # match +5 5 | _ = Path(".") +6 6 | _ = pth(".") +7 |-_ = PurePath(".") + 7 |+_ = PurePath() +8 8 | _ = Path("") +9 9 | +10 10 | # no match + +PTH201.py:8:10: PTH201 [*] Do not pass the current directory explicitly to `Path` + | + 6 | _ = pth(".") + 7 | _ = PurePath(".") + 8 | _ = Path("") + | ^^ PTH201 + 9 | +10 | # no match + | + = help: Remove the current directory argument + +ℹ Fix +5 5 | _ = Path(".") +6 6 | _ = pth(".") +7 7 | _ = PurePath(".") +8 |-_ = Path("") + 8 |+_ = Path() +9 9 | +10 10 | # no match +11 11 | _ = Path() + + 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 new file mode 100644 index 0000000000..033a2d511e --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH202_PTH202.py.snap @@ -0,0 +1,76 @@ +--- +source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs +--- +PTH202.py:6:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + | +6 | os.path.getsize("filename") + | ^^^^^^^^^^^^^^^ PTH202 +7 | os.path.getsize(b"filename") +8 | os.path.getsize(Path("filename")) + | + +PTH202.py:7:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + | +6 | os.path.getsize("filename") +7 | os.path.getsize(b"filename") + | ^^^^^^^^^^^^^^^ PTH202 +8 | os.path.getsize(Path("filename")) +9 | os.path.getsize(__file__) + | + +PTH202.py:8:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + | +6 | os.path.getsize("filename") +7 | os.path.getsize(b"filename") +8 | os.path.getsize(Path("filename")) + | ^^^^^^^^^^^^^^^ PTH202 +9 | os.path.getsize(__file__) + | + +PTH202.py:9:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + | + 7 | os.path.getsize(b"filename") + 8 | os.path.getsize(Path("filename")) + 9 | os.path.getsize(__file__) + | ^^^^^^^^^^^^^^^ PTH202 +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 | +11 | getsize("filename") + | ^^^^^^^ PTH202 +12 | getsize(b"filename") +13 | getsize(Path("filename")) + | + +PTH202.py:12:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + | +11 | getsize("filename") +12 | getsize(b"filename") + | ^^^^^^^ PTH202 +13 | getsize(Path("filename")) +14 | getsize(__file__) + | + +PTH202.py:13:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + | +11 | getsize("filename") +12 | getsize(b"filename") +13 | getsize(Path("filename")) + | ^^^^^^^ PTH202 +14 | getsize(__file__) + | + +PTH202.py:14:1: PTH202 `os.path.getsize` should be replaced by `Path.stat().st_size` + | +12 | getsize(b"filename") +13 | getsize(Path("filename")) +14 | getsize(__file__) + | ^^^^^^^ PTH202 + | + + 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 new file mode 100644 index 0000000000..db0681da91 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH203_PTH203.py.snap @@ -0,0 +1,54 @@ +--- +source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs +--- +PTH203.py:5:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + | +3 | from os.path import getatime +4 | +5 | os.path.getatime("filename") + | ^^^^^^^^^^^^^^^^ PTH203 +6 | os.path.getatime(b"filename") +7 | os.path.getatime(Path("filename")) + | + +PTH203.py:6:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + | +5 | os.path.getatime("filename") +6 | os.path.getatime(b"filename") + | ^^^^^^^^^^^^^^^^ PTH203 +7 | os.path.getatime(Path("filename")) + | + +PTH203.py:7:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + | +5 | os.path.getatime("filename") +6 | os.path.getatime(b"filename") +7 | os.path.getatime(Path("filename")) + | ^^^^^^^^^^^^^^^^ PTH203 + | + +PTH203.py:10:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + | +10 | getatime("filename") + | ^^^^^^^^ PTH203 +11 | getatime(b"filename") +12 | getatime(Path("filename")) + | + +PTH203.py:11:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + | +10 | getatime("filename") +11 | getatime(b"filename") + | ^^^^^^^^ PTH203 +12 | getatime(Path("filename")) + | + +PTH203.py:12:1: PTH203 `os.path.getatime` should be replaced by `Path.stat().st_atime` + | +10 | getatime("filename") +11 | getatime(b"filename") +12 | getatime(Path("filename")) + | ^^^^^^^^ PTH203 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH204_PTH204.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH204_PTH204.py.snap new file mode 100644 index 0000000000..1451bdb737 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH204_PTH204.py.snap @@ -0,0 +1,52 @@ +--- +source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs +--- +PTH204.py:6:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` + | +6 | os.path.getmtime("filename") + | ^^^^^^^^^^^^^^^^ PTH204 +7 | os.path.getmtime(b"filename") +8 | os.path.getmtime(Path("filename")) + | + +PTH204.py:7:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` + | +6 | os.path.getmtime("filename") +7 | os.path.getmtime(b"filename") + | ^^^^^^^^^^^^^^^^ PTH204 +8 | os.path.getmtime(Path("filename")) + | + +PTH204.py:8:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` + | +6 | os.path.getmtime("filename") +7 | os.path.getmtime(b"filename") +8 | os.path.getmtime(Path("filename")) + | ^^^^^^^^^^^^^^^^ PTH204 + | + +PTH204.py:11:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` + | +11 | getmtime("filename") + | ^^^^^^^^ PTH204 +12 | getmtime(b"filename") +13 | getmtime(Path("filename")) + | + +PTH204.py:12:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` + | +11 | getmtime("filename") +12 | getmtime(b"filename") + | ^^^^^^^^ PTH204 +13 | getmtime(Path("filename")) + | + +PTH204.py:13:1: PTH204 `os.path.getmtime` should be replaced by `Path.stat().st_mtime` + | +11 | getmtime("filename") +12 | getmtime(b"filename") +13 | getmtime(Path("filename")) + | ^^^^^^^^ PTH204 + | + + 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 new file mode 100644 index 0000000000..5afa0f483a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH205_PTH205.py.snap @@ -0,0 +1,56 @@ +--- +source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs +--- +PTH205.py:6:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` + | +6 | os.path.getctime("filename") + | ^^^^^^^^^^^^^^^^ PTH205 +7 | os.path.getctime(b"filename") +8 | os.path.getctime(Path("filename")) + | + +PTH205.py:7:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` + | +6 | os.path.getctime("filename") +7 | os.path.getctime(b"filename") + | ^^^^^^^^^^^^^^^^ PTH205 +8 | os.path.getctime(Path("filename")) + | + +PTH205.py:8:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` + | + 6 | os.path.getctime("filename") + 7 | os.path.getctime(b"filename") + 8 | os.path.getctime(Path("filename")) + | ^^^^^^^^^^^^^^^^ PTH205 + 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 | +10 | getctime("filename") + | ^^^^^^^^ PTH205 +11 | getctime(b"filename") +12 | getctime(Path("filename")) + | + +PTH205.py:11:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` + | +10 | getctime("filename") +11 | getctime(b"filename") + | ^^^^^^^^ PTH205 +12 | getctime(Path("filename")) + | + +PTH205.py:12:1: PTH205 `os.path.getctime` should be replaced by `Path.stat().st_ctime` + | +10 | getctime("filename") +11 | getctime(b"filename") +12 | getctime(Path("filename")) + | ^^^^^^^^ PTH205 + | + + 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 new file mode 100644 index 0000000000..86aeedbfbc --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH206_PTH206.py.snap @@ -0,0 +1,102 @@ +--- +source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs +--- +PTH206.py:8:12: PTH206 Replace `.split(os.sep)` with `Path.parts` + | + 7 | # PTH206 + 8 | "foo/bar/".split(os.sep) + | ^^^^^ PTH206 + 9 | "foo/bar/".split(sep=os.sep) +10 | "foo/bar/".split(os.sep)[-1] + | + +PTH206.py:9:12: PTH206 Replace `.split(os.sep)` with `Path.parts` + | + 7 | # PTH206 + 8 | "foo/bar/".split(os.sep) + 9 | "foo/bar/".split(sep=os.sep) + | ^^^^^ PTH206 +10 | "foo/bar/".split(os.sep)[-1] +11 | "foo/bar/".split(os.sep)[-2] + | + +PTH206.py:10:12: PTH206 Replace `.split(os.sep)` with `Path.parts` + | + 8 | "foo/bar/".split(os.sep) + 9 | "foo/bar/".split(sep=os.sep) +10 | "foo/bar/".split(os.sep)[-1] + | ^^^^^ PTH206 +11 | "foo/bar/".split(os.sep)[-2] +12 | "foo/bar/".split(os.sep)[-2:] + | + +PTH206.py:11:12: PTH206 Replace `.split(os.sep)` with `Path.parts` + | + 9 | "foo/bar/".split(sep=os.sep) +10 | "foo/bar/".split(os.sep)[-1] +11 | "foo/bar/".split(os.sep)[-2] + | ^^^^^ PTH206 +12 | "foo/bar/".split(os.sep)[-2:] +13 | "fizz/buzz".split(sep) + | + +PTH206.py:12:12: PTH206 Replace `.split(os.sep)` with `Path.parts` + | +10 | "foo/bar/".split(os.sep)[-1] +11 | "foo/bar/".split(os.sep)[-2] +12 | "foo/bar/".split(os.sep)[-2:] + | ^^^^^ PTH206 +13 | "fizz/buzz".split(sep) +14 | "fizz/buzz".split(sep)[-1] + | + +PTH206.py:13:13: PTH206 Replace `.split(os.sep)` with `Path.parts` + | +11 | "foo/bar/".split(os.sep)[-2] +12 | "foo/bar/".split(os.sep)[-2:] +13 | "fizz/buzz".split(sep) + | ^^^^^ PTH206 +14 | "fizz/buzz".split(sep)[-1] +15 | os.path.splitext("path/to/hello_world.py")[0].split(os.sep)[-1] + | + +PTH206.py:14:13: PTH206 Replace `.split(os.sep)` with `Path.parts` + | +12 | "foo/bar/".split(os.sep)[-2:] +13 | "fizz/buzz".split(sep) +14 | "fizz/buzz".split(sep)[-1] + | ^^^^^ PTH206 +15 | os.path.splitext("path/to/hello_world.py")[0].split(os.sep)[-1] +16 | file_name.split(os.sep) + | + +PTH206.py:15:47: PTH206 Replace `.split(os.sep)` with `Path.parts` + | +13 | "fizz/buzz".split(sep) +14 | "fizz/buzz".split(sep)[-1] +15 | os.path.splitext("path/to/hello_world.py")[0].split(os.sep)[-1] + | ^^^^^ PTH206 +16 | file_name.split(os.sep) +17 | (os.path.abspath(file_name)).split(os.sep) + | + +PTH206.py:16:11: PTH206 Replace `.split(os.sep)` with `Path.parts` + | +14 | "fizz/buzz".split(sep)[-1] +15 | os.path.splitext("path/to/hello_world.py")[0].split(os.sep)[-1] +16 | file_name.split(os.sep) + | ^^^^^ PTH206 +17 | (os.path.abspath(file_name)).split(os.sep) + | + +PTH206.py:17:30: PTH206 Replace `.split(os.sep)` with `Path.parts` + | +15 | os.path.splitext("path/to/hello_world.py")[0].split(os.sep)[-1] +16 | file_name.split(os.sep) +17 | (os.path.abspath(file_name)).split(os.sep) + | ^^^^^ PTH206 +18 | +19 | # OK + | + + diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH207_PTH207.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH207_PTH207.py.snap new file mode 100644 index 0000000000..fde2f146d9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__PTH207_PTH207.py.snap @@ -0,0 +1,30 @@ +--- +source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs +--- +PTH207.py:9:1: PTH207 Replace `glob` with `Path.glob` or `Path.rglob` + | + 8 | # PTH207 + 9 | glob.glob(os.path.join(extensions_dir, "ops", "autograd", "*.cpp")) + | ^^^^^^^^^ PTH207 +10 | list(glob.iglob(os.path.join(extensions_dir, "ops", "autograd", "*.cpp"))) +11 | search("*.png") + | + +PTH207.py:10:6: PTH207 Replace `iglob` with `Path.glob` or `Path.rglob` + | + 8 | # PTH207 + 9 | glob.glob(os.path.join(extensions_dir, "ops", "autograd", "*.cpp")) +10 | list(glob.iglob(os.path.join(extensions_dir, "ops", "autograd", "*.cpp"))) + | ^^^^^^^^^^ PTH207 +11 | search("*.png") + | + +PTH207.py:11:1: PTH207 Replace `glob` with `Path.glob` or `Path.rglob` + | + 9 | glob.glob(os.path.join(extensions_dir, "ops", "autograd", "*.cpp")) +10 | list(glob.iglob(os.path.join(extensions_dir, "ops", "autograd", "*.cpp"))) +11 | search("*.png") + | ^^^^^^ PTH207 + | + + 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 new file mode 100644 index 0000000000..1f087acbf2 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__full_name.py.snap @@ -0,0 +1,280 @@ +--- +source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs +--- +full_name.py:7:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` + | +5 | q = "bar" +6 | +7 | a = os.path.abspath(p) + | ^^^^^^^^^^^^^^^ PTH100 +8 | aa = os.chmod(p) +9 | aaa = os.mkdir(p) + | + +full_name.py:8:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()` + | + 7 | a = os.path.abspath(p) + 8 | aa = os.chmod(p) + | ^^^^^^^^ PTH101 + 9 | aaa = os.mkdir(p) +10 | os.makedirs(p) + | + +full_name.py:9:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` + | + 7 | a = os.path.abspath(p) + 8 | aa = os.chmod(p) + 9 | aaa = os.mkdir(p) + | ^^^^^^^^ PTH102 +10 | os.makedirs(p) +11 | os.rename(p) + | + +full_name.py:10:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` + | + 8 | aa = os.chmod(p) + 9 | aaa = os.mkdir(p) +10 | os.makedirs(p) + | ^^^^^^^^^^^ PTH103 +11 | os.rename(p) +12 | os.replace(p) + | + +full_name.py:11:1: PTH104 `os.rename()` should be replaced by `Path.rename()` + | + 9 | aaa = os.mkdir(p) +10 | os.makedirs(p) +11 | os.rename(p) + | ^^^^^^^^^ PTH104 +12 | os.replace(p) +13 | os.rmdir(p) + | + +full_name.py:12:1: PTH105 `os.replace()` should be replaced by `Path.replace()` + | +10 | os.makedirs(p) +11 | os.rename(p) +12 | os.replace(p) + | ^^^^^^^^^^ PTH105 +13 | os.rmdir(p) +14 | os.remove(p) + | + +full_name.py:13:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()` + | +11 | os.rename(p) +12 | os.replace(p) +13 | os.rmdir(p) + | ^^^^^^^^ PTH106 +14 | os.remove(p) +15 | os.unlink(p) + | + +full_name.py:14:1: PTH107 `os.remove()` should be replaced by `Path.unlink()` + | +12 | os.replace(p) +13 | os.rmdir(p) +14 | os.remove(p) + | ^^^^^^^^^ PTH107 +15 | os.unlink(p) +16 | os.getcwd(p) + | + +full_name.py:15:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()` + | +13 | os.rmdir(p) +14 | os.remove(p) +15 | os.unlink(p) + | ^^^^^^^^^ PTH108 +16 | os.getcwd(p) +17 | b = os.path.exists(p) + | + +full_name.py:16:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` + | +14 | os.remove(p) +15 | os.unlink(p) +16 | os.getcwd(p) + | ^^^^^^^^^ PTH109 +17 | b = os.path.exists(p) +18 | bb = os.path.expanduser(p) + | + +full_name.py:17:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()` + | +15 | os.unlink(p) +16 | os.getcwd(p) +17 | b = os.path.exists(p) + | ^^^^^^^^^^^^^^ PTH110 +18 | bb = os.path.expanduser(p) +19 | bbb = os.path.isdir(p) + | + +full_name.py:18:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()` + | +16 | os.getcwd(p) +17 | b = os.path.exists(p) +18 | bb = os.path.expanduser(p) + | ^^^^^^^^^^^^^^^^^^ PTH111 +19 | bbb = os.path.isdir(p) +20 | bbbb = os.path.isfile(p) + | + +full_name.py:19:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()` + | +17 | b = os.path.exists(p) +18 | bb = os.path.expanduser(p) +19 | bbb = os.path.isdir(p) + | ^^^^^^^^^^^^^ PTH112 +20 | bbbb = os.path.isfile(p) +21 | bbbbb = os.path.islink(p) + | + +full_name.py:20:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()` + | +18 | bb = os.path.expanduser(p) +19 | bbb = os.path.isdir(p) +20 | bbbb = os.path.isfile(p) + | ^^^^^^^^^^^^^^ PTH113 +21 | bbbbb = os.path.islink(p) +22 | os.readlink(p) + | + +full_name.py:21:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()` + | +19 | bbb = os.path.isdir(p) +20 | bbbb = os.path.isfile(p) +21 | bbbbb = os.path.islink(p) + | ^^^^^^^^^^^^^^ PTH114 +22 | os.readlink(p) +23 | os.stat(p) + | + +full_name.py:22:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()` + | +20 | bbbb = os.path.isfile(p) +21 | bbbbb = os.path.islink(p) +22 | os.readlink(p) + | ^^^^^^^^^^^ PTH115 +23 | os.stat(p) +24 | os.path.isabs(p) + | + +full_name.py:23:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` + | +21 | bbbbb = os.path.islink(p) +22 | os.readlink(p) +23 | os.stat(p) + | ^^^^^^^ PTH116 +24 | os.path.isabs(p) +25 | os.path.join(p, q) + | + +full_name.py:24:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()` + | +22 | os.readlink(p) +23 | os.stat(p) +24 | os.path.isabs(p) + | ^^^^^^^^^^^^^ PTH117 +25 | os.path.join(p, q) +26 | os.sep.join([p, q]) + | + +full_name.py:25:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator + | +23 | os.stat(p) +24 | os.path.isabs(p) +25 | os.path.join(p, q) + | ^^^^^^^^^^^^ PTH118 +26 | os.sep.join([p, q]) +27 | os.sep.join((p, q)) + | + +full_name.py:26:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + | +24 | os.path.isabs(p) +25 | os.path.join(p, q) +26 | os.sep.join([p, q]) + | ^^^^^^^^^^^ PTH118 +27 | os.sep.join((p, q)) +28 | os.path.basename(p) + | + +full_name.py:27:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + | +25 | os.path.join(p, q) +26 | os.sep.join([p, q]) +27 | os.sep.join((p, q)) + | ^^^^^^^^^^^ PTH118 +28 | os.path.basename(p) +29 | os.path.dirname(p) + | + +full_name.py:28:1: PTH119 `os.path.basename()` should be replaced by `Path.name` + | +26 | os.sep.join([p, q]) +27 | os.sep.join((p, q)) +28 | os.path.basename(p) + | ^^^^^^^^^^^^^^^^ PTH119 +29 | os.path.dirname(p) +30 | os.path.samefile(p) + | + +full_name.py:29:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent` + | +27 | os.sep.join((p, q)) +28 | os.path.basename(p) +29 | os.path.dirname(p) + | ^^^^^^^^^^^^^^^ PTH120 +30 | os.path.samefile(p) +31 | os.path.splitext(p) + | + +full_name.py:30:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` + | +28 | os.path.basename(p) +29 | os.path.dirname(p) +30 | os.path.samefile(p) + | ^^^^^^^^^^^^^^^^ PTH121 +31 | os.path.splitext(p) +32 | with open(p) as fp: + | + +full_name.py:31:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` + | +29 | os.path.dirname(p) +30 | os.path.samefile(p) +31 | os.path.splitext(p) + | ^^^^^^^^^^^^^^^^ PTH122 +32 | with open(p) as fp: +33 | fp.read() + | + +full_name.py:32:6: PTH123 `open()` should be replaced by `Path.open()` + | +30 | os.path.samefile(p) +31 | os.path.splitext(p) +32 | with open(p) as fp: + | ^^^^ PTH123 +33 | fp.read() +34 | open(p).close() + | + +full_name.py:34:1: PTH123 `open()` should be replaced by `Path.open()` + | +32 | with open(p) as fp: +33 | fp.read() +34 | open(p).close() + | ^^^^ PTH123 +35 | os.getcwdb(p) + | + +full_name.py:35:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` + | +33 | fp.read() +34 | open(p).close() +35 | os.getcwdb(p) + | ^^^^^^^^^^ PTH109 + | + + 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 new file mode 100644 index 0000000000..30ea651dac --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_as.py.snap @@ -0,0 +1,250 @@ +--- +source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs +--- +import_as.py:7:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` + | +5 | q = "bar" +6 | +7 | a = foo_p.abspath(p) + | ^^^^^^^^^^^^^ PTH100 +8 | aa = foo.chmod(p) +9 | aaa = foo.mkdir(p) + | + +import_as.py:8:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()` + | + 7 | a = foo_p.abspath(p) + 8 | aa = foo.chmod(p) + | ^^^^^^^^^ PTH101 + 9 | aaa = foo.mkdir(p) +10 | foo.makedirs(p) + | + +import_as.py:9:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` + | + 7 | a = foo_p.abspath(p) + 8 | aa = foo.chmod(p) + 9 | aaa = foo.mkdir(p) + | ^^^^^^^^^ PTH102 +10 | foo.makedirs(p) +11 | foo.rename(p) + | + +import_as.py:10:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` + | + 8 | aa = foo.chmod(p) + 9 | aaa = foo.mkdir(p) +10 | foo.makedirs(p) + | ^^^^^^^^^^^^ PTH103 +11 | foo.rename(p) +12 | foo.replace(p) + | + +import_as.py:11:1: PTH104 `os.rename()` should be replaced by `Path.rename()` + | + 9 | aaa = foo.mkdir(p) +10 | foo.makedirs(p) +11 | foo.rename(p) + | ^^^^^^^^^^ PTH104 +12 | foo.replace(p) +13 | foo.rmdir(p) + | + +import_as.py:12:1: PTH105 `os.replace()` should be replaced by `Path.replace()` + | +10 | foo.makedirs(p) +11 | foo.rename(p) +12 | foo.replace(p) + | ^^^^^^^^^^^ PTH105 +13 | foo.rmdir(p) +14 | foo.remove(p) + | + +import_as.py:13:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()` + | +11 | foo.rename(p) +12 | foo.replace(p) +13 | foo.rmdir(p) + | ^^^^^^^^^ PTH106 +14 | foo.remove(p) +15 | foo.unlink(p) + | + +import_as.py:14:1: PTH107 `os.remove()` should be replaced by `Path.unlink()` + | +12 | foo.replace(p) +13 | foo.rmdir(p) +14 | foo.remove(p) + | ^^^^^^^^^^ PTH107 +15 | foo.unlink(p) +16 | foo.getcwd(p) + | + +import_as.py:15:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()` + | +13 | foo.rmdir(p) +14 | foo.remove(p) +15 | foo.unlink(p) + | ^^^^^^^^^^ PTH108 +16 | foo.getcwd(p) +17 | b = foo_p.exists(p) + | + +import_as.py:16:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` + | +14 | foo.remove(p) +15 | foo.unlink(p) +16 | foo.getcwd(p) + | ^^^^^^^^^^ PTH109 +17 | b = foo_p.exists(p) +18 | bb = foo_p.expanduser(p) + | + +import_as.py:17:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()` + | +15 | foo.unlink(p) +16 | foo.getcwd(p) +17 | b = foo_p.exists(p) + | ^^^^^^^^^^^^ PTH110 +18 | bb = foo_p.expanduser(p) +19 | bbb = foo_p.isdir(p) + | + +import_as.py:18:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()` + | +16 | foo.getcwd(p) +17 | b = foo_p.exists(p) +18 | bb = foo_p.expanduser(p) + | ^^^^^^^^^^^^^^^^ PTH111 +19 | bbb = foo_p.isdir(p) +20 | bbbb = foo_p.isfile(p) + | + +import_as.py:19:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()` + | +17 | b = foo_p.exists(p) +18 | bb = foo_p.expanduser(p) +19 | bbb = foo_p.isdir(p) + | ^^^^^^^^^^^ PTH112 +20 | bbbb = foo_p.isfile(p) +21 | bbbbb = foo_p.islink(p) + | + +import_as.py:20:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()` + | +18 | bb = foo_p.expanduser(p) +19 | bbb = foo_p.isdir(p) +20 | bbbb = foo_p.isfile(p) + | ^^^^^^^^^^^^ PTH113 +21 | bbbbb = foo_p.islink(p) +22 | foo.readlink(p) + | + +import_as.py:21:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()` + | +19 | bbb = foo_p.isdir(p) +20 | bbbb = foo_p.isfile(p) +21 | bbbbb = foo_p.islink(p) + | ^^^^^^^^^^^^ PTH114 +22 | foo.readlink(p) +23 | foo.stat(p) + | + +import_as.py:22:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()` + | +20 | bbbb = foo_p.isfile(p) +21 | bbbbb = foo_p.islink(p) +22 | foo.readlink(p) + | ^^^^^^^^^^^^ PTH115 +23 | foo.stat(p) +24 | foo_p.isabs(p) + | + +import_as.py:23:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` + | +21 | bbbbb = foo_p.islink(p) +22 | foo.readlink(p) +23 | foo.stat(p) + | ^^^^^^^^ PTH116 +24 | foo_p.isabs(p) +25 | foo_p.join(p, q) + | + +import_as.py:24:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()` + | +22 | foo.readlink(p) +23 | foo.stat(p) +24 | foo_p.isabs(p) + | ^^^^^^^^^^^ PTH117 +25 | foo_p.join(p, q) +26 | foo.sep.join([p, q]) + | + +import_as.py:25:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator + | +23 | foo.stat(p) +24 | foo_p.isabs(p) +25 | foo_p.join(p, q) + | ^^^^^^^^^^ PTH118 +26 | foo.sep.join([p, q]) +27 | foo.sep.join((p, q)) + | + +import_as.py:26:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + | +24 | foo_p.isabs(p) +25 | foo_p.join(p, q) +26 | foo.sep.join([p, q]) + | ^^^^^^^^^^^^ PTH118 +27 | foo.sep.join((p, q)) +28 | foo_p.basename(p) + | + +import_as.py:27:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + | +25 | foo_p.join(p, q) +26 | foo.sep.join([p, q]) +27 | foo.sep.join((p, q)) + | ^^^^^^^^^^^^ PTH118 +28 | foo_p.basename(p) +29 | foo_p.dirname(p) + | + +import_as.py:28:1: PTH119 `os.path.basename()` should be replaced by `Path.name` + | +26 | foo.sep.join([p, q]) +27 | foo.sep.join((p, q)) +28 | foo_p.basename(p) + | ^^^^^^^^^^^^^^ PTH119 +29 | foo_p.dirname(p) +30 | foo_p.samefile(p) + | + +import_as.py:29:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent` + | +27 | foo.sep.join((p, q)) +28 | foo_p.basename(p) +29 | foo_p.dirname(p) + | ^^^^^^^^^^^^^ PTH120 +30 | foo_p.samefile(p) +31 | foo_p.splitext(p) + | + +import_as.py:30:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` + | +28 | foo_p.basename(p) +29 | foo_p.dirname(p) +30 | foo_p.samefile(p) + | ^^^^^^^^^^^^^^ PTH121 +31 | foo_p.splitext(p) + | + +import_as.py:31:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` + | +29 | foo_p.dirname(p) +30 | foo_p.samefile(p) +31 | foo_p.splitext(p) + | ^^^^^^^^^^^^^^ PTH122 + | + + 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 new file mode 100644 index 0000000000..7dcdd1a5c2 --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_from.py.snap @@ -0,0 +1,271 @@ +--- +source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs +--- +import_from.py:9:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` + | + 7 | q = "bar" + 8 | + 9 | a = abspath(p) + | ^^^^^^^ PTH100 +10 | aa = chmod(p) +11 | aaa = mkdir(p) + | + +import_from.py:10:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()` + | + 9 | a = abspath(p) +10 | aa = chmod(p) + | ^^^^^ PTH101 +11 | aaa = mkdir(p) +12 | makedirs(p) + | + +import_from.py:11:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` + | + 9 | a = abspath(p) +10 | aa = chmod(p) +11 | aaa = mkdir(p) + | ^^^^^ PTH102 +12 | makedirs(p) +13 | rename(p) + | + +import_from.py:12:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` + | +10 | aa = chmod(p) +11 | aaa = mkdir(p) +12 | makedirs(p) + | ^^^^^^^^ PTH103 +13 | rename(p) +14 | replace(p) + | + +import_from.py:13:1: PTH104 `os.rename()` should be replaced by `Path.rename()` + | +11 | aaa = mkdir(p) +12 | makedirs(p) +13 | rename(p) + | ^^^^^^ PTH104 +14 | replace(p) +15 | rmdir(p) + | + +import_from.py:14:1: PTH105 `os.replace()` should be replaced by `Path.replace()` + | +12 | makedirs(p) +13 | rename(p) +14 | replace(p) + | ^^^^^^^ PTH105 +15 | rmdir(p) +16 | remove(p) + | + +import_from.py:15:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()` + | +13 | rename(p) +14 | replace(p) +15 | rmdir(p) + | ^^^^^ PTH106 +16 | remove(p) +17 | unlink(p) + | + +import_from.py:16:1: PTH107 `os.remove()` should be replaced by `Path.unlink()` + | +14 | replace(p) +15 | rmdir(p) +16 | remove(p) + | ^^^^^^ PTH107 +17 | unlink(p) +18 | getcwd(p) + | + +import_from.py:17:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()` + | +15 | rmdir(p) +16 | remove(p) +17 | unlink(p) + | ^^^^^^ PTH108 +18 | getcwd(p) +19 | b = exists(p) + | + +import_from.py:18:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` + | +16 | remove(p) +17 | unlink(p) +18 | getcwd(p) + | ^^^^^^ PTH109 +19 | b = exists(p) +20 | bb = expanduser(p) + | + +import_from.py:19:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()` + | +17 | unlink(p) +18 | getcwd(p) +19 | b = exists(p) + | ^^^^^^ PTH110 +20 | bb = expanduser(p) +21 | bbb = isdir(p) + | + +import_from.py:20:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()` + | +18 | getcwd(p) +19 | b = exists(p) +20 | bb = expanduser(p) + | ^^^^^^^^^^ PTH111 +21 | bbb = isdir(p) +22 | bbbb = isfile(p) + | + +import_from.py:21:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()` + | +19 | b = exists(p) +20 | bb = expanduser(p) +21 | bbb = isdir(p) + | ^^^^^ PTH112 +22 | bbbb = isfile(p) +23 | bbbbb = islink(p) + | + +import_from.py:22:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()` + | +20 | bb = expanduser(p) +21 | bbb = isdir(p) +22 | bbbb = isfile(p) + | ^^^^^^ PTH113 +23 | bbbbb = islink(p) +24 | readlink(p) + | + +import_from.py:23:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()` + | +21 | bbb = isdir(p) +22 | bbbb = isfile(p) +23 | bbbbb = islink(p) + | ^^^^^^ PTH114 +24 | readlink(p) +25 | stat(p) + | + +import_from.py:24:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()` + | +22 | bbbb = isfile(p) +23 | bbbbb = islink(p) +24 | readlink(p) + | ^^^^^^^^ PTH115 +25 | stat(p) +26 | isabs(p) + | + +import_from.py:25:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` + | +23 | bbbbb = islink(p) +24 | readlink(p) +25 | stat(p) + | ^^^^ PTH116 +26 | isabs(p) +27 | join(p, q) + | + +import_from.py:26:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()` + | +24 | readlink(p) +25 | stat(p) +26 | isabs(p) + | ^^^^^ PTH117 +27 | join(p, q) +28 | sep.join((p, q)) + | + +import_from.py:27:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator + | +25 | stat(p) +26 | isabs(p) +27 | join(p, q) + | ^^^^ PTH118 +28 | sep.join((p, q)) +29 | sep.join([p, q]) + | + +import_from.py:28:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + | +26 | isabs(p) +27 | join(p, q) +28 | sep.join((p, q)) + | ^^^^^^^^ PTH118 +29 | sep.join([p, q]) +30 | basename(p) + | + +import_from.py:29:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + | +27 | join(p, q) +28 | sep.join((p, q)) +29 | sep.join([p, q]) + | ^^^^^^^^ PTH118 +30 | basename(p) +31 | dirname(p) + | + +import_from.py:30:1: PTH119 `os.path.basename()` should be replaced by `Path.name` + | +28 | sep.join((p, q)) +29 | sep.join([p, q]) +30 | basename(p) + | ^^^^^^^^ PTH119 +31 | dirname(p) +32 | samefile(p) + | + +import_from.py:31:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent` + | +29 | sep.join([p, q]) +30 | basename(p) +31 | dirname(p) + | ^^^^^^^ PTH120 +32 | samefile(p) +33 | splitext(p) + | + +import_from.py:32:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` + | +30 | basename(p) +31 | dirname(p) +32 | samefile(p) + | ^^^^^^^^ PTH121 +33 | splitext(p) +34 | with open(p) as fp: + | + +import_from.py:33:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` + | +31 | dirname(p) +32 | samefile(p) +33 | splitext(p) + | ^^^^^^^^ PTH122 +34 | with open(p) as fp: +35 | fp.read() + | + +import_from.py:34:6: PTH123 `open()` should be replaced by `Path.open()` + | +32 | samefile(p) +33 | splitext(p) +34 | with open(p) as fp: + | ^^^^ PTH123 +35 | fp.read() +36 | open(p).close() + | + +import_from.py:36:1: PTH123 `open()` should be replaced by `Path.open()` + | +34 | with open(p) as fp: +35 | fp.read() +36 | open(p).close() + | ^^^^ PTH123 + | + + 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 new file mode 100644 index 0000000000..759f682c6a --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__import_from_as.py.snap @@ -0,0 +1,250 @@ +--- +source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs +--- +import_from_as.py:14:5: PTH100 `os.path.abspath()` should be replaced by `Path.resolve()` + | +12 | q = "bar" +13 | +14 | a = xabspath(p) + | ^^^^^^^^ PTH100 +15 | aa = xchmod(p) +16 | aaa = xmkdir(p) + | + +import_from_as.py:15:6: PTH101 `os.chmod()` should be replaced by `Path.chmod()` + | +14 | a = xabspath(p) +15 | aa = xchmod(p) + | ^^^^^^ PTH101 +16 | aaa = xmkdir(p) +17 | xmakedirs(p) + | + +import_from_as.py:16:7: PTH102 `os.mkdir()` should be replaced by `Path.mkdir()` + | +14 | a = xabspath(p) +15 | aa = xchmod(p) +16 | aaa = xmkdir(p) + | ^^^^^^ PTH102 +17 | xmakedirs(p) +18 | xrename(p) + | + +import_from_as.py:17:1: PTH103 `os.makedirs()` should be replaced by `Path.mkdir(parents=True)` + | +15 | aa = xchmod(p) +16 | aaa = xmkdir(p) +17 | xmakedirs(p) + | ^^^^^^^^^ PTH103 +18 | xrename(p) +19 | xreplace(p) + | + +import_from_as.py:18:1: PTH104 `os.rename()` should be replaced by `Path.rename()` + | +16 | aaa = xmkdir(p) +17 | xmakedirs(p) +18 | xrename(p) + | ^^^^^^^ PTH104 +19 | xreplace(p) +20 | xrmdir(p) + | + +import_from_as.py:19:1: PTH105 `os.replace()` should be replaced by `Path.replace()` + | +17 | xmakedirs(p) +18 | xrename(p) +19 | xreplace(p) + | ^^^^^^^^ PTH105 +20 | xrmdir(p) +21 | xremove(p) + | + +import_from_as.py:20:1: PTH106 `os.rmdir()` should be replaced by `Path.rmdir()` + | +18 | xrename(p) +19 | xreplace(p) +20 | xrmdir(p) + | ^^^^^^ PTH106 +21 | xremove(p) +22 | xunlink(p) + | + +import_from_as.py:21:1: PTH107 `os.remove()` should be replaced by `Path.unlink()` + | +19 | xreplace(p) +20 | xrmdir(p) +21 | xremove(p) + | ^^^^^^^ PTH107 +22 | xunlink(p) +23 | xgetcwd(p) + | + +import_from_as.py:22:1: PTH108 `os.unlink()` should be replaced by `Path.unlink()` + | +20 | xrmdir(p) +21 | xremove(p) +22 | xunlink(p) + | ^^^^^^^ PTH108 +23 | xgetcwd(p) +24 | b = xexists(p) + | + +import_from_as.py:23:1: PTH109 `os.getcwd()` should be replaced by `Path.cwd()` + | +21 | xremove(p) +22 | xunlink(p) +23 | xgetcwd(p) + | ^^^^^^^ PTH109 +24 | b = xexists(p) +25 | bb = xexpanduser(p) + | + +import_from_as.py:24:5: PTH110 `os.path.exists()` should be replaced by `Path.exists()` + | +22 | xunlink(p) +23 | xgetcwd(p) +24 | b = xexists(p) + | ^^^^^^^ PTH110 +25 | bb = xexpanduser(p) +26 | bbb = xisdir(p) + | + +import_from_as.py:25:6: PTH111 `os.path.expanduser()` should be replaced by `Path.expanduser()` + | +23 | xgetcwd(p) +24 | b = xexists(p) +25 | bb = xexpanduser(p) + | ^^^^^^^^^^^ PTH111 +26 | bbb = xisdir(p) +27 | bbbb = xisfile(p) + | + +import_from_as.py:26:7: PTH112 `os.path.isdir()` should be replaced by `Path.is_dir()` + | +24 | b = xexists(p) +25 | bb = xexpanduser(p) +26 | bbb = xisdir(p) + | ^^^^^^ PTH112 +27 | bbbb = xisfile(p) +28 | bbbbb = xislink(p) + | + +import_from_as.py:27:8: PTH113 `os.path.isfile()` should be replaced by `Path.is_file()` + | +25 | bb = xexpanduser(p) +26 | bbb = xisdir(p) +27 | bbbb = xisfile(p) + | ^^^^^^^ PTH113 +28 | bbbbb = xislink(p) +29 | xreadlink(p) + | + +import_from_as.py:28:9: PTH114 `os.path.islink()` should be replaced by `Path.is_symlink()` + | +26 | bbb = xisdir(p) +27 | bbbb = xisfile(p) +28 | bbbbb = xislink(p) + | ^^^^^^^ PTH114 +29 | xreadlink(p) +30 | xstat(p) + | + +import_from_as.py:29:1: PTH115 `os.readlink()` should be replaced by `Path.readlink()` + | +27 | bbbb = xisfile(p) +28 | bbbbb = xislink(p) +29 | xreadlink(p) + | ^^^^^^^^^ PTH115 +30 | xstat(p) +31 | xisabs(p) + | + +import_from_as.py:30:1: PTH116 `os.stat()` should be replaced by `Path.stat()`, `Path.owner()`, or `Path.group()` + | +28 | bbbbb = xislink(p) +29 | xreadlink(p) +30 | xstat(p) + | ^^^^^ PTH116 +31 | xisabs(p) +32 | xjoin(p, q) + | + +import_from_as.py:31:1: PTH117 `os.path.isabs()` should be replaced by `Path.is_absolute()` + | +29 | xreadlink(p) +30 | xstat(p) +31 | xisabs(p) + | ^^^^^^ PTH117 +32 | xjoin(p, q) +33 | s.join((p, q)) + | + +import_from_as.py:32:1: PTH118 `os.path.join()` should be replaced by `Path` with `/` operator + | +30 | xstat(p) +31 | xisabs(p) +32 | xjoin(p, q) + | ^^^^^ PTH118 +33 | s.join((p, q)) +34 | s.join([p, q]) + | + +import_from_as.py:33:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + | +31 | xisabs(p) +32 | xjoin(p, q) +33 | s.join((p, q)) + | ^^^^^^ PTH118 +34 | s.join([p, q]) +35 | xbasename(p) + | + +import_from_as.py:34:1: PTH118 `os.sep.join()` should be replaced by `Path` with `/` operator + | +32 | xjoin(p, q) +33 | s.join((p, q)) +34 | s.join([p, q]) + | ^^^^^^ PTH118 +35 | xbasename(p) +36 | xdirname(p) + | + +import_from_as.py:35:1: PTH119 `os.path.basename()` should be replaced by `Path.name` + | +33 | s.join((p, q)) +34 | s.join([p, q]) +35 | xbasename(p) + | ^^^^^^^^^ PTH119 +36 | xdirname(p) +37 | xsamefile(p) + | + +import_from_as.py:36:1: PTH120 `os.path.dirname()` should be replaced by `Path.parent` + | +34 | s.join([p, q]) +35 | xbasename(p) +36 | xdirname(p) + | ^^^^^^^^ PTH120 +37 | xsamefile(p) +38 | xsplitext(p) + | + +import_from_as.py:37:1: PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` + | +35 | xbasename(p) +36 | xdirname(p) +37 | xsamefile(p) + | ^^^^^^^^^ PTH121 +38 | xsplitext(p) + | + +import_from_as.py:38:1: PTH122 `os.path.splitext()` should be replaced by `Path.suffix`, `Path.stem`, and `Path.parent` + | +36 | xdirname(p) +37 | xsamefile(p) +38 | xsplitext(p) + | ^^^^^^^^^ PTH122 + | + + diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__use_pathlib.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__use_pathlib.py.snap new file mode 100644 index 0000000000..10a495237c --- /dev/null +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__use_pathlib.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/flake8_use_pathlib/mod.rs +--- + diff --git a/crates/ruff/src/rules/flake8_use_pathlib/violations.rs b/crates/ruff_linter/src/rules/flake8_use_pathlib/violations.rs similarity index 100% rename from crates/ruff/src/rules/flake8_use_pathlib/violations.rs rename to crates/ruff_linter/src/rules/flake8_use_pathlib/violations.rs diff --git a/crates/ruff/src/rules/flynt/helpers.rs b/crates/ruff_linter/src/rules/flynt/helpers.rs similarity index 100% rename from crates/ruff/src/rules/flynt/helpers.rs rename to crates/ruff_linter/src/rules/flynt/helpers.rs diff --git a/crates/ruff/src/rules/flynt/mod.rs b/crates/ruff_linter/src/rules/flynt/mod.rs similarity index 100% rename from crates/ruff/src/rules/flynt/mod.rs rename to crates/ruff_linter/src/rules/flynt/mod.rs diff --git a/crates/ruff/src/rules/flynt/rules/mod.rs b/crates/ruff_linter/src/rules/flynt/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/flynt/rules/mod.rs rename to crates/ruff_linter/src/rules/flynt/rules/mod.rs diff --git a/crates/ruff/src/rules/flynt/rules/static_join_to_fstring.rs b/crates/ruff_linter/src/rules/flynt/rules/static_join_to_fstring.rs similarity index 100% rename from crates/ruff/src/rules/flynt/rules/static_join_to_fstring.rs rename to crates/ruff_linter/src/rules/flynt/rules/static_join_to_fstring.rs 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 new file mode 100644 index 0000000000..17ac7a8ef9 --- /dev/null +++ b/crates/ruff_linter/src/rules/flynt/snapshots/ruff_linter__rules__flynt__tests__FLY002_FLY002.py.snap @@ -0,0 +1,144 @@ +--- +source: crates/ruff_linter/src/rules/flynt/mod.rs +--- +FLY002.py:5:7: FLY002 [*] Consider `f"{a} World"` instead of string join + | +4 | a = "Hello" +5 | ok1 = " ".join([a, " World"]) # OK + | ^^^^^^^^^^^^^^^^^^^^^^^ FLY002 +6 | ok2 = "".join(["Finally, ", a, " World"]) # OK +7 | ok3 = "x".join(("1", "2", "3")) # OK + | + = help: Replace with `f"{a} World"` + +ℹ Suggested fix +2 2 | from random import random, choice +3 3 | +4 4 | a = "Hello" +5 |-ok1 = " ".join([a, " World"]) # OK + 5 |+ok1 = f"{a} World" # OK +6 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK +7 7 | ok3 = "x".join(("1", "2", "3")) # OK +8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally + +FLY002.py:6:7: FLY002 [*] Consider `f"Finally, {a} World"` instead of string join + | +4 | a = "Hello" +5 | ok1 = " ".join([a, " World"]) # OK +6 | ok2 = "".join(["Finally, ", a, " World"]) # OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 +7 | ok3 = "x".join(("1", "2", "3")) # OK +8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally + | + = help: Replace with `f"Finally, {a} World"` + +ℹ Suggested fix +3 3 | +4 4 | a = "Hello" +5 5 | ok1 = " ".join([a, " World"]) # OK +6 |-ok2 = "".join(["Finally, ", a, " World"]) # OK + 6 |+ok2 = f"Finally, {a} World" # OK +7 7 | ok3 = "x".join(("1", "2", "3")) # OK +8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally +9 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) + +FLY002.py:7:7: FLY002 [*] Consider `"1x2x3"` instead of string join + | +5 | ok1 = " ".join([a, " World"]) # OK +6 | ok2 = "".join(["Finally, ", a, " World"]) # OK +7 | ok3 = "x".join(("1", "2", "3")) # OK + | ^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 +8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally +9 | ok5 = "a".join([random(), random()]) # OK (simple calls) + | + = help: Replace with `"1x2x3"` + +ℹ Suggested fix +4 4 | a = "Hello" +5 5 | ok1 = " ".join([a, " World"]) # OK +6 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK +7 |-ok3 = "x".join(("1", "2", "3")) # OK + 7 |+ok3 = "1x2x3" # OK +8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally +9 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) +10 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) + +FLY002.py:8:7: FLY002 [*] Consider `f"{1}y{2}y{3}"` instead of string join + | + 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK + 7 | ok3 = "x".join(("1", "2", "3")) # OK + 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally + | ^^^^^^^^^^^^^^^^^^^ FLY002 + 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) +10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) + | + = help: Replace with `f"{1}y{2}y{3}"` + +ℹ Suggested fix +5 5 | ok1 = " ".join([a, " World"]) # OK +6 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK +7 7 | ok3 = "x".join(("1", "2", "3")) # OK +8 |-ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally + 8 |+ok4 = f"{1}y{2}y{3}" # Technically OK, though would've been an error originally +9 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) +10 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) +11 11 | + +FLY002.py:9:7: FLY002 [*] Consider `f"{random()}a{random()}"` instead of string join + | + 7 | ok3 = "x".join(("1", "2", "3")) # OK + 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally + 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 +10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) + | + = help: Replace with `f"{random()}a{random()}"` + +ℹ Suggested fix +6 6 | ok2 = "".join(["Finally, ", a, " World"]) # OK +7 7 | ok3 = "x".join(("1", "2", "3")) # OK +8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally +9 |-ok5 = "a".join([random(), random()]) # OK (simple calls) + 9 |+ok5 = f"{random()}a{random()}" # OK (simple calls) +10 10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) +11 11 | +12 12 | nok1 = "x".join({"4", "5", "yee"}) # Not OK (set) + +FLY002.py:10:7: FLY002 [*] Consider `f"{secrets.token_urlsafe()}a{secrets.token_hex()}"` instead of string join + | + 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally + 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) +10 | ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 +11 | +12 | nok1 = "x".join({"4", "5", "yee"}) # Not OK (set) + | + = help: Replace with `f"{secrets.token_urlsafe()}a{secrets.token_hex()}"` + +ℹ Suggested fix +7 7 | ok3 = "x".join(("1", "2", "3")) # OK +8 8 | ok4 = "y".join([1, 2, 3]) # Technically OK, though would've been an error originally +9 9 | ok5 = "a".join([random(), random()]) # OK (simple calls) +10 |-ok6 = "a".join([secrets.token_urlsafe(), secrets.token_hex()]) # OK (attr calls) + 10 |+ok6 = f"{secrets.token_urlsafe()}a{secrets.token_hex()}" # OK (attr calls) +11 11 | +12 12 | nok1 = "x".join({"4", "5", "yee"}) # Not OK (set) +13 13 | nok2 = a.join(["1", "2", "3"]) # Not OK (not a static joiner) + +FLY002.py:23:11: FLY002 [*] Consider `f"{url}{filename}"` instead of string join + | +21 | # Regression test for: https://github.com/astral-sh/ruff/issues/7197 +22 | def create_file_public_url(url, filename): +23 | return''.join([url, filename]) + | ^^^^^^^^^^^^^^^^^^^^^^^^ FLY002 + | + = help: Replace with `f"{url}{filename}"` + +ℹ Suggested fix +20 20 | +21 21 | # Regression test for: https://github.com/astral-sh/ruff/issues/7197 +22 22 | def create_file_public_url(url, filename): +23 |- return''.join([url, filename]) + 23 |+ return f"{url}{filename}" + + diff --git a/crates/ruff/src/rules/isort/annotate.rs b/crates/ruff_linter/src/rules/isort/annotate.rs similarity index 100% rename from crates/ruff/src/rules/isort/annotate.rs rename to crates/ruff_linter/src/rules/isort/annotate.rs diff --git a/crates/ruff/src/rules/isort/block.rs b/crates/ruff_linter/src/rules/isort/block.rs similarity index 100% rename from crates/ruff/src/rules/isort/block.rs rename to crates/ruff_linter/src/rules/isort/block.rs diff --git a/crates/ruff/src/rules/isort/categorize.rs b/crates/ruff_linter/src/rules/isort/categorize.rs similarity index 100% rename from crates/ruff/src/rules/isort/categorize.rs rename to crates/ruff_linter/src/rules/isort/categorize.rs diff --git a/crates/ruff/src/rules/isort/comments.rs b/crates/ruff_linter/src/rules/isort/comments.rs similarity index 100% rename from crates/ruff/src/rules/isort/comments.rs rename to crates/ruff_linter/src/rules/isort/comments.rs diff --git a/crates/ruff/src/rules/isort/format.rs b/crates/ruff_linter/src/rules/isort/format.rs similarity index 100% rename from crates/ruff/src/rules/isort/format.rs rename to crates/ruff_linter/src/rules/isort/format.rs diff --git a/crates/ruff/src/rules/isort/helpers.rs b/crates/ruff_linter/src/rules/isort/helpers.rs similarity index 100% rename from crates/ruff/src/rules/isort/helpers.rs rename to crates/ruff_linter/src/rules/isort/helpers.rs diff --git a/crates/ruff/src/rules/isort/mod.rs b/crates/ruff_linter/src/rules/isort/mod.rs similarity index 100% rename from crates/ruff/src/rules/isort/mod.rs rename to crates/ruff_linter/src/rules/isort/mod.rs diff --git a/crates/ruff/src/rules/isort/normalize.rs b/crates/ruff_linter/src/rules/isort/normalize.rs similarity index 100% rename from crates/ruff/src/rules/isort/normalize.rs rename to crates/ruff_linter/src/rules/isort/normalize.rs diff --git a/crates/ruff/src/rules/isort/order.rs b/crates/ruff_linter/src/rules/isort/order.rs similarity index 100% rename from crates/ruff/src/rules/isort/order.rs rename to crates/ruff_linter/src/rules/isort/order.rs diff --git a/crates/ruff/src/rules/isort/rules/add_required_imports.rs b/crates/ruff_linter/src/rules/isort/rules/add_required_imports.rs similarity index 100% rename from crates/ruff/src/rules/isort/rules/add_required_imports.rs rename to crates/ruff_linter/src/rules/isort/rules/add_required_imports.rs diff --git a/crates/ruff/src/rules/isort/rules/mod.rs b/crates/ruff_linter/src/rules/isort/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/isort/rules/mod.rs rename to crates/ruff_linter/src/rules/isort/rules/mod.rs diff --git a/crates/ruff/src/rules/isort/rules/organize_imports.rs b/crates/ruff_linter/src/rules/isort/rules/organize_imports.rs similarity index 100% rename from crates/ruff/src/rules/isort/rules/organize_imports.rs rename to crates/ruff_linter/src/rules/isort/rules/organize_imports.rs diff --git a/crates/ruff/src/rules/isort/settings.rs b/crates/ruff_linter/src/rules/isort/settings.rs similarity index 100% rename from crates/ruff/src/rules/isort/settings.rs rename to crates/ruff_linter/src/rules/isort/settings.rs 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 new file mode 100644 index 0000000000..344f645f31 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__1_separate_subpackage_first_and_third_party_imports.py.snap @@ -0,0 +1,33 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / import sys +2 | | import baz +3 | | from foo import bar, baz +4 | | from foo.bar import blah, blub +5 | | from foo.bar.baz import something +6 | | import foo +7 | | import foo.bar +8 | | import foo.bar.baz + | + = help: Organize imports + +ℹ Fix +1 1 | import sys + 2 |+ + 3 |+import foo + 4 |+from foo import bar, baz + 5 |+ +2 6 | import baz +3 |-from foo import bar, baz + 7 |+import foo.bar + 8 |+import foo.bar.baz +4 9 | from foo.bar import blah, blub +5 10 | from foo.bar.baz import something +6 |-import foo +7 |-import foo.bar +8 |-import foo.bar.baz + + 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 new file mode 100644 index 0000000000..07c548e246 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__2_separate_subpackage_first_and_third_party_imports.py.snap @@ -0,0 +1,32 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / import sys +2 | | import baz +3 | | from foo import bar, baz +4 | | from foo.bar import blah, blub +5 | | from foo.bar.baz import something +6 | | import foo +7 | | import foo.bar +8 | | import foo.bar.baz + | + = help: Organize imports + +ℹ Fix +1 1 | import sys + 2 |+ +2 3 | import baz +3 |-from foo import bar, baz + 4 |+import foo.bar + 5 |+import foo.bar.baz +4 6 | from foo.bar import blah, blub +5 7 | from foo.bar.baz import something + 8 |+ +6 9 | import foo +7 |-import foo.bar +8 |-import foo.bar.baz + 10 |+from foo import bar, baz + + 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 new file mode 100644 index 0000000000..88702a460e --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__add_newline_before_comments.py.snap @@ -0,0 +1,28 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +add_newline_before_comments.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / import os +2 | | # This is a comment in the same section, so we need to add one newline. +3 | | import sys +4 | | import numpy as np +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 + | + = help: Organize imports + +ℹ Fix +1 1 | import os + 2 |+ +2 3 | # This is a comment in the same section, so we need to add one newline. +3 4 | import sys + 5 |+ +4 6 | import numpy as np + 7 |+ +5 8 | # This is a comment, but it starts a new section, so we don't need to add a newline +6 9 | # before it. +7 10 | import leading_prefix + + 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 new file mode 100644 index 0000000000..875212c181 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__as_imports_comments.py.snap @@ -0,0 +1,45 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +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 | | + 5 | | from bar import ( # Comment on `bar` + 6 | | Member, # Comment on `Member` + 7 | | ) + 8 | | + 9 | | from baz import ( # Comment on `baz` +10 | | Member as Alias # Comment on `Alias` +11 | | ) +12 | | +13 | | from bop import ( # Comment on `bop` +14 | | Member # Comment on `Member` +15 | | ) + | + = help: Organize imports + +ℹ Fix +1 |-from foo import ( # Comment on `foo` +2 |- Member as Alias, # Comment on `Alias` +3 |-) +4 |- +5 1 | from bar import ( # Comment on `bar` +6 2 | Member, # Comment on `Member` +7 |-) +8 |- +9 |-from baz import ( # Comment on `baz` +10 |- Member as Alias # Comment on `Alias` +11 3 | ) +12 |- +13 |-from bop import ( # Comment on `bop` +14 |- Member # Comment on `Member` + 4 |+from baz import Member as Alias # Comment on `Alias` # Comment on `baz` + 5 |+from bop import Member # Comment on `Member` # Comment on `bop` + 6 |+from foo import ( # Comment on `foo` + 7 |+ Member as Alias, # Comment on `Alias` +15 8 | ) + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__bom_sorted.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__bom_sorted.py.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__bom_sorted.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + 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 new file mode 100644 index 0000000000..ef1b7cdaa5 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__bom_unsorted.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +bom_unsorted.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | import foo + | _^ +2 | | import bar + | + = help: Organize imports + +ℹ Fix +1 |-import foo +2 |-import bar + 1 |+import bar + 2 |+import foo + + 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 new file mode 100644 index 0000000000..a4285be498 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__case_sensitive_case_sensitive.py.snap @@ -0,0 +1,33 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +case_sensitive.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / import A +2 | | import B +3 | | import b +4 | | import C +5 | | import d +6 | | import E +7 | | import f +8 | | from g import a, B, c +9 | | from h import A, b, C + | + = help: Organize imports + +ℹ Fix +1 1 | import A +2 2 | import B + 3 |+import C + 4 |+import E +3 5 | import b +4 |-import C +5 6 | import d +6 |-import E +7 7 | import f +8 |-from g import a, B, c +9 |-from h import A, b, C + 8 |+from g import B, a, c + 9 |+from h import A, C, b + + 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 new file mode 100644 index 0000000000..8c3f8b3d93 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__closest_to_furthest_relative_imports_order.py.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +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 + | + = help: Organize imports + +ℹ Fix + 1 |+from . import c + 2 |+from .. import b +1 3 | from ... import a +2 |-from .. import b +3 |-from . import c + + 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 new file mode 100644 index 0000000000..69a4c6536c --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +combine_as_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / from module import Class as C +2 | | from module import CONSTANT +3 | | from module import function +4 | | from module import function as f + | + = help: Organize imports + +ℹ Fix + 1 |+from module import CONSTANT, function +1 2 | from module import Class as C +2 |-from module import CONSTANT +3 |-from module import function +4 3 | from module import function as f + + 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 new file mode 100644 index 0000000000..369f05e556 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_as_imports_combine_as_imports.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +combine_as_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / from module import Class as C +2 | | from module import CONSTANT +3 | | from module import function +4 | | from module import function as f + | + = help: Organize imports + +ℹ Fix +1 |-from module import Class as C +2 |-from module import CONSTANT +3 |-from module import function +4 |-from module import function as f + 1 |+from module import CONSTANT, Class as C, function, function as f + + 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 new file mode 100644 index 0000000000..79b027ef7f --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combine_import_from.py.snap @@ -0,0 +1,29 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +combine_import_from.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / from collections import Awaitable +2 | | from collections import AsyncIterable +3 | | from collections import Collection +4 | | from collections import ChainMap +5 | | from collections import MutableSequence, MutableMapping + | + = help: Organize imports + +ℹ Fix +1 |-from collections import Awaitable +2 |-from collections import AsyncIterable +3 |-from collections import Collection +4 |-from collections import ChainMap +5 |-from collections import MutableSequence, MutableMapping + 1 |+from collections import ( + 2 |+ AsyncIterable, + 3 |+ Awaitable, + 4 |+ ChainMap, + 5 |+ Collection, + 6 |+ MutableMapping, + 7 |+ MutableSequence, + 8 |+) + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combined_required_imports_docstring.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combined_required_imports_docstring.py.snap new file mode 100644 index 0000000000..daa796cd23 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combined_required_imports_docstring.py.snap @@ -0,0 +1,34 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` + | +1 | """Hello, world!""" + | I002 +2 | +3 | x = 1 + | + = help: Insert required import: `from future import annotations` + +ℹ Fix +1 1 | """Hello, world!""" + 2 |+from __future__ import annotations +2 3 | +3 4 | x = 1 + +docstring.py:1:1: I002 [*] Missing required import: `from __future__ import generator_stop` + | +1 | """Hello, world!""" + | I002 +2 | +3 | x = 1 + | + = help: Insert required import: `from future import generator_stop` + +ℹ Fix +1 1 | """Hello, world!""" + 2 |+from __future__ import generator_stop +2 3 | +3 4 | x = 1 + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combined_required_imports_docstring.pyi.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combined_required_imports_docstring.pyi.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combined_required_imports_docstring.pyi.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combined_required_imports_docstring_only.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combined_required_imports_docstring_only.py.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combined_required_imports_docstring_only.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combined_required_imports_empty.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combined_required_imports_empty.py.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__combined_required_imports_empty.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + 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 new file mode 100644 index 0000000000..b91b694c57 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__comments.py.snap @@ -0,0 +1,89 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +comments.py:3:1: I001 [*] Import block is un-sorted or un-formatted + | + 1 | # Comment 1 + 2 | # Comment 2 + 3 | / import D + 4 | | + 5 | | # Comment 3a + 6 | | import C + 7 | | + 8 | | # Comment 3b + 9 | | import C +10 | | +11 | | import B # Comment 4 +12 | | +13 | | # Comment 5 +14 | | +15 | | # Comment 6 +16 | | from A import ( +17 | | a, # Comment 7 +18 | | b, +19 | | c, # Comment 8 +20 | | ) +21 | | from A import ( +22 | | a, # Comment 9 +23 | | b, # Comment 10 +24 | | c, # Comment 11 +25 | | ) +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 | | +30 | | from E import a # Comment 1 +31 | | +32 | | from F import a # Comment 1 +33 | | from F import b + | + = help: Organize imports + +ℹ Fix +1 1 | # Comment 1 +2 2 | # Comment 2 +3 |-import D + 3 |+import B # Comment 4 +4 4 | +5 5 | # Comment 3a +6 |-import C +7 |- +8 6 | # Comment 3b +9 7 | import C +10 |- +11 |-import B # Comment 4 + 8 |+import D +12 9 | +13 10 | # Comment 5 +14 |- +15 11 | # Comment 6 +16 12 | from A import ( +17 |- a, # Comment 7 +18 |- b, +19 |- c, # Comment 8 + 13 |+ a, # Comment 7 # Comment 9 + 14 |+ b, # Comment 10 + 15 |+ c, # Comment 8 # Comment 11 +20 16 | ) +21 |-from A import ( +22 |- a, # Comment 9 +23 |- b, # Comment 10 +24 |- c, # Comment 11 + 17 |+from D import ( + 18 |+ a_long_name_to_force_multiple_lines, # Comment 12 + 19 |+ another_long_name_to_force_multiple_lines, # Comment 13 +25 20 | ) +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 |- +30 21 | from E import a # Comment 1 +31 |- +32 |-from F import a # Comment 1 +33 |-from F import b + 22 |+from F import ( + 23 |+ a, # Comment 1 + 24 |+ b, + 25 |+) + + 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 new file mode 100644 index 0000000000..ea563514f8 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__deduplicate_imports.py.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +deduplicate_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / import os +2 | | import os +3 | | import os as os1 +4 | | import os as os2 + | + = help: Organize imports + +ℹ Fix +1 1 | import os +2 |-import os +3 2 | import os as os1 +4 3 | import os as os2 + + 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 new file mode 100644 index 0000000000..f185340adc --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__detect_same_package.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +bar.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / import os +2 | | import pandas +3 | | import foo.baz + | + = help: Organize imports + +ℹ Fix +1 1 | import os + 2 |+ +2 3 | import pandas + 4 |+ +3 5 | import foo.baz + + 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 new file mode 100644 index 0000000000..1a39fba378 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length.py.snap @@ -0,0 +1,42 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +fit_line_length.py:7:1: I001 [*] Import block is un-sorted or un-formatted + | + 6 | if indented: + 7 | / from line_with_88 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + 8 | | from line_with_89 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + 9 | | from line_with_90 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +10 | | from line_with_91 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +11 | | from line_with_92 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +12 | | from line_with_93 import ( +13 | | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, +14 | | ) + | + = help: Organize imports + +ℹ Fix +5 5 | +6 6 | if indented: +7 7 | from line_with_88 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +8 |- from line_with_89 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +9 |- from line_with_90 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +10 |- from line_with_91 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +11 |- from line_with_92 import aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + 8 |+ from line_with_89 import ( + 9 |+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + 10 |+ ) + 11 |+ from line_with_90 import ( + 12 |+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + 13 |+ ) + 14 |+ from line_with_91 import ( + 15 |+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + 16 |+ ) + 17 |+ from line_with_92 import ( + 18 |+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + 19 |+ ) +12 20 | from line_with_93 import ( +13 21 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, +14 22 | ) + + 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 new file mode 100644 index 0000000000..e0082e24db --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__fit_line_length_comment.py.snap @@ -0,0 +1,36 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +fit_line_length_comment.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / import a +2 | | # Don't take this comment into account when determining whether the next import can fit on one line. +3 | | from b import c +4 | | from d import e # Do take this comment into account when determining whether the next import can fit on one line. +5 | | # The next import fits on one line. +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 + | + = help: Organize imports + +ℹ Fix +1 1 | import a + 2 |+ +2 3 | # Don't take this comment into account when determining whether the next import can fit on one line. +3 4 | from b import c +4 |-from d import e # Do take this comment into account when determining whether the next import can fit on one line. + 5 |+from d import ( + 6 |+ e, # Do take this comment into account when determining whether the next import can fit on one line. + 7 |+) + 8 |+ +5 9 | # The next import fits on one line. +6 10 | 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ℝ + 11 |+ +7 12 | # 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 + 13 |+from h import ( + 14 |+ i, # 012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9012ß9💣2ℝ9 + 15 |+) + + 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 new file mode 100644 index 0000000000..2d862ff5d9 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_single_line_force_single_line.py.snap @@ -0,0 +1,85 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +force_single_line.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | + 1 | / import sys, math + 2 | | from os import path, uname + 3 | | from json import detect_encoding + 4 | | from json import dump + 5 | | from json import dumps as json_dumps + 6 | | from json import load + 7 | | from json import loads as json_loads + 8 | | from logging.handlers import StreamHandler, FileHandler + 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 | | +16 | | from foo import bar # comment 3 +17 | | from foo2 import bar2 # comment 4 +18 | | from foo3 import bar3, baz3 # comment 5 +19 | | +20 | | # comment 6 +21 | | from bar import ( +22 | | a, # comment 7 +23 | | b, # comment 8 +24 | | ) +25 | | +26 | | # comment 9 +27 | | from baz import * # comment 10 + | + = help: Organize imports + +ℹ Fix +1 |-import sys, math +2 |-from os import path, uname + 1 |+import math + 2 |+import sys +3 3 | from json import detect_encoding +4 4 | from json import dump +5 5 | from json import dumps as json_dumps +6 6 | from json import load +7 7 | from json import loads as json_loads +8 |-from logging.handlers import StreamHandler, FileHandler + 8 |+from logging.handlers import FileHandler, StreamHandler + 9 |+from os import path, uname +9 10 | +10 |-# comment 1 +11 |-from third_party import lib1, lib2, \ +12 |- lib3, lib7, lib5, lib6 +13 |-# comment 2 +14 |-from third_party import lib4 + 11 |+# comment 6 + 12 |+from bar import a # comment 7 + 13 |+from bar import b # comment 8 +15 14 | + 15 |+# comment 9 + 16 |+from baz import * # comment 10 +16 17 | from foo import bar # comment 3 +17 18 | from foo2 import bar2 # comment 4 +18 |-from foo3 import bar3, baz3 # comment 5 + 19 |+from foo3 import bar3 # comment 5 + 20 |+from foo3 import baz3 # comment 5 +19 21 | +20 |-# comment 6 +21 |-from bar import ( +22 |- a, # comment 7 +23 |- b, # comment 8 +24 |-) + 22 |+# comment 1 + 23 |+from third_party import lib1 + 24 |+from third_party import lib2 + 25 |+from third_party import lib3 +25 26 | +26 |-# comment 9 +27 |-from baz import * # comment 10 + 27 |+# comment 2 + 28 |+from third_party import lib4 + 29 |+from third_party import lib5 + 30 |+from third_party import lib6 + 31 |+from third_party import lib7 + + 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 new file mode 100644 index 0000000000..f898d1c5e9 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections.py.snap @@ -0,0 +1,43 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +force_sort_within_sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | + 1 | / from a import a1 # import_from + 2 | | from c import * # import_from_star + 3 | | import a # import + 4 | | import c.d + 5 | | from z import z1 + 6 | | import b as b1 # import_as + 7 | | import z + 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 + | + = help: Organize imports + +ℹ Fix +1 |-from a import a1 # import_from +2 |-from c import * # import_from_star +3 1 | import a # import + 2 |+import b as b1 # import_as +4 3 | import c.d + 4 |+import z + 5 |+from a import a1 # import_from + 6 |+from c import * # import_from_star +5 7 | from z import z1 +6 |-import b as b1 # import_as +7 |-import z +8 8 | + 9 |+from ...grandparent import fn3 +9 10 | from ..parent import * + 11 |+from . import my +10 12 | from .my import fn +11 |-from . import my +12 13 | from .my.nested import fn2 +13 |-from ...grandparent import fn3 + + 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 new file mode 100644 index 0000000000..ec201eb34c --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_sort_within_sections_force_sort_within_sections.py.snap @@ -0,0 +1,44 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +force_sort_within_sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | + 1 | / from a import a1 # import_from + 2 | | from c import * # import_from_star + 3 | | import a # import + 4 | | import c.d + 5 | | from z import z1 + 6 | | import b as b1 # import_as + 7 | | import z + 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 + | + = help: Organize imports + +ℹ Fix +1 |-from a import a1 # import_from +2 |-from c import * # import_from_star + 1 |+import z + 2 |+from z import z1 +3 3 | import a # import + 4 |+from a import a1 # import_from + 5 |+import b as b1 # import_as + 6 |+from c import * # import_from_star +4 7 | import c.d +5 |-from z import z1 +6 |-import b as b1 # import_as +7 |-import z +8 8 | + 9 |+from ...grandparent import fn3 +9 10 | from ..parent import * + 11 |+from . import my +10 12 | from .my import fn +11 |-from . import my +12 13 | from .my.nested import fn2 +13 |-from ...grandparent import fn3 + + 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 new file mode 100644 index 0000000000..ecab269b6f --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top.py.snap @@ -0,0 +1,67 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | + 1 | / import lib6 + 2 | | import lib2 + 3 | | import lib5 + 4 | | import lib1 + 5 | | import lib3 + 6 | | import lib4 + 7 | | + 8 | | import foo + 9 | | import z +10 | | from foo import bar +11 | | from lib1 import foo +12 | | from lib2 import foo +13 | | from lib1.lib2 import foo +14 | | from foo.lib1.bar import baz +15 | | from lib4 import lib1 +16 | | from lib5 import lib2 +17 | | from lib4 import lib2 +18 | | from lib5 import lib1 +19 | | +20 | | import lib3.lib4 +21 | | import lib3.lib4.lib5 +22 | | from lib3.lib4 import foo +23 | | from lib3.lib4.lib5 import foo + | + = help: Organize imports + +ℹ Fix +1 |-import lib6 + 1 |+import foo + 2 |+import lib1 +2 3 | import lib2 +3 |-import lib5 +4 |-import lib1 +5 4 | import lib3 + 5 |+import lib3.lib4 + 6 |+import lib3.lib4.lib5 +6 7 | import lib4 +7 |- +8 |-import foo + 8 |+import lib5 + 9 |+import lib6 +9 10 | import z +10 11 | from foo import bar + 12 |+from foo.lib1.bar import baz +11 13 | from lib1 import foo +12 |-from lib2 import foo +13 14 | from lib1.lib2 import foo +14 |-from foo.lib1.bar import baz +15 |-from lib4 import lib1 +16 |-from lib5 import lib2 +17 |-from lib4 import lib2 +18 |-from lib5 import lib1 +19 |- +20 |-import lib3.lib4 +21 |-import lib3.lib4.lib5 + 15 |+from lib2 import foo +22 16 | from lib3.lib4 import foo +23 17 | from lib3.lib4.lib5 import foo + 18 |+from lib4 import lib1, lib2 + 19 |+from lib5 import lib1, lib2 + + 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 new file mode 100644 index 0000000000..9a9d0db607 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_to_top_force_to_top.py.snap @@ -0,0 +1,70 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +force_to_top.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | + 1 | / import lib6 + 2 | | import lib2 + 3 | | import lib5 + 4 | | import lib1 + 5 | | import lib3 + 6 | | import lib4 + 7 | | + 8 | | import foo + 9 | | import z +10 | | from foo import bar +11 | | from lib1 import foo +12 | | from lib2 import foo +13 | | from lib1.lib2 import foo +14 | | from foo.lib1.bar import baz +15 | | from lib4 import lib1 +16 | | from lib5 import lib2 +17 | | from lib4 import lib2 +18 | | from lib5 import lib1 +19 | | +20 | | import lib3.lib4 +21 | | import lib3.lib4.lib5 +22 | | from lib3.lib4 import foo +23 | | from lib3.lib4.lib5 import foo + | + = help: Organize imports + +ℹ Fix +1 |-import lib6 +2 |-import lib2 +3 |-import lib5 +4 1 | import lib1 +5 2 | import lib3 +6 |-import lib4 +7 |- + 3 |+import lib3.lib4 + 4 |+import lib5 + 5 |+import z +8 6 | import foo +9 |-import z + 7 |+import lib2 + 8 |+import lib3.lib4.lib5 + 9 |+import lib4 + 10 |+import lib6 + 11 |+from lib1 import foo + 12 |+from lib3.lib4 import foo + 13 |+from lib5 import lib1, lib2 +10 14 | from foo import bar +11 |-from lib1 import foo +12 |-from lib2 import foo +13 |-from lib1.lib2 import foo +14 15 | from foo.lib1.bar import baz +15 |-from lib4 import lib1 +16 |-from lib5 import lib2 +17 |-from lib4 import lib2 +18 |-from lib5 import lib1 +19 |- +20 |-import lib3.lib4 +21 |-import lib3.lib4.lib5 +22 |-from lib3.lib4 import foo + 16 |+from lib1.lib2 import foo + 17 |+from lib2 import foo +23 18 | from lib3.lib4.lib5 import foo + 19 |+from lib4 import lib1, lib2 + + 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 new file mode 100644 index 0000000000..718ab45ee3 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases.py.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +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 + | + = help: Organize imports + +ℹ Fix +1 |-from .a import a1 as a1, a2 as a2 + 1 |+from .a import a1 as a1 + 2 |+from .a import a2 as a2 +2 3 | from .b import b1 as b1 +3 4 | from .c import c1 + + 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 new file mode 100644 index 0000000000..e09ac572a5 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__force_wrap_aliases_force_wrap_aliases.py.snap @@ -0,0 +1,21 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +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 + | + = help: Organize imports + +ℹ Fix +1 |-from .a import a1 as a1, a2 as a2 + 1 |+from .a import ( + 2 |+ a1 as a1, + 3 |+ a2 as a2, + 4 |+) +2 5 | from .b import b1 as b1 +3 6 | from .c import c1 + + 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 new file mode 100644 index 0000000000..894e113c85 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__forced_separate.py.snap @@ -0,0 +1,30 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +forced_separate.py:3:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | # office_helper and tests are both first-party, +2 | # but we want tests and experiments to be separated, in that order +3 | / from office_helper.core import CoreState +4 | | import tests.common.foo as tcf +5 | | from tests.common import async_mock_service +6 | | from experiments.starry import * +7 | | from experiments.weird import varieties +8 | | from office_helper.assistants import entity_registry as er + | + = help: Organize imports + +ℹ Fix +1 1 | # office_helper and tests are both first-party, +2 2 | # but we want tests and experiments to be separated, in that order + 3 |+from office_helper.assistants import entity_registry as er +3 4 | from office_helper.core import CoreState + 5 |+ +4 6 | import tests.common.foo as tcf +5 7 | from tests.common import async_mock_service + 8 |+ +6 9 | from experiments.starry import * +7 10 | from experiments.weird import varieties +8 |-from office_helper.assistants import entity_registry as er + + 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 new file mode 100644 index 0000000000..344f645f31 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__glob_1_separate_subpackage_first_and_third_party_imports.py.snap @@ -0,0 +1,33 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +separate_subpackage_first_and_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / import sys +2 | | import baz +3 | | from foo import bar, baz +4 | | from foo.bar import blah, blub +5 | | from foo.bar.baz import something +6 | | import foo +7 | | import foo.bar +8 | | import foo.bar.baz + | + = help: Organize imports + +ℹ Fix +1 1 | import sys + 2 |+ + 3 |+import foo + 4 |+from foo import bar, baz + 5 |+ +2 6 | import baz +3 |-from foo import bar, baz + 7 |+import foo.bar + 8 |+import foo.bar.baz +4 9 | from foo.bar import blah, blub +5 10 | from foo.bar.baz import something +6 |-import foo +7 |-import foo.bar +8 |-import foo.bar.baz + + 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 new file mode 100644 index 0000000000..4644db8a08 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__if_elif_else.py.snap @@ -0,0 +1,21 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +if_elif_else.py:6:1: I001 [*] Import block is un-sorted or un-formatted + | +4 | from setuptools.command.sdist import sdist as _sdist +5 | else: +6 | / from setuptools.command.sdist import sdist as _sdist +7 | | from distutils.command.sdist import sdist as _sdist + | + = help: Organize imports + +ℹ Fix +3 3 | elif "setuptools" in sys.modules: +4 4 | from setuptools.command.sdist import sdist as _sdist +5 5 | else: + 6 |+ from distutils.command.sdist import sdist as _sdist +6 7 | from setuptools.command.sdist import sdist as _sdist +7 |- from distutils.command.sdist import sdist as _sdist + + 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 new file mode 100644 index 0000000000..fb24018262 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__import_from_after_import.py.snap @@ -0,0 +1,16 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +import_from_after_import.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / from collections import Collection +2 | | import os + | + = help: Organize imports + +ℹ Fix + 1 |+import os +1 2 | from collections import Collection +2 |-import os + + 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 new file mode 100644 index 0000000000..e25911cad1 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__inline_comments.py.snap @@ -0,0 +1,40 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +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 | | + 5 | | from b.prometheus.metrics import ( + 6 | | TERMINAL_CURRENTLY_RUNNING_TOTAL, # type:ignore[attr-defined] + 7 | | ) + 8 | | + 9 | | from c.prometheus.metrics import TERMINAL_CURRENTLY_RUNNING_TOTAL # type:ignore[attr-defined] +10 | | +11 | | from d.prometheus.metrics import TERMINAL_CURRENTLY_RUNNING_TOTAL, OTHER_RUNNING_TOTAL # type:ignore[attr-defined] + | + = help: Organize imports + +ℹ Fix +1 1 | from a.prometheus.metrics import ( # type:ignore[attr-defined] +2 2 | TERMINAL_CURRENTLY_RUNNING_TOTAL, +3 3 | ) +4 |- +5 4 | from b.prometheus.metrics import ( +6 5 | TERMINAL_CURRENTLY_RUNNING_TOTAL, # type:ignore[attr-defined] +7 6 | ) +8 |- +9 |-from c.prometheus.metrics import TERMINAL_CURRENTLY_RUNNING_TOTAL # type:ignore[attr-defined] +10 |- +11 |-from d.prometheus.metrics import TERMINAL_CURRENTLY_RUNNING_TOTAL, OTHER_RUNNING_TOTAL # type:ignore[attr-defined] + 7 |+from c.prometheus.metrics import ( + 8 |+ TERMINAL_CURRENTLY_RUNNING_TOTAL, # type:ignore[attr-defined] + 9 |+) + 10 |+from d.prometheus.metrics import ( # type:ignore[attr-defined] + 11 |+ OTHER_RUNNING_TOTAL, + 12 |+ TERMINAL_CURRENTLY_RUNNING_TOTAL, + 13 |+) + + 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 new file mode 100644 index 0000000000..198031daeb --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.py.snap @@ -0,0 +1,88 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +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 +4 | import os +5 | import sys + | + = help: Organize imports + +ℹ Fix +1 1 | import a +2 2 | import b + 3 |+ +3 4 | x = 1 +4 5 | import os +5 6 | import sys + +insert_empty_lines.py:4:1: I001 [*] Import block is un-sorted or un-formatted + | +2 | import b +3 | x = 1 +4 | / import os +5 | | import sys +6 | | def f(): + | |_^ I001 +7 | pass +8 | if True: + | + = help: Organize imports + +ℹ Fix +3 3 | x = 1 +4 4 | import os +5 5 | import sys + 6 |+ + 7 |+ +6 8 | def f(): +7 9 | pass +8 10 | if True: + +insert_empty_lines.py:14:1: I001 [*] Import block is un-sorted or un-formatted + | +12 | class X: pass +13 | y = 1 +14 | / import os +15 | | import sys +16 | | """Docstring""" + | |_^ I001 +17 | +18 | if True: + | + = help: Organize imports + +ℹ Fix +13 13 | y = 1 +14 14 | import os +15 15 | import sys + 16 |+ +16 17 | """Docstring""" +17 18 | +18 19 | if True: + +insert_empty_lines.py:52:1: I001 [*] Import block is un-sorted or un-formatted + | +52 | / import os +53 | | +54 | | # Comment goes here. + | |_^ I001 +55 | def f(): +56 | pass + | + = help: Organize imports + +ℹ Fix +51 51 | +52 52 | import os +53 53 | + 54 |+ +54 55 | # Comment goes here. +55 56 | def f(): +56 57 | 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 new file mode 100644 index 0000000000..670834f2e7 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__insert_empty_lines.pyi.snap @@ -0,0 +1,67 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +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 +4 | import os +5 | import sys + | + = help: Organize imports + +ℹ Fix +1 1 | import a +2 2 | import b + 3 |+ +3 4 | x = 1 +4 5 | import os +5 6 | import sys + +insert_empty_lines.pyi:4:1: I001 [*] Import block is un-sorted or un-formatted + | +2 | import b +3 | x = 1 +4 | / import os +5 | | import sys +6 | | def f(): + | |_^ I001 +7 | pass +8 | if True: + | + = help: Organize imports + +ℹ Fix +3 3 | x = 1 +4 4 | import os +5 5 | import sys + 6 |+ +6 7 | def f(): +7 8 | pass +8 9 | if True: + +insert_empty_lines.pyi:14:1: I001 [*] Import block is un-sorted or un-formatted + | +12 | class X: pass +13 | y = 1 +14 | / import os +15 | | import sys +16 | | """Docstring""" + | |_^ I001 +17 | +18 | if True: + | + = help: Organize imports + +ℹ Fix +13 13 | y = 1 +14 14 | import os +15 15 | import sys + 16 |+ +16 17 | """Docstring""" +17 18 | +18 19 | if True: + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__isort_skip_file.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__isort_skip_file.py.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__isort_skip_file.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + 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 new file mode 100644 index 0000000000..a77f5701d9 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__known_local_folder_separate_local_folder_imports.py.snap @@ -0,0 +1,25 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / import sys +2 | | import ruff +3 | | import leading_prefix +4 | | import os +5 | | from . import leading_prefix + | + = help: Organize imports + +ℹ Fix + 1 |+import os +1 2 | import sys + 3 |+ + 4 |+import leading_prefix + 5 |+ +2 6 | import ruff +3 |-import leading_prefix +4 |-import os +5 7 | from . import leading_prefix + + 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 new file mode 100644 index 0000000000..c84144c29e --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__leading_prefix.py.snap @@ -0,0 +1,46 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +leading_prefix.py:1:8: I001 Import block is un-sorted or un-formatted + | +1 | x = 1; import sys + | ________^ +2 | | import os + | |_________^ I001 +3 | +4 | if True: + | + = help: Organize imports + +leading_prefix.py:5:12: I001 Import block is un-sorted or un-formatted + | +4 | if True: +5 | x = 1; import sys + | ____________^ +6 | | import os + | |_____________^ I001 +7 | +8 | if True: + | + = help: Organize imports + +leading_prefix.py:10:9: I001 Import block is un-sorted or un-formatted + | + 8 | if True: + 9 | x = 1; \ +10 | import os + | ^^^^^^^^^ I001 +11 | +12 | x = 1; \ + | + = help: Organize imports + +leading_prefix.py:13:1: I001 Import block is un-sorted or un-formatted + | +12 | x = 1; \ +13 | import os + | ^^^^^^^^^ 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_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 new file mode 100644 index 0000000000..43bd1f67b7 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_class_after.py.snap @@ -0,0 +1,39 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +lines_after_imports_class_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | + 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 | | class Thing(object): + | |_^ I001 +11 | name: str +12 | def __init__(self, name: str): + | + = help: Organize imports + +ℹ Fix +2 2 | +3 3 | from typing import Any +4 4 | + 5 |+from my_first_party import my_first_party_object +5 6 | from requests import Session +6 7 | +7 |-from my_first_party import my_first_party_object + 8 |+from . import my_local_folder_object + 9 |+ + 10 |+ +8 11 | +9 |-from . import my_local_folder_object +10 12 | class Thing(object): +11 13 | name: str +12 14 | 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 new file mode 100644 index 0000000000..c0351452e9 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_func_after.py.snap @@ -0,0 +1,54 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +lines_after_imports_func_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | + 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 | | +14 | | +15 | | +16 | | +17 | | +18 | | +19 | | +20 | | +21 | | def main(): + | |_^ I001 +22 | my_local_folder_object.get() + | + = help: Organize imports + +ℹ Fix +2 2 | +3 3 | from typing import Any +4 4 | +5 |-from requests import Session +6 |- +7 5 | from my_first_party import my_first_party_object + 6 |+from requests import Session +8 7 | +9 8 | from . import my_local_folder_object +10 |- +11 |- +12 |- +13 |- +14 |- +15 |- +16 |- +17 |- +18 9 | +19 10 | +20 11 | + + 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 new file mode 100644 index 0000000000..e371fb2bcc --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_after_imports_lines_after_imports_nothing_after.py.snap @@ -0,0 +1,29 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +lines_after_imports_nothing_after.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +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 + | + = help: Organize imports + +ℹ Fix +2 2 | +3 3 | from typing import Any +4 4 | +5 |-from requests import Session +6 |- +7 5 | from my_first_party import my_first_party_object + 6 |+from requests import Session +8 7 | +9 8 | from . import my_local_folder_object + + 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 new file mode 100644 index 0000000000..f22f2f20b8 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__lines_between_typeslines_between_types.py.snap @@ -0,0 +1,36 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +lines_between_types.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | + 1 | / from __future__ import annotations + 2 | | + 3 | | import datetime + 4 | | import json + 5 | | + 6 | | + 7 | | from binascii import hexlify + 8 | | + 9 | | import requests +10 | | +11 | | +12 | | from sanic import Sanic +13 | | from loguru import Logger +14 | | +15 | | from . import config +16 | | from .data import Data + | + = help: Organize imports + +ℹ Fix +9 9 | import requests +10 10 | +11 11 | + 12 |+from loguru import Logger +12 13 | from sanic import Sanic +13 |-from loguru import Logger +14 14 | +15 15 | from . import config +16 16 | from .data import Data + + 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 new file mode 100644 index 0000000000..1fd333035b --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__magic_trailing_comma.py.snap @@ -0,0 +1,101 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted + | + 1 | # This has a magic trailing comma, will be sorted, but not rolled into one line + 2 | / from sys import ( + 3 | | stderr, + 4 | | argv, + 5 | | stdout, + 6 | | exit, + 7 | | ) + 8 | | + 9 | | # No magic comma, this will be rolled into one line. +10 | | from os import ( +11 | | path, +12 | | environ, +13 | | execl, +14 | | execv +15 | | ) +16 | | +17 | | from glob import ( +18 | | glob, +19 | | iglob, +20 | | escape, # Ends with a comment, should still treat as magic trailing comma. +21 | | ) +22 | | +23 | | # These will be combined, but without a trailing comma. +24 | | from foo import bar +25 | | from foo import baz +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 | | +34 | | # These will be combined, _with_ a trailing comma. +35 | | from module2 import member1, member2 +36 | | from module2 import ( +37 | | member3, +38 | | ) + | + = help: Organize imports + +ℹ Fix +1 1 | # This has a magic trailing comma, will be sorted, but not rolled into one line +2 |-from sys import ( +3 |- stderr, +4 |- argv, +5 |- stdout, +6 |- exit, + 2 |+from glob import ( + 3 |+ escape, # Ends with a comment, should still treat as magic trailing comma. + 4 |+ glob, + 5 |+ iglob, +7 6 | ) +8 7 | +9 8 | # No magic comma, this will be rolled into one line. +10 |-from os import ( +11 |- path, +12 |- environ, +13 |- execl, +14 |- execv +15 |-) +16 |- +17 |-from glob import ( +18 |- glob, +19 |- iglob, +20 |- escape, # Ends with a comment, should still treat as magic trailing comma. + 9 |+from os import environ, execl, execv, path + 10 |+from sys import ( + 11 |+ argv, + 12 |+ exit, + 13 |+ stderr, + 14 |+ stdout, +21 15 | ) +22 16 | +23 17 | # These will be combined, but without a trailing comma. +24 |-from foo import bar +25 |-from foo import baz + 18 |+from foo import bar, baz +26 19 | +27 20 | # These will be combined, _with_ a trailing comma. +28 |-from module1 import member1 +29 21 | from module1 import ( + 22 |+ member1, +30 23 | member2, +31 24 | member3, +32 25 | ) +33 26 | +34 27 | # These will be combined, _with_ a trailing comma. +35 |-from module2 import member1, member2 +36 28 | from module2 import ( + 29 |+ member1, + 30 |+ member2, +37 31 | member3, +38 32 | ) + + 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 new file mode 100644 index 0000000000..db30dd9b29 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__match_case.py.snap @@ -0,0 +1,44 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +match_case.py:3:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | match 1: +2 | case 1: +3 | / import sys +4 | | import os +5 | | case 2: + | |_^ I001 +6 | import collections +7 | import abc + | + = help: Organize imports + +ℹ Fix +1 1 | match 1: +2 2 | case 1: + 3 |+ import os +3 4 | import sys +4 |- import os +5 5 | case 2: +6 6 | import collections +7 7 | import abc + +match_case.py:6:1: I001 [*] Import block is un-sorted or un-formatted + | +4 | import os +5 | case 2: +6 | / import collections +7 | | import abc + | + = help: Organize imports + +ℹ Fix +3 3 | import sys +4 4 | import os +5 5 | case 2: + 6 |+ import abc +6 7 | import collections +7 |- import abc + + 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 new file mode 100644 index 0000000000..6f71bf8af1 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__natural_order.py.snap @@ -0,0 +1,46 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +natural_order.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | + 1 | / import numpy1 + 2 | | import numpy10 + 3 | | import numpy2 + 4 | | from numpy import ( + 5 | | cos, + 6 | | int8, + 7 | | sin, + 8 | | int32, + 9 | | int64, +10 | | tan, +11 | | uint8, +12 | | uint16, +13 | | int16, +14 | | uint32, +15 | | uint64, +16 | | ) + | + = help: Organize imports + +ℹ Fix +1 1 | import numpy1 + 2 |+import numpy2 +2 3 | import numpy10 +3 |-import numpy2 +4 4 | from numpy import ( +5 5 | cos, +6 6 | int8, +7 |- sin, + 7 |+ int16, +8 8 | int32, +9 9 | int64, + 10 |+ sin, +10 11 | tan, +11 12 | uint8, +12 13 | uint16, +13 |- int16, +14 14 | uint32, +15 15 | uint64, +16 16 | ) + + 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 new file mode 100644 index 0000000000..0aadd1a9bb --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_detect_same_package.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +bar.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / import os +2 | | import pandas +3 | | import foo.baz + | + = help: Organize imports + +ℹ Fix +1 1 | import os +2 |-import pandas + 2 |+ +3 3 | import foo.baz + 4 |+import pandas + + 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 new file mode 100644 index 0000000000..fbf7979904 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py.snap @@ -0,0 +1,29 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +no_lines_before.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +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 + | + = help: Organize imports + +ℹ Fix +2 2 | +3 3 | from typing import Any +4 4 | +5 |-from requests import Session +6 |- +7 5 | from my_first_party import my_first_party_object + 6 |+from requests import Session +8 7 | +9 8 | from . import my_local_folder_object + + 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 new file mode 100644 index 0000000000..7ff05013aa --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_lines_before.py_no_lines_before.py.snap @@ -0,0 +1,30 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +no_lines_before.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +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 + | + = help: Organize imports + +ℹ Fix +1 1 | from __future__ import annotations +2 |- +3 2 | from typing import Any +4 |- + 3 |+from my_first_party import my_first_party_object +5 4 | from requests import Session +6 |- +7 |-from my_first_party import my_first_party_object +8 |- +9 5 | from . import my_local_folder_object + + 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 new file mode 100644 index 0000000000..eac16473f2 --- /dev/null +++ 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 @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +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 + | + = help: Organize imports + +ℹ Fix +1 1 | from __future__ import annotations +2 2 | from typing import Any + 3 |+ +3 4 | from . import my_local_folder_object + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_reorder_within_section.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_reorder_within_section.py.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_reorder_within_section.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + 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 new file mode 100644 index 0000000000..83c182e237 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__no_wrap_star.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +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 + | + = help: Organize imports + +ℹ Fix +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 + + 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 new file mode 100644 index 0000000000..08757f20e3 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type.py.snap @@ -0,0 +1,41 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +order_by_type.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | + 1 | / import StringIO + 2 | | import glob + 3 | | import os + 4 | | import shutil + 5 | | import tempfile + 6 | | import time + 7 | | from subprocess import PIPE, Popen, STDOUT + 8 | | from module import Class, CONSTANT, function, BASIC, Apple + 9 | | import foo +10 | | import FOO +11 | | import BAR +12 | | import bar + | + = help: Organize imports + +ℹ Fix +1 |-import StringIO +2 1 | import glob +3 2 | import os +4 3 | import shutil +5 4 | import tempfile +6 5 | import time +7 |-from subprocess import PIPE, Popen, STDOUT +8 |-from module import Class, CONSTANT, function, BASIC, Apple +9 |-import foo +10 |-import FOO + 6 |+from subprocess import PIPE, STDOUT, Popen + 7 |+ +11 8 | import BAR +12 9 | import bar + 10 |+import FOO + 11 |+import foo + 12 |+import StringIO + 13 |+from module import BASIC, CONSTANT, Apple, Class, function + + 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 new file mode 100644 index 0000000000..a1f081277a --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_false_order_by_type.py.snap @@ -0,0 +1,40 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +order_by_type.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | + 1 | / import StringIO + 2 | | import glob + 3 | | import os + 4 | | import shutil + 5 | | import tempfile + 6 | | import time + 7 | | from subprocess import PIPE, Popen, STDOUT + 8 | | from module import Class, CONSTANT, function, BASIC, Apple + 9 | | import foo +10 | | import FOO +11 | | import BAR +12 | | import bar + | + = help: Organize imports + +ℹ Fix +1 |-import StringIO +2 1 | import glob +3 2 | import os +4 3 | import shutil +5 4 | import tempfile +6 5 | import time +7 6 | from subprocess import PIPE, Popen, STDOUT +8 |-from module import Class, CONSTANT, function, BASIC, Apple +9 |-import foo +10 |-import FOO + 7 |+ +11 8 | import BAR +12 9 | import bar + 10 |+import FOO + 11 |+import foo + 12 |+import StringIO + 13 |+from module import Apple, BASIC, Class, CONSTANT, function + + 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 new file mode 100644 index 0000000000..6d4aade543 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_classes.py.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +order_by_type_with_custom_classes.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / from sklearn.svm import func, SVC, CONST, Klass +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 + | + = help: Organize imports + +ℹ Fix +1 |-from sklearn.svm import func, SVC, CONST, Klass +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 + 1 |+from subprocess import N_CLASS, PIPE, STDOUT, Popen + 2 |+ + 3 |+from module import BASIC, CLASS, CONSTANT, Apple, Class, function + 4 |+from sklearn.svm import CONST, SVC, Klass, func + 5 |+from torch.nn import A_CONSTANT, SELU, AClass + + 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 new file mode 100644 index 0000000000..26e53378de --- /dev/null +++ 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 @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +order_by_type_with_custom_classes.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / from sklearn.svm import func, SVC, CONST, Klass +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 + | + = help: Organize imports + +ℹ Fix +1 |-from sklearn.svm import func, SVC, CONST, Klass +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 + 1 |+from subprocess import PIPE, STDOUT, N_CLASS, Popen + 2 |+ + 3 |+from module import BASIC, CONSTANT, Apple, CLASS, Class, function + 4 |+from sklearn.svm import CONST, Klass, SVC, func + 5 |+from torch.nn import A_CONSTANT, AClass, SELU + + 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 new file mode 100644 index 0000000000..8003376029 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_constants.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +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 + | + = help: Organize imports + +ℹ Fix +1 |-from sklearn.svm import XYZ, func, variable, Const, Klass, constant +2 |-from subprocess import First, var, func, Class, konst, A_constant, Last, STDOUT + 1 |+from subprocess import STDOUT, A_constant, Class, First, Last, func, konst, var + 2 |+ + 3 |+from sklearn.svm import XYZ, Const, Klass, constant, func, variable + + 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 new file mode 100644 index 0000000000..86286e4a59 --- /dev/null +++ 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 @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +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 + | + = help: Organize imports + +ℹ Fix +1 |-from sklearn.svm import XYZ, func, variable, Const, Klass, constant +2 |-from subprocess import First, var, func, Class, konst, A_constant, Last, STDOUT + 1 |+from subprocess import A_constant, First, konst, Last, STDOUT, Class, func, var + 2 |+ + 3 |+from sklearn.svm import Const, constant, XYZ, Klass, func, variable + + 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 new file mode 100644 index 0000000000..9001677f11 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_by_type_with_custom_variables.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +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 + | + = help: Organize imports + +ℹ Fix +1 |-from sklearn.svm import VAR, Class, MyVar, CONST, abc +2 |-from subprocess import utils, var_ABC, Variable, Klass, CONSTANT, exe + 1 |+from subprocess import CONSTANT, Klass, Variable, exe, utils, var_ABC + 2 |+ + 3 |+from sklearn.svm import CONST, VAR, Class, MyVar, abc + + 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 new file mode 100644 index 0000000000..7931ce3bae --- /dev/null +++ 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 @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +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 + | + = help: Organize imports + +ℹ Fix +1 |-from sklearn.svm import VAR, Class, MyVar, CONST, abc +2 |-from subprocess import utils, var_ABC, Variable, Klass, CONSTANT, exe + 1 |+from subprocess import CONSTANT, Klass, exe, utils, var_ABC, Variable + 2 |+ + 3 |+from sklearn.svm import CONST, Class, abc, MyVar, VAR + + 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 new file mode 100644 index 0000000000..41791b9d4f --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__order_relative_imports_by_level.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +order_relative_imports_by_level.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / from .a import a +2 | | from ..a import a +3 | | from ..b import a +4 | | from .b import a + | + = help: Organize imports + +ℹ Fix +1 |-from .a import a +2 1 | from ..a import a +3 2 | from ..b import a + 3 |+from .a import a +4 4 | from .b import a + + 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 new file mode 100644 index 0000000000..04dbd34c38 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_comment_order.py.snap @@ -0,0 +1,33 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +preserve_comment_order.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | + 1 | / import io + 2 | | # Old MacDonald had a farm, + 3 | | # EIEIO + 4 | | # And on his farm he had a cow, + 5 | | # EIEIO + 6 | | # With a moo-moo here and a moo-moo there + 7 | | # Here a moo, there a moo, everywhere moo-moo + 8 | | # Old MacDonald had a farm, + 9 | | # EIEIO +10 | | from errno import EIO +11 | | import abc + | + = help: Organize imports + +ℹ Fix + 1 |+import abc +1 2 | import io + 3 |+ +2 4 | # Old MacDonald had a farm, +3 5 | # EIEIO +4 6 | # And on his farm he had a cow, +-------------------------------------------------------------------------------- +8 10 | # Old MacDonald had a farm, +9 11 | # EIEIO +10 12 | from errno import EIO +11 |-import abc + + 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 new file mode 100644 index 0000000000..e86696ab01 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_import_star.py.snap @@ -0,0 +1,28 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +preserve_import_star.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / from some_other_module import some_class +2 | | from some_other_module import * +3 | | # Above +4 | | from some_module import some_class # Aside +5 | | # Above +6 | | from some_module import * # Aside + | + = help: Organize imports + +ℹ Fix +1 |-from some_other_module import some_class +2 |-from some_other_module import * +3 1 | # Above +4 |-from some_module import some_class # Aside +5 |-# Above +6 2 | from some_module import * # Aside + 3 |+ + 4 |+# Above + 5 |+from some_module import some_class # Aside + 6 |+from some_other_module import * + 7 |+from some_other_module import some_class + + 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 new file mode 100644 index 0000000000..b66659dfd4 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_indentation.py.snap @@ -0,0 +1,42 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +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 +5 | import sys +6 | import os + | + = help: Organize imports + +ℹ Fix +1 1 | if True: + 2 |+ import os +2 3 | import sys +3 |- import os +4 4 | else: +5 5 | import sys +6 6 | import os + +preserve_indentation.py:5:1: I001 [*] Import block is un-sorted or un-formatted + | +3 | import os +4 | else: +5 | / import sys +6 | | import os + | + = help: Organize imports + +ℹ Fix +2 2 | import sys +3 3 | import os +4 4 | else: + 5 |+ import os +5 6 | import sys +6 |- import os + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_tabs.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_tabs.py.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_tabs.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_tabs_2.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_tabs_2.py.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__preserve_tabs_2.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + 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 new file mode 100644 index 0000000000..7a41bc5b7c --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__propagate_inline_comments_propagate_inline_comments.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +propagate_inline_comments.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / from mypackage.subpackage import ( # long comment that seems to be a problem +2 | | a_long_variable_name_that_causes_problems, +3 | | items, +4 | | ) + | + = help: Organize imports + +ℹ Fix +1 1 | from mypackage.subpackage import ( # long comment that seems to be a problem +2 2 | a_long_variable_name_that_causes_problems, +3 |- items, +4 3 | ) + 4 |+from mypackage.subpackage import items # long comment that seems to be a problem + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__relative_imports_order.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__relative_imports_order.py.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__relative_imports_order.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + 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 new file mode 100644 index 0000000000..3753a31cfa --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__reorder_within_section.py.snap @@ -0,0 +1,16 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +reorder_within_section.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / import sys +2 | | import os + | + = help: Organize imports + +ℹ Fix + 1 |+import os +1 2 | import sys +2 |-import os + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comment.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comment.py.snap new file mode 100644 index 0000000000..772e31afd8 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comment.py.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +comment.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` + | +1 | #!/usr/bin/env python3 + | I002 +2 | +3 | x = 1 + | + = help: Insert required import: `from future import annotations` + +ℹ Fix +1 1 | #!/usr/bin/env python3 + 2 |+from __future__ import annotations +2 3 | +3 4 | x = 1 + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comments_and_newlines.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comments_and_newlines.py.snap new file mode 100644 index 0000000000..4aa924b0de --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_comments_and_newlines.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +comments_and_newlines.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` + | +1 | #!/usr/bin/env python3 + | I002 +2 | # A copyright notice could go here + | + = help: Insert required import: `from future import annotations` + +ℹ Fix +2 2 | # A copyright notice could go here +3 3 | +4 4 | # A linter directive could go here + 5 |+from __future__ import annotations +5 6 | +6 7 | x = 1 + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring.py.snap new file mode 100644 index 0000000000..34d78ecd6c --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring.py.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` + | +1 | """Hello, world!""" + | I002 +2 | +3 | x = 1 + | + = help: Insert required import: `from future import annotations` + +ℹ Fix +1 1 | """Hello, world!""" + 2 |+from __future__ import annotations +2 3 | +3 4 | x = 1 + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring.pyi.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring.pyi.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring.pyi.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_only.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_only.py.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_only.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_continuation.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_continuation.py.snap new file mode 100644 index 0000000000..6211d34082 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_continuation.py.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +docstring_with_continuation.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` + | +1 | """Hello, world!"""; x = \ + | I002 +2 | 1; y = 2 + | + = help: Insert required import: `from future import annotations` + +ℹ Fix +1 |-"""Hello, world!"""; x = \ + 1 |+"""Hello, world!"""; from __future__ import annotations; x = \ +2 2 | 1; y = 2 + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_semicolon.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_semicolon.py.snap new file mode 100644 index 0000000000..46736a2bbb --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_docstring_with_semicolon.py.snap @@ -0,0 +1,15 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +docstring_with_semicolon.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` + | +1 | """Hello, world!"""; x = 1 + | I002 + | + = help: Insert required import: `from future import annotations` + +ℹ Fix +1 |-"""Hello, world!"""; x = 1 + 1 |+"""Hello, world!"""; from __future__ import annotations; x = 1 + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_empty.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_empty.py.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_empty.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_existing_import.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_existing_import.py.snap new file mode 100644 index 0000000000..067dfcc5ef --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_existing_import.py.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +existing_import.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` + | +1 | from __future__ import generator_stop + | I002 +2 | import os + | + = help: Insert required import: `from future import annotations` + +ℹ Fix + 1 |+from __future__ import annotations +1 2 | from __future__ import generator_stop +2 3 | import os + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_multiline_docstring.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_multiline_docstring.py.snap new file mode 100644 index 0000000000..37507cc1bf --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_multiline_docstring.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +multiline_docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` + | +1 | """a + | I002 +2 | b""" +3 | # b + | + = help: Insert required import: `from future import annotations` + +ℹ Fix +1 1 | """a +2 2 | b""" +3 3 | # b + 4 |+from __future__ import annotations +4 5 | import os + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_off.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_off.py.snap new file mode 100644 index 0000000000..c217a0ed14 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_off.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +off.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` + | +1 | # isort: off + | I002 +2 | +3 | x = 1 + | + = help: Insert required import: `from future import annotations` + +ℹ Fix +1 1 | # isort: off + 2 |+from __future__ import annotations +2 3 | +3 4 | x = 1 +4 5 | # isort: on + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comment.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comment.py.snap new file mode 100644 index 0000000000..bf0d44307f --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comment.py.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +comment.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` + | +1 | #!/usr/bin/env python3 + | I002 +2 | +3 | x = 1 + | + = help: Insert required import: `from future import annotations as _annotations` + +ℹ Fix +1 1 | #!/usr/bin/env python3 + 2 |+from __future__ import annotations as _annotations +2 3 | +3 4 | x = 1 + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comments_and_newlines.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comments_and_newlines.py.snap new file mode 100644 index 0000000000..5044313ec0 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_comments_and_newlines.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +comments_and_newlines.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` + | +1 | #!/usr/bin/env python3 + | I002 +2 | # A copyright notice could go here + | + = help: Insert required import: `from future import annotations as _annotations` + +ℹ Fix +2 2 | # A copyright notice could go here +3 3 | +4 4 | # A linter directive could go here + 5 |+from __future__ import annotations as _annotations +5 6 | +6 7 | x = 1 + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring.py.snap new file mode 100644 index 0000000000..24571fc589 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring.py.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` + | +1 | """Hello, world!""" + | I002 +2 | +3 | x = 1 + | + = help: Insert required import: `from future import annotations as _annotations` + +ℹ Fix +1 1 | """Hello, world!""" + 2 |+from __future__ import annotations as _annotations +2 3 | +3 4 | x = 1 + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring.pyi.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring.pyi.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring.pyi.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_only.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_only.py.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_only.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_continuation.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_continuation.py.snap new file mode 100644 index 0000000000..10e724dd0e --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_continuation.py.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +docstring_with_continuation.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` + | +1 | """Hello, world!"""; x = \ + | I002 +2 | 1; y = 2 + | + = help: Insert required import: `from future import annotations as _annotations` + +ℹ Fix +1 |-"""Hello, world!"""; x = \ + 1 |+"""Hello, world!"""; from __future__ import annotations as _annotations; x = \ +2 2 | 1; y = 2 + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_semicolon.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_semicolon.py.snap new file mode 100644 index 0000000000..955b81f9a1 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_docstring_with_semicolon.py.snap @@ -0,0 +1,15 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +docstring_with_semicolon.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` + | +1 | """Hello, world!"""; x = 1 + | I002 + | + = help: Insert required import: `from future import annotations as _annotations` + +ℹ Fix +1 |-"""Hello, world!"""; x = 1 + 1 |+"""Hello, world!"""; from __future__ import annotations as _annotations; x = 1 + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_empty.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_empty.py.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_empty.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_existing_import.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_existing_import.py.snap new file mode 100644 index 0000000000..489f7a3dc0 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_existing_import.py.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +existing_import.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` + | +1 | from __future__ import generator_stop + | I002 +2 | import os + | + = help: Insert required import: `from future import annotations as _annotations` + +ℹ Fix + 1 |+from __future__ import annotations as _annotations +1 2 | from __future__ import generator_stop +2 3 | import os + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_multiline_docstring.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_multiline_docstring.py.snap new file mode 100644 index 0000000000..a018f460aa --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_multiline_docstring.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +multiline_docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` + | +1 | """a + | I002 +2 | b""" +3 | # b + | + = help: Insert required import: `from future import annotations as _annotations` + +ℹ Fix +1 1 | """a +2 2 | b""" +3 3 | # b + 4 |+from __future__ import annotations as _annotations +4 5 | import os + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_off.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_off.py.snap new file mode 100644 index 0000000000..cd6edaecce --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_import_with_alias_off.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +off.py:1:1: I002 [*] Missing required import: `from __future__ import annotations as _annotations` + | +1 | # isort: off + | I002 +2 | +3 | x = 1 + | + = help: Insert required import: `from future import annotations as _annotations` + +ℹ Fix +1 1 | # isort: off + 2 |+from __future__ import annotations as _annotations +2 3 | +3 4 | x = 1 +4 5 | # isort: on + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_docstring.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_docstring.py.snap new file mode 100644 index 0000000000..daa796cd23 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_docstring.py.snap @@ -0,0 +1,34 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +docstring.py:1:1: I002 [*] Missing required import: `from __future__ import annotations` + | +1 | """Hello, world!""" + | I002 +2 | +3 | x = 1 + | + = help: Insert required import: `from future import annotations` + +ℹ Fix +1 1 | """Hello, world!""" + 2 |+from __future__ import annotations +2 3 | +3 4 | x = 1 + +docstring.py:1:1: I002 [*] Missing required import: `from __future__ import generator_stop` + | +1 | """Hello, world!""" + | I002 +2 | +3 | x = 1 + | + = help: Insert required import: `from future import generator_stop` + +ℹ Fix +1 1 | """Hello, world!""" + 2 |+from __future__ import generator_stop +2 3 | +3 4 | x = 1 + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_docstring.pyi.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_docstring.pyi.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_docstring.pyi.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_docstring_only.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_docstring_only.py.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_docstring_only.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_empty.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_empty.py.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__required_imports_empty.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__ruff_skip_file.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__ruff_skip_file.py.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__ruff_skip_file.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + 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 new file mode 100644 index 0000000000..003198715a --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__section_order_sections.py.snap @@ -0,0 +1,30 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / from __future__ import annotations +2 | | import os +3 | | import sys +4 | | import pytz +5 | | import django.settings +6 | | from library import foo +7 | | from . import local + | + = help: Organize imports + +ℹ Fix +1 1 | from __future__ import annotations + 2 |+ +2 3 | import os +3 4 | import sys + 5 |+ +4 6 | import pytz + 7 |+ +5 8 | import django.settings + 9 |+ +6 10 | from library import foo + 11 |+ +7 12 | from . import local + + 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 new file mode 100644 index 0000000000..99f06eeb47 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sections_sections.py.snap @@ -0,0 +1,30 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +sections.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / from __future__ import annotations +2 | | import os +3 | | import sys +4 | | import pytz +5 | | import django.settings +6 | | from library import foo +7 | | from . import local + | + = help: Organize imports + +ℹ Fix +1 1 | from __future__ import annotations + 2 |+ +2 3 | import os +3 4 | import sys + 5 |+ +4 6 | import pytz +5 |-import django.settings +6 7 | from library import foo + 8 |+ +7 9 | from . import local + 10 |+ + 11 |+import django.settings + + 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 new file mode 100644 index 0000000000..7327c38f45 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_first_party_imports.py.snap @@ -0,0 +1,25 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +separate_first_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / import sys +2 | | import leading_prefix +3 | | import numpy as np +4 | | import os +5 | | from leading_prefix import Class + | + = help: Organize imports + +ℹ Fix + 1 |+import os +1 2 | import sys + 3 |+ + 4 |+import numpy as np + 5 |+ +2 6 | import leading_prefix +3 |-import numpy as np +4 |-import os +5 7 | from leading_prefix import Class + + 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 new file mode 100644 index 0000000000..a2831e4716 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_future_imports.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +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 + | + = help: Organize imports + +ℹ Fix +1 |-import sys +2 |-import os +3 1 | from __future__ import annotations + 2 |+ + 3 |+import os + 4 |+import sys + + 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 new file mode 100644 index 0000000000..3fbc0ca966 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_local_folder_imports.py.snap @@ -0,0 +1,25 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +separate_local_folder_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / import sys +2 | | import ruff +3 | | import leading_prefix +4 | | import os +5 | | from . import leading_prefix + | + = help: Organize imports + +ℹ Fix + 1 |+import os +1 2 | import sys + 3 |+ +2 4 | import ruff + 5 |+ +3 6 | import leading_prefix +4 |-import os + 7 |+ +5 8 | from . import leading_prefix + + 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 new file mode 100644 index 0000000000..8165f0d39f --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__separate_third_party_imports.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +separate_third_party_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | +1 | / import pandas as pd +2 | | import sys +3 | | import numpy as np +4 | | import os + | + = help: Organize imports + +ℹ Fix +1 |-import pandas as pd + 1 |+import os +2 2 | import sys + 3 |+ +3 4 | import numpy as np +4 |-import os + 5 |+import pandas as pd + + 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 new file mode 100644 index 0000000000..1d1a6f99c5 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__skip.py.snap @@ -0,0 +1,68 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +skip.py:20:1: I001 [*] Import block is un-sorted or un-formatted + | +18 | import sys +19 | import os # isort: skip +20 | / import collections +21 | | import abc +22 | | + | |_^ I001 +23 | +24 | def f(): + | + = help: Organize imports + +ℹ Fix +17 17 | def f(): +18 18 | import sys +19 19 | import os # isort: skip + 20 |+ import abc +20 21 | import collections +21 |- import abc +22 22 | +23 23 | +24 24 | def f(): + +skip.py:27:1: I001 [*] Import block is un-sorted or un-formatted + | +25 | import sys +26 | import os # isort:skip +27 | / import collections +28 | | import abc +29 | | + | |_^ I001 +30 | +31 | def f(): + | + = help: Organize imports + +ℹ Fix +24 24 | def f(): +25 25 | import sys +26 26 | import os # isort:skip + 27 |+ import abc +27 28 | import collections +28 |- import abc +29 29 | +30 30 | +31 31 | def f(): + +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 + +ℹ Fix +31 31 | def f(): +32 32 | import sys; import os # isort:skip +33 33 | import sys; import os # isort:skip # isort:skip +34 |- import sys; import os + 34 |+ import os + 35 |+ import sys + + 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 new file mode 100644 index 0000000000..a898a9cd08 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__sort_similar_imports.py.snap @@ -0,0 +1,77 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +sort_similar_imports.py:1:1: I001 [*] Import block is un-sorted or un-formatted + | + 1 | / from a import b + 2 | | from a import BAD as DEF + 3 | | from a import B + 4 | | from a import Boo as DEF + 5 | | from a import B as Abc + 6 | | from a import B as A + 7 | | from a import B as DEF + 8 | | from a import b as a + 9 | | from a import b as x +10 | | from a import b as c +11 | | from b import c +12 | | from a import b as d +13 | | from a import b as y +14 | | from b import C +15 | | from b import c as d +16 | | +17 | | import A +18 | | import a +19 | | import b +20 | | import B +21 | | +22 | | import x as y +23 | | import x as A +24 | | import x as Y +25 | | import x +26 | | import x as a + | + = help: Organize imports + +ℹ Fix +1 |-from a import b + 1 |+import A + 2 |+import a + 3 |+import B + 4 |+import b + 5 |+import x + 6 |+import x as A + 7 |+import x as Y + 8 |+import x as a + 9 |+import x as y +2 10 | from a import BAD as DEF +3 |-from a import B +4 |-from a import Boo as DEF + 11 |+from a import B, b + 12 |+from a import B as A +5 13 | from a import B as Abc +6 |-from a import B as A +7 14 | from a import B as DEF + 15 |+from a import Boo as DEF +8 16 | from a import b as a +9 |-from a import b as x +10 17 | from a import b as c +11 |-from b import c +12 18 | from a import b as d + 19 |+from a import b as x +13 20 | from a import b as y +14 |-from b import C + 21 |+from b import C, c +15 22 | from b import c as d +16 |- +17 |-import A +18 |-import a +19 |-import b +20 |-import B +21 |- +22 |-import x as y +23 |-import x as A +24 |-import x as Y +25 |-import x +26 |-import x as a + + 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 new file mode 100644 index 0000000000..e143bee69a --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split.py.snap @@ -0,0 +1,67 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +split.py:15:1: I001 [*] Import block is un-sorted or un-formatted + | +14 | if True: +15 | / import C +16 | | import A +17 | | + | |_^ I001 +18 | # isort: split + | + = help: Organize imports + +ℹ Fix +12 12 | import b +13 13 | +14 14 | if True: + 15 |+ import A +15 16 | import C +16 |- import A +17 17 | +18 18 | # isort: split +19 19 | + +split.py:20:1: I001 [*] Import block is un-sorted or un-formatted + | +18 | # isort: split +19 | +20 | / import D +21 | | import B +22 | | + | |_^ I001 +23 | +24 | import e + | + = help: Organize imports + +ℹ Fix +17 17 | +18 18 | # isort: split +19 19 | + 20 |+ import B +20 21 | import D +21 |- import B +22 22 | +23 23 | +24 24 | import e + +split.py:30:1: I001 [*] Import block is un-sorted or un-formatted + | +28 | # isort: split +29 | +30 | / import d +31 | | import c + | + = help: Organize imports + +ℹ Fix +27 27 | # isort: split +28 28 | # isort: split +29 29 | + 30 |+import c +30 31 | import d +31 |-import c + + 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 new file mode 100644 index 0000000000..1a0bb9dd5c --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__split_on_trailing_comma_magic_trailing_comma.py.snap @@ -0,0 +1,95 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +magic_trailing_comma.py:2:1: I001 [*] Import block is un-sorted or un-formatted + | + 1 | # This has a magic trailing comma, will be sorted, but not rolled into one line + 2 | / from sys import ( + 3 | | stderr, + 4 | | argv, + 5 | | stdout, + 6 | | exit, + 7 | | ) + 8 | | + 9 | | # No magic comma, this will be rolled into one line. +10 | | from os import ( +11 | | path, +12 | | environ, +13 | | execl, +14 | | execv +15 | | ) +16 | | +17 | | from glob import ( +18 | | glob, +19 | | iglob, +20 | | escape, # Ends with a comment, should still treat as magic trailing comma. +21 | | ) +22 | | +23 | | # These will be combined, but without a trailing comma. +24 | | from foo import bar +25 | | from foo import baz +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 | | +34 | | # These will be combined, _with_ a trailing comma. +35 | | from module2 import member1, member2 +36 | | from module2 import ( +37 | | member3, +38 | | ) + | + = help: Organize imports + +ℹ Fix +1 1 | # This has a magic trailing comma, will be sorted, but not rolled into one line +2 |-from sys import ( +3 |- stderr, +4 |- argv, +5 |- stdout, +6 |- exit, +7 |-) +8 |- +9 |-# No magic comma, this will be rolled into one line. +10 |-from os import ( +11 |- path, +12 |- environ, +13 |- execl, +14 |- execv +15 |-) +16 |- +17 2 | from glob import ( + 3 |+ escape, # Ends with a comment, should still treat as magic trailing comma. +18 4 | glob, +19 5 | iglob, +20 |- escape, # Ends with a comment, should still treat as magic trailing comma. +21 6 | ) +22 7 | + 8 |+# No magic comma, this will be rolled into one line. + 9 |+from os import environ, execl, execv, path + 10 |+from sys import argv, exit, stderr, stdout + 11 |+ +23 12 | # These will be combined, but without a trailing comma. +24 |-from foo import bar +25 |-from foo import baz + 13 |+from foo import bar, baz +26 14 | +27 15 | # These will be combined, _with_ a trailing comma. +28 |-from module1 import member1 +29 |-from module1 import ( +30 |- member2, +31 |- member3, +32 |-) + 16 |+from module1 import member1, member2, member3 +33 17 | +34 18 | # These will be combined, _with_ a trailing comma. +35 |-from module2 import member1, member2 +36 |-from module2 import ( +37 |- member3, +38 |-) + 19 |+from module2 import member1, member2, member3 + + 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 new file mode 100644 index 0000000000..c8eaf17cc2 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__star_before_others.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +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 * + | + = help: Organize imports + +ℹ Fix +1 1 | from .logging import config_logging + 2 |+from .settings import * +2 3 | from .settings import ENV +3 |-from .settings import * + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.py.snap new file mode 100644 index 0000000000..60e02f76e4 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.py.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +docstring.py:1:1: I002 [*] Missing required import: `import os` + | +1 | """Hello, world!""" + | I002 +2 | +3 | x = 1 + | + = help: Insert required import: `import os` + +ℹ Fix +1 1 | """Hello, world!""" + 2 |+import os +2 3 | +3 4 | x = 1 + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.pyi.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.pyi.snap new file mode 100644 index 0000000000..9035148f31 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring.pyi.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +docstring.pyi:1:1: I002 [*] Missing required import: `import os` + | +1 | """Hello, world!""" + | I002 +2 | +3 | x = 1 + | + = help: Insert required import: `import os` + +ℹ Fix +1 1 | """Hello, world!""" + 2 |+import os +2 3 | +3 4 | x = 1 + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring_only.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring_only.py.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_docstring_only.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_empty.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_empty.py.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__straight_required_import_empty.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + 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 new file mode 100644 index 0000000000..3f86e235fe --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__trailing_suffix.py.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- +trailing_suffix.py:1:1: I001 Import block is un-sorted or un-formatted + | +1 | / import sys +2 | | import os; x = 1 + | |_________^ I001 +3 | +4 | if True: + | + = help: Organize imports + +trailing_suffix.py:5:5: I001 Import block is un-sorted or un-formatted + | +4 | if True: +5 | import sys + | _____^ +6 | | import os; x = 1 + | |_____________^ I001 + | + = help: Organize imports + + diff --git a/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__type_comments.py.snap b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__type_comments.py.snap new file mode 100644 index 0000000000..ed369f0fd6 --- /dev/null +++ b/crates/ruff_linter/src/rules/isort/snapshots/ruff_linter__rules__isort__tests__type_comments.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/isort/mod.rs +--- + diff --git a/crates/ruff/src/rules/isort/sorting.rs b/crates/ruff_linter/src/rules/isort/sorting.rs similarity index 100% rename from crates/ruff/src/rules/isort/sorting.rs rename to crates/ruff_linter/src/rules/isort/sorting.rs diff --git a/crates/ruff/src/rules/isort/split.rs b/crates/ruff_linter/src/rules/isort/split.rs similarity index 100% rename from crates/ruff/src/rules/isort/split.rs rename to crates/ruff_linter/src/rules/isort/split.rs diff --git a/crates/ruff/src/rules/isort/types.rs b/crates/ruff_linter/src/rules/isort/types.rs similarity index 100% rename from crates/ruff/src/rules/isort/types.rs rename to crates/ruff_linter/src/rules/isort/types.rs diff --git a/crates/ruff/src/rules/mccabe/mod.rs b/crates/ruff_linter/src/rules/mccabe/mod.rs similarity index 100% rename from crates/ruff/src/rules/mccabe/mod.rs rename to crates/ruff_linter/src/rules/mccabe/mod.rs diff --git a/crates/ruff/src/rules/mccabe/rules/function_is_too_complex.rs b/crates/ruff_linter/src/rules/mccabe/rules/function_is_too_complex.rs similarity index 100% rename from crates/ruff/src/rules/mccabe/rules/function_is_too_complex.rs rename to crates/ruff_linter/src/rules/mccabe/rules/function_is_too_complex.rs diff --git a/crates/ruff/src/rules/mccabe/rules/mod.rs b/crates/ruff_linter/src/rules/mccabe/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/mccabe/rules/mod.rs rename to crates/ruff_linter/src/rules/mccabe/rules/mod.rs diff --git a/crates/ruff/src/rules/mccabe/settings.rs b/crates/ruff_linter/src/rules/mccabe/settings.rs similarity index 100% rename from crates/ruff/src/rules/mccabe/settings.rs rename to crates/ruff_linter/src/rules/mccabe/settings.rs 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 new file mode 100644 index 0000000000..92a113461e --- /dev/null +++ b/crates/ruff_linter/src/rules/mccabe/snapshots/ruff_linter__rules__mccabe__tests__max_complexity_0.snap @@ -0,0 +1,200 @@ +--- +source: crates/ruff_linter/src/rules/mccabe/mod.rs +--- +C901.py:2:5: C901 `trivial` is too complex (1 > 0) + | +1 | # Complexity = 1 +2 | def trivial(): + | ^^^^^^^ C901 +3 | pass + | + +C901.py:7:5: C901 `expr_as_statement` is too complex (1 > 0) + | +6 | # Complexity = 1 +7 | def expr_as_statement(): + | ^^^^^^^^^^^^^^^^^ C901 +8 | 0xF00D + | + +C901.py:12:5: C901 `sequential` is too complex (1 > 0) + | +11 | # Complexity = 1 +12 | def sequential(n): + | ^^^^^^^^^^ C901 +13 | k = n + 4 +14 | s = k + n + | + +C901.py:19:5: C901 `if_elif_else_dead_path` is too complex (3 > 0) + | +18 | # Complexity = 3 +19 | def if_elif_else_dead_path(n): + | ^^^^^^^^^^^^^^^^^^^^^^ C901 +20 | if n > 3: +21 | return "bigger than three" + | + +C901.py:29:5: C901 `nested_ifs` is too complex (3 > 0) + | +28 | # Complexity = 3 +29 | def nested_ifs(): + | ^^^^^^^^^^ C901 +30 | if n > 3: +31 | if n > 4: + | + +C901.py:40:5: C901 `for_loop` is too complex (2 > 0) + | +39 | # Complexity = 2 +40 | def for_loop(): + | ^^^^^^^^ C901 +41 | for i in range(10): +42 | print(i) + | + +C901.py:46:5: C901 `for_else` is too complex (2 > 0) + | +45 | # Complexity = 2 +46 | def for_else(mylist): + | ^^^^^^^^ C901 +47 | for i in mylist: +48 | print(i) + | + +C901.py:54:5: C901 `recursive` is too complex (2 > 0) + | +53 | # Complexity = 2 +54 | def recursive(n): + | ^^^^^^^^^ C901 +55 | if n > 4: +56 | return f(n - 1) + | + +C901.py:62:5: C901 `nested_functions` is too complex (3 > 0) + | +61 | # Complexity = 3 +62 | def nested_functions(): + | ^^^^^^^^^^^^^^^^ C901 +63 | def a(): +64 | def b(): + | + +C901.py:63:9: C901 `a` is too complex (2 > 0) + | +61 | # Complexity = 3 +62 | def nested_functions(): +63 | def a(): + | ^ C901 +64 | def b(): +65 | pass + | + +C901.py:64:13: C901 `b` is too complex (1 > 0) + | +62 | def nested_functions(): +63 | def a(): +64 | def b(): + | ^ C901 +65 | pass + | + +C901.py:73:5: C901 `try_else` is too complex (4 > 0) + | +72 | # Complexity = 4 +73 | def try_else(): + | ^^^^^^^^ C901 +74 | try: +75 | print(1) + | + +C901.py:85:5: C901 `nested_try_finally` is too complex (1 > 0) + | +84 | # Complexity = 3 +85 | def nested_try_finally(): + | ^^^^^^^^^^^^^^^^^^ C901 +86 | try: +87 | try: + | + +C901.py:96:11: C901 `foobar` is too complex (3 > 0) + | +95 | # Complexity = 3 +96 | async def foobar(a, b, c): + | ^^^^^^ C901 +97 | await whatever(a, b, c) +98 | if await b: + | + +C901.py:107:5: C901 `annotated_assign` is too complex (1 > 0) + | +106 | # Complexity = 1 +107 | def annotated_assign(): + | ^^^^^^^^^^^^^^^^ C901 +108 | x: Any = None + | + +C901.py:113:9: C901 `handle` is too complex (9 > 0) + | +111 | # Complexity = 9 +112 | class Class: +113 | def handle(self, *args, **options): + | ^^^^^^ C901 +114 | if args: +115 | return + | + +C901.py:118:17: C901 `a` is too complex (1 > 0) + | +117 | class ServiceProvider: +118 | def a(self): + | ^ C901 +119 | pass + | + +C901.py:121:17: C901 `b` is too complex (2 > 0) + | +119 | pass +120 | +121 | def b(self, data): + | ^ C901 +122 | if not args: +123 | pass + | + +C901.py:126:17: C901 `c` is too complex (1 > 0) + | +125 | class Logger: +126 | def c(*args, **kwargs): + | ^ C901 +127 | pass + | + +C901.py:129:17: C901 `error` is too complex (1 > 0) + | +127 | pass +128 | +129 | def error(self, message): + | ^^^^^ C901 +130 | pass + | + +C901.py:132:17: C901 `info` is too complex (1 > 0) + | +130 | pass +131 | +132 | def info(self, message): + | ^^^^ C901 +133 | pass + | + +C901.py:135:17: C901 `exception` is too complex (1 > 0) + | +133 | pass +134 | +135 | def exception(self): + | ^^^^^^^^^ C901 +136 | pass + | + + diff --git a/crates/ruff_linter/src/rules/mccabe/snapshots/ruff_linter__rules__mccabe__tests__max_complexity_10.snap b/crates/ruff_linter/src/rules/mccabe/snapshots/ruff_linter__rules__mccabe__tests__max_complexity_10.snap new file mode 100644 index 0000000000..59f3ea53f2 --- /dev/null +++ b/crates/ruff_linter/src/rules/mccabe/snapshots/ruff_linter__rules__mccabe__tests__max_complexity_10.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/mccabe/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/mccabe/snapshots/ruff_linter__rules__mccabe__tests__max_complexity_3.snap b/crates/ruff_linter/src/rules/mccabe/snapshots/ruff_linter__rules__mccabe__tests__max_complexity_3.snap new file mode 100644 index 0000000000..cd1c01d173 --- /dev/null +++ b/crates/ruff_linter/src/rules/mccabe/snapshots/ruff_linter__rules__mccabe__tests__max_complexity_3.snap @@ -0,0 +1,23 @@ +--- +source: crates/ruff_linter/src/rules/mccabe/mod.rs +--- +C901.py:73:5: C901 `try_else` is too complex (4 > 3) + | +72 | # Complexity = 4 +73 | def try_else(): + | ^^^^^^^^ C901 +74 | try: +75 | print(1) + | + +C901.py:113:9: C901 `handle` is too complex (9 > 3) + | +111 | # Complexity = 9 +112 | class Class: +113 | def handle(self, *args, **options): + | ^^^^^^ C901 +114 | if args: +115 | return + | + + diff --git a/crates/ruff/src/rules/mod.rs b/crates/ruff_linter/src/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/mod.rs rename to crates/ruff_linter/src/rules/mod.rs diff --git a/crates/ruff/src/rules/numpy/mod.rs b/crates/ruff_linter/src/rules/numpy/mod.rs similarity index 100% rename from crates/ruff/src/rules/numpy/mod.rs rename to crates/ruff_linter/src/rules/numpy/mod.rs diff --git a/crates/ruff/src/rules/numpy/rules/deprecated_function.rs b/crates/ruff_linter/src/rules/numpy/rules/deprecated_function.rs similarity index 100% rename from crates/ruff/src/rules/numpy/rules/deprecated_function.rs rename to crates/ruff_linter/src/rules/numpy/rules/deprecated_function.rs diff --git a/crates/ruff/src/rules/numpy/rules/deprecated_type_alias.rs b/crates/ruff_linter/src/rules/numpy/rules/deprecated_type_alias.rs similarity index 100% rename from crates/ruff/src/rules/numpy/rules/deprecated_type_alias.rs rename to crates/ruff_linter/src/rules/numpy/rules/deprecated_type_alias.rs diff --git a/crates/ruff/src/rules/numpy/rules/legacy_random.rs b/crates/ruff_linter/src/rules/numpy/rules/legacy_random.rs similarity index 100% rename from crates/ruff/src/rules/numpy/rules/legacy_random.rs rename to crates/ruff_linter/src/rules/numpy/rules/legacy_random.rs diff --git a/crates/ruff/src/rules/numpy/rules/mod.rs b/crates/ruff_linter/src/rules/numpy/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/numpy/rules/mod.rs rename to crates/ruff_linter/src/rules/numpy/rules/mod.rs 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 new file mode 100644 index 0000000000..1d8aa9dc02 --- /dev/null +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-function_NPY003.py.snap @@ -0,0 +1,225 @@ +--- +source: crates/ruff_linter/src/rules/numpy/mod.rs +--- +NPY003.py:4:5: NPY003 [*] `np.round_` is deprecated; use `np.round` instead + | +2 | import numpy as np +3 | +4 | np.round_(np.random.rand(5, 5), 2) + | ^^^^^^^^^ NPY003 +5 | np.product(np.random.rand(5, 5)) +6 | np.cumproduct(np.random.rand(5, 5)) + | + = help: Replace with `np.round` + +ℹ Suggested fix +1 1 | def func(): +2 2 | import numpy as np +3 3 | +4 |- np.round_(np.random.rand(5, 5), 2) + 4 |+ np.round(np.random.rand(5, 5), 2) +5 5 | np.product(np.random.rand(5, 5)) +6 6 | np.cumproduct(np.random.rand(5, 5)) +7 7 | np.sometrue(np.random.rand(5, 5)) + +NPY003.py:5:5: NPY003 [*] `np.product` is deprecated; use `np.prod` instead + | +4 | np.round_(np.random.rand(5, 5), 2) +5 | np.product(np.random.rand(5, 5)) + | ^^^^^^^^^^ NPY003 +6 | np.cumproduct(np.random.rand(5, 5)) +7 | np.sometrue(np.random.rand(5, 5)) + | + = help: Replace with `np.prod` + +ℹ Suggested fix +2 2 | import numpy as np +3 3 | +4 4 | np.round_(np.random.rand(5, 5), 2) +5 |- np.product(np.random.rand(5, 5)) + 5 |+ np.prod(np.random.rand(5, 5)) +6 6 | np.cumproduct(np.random.rand(5, 5)) +7 7 | np.sometrue(np.random.rand(5, 5)) +8 8 | np.alltrue(np.random.rand(5, 5)) + +NPY003.py:6:5: NPY003 [*] `np.cumproduct` is deprecated; use `np.cumprod` instead + | +4 | np.round_(np.random.rand(5, 5), 2) +5 | np.product(np.random.rand(5, 5)) +6 | np.cumproduct(np.random.rand(5, 5)) + | ^^^^^^^^^^^^^ NPY003 +7 | np.sometrue(np.random.rand(5, 5)) +8 | np.alltrue(np.random.rand(5, 5)) + | + = help: Replace with `np.cumprod` + +ℹ Suggested fix +3 3 | +4 4 | np.round_(np.random.rand(5, 5), 2) +5 5 | np.product(np.random.rand(5, 5)) +6 |- np.cumproduct(np.random.rand(5, 5)) + 6 |+ np.cumprod(np.random.rand(5, 5)) +7 7 | np.sometrue(np.random.rand(5, 5)) +8 8 | np.alltrue(np.random.rand(5, 5)) +9 9 | + +NPY003.py:7:5: NPY003 [*] `np.sometrue` is deprecated; use `np.any` instead + | +5 | np.product(np.random.rand(5, 5)) +6 | np.cumproduct(np.random.rand(5, 5)) +7 | np.sometrue(np.random.rand(5, 5)) + | ^^^^^^^^^^^ NPY003 +8 | np.alltrue(np.random.rand(5, 5)) + | + = help: Replace with `np.any` + +ℹ Suggested fix +4 4 | np.round_(np.random.rand(5, 5), 2) +5 5 | np.product(np.random.rand(5, 5)) +6 6 | np.cumproduct(np.random.rand(5, 5)) +7 |- np.sometrue(np.random.rand(5, 5)) + 7 |+ np.any(np.random.rand(5, 5)) +8 8 | np.alltrue(np.random.rand(5, 5)) +9 9 | +10 10 | + +NPY003.py:8:5: NPY003 [*] `np.alltrue` is deprecated; use `np.all` instead + | +6 | np.cumproduct(np.random.rand(5, 5)) +7 | np.sometrue(np.random.rand(5, 5)) +8 | np.alltrue(np.random.rand(5, 5)) + | ^^^^^^^^^^ NPY003 + | + = help: Replace with `np.all` + +ℹ Suggested fix +5 5 | np.product(np.random.rand(5, 5)) +6 6 | np.cumproduct(np.random.rand(5, 5)) +7 7 | np.sometrue(np.random.rand(5, 5)) +8 |- np.alltrue(np.random.rand(5, 5)) + 8 |+ np.all(np.random.rand(5, 5)) +9 9 | +10 10 | +11 11 | def func(): + +NPY003.py:14:5: NPY003 [*] `np.round_` is deprecated; use `np.round` instead + | +12 | from numpy import round_, product, cumproduct, sometrue, alltrue +13 | +14 | round_(np.random.rand(5, 5), 2) + | ^^^^^^ NPY003 +15 | product(np.random.rand(5, 5)) +16 | cumproduct(np.random.rand(5, 5)) + | + = help: Replace with `np.round` + +ℹ Suggested fix + 1 |+from numpy import round +1 2 | def func(): +2 3 | import numpy as np +3 4 | +-------------------------------------------------------------------------------- +11 12 | def func(): +12 13 | from numpy import round_, product, cumproduct, sometrue, alltrue +13 14 | +14 |- round_(np.random.rand(5, 5), 2) + 15 |+ round(np.random.rand(5, 5), 2) +15 16 | product(np.random.rand(5, 5)) +16 17 | cumproduct(np.random.rand(5, 5)) +17 18 | sometrue(np.random.rand(5, 5)) + +NPY003.py:15:5: NPY003 [*] `np.product` is deprecated; use `np.prod` instead + | +14 | round_(np.random.rand(5, 5), 2) +15 | product(np.random.rand(5, 5)) + | ^^^^^^^ NPY003 +16 | cumproduct(np.random.rand(5, 5)) +17 | sometrue(np.random.rand(5, 5)) + | + = help: Replace with `np.prod` + +ℹ Suggested fix + 1 |+from numpy import prod +1 2 | def func(): +2 3 | import numpy as np +3 4 | +-------------------------------------------------------------------------------- +12 13 | from numpy import round_, product, cumproduct, sometrue, alltrue +13 14 | +14 15 | round_(np.random.rand(5, 5), 2) +15 |- product(np.random.rand(5, 5)) + 16 |+ prod(np.random.rand(5, 5)) +16 17 | cumproduct(np.random.rand(5, 5)) +17 18 | sometrue(np.random.rand(5, 5)) +18 19 | alltrue(np.random.rand(5, 5)) + +NPY003.py:16:5: NPY003 [*] `np.cumproduct` is deprecated; use `np.cumprod` instead + | +14 | round_(np.random.rand(5, 5), 2) +15 | product(np.random.rand(5, 5)) +16 | cumproduct(np.random.rand(5, 5)) + | ^^^^^^^^^^ NPY003 +17 | sometrue(np.random.rand(5, 5)) +18 | alltrue(np.random.rand(5, 5)) + | + = help: Replace with `np.cumprod` + +ℹ Suggested fix + 1 |+from numpy import cumprod +1 2 | def func(): +2 3 | import numpy as np +3 4 | +-------------------------------------------------------------------------------- +13 14 | +14 15 | round_(np.random.rand(5, 5), 2) +15 16 | product(np.random.rand(5, 5)) +16 |- cumproduct(np.random.rand(5, 5)) + 17 |+ cumprod(np.random.rand(5, 5)) +17 18 | sometrue(np.random.rand(5, 5)) +18 19 | alltrue(np.random.rand(5, 5)) + +NPY003.py:17:5: NPY003 [*] `np.sometrue` is deprecated; use `np.any` instead + | +15 | product(np.random.rand(5, 5)) +16 | cumproduct(np.random.rand(5, 5)) +17 | sometrue(np.random.rand(5, 5)) + | ^^^^^^^^ NPY003 +18 | alltrue(np.random.rand(5, 5)) + | + = help: Replace with `np.any` + +ℹ Suggested fix + 1 |+from numpy import any +1 2 | def func(): +2 3 | import numpy as np +3 4 | +-------------------------------------------------------------------------------- +14 15 | round_(np.random.rand(5, 5), 2) +15 16 | product(np.random.rand(5, 5)) +16 17 | cumproduct(np.random.rand(5, 5)) +17 |- sometrue(np.random.rand(5, 5)) + 18 |+ any(np.random.rand(5, 5)) +18 19 | alltrue(np.random.rand(5, 5)) + +NPY003.py:18:5: NPY003 [*] `np.alltrue` is deprecated; use `np.all` instead + | +16 | cumproduct(np.random.rand(5, 5)) +17 | sometrue(np.random.rand(5, 5)) +18 | alltrue(np.random.rand(5, 5)) + | ^^^^^^^ NPY003 + | + = help: Replace with `np.all` + +ℹ Suggested fix + 1 |+from numpy import all +1 2 | def func(): +2 3 | import numpy as np +3 4 | +-------------------------------------------------------------------------------- +15 16 | product(np.random.rand(5, 5)) +16 17 | cumproduct(np.random.rand(5, 5)) +17 18 | sometrue(np.random.rand(5, 5)) +18 |- alltrue(np.random.rand(5, 5)) + 19 |+ all(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 new file mode 100644 index 0000000000..f83b5e3a32 --- /dev/null +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-deprecated-type-alias_NPY001.py.snap @@ -0,0 +1,156 @@ +--- +source: crates/ruff_linter/src/rules/numpy/mod.rs +--- +NPY001.py:6:1: NPY001 [*] Type alias `np.bool` is deprecated, replace with builtin type + | +5 | # Error +6 | npy.bool + | ^^^^^^^^ NPY001 +7 | npy.int + | + = help: Replace `np.bool` with builtin type + +ℹ Suggested fix +3 3 | import numpy +4 4 | +5 5 | # Error +6 |-npy.bool + 6 |+bool +7 7 | npy.int +8 8 | +9 9 | if dtype == np.object: + +NPY001.py:7:1: NPY001 [*] Type alias `np.int` is deprecated, replace with builtin type + | +5 | # Error +6 | npy.bool +7 | npy.int + | ^^^^^^^ NPY001 +8 | +9 | if dtype == np.object: + | + = help: Replace `np.int` with builtin type + +ℹ Suggested fix +4 4 | +5 5 | # Error +6 6 | npy.bool +7 |-npy.int + 7 |+int +8 8 | +9 9 | if dtype == np.object: +10 10 | ... + +NPY001.py:9:13: NPY001 [*] Type alias `np.object` is deprecated, replace with builtin type + | + 7 | npy.int + 8 | + 9 | if dtype == np.object: + | ^^^^^^^^^ NPY001 +10 | ... + | + = help: Replace `np.object` with builtin type + +ℹ Suggested fix +6 6 | npy.bool +7 7 | npy.int +8 8 | +9 |-if dtype == np.object: + 9 |+if dtype == object: +10 10 | ... +11 11 | +12 12 | result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.long]) + +NPY001.py:12:72: NPY001 [*] Type alias `np.int` is deprecated, replace with builtin type + | +10 | ... +11 | +12 | result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.long]) + | ^^^^^^ NPY001 +13 | +14 | pdf = pd.DataFrame( + | + = help: Replace `np.int` with builtin type + +ℹ Suggested fix +9 9 | if dtype == np.object: +10 10 | ... +11 11 | +12 |-result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.long]) + 12 |+result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, int, np.long]) +13 13 | +14 14 | pdf = pd.DataFrame( +15 15 | data=[[1, 2, 3]], + +NPY001.py:12:80: NPY001 [*] Type alias `np.long` is deprecated, replace with builtin type + | +10 | ... +11 | +12 | result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.long]) + | ^^^^^^^ NPY001 +13 | +14 | pdf = pd.DataFrame( + | + = help: Replace `np.long` with builtin type + +ℹ Suggested fix +9 9 | if dtype == np.object: +10 10 | ... +11 11 | +12 |-result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.long]) + 12 |+result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, int]) +13 13 | +14 14 | pdf = pd.DataFrame( +15 15 | data=[[1, 2, 3]], + +NPY001.py:17:11: NPY001 [*] Type alias `np.object` is deprecated, replace with builtin type + | +15 | data=[[1, 2, 3]], +16 | columns=["a", "b", "c"], +17 | dtype=numpy.object, + | ^^^^^^^^^^^^ NPY001 +18 | ) + | + = help: Replace `np.object` with builtin type + +ℹ Suggested fix +14 14 | pdf = pd.DataFrame( +15 15 | data=[[1, 2, 3]], +16 16 | columns=["a", "b", "c"], +17 |- dtype=numpy.object, + 17 |+ dtype=object, +18 18 | ) +19 19 | +20 20 | _ = arr.astype(np.int) + +NPY001.py:20:16: NPY001 [*] Type alias `np.int` is deprecated, replace with builtin type + | +18 | ) +19 | +20 | _ = arr.astype(np.int) + | ^^^^^^ NPY001 +21 | +22 | # Regression test for: https://github.com/astral-sh/ruff/issues/6952 + | + = help: Replace `np.int` with builtin type + +ℹ Suggested fix +17 17 | dtype=numpy.object, +18 18 | ) +19 19 | +20 |-_ = arr.astype(np.int) + 20 |+_ = arr.astype(int) +21 21 | +22 22 | # Regression test for: https://github.com/astral-sh/ruff/issues/6952 +23 23 | from numpy import float + +NPY001.py:25:1: NPY001 Type alias `np.float` is deprecated, replace with builtin type + | +23 | from numpy import float +24 | +25 | float(1) + | ^^^^^ NPY001 + | + = help: Replace `np.float` with builtin type + + 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 new file mode 100644 index 0000000000..b6f40de745 --- /dev/null +++ b/crates/ruff_linter/src/rules/numpy/snapshots/ruff_linter__rules__numpy__tests__numpy-legacy-random_NPY002.py.snap @@ -0,0 +1,498 @@ +--- +source: crates/ruff_linter/src/rules/numpy/mod.rs +--- +NPY002.py:12:8: NPY002 Replace legacy `np.random.standard_normal` call with `np.random.Generator` + | +10 | from numpy import random +11 | +12 | vals = random.standard_normal(10) + | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 +13 | more_vals = random.standard_normal(10) +14 | numbers = random.integers(high, size=5) + | + +NPY002.py:13:13: NPY002 Replace legacy `np.random.standard_normal` call with `np.random.Generator` + | +12 | vals = random.standard_normal(10) +13 | more_vals = random.standard_normal(10) + | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 +14 | numbers = random.integers(high, size=5) + | + +NPY002.py:18:1: NPY002 Replace legacy `np.random.seed` call with `np.random.Generator` + | +16 | import numpy +17 | +18 | numpy.random.seed() + | ^^^^^^^^^^^^^^^^^ NPY002 +19 | numpy.random.get_state() +20 | numpy.random.set_state() + | + +NPY002.py:19:1: NPY002 Replace legacy `np.random.get_state` call with `np.random.Generator` + | +18 | numpy.random.seed() +19 | numpy.random.get_state() + | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 +20 | numpy.random.set_state() +21 | numpy.random.rand() + | + +NPY002.py:20:1: NPY002 Replace legacy `np.random.set_state` call with `np.random.Generator` + | +18 | numpy.random.seed() +19 | numpy.random.get_state() +20 | numpy.random.set_state() + | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 +21 | numpy.random.rand() +22 | numpy.random.randn() + | + +NPY002.py:21:1: NPY002 Replace legacy `np.random.rand` call with `np.random.Generator` + | +19 | numpy.random.get_state() +20 | numpy.random.set_state() +21 | numpy.random.rand() + | ^^^^^^^^^^^^^^^^^ NPY002 +22 | numpy.random.randn() +23 | numpy.random.randint() + | + +NPY002.py:22:1: NPY002 Replace legacy `np.random.randn` call with `np.random.Generator` + | +20 | numpy.random.set_state() +21 | numpy.random.rand() +22 | numpy.random.randn() + | ^^^^^^^^^^^^^^^^^^ NPY002 +23 | numpy.random.randint() +24 | numpy.random.random_integers() + | + +NPY002.py:23:1: NPY002 Replace legacy `np.random.randint` call with `np.random.Generator` + | +21 | numpy.random.rand() +22 | numpy.random.randn() +23 | numpy.random.randint() + | ^^^^^^^^^^^^^^^^^^^^ NPY002 +24 | numpy.random.random_integers() +25 | numpy.random.random_sample() + | + +NPY002.py:24:1: NPY002 Replace legacy `np.random.random_integers` call with `np.random.Generator` + | +22 | numpy.random.randn() +23 | numpy.random.randint() +24 | numpy.random.random_integers() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 +25 | numpy.random.random_sample() +26 | numpy.random.choice() + | + +NPY002.py:25:1: NPY002 Replace legacy `np.random.random_sample` call with `np.random.Generator` + | +23 | numpy.random.randint() +24 | numpy.random.random_integers() +25 | numpy.random.random_sample() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 +26 | numpy.random.choice() +27 | numpy.random.bytes() + | + +NPY002.py:26:1: NPY002 Replace legacy `np.random.choice` call with `np.random.Generator` + | +24 | numpy.random.random_integers() +25 | numpy.random.random_sample() +26 | numpy.random.choice() + | ^^^^^^^^^^^^^^^^^^^ NPY002 +27 | numpy.random.bytes() +28 | numpy.random.shuffle() + | + +NPY002.py:27:1: NPY002 Replace legacy `np.random.bytes` call with `np.random.Generator` + | +25 | numpy.random.random_sample() +26 | numpy.random.choice() +27 | numpy.random.bytes() + | ^^^^^^^^^^^^^^^^^^ NPY002 +28 | numpy.random.shuffle() +29 | numpy.random.permutation() + | + +NPY002.py:28:1: NPY002 Replace legacy `np.random.shuffle` call with `np.random.Generator` + | +26 | numpy.random.choice() +27 | numpy.random.bytes() +28 | numpy.random.shuffle() + | ^^^^^^^^^^^^^^^^^^^^ NPY002 +29 | numpy.random.permutation() +30 | numpy.random.beta() + | + +NPY002.py:29:1: NPY002 Replace legacy `np.random.permutation` call with `np.random.Generator` + | +27 | numpy.random.bytes() +28 | numpy.random.shuffle() +29 | numpy.random.permutation() + | ^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 +30 | numpy.random.beta() +31 | numpy.random.binomial() + | + +NPY002.py:30:1: NPY002 Replace legacy `np.random.beta` call with `np.random.Generator` + | +28 | numpy.random.shuffle() +29 | numpy.random.permutation() +30 | numpy.random.beta() + | ^^^^^^^^^^^^^^^^^ NPY002 +31 | numpy.random.binomial() +32 | numpy.random.chisquare() + | + +NPY002.py:31:1: NPY002 Replace legacy `np.random.binomial` call with `np.random.Generator` + | +29 | numpy.random.permutation() +30 | numpy.random.beta() +31 | numpy.random.binomial() + | ^^^^^^^^^^^^^^^^^^^^^ NPY002 +32 | numpy.random.chisquare() +33 | numpy.random.dirichlet() + | + +NPY002.py:32:1: NPY002 Replace legacy `np.random.chisquare` call with `np.random.Generator` + | +30 | numpy.random.beta() +31 | numpy.random.binomial() +32 | numpy.random.chisquare() + | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 +33 | numpy.random.dirichlet() +34 | numpy.random.exponential() + | + +NPY002.py:33:1: NPY002 Replace legacy `np.random.dirichlet` call with `np.random.Generator` + | +31 | numpy.random.binomial() +32 | numpy.random.chisquare() +33 | numpy.random.dirichlet() + | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 +34 | numpy.random.exponential() +35 | numpy.random.f() + | + +NPY002.py:34:1: NPY002 Replace legacy `np.random.exponential` call with `np.random.Generator` + | +32 | numpy.random.chisquare() +33 | numpy.random.dirichlet() +34 | numpy.random.exponential() + | ^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 +35 | numpy.random.f() +36 | numpy.random.gamma() + | + +NPY002.py:35:1: NPY002 Replace legacy `np.random.f` call with `np.random.Generator` + | +33 | numpy.random.dirichlet() +34 | numpy.random.exponential() +35 | numpy.random.f() + | ^^^^^^^^^^^^^^ NPY002 +36 | numpy.random.gamma() +37 | numpy.random.geometric() + | + +NPY002.py:36:1: NPY002 Replace legacy `np.random.gamma` call with `np.random.Generator` + | +34 | numpy.random.exponential() +35 | numpy.random.f() +36 | numpy.random.gamma() + | ^^^^^^^^^^^^^^^^^^ NPY002 +37 | numpy.random.geometric() +38 | numpy.random.get_state() + | + +NPY002.py:37:1: NPY002 Replace legacy `np.random.geometric` call with `np.random.Generator` + | +35 | numpy.random.f() +36 | numpy.random.gamma() +37 | numpy.random.geometric() + | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 +38 | numpy.random.get_state() +39 | numpy.random.gumbel() + | + +NPY002.py:38:1: NPY002 Replace legacy `np.random.get_state` call with `np.random.Generator` + | +36 | numpy.random.gamma() +37 | numpy.random.geometric() +38 | numpy.random.get_state() + | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 +39 | numpy.random.gumbel() +40 | numpy.random.hypergeometric() + | + +NPY002.py:39:1: NPY002 Replace legacy `np.random.gumbel` call with `np.random.Generator` + | +37 | numpy.random.geometric() +38 | numpy.random.get_state() +39 | numpy.random.gumbel() + | ^^^^^^^^^^^^^^^^^^^ NPY002 +40 | numpy.random.hypergeometric() +41 | numpy.random.laplace() + | + +NPY002.py:40:1: NPY002 Replace legacy `np.random.hypergeometric` call with `np.random.Generator` + | +38 | numpy.random.get_state() +39 | numpy.random.gumbel() +40 | numpy.random.hypergeometric() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 +41 | numpy.random.laplace() +42 | numpy.random.logistic() + | + +NPY002.py:41:1: NPY002 Replace legacy `np.random.laplace` call with `np.random.Generator` + | +39 | numpy.random.gumbel() +40 | numpy.random.hypergeometric() +41 | numpy.random.laplace() + | ^^^^^^^^^^^^^^^^^^^^ NPY002 +42 | numpy.random.logistic() +43 | numpy.random.lognormal() + | + +NPY002.py:42:1: NPY002 Replace legacy `np.random.logistic` call with `np.random.Generator` + | +40 | numpy.random.hypergeometric() +41 | numpy.random.laplace() +42 | numpy.random.logistic() + | ^^^^^^^^^^^^^^^^^^^^^ NPY002 +43 | numpy.random.lognormal() +44 | numpy.random.logseries() + | + +NPY002.py:43:1: NPY002 Replace legacy `np.random.lognormal` call with `np.random.Generator` + | +41 | numpy.random.laplace() +42 | numpy.random.logistic() +43 | numpy.random.lognormal() + | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 +44 | numpy.random.logseries() +45 | numpy.random.multinomial() + | + +NPY002.py:44:1: NPY002 Replace legacy `np.random.logseries` call with `np.random.Generator` + | +42 | numpy.random.logistic() +43 | numpy.random.lognormal() +44 | numpy.random.logseries() + | ^^^^^^^^^^^^^^^^^^^^^^ NPY002 +45 | numpy.random.multinomial() +46 | numpy.random.multivariate_normal() + | + +NPY002.py:45:1: NPY002 Replace legacy `np.random.multinomial` call with `np.random.Generator` + | +43 | numpy.random.lognormal() +44 | numpy.random.logseries() +45 | numpy.random.multinomial() + | ^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 +46 | numpy.random.multivariate_normal() +47 | numpy.random.negative_binomial() + | + +NPY002.py:46:1: NPY002 Replace legacy `np.random.multivariate_normal` call with `np.random.Generator` + | +44 | numpy.random.logseries() +45 | numpy.random.multinomial() +46 | numpy.random.multivariate_normal() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 +47 | numpy.random.negative_binomial() +48 | numpy.random.noncentral_chisquare() + | + +NPY002.py:47:1: NPY002 Replace legacy `np.random.negative_binomial` call with `np.random.Generator` + | +45 | numpy.random.multinomial() +46 | numpy.random.multivariate_normal() +47 | numpy.random.negative_binomial() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 +48 | numpy.random.noncentral_chisquare() +49 | numpy.random.noncentral_f() + | + +NPY002.py:48:1: NPY002 Replace legacy `np.random.noncentral_chisquare` call with `np.random.Generator` + | +46 | numpy.random.multivariate_normal() +47 | numpy.random.negative_binomial() +48 | numpy.random.noncentral_chisquare() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 +49 | numpy.random.noncentral_f() +50 | numpy.random.normal() + | + +NPY002.py:49:1: NPY002 Replace legacy `np.random.noncentral_f` call with `np.random.Generator` + | +47 | numpy.random.negative_binomial() +48 | numpy.random.noncentral_chisquare() +49 | numpy.random.noncentral_f() + | ^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 +50 | numpy.random.normal() +51 | numpy.random.pareto() + | + +NPY002.py:50:1: NPY002 Replace legacy `np.random.normal` call with `np.random.Generator` + | +48 | numpy.random.noncentral_chisquare() +49 | numpy.random.noncentral_f() +50 | numpy.random.normal() + | ^^^^^^^^^^^^^^^^^^^ NPY002 +51 | numpy.random.pareto() +52 | numpy.random.poisson() + | + +NPY002.py:51:1: NPY002 Replace legacy `np.random.pareto` call with `np.random.Generator` + | +49 | numpy.random.noncentral_f() +50 | numpy.random.normal() +51 | numpy.random.pareto() + | ^^^^^^^^^^^^^^^^^^^ NPY002 +52 | numpy.random.poisson() +53 | numpy.random.power() + | + +NPY002.py:52:1: NPY002 Replace legacy `np.random.poisson` call with `np.random.Generator` + | +50 | numpy.random.normal() +51 | numpy.random.pareto() +52 | numpy.random.poisson() + | ^^^^^^^^^^^^^^^^^^^^ NPY002 +53 | numpy.random.power() +54 | numpy.random.rayleigh() + | + +NPY002.py:53:1: NPY002 Replace legacy `np.random.power` call with `np.random.Generator` + | +51 | numpy.random.pareto() +52 | numpy.random.poisson() +53 | numpy.random.power() + | ^^^^^^^^^^^^^^^^^^ NPY002 +54 | numpy.random.rayleigh() +55 | numpy.random.standard_cauchy() + | + +NPY002.py:54:1: NPY002 Replace legacy `np.random.rayleigh` call with `np.random.Generator` + | +52 | numpy.random.poisson() +53 | numpy.random.power() +54 | numpy.random.rayleigh() + | ^^^^^^^^^^^^^^^^^^^^^ NPY002 +55 | numpy.random.standard_cauchy() +56 | numpy.random.standard_exponential() + | + +NPY002.py:55:1: NPY002 Replace legacy `np.random.standard_cauchy` call with `np.random.Generator` + | +53 | numpy.random.power() +54 | numpy.random.rayleigh() +55 | numpy.random.standard_cauchy() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 +56 | numpy.random.standard_exponential() +57 | numpy.random.standard_gamma() + | + +NPY002.py:56:1: NPY002 Replace legacy `np.random.standard_exponential` call with `np.random.Generator` + | +54 | numpy.random.rayleigh() +55 | numpy.random.standard_cauchy() +56 | numpy.random.standard_exponential() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 +57 | numpy.random.standard_gamma() +58 | numpy.random.standard_normal() + | + +NPY002.py:57:1: NPY002 Replace legacy `np.random.standard_gamma` call with `np.random.Generator` + | +55 | numpy.random.standard_cauchy() +56 | numpy.random.standard_exponential() +57 | numpy.random.standard_gamma() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 +58 | numpy.random.standard_normal() +59 | numpy.random.standard_t() + | + +NPY002.py:58:1: NPY002 Replace legacy `np.random.standard_normal` call with `np.random.Generator` + | +56 | numpy.random.standard_exponential() +57 | numpy.random.standard_gamma() +58 | numpy.random.standard_normal() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002 +59 | numpy.random.standard_t() +60 | numpy.random.triangular() + | + +NPY002.py:59:1: NPY002 Replace legacy `np.random.standard_t` call with `np.random.Generator` + | +57 | numpy.random.standard_gamma() +58 | numpy.random.standard_normal() +59 | numpy.random.standard_t() + | ^^^^^^^^^^^^^^^^^^^^^^^ NPY002 +60 | numpy.random.triangular() +61 | numpy.random.uniform() + | + +NPY002.py:60:1: NPY002 Replace legacy `np.random.triangular` call with `np.random.Generator` + | +58 | numpy.random.standard_normal() +59 | numpy.random.standard_t() +60 | numpy.random.triangular() + | ^^^^^^^^^^^^^^^^^^^^^^^ NPY002 +61 | numpy.random.uniform() +62 | numpy.random.vonmises() + | + +NPY002.py:61:1: NPY002 Replace legacy `np.random.uniform` call with `np.random.Generator` + | +59 | numpy.random.standard_t() +60 | numpy.random.triangular() +61 | numpy.random.uniform() + | ^^^^^^^^^^^^^^^^^^^^ NPY002 +62 | numpy.random.vonmises() +63 | numpy.random.wald() + | + +NPY002.py:62:1: NPY002 Replace legacy `np.random.vonmises` call with `np.random.Generator` + | +60 | numpy.random.triangular() +61 | numpy.random.uniform() +62 | numpy.random.vonmises() + | ^^^^^^^^^^^^^^^^^^^^^ NPY002 +63 | numpy.random.wald() +64 | numpy.random.weibull() + | + +NPY002.py:63:1: NPY002 Replace legacy `np.random.wald` call with `np.random.Generator` + | +61 | numpy.random.uniform() +62 | numpy.random.vonmises() +63 | numpy.random.wald() + | ^^^^^^^^^^^^^^^^^ NPY002 +64 | numpy.random.weibull() +65 | numpy.random.zipf() + | + +NPY002.py:64:1: NPY002 Replace legacy `np.random.weibull` call with `np.random.Generator` + | +62 | numpy.random.vonmises() +63 | numpy.random.wald() +64 | numpy.random.weibull() + | ^^^^^^^^^^^^^^^^^^^^ NPY002 +65 | numpy.random.zipf() + | + +NPY002.py:65:1: NPY002 Replace legacy `np.random.zipf` call with `np.random.Generator` + | +63 | numpy.random.wald() +64 | numpy.random.weibull() +65 | numpy.random.zipf() + | ^^^^^^^^^^^^^^^^^ NPY002 + | + + diff --git a/crates/ruff/src/rules/pandas_vet/helpers.rs b/crates/ruff_linter/src/rules/pandas_vet/helpers.rs similarity index 100% rename from crates/ruff/src/rules/pandas_vet/helpers.rs rename to crates/ruff_linter/src/rules/pandas_vet/helpers.rs diff --git a/crates/ruff/src/rules/pandas_vet/mod.rs b/crates/ruff_linter/src/rules/pandas_vet/mod.rs similarity index 100% rename from crates/ruff/src/rules/pandas_vet/mod.rs rename to crates/ruff_linter/src/rules/pandas_vet/mod.rs diff --git a/crates/ruff/src/rules/pandas_vet/rules/assignment_to_df.rs b/crates/ruff_linter/src/rules/pandas_vet/rules/assignment_to_df.rs similarity index 100% rename from crates/ruff/src/rules/pandas_vet/rules/assignment_to_df.rs rename to crates/ruff_linter/src/rules/pandas_vet/rules/assignment_to_df.rs diff --git a/crates/ruff/src/rules/pandas_vet/rules/attr.rs b/crates/ruff_linter/src/rules/pandas_vet/rules/attr.rs similarity index 100% rename from crates/ruff/src/rules/pandas_vet/rules/attr.rs rename to crates/ruff_linter/src/rules/pandas_vet/rules/attr.rs diff --git a/crates/ruff/src/rules/pandas_vet/rules/call.rs b/crates/ruff_linter/src/rules/pandas_vet/rules/call.rs similarity index 100% rename from crates/ruff/src/rules/pandas_vet/rules/call.rs rename to crates/ruff_linter/src/rules/pandas_vet/rules/call.rs diff --git a/crates/ruff/src/rules/pandas_vet/rules/inplace_argument.rs b/crates/ruff_linter/src/rules/pandas_vet/rules/inplace_argument.rs similarity index 100% rename from crates/ruff/src/rules/pandas_vet/rules/inplace_argument.rs rename to crates/ruff_linter/src/rules/pandas_vet/rules/inplace_argument.rs diff --git a/crates/ruff/src/rules/pandas_vet/rules/mod.rs b/crates/ruff_linter/src/rules/pandas_vet/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/pandas_vet/rules/mod.rs rename to crates/ruff_linter/src/rules/pandas_vet/rules/mod.rs diff --git a/crates/ruff/src/rules/pandas_vet/rules/nunique_constant_series_check.rs b/crates/ruff_linter/src/rules/pandas_vet/rules/nunique_constant_series_check.rs similarity index 100% rename from crates/ruff/src/rules/pandas_vet/rules/nunique_constant_series_check.rs rename to crates/ruff_linter/src/rules/pandas_vet/rules/nunique_constant_series_check.rs diff --git a/crates/ruff/src/rules/pandas_vet/rules/pd_merge.rs b/crates/ruff_linter/src/rules/pandas_vet/rules/pd_merge.rs similarity index 100% rename from crates/ruff/src/rules/pandas_vet/rules/pd_merge.rs rename to crates/ruff_linter/src/rules/pandas_vet/rules/pd_merge.rs diff --git a/crates/ruff/src/rules/pandas_vet/rules/read_table.rs b/crates/ruff_linter/src/rules/pandas_vet/rules/read_table.rs similarity index 100% rename from crates/ruff/src/rules/pandas_vet/rules/read_table.rs rename to crates/ruff_linter/src/rules/pandas_vet/rules/read_table.rs diff --git a/crates/ruff/src/rules/pandas_vet/rules/subscript.rs b/crates/ruff_linter/src/rules/pandas_vet/rules/subscript.rs similarity index 100% rename from crates/ruff/src/rules/pandas_vet/rules/subscript.rs rename to crates/ruff_linter/src/rules/pandas_vet/rules/subscript.rs 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 new file mode 100644 index 0000000000..8fd8323c46 --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_PD002.py.snap @@ -0,0 +1,177 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- +PD002.py:5:23: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior + | +3 | x = pd.DataFrame() +4 | +5 | x.drop(["a"], axis=1, inplace=True) + | ^^^^^^^^^^^^ PD002 +6 | +7 | x.y.drop(["a"], axis=1, inplace=True) + | + = help: Assign to variable; remove `inplace` arg + +ℹ Suggested fix +2 2 | +3 3 | x = pd.DataFrame() +4 4 | +5 |-x.drop(["a"], axis=1, inplace=True) + 5 |+x = x.drop(["a"], axis=1) +6 6 | +7 7 | x.y.drop(["a"], axis=1, inplace=True) +8 8 | + +PD002.py:7:25: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior + | +5 | x.drop(["a"], axis=1, inplace=True) +6 | +7 | x.y.drop(["a"], axis=1, inplace=True) + | ^^^^^^^^^^^^ PD002 +8 | +9 | x["y"].drop(["a"], axis=1, inplace=True) + | + = help: Assign to variable; remove `inplace` arg + +ℹ Suggested fix +4 4 | +5 5 | x.drop(["a"], axis=1, inplace=True) +6 6 | +7 |-x.y.drop(["a"], axis=1, inplace=True) + 7 |+x.y = x.y.drop(["a"], axis=1) +8 8 | +9 9 | x["y"].drop(["a"], axis=1, inplace=True) +10 10 | + +PD002.py:9:28: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior + | + 7 | x.y.drop(["a"], axis=1, inplace=True) + 8 | + 9 | x["y"].drop(["a"], axis=1, inplace=True) + | ^^^^^^^^^^^^ PD002 +10 | +11 | x.drop( + | + = help: Assign to variable; remove `inplace` arg + +ℹ Suggested fix +6 6 | +7 7 | x.y.drop(["a"], axis=1, inplace=True) +8 8 | +9 |-x["y"].drop(["a"], axis=1, inplace=True) + 9 |+x["y"] = x["y"].drop(["a"], axis=1) +10 10 | +11 11 | x.drop( +12 12 | inplace=True, + +PD002.py:12:5: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior + | +11 | x.drop( +12 | inplace=True, + | ^^^^^^^^^^^^ PD002 +13 | columns=["a"], +14 | axis=1, + | + = help: Assign to variable; remove `inplace` arg + +ℹ Suggested fix +8 8 | +9 9 | x["y"].drop(["a"], axis=1, inplace=True) +10 10 | +11 |-x.drop( +12 |- inplace=True, + 11 |+x = x.drop( +13 12 | columns=["a"], +14 13 | axis=1, +15 14 | ) + +PD002.py:19:9: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior + | +17 | if True: +18 | x.drop( +19 | inplace=True, + | ^^^^^^^^^^^^ PD002 +20 | columns=["a"], +21 | axis=1, + | + = help: Assign to variable; remove `inplace` arg + +ℹ Suggested fix +15 15 | ) +16 16 | +17 17 | if True: +18 |- x.drop( +19 |- inplace=True, + 18 |+ x = x.drop( +20 19 | columns=["a"], +21 20 | axis=1, +22 21 | ) + +PD002.py:24:33: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior + | +22 | ) +23 | +24 | x.drop(["a"], axis=1, **kwargs, inplace=True) + | ^^^^^^^^^^^^ PD002 +25 | x.drop(["a"], axis=1, inplace=True, **kwargs) +26 | f(x.drop(["a"], axis=1, inplace=True)) + | + = help: Assign to variable; remove `inplace` arg + +ℹ Suggested fix +21 21 | axis=1, +22 22 | ) +23 23 | +24 |-x.drop(["a"], axis=1, **kwargs, inplace=True) + 24 |+x = x.drop(["a"], axis=1, **kwargs) +25 25 | x.drop(["a"], axis=1, inplace=True, **kwargs) +26 26 | f(x.drop(["a"], axis=1, inplace=True)) +27 27 | + +PD002.py:25:23: PD002 `inplace=True` should be avoided; it has inconsistent behavior + | +24 | x.drop(["a"], axis=1, **kwargs, inplace=True) +25 | x.drop(["a"], axis=1, inplace=True, **kwargs) + | ^^^^^^^^^^^^ PD002 +26 | f(x.drop(["a"], axis=1, inplace=True)) + | + = help: Assign to variable; remove `inplace` arg + +PD002.py:26:25: PD002 `inplace=True` should be avoided; it has inconsistent behavior + | +24 | x.drop(["a"], axis=1, **kwargs, inplace=True) +25 | x.drop(["a"], axis=1, inplace=True, **kwargs) +26 | f(x.drop(["a"], axis=1, inplace=True)) + | ^^^^^^^^^^^^ PD002 +27 | +28 | x.apply(lambda x: x.sort_values("a", inplace=True)) + | + = help: Assign to variable; remove `inplace` arg + +PD002.py:28:38: PD002 `inplace=True` should be avoided; it has inconsistent behavior + | +26 | f(x.drop(["a"], axis=1, inplace=True)) +27 | +28 | x.apply(lambda x: x.sort_values("a", inplace=True)) + | ^^^^^^^^^^^^ PD002 +29 | import torch + | + = help: Assign to variable; remove `inplace` arg + +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 | +33 | (x.drop(["a"], axis=1, inplace=True)) + | ^^^^^^^^^^^^ PD002 + | + = help: Assign to variable; remove `inplace` arg + +ℹ Suggested fix +30 30 | +31 31 | torch.m.ReLU(inplace=True) # safe because this isn't a pandas call +32 32 | +33 |-(x.drop(["a"], axis=1, inplace=True)) + 33 |+x = (x.drop(["a"], axis=1)) + + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_fail.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_fail.snap new file mode 100644 index 0000000000..d88f95e114 --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_fail.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- +:4:23: PD002 [*] `inplace=True` should be avoided; it has inconsistent behavior + | +2 | import pandas as pd +3 | x = pd.DataFrame() +4 | x.drop(["a"], axis=1, inplace=True) + | ^^^^^^^^^^^^ PD002 + | + = help: Assign to variable; remove `inplace` arg + +ℹ Suggested fix +1 1 | +2 2 | import pandas as pd +3 3 | x = pd.DataFrame() +4 |-x.drop(["a"], axis=1, inplace=True) + 4 |+x = x.drop(["a"], axis=1) + + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_pass.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_pass.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD002_pass.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD003_allows_other_calls.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD003_allows_other_calls.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD003_allows_other_calls.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD003_fail.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD003_fail.snap new file mode 100644 index 0000000000..19199f9380 --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD003_fail.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- +:3:9: PD003 `.isna` is preferred to `.isnull`; functionality is equivalent + | +2 | import pandas as pd +3 | nulls = pd.isnull(val) + | ^^^^^^^^^ PD003 + | + + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD003_pass.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD003_pass.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD003_pass.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD004_fail.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD004_fail.snap new file mode 100644 index 0000000000..e5ffb845c0 --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD004_fail.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- +:3:13: PD004 `.notna` is preferred to `.notnull`; functionality is equivalent + | +2 | import pandas as pd +3 | not_nulls = pd.notnull(val) + | ^^^^^^^^^^ PD004 + | + + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD004_pass.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD004_pass.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD004_pass.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD007_fail.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD007_fail.snap new file mode 100644 index 0000000000..bcbd120c01 --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD007_fail.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- +:4:5: PD007 `.ix` is deprecated; use more explicit `.loc` or `.iloc` + | +2 | import pandas as pd +3 | x = pd.DataFrame() +4 | y = x.ix[[0, 2], "A"] + | ^^^^^^^^^^^^^^^^^ PD007 + | + + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD007_pass_iloc.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD007_pass_iloc.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD007_pass_iloc.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD007_pass_loc.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD007_pass_loc.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD007_pass_loc.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD008_fail.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD008_fail.snap new file mode 100644 index 0000000000..40fae2d6b0 --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD008_fail.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- +:4:9: PD008 Use `.loc` instead of `.at`. If speed is important, use NumPy. + | +2 | import pandas as pd +3 | x = pd.DataFrame() +4 | index = x.at[:, ["B", "A"]] + | ^^^^^^^^^^^^^^^^^^^ PD008 + | + + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD008_pass.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD008_pass.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD008_pass.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD008_pass_on_attr.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD008_pass_on_attr.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD008_pass_on_attr.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD009_fail.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD009_fail.snap new file mode 100644 index 0000000000..1d6826d250 --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD009_fail.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- +:4:9: PD009 Use `.iloc` instead of `.iat`. If speed is important, use NumPy. + | +2 | import pandas as pd +3 | x = pd.DataFrame() +4 | index = x.iat[:, 1:3] + | ^^^^^^^^^^^^^ PD009 + | + + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD009_pass.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD009_pass.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD009_pass.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD010_fail_pivot.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD010_fail_pivot.snap new file mode 100644 index 0000000000..894fbee4dc --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD010_fail_pivot.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- +:4:9: PD010 `.pivot_table` is preferred to `.pivot` or `.unstack`; provides same functionality + | +2 | import pandas as pd +3 | x = pd.DataFrame() +4 | table = pd.pivot( + | ^^^^^^^^ PD010 +5 | x, +6 | index="foo", + | + + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD010_pass.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD010_pass.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD010_pass.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_fail_values.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_fail_values.snap new file mode 100644 index 0000000000..94dd9fed94 --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_fail_values.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- +:4:10: PD011 Use `.to_numpy()` instead of `.values` + | +2 | import pandas as pd +3 | x = pd.DataFrame() +4 | result = x.values + | ^^^^^^^^ PD011 + | + + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_array.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_array.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_array.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_node_name.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_node_name.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_node_name.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_to_array.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_to_array.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_to_array.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_values_call.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_values_call.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_values_call.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_values_dict.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_values_dict.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_values_dict.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_values_import.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_values_import.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_values_import.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_values_instance.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_values_instance.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_values_instance.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_values_store.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_values_store.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_values_store.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_values_unbound.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_values_unbound.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD011_pass_values_unbound.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + 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 new file mode 100644 index 0000000000..a9621cdd85 --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD012_pandas_use_of_dot_read_table.py.snap @@ -0,0 +1,42 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- +pandas_use_of_dot_read_table.py:4:6: PD012 Use `.read_csv` instead of `.read_table` to read CSV files + | +3 | # Errors. +4 | df = pd.read_table("data.csv", sep=",") + | ^^^^^^^^^^^^^ PD012 +5 | df = pd.read_table("data.csv", sep=",", header=0) +6 | filename = "data.csv" + | + +pandas_use_of_dot_read_table.py:5:6: PD012 Use `.read_csv` instead of `.read_table` to read CSV files + | +3 | # Errors. +4 | df = pd.read_table("data.csv", sep=",") +5 | df = pd.read_table("data.csv", sep=",", header=0) + | ^^^^^^^^^^^^^ PD012 +6 | filename = "data.csv" +7 | df = pd.read_table(filename, sep=",") + | + +pandas_use_of_dot_read_table.py:7:6: PD012 Use `.read_csv` instead of `.read_table` to read CSV files + | +5 | df = pd.read_table("data.csv", sep=",", header=0) +6 | filename = "data.csv" +7 | df = pd.read_table(filename, sep=",") + | ^^^^^^^^^^^^^ PD012 +8 | df = pd.read_table(filename, sep=",", header=0) + | + +pandas_use_of_dot_read_table.py:8:6: PD012 Use `.read_csv` instead of `.read_table` to read CSV files + | + 6 | filename = "data.csv" + 7 | df = pd.read_table(filename, sep=",") + 8 | df = pd.read_table(filename, sep=",", header=0) + | ^^^^^^^^^^^^^ PD012 + 9 | +10 | # Non-errors. + | + + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD013_fail_stack.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD013_fail_stack.snap new file mode 100644 index 0000000000..ccf015aa5c --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD013_fail_stack.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- +:4:5: PD013 `.melt` is preferred to `.stack`; provides same functionality + | +2 | import pandas as pd +3 | x = pd.DataFrame() +4 | y = x.stack(level=-1, dropna=True) + | ^^^^^^^ PD013 + | + + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD013_pass.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD013_pass.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD013_pass.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD013_pass_numpy.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD013_pass_numpy.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD013_pass_numpy.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD013_pass_unbound.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD013_pass_unbound.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD013_pass_unbound.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD015_fail_merge_on_pandas_object.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD015_fail_merge_on_pandas_object.snap new file mode 100644 index 0000000000..c8cf3ff541 --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD015_fail_merge_on_pandas_object.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- +:5:1: PD015 Use `.merge` method instead of `pd.merge` function. They have equivalent functionality. + | +3 | x = pd.DataFrame() +4 | y = pd.DataFrame() +5 | pd.merge(x, y) + | ^^^^^^^^ PD015 + | + + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD015_pass_merge_on_dataframe.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD015_pass_merge_on_dataframe.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD015_pass_merge_on_dataframe.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD015_pass_merge_on_dataframe_with_multiple_args.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD015_pass_merge_on_dataframe_with_multiple_args.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD015_pass_merge_on_dataframe_with_multiple_args.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD015_pass_other_pd_function.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD015_pass_other_pd_function.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD015_pass_other_pd_function.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + 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 new file mode 100644 index 0000000000..5df060ab23 --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD101_PD101.py.snap @@ -0,0 +1,122 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- +PD101.py:7:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient + | +6 | # PD101 +7 | data.nunique() <= 1 + | ^^^^^^^^^^^^^^^^^^^ PD101 +8 | data.nunique(dropna=True) <= 1 +9 | data.nunique(dropna=False) <= 1 + | + +PD101.py:8:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient + | + 6 | # PD101 + 7 | data.nunique() <= 1 + 8 | data.nunique(dropna=True) <= 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 + 9 | data.nunique(dropna=False) <= 1 +10 | data.nunique() == 1 + | + +PD101.py:9:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient + | + 7 | data.nunique() <= 1 + 8 | data.nunique(dropna=True) <= 1 + 9 | data.nunique(dropna=False) <= 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 +10 | data.nunique() == 1 +11 | data.nunique(dropna=True) == 1 + | + +PD101.py:10:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient + | + 8 | data.nunique(dropna=True) <= 1 + 9 | data.nunique(dropna=False) <= 1 +10 | data.nunique() == 1 + | ^^^^^^^^^^^^^^^^^^^ PD101 +11 | data.nunique(dropna=True) == 1 +12 | data.nunique(dropna=False) == 1 + | + +PD101.py:11:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient + | + 9 | data.nunique(dropna=False) <= 1 +10 | data.nunique() == 1 +11 | data.nunique(dropna=True) == 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 +12 | data.nunique(dropna=False) == 1 +13 | data.nunique() != 1 + | + +PD101.py:12:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient + | +10 | data.nunique() == 1 +11 | data.nunique(dropna=True) == 1 +12 | data.nunique(dropna=False) == 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 +13 | data.nunique() != 1 +14 | data.nunique(dropna=True) != 1 + | + +PD101.py:13:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient + | +11 | data.nunique(dropna=True) == 1 +12 | data.nunique(dropna=False) == 1 +13 | data.nunique() != 1 + | ^^^^^^^^^^^^^^^^^^^ PD101 +14 | data.nunique(dropna=True) != 1 +15 | data.nunique(dropna=False) != 1 + | + +PD101.py:14:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient + | +12 | data.nunique(dropna=False) == 1 +13 | data.nunique() != 1 +14 | data.nunique(dropna=True) != 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 +15 | data.nunique(dropna=False) != 1 +16 | data.nunique() > 1 + | + +PD101.py:15:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient + | +13 | data.nunique() != 1 +14 | data.nunique(dropna=True) != 1 +15 | data.nunique(dropna=False) != 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 +16 | data.nunique() > 1 +17 | data.dropna().nunique() == 1 + | + +PD101.py:16:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient + | +14 | data.nunique(dropna=True) != 1 +15 | data.nunique(dropna=False) != 1 +16 | data.nunique() > 1 + | ^^^^^^^^^^^^^^^^^^ PD101 +17 | data.dropna().nunique() == 1 +18 | data[data.notnull()].nunique() == 1 + | + +PD101.py:17:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient + | +15 | data.nunique(dropna=False) != 1 +16 | data.nunique() > 1 +17 | data.dropna().nunique() == 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 +18 | data[data.notnull()].nunique() == 1 + | + +PD101.py:18:1: PD101 Using `series.nunique()` for checking that a series is constant is inefficient + | +16 | data.nunique() > 1 +17 | data.dropna().nunique() == 1 +18 | data[data.notnull()].nunique() == 1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PD101 +19 | +20 | # No violation of this rule + | + + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD901_fail_df_var.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD901_fail_df_var.snap new file mode 100644 index 0000000000..eb5c99e6ed --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD901_fail_df_var.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- +:3:1: PD901 `df` is a bad variable name. Be kinder to your future self. + | +2 | import pandas as pd +3 | df = pd.DataFrame() + | ^^ PD901 + | + + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD901_pass_df_param.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD901_pass_df_param.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD901_pass_df_param.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD901_pass_non_df.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD901_pass_non_df.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD901_pass_non_df.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD901_pass_part_df.snap b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD901_pass_part_df.snap new file mode 100644 index 0000000000..07173f8f1b --- /dev/null +++ b/crates/ruff_linter/src/rules/pandas_vet/snapshots/ruff_linter__rules__pandas_vet__tests__PD901_pass_part_df.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pandas_vet/mod.rs +--- + diff --git a/crates/ruff/src/rules/pep8_naming/helpers.rs b/crates/ruff_linter/src/rules/pep8_naming/helpers.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/helpers.rs rename to crates/ruff_linter/src/rules/pep8_naming/helpers.rs diff --git a/crates/ruff/src/rules/pep8_naming/mod.rs b/crates/ruff_linter/src/rules/pep8_naming/mod.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/mod.rs rename to crates/ruff_linter/src/rules/pep8_naming/mod.rs diff --git a/crates/ruff/src/rules/pep8_naming/rules/camelcase_imported_as_acronym.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/camelcase_imported_as_acronym.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/rules/camelcase_imported_as_acronym.rs rename to crates/ruff_linter/src/rules/pep8_naming/rules/camelcase_imported_as_acronym.rs diff --git a/crates/ruff/src/rules/pep8_naming/rules/camelcase_imported_as_constant.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/camelcase_imported_as_constant.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/rules/camelcase_imported_as_constant.rs rename to crates/ruff_linter/src/rules/pep8_naming/rules/camelcase_imported_as_constant.rs diff --git a/crates/ruff/src/rules/pep8_naming/rules/camelcase_imported_as_lowercase.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/camelcase_imported_as_lowercase.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/rules/camelcase_imported_as_lowercase.rs rename to crates/ruff_linter/src/rules/pep8_naming/rules/camelcase_imported_as_lowercase.rs diff --git a/crates/ruff/src/rules/pep8_naming/rules/constant_imported_as_non_constant.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/constant_imported_as_non_constant.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/rules/constant_imported_as_non_constant.rs rename to crates/ruff_linter/src/rules/pep8_naming/rules/constant_imported_as_non_constant.rs diff --git a/crates/ruff/src/rules/pep8_naming/rules/dunder_function_name.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/dunder_function_name.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/rules/dunder_function_name.rs rename to crates/ruff_linter/src/rules/pep8_naming/rules/dunder_function_name.rs diff --git a/crates/ruff/src/rules/pep8_naming/rules/error_suffix_on_exception_name.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/error_suffix_on_exception_name.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/rules/error_suffix_on_exception_name.rs rename to crates/ruff_linter/src/rules/pep8_naming/rules/error_suffix_on_exception_name.rs diff --git a/crates/ruff/src/rules/pep8_naming/rules/invalid_argument_name.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_argument_name.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/rules/invalid_argument_name.rs rename to crates/ruff_linter/src/rules/pep8_naming/rules/invalid_argument_name.rs diff --git a/crates/ruff/src/rules/pep8_naming/rules/invalid_class_name.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_class_name.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/rules/invalid_class_name.rs rename to crates/ruff_linter/src/rules/pep8_naming/rules/invalid_class_name.rs diff --git a/crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_class_method.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_first_argument_name_for_class_method.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_class_method.rs rename to crates/ruff_linter/src/rules/pep8_naming/rules/invalid_first_argument_name_for_class_method.rs diff --git a/crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_method.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_first_argument_name_for_method.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_method.rs rename to crates/ruff_linter/src/rules/pep8_naming/rules/invalid_first_argument_name_for_method.rs diff --git a/crates/ruff/src/rules/pep8_naming/rules/invalid_function_name.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_function_name.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/rules/invalid_function_name.rs rename to crates/ruff_linter/src/rules/pep8_naming/rules/invalid_function_name.rs diff --git a/crates/ruff/src/rules/pep8_naming/rules/invalid_module_name.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/invalid_module_name.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/rules/invalid_module_name.rs rename to crates/ruff_linter/src/rules/pep8_naming/rules/invalid_module_name.rs diff --git a/crates/ruff/src/rules/pep8_naming/rules/lowercase_imported_as_non_lowercase.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/lowercase_imported_as_non_lowercase.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/rules/lowercase_imported_as_non_lowercase.rs rename to crates/ruff_linter/src/rules/pep8_naming/rules/lowercase_imported_as_non_lowercase.rs diff --git a/crates/ruff/src/rules/pep8_naming/rules/mixed_case_variable_in_class_scope.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/mixed_case_variable_in_class_scope.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/rules/mixed_case_variable_in_class_scope.rs rename to crates/ruff_linter/src/rules/pep8_naming/rules/mixed_case_variable_in_class_scope.rs diff --git a/crates/ruff/src/rules/pep8_naming/rules/mixed_case_variable_in_global_scope.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/mixed_case_variable_in_global_scope.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/rules/mixed_case_variable_in_global_scope.rs rename to crates/ruff_linter/src/rules/pep8_naming/rules/mixed_case_variable_in_global_scope.rs diff --git a/crates/ruff/src/rules/pep8_naming/rules/mod.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/rules/mod.rs rename to crates/ruff_linter/src/rules/pep8_naming/rules/mod.rs diff --git a/crates/ruff/src/rules/pep8_naming/rules/non_lowercase_variable_in_function.rs b/crates/ruff_linter/src/rules/pep8_naming/rules/non_lowercase_variable_in_function.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/rules/non_lowercase_variable_in_function.rs rename to crates/ruff_linter/src/rules/pep8_naming/rules/non_lowercase_variable_in_function.rs diff --git a/crates/ruff/src/rules/pep8_naming/settings.rs b/crates/ruff_linter/src/rules/pep8_naming/settings.rs similarity index 100% rename from crates/ruff/src/rules/pep8_naming/settings.rs rename to crates/ruff_linter/src/rules/pep8_naming/settings.rs diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N801_N801.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N801_N801.py.snap new file mode 100644 index 0000000000..66c139e033 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N801_N801.py.snap @@ -0,0 +1,39 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N801.py:1:7: N801 Class name `bad` should use CapWords convention + | +1 | class bad: + | ^^^ N801 +2 | pass + | + +N801.py:5:7: N801 Class name `_bad` should use CapWords convention + | +5 | class _bad: + | ^^^^ N801 +6 | pass + | + +N801.py:9:7: N801 Class name `bad_class` should use CapWords convention + | + 9 | class bad_class: + | ^^^^^^^^^ N801 +10 | pass + | + +N801.py:13:7: N801 Class name `Bad_Class` should use CapWords convention + | +13 | class Bad_Class: + | ^^^^^^^^^ N801 +14 | pass + | + +N801.py:17:7: N801 Class name `BAD_CLASS` should use CapWords convention + | +17 | class BAD_CLASS: + | ^^^^^^^^^ N801 +18 | pass + | + + 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 new file mode 100644 index 0000000000..7e901545aa --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N802_N802.py.snap @@ -0,0 +1,41 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N802.py:4:5: N802 Function name `Bad` should be lowercase + | +4 | def Bad(): + | ^^^ N802 +5 | pass + | + +N802.py:8:5: N802 Function name `_Bad` should be lowercase + | +8 | def _Bad(): + | ^^^^ N802 +9 | pass + | + +N802.py:12:5: N802 Function name `BAD` should be lowercase + | +12 | def BAD(): + | ^^^ N802 +13 | pass + | + +N802.py:16:5: N802 Function name `BAD_FUNC` should be lowercase + | +16 | def BAD_FUNC(): + | ^^^^^^^^ N802 +17 | pass + | + +N802.py:40:9: N802 Function name `testTest` should be lowercase + | +38 | return super().tearDown() +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__N803_N803.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N803_N803.py.snap new file mode 100644 index 0000000000..cf7c5170e8 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N803_N803.py.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N803.py:1:16: N803 Argument name `A` should be lowercase + | +1 | def func(_, a, A): + | ^ N803 +2 | return _, a, A + | + +N803.py:6:28: N803 Argument name `A` should be lowercase + | +5 | class Class: +6 | def method(self, _, a, A): + | ^ N803 +7 | return _, a, A + | + + 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 new file mode 100644 index 0000000000..0546db9dc8 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N804_N804.py.snap @@ -0,0 +1,29 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N804.py:30:27: N804 First argument of a class method should be named `cls` + | +28 | ... +29 | +30 | def __init_subclass__(self, default_name, **kwargs): + | ^^^^ N804 +31 | ... + | + +N804.py:38:56: N804 First argument of a class method should be named `cls` + | +37 | @classmethod +38 | def bad_class_method_with_positional_only_argument(self, x, /, other): + | ^^^^ N804 +39 | ... + | + +N804.py:43:20: N804 First argument of a class method should be named `cls` + | +42 | class MetaClass(ABCMeta): +43 | def bad_method(self): + | ^^^^ N804 +44 | pass + | + + 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 new file mode 100644 index 0000000000..0038513dbc --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N805_N805.py.snap @@ -0,0 +1,46 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N805.py:7:20: N805 First argument of a method should be named `self` + | +6 | class Class: +7 | def bad_method(this): + | ^^^^ N805 +8 | pass + | + +N805.py:12:30: N805 First argument of a method should be named `self` + | +10 | if False: +11 | +12 | def extra_bad_method(this): + | ^^^^ N805 +13 | pass + | + +N805.py:31:15: N805 First argument of a method should be named `self` + | +30 | @pydantic.validator +31 | def lower(cls, my_field: str) -> str: + | ^^^ N805 +32 | pass + | + +N805.py:35:15: N805 First argument of a method should be named `self` + | +34 | @pydantic.validator("my_field") +35 | def lower(cls, my_field: str) -> str: + | ^^^ N805 +36 | pass + | + +N805.py:64:29: N805 First argument of a method should be named `self` + | +62 | pass +63 | +64 | def bad_method_pos_only(this, blah, /, self, something: str): + | ^^^^ N805 +65 | pass + | + + 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 new file mode 100644 index 0000000000..16718b5a99 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N806_N806.py.snap @@ -0,0 +1,23 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N806.py:12:5: N806 Variable `Camel` in function should be lowercase + | +10 | GLOBAL = "bar" +11 | lower = 0 +12 | Camel = 0 + | ^^^^^ N806 +13 | CONSTANT = 0 +14 | _ = 0 + | + +N806.py:13:5: N806 Variable `CONSTANT` in function should be lowercase + | +11 | lower = 0 +12 | Camel = 0 +13 | CONSTANT = 0 + | ^^^^^^^^ N806 +14 | _ = 0 + | + + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N807_N807.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N807_N807.py.snap new file mode 100644 index 0000000000..a1fa93b983 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N807_N807.py.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N807.py:1:5: N807 Function name should not start and end with `__` + | +1 | def __bad__(): + | ^^^^^^^ N807 +2 | pass + | + +N807.py:14:9: N807 Function name should not start and end with `__` + | +13 | def nested(): +14 | def __bad__(): + | ^^^^^^^ N807 +15 | pass + | + + 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 new file mode 100644 index 0000000000..0221ec269a --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N811_N811.py.snap @@ -0,0 +1,28 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N811.py:1:8: N811 Constant `CONST` imported as non-constant `const` + | +1 | import mod.CONST as const + | ^^^^^^^^^^^^^^^^^^ N811 +2 | from mod import CONSTANT as constant +3 | from mod import ANOTHER_CONSTANT as another_constant + | + +N811.py:2:17: N811 Constant `CONSTANT` imported as non-constant `constant` + | +1 | import mod.CONST as const +2 | from mod import CONSTANT as constant + | ^^^^^^^^^^^^^^^^^^^^ N811 +3 | from mod import ANOTHER_CONSTANT as another_constant + | + +N811.py:3:17: N811 Constant `ANOTHER_CONSTANT` imported as non-constant `another_constant` + | +1 | import mod.CONST as const +2 | from mod import CONSTANT as constant +3 | from mod import ANOTHER_CONSTANT as another_constant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ N811 + | + + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N812_N812.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N812_N812.py.snap new file mode 100644 index 0000000000..2efc0a3344 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N812_N812.py.snap @@ -0,0 +1,28 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N812.py:1:8: N812 Lowercase `lowercase` imported as non-lowercase `Lower` + | +1 | import modl.lowercase as Lower + | ^^^^^^^^^^^^^^^^^^^^^^^ N812 +2 | from mod import lowercase as Lowercase +3 | from mod import another_lowercase as AnotherLowercase + | + +N812.py:2:17: N812 Lowercase `lowercase` imported as non-lowercase `Lowercase` + | +1 | import modl.lowercase as Lower +2 | from mod import lowercase as Lowercase + | ^^^^^^^^^^^^^^^^^^^^^^ N812 +3 | from mod import another_lowercase as AnotherLowercase + | + +N812.py:3:17: N812 Lowercase `another_lowercase` imported as non-lowercase `AnotherLowercase` + | +1 | import modl.lowercase as Lower +2 | from mod import lowercase as Lowercase +3 | from mod import another_lowercase as AnotherLowercase + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ N812 + | + + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N813_N813.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N813_N813.py.snap new file mode 100644 index 0000000000..d054e25e0e --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N813_N813.py.snap @@ -0,0 +1,28 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N813.py:1:8: N813 Camelcase `Camel` imported as lowercase `camel` + | +1 | import mod.Camel as camel + | ^^^^^^^^^^^^^^^^^^ N813 +2 | from mod import CamelCase as camelcase +3 | from mod import AnotherCamelCase as another_camelcase + | + +N813.py:2:17: N813 Camelcase `CamelCase` imported as lowercase `camelcase` + | +1 | import mod.Camel as camel +2 | from mod import CamelCase as camelcase + | ^^^^^^^^^^^^^^^^^^^^^^ N813 +3 | from mod import AnotherCamelCase as another_camelcase + | + +N813.py:3:17: N813 Camelcase `AnotherCamelCase` imported as lowercase `another_camelcase` + | +1 | import mod.Camel as camel +2 | from mod import CamelCase as camelcase +3 | from mod import AnotherCamelCase as another_camelcase + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ N813 + | + + 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 new file mode 100644 index 0000000000..30aef08f54 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N814_N814.py.snap @@ -0,0 +1,28 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N814.py:1:8: N814 Camelcase `Camel` imported as constant `CAMEL` + | +1 | import mod.Camel as CAMEL + | ^^^^^^^^^^^^^^^^^^ N814 +2 | from mod import CamelCase as CAMELCASE +3 | from mod import AnotherCamelCase as ANOTHER_CAMELCASE + | + +N814.py:2:17: N814 Camelcase `CamelCase` imported as constant `CAMELCASE` + | +1 | import mod.Camel as CAMEL +2 | from mod import CamelCase as CAMELCASE + | ^^^^^^^^^^^^^^^^^^^^^^ N814 +3 | from mod import AnotherCamelCase as ANOTHER_CAMELCASE + | + +N814.py:3:17: N814 Camelcase `AnotherCamelCase` imported as constant `ANOTHER_CAMELCASE` + | +1 | import mod.Camel as CAMEL +2 | from mod import CamelCase as CAMELCASE +3 | from mod import AnotherCamelCase as ANOTHER_CAMELCASE + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ N814 + | + + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N815_N815.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N815_N815.py.snap new file mode 100644 index 0000000000..d507e8d1ca --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N815_N815.py.snap @@ -0,0 +1,34 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N815.py:9:5: N815 Variable `mixedCase` in class scope should not be mixedCase + | + 7 | lower = 0 + 8 | CONSTANT = 0 + 9 | mixedCase = 0 + | ^^^^^^^^^ N815 +10 | _mixedCase = 0 +11 | mixed_Case = 0 + | + +N815.py:10:5: N815 Variable `_mixedCase` in class scope should not be mixedCase + | + 8 | CONSTANT = 0 + 9 | mixedCase = 0 +10 | _mixedCase = 0 + | ^^^^^^^^^^ N815 +11 | mixed_Case = 0 +12 | myObj1 = collections.namedtuple("MyObj1", ["a", "b"]) + | + +N815.py:11:5: N815 Variable `mixed_Case` in class scope should not be mixedCase + | + 9 | mixedCase = 0 +10 | _mixedCase = 0 +11 | mixed_Case = 0 + | ^^^^^^^^^^ N815 +12 | myObj1 = collections.namedtuple("MyObj1", ["a", "b"]) +13 | myObj2 = namedtuple("MyObj2", ["a", "b"]) + | + + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N816_N816.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N816_N816.py.snap new file mode 100644 index 0000000000..03281db7ac --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N816_N816.py.snap @@ -0,0 +1,34 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N816.py:7:1: N816 Variable `mixedCase` in global scope should not be mixedCase + | +5 | lower = 0 +6 | CONSTANT = 0 +7 | mixedCase = 0 + | ^^^^^^^^^ N816 +8 | _mixedCase = 0 +9 | mixed_Case = 0 + | + +N816.py:8:1: N816 Variable `_mixedCase` in global scope should not be mixedCase + | + 6 | CONSTANT = 0 + 7 | mixedCase = 0 + 8 | _mixedCase = 0 + | ^^^^^^^^^^ N816 + 9 | mixed_Case = 0 +10 | myObj1 = collections.namedtuple("MyObj1", ["a", "b"]) + | + +N816.py:9:1: N816 Variable `mixed_Case` in global scope should not be mixedCase + | + 7 | mixedCase = 0 + 8 | _mixedCase = 0 + 9 | mixed_Case = 0 + | ^^^^^^^^^^ N816 +10 | myObj1 = collections.namedtuple("MyObj1", ["a", "b"]) +11 | myObj2 = namedtuple("MyObj2", ["a", "b"]) + | + + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N817_N817.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N817_N817.py.snap new file mode 100644 index 0000000000..5615c1fca3 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N817_N817.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N817.py:1:8: N817 CamelCase `CaMel` imported as acronym `CM` + | +1 | import mod.CaMel as CM + | ^^^^^^^^^^^^^^^ N817 +2 | from mod import CamelCase as CC + | + +N817.py:2:17: N817 CamelCase `CamelCase` imported as acronym `CC` + | +1 | import mod.CaMel as CM +2 | from mod import CamelCase as CC + | ^^^^^^^^^^^^^^^ N817 + | + + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N818_N818.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N818_N818.py.snap new file mode 100644 index 0000000000..0ed5704b28 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N818_N818.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N818.py:9:7: N818 Exception name `C` should be named with an Error suffix + | + 9 | class C(Exception): + | ^ N818 +10 | pass + | + +N818.py:17:7: N818 Exception name `E` should be named with an Error suffix + | +17 | class E(AnotherError): + | ^ N818 +18 | pass + | + + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__MODULE____init__.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__MODULE____init__.py.snap new file mode 100644 index 0000000000..a6d10e366b --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__MODULE____init__.py.snap @@ -0,0 +1,8 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +__init__.py:1:1: N999 Invalid module name: 'MODULE' + | + | + + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__MODULE__file.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__MODULE__file.py.snap new file mode 100644 index 0000000000..719c39c477 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__MODULE__file.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__flake9____init__.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__flake9____init__.py.snap new file mode 100644 index 0000000000..719c39c477 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__flake9____init__.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__invalid_name__0001_initial.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__invalid_name__0001_initial.py.snap new file mode 100644 index 0000000000..b23ee6372b --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__invalid_name__0001_initial.py.snap @@ -0,0 +1,8 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +0001_initial.py:1:1: N999 Invalid module name: '0001_initial' + | + | + + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__invalid_name__import.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__invalid_name__import.py.snap new file mode 100644 index 0000000000..025eda7263 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__invalid_name__import.py.snap @@ -0,0 +1,8 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +import.py:1:1: N999 Invalid module name: 'import' + | + | + + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__mod with spaces____init__.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__mod with spaces____init__.py.snap new file mode 100644 index 0000000000..ea610ef580 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__mod with spaces____init__.py.snap @@ -0,0 +1,8 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +__init__.py:1:1: N999 Invalid module name: 'mod with spaces' + | + | + + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__mod with spaces__file.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__mod with spaces__file.py.snap new file mode 100644 index 0000000000..719c39c477 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__mod with spaces__file.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__mod-with-dashes____init__.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__mod-with-dashes____init__.py.snap new file mode 100644 index 0000000000..cda914441c --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__mod-with-dashes____init__.py.snap @@ -0,0 +1,8 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +__init__.py:1:1: N999 Invalid module name: 'mod-with-dashes' + | + | + + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__no_module__test.txt.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__no_module__test.txt.snap new file mode 100644 index 0000000000..719c39c477 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__no_module__test.txt.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__valid_name____init__.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__valid_name____init__.py.snap new file mode 100644 index 0000000000..719c39c477 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__valid_name____init__.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__valid_name____main__.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__valid_name____main__.py.snap new file mode 100644 index 0000000000..719c39c477 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__valid_name____main__.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__valid_name____setup__.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__valid_name____setup__.py.snap new file mode 100644 index 0000000000..719c39c477 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__valid_name____setup__.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__valid_name__file-with-dashes.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__valid_name__file-with-dashes.py.snap new file mode 100644 index 0000000000..5ac41aed6e --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__valid_name__file-with-dashes.py.snap @@ -0,0 +1,8 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +file-with-dashes.py:1:1: N999 Invalid module name: 'file-with-dashes' + | + | + + diff --git a/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__valid_name__file-with-dashes.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__valid_name__file-with-dashes.snap new file mode 100644 index 0000000000..719c39c477 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N999_N999__module__valid_name__file-with-dashes.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- + 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 new file mode 100644 index 0000000000..2cdbc4438e --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__classmethod_decorators.snap @@ -0,0 +1,30 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N805.py:7:20: N805 First argument of a method should be named `self` + | +6 | class Class: +7 | def bad_method(this): + | ^^^^ N805 +8 | pass + | + +N805.py:12:30: N805 First argument of a method should be named `self` + | +10 | if False: +11 | +12 | def extra_bad_method(this): + | ^^^^ N805 +13 | pass + | + +N805.py:64:29: N805 First argument of a method should be named `self` + | +62 | pass +63 | +64 | def bad_method_pos_only(this, blah, /, self, something: str): + | ^^^^ N805 +65 | pass + | + + 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 new file mode 100644 index 0000000000..f594606b62 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N801_N801.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N801.py:4:7: N801 Class name `stillBad` should use CapWords convention + | +2 | pass +3 | +4 | class stillBad: + | ^^^^^^^^ N801 +5 | pass + | + +N801.py:10:7: N801 Class name `STILL_BAD` should use CapWords convention + | + 8 | pass + 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 new file mode 100644 index 0000000000..516e7f5aee --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N802_N802.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N802.py:6:5: N802 Function name `stillBad` should be lowercase + | +4 | pass +5 | +6 | def stillBad(): + | ^^^^^^^^ N802 +7 | pass + | + +N802.py:13:9: N802 Function name `stillBad` should be lowercase + | +11 | return super().tearDown() +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 new file mode 100644 index 0000000000..fbe7f97113 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N803_N803.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N803.py:4:16: N803 Argument name `stillBad` should be lowercase + | +2 | return _, a, badAllowed +3 | +4 | def func(_, a, stillBad): + | ^^^^^^^^ N803 +5 | return _, a, stillBad + | + +N803.py:11:28: N803 Argument name `stillBad` should be lowercase + | + 9 | return _, a, badAllowed +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 new file mode 100644 index 0000000000..cc74a934ce --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N804_N804.py.snap @@ -0,0 +1,29 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N804.py:5:27: N804 First argument of a class method should be named `cls` + | +4 | class Class: +5 | def __init_subclass__(self, default_name, **kwargs): + | ^^^^ N804 +6 | ... + | + +N804.py:13:18: N804 First argument of a class method should be named `cls` + | +12 | @classmethod +13 | def stillBad(self, x, /, other): + | ^^^^ N804 +14 | ... + | + +N804.py:21:18: N804 First argument of a class method should be named `cls` + | +19 | pass +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 new file mode 100644 index 0000000000..e4844d4fe3 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N805_N805.py.snap @@ -0,0 +1,47 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N805.py:10:18: N805 First argument of a method should be named `self` + | + 8 | pass + 9 | +10 | def stillBad(this): + | ^^^^ N805 +11 | pass + | + +N805.py:18:22: N805 First argument of a method should be named `self` + | +16 | pass +17 | +18 | def stillBad(this): + | ^^^^ N805 +19 | pass + | + +N805.py:26:18: N805 First argument of a method should be named `self` + | +25 | @pydantic.validator +26 | def stillBad(cls, my_field: str) -> str: + | ^^^ N805 +27 | pass + | + +N805.py:34:18: N805 First argument of a method should be named `self` + | +33 | @pydantic.validator("my_field") +34 | def stillBad(cls, my_field: str) -> str: + | ^^^ N805 +35 | pass + | + +N805.py:58:18: N805 First argument of a method should be named `self` + | +56 | pass +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 new file mode 100644 index 0000000000..7c718b9c8f --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N806_N806.py.snap @@ -0,0 +1,21 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N806.py:3:5: N806 Variable `stillBad` in function should be lowercase + | +1 | def assign(): +2 | badAllowed = 0 +3 | stillBad = 0 + | ^^^^^^^^ N806 +4 | +5 | BAD_ALLOWED = 0 + | + +N806.py:6:5: N806 Variable `STILL_BAD` in function should be lowercase + | +5 | BAD_ALLOWED = 0 +6 | STILL_BAD = 0 + | ^^^^^^^^^ N806 + | + + 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 new file mode 100644 index 0000000000..691b3ddbee --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N807_N807.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N807.py:4:5: N807 Function name should not start and end with `__` + | +2 | pass +3 | +4 | def __stillBad__(): + | ^^^^^^^^^^^^ N807 +5 | pass + | + +N807.py:12:9: N807 Function name should not start and end with `__` + | +10 | pass +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 new file mode 100644 index 0000000000..4c76ee9b84 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N811_N811.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +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 | +4 | from mod import BAD_ALLOWED as badAllowed + | + +N811.py:5:17: N811 Constant `STILL_BAD` imported as non-constant `stillBad` + | +4 | from mod import BAD_ALLOWED as badAllowed +5 | from mod import STILL_BAD as stillBad + | ^^^^^^^^^^^^^^^^^^^^^ N811 + | + + 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 new file mode 100644 index 0000000000..5e40f3a2ac --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N812_N812.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +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 | +4 | from mod import badallowed as BadAllowed + | + +N812.py:5:17: N812 Lowercase `stillbad` imported as non-lowercase `StillBad` + | +4 | from mod import badallowed as BadAllowed +5 | from mod import stillbad as StillBad + | ^^^^^^^^^^^^^^^^^^^^ N812 + | + + 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 new file mode 100644 index 0000000000..ce2bc77af7 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N813_N813.py.snap @@ -0,0 +1,29 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +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 | +4 | from mod import BadAllowed as badallowed + | + +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 | +7 | from mod import BadAllowed as bad_allowed + | + +N813.py:8:17: N813 Camelcase `StillBad` imported as lowercase `still_bad` + | +7 | from mod import BadAllowed as bad_allowed +8 | from mod import StillBad as still_bad + | ^^^^^^^^^^^^^^^^^^^^^ N813 + | + + 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 new file mode 100644 index 0000000000..d134f3384d --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N814_N814.py.snap @@ -0,0 +1,29 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +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 | +4 | from mod import BadAllowed as BADALLOWED + | + +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 | +7 | from mod import BadAllowed as BAD_ALLOWED + | + +N814.py:8:17: N814 Camelcase `StillBad` imported as constant `STILL_BAD` + | +7 | from mod import BadAllowed as BAD_ALLOWED +8 | from mod import StillBad as STILL_BAD + | ^^^^^^^^^^^^^^^^^^^^^ N814 + | + + 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 new file mode 100644 index 0000000000..85aad3c0b3 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N815_N815.py.snap @@ -0,0 +1,58 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N815.py:3:5: N815 Variable `stillBad` in class scope should not be mixedCase + | +1 | class C: +2 | badAllowed = 0 +3 | stillBad = 0 + | ^^^^^^^^ N815 +4 | +5 | _badAllowed = 0 + | + +N815.py:6:5: N815 Variable `_stillBad` in class scope should not be mixedCase + | +5 | _badAllowed = 0 +6 | _stillBad = 0 + | ^^^^^^^^^ N815 +7 | +8 | bad_Allowed = 0 + | + +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 | +11 | class D(TypedDict): + | + +N815.py:13:5: N815 Variable `stillBad` in class scope should not be mixedCase + | +11 | class D(TypedDict): +12 | badAllowed: bool +13 | stillBad: bool + | ^^^^^^^^ N815 +14 | +15 | _badAllowed: list + | + +N815.py:16:5: N815 Variable `_stillBad` in class scope should not be mixedCase + | +15 | _badAllowed: list +16 | _stillBad: list + | ^^^^^^^^^ N815 +17 | +18 | bad_Allowed: set + | + +N815.py:19:5: N815 Variable `still_Bad` in class scope should not be mixedCase + | +18 | bad_Allowed: set +19 | still_Bad: set + | ^^^^^^^^^ N815 + | + + 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 new file mode 100644 index 0000000000..56f48fe0a7 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N816_N816.py.snap @@ -0,0 +1,29 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N816.py:2:1: N816 Variable `stillBad` in global scope should not be mixedCase + | +1 | badAllowed = 0 +2 | stillBad = 0 + | ^^^^^^^^ N816 +3 | +4 | _badAllowed = 0 + | + +N816.py:5:1: N816 Variable `_stillBad` in global scope should not be mixedCase + | +4 | _badAllowed = 0 +5 | _stillBad = 0 + | ^^^^^^^^^ N816 +6 | +7 | bad_Allowed = 0 + | + +N816.py:8:1: N816 Variable `still_Bad` in global scope should not be mixedCase + | +7 | bad_Allowed = 0 +8 | still_Bad = 0 + | ^^^^^^^^^ N816 + | + + 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 new file mode 100644 index 0000000000..c746a3a0c2 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N817_N817.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +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 | +4 | from mod import BadAllowed as BA + | + +N817.py:5:17: N817 CamelCase `StillBad` imported as acronym `SB` + | +4 | from mod import BadAllowed as BA +5 | from mod import StillBad as SB + | ^^^^^^^^^^^^^^ N817 + | + + 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 new file mode 100644 index 0000000000..fc378dc639 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N818_N818.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- +N818.py:4:7: N818 Exception name `StillBad` should be named with an Error suffix + | +2 | pass +3 | +4 | class StillBad(Exception): + | ^^^^^^^^ N818 +5 | pass + | + +N818.py:10:7: N818 Exception name `StillBad` should be named with an Error suffix + | + 8 | pass + 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__ignore_names_N999_N999__badAllowed____init__.py.snap b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N999_N999__badAllowed____init__.py.snap new file mode 100644 index 0000000000..719c39c477 --- /dev/null +++ b/crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__ignore_names_N999_N999__badAllowed____init__.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pep8_naming/mod.rs +--- + diff --git a/crates/ruff/src/rules/perflint/mod.rs b/crates/ruff_linter/src/rules/perflint/mod.rs similarity index 100% rename from crates/ruff/src/rules/perflint/mod.rs rename to crates/ruff_linter/src/rules/perflint/mod.rs diff --git a/crates/ruff/src/rules/perflint/rules/incorrect_dict_iterator.rs b/crates/ruff_linter/src/rules/perflint/rules/incorrect_dict_iterator.rs similarity index 100% rename from crates/ruff/src/rules/perflint/rules/incorrect_dict_iterator.rs rename to crates/ruff_linter/src/rules/perflint/rules/incorrect_dict_iterator.rs diff --git a/crates/ruff/src/rules/perflint/rules/manual_dict_comprehension.rs b/crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs similarity index 100% rename from crates/ruff/src/rules/perflint/rules/manual_dict_comprehension.rs rename to crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs diff --git a/crates/ruff/src/rules/perflint/rules/manual_list_comprehension.rs b/crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs similarity index 100% rename from crates/ruff/src/rules/perflint/rules/manual_list_comprehension.rs rename to crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs diff --git a/crates/ruff/src/rules/perflint/rules/manual_list_copy.rs b/crates/ruff_linter/src/rules/perflint/rules/manual_list_copy.rs similarity index 100% rename from crates/ruff/src/rules/perflint/rules/manual_list_copy.rs rename to crates/ruff_linter/src/rules/perflint/rules/manual_list_copy.rs diff --git a/crates/ruff/src/rules/perflint/rules/mod.rs b/crates/ruff_linter/src/rules/perflint/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/perflint/rules/mod.rs rename to crates/ruff_linter/src/rules/perflint/rules/mod.rs diff --git a/crates/ruff/src/rules/perflint/rules/try_except_in_loop.rs b/crates/ruff_linter/src/rules/perflint/rules/try_except_in_loop.rs similarity index 100% rename from crates/ruff/src/rules/perflint/rules/try_except_in_loop.rs rename to crates/ruff_linter/src/rules/perflint/rules/try_except_in_loop.rs diff --git a/crates/ruff/src/rules/perflint/rules/unnecessary_list_cast.rs b/crates/ruff_linter/src/rules/perflint/rules/unnecessary_list_cast.rs similarity index 100% rename from crates/ruff/src/rules/perflint/rules/unnecessary_list_cast.rs rename to crates/ruff_linter/src/rules/perflint/rules/unnecessary_list_cast.rs 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 new file mode 100644 index 0000000000..a51e257199 --- /dev/null +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF101_PERF101.py.snap @@ -0,0 +1,183 @@ +--- +source: crates/ruff_linter/src/rules/perflint/mod.rs +--- +PERF101.py:7:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it + | +5 | foo_int = 123 +6 | +7 | for i in list(foo_tuple): # PERF101 + | ^^^^^^^^^^^^^^^ PERF101 +8 | pass + | + = help: Remove `list()` cast + +ℹ Fix +4 4 | foo_dict = {1: 2, 3: 4} +5 5 | foo_int = 123 +6 6 | +7 |-for i in list(foo_tuple): # PERF101 + 7 |+for i in foo_tuple: # PERF101 +8 8 | pass +9 9 | +10 10 | for i in list(foo_list): # PERF101 + +PERF101.py:10:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it + | + 8 | pass + 9 | +10 | for i in list(foo_list): # PERF101 + | ^^^^^^^^^^^^^^ PERF101 +11 | pass + | + = help: Remove `list()` cast + +ℹ Fix +7 7 | for i in list(foo_tuple): # PERF101 +8 8 | pass +9 9 | +10 |-for i in list(foo_list): # PERF101 + 10 |+for i in foo_list: # PERF101 +11 11 | pass +12 12 | +13 13 | for i in list(foo_set): # PERF101 + +PERF101.py:13:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it + | +11 | pass +12 | +13 | for i in list(foo_set): # PERF101 + | ^^^^^^^^^^^^^ PERF101 +14 | pass + | + = help: Remove `list()` cast + +ℹ Fix +10 10 | for i in list(foo_list): # PERF101 +11 11 | pass +12 12 | +13 |-for i in list(foo_set): # PERF101 + 13 |+for i in foo_set: # PERF101 +14 14 | pass +15 15 | +16 16 | for i in list((1, 2, 3)): # PERF101 + +PERF101.py:16:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it + | +14 | pass +15 | +16 | for i in list((1, 2, 3)): # PERF101 + | ^^^^^^^^^^^^^^^ PERF101 +17 | pass + | + = help: Remove `list()` cast + +ℹ Fix +13 13 | for i in list(foo_set): # PERF101 +14 14 | pass +15 15 | +16 |-for i in list((1, 2, 3)): # PERF101 + 16 |+for i in (1, 2, 3): # PERF101 +17 17 | pass +18 18 | +19 19 | for i in list([1, 2, 3]): # PERF101 + +PERF101.py:19:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it + | +17 | pass +18 | +19 | for i in list([1, 2, 3]): # PERF101 + | ^^^^^^^^^^^^^^^ PERF101 +20 | pass + | + = help: Remove `list()` cast + +ℹ Fix +16 16 | for i in list((1, 2, 3)): # PERF101 +17 17 | pass +18 18 | +19 |-for i in list([1, 2, 3]): # PERF101 + 19 |+for i in [1, 2, 3]: # PERF101 +20 20 | pass +21 21 | +22 22 | for i in list({1, 2, 3}): # PERF101 + +PERF101.py:22:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it + | +20 | pass +21 | +22 | for i in list({1, 2, 3}): # PERF101 + | ^^^^^^^^^^^^^^^ PERF101 +23 | pass + | + = help: Remove `list()` cast + +ℹ Fix +19 19 | for i in list([1, 2, 3]): # PERF101 +20 20 | pass +21 21 | +22 |-for i in list({1, 2, 3}): # PERF101 + 22 |+for i in {1, 2, 3}: # PERF101 +23 23 | pass +24 24 | +25 25 | for i in list( + +PERF101.py:25:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it + | +23 | pass +24 | +25 | for i in list( + | __________^ +26 | | { +27 | | 1, +28 | | 2, +29 | | 3, +30 | | } +31 | | ): + | |_^ PERF101 +32 | pass + | + = help: Remove `list()` cast + +ℹ Fix +22 22 | for i in list({1, 2, 3}): # PERF101 +23 23 | pass +24 24 | +25 |-for i in list( +26 |- { + 25 |+for i in { +27 26 | 1, +28 27 | 2, +29 28 | 3, +30 |- } +31 |-): + 29 |+ }: +32 30 | pass +33 31 | +34 32 | for i in list( # Comment + +PERF101.py:34:10: PERF101 [*] Do not cast an iterable to `list` before iterating over it + | +32 | pass +33 | +34 | for i in list( # Comment + | __________^ +35 | | {1, 2, 3} +36 | | ): # PERF101 + | |_^ PERF101 +37 | pass + | + = help: Remove `list()` cast + +ℹ Fix +31 31 | ): +32 32 | pass +33 33 | +34 |-for i in list( # Comment +35 |- {1, 2, 3} +36 |-): # PERF101 + 34 |+for i in {1, 2, 3}: # PERF101 +37 35 | pass +38 36 | +39 37 | for i in list(foo_dict): # Ok + + diff --git a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF102_PERF102.py.snap b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF102_PERF102.py.snap new file mode 100644 index 0000000000..e5a71ef5ec --- /dev/null +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF102_PERF102.py.snap @@ -0,0 +1,211 @@ +--- +source: crates/ruff_linter/src/rules/perflint/mod.rs +--- +PERF102.py:5:21: PERF102 [*] When using only the values of a dict use the `values()` method + | +4 | def f(): +5 | for _, value in some_dict.items(): # PERF102 + | ^^^^^^^^^^^^^^^ PERF102 +6 | print(value) + | + = help: Replace `.items()` with `.values()` + +ℹ Suggested fix +2 2 | +3 3 | +4 4 | def f(): +5 |- for _, value in some_dict.items(): # PERF102 + 5 |+ for value in some_dict.values(): # PERF102 +6 6 | print(value) +7 7 | +8 8 | + +PERF102.py:10:19: PERF102 [*] When using only the keys of a dict use the `keys()` method + | + 9 | def f(): +10 | for key, _ in some_dict.items(): # PERF102 + | ^^^^^^^^^^^^^^^ PERF102 +11 | print(key) + | + = help: Replace `.items()` with `.keys()` + +ℹ Suggested fix +7 7 | +8 8 | +9 9 | def f(): +10 |- for key, _ in some_dict.items(): # PERF102 + 10 |+ for key in some_dict.keys(): # PERF102 +11 11 | print(key) +12 12 | +13 13 | + +PERF102.py:15:30: PERF102 [*] When using only the keys of a dict use the `keys()` method + | +14 | def f(): +15 | for weird_arg_name, _ in some_dict.items(): # PERF102 + | ^^^^^^^^^^^^^^^ PERF102 +16 | print(weird_arg_name) + | + = help: Replace `.items()` with `.keys()` + +ℹ Suggested fix +12 12 | +13 13 | +14 14 | def f(): +15 |- for weird_arg_name, _ in some_dict.items(): # PERF102 + 15 |+ for weird_arg_name in some_dict.keys(): # PERF102 +16 16 | print(weird_arg_name) +17 17 | +18 18 | + +PERF102.py:20:25: PERF102 [*] When using only the keys of a dict use the `keys()` method + | +19 | def f(): +20 | for name, (_, _) in some_dict.items(): # PERF102 + | ^^^^^^^^^^^^^^^ PERF102 +21 | print(name) + | + = help: Replace `.items()` with `.keys()` + +ℹ Suggested fix +17 17 | +18 18 | +19 19 | def f(): +20 |- for name, (_, _) in some_dict.items(): # PERF102 + 20 |+ for name in some_dict.keys(): # PERF102 +21 21 | print(name) +22 22 | +23 23 | + +PERF102.py:30:30: PERF102 [*] When using only the keys of a dict use the `keys()` method + | +29 | def f(): +30 | for (key1, _), (_, _) in some_dict.items(): # PERF102 + | ^^^^^^^^^^^^^^^ PERF102 +31 | print(key1) + | + = help: Replace `.items()` with `.keys()` + +ℹ Suggested fix +27 27 | +28 28 | +29 29 | def f(): +30 |- for (key1, _), (_, _) in some_dict.items(): # PERF102 + 30 |+ for (key1, _) in some_dict.keys(): # PERF102 +31 31 | print(key1) +32 32 | +33 33 | + +PERF102.py:35:36: PERF102 [*] When using only the values of a dict use the `values()` method + | +34 | def f(): +35 | for (_, (_, _)), (value, _) in some_dict.items(): # PERF102 + | ^^^^^^^^^^^^^^^ PERF102 +36 | print(value) + | + = help: Replace `.items()` with `.values()` + +ℹ Suggested fix +32 32 | +33 33 | +34 34 | def f(): +35 |- for (_, (_, _)), (value, _) in some_dict.items(): # PERF102 + 35 |+ for (value, _) in some_dict.values(): # PERF102 +36 36 | print(value) +37 37 | +38 38 | + +PERF102.py:50:32: PERF102 [*] When using only the keys of a dict use the `keys()` method + | +49 | def f(): +50 | for ((_, key2), (_, _)) in some_dict.items(): # PERF102 + | ^^^^^^^^^^^^^^^ PERF102 +51 | print(key2) + | + = help: Replace `.items()` with `.keys()` + +ℹ Suggested fix +47 47 | +48 48 | +49 49 | def f(): +50 |- for ((_, key2), (_, _)) in some_dict.items(): # PERF102 + 50 |+ for (_, key2) in some_dict.keys(): # PERF102 +51 51 | print(key2) +52 52 | +53 53 | + +PERF102.py:85:25: PERF102 [*] When using only the keys of a dict use the `keys()` method + | +84 | def f(): +85 | for name, (_, _) in (some_function()).items(): # PERF102 + | ^^^^^^^^^^^^^^^^^^^^^^^ PERF102 +86 | print(name) + | + = help: Replace `.items()` with `.keys()` + +ℹ Suggested fix +82 82 | +83 83 | +84 84 | def f(): +85 |- for name, (_, _) in (some_function()).items(): # PERF102 + 85 |+ for name in (some_function()).keys(): # PERF102 +86 86 | print(name) +87 87 | +88 88 | + +PERF102.py:90:25: PERF102 [*] When using only the keys of a dict use the `keys()` method + | +89 | def f(): +90 | for name, (_, _) in (some_function().some_attribute).items(): # PERF102 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PERF102 +91 | print(name) + | + = help: Replace `.items()` with `.keys()` + +ℹ Suggested fix +87 87 | +88 88 | +89 89 | def f(): +90 |- for name, (_, _) in (some_function().some_attribute).items(): # PERF102 + 90 |+ for name in (some_function().some_attribute).keys(): # PERF102 +91 91 | print(name) +92 92 | +93 93 | + +PERF102.py:95:31: PERF102 [*] When using only the keys of a dict use the `keys()` method + | +94 | def f(): +95 | for name, unused_value in some_dict.items(): # PERF102 + | ^^^^^^^^^^^^^^^ PERF102 +96 | print(name) + | + = help: Replace `.items()` with `.keys()` + +ℹ Suggested fix +92 92 | +93 93 | +94 94 | def f(): +95 |- for name, unused_value in some_dict.items(): # PERF102 + 95 |+ for name in some_dict.keys(): # PERF102 +96 96 | print(name) +97 97 | +98 98 | + +PERF102.py:100:31: PERF102 [*] When using only the values of a dict use the `values()` method + | + 99 | def f(): +100 | for unused_name, value in some_dict.items(): # PERF102 + | ^^^^^^^^^^^^^^^ PERF102 +101 | print(value) + | + = help: Replace `.items()` with `.values()` + +ℹ Suggested fix +97 97 | +98 98 | +99 99 | def f(): +100 |- for unused_name, value in some_dict.items(): # PERF102 + 100 |+ for value in some_dict.values(): # PERF102 +101 101 | print(value) + + 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 new file mode 100644 index 0000000000..e67fdafc24 --- /dev/null +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF203_PERF203.py.snap @@ -0,0 +1,16 @@ +--- +source: crates/ruff_linter/src/rules/perflint/mod.rs +--- +PERF203.py:5:5: PERF203 `try`-`except` within a loop incurs performance overhead + | +3 | try: +4 | print(f"{i}") +5 | except: + | _____^ +6 | | print("error") + | |______________________^ PERF203 +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 new file mode 100644 index 0000000000..2010bb74a6 --- /dev/null +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF401_PERF401.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/perflint/mod.rs +--- +PERF401.py:6:13: PERF401 Use a list comprehension to create a transformed list + | +4 | for i in items: +5 | if i % 2: +6 | result.append(i) # PERF401 + | ^^^^^^^^^^^^^^^^ PERF401 + | + +PERF401.py:13:9: PERF401 Use a list comprehension to create a transformed list + | +11 | result = [] +12 | for i in items: +13 | result.append(i * i) # PERF401 + | ^^^^^^^^^^^^^^^^^^^^ PERF401 + | + + diff --git a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF402_PERF402.py.snap b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF402_PERF402.py.snap new file mode 100644 index 0000000000..08bcfb4a0c --- /dev/null +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF402_PERF402.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/perflint/mod.rs +--- +PERF402.py:5:9: PERF402 Use `list` or `list.copy` to create a copy of a list + | +3 | result = [] +4 | for i in items: +5 | result.append(i) # PERF402 + | ^^^^^^^^^^^^^^^^ PERF402 + | + + diff --git a/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF403_PERF403.py.snap b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF403_PERF403.py.snap new file mode 100644 index 0000000000..38e98d9faf --- /dev/null +++ b/crates/ruff_linter/src/rules/perflint/snapshots/ruff_linter__rules__perflint__tests__PERF403_PERF403.py.snap @@ -0,0 +1,52 @@ +--- +source: crates/ruff_linter/src/rules/perflint/mod.rs +--- +PERF403.py:5:9: PERF403 Use a dictionary comprehension instead of a for-loop + | +3 | result = {} +4 | for idx, name in enumerate(fruit): +5 | result[idx] = name # PERF403 + | ^^^^^^^^^^^^^^^^^^ PERF403 + | + +PERF403.py:13:13: PERF403 Use a dictionary comprehension instead of a for-loop + | +11 | for idx, name in enumerate(fruit): +12 | if idx % 2: +13 | result[idx] = name # PERF403 + | ^^^^^^^^^^^^^^^^^^ PERF403 + | + +PERF403.py:31:13: PERF403 Use a dictionary comprehension instead of a for-loop + | +29 | for idx, name in enumerate(fruit): +30 | if idx % 2: +31 | result[idx] = name # PERF403 + | ^^^^^^^^^^^^^^^^^^ PERF403 + | + +PERF403.py:61:13: PERF403 Use a dictionary comprehension instead of a for-loop + | +59 | for idx, name in enumerate(fruit): +60 | if idx % 2: +61 | result[idx] = name # PERF403 + | ^^^^^^^^^^^^^^^^^^ PERF403 + | + +PERF403.py:76:9: PERF403 Use a dictionary comprehension instead of a for-loop + | +74 | result = {} +75 | for name in fruit: +76 | result[name] = name # PERF403 + | ^^^^^^^^^^^^^^^^^^^ PERF403 + | + +PERF403.py:83:9: PERF403 Use a dictionary comprehension instead of a for-loop + | +81 | result = {} +82 | for idx, name in enumerate(fruit): +83 | result[name] = idx # PERF403 + | ^^^^^^^^^^^^^^^^^^ PERF403 + | + + diff --git a/crates/ruff/src/rules/pycodestyle/helpers.rs b/crates/ruff_linter/src/rules/pycodestyle/helpers.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/helpers.rs rename to crates/ruff_linter/src/rules/pycodestyle/helpers.rs diff --git a/crates/ruff/src/rules/pycodestyle/mod.rs b/crates/ruff_linter/src/rules/pycodestyle/mod.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/mod.rs rename to crates/ruff_linter/src/rules/pycodestyle/mod.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/ambiguous_class_name.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/ambiguous_class_name.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/ambiguous_class_name.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/ambiguous_class_name.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/ambiguous_function_name.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/ambiguous_function_name.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/ambiguous_function_name.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/ambiguous_function_name.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/ambiguous_variable_name.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/ambiguous_variable_name.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/ambiguous_variable_name.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/ambiguous_variable_name.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/bare_except.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/bare_except.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/bare_except.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/bare_except.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/compound_statements.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/compound_statements.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/compound_statements.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/compound_statements.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/doc_line_too_long.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/doc_line_too_long.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/doc_line_too_long.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/doc_line_too_long.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/errors.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/errors.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/errors.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/errors.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/imports.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/imports.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/imports.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/imports.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/invalid_escape_sequence.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/invalid_escape_sequence.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/invalid_escape_sequence.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/invalid_escape_sequence.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/lambda_assignment.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/lambda_assignment.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/lambda_assignment.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/lambda_assignment.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/line_too_long.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/line_too_long.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/line_too_long.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/line_too_long.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/literal_comparisons.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/literal_comparisons.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/literal_comparisons.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/literal_comparisons.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/indentation.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/indentation.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/logical_lines/indentation.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/indentation.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_after_keyword.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_after_keyword.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_after_keyword.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_after_keyword.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_around_operator.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_around_operator.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_around_operator.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_around_operator.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/mod.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/mod.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/logical_lines/mod.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/mod.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_around_keywords.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_around_keywords.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_around_keywords.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_around_keywords.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_around_named_parameter_equals.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_around_named_parameter_equals.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_around_named_parameter_equals.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_around_named_parameter_equals.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_comment.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_before_comment.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_comment.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_before_comment.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_parameters.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_before_parameters.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_parameters.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_before_parameters.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/missing_newline_at_end_of_file.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/missing_newline_at_end_of_file.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/missing_newline_at_end_of_file.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/missing_newline_at_end_of_file.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/mixed_spaces_and_tabs.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/mixed_spaces_and_tabs.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/mixed_spaces_and_tabs.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/mixed_spaces_and_tabs.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/mod.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/mod.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/mod.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/not_tests.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/not_tests.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/not_tests.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/not_tests.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/tab_indentation.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/tab_indentation.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/tab_indentation.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/tab_indentation.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/trailing_whitespace.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/trailing_whitespace.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/trailing_whitespace.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/trailing_whitespace.rs diff --git a/crates/ruff/src/rules/pycodestyle/rules/type_comparison.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/type_comparison.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/rules/type_comparison.rs rename to crates/ruff_linter/src/rules/pycodestyle/rules/type_comparison.rs diff --git a/crates/ruff/src/rules/pycodestyle/settings.rs b/crates/ruff_linter/src/rules/pycodestyle/settings.rs similarity index 100% rename from crates/ruff/src/rules/pycodestyle/settings.rs rename to crates/ruff_linter/src/rules/pycodestyle/settings.rs 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 new file mode 100644 index 0000000000..cfd70d8a76 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E101_E101.py.snap @@ -0,0 +1,32 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E101.py:11:1: E101 Indentation contains mixed spaces and tabs + | + 9 | def func_mixed_start_with_tab(): +10 | # E101 +11 | print("mixed starts with tab") + | ^^^^^^ E101 +12 | +13 | def func_mixed_start_with_space(): + | + +E101.py:15:1: E101 Indentation contains mixed spaces and tabs + | +13 | def func_mixed_start_with_space(): +14 | # E101 +15 | print("mixed starts with space") + | ^^^^^^^^^^^^^^^ E101 +16 | +17 | def xyz(): + | + +E101.py:19:1: E101 Indentation contains mixed spaces and tabs + | +17 | def xyz(): +18 | # E101 +19 | print("xyz"); + | ^^^^ E101 + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E111_E11.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E111_E11.py.snap new file mode 100644 index 0000000000..5ff96325ee --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E111_E11.py.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E11.py:3:1: E111 Indentation is not a multiple of 4 + | +1 | #: E111 +2 | if x > 2: +3 | print(x) + | ^^ E111 +4 | #: E111 E117 +5 | if True: + | + +E11.py:6:1: E111 Indentation is not a multiple of 4 + | +4 | #: E111 E117 +5 | if True: +6 | print() + | ^^^^^ E111 +7 | #: E112 +8 | if False: + | + + 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 new file mode 100644 index 0000000000..ea4f5346a8 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E112_E11.py.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E11.py:9:1: E112 Expected an indented block + | + 7 | #: E112 + 8 | if False: + 9 | print() + | E112 +10 | #: E113 +11 | print() + | + +E11.py:45:1: E112 Expected an indented block + | +43 | #: E112 +44 | if False: # +45 | print() + | E112 +46 | #: +47 | if False: + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E113_E11.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E113_E11.py.snap new file mode 100644 index 0000000000..fe41aac33f --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E113_E11.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E11.py:12:1: E113 Unexpected indentation + | +10 | #: E113 +11 | print() +12 | print() + | ^^^^ E113 +13 | #: E114 E116 +14 | mimetype = 'application/x-directory' + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E114_E11.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E114_E11.py.snap new file mode 100644 index 0000000000..3fcbbc03f8 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E114_E11.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E11.py:15:1: E114 Indentation is not a multiple of 4 (comment) + | +13 | #: E114 E116 +14 | mimetype = 'application/x-directory' +15 | # 'httpd/unix-directory' + | ^^^^^ E114 +16 | create_date = False +17 | #: E116 E116 E116 + | + + 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 new file mode 100644 index 0000000000..34e21b201e --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E115_E11.py.snap @@ -0,0 +1,64 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E11.py:30:1: E115 Expected an indented block (comment) + | +28 | def start(self): +29 | if True: +30 | # try: + | E115 +31 | # self.master.start() +32 | # except MasterExit: + | + +E11.py:31:1: E115 Expected an indented block (comment) + | +29 | if True: +30 | # try: +31 | # self.master.start() + | E115 +32 | # except MasterExit: +33 | # self.shutdown() + | + +E11.py:32:1: E115 Expected an indented block (comment) + | +30 | # try: +31 | # self.master.start() +32 | # except MasterExit: + | E115 +33 | # self.shutdown() +34 | # finally: + | + +E11.py:33:1: E115 Expected an indented block (comment) + | +31 | # self.master.start() +32 | # except MasterExit: +33 | # self.shutdown() + | E115 +34 | # finally: +35 | # sys.exit() + | + +E11.py:34:1: E115 Expected an indented block (comment) + | +32 | # except MasterExit: +33 | # self.shutdown() +34 | # finally: + | E115 +35 | # sys.exit() +36 | self.master.start() + | + +E11.py:35:1: E115 Expected an indented block (comment) + | +33 | # self.shutdown() +34 | # finally: +35 | # sys.exit() + | E115 +36 | self.master.start() +37 | #: E117 + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E116_E11.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E116_E11.py.snap new file mode 100644 index 0000000000..8f1a719473 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E116_E11.py.snap @@ -0,0 +1,44 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E11.py:15:1: E116 Unexpected indentation (comment) + | +13 | #: E114 E116 +14 | mimetype = 'application/x-directory' +15 | # 'httpd/unix-directory' + | ^^^^^ E116 +16 | create_date = False +17 | #: E116 E116 E116 + | + +E11.py:22:1: E116 Unexpected indentation (comment) + | +20 | self.master.start() +21 | # try: +22 | # self.master.start() + | ^^^^^^^^^^^^ E116 +23 | # except MasterExit: +24 | # self.shutdown() + | + +E11.py:24:1: E116 Unexpected indentation (comment) + | +22 | # self.master.start() +23 | # except MasterExit: +24 | # self.shutdown() + | ^^^^^^^^^^^^ E116 +25 | # finally: +26 | # sys.exit() + | + +E11.py:26:1: E116 Unexpected indentation (comment) + | +24 | # self.shutdown() +25 | # finally: +26 | # sys.exit() + | ^^^^^^^^^^^^ E116 +27 | #: E115 E115 E115 E115 E115 E115 +28 | def start(self): + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E117_E11.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E117_E11.py.snap new file mode 100644 index 0000000000..fc9e939039 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E117_E11.py.snap @@ -0,0 +1,34 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E11.py:6:1: E117 Over-indented + | +4 | #: E111 E117 +5 | if True: +6 | print() + | ^^^^^ E117 +7 | #: E112 +8 | if False: + | + +E11.py:39:1: E117 Over-indented + | +37 | #: E117 +38 | def start(): +39 | print() + | ^^^^^^^^ E117 +40 | #: E117 W191 +41 | def start(): + | + +E11.py:42:1: E117 Over-indented + | +40 | #: E117 W191 +41 | def start(): +42 | print() + | ^^^^^^^^ E117 +43 | #: E112 +44 | if False: # + | + + 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 new file mode 100644 index 0000000000..a7eb5c281c --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E201_E20.py.snap @@ -0,0 +1,147 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E20.py:2:6: E201 [*] Whitespace after '(' + | +1 | #: E201:1:6 +2 | spam( ham[1], {eggs: 2}) + | ^ E201 +3 | #: E201:1:10 +4 | spam(ham[ 1], {eggs: 2}) + | + = help: Remove whitespace before '(' + +ℹ Fix +1 1 | #: E201:1:6 +2 |-spam( ham[1], {eggs: 2}) + 2 |+spam(ham[1], {eggs: 2}) +3 3 | #: E201:1:10 +4 4 | spam(ham[ 1], {eggs: 2}) +5 5 | #: E201:1:15 + +E20.py:4:10: E201 [*] Whitespace after '[' + | +2 | spam( ham[1], {eggs: 2}) +3 | #: E201:1:10 +4 | spam(ham[ 1], {eggs: 2}) + | ^ E201 +5 | #: E201:1:15 +6 | spam(ham[1], { eggs: 2}) + | + = help: Remove whitespace before '[' + +ℹ Fix +1 1 | #: E201:1:6 +2 2 | spam( ham[1], {eggs: 2}) +3 3 | #: E201:1:10 +4 |-spam(ham[ 1], {eggs: 2}) + 4 |+spam(ham[1], {eggs: 2}) +5 5 | #: E201:1:15 +6 6 | spam(ham[1], { eggs: 2}) +7 7 | #: E201:1:6 + +E20.py:6:15: E201 [*] Whitespace after '{' + | +4 | spam(ham[ 1], {eggs: 2}) +5 | #: E201:1:15 +6 | spam(ham[1], { eggs: 2}) + | ^ E201 +7 | #: E201:1:6 +8 | spam( ham[1], {eggs: 2}) + | + = help: Remove whitespace before '{' + +ℹ Fix +3 3 | #: E201:1:10 +4 4 | spam(ham[ 1], {eggs: 2}) +5 5 | #: E201:1:15 +6 |-spam(ham[1], { eggs: 2}) + 6 |+spam(ham[1], {eggs: 2}) +7 7 | #: E201:1:6 +8 8 | spam( ham[1], {eggs: 2}) +9 9 | #: E201:1:10 + +E20.py:8:6: E201 [*] Whitespace after '(' + | + 6 | spam(ham[1], { eggs: 2}) + 7 | #: E201:1:6 + 8 | spam( ham[1], {eggs: 2}) + | ^^^ E201 + 9 | #: E201:1:10 +10 | spam(ham[ 1], {eggs: 2}) + | + = help: Remove whitespace before '(' + +ℹ Fix +5 5 | #: E201:1:15 +6 6 | spam(ham[1], { eggs: 2}) +7 7 | #: E201:1:6 +8 |-spam( ham[1], {eggs: 2}) + 8 |+spam(ham[1], {eggs: 2}) +9 9 | #: E201:1:10 +10 10 | spam(ham[ 1], {eggs: 2}) +11 11 | #: E201:1:15 + +E20.py:10:10: E201 [*] Whitespace after '[' + | + 8 | spam( ham[1], {eggs: 2}) + 9 | #: E201:1:10 +10 | spam(ham[ 1], {eggs: 2}) + | ^^^ E201 +11 | #: E201:1:15 +12 | spam(ham[1], { eggs: 2}) + | + = help: Remove whitespace before '[' + +ℹ Fix +7 7 | #: E201:1:6 +8 8 | spam( ham[1], {eggs: 2}) +9 9 | #: E201:1:10 +10 |-spam(ham[ 1], {eggs: 2}) + 10 |+spam(ham[1], {eggs: 2}) +11 11 | #: E201:1:15 +12 12 | spam(ham[1], { eggs: 2}) +13 13 | #: Okay + +E20.py:12:15: E201 [*] Whitespace after '{' + | +10 | spam(ham[ 1], {eggs: 2}) +11 | #: E201:1:15 +12 | spam(ham[1], { eggs: 2}) + | ^^ E201 +13 | #: Okay +14 | spam(ham[1], {eggs: 2}) + | + = help: Remove whitespace before '{' + +ℹ Fix +9 9 | #: E201:1:10 +10 10 | spam(ham[ 1], {eggs: 2}) +11 11 | #: E201:1:15 +12 |-spam(ham[1], { eggs: 2}) + 12 |+spam(ham[1], {eggs: 2}) +13 13 | #: Okay +14 14 | spam(ham[1], {eggs: 2}) +15 15 | #: + +E20.py:81:6: E201 [*] Whitespace after '[' + | +80 | #: E201:1:6 +81 | spam[ ~ham] + | ^ E201 +82 | +83 | #: Okay + | + = help: Remove whitespace before '[' + +ℹ Fix +78 78 | #: +79 79 | +80 80 | #: E201:1:6 +81 |-spam[ ~ham] + 81 |+spam[~ham] +82 82 | +83 83 | #: Okay +84 84 | x = [ # + + 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 new file mode 100644 index 0000000000..4382a6f14d --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E202_E20.py.snap @@ -0,0 +1,129 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E20.py:19:23: E202 [*] Whitespace before ')' + | +18 | #: E202:1:23 +19 | spam(ham[1], {eggs: 2} ) + | ^ E202 +20 | #: E202:1:22 +21 | spam(ham[1], {eggs: 2 }) + | + = help: Remove whitespace before ')' + +ℹ Fix +16 16 | +17 17 | +18 18 | #: E202:1:23 +19 |-spam(ham[1], {eggs: 2} ) + 19 |+spam(ham[1], {eggs: 2}) +20 20 | #: E202:1:22 +21 21 | spam(ham[1], {eggs: 2 }) +22 22 | #: E202:1:11 + +E20.py:21:22: E202 [*] Whitespace before '}' + | +19 | spam(ham[1], {eggs: 2} ) +20 | #: E202:1:22 +21 | spam(ham[1], {eggs: 2 }) + | ^ E202 +22 | #: E202:1:11 +23 | spam(ham[1 ], {eggs: 2}) + | + = help: Remove whitespace before '}' + +ℹ Fix +18 18 | #: E202:1:23 +19 19 | spam(ham[1], {eggs: 2} ) +20 20 | #: E202:1:22 +21 |-spam(ham[1], {eggs: 2 }) + 21 |+spam(ham[1], {eggs: 2}) +22 22 | #: E202:1:11 +23 23 | spam(ham[1 ], {eggs: 2}) +24 24 | #: E202:1:23 + +E20.py:23:11: E202 [*] Whitespace before ']' + | +21 | spam(ham[1], {eggs: 2 }) +22 | #: E202:1:11 +23 | spam(ham[1 ], {eggs: 2}) + | ^ E202 +24 | #: E202:1:23 +25 | spam(ham[1], {eggs: 2} ) + | + = help: Remove whitespace before ']' + +ℹ Fix +20 20 | #: E202:1:22 +21 21 | spam(ham[1], {eggs: 2 }) +22 22 | #: E202:1:11 +23 |-spam(ham[1 ], {eggs: 2}) + 23 |+spam(ham[1], {eggs: 2}) +24 24 | #: E202:1:23 +25 25 | spam(ham[1], {eggs: 2} ) +26 26 | #: E202:1:22 + +E20.py:25:23: E202 [*] Whitespace before ')' + | +23 | spam(ham[1 ], {eggs: 2}) +24 | #: E202:1:23 +25 | spam(ham[1], {eggs: 2} ) + | ^^ E202 +26 | #: E202:1:22 +27 | spam(ham[1], {eggs: 2 }) + | + = help: Remove whitespace before ')' + +ℹ Fix +22 22 | #: E202:1:11 +23 23 | spam(ham[1 ], {eggs: 2}) +24 24 | #: E202:1:23 +25 |-spam(ham[1], {eggs: 2} ) + 25 |+spam(ham[1], {eggs: 2}) +26 26 | #: E202:1:22 +27 27 | spam(ham[1], {eggs: 2 }) +28 28 | #: E202:1:11 + +E20.py:27:22: E202 [*] Whitespace before '}' + | +25 | spam(ham[1], {eggs: 2} ) +26 | #: E202:1:22 +27 | spam(ham[1], {eggs: 2 }) + | ^^^ E202 +28 | #: E202:1:11 +29 | spam(ham[1 ], {eggs: 2}) + | + = help: Remove whitespace before '}' + +ℹ Fix +24 24 | #: E202:1:23 +25 25 | spam(ham[1], {eggs: 2} ) +26 26 | #: E202:1:22 +27 |-spam(ham[1], {eggs: 2 }) + 27 |+spam(ham[1], {eggs: 2}) +28 28 | #: E202:1:11 +29 29 | spam(ham[1 ], {eggs: 2}) +30 30 | #: Okay + +E20.py:29:11: E202 [*] Whitespace before ']' + | +27 | spam(ham[1], {eggs: 2 }) +28 | #: E202:1:11 +29 | spam(ham[1 ], {eggs: 2}) + | ^^ E202 +30 | #: Okay +31 | spam(ham[1], {eggs: 2}) + | + = help: Remove whitespace before ']' + +ℹ Fix +26 26 | #: E202:1:22 +27 27 | spam(ham[1], {eggs: 2 }) +28 28 | #: E202:1:11 +29 |-spam(ham[1 ], {eggs: 2}) + 29 |+spam(ham[1], {eggs: 2}) +30 30 | #: Okay +31 31 | spam(ham[1], {eggs: 2}) +32 32 | + + 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 new file mode 100644 index 0000000000..4b8a856864 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E203_E20.py.snap @@ -0,0 +1,129 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E20.py:51:10: E203 [*] Whitespace before ':' + | +50 | #: E203:1:10 +51 | if x == 4 : + | ^ E203 +52 | print x, y +53 | x, y = y, x + | + = help: Remove whitespace before ':' + +ℹ Fix +48 48 | +49 49 | +50 50 | #: E203:1:10 +51 |-if x == 4 : + 51 |+if x == 4: +52 52 | print x, y +53 53 | x, y = y, x +54 54 | #: E203:1:10 + +E20.py:55:10: E203 [*] Whitespace before ':' + | +53 | x, y = y, x +54 | #: E203:1:10 +55 | if x == 4 : + | ^^^ E203 +56 | print x, y +57 | x, y = y, x + | + = help: Remove whitespace before ':' + +ℹ Fix +52 52 | print x, y +53 53 | x, y = y, x +54 54 | #: E203:1:10 +55 |-if x == 4 : + 55 |+if x == 4: +56 56 | print x, y +57 57 | x, y = y, x +58 58 | #: E203:2:15 E702:2:16 + +E20.py:60:15: E203 [*] Whitespace before ';' + | +58 | #: E203:2:15 E702:2:16 +59 | if x == 4: +60 | print x, y ; x, y = y, x + | ^ E203 +61 | #: E203:2:15 E702:2:16 +62 | if x == 4: + | + = help: Remove whitespace before ';' + +ℹ Fix +57 57 | x, y = y, x +58 58 | #: E203:2:15 E702:2:16 +59 59 | if x == 4: +60 |- print x, y ; x, y = y, x + 60 |+ print x, y; x, y = y, x +61 61 | #: E203:2:15 E702:2:16 +62 62 | if x == 4: +63 63 | print x, y ; x, y = y, x + +E20.py:63:15: E203 [*] Whitespace before ';' + | +61 | #: E203:2:15 E702:2:16 +62 | if x == 4: +63 | print x, y ; x, y = y, x + | ^^ E203 +64 | #: E203:3:13 +65 | if x == 4: + | + = help: Remove whitespace before ';' + +ℹ Fix +60 60 | print x, y ; x, y = y, x +61 61 | #: E203:2:15 E702:2:16 +62 62 | if x == 4: +63 |- print x, y ; x, y = y, x + 63 |+ print x, y; x, y = y, x +64 64 | #: E203:3:13 +65 65 | if x == 4: +66 66 | print x, y + +E20.py:67:13: E203 [*] Whitespace before ',' + | +65 | if x == 4: +66 | print x, y +67 | x, y = y , x + | ^ E203 +68 | #: E203:3:13 +69 | if x == 4: + | + = help: Remove whitespace before ',' + +ℹ Fix +64 64 | #: E203:3:13 +65 65 | if x == 4: +66 66 | print x, y +67 |- x, y = y , x + 67 |+ x, y = y, x +68 68 | #: E203:3:13 +69 69 | if x == 4: +70 70 | print x, y + +E20.py:71:13: E203 [*] Whitespace before ',' + | +69 | if x == 4: +70 | print x, y +71 | x, y = y , x + | ^^^^ E203 +72 | #: Okay +73 | if x == 4: + | + = help: Remove whitespace before ',' + +ℹ Fix +68 68 | #: E203:3:13 +69 69 | if x == 4: +70 70 | print x, y +71 |- x, y = y , x + 71 |+ x, y = y, x +72 72 | #: Okay +73 73 | if x == 4: +74 74 | print x, y + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E211_E21.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E211_E21.py.snap new file mode 100644 index 0000000000..c16db96f22 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E211_E21.py.snap @@ -0,0 +1,85 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E21.py:2:5: E211 [*] Whitespace before '(' + | +1 | #: E211 +2 | spam (1) + | ^ E211 +3 | #: E211 E211 +4 | dict ['key'] = list [index] + | + = help: Removed whitespace before '(' + +ℹ Fix +1 1 | #: E211 +2 |-spam (1) + 2 |+spam(1) +3 3 | #: E211 E211 +4 4 | dict ['key'] = list [index] +5 5 | #: E211 + +E21.py:4:5: E211 [*] Whitespace before '[' + | +2 | spam (1) +3 | #: E211 E211 +4 | dict ['key'] = list [index] + | ^ E211 +5 | #: E211 +6 | dict['key'] ['subkey'] = list[index] + | + = help: Removed whitespace before '[' + +ℹ Fix +1 1 | #: E211 +2 2 | spam (1) +3 3 | #: E211 E211 +4 |-dict ['key'] = list [index] + 4 |+dict['key'] = list [index] +5 5 | #: E211 +6 6 | dict['key'] ['subkey'] = list[index] +7 7 | #: Okay + +E21.py:4:20: E211 [*] Whitespace before '[' + | +2 | spam (1) +3 | #: E211 E211 +4 | dict ['key'] = list [index] + | ^ E211 +5 | #: E211 +6 | dict['key'] ['subkey'] = list[index] + | + = help: Removed whitespace before '[' + +ℹ Fix +1 1 | #: E211 +2 2 | spam (1) +3 3 | #: E211 E211 +4 |-dict ['key'] = list [index] + 4 |+dict ['key'] = list[index] +5 5 | #: E211 +6 6 | dict['key'] ['subkey'] = list[index] +7 7 | #: Okay + +E21.py:6:12: E211 [*] Whitespace before '[' + | +4 | dict ['key'] = list [index] +5 | #: E211 +6 | dict['key'] ['subkey'] = list[index] + | ^ E211 +7 | #: Okay +8 | spam(1) + | + = help: Removed whitespace before '[' + +ℹ Fix +3 3 | #: E211 E211 +4 4 | dict ['key'] = list [index] +5 5 | #: E211 +6 |-dict['key'] ['subkey'] = list[index] + 6 |+dict['key']['subkey'] = list[index] +7 7 | #: Okay +8 8 | spam(1) +9 9 | dict['key'] = list[index] + + 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 new file mode 100644 index 0000000000..d995e58ac9 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E221_E22.py.snap @@ -0,0 +1,84 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E22.py:3:6: E221 Multiple spaces before operator + | +1 | #: E221 +2 | a = 12 + 3 +3 | b = 4 + 5 + | ^^ E221 +4 | #: E221 E221 +5 | x = 1 + | + +E22.py:5:2: E221 Multiple spaces before operator + | +3 | b = 4 + 5 +4 | #: E221 E221 +5 | x = 1 + | ^^^^^^^^^^^^^ E221 +6 | y = 2 +7 | long_variable = 3 + | + +E22.py:6:2: E221 Multiple spaces before operator + | +4 | #: E221 E221 +5 | x = 1 +6 | y = 2 + | ^^^^^^^^^^^^^ E221 +7 | long_variable = 3 +8 | #: E221 E221 + | + +E22.py:9:5: E221 Multiple spaces before operator + | + 7 | long_variable = 3 + 8 | #: E221 E221 + 9 | x[0] = 1 + | ^^^^^^^^^^ E221 +10 | x[1] = 2 +11 | long_variable = 3 + | + +E22.py:10:5: E221 Multiple spaces before operator + | + 8 | #: E221 E221 + 9 | x[0] = 1 +10 | x[1] = 2 + | ^^^^^^^^^^ E221 +11 | long_variable = 3 +12 | #: E221 E221 + | + +E22.py:13:9: E221 Multiple spaces before operator + | +11 | long_variable = 3 +12 | #: E221 E221 +13 | x = f(x) + 1 + | ^^^^^^^^^^ E221 +14 | y = long_variable + 2 +15 | z = x[0] + 3 + | + +E22.py:15:9: E221 Multiple spaces before operator + | +13 | x = f(x) + 1 +14 | y = long_variable + 2 +15 | z = x[0] + 3 + | ^^^^^^^^^^ E221 +16 | #: E221:3:14 +17 | text = """ + | + +E22.py:19:14: E221 Multiple spaces before operator + | +17 | text = """ +18 | bar +19 | foo %s""" % rofl + | ^^ E221 +20 | #: Okay +21 | x = 1 + | + + 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 new file mode 100644 index 0000000000..ca4dac6d17 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E222_E22.py.snap @@ -0,0 +1,53 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E22.py:28:8: E222 Multiple spaces after operator + | +27 | #: E222 +28 | a = a + 1 + | ^^ E222 +29 | b = b + 10 +30 | #: E222 E222 + | + +E22.py:31:4: E222 Multiple spaces after operator + | +29 | b = b + 10 +30 | #: E222 E222 +31 | x = -1 + | ^^^^^^^^^^^^ E222 +32 | y = -2 +33 | long_variable = 3 + | + +E22.py:32:4: E222 Multiple spaces after operator + | +30 | #: E222 E222 +31 | x = -1 +32 | y = -2 + | ^^^^^^^^^^^^ E222 +33 | long_variable = 3 +34 | #: E222 E222 + | + +E22.py:35:7: E222 Multiple spaces after operator + | +33 | long_variable = 3 +34 | #: E222 E222 +35 | x[0] = 1 + | ^^^^^^^^^^ E222 +36 | x[1] = 2 +37 | long_variable = 3 + | + +E22.py:36:7: E222 Multiple spaces after operator + | +34 | #: E222 E222 +35 | x[0] = 1 +36 | x[1] = 2 + | ^^^^^^^^^^ E222 +37 | long_variable = 3 +38 | #: + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E223_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E223_E22.py.snap new file mode 100644 index 0000000000..58f50d1a46 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E223_E22.py.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E22.py:43:2: E223 Tab before operator + | +41 | #: E223 +42 | foobart = 4 +43 | a = 3 # aligned with tab + | ^^^ E223 +44 | #: + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E224_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E224_E22.py.snap new file mode 100644 index 0000000000..59b473485c --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E224_E22.py.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E22.py:48:5: E224 Tab after operator + | +47 | #: E224 +48 | a += 1 + | ^^^^ E224 +49 | b += 1000 +50 | #: + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E225_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E225_E22.py.snap new file mode 100644 index 0000000000..635b1cdeba --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E225_E22.py.snap @@ -0,0 +1,272 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E22.py:54:11: E225 Missing whitespace around operator + | +53 | #: E225 +54 | submitted +=1 + | ^^ E225 +55 | #: E225 +56 | submitted+= 1 + | + +E22.py:56:10: E225 Missing whitespace around operator + | +54 | submitted +=1 +55 | #: E225 +56 | submitted+= 1 + | ^^ E225 +57 | #: E225 +58 | c =-1 + | + +E22.py:58:3: E225 Missing whitespace around operator + | +56 | submitted+= 1 +57 | #: E225 +58 | c =-1 + | ^ E225 +59 | #: E225 +60 | x = x /2 - 1 + | + +E22.py:60:7: E225 Missing whitespace around operator + | +58 | c =-1 +59 | #: E225 +60 | x = x /2 - 1 + | ^ E225 +61 | #: E225 +62 | c = alpha -4 + | + +E22.py:62:11: E225 Missing whitespace around operator + | +60 | x = x /2 - 1 +61 | #: E225 +62 | c = alpha -4 + | ^ E225 +63 | #: E225 +64 | c = alpha- 4 + | + +E22.py:64:10: E225 Missing whitespace around operator + | +62 | c = alpha -4 +63 | #: E225 +64 | c = alpha- 4 + | ^ E225 +65 | #: E225 +66 | z = x **y + | + +E22.py:66:7: E225 Missing whitespace around operator + | +64 | c = alpha- 4 +65 | #: E225 +66 | z = x **y + | ^^ E225 +67 | #: E225 +68 | z = (x + 1) **y + | + +E22.py:68:13: E225 Missing whitespace around operator + | +66 | z = x **y +67 | #: E225 +68 | z = (x + 1) **y + | ^^ E225 +69 | #: E225 +70 | z = (x + 1)** y + | + +E22.py:70:12: E225 Missing whitespace around operator + | +68 | z = (x + 1) **y +69 | #: E225 +70 | z = (x + 1)** y + | ^^ E225 +71 | #: E225 +72 | _1kB = _1MB >>10 + | + +E22.py:72:13: E225 Missing whitespace around operator + | +70 | z = (x + 1)** y +71 | #: E225 +72 | _1kB = _1MB >>10 + | ^^ E225 +73 | #: E225 +74 | _1kB = _1MB>> 10 + | + +E22.py:74:12: E225 Missing whitespace around operator + | +72 | _1kB = _1MB >>10 +73 | #: E225 +74 | _1kB = _1MB>> 10 + | ^^ E225 +75 | #: E225 E225 +76 | i=i+ 1 + | + +E22.py:76:2: E225 Missing whitespace around operator + | +74 | _1kB = _1MB>> 10 +75 | #: E225 E225 +76 | i=i+ 1 + | ^ E225 +77 | #: E225 E225 +78 | i=i +1 + | + +E22.py:76:4: E225 Missing whitespace around operator + | +74 | _1kB = _1MB>> 10 +75 | #: E225 E225 +76 | i=i+ 1 + | ^ E225 +77 | #: E225 E225 +78 | i=i +1 + | + +E22.py:78:2: E225 Missing whitespace around operator + | +76 | i=i+ 1 +77 | #: E225 E225 +78 | i=i +1 + | ^ E225 +79 | #: E225 +80 | i = 1and 1 + | + +E22.py:78:5: E225 Missing whitespace around operator + | +76 | i=i+ 1 +77 | #: E225 E225 +78 | i=i +1 + | ^ E225 +79 | #: E225 +80 | i = 1and 1 + | + +E22.py:80:6: E225 Missing whitespace around operator + | +78 | i=i +1 +79 | #: E225 +80 | i = 1and 1 + | ^^^ E225 +81 | #: E225 +82 | i = 1or 0 + | + +E22.py:82:6: E225 Missing whitespace around operator + | +80 | i = 1and 1 +81 | #: E225 +82 | i = 1or 0 + | ^^ E225 +83 | #: E225 +84 | 1is 1 + | + +E22.py:84:2: E225 Missing whitespace around operator + | +82 | i = 1or 0 +83 | #: E225 +84 | 1is 1 + | ^^ E225 +85 | #: E225 +86 | 1in [] + | + +E22.py:86:2: E225 Missing whitespace around operator + | +84 | 1is 1 +85 | #: E225 +86 | 1in [] + | ^^ E225 +87 | #: E225 +88 | i = 1 @2 + | + +E22.py:88:7: E225 Missing whitespace around operator + | +86 | 1in [] +87 | #: E225 +88 | i = 1 @2 + | ^ E225 +89 | #: E225 +90 | i = 1@ 2 + | + +E22.py:90:6: E225 Missing whitespace around operator + | +88 | i = 1 @2 +89 | #: E225 +90 | i = 1@ 2 + | ^ E225 +91 | #: E225 E226 +92 | i=i+1 + | + +E22.py:92:2: E225 Missing whitespace around operator + | +90 | i = 1@ 2 +91 | #: E225 E226 +92 | i=i+1 + | ^ E225 +93 | #: E225 E226 +94 | i =i+1 + | + +E22.py:94:3: E225 Missing whitespace around operator + | +92 | i=i+1 +93 | #: E225 E226 +94 | i =i+1 + | ^ E225 +95 | #: E225 E226 +96 | i= i+1 + | + +E22.py:96:2: E225 Missing whitespace around operator + | +94 | i =i+1 +95 | #: E225 E226 +96 | i= i+1 + | ^ E225 +97 | #: E225 E226 +98 | c = (a +b)*(a - b) + | + +E22.py:98:8: E225 Missing whitespace around operator + | + 96 | i= i+1 + 97 | #: E225 E226 + 98 | c = (a +b)*(a - b) + | ^ E225 + 99 | #: E225 E226 +100 | c = (a+ b)*(a - b) + | + +E22.py:100:7: E225 Missing whitespace around operator + | + 98 | c = (a +b)*(a - b) + 99 | #: E225 E226 +100 | c = (a+ b)*(a - b) + | ^ E225 +101 | #: + | + +E22.py:154:11: E225 Missing whitespace around operator + | +152 | func2(lambda a, b=h[:], c=0: (a, b, c)) +153 | if not -5 < x < +5: +154 | print >>sys.stderr, "x is out of range." + | ^^ E225 +155 | print >> sys.stdout, "x is an integer." +156 | x = x / 2 - 1 + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E226_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E226_E22.py.snap new file mode 100644 index 0000000000..56033e4665 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E226_E22.py.snap @@ -0,0 +1,142 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E22.py:92:4: E226 Missing whitespace around arithmetic operator + | +90 | i = 1@ 2 +91 | #: E225 E226 +92 | i=i+1 + | ^ E226 +93 | #: E225 E226 +94 | i =i+1 + | + +E22.py:94:5: E226 Missing whitespace around arithmetic operator + | +92 | i=i+1 +93 | #: E225 E226 +94 | i =i+1 + | ^ E226 +95 | #: E225 E226 +96 | i= i+1 + | + +E22.py:96:5: E226 Missing whitespace around arithmetic operator + | +94 | i =i+1 +95 | #: E225 E226 +96 | i= i+1 + | ^ E226 +97 | #: E225 E226 +98 | c = (a +b)*(a - b) + | + +E22.py:98:11: E226 Missing whitespace around arithmetic operator + | + 96 | i= i+1 + 97 | #: E225 E226 + 98 | c = (a +b)*(a - b) + | ^ E226 + 99 | #: E225 E226 +100 | c = (a+ b)*(a - b) + | + +E22.py:100:11: E226 Missing whitespace around arithmetic operator + | + 98 | c = (a +b)*(a - b) + 99 | #: E225 E226 +100 | c = (a+ b)*(a - b) + | ^ E226 +101 | #: + | + +E22.py:104:6: E226 Missing whitespace around arithmetic operator + | +103 | #: E226 +104 | z = 2//30 + | ^^ E226 +105 | #: E226 E226 +106 | c = (a+b) * (a-b) + | + +E22.py:106:7: E226 Missing whitespace around arithmetic operator + | +104 | z = 2//30 +105 | #: E226 E226 +106 | c = (a+b) * (a-b) + | ^ E226 +107 | #: E226 +108 | norman = True+False + | + +E22.py:106:15: E226 Missing whitespace around arithmetic operator + | +104 | z = 2//30 +105 | #: E226 E226 +106 | c = (a+b) * (a-b) + | ^ E226 +107 | #: E226 +108 | norman = True+False + | + +E22.py:110:6: E226 Missing whitespace around arithmetic operator + | +108 | norman = True+False +109 | #: E226 +110 | x = x*2 - 1 + | ^ E226 +111 | #: E226 +112 | x = x/2 - 1 + | + +E22.py:112:6: E226 Missing whitespace around arithmetic operator + | +110 | x = x*2 - 1 +111 | #: E226 +112 | x = x/2 - 1 + | ^ E226 +113 | #: E226 E226 +114 | hypot2 = x*x + y*y + | + +E22.py:114:11: E226 Missing whitespace around arithmetic operator + | +112 | x = x/2 - 1 +113 | #: E226 E226 +114 | hypot2 = x*x + y*y + | ^ E226 +115 | #: E226 +116 | c = (a + b)*(a - b) + | + +E22.py:114:17: E226 Missing whitespace around arithmetic operator + | +112 | x = x/2 - 1 +113 | #: E226 E226 +114 | hypot2 = x*x + y*y + | ^ E226 +115 | #: E226 +116 | c = (a + b)*(a - b) + | + +E22.py:116:12: E226 Missing whitespace around arithmetic operator + | +114 | hypot2 = x*x + y*y +115 | #: E226 +116 | c = (a + b)*(a - b) + | ^ E226 +117 | #: E226 +118 | def halves(n): + | + +E22.py:119:14: E226 Missing whitespace around arithmetic operator + | +117 | #: E226 +118 | def halves(n): +119 | return (i//2 for i in range(n)) + | ^^ E226 +120 | #: E227 +121 | _1kB = _1MB>>10 + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E227_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E227_E22.py.snap new file mode 100644 index 0000000000..1a9bb8b8f6 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E227_E22.py.snap @@ -0,0 +1,54 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E22.py:121:12: E227 Missing whitespace around bitwise or shift operator + | +119 | return (i//2 for i in range(n)) +120 | #: E227 +121 | _1kB = _1MB>>10 + | ^^ E227 +122 | #: E227 +123 | _1MB = _1kB<<10 + | + +E22.py:123:12: E227 Missing whitespace around bitwise or shift operator + | +121 | _1kB = _1MB>>10 +122 | #: E227 +123 | _1MB = _1kB<<10 + | ^^ E227 +124 | #: E227 +125 | a = b|c + | + +E22.py:125:6: E227 Missing whitespace around bitwise or shift operator + | +123 | _1MB = _1kB<<10 +124 | #: E227 +125 | a = b|c + | ^ E227 +126 | #: E227 +127 | b = c&a + | + +E22.py:127:6: E227 Missing whitespace around bitwise or shift operator + | +125 | a = b|c +126 | #: E227 +127 | b = c&a + | ^ E227 +128 | #: E227 +129 | c = b^a + | + +E22.py:129:6: E227 Missing whitespace around bitwise or shift operator + | +127 | b = c&a +128 | #: E227 +129 | c = b^a + | ^ E227 +130 | #: E228 +131 | a = b%c + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E228_E22.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E228_E22.py.snap new file mode 100644 index 0000000000..308f097a78 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E228_E22.py.snap @@ -0,0 +1,33 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E22.py:131:6: E228 Missing whitespace around modulo operator + | +129 | c = b^a +130 | #: E228 +131 | a = b%c + | ^ E228 +132 | #: E228 +133 | msg = fmt%(errno, errmsg) + | + +E22.py:133:10: E228 Missing whitespace around modulo operator + | +131 | a = b%c +132 | #: E228 +133 | msg = fmt%(errno, errmsg) + | ^ E228 +134 | #: E228 +135 | msg = "Error %d occurred"%errno + | + +E22.py:135:26: E228 Missing whitespace around modulo operator + | +133 | msg = fmt%(errno, errmsg) +134 | #: E228 +135 | msg = "Error %d occurred"%errno + | ^ E228 +136 | #: + | + + 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 new file mode 100644 index 0000000000..049c9d52b6 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E231_E23.py.snap @@ -0,0 +1,104 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E23.py:2:7: E231 [*] Missing whitespace after ',' + | +1 | #: E231 +2 | a = (1,2) + | ^ E231 +3 | #: E231 +4 | a[b1,:] + | + = help: Added missing whitespace after ',' + +ℹ Fix +1 1 | #: E231 +2 |-a = (1,2) + 2 |+a = (1, 2) +3 3 | #: E231 +4 4 | a[b1,:] +5 5 | #: E231 + +E23.py:4:5: E231 [*] Missing whitespace after ',' + | +2 | a = (1,2) +3 | #: E231 +4 | a[b1,:] + | ^ E231 +5 | #: E231 +6 | a = [{'a':''}] + | + = help: Added missing whitespace after ',' + +ℹ Fix +1 1 | #: E231 +2 2 | a = (1,2) +3 3 | #: E231 +4 |-a[b1,:] + 4 |+a[b1, :] +5 5 | #: E231 +6 6 | a = [{'a':''}] +7 7 | #: Okay + +E23.py:6:10: E231 [*] Missing whitespace after ':' + | +4 | a[b1,:] +5 | #: E231 +6 | a = [{'a':''}] + | ^ E231 +7 | #: Okay +8 | a = (4,) + | + = help: Added missing whitespace after ':' + +ℹ Fix +3 3 | #: E231 +4 4 | a[b1,:] +5 5 | #: E231 +6 |-a = [{'a':''}] + 6 |+a = [{'a': ''}] +7 7 | #: Okay +8 8 | a = (4,) +9 9 | b = (5, ) + +E23.py:19:10: E231 [*] Missing whitespace after ',' + | +17 | def foo() -> None: +18 | #: E231 +19 | if (1,2): + | ^ E231 +20 | pass + | + = help: Added missing whitespace after ',' + +ℹ Fix +16 16 | +17 17 | def foo() -> None: +18 18 | #: E231 +19 |- if (1,2): + 19 |+ if (1, 2): +20 20 | pass +21 21 | +22 22 | #: Okay + +E23.py:29:20: E231 [*] Missing whitespace after ':' + | +27 | mdtypes_template = { +28 | 'tag_full': [('mdtype', 'u4'), ('byte_count', 'u4')], +29 | 'tag_smalldata':[('byte_count_mdtype', 'u4'), ('data', 'S4')], + | ^ E231 +30 | } + | + = help: Added missing whitespace after ':' + +ℹ Fix +26 26 | #: E231:2:20 +27 27 | mdtypes_template = { +28 28 | 'tag_full': [('mdtype', 'u4'), ('byte_count', 'u4')], +29 |- 'tag_smalldata':[('byte_count_mdtype', 'u4'), ('data', 'S4')], + 29 |+ 'tag_smalldata': [('byte_count_mdtype', 'u4'), ('data', 'S4')], +30 30 | } +31 31 | +32 32 | #: Okay + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E241_E24.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E241_E24.py.snap new file mode 100644 index 0000000000..a54cd258a3 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E241_E24.py.snap @@ -0,0 +1,40 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E24.py:2:8: E241 Multiple spaces after comma + | +1 | #: E241 +2 | a = (1, 2) + | ^^ E241 +3 | #: Okay +4 | b = (1, 20) + | + +E24.py:11:18: E241 Multiple spaces after comma + | + 9 | #: E241 E241 E241 +10 | # issue 135 +11 | more_spaces = [a, b, + | ^^^^ E241 +12 | ef, +h, +13 | c, -d] + | + +E24.py:12:19: E241 Multiple spaces after comma + | +10 | # issue 135 +11 | more_spaces = [a, b, +12 | ef, +h, + | ^^ E241 +13 | c, -d] + | + +E24.py:13:18: E241 Multiple spaces after comma + | +11 | more_spaces = [a, b, +12 | ef, +h, +13 | c, -d] + | ^^^ E241 + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E242_E24.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E242_E24.py.snap new file mode 100644 index 0000000000..7f74a19342 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E242_E24.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E24.py:6:8: E242 Tab after comma + | +4 | b = (1, 20) +5 | #: E242 +6 | a = (1, 2) # tab before 2 + | ^ E242 +7 | #: Okay +8 | b = (1, 20) # space before 20 + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E251_E25.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E251_E25.py.snap new file mode 100644 index 0000000000..88d211954b --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E251_E25.py.snap @@ -0,0 +1,116 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E25.py:2:12: E251 Unexpected spaces around keyword / parameter equals + | +1 | #: E251 E251 +2 | def foo(bar = False): + | ^ E251 +3 | '''Test function with an error in declaration''' +4 | pass + | + +E25.py:2:14: E251 Unexpected spaces around keyword / parameter equals + | +1 | #: E251 E251 +2 | def foo(bar = False): + | ^ E251 +3 | '''Test function with an error in declaration''' +4 | pass + | + +E25.py:6:9: E251 Unexpected spaces around keyword / parameter equals + | +4 | pass +5 | #: E251 +6 | foo(bar= True) + | ^ E251 +7 | #: E251 +8 | foo(bar =True) + | + +E25.py:8:8: E251 Unexpected spaces around keyword / parameter equals + | + 6 | foo(bar= True) + 7 | #: E251 + 8 | foo(bar =True) + | ^ E251 + 9 | #: E251 E251 +10 | foo(bar = True) + | + +E25.py:10:8: E251 Unexpected spaces around keyword / parameter equals + | + 8 | foo(bar =True) + 9 | #: E251 E251 +10 | foo(bar = True) + | ^ E251 +11 | #: E251 +12 | y = bar(root= "sdasd") + | + +E25.py:10:10: E251 Unexpected spaces around keyword / parameter equals + | + 8 | foo(bar =True) + 9 | #: E251 E251 +10 | foo(bar = True) + | ^ E251 +11 | #: E251 +12 | y = bar(root= "sdasd") + | + +E25.py:12:14: E251 Unexpected spaces around keyword / parameter equals + | +10 | foo(bar = True) +11 | #: E251 +12 | y = bar(root= "sdasd") + | ^ E251 +13 | #: E251:2:29 +14 | parser.add_argument('--long-option', + | + +E25.py:15:29: E251 Unexpected spaces around keyword / parameter equals + | +13 | #: E251:2:29 +14 | parser.add_argument('--long-option', +15 | default= + | _____________________________^ +16 | | "/rather/long/filesystem/path/here/blah/blah/blah") + | |____________________^ E251 +17 | #: E251:1:45 +18 | parser.add_argument('--long-option', default + | + +E25.py:18:45: E251 Unexpected spaces around keyword / parameter equals + | +16 | "/rather/long/filesystem/path/here/blah/blah/blah") +17 | #: E251:1:45 +18 | parser.add_argument('--long-option', default + | _____________________________________________^ +19 | | ="/rather/long/filesystem/path/here/blah/blah/blah") + | |____________________^ E251 +20 | #: E251:3:8 E251:3:10 +21 | foo(True, + | + +E25.py:23:8: E251 Unexpected spaces around keyword / parameter equals + | +21 | foo(True, +22 | baz=(1, 2), +23 | biz = 'foo' + | ^ E251 +24 | ) +25 | #: Okay + | + +E25.py:23:10: E251 Unexpected spaces around keyword / parameter equals + | +21 | foo(True, +22 | baz=(1, 2), +23 | biz = 'foo' + | ^ E251 +24 | ) +25 | #: Okay + | + + 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 new file mode 100644 index 0000000000..04d099aa11 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E252_E25.py.snap @@ -0,0 +1,44 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E25.py:46:15: E252 Missing whitespace around parameter equals + | +44 | return a + b +45 | #: E252:1:15 E252:1:16 E252:1:27 E252:1:36 +46 | def add(a: int=0, b: int =0, c: int= 0) -> int: + | ^ E252 +47 | return a + b + c +48 | #: Okay + | + +E25.py:46:15: E252 Missing whitespace around parameter equals + | +44 | return a + b +45 | #: E252:1:15 E252:1:16 E252:1:27 E252:1:36 +46 | def add(a: int=0, b: int =0, c: int= 0) -> int: + | ^ E252 +47 | return a + b + c +48 | #: Okay + | + +E25.py:46:26: E252 Missing whitespace around parameter equals + | +44 | return a + b +45 | #: E252:1:15 E252:1:16 E252:1:27 E252:1:36 +46 | def add(a: int=0, b: int =0, c: int= 0) -> int: + | ^ E252 +47 | return a + b + c +48 | #: Okay + | + +E25.py:46:36: E252 Missing whitespace around parameter equals + | +44 | return a + b +45 | #: E252:1:15 E252:1:16 E252:1:27 E252:1:36 +46 | def add(a: int=0, b: int =0, c: int= 0) -> int: + | ^ E252 +47 | return a + b + c +48 | #: Okay + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E261_E26.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E261_E26.py.snap new file mode 100644 index 0000000000..ab8a934e47 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E261_E26.py.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E26.py:2:5: E261 Insert at least two spaces before an inline comment + | +1 | #: E261:1:5 +2 | pass # an inline comment + | ^ E261 +3 | #: E262:1:12 +4 | x = x + 1 #Increment x + | + + 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 new file mode 100644 index 0000000000..a01a1eb2d7 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E262_E26.py.snap @@ -0,0 +1,54 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E26.py:4:12: E262 Inline comment should start with `# ` + | +2 | pass # an inline comment +3 | #: E262:1:12 +4 | x = x + 1 #Increment x + | ^^^^^^^^^^^^ E262 +5 | #: E262:1:12 +6 | x = x + 1 # Increment x + | + +E26.py:6:12: E262 Inline comment should start with `# ` + | +4 | x = x + 1 #Increment x +5 | #: E262:1:12 +6 | x = x + 1 # Increment x + | ^^^^^^^^^^^^^^ E262 +7 | #: E262:1:12 +8 | x = y + 1 #: Increment x + | + +E26.py:8:12: E262 Inline comment should start with `# ` + | + 6 | x = x + 1 # Increment x + 7 | #: E262:1:12 + 8 | x = y + 1 #: Increment x + | ^^^^^^^^^^^^^^^ E262 + 9 | #: E265:1:1 +10 | #Block comment + | + +E26.py:63:9: E262 Inline comment should start with `# ` + | +61 | # -*- coding: utf8 -*- +62 | #  (One space one NBSP) Ok for block comment +63 | a = 42 #  (One space one NBSP) + | ^^^^^^^^^^^^^^^^^^^^^^^ E262 +64 | #: E262:2:9 +65 | # (Two spaces) Ok for block comment + | + +E26.py:66:9: E262 Inline comment should start with `# ` + | +64 | #: E262:2:9 +65 | # (Two spaces) Ok for block comment +66 | a = 42 # (Two spaces) + | ^^^^^^^^^^^^^^^ E262 +67 | +68 | #: E265:5:1 + | + + 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 new file mode 100644 index 0000000000..6017827141 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E265_E26.py.snap @@ -0,0 +1,52 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E26.py:10:1: E265 Block comment should start with `# ` + | + 8 | x = y + 1 #: Increment x + 9 | #: E265:1:1 +10 | #Block comment + | ^^^^^^^^^^^^^^ E265 +11 | a = 1 +12 | #: E265:2:1 + | + +E26.py:14:1: E265 Block comment should start with `# ` + | +12 | #: E265:2:1 +13 | m = 42 +14 | #! This is important + | ^^^^^^^^^^^^^^^^^^^^ E265 +15 | mx = 42 - 42 +16 | #: E266:3:5 E266:6:5 + | + +E26.py:25:1: E265 Block comment should start with `# ` + | +23 | return +24 | #: E265:1:1 E266:2:1 +25 | ##if DEBUG: + | ^^^^^^^^^^^ E265 +26 | ## logging.error() +27 | #: W291:1:42 + | + +E26.py:32:1: E265 Block comment should start with `# ` + | +31 | #: Okay +32 | #!/usr/bin/env python + | ^^^^^^^^^^^^^^^^^^^^^ E265 +33 | +34 | pass # an inline comment + | + +E26.py:73:1: E265 Block comment should start with `# ` + | +71 | # F Means test is failing (F) +72 | # EF Means test is giving error and Failing +73 | #! Means test is segfaulting + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E265 +74 | # 8 Means test runs forever + | + + 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 new file mode 100644 index 0000000000..5eb382385c --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E266_E26.py.snap @@ -0,0 +1,42 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E26.py:19:5: E266 Too many leading `#` before block comment + | +17 | def how_it_feel(r): +18 | +19 | ### This is a variable ### + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E266 +20 | a = 42 + | + +E26.py:22:5: E266 Too many leading `#` before block comment + | +20 | a = 42 +21 | +22 | ### Of course it is unused + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ E266 +23 | return +24 | #: E265:1:1 E266:2:1 + | + +E26.py:26:1: E266 Too many leading `#` before block comment + | +24 | #: E265:1:1 E266:2:1 +25 | ##if DEBUG: +26 | ## logging.error() + | ^^^^^^^^^^^^^^^^^^^^^ E266 +27 | #: W291:1:42 +28 | ######################################### + | + +E26.py:69:1: E266 Too many leading `#` before block comment + | +68 | #: E265:5:1 +69 | ### Means test is not done yet + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E266 +70 | # E Means test is giving error (E) +71 | # F Means test is failing (F) + | + + 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 new file mode 100644 index 0000000000..314cdb4a6c --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E271_E27.py.snap @@ -0,0 +1,94 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E27.py:4:9: E271 Multiple spaces after keyword + | +2 | True and False +3 | #: E271 +4 | True and False + | ^^ E271 +5 | #: E272 +6 | True and False + | + +E27.py:6:5: E271 Multiple spaces after keyword + | +4 | True and False +5 | #: E272 +6 | True and False + | ^^ E271 +7 | #: E271 +8 | if 1: + | + +E27.py:8:3: E271 Multiple spaces after keyword + | + 6 | True and False + 7 | #: E271 + 8 | if 1: + | ^^^ E271 + 9 | #: E273 +10 | True and False + | + +E27.py:14:6: E271 Multiple spaces after keyword + | +12 | True and False +13 | #: E271 +14 | a and b + | ^^ E271 +15 | #: E271 +16 | 1 and b + | + +E27.py:16:6: E271 Multiple spaces after keyword + | +14 | a and b +15 | #: E271 +16 | 1 and b + | ^^ E271 +17 | #: E271 +18 | a and 2 + | + +E27.py:18:6: E271 Multiple spaces after keyword + | +16 | 1 and b +17 | #: E271 +18 | a and 2 + | ^^ E271 +19 | #: E271 E272 +20 | 1 and b + | + +E27.py:20:7: E271 Multiple spaces after keyword + | +18 | a and 2 +19 | #: E271 E272 +20 | 1 and b + | ^^ E271 +21 | #: E271 E272 +22 | a and 2 + | + +E27.py:22:7: E271 Multiple spaces after keyword + | +20 | 1 and b +21 | #: E271 E272 +22 | a and 2 + | ^^ E271 +23 | #: E272 +24 | this and False + | + +E27.py:35:14: E271 Multiple spaces after keyword + | +33 | from v import c, d +34 | #: E271 +35 | from w import (e, f) + | ^^ E271 +36 | #: E275 +37 | from w import(e, f) + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E272_E27.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E272_E27.py.snap new file mode 100644 index 0000000000..de8e255e62 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E272_E27.py.snap @@ -0,0 +1,34 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E27.py:20:2: E272 Multiple spaces before keyword + | +18 | a and 2 +19 | #: E271 E272 +20 | 1 and b + | ^^ E272 +21 | #: E271 E272 +22 | a and 2 + | + +E27.py:22:2: E272 Multiple spaces before keyword + | +20 | 1 and b +21 | #: E271 E272 +22 | a and 2 + | ^^ E272 +23 | #: E272 +24 | this and False + | + +E27.py:24:5: E272 Multiple spaces before keyword + | +22 | a and 2 +23 | #: E272 +24 | this and False + | ^^ E272 +25 | #: E273 +26 | a and b + | + + 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 new file mode 100644 index 0000000000..122c091a1e --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E273_E27.py.snap @@ -0,0 +1,54 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E27.py:10:9: E273 Tab after keyword + | + 8 | if 1: + 9 | #: E273 +10 | True and False + | ^^^^^^^^ E273 +11 | #: E273 E274 +12 | True and False + | + +E27.py:12:5: E273 Tab after keyword + | +10 | True and False +11 | #: E273 E274 +12 | True and False + | ^^^^^^^^ E273 +13 | #: E271 +14 | a and b + | + +E27.py:12:10: E273 Tab after keyword + | +10 | True and False +11 | #: E273 E274 +12 | True and False + | ^ E273 +13 | #: E271 +14 | a and b + | + +E27.py:26:6: E273 Tab after keyword + | +24 | this and False +25 | #: E273 +26 | a and b + | ^^^ E273 +27 | #: E274 +28 | a and b + | + +E27.py:30:10: E273 Tab after keyword + | +28 | a and b +29 | #: E273 E274 +30 | this and False + | ^ E273 +31 | #: Okay +32 | from u import (a, b) + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E274_E27.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E274_E27.py.snap new file mode 100644 index 0000000000..3230f60fe8 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E274_E27.py.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E27.py:28:2: E274 Tab before keyword + | +26 | a and b +27 | #: E274 +28 | a and b + | ^^^^^^^ E274 +29 | #: E273 E274 +30 | this and False + | + +E27.py:30:5: E274 Tab before keyword + | +28 | a and b +29 | #: E273 E274 +30 | this and False + | ^^^^^^^^ E274 +31 | #: Okay +32 | from u import (a, b) + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E275_E27.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E275_E27.py.snap new file mode 100644 index 0000000000..3c73cb2654 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E275_E27.py.snap @@ -0,0 +1,54 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E27.py:37:8: E275 Missing whitespace after keyword + | +35 | from w import (e, f) +36 | #: E275 +37 | from w import(e, f) + | ^^^^^^ E275 +38 | #: E275 +39 | from importable.module import(e, f) + | + +E27.py:39:24: E275 Missing whitespace after keyword + | +37 | from w import(e, f) +38 | #: E275 +39 | from importable.module import(e, f) + | ^^^^^^ E275 +40 | #: E275 +41 | try: + | + +E27.py:42:28: E275 Missing whitespace after keyword + | +40 | #: E275 +41 | try: +42 | from importable.module import(e, f) + | ^^^^^^ E275 +43 | except ImportError: +44 | pass + | + +E27.py:46:1: E275 Missing whitespace after keyword + | +44 | pass +45 | #: E275 +46 | if(foo): + | ^^ E275 +47 | pass +48 | else: + | + +E27.py:54:5: E275 Missing whitespace after keyword + | +52 | #: E275:2:11 +53 | if True: +54 | assert(1) + | ^^^^^^ E275 +55 | #: Okay +56 | def f(): + | + + 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 new file mode 100644 index 0000000000..3ee33734d4 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E401_E40.py.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E40.py:2:1: E401 Multiple imports on one line + | +1 | #: E401 +2 | import os, sys + | ^^^^^^^^^^^^^^ E401 +3 | #: Okay +4 | import os + | + + 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 new file mode 100644 index 0000000000..2525069ae9 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E40.py.snap @@ -0,0 +1,32 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E40.py:55:1: E402 Module level import not at top of file + | +53 | VERSION = '1.2.3' +54 | +55 | import foo + | ^^^^^^^^^^ E402 +56 | #: E402 +57 | import foo + | + +E40.py:57:1: E402 Module level import not at top of file + | +55 | import foo +56 | #: E402 +57 | import foo + | ^^^^^^^^^^ E402 +58 | +59 | a = 1 + | + +E40.py:61:1: E402 Module level import not at top of file + | +59 | a = 1 +60 | +61 | import bar + | ^^^^^^^^^^ E402 + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402.py.snap new file mode 100644 index 0000000000..8c15438eb5 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E402_E402.py.snap @@ -0,0 +1,28 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E402.py:24:1: E402 Module level import not at top of file + | +22 | __some__magic = 1 +23 | +24 | import f + | ^^^^^^^^ E402 + | + +E402.py:34:1: E402 Module level import not at top of file + | +32 | import g +33 | +34 | import h; import i + | ^^^^^^^^ E402 + | + +E402.py:34:11: E402 Module level import not at top of file + | +32 | import g +33 | +34 | import h; import i + | ^^^^^^^^ E402 + | + + 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 new file mode 100644 index 0000000000..9445864d57 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E501_E501.py.snap @@ -0,0 +1,59 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E501.py:5:89: E501 Line too long (123 > 88 characters) + | +3 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 +4 | +5 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 +6 | """ + | + +E501.py:16:85: E501 Line too long (95 > 88 characters) + | +15 | _ = "---------------------------------------------------------------------------AAAAAAA" +16 | _ = "---------------------------------------------------------------------------亜亜亜亜亜亜亜" + | ^^^^^^^ E501 + | + +E501.py:25:89: E501 Line too long (127 > 88 characters) + | +23 | caller( +24 | """ +25 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 +26 | """, +27 | ) + | + +E501.py:40:89: E501 Line too long (132 > 88 characters) + | +38 | "Lorem ipsum dolor": "sit amet", +39 | # E501 Line too long +40 | "Lorem ipsum dolor": "sit amet consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E501 +41 | # E501 Line too long +42 | "Lorem ipsum dolor": """ + | + +E501.py:43:89: E501 Line too long (105 > 88 characters) + | +41 | # E501 Line too long +42 | "Lorem ipsum dolor": """ +43 | sit amet consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + | ^^^^^^^^^^^^^^^^^ E501 +44 | """, +45 | # OK + | + +E501.py:83:89: E501 Line too long (147 > 88 characters) + | +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 | """ + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E701_E70.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E701_E70.py.snap new file mode 100644 index 0000000000..ddb2fbd2b7 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E701_E70.py.snap @@ -0,0 +1,143 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E70.py:2:5: E701 Multiple statements on one line (colon) + | +1 | #: E701:1:5 +2 | if a: a = False + | ^ E701 +3 | #: E701:1:40 +4 | if not header or header[:6] != 'bytes=': return + | + +E70.py:4:40: E701 Multiple statements on one line (colon) + | +2 | if a: a = False +3 | #: E701:1:40 +4 | if not header or header[:6] != 'bytes=': return + | ^ E701 +5 | #: E702:1:10 +6 | a = False; b = True + | + +E70.py:25:8: E701 Multiple statements on one line (colon) + | +23 | def f(x): return 2*x +24 | #: E704:1:8 E702:1:11 E703:1:14 +25 | if True: x; y; + | ^ E701 +26 | #: E701:1:8 +27 | if True: lambda a: b + | + +E70.py:27:8: E701 Multiple statements on one line (colon) + | +25 | if True: x; y; +26 | #: E701:1:8 +27 | if True: lambda a: b + | ^ E701 +28 | #: E701:1:10 +29 | if a := 1: pass + | + +E70.py:29:10: E701 Multiple statements on one line (colon) + | +27 | if True: lambda a: b +28 | #: E701:1:10 +29 | if a := 1: pass + | ^ E701 +30 | # E701:1:4 E701:2:18 E701:3:8 +31 | try: lambda foo: bar + | + +E70.py:31:4: E701 Multiple statements on one line (colon) + | +29 | if a := 1: pass +30 | # E701:1:4 E701:2:18 E701:3:8 +31 | try: lambda foo: bar + | ^ E701 +32 | except ValueError: pass +33 | finally: pass + | + +E70.py:32:18: E701 Multiple statements on one line (colon) + | +30 | # E701:1:4 E701:2:18 E701:3:8 +31 | try: lambda foo: bar +32 | except ValueError: pass + | ^ E701 +33 | finally: pass +34 | # E701:1:7 + | + +E70.py:33:8: E701 Multiple statements on one line (colon) + | +31 | try: lambda foo: bar +32 | except ValueError: pass +33 | finally: pass + | ^ E701 +34 | # E701:1:7 +35 | class C: pass + | + +E70.py:35:8: E701 Multiple statements on one line (colon) + | +33 | finally: pass +34 | # E701:1:7 +35 | class C: pass + | ^ E701 +36 | # E701:1:7 +37 | with C(): pass + | + +E70.py:37:9: E701 Multiple statements on one line (colon) + | +35 | class C: pass +36 | # E701:1:7 +37 | with C(): pass + | ^ E701 +38 | # E701:1:14 +39 | async with C(): pass + | + +E70.py:39:15: E701 Multiple statements on one line (colon) + | +37 | with C(): pass +38 | # E701:1:14 +39 | async with C(): pass + | ^ E701 +40 | #: +41 | lambda a: b + | + +E70.py:54:8: E701 Multiple statements on one line (colon) + | +52 | def f(): ... +53 | #: E701:1:8 E702:1:13 +54 | class C: ...; x = 1 + | ^ E701 +55 | #: E701:1:8 E702:1:13 +56 | class C: ...; ... + | + +E70.py:56:8: E701 Multiple statements on one line (colon) + | +54 | class C: ...; x = 1 +55 | #: E701:1:8 E702:1:13 +56 | class C: ...; ... + | ^ E701 +57 | #: E701:2:12 +58 | match *0, 1, *2: + | + +E70.py:59:12: E701 Multiple statements on one line (colon) + | +57 | #: E701:2:12 +58 | match *0, 1, *2: +59 | case 0,: y = 0 + | ^ E701 +60 | #: +61 | class Foo: + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E702_E70.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E702_E70.py.snap new file mode 100644 index 0000000000..56e7718289 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E702_E70.py.snap @@ -0,0 +1,74 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E70.py:6:10: E702 Multiple statements on one line (semicolon) + | +4 | if not header or header[:6] != 'bytes=': return +5 | #: E702:1:10 +6 | a = False; b = True + | ^ E702 +7 | #: E702:1:17 +8 | import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe) + | + +E70.py:8:17: E702 Multiple statements on one line (semicolon) + | + 6 | a = False; b = True + 7 | #: E702:1:17 + 8 | import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe) + | ^ E702 + 9 | #: E703:1:13 +10 | import shlex; + | + +E70.py:12:9: E702 Multiple statements on one line (semicolon) + | +10 | import shlex; +11 | #: E702:1:9 E703:1:23 +12 | del a[:]; a.append(42); + | ^ E702 +13 | #: E704:1:1 +14 | def f(x): return 2 + | + +E70.py:25:11: E702 Multiple statements on one line (semicolon) + | +23 | def f(x): return 2*x +24 | #: E704:1:8 E702:1:11 E703:1:14 +25 | if True: x; y; + | ^ E702 +26 | #: E701:1:8 +27 | if True: lambda a: b + | + +E70.py:54:13: E702 Multiple statements on one line (semicolon) + | +52 | def f(): ... +53 | #: E701:1:8 E702:1:13 +54 | class C: ...; x = 1 + | ^ E702 +55 | #: E701:1:8 E702:1:13 +56 | class C: ...; ... + | + +E70.py:56:13: E702 Multiple statements on one line (semicolon) + | +54 | class C: ...; x = 1 +55 | #: E701:1:8 E702:1:13 +56 | class C: ...; ... + | ^ E702 +57 | #: E701:2:12 +58 | match *0, 1, *2: + | + +E70.py:65:4: E702 Multiple statements on one line (semicolon) + | +63 | #: E702:2:4 +64 | while 1: +65 | 1;... + | ^ E702 +66 | #: E703:2:1 +67 | 0\ + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E703_E70.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E703_E70.py.snap new file mode 100644 index 0000000000..798febf236 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E703_E70.py.snap @@ -0,0 +1,105 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E70.py:10:13: E703 [*] Statement ends with an unnecessary semicolon + | + 8 | import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe) + 9 | #: E703:1:13 +10 | import shlex; + | ^ E703 +11 | #: E702:1:9 E703:1:23 +12 | del a[:]; a.append(42); + | + = help: Remove unnecessary semicolon + +ℹ Fix +7 7 | #: E702:1:17 +8 8 | import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe) +9 9 | #: E703:1:13 +10 |-import shlex; + 10 |+import shlex +11 11 | #: E702:1:9 E703:1:23 +12 12 | del a[:]; a.append(42); +13 13 | #: E704:1:1 + +E70.py:12:23: E703 [*] Statement ends with an unnecessary semicolon + | +10 | import shlex; +11 | #: E702:1:9 E703:1:23 +12 | del a[:]; a.append(42); + | ^ E703 +13 | #: E704:1:1 +14 | def f(x): return 2 + | + = help: Remove unnecessary semicolon + +ℹ Fix +9 9 | #: E703:1:13 +10 10 | import shlex; +11 11 | #: E702:1:9 E703:1:23 +12 |-del a[:]; a.append(42); + 12 |+del a[:]; a.append(42) +13 13 | #: E704:1:1 +14 14 | def f(x): return 2 +15 15 | #: E704:1:1 + +E70.py:25:14: E703 [*] Statement ends with an unnecessary semicolon + | +23 | def f(x): return 2*x +24 | #: E704:1:8 E702:1:11 E703:1:14 +25 | if True: x; y; + | ^ E703 +26 | #: E701:1:8 +27 | if True: lambda a: b + | + = help: Remove unnecessary semicolon + +ℹ Fix +22 22 | while all is round: +23 23 | def f(x): return 2*x +24 24 | #: E704:1:8 E702:1:11 E703:1:14 +25 |-if True: x; y; + 25 |+if True: x; y +26 26 | #: E701:1:8 +27 27 | if True: lambda a: b +28 28 | #: E701:1:10 + +E70.py:68:1: E703 [*] Statement ends with an unnecessary semicolon + | +66 | #: E703:2:1 +67 | 0\ +68 | ; + | ^ E703 +69 | #: E701:2:3 +70 | a = \ + | + = help: Remove unnecessary semicolon + +ℹ Fix +64 64 | while 1: +65 65 | 1;... +66 66 | #: E703:2:1 +67 |-0\ +68 |-; + 67 |+0 +69 68 | #: E701:2:3 +70 69 | a = \ +71 70 | 5; + +E70.py:71:4: E703 [*] Statement ends with an unnecessary semicolon + | +69 | #: E701:2:3 +70 | a = \ +71 | 5; + | ^ E703 + | + = help: Remove unnecessary semicolon + +ℹ Fix +68 68 | ; +69 69 | #: E701:2:3 +70 70 | a = \ +71 |- 5; + 71 |+ 5 + + 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 new file mode 100644 index 0000000000..0929543ee6 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E711_E711.py.snap @@ -0,0 +1,208 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E711.py:2:11: E711 [*] Comparison to `None` should be `cond is None` + | +1 | #: E711 +2 | if res == None: + | ^^^^ E711 +3 | pass +4 | #: E711 + | + = help: Replace with `cond is None` + +ℹ Suggested fix +1 1 | #: E711 +2 |-if res == None: + 2 |+if res is None: +3 3 | pass +4 4 | #: E711 +5 5 | if res != None: + +E711.py:5:11: E711 [*] Comparison to `None` should be `cond is not None` + | +3 | pass +4 | #: E711 +5 | if res != None: + | ^^^^ E711 +6 | pass +7 | #: E711 + | + = help: Replace with `cond is not None` + +ℹ Suggested fix +2 2 | if res == None: +3 3 | pass +4 4 | #: E711 +5 |-if res != None: + 5 |+if res is not None: +6 6 | pass +7 7 | #: E711 +8 8 | if None == res: + +E711.py:8:4: E711 [*] Comparison to `None` should be `cond is None` + | + 6 | pass + 7 | #: E711 + 8 | if None == res: + | ^^^^ E711 + 9 | pass +10 | #: E711 + | + = help: Replace with `cond is None` + +ℹ Suggested fix +5 5 | if res != None: +6 6 | pass +7 7 | #: E711 +8 |-if None == res: + 8 |+if None is res: +9 9 | pass +10 10 | #: E711 +11 11 | if None != res: + +E711.py:11:4: E711 [*] Comparison to `None` should be `cond is not None` + | + 9 | pass +10 | #: E711 +11 | if None != res: + | ^^^^ E711 +12 | pass +13 | #: E711 + | + = help: Replace with `cond is not None` + +ℹ Suggested fix +8 8 | if None == res: +9 9 | pass +10 10 | #: E711 +11 |-if None != res: + 11 |+if None is not res: +12 12 | pass +13 13 | #: E711 +14 14 | if res[1] == None: + +E711.py:14:14: E711 [*] Comparison to `None` should be `cond is None` + | +12 | pass +13 | #: E711 +14 | if res[1] == None: + | ^^^^ E711 +15 | pass +16 | #: E711 + | + = help: Replace with `cond is None` + +ℹ Suggested fix +11 11 | if None != res: +12 12 | pass +13 13 | #: E711 +14 |-if res[1] == None: + 14 |+if res[1] is None: +15 15 | pass +16 16 | #: E711 +17 17 | if res[1] != None: + +E711.py:17:14: E711 [*] Comparison to `None` should be `cond is not None` + | +15 | pass +16 | #: E711 +17 | if res[1] != None: + | ^^^^ E711 +18 | pass +19 | #: E711 + | + = help: Replace with `cond is not None` + +ℹ Suggested fix +14 14 | if res[1] == None: +15 15 | pass +16 16 | #: E711 +17 |-if res[1] != None: + 17 |+if res[1] is not None: +18 18 | pass +19 19 | #: E711 +20 20 | if None != res[1]: + +E711.py:20:4: E711 [*] Comparison to `None` should be `cond is not None` + | +18 | pass +19 | #: E711 +20 | if None != res[1]: + | ^^^^ E711 +21 | pass +22 | #: E711 + | + = help: Replace with `cond is not None` + +ℹ Suggested fix +17 17 | if res[1] != None: +18 18 | pass +19 19 | #: E711 +20 |-if None != res[1]: + 20 |+if None is not res[1]: +21 21 | pass +22 22 | #: E711 +23 23 | if None == res[1]: + +E711.py:23:4: E711 [*] Comparison to `None` should be `cond is None` + | +21 | pass +22 | #: E711 +23 | if None == res[1]: + | ^^^^ E711 +24 | pass + | + = help: Replace with `cond is None` + +ℹ Suggested fix +20 20 | if None != res[1]: +21 21 | pass +22 22 | #: E711 +23 |-if None == res[1]: + 23 |+if None is res[1]: +24 24 | pass +25 25 | +26 26 | if x == None != None: + +E711.py:26:9: E711 [*] Comparison to `None` should be `cond is None` + | +24 | pass +25 | +26 | if x == None != None: + | ^^^^ E711 +27 | pass + | + = help: Replace with `cond is None` + +ℹ Suggested fix +23 23 | if None == res[1]: +24 24 | pass +25 25 | +26 |-if x == None != None: + 26 |+if x is None is not None: +27 27 | pass +28 28 | +29 29 | #: Okay + +E711.py:26:17: E711 [*] Comparison to `None` should be `cond is not None` + | +24 | pass +25 | +26 | if x == None != None: + | ^^^^ E711 +27 | pass + | + = help: Replace with `cond is not None` + +ℹ Suggested fix +23 23 | if None == res[1]: +24 24 | pass +25 25 | +26 |-if x == None != None: + 26 |+if x is None is not None: +27 27 | pass +28 28 | +29 29 | #: Okay + + 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 new file mode 100644 index 0000000000..6f4b23c2de --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E712_E712.py.snap @@ -0,0 +1,269 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E712.py:2:11: E712 [*] Comparison to `True` should be `cond is True` or `if cond:` + | +1 | #: E712 +2 | if res == True: + | ^^^^ E712 +3 | pass +4 | #: E712 + | + = help: Replace with `cond is True` + +ℹ Suggested fix +1 1 | #: E712 +2 |-if res == True: + 2 |+if res is True: +3 3 | pass +4 4 | #: E712 +5 5 | if res != False: + +E712.py:5:11: E712 [*] Comparison to `False` should be `cond is not False` or `if cond:` + | +3 | pass +4 | #: E712 +5 | if res != False: + | ^^^^^ E712 +6 | pass +7 | #: E712 + | + = help: Replace with `cond is not False` + +ℹ Suggested fix +2 2 | if res == True: +3 3 | pass +4 4 | #: E712 +5 |-if res != False: + 5 |+if res is not False: +6 6 | pass +7 7 | #: E712 +8 8 | if True != res: + +E712.py:8:4: E712 [*] Comparison to `True` should be `cond is not True` or `if not cond:` + | + 6 | pass + 7 | #: E712 + 8 | if True != res: + | ^^^^ E712 + 9 | pass +10 | #: E712 + | + = help: Replace with `cond is not True` + +ℹ Suggested fix +5 5 | if res != False: +6 6 | pass +7 7 | #: E712 +8 |-if True != res: + 8 |+if True is not res: +9 9 | pass +10 10 | #: E712 +11 11 | if False == res: + +E712.py:11:4: E712 [*] Comparison to `False` should be `cond is False` or `if not cond:` + | + 9 | pass +10 | #: E712 +11 | if False == res: + | ^^^^^ E712 +12 | pass +13 | #: E712 + | + = help: Replace with `cond is False` + +ℹ Suggested fix +8 8 | if True != res: +9 9 | pass +10 10 | #: E712 +11 |-if False == res: + 11 |+if False is res: +12 12 | pass +13 13 | #: E712 +14 14 | if res[1] == True: + +E712.py:14:14: E712 [*] Comparison to `True` should be `cond is True` or `if cond:` + | +12 | pass +13 | #: E712 +14 | if res[1] == True: + | ^^^^ E712 +15 | pass +16 | #: E712 + | + = help: Replace with `cond is True` + +ℹ Suggested fix +11 11 | if False == res: +12 12 | pass +13 13 | #: E712 +14 |-if res[1] == True: + 14 |+if res[1] is True: +15 15 | pass +16 16 | #: E712 +17 17 | if res[1] != False: + +E712.py:17:14: E712 [*] Comparison to `False` should be `cond is not False` or `if cond:` + | +15 | pass +16 | #: E712 +17 | if res[1] != False: + | ^^^^^ E712 +18 | pass +19 | #: E712 + | + = help: Replace with `cond is not False` + +ℹ Suggested fix +14 14 | if res[1] == True: +15 15 | pass +16 16 | #: E712 +17 |-if res[1] != False: + 17 |+if res[1] is not False: +18 18 | pass +19 19 | #: E712 +20 20 | var = 1 if cond == True else -1 if cond == False else cond + +E712.py:20:20: E712 [*] Comparison to `True` should be `cond is True` or `if cond:` + | +18 | pass +19 | #: E712 +20 | var = 1 if cond == True else -1 if cond == False else cond + | ^^^^ E712 +21 | #: E712 +22 | if (True) == TrueElement or x == TrueElement: + | + = help: Replace with `cond is True` + +ℹ Suggested fix +17 17 | if res[1] != False: +18 18 | pass +19 19 | #: E712 +20 |-var = 1 if cond == True else -1 if cond == False else cond + 20 |+var = 1 if cond is True else -1 if cond == False else cond +21 21 | #: E712 +22 22 | if (True) == TrueElement or x == TrueElement: +23 23 | pass + +E712.py:20:44: E712 [*] Comparison to `False` should be `cond is False` or `if not cond:` + | +18 | pass +19 | #: E712 +20 | var = 1 if cond == True else -1 if cond == False else cond + | ^^^^^ E712 +21 | #: E712 +22 | if (True) == TrueElement or x == TrueElement: + | + = help: Replace with `cond is False` + +ℹ Suggested fix +17 17 | if res[1] != False: +18 18 | pass +19 19 | #: E712 +20 |-var = 1 if cond == True else -1 if cond == False else cond + 20 |+var = 1 if cond == True else -1 if cond is False else cond +21 21 | #: E712 +22 22 | if (True) == TrueElement or x == TrueElement: +23 23 | pass + +E712.py:22:5: E712 [*] Comparison to `True` should be `cond is True` or `if cond:` + | +20 | var = 1 if cond == True else -1 if cond == False else cond +21 | #: E712 +22 | if (True) == TrueElement or x == TrueElement: + | ^^^^ E712 +23 | pass + | + = help: Replace with `cond is True` + +ℹ Suggested fix +19 19 | #: E712 +20 20 | var = 1 if cond == True else -1 if cond == False else cond +21 21 | #: E712 +22 |-if (True) == TrueElement or x == TrueElement: + 22 |+if (True) is TrueElement or x == TrueElement: +23 23 | pass +24 24 | +25 25 | if res == True != False: + +E712.py:25:11: E712 [*] Comparison to `True` should be `cond is True` or `if cond:` + | +23 | pass +24 | +25 | if res == True != False: + | ^^^^ E712 +26 | pass + | + = help: Replace with `cond is True` + +ℹ Suggested fix +22 22 | if (True) == TrueElement or x == TrueElement: +23 23 | pass +24 24 | +25 |-if res == True != False: + 25 |+if res is True is not False: +26 26 | pass +27 27 | +28 28 | if(True) == TrueElement or x == TrueElement: + +E712.py:25:19: E712 [*] Comparison to `False` should be `cond is not False` or `if cond:` + | +23 | pass +24 | +25 | if res == True != False: + | ^^^^^ E712 +26 | pass + | + = help: Replace with `cond is not False` + +ℹ Suggested fix +22 22 | if (True) == TrueElement or x == TrueElement: +23 23 | pass +24 24 | +25 |-if res == True != False: + 25 |+if res is True is not False: +26 26 | pass +27 27 | +28 28 | if(True) == TrueElement or x == TrueElement: + +E712.py:28:4: E712 [*] Comparison to `True` should be `cond is True` or `if cond:` + | +26 | pass +27 | +28 | if(True) == TrueElement or x == TrueElement: + | ^^^^ E712 +29 | pass + | + = help: Replace with `cond is True` + +ℹ Suggested fix +25 25 | if res == True != False: +26 26 | pass +27 27 | +28 |-if(True) == TrueElement or x == TrueElement: + 28 |+if(True) is TrueElement or x == TrueElement: +29 29 | pass +30 30 | +31 31 | if (yield i) == True: + +E712.py:31:17: E712 [*] Comparison to `True` should be `cond is True` or `if cond:` + | +29 | pass +30 | +31 | if (yield i) == True: + | ^^^^ E712 +32 | print("even") + | + = help: Replace with `cond is True` + +ℹ Suggested fix +28 28 | if(True) == TrueElement or x == TrueElement: +29 29 | pass +30 30 | +31 |-if (yield i) == True: + 31 |+if (yield i) is True: +32 32 | print("even") +33 33 | +34 34 | #: Okay + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E713_E713.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E713_E713.py.snap new file mode 100644 index 0000000000..b1055ba21e --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E713_E713.py.snap @@ -0,0 +1,121 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E713.py:2:8: E713 [*] Test for membership should be `not in` + | +1 | #: E713 +2 | if not X in Y: + | ^^^^^^ E713 +3 | pass +4 | #: E713 + | + = help: Convert to `not in` + +ℹ Fix +1 1 | #: E713 +2 |-if not X in Y: + 2 |+if X not in Y: +3 3 | pass +4 4 | #: E713 +5 5 | if not X.B in Y: + +E713.py:5:8: E713 [*] Test for membership should be `not in` + | +3 | pass +4 | #: E713 +5 | if not X.B in Y: + | ^^^^^^^^ E713 +6 | pass +7 | #: E713 + | + = help: Convert to `not in` + +ℹ Fix +2 2 | if not X in Y: +3 3 | pass +4 4 | #: E713 +5 |-if not X.B in Y: + 5 |+if X.B not in Y: +6 6 | pass +7 7 | #: E713 +8 8 | if not X in Y and Z == "zero": + +E713.py:8:8: E713 [*] Test for membership should be `not in` + | + 6 | pass + 7 | #: E713 + 8 | if not X in Y and Z == "zero": + | ^^^^^^ E713 + 9 | pass +10 | #: E713 + | + = help: Convert to `not in` + +ℹ Fix +5 5 | if not X.B in Y: +6 6 | pass +7 7 | #: E713 +8 |-if not X in Y and Z == "zero": + 8 |+if X not in Y and Z == "zero": +9 9 | pass +10 10 | #: E713 +11 11 | if X == "zero" or not Y in Z: + +E713.py:11:23: E713 [*] Test for membership should be `not in` + | + 9 | pass +10 | #: E713 +11 | if X == "zero" or not Y in Z: + | ^^^^^^ E713 +12 | pass +13 | #: E713 + | + = help: Convert to `not in` + +ℹ Fix +8 8 | if not X in Y and Z == "zero": +9 9 | pass +10 10 | #: E713 +11 |-if X == "zero" or not Y in Z: + 11 |+if X == "zero" or Y not in Z: +12 12 | pass +13 13 | #: E713 +14 14 | if not (X in Y): + +E713.py:14:9: E713 [*] Test for membership should be `not in` + | +12 | pass +13 | #: E713 +14 | if not (X in Y): + | ^^^^^^ E713 +15 | pass + | + = help: Convert to `not in` + +ℹ Fix +11 11 | if X == "zero" or not Y in Z: +12 12 | pass +13 13 | #: E713 +14 |-if not (X in Y): + 14 |+if X not in Y: +15 15 | pass +16 16 | +17 17 | #: Okay + +E713.py:40:12: E713 [*] Test for membership should be `not in` + | +38 | assert [42, not foo] in bar +39 | assert not (re.search(r"^.:\\Users\\[^\\]*\\Downloads\\.*") is None) +40 | assert not('name' in request)or not request['name'] + | ^^^^^^^^^^^^^^^^^ E713 + | + = help: Convert to `not in` + +ℹ Fix +37 37 | assert {"x": not foo} in bar +38 38 | assert [42, not foo] in bar +39 39 | assert not (re.search(r"^.:\\Users\\[^\\]*\\Downloads\\.*") is None) +40 |-assert not('name' in request)or not request['name'] + 40 |+assert 'name' not in request or not request['name'] + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E714_E714.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E714_E714.py.snap new file mode 100644 index 0000000000..7195ac921c --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E714_E714.py.snap @@ -0,0 +1,58 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E714.py:2:8: E714 [*] Test for object identity should be `is not` + | +1 | #: E714 +2 | if not X is Y: + | ^^^^^^ E714 +3 | pass +4 | #: E714 + | + = help: Convert to `is not` + +ℹ Fix +1 1 | #: E714 +2 |-if not X is Y: + 2 |+if X is not Y: +3 3 | pass +4 4 | #: E714 +5 5 | if not X.B is Y: + +E714.py:5:8: E714 [*] Test for object identity should be `is not` + | +3 | pass +4 | #: E714 +5 | if not X.B is Y: + | ^^^^^^^^ E714 +6 | pass + | + = help: Convert to `is not` + +ℹ Fix +2 2 | if not X is Y: +3 3 | pass +4 4 | #: E714 +5 |-if not X.B is Y: + 5 |+if X.B is not Y: +6 6 | pass +7 7 | +8 8 | #: Okay + +E714.py:39:13: E714 [*] Test for object identity should be `is not` + | +37 | assert {"x": not foo} in bar +38 | assert [42, not foo] in bar +39 | assert not (re.search(r"^.:\\Users\\[^\\]*\\Downloads\\.*") is None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E714 + | + = help: Convert to `is not` + +ℹ Fix +36 36 | assert (not foo) in bar +37 37 | assert {"x": not foo} in bar +38 38 | assert [42, not foo] in bar +39 |-assert not (re.search(r"^.:\\Users\\[^\\]*\\Downloads\\.*") is None) + 39 |+assert re.search(r"^.:\\Users\\[^\\]*\\Downloads\\.*") is not None + + 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 new file mode 100644 index 0000000000..c1947fa971 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E721_E721.py.snap @@ -0,0 +1,173 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E721.py:2:4: E721 Do not compare types, use `isinstance()` + | +1 | #: E721 +2 | if type(res) == type(42): + | ^^^^^^^^^^^^^^^^^^^^^ E721 +3 | pass +4 | #: E721 + | + +E721.py:5:4: E721 Do not compare types, use `isinstance()` + | +3 | pass +4 | #: E721 +5 | if type(res) != type(""): + | ^^^^^^^^^^^^^^^^^^^^^ E721 +6 | pass +7 | #: E721 + | + +E721.py:15:4: E721 Do not compare types, use `isinstance()` + | +13 | import types +14 | +15 | if type(res) is not types.ListType: + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E721 +16 | pass +17 | #: E721 + | + +E721.py:18:8: E721 Do not compare types, use `isinstance()` + | +16 | pass +17 | #: E721 +18 | assert type(res) == type(False) + | ^^^^^^^^^^^^^^^^^^^^^^^^ E721 +19 | #: E721 +20 | assert type(res) == type([]) + | + +E721.py:20:8: E721 Do not compare types, use `isinstance()` + | +18 | assert type(res) == type(False) +19 | #: E721 +20 | assert type(res) == type([]) + | ^^^^^^^^^^^^^^^^^^^^^ E721 +21 | #: E721 +22 | assert type(res) == type(()) + | + +E721.py:22:8: E721 Do not compare types, use `isinstance()` + | +20 | assert type(res) == type([]) +21 | #: E721 +22 | assert type(res) == type(()) + | ^^^^^^^^^^^^^^^^^^^^^ E721 +23 | #: E721 +24 | assert type(res) == type((0,)) + | + +E721.py:24:8: E721 Do not compare types, use `isinstance()` + | +22 | assert type(res) == type(()) +23 | #: E721 +24 | assert type(res) == type((0,)) + | ^^^^^^^^^^^^^^^^^^^^^^^ E721 +25 | #: E721 +26 | assert type(res) == type((0)) + | + +E721.py:26:8: E721 Do not compare types, use `isinstance()` + | +24 | assert type(res) == type((0,)) +25 | #: E721 +26 | assert type(res) == type((0)) + | ^^^^^^^^^^^^^^^^^^^^^^ E721 +27 | #: E721 +28 | assert type(res) != type((1,)) + | + +E721.py:28:8: E721 Do not compare types, use `isinstance()` + | +26 | assert type(res) == type((0)) +27 | #: E721 +28 | assert type(res) != type((1,)) + | ^^^^^^^^^^^^^^^^^^^^^^^ E721 +29 | #: E721 +30 | assert type(res) is type((1,)) + | + +E721.py:30:8: E721 Do not compare types, use `isinstance()` + | +28 | assert type(res) != type((1,)) +29 | #: E721 +30 | assert type(res) is type((1,)) + | ^^^^^^^^^^^^^^^^^^^^^^^ E721 +31 | #: E721 +32 | assert type(res) is not type((1,)) + | + +E721.py:32:8: E721 Do not compare types, use `isinstance()` + | +30 | assert type(res) is type((1,)) +31 | #: E721 +32 | assert type(res) is not type((1,)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ E721 +33 | #: E211 E721 +34 | assert type(res) == type( + | + +E721.py:34:8: E721 Do not compare types, use `isinstance()` + | +32 | assert type(res) is not type((1,)) +33 | #: E211 E721 +34 | assert type(res) == type( + | ________^ +35 | | [ +36 | | 2, +37 | | ] +38 | | ) + | |_^ E721 +39 | #: E201 E201 E202 E721 +40 | assert type(res) == type(()) + | + +E721.py:40:8: E721 Do not compare types, use `isinstance()` + | +38 | ) +39 | #: E201 E201 E202 E721 +40 | assert type(res) == type(()) + | ^^^^^^^^^^^^^^^^^^^^^ E721 +41 | #: E201 E202 E721 +42 | assert type(res) == type((0,)) + | + +E721.py:42:8: E721 Do not compare types, use `isinstance()` + | +40 | assert type(res) == type(()) +41 | #: E201 E202 E721 +42 | assert type(res) == type((0,)) + | ^^^^^^^^^^^^^^^^^^^^^^^ E721 +43 | +44 | #: Okay + | + +E721.py:63:8: E721 Do not compare types, use `isinstance()` + | +62 | #: E721 +63 | assert type(res) is int + | ^^^^^^^^^^^^^^^^ E721 + | + +E721.py:69:12: E721 Do not compare types, use `isinstance()` + | +67 | def asdf(self, value: str | None): +68 | #: E721 +69 | if type(value) is str: + | ^^^^^^^^^^^^^^^^^^ E721 +70 | ... + | + +E721.py:79:12: E721 Do not compare types, use `isinstance()` + | +77 | def asdf(self, value: str | None): +78 | #: E721 +79 | if type(value) is str: + | ^^^^^^^^^^^^^^^^^^ E721 +80 | ... + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E722_E722.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E722_E722.py.snap new file mode 100644 index 0000000000..9de6888cf8 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E722_E722.py.snap @@ -0,0 +1,34 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E722.py:4:1: E722 Do not use bare `except` + | +2 | try: +3 | pass +4 | except: + | ^^^^^^ E722 +5 | pass +6 | #: E722 + | + +E722.py:11:1: E722 Do not use bare `except` + | + 9 | except Exception: +10 | pass +11 | except: + | ^^^^^^ E722 +12 | pass +13 | #: E722 + | + +E722.py:16:1: E722 Do not use bare `except` + | +14 | try: +15 | pass +16 | except: + | ^^^^^^ E722 +17 | pass +18 | #: Okay + | + + 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 new file mode 100644 index 0000000000..ce00ec0a9a --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E731_E731.py.snap @@ -0,0 +1,387 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E731.py:3:5: E731 [*] Do not assign a `lambda` expression, use a `def` + | +1 | def scope(): +2 | # E731 +3 | f = lambda x: 2 * x + | ^^^^^^^^^^^^^^^^^^^ E731 + | + = help: Rewrite `f` as a `def` + +ℹ Suggested fix +1 1 | def scope(): +2 2 | # E731 +3 |- f = lambda x: 2 * x + 3 |+ def f(x): + 4 |+ return 2 * x +4 5 | +5 6 | +6 7 | def scope(): + +E731.py:8:5: E731 [*] Do not assign a `lambda` expression, use a `def` + | +6 | def scope(): +7 | # E731 +8 | f = lambda x: 2 * x + | ^^^^^^^^^^^^^^^^^^^ E731 + | + = help: Rewrite `f` as a `def` + +ℹ Suggested fix +5 5 | +6 6 | def scope(): +7 7 | # E731 +8 |- f = lambda x: 2 * x + 8 |+ def f(x): + 9 |+ return 2 * x +9 10 | +10 11 | +11 12 | def scope(): + +E731.py:14:9: E731 [*] Do not assign a `lambda` expression, use a `def` + | +12 | # E731 +13 | while False: +14 | this = lambda y, z: 2 * x + | ^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | + = help: Rewrite `this` as a `def` + +ℹ Suggested fix +11 11 | def scope(): +12 12 | # E731 +13 13 | while False: +14 |- this = lambda y, z: 2 * x + 14 |+ def this(y, z): + 15 |+ return 2 * x +15 16 | +16 17 | +17 18 | def scope(): + +E731.py:19:5: E731 [*] Do not assign a `lambda` expression, use a `def` + | +17 | def scope(): +18 | # E731 +19 | f = lambda: (yield 1) + | ^^^^^^^^^^^^^^^^^^^^^ E731 + | + = help: Rewrite `f` as a `def` + +ℹ Suggested fix +16 16 | +17 17 | def scope(): +18 18 | # E731 +19 |- f = lambda: (yield 1) + 19 |+ def f(): + 20 |+ return (yield 1) +20 21 | +21 22 | +22 23 | def scope(): + +E731.py:24:5: E731 [*] Do not assign a `lambda` expression, use a `def` + | +22 | def scope(): +23 | # E731 +24 | f = lambda: (yield from g()) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | + = help: Rewrite `f` as a `def` + +ℹ Suggested fix +21 21 | +22 22 | def scope(): +23 23 | # E731 +24 |- f = lambda: (yield from g()) + 24 |+ def f(): + 25 |+ return (yield from g()) +25 26 | +26 27 | +27 28 | def scope(): + +E731.py:57:5: E731 [*] Do not assign a `lambda` expression, use a `def` + | +55 | class Scope: +56 | # E731 +57 | f = lambda x: 2 * x + | ^^^^^^^^^^^^^^^^^^^ E731 + | + = help: Rewrite `f` as a `def` + +ℹ Possible fix +54 54 | +55 55 | class Scope: +56 56 | # E731 +57 |- f = lambda x: 2 * x + 57 |+ def f(x): + 58 |+ return 2 * x +58 59 | +59 60 | +60 61 | class Scope: + +E731.py:64:5: E731 [*] Do not assign a `lambda` expression, use a `def` + | +63 | # E731 +64 | f: Callable[[int], int] = lambda x: 2 * x + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | + = help: Rewrite `f` as a `def` + +ℹ Possible fix +61 61 | from typing import Callable +62 62 | +63 63 | # E731 +64 |- f: Callable[[int], int] = lambda x: 2 * x + 64 |+ def f(x: int) -> int: + 65 |+ return 2 * x +65 66 | +66 67 | +67 68 | def scope(): + +E731.py:73:9: E731 [*] Do not assign a `lambda` expression, use a `def` + | +71 | x: Callable[[int], int] +72 | if True: +73 | x = lambda: 1 + | ^^^^^^^^^^^^^ E731 +74 | else: +75 | x = lambda: 2 + | + = help: Rewrite `x` as a `def` + +ℹ Possible fix +70 70 | +71 71 | x: Callable[[int], int] +72 72 | if True: +73 |- x = lambda: 1 + 73 |+ def x(): + 74 |+ return 1 +74 75 | else: +75 76 | x = lambda: 2 +76 77 | return x + +E731.py:75:9: E731 [*] Do not assign a `lambda` expression, use a `def` + | +73 | x = lambda: 1 +74 | else: +75 | x = lambda: 2 + | ^^^^^^^^^^^^^ E731 +76 | return x + | + = help: Rewrite `x` as a `def` + +ℹ Possible fix +72 72 | if True: +73 73 | x = lambda: 1 +74 74 | else: +75 |- x = lambda: 2 + 75 |+ def x(): + 76 |+ return 2 +76 77 | return x +77 78 | +78 79 | + +E731.py:86:5: E731 [*] Do not assign a `lambda` expression, use a `def` + | +84 | # ParamSpec cannot be used in this context, so do not preserve the annotation. +85 | P = ParamSpec("P") +86 | f: Callable[P, int] = lambda *args: len(args) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | + = help: Rewrite `f` as a `def` + +ℹ Suggested fix +83 83 | +84 84 | # ParamSpec cannot be used in this context, so do not preserve the annotation. +85 85 | P = ParamSpec("P") +86 |- f: Callable[P, int] = lambda *args: len(args) + 86 |+ def f(*args): + 87 |+ return len(args) +87 88 | +88 89 | +89 90 | def scope(): + +E731.py:94:5: E731 [*] Do not assign a `lambda` expression, use a `def` + | +92 | from typing import Callable +93 | +94 | f: Callable[[], None] = lambda: None + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | + = help: Rewrite `f` as a `def` + +ℹ Suggested fix +91 91 | +92 92 | from typing import Callable +93 93 | +94 |- f: Callable[[], None] = lambda: None + 94 |+ def f() -> None: + 95 |+ return None +95 96 | +96 97 | +97 98 | def scope(): + +E731.py:102:5: E731 [*] Do not assign a `lambda` expression, use a `def` + | +100 | from typing import Callable +101 | +102 | f: Callable[..., None] = lambda a, b: None + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | + = help: Rewrite `f` as a `def` + +ℹ Suggested fix +99 99 | +100 100 | from typing import Callable +101 101 | +102 |- f: Callable[..., None] = lambda a, b: None + 102 |+ def f(a, b) -> None: + 103 |+ return None +103 104 | +104 105 | +105 106 | def scope(): + +E731.py:110:5: E731 [*] Do not assign a `lambda` expression, use a `def` + | +108 | from typing import Callable +109 | +110 | f: Callable[[int], int] = lambda x: 2 * x + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | + = help: Rewrite `f` as a `def` + +ℹ Suggested fix +107 107 | +108 108 | from typing import Callable +109 109 | +110 |- f: Callable[[int], int] = lambda x: 2 * x + 110 |+ def f(x: int) -> int: + 111 |+ return 2 * x +111 112 | +112 113 | +113 114 | # Let's use the `Callable` type from `collections.abc` instead. + +E731.py:119:5: E731 [*] Do not assign a `lambda` expression, use a `def` + | +117 | from collections.abc import Callable +118 | +119 | f: Callable[[str, int], str] = lambda a, b: a * b + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | + = help: Rewrite `f` as a `def` + +ℹ Suggested fix +116 116 | +117 117 | from collections.abc import Callable +118 118 | +119 |- f: Callable[[str, int], str] = lambda a, b: a * b + 119 |+ def f(a: str, b: int) -> str: + 120 |+ return a * b +120 121 | +121 122 | +122 123 | def scope(): + +E731.py:127:5: E731 [*] Do not assign a `lambda` expression, use a `def` + | +125 | from collections.abc import Callable +126 | +127 | f: Callable[[str, int], tuple[str, int]] = lambda a, b: (a, b) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | + = help: Rewrite `f` as a `def` + +ℹ Suggested fix +124 124 | +125 125 | from collections.abc import Callable +126 126 | +127 |- f: Callable[[str, int], tuple[str, int]] = lambda a, b: (a, b) + 127 |+ def f(a: str, b: int) -> tuple[str, int]: + 128 |+ return a, b +128 129 | +129 130 | +130 131 | def scope(): + +E731.py:135:5: E731 [*] Do not assign a `lambda` expression, use a `def` + | +133 | from collections.abc import Callable +134 | +135 | f: Callable[[str, int, list[str]], list[str]] = lambda a, b, /, c: [*c, a * b] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | + = help: Rewrite `f` as a `def` + +ℹ Suggested fix +132 132 | +133 133 | from collections.abc import Callable +134 134 | +135 |- f: Callable[[str, int, list[str]], list[str]] = lambda a, b, /, c: [*c, a * b] + 135 |+ def f(a: str, b: int, /, c: list[str]) -> list[str]: + 136 |+ return [*c, a * b] +136 137 | +137 138 | +138 139 | class TemperatureScales(Enum): + +E731.py:139:5: E731 [*] Do not assign a `lambda` expression, use a `def` + | +138 | class TemperatureScales(Enum): +139 | CELSIUS = (lambda deg_c: deg_c) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 +140 | FAHRENHEIT = (lambda deg_c: deg_c * 9 / 5 + 32) + | + = help: Rewrite `CELSIUS` as a `def` + +ℹ Possible fix +136 136 | +137 137 | +138 138 | class TemperatureScales(Enum): +139 |- CELSIUS = (lambda deg_c: deg_c) + 139 |+ def CELSIUS(deg_c): + 140 |+ return deg_c +140 141 | FAHRENHEIT = (lambda deg_c: deg_c * 9 / 5 + 32) +141 142 | +142 143 | + +E731.py:140:5: E731 [*] Do not assign a `lambda` expression, use a `def` + | +138 | class TemperatureScales(Enum): +139 | CELSIUS = (lambda deg_c: deg_c) +140 | FAHRENHEIT = (lambda deg_c: deg_c * 9 / 5 + 32) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E731 + | + = help: Rewrite `FAHRENHEIT` as a `def` + +ℹ Possible fix +137 137 | +138 138 | class TemperatureScales(Enum): +139 139 | CELSIUS = (lambda deg_c: deg_c) +140 |- FAHRENHEIT = (lambda deg_c: deg_c * 9 / 5 + 32) + 140 |+ def FAHRENHEIT(deg_c): + 141 |+ return deg_c * 9 / 5 + 32 +141 142 | +142 143 | +143 144 | # Regression test for: https://github.com/astral-sh/ruff/issues/7141 + +E731.py:147:5: E731 [*] Do not assign a `lambda` expression, use a `def` + | +145 | # E731 +146 | +147 | f = lambda: ( + | _____^ +148 | | i := 1, +149 | | ) + | |_____^ E731 + | + = help: Rewrite `f` as a `def` + +ℹ Suggested fix +144 144 | def scope(): +145 145 | # E731 +146 146 | +147 |- f = lambda: ( +148 |- i := 1, +149 |- ) + 147 |+ def f(): + 148 |+ return (i := 1), + + 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 new file mode 100644 index 0000000000..ceea95df29 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E741_E741.py.snap @@ -0,0 +1,213 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E741.py:3:1: E741 Ambiguous variable name: `l` + | +1 | from contextlib import contextmanager +2 | +3 | l = 0 + | ^ E741 +4 | I = 0 +5 | O = 0 + | + +E741.py:4:1: E741 Ambiguous variable name: `I` + | +3 | l = 0 +4 | I = 0 + | ^ E741 +5 | O = 0 +6 | l: int = 0 + | + +E741.py:5:1: E741 Ambiguous variable name: `O` + | +3 | l = 0 +4 | I = 0 +5 | O = 0 + | ^ E741 +6 | l: int = 0 + | + +E741.py:6:1: E741 Ambiguous variable name: `l` + | +4 | I = 0 +5 | O = 0 +6 | l: int = 0 + | ^ E741 +7 | +8 | a, l = 0, 1 + | + +E741.py:8:4: E741 Ambiguous variable name: `l` + | + 6 | l: int = 0 + 7 | + 8 | a, l = 0, 1 + | ^ E741 + 9 | [a, l] = 0, 1 +10 | a, *l = 0, 1, 2 + | + +E741.py:9:5: E741 Ambiguous variable name: `l` + | + 8 | a, l = 0, 1 + 9 | [a, l] = 0, 1 + | ^ E741 +10 | a, *l = 0, 1, 2 +11 | a = l = 0 + | + +E741.py:10:5: E741 Ambiguous variable name: `l` + | + 8 | a, l = 0, 1 + 9 | [a, l] = 0, 1 +10 | a, *l = 0, 1, 2 + | ^ E741 +11 | a = l = 0 + | + +E741.py:11:5: E741 Ambiguous variable name: `l` + | + 9 | [a, l] = 0, 1 +10 | a, *l = 0, 1, 2 +11 | a = l = 0 + | ^ E741 +12 | +13 | o = 0 + | + +E741.py:16:5: E741 Ambiguous variable name: `l` + | +14 | i = 0 +15 | +16 | for l in range(3): + | ^ E741 +17 | pass + | + +E741.py:20:8: E741 Ambiguous variable name: `l` + | +20 | for a, l in zip(range(3), range(3)): + | ^ E741 +21 | pass + | + +E741.py:25:12: E741 Ambiguous variable name: `l` + | +24 | def f1(): +25 | global l + | ^ E741 +26 | l = 0 + | + +E741.py:26:5: E741 Ambiguous variable name: `l` + | +24 | def f1(): +25 | global l +26 | l = 0 + | ^ E741 + | + +E741.py:30:5: E741 Ambiguous variable name: `l` + | +29 | def f2(): +30 | l = 0 + | ^ E741 +31 | +32 | def f3(): + | + +E741.py:33:18: E741 Ambiguous variable name: `l` + | +32 | def f3(): +33 | nonlocal l + | ^ E741 +34 | l = 1 + | + +E741.py:34:9: E741 Ambiguous variable name: `l` + | +32 | def f3(): +33 | nonlocal l +34 | l = 1 + | ^ E741 +35 | +36 | f3() + | + +E741.py:40:8: E741 Ambiguous variable name: `l` + | +40 | def f4(l, /, I): + | ^ E741 +41 | return l, I, O + | + +E741.py:40:14: E741 Ambiguous variable name: `I` + | +40 | def f4(l, /, I): + | ^ E741 +41 | return l, I, O + | + +E741.py:44:8: E741 Ambiguous variable name: `l` + | +44 | def f5(l=0, *, I=1): + | ^ E741 +45 | return l, I + | + +E741.py:44:16: E741 Ambiguous variable name: `I` + | +44 | def f5(l=0, *, I=1): + | ^ E741 +45 | return l, I + | + +E741.py:48:9: E741 Ambiguous variable name: `l` + | +48 | def f6(*l, **I): + | ^ E741 +49 | return l, I + | + +E741.py:48:14: E741 Ambiguous variable name: `I` + | +48 | def f6(*l, **I): + | ^ E741 +49 | return l, I + | + +E741.py:57:16: E741 Ambiguous variable name: `l` + | +57 | with ctx1() as l: + | ^ E741 +58 | pass + | + +E741.py:66:20: E741 Ambiguous variable name: `l` + | +66 | with ctx2() as (a, l): + | ^ E741 +67 | pass + | + +E741.py:71:22: E741 Ambiguous variable name: `l` + | +69 | try: +70 | pass +71 | except ValueError as l: + | ^ E741 +72 | pass + | + +E741.py:74:5: E741 Ambiguous variable name: `l` + | +72 | pass +73 | +74 | if (l := 5) > 0: + | ^ E741 +75 | pass + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E742_E742.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E742_E742.py.snap new file mode 100644 index 0000000000..6b4c1429be --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E742_E742.py.snap @@ -0,0 +1,25 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E742.py:1:7: E742 Ambiguous class name: `l` + | +1 | class l: + | ^ E742 +2 | pass + | + +E742.py:5:7: E742 Ambiguous class name: `I` + | +5 | class I: + | ^ E742 +6 | pass + | + +E742.py:9:7: E742 Ambiguous class name: `O` + | + 9 | class O: + | ^ E742 +10 | pass + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E743_E743.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E743_E743.py.snap new file mode 100644 index 0000000000..067cbe927f --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E743_E743.py.snap @@ -0,0 +1,26 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E743.py:1:5: E743 Ambiguous function name: `l` + | +1 | def l(): + | ^ E743 +2 | pass + | + +E743.py:5:5: E743 Ambiguous function name: `I` + | +5 | def I(): + | ^ E743 +6 | pass + | + +E743.py:10:9: E743 Ambiguous function name: `O` + | + 9 | class X: +10 | def O(self): + | ^ E743 +11 | pass + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E999_E999.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E999_E999.py.snap new file mode 100644 index 0000000000..767f6e4a0a --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__E999_E999.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E999.py:3:1: E999 SyntaxError: unindent does not match any outer indentation level + | +2 | def x(): +3 | + | ^ E999 +4 | + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W191_W19.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W191_W19.py.snap new file mode 100644 index 0000000000..ff6c28bc72 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W191_W19.py.snap @@ -0,0 +1,352 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +W19.py:1:1: W191 Indentation contains tabs + | +1 | '''File starts with a tab + | ^^^^ W191 +2 | multiline string with tab in it''' + | + +W19.py:6:1: W191 Indentation contains tabs + | +4 | #: W191 +5 | if False: +6 | print # indented with 1 tab + | ^^^^ W191 +7 | #: + | + +W19.py:12:1: W191 Indentation contains tabs + | +10 | #: W191 +11 | y = x == 2 \ +12 | or x == 3 + | ^^^^ W191 +13 | #: E101 W191 W504 +14 | if ( + | + +W19.py:19:1: W191 Indentation contains tabs + | +17 | ) or +18 | y == 4): +19 | pass + | ^^^^ W191 +20 | #: E101 W191 +21 | if x == 2 \ + | + +W19.py:24:1: W191 Indentation contains tabs + | +22 | or y > 1 \ +23 | or x == 3: +24 | pass + | ^^^^ W191 +25 | #: E101 W191 +26 | if x == 2 \ + | + +W19.py:29:1: W191 Indentation contains tabs + | +27 | or y > 1 \ +28 | or x == 3: +29 | pass + | ^^^^ W191 +30 | #: + | + +W19.py:35:1: W191 Indentation contains tabs + | +33 | if (foo == bar and +34 | baz == bop): +35 | pass + | ^^^^ W191 +36 | #: E101 W191 W504 +37 | if ( + | + +W19.py:41:1: W191 Indentation contains tabs + | +39 | baz == bop +40 | ): +41 | pass + | ^^^^ W191 +42 | #: + | + +W19.py:47:1: W191 Indentation contains tabs + | +45 | if start[1] > end_col and not ( +46 | over_indent == 4 and indent_next): +47 | return (0, "E121 continuation line over-" + | ^^^^ W191 +48 | "indented for visual indent") +49 | #: + | + +W19.py:48:1: W191 Indentation contains tabs + | +46 | over_indent == 4 and indent_next): +47 | return (0, "E121 continuation line over-" +48 | "indented for visual indent") + | ^^^^^^^^^^^^ W191 +49 | #: + | + +W19.py:57:1: W191 Indentation contains tabs + | +55 | var_one, var_two, var_three, +56 | var_four): +57 | print(var_one) + | ^^^^ W191 +58 | #: E101 W191 W504 +59 | if ((row < 0 or self.moduleCount <= row or + | + +W19.py:61:1: W191 Indentation contains tabs + | +59 | if ((row < 0 or self.moduleCount <= row or +60 | col < 0 or self.moduleCount <= col)): +61 | raise Exception("%s,%s - %s" % (row, col, self.moduleCount)) + | ^^^^ W191 +62 | #: E101 E101 E101 E101 W191 W191 W191 W191 W191 W191 +63 | if bar: + | + +W19.py:64:1: W191 Indentation contains tabs + | +62 | #: E101 E101 E101 E101 W191 W191 W191 W191 W191 W191 +63 | if bar: +64 | return ( + | ^^^^ W191 +65 | start, 'E121 lines starting with a ' +66 | 'closing bracket should be indented ' + | + +W19.py:65:1: W191 Indentation contains tabs + | +63 | if bar: +64 | return ( +65 | start, 'E121 lines starting with a ' + | ^^^^^^^^ W191 +66 | 'closing bracket should be indented ' +67 | "to match that of the opening " + | + +W19.py:66:1: W191 Indentation contains tabs + | +64 | return ( +65 | start, 'E121 lines starting with a ' +66 | 'closing bracket should be indented ' + | ^^^^^^^^ W191 +67 | "to match that of the opening " +68 | "bracket's line" + | + +W19.py:67:1: W191 Indentation contains tabs + | +65 | start, 'E121 lines starting with a ' +66 | 'closing bracket should be indented ' +67 | "to match that of the opening " + | ^^^^^^^^ W191 +68 | "bracket's line" +69 | ) + | + +W19.py:68:1: W191 Indentation contains tabs + | +66 | 'closing bracket should be indented ' +67 | "to match that of the opening " +68 | "bracket's line" + | ^^^^^^^^ W191 +69 | ) +70 | # + | + +W19.py:69:1: W191 Indentation contains tabs + | +67 | "to match that of the opening " +68 | "bracket's line" +69 | ) + | ^^^^ W191 +70 | # +71 | #: E101 W191 W504 + | + +W19.py:76:1: W191 Indentation contains tabs + | +74 | foo.bar("bop") +75 | )): +76 | print "yes" + | ^^^^ W191 +77 | #: E101 W191 W504 +78 | # also ok, but starting to look like LISP + | + +W19.py:81:1: W191 Indentation contains tabs + | +79 | if ((foo.bar("baz") and +80 | foo.bar("bop"))): +81 | print "yes" + | ^^^^ W191 +82 | #: E101 W191 W504 +83 | if (a == 2 or + | + +W19.py:86:1: W191 Indentation contains tabs + | +84 | b == "abc def ghi" +85 | "jkl mno"): +86 | return True + | ^^^^ W191 +87 | #: E101 W191 W504 +88 | if (a == 2 or + | + +W19.py:91:1: W191 Indentation contains tabs + | +89 | b == """abc def ghi +90 | jkl mno"""): +91 | return True + | ^^^^ W191 +92 | #: W191:2:1 W191:3:1 E101:3:2 +93 | if length > options.max_line_length: + | + +W19.py:94:1: W191 Indentation contains tabs + | +92 | #: W191:2:1 W191:3:1 E101:3:2 +93 | if length > options.max_line_length: +94 | return options.max_line_length, \ + | ^^^^ W191 +95 | "E501 line too long (%d characters)" % length + | + +W19.py:95:1: W191 Indentation contains tabs + | +93 | if length > options.max_line_length: +94 | return options.max_line_length, \ +95 | "E501 line too long (%d characters)" % length + | ^^^^^^^^ W191 + | + +W19.py:101:1: W191 Indentation contains tabs + | + 99 | #: E101 W191 W191 W504 +100 | if os.path.exists(os.path.join(path, PEP8_BIN)): +101 | cmd = ([os.path.join(path, PEP8_BIN)] + + | ^^^^ W191 +102 | self._pep8_options(targetfile)) +103 | #: W191 - okay + | + +W19.py:102:1: W191 Indentation contains tabs + | +100 | if os.path.exists(os.path.join(path, PEP8_BIN)): +101 | cmd = ([os.path.join(path, PEP8_BIN)] + +102 | self._pep8_options(targetfile)) + | ^^^^^^^^^^^ W191 +103 | #: W191 - okay +104 | ''' + | + +W19.py:128:1: W191 Indentation contains tabs + | +126 | if foo is None and bar is "bop" and \ +127 | blah == 'yeah': +128 | blah = 'yeahnah' + | ^^^^ W191 + | + +W19.py:134:1: W191 Indentation contains tabs + | +132 | #: W191 W191 W191 +133 | if True: +134 | foo( + | ^^^^ W191 +135 | 1, +136 | 2) + | + +W19.py:135:1: W191 Indentation contains tabs + | +133 | if True: +134 | foo( +135 | 1, + | ^^^^^^^^ W191 +136 | 2) +137 | #: W191 W191 W191 W191 W191 + | + +W19.py:136:1: W191 Indentation contains tabs + | +134 | foo( +135 | 1, +136 | 2) + | ^^^^^^^^ W191 +137 | #: W191 W191 W191 W191 W191 +138 | def test_keys(self): + | + +W19.py:139:1: W191 Indentation contains tabs + | +137 | #: W191 W191 W191 W191 W191 +138 | def test_keys(self): +139 | """areas.json - All regions are accounted for.""" + | ^^^^ W191 +140 | expected = set([ +141 | u'Norrbotten', + | + +W19.py:140:1: W191 Indentation contains tabs + | +138 | def test_keys(self): +139 | """areas.json - All regions are accounted for.""" +140 | expected = set([ + | ^^^^ W191 +141 | u'Norrbotten', +142 | u'V\xe4sterbotten', + | + +W19.py:141:1: W191 Indentation contains tabs + | +139 | """areas.json - All regions are accounted for.""" +140 | expected = set([ +141 | u'Norrbotten', + | ^^^^^^^^ W191 +142 | u'V\xe4sterbotten', +143 | ]) + | + +W19.py:142:1: W191 Indentation contains tabs + | +140 | expected = set([ +141 | u'Norrbotten', +142 | u'V\xe4sterbotten', + | ^^^^^^^^ W191 +143 | ]) +144 | #: W191 + | + +W19.py:143:1: W191 Indentation contains tabs + | +141 | u'Norrbotten', +142 | u'V\xe4sterbotten', +143 | ]) + | ^^^^ W191 +144 | #: W191 +145 | x = [ + | + +W19.py:146:1: W191 Indentation contains tabs + | +144 | #: W191 +145 | x = [ +146 | 'abc' + | ^^^^ W191 +147 | ] +148 | #: W191 - okay + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W29.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W29.py.snap new file mode 100644 index 0000000000..00770929a2 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W291_W29.py.snap @@ -0,0 +1,67 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +W29.py:4:6: W291 [*] Trailing whitespace + | +2 | # 情 +3 | #: W291:1:6 +4 | print + | ^ W291 +5 | #: W293:2:1 +6 | class Foo(object): + | + = help: Remove trailing whitespace + +ℹ Fix +1 1 | #: Okay +2 2 | # 情 +3 3 | #: W291:1:6 +4 |-print + 4 |+print +5 5 | #: W293:2:1 +6 6 | class Foo(object): +7 7 | + +W29.py:11:35: W291 [*] Trailing whitespace + | + 9 | #: W291:2:35 +10 | '''multiline +11 | string with trailing whitespace''' + | ^^^ W291 +12 | #: W291 W292 noeol +13 | x = 1 + | + = help: Remove trailing whitespace + +ℹ Fix +8 8 | bang = 12 +9 9 | #: W291:2:35 +10 10 | '''multiline +11 |-string with trailing whitespace''' + 11 |+string with trailing whitespace''' +12 12 | #: W291 W292 noeol +13 13 | x = 1 +14 14 | #: W191 W292 noeol + +W29.py:13:6: W291 [*] Trailing whitespace + | +11 | string with trailing whitespace''' +12 | #: W291 W292 noeol +13 | x = 1 + | ^^^ W291 +14 | #: W191 W292 noeol +15 | if False: + | + = help: Remove trailing whitespace + +ℹ Fix +10 10 | '''multiline +11 11 | string with trailing whitespace''' +12 12 | #: W291 W292 noeol +13 |-x = 1 + 13 |+x = 1 +14 14 | #: W191 W292 noeol +15 15 | if False: +16 16 | pass # indented with tabs + + 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 new file mode 100644 index 0000000000..2e1466e13a --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_0.py.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +W292_0.py:2:9: W292 [*] No newline at end of file + | +1 | def fn() -> None: +2 | pass + | W292 + | + = help: Add trailing newline + +ℹ Fix +1 1 | def fn() -> None: +2 |- pass + 2 |+ pass + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_1.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_1.py.snap new file mode 100644 index 0000000000..6dcc4546f1 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_1.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_2.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_2.py.snap new file mode 100644 index 0000000000..6dcc4546f1 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_2.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_3.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_3.py.snap new file mode 100644 index 0000000000..6dcc4546f1 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W292_W292_3.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W293_W29.py.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W293_W29.py.snap new file mode 100644 index 0000000000..d13b051aed --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W293_W29.py.snap @@ -0,0 +1,25 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +W29.py:7:1: W293 [*] Blank line contains whitespace + | +5 | #: W293:2:1 +6 | class Foo(object): +7 | + | ^^^^ W293 +8 | bang = 12 +9 | #: W291:2:35 + | + = help: Remove whitespace from blank line + +ℹ Fix +4 4 | print +5 5 | #: W293:2:1 +6 6 | class Foo(object): +7 |- + 7 |+ +8 8 | bang = 12 +9 9 | #: W291:2:35 +10 10 | '''multiline + + 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 new file mode 100644 index 0000000000..c5997156d2 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_0.py.snap @@ -0,0 +1,138 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +W605_0.py:2:10: W605 [*] Invalid escape sequence: `\.` + | +1 | #: W605:1:10 +2 | regex = '\.png$' + | ^^ W605 +3 | +4 | #: W605:2:1 + | + = help: Add backslash to escape sequence + +ℹ Fix +1 1 | #: W605:1:10 +2 |-regex = '\.png$' + 2 |+regex = r'\.png$' +3 3 | +4 4 | #: W605:2:1 +5 5 | regex = ''' + +W605_0.py:6:1: W605 [*] Invalid escape sequence: `\.` + | +4 | #: W605:2:1 +5 | regex = ''' +6 | \.png$ + | ^^ W605 +7 | ''' + | + = help: Add backslash to escape sequence + +ℹ Fix +2 2 | regex = '\.png$' +3 3 | +4 4 | #: W605:2:1 +5 |-regex = ''' + 5 |+regex = r''' +6 6 | \.png$ +7 7 | ''' +8 8 | + +W605_0.py:11:6: W605 [*] Invalid escape sequence: `\_` + | + 9 | #: W605:2:6 +10 | f( +11 | '\_' + | ^^ W605 +12 | ) + | + = help: Add backslash to escape sequence + +ℹ Fix +8 8 | +9 9 | #: W605:2:6 +10 10 | f( +11 |- '\_' + 11 |+ r'\_' +12 12 | ) +13 13 | +14 14 | #: W605:4:6 + +W605_0.py:18:6: W605 [*] Invalid escape sequence: `\_` + | +16 | multi-line +17 | literal +18 | with \_ somewhere + | ^^ W605 +19 | in the middle +20 | """ + | + = help: Add backslash to escape sequence + +ℹ Fix +12 12 | ) +13 13 | +14 14 | #: W605:4:6 +15 |-""" + 15 |+r""" +16 16 | multi-line +17 17 | literal +18 18 | with \_ somewhere + +W605_0.py:23:39: W605 [*] Invalid escape sequence: `\_` + | +22 | #: W605:1:38 +23 | value = 'new line\nand invalid escape \_ here' + | ^^ W605 + | + = help: Add backslash to escape sequence + +ℹ Fix +20 20 | """ +21 21 | +22 22 | #: W605:1:38 +23 |-value = 'new line\nand invalid escape \_ here' + 23 |+value = 'new line\nand invalid escape \\_ here' +24 24 | +25 25 | +26 26 | def f(): + +W605_0.py:28:12: W605 [*] Invalid escape sequence: `\.` + | +26 | def f(): +27 | #: W605:1:11 +28 | return'\.png$' + | ^^ W605 +29 | +30 | #: Okay + | + = help: Add backslash to escape sequence + +ℹ Fix +25 25 | +26 26 | def f(): +27 27 | #: W605:1:11 +28 |- return'\.png$' + 28 |+ return r'\.png$' +29 29 | +30 30 | #: Okay +31 31 | regex = r'\.png$' + +W605_0.py:45:12: W605 [*] Invalid escape sequence: `\_` + | +43 | ''' # noqa +44 | +45 | regex = '\\\_' + | ^^ W605 + | + = help: Add backslash to escape sequence + +ℹ Fix +42 42 | \w +43 43 | ''' # noqa +44 44 | +45 |-regex = '\\\_' + 45 |+regex = '\\\\_' + + 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 new file mode 100644 index 0000000000..5d7cd884cc --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__W605_W605_1.py.snap @@ -0,0 +1,104 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +W605_1.py:2:10: W605 [*] Invalid escape sequence: `\.` + | +1 | #: W605:1:10 +2 | regex = '\.png$' + | ^^ W605 +3 | +4 | #: W605:2:1 + | + = help: Add backslash to escape sequence + +ℹ Fix +1 1 | #: W605:1:10 +2 |-regex = '\.png$' + 2 |+regex = r'\.png$' +3 3 | +4 4 | #: W605:2:1 +5 5 | regex = ''' + +W605_1.py:6:1: W605 [*] Invalid escape sequence: `\.` + | +4 | #: W605:2:1 +5 | regex = ''' +6 | \.png$ + | ^^ W605 +7 | ''' + | + = help: Add backslash to escape sequence + +ℹ Fix +2 2 | regex = '\.png$' +3 3 | +4 4 | #: W605:2:1 +5 |-regex = ''' + 5 |+regex = r''' +6 6 | \.png$ +7 7 | ''' +8 8 | + +W605_1.py:11:6: W605 [*] Invalid escape sequence: `\_` + | + 9 | #: W605:2:6 +10 | f( +11 | '\_' + | ^^ W605 +12 | ) + | + = help: Add backslash to escape sequence + +ℹ Fix +8 8 | +9 9 | #: W605:2:6 +10 10 | f( +11 |- '\_' + 11 |+ r'\_' +12 12 | ) +13 13 | +14 14 | #: W605:4:6 + +W605_1.py:18:6: W605 [*] Invalid escape sequence: `\_` + | +16 | multi-line +17 | literal +18 | with \_ somewhere + | ^^ W605 +19 | in the middle +20 | """ + | + = help: Add backslash to escape sequence + +ℹ Fix +12 12 | ) +13 13 | +14 14 | #: W605:4:6 +15 |-""" + 15 |+r""" +16 16 | multi-line +17 17 | literal +18 18 | with \_ somewhere + +W605_1.py:25:12: W605 [*] Invalid escape sequence: `\.` + | +23 | def f(): +24 | #: W605:1:11 +25 | return'\.png$' + | ^^ W605 +26 | +27 | #: Okay + | + = help: Add backslash to escape sequence + +ℹ Fix +22 22 | +23 23 | def f(): +24 24 | #: W605:1:11 +25 |- return'\.png$' + 25 |+ return r'\.png$' +26 26 | +27 27 | #: Okay +28 28 | regex = r'\.png$' + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__constant_literals.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__constant_literals.snap new file mode 100644 index 0000000000..e8a55ce2fb --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__constant_literals.snap @@ -0,0 +1,191 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +constant_literals.py:4:4: F632 [*] Use `==` to compare constant literals + | +2 | # Errors +3 | ### +4 | if "abc" is "def": # F632 (fix) + | ^^^^^^^^^^^^^^ F632 +5 | pass +6 | if "abc" is None: # F632 (fix, but leaves behind unfixable E711) + | + = help: Replace `is` with `==` + +ℹ Fix +1 1 | ### +2 2 | # Errors +3 3 | ### +4 |-if "abc" is "def": # F632 (fix) + 4 |+if "abc" == "def": # F632 (fix) +5 5 | pass +6 6 | if "abc" is None: # F632 (fix, but leaves behind unfixable E711) +7 7 | pass + +constant_literals.py:6:4: F632 [*] Use `==` to compare constant literals + | +4 | if "abc" is "def": # F632 (fix) +5 | pass +6 | if "abc" is None: # F632 (fix, but leaves behind unfixable E711) + | ^^^^^^^^^^^^^ F632 +7 | pass +8 | if None is "abc": # F632 (fix, but leaves behind unfixable E711) + | + = help: Replace `is` with `==` + +ℹ Fix +3 3 | ### +4 4 | if "abc" is "def": # F632 (fix) +5 5 | pass +6 |-if "abc" is None: # F632 (fix, but leaves behind unfixable E711) + 6 |+if "abc" == None: # F632 (fix, but leaves behind unfixable E711) +7 7 | pass +8 8 | if None is "abc": # F632 (fix, but leaves behind unfixable E711) +9 9 | pass + +constant_literals.py:8:4: F632 [*] Use `==` to compare constant literals + | + 6 | if "abc" is None: # F632 (fix, but leaves behind unfixable E711) + 7 | pass + 8 | if None is "abc": # F632 (fix, but leaves behind unfixable E711) + | ^^^^^^^^^^^^^ F632 + 9 | pass +10 | if "abc" is False: # F632 (fix, but leaves behind unfixable E712) + | + = help: Replace `is` with `==` + +ℹ Fix +5 5 | pass +6 6 | if "abc" is None: # F632 (fix, but leaves behind unfixable E711) +7 7 | pass +8 |-if None is "abc": # F632 (fix, but leaves behind unfixable E711) + 8 |+if None == "abc": # F632 (fix, but leaves behind unfixable E711) +9 9 | pass +10 10 | if "abc" is False: # F632 (fix, but leaves behind unfixable E712) +11 11 | pass + +constant_literals.py:10:4: F632 [*] Use `==` to compare constant literals + | + 8 | if None is "abc": # F632 (fix, but leaves behind unfixable E711) + 9 | pass +10 | if "abc" is False: # F632 (fix, but leaves behind unfixable E712) + | ^^^^^^^^^^^^^^ F632 +11 | pass +12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) + | + = help: Replace `is` with `==` + +ℹ Fix +7 7 | pass +8 8 | if None is "abc": # F632 (fix, but leaves behind unfixable E711) +9 9 | pass +10 |-if "abc" is False: # F632 (fix, but leaves behind unfixable E712) + 10 |+if "abc" == False: # F632 (fix, but leaves behind unfixable E712) +11 11 | pass +12 12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) +13 13 | pass + +constant_literals.py:12:4: F632 [*] Use `==` to compare constant literals + | +10 | if "abc" is False: # F632 (fix, but leaves behind unfixable E712) +11 | pass +12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) + | ^^^^^^^^^^^^^^ F632 +13 | pass +14 | if False == None: # E711, E712 (fix) + | + = help: Replace `is` with `==` + +ℹ Fix +9 9 | pass +10 10 | if "abc" is False: # F632 (fix, but leaves behind unfixable E712) +11 11 | pass +12 |-if False is "abc": # F632 (fix, but leaves behind unfixable E712) + 12 |+if False == "abc": # F632 (fix, but leaves behind unfixable E712) +13 13 | pass +14 14 | if False == None: # E711, E712 (fix) +15 15 | pass + +constant_literals.py:14:4: E712 [*] Comparison to `False` should be `cond is False` or `if not cond:` + | +12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) +13 | pass +14 | if False == None: # E711, E712 (fix) + | ^^^^^ E712 +15 | pass +16 | if None == False: # E711, E712 (fix) + | + = help: Replace with `cond is False` + +ℹ Suggested fix +11 11 | pass +12 12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) +13 13 | pass +14 |-if False == None: # E711, E712 (fix) + 14 |+if False is None: # E711, E712 (fix) +15 15 | pass +16 16 | if None == False: # E711, E712 (fix) +17 17 | pass + +constant_literals.py:14:13: E711 [*] Comparison to `None` should be `cond is None` + | +12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) +13 | pass +14 | if False == None: # E711, E712 (fix) + | ^^^^ E711 +15 | pass +16 | if None == False: # E711, E712 (fix) + | + = help: Replace with `cond is None` + +ℹ Suggested fix +11 11 | pass +12 12 | if False is "abc": # F632 (fix, but leaves behind unfixable E712) +13 13 | pass +14 |-if False == None: # E711, E712 (fix) + 14 |+if False is None: # E711, E712 (fix) +15 15 | pass +16 16 | if None == False: # E711, E712 (fix) +17 17 | pass + +constant_literals.py:16:4: E711 [*] Comparison to `None` should be `cond is None` + | +14 | if False == None: # E711, E712 (fix) +15 | pass +16 | if None == False: # E711, E712 (fix) + | ^^^^ E711 +17 | pass + | + = help: Replace with `cond is None` + +ℹ Suggested fix +13 13 | pass +14 14 | if False == None: # E711, E712 (fix) +15 15 | pass +16 |-if None == False: # E711, E712 (fix) + 16 |+if None is False: # E711, E712 (fix) +17 17 | pass +18 18 | +19 19 | ### + +constant_literals.py:16:12: E712 [*] Comparison to `False` should be `cond is False` or `if not cond:` + | +14 | if False == None: # E711, E712 (fix) +15 | pass +16 | if None == False: # E711, E712 (fix) + | ^^^^^ E712 +17 | pass + | + = help: Replace with `cond is False` + +ℹ Suggested fix +13 13 | pass +14 14 | if False == None: # E711, E712 (fix) +15 15 | pass +16 |-if None == False: # E711, E712 (fix) + 16 |+if None is False: # E711, E712 (fix) +17 17 | pass +18 18 | +19 19 | ### + + 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 new file mode 100644 index 0000000000..18e19e53e2 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length.snap @@ -0,0 +1,62 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +W505.py:2:51: W505 Doc line too long (57 > 50 characters) + | +1 | #!/usr/bin/env python3 +2 | """Here's a top-level docstring that's over the limit.""" + | ^^^^^^^ W505 + | + +W505.py:6:51: W505 Doc line too long (56 > 50 characters) + | +5 | def f1(): +6 | """Here's a docstring that's also over the limit.""" + | ^^^^^^ W505 +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 characters) + | + 8 | x = 1 # Here's a comment that's over the limit, but it's not standalone. + 9 | +10 | # Here's a standalone comment that's over the limit. + | ^^^^^^ W505 +11 | +12 | x = 2 + | + +W505.py:13:51: W505 Doc line too long (93 > 50 characters) + | +12 | x = 2 +13 | # Another standalone that is preceded by a newline and indent toke and is over the limit. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 +14 | +15 | print("Here's a string that's over the limit, but it's not a docstring.") + | + +W505.py:18:51: W505 Doc line too long (61 > 50 characters) + | +18 | "This is also considered a docstring, and is over the limit." + | ^^^^^^^^^^^ W505 + | + +W505.py:24:51: W505 Doc line too long (82 > 50 characters) + | +22 | """Here's a multi-line docstring. +23 | +24 | It's over the limit on this line, which isn't the first line in the docstring. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 +25 | """ + | + +W505.py:31:51: W505 Doc line too long (85 > 50 characters) + | +29 | """Here's a multi-line docstring. +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 new file mode 100644 index 0000000000..42bcfd88d7 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__max_doc_length_with_utf_8.snap @@ -0,0 +1,62 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +W505_utf_8.py:2:50: W505 Doc line too long (57 > 50 characters) + | +1 | #!/usr/bin/env python3 +2 | """Here's a top-level ß9💣2ℝing that's over theß9💣2ℝ.""" + | ^^^^^^ W505 + | + +W505_utf_8.py:6:49: W505 Doc line too long (56 > 50 characters) + | +5 | def f1(): +6 | """Here's a ß9💣2ℝing that's also over theß9💣2ℝ.""" + | ^^^^^^ W505 +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 characters) + | + 8 | x = 1 # Here's a comment that's over theß9💣2ℝ, but it's not standalone. + 9 | +10 | # Here's a standalone comment that's over theß9💣2ℝ. + | ^^^^^^ W505 +11 | +12 | x = 2 + | + +W505_utf_8.py:13:51: W505 Doc line too long (93 > 50 characters) + | +12 | x = 2 +13 | # Another standalone that is preceded by a newline and indent toke and is over theß9💣2ℝ. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 +14 | +15 | print("Here's a string that's over theß9💣2ℝ, but it's not a ß9💣2ℝing.") + | + +W505_utf_8.py:18:50: W505 Doc line too long (61 > 50 characters) + | +18 | "This is also considered a ß9💣2ℝing, and is over theß9💣2ℝ." + | ^^^^^^^^^^^ W505 + | + +W505_utf_8.py:24:50: W505 Doc line too long (82 > 50 characters) + | +22 | """Here's a multi-line ß9💣2ℝing. +23 | +24 | It's over theß9💣2ℝ on this line, which isn't the first line in the ß9💣2ℝing. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ W505 +25 | """ + | + +W505_utf_8.py:31:50: W505 Doc line too long (85 > 50 characters) + | +29 | """Here's a multi-line ß9💣2ℝing. +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__shebang.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__shebang.snap new file mode 100644 index 0000000000..63d5b9fefc --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__shebang.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +shebang.py:3:1: E265 Block comment should start with `# ` + | +1 | #!/usr/bin/python +2 | # +3 | #! + | ^^ E265 +4 | #: + | + + 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 new file mode 100644 index 0000000000..414ff81309 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_1.snap @@ -0,0 +1,51 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E501_2.py:2:7: E501 Line too long (7 > 6 characters) + | +1 | # aaaa +2 | # aaaaa + | ^ E501 +3 | # a +4 | # a + | + +E501_2.py:3:7: E501 Line too long (7 > 6 characters) + | +1 | # aaaa +2 | # aaaaa +3 | # a + | ^ E501 +4 | # a +5 | # aa + | + +E501_2.py:7:7: E501 Line too long (7 > 6 characters) + | +5 | # aa +6 | # aaa +7 | # aaaa + | ^ E501 +8 | # a +9 | # aa + | + +E501_2.py:10:7: E501 Line too long (7 > 6 characters) + | + 8 | # a + 9 | # aa +10 | # aaa + | ^ E501 +11 | +12 | if True: # noqa: E501 + | + +E501_2.py:16:7: E501 Line too long (7 > 6 characters) + | +14 | [12 ] +15 | [1,2] +16 | [1, 2] + | ^ 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 new file mode 100644 index 0000000000..34f004a606 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_2.snap @@ -0,0 +1,90 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E501_2.py:2:7: E501 Line too long (7 > 6 characters) + | +1 | # aaaa +2 | # aaaaa + | ^ E501 +3 | # a +4 | # a + | + +E501_2.py:3:7: E501 Line too long (7 > 6 characters) + | +1 | # aaaa +2 | # aaaaa +3 | # a + | ^ E501 +4 | # a +5 | # aa + | + +E501_2.py:6:6: E501 Line too long (7 > 6 characters) + | +4 | # a +5 | # aa +6 | # aaa + | ^ E501 +7 | # aaaa +8 | # a + | + +E501_2.py:7:6: E501 Line too long (8 > 6 characters) + | +5 | # aa +6 | # aaa +7 | # aaaa + | ^^ E501 +8 | # a +9 | # aa + | + +E501_2.py:8:5: E501 Line too long (7 > 6 characters) + | + 6 | # aaa + 7 | # aaaa + 8 | # a + | ^ E501 + 9 | # aa +10 | # aaa + | + +E501_2.py:9:5: E501 Line too long (8 > 6 characters) + | + 7 | # aaaa + 8 | # a + 9 | # aa + | ^^ E501 +10 | # aaa + | + +E501_2.py:10:5: E501 Line too long (9 > 6 characters) + | + 8 | # a + 9 | # aa +10 | # aaa + | ^^^ E501 +11 | +12 | if True: # noqa: E501 + | + +E501_2.py:14:6: E501 Line too long (7 > 6 characters) + | +12 | if True: # noqa: E501 +13 | [12] +14 | [12 ] + | ^ E501 +15 | [1,2] +16 | [1, 2] + | + +E501_2.py:16:6: E501 Line too long (8 > 6 characters) + | +14 | [12 ] +15 | [1,2] +16 | [1, 2] + | ^^ 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 new file mode 100644 index 0000000000..b9717b2f59 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_4.snap @@ -0,0 +1,110 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E501_2.py:2:7: E501 Line too long (7 > 6 characters) + | +1 | # aaaa +2 | # aaaaa + | ^ E501 +3 | # a +4 | # a + | + +E501_2.py:3:7: E501 Line too long (7 > 6 characters) + | +1 | # aaaa +2 | # aaaaa +3 | # a + | ^ E501 +4 | # a +5 | # aa + | + +E501_2.py:4:4: E501 Line too long (7 > 6 characters) + | +2 | # aaaaa +3 | # a +4 | # a + | ^ E501 +5 | # aa +6 | # aaa + | + +E501_2.py:5:4: E501 Line too long (8 > 6 characters) + | +3 | # a +4 | # a +5 | # aa + | ^^ E501 +6 | # aaa +7 | # aaaa + | + +E501_2.py:6:4: E501 Line too long (9 > 6 characters) + | +4 | # a +5 | # aa +6 | # aaa + | ^^^ E501 +7 | # aaaa +8 | # a + | + +E501_2.py:7:4: E501 Line too long (10 > 6 characters) + | +5 | # aa +6 | # aaa +7 | # aaaa + | ^^^^ E501 +8 | # a +9 | # aa + | + +E501_2.py:8:3: E501 Line too long (11 > 6 characters) + | + 6 | # aaa + 7 | # aaaa + 8 | # a + | ^^^ E501 + 9 | # aa +10 | # aaa + | + +E501_2.py:9:3: E501 Line too long (12 > 6 characters) + | + 7 | # aaaa + 8 | # a + 9 | # aa + | ^^^^ E501 +10 | # aaa + | + +E501_2.py:10:3: E501 Line too long (13 > 6 characters) + | + 8 | # a + 9 | # aa +10 | # aaa + | ^^^^^ E501 +11 | +12 | if True: # noqa: E501 + | + +E501_2.py:14:4: E501 Line too long (9 > 6 characters) + | +12 | if True: # noqa: E501 +13 | [12] +14 | [12 ] + | ^^^ E501 +15 | [1,2] +16 | [1, 2] + | + +E501_2.py:16:4: E501 Line too long (10 > 6 characters) + | +14 | [12 ] +15 | [1,2] +16 | [1, 2] + | ^^^^ 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 new file mode 100644 index 0000000000..9adffbfb99 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__tab_size_8.snap @@ -0,0 +1,110 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E501_2.py:2:7: E501 Line too long (7 > 6 characters) + | +1 | # aaaa +2 | # aaaaa + | ^ E501 +3 | # a +4 | # a + | + +E501_2.py:3:7: E501 Line too long (7 > 6 characters) + | +1 | # aaaa +2 | # aaaaa +3 | # a + | ^ E501 +4 | # a +5 | # aa + | + +E501_2.py:4:2: E501 Line too long (11 > 6 characters) + | +2 | # aaaaa +3 | # a +4 | # a + | ^^^ E501 +5 | # aa +6 | # aaa + | + +E501_2.py:5:2: E501 Line too long (12 > 6 characters) + | +3 | # a +4 | # a +5 | # aa + | ^^^^ E501 +6 | # aaa +7 | # aaaa + | + +E501_2.py:6:2: E501 Line too long (13 > 6 characters) + | +4 | # a +5 | # aa +6 | # aaa + | ^^^^^ E501 +7 | # aaaa +8 | # a + | + +E501_2.py:7:2: E501 Line too long (14 > 6 characters) + | +5 | # aa +6 | # aaa +7 | # aaaa + | ^^^^^^ E501 +8 | # a +9 | # aa + | + +E501_2.py:8:2: E501 Line too long (19 > 6 characters) + | + 6 | # aaa + 7 | # aaaa + 8 | # a + | ^^^^^^^ E501 + 9 | # aa +10 | # aaa + | + +E501_2.py:9:2: E501 Line too long (20 > 6 characters) + | + 7 | # aaaa + 8 | # a + 9 | # aa + | ^^^^^^^^ E501 +10 | # aaa + | + +E501_2.py:10:2: E501 Line too long (21 > 6 characters) + | + 8 | # a + 9 | # aa +10 | # aaa + | ^^^^^^^^^ E501 +11 | +12 | if True: # noqa: E501 + | + +E501_2.py:14:2: E501 Line too long (13 > 6 characters) + | +12 | if True: # noqa: E501 +13 | [12] +14 | [12 ] + | ^^^^^ E501 +15 | [1,2] +16 | [1, 2] + | + +E501_2.py:16:2: E501 Line too long (14 > 6 characters) + | +14 | [12 ] +15 | [1,2] +16 | [1, 2] + | ^^^^^^ E501 + | + + 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 new file mode 100644 index 0000000000..0075115ad1 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__task_tags_false.snap @@ -0,0 +1,58 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +E501_1.py:1:89: E501 Line too long (149 > 88 characters) + | +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 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_1.py:2:89: E501 Line too long (148 > 88 characters) + | +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 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 | # 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_1.py:3:89: E501 Line too long (155 > 88 characters) + | +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 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 | # 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` +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_1.py:4:89: E501 Line too long (150 > 88 characters) + | +2 | # 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` +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 | # 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 +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_1.py:5:89: E501 Line too long (149 > 88 characters) + | +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 | # 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` +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` + | + +E501_1.py:6:89: E501 Line too long (156 > 88 characters) + | +4 | # 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` +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 + | + + diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__task_tags_true.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__task_tags_true.snap new file mode 100644 index 0000000000..6dcc4546f1 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__task_tags_true.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- + 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 new file mode 100644 index 0000000000..d9e030bca0 --- /dev/null +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__w292_4.snap @@ -0,0 +1,15 @@ +--- +source: crates/ruff_linter/src/rules/pycodestyle/mod.rs +--- +W292_4.py:1:2: W292 [*] No newline at end of file + | +1 | + | W292 + | + = help: Add trailing newline + +ℹ Fix +1 |- + 1 |+ + + diff --git a/crates/ruff/src/rules/pydocstyle/helpers.rs b/crates/ruff_linter/src/rules/pydocstyle/helpers.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/helpers.rs rename to crates/ruff_linter/src/rules/pydocstyle/helpers.rs diff --git a/crates/ruff/src/rules/pydocstyle/mod.rs b/crates/ruff_linter/src/rules/pydocstyle/mod.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/mod.rs rename to crates/ruff_linter/src/rules/pydocstyle/mod.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/backslashes.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/backslashes.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/backslashes.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/backslashes.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/blank_after_summary.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/blank_after_summary.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/blank_after_summary.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/blank_after_summary.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/blank_before_after_class.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/blank_before_after_class.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_function.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/blank_before_after_function.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/blank_before_after_function.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/blank_before_after_function.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/capitalized.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/capitalized.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/capitalized.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/capitalized.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/ends_with_period.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_period.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/ends_with_period.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_period.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/ends_with_punctuation.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_punctuation.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/ends_with_punctuation.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_punctuation.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/if_needed.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/if_needed.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/if_needed.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/if_needed.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/indent.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/indent.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/indent.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/indent.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/mod.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/mod.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/mod.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/multi_line_summary_start.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/multi_line_summary_start.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/multi_line_summary_start.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/multi_line_summary_start.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/newline_after_last_paragraph.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/newline_after_last_paragraph.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/newline_after_last_paragraph.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/newline_after_last_paragraph.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/no_signature.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/no_signature.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/no_signature.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/no_signature.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/no_surrounding_whitespace.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/no_surrounding_whitespace.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/no_surrounding_whitespace.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/no_surrounding_whitespace.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/non_imperative_mood.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/non_imperative_mood.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/non_imperative_mood.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/non_imperative_mood.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/not_empty.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/not_empty.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/not_empty.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/not_empty.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/not_missing.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/not_missing.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/not_missing.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/not_missing.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/one_liner.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/one_liner.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/one_liner.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/one_liner.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/sections.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/sections.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/starts_with_this.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/starts_with_this.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/starts_with_this.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/starts_with_this.rs diff --git a/crates/ruff/src/rules/pydocstyle/rules/triple_quotes.rs b/crates/ruff_linter/src/rules/pydocstyle/rules/triple_quotes.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/rules/triple_quotes.rs rename to crates/ruff_linter/src/rules/pydocstyle/rules/triple_quotes.rs diff --git a/crates/ruff/src/rules/pydocstyle/settings.rs b/crates/ruff_linter/src/rules/pydocstyle/settings.rs similarity index 100% rename from crates/ruff/src/rules/pydocstyle/settings.rs rename to crates/ruff_linter/src/rules/pydocstyle/settings.rs diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100_D.py.snap new file mode 100644 index 0000000000..2a12cdc327 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100_D.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:1:1: D100 Missing docstring in public module + | +1 | # No docstring, so we can test D100 + | D100 +2 | from functools import wraps +3 | import os + | + + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100__unrelated___no_pkg_priv.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100__unrelated___no_pkg_priv.py.snap new file mode 100644 index 0000000000..724d6e7d20 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100__unrelated___no_pkg_priv.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100__unrelated__pkg__D100_pub.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100__unrelated__pkg__D100_pub.py.snap new file mode 100644 index 0000000000..6ed4a35eac --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100__unrelated__pkg__D100_pub.py.snap @@ -0,0 +1,8 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D100_pub.py:1:1: D100 Missing docstring in public module + | + | + + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100__unrelated__pkg___priv__no_D100_priv.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100__unrelated__pkg___priv__no_D100_priv.py.snap new file mode 100644 index 0000000000..724d6e7d20 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D100__unrelated__pkg___priv__no_D100_priv.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- + 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 new file mode 100644 index 0000000000..dcfc126666 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D101_D.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:15:7: D101 Missing docstring in public class + | +15 | class class_: + | ^^^^^^ D101 +16 | +17 | expect('meta', 'D419: Docstring is empty') + | + + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D102_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D102_D.py.snap new file mode 100644 index 0000000000..541ef0be67 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D102_D.py.snap @@ -0,0 +1,46 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:23:9: D102 Missing docstring in public method + | +22 | @expect('D102: Missing docstring in public method') +23 | def method(self=None): + | ^^^^^^ D102 +24 | pass + | + +D.py:56:9: D102 Missing docstring in public method + | +55 | @expect('D102: Missing docstring in public method') +56 | def __new__(self=None): + | ^^^^^^^ D102 +57 | pass + | + +D.py:68:9: D102 Missing docstring in public method + | +67 | @expect('D102: Missing docstring in public method') +68 | def __call__(self=None, x=None, y=None, z=None): + | ^^^^^^^^ D102 +69 | pass + | + +D.py:650:9: D102 Missing docstring in public method + | +648 | class StatementOnSameLineAsDocstring: +649 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 +650 | def sort_services(self): + | ^^^^^^^^^^^^^ D102 +651 | pass + | + +D.py:659:9: D102 Missing docstring in public method + | +657 | class CommentAfterDocstring: +658 | "After this docstring there's a comment." # priorities=1 +659 | def sort_services(self): + | ^^^^^^^^^^^^^ D102 +660 | pass + | + + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D102_setter.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D102_setter.py.snap new file mode 100644 index 0000000000..522d7c43ee --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D102_setter.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +setter.py:16:9: D102 Missing docstring in public method + | +15 | @foo +16 | def foo(self, value: str) -> None: + | ^^^ D102 +17 | pass + | + + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D103_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D103_D.py.snap new file mode 100644 index 0000000000..28944e8e09 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D103_D.py.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:400:5: D103 Missing docstring in public function + | +399 | @expect("D103: Missing docstring in public function") +400 | def oneliner_d102(): return + | ^^^^^^^^^^^^^ D103 + | + + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D104_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D104_D.py.snap new file mode 100644 index 0000000000..724d6e7d20 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D104_D.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D104_D104____init__.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D104_D104____init__.py.snap new file mode 100644 index 0000000000..963470d033 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D104_D104____init__.py.snap @@ -0,0 +1,8 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +__init__.py:1:1: D104 Missing docstring in public package + | + | + + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D105_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D105_D.py.snap new file mode 100644 index 0000000000..bc2595c1be --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D105_D.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:64:9: D105 Missing docstring in magic method + | +63 | @expect('D105: Missing docstring in magic method') +64 | def __str__(self=None): + | ^^^^^^^ D105 +65 | pass + | + + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D106_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D106_D.py.snap new file mode 100644 index 0000000000..724d6e7d20 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D106_D.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- + 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 new file mode 100644 index 0000000000..f1e639bedd --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D107_D.py.snap @@ -0,0 +1,21 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:60:9: D107 Missing docstring in `__init__` + | +59 | @expect('D107: Missing docstring in __init__') +60 | def __init__(self=None): + | ^^^^^^^^ D107 +61 | pass + | + +D.py:534:9: D107 Missing docstring in `__init__` + | +532 | """ +533 | +534 | def __init__(self, x): + | ^^^^^^^^ D107 +535 | pass + | + + 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 new file mode 100644 index 0000000000..2e9ab57a98 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D.py.snap @@ -0,0 +1,112 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +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 | """ + | _____^ +130 | | Wrong. +131 | | """ + | |_______^ D200 + | + = help: Reformat to one line + +ℹ Suggested fix +126 126 | '(found 3)') +127 127 | @expect('D212: Multi-line docstring summary should start at the first line') +128 128 | def asdlkfasd(): +129 |- """ +130 |- Wrong. +131 |- """ + 129 |+ """Wrong.""" +132 130 | +133 131 | +134 132 | @expect('D201: No blank lines allowed before function docstring (found 1)') + +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 | | +599 | | Wrong.""" + | |_____________^ D200 + | + = help: Reformat to one line + +ℹ Suggested fix +594 594 | '(found 3)') +595 595 | @expect('D212: Multi-line docstring summary should start at the first line') +596 596 | def one_liner(): +597 |- """ +598 |- +599 |- Wrong.""" + 597 |+ """Wrong.""" +600 598 | +601 599 | +602 600 | @expect('D200: One-line docstring should fit on one line with quotes ' + +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 | | +608 | | """ + | |_______^ D200 + | + = help: Reformat to one line + +ℹ Suggested fix +603 603 | '(found 3)') +604 604 | @expect('D212: Multi-line docstring summary should start at the first line') +605 605 | def one_liner(): +606 |- r"""Wrong. +607 |- +608 |- """ + 606 |+ r"""Wrong.""" +609 607 | +610 608 | +611 609 | @expect('D200: One-line docstring should fit on one line with quotes ' + +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 | | +617 | | """ + | |_______^ D200 + | + = help: Reformat to one line + +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 | | +626 | | "Wrong.""" + | |______________^ D200 + | + = help: Reformat to 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 | "\ + | _____^ +646 | | " + | |_____^ D200 +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 new file mode 100644 index 0000000000..d4f68ce602 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D200_D200.py.snap @@ -0,0 +1,45 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D200.py:2:5: D200 One-line docstring should fit on one line + | +1 | def func(): +2 | """\ + | _____^ +3 | | """ + | |_______^ D200 + | + = help: Reformat to one line + +D200.py:7:5: D200 [*] One-line docstring should fit on one line + | +6 | def func(): +7 | """\\ + | _____^ +8 | | """ + | |_______^ D200 + | + = help: Reformat to one line + +ℹ Suggested fix +4 4 | +5 5 | +6 6 | def func(): +7 |- """\\ +8 |- """ + 7 |+ """\\""" +9 8 | +10 9 | +11 10 | def func(): + +D200.py:12:5: D200 One-line docstring should fit on one line + | +11 | def func(): +12 | """\ \ + | _____^ +13 | | """ + | |_______^ D200 + | + = help: Reformat to one line + + 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 new file mode 100644 index 0000000000..b666e6fa3a --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D201_D.py.snap @@ -0,0 +1,88 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:137:5: D201 [*] No blank lines allowed before function docstring (found 1) + | +135 | def leading_space(): +136 | +137 | """Leading space.""" + | ^^^^^^^^^^^^^^^^^^^^ D201 + | + = help: Remove blank line(s) before function docstring + +ℹ Fix +133 133 | +134 134 | @expect('D201: No blank lines allowed before function docstring (found 1)') +135 135 | def leading_space(): +136 |- +137 136 | """Leading space.""" +138 137 | +139 138 | + +D.py:151:5: D201 [*] No blank lines allowed before function docstring (found 1) + | +149 | def trailing_and_leading_space(): +150 | +151 | """Trailing and leading space.""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D201 +152 | +153 | pass + | + = help: Remove blank line(s) before function docstring + +ℹ Fix +147 147 | @expect('D201: No blank lines allowed before function docstring (found 1)') +148 148 | @expect('D202: No blank lines allowed after function docstring (found 1)') +149 149 | def trailing_and_leading_space(): +150 |- +151 150 | """Trailing and leading space.""" +152 151 | +153 152 | pass + +D.py:546:5: D201 [*] No blank lines allowed before function docstring (found 1) + | +544 | def multiline_leading_space(): +545 | +546 | """Leading space. + | _____^ +547 | | +548 | | More content. +549 | | """ + | |_______^ D201 + | + = help: Remove blank line(s) before function docstring + +ℹ Fix +542 542 | @expect('D201: No blank lines allowed before function docstring (found 1)') +543 543 | @expect('D213: Multi-line docstring summary should start at the second line') +544 544 | def multiline_leading_space(): +545 |- +546 545 | """Leading space. +547 546 | +548 547 | More content. + +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 | | +570 | | More content. +571 | | """ + | |_______^ D201 +572 | +573 | pass + | + = help: Remove blank line(s) before function docstring + +ℹ Fix +564 564 | @expect('D202: No blank lines allowed after function docstring (found 1)') +565 565 | @expect('D213: Multi-line docstring summary should start at the second line') +566 566 | def multiline_trailing_and_leading_space(): +567 |- +568 567 | """Trailing and leading space. +569 568 | +570 569 | More content. + + 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 new file mode 100644 index 0000000000..7fbb6cc885 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D.py.snap @@ -0,0 +1,92 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:142:5: D202 [*] No blank lines allowed after function docstring (found 1) + | +140 | @expect('D202: No blank lines allowed after function docstring (found 1)') +141 | def trailing_space(): +142 | """Leading space.""" + | ^^^^^^^^^^^^^^^^^^^^ D202 +143 | +144 | pass + | + = help: Remove blank line(s) after function docstring + +ℹ Fix +140 140 | @expect('D202: No blank lines allowed after function docstring (found 1)') +141 141 | def trailing_space(): +142 142 | """Leading space.""" +143 |- +144 143 | pass +145 144 | +146 145 | + +D.py:151:5: D202 [*] No blank lines allowed after function docstring (found 1) + | +149 | def trailing_and_leading_space(): +150 | +151 | """Trailing and leading space.""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D202 +152 | +153 | pass + | + = help: Remove blank line(s) after function docstring + +ℹ Fix +149 149 | def trailing_and_leading_space(): +150 150 | +151 151 | """Trailing and leading space.""" +152 |- +153 152 | pass +154 153 | +155 154 | + +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 | | +557 | | More content. +558 | | """ + | |_______^ D202 +559 | +560 | pass + | + = help: Remove blank line(s) after function docstring + +ℹ Fix +556 556 | +557 557 | More content. +558 558 | """ +559 |- +560 559 | pass +561 560 | +562 561 | + +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 | | +570 | | More content. +571 | | """ + | |_______^ D202 +572 | +573 | pass + | + = help: Remove blank line(s) after function docstring + +ℹ Fix +569 569 | +570 570 | More content. +571 571 | """ +572 |- +573 572 | pass +574 573 | +575 574 | + + 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 new file mode 100644 index 0000000000..2a17a65416 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D202_D202.py.snap @@ -0,0 +1,62 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D202.py:57:5: D202 [*] No blank lines allowed after function docstring (found 2) + | +55 | # D202 +56 | def outer(): +57 | """This is a docstring.""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ D202 + | + = help: Remove blank line(s) after function docstring + +ℹ Fix +55 55 | # D202 +56 56 | def outer(): +57 57 | """This is a docstring.""" +58 |- +59 |- +60 58 | def inner(): +61 59 | return +62 60 | + +D202.py:68:5: D202 [*] No blank lines allowed after function docstring (found 2) + | +66 | # D202 +67 | def outer(): +68 | """This is a docstring.""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ D202 + | + = help: Remove blank line(s) after function docstring + +ℹ Fix +66 66 | # D202 +67 67 | def outer(): +68 68 | """This is a docstring.""" +69 |- +70 |- +71 69 | # This is a comment. +72 70 | def inner(): +73 71 | return + +D202.py:80:5: D202 [*] No blank lines allowed after function docstring (found 1) + | +78 | # D202 +79 | def outer(): +80 | """This is a docstring.""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ D202 +81 | +82 | # This is a comment. + | + = help: Remove blank line(s) after function docstring + +ℹ Fix +78 78 | # D202 +79 79 | def outer(): +80 80 | """This is a docstring.""" +81 |- +82 81 | # This is a comment. +83 82 | +84 83 | def inner(): + + 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 new file mode 100644 index 0000000000..fe427f7d6c --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D203_D.py.snap @@ -0,0 +1,121 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:161:5: D203 [*] 1 blank line required before class docstring + | +160 | class LeadingSpaceMissing: +161 | """Leading space missing.""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D203 + | + = help: Insert 1 blank line before class docstring + +ℹ Fix +158 158 | +159 159 | +160 160 | class LeadingSpaceMissing: + 161 |+ +161 162 | """Leading space missing.""" +162 163 | +163 164 | + +D.py:192:5: D203 [*] 1 blank line required before class docstring + | +191 | class LeadingAndTrailingSpaceMissing: +192 | """Leading and trailing space missing.""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D203 +193 | pass + | + = help: Insert 1 blank line before class docstring + +ℹ Fix +189 189 | +190 190 | +191 191 | class LeadingAndTrailingSpaceMissing: + 192 |+ +192 193 | """Leading and trailing space missing.""" +193 194 | pass +194 195 | + +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 | | +528 | | Parameters +529 | | ---------- +530 | | x : int +531 | | +532 | | """ + | |_______^ D203 +533 | +534 | def __init__(self, x): + | + = help: Insert 1 blank line before class docstring + +ℹ Fix +523 523 | # This is reproducing a bug where AttributeError is raised when parsing class +524 524 | # parameters as functions for Google / Numpy conventions. +525 525 | class Blah: # noqa: D203,D213 + 526 |+ +526 527 | """A Blah. +527 528 | +528 529 | Parameters + +D.py:649:5: D203 [*] 1 blank line required before class docstring + | +648 | class StatementOnSameLineAsDocstring: +649 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D203 +650 | def sort_services(self): +651 | pass + | + = help: Insert 1 blank line before class docstring + +ℹ Fix +646 646 | " +647 647 | +648 648 | class StatementOnSameLineAsDocstring: + 649 |+ +649 650 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 +650 651 | def sort_services(self): +651 652 | pass + +D.py:654:5: D203 [*] 1 blank line required before class docstring + | +653 | class StatementOnSameLineAsDocstring: +654 | "After this docstring there's another statement on the same line separated by a semicolon."; priorities=1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D203 + | + = help: Insert 1 blank line before class docstring + +ℹ Fix +651 651 | pass +652 652 | +653 653 | class StatementOnSameLineAsDocstring: + 654 |+ +654 655 | "After this docstring there's another statement on the same line separated by a semicolon."; priorities=1 +655 656 | +656 657 | + +D.py:658:5: D203 [*] 1 blank line required before class docstring + | +657 | class CommentAfterDocstring: +658 | "After this docstring there's a comment." # priorities=1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D203 +659 | def sort_services(self): +660 | pass + | + = help: Insert 1 blank line before class docstring + +ℹ Fix +655 655 | +656 656 | +657 657 | class CommentAfterDocstring: + 658 |+ +658 659 | "After this docstring there's a comment." # priorities=1 +659 660 | def sort_services(self): +660 661 | pass + + 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 new file mode 100644 index 0000000000..f9a9ef76f8 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D204_D.py.snap @@ -0,0 +1,102 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:181:5: D204 [*] 1 blank line required after class docstring + | +179 | class TrailingSpace: +180 | +181 | """TrailingSpace.""" + | ^^^^^^^^^^^^^^^^^^^^ D204 +182 | pass + | + = help: Insert 1 blank line after class docstring + +ℹ Fix +179 179 | class TrailingSpace: +180 180 | +181 181 | """TrailingSpace.""" + 182 |+ +182 183 | pass +183 184 | +184 185 | + +D.py:192:5: D204 [*] 1 blank line required after class docstring + | +191 | class LeadingAndTrailingSpaceMissing: +192 | """Leading and trailing space missing.""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D204 +193 | pass + | + = help: Insert 1 blank line after class docstring + +ℹ Fix +190 190 | +191 191 | class LeadingAndTrailingSpaceMissing: +192 192 | """Leading and trailing space missing.""" + 193 |+ +193 194 | pass +194 195 | +195 196 | + +D.py:649:5: D204 [*] 1 blank line required after class docstring + | +648 | class StatementOnSameLineAsDocstring: +649 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D204 +650 | def sort_services(self): +651 | pass + | + = help: Insert 1 blank line after class docstring + +ℹ Fix +646 646 | " +647 647 | +648 648 | class StatementOnSameLineAsDocstring: +649 |- "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 + 649 |+ "After this docstring there's another statement on the same line separated by a semicolon." + 650 |+ + 651 |+ priorities=1 +650 652 | def sort_services(self): +651 653 | pass +652 654 | + +D.py:654:5: D204 [*] 1 blank line required after class docstring + | +653 | class StatementOnSameLineAsDocstring: +654 | "After this docstring there's another statement on the same line separated by a semicolon."; priorities=1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D204 + | + = help: Insert 1 blank line after class docstring + +ℹ Fix +651 651 | pass +652 652 | +653 653 | class StatementOnSameLineAsDocstring: +654 |- "After this docstring there's another statement on the same line separated by a semicolon."; priorities=1 + 654 |+ "After this docstring there's another statement on the same line separated by a semicolon." + 655 |+ + 656 |+ priorities=1 +655 657 | +656 658 | +657 659 | class CommentAfterDocstring: + +D.py:658:5: D204 [*] 1 blank line required after class docstring + | +657 | class CommentAfterDocstring: +658 | "After this docstring there's a comment." # priorities=1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D204 +659 | def sort_services(self): +660 | pass + | + = help: Insert 1 blank line after class docstring + +ℹ Fix +656 656 | +657 657 | class CommentAfterDocstring: +658 658 | "After this docstring there's a comment." # priorities=1 + 659 |+ +659 660 | def sort_services(self): +660 661 | pass +661 662 | + + 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 new file mode 100644 index 0000000000..39f339c83f --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D205_D.py.snap @@ -0,0 +1,41 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +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. + | _____^ +201 | | Description. +202 | | +203 | | """ + | |_______^ D205 + | + = help: Insert single blank line + +D.py:210:5: D205 [*] 1 blank line required between summary line and description (found 2) + | +208 | @expect('D213: Multi-line docstring summary should start at the second line') +209 | def multi_line_two_separating_blanks(): +210 | """Summary. + | _____^ +211 | | +212 | | +213 | | Description. +214 | | +215 | | """ + | |_______^ D205 + | + = help: Insert single blank line + +ℹ Fix +209 209 | def multi_line_two_separating_blanks(): +210 210 | """Summary. +211 211 | +212 |- +213 212 | Description. +214 213 | +215 214 | """ + + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D206_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D206_D.py.snap new file mode 100644 index 0000000000..724d6e7d20 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D206_D.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- + 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 new file mode 100644 index 0000000000..355d9c79d7 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D207_D.py.snap @@ -0,0 +1,82 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:232:1: D207 [*] Docstring is under-indented + | +230 | """Summary. +231 | +232 | Description. + | D207 +233 | +234 | """ + | + = help: Increase indentation + +ℹ Fix +229 229 | def asdfsdf(): +230 230 | """Summary. +231 231 | +232 |-Description. + 232 |+ Description. +233 233 | +234 234 | """ +235 235 | + +D.py:244:1: D207 [*] Docstring is under-indented + | +242 | Description. +243 | +244 | """ + | D207 + | + = help: Increase indentation + +ℹ Fix +241 241 | +242 242 | Description. +243 243 | +244 |-""" + 244 |+ """ +245 245 | +246 246 | +247 247 | @expect('D208: Docstring is over-indented') + +D.py:440:1: D207 [*] Docstring is under-indented + | +438 | def docstring_start_in_same_line(): """First Line. +439 | +440 | Second Line + | D207 +441 | """ + | + = help: Increase indentation + +ℹ Fix +437 437 | @expect('D213: Multi-line docstring summary should start at the second line') +438 438 | def docstring_start_in_same_line(): """First Line. +439 439 | +440 |- Second Line + 440 |+ Second Line +441 441 | """ +442 442 | +443 443 | + +D.py:441:1: D207 [*] Docstring is under-indented + | +440 | Second Line +441 | """ + | D207 + | + = help: Increase indentation + +ℹ Fix +438 438 | def docstring_start_in_same_line(): """First Line. +439 439 | +440 440 | Second Line +441 |- """ + 441 |+ """ +442 442 | +443 443 | +444 444 | def function_with_lambda_arg(x=lambda y: y): + + 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 new file mode 100644 index 0000000000..9a1338b023 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D208_D.py.snap @@ -0,0 +1,65 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:252:1: D208 [*] Docstring is over-indented + | +250 | """Summary. +251 | +252 | Description. + | D208 +253 | +254 | """ + | + = help: Remove over-indentation + +ℹ Fix +249 249 | def asdfsdsdf24(): +250 250 | """Summary. +251 251 | +252 |- Description. + 252 |+ Description. +253 253 | +254 254 | """ +255 255 | + +D.py:264:1: D208 [*] Docstring is over-indented + | +262 | Description. +263 | +264 | """ + | D208 + | + = help: Remove over-indentation + +ℹ Fix +261 261 | +262 262 | Description. +263 263 | +264 |- """ + 264 |+ """ +265 265 | +266 266 | +267 267 | @expect('D208: Docstring is over-indented') + +D.py:272:1: D208 [*] Docstring is over-indented + | +270 | """Summary. +271 | +272 | Description. + | D208 +273 | +274 | """ + | + = help: Remove over-indentation + +ℹ Fix +269 269 | def asdfsdfsdsdsdfsdf24(): +270 270 | """Summary. +271 271 | +272 |- Description. + 272 |+ Description. +273 273 | +274 274 | """ +275 275 | + + 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 new file mode 100644 index 0000000000..a7339839f9 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D209_D.py.snap @@ -0,0 +1,50 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +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 | | +283 | | Description.""" + | |___________________^ D209 + | + = help: Move closing quotes to new line + +ℹ Fix +280 280 | def asdfljdf24(): +281 281 | """Summary. +282 282 | +283 |- Description.""" + 283 |+ Description. + 284 |+ """ +284 285 | +285 286 | +286 287 | @expect('D210: No whitespaces allowed surrounding docstring text') + +D.py:588:5: D209 [*] Multi-line docstring closing quotes should be on a separate line + | +586 | @expect('D213: Multi-line docstring summary should start at the second line') +587 | def asdfljdjgf24(): +588 | """Summary. + | _____^ +589 | | +590 | | Description. """ + | |_____________________^ D209 + | + = help: Move closing quotes to new line + +ℹ Fix +587 587 | def asdfljdjgf24(): +588 588 | """Summary. +589 589 | +590 |- Description. """ + 590 |+ Description. + 591 |+ """ +591 592 | +592 593 | +593 594 | @expect('D200: One-line docstring should fit on one line with quotes ' + + 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 new file mode 100644 index 0000000000..538c0f34ba --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D210_D.py.snap @@ -0,0 +1,74 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:288:5: D210 [*] No whitespaces allowed surrounding docstring text + | +286 | @expect('D210: No whitespaces allowed surrounding docstring text') +287 | def endswith(): +288 | """Whitespace at the end. """ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D210 + | + = help: Trim surrounding whitespace + +ℹ Fix +285 285 | +286 286 | @expect('D210: No whitespaces allowed surrounding docstring text') +287 287 | def endswith(): +288 |- """Whitespace at the end. """ + 288 |+ """Whitespace at the end.""" +289 289 | +290 290 | +291 291 | @expect('D210: No whitespaces allowed surrounding docstring text') + +D.py:293:5: D210 [*] No whitespaces allowed surrounding docstring text + | +291 | @expect('D210: No whitespaces allowed surrounding docstring text') +292 | def around(): +293 | """ Whitespace at everywhere. """ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D210 + | + = help: Trim surrounding whitespace + +ℹ Fix +290 290 | +291 291 | @expect('D210: No whitespaces allowed surrounding docstring text') +292 292 | def around(): +293 |- """ Whitespace at everywhere. """ + 293 |+ """Whitespace at everywhere.""" +294 294 | +295 295 | +296 296 | @expect('D210: No whitespaces allowed surrounding docstring text') + +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 | | +301 | | This is the end. +302 | | """ + | |_______^ D210 + | + = help: Trim surrounding whitespace + +ℹ Fix +296 296 | @expect('D210: No whitespaces allowed surrounding docstring text') +297 297 | @expect('D213: Multi-line docstring summary should start at the second line') +298 298 | def multiline(): +299 |- """ Whitespace at the beginning. + 299 |+ """Whitespace at the beginning. +300 300 | +301 301 | This is the end. +302 302 | """ + +D.py:581:5: D210 No whitespaces allowed surrounding docstring text + | +579 | "or exclamation point (not '\"')") +580 | def endswith_quote(): +581 | """Whitespace at the end, but also a quote" """ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D210 + | + = help: Trim surrounding whitespace + + 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 new file mode 100644 index 0000000000..06819455f6 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D211_D.py.snap @@ -0,0 +1,41 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:170:5: D211 [*] No blank lines allowed before class docstring + | +168 | class WithLeadingSpace: +169 | +170 | """With leading space.""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^ D211 + | + = help: Remove blank line(s) before class docstring + +ℹ Fix +166 166 | +167 167 | +168 168 | class WithLeadingSpace: +169 |- +170 169 | """With leading space.""" +171 170 | +172 171 | + +D.py:181:5: D211 [*] No blank lines allowed before class docstring + | +179 | class TrailingSpace: +180 | +181 | """TrailingSpace.""" + | ^^^^^^^^^^^^^^^^^^^^ D211 +182 | pass + | + = help: Remove blank line(s) before class docstring + +ℹ Fix +177 177 | +178 178 | +179 179 | class TrailingSpace: +180 |- +181 180 | """TrailingSpace.""" +182 181 | pass +183 182 | + + 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 new file mode 100644 index 0000000000..8ff4e77c75 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D212_D.py.snap @@ -0,0 +1,75 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +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 | """ + | _____^ +130 | | Wrong. +131 | | """ + | |_______^ D212 + | + = help: Remove whitespace after opening quotes + +ℹ Fix +126 126 | '(found 3)') +127 127 | @expect('D212: Multi-line docstring summary should start at the first line') +128 128 | def asdlkfasd(): +129 |- """ +130 |- Wrong. + 129 |+ """Wrong. +131 130 | """ +132 131 | +133 132 | + +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 | | +599 | | Wrong.""" + | |_____________^ D212 + | + = help: Remove whitespace after opening quotes + +ℹ Fix +594 594 | '(found 3)') +595 595 | @expect('D212: Multi-line docstring summary should start at the first line') +596 596 | def one_liner(): +597 |- """ +598 |- +599 |- Wrong.""" + 597 |+ """Wrong.""" +600 598 | +601 599 | +602 600 | @expect('D200: One-line docstring should fit on one line with quotes ' + +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 | | +626 | | "Wrong.""" + | |______________^ D212 + | + = help: Remove whitespace after opening quotes + +ℹ Fix +621 621 | '(found 3)') +622 622 | @expect('D212: Multi-line docstring summary should start at the first line') +623 623 | def one_liner(): +624 |- """ +625 |- +626 |- "Wrong.""" + 624 |+ """"Wrong.""" +627 625 | +628 626 | +629 627 | @expect('D404: First word of the docstring should not be "This"') + + 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 new file mode 100644 index 0000000000..cf152b3416 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D213_D.py.snap @@ -0,0 +1,550 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +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. + | _____^ +201 | | Description. +202 | | +203 | | """ + | |_______^ D213 + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +197 197 | '(found 0)') +198 198 | @expect('D213: Multi-line docstring summary should start at the second line') +199 199 | def multi_line_zero_separating_blanks(): +200 |- """Summary. + 200 |+ """ + 201 |+ Summary. +201 202 | Description. +202 203 | +203 204 | """ + +D.py:210:5: D213 [*] Multi-line docstring summary should start at the second line + | +208 | @expect('D213: Multi-line docstring summary should start at the second line') +209 | def multi_line_two_separating_blanks(): +210 | """Summary. + | _____^ +211 | | +212 | | +213 | | Description. +214 | | +215 | | """ + | |_______^ D213 + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +207 207 | '(found 2)') +208 208 | @expect('D213: Multi-line docstring summary should start at the second line') +209 209 | def multi_line_two_separating_blanks(): +210 |- """Summary. + 210 |+ """ + 211 |+ Summary. +211 212 | +212 213 | +213 214 | Description. + +D.py:220:5: D213 [*] Multi-line docstring summary should start at the second line + | +218 | @expect('D213: Multi-line docstring summary should start at the second line') +219 | def multi_line_one_separating_blanks(): +220 | """Summary. + | _____^ +221 | | +222 | | Description. +223 | | +224 | | """ + | |_______^ D213 + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +217 217 | +218 218 | @expect('D213: Multi-line docstring summary should start at the second line') +219 219 | def multi_line_one_separating_blanks(): +220 |- """Summary. + 220 |+ """ + 221 |+ Summary. +221 222 | +222 223 | Description. +223 224 | + +D.py:230:5: D213 [*] Multi-line docstring summary should start at the second line + | +228 | @expect('D213: Multi-line docstring summary should start at the second line') +229 | def asdfsdf(): +230 | """Summary. + | _____^ +231 | | +232 | | Description. +233 | | +234 | | """ + | |_______^ D213 + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +227 227 | @expect('D207: Docstring is under-indented') +228 228 | @expect('D213: Multi-line docstring summary should start at the second line') +229 229 | def asdfsdf(): +230 |- """Summary. + 230 |+ """ + 231 |+ Summary. +231 232 | +232 233 | Description. +233 234 | + +D.py:240:5: D213 [*] Multi-line docstring summary should start at the second line + | +238 | @expect('D213: Multi-line docstring summary should start at the second line') +239 | def asdsdfsdffsdf(): +240 | """Summary. + | _____^ +241 | | +242 | | Description. +243 | | +244 | | """ + | |___^ D213 + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +237 237 | @expect('D207: Docstring is under-indented') +238 238 | @expect('D213: Multi-line docstring summary should start at the second line') +239 239 | def asdsdfsdffsdf(): +240 |- """Summary. + 240 |+ """ + 241 |+ Summary. +241 242 | +242 243 | Description. +243 244 | + +D.py:250:5: D213 [*] Multi-line docstring summary should start at the second line + | +248 | @expect('D213: Multi-line docstring summary should start at the second line') +249 | def asdfsdsdf24(): +250 | """Summary. + | _____^ +251 | | +252 | | Description. +253 | | +254 | | """ + | |_______^ D213 + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +247 247 | @expect('D208: Docstring is over-indented') +248 248 | @expect('D213: Multi-line docstring summary should start at the second line') +249 249 | def asdfsdsdf24(): +250 |- """Summary. + 250 |+ """ + 251 |+ Summary. +251 252 | +252 253 | Description. +253 254 | + +D.py:260:5: D213 [*] Multi-line docstring summary should start at the second line + | +258 | @expect('D213: Multi-line docstring summary should start at the second line') +259 | def asdfsdsdfsdf24(): +260 | """Summary. + | _____^ +261 | | +262 | | Description. +263 | | +264 | | """ + | |___________^ D213 + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +257 257 | @expect('D208: Docstring is over-indented') +258 258 | @expect('D213: Multi-line docstring summary should start at the second line') +259 259 | def asdfsdsdfsdf24(): +260 |- """Summary. + 260 |+ """ + 261 |+ Summary. +261 262 | +262 263 | Description. +263 264 | + +D.py:270:5: D213 [*] Multi-line docstring summary should start at the second line + | +268 | @expect('D213: Multi-line docstring summary should start at the second line') +269 | def asdfsdfsdsdsdfsdf24(): +270 | """Summary. + | _____^ +271 | | +272 | | Description. +273 | | +274 | | """ + | |_______^ D213 + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +267 267 | @expect('D208: Docstring is over-indented') +268 268 | @expect('D213: Multi-line docstring summary should start at the second line') +269 269 | def asdfsdfsdsdsdfsdf24(): +270 |- """Summary. + 270 |+ """ + 271 |+ Summary. +271 272 | +272 273 | Description. +273 274 | + +D.py:281:5: D213 [*] Multi-line docstring summary should start at the second line + | +279 | @expect('D213: Multi-line docstring summary should start at the second line') +280 | def asdfljdf24(): +281 | """Summary. + | _____^ +282 | | +283 | | Description.""" + | |___________________^ D213 + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +278 278 | 'line') +279 279 | @expect('D213: Multi-line docstring summary should start at the second line') +280 280 | def asdfljdf24(): +281 |- """Summary. + 281 |+ """ + 282 |+ Summary. +282 283 | +283 284 | Description.""" +284 285 | + +D.py:299:5: D213 [*] Multi-line docstring summary should start at the second line + | +297 | @expect('D213: Multi-line docstring summary should start at the second line') +298 | def multiline(): +299 | """ Whitespace at the beginning. + | _____^ +300 | | +301 | | This is the end. +302 | | """ + | |_______^ D213 + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +296 296 | @expect('D210: No whitespaces allowed surrounding docstring text') +297 297 | @expect('D213: Multi-line docstring summary should start at the second line') +298 298 | def multiline(): +299 |- """ Whitespace at the beginning. + 299 |+ """ + 300 |+ Whitespace at the beginning. +300 301 | +301 302 | This is the end. +302 303 | """ + +D.py:343:5: D213 [*] Multi-line docstring summary should start at the second line + | +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 | | +345 | | In particular, line continuations \ +346 | | and unicode literals \u0394 and \N{GREEK CAPITAL LETTER DELTA}. +347 | | They are considered to be intentionally unescaped. +348 | | """ + | |_______^ D213 + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +340 340 | +341 341 | @expect('D213: Multi-line docstring summary should start at the second line') +342 342 | def exceptions_of_D301(): +343 |- """Exclude some backslashes from D301. + 343 |+ """ + 344 |+ Exclude some backslashes from D301. +344 345 | +345 346 | In particular, line continuations \ +346 347 | and unicode literals \u0394 and \N{GREEK CAPITAL LETTER DELTA}. + +D.py:383:5: D213 [*] Multi-line docstring summary should start at the second line + | +381 | @expect('D213: Multi-line docstring summary should start at the second line') +382 | def new_209(): +383 | """First line. + | _____^ +384 | | +385 | | More lines. +386 | | """ + | |_______^ D213 +387 | pass + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +380 380 | +381 381 | @expect('D213: Multi-line docstring summary should start at the second line') +382 382 | def new_209(): +383 |- """First line. + 383 |+ """ + 384 |+ First line. +384 385 | +385 386 | More lines. +386 387 | """ + +D.py:392:5: D213 [*] Multi-line docstring summary should start at the second line + | +390 | @expect('D213: Multi-line docstring summary should start at the second line') +391 | def old_209(): +392 | """One liner. + | _____^ +393 | | +394 | | Multi-line comments. OK to have extra blank line +395 | | +396 | | """ + | |_______^ D213 + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +389 389 | +390 390 | @expect('D213: Multi-line docstring summary should start at the second line') +391 391 | def old_209(): +392 |- """One liner. + 392 |+ """ + 393 |+ One liner. +393 394 | +394 395 | Multi-line comments. OK to have extra blank line +395 396 | + +D.py:438:37: D213 [*] Multi-line docstring summary should start at the second line + | +436 | @expect("D207: Docstring is under-indented") +437 | @expect('D213: Multi-line docstring summary should start at the second line') +438 | def docstring_start_in_same_line(): """First Line. + | _____________________________________^ +439 | | +440 | | Second Line +441 | | """ + | |_______^ D213 + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +435 435 | +436 436 | @expect("D207: Docstring is under-indented") +437 437 | @expect('D213: Multi-line docstring summary should start at the second line') +438 |-def docstring_start_in_same_line(): """First Line. + 438 |+def docstring_start_in_same_line(): """ + 439 |+ First Line. +439 440 | +440 441 | Second Line +441 442 | """ + +D.py:450:5: D213 [*] Multi-line docstring summary should start at the second line + | +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 | | +452 | | The assertion was caused in the next function, so this one is necessary. +453 | | +454 | | """ + | |_______^ D213 + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +447 447 | +448 448 | @expect('D213: Multi-line docstring summary should start at the second line') +449 449 | def a_following_valid_function(x=None): +450 |- """Check for a bug where the previous function caused an assertion. + 450 |+ """ + 451 |+ Check for a bug where the previous function caused an assertion. +451 452 | +452 453 | The assertion was caused in the next function, so this one is necessary. +453 454 | + +D.py:526:5: D213 [*] Multi-line docstring summary should start at the second line + | +524 | # parameters as functions for Google / Numpy conventions. +525 | class Blah: # noqa: D203,D213 +526 | """A Blah. + | _____^ +527 | | +528 | | Parameters +529 | | ---------- +530 | | x : int +531 | | +532 | | """ + | |_______^ D213 +533 | +534 | def __init__(self, x): + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +523 523 | # This is reproducing a bug where AttributeError is raised when parsing class +524 524 | # parameters as functions for Google / Numpy conventions. +525 525 | class Blah: # noqa: D203,D213 +526 |- """A Blah. + 526 |+ """ + 527 |+ A Blah. +527 528 | +528 529 | Parameters +529 530 | ---------- + +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 | | +548 | | More content. +549 | | """ + | |_______^ D213 + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +543 543 | @expect('D213: Multi-line docstring summary should start at the second line') +544 544 | def multiline_leading_space(): +545 545 | +546 |- """Leading space. + 546 |+ """ + 547 |+ Leading space. +547 548 | +548 549 | More content. +549 550 | """ + +D.py:555:5: D213 [*] Multi-line docstring summary should start at the second line + | +553 | @expect('D213: Multi-line docstring summary should start at the second line') +554 | def multiline_trailing_space(): +555 | """Leading space. + | _____^ +556 | | +557 | | More content. +558 | | """ + | |_______^ D213 +559 | +560 | pass + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +552 552 | @expect('D202: No blank lines allowed after function docstring (found 1)') +553 553 | @expect('D213: Multi-line docstring summary should start at the second line') +554 554 | def multiline_trailing_space(): +555 |- """Leading space. + 555 |+ """ + 556 |+ Leading space. +556 557 | +557 558 | More content. +558 559 | """ + +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 | | +570 | | More content. +571 | | """ + | |_______^ D213 +572 | +573 | pass + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +565 565 | @expect('D213: Multi-line docstring summary should start at the second line') +566 566 | def multiline_trailing_and_leading_space(): +567 567 | +568 |- """Trailing and leading space. + 568 |+ """ + 569 |+ Trailing and leading space. +569 570 | +570 571 | More content. +571 572 | """ + +D.py:588:5: D213 [*] Multi-line docstring summary should start at the second line + | +586 | @expect('D213: Multi-line docstring summary should start at the second line') +587 | def asdfljdjgf24(): +588 | """Summary. + | _____^ +589 | | +590 | | Description. """ + | |_____________________^ D213 + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +585 585 | 'line') +586 586 | @expect('D213: Multi-line docstring summary should start at the second line') +587 587 | def asdfljdjgf24(): +588 |- """Summary. + 588 |+ """ + 589 |+ Summary. +589 590 | +590 591 | Description. """ +591 592 | + +D.py:606:5: D213 [*] Multi-line docstring summary should start at the second line + | +604 | @expect('D212: Multi-line docstring summary should start at the first line') +605 | def one_liner(): +606 | r"""Wrong. + | _____^ +607 | | +608 | | """ + | |_______^ D213 + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +603 603 | '(found 3)') +604 604 | @expect('D212: Multi-line docstring summary should start at the first line') +605 605 | def one_liner(): +606 |- r"""Wrong. + 606 |+ r""" + 607 |+ Wrong. +607 608 | +608 609 | """ +609 610 | + +D.py:615:5: D213 [*] Multi-line docstring summary should start at the second line + | +613 | @expect('D212: Multi-line docstring summary should start at the first line') +614 | def one_liner(): +615 | """Wrong." + | _____^ +616 | | +617 | | """ + | |_______^ D213 + | + = help: Insert line break and indentation after opening quotes + +ℹ Fix +612 612 | '(found 3)') +613 613 | @expect('D212: Multi-line docstring summary should start at the first line') +614 614 | def one_liner(): +615 |- """Wrong." + 615 |+ """ + 616 |+ Wrong." +616 617 | +617 618 | """ +618 619 | + + 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 new file mode 100644 index 0000000000..1d4c284b9b --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_D214_module.py.snap @@ -0,0 +1,59 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D214_module.py:1:1: D214 [*] Section is over-indented ("Returns") + | + 1 | / """A module docstring with D214 violations + 2 | | + 3 | | Returns + 4 | | ----- + 5 | | valid returns + 6 | | + 7 | | Args + 8 | | ----- + 9 | | valid args +10 | | """ + | |___^ D214 +11 | +12 | import os + | + = help: Remove over-indentation from "Returns" + +ℹ Fix +1 1 | """A module docstring with D214 violations +2 2 | +3 |- Returns + 3 |+Returns +4 4 | ----- +5 5 | valid returns +6 6 | + +D214_module.py:1:1: D214 [*] Section is over-indented ("Args") + | + 1 | / """A module docstring with D214 violations + 2 | | + 3 | | Returns + 4 | | ----- + 5 | | valid returns + 6 | | + 7 | | Args + 8 | | ----- + 9 | | valid args +10 | | """ + | |___^ D214 +11 | +12 | import os + | + = help: Remove over-indentation from "Args" + +ℹ Fix +4 4 | ----- +5 5 | valid returns +6 6 | +7 |- Args + 7 |+Args +8 8 | ----- +9 9 | valid args +10 10 | """ + + 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 new file mode 100644 index 0000000000..d9b922a8e0 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D214_sections.py.snap @@ -0,0 +1,30 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +sections.py:144:5: D214 [*] Section is over-indented ("Returns") + | +142 | @expect("D214: Section is over-indented ('Returns')") +143 | def section_overindented(): # noqa: D416 +144 | """Toggle the gizmo. + | _____^ +145 | | +146 | | Returns +147 | | ------- +148 | | A value of some sort. +149 | | +150 | | """ + | |_______^ D214 + | + = help: Remove over-indentation from "Returns" + +ℹ Fix +143 143 | def section_overindented(): # noqa: D416 +144 144 | """Toggle the gizmo. +145 145 | +146 |- Returns + 146 |+ Returns +147 147 | ------- +148 148 | A value of some sort. +149 149 | + + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D215_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D215_sections.py.snap new file mode 100644 index 0000000000..ae6dc1dfed --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D215_sections.py.snap @@ -0,0 +1,54 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +sections.py:156:5: D215 [*] Section underline is over-indented ("Returns") + | +154 | @expect("D215: Section underline is over-indented (in section 'Returns')") +155 | def section_underline_overindented(): # noqa: D416 +156 | """Toggle the gizmo. + | _____^ +157 | | +158 | | Returns +159 | | ------- +160 | | A value of some sort. +161 | | +162 | | """ + | |_______^ D215 + | + = help: Remove over-indentation from "Returns" underline + +ℹ Fix +156 156 | """Toggle the gizmo. +157 157 | +158 158 | Returns +159 |- ------- + 159 |+ ------ +160 160 | A value of some sort. +161 161 | +162 162 | """ + +sections.py:170:5: D215 [*] Section underline is over-indented ("Returns") + | +168 | @expect("D414: Section has no content ('Returns')") +169 | def section_underline_overindented_and_contentless(): # noqa: D416 +170 | """Toggle the gizmo. + | _____^ +171 | | +172 | | Returns +173 | | ------- +174 | | """ + | |_______^ D215 + | + = help: Remove over-indentation from "Returns" underline + +ℹ Fix +170 170 | """Toggle the gizmo. +171 171 | +172 172 | Returns +173 |- ------- + 173 |+ ------ +174 174 | """ +175 175 | +176 176 | + + 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 new file mode 100644 index 0000000000..dbf703c165 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D300_D.py.snap @@ -0,0 +1,89 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:307:5: D300 Use triple double quotes `"""` + | +305 | @expect('D300: Use """triple double quotes""" (found \'\'\'-quotes)') +306 | def triple_single_quotes_raw(): +307 | r'''Summary.''' + | ^^^^^^^^^^^^^^^ D300 + | + +D.py:312:5: D300 Use triple double quotes `"""` + | +310 | @expect('D300: Use """triple double quotes""" (found \'\'\'-quotes)') +311 | def triple_single_quotes_raw_uppercase(): +312 | R'''Summary.''' + | ^^^^^^^^^^^^^^^ D300 + | + +D.py:317:5: D300 Use triple double quotes `"""` + | +315 | @expect('D300: Use """triple double quotes""" (found \'-quotes)') +316 | def single_quotes_raw(): +317 | r'Summary.' + | ^^^^^^^^^^^ D300 + | + +D.py:322:5: D300 Use triple double quotes `"""` + | +320 | @expect('D300: Use """triple double quotes""" (found \'-quotes)') +321 | def single_quotes_raw_uppercase(): +322 | R'Summary.' + | ^^^^^^^^^^^ D300 + | + +D.py:328:5: D300 Use triple double quotes `"""` + | +326 | @expect('D301: Use r""" if any backslashes in a docstring') +327 | def single_quotes_raw_uppercase_backslash(): +328 | R'Sum\mary.' + | ^^^^^^^^^^^^ D300 + | + +D.py:645:5: D300 Use triple double quotes `"""` + | +644 | def single_line_docstring_with_an_escaped_backslash(): +645 | "\ + | _____^ +646 | | " + | |_____^ D300 +647 | +648 | class StatementOnSameLineAsDocstring: + | + +D.py:649:5: D300 Use triple double quotes `"""` + | +648 | class StatementOnSameLineAsDocstring: +649 | "After this docstring there's another statement on the same line separated by a semicolon." ; priorities=1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D300 +650 | def sort_services(self): +651 | pass + | + +D.py:654:5: D300 Use triple double quotes `"""` + | +653 | class StatementOnSameLineAsDocstring: +654 | "After this docstring there's another statement on the same line separated by a semicolon."; priorities=1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D300 + | + +D.py:658:5: D300 Use triple double quotes `"""` + | +657 | class CommentAfterDocstring: +658 | "After this docstring there's a comment." # priorities=1 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D300 +659 | def sort_services(self): +660 | pass + | + +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 \ + | _____^ +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_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D.py.snap new file mode 100644 index 0000000000..9c2880c067 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D.py.snap @@ -0,0 +1,28 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:328:5: D301 Use `r"""` if any backslashes in a docstring + | +326 | @expect('D301: Use r""" if any backslashes in a docstring') +327 | def single_quotes_raw_uppercase_backslash(): +328 | R'Sum\mary.' + | ^^^^^^^^^^^^ D301 + | + +D.py:333:5: D301 Use `r"""` if any backslashes in a docstring + | +331 | @expect('D301: Use r""" if any backslashes in a docstring') +332 | def double_quotes_backslash(): +333 | """Sum\\mary.""" + | ^^^^^^^^^^^^^^^^ D301 + | + +D.py:338:5: D301 Use `r"""` if any backslashes in a docstring + | +336 | @expect('D301: Use r""" if any backslashes in a docstring') +337 | def double_quotes_backslash_uppercase(): +338 | R"""Sum\\mary.""" + | ^^^^^^^^^^^^^^^^^ D301 + | + + 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 new file mode 100644 index 0000000000..5ee1cedd05 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D301_D301.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D301.py:2:5: D301 Use `r"""` if any backslashes in a docstring + | +1 | def double_quotes_backslash(): +2 | """Sum\\mary.""" + | ^^^^^^^^^^^^^^^^ D301 + | + +D301.py:10:5: D301 Use `r"""` if any backslashes in a docstring + | + 9 | def double_quotes_backslash_uppercase(): +10 | R"""Sum\\mary.""" + | ^^^^^^^^^^^^^^^^^ 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 new file mode 100644 index 0000000000..7d0eafb11d --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D.py.snap @@ -0,0 +1,330 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:355:5: D400 [*] First line should end with a period + | +353 | "or exclamation point (not 'y')") +354 | def lwnlkjl(): +355 | """Summary""" + | ^^^^^^^^^^^^^ D400 + | + = help: Add period + +ℹ Suggested fix +352 352 | @expect("D415: First line should end with a period, question mark, " +353 353 | "or exclamation point (not 'y')") +354 354 | def lwnlkjl(): +355 |- """Summary""" + 355 |+ """Summary.""" +356 356 | +357 357 | +358 358 | @expect("D401: First line should be in imperative mood " + +D.py:406:25: D400 [*] First line should end with a period + | +404 | @expect("D415: First line should end with a period, question mark," +405 | " or exclamation point (not 'r')") +406 | def oneliner_withdoc(): """One liner""" + | ^^^^^^^^^^^^^^^ D400 + | + = help: Add period + +ℹ Suggested fix +403 403 | @expect("D400: First line should end with a period (not 'r')") +404 404 | @expect("D415: First line should end with a period, question mark," +405 405 | " or exclamation point (not 'r')") +406 |-def oneliner_withdoc(): """One liner""" + 406 |+def oneliner_withdoc(): """One liner.""" +407 407 | +408 408 | +409 409 | def ignored_decorator(func): # noqa: D400,D401,D415 + +D.py:410:5: D400 [*] First line should end with a period + | +409 | def ignored_decorator(func): # noqa: D400,D401,D415 +410 | """Runs something""" + | ^^^^^^^^^^^^^^^^^^^^ D400 +411 | func() +412 | pass + | + = help: Add period + +ℹ Suggested fix +407 407 | +408 408 | +409 409 | def ignored_decorator(func): # noqa: D400,D401,D415 +410 |- """Runs something""" + 410 |+ """Runs something.""" +411 411 | func() +412 412 | pass +413 413 | + +D.py:416:5: D400 [*] First line should end with a period + | +415 | def decorator_for_test(func): # noqa: D400,D401,D415 +416 | """Runs something""" + | ^^^^^^^^^^^^^^^^^^^^ D400 +417 | func() +418 | pass + | + = help: Add period + +ℹ Suggested fix +413 413 | +414 414 | +415 415 | def decorator_for_test(func): # noqa: D400,D401,D415 +416 |- """Runs something""" + 416 |+ """Runs something.""" +417 417 | func() +418 418 | pass +419 419 | + +D.py:422:35: D400 [*] First line should end with a period + | +421 | @ignored_decorator +422 | def oneliner_ignored_decorator(): """One liner""" + | ^^^^^^^^^^^^^^^ D400 + | + = help: Add period + +ℹ Suggested fix +419 419 | +420 420 | +421 421 | @ignored_decorator +422 |-def oneliner_ignored_decorator(): """One liner""" + 422 |+def oneliner_ignored_decorator(): """One liner.""" +423 423 | +424 424 | +425 425 | @decorator_for_test + +D.py:429:49: D400 [*] First line should end with a period + | +427 | @expect("D415: First line should end with a period, question mark," +428 | " or exclamation point (not 'r')") +429 | def oneliner_with_decorator_expecting_errors(): """One liner""" + | ^^^^^^^^^^^^^^^ D400 + | + = help: Add period + +ℹ Suggested fix +426 426 | @expect("D400: First line should end with a period (not 'r')") +427 427 | @expect("D415: First line should end with a period, question mark," +428 428 | " or exclamation point (not 'r')") +429 |-def oneliner_with_decorator_expecting_errors(): """One liner""" + 429 |+def oneliner_with_decorator_expecting_errors(): """One liner.""" +430 430 | +431 431 | +432 432 | @decorator_for_test + +D.py:470:5: D400 [*] First line should end with a period + | +468 | "or exclamation point (not 'g')") +469 | def docstring_bad(): +470 | """Runs something""" + | ^^^^^^^^^^^^^^^^^^^^ D400 +471 | pass + | + = help: Add period + +ℹ Suggested fix +467 467 | @expect("D415: First line should end with a period, question mark, " +468 468 | "or exclamation point (not 'g')") +469 469 | def docstring_bad(): +470 |- """Runs something""" + 470 |+ """Runs something.""" +471 471 | pass +472 472 | +473 473 | + +D.py:475:5: D400 [*] First line should end with a period + | +474 | def docstring_bad_ignore_all(): # noqa +475 | """Runs something""" + | ^^^^^^^^^^^^^^^^^^^^ D400 +476 | pass + | + = help: Add period + +ℹ Suggested fix +472 472 | +473 473 | +474 474 | def docstring_bad_ignore_all(): # noqa +475 |- """Runs something""" + 475 |+ """Runs something.""" +476 476 | pass +477 477 | +478 478 | + +D.py:480:5: D400 [*] First line should end with a period + | +479 | def docstring_bad_ignore_one(): # noqa: D400,D401,D415 +480 | """Runs something""" + | ^^^^^^^^^^^^^^^^^^^^ D400 +481 | pass + | + = help: Add period + +ℹ Suggested fix +477 477 | +478 478 | +479 479 | def docstring_bad_ignore_one(): # noqa: D400,D401,D415 +480 |- """Runs something""" + 480 |+ """Runs something.""" +481 481 | pass +482 482 | +483 483 | + +D.py:487:5: D400 [*] First line should end with a period + | +485 | "(perhaps 'Run', not 'Runs')") +486 | def docstring_ignore_some_violations_but_catch_D401(): # noqa: E501,D400,D415 +487 | """Runs something""" + | ^^^^^^^^^^^^^^^^^^^^ D400 +488 | pass + | + = help: Add period + +ℹ Suggested fix +484 484 | @expect("D401: First line should be in imperative mood " +485 485 | "(perhaps 'Run', not 'Runs')") +486 486 | def docstring_ignore_some_violations_but_catch_D401(): # noqa: E501,D400,D415 +487 |- """Runs something""" + 487 |+ """Runs something.""" +488 488 | pass +489 489 | +490 490 | + +D.py:514:5: D400 [*] First line should end with a period + | +513 | def valid_google_string(): # noqa: D400 +514 | """Test a valid something!""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | + = help: Add period + +ℹ Suggested fix +511 511 | +512 512 | +513 513 | def valid_google_string(): # noqa: D400 +514 |- """Test a valid something!""" + 514 |+ """Test a valid something!.""" +515 515 | +516 516 | +517 517 | @expect("D415: First line should end with a period, question mark, " + +D.py:520:5: D400 [*] First line should end with a period + | +518 | "or exclamation point (not 'g')") +519 | def bad_google_string(): # noqa: D400 +520 | """Test a valid something""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | + = help: Add period + +ℹ Suggested fix +517 517 | @expect("D415: First line should end with a period, question mark, " +518 518 | "or exclamation point (not 'g')") +519 519 | def bad_google_string(): # noqa: D400 +520 |- """Test a valid something""" + 520 |+ """Test a valid something.""" +521 521 | +522 522 | +523 523 | # This is reproducing a bug where AttributeError is raised when parsing class + +D.py:581:5: D400 [*] First line should end with a period + | +579 | "or exclamation point (not '\"')") +580 | def endswith_quote(): +581 | """Whitespace at the end, but also a quote" """ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | + = help: Add period + +ℹ Suggested fix +578 578 | @expect("D415: First line should end with a period, question mark, " +579 579 | "or exclamation point (not '\"')") +580 580 | def endswith_quote(): +581 |- """Whitespace at the end, but also a quote" """ + 581 |+ """Whitespace at the end, but also a quote". """ +582 582 | +583 583 | +584 584 | @expect('D209: Multi-line docstring closing quotes should be on a separate ' + +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 | | +617 | | """ + | |_______^ D400 + | + = help: Add period + +ℹ Suggested fix +612 612 | '(found 3)') +613 613 | @expect('D212: Multi-line docstring summary should start at the first line') +614 614 | def one_liner(): +615 |- """Wrong." + 615 |+ """Wrong.". +616 616 | +617 617 | """ +618 618 | + +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 | +641 | def same_line(): """This is a docstring on the same line""" + | + = help: Add period + +ℹ Suggested fix +636 636 | """ This is a docstring that starts with a space.""" # noqa: D210 +637 637 | +638 638 | +639 |-class SameLine: """This is a docstring on the same line""" + 639 |+class SameLine: """This is a docstring on the same line.""" +640 640 | +641 641 | def same_line(): """This is a docstring on the same line""" +642 642 | + +D.py:641:18: D400 [*] First line should end with a period + | +639 | class SameLine: """This is a docstring on the same line""" +640 | +641 | def same_line(): """This is a docstring on the same line""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 + | + = help: Add period + +ℹ Suggested fix +638 638 | +639 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""" + 641 |+def same_line(): """This is a docstring on the same line.""" +642 642 | +643 643 | +644 644 | def single_line_docstring_with_an_escaped_backslash(): + +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 \ + | _____^ +665 | | but continuations shouldn't be considered multi-line" + | |_________________________________________________________^ D400 + | + = help: Add period + +ℹ Suggested fix +662 662 | +663 663 | def newline_after_closing_quote(self): +664 664 | "We enforce a newline after the closing quote for a multi-line docstring \ +665 |- but continuations shouldn't be considered multi-line" + 665 |+ but continuations shouldn't be considered multi-line." + + 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 new file mode 100644 index 0000000000..4404e55641 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D400_D400.py.snap @@ -0,0 +1,250 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D400.py:2:5: D400 [*] First line should end with a period + | +1 | def f(): +2 | "Here's a line without a period" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 +3 | ... + | + = help: Add period + +ℹ Suggested fix +1 1 | def f(): +2 |- "Here's a line without a period" + 2 |+ "Here's a line without a period." +3 3 | ... +4 4 | +5 5 | + +D400.py:7:5: D400 [*] First line should end with a period + | +6 | def f(): +7 | """Here's a line without a period""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 +8 | ... + | + = help: Add period + +ℹ Suggested fix +4 4 | +5 5 | +6 6 | def f(): +7 |- """Here's a line without a period""" + 7 |+ """Here's a line without a period.""" +8 8 | ... +9 9 | +10 10 | + +D400.py:12:5: D400 [*] First line should end with a period + | +11 | def f(): +12 | """ + | _____^ +13 | | Here's a line without a period, +14 | | but here's the next line +15 | | """ + | |_______^ D400 +16 | ... + | + = help: Add period + +ℹ Suggested fix +11 11 | def f(): +12 12 | """ +13 13 | Here's a line without a period, +14 |- but here's the next line + 14 |+ but here's the next line. +15 15 | """ +16 16 | ... +17 17 | + +D400.py:20:5: D400 [*] First line should end with a period + | +19 | def f(): +20 | """Here's a line without a period""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 +21 | ... + | + = help: Add period + +ℹ Suggested fix +17 17 | +18 18 | +19 19 | def f(): +20 |- """Here's a line without a period""" + 20 |+ """Here's a line without a period.""" +21 21 | ... +22 22 | +23 23 | + +D400.py:25:5: D400 [*] First line should end with a period + | +24 | def f(): +25 | """ + | _____^ +26 | | Here's a line without a period, +27 | | but here's the next line""" + | |_______________________________^ D400 +28 | ... + | + = help: Add period + +ℹ Suggested fix +24 24 | def f(): +25 25 | """ +26 26 | Here's a line without a period, +27 |- but here's the next line""" + 27 |+ but here's the next line.""" +28 28 | ... +29 29 | +30 30 | + +D400.py:32:5: D400 [*] First line should end with a period + | +31 | def f(): +32 | """ + | _____^ +33 | | Here's a line without a period, +34 | | but here's the next line with trailing space """ + | |____________________________________________________^ D400 +35 | ... + | + = help: Add period + +ℹ Suggested fix +31 31 | def f(): +32 32 | """ +33 33 | Here's a line without a period, +34 |- but here's the next line with trailing space """ + 34 |+ but here's the next line with trailing space. """ +35 35 | ... +36 36 | +37 37 | + +D400.py:39:5: D400 [*] First line should end with a period + | +38 | def f(): +39 | r"Here's a line without a period" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 +40 | ... + | + = help: Add period + +ℹ Suggested fix +36 36 | +37 37 | +38 38 | def f(): +39 |- r"Here's a line without a period" + 39 |+ r"Here's a line without a period." +40 40 | ... +41 41 | +42 42 | + +D400.py:44:5: D400 [*] First line should end with a period + | +43 | def f(): +44 | r"""Here's a line without a period""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 +45 | ... + | + = help: Add period + +ℹ Suggested fix +41 41 | +42 42 | +43 43 | def f(): +44 |- r"""Here's a line without a period""" + 44 |+ r"""Here's a line without a period.""" +45 45 | ... +46 46 | +47 47 | + +D400.py:49:5: D400 [*] First line should end with a period + | +48 | def f(): +49 | r""" + | _____^ +50 | | Here's a line without a period, +51 | | but here's the next line +52 | | """ + | |_______^ D400 +53 | ... + | + = help: Add period + +ℹ Suggested fix +48 48 | def f(): +49 49 | r""" +50 50 | Here's a line without a period, +51 |- but here's the next line + 51 |+ but here's the next line. +52 52 | """ +53 53 | ... +54 54 | + +D400.py:57:5: D400 [*] First line should end with a period + | +56 | def f(): +57 | r"""Here's a line without a period""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400 +58 | ... + | + = help: Add period + +ℹ Suggested fix +54 54 | +55 55 | +56 56 | def f(): +57 |- r"""Here's a line without a period""" + 57 |+ r"""Here's a line without a period.""" +58 58 | ... +59 59 | +60 60 | + +D400.py:62:5: D400 [*] First line should end with a period + | +61 | def f(): +62 | r""" + | _____^ +63 | | Here's a line without a period, +64 | | but here's the next line""" + | |_______________________________^ D400 +65 | ... + | + = help: Add period + +ℹ Suggested fix +61 61 | def f(): +62 62 | r""" +63 63 | Here's a line without a period, +64 |- but here's the next line""" + 64 |+ but here's the next line.""" +65 65 | ... +66 66 | +67 67 | + +D400.py:69:5: D400 [*] First line should end with a period + | +68 | def f(): +69 | r""" + | _____^ +70 | | Here's a line without a period, +71 | | but here's the next line with trailing space """ + | |____________________________________________________^ D400 +72 | ... + | + = help: Add period + +ℹ Suggested fix +68 68 | def f(): +69 69 | r""" +70 70 | Here's a line without a period, +71 |- but here's the next line with trailing space """ + 71 |+ but here's the next line with trailing space. """ +72 72 | ... +73 73 | +74 74 | + + 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 new file mode 100644 index 0000000000..b172f391a8 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D401_D401.py.snap @@ -0,0 +1,67 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D401.py:10:5: D401 First line of docstring should be in imperative mood: "Returns foo." + | + 9 | def bad_liouiwnlkjl(): +10 | """Returns foo.""" + | ^^^^^^^^^^^^^^^^^^ D401 + | + +D401.py:14:5: D401 First line of docstring should be in imperative mood: "Constructor for a foo." + | +13 | def bad_sdgfsdg23245(): +14 | """Constructor for a foo.""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D401 + | + +D401.py:18:5: D401 First line of docstring should be in imperative mood: "Constructor for a boa." + | +17 | def bad_sdgfsdg23245777(): +18 | """ + | _____^ +19 | | +20 | | Constructor for a boa. +21 | | +22 | | """ + | |_______^ D401 + | + +D401.py:26:5: D401 First line of docstring should be in imperative mood: "Runs something" + | +25 | def bad_run_something(): +26 | """Runs something""" + | ^^^^^^^^^^^^^^^^^^^^ D401 +27 | +28 | def bad_nested(): + | + +D401.py:29:9: D401 First line of docstring should be in imperative mood: "Runs other things, nested" + | +28 | def bad_nested(): +29 | """Runs other things, nested""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D401 +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 + | _____^ +36 | | extends to two physical lines. +37 | | """ + | |_______^ D401 + | + +D401.py:74:9: D401 First line of docstring should be in imperative mood: "This method docstring should be written in imperative mood." + | +73 | def bad_method(self): +74 | """This method docstring should be written in imperative mood.""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D401 +75 | +76 | @property + | + + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D402_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D402_D.py.snap new file mode 100644 index 0000000000..d2a3fedef8 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D402_D.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:378:5: D402 First line should not be the function's signature + | +376 | @expect('D402: First line should not be the function\'s "signature"') +377 | def foobar(): +378 | """Signature: foobar().""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ D402 + | + + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D403_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D403_D.py.snap new file mode 100644 index 0000000000..724d6e7d20 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D403_D.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- + 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 new file mode 100644 index 0000000000..9900625354 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D403_D403.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D403.py:2:5: D403 [*] First word of the first line should be capitalized: `this` -> `This` + | +1 | def bad_function(): +2 | """this docstring is not capitalized""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D403 +3 | +4 | def good_function(): + | + = help: Capitalize `this` to `This` + +ℹ Fix +1 1 | def bad_function(): +2 |- """this docstring is not capitalized""" + 2 |+ """This docstring is not capitalized""" +3 3 | +4 4 | def good_function(): +5 5 | """This docstring is capitalized.""" + + 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 new file mode 100644 index 0000000000..4f75df8c0f --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D404_D.py.snap @@ -0,0 +1,36 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:631:5: D404 First word of the docstring should not be "This" + | +629 | @expect('D404: First word of the docstring should not be "This"') +630 | def starts_with_this(): +631 | """This is a docstring.""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ D404 + | + +D.py:636:5: D404 First word of the docstring should not be "This" + | +634 | @expect('D404: First word of the docstring should not be "This"') +635 | def starts_with_space_then_this(): +636 | """ This is a docstring that starts with a space.""" # noqa: D210 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D404 + | + +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 | +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 | +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 new file mode 100644 index 0000000000..c0f88a68d6 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D405_sections.py.snap @@ -0,0 +1,64 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +sections.py:17:5: D405 [*] Section name should be properly capitalized ("returns") + | +15 | "('Returns', not 'returns')") +16 | def not_capitalized(): # noqa: D416 +17 | """Toggle the gizmo. + | _____^ +18 | | +19 | | returns +20 | | ------- +21 | | A value of some sort. +22 | | +23 | | """ + | |_______^ D405 + | + = help: Capitalize "returns" + +ℹ Fix +16 16 | def not_capitalized(): # noqa: D416 +17 17 | """Toggle the gizmo. +18 18 | +19 |- returns + 19 |+ Returns +20 20 | ------- +21 21 | A value of some sort. +22 22 | + +sections.py:216:5: D405 [*] Section name should be properly capitalized ("Short summary") + | +214 | @expect("D407: Missing dashed underline after section ('Raises')") +215 | def multiple_sections(): # noqa: D416 +216 | """Toggle the gizmo. + | _____^ +217 | | +218 | | Short summary +219 | | ------------- +220 | | +221 | | This is the function's description, which will also specify what it +222 | | returns. +223 | | +224 | | Returns +225 | | ------ +226 | | Many many wonderful things. +227 | | Raises: +228 | | My attention. +229 | | +230 | | """ + | |_______^ D405 + | + = help: Capitalize "Short summary" + +ℹ Fix +215 215 | def multiple_sections(): # noqa: D416 +216 216 | """Toggle the gizmo. +217 217 | +218 |- Short summary + 218 |+ Short Summary +219 219 | ------------- +220 220 | +221 221 | This is the function's description, which will also specify what it + + 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 new file mode 100644 index 0000000000..42113771b3 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D406_sections.py.snap @@ -0,0 +1,64 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +sections.py:30:5: D406 [*] Section name should end with a newline ("Returns") + | +28 | "('Returns', not 'Returns:')") +29 | def superfluous_suffix(): # noqa: D416 +30 | """Toggle the gizmo. + | _____^ +31 | | +32 | | Returns: +33 | | ------- +34 | | A value of some sort. +35 | | +36 | | """ + | |_______^ D406 + | + = help: Add newline after "Returns" + +ℹ Fix +29 29 | def superfluous_suffix(): # noqa: D416 +30 30 | """Toggle the gizmo. +31 31 | +32 |- Returns: + 32 |+ Returns +33 33 | ------- +34 34 | A value of some sort. +35 35 | + +sections.py:216:5: D406 [*] Section name should end with a newline ("Raises") + | +214 | @expect("D407: Missing dashed underline after section ('Raises')") +215 | def multiple_sections(): # noqa: D416 +216 | """Toggle the gizmo. + | _____^ +217 | | +218 | | Short summary +219 | | ------------- +220 | | +221 | | This is the function's description, which will also specify what it +222 | | returns. +223 | | +224 | | Returns +225 | | ------ +226 | | Many many wonderful things. +227 | | Raises: +228 | | My attention. +229 | | +230 | | """ + | |_______^ D406 + | + = help: Add newline after "Raises" + +ℹ Fix +224 224 | Returns +225 225 | ------ +226 226 | Many many wonderful things. +227 |- Raises: + 227 |+ Raises +228 228 | My attention. +229 229 | +230 230 | """ + + 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 new file mode 100644 index 0000000000..634a74e621 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D407_sections.py.snap @@ -0,0 +1,501 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +sections.py:42:5: D407 [*] Missing dashed underline after section ("Returns") + | +40 | @expect("D407: Missing dashed underline after section ('Returns')") +41 | def no_underline(): # noqa: D416 +42 | """Toggle the gizmo. + | _____^ +43 | | +44 | | Returns +45 | | A value of some sort. +46 | | +47 | | """ + | |_______^ D407 + | + = help: Add dashed line under "Returns" + +ℹ Fix +42 42 | """Toggle the gizmo. +43 43 | +44 44 | Returns + 45 |+ ------- +45 46 | A value of some sort. +46 47 | +47 48 | """ + +sections.py:54:5: D407 [*] Missing dashed underline after section ("Returns") + | +52 | @expect("D414: Section has no content ('Returns')") +53 | def no_underline_and_no_description(): # noqa: D416 +54 | """Toggle the gizmo. + | _____^ +55 | | +56 | | Returns +57 | | +58 | | """ + | |_______^ D407 + | + = help: Add dashed line under "Returns" + +ℹ Fix +54 54 | """Toggle the gizmo. +55 55 | +56 56 | Returns + 57 |+ ------- +57 58 | +58 59 | """ +59 60 | + +sections.py:65:5: D407 [*] Missing dashed underline after section ("Returns") + | +63 | @expect("D414: Section has no content ('Returns')") +64 | def no_underline_and_no_newline(): # noqa: D416 +65 | """Toggle the gizmo. + | _____^ +66 | | +67 | | Returns""" + | |______________^ D407 + | + = help: Add dashed line under "Returns" + +ℹ Fix +64 64 | def no_underline_and_no_newline(): # noqa: D416 +65 65 | """Toggle the gizmo. +66 66 | +67 |- Returns""" + 67 |+ Returns + 68 |+ -------""" +68 69 | +69 70 | +70 71 | @expect(_D213) + +sections.py:216:5: D407 [*] Missing dashed underline after section ("Raises") + | +214 | @expect("D407: Missing dashed underline after section ('Raises')") +215 | def multiple_sections(): # noqa: D416 +216 | """Toggle the gizmo. + | _____^ +217 | | +218 | | Short summary +219 | | ------------- +220 | | +221 | | This is the function's description, which will also specify what it +222 | | returns. +223 | | +224 | | Returns +225 | | ------ +226 | | Many many wonderful things. +227 | | Raises: +228 | | My attention. +229 | | +230 | | """ + | |_______^ D407 + | + = help: Add dashed line under "Raises" + +ℹ Fix +225 225 | ------ +226 226 | Many many wonderful things. +227 227 | Raises: + 228 |+ ------ +228 229 | My attention. +229 230 | +230 231 | """ + +sections.py:261:5: D407 [*] Missing dashed underline after section ("Args") + | +259 | @expect("D414: Section has no content ('Returns')") +260 | def valid_google_style_section(): # noqa: D406, D407 +261 | """Toggle the gizmo. + | _____^ +262 | | +263 | | Args: +264 | | note: A random string. +265 | | +266 | | Returns: +267 | | +268 | | Raises: +269 | | RandomError: A random error that occurs randomly. +270 | | +271 | | """ + | |_______^ D407 + | + = help: Add dashed line under "Args" + +ℹ Fix +261 261 | """Toggle the gizmo. +262 262 | +263 263 | Args: + 264 |+ ---- +264 265 | note: A random string. +265 266 | +266 267 | Returns: + +sections.py:261:5: D407 [*] Missing dashed underline after section ("Returns") + | +259 | @expect("D414: Section has no content ('Returns')") +260 | def valid_google_style_section(): # noqa: D406, D407 +261 | """Toggle the gizmo. + | _____^ +262 | | +263 | | Args: +264 | | note: A random string. +265 | | +266 | | Returns: +267 | | +268 | | Raises: +269 | | RandomError: A random error that occurs randomly. +270 | | +271 | | """ + | |_______^ D407 + | + = help: Add dashed line under "Returns" + +ℹ Fix +264 264 | note: A random string. +265 265 | +266 266 | Returns: + 267 |+ ------- +267 268 | +268 269 | Raises: +269 270 | RandomError: A random error that occurs randomly. + +sections.py:261:5: D407 [*] Missing dashed underline after section ("Raises") + | +259 | @expect("D414: Section has no content ('Returns')") +260 | def valid_google_style_section(): # noqa: D406, D407 +261 | """Toggle the gizmo. + | _____^ +262 | | +263 | | Args: +264 | | note: A random string. +265 | | +266 | | Returns: +267 | | +268 | | Raises: +269 | | RandomError: A random error that occurs randomly. +270 | | +271 | | """ + | |_______^ D407 + | + = help: Add dashed line under "Raises" + +ℹ Fix +266 266 | Returns: +267 267 | +268 268 | Raises: + 269 |+ ------ +269 270 | RandomError: A random error that occurs randomly. +270 271 | +271 272 | """ + +sections.py:278:5: D407 [*] Missing dashed underline after section ("Args") + | +276 | "('Args:', not 'Args')") +277 | def missing_colon_google_style_section(): # noqa: D406, D407 +278 | """Toggle the gizmo. + | _____^ +279 | | +280 | | Args +281 | | note: A random string. +282 | | +283 | | """ + | |_______^ D407 + | + = help: Add dashed line under "Args" + +ℹ Fix +278 278 | """Toggle the gizmo. +279 279 | +280 280 | Args + 281 |+ ---- +281 282 | note: A random string. +282 283 | +283 284 | """ + +sections.py:293:9: D407 [*] Missing dashed underline after section ("Args") + | +292 | def bar(y=2): # noqa: D207, D213, D406, D407 +293 | """Nested function test for docstrings. + | _________^ +294 | | +295 | | Will this work when referencing x? +296 | | +297 | | Args: +298 | | x: Test something +299 | | that is broken. +300 | | +301 | | """ + | |___________^ D407 +302 | print(x) + | + = help: Add dashed line under "Args" + +ℹ Fix +295 295 | Will this work when referencing x? +296 296 | +297 297 | Args: + 298 |+ ---- +298 299 | x: Test something +299 300 | that is broken. +300 301 | + +sections.py:310:5: D407 [*] Missing dashed underline after section ("Args") + | +308 | "'test_missing_google_args' docstring)") +309 | def test_missing_google_args(x=1, y=2, _private=3): # noqa: D406, D407 +310 | """Toggle the gizmo. + | _____^ +311 | | +312 | | Args: +313 | | x (int): The greatest integer. +314 | | +315 | | """ + | |_______^ D407 + | + = help: Add dashed line under "Args" + +ℹ Fix +310 310 | """Toggle the gizmo. +311 311 | +312 312 | Args: + 313 |+ ---- +313 314 | x (int): The greatest integer. +314 315 | +315 316 | """ + +sections.py:322:9: D407 [*] Missing dashed underline after section ("Args") + | +321 | def test_method(self, test, another_test, _): # noqa: D213, D407 +322 | """Test a valid args section. + | _________^ +323 | | +324 | | Args: +325 | | test: A parameter. +326 | | another_test: Another parameter. +327 | | +328 | | """ + | |___________^ D407 +329 | +330 | @expect("D417: Missing argument descriptions in the docstring " + | + = help: Add dashed line under "Args" + +ℹ Fix +322 322 | """Test a valid args section. +323 323 | +324 324 | Args: + 325 |+ ---- +325 326 | test: A parameter. +326 327 | another_test: Another parameter. +327 328 | + +sections.py:334:9: D407 [*] Missing dashed underline after section ("Args") + | +332 | "'test_missing_args' docstring)", arg_count=5) +333 | def test_missing_args(self, test, x, y, z=3, _private_arg=3): # noqa: D213, D407 +334 | """Test a valid args section. + | _________^ +335 | | +336 | | Args: +337 | | x: Another parameter. +338 | | +339 | | """ + | |___________^ D407 +340 | +341 | @classmethod + | + = help: Add dashed line under "Args" + +ℹ Fix +334 334 | """Test a valid args section. +335 335 | +336 336 | Args: + 337 |+ ---- +337 338 | x: Another parameter. +338 339 | +339 340 | """ + +sections.py:346:9: D407 [*] Missing dashed underline after section ("Args") + | +344 | "'test_missing_args_class_method' docstring)", arg_count=5) +345 | def test_missing_args_class_method(cls, test, x, y, _, z=3): # noqa: D213, D407 +346 | """Test a valid args section. + | _________^ +347 | | +348 | | Args: +349 | | x: Another parameter. The parameter below is missing description. +350 | | y: +351 | | +352 | | """ + | |___________^ D407 +353 | +354 | @staticmethod + | + = help: Add dashed line under "Args" + +ℹ Fix +346 346 | """Test a valid args section. +347 347 | +348 348 | Args: + 349 |+ ---- +349 350 | x: Another parameter. The parameter below is missing description. +350 351 | y: +351 352 | + +sections.py:359:9: D407 [*] Missing dashed underline after section ("Args") + | +357 | "'test_missing_args_static_method' docstring)", arg_count=4) +358 | def test_missing_args_static_method(a, x, y, _test, z=3): # noqa: D213, D407 +359 | """Test a valid args section. + | _________^ +360 | | +361 | | Args: +362 | | x: Another parameter. +363 | | +364 | | """ + | |___________^ D407 +365 | +366 | @staticmethod + | + = help: Add dashed line under "Args" + +ℹ Fix +359 359 | """Test a valid args section. +360 360 | +361 361 | Args: + 362 |+ ---- +362 363 | x: Another parameter. +363 364 | +364 365 | """ + +sections.py:371:9: D407 [*] Missing dashed underline after section ("Args") + | +369 | "'test_missing_docstring' docstring)", arg_count=2) +370 | def test_missing_docstring(a, b): # noqa: D213, D407 +371 | """Test a valid args section. + | _________^ +372 | | +373 | | Args: +374 | | a: +375 | | +376 | | """ + | |___________^ D407 +377 | +378 | @staticmethod + | + = help: Add dashed line under "Args" + +ℹ Fix +371 371 | """Test a valid args section. +372 372 | +373 373 | Args: + 374 |+ ---- +374 375 | a: +375 376 | +376 377 | """ + +sections.py:380:9: D407 [*] Missing dashed underline after section ("Args") + | +378 | @staticmethod +379 | def test_hanging_indent(skip, verbose): # noqa: D213, D407 +380 | """Do stuff. + | _________^ +381 | | +382 | | Args: +383 | | skip (:attr:`.Skip`): +384 | | Lorem ipsum dolor sit amet, consectetur adipiscing elit. +385 | | Etiam at tellus a tellus faucibus maximus. Curabitur tellus +386 | | mauris, semper id vehicula ac, feugiat ut tortor. +387 | | verbose (bool): +388 | | If True, print out as much information as possible. +389 | | If False, print out concise "one-liner" information. +390 | | +391 | | """ + | |___________^ D407 + | + = help: Add dashed line under "Args" + +ℹ Fix +380 380 | """Do stuff. +381 381 | +382 382 | Args: + 383 |+ ---- +383 384 | skip (:attr:`.Skip`): +384 385 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. +385 386 | Etiam at tellus a tellus faucibus maximus. Curabitur tellus + +sections.py:499:9: D407 [*] Missing dashed underline after section ("Args") + | +497 | "'test_incorrect_indent' docstring)", arg_count=3) +498 | def test_incorrect_indent(self, x=1, y=2): # noqa: D207, D213, D407 +499 | """Reproducing issue #437. + | _________^ +500 | | +501 | | Testing this incorrectly indented docstring. +502 | | +503 | | Args: +504 | | x: Test argument. +505 | | +506 | | """ + | |___________^ D407 + | + = help: Add dashed line under "Args" + +ℹ Fix +501 501 | Testing this incorrectly indented docstring. +502 502 | +503 503 | Args: + 504 |+ ---- +504 505 | x: Test argument. +505 506 | +506 507 | """ + +sections.py:519:5: D407 [*] Missing dashed underline after section ("Parameters") + | +518 | def replace_equals_with_dash(): +519 | """Equal length equals should be replaced with dashes. + | _____^ +520 | | +521 | | Parameters +522 | | ========== +523 | | """ + | |_______^ D407 + | + = help: Add dashed line under "Parameters" + +ℹ Fix +519 519 | """Equal length equals should be replaced with dashes. +520 520 | +521 521 | Parameters +522 |- ========== + 522 |+ ---------- +523 523 | """ +524 524 | +525 525 | + +sections.py:527:5: D407 [*] Missing dashed underline after section ("Parameters") + | +526 | def replace_equals_with_dash2(): +527 | """Here, the length of equals is not the same. + | _____^ +528 | | +529 | | Parameters +530 | | =========== +531 | | """ + | |_______^ D407 + | + = help: Add dashed line under "Parameters" + +ℹ Fix +527 527 | """Here, the length of equals is not the same. +528 528 | +529 529 | Parameters + 530 |+ ---------- +530 531 | =========== +531 532 | """ +532 533 | + + 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 new file mode 100644 index 0000000000..c40de2c794 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D408_sections.py.snap @@ -0,0 +1,30 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +sections.py:94:5: D408 [*] Section underline should be in the line following the section's name ("Returns") + | + 92 | "section's name ('Returns')") + 93 | def blank_line_before_underline(): # noqa: D416 + 94 | """Toggle the gizmo. + | _____^ + 95 | | + 96 | | Returns + 97 | | + 98 | | ------- + 99 | | A value of some sort. +100 | | +101 | | """ + | |_______^ D408 + | + = help: Add underline to "Returns" + +ℹ Fix +94 94 | """Toggle the gizmo. +95 95 | +96 96 | Returns +97 |- +98 97 | ------- +99 98 | A value of some sort. +100 99 | + + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D409_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D409_sections.py.snap new file mode 100644 index 0000000000..331114ace5 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D409_sections.py.snap @@ -0,0 +1,64 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +sections.py:108:5: D409 [*] Section underline should match the length of its name ("Returns") + | +106 | "(Expected 7 dashes in section 'Returns', got 2)") +107 | def bad_underline_length(): # noqa: D416 +108 | """Toggle the gizmo. + | _____^ +109 | | +110 | | Returns +111 | | -- +112 | | A value of some sort. +113 | | +114 | | """ + | |_______^ D409 + | + = help: Adjust underline length to match "Returns" + +ℹ Fix +108 108 | """Toggle the gizmo. +109 109 | +110 110 | Returns +111 |- -- + 111 |+ ------- +112 112 | A value of some sort. +113 113 | +114 114 | """ + +sections.py:216:5: D409 [*] Section underline should match the length of its name ("Returns") + | +214 | @expect("D407: Missing dashed underline after section ('Raises')") +215 | def multiple_sections(): # noqa: D416 +216 | """Toggle the gizmo. + | _____^ +217 | | +218 | | Short summary +219 | | ------------- +220 | | +221 | | This is the function's description, which will also specify what it +222 | | returns. +223 | | +224 | | Returns +225 | | ------ +226 | | Many many wonderful things. +227 | | Raises: +228 | | My attention. +229 | | +230 | | """ + | |_______^ D409 + | + = help: Adjust underline length to match "Returns" + +ℹ Fix +222 222 | returns. +223 223 | +224 224 | Returns +225 |- ------ + 225 |+ ------- +226 226 | Many many wonderful things. +227 227 | Raises: +228 228 | My attention. + + 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 new file mode 100644 index 0000000000..1c467c9960 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_D410.py.snap @@ -0,0 +1,59 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D410.py:2:5: D410 [*] Missing blank line after section ("Parameters") + | + 1 | def f(a: int, b: int) -> int: + 2 | """Showcase function. + | _____^ + 3 | | + 4 | | Parameters + 5 | | ---------- + 6 | | a : int + 7 | | _description_ + 8 | | b : int + 9 | | _description_ +10 | | Returns +11 | | ------- +12 | | int +13 | | _description +14 | | """ + | |_______^ D410 +15 | return b - a + | + = help: Add blank line after "Parameters" + +ℹ Fix +7 7 | _description_ +8 8 | b : int +9 9 | _description_ + 10 |+ +10 11 | Returns +11 12 | ------- +12 13 | int + +D410.py:19:5: D410 [*] Missing blank line after section ("Parameters") + | +18 | def f() -> int: +19 | """Showcase function. + | _____^ +20 | | +21 | | Parameters +22 | | ---------- +23 | | Returns +24 | | ------- +25 | | """ + | |_______^ D410 + | + = help: Add blank line after "Parameters" + +ℹ Fix +20 20 | +21 21 | Parameters +22 22 | ---------- + 23 |+ +23 24 | Returns +24 25 | ------- +25 26 | """ + + 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 new file mode 100644 index 0000000000..9a3f97dfb3 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D410_sections.py.snap @@ -0,0 +1,67 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +sections.py:76:5: D410 [*] Missing blank line after section ("Returns") + | +74 | @expect("D414: Section has no content ('Yields')") +75 | def consecutive_sections(): # noqa: D416 +76 | """Toggle the gizmo. + | _____^ +77 | | +78 | | Returns +79 | | ------- +80 | | Yields +81 | | ------ +82 | | +83 | | Raises +84 | | ------ +85 | | Questions. +86 | | +87 | | """ + | |_______^ D410 + | + = help: Add blank line after "Returns" + +ℹ Fix +77 77 | +78 78 | Returns +79 79 | ------- + 80 |+ +80 81 | Yields +81 82 | ------ +82 83 | + +sections.py:216:5: D410 [*] Missing blank line after section ("Returns") + | +214 | @expect("D407: Missing dashed underline after section ('Raises')") +215 | def multiple_sections(): # noqa: D416 +216 | """Toggle the gizmo. + | _____^ +217 | | +218 | | Short summary +219 | | ------------- +220 | | +221 | | This is the function's description, which will also specify what it +222 | | returns. +223 | | +224 | | Returns +225 | | ------ +226 | | Many many wonderful things. +227 | | Raises: +228 | | My attention. +229 | | +230 | | """ + | |_______^ D410 + | + = help: Add blank line after "Returns" + +ℹ Fix +224 224 | Returns +225 225 | ------ +226 226 | Many many wonderful things. + 227 |+ +227 228 | Raises: +228 229 | My attention. +229 230 | + + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D411_sections.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D411_sections.py.snap new file mode 100644 index 0000000000..df08719209 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D411_sections.py.snap @@ -0,0 +1,93 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +sections.py:76:5: D411 [*] Missing blank line before section ("Yields") + | +74 | @expect("D414: Section has no content ('Yields')") +75 | def consecutive_sections(): # noqa: D416 +76 | """Toggle the gizmo. + | _____^ +77 | | +78 | | Returns +79 | | ------- +80 | | Yields +81 | | ------ +82 | | +83 | | Raises +84 | | ------ +85 | | Questions. +86 | | +87 | | """ + | |_______^ D411 + | + = help: Add blank line before "Yields" + +ℹ Fix +77 77 | +78 78 | Returns +79 79 | ------- + 80 |+ +80 81 | Yields +81 82 | ------ +82 83 | + +sections.py:131:5: D411 [*] Missing blank line before section ("Returns") + | +129 | @expect("D411: Missing blank line before section ('Returns')") +130 | def no_blank_line_before_section(): # noqa: D416 +131 | """Toggle the gizmo. + | _____^ +132 | | +133 | | The function's description. +134 | | Returns +135 | | ------- +136 | | A value of some sort. +137 | | +138 | | """ + | |_______^ D411 + | + = help: Add blank line before "Returns" + +ℹ Fix +131 131 | """Toggle the gizmo. +132 132 | +133 133 | The function's description. + 134 |+ +134 135 | Returns +135 136 | ------- +136 137 | A value of some sort. + +sections.py:216:5: D411 [*] Missing blank line before section ("Raises") + | +214 | @expect("D407: Missing dashed underline after section ('Raises')") +215 | def multiple_sections(): # noqa: D416 +216 | """Toggle the gizmo. + | _____^ +217 | | +218 | | Short summary +219 | | ------------- +220 | | +221 | | This is the function's description, which will also specify what it +222 | | returns. +223 | | +224 | | Returns +225 | | ------ +226 | | Many many wonderful things. +227 | | Raises: +228 | | My attention. +229 | | +230 | | """ + | |_______^ D411 + | + = help: Add blank line before "Raises" + +ℹ Fix +224 224 | Returns +225 225 | ------ +226 226 | Many many wonderful things. + 227 |+ +227 228 | Raises: +228 229 | My attention. +229 230 | + + 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 new file mode 100644 index 0000000000..6490ca9318 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D412_sections.py.snap @@ -0,0 +1,37 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +sections.py:216:5: D412 [*] No blank lines allowed between a section header and its content ("Short summary") + | +214 | @expect("D407: Missing dashed underline after section ('Raises')") +215 | def multiple_sections(): # noqa: D416 +216 | """Toggle the gizmo. + | _____^ +217 | | +218 | | Short summary +219 | | ------------- +220 | | +221 | | This is the function's description, which will also specify what it +222 | | returns. +223 | | +224 | | Returns +225 | | ------ +226 | | Many many wonderful things. +227 | | Raises: +228 | | My attention. +229 | | +230 | | """ + | |_______^ D412 + | + = help: Remove blank line(s) + +ℹ Fix +217 217 | +218 218 | Short summary +219 219 | ------------- +220 |- +221 220 | This is the function's description, which will also specify what it +222 221 | returns. +223 222 | + + 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 new file mode 100644 index 0000000000..2fa38b08c3 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D413_sections.py.snap @@ -0,0 +1,27 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +sections.py:65:5: D413 [*] Missing blank line after last section ("Returns") + | +63 | @expect("D414: Section has no content ('Returns')") +64 | def no_underline_and_no_newline(): # noqa: D416 +65 | """Toggle the gizmo. + | _____^ +66 | | +67 | | Returns""" + | |______________^ D413 + | + = help: Add blank line after "Returns" + +ℹ Fix +64 64 | def no_underline_and_no_newline(): # noqa: D416 +65 65 | """Toggle the gizmo. +66 66 | +67 |- Returns""" + 67 |+ Returns + 68 |+ """ +68 69 | +69 70 | +70 71 | @expect(_D213) + + 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 new file mode 100644 index 0000000000..26302131bd --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D414_sections.py.snap @@ -0,0 +1,100 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +sections.py:54:5: D414 Section has no content ("Returns") + | +52 | @expect("D414: Section has no content ('Returns')") +53 | def no_underline_and_no_description(): # noqa: D416 +54 | """Toggle the gizmo. + | _____^ +55 | | +56 | | Returns +57 | | +58 | | """ + | |_______^ D414 + | + +sections.py:65:5: D414 Section has no content ("Returns") + | +63 | @expect("D414: Section has no content ('Returns')") +64 | def no_underline_and_no_newline(): # noqa: D416 +65 | """Toggle the gizmo. + | _____^ +66 | | +67 | | Returns""" + | |______________^ D414 + | + +sections.py:76:5: D414 Section has no content ("Returns") + | +74 | @expect("D414: Section has no content ('Yields')") +75 | def consecutive_sections(): # noqa: D416 +76 | """Toggle the gizmo. + | _____^ +77 | | +78 | | Returns +79 | | ------- +80 | | Yields +81 | | ------ +82 | | +83 | | Raises +84 | | ------ +85 | | Questions. +86 | | +87 | | """ + | |_______^ D414 + | + +sections.py:76:5: D414 Section has no content ("Yields") + | +74 | @expect("D414: Section has no content ('Yields')") +75 | def consecutive_sections(): # noqa: D416 +76 | """Toggle the gizmo. + | _____^ +77 | | +78 | | Returns +79 | | ------- +80 | | Yields +81 | | ------ +82 | | +83 | | Raises +84 | | ------ +85 | | Questions. +86 | | +87 | | """ + | |_______^ D414 + | + +sections.py:170:5: D414 Section has no content ("Returns") + | +168 | @expect("D414: Section has no content ('Returns')") +169 | def section_underline_overindented_and_contentless(): # noqa: D416 +170 | """Toggle the gizmo. + | _____^ +171 | | +172 | | Returns +173 | | ------- +174 | | """ + | |_______^ D414 + | + +sections.py:261:5: D414 Section has no content ("Returns") + | +259 | @expect("D414: Section has no content ('Returns')") +260 | def valid_google_style_section(): # noqa: D406, D407 +261 | """Toggle the gizmo. + | _____^ +262 | | +263 | | Args: +264 | | note: A random string. +265 | | +266 | | Returns: +267 | | +268 | | Raises: +269 | | RandomError: A random error that occurs randomly. +270 | | +271 | | """ + | |_______^ D414 + | + + 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 new file mode 100644 index 0000000000..3bdc949e58 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D415_D.py.snap @@ -0,0 +1,312 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:355:5: D415 [*] First line should end with a period, question mark, or exclamation point + | +353 | "or exclamation point (not 'y')") +354 | def lwnlkjl(): +355 | """Summary""" + | ^^^^^^^^^^^^^ D415 + | + = help: Add closing punctuation + +ℹ Suggested fix +352 352 | @expect("D415: First line should end with a period, question mark, " +353 353 | "or exclamation point (not 'y')") +354 354 | def lwnlkjl(): +355 |- """Summary""" + 355 |+ """Summary.""" +356 356 | +357 357 | +358 358 | @expect("D401: First line should be in imperative mood " + +D.py:406:25: D415 [*] First line should end with a period, question mark, or exclamation point + | +404 | @expect("D415: First line should end with a period, question mark," +405 | " or exclamation point (not 'r')") +406 | def oneliner_withdoc(): """One liner""" + | ^^^^^^^^^^^^^^^ D415 + | + = help: Add closing punctuation + +ℹ Suggested fix +403 403 | @expect("D400: First line should end with a period (not 'r')") +404 404 | @expect("D415: First line should end with a period, question mark," +405 405 | " or exclamation point (not 'r')") +406 |-def oneliner_withdoc(): """One liner""" + 406 |+def oneliner_withdoc(): """One liner.""" +407 407 | +408 408 | +409 409 | def ignored_decorator(func): # noqa: D400,D401,D415 + +D.py:410:5: D415 [*] First line should end with a period, question mark, or exclamation point + | +409 | def ignored_decorator(func): # noqa: D400,D401,D415 +410 | """Runs something""" + | ^^^^^^^^^^^^^^^^^^^^ D415 +411 | func() +412 | pass + | + = help: Add closing punctuation + +ℹ Suggested fix +407 407 | +408 408 | +409 409 | def ignored_decorator(func): # noqa: D400,D401,D415 +410 |- """Runs something""" + 410 |+ """Runs something.""" +411 411 | func() +412 412 | pass +413 413 | + +D.py:416:5: D415 [*] First line should end with a period, question mark, or exclamation point + | +415 | def decorator_for_test(func): # noqa: D400,D401,D415 +416 | """Runs something""" + | ^^^^^^^^^^^^^^^^^^^^ D415 +417 | func() +418 | pass + | + = help: Add closing punctuation + +ℹ Suggested fix +413 413 | +414 414 | +415 415 | def decorator_for_test(func): # noqa: D400,D401,D415 +416 |- """Runs something""" + 416 |+ """Runs something.""" +417 417 | func() +418 418 | pass +419 419 | + +D.py:422:35: D415 [*] First line should end with a period, question mark, or exclamation point + | +421 | @ignored_decorator +422 | def oneliner_ignored_decorator(): """One liner""" + | ^^^^^^^^^^^^^^^ D415 + | + = help: Add closing punctuation + +ℹ Suggested fix +419 419 | +420 420 | +421 421 | @ignored_decorator +422 |-def oneliner_ignored_decorator(): """One liner""" + 422 |+def oneliner_ignored_decorator(): """One liner.""" +423 423 | +424 424 | +425 425 | @decorator_for_test + +D.py:429:49: D415 [*] First line should end with a period, question mark, or exclamation point + | +427 | @expect("D415: First line should end with a period, question mark," +428 | " or exclamation point (not 'r')") +429 | def oneliner_with_decorator_expecting_errors(): """One liner""" + | ^^^^^^^^^^^^^^^ D415 + | + = help: Add closing punctuation + +ℹ Suggested fix +426 426 | @expect("D400: First line should end with a period (not 'r')") +427 427 | @expect("D415: First line should end with a period, question mark," +428 428 | " or exclamation point (not 'r')") +429 |-def oneliner_with_decorator_expecting_errors(): """One liner""" + 429 |+def oneliner_with_decorator_expecting_errors(): """One liner.""" +430 430 | +431 431 | +432 432 | @decorator_for_test + +D.py:470:5: D415 [*] First line should end with a period, question mark, or exclamation point + | +468 | "or exclamation point (not 'g')") +469 | def docstring_bad(): +470 | """Runs something""" + | ^^^^^^^^^^^^^^^^^^^^ D415 +471 | pass + | + = help: Add closing punctuation + +ℹ Suggested fix +467 467 | @expect("D415: First line should end with a period, question mark, " +468 468 | "or exclamation point (not 'g')") +469 469 | def docstring_bad(): +470 |- """Runs something""" + 470 |+ """Runs something.""" +471 471 | pass +472 472 | +473 473 | + +D.py:475:5: D415 [*] First line should end with a period, question mark, or exclamation point + | +474 | def docstring_bad_ignore_all(): # noqa +475 | """Runs something""" + | ^^^^^^^^^^^^^^^^^^^^ D415 +476 | pass + | + = help: Add closing punctuation + +ℹ Suggested fix +472 472 | +473 473 | +474 474 | def docstring_bad_ignore_all(): # noqa +475 |- """Runs something""" + 475 |+ """Runs something.""" +476 476 | pass +477 477 | +478 478 | + +D.py:480:5: D415 [*] First line should end with a period, question mark, or exclamation point + | +479 | def docstring_bad_ignore_one(): # noqa: D400,D401,D415 +480 | """Runs something""" + | ^^^^^^^^^^^^^^^^^^^^ D415 +481 | pass + | + = help: Add closing punctuation + +ℹ Suggested fix +477 477 | +478 478 | +479 479 | def docstring_bad_ignore_one(): # noqa: D400,D401,D415 +480 |- """Runs something""" + 480 |+ """Runs something.""" +481 481 | pass +482 482 | +483 483 | + +D.py:487:5: D415 [*] First line should end with a period, question mark, or exclamation point + | +485 | "(perhaps 'Run', not 'Runs')") +486 | def docstring_ignore_some_violations_but_catch_D401(): # noqa: E501,D400,D415 +487 | """Runs something""" + | ^^^^^^^^^^^^^^^^^^^^ D415 +488 | pass + | + = help: Add closing punctuation + +ℹ Suggested fix +484 484 | @expect("D401: First line should be in imperative mood " +485 485 | "(perhaps 'Run', not 'Runs')") +486 486 | def docstring_ignore_some_violations_but_catch_D401(): # noqa: E501,D400,D415 +487 |- """Runs something""" + 487 |+ """Runs something.""" +488 488 | pass +489 489 | +490 490 | + +D.py:520:5: D415 [*] First line should end with a period, question mark, or exclamation point + | +518 | "or exclamation point (not 'g')") +519 | def bad_google_string(): # noqa: D400 +520 | """Test a valid something""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D415 + | + = help: Add closing punctuation + +ℹ Suggested fix +517 517 | @expect("D415: First line should end with a period, question mark, " +518 518 | "or exclamation point (not 'g')") +519 519 | def bad_google_string(): # noqa: D400 +520 |- """Test a valid something""" + 520 |+ """Test a valid something.""" +521 521 | +522 522 | +523 523 | # This is reproducing a bug where AttributeError is raised when parsing class + +D.py:581:5: D415 [*] First line should end with a period, question mark, or exclamation point + | +579 | "or exclamation point (not '\"')") +580 | def endswith_quote(): +581 | """Whitespace at the end, but also a quote" """ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D415 + | + = help: Add closing punctuation + +ℹ Suggested fix +578 578 | @expect("D415: First line should end with a period, question mark, " +579 579 | "or exclamation point (not '\"')") +580 580 | def endswith_quote(): +581 |- """Whitespace at the end, but also a quote" """ + 581 |+ """Whitespace at the end, but also a quote". """ +582 582 | +583 583 | +584 584 | @expect('D209: Multi-line docstring closing quotes should be on a separate ' + +D.py:615:5: D415 [*] First line should end with a period, question mark, or exclamation point + | +613 | @expect('D212: Multi-line docstring summary should start at the first line') +614 | def one_liner(): +615 | """Wrong." + | _____^ +616 | | +617 | | """ + | |_______^ D415 + | + = help: Add closing punctuation + +ℹ Suggested fix +612 612 | '(found 3)') +613 613 | @expect('D212: Multi-line docstring summary should start at the first line') +614 614 | def one_liner(): +615 |- """Wrong." + 615 |+ """Wrong.". +616 616 | +617 617 | """ +618 618 | + +D.py:639:17: D415 [*] First line should end with a period, question mark, or exclamation point + | +639 | class SameLine: """This is a docstring on the same line""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D415 +640 | +641 | def same_line(): """This is a docstring on the same line""" + | + = help: Add closing punctuation + +ℹ Suggested fix +636 636 | """ This is a docstring that starts with a space.""" # noqa: D210 +637 637 | +638 638 | +639 |-class SameLine: """This is a docstring on the same line""" + 639 |+class SameLine: """This is a docstring on the same line.""" +640 640 | +641 641 | def same_line(): """This is a docstring on the same line""" +642 642 | + +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 | +641 | def same_line(): """This is a docstring on the same line""" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D415 + | + = help: Add closing punctuation + +ℹ Suggested fix +638 638 | +639 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""" + 641 |+def same_line(): """This is a docstring on the same line.""" +642 642 | +643 643 | +644 644 | def single_line_docstring_with_an_escaped_backslash(): + +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 \ + | _____^ +665 | | but continuations shouldn't be considered multi-line" + | |_________________________________________________________^ D415 + | + = help: Add closing punctuation + +ℹ Suggested fix +662 662 | +663 663 | def newline_after_closing_quote(self): +664 664 | "We enforce a newline after the closing quote for a multi-line docstring \ +665 |- but continuations shouldn't be considered multi-line" + 665 |+ but continuations shouldn't be considered multi-line." + + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D416_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D416_D.py.snap new file mode 100644 index 0000000000..724d6e7d20 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D416_D.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D417_canonical_google_examples.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D417_canonical_google_examples.py.snap new file mode 100644 index 0000000000..724d6e7d20 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D417_canonical_google_examples.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D417_canonical_numpy_examples.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D417_canonical_numpy_examples.py.snap new file mode 100644 index 0000000000..724d6e7d20 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D417_canonical_numpy_examples.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- + 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 new file mode 100644 index 0000000000..1ea3024585 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D417_sections.py.snap @@ -0,0 +1,103 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +sections.py:292:9: D417 Missing argument description in the docstring for `bar`: `y` + | +290 | x = 1 +291 | +292 | def bar(y=2): # noqa: D207, D213, D406, D407 + | ^^^ D417 +293 | """Nested function test for docstrings. + | + +sections.py:309:5: D417 Missing argument description in the docstring for `test_missing_google_args`: `y` + | +307 | "(argument(s) y are missing descriptions in " +308 | "'test_missing_google_args' docstring)") +309 | def test_missing_google_args(x=1, y=2, _private=3): # noqa: D406, D407 + | ^^^^^^^^^^^^^^^^^^^^^^^^ D417 +310 | """Toggle the gizmo. + | + +sections.py:333:9: D417 Missing argument descriptions in the docstring for `test_missing_args`: `test`, `y`, `z` + | +331 | "(argument(s) test, y, z are missing descriptions in " +332 | "'test_missing_args' docstring)", arg_count=5) +333 | def test_missing_args(self, test, x, y, z=3, _private_arg=3): # noqa: D213, D407 + | ^^^^^^^^^^^^^^^^^ D417 +334 | """Test a valid args section. + | + +sections.py:345:9: D417 Missing argument descriptions in the docstring for `test_missing_args_class_method`: `test`, `y`, `z` + | +343 | "(argument(s) test, y, z are missing descriptions in " +344 | "'test_missing_args_class_method' docstring)", arg_count=5) +345 | def test_missing_args_class_method(cls, test, x, y, _, z=3): # noqa: D213, D407 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D417 +346 | """Test a valid args section. + | + +sections.py:358:9: D417 Missing argument descriptions in the docstring for `test_missing_args_static_method`: `a`, `y`, `z` + | +356 | "(argument(s) a, y, z are missing descriptions in " +357 | "'test_missing_args_static_method' docstring)", arg_count=4) +358 | def test_missing_args_static_method(a, x, y, _test, z=3): # noqa: D213, D407 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D417 +359 | """Test a valid args section. + | + +sections.py:370:9: D417 Missing argument descriptions in the docstring for `test_missing_docstring`: `a`, `b` + | +368 | "(argument(s) a, b are missing descriptions in " +369 | "'test_missing_docstring' docstring)", arg_count=2) +370 | def test_missing_docstring(a, b): # noqa: D213, D407 + | ^^^^^^^^^^^^^^^^^^^^^^ D417 +371 | """Test a valid args section. + | + +sections.py:398:5: D417 Missing argument description in the docstring for `test_missing_numpy_args`: `y` + | +396 | "(argument(s) y are missing descriptions in " +397 | "'test_missing_numpy_args' docstring)") +398 | def test_missing_numpy_args(_private_arg=0, x=1, y=2): # noqa: D406, D407 + | ^^^^^^^^^^^^^^^^^^^^^^^ D417 +399 | """Toggle the gizmo. + | + +sections.py:434:9: D417 Missing argument descriptions in the docstring for `test_missing_args`: `test`, `y`, `z` + | +432 | "(argument(s) test, y, z are missing descriptions in " +433 | "'test_missing_args' docstring)", arg_count=5) +434 | def test_missing_args(self, test, x, y, z=3, t=1, _private=0): # noqa: D213, D407 + | ^^^^^^^^^^^^^^^^^ D417 +435 | """Test a valid args section. + | + +sections.py:449:9: D417 Missing argument descriptions in the docstring for `test_missing_args_class_method`: `test`, `y`, `z` + | +447 | "(argument(s) test, y, z are missing descriptions in " +448 | "'test_missing_args_class_method' docstring)", arg_count=4) +449 | def test_missing_args_class_method(cls, test, x, y, z=3): # noqa: D213, D407 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D417 +450 | """Test a valid args section. + | + +sections.py:468:9: D417 Missing argument descriptions in the docstring for `test_missing_args_static_method`: `a`, `z` + | +466 | "(argument(s) a, z are missing descriptions in " +467 | "'test_missing_args_static_method' docstring)", arg_count=3) +468 | def test_missing_args_static_method(a, x, y, z=3, t=1): # noqa: D213, D407 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D417 +469 | """Test a valid args section. + | + +sections.py:498:9: D417 Missing argument description in the docstring for `test_incorrect_indent`: `y` + | +496 | "(argument(s) y are missing descriptions in " +497 | "'test_incorrect_indent' docstring)", arg_count=3) +498 | def test_incorrect_indent(self, x=1, y=2): # noqa: D207, D213, D407 + | ^^^^^^^^^^^^^^^^^^^^^ D417 +499 | """Reproducing issue #437. + | + + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D418_D.py.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D418_D.py.snap new file mode 100644 index 0000000000..984c3d6a0f --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D418_D.py.snap @@ -0,0 +1,31 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:34:9: D418 Function decorated with `@overload` shouldn't contain a docstring + | +33 | @overload +34 | def overloaded_method(self, a: str) -> str: + | ^^^^^^^^^^^^^^^^^ D418 +35 | """Foo bar documentation.""" +36 | ... + | + +D.py:90:9: D418 Function decorated with `@overload` shouldn't contain a docstring + | +89 | @overload +90 | def nested_overloaded_func(a: str) -> str: + | ^^^^^^^^^^^^^^^^^^^^^^ D418 +91 | """Foo bar documentation.""" +92 | ... + | + +D.py:110:5: D418 Function decorated with `@overload` shouldn't contain a docstring + | +109 | @overload +110 | def overloaded_func(a: str) -> str: + | ^^^^^^^^^^^^^^^ D418 +111 | """Foo bar documentation.""" +112 | ... + | + + 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 new file mode 100644 index 0000000000..0a2310b792 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__D419_D.py.snap @@ -0,0 +1,31 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D.py:20:9: D419 Docstring is empty + | +19 | class meta: +20 | """""" + | ^^^^^^ D419 +21 | +22 | @expect('D102: Missing docstring in public method') + | + +D.py:74:5: D419 Docstring is empty + | +72 | @expect('D419: Docstring is empty') +73 | def function(): +74 | """ """ + | ^^^^^^^ D419 +75 | def ok_since_nested(): +76 | pass + | + +D.py:80:9: D419 Docstring is empty + | +78 | @expect('D419: Docstring is empty') +79 | def nested(): +80 | '' + | ^^ D419 + | + + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__all.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__all.snap new file mode 100644 index 0000000000..6aad9dcce6 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__all.snap @@ -0,0 +1,34 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +all.py:1:1: D100 Missing docstring in public module + | +1 | def public_func(): + | D100 +2 | pass + | + +all.py:1:5: D103 Missing docstring in public function + | +1 | def public_func(): + | ^^^^^^^^^^^ D103 +2 | pass + | + +all.py:9:7: D101 Missing docstring in public class + | + 9 | class PublicClass: + | ^^^^^^^^^^^ D101 +10 | class PublicNestedClass: +11 | pass + | + +all.py:10:11: D106 Missing docstring in public nested class + | + 9 | class PublicClass: +10 | class PublicNestedClass: + | ^^^^^^^^^^^^^^^^^ D106 +11 | pass + | + + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__bom.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__bom.snap new file mode 100644 index 0000000000..1c7757d4b4 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__bom.snap @@ -0,0 +1,10 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +bom.py:1:1: D300 Use triple double quotes `"""` + | +1 | ''' SAM macro definitions ''' + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D300 + | + + 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 new file mode 100644 index 0000000000..17a4753d2b --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d209_d400.snap @@ -0,0 +1,37 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +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 + | _____^ +3 | | sed do eiusmod tempor incididunt ut labore et dolore magna aliqua""" + | |________________________________________________________________________^ D209 + | + = help: Move closing quotes to new line + +ℹ Fix +1 1 | def lorem(): +2 2 | """lorem ipsum dolor sit amet consectetur adipiscing elit +3 |- sed do eiusmod tempor incididunt ut labore et dolore magna aliqua""" + 3 |+ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua + 4 |+ """ + +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 + | _____^ +3 | | sed do eiusmod tempor incididunt ut labore et dolore magna aliqua""" + | |________________________________________________________________________^ D400 + | + = help: Add period + +ℹ Suggested fix +1 1 | def lorem(): +2 2 | """lorem ipsum dolor sit amet consectetur adipiscing elit +3 |- sed do eiusmod tempor incididunt ut labore et dolore magna aliqua""" + 3 |+ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.""" + + 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 new file mode 100644 index 0000000000..641662a53b --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_google.snap @@ -0,0 +1,67 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D417.py:1:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + | +1 | def f(x, y, z): + | ^ D417 +2 | """Do something. + | + +D417.py:14:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + | +14 | def f(x, y, z): + | ^ D417 +15 | """Do something. + | + +D417.py:27:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + | +27 | def f(x, y, z): + | ^ D417 +28 | """Do something. + | + +D417.py:39:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + | +39 | def f(x, y, z): + | ^ D417 +40 | """Do something. + | + +D417.py:52:5: D417 Missing argument description in the docstring for `f`: `y` + | +52 | def f(x, y, z): + | ^ D417 +53 | """Do something. + | + +D417.py:65:5: D417 Missing argument description in the docstring for `f`: `y` + | +65 | def f(x, y, z): + | ^ D417 +66 | """Do something. + | + +D417.py:77:5: D417 Missing argument description in the docstring for `f`: `y` + | +77 | def f(x, y, z): + | ^ D417 +78 | """Do something. + | + +D417.py:98:5: D417 Missing argument description in the docstring for `f`: `x` + | +98 | def f(x, *args, **kwargs): + | ^ D417 +99 | """Do something. + | + +D417.py:108:5: D417 Missing argument description in the docstring for `f`: `*args` + | +108 | def f(x, *args, **kwargs): + | ^ D417 +109 | """Do something. + | + + diff --git a/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_numpy.snap b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_numpy.snap new file mode 100644 index 0000000000..724d6e7d20 --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_numpy.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- + 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 new file mode 100644 index 0000000000..641662a53b --- /dev/null +++ b/crates/ruff_linter/src/rules/pydocstyle/snapshots/ruff_linter__rules__pydocstyle__tests__d417_unspecified.snap @@ -0,0 +1,67 @@ +--- +source: crates/ruff_linter/src/rules/pydocstyle/mod.rs +--- +D417.py:1:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + | +1 | def f(x, y, z): + | ^ D417 +2 | """Do something. + | + +D417.py:14:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + | +14 | def f(x, y, z): + | ^ D417 +15 | """Do something. + | + +D417.py:27:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + | +27 | def f(x, y, z): + | ^ D417 +28 | """Do something. + | + +D417.py:39:5: D417 Missing argument descriptions in the docstring for `f`: `y`, `z` + | +39 | def f(x, y, z): + | ^ D417 +40 | """Do something. + | + +D417.py:52:5: D417 Missing argument description in the docstring for `f`: `y` + | +52 | def f(x, y, z): + | ^ D417 +53 | """Do something. + | + +D417.py:65:5: D417 Missing argument description in the docstring for `f`: `y` + | +65 | def f(x, y, z): + | ^ D417 +66 | """Do something. + | + +D417.py:77:5: D417 Missing argument description in the docstring for `f`: `y` + | +77 | def f(x, y, z): + | ^ D417 +78 | """Do something. + | + +D417.py:98:5: D417 Missing argument description in the docstring for `f`: `x` + | +98 | def f(x, *args, **kwargs): + | ^ D417 +99 | """Do something. + | + +D417.py:108:5: D417 Missing argument description in the docstring for `f`: `*args` + | +108 | def f(x, *args, **kwargs): + | ^ D417 +109 | """Do something. + | + + diff --git a/crates/ruff/src/rules/pyflakes/cformat.rs b/crates/ruff_linter/src/rules/pyflakes/cformat.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/cformat.rs rename to crates/ruff_linter/src/rules/pyflakes/cformat.rs diff --git a/crates/ruff/src/rules/pyflakes/fixes.rs b/crates/ruff_linter/src/rules/pyflakes/fixes.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/fixes.rs rename to crates/ruff_linter/src/rules/pyflakes/fixes.rs diff --git a/crates/ruff/src/rules/pyflakes/format.rs b/crates/ruff_linter/src/rules/pyflakes/format.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/format.rs rename to crates/ruff_linter/src/rules/pyflakes/format.rs diff --git a/crates/ruff/src/rules/pyflakes/mod.rs b/crates/ruff_linter/src/rules/pyflakes/mod.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/mod.rs rename to crates/ruff_linter/src/rules/pyflakes/mod.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/assert_tuple.rs b/crates/ruff_linter/src/rules/pyflakes/rules/assert_tuple.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/assert_tuple.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/assert_tuple.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/break_outside_loop.rs b/crates/ruff_linter/src/rules/pyflakes/rules/break_outside_loop.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/break_outside_loop.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/break_outside_loop.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/continue_outside_loop.rs b/crates/ruff_linter/src/rules/pyflakes/rules/continue_outside_loop.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/continue_outside_loop.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/continue_outside_loop.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/default_except_not_last.rs b/crates/ruff_linter/src/rules/pyflakes/rules/default_except_not_last.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/default_except_not_last.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/default_except_not_last.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/f_string_missing_placeholders.rs b/crates/ruff_linter/src/rules/pyflakes/rules/f_string_missing_placeholders.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/f_string_missing_placeholders.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/f_string_missing_placeholders.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/forward_annotation_syntax_error.rs b/crates/ruff_linter/src/rules/pyflakes/rules/forward_annotation_syntax_error.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/forward_annotation_syntax_error.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/forward_annotation_syntax_error.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/future_feature_not_defined.rs b/crates/ruff_linter/src/rules/pyflakes/rules/future_feature_not_defined.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/future_feature_not_defined.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/future_feature_not_defined.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/if_tuple.rs b/crates/ruff_linter/src/rules/pyflakes/rules/if_tuple.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/if_tuple.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/if_tuple.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/imports.rs b/crates/ruff_linter/src/rules/pyflakes/rules/imports.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/imports.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/imports.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/invalid_literal_comparisons.rs b/crates/ruff_linter/src/rules/pyflakes/rules/invalid_literal_comparisons.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/invalid_literal_comparisons.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/invalid_literal_comparisons.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/invalid_print_syntax.rs b/crates/ruff_linter/src/rules/pyflakes/rules/invalid_print_syntax.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/invalid_print_syntax.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/invalid_print_syntax.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/mod.rs b/crates/ruff_linter/src/rules/pyflakes/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/mod.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/mod.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/raise_not_implemented.rs b/crates/ruff_linter/src/rules/pyflakes/rules/raise_not_implemented.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/raise_not_implemented.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/raise_not_implemented.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/redefined_while_unused.rs b/crates/ruff_linter/src/rules/pyflakes/rules/redefined_while_unused.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/redefined_while_unused.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/redefined_while_unused.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/repeated_keys.rs b/crates/ruff_linter/src/rules/pyflakes/rules/repeated_keys.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/repeated_keys.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/repeated_keys.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/return_outside_function.rs b/crates/ruff_linter/src/rules/pyflakes/rules/return_outside_function.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/return_outside_function.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/return_outside_function.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/starred_expressions.rs b/crates/ruff_linter/src/rules/pyflakes/rules/starred_expressions.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/starred_expressions.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/starred_expressions.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/strings.rs b/crates/ruff_linter/src/rules/pyflakes/rules/strings.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/strings.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/strings.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/undefined_export.rs b/crates/ruff_linter/src/rules/pyflakes/rules/undefined_export.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/undefined_export.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/undefined_export.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/undefined_local.rs b/crates/ruff_linter/src/rules/pyflakes/rules/undefined_local.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/undefined_local.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/undefined_local.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/undefined_name.rs b/crates/ruff_linter/src/rules/pyflakes/rules/undefined_name.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/undefined_name.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/undefined_name.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/unused_annotation.rs b/crates/ruff_linter/src/rules/pyflakes/rules/unused_annotation.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/unused_annotation.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/unused_annotation.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/unused_import.rs b/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/unused_import.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/unused_variable.rs b/crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/unused_variable.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs diff --git a/crates/ruff/src/rules/pyflakes/rules/yield_outside_function.rs b/crates/ruff_linter/src/rules/pyflakes/rules/yield_outside_function.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/rules/yield_outside_function.rs rename to crates/ruff_linter/src/rules/pyflakes/rules/yield_outside_function.rs diff --git a/crates/ruff/src/rules/pyflakes/settings.rs b/crates/ruff_linter/src/rules/pyflakes/settings.rs similarity index 100% rename from crates/ruff/src/rules/pyflakes/settings.rs rename to crates/ruff_linter/src/rules/pyflakes/settings.rs 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 new file mode 100644 index 0000000000..cd39f357df --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_0.py.snap @@ -0,0 +1,286 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F401_0.py:2:8: F401 [*] `functools` imported but unused + | +1 | from __future__ import all_feature_names +2 | import functools, os + | ^^^^^^^^^ F401 +3 | from datetime import datetime +4 | from collections import ( + | + = help: Remove unused import: `functools` + +ℹ Fix +1 1 | from __future__ import all_feature_names +2 |-import functools, os + 2 |+import os +3 3 | from datetime import datetime +4 4 | from collections import ( +5 5 | Counter, + +F401_0.py:6:5: F401 [*] `collections.OrderedDict` imported but unused + | +4 | from collections import ( +5 | Counter, +6 | OrderedDict, + | ^^^^^^^^^^^ F401 +7 | namedtuple, +8 | ) + | + = help: Remove unused import: `collections.OrderedDict` + +ℹ Fix +3 3 | from datetime import datetime +4 4 | from collections import ( +5 5 | Counter, +6 |- OrderedDict, +7 6 | namedtuple, +8 7 | ) +9 8 | import multiprocessing.pool + +F401_0.py:12:8: F401 [*] `logging.handlers` imported but unused + | +10 | import multiprocessing.process +11 | import logging.config +12 | import logging.handlers + | ^^^^^^^^^^^^^^^^ F401 +13 | from typing import ( +14 | TYPE_CHECKING, + | + = help: Remove unused import: `logging.handlers` + +ℹ Fix +9 9 | import multiprocessing.pool +10 10 | import multiprocessing.process +11 11 | import logging.config +12 |-import logging.handlers +13 12 | from typing import ( +14 13 | TYPE_CHECKING, +15 14 | NamedTuple, + +F401_0.py:32:12: F401 [*] `shelve` imported but unused + | +31 | if TYPE_CHECKING: +32 | import shelve + | ^^^^^^ F401 +33 | import importlib + | + = help: Remove unused import: `shelve` + +ℹ Fix +29 29 | from models import Fruit, Nut, Vegetable +30 30 | +31 31 | if TYPE_CHECKING: +32 |- import shelve +33 32 | import importlib +34 33 | +35 34 | if TYPE_CHECKING: + +F401_0.py:33:12: F401 [*] `importlib` imported but unused + | +31 | if TYPE_CHECKING: +32 | import shelve +33 | import importlib + | ^^^^^^^^^ F401 +34 | +35 | if TYPE_CHECKING: + | + = help: Remove unused import: `importlib` + +ℹ Fix +30 30 | +31 31 | if TYPE_CHECKING: +32 32 | import shelve +33 |- import importlib +34 33 | +35 34 | if TYPE_CHECKING: +36 35 | """Hello, world!""" + +F401_0.py:37:12: F401 [*] `pathlib` imported but unused + | +35 | if TYPE_CHECKING: +36 | """Hello, world!""" +37 | import pathlib + | ^^^^^^^ F401 +38 | +39 | z = 1 + | + = help: Remove unused import: `pathlib` + +ℹ Fix +34 34 | +35 35 | if TYPE_CHECKING: +36 36 | """Hello, world!""" +37 |- import pathlib +38 37 | +39 38 | z = 1 +40 39 | + +F401_0.py:52:16: F401 [*] `pickle` imported but unused + | +51 | def b(self) -> None: +52 | import pickle + | ^^^^^^ F401 + | + = help: Remove unused import: `pickle` + +ℹ Fix +49 49 | z = multiprocessing.pool.ThreadPool() +50 50 | +51 51 | def b(self) -> None: +52 |- import pickle + 52 |+ pass +53 53 | +54 54 | +55 55 | __all__ = ["ClassA"] + ["ClassB"] + +F401_0.py:93:16: F401 [*] `x` imported but unused + | +91 | match *0, 1, *2: +92 | case 0,: +93 | import x + | ^ F401 +94 | import y + | + = help: Remove unused import: `x` + +ℹ Fix +90 90 | # Test: match statements. +91 91 | match *0, 1, *2: +92 92 | case 0,: +93 |- import x +94 93 | import y +95 94 | +96 95 | + +F401_0.py:94:16: F401 [*] `y` imported but unused + | +92 | case 0,: +93 | import x +94 | import y + | ^ F401 + | + = help: Remove unused import: `y` + +ℹ Fix +91 91 | match *0, 1, *2: +92 92 | case 0,: +93 93 | import x +94 |- import y +95 94 | +96 95 | +97 96 | # Test: access a sub-importation via an alias. + +F401_0.py:99:8: F401 [*] `foo.bar.baz` imported but unused + | + 97 | # Test: access a sub-importation via an alias. + 98 | import foo.bar as bop + 99 | import foo.bar.baz + | ^^^^^^^^^^^ F401 +100 | +101 | print(bop.baz.read_csv("test.csv")) + | + = help: Remove unused import: `foo.bar.baz` + +ℹ Fix +96 96 | +97 97 | # Test: access a sub-importation via an alias. +98 98 | import foo.bar as bop +99 |-import foo.bar.baz +100 99 | +101 100 | print(bop.baz.read_csv("test.csv")) +102 101 | + +F401_0.py:105:12: F401 [*] `a1` imported but unused + | +103 | # Test: isolated deletions. +104 | if TYPE_CHECKING: +105 | import a1 + | ^^ F401 +106 | +107 | import a2 + | + = help: Remove unused import: `a1` + +ℹ Fix +102 102 | +103 103 | # Test: isolated deletions. +104 104 | if TYPE_CHECKING: +105 |- import a1 +106 105 | +107 106 | import a2 +108 107 | + +F401_0.py:107:12: F401 [*] `a2` imported but unused + | +105 | import a1 +106 | +107 | import a2 + | ^^ F401 + | + = help: Remove unused import: `a2` + +ℹ Fix +104 104 | if TYPE_CHECKING: +105 105 | import a1 +106 106 | +107 |- import a2 +108 107 | +109 108 | +110 109 | match *0, 1, *2: + +F401_0.py:112:16: F401 [*] `b1` imported but unused + | +110 | match *0, 1, *2: +111 | case 0,: +112 | import b1 + | ^^ F401 +113 | +114 | import b2 + | + = help: Remove unused import: `b1` + +ℹ Fix +109 109 | +110 110 | match *0, 1, *2: +111 111 | case 0,: +112 |- import b1 +113 112 | +114 113 | import b2 +115 114 | + +F401_0.py:114:16: F401 [*] `b2` imported but unused + | +112 | import b1 +113 | +114 | import b2 + | ^^ F401 + | + = help: Remove unused import: `b2` + +ℹ Fix +111 111 | case 0,: +112 112 | import b1 +113 113 | +114 |- import b2 +115 114 | +116 115 | +117 116 | # Regression test for: https://github.com/astral-sh/ruff/issues/7244 + +F401_0.py:122:1: F401 [*] `datameta_client_lib.model_helpers.noqa` imported but unused + | +121 | from datameta_client_lib.model_helpers import ( +122 | noqa ) + | ^^^^ F401 + | + = help: Remove unused import: `datameta_client_lib.model_helpers.noqa` + +ℹ Fix +118 118 | from datameta_client_lib.model_utils import ( # noqa: F401 +119 119 | noqa ) +120 120 | +121 |-from datameta_client_lib.model_helpers import ( +122 |-noqa ) + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_1.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_1.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_1.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + 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 new file mode 100644 index 0000000000..213cd18b0a --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_10.py.snap @@ -0,0 +1,26 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F401_10.py:6:16: F401 `orjson` imported but unused; consider using `importlib.util.find_spec` to test for availability + | +4 | def module_not_found_error(): +5 | try: +6 | import orjson + | ^^^^^^ F401 +7 | +8 | return True + | + = help: Remove unused import: `orjson` + +F401_10.py:15:16: F401 `orjson` imported but unused; consider using `importlib.util.find_spec` to test for availability + | +13 | def import_error(): +14 | try: +15 | import orjson + | ^^^^^^ F401 +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_11.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_11.py.snap new file mode 100644 index 0000000000..c7b255b011 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_11.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F401_11.py:4:27: F401 [*] `pathlib.PurePath` imported but unused + | +3 | from typing import List +4 | from pathlib import Path, PurePath + | ^^^^^^^^ F401 + | + = help: Remove unused import: `pathlib.PurePath` + +ℹ Fix +1 1 | """Test: parsing of nested string annotations.""" +2 2 | +3 3 | from typing import List +4 |-from pathlib import Path, PurePath + 4 |+from pathlib import Path +5 5 | +6 6 | +7 7 | x: """List['Path']""" = [] + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_12.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_12.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_12.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_13.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_13.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_13.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_14.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_14.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_14.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_15.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_15.py.snap new file mode 100644 index 0000000000..abcc293126 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_15.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F401_15.py:5:25: F401 [*] `pathlib.Path` imported but unused + | +4 | if TYPE_CHECKING: +5 | from pathlib import Path + | ^^^^ F401 + | + = help: Remove unused import: `pathlib.Path` + +ℹ Fix +2 2 | from django.db.models import ForeignKey +3 3 | +4 4 | if TYPE_CHECKING: +5 |- from pathlib import Path + 5 |+ pass +6 6 | +7 7 | +8 8 | class Foo: + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_16.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_16.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_16.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + 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 new file mode 100644 index 0000000000..82be7eb9c7 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_17.py.snap @@ -0,0 +1,42 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F401_17.py:12:27: F401 [*] `threading.Thread` imported but unused + | +11 | def fn(thread: Thread): +12 | from threading import Thread + | ^^^^^^ F401 +13 | +14 | # The `Thread` on the left-hand side should resolve to the `Thread` imported at the + | + = help: Remove unused import: `threading.Thread` + +ℹ Fix +9 9 | +10 10 | +11 11 | def fn(thread: Thread): +12 |- from threading import Thread +13 12 | +14 13 | # The `Thread` on the left-hand side should resolve to the `Thread` imported at the +15 14 | # top level. + +F401_17.py:20:27: F401 [*] `threading.Thread` imported but unused + | +19 | def fn(thread: Thread): +20 | from threading import Thread + | ^^^^^^ F401 +21 | +22 | # The `Thread` on the left-hand side should resolve to the `Thread` imported at the + | + = help: Remove unused import: `threading.Thread` + +ℹ Fix +17 17 | +18 18 | +19 19 | def fn(thread: Thread): +20 |- from threading import Thread +21 20 | +22 21 | # The `Thread` on the left-hand side should resolve to the `Thread` imported at the +23 22 | # top level. + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_18.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_18.py.snap new file mode 100644 index 0000000000..e5952be0d5 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_18.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F401_18.py:5:12: F401 [*] `__future__` imported but unused + | +4 | def f(): +5 | import __future__ + | ^^^^^^^^^^ F401 + | + = help: Remove unused import: `future` + +ℹ Fix +2 2 | +3 3 | +4 4 | def f(): +5 |- import __future__ + 5 |+ pass +6 6 | +7 7 | +8 8 | def f(): + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_2.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_2.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_2.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_3.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_3.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_3.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_4.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_4.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_4.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_5.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_5.py.snap new file mode 100644 index 0000000000..b67b6c1222 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_5.py.snap @@ -0,0 +1,71 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F401_5.py:2:17: F401 [*] `a.b.c` imported but unused + | +1 | """Test: removal of multi-segment and aliases imports.""" +2 | from a.b import c + | ^ F401 +3 | from d.e import f as g +4 | import h.i + | + = help: Remove unused import: `a.b.c` + +ℹ Fix +1 1 | """Test: removal of multi-segment and aliases imports.""" +2 |-from a.b import c +3 2 | from d.e import f as g +4 3 | import h.i +5 4 | import j.k as l + +F401_5.py:3:22: F401 [*] `d.e.f` imported but unused + | +1 | """Test: removal of multi-segment and aliases imports.""" +2 | from a.b import c +3 | from d.e import f as g + | ^ F401 +4 | import h.i +5 | import j.k as l + | + = help: Remove unused import: `d.e.f` + +ℹ Fix +1 1 | """Test: removal of multi-segment and aliases imports.""" +2 2 | from a.b import c +3 |-from d.e import f as g +4 3 | import h.i +5 4 | import j.k as l + +F401_5.py:4:8: F401 [*] `h.i` imported but unused + | +2 | from a.b import c +3 | from d.e import f as g +4 | import h.i + | ^^^ F401 +5 | import j.k as l + | + = help: Remove unused import: `h.i` + +ℹ Fix +1 1 | """Test: removal of multi-segment and aliases imports.""" +2 2 | from a.b import c +3 3 | from d.e import f as g +4 |-import h.i +5 4 | import j.k as l + +F401_5.py:5:15: F401 [*] `j.k` imported but unused + | +3 | from d.e import f as g +4 | import h.i +5 | import j.k as l + | ^ F401 + | + = help: Remove unused import: `j.k` + +ℹ Fix +2 2 | from a.b import c +3 3 | from d.e import f as g +4 4 | import h.i +5 |-import j.k as l + + 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 new file mode 100644 index 0000000000..7bc4650a52 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_6.py.snap @@ -0,0 +1,75 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +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 | +9 | # F401 `datastructures.UploadFile` imported but unused + | + = help: Remove unused import: `.background.BackgroundTasks` + +ℹ Fix +4 4 | from .applications import FastAPI as FastAPI +5 5 | +6 6 | # F401 `background.BackgroundTasks` imported but unused +7 |-from .background import BackgroundTasks +8 7 | +9 8 | # F401 `datastructures.UploadFile` imported but unused +10 9 | from .datastructures import UploadFile as FileUpload + +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 | +12 | # OK + | + = help: Remove unused import: `.datastructures.UploadFile` + +ℹ Fix +7 7 | from .background import BackgroundTasks +8 8 | +9 9 | # F401 `datastructures.UploadFile` imported but unused +10 |-from .datastructures import UploadFile as FileUpload +11 10 | +12 11 | # OK +13 12 | import applications as applications + +F401_6.py:16:8: F401 [*] `background` imported but unused + | +15 | # F401 `background` imported but unused +16 | import background + | ^^^^^^^^^^ F401 +17 | +18 | # F401 `datastructures` imported but unused + | + = help: Remove unused import: `background` + +ℹ Fix +13 13 | import applications as applications +14 14 | +15 15 | # F401 `background` imported but unused +16 |-import background +17 16 | +18 17 | # F401 `datastructures` imported but unused +19 18 | import datastructures as structures + +F401_6.py:19:26: F401 [*] `datastructures` imported but unused + | +18 | # F401 `datastructures` imported but unused +19 | import datastructures as structures + | ^^^^^^^^^^ F401 + | + = help: Remove unused import: `datastructures` + +ℹ Fix +16 16 | import background +17 17 | +18 18 | # F401 `datastructures` imported but unused +19 |-import datastructures as structures + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_7.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_7.py.snap new file mode 100644 index 0000000000..2966e7a542 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_7.py.snap @@ -0,0 +1,53 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F401_7.py:30:5: F401 [*] `typing.Union` imported but unused + | +28 | from typing import ( +29 | Mapping, # noqa: F401 +30 | Union, + | ^^^^^ F401 +31 | ) + | + = help: Remove unused import: `typing.Union` + +ℹ Fix +27 27 | # This should ignore the first error. +28 28 | from typing import ( +29 29 | Mapping, # noqa: F401 +30 |- Union, +31 |-) + 30 |+ ) +32 31 | +33 32 | # This should ignore both errors. +34 33 | from typing import ( # noqa + +F401_7.py:66:20: F401 [*] `typing.Awaitable` imported but unused + | +65 | # This should mark F501 as unused. +66 | from typing import Awaitable, AwaitableGenerator # noqa: F501 + | ^^^^^^^^^ F401 + | + = help: Remove unused import + +ℹ Fix +63 63 | from typing import AsyncIterable, AsyncGenerator # noqa +64 64 | +65 65 | # This should mark F501 as unused. +66 |-from typing import Awaitable, AwaitableGenerator # noqa: F501 + +F401_7.py:66:31: F401 [*] `typing.AwaitableGenerator` imported but unused + | +65 | # This should mark F501 as unused. +66 | from typing import Awaitable, AwaitableGenerator # noqa: F501 + | ^^^^^^^^^^^^^^^^^^ F401 + | + = help: Remove unused import + +ℹ Fix +63 63 | from typing import AsyncIterable, AsyncGenerator # noqa +64 64 | +65 65 | # This should mark F501 as unused. +66 |-from typing import Awaitable, AwaitableGenerator # noqa: F501 + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_8.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_8.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_8.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_9.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_9.py.snap new file mode 100644 index 0000000000..88e03d15c2 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F401_F401_9.py.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F401_9.py:4:22: F401 [*] `foo.baz` imported but unused + | +3 | __all__ = ("bar",) +4 | from foo import bar, baz + | ^^^ F401 + | + = help: Remove unused import: `foo.baz` + +ℹ Fix +1 1 | """Test: late-binding of `__all__`.""" +2 2 | +3 3 | __all__ = ("bar",) +4 |-from foo import bar, baz + 4 |+from foo import bar + + 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 new file mode 100644 index 0000000000..acf46aff98 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F402_F402.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F402.py:5:5: F402 Import `os` from line 1 shadowed by loop variable + | +5 | for os in range(3): + | ^^ F402 +6 | pass + | + +F402.py:8:5: F402 Import `path` from line 2 shadowed by loop variable + | +6 | pass +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 new file mode 100644 index 0000000000..c9432addf2 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F403_F403.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F403.py:1:1: F403 `from F634 import *` used; unable to detect undefined names + | +1 | from F634 import * + | ^^^^^^^^^^^^^^^^^^ F403 +2 | from F634 import * # noqa: E501 + | + +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 | +4 | from F634 import * # noqa + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404.py.snap new file mode 100644 index 0000000000..fee99fc907 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F404_F404.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F404.py:6:1: F404 `from __future__` imports must occur at the beginning of the file + | +4 | from collections import namedtuple +5 | +6 | from __future__ import print_function + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F404 +7 | +8 | import __future__ + | + + 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 new file mode 100644 index 0000000000..3e3c43d3b9 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F405_F405.py.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F405.py:5:11: F405 `name` may be undefined, or defined from star imports + | +4 | def print_name(): +5 | print(name) + | ^^^^ F405 + | + +F405.py:11:1: F405 `a` may be undefined, or defined from star imports + | + 9 | print(name) +10 | +11 | __all__ = ['a'] + | ^^^^^^^ F405 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F406_F406.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F406_F406.py.snap new file mode 100644 index 0000000000..5263bb2eb5 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F406_F406.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F406.py:5:5: F406 `from F634 import *` only allowed at module level + | +4 | def f(): +5 | from F634 import * + | ^^^^^^^^^^^^^^^^^^ F406 + | + +F406.py:9:5: F406 `from F634 import *` only allowed at module level + | +8 | class F: +9 | from F634 import * + | ^^^^^^^^^^^^^^^^^^ F406 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F407_F407.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F407_F407.py.snap new file mode 100644 index 0000000000..c791c147bb --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F407_F407.py.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F407.py:2:24: F407 Future feature `non_existent_feature` is not defined + | +1 | from __future__ import print_function +2 | from __future__ import non_existent_feature + | ^^^^^^^^^^^^^^^^^^^^ F407 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F501_F50x.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F501_F50x.py.snap new file mode 100644 index 0000000000..225b34a087 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F501_F50x.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F50x.py:1:1: F501 `%`-format string has invalid format string: incomplete format + | +1 | '%(foo)' % {'foo': 'bar'} # F501 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ F501 +2 | '%s %(foo)s' % {'foo': 'bar'} # F506 +3 | '%(foo)s %s' % {'foo': 'bar'} # F506 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F502_F502.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F502_F502.py.snap new file mode 100644 index 0000000000..1fd7af4900 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F502_F502.py.snap @@ -0,0 +1,71 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F502.py:6:1: F502 `%`-format string expected mapping but got sequence + | +4 | "%(bob)s" % {"bob": "bob"} +5 | "%(bob)s" % {**{"bob": "bob"}} +6 | "%(bob)s" % ["bob"] # F202 + | ^^^^^^^^^^^^^^^^^^^ F502 +7 | "%(bob)s" % ("bob",) # F202 +8 | "%(bob)s" % {"bob"} # F202 + | + +F502.py:7:1: F502 `%`-format string expected mapping but got sequence + | +5 | "%(bob)s" % {**{"bob": "bob"}} +6 | "%(bob)s" % ["bob"] # F202 +7 | "%(bob)s" % ("bob",) # F202 + | ^^^^^^^^^^^^^^^^^^^^ F502 +8 | "%(bob)s" % {"bob"} # F202 +9 | "%(bob)s" % [*["bob"]] # F202 + | + +F502.py:8:1: F502 `%`-format string expected mapping but got sequence + | + 6 | "%(bob)s" % ["bob"] # F202 + 7 | "%(bob)s" % ("bob",) # F202 + 8 | "%(bob)s" % {"bob"} # F202 + | ^^^^^^^^^^^^^^^^^^^ F502 + 9 | "%(bob)s" % [*["bob"]] # F202 +10 | "%(bob)s" % {"bob": "bob" for _ in range(1)} + | + +F502.py:9:1: F502 `%`-format string expected mapping but got sequence + | + 7 | "%(bob)s" % ("bob",) # F202 + 8 | "%(bob)s" % {"bob"} # F202 + 9 | "%(bob)s" % [*["bob"]] # F202 + | ^^^^^^^^^^^^^^^^^^^^^^ F502 +10 | "%(bob)s" % {"bob": "bob" for _ in range(1)} +11 | "%(bob)s" % ["bob" for _ in range(1)] # F202 + | + +F502.py:11:1: F502 `%`-format string expected mapping but got sequence + | + 9 | "%(bob)s" % [*["bob"]] # F202 +10 | "%(bob)s" % {"bob": "bob" for _ in range(1)} +11 | "%(bob)s" % ["bob" for _ in range(1)] # F202 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F502 +12 | "%(bob)s" % ("bob" for _ in range(1)) # F202 +13 | "%(bob)s" % {"bob" for _ in range(1)} # F202 + | + +F502.py:12:1: F502 `%`-format string expected mapping but got sequence + | +10 | "%(bob)s" % {"bob": "bob" for _ in range(1)} +11 | "%(bob)s" % ["bob" for _ in range(1)] # F202 +12 | "%(bob)s" % ("bob" for _ in range(1)) # F202 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F502 +13 | "%(bob)s" % {"bob" for _ in range(1)} # F202 + | + +F502.py:13:1: F502 `%`-format string expected mapping but got sequence + | +11 | "%(bob)s" % ["bob" for _ in range(1)] # F202 +12 | "%(bob)s" % ("bob" for _ in range(1)) # F202 +13 | "%(bob)s" % {"bob" for _ in range(1)} # F202 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F502 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F502_F50x.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F502_F50x.py.snap new file mode 100644 index 0000000000..c82bf8b4ac --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F502_F50x.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F50x.py:9:1: F502 `%`-format string expected mapping but got sequence + | + 7 | '%(bar)s' % {} # F505 + 8 | '%(bar)s' % {'bar': 1, 'baz': 2} # F504 + 9 | '%(bar)s' % (1, 2, 3) # F502 + | ^^^^^^^^^^^^^^^^^^^^^ F502 +10 | '%s %s' % {'k': 'v'} # F503 +11 | '%(bar)*s' % {'bar': 'baz'} # F506, F508 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F503_F503.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F503_F503.py.snap new file mode 100644 index 0000000000..e568cd7e70 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F503_F503.py.snap @@ -0,0 +1,34 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F503.py:17:1: F503 `%`-format string expected sequence but got mapping + | +15 | # Multiple placeholders +16 | "%s %s" % dog +17 | "%s %s" % {"bob": "bob"} # F503 + | ^^^^^^^^^^^^^^^^^^^^^^^^ F503 +18 | "%s %s" % {**{"bob": "bob"}} # F503 +19 | "%s %s" % ["bob"] + | + +F503.py:18:1: F503 `%`-format string expected sequence but got mapping + | +16 | "%s %s" % dog +17 | "%s %s" % {"bob": "bob"} # F503 +18 | "%s %s" % {**{"bob": "bob"}} # F503 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F503 +19 | "%s %s" % ["bob"] +20 | "%s %s" % ("bob",) + | + +F503.py:23:1: F503 `%`-format string expected sequence but got mapping + | +21 | "%s %s" % {"bob"} +22 | "%s %s" % [*["bob"]] +23 | "%s %s" % {"bob": "bob" for _ in range(1)} # F503 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F503 +24 | "%s %s" % ["bob" for _ in range(1)] +25 | "%s %s" % ("bob" for _ in range(1)) + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F503_F50x.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F503_F50x.py.snap new file mode 100644 index 0000000000..cdd18e4d9e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F503_F50x.py.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F50x.py:10:1: F503 `%`-format string expected sequence but got mapping + | + 8 | '%(bar)s' % {'bar': 1, 'baz': 2} # F504 + 9 | '%(bar)s' % (1, 2, 3) # F502 +10 | '%s %s' % {'k': 'v'} # F503 + | ^^^^^^^^^^^^^^^^^^^^ F503 +11 | '%(bar)*s' % {'bar': 'baz'} # F506, F508 + | + + 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 new file mode 100644 index 0000000000..8af7d0e85c --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F504.py.snap @@ -0,0 +1,103 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F504.py:3:1: F504 [*] `%`-format string has unused named argument(s): b + | +1 | # Ruff has no way of knowing if the following are F505s +2 | a = "wrong" +3 | "%(a)s %(c)s" % {a: "?", "b": "!"} # F504 ("b" not used) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F504 +4 | +5 | hidden = {"a": "!"} + | + = help: Remove extra named arguments: b + +ℹ Fix +1 1 | # Ruff has no way of knowing if the following are F505s +2 2 | a = "wrong" +3 |-"%(a)s %(c)s" % {a: "?", "b": "!"} # F504 ("b" not used) + 3 |+"%(a)s %(c)s" % {a: "?", } # F504 ("b" not used) +4 4 | +5 5 | hidden = {"a": "!"} +6 6 | "%(a)s %(c)s" % {"x": 1, **hidden} # Ok (cannot see through splat) + +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 | +8 | "%(a)s" % {"a": 1, r"b": "!"} # F504 ("b" not used) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F504 +9 | "%(a)s" % {'a': 1, u"b": "!"} # F504 ("b" not used) + | + = help: Remove extra named arguments: b + +ℹ Fix +5 5 | hidden = {"a": "!"} +6 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) + 8 |+"%(a)s" % {"a": 1, } # F504 ("b" not used) +9 9 | "%(a)s" % {'a': 1, u"b": "!"} # F504 ("b" not used) +10 10 | +11 11 | '' % {'a''b' : ''} # F504 ("ab" not used) + +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 | +11 | '' % {'a''b' : ''} # F504 ("ab" not used) + | + = help: Remove extra named arguments: b + +ℹ Fix +6 6 | "%(a)s %(c)s" % {"x": 1, **hidden} # Ok (cannot see through splat) +7 7 | +8 8 | "%(a)s" % {"a": 1, r"b": "!"} # F504 ("b" not used) +9 |-"%(a)s" % {'a': 1, u"b": "!"} # F504 ("b" not used) + 9 |+"%(a)s" % {'a': 1, } # F504 ("b" not used) +10 10 | +11 11 | '' % {'a''b' : ''} # F504 ("ab" not used) +12 12 | + +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 | +11 | '' % {'a''b' : ''} # F504 ("ab" not used) + | ^^^^^^^^^^^^^^^^^^ F504 +12 | +13 | # https://github.com/astral-sh/ruff/issues/4899 + | + = help: Remove extra named arguments: ab + +ℹ Fix +8 8 | "%(a)s" % {"a": 1, r"b": "!"} # F504 ("b" not used) +9 9 | "%(a)s" % {'a': 1, u"b": "!"} # F504 ("b" not used) +10 10 | +11 |-'' % {'a''b' : ''} # F504 ("ab" not used) + 11 |+'' % {} # F504 ("ab" not used) +12 12 | +13 13 | # https://github.com/astral-sh/ruff/issues/4899 +14 14 | "" % { + +F504.py:14:1: F504 [*] `%`-format string has unused named argument(s): test1, test2 + | +13 | # https://github.com/astral-sh/ruff/issues/4899 +14 | / "" % { +15 | | 'test1': '', 'test2': '', +16 | | } + | |_^ F504 + | + = help: Remove extra named arguments: test1, test2 + +ℹ Fix +12 12 | +13 13 | # https://github.com/astral-sh/ruff/issues/4899 +14 14 | "" % { +15 |- 'test1': '', 16 |- 'test2': '', + 15 |+ +17 16 | } + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F50x.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F50x.py.snap new file mode 100644 index 0000000000..317942fa7e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F504_F50x.py.snap @@ -0,0 +1,25 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F50x.py:8:1: F504 [*] `%`-format string has unused named argument(s): baz + | + 6 | '%s %s' % (1, 2, 3) # F507 + 7 | '%(bar)s' % {} # F505 + 8 | '%(bar)s' % {'bar': 1, 'baz': 2} # F504 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F504 + 9 | '%(bar)s' % (1, 2, 3) # F502 +10 | '%s %s' % {'k': 'v'} # F503 + | + = help: Remove extra named arguments: baz + +ℹ Fix +5 5 | '%s %s' % (1,) # F507 +6 6 | '%s %s' % (1, 2, 3) # F507 +7 7 | '%(bar)s' % {} # F505 +8 |-'%(bar)s' % {'bar': 1, 'baz': 2} # F504 + 8 |+'%(bar)s' % {'bar': 1, } # F504 +9 9 | '%(bar)s' % (1, 2, 3) # F502 +10 10 | '%s %s' % {'k': 'v'} # F503 +11 11 | '%(bar)*s' % {'bar': 'baz'} # F506, F508 + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F505_F504.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F505_F504.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F505_F504.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F505_F50x.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F505_F50x.py.snap new file mode 100644 index 0000000000..e1d10c3791 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F505_F50x.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F50x.py:7:1: F505 `%`-format string is missing argument(s) for placeholder(s): bar + | +5 | '%s %s' % (1,) # F507 +6 | '%s %s' % (1, 2, 3) # F507 +7 | '%(bar)s' % {} # F505 + | ^^^^^^^^^^^^^^ F505 +8 | '%(bar)s' % {'bar': 1, 'baz': 2} # F504 +9 | '%(bar)s' % (1, 2, 3) # F502 + | + + 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 new file mode 100644 index 0000000000..7a92ee2c30 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F506_F50x.py.snap @@ -0,0 +1,33 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F50x.py:2:1: F506 `%`-format string has mixed positional and named placeholders + | +1 | '%(foo)' % {'foo': 'bar'} # F501 +2 | '%s %(foo)s' % {'foo': 'bar'} # F506 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F506 +3 | '%(foo)s %s' % {'foo': 'bar'} # F506 +4 | '%j' % (1,) # F509 + | + +F50x.py:3:1: F506 `%`-format string has mixed positional and named placeholders + | +1 | '%(foo)' % {'foo': 'bar'} # F501 +2 | '%s %(foo)s' % {'foo': 'bar'} # F506 +3 | '%(foo)s %s' % {'foo': 'bar'} # F506 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F506 +4 | '%j' % (1,) # F509 +5 | '%s %s' % (1,) # F507 + | + +F50x.py:11:1: F506 `%`-format string has mixed positional and named placeholders + | + 9 | '%(bar)s' % (1, 2, 3) # F502 +10 | '%s %s' % {'k': 'v'} # F503 +11 | '%(bar)*s' % {'bar': 'baz'} # F506, F508 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ F506 +12 | +13 | # ok: single %s with mapping + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F507_F50x.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F507_F50x.py.snap new file mode 100644 index 0000000000..a78447db5e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F507_F50x.py.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F50x.py:5:1: F507 `%`-format string has 2 placeholder(s) but 1 substitution(s) + | +3 | '%(foo)s %s' % {'foo': 'bar'} # F506 +4 | '%j' % (1,) # F509 +5 | '%s %s' % (1,) # F507 + | ^^^^^^^^^^^^^^ F507 +6 | '%s %s' % (1, 2, 3) # F507 +7 | '%(bar)s' % {} # F505 + | + +F50x.py:6:1: F507 `%`-format string has 2 placeholder(s) but 3 substitution(s) + | +4 | '%j' % (1,) # F509 +5 | '%s %s' % (1,) # F507 +6 | '%s %s' % (1, 2, 3) # F507 + | ^^^^^^^^^^^^^^^^^^^ F507 +7 | '%(bar)s' % {} # F505 +8 | '%(bar)s' % {'bar': 1, 'baz': 2} # F504 + | + + 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 new file mode 100644 index 0000000000..add7bb3122 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F508_F50x.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F50x.py:11:1: F508 `%`-format string `*` specifier requires sequence + | + 9 | '%(bar)s' % (1, 2, 3) # F502 +10 | '%s %s' % {'k': 'v'} # F503 +11 | '%(bar)*s' % {'bar': 'baz'} # F506, F508 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ F508 +12 | +13 | # ok: single %s with mapping + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F509_F50x.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F509_F50x.py.snap new file mode 100644 index 0000000000..e1eeb3f4c2 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F509_F50x.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F50x.py:4:1: F509 `%`-format string has unsupported format character `j` + | +2 | '%s %(foo)s' % {'foo': 'bar'} # F506 +3 | '%(foo)s %s' % {'foo': 'bar'} # F506 +4 | '%j' % (1,) # F509 + | ^^^^^^^^^^^ F509 +5 | '%s %s' % (1,) # F507 +6 | '%s %s' % (1, 2, 3) # F507 + | + + 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 new file mode 100644 index 0000000000..56d4add051 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F521_F521.py.snap @@ -0,0 +1,70 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F521.py:1:1: F521 `.format` call has invalid format string: Single '{' encountered in format string + | +1 | "{".format(1) + | ^^^^^^^^^^^^^ F521 +2 | "}".format(1) +3 | "{foo[}".format(foo=1) + | + +F521.py:2:1: F521 `.format` call has invalid format string: Single '}' encountered in format string + | +1 | "{".format(1) +2 | "}".format(1) + | ^^^^^^^^^^^^^ F521 +3 | "{foo[}".format(foo=1) +4 | # too much string recursion (placeholder-in-placeholder) + | + +F521.py:3:1: F521 `.format` call has invalid format string: Expected '}' before end of string + | +1 | "{".format(1) +2 | "}".format(1) +3 | "{foo[}".format(foo=1) + | ^^^^^^^^^^^^^^^^^^^^^^ F521 +4 | # too much string recursion (placeholder-in-placeholder) +5 | "{:{:{}}}".format(1, 2, 3) + | + +F521.py:5:1: F521 `.format` call has invalid format string: Max format placeholder recursion exceeded + | +3 | "{foo[}".format(foo=1) +4 | # too much string recursion (placeholder-in-placeholder) +5 | "{:{:{}}}".format(1, 2, 3) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ F521 +6 | # ruff picks these issues up, but flake8 doesn't +7 | "{foo[]}".format(foo={"": 1}) + | + +F521.py:7:1: F521 `.format` call has invalid format string: Empty attribute in format string + | +5 | "{:{:{}}}".format(1, 2, 3) +6 | # ruff picks these issues up, but flake8 doesn't +7 | "{foo[]}".format(foo={"": 1}) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F521 +8 | "{foo..}".format(foo=1) +9 | "{foo..bar}".format(foo=1) + | + +F521.py:8:1: F521 `.format` call has invalid format string: Empty attribute in format string + | +6 | # ruff picks these issues up, but flake8 doesn't +7 | "{foo[]}".format(foo={"": 1}) +8 | "{foo..}".format(foo=1) + | ^^^^^^^^^^^^^^^^^^^^^^^ F521 +9 | "{foo..bar}".format(foo=1) + | + +F521.py:9:1: F521 `.format` call has invalid format string: Empty attribute in format string + | + 7 | "{foo[]}".format(foo={"": 1}) + 8 | "{foo..}".format(foo=1) + 9 | "{foo..bar}".format(foo=1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ F521 +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__F522_F522.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F522_F522.py.snap new file mode 100644 index 0000000000..63d372c753 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F522_F522.py.snap @@ -0,0 +1,76 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F522.py:1:1: F522 [*] `.format` call has unused named argument(s): bar + | +1 | "{}".format(1, bar=2) # F522 + | ^^^^^^^^^^^^^^^^^^^^^ F522 +2 | "{bar}{}".format(1, bar=2, spam=3) # F522 +3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues + | + = help: Remove extra named arguments: bar + +ℹ Fix +1 |-"{}".format(1, bar=2) # F522 + 1 |+"{}".format(1, ) # F522 +2 2 | "{bar}{}".format(1, bar=2, spam=3) # F522 +3 3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues +4 4 | "{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 + +F522.py:2:1: F522 [*] `.format` call has unused named argument(s): spam + | +1 | "{}".format(1, bar=2) # F522 +2 | "{bar}{}".format(1, bar=2, spam=3) # F522 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F522 +3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues +4 | "{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 + | + = help: Remove extra named arguments: spam + +ℹ Fix +1 1 | "{}".format(1, bar=2) # F522 +2 |-"{bar}{}".format(1, bar=2, spam=3) # F522 + 2 |+"{bar}{}".format(1, bar=2, ) # F522 +3 3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues +4 4 | "{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 +5 5 | ('' + +F522.py:4:1: F522 [*] `.format` call has unused named argument(s): eggs, ham + | +2 | "{bar}{}".format(1, bar=2, spam=3) # F522 +3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues +4 | "{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F522 +5 | ('' +6 | .format(x=2)) # F522 + | + = help: Remove extra named arguments: eggs, ham + +ℹ Fix +1 1 | "{}".format(1, bar=2) # F522 +2 2 | "{bar}{}".format(1, bar=2, spam=3) # F522 +3 3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues +4 |-"{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 + 4 |+"{bar:{spam}}".format(bar=2, spam=3, ) # F522 +5 5 | ('' +6 6 | .format(x=2)) # F522 + +F522.py:5:2: F522 [*] `.format` call has unused named argument(s): x + | +3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues +4 | "{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 +5 | ('' + | __^ +6 | | .format(x=2)) # F522 + | |_____________^ F522 + | + = help: Remove extra named arguments: x + +ℹ Fix +3 3 | "{bar:{spam}}".format(bar=2, spam=3) # No issues +4 4 | "{bar:{spam}}".format(bar=2, spam=3, eggs=4, ham=5) # F522 +5 5 | ('' +6 |- .format(x=2)) # F522 + 6 |+ .format()) # F522 + + 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 new file mode 100644 index 0000000000..875812f357 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F523_F523.py.snap @@ -0,0 +1,267 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F523.py:2:1: F523 [*] `.format` call has unused arguments at position(s): 1 + | +1 | # With indexes +2 | "{0}".format(1, 2) # F523 + | ^^^^^^^^^^^^^^^^^^ F523 +3 | "{1}".format(1, 2, 3) # F523 +4 | "{1:{0}}".format(1, 2) # No issues + | + = help: Remove extra positional arguments at position(s): 1 + +ℹ Fix +1 1 | # With indexes +2 |-"{0}".format(1, 2) # F523 + 2 |+"{0}".format(1, ) # F523 +3 3 | "{1}".format(1, 2, 3) # F523 +4 4 | "{1:{0}}".format(1, 2) # No issues +5 5 | "{1:{0}}".format(1, 2, 3) # F523 + +F523.py:3:1: F523 `.format` call has unused arguments at position(s): 0, 2 + | +1 | # With indexes +2 | "{0}".format(1, 2) # F523 +3 | "{1}".format(1, 2, 3) # F523 + | ^^^^^^^^^^^^^^^^^^^^^ F523 +4 | "{1:{0}}".format(1, 2) # No issues +5 | "{1:{0}}".format(1, 2, 3) # F523 + | + = help: Remove extra positional arguments at position(s): 0, 2 + +F523.py:5:1: F523 [*] `.format` call has unused arguments at position(s): 2 + | +3 | "{1}".format(1, 2, 3) # F523 +4 | "{1:{0}}".format(1, 2) # No issues +5 | "{1:{0}}".format(1, 2, 3) # F523 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ F523 +6 | "{0}{2}".format(1, 2) # F523, # F524 +7 | "{1.arg[1]!r:0{2['arg']}{1}}".format(1, 2, 3, 4) # F523 + | + = help: Remove extra positional arguments at position(s): 2 + +ℹ Fix +2 2 | "{0}".format(1, 2) # F523 +3 3 | "{1}".format(1, 2, 3) # F523 +4 4 | "{1:{0}}".format(1, 2) # No issues +5 |-"{1:{0}}".format(1, 2, 3) # F523 + 5 |+"{1:{0}}".format(1, 2, ) # F523 +6 6 | "{0}{2}".format(1, 2) # F523, # F524 +7 7 | "{1.arg[1]!r:0{2['arg']}{1}}".format(1, 2, 3, 4) # F523 +8 8 | + +F523.py:6:1: F523 [*] `.format` call has unused arguments at position(s): 1 + | +4 | "{1:{0}}".format(1, 2) # No issues +5 | "{1:{0}}".format(1, 2, 3) # F523 +6 | "{0}{2}".format(1, 2) # F523, # F524 + | ^^^^^^^^^^^^^^^^^^^^^ F523 +7 | "{1.arg[1]!r:0{2['arg']}{1}}".format(1, 2, 3, 4) # F523 + | + = help: Remove extra positional arguments at position(s): 1 + +ℹ Fix +3 3 | "{1}".format(1, 2, 3) # F523 +4 4 | "{1:{0}}".format(1, 2) # No issues +5 5 | "{1:{0}}".format(1, 2, 3) # F523 +6 |-"{0}{2}".format(1, 2) # F523, # F524 + 6 |+"{0}{2}".format(1, ) # F523, # F524 +7 7 | "{1.arg[1]!r:0{2['arg']}{1}}".format(1, 2, 3, 4) # F523 +8 8 | +9 9 | # With no indexes + +F523.py:7:1: F523 `.format` call has unused arguments at position(s): 0, 3 + | +5 | "{1:{0}}".format(1, 2, 3) # F523 +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 | +9 | # With no indexes + | + = help: Remove extra positional arguments at position(s): 0, 3 + +F523.py:10:1: F523 [*] `.format` call has unused arguments at position(s): 1 + | + 9 | # With no indexes +10 | "{}".format(1, 2) # F523 + | ^^^^^^^^^^^^^^^^^ F523 +11 | "{}".format(1, 2, 3) # F523 +12 | "{:{}}".format(1, 2) # No issues + | + = help: Remove extra positional arguments at position(s): 1 + +ℹ Fix +7 7 | "{1.arg[1]!r:0{2['arg']}{1}}".format(1, 2, 3, 4) # F523 +8 8 | +9 9 | # With no indexes +10 |-"{}".format(1, 2) # F523 + 10 |+"{}".format(1, ) # F523 +11 11 | "{}".format(1, 2, 3) # F523 +12 12 | "{:{}}".format(1, 2) # No issues +13 13 | "{:{}}".format(1, 2, 3) # F523 + +F523.py:11:1: F523 [*] `.format` call has unused arguments at position(s): 1, 2 + | + 9 | # With no indexes +10 | "{}".format(1, 2) # F523 +11 | "{}".format(1, 2, 3) # F523 + | ^^^^^^^^^^^^^^^^^^^^ F523 +12 | "{:{}}".format(1, 2) # No issues +13 | "{:{}}".format(1, 2, 3) # F523 + | + = help: Remove extra positional arguments at position(s): 1, 2 + +ℹ Fix +8 8 | +9 9 | # With no indexes +10 10 | "{}".format(1, 2) # F523 +11 |-"{}".format(1, 2, 3) # F523 + 11 |+"{}".format(1, ) # F523 +12 12 | "{:{}}".format(1, 2) # No issues +13 13 | "{:{}}".format(1, 2, 3) # F523 +14 14 | + +F523.py:13:1: F523 [*] `.format` call has unused arguments at position(s): 2 + | +11 | "{}".format(1, 2, 3) # F523 +12 | "{:{}}".format(1, 2) # No issues +13 | "{:{}}".format(1, 2, 3) # F523 + | ^^^^^^^^^^^^^^^^^^^^^^^ F523 +14 | +15 | # With *args + | + = help: Remove extra positional arguments at position(s): 2 + +ℹ Fix +10 10 | "{}".format(1, 2) # F523 +11 11 | "{}".format(1, 2, 3) # F523 +12 12 | "{:{}}".format(1, 2) # No issues +13 |-"{:{}}".format(1, 2, 3) # F523 + 13 |+"{:{}}".format(1, 2, ) # F523 +14 14 | +15 15 | # With *args +16 16 | "{0}{1}".format(*args) # No issues + +F523.py:19:1: F523 `.format` call has unused arguments at position(s): 2 + | +17 | "{0}{1}".format(1, *args) # No issues +18 | "{0}{1}".format(1, 2, *args) # No issues +19 | "{0}{1}".format(1, 2, 3, *args) # F523 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F523 +20 | +21 | # With nested quotes + | + = help: Remove extra positional arguments at position(s): 2 + +F523.py:22:1: F523 [*] `.format` call has unused arguments at position(s): 1, 2 + | +21 | # With nested quotes +22 | "''1{0}".format(1, 2, 3) # F523 + | ^^^^^^^^^^^^^^^^^^^^^^^^ F523 +23 | "\"\"{1}{0}".format(1, 2, 3) # F523 +24 | '""{1}{0}'.format(1, 2, 3) # F523 + | + = help: Remove extra positional arguments at position(s): 1, 2 + +ℹ Fix +19 19 | "{0}{1}".format(1, 2, 3, *args) # F523 +20 20 | +21 21 | # With nested quotes +22 |-"''1{0}".format(1, 2, 3) # F523 + 22 |+"''1{0}".format(1, ) # F523 +23 23 | "\"\"{1}{0}".format(1, 2, 3) # F523 +24 24 | '""{1}{0}'.format(1, 2, 3) # F523 +25 25 | + +F523.py:23:1: F523 [*] `.format` call has unused arguments at position(s): 2 + | +21 | # With nested quotes +22 | "''1{0}".format(1, 2, 3) # F523 +23 | "\"\"{1}{0}".format(1, 2, 3) # F523 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ F523 +24 | '""{1}{0}'.format(1, 2, 3) # F523 + | + = help: Remove extra positional arguments at position(s): 2 + +ℹ Fix +20 20 | +21 21 | # With nested quotes +22 22 | "''1{0}".format(1, 2, 3) # F523 +23 |-"\"\"{1}{0}".format(1, 2, 3) # F523 + 23 |+"\"\"{1}{0}".format(1, 2, ) # F523 +24 24 | '""{1}{0}'.format(1, 2, 3) # F523 +25 25 | +26 26 | # With modified indexes + +F523.py:24:1: F523 [*] `.format` call has unused arguments at position(s): 2 + | +22 | "''1{0}".format(1, 2, 3) # F523 +23 | "\"\"{1}{0}".format(1, 2, 3) # F523 +24 | '""{1}{0}'.format(1, 2, 3) # F523 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ F523 +25 | +26 | # With modified indexes + | + = help: Remove extra positional arguments at position(s): 2 + +ℹ Fix +21 21 | # With nested quotes +22 22 | "''1{0}".format(1, 2, 3) # F523 +23 23 | "\"\"{1}{0}".format(1, 2, 3) # F523 +24 |-'""{1}{0}'.format(1, 2, 3) # F523 + 24 |+'""{1}{0}'.format(1, 2, ) # F523 +25 25 | +26 26 | # With modified indexes +27 27 | "{1}{2}".format(1, 2, 3) # F523, # F524 + +F523.py:27:1: F523 `.format` call has unused arguments at position(s): 0 + | +26 | # With modified indexes +27 | "{1}{2}".format(1, 2, 3) # F523, # F524 + | ^^^^^^^^^^^^^^^^^^^^^^^^ F523 +28 | "{1}{3}".format(1, 2, 3, 4) # F523, # F524 +29 | "{1} {8}".format(0, 1) # F523, # F524 + | + = help: Remove extra positional arguments at position(s): 0 + +F523.py:28:1: F523 `.format` call has unused arguments at position(s): 0, 2 + | +26 | # With modified indexes +27 | "{1}{2}".format(1, 2, 3) # F523, # F524 +28 | "{1}{3}".format(1, 2, 3, 4) # F523, # F524 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ F523 +29 | "{1} {8}".format(0, 1) # F523, # F524 + | + = help: Remove extra positional arguments at position(s): 0, 2 + +F523.py:29:1: F523 `.format` call has unused arguments at position(s): 0 + | +27 | "{1}{2}".format(1, 2, 3) # F523, # F524 +28 | "{1}{3}".format(1, 2, 3, 4) # F523, # F524 +29 | "{1} {8}".format(0, 1) # F523, # F524 + | ^^^^^^^^^^^^^^^^^^^^^^ F523 +30 | +31 | # Multiline + | + = help: Remove extra positional arguments at position(s): 0 + +F523.py:32:2: F523 [*] `.format` call has unused arguments at position(s): 0 + | +31 | # Multiline +32 | ('' + | __^ +33 | | .format(2)) + | |__________^ F523 + | + = help: Remove extra positional arguments at position(s): 0 + +ℹ Fix +30 30 | +31 31 | # Multiline +32 32 | ('' +33 |-.format(2)) + 33 |+.format()) + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F524_F524.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F524_F524.py.snap new file mode 100644 index 0000000000..f93219db64 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F524_F524.py.snap @@ -0,0 +1,68 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F524.py:1:1: F524 `.format` call is missing argument(s) for placeholder(s): 1 + | +1 | "{} {}".format(1) # F524 + | ^^^^^^^^^^^^^^^^^ F524 +2 | "{2}".format() # F524 +3 | "{bar}".format() # F524 + | + +F524.py:2:1: F524 `.format` call is missing argument(s) for placeholder(s): 2 + | +1 | "{} {}".format(1) # F524 +2 | "{2}".format() # F524 + | ^^^^^^^^^^^^^^ F524 +3 | "{bar}".format() # F524 +4 | "{0} {bar}".format(1) # F524 + | + +F524.py:3:1: F524 `.format` call is missing argument(s) for placeholder(s): bar + | +1 | "{} {}".format(1) # F524 +2 | "{2}".format() # F524 +3 | "{bar}".format() # F524 + | ^^^^^^^^^^^^^^^^ F524 +4 | "{0} {bar}".format(1) # F524 +5 | "{0} {bar}".format() # F524 + | + +F524.py:4:1: F524 `.format` call is missing argument(s) for placeholder(s): bar + | +2 | "{2}".format() # F524 +3 | "{bar}".format() # F524 +4 | "{0} {bar}".format(1) # F524 + | ^^^^^^^^^^^^^^^^^^^^^ F524 +5 | "{0} {bar}".format() # F524 +6 | "{bar} {0}".format() # F524 + | + +F524.py:5:1: F524 `.format` call is missing argument(s) for placeholder(s): 0, bar + | +3 | "{bar}".format() # F524 +4 | "{0} {bar}".format(1) # F524 +5 | "{0} {bar}".format() # F524 + | ^^^^^^^^^^^^^^^^^^^^ F524 +6 | "{bar} {0}".format() # F524 +7 | "{1} {8}".format(0, 1) + | + +F524.py:6:1: F524 `.format` call is missing argument(s) for placeholder(s): 0, bar + | +4 | "{0} {bar}".format(1) # F524 +5 | "{0} {bar}".format() # F524 +6 | "{bar} {0}".format() # F524 + | ^^^^^^^^^^^^^^^^^^^^ F524 +7 | "{1} {8}".format(0, 1) + | + +F524.py:7:1: F524 `.format` call is missing argument(s) for placeholder(s): 8 + | +5 | "{0} {bar}".format() # F524 +6 | "{bar} {0}".format() # F524 +7 | "{1} {8}".format(0, 1) + | ^^^^^^^^^^^^^^^^^^^^^^ F524 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F525_F525.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F525_F525.py.snap new file mode 100644 index 0000000000..c8f6727c68 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F525_F525.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F525.py:1:1: F525 `.format` string mixes automatic and manual numbering + | +1 | "{} {1}".format(1, 2) # F525 + | ^^^^^^^^^^^^^^^^^^^^^ F525 +2 | "{0} {}".format(1, 2) # F523, F525 + | + +F525.py:2:1: F525 `.format` string mixes automatic and manual numbering + | +1 | "{} {1}".format(1, 2) # F525 +2 | "{0} {}".format(1, 2) # F523, F525 + | ^^^^^^^^^^^^^^^^^^^^^ F525 + | + + 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 new file mode 100644 index 0000000000..48e7e646c4 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F541_F541.py.snap @@ -0,0 +1,378 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F541.py:6:5: F541 [*] f-string without any placeholders + | +5 | # Errors +6 | c = f"def" + | ^^^^^^ F541 +7 | d = f"def" + "ghi" +8 | e = ( + | + = help: Remove extraneous `f` prefix + +ℹ Fix +3 3 | b = f"ghi{'jkl'}" +4 4 | +5 5 | # Errors +6 |-c = f"def" + 6 |+c = "def" +7 7 | d = f"def" + "ghi" +8 8 | e = ( +9 9 | f"def" + + +F541.py:7:5: F541 [*] f-string without any placeholders + | +5 | # Errors +6 | c = f"def" +7 | d = f"def" + "ghi" + | ^^^^^^ F541 +8 | e = ( +9 | f"def" + + | + = help: Remove extraneous `f` prefix + +ℹ Fix +4 4 | +5 5 | # Errors +6 6 | c = f"def" +7 |-d = f"def" + "ghi" + 7 |+d = "def" + "ghi" +8 8 | e = ( +9 9 | f"def" + +10 10 | "ghi" + +F541.py:9:5: F541 [*] f-string without any placeholders + | + 7 | d = f"def" + "ghi" + 8 | e = ( + 9 | f"def" + + | ^^^^^^ F541 +10 | "ghi" +11 | ) + | + = help: Remove extraneous `f` prefix + +ℹ Fix +6 6 | c = f"def" +7 7 | d = f"def" + "ghi" +8 8 | e = ( +9 |- f"def" + + 9 |+ "def" + +10 10 | "ghi" +11 11 | ) +12 12 | f = ( + +F541.py:13:5: F541 [*] f-string without any placeholders + | +11 | ) +12 | f = ( +13 | f"a" + | ^^^^ F541 +14 | F"b" +15 | "c" + | + = help: Remove extraneous `f` prefix + +ℹ Fix +10 10 | "ghi" +11 11 | ) +12 12 | f = ( +13 |- f"a" + 13 |+ "a" +14 14 | F"b" +15 15 | "c" +16 16 | rf"d" + +F541.py:14:5: F541 [*] f-string without any placeholders + | +12 | f = ( +13 | f"a" +14 | F"b" + | ^^^^ F541 +15 | "c" +16 | rf"d" + | + = help: Remove extraneous `f` prefix + +ℹ Fix +11 11 | ) +12 12 | f = ( +13 13 | f"a" +14 |- F"b" + 14 |+ "b" +15 15 | "c" +16 16 | rf"d" +17 17 | fr"e" + +F541.py:16:5: F541 [*] f-string without any placeholders + | +14 | F"b" +15 | "c" +16 | rf"d" + | ^^^^^ F541 +17 | fr"e" +18 | ) + | + = help: Remove extraneous `f` prefix + +ℹ Fix +13 13 | f"a" +14 14 | F"b" +15 15 | "c" +16 |- rf"d" + 16 |+ r"d" +17 17 | fr"e" +18 18 | ) +19 19 | g = f"" + +F541.py:17:5: F541 [*] f-string without any placeholders + | +15 | "c" +16 | rf"d" +17 | fr"e" + | ^^^^^ F541 +18 | ) +19 | g = f"" + | + = help: Remove extraneous `f` prefix + +ℹ Fix +14 14 | F"b" +15 15 | "c" +16 16 | rf"d" +17 |- fr"e" + 17 |+ r"e" +18 18 | ) +19 19 | g = f"" +20 20 | + +F541.py:19:5: F541 [*] f-string without any placeholders + | +17 | fr"e" +18 | ) +19 | g = f"" + | ^^^ F541 +20 | +21 | # OK + | + = help: Remove extraneous `f` prefix + +ℹ Fix +16 16 | rf"d" +17 17 | fr"e" +18 18 | ) +19 |-g = f"" + 19 |+g = "" +20 20 | +21 21 | # OK +22 22 | g = f"ghi{123:{45}}" + +F541.py:25:13: F541 [*] f-string without any placeholders + | +24 | # Error +25 | h = "x" "y" f"z" + | ^^^^ F541 +26 | +27 | v = 23.234234 + | + = help: Remove extraneous `f` prefix + +ℹ Fix +22 22 | g = f"ghi{123:{45}}" +23 23 | +24 24 | # Error +25 |-h = "x" "y" f"z" + 25 |+h = "x" "y" "z" +26 26 | +27 27 | v = 23.234234 +28 28 | + +F541.py:34:7: F541 [*] f-string without any placeholders + | +33 | # Errors +34 | f"{v:{f'0.2f'}}" + | ^^^^^^^ F541 +35 | f"{f''}" +36 | f"{{test}}" + | + = help: Remove extraneous `f` prefix + +ℹ Fix +31 31 | f"{f'{v:0.2f}'}" +32 32 | +33 33 | # Errors +34 |-f"{v:{f'0.2f'}}" + 34 |+f"{v:{'0.2f'}}" +35 35 | f"{f''}" +36 36 | f"{{test}}" +37 37 | f'{{ 40 }}' + +F541.py:35:4: F541 [*] f-string without any placeholders + | +33 | # Errors +34 | f"{v:{f'0.2f'}}" +35 | f"{f''}" + | ^^^ F541 +36 | f"{{test}}" +37 | f'{{ 40 }}' + | + = help: Remove extraneous `f` prefix + +ℹ Fix +32 32 | +33 33 | # Errors +34 34 | f"{v:{f'0.2f'}}" +35 |-f"{f''}" + 35 |+f"{''}" +36 36 | f"{{test}}" +37 37 | f'{{ 40 }}' +38 38 | f"{{a {{x}}" + +F541.py:36:1: F541 [*] f-string without any placeholders + | +34 | f"{v:{f'0.2f'}}" +35 | f"{f''}" +36 | f"{{test}}" + | ^^^^^^^^^^^ F541 +37 | f'{{ 40 }}' +38 | f"{{a {{x}}" + | + = help: Remove extraneous `f` prefix + +ℹ Fix +33 33 | # Errors +34 34 | f"{v:{f'0.2f'}}" +35 35 | f"{f''}" +36 |-f"{{test}}" + 36 |+"{test}" +37 37 | f'{{ 40 }}' +38 38 | f"{{a {{x}}" +39 39 | f"{{{{x}}}}" + +F541.py:37:1: F541 [*] f-string without any placeholders + | +35 | f"{f''}" +36 | f"{{test}}" +37 | f'{{ 40 }}' + | ^^^^^^^^^^^ F541 +38 | f"{{a {{x}}" +39 | f"{{{{x}}}}" + | + = help: Remove extraneous `f` prefix + +ℹ Fix +34 34 | f"{v:{f'0.2f'}}" +35 35 | f"{f''}" +36 36 | f"{{test}}" +37 |-f'{{ 40 }}' + 37 |+'{ 40 }' +38 38 | f"{{a {{x}}" +39 39 | f"{{{{x}}}}" +40 40 | ""f"" + +F541.py:38:1: F541 [*] f-string without any placeholders + | +36 | f"{{test}}" +37 | f'{{ 40 }}' +38 | f"{{a {{x}}" + | ^^^^^^^^^^^^ F541 +39 | f"{{{{x}}}}" +40 | ""f"" + | + = help: Remove extraneous `f` prefix + +ℹ Fix +35 35 | f"{f''}" +36 36 | f"{{test}}" +37 37 | f'{{ 40 }}' +38 |-f"{{a {{x}}" + 38 |+"{a {x}" +39 39 | f"{{{{x}}}}" +40 40 | ""f"" +41 41 | ''f"" + +F541.py:39:1: F541 [*] f-string without any placeholders + | +37 | f'{{ 40 }}' +38 | f"{{a {{x}}" +39 | f"{{{{x}}}}" + | ^^^^^^^^^^^^ F541 +40 | ""f"" +41 | ''f"" + | + = help: Remove extraneous `f` prefix + +ℹ Fix +36 36 | f"{{test}}" +37 37 | f'{{ 40 }}' +38 38 | f"{{a {{x}}" +39 |-f"{{{{x}}}}" + 39 |+"{{x}}" +40 40 | ""f"" +41 41 | ''f"" +42 42 | (""f""r"") + +F541.py:40:3: F541 [*] f-string without any placeholders + | +38 | f"{{a {{x}}" +39 | f"{{{{x}}}}" +40 | ""f"" + | ^^^ F541 +41 | ''f"" +42 | (""f""r"") + | + = help: Remove extraneous `f` prefix + +ℹ Fix +37 37 | f'{{ 40 }}' +38 38 | f"{{a {{x}}" +39 39 | f"{{{{x}}}}" +40 |-""f"" + 40 |+"" "" +41 41 | ''f"" +42 42 | (""f""r"") +43 43 | + +F541.py:41:3: F541 [*] f-string without any placeholders + | +39 | f"{{{{x}}}}" +40 | ""f"" +41 | ''f"" + | ^^^ F541 +42 | (""f""r"") + | + = help: Remove extraneous `f` prefix + +ℹ Fix +38 38 | f"{{a {{x}}" +39 39 | f"{{{{x}}}}" +40 40 | ""f"" +41 |-''f"" + 41 |+''"" +42 42 | (""f""r"") +43 43 | +44 44 | # To be fixed + +F541.py:42:4: F541 [*] f-string without any placeholders + | +40 | ""f"" +41 | ''f"" +42 | (""f""r"") + | ^^^ F541 +43 | +44 | # To be fixed + | + = help: Remove extraneous `f` prefix + +ℹ Fix +39 39 | f"{{{{x}}}}" +40 40 | ""f"" +41 41 | ''f"" +42 |-(""f""r"") + 42 |+("" ""r"") +43 43 | +44 44 | # To be fixed +45 45 | # Error: f-string: single '}' is not allowed at line 41 column 8 + + 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 new file mode 100644 index 0000000000..60699ba130 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F601_F601.py.snap @@ -0,0 +1,284 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F601.py:3:5: F601 Dictionary key literal `"a"` repeated + | +1 | x = { +2 | "a": 1, +3 | "a": 2, + | ^^^ F601 +4 | "b": 3, +5 | ("a", "b"): 3, + | + = help: Remove repeated key literal `"a"` + +F601.py:6:5: F601 Dictionary key literal `("a", "b")` repeated + | +4 | "b": 3, +5 | ("a", "b"): 3, +6 | ("a", "b"): 4, + | ^^^^^^^^^^ F601 +7 | 1.0: 2, +8 | 1: 0, + | + = help: Remove repeated key literal `("a", "b")` + +F601.py:9:5: F601 Dictionary key literal `1` repeated + | + 7 | 1.0: 2, + 8 | 1: 0, + 9 | 1: 3, + | ^ F601 +10 | b"123": 1, +11 | b"123": 4, + | + = help: Remove repeated key literal `1` + +F601.py:11:5: F601 Dictionary key literal `b"123"` repeated + | + 9 | 1: 3, +10 | b"123": 1, +11 | b"123": 4, + | ^^^^^^ F601 +12 | } + | + = help: Remove repeated key literal `b"123"` + +F601.py:16:5: F601 Dictionary key literal `"a"` repeated + | +14 | x = { +15 | "a": 1, +16 | "a": 2, + | ^^^ F601 +17 | "a": 3, +18 | "a": 3, + | + = help: Remove repeated key literal `"a"` + +F601.py:17:5: F601 Dictionary key literal `"a"` repeated + | +15 | "a": 1, +16 | "a": 2, +17 | "a": 3, + | ^^^ F601 +18 | "a": 3, +19 | } + | + = help: Remove repeated key literal `"a"` + +F601.py:18:5: F601 [*] Dictionary key literal `"a"` repeated + | +16 | "a": 2, +17 | "a": 3, +18 | "a": 3, + | ^^^ F601 +19 | } + | + = help: Remove repeated key literal `"a"` + +ℹ Suggested fix +15 15 | "a": 1, +16 16 | "a": 2, +17 17 | "a": 3, +18 |- "a": 3, +19 18 | } +20 19 | +21 20 | x = { + +F601.py:23:5: F601 Dictionary key literal `"a"` repeated + | +21 | x = { +22 | "a": 1, +23 | "a": 2, + | ^^^ F601 +24 | "a": 3, +25 | "a": 3, + | + = help: Remove repeated key literal `"a"` + +F601.py:24:5: F601 Dictionary key literal `"a"` repeated + | +22 | "a": 1, +23 | "a": 2, +24 | "a": 3, + | ^^^ F601 +25 | "a": 3, +26 | "a": 4, + | + = help: Remove repeated key literal `"a"` + +F601.py:25:5: F601 [*] Dictionary key literal `"a"` repeated + | +23 | "a": 2, +24 | "a": 3, +25 | "a": 3, + | ^^^ F601 +26 | "a": 4, +27 | } + | + = help: Remove repeated key literal `"a"` + +ℹ Suggested fix +22 22 | "a": 1, +23 23 | "a": 2, +24 24 | "a": 3, +25 |- "a": 3, +26 25 | "a": 4, +27 26 | } +28 27 | + +F601.py:26:5: F601 Dictionary key literal `"a"` repeated + | +24 | "a": 3, +25 | "a": 3, +26 | "a": 4, + | ^^^ F601 +27 | } + | + = help: Remove repeated key literal `"a"` + +F601.py:31:5: F601 [*] Dictionary key literal `"a"` repeated + | +29 | x = { +30 | "a": 1, +31 | "a": 1, + | ^^^ F601 +32 | "a": 2, +33 | "a": 3, + | + = help: Remove repeated key literal `"a"` + +ℹ Suggested fix +28 28 | +29 29 | x = { +30 30 | "a": 1, +31 |- "a": 1, +32 31 | "a": 2, +33 32 | "a": 3, +34 33 | "a": 4, + +F601.py:32:5: F601 Dictionary key literal `"a"` repeated + | +30 | "a": 1, +31 | "a": 1, +32 | "a": 2, + | ^^^ F601 +33 | "a": 3, +34 | "a": 4, + | + = help: Remove repeated key literal `"a"` + +F601.py:33:5: F601 Dictionary key literal `"a"` repeated + | +31 | "a": 1, +32 | "a": 2, +33 | "a": 3, + | ^^^ F601 +34 | "a": 4, +35 | } + | + = help: Remove repeated key literal `"a"` + +F601.py:34:5: F601 Dictionary key literal `"a"` repeated + | +32 | "a": 2, +33 | "a": 3, +34 | "a": 4, + | ^^^ F601 +35 | } + | + = help: Remove repeated key literal `"a"` + +F601.py:41:5: F601 Dictionary key literal `"a"` repeated + | +39 | "a": 1, +40 | a: 1, +41 | "a": 2, + | ^^^ F601 +42 | a: 2, +43 | "a": 3, + | + = help: Remove repeated key literal `"a"` + +F601.py:43:5: F601 Dictionary key literal `"a"` repeated + | +41 | "a": 2, +42 | a: 2, +43 | "a": 3, + | ^^^ F601 +44 | a: 3, +45 | "a": 3, + | + = help: Remove repeated key literal `"a"` + +F601.py:45:5: F601 [*] Dictionary key literal `"a"` repeated + | +43 | "a": 3, +44 | a: 3, +45 | "a": 3, + | ^^^ F601 +46 | a: 4, +47 | } + | + = help: Remove repeated key literal `"a"` + +ℹ Suggested fix +42 42 | a: 2, +43 43 | "a": 3, +44 44 | a: 3, +45 |- "a": 3, +46 45 | a: 4, +47 46 | } +48 47 | + +F601.py:49:14: F601 [*] Dictionary key literal `"a"` repeated + | +47 | } +48 | +49 | x = {"a": 1, "a": 1} + | ^^^ F601 +50 | x = {"a": 1, "b": 2, "a": 1} + | + = help: Remove repeated key literal `"a"` + +ℹ Suggested fix +46 46 | a: 4, +47 47 | } +48 48 | +49 |-x = {"a": 1, "a": 1} + 49 |+x = {"a": 1} +50 50 | x = {"a": 1, "b": 2, "a": 1} +51 51 | +52 52 | x = { + +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 | +52 | x = { + | + = help: Remove repeated key literal `"a"` + +ℹ Suggested fix +47 47 | } +48 48 | +49 49 | x = {"a": 1, "a": 1} +50 |-x = {"a": 1, "b": 2, "a": 1} + 50 |+x = {"a": 1, "b": 2} +51 51 | +52 52 | x = { +53 53 | ('a', 'b'): 'asdf', + +F601.py:54:5: F601 Dictionary key literal `('a', 'b')` repeated + | +52 | x = { +53 | ('a', 'b'): 'asdf', +54 | ('a', 'b'): 'qwer', + | ^^^^^^^^^^ F601 +55 | } + | + = help: Remove repeated key literal `('a', 'b')` + + 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 new file mode 100644 index 0000000000..378346592a --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F602_F602.py.snap @@ -0,0 +1,245 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F602.py:5:5: F602 Dictionary key `a` repeated + | +3 | x = { +4 | a: 1, +5 | a: 2, + | ^ F602 +6 | b: 3, +7 | } + | + = help: Remove repeated key `a` + +F602.py:11:5: F602 Dictionary key `a` repeated + | + 9 | x = { +10 | a: 1, +11 | a: 2, + | ^ F602 +12 | a: 3, +13 | a: 3, + | + = help: Remove repeated key `a` + +F602.py:12:5: F602 Dictionary key `a` repeated + | +10 | a: 1, +11 | a: 2, +12 | a: 3, + | ^ F602 +13 | a: 3, +14 | } + | + = help: Remove repeated key `a` + +F602.py:13:5: F602 [*] Dictionary key `a` repeated + | +11 | a: 2, +12 | a: 3, +13 | a: 3, + | ^ F602 +14 | } + | + = help: Remove repeated key `a` + +ℹ Suggested fix +10 10 | a: 1, +11 11 | a: 2, +12 12 | a: 3, +13 |- a: 3, +14 13 | } +15 14 | +16 15 | x = { + +F602.py:18:5: F602 Dictionary key `a` repeated + | +16 | x = { +17 | a: 1, +18 | a: 2, + | ^ F602 +19 | a: 3, +20 | a: 3, + | + = help: Remove repeated key `a` + +F602.py:19:5: F602 Dictionary key `a` repeated + | +17 | a: 1, +18 | a: 2, +19 | a: 3, + | ^ F602 +20 | a: 3, +21 | a: 4, + | + = help: Remove repeated key `a` + +F602.py:20:5: F602 [*] Dictionary key `a` repeated + | +18 | a: 2, +19 | a: 3, +20 | a: 3, + | ^ F602 +21 | a: 4, +22 | } + | + = help: Remove repeated key `a` + +ℹ Suggested fix +17 17 | a: 1, +18 18 | a: 2, +19 19 | a: 3, +20 |- a: 3, +21 20 | a: 4, +22 21 | } +23 22 | + +F602.py:21:5: F602 Dictionary key `a` repeated + | +19 | a: 3, +20 | a: 3, +21 | a: 4, + | ^ F602 +22 | } + | + = help: Remove repeated key `a` + +F602.py:26:5: F602 [*] Dictionary key `a` repeated + | +24 | x = { +25 | a: 1, +26 | a: 1, + | ^ F602 +27 | a: 2, +28 | a: 3, + | + = help: Remove repeated key `a` + +ℹ Suggested fix +23 23 | +24 24 | x = { +25 25 | a: 1, +26 |- a: 1, +27 26 | a: 2, +28 27 | a: 3, +29 28 | a: 4, + +F602.py:27:5: F602 Dictionary key `a` repeated + | +25 | a: 1, +26 | a: 1, +27 | a: 2, + | ^ F602 +28 | a: 3, +29 | a: 4, + | + = help: Remove repeated key `a` + +F602.py:28:5: F602 Dictionary key `a` repeated + | +26 | a: 1, +27 | a: 2, +28 | a: 3, + | ^ F602 +29 | a: 4, +30 | } + | + = help: Remove repeated key `a` + +F602.py:29:5: F602 Dictionary key `a` repeated + | +27 | a: 2, +28 | a: 3, +29 | a: 4, + | ^ F602 +30 | } + | + = help: Remove repeated key `a` + +F602.py:35:5: F602 [*] Dictionary key `a` repeated + | +33 | a: 1, +34 | "a": 1, +35 | a: 1, + | ^ F602 +36 | "a": 2, +37 | a: 2, + | + = help: Remove repeated key `a` + +ℹ Suggested fix +32 32 | x = { +33 33 | a: 1, +34 34 | "a": 1, +35 |- a: 1, +36 35 | "a": 2, +37 36 | a: 2, +38 37 | "a": 3, + +F602.py:37:5: F602 Dictionary key `a` repeated + | +35 | a: 1, +36 | "a": 2, +37 | a: 2, + | ^ F602 +38 | "a": 3, +39 | a: 3, + | + = help: Remove repeated key `a` + +F602.py:39:5: F602 Dictionary key `a` repeated + | +37 | a: 2, +38 | "a": 3, +39 | a: 3, + | ^ F602 +40 | "a": 3, +41 | a: 4, + | + = help: Remove repeated key `a` + +F602.py:41:5: F602 Dictionary key `a` repeated + | +39 | a: 3, +40 | "a": 3, +41 | a: 4, + | ^ F602 +42 | } + | + = help: Remove repeated key `a` + +F602.py:44:12: F602 [*] Dictionary key `a` repeated + | +42 | } +43 | +44 | x = {a: 1, a: 1} + | ^ F602 +45 | x = {a: 1, b: 2, a: 1} + | + = help: Remove repeated key `a` + +ℹ Suggested fix +41 41 | a: 4, +42 42 | } +43 43 | +44 |-x = {a: 1, a: 1} + 44 |+x = {a: 1} +45 45 | x = {a: 1, b: 2, a: 1} + +F602.py:45:18: F602 [*] Dictionary key `a` repeated + | +44 | x = {a: 1, a: 1} +45 | x = {a: 1, b: 2, a: 1} + | ^ F602 + | + = help: Remove repeated key `a` + +ℹ Suggested fix +42 42 | } +43 43 | +44 44 | x = {a: 1, a: 1} +45 |-x = {a: 1, b: 2, a: 1} + 45 |+x = {a: 1, b: 2} + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F622_F622.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F622_F622.py.snap new file mode 100644 index 0000000000..b014fae36a --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F622_F622.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F622.py:1:1: F622 Two starred expressions in assignment + | +1 | *a, *b, c = (1, 2, 3) + | ^^^^^^^^^ F622 +2 | *a, b, c = (1, 2, 3) +3 | a, b, *c = (1, 2, 3) + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F631_F631.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F631_F631.py.snap new file mode 100644 index 0000000000..dea3b048ee --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F631_F631.py.snap @@ -0,0 +1,21 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F631.py:1:1: F631 Assert test is a non-empty tuple, which is always `True` + | +1 | assert (False, "x") + | ^^^^^^^^^^^^^^^^^^^ F631 +2 | assert (False,) +3 | assert () + | + +F631.py:2:1: F631 Assert test is a non-empty tuple, which is always `True` + | +1 | assert (False, "x") +2 | assert (False,) + | ^^^^^^^^^^^^^^^ F631 +3 | assert () +4 | assert True + | + + 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 new file mode 100644 index 0000000000..b23df34224 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F632_F632.py.snap @@ -0,0 +1,185 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F632.py:1:4: F632 [*] Use `==` to compare constant literals + | +1 | if x is "abc": + | ^^^^^^^^^^ F632 +2 | pass + | + = help: Replace `is` with `==` + +ℹ Fix +1 |-if x is "abc": + 1 |+if x == "abc": +2 2 | pass +3 3 | +4 4 | if 123 is not y: + +F632.py:4:4: F632 [*] Use `!=` to compare constant literals + | +2 | pass +3 | +4 | if 123 is not y: + | ^^^^^^^^^^^^ F632 +5 | pass + | + = help: Replace `is not` with `!=` + +ℹ Fix +1 1 | if x is "abc": +2 2 | pass +3 3 | +4 |-if 123 is not y: + 4 |+if 123 != y: +5 5 | pass +6 6 | +7 7 | if 123 is \ + +F632.py:7:4: F632 [*] Use `!=` to compare constant literals + | +5 | pass +6 | +7 | if 123 is \ + | ____^ +8 | | not y: + | |_____________^ F632 +9 | pass + | + = help: Replace `is not` with `!=` + +ℹ Fix +4 4 | if 123 is not y: +5 5 | pass +6 6 | +7 |-if 123 is \ +8 |- not y: + 7 |+if 123 != y: +9 8 | pass +10 9 | +11 10 | if "123" is x < 3: + +F632.py:11:4: F632 [*] Use `==` to compare constant literals + | + 9 | pass +10 | +11 | if "123" is x < 3: + | ^^^^^^^^^^^^^^ F632 +12 | pass + | + = help: Replace `is` with `==` + +ℹ Fix +8 8 | not y: +9 9 | pass +10 10 | +11 |-if "123" is x < 3: + 11 |+if "123" == x < 3: +12 12 | pass +13 13 | +14 14 | if "123" != x is 3: + +F632.py:14:4: F632 [*] Use `==` to compare constant literals + | +12 | pass +13 | +14 | if "123" != x is 3: + | ^^^^^^^^^^^^^^^ F632 +15 | pass + | + = help: Replace `is` with `==` + +ℹ Fix +11 11 | if "123" is x < 3: +12 12 | pass +13 13 | +14 |-if "123" != x is 3: + 14 |+if "123" != x == 3: +15 15 | pass +16 16 | +17 17 | if ("123" != x) is 3: + +F632.py:17:4: F632 [*] Use `==` to compare constant literals + | +15 | pass +16 | +17 | if ("123" != x) is 3: + | ^^^^^^^^^^^^^^^^^ F632 +18 | pass + | + = help: Replace `is` with `==` + +ℹ Fix +14 14 | if "123" != x is 3: +15 15 | pass +16 16 | +17 |-if ("123" != x) is 3: + 17 |+if ("123" != x) == 3: +18 18 | pass +19 19 | +20 20 | if "123" != (x is 3): + +F632.py:20:14: F632 [*] Use `==` to compare constant literals + | +18 | pass +19 | +20 | if "123" != (x is 3): + | ^^^^^^ F632 +21 | pass + | + = help: Replace `is` with `==` + +ℹ Fix +17 17 | if ("123" != x) is 3: +18 18 | pass +19 19 | +20 |-if "123" != (x is 3): + 20 |+if "123" != (x == 3): +21 21 | pass +22 22 | +23 23 | {2 is + +F632.py:23:2: F632 [*] Use `!=` to compare constant literals + | +21 | pass +22 | +23 | {2 is + | __^ +24 | | not ''} + | |______^ F632 +25 | +26 | {2 is + | + = help: Replace `is not` with `!=` + +ℹ Fix +20 20 | if "123" != (x is 3): +21 21 | pass +22 22 | +23 |-{2 is +24 |-not ''} + 23 |+{2 != ''} +25 24 | +26 25 | {2 is +27 26 | not ''} + +F632.py:26:2: F632 [*] Use `!=` to compare constant literals + | +24 | not ''} +25 | +26 | {2 is + | __^ +27 | | not ''} + | |_______^ F632 + | + = help: Replace `is not` with `!=` + +ℹ Fix +23 23 | {2 is +24 24 | not ''} +25 25 | +26 |-{2 is +27 |- not ''} + 26 |+{2 != ''} + + 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 new file mode 100644 index 0000000000..5fbf56d084 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F633_F633.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F633.py:4:1: F633 Use of `>>` is invalid with `print` function + | +2 | import sys +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 new file mode 100644 index 0000000000..428488bbe6 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F634_F634.py.snap @@ -0,0 +1,31 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F634.py:1:4: F634 If test is a tuple, which is always `True` + | +1 | if (1, 2): + | ^^^^^^ F634 +2 | pass + | + +F634.py:4:4: F634 If test is a tuple, which is always `True` + | +2 | pass +3 | +4 | if (3, 4): + | ^^^^^^ F634 +5 | pass +6 | elif foo: + | + +F634.py:12:10: F634 If test is a tuple, which is always `True` + | +10 | if True: +11 | pass +12 | elif (3, 4): + | ^^^^^^ F634 +13 | pass +14 | elif (): + | + + 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 new file mode 100644 index 0000000000..008343d914 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F701_F701.py.snap @@ -0,0 +1,35 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F701.py:4:5: F701 `break` outside loop + | +2 | break +3 | else: +4 | break + | ^^^^^ F701 +5 | +6 | i = 0 + | + +F701.py:16:5: F701 `break` outside loop + | +14 | break +15 | +16 | break + | ^^^^^ F701 + | + +F701.py:20:5: F701 `break` outside loop + | +19 | class Foo: +20 | break + | ^^^^^ F701 + | + +F701.py:23:1: F701 `break` outside loop + | +23 | 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 new file mode 100644 index 0000000000..4ef5ce2669 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F702_F702.py.snap @@ -0,0 +1,35 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F702.py:4:5: F702 `continue` not properly in loop + | +2 | continue +3 | else: +4 | continue + | ^^^^^^^^ F702 +5 | +6 | i = 0 + | + +F702.py:16:5: F702 `continue` not properly in loop + | +14 | continue +15 | +16 | continue + | ^^^^^^^^ F702 + | + +F702.py:20:5: F702 `continue` not properly in loop + | +19 | class Foo: +20 | continue + | ^^^^^^^^ F702 + | + +F702.py:23:1: F702 `continue` not properly in loop + | +23 | continue + | ^^^^^^^^ F702 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F704_F704.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F704_F704.py.snap new file mode 100644 index 0000000000..57efd26c39 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F704_F704.py.snap @@ -0,0 +1,35 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F704.py:6:5: F704 `yield` statement outside of a function + | +5 | class Foo: +6 | yield 2 + | ^^^^^^^ F704 + | + +F704.py:9:1: F704 `yield` statement outside of a function + | + 9 | yield 3 + | ^^^^^^^ F704 +10 | yield from 3 +11 | await f() + | + +F704.py:10:1: F704 `yield from` statement outside of a function + | + 9 | yield 3 +10 | yield from 3 + | ^^^^^^^^^^^^ F704 +11 | await f() + | + +F704.py:11:1: F704 `await` statement outside of a function + | + 9 | yield 3 +10 | yield from 3 +11 | await f() + | ^^^^^^^^^ F704 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F706_F706.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F706_F706.py.snap new file mode 100644 index 0000000000..921cc6b28a --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F706_F706.py.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F706.py:6:5: F706 `return` statement outside of a function/method + | +5 | class Foo: +6 | return 2 + | ^^^^^^^^ F706 + | + +F706.py:9:1: F706 `return` statement outside of a function/method + | +9 | return 3 + | ^^^^^^^^ F706 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F707_F707.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F707_F707.py.snap new file mode 100644 index 0000000000..72bbed1abc --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F707_F707.py.snap @@ -0,0 +1,34 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F707.py:3:1: F707 An `except` block as not the last exception handler + | +1 | try: +2 | pass +3 | except: + | ^^^^^^ F707 +4 | pass +5 | except ValueError: + | + +F707.py:10:1: F707 An `except` block as not the last exception handler + | + 8 | try: + 9 | pass +10 | except: + | ^^^^^^ F707 +11 | pass +12 | except ValueError: + | + +F707.py:19:1: F707 An `except` block as not the last exception handler + | +17 | try: +18 | pass +19 | except: + | ^^^^^^ F707 +20 | pass +21 | except ValueError: + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F722_F722.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F722_F722.py.snap new file mode 100644 index 0000000000..500f1ca729 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F722_F722.py.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F722.py:9:12: F722 Syntax error in forward annotation: `///` + | + 9 | def g() -> "///": + | ^^^^^ F722 +10 | pass + | + +F722.py:13:4: F722 Syntax error in forward annotation: `List[int]☃` + | +13 | X: """List[int]"""'☃' = [] + | ^^^^^^^^^^^^^^^^^^ F722 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_0.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_0.py.snap new file mode 100644 index 0000000000..1b8ba23d08 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_0.py.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_0.py:10:5: F811 Redefinition of unused `bar` from line 6 + | +10 | def bar(): + | ^^^ F811 +11 | pass + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_1.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_1.py.snap new file mode 100644 index 0000000000..196fcfd1c3 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_1.py.snap @@ -0,0 +1,10 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_1.py:1:25: F811 Redefinition of unused `FU` from line 1 + | +1 | import fu as FU, bar as FU + | ^^ F811 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_10.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_10.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_10.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_11.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_11.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_11.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_12.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_12.py.snap new file mode 100644 index 0000000000..3582a992fd --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_12.py.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_12.py:6:20: F811 Redefinition of unused `mixer` from line 2 + | +4 | pass +5 | else: +6 | from bb import mixer + | ^^^^^ F811 +7 | mixer(123) + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_13.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_13.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_13.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_14.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_14.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_14.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_15.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_15.py.snap new file mode 100644 index 0000000000..ee9654382c --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_15.py.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_15.py:4:5: F811 Redefinition of unused `fu` from line 1 + | +4 | def fu(): + | ^^ F811 +5 | pass + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_16.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_16.py.snap new file mode 100644 index 0000000000..7a9b81e5e7 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_16.py.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_16.py:8:13: F811 Redefinition of unused `fu` from line 3 + | +6 | def bar(): +7 | def baz(): +8 | def fu(): + | ^^ F811 +9 | pass + | + + 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 new file mode 100644 index 0000000000..ebcb6d42a2 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_17.py.snap @@ -0,0 +1,21 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_17.py:6:12: F811 Redefinition of unused `fu` from line 2 + | +5 | def bar(): +6 | import fu + | ^^ F811 +7 | +8 | def baz(): + | + +F811_17.py:9:13: F811 Redefinition of unused `fu` from line 6 + | + 8 | def baz(): + 9 | def fu(): + | ^^ F811 +10 | pass + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_18.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_18.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_18.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_19.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_19.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_19.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_2.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_2.py.snap new file mode 100644 index 0000000000..c51c3fe03f --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_2.py.snap @@ -0,0 +1,10 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_2.py:1:34: F811 Redefinition of unused `FU` from line 1 + | +1 | from moo import fu as FU, bar as FU + | ^^ F811 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_20.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_20.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_20.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_21.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_21.py.snap new file mode 100644 index 0000000000..2cf8492603 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_21.py.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_21.py:32:5: F811 Redefinition of unused `Sequence` from line 26 + | +30 | from typing import ( +31 | List, # noqa: F811 +32 | Sequence, + | ^^^^^^^^ F811 +33 | ) + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_22.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_22.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_22.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_23.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_23.py.snap new file mode 100644 index 0000000000..4816ae23e8 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_23.py.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_23.py:4:15: F811 Redefinition of unused `foo` from line 3 + | +3 | import foo as foo +4 | import bar as foo + | ^^^ F811 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_24.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_24.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_24.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_25.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_25.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_25.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + 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 new file mode 100644 index 0000000000..142ee127fd --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_26.py.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_26.py:5:9: F811 Redefinition of unused `func` from line 2 + | +3 | pass +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_3.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_3.py.snap new file mode 100644 index 0000000000..81d8e6bb5b --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_3.py.snap @@ -0,0 +1,10 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_3.py:1:12: F811 Redefinition of unused `fu` from line 1 + | +1 | import fu; fu = 3 + | ^^ F811 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_4.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_4.py.snap new file mode 100644 index 0000000000..0877d0f556 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_4.py.snap @@ -0,0 +1,10 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_4.py:1:12: F811 Redefinition of unused `fu` from line 1 + | +1 | import fu; fu, bar = 3 + | ^^ F811 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_5.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_5.py.snap new file mode 100644 index 0000000000..e6217fbe58 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_5.py.snap @@ -0,0 +1,10 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_5.py:1:13: F811 Redefinition of unused `fu` from line 1 + | +1 | import fu; [fu, bar] = 3 + | ^^ F811 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_6.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_6.py.snap new file mode 100644 index 0000000000..afb110adb0 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_6.py.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_6.py:6:12: F811 Redefinition of unused `os` from line 5 + | +4 | if i == 1: +5 | import os +6 | import os + | ^^ F811 +7 | os.path + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_7.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_7.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_7.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_8.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_8.py.snap new file mode 100644 index 0000000000..9680f04573 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_8.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F811_8.py:5:12: F811 Redefinition of unused `os` from line 4 + | +3 | try: +4 | import os +5 | import os + | ^^ F811 +6 | except: +7 | pass + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_9.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_9.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F811_F811_9.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + 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 new file mode 100644 index 0000000000..1f6ee4d23c --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_0.py.snap @@ -0,0 +1,117 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F821_0.py:2:12: F821 Undefined name `self` + | +1 | def get_name(): +2 | return self.name + | ^^^^ F821 + | + +F821_0.py:6:13: F821 Undefined name `self` + | +5 | def get_name(): +6 | return (self.name,) + | ^^^^ F821 + | + +F821_0.py:10:9: F821 Undefined name `self` + | + 9 | def get_name(): +10 | del self.name + | ^^^^ F821 + | + +F821_0.py:21:12: F821 Undefined name `numeric_string` + | +20 | def randdec(maxprec, maxexp): +21 | return numeric_string(maxprec, maxexp) + | ^^^^^^^^^^^^^^ F821 + | + +F821_0.py:58:5: F821 Undefined name `Bar` + | +56 | y: int = 1 +57 | +58 | x: "Bar" = 1 + | ^^^ F821 +59 | +60 | [first] = ["yup"] + | + +F821_0.py:83:11: F821 Undefined name `TOMATO` + | +82 | def update_tomato(): +83 | print(TOMATO) + | ^^^^^^ F821 +84 | TOMATO = "cherry tomato" + | + +F821_0.py:87:8: F821 Undefined name `B` + | +87 | A = f'{B}' + | ^ F821 +88 | A = ( +89 | f'B' + | + +F821_0.py:90:8: F821 Undefined name `B` + | +88 | A = ( +89 | f'B' +90 | f'{B}' + | ^ F821 +91 | ) +92 | C = f'{A:{B}}' + | + +F821_0.py:92:11: F821 Undefined name `B` + | +90 | f'{B}' +91 | ) +92 | C = f'{A:{B}}' + | ^ F821 +93 | C = f'{A:{f"{B}"}}' + | + +F821_0.py:93:14: F821 Undefined name `B` + | +91 | ) +92 | C = f'{A:{B}}' +93 | C = f'{A:{f"{B}"}}' + | ^ F821 +94 | +95 | from typing import Annotated, Literal + | + +F821_0.py:115:10: F821 Undefined name `PEP593Test123` + | +113 | ] +114 | field_with_undefined_stringified_type: Annotated[ +115 | "PEP593Test123", + | ^^^^^^^^^^^^^ F821 +116 | 123, +117 | ] + | + +F821_0.py:123:15: F821 Undefined name `foo` + | +121 | ] +122 | field_with_undefined_nested_subscript: Annotated[ +123 | dict["foo", "bar"], # Expected to fail as undefined. + | ^^^ F821 +124 | 123, +125 | ] + | + +F821_0.py:123:22: F821 Undefined name `bar` + | +121 | ] +122 | field_with_undefined_nested_subscript: Annotated[ +123 | dict["foo", "bar"], # Expected to fail as undefined. + | ^^^ F821 +124 | 123, +125 | ] + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_1.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_1.py.snap new file mode 100644 index 0000000000..d928a61158 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_1.py.snap @@ -0,0 +1,32 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F821_1.py:11:11: F821 Undefined name `Model` + | +10 | # F821 Undefined name `Model` +11 | x = cast("Model", x) + | ^^^^^ F821 + | + +F821_1.py:18:18: F821 Undefined name `Model` + | +17 | # F821 Undefined name `Model` +18 | x = typing.cast("Model", x) + | ^^^^^ F821 + | + +F821_1.py:24:14: F821 Undefined name `Model` + | +23 | # F821 Undefined name `Model` +24 | x = Pattern["Model"] + | ^^^^^ F821 + | + +F821_1.py:30:12: F821 Undefined name `Model` + | +29 | # F821 Undefined name `Model` +30 | x = Match["Model"] + | ^^^^^ F821 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_10.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_10.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_10.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_11.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_11.py.snap new file mode 100644 index 0000000000..a2604bd8b8 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_11.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F821_11.py:18:28: F821 Undefined name `os` + | +18 | def f(x: Callable[[VarArg("os")], None]): # F821 + | ^^ F821 +19 | pass + | + +F821_11.py:23:14: F821 Undefined name `Baz` + | +22 | f(Callable[["Bar"], None]) +23 | f(Callable[["Baz"], None]) + | ^^^ F821 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_12.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_12.py.snap new file mode 100644 index 0000000000..1cb1eca885 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_12.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F821_12.py:20:28: F821 Undefined name `os` + | +20 | def f(x: Callable[[VarArg("os")], None]): # F821 + | ^^ F821 +21 | pass + | + +F821_12.py:25:14: F821 Undefined name `Baz` + | +24 | f(Callable[["Bar"], None]) +25 | f(Callable[["Baz"], None]) + | ^^^ F821 + | + + 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 new file mode 100644 index 0000000000..a82c199902 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_13.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F821_13.py:8:19: F821 Undefined name `List` + | +6 | Y: ForwardRef("List[int]") +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_14.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_14.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_14.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_15.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_15.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_15.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_16.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_16.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_16.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + 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 new file mode 100644 index 0000000000..38834e5e19 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_17.py.snap @@ -0,0 +1,178 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F821_17.py:16:12: F821 Undefined name `DoesNotExist` + | +14 | # Types used in aliased assignment must exist +15 | +16 | type Foo = DoesNotExist # F821: Undefined name `DoesNotExist` + | ^^^^^^^^^^^^ F821 +17 | type Foo = list[DoesNotExist] # F821: Undefined name `DoesNotExist` + | + +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 | +19 | # Type parameters do not escape alias scopes + | + +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 | +24 | # Type parameters in functions + | + +F821_17.py:39:17: F821 Undefined name `T` + | +37 | from some_library import some_decorator +38 | +39 | @some_decorator(T) # F821: Undefined name `T` - not accessible in decorators + | ^ F821 +40 | +41 | def foo[T](t: T) -> None: ... + | + +F821_17.py:42:1: F821 Undefined name `T` + | +41 | def foo[T](t: T) -> None: ... +42 | T # F821: Undefined name `T` - not accessible afterward function scope + | ^ F821 + | + +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 | +66 | class Foo[T](list[T]): ... + | + +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 | +69 | # Types specified in bounds should exist + | + +F821_17.py:71:13: F821 Undefined name `DoesNotExist` + | +69 | # Types specified in bounds should exist +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` +73 | class Foo[T: DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` + | + +F821_17.py:72:12: F821 Undefined name `DoesNotExist` + | +71 | type Foo[T: DoesNotExist] = T # F821: Undefined name `DoesNotExist` +72 | def foo[T: DoesNotExist](t: T) -> T: return t # F821: Undefined name `DoesNotExist` + | ^^^^^^^^^^^^ F821 +73 | class Foo[T: DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` + | + +F821_17.py:73:14: F821 Undefined name `DoesNotExist` + | +71 | type Foo[T: DoesNotExist] = T # 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 | +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 | +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` +77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` + | + +F821_17.py:75:29: F821 Undefined name `DoesNotExist2` + | +73 | class Foo[T: DoesNotExist](list[T]): ... # F821: Undefined name `DoesNotExist` +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` +77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` + | + +F821_17.py:76:13: F821 Undefined name `DoesNotExist1` + | +75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` +76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` + | ^^^^^^^^^^^^^ F821 +77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` + | + +F821_17.py:76:28: F821 Undefined name `DoesNotExist2` + | +75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` +76 | def foo[T: (DoesNotExist1, DoesNotExist2)](t: T) -> T: return t # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` + | ^^^^^^^^^^^^^ F821 +77 | class Foo[T: (DoesNotExist1, DoesNotExist2)](list[T]): ... # F821: Undefined name `DoesNotExist1`, Undefined name `DoesNotExist2` + | + +F821_17.py:77:15: F821 Undefined name `DoesNotExist1` + | +75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, 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 | +79 | # Type parameters in nested classes + | + +F821_17.py:77:30: F821 Undefined name `DoesNotExist2` + | +75 | type Foo[T: (DoesNotExist1, DoesNotExist2)] = T # F821: Undefined name `DoesNotExist1`, 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 | +79 | # Type parameters in nested classes + | + +F821_17.py:92:52: F821 Undefined name `t` + | +90 | return x +91 | +92 | def cannot_access_parent_variable(self, x: t) -> t: # F821: Undefined name `T` + | ^ F821 +93 | t # F821: Undefined name `t` +94 | return x + | + +F821_17.py:92:58: F821 Undefined name `t` + | +90 | return x +91 | +92 | def cannot_access_parent_variable(self, x: t) -> t: # F821: Undefined name `T` + | ^ F821 +93 | t # F821: Undefined name `t` +94 | return x + | + +F821_17.py:93:17: F821 Undefined name `t` + | +92 | def cannot_access_parent_variable(self, x: t) -> t: # F821: Undefined name `T` +93 | t # F821: Undefined name `t` + | ^ F821 +94 | return x + | + + 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 new file mode 100644 index 0000000000..2915f54728 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_2.py.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F821_2.py:5:13: F821 Undefined name `Model` + | +4 | # F821 Undefined name `Model` +5 | x: Literal["Model"] + | ^^^^^ F821 +6 | +7 | from typing_extensions import Literal + | + + 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 new file mode 100644 index 0000000000..294e412298 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_3.py.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F821_3.py:11:10: F821 Undefined name `key` + | + 9 | # F821 Undefined name `key` +10 | # F821 Undefined name `value` +11 | x: dict["key", "value"] + | ^^^ F821 +12 | +13 | # OK + | + +F821_3.py:11:17: F821 Undefined name `value` + | + 9 | # F821 Undefined name `key` +10 | # F821 Undefined name `value` +11 | x: dict["key", "value"] + | ^^^^^ F821 +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 new file mode 100644 index 0000000000..5b6a6bd2ee --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_4.py.snap @@ -0,0 +1,44 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F821_4.py:4:11: F821 Undefined name `Model` + | +2 | from typing import List +3 | +4 | _ = List["Model"] + | ^^^^^ F821 + | + +F821_4.py:9:12: F821 Undefined name `Model` + | +7 | from typing import List as IList +8 | +9 | _ = IList["Model"] + | ^^^^^ F821 + | + +F821_4.py:14:16: F821 Undefined name `Model` + | +12 | from collections.abc import ItemsView +13 | +14 | _ = ItemsView["Model"] + | ^^^^^ F821 + | + +F821_4.py:19:32: F821 Undefined name `Model` + | +17 | import collections.abc +18 | +19 | _ = collections.abc.ItemsView["Model"] + | ^^^^^ F821 + | + +F821_4.py:24:20: F821 Undefined name `Model` + | +22 | from collections import abc +23 | +24 | _ = abc.ItemsView["Model"] + | ^^^^^ F821 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_5.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_5.py.snap new file mode 100644 index 0000000000..59855f49c5 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_5.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F821_5.py:5:31: F821 Undefined name `InnerClass` + | +4 | class RandomClass: +5 | def random_func(self) -> "InnerClass": + | ^^^^^^^^^^ F821 +6 | pass + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_6.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_6.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_6.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_7.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_7.py.snap new file mode 100644 index 0000000000..2285bc9e54 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_7.py.snap @@ -0,0 +1,30 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F821_7.py:11:22: F821 Undefined name `Undefined` + | +10 | # Not OK +11 | _ = DefaultNamedArg("Undefined", name="some_prop_name") + | ^^^^^^^^^ F821 +12 | _ = DefaultNamedArg(type="Undefined", name="some_prop_name") +13 | _ = DefaultNamedArg("Undefined", "some_prop_name") + | + +F821_7.py:12:27: F821 Undefined name `Undefined` + | +10 | # Not OK +11 | _ = DefaultNamedArg("Undefined", name="some_prop_name") +12 | _ = DefaultNamedArg(type="Undefined", name="some_prop_name") + | ^^^^^^^^^ F821 +13 | _ = DefaultNamedArg("Undefined", "some_prop_name") + | + +F821_7.py:13:22: F821 Undefined name `Undefined` + | +11 | _ = DefaultNamedArg("Undefined", name="some_prop_name") +12 | _ = DefaultNamedArg(type="Undefined", name="some_prop_name") +13 | _ = DefaultNamedArg("Undefined", "some_prop_name") + | ^^^^^^^^^ F821 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_8.pyi.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_8.pyi.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_8.pyi.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_9.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_9.py.snap new file mode 100644 index 0000000000..b7a4023568 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_9.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F821_9.py:22:20: F821 Undefined name `captured` + | +20 | match provided: +21 | case True: +22 | return captured # F821 + | ^^^^^^^^ 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 new file mode 100644 index 0000000000..e4ced191b5 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_0.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F822_0.py:3:1: F822 Undefined name `b` in `__all__` + | +1 | a = 1 +2 | +3 | __all__ = ["a", "b"] + | ^^^^^^^ 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 new file mode 100644 index 0000000000..0e28a36803 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_1.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F822_1.py:3:1: F822 Undefined name `b` in `__all__` + | +1 | a = 1 +2 | +3 | __all__ = list(["a", "b"]) + | ^^^^^^^ F822 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_2.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_2.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F822_F822_2.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + 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 new file mode 100644 index 0000000000..f881e67454 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F823_F823.py.snap @@ -0,0 +1,46 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F823.py:6:5: F823 Local variable `my_var` referenced before assignment + | +5 | def foo(): +6 | my_var += 1 + | ^^^^^^ F823 + | + +F823.py:32:15: F823 Local variable `my_var` referenced before assignment + | +30 | class Class: +31 | def f(self): +32 | print(my_var) + | ^^^^^^ F823 +33 | my_var = 1 + | + +F823.py:40:15: F823 Local variable `my_var` referenced before assignment + | +39 | def f(self): +40 | print(my_var) + | ^^^^^^ F823 +41 | my_var = 1 + | + +F823.py:48:11: F823 Local variable `sys` referenced before assignment + | +47 | def main(): +48 | print(sys.argv) + | ^^^ F823 +49 | +50 | try: + | + +F823.py:62:11: F823 Local variable `sys` referenced before assignment + | +61 | def main(): +62 | print(sys.argv) + | ^^^ F823 +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 new file mode 100644 index 0000000000..e3f2fc6d02 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_0.py.snap @@ -0,0 +1,222 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F841_0.py:3:22: F841 [*] Local variable `e` is assigned to but never used + | +1 | try: +2 | 1 / 0 +3 | except ValueError as e: + | ^ F841 +4 | pass + | + = help: Remove assignment to unused variable `e` + +ℹ Fix +1 1 | try: +2 2 | 1 / 0 +3 |-except ValueError as e: + 3 |+except ValueError: +4 4 | pass +5 5 | +6 6 | + +F841_0.py:16:5: F841 [*] Local variable `z` is assigned to but never used + | +14 | x = 1 +15 | y = 2 +16 | z = x + y + | ^ F841 + | + = help: Remove assignment to unused variable `z` + +ℹ Suggested fix +13 13 | def f(): +14 14 | x = 1 +15 15 | y = 2 +16 |- z = x + y + 16 |+ x + y +17 17 | +18 18 | +19 19 | def f(): + +F841_0.py:20:5: F841 [*] Local variable `foo` is assigned to but never used + | +19 | def f(): +20 | foo = (1, 2) + | ^^^ F841 +21 | (a, b) = (1, 2) + | + = help: Remove assignment to unused variable `foo` + +ℹ Suggested fix +17 17 | +18 18 | +19 19 | def f(): +20 |- foo = (1, 2) +21 20 | (a, b) = (1, 2) +22 21 | +23 22 | bar = (1, 2) + +F841_0.py:21:6: F841 Local variable `a` is assigned to but never used + | +19 | def f(): +20 | foo = (1, 2) +21 | (a, b) = (1, 2) + | ^ F841 +22 | +23 | bar = (1, 2) + | + = help: Remove assignment to unused variable `a` + +F841_0.py:21:9: F841 Local variable `b` is assigned to but never used + | +19 | def f(): +20 | foo = (1, 2) +21 | (a, b) = (1, 2) + | ^ F841 +22 | +23 | bar = (1, 2) + | + = help: Remove assignment to unused variable `b` + +F841_0.py:26:14: F841 [*] Local variable `baz` is assigned to but never used + | +24 | (c, d) = bar +25 | +26 | (x, y) = baz = bar + | ^^^ F841 + | + = help: Remove assignment to unused variable `baz` + +ℹ Suggested fix +23 23 | bar = (1, 2) +24 24 | (c, d) = bar +25 25 | +26 |- (x, y) = baz = bar + 26 |+ (x, y) = bar +27 27 | +28 28 | +29 29 | def f(): + +F841_0.py:51:9: F841 [*] Local variable `b` is assigned to but never used + | +49 | def c(): +50 | # F841 +51 | b = 1 + | ^ F841 +52 | +53 | def d(): + | + = help: Remove assignment to unused variable `b` + +ℹ Suggested fix +48 48 | +49 49 | def c(): +50 50 | # F841 +51 |- b = 1 + 51 |+ pass +52 52 | +53 53 | def d(): +54 54 | nonlocal b + +F841_0.py:79:26: F841 [*] Local variable `my_file` is assigned to but never used + | +78 | def f(): +79 | with open("file") as my_file, open("") as ((this, that)): + | ^^^^^^^ F841 +80 | print("hello") + | + = help: Remove assignment to unused variable `my_file` + +ℹ Suggested fix +76 76 | +77 77 | +78 78 | def f(): +79 |- with open("file") as my_file, open("") as ((this, that)): + 79 |+ with open("file"), open("") as ((this, that)): +80 80 | print("hello") +81 81 | +82 82 | + +F841_0.py:85:25: F841 [*] Local variable `my_file` is assigned to but never used + | +83 | def f(): +84 | with ( +85 | open("file") as my_file, + | ^^^^^^^ F841 +86 | open("") as ((this, that)), +87 | ): + | + = help: Remove assignment to unused variable `my_file` + +ℹ Suggested fix +82 82 | +83 83 | def f(): +84 84 | with ( +85 |- open("file") as my_file, + 85 |+ open("file"), +86 86 | open("") as ((this, that)), +87 87 | ): +88 88 | print("hello") + +F841_0.py:102:5: F841 [*] Local variable `msg3` is assigned to but never used + | +100 | msg1 = "Hello, world!" +101 | msg2 = "Hello, world!" +102 | msg3 = "Hello, world!" + | ^^^^ F841 +103 | match x: +104 | case 1: + | + = help: Remove assignment to unused variable `msg3` + +ℹ Suggested fix +99 99 | def f(x: int): +100 100 | msg1 = "Hello, world!" +101 101 | msg2 = "Hello, world!" +102 |- msg3 = "Hello, world!" +103 102 | match x: +104 103 | case 1: +105 104 | print(msg1) + +F841_0.py:115:5: F841 [*] Local variable `Baz` is assigned to but never used + | +113 | Foo = enum.Enum("Foo", "A B") +114 | Bar = enum.Enum("Bar", "A B") +115 | Baz = enum.Enum("Baz", "A B") + | ^^^ F841 +116 | +117 | match x: + | + = help: Remove assignment to unused variable `Baz` + +ℹ Suggested fix +112 112 | +113 113 | Foo = enum.Enum("Foo", "A B") +114 114 | Bar = enum.Enum("Bar", "A B") +115 |- Baz = enum.Enum("Baz", "A B") + 115 |+ enum.Enum("Baz", "A B") +116 116 | +117 117 | match x: +118 118 | case (Foo.A): + +F841_0.py:122:14: F841 Local variable `y` is assigned to but never used + | +120 | case [Bar.A, *_]: +121 | print("A") +122 | case y: + | ^ F841 +123 | pass + | + = help: Remove assignment to unused variable `y` + +F841_0.py:127:21: F841 Local variable `value` is assigned to but never used + | +126 | def f(): +127 | if any((key := (value := x)) for x in ["ok"]): + | ^^^^^ F841 +128 | print(key) + | + = help: Remove assignment to unused variable `value` + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_1.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_1.py.snap new file mode 100644 index 0000000000..21aec0a0e5 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_1.py.snap @@ -0,0 +1,88 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F841_1.py:6:5: F841 Local variable `x` is assigned to but never used + | +5 | def f(): +6 | x, y = 1, 2 # this triggers F841 as it's just a simple assignment where unpacking isn't needed + | ^ F841 + | + = help: Remove assignment to unused variable `x` + +F841_1.py:6:8: F841 Local variable `y` is assigned to but never used + | +5 | def f(): +6 | x, y = 1, 2 # this triggers F841 as it's just a simple assignment where unpacking isn't needed + | ^ F841 + | + = help: Remove assignment to unused variable `y` + +F841_1.py:16:14: F841 [*] Local variable `coords` is assigned to but never used + | +15 | def f(): +16 | (x, y) = coords = 1, 2 # this triggers F841 on coords + | ^^^^^^ F841 + | + = help: Remove assignment to unused variable `coords` + +ℹ Suggested fix +13 13 | +14 14 | +15 15 | def f(): +16 |- (x, y) = coords = 1, 2 # this triggers F841 on coords + 16 |+ (x, y) = 1, 2 # this triggers F841 on coords +17 17 | +18 18 | +19 19 | def f(): + +F841_1.py:20:5: F841 [*] Local variable `coords` is assigned to but never used + | +19 | def f(): +20 | coords = (x, y) = 1, 2 # this triggers F841 on coords + | ^^^^^^ F841 + | + = help: Remove assignment to unused variable `coords` + +ℹ Suggested fix +17 17 | +18 18 | +19 19 | def f(): +20 |- coords = (x, y) = 1, 2 # this triggers F841 on coords + 20 |+ (x, y) = 1, 2 # this triggers F841 on coords +21 21 | +22 22 | +23 23 | def f(): + +F841_1.py:24:6: F841 Local variable `a` is assigned to but never used + | +23 | def f(): +24 | (a, b) = (x, y) = 1, 2 # this triggers F841 on everything + | ^ F841 + | + = help: Remove assignment to unused variable `a` + +F841_1.py:24:9: F841 Local variable `b` is assigned to but never used + | +23 | def f(): +24 | (a, b) = (x, y) = 1, 2 # this triggers F841 on everything + | ^ F841 + | + = help: Remove assignment to unused variable `b` + +F841_1.py:24:15: F841 Local variable `x` is assigned to but never used + | +23 | def f(): +24 | (a, b) = (x, y) = 1, 2 # this triggers F841 on everything + | ^ F841 + | + = help: Remove assignment to unused variable `x` + +F841_1.py:24:18: F841 Local variable `y` is assigned to but never used + | +23 | def f(): +24 | (a, b) = (x, y) = 1, 2 # this triggers F841 on everything + | ^ F841 + | + = help: Remove assignment to unused variable `y` + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_2.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_2.py.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_2.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + 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 new file mode 100644 index 0000000000..7527c4e2cd --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F841_F841_3.py.snap @@ -0,0 +1,696 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F841_3.py:5:5: F841 [*] Local variable `x` is assigned to but never used + | +4 | def f(): +5 | x = 1 + | ^ F841 +6 | y = 2 + | + = help: Remove assignment to unused variable `x` + +ℹ Suggested fix +2 2 | +3 3 | +4 4 | def f(): +5 |- x = 1 +6 5 | y = 2 +7 6 | +8 7 | z = 3 + +F841_3.py:6:5: F841 [*] Local variable `y` is assigned to but never used + | +4 | def f(): +5 | x = 1 +6 | y = 2 + | ^ F841 +7 | +8 | z = 3 + | + = help: Remove assignment to unused variable `y` + +ℹ Suggested fix +3 3 | +4 4 | def f(): +5 5 | x = 1 +6 |- y = 2 +7 6 | +8 7 | z = 3 +9 8 | print(z) + +F841_3.py:13:5: F841 [*] Local variable `x` is assigned to but never used + | +12 | def f(): +13 | x: int = 1 + | ^ F841 +14 | y: int = 2 + | + = help: Remove assignment to unused variable `x` + +ℹ Suggested fix +10 10 | +11 11 | +12 12 | def f(): +13 |- x: int = 1 +14 13 | y: int = 2 +15 14 | +16 15 | z: int = 3 + +F841_3.py:14:5: F841 [*] Local variable `y` is assigned to but never used + | +12 | def f(): +13 | x: int = 1 +14 | y: int = 2 + | ^ F841 +15 | +16 | z: int = 3 + | + = help: Remove assignment to unused variable `y` + +ℹ Suggested fix +11 11 | +12 12 | def f(): +13 13 | x: int = 1 +14 |- y: int = 2 +15 14 | +16 15 | z: int = 3 +17 16 | print(z) + +F841_3.py:21:19: F841 [*] Local variable `x1` is assigned to but never used + | +20 | def f(): +21 | with foo() as x1: + | ^^ F841 +22 | pass + | + = help: Remove assignment to unused variable `x1` + +ℹ Suggested fix +18 18 | +19 19 | +20 20 | def f(): +21 |- with foo() as x1: + 21 |+ with foo(): +22 22 | pass +23 23 | +24 24 | with foo() as (x2, y2): + +F841_3.py:27:20: F841 [*] Local variable `x3` is assigned to but never used + | +25 | pass +26 | +27 | with (foo() as x3, foo() as y3, foo() as z3): + | ^^ F841 +28 | pass + | + = help: Remove assignment to unused variable `x3` + +ℹ Suggested fix +24 24 | with foo() as (x2, y2): +25 25 | pass +26 26 | +27 |- with (foo() as x3, foo() as y3, foo() as z3): + 27 |+ with (foo(), foo() as y3, foo() as z3): +28 28 | pass +29 29 | +30 30 | + +F841_3.py:27:33: F841 [*] Local variable `y3` is assigned to but never used + | +25 | pass +26 | +27 | with (foo() as x3, foo() as y3, foo() as z3): + | ^^ F841 +28 | pass + | + = help: Remove assignment to unused variable `y3` + +ℹ Suggested fix +24 24 | with foo() as (x2, y2): +25 25 | pass +26 26 | +27 |- with (foo() as x3, foo() as y3, foo() as z3): + 27 |+ with (foo() as x3, foo(), foo() as z3): +28 28 | pass +29 29 | +30 30 | + +F841_3.py:27:46: F841 [*] Local variable `z3` is assigned to but never used + | +25 | pass +26 | +27 | with (foo() as x3, foo() as y3, foo() as z3): + | ^^ F841 +28 | pass + | + = help: Remove assignment to unused variable `z3` + +ℹ Suggested fix +24 24 | with foo() as (x2, y2): +25 25 | pass +26 26 | +27 |- with (foo() as x3, foo() as y3, foo() as z3): + 27 |+ with (foo() as x3, foo() as y3, foo()): +28 28 | pass +29 29 | +30 30 | + +F841_3.py:32:6: F841 Local variable `x1` is assigned to but never used + | +31 | def f(): +32 | (x1, y1) = (1, 2) + | ^^ F841 +33 | (x2, y2) = coords2 = (1, 2) +34 | coords3 = (x3, y3) = (1, 2) + | + = help: Remove assignment to unused variable `x1` + +F841_3.py:32:10: F841 Local variable `y1` is assigned to but never used + | +31 | def f(): +32 | (x1, y1) = (1, 2) + | ^^ F841 +33 | (x2, y2) = coords2 = (1, 2) +34 | coords3 = (x3, y3) = (1, 2) + | + = help: Remove assignment to unused variable `y1` + +F841_3.py:33:16: F841 [*] Local variable `coords2` is assigned to but never used + | +31 | def f(): +32 | (x1, y1) = (1, 2) +33 | (x2, y2) = coords2 = (1, 2) + | ^^^^^^^ F841 +34 | coords3 = (x3, y3) = (1, 2) + | + = help: Remove assignment to unused variable `coords2` + +ℹ Suggested fix +30 30 | +31 31 | def f(): +32 32 | (x1, y1) = (1, 2) +33 |- (x2, y2) = coords2 = (1, 2) + 33 |+ (x2, y2) = (1, 2) +34 34 | coords3 = (x3, y3) = (1, 2) +35 35 | +36 36 | + +F841_3.py:34:5: F841 [*] Local variable `coords3` is assigned to but never used + | +32 | (x1, y1) = (1, 2) +33 | (x2, y2) = coords2 = (1, 2) +34 | coords3 = (x3, y3) = (1, 2) + | ^^^^^^^ F841 + | + = help: Remove assignment to unused variable `coords3` + +ℹ Suggested fix +31 31 | def f(): +32 32 | (x1, y1) = (1, 2) +33 33 | (x2, y2) = coords2 = (1, 2) +34 |- coords3 = (x3, y3) = (1, 2) + 34 |+ (x3, y3) = (1, 2) +35 35 | +36 36 | +37 37 | def f(): + +F841_3.py:40:26: F841 [*] Local variable `x1` is assigned to but never used + | +38 | try: +39 | 1 / 0 +40 | except ValueError as x1: + | ^^ F841 +41 | pass + | + = help: Remove assignment to unused variable `x1` + +ℹ Fix +37 37 | def f(): +38 38 | try: +39 39 | 1 / 0 +40 |- except ValueError as x1: + 40 |+ except ValueError: +41 41 | pass +42 42 | +43 43 | try: + +F841_3.py:45:47: F841 [*] Local variable `x2` is assigned to but never used + | +43 | try: +44 | 1 / 0 +45 | except (ValueError, ZeroDivisionError) as x2: + | ^^ F841 +46 | pass + | + = help: Remove assignment to unused variable `x2` + +ℹ Fix +42 42 | +43 43 | try: +44 44 | 1 / 0 +45 |- except (ValueError, ZeroDivisionError) as x2: + 45 |+ except (ValueError, ZeroDivisionError): +46 46 | pass +47 47 | +48 48 | + +F841_3.py:50:5: F841 [*] Local variable `x` is assigned to but never used + | +49 | def f(a, b): +50 | x = ( + | ^ F841 +51 | a() +52 | if a is not None + | + = help: Remove assignment to unused variable `x` + +ℹ Suggested fix +47 47 | +48 48 | +49 49 | def f(a, b): +50 |- x = ( + 50 |+ ( +51 51 | a() +52 52 | if a is not None +53 53 | else b + +F841_3.py:56:5: F841 [*] Local variable `y` is assigned to but never used + | +54 | ) +55 | +56 | y = \ + | ^ F841 +57 | a() if a is not None else b + | + = help: Remove assignment to unused variable `y` + +ℹ Suggested fix +53 53 | else b +54 54 | ) +55 55 | +56 |- y = \ +57 |- a() if a is not None else b + 56 |+ a() if a is not None else b +58 57 | +59 58 | +60 59 | def f(a, b): + +F841_3.py:61:5: F841 [*] Local variable `x` is assigned to but never used + | +60 | def f(a, b): +61 | x = ( + | ^ F841 +62 | a +63 | if a is not None + | + = help: Remove assignment to unused variable `x` + +ℹ Suggested fix +58 58 | +59 59 | +60 60 | def f(a, b): +61 |- x = ( +62 |- a +63 |- if a is not None +64 |- else b +65 |- ) +66 61 | +67 62 | y = \ +68 63 | a if a is not None else b + +F841_3.py:67:5: F841 [*] Local variable `y` is assigned to but never used + | +65 | ) +66 | +67 | y = \ + | ^ F841 +68 | a if a is not None else b + | + = help: Remove assignment to unused variable `y` + +ℹ Suggested fix +64 64 | else b +65 65 | ) +66 66 | +67 |- y = \ +68 |- a if a is not None else b +69 67 | +70 68 | +71 69 | def f(): + +F841_3.py:72:24: F841 [*] Local variable `cm` is assigned to but never used + | +71 | def f(): +72 | with Nested(m) as (cm): + | ^^ F841 +73 | pass + | + = help: Remove assignment to unused variable `cm` + +ℹ Suggested fix +69 69 | +70 70 | +71 71 | def f(): +72 |- with Nested(m) as (cm): + 72 |+ with Nested(m): +73 73 | pass +74 74 | +75 75 | + +F841_3.py:77:25: F841 [*] Local variable `cm` is assigned to but never used + | +76 | def f(): +77 | with (Nested(m) as (cm),): + | ^^ F841 +78 | pass + | + = help: Remove assignment to unused variable `cm` + +ℹ Suggested fix +74 74 | +75 75 | +76 76 | def f(): +77 |- with (Nested(m) as (cm),): + 77 |+ with (Nested(m),): +78 78 | pass +79 79 | +80 80 | + +F841_3.py:87:26: F841 [*] Local variable `cm` is assigned to but never used + | +86 | def f(): +87 | with (Nested(m)) as (cm): + | ^^ F841 +88 | pass + | + = help: Remove assignment to unused variable `cm` + +ℹ Suggested fix +84 84 | +85 85 | +86 86 | def f(): +87 |- with (Nested(m)) as (cm): + 87 |+ with (Nested(m)): +88 88 | pass +89 89 | +90 90 | + +F841_3.py:92:5: F841 [*] Local variable `toplevel` is assigned to but never used + | +91 | def f(): +92 | toplevel = tt = lexer.get_token() + | ^^^^^^^^ F841 +93 | if not tt: +94 | break + | + = help: Remove assignment to unused variable `toplevel` + +ℹ Suggested fix +89 89 | +90 90 | +91 91 | def f(): +92 |- toplevel = tt = lexer.get_token() + 92 |+ tt = lexer.get_token() +93 93 | if not tt: +94 94 | break +95 95 | + +F841_3.py:98:5: F841 [*] Local variable `toplevel` is assigned to but never used + | +97 | def f(): +98 | toplevel = tt = lexer.get_token() + | ^^^^^^^^ F841 + | + = help: Remove assignment to unused variable `toplevel` + +ℹ Suggested fix +95 95 | +96 96 | +97 97 | def f(): +98 |- toplevel = tt = lexer.get_token() + 98 |+ tt = lexer.get_token() +99 99 | +100 100 | +101 101 | def f(): + +F841_3.py:98:16: F841 [*] Local variable `tt` is assigned to but never used + | +97 | def f(): +98 | toplevel = tt = lexer.get_token() + | ^^ F841 + | + = help: Remove assignment to unused variable `tt` + +ℹ Suggested fix +95 95 | +96 96 | +97 97 | def f(): +98 |- toplevel = tt = lexer.get_token() + 98 |+ toplevel = lexer.get_token() +99 99 | +100 100 | +101 101 | def f(): + +F841_3.py:102:5: F841 [*] Local variable `toplevel` is assigned to but never used + | +101 | def f(): +102 | toplevel = (a, b) = lexer.get_token() + | ^^^^^^^^ F841 + | + = help: Remove assignment to unused variable `toplevel` + +ℹ Suggested fix +99 99 | +100 100 | +101 101 | def f(): +102 |- toplevel = (a, b) = lexer.get_token() + 102 |+ (a, b) = lexer.get_token() +103 103 | +104 104 | +105 105 | def f(): + +F841_3.py:106:14: F841 [*] Local variable `toplevel` is assigned to but never used + | +105 | def f(): +106 | (a, b) = toplevel = lexer.get_token() + | ^^^^^^^^ F841 + | + = help: Remove assignment to unused variable `toplevel` + +ℹ Suggested fix +103 103 | +104 104 | +105 105 | def f(): +106 |- (a, b) = toplevel = lexer.get_token() + 106 |+ (a, b) = lexer.get_token() +107 107 | +108 108 | +109 109 | def f(): + +F841_3.py:110:5: F841 [*] Local variable `toplevel` is assigned to but never used + | +109 | def f(): +110 | toplevel = tt = 1 + | ^^^^^^^^ F841 + | + = help: Remove assignment to unused variable `toplevel` + +ℹ Suggested fix +107 107 | +108 108 | +109 109 | def f(): +110 |- toplevel = tt = 1 + 110 |+ tt = 1 +111 111 | +112 112 | +113 113 | def f(provided: int) -> int: + +F841_3.py:110:16: F841 [*] Local variable `tt` is assigned to but never used + | +109 | def f(): +110 | toplevel = tt = 1 + | ^^ F841 + | + = help: Remove assignment to unused variable `tt` + +ℹ Suggested fix +107 107 | +108 108 | +109 109 | def f(): +110 |- toplevel = tt = 1 + 110 |+ toplevel = 1 +111 111 | +112 112 | +113 113 | def f(provided: int) -> int: + +F841_3.py:115:19: F841 Local variable `x` is assigned to but never used + | +113 | def f(provided: int) -> int: +114 | match provided: +115 | case [_, *x]: + | ^ F841 +116 | pass + | + = help: Remove assignment to unused variable `x` + +F841_3.py:121:14: F841 Local variable `x` is assigned to but never used + | +119 | def f(provided: int) -> int: +120 | match provided: +121 | case x: + | ^ F841 +122 | pass + | + = help: Remove assignment to unused variable `x` + +F841_3.py:127:18: F841 Local variable `bar` is assigned to but never used + | +125 | def f(provided: int) -> int: +126 | match provided: +127 | case Foo(bar) as x: + | ^^^ F841 +128 | pass + | + = help: Remove assignment to unused variable `bar` + +F841_3.py:127:26: F841 Local variable `x` is assigned to but never used + | +125 | def f(provided: int) -> int: +126 | match provided: +127 | case Foo(bar) as x: + | ^ F841 +128 | pass + | + = help: Remove assignment to unused variable `x` + +F841_3.py:133:27: F841 Local variable `x` is assigned to but never used + | +131 | def f(provided: int) -> int: +132 | match provided: +133 | case {"foo": 0, **x}: + | ^ F841 +134 | pass + | + = help: Remove assignment to unused variable `x` + +F841_3.py:139:17: F841 Local variable `x` is assigned to but never used + | +137 | def f(provided: int) -> int: +138 | match provided: +139 | case {**x}: + | ^ F841 +140 | pass + | + = help: Remove assignment to unused variable `x` + +F841_3.py:155:17: F841 [*] Local variable `e` is assigned to but never used + | +153 | try: +154 | print("hello") +155 | except A as e : + | ^ F841 +156 | print("oh no!") + | + = help: Remove assignment to unused variable `e` + +ℹ Fix +152 152 | def f() -> None: +153 153 | try: +154 154 | print("hello") +155 |- except A as e : + 155 |+ except A: +156 156 | print("oh no!") +157 157 | +158 158 | + +F841_3.py:160:5: F841 [*] Local variable `x` is assigned to but never used + | +159 | def f(): +160 | x = 1 + | ^ F841 +161 | y = 2 + | + = help: Remove assignment to unused variable `x` + +ℹ Suggested fix +157 157 | +158 158 | +159 159 | def f(): +160 |- x = 1 +161 160 | y = 2 +162 161 | +163 162 | + +F841_3.py:161:5: F841 [*] Local variable `y` is assigned to but never used + | +159 | def f(): +160 | x = 1 +161 | y = 2 + | ^ F841 + | + = help: Remove assignment to unused variable `y` + +ℹ Suggested fix +158 158 | +159 159 | def f(): +160 160 | x = 1 +161 |- y = 2 +162 161 | +163 162 | +164 163 | def f(): + +F841_3.py:165:5: F841 [*] Local variable `x` is assigned to but never used + | +164 | def f(): +165 | x = 1 + | ^ F841 +166 | +167 | y = 2 + | + = help: Remove assignment to unused variable `x` + +ℹ Suggested fix +162 162 | +163 163 | +164 164 | def f(): +165 |- x = 1 +166 165 | +167 166 | y = 2 +168 167 | + +F841_3.py:167:5: F841 [*] Local variable `y` is assigned to but never used + | +165 | x = 1 +166 | +167 | y = 2 + | ^ F841 + | + = help: Remove assignment to unused variable `y` + +ℹ Suggested fix +164 164 | def f(): +165 165 | x = 1 +166 166 | +167 |- y = 2 +168 167 | +169 168 | +170 169 | def f(): + +F841_3.py:173:6: F841 [*] Local variable `x` is assigned to but never used + | +171 | (x) = foo() +172 | ((x)) = foo() +173 | (x) = (y.z) = foo() + | ^ F841 + | + = help: Remove assignment to unused variable `x` + +ℹ Suggested fix +170 170 | def f(): +171 171 | (x) = foo() +172 172 | ((x)) = foo() +173 |- (x) = (y.z) = foo() + 173 |+ (y.z) = foo() + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F842_F842.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F842_F842.py.snap new file mode 100644 index 0000000000..815af1b008 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F842_F842.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F842.py:2:5: F842 Local variable `name` is annotated but never used + | +1 | def f(): +2 | name: str + | ^^^^ F842 +3 | age: int + | + +F842.py:3:5: F842 Local variable `age` is annotated but never used + | +1 | def f(): +2 | name: str +3 | age: int + | ^^^ F842 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F901_F901.py.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F901_F901.py.snap new file mode 100644 index 0000000000..1fdcc0fa9e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F901_F901.py.snap @@ -0,0 +1,35 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F901.py:2:11: F901 [*] `raise NotImplemented` should be `raise NotImplementedError` + | +1 | def f() -> None: +2 | raise NotImplemented() + | ^^^^^^^^^^^^^^ F901 + | + = help: Use `raise NotImplementedError` + +ℹ Fix +1 1 | def f() -> None: +2 |- raise NotImplemented() + 2 |+ raise NotImplementedError() +3 3 | +4 4 | +5 5 | def g() -> None: + +F901.py:6:11: F901 [*] `raise NotImplemented` should be `raise NotImplementedError` + | +5 | def g() -> None: +6 | raise NotImplemented + | ^^^^^^^^^^^^^^ F901 + | + = help: Use `raise NotImplementedError` + +ℹ Fix +3 3 | +4 4 | +5 5 | def g() -> None: +6 |- raise NotImplemented + 6 |+ raise NotImplementedError + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__augmented_assignment_after_del.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__augmented_assignment_after_del.snap new file mode 100644 index 0000000000..809ec335a3 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__augmented_assignment_after_del.snap @@ -0,0 +1,21 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +:10:5: F821 Undefined name `x` + | + 8 | # entirely after the `del` statement. However, it should be an F821 + 9 | # error, because the name is defined in the scope, but unbound. +10 | x += 1 + | ^ F821 + | + +:10:5: F841 Local variable `x` is assigned to but never used + | + 8 | # entirely after the `del` statement. However, it should be an F821 + 9 | # error, because the name is defined in the scope, but unbound. +10 | x += 1 + | ^ F841 + | + = help: Remove assignment to unused variable `x` + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__default_builtins.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__default_builtins.snap new file mode 100644 index 0000000000..d574ec9304 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__default_builtins.snap @@ -0,0 +1,10 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +builtins.py:1:1: F821 Undefined name `_` + | +1 | _("Translations") + | ^ F821 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__default_typing_modules.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__default_typing_modules.snap new file mode 100644 index 0000000000..f708d1ddae --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__default_typing_modules.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +typing_modules.py:6:36: F821 Undefined name `db` + | +6 | X = Union[Literal[False], Literal["db"]] + | ^^ F821 +7 | y = Optional["Class"] + | + + 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 new file mode 100644 index 0000000000..db057c4e41 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_global_scope.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +:5:12: F401 [*] `os` imported but unused + | +4 | def f(): +5 | import os + | ^^ F401 +6 | +7 | # Despite this `del`, `import os` in `f` should still be flagged as shadowing an unused + | + = help: Remove unused import: `os` + +ℹ Fix +2 2 | import os +3 3 | +4 4 | def f(): +5 |- import os + 5 |+ pass +6 6 | +7 7 | # Despite this `del`, `import os` in `f` should still be flagged as shadowing an unused +8 8 | # import. (This is a false negative, but is consistent with Pyflakes.) + + 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 new file mode 100644 index 0000000000..b12f87c98f --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_global_import_in_local_scope.snap @@ -0,0 +1,29 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +:2:8: F401 [*] `os` imported but unused + | +2 | import os + | ^^ F401 +3 | +4 | def f(): + | + = help: Remove unused import: `os` + +ℹ Fix +1 1 | +2 |-import os +3 2 | +4 3 | def f(): +5 4 | import os + +:5:12: F811 Redefinition of unused `os` from line 2 + | +4 | def f(): +5 | import os + | ^^ F811 +6 | +7 | # Despite this `del`, `import os` in `f` should still be flagged as shadowing an unused + | + + 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 new file mode 100644 index 0000000000..6a0b807ddc --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_import_shadow_in_local_scope.snap @@ -0,0 +1,28 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +:2:8: F401 [*] `os` imported but unused + | +2 | import os + | ^^ F401 +3 | +4 | def f(): + | + = help: Remove unused import: `os` + +ℹ Fix +1 1 | +2 |-import os +3 2 | +4 3 | def f(): +5 4 | os = 1 + +:5:5: F811 Redefinition of unused `os` from line 2 + | +4 | def f(): +5 | os = 1 + | ^^ F811 +6 | print(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 new file mode 100644 index 0000000000..b8807e970a --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__del_shadowed_local_import_in_local_scope.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +:4:12: F811 Redefinition of unused `os` from line 3 + | +2 | def f(): +3 | import os +4 | import os + | ^^ F811 +5 | +6 | # Despite this `del`, `import os` should still be flagged as shadowing an unused + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__double_del.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__double_del.snap new file mode 100644 index 0000000000..b397846c0d --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__double_del.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +:5:9: F821 Undefined name `x` + | +3 | x = 1 +4 | del x +5 | del x + | ^ F821 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__extend_immutable_calls.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__extend_immutable_calls.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__extend_immutable_calls.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__extra_builtins.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__extra_builtins.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__extra_builtins.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__extra_typing_modules.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__extra_typing_modules.snap new file mode 100644 index 0000000000..b8eec450b4 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__extra_typing_modules.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +typing_modules.py:7:15: F821 Undefined name `Class` + | +6 | X = Union[Literal[False], Literal["db"]] +7 | y = Optional["Class"] + | ^^^^^ F821 + | + + 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 new file mode 100644 index 0000000000..c117fdff6e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__f841_dummy_variable_rgx.snap @@ -0,0 +1,277 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +F841_0.py:3:22: F841 [*] Local variable `e` is assigned to but never used + | +1 | try: +2 | 1 / 0 +3 | except ValueError as e: + | ^ F841 +4 | pass + | + = help: Remove assignment to unused variable `e` + +ℹ Fix +1 1 | try: +2 2 | 1 / 0 +3 |-except ValueError as e: + 3 |+except ValueError: +4 4 | pass +5 5 | +6 6 | + +F841_0.py:20:5: F841 [*] Local variable `foo` is assigned to but never used + | +19 | def f(): +20 | foo = (1, 2) + | ^^^ F841 +21 | (a, b) = (1, 2) + | + = help: Remove assignment to unused variable `foo` + +ℹ Suggested fix +17 17 | +18 18 | +19 19 | def f(): +20 |- foo = (1, 2) +21 20 | (a, b) = (1, 2) +22 21 | +23 22 | bar = (1, 2) + +F841_0.py:21:6: F841 Local variable `a` is assigned to but never used + | +19 | def f(): +20 | foo = (1, 2) +21 | (a, b) = (1, 2) + | ^ F841 +22 | +23 | bar = (1, 2) + | + = help: Remove assignment to unused variable `a` + +F841_0.py:21:9: F841 Local variable `b` is assigned to but never used + | +19 | def f(): +20 | foo = (1, 2) +21 | (a, b) = (1, 2) + | ^ F841 +22 | +23 | bar = (1, 2) + | + = help: Remove assignment to unused variable `b` + +F841_0.py:26:14: F841 [*] Local variable `baz` is assigned to but never used + | +24 | (c, d) = bar +25 | +26 | (x, y) = baz = bar + | ^^^ F841 + | + = help: Remove assignment to unused variable `baz` + +ℹ Suggested fix +23 23 | bar = (1, 2) +24 24 | (c, d) = bar +25 25 | +26 |- (x, y) = baz = bar + 26 |+ (x, y) = bar +27 27 | +28 28 | +29 29 | def f(): + +F841_0.py:35:5: F841 [*] Local variable `_` is assigned to but never used + | +34 | def f(): +35 | _ = 1 + | ^ F841 +36 | __ = 1 +37 | _discarded = 1 + | + = help: Remove assignment to unused variable `_` + +ℹ Suggested fix +32 32 | +33 33 | +34 34 | def f(): +35 |- _ = 1 +36 35 | __ = 1 +37 36 | _discarded = 1 +38 37 | + +F841_0.py:36:5: F841 [*] Local variable `__` is assigned to but never used + | +34 | def f(): +35 | _ = 1 +36 | __ = 1 + | ^^ F841 +37 | _discarded = 1 + | + = help: Remove assignment to unused variable `` + +ℹ Suggested fix +33 33 | +34 34 | def f(): +35 35 | _ = 1 +36 |- __ = 1 +37 36 | _discarded = 1 +38 37 | +39 38 | + +F841_0.py:37:5: F841 [*] Local variable `_discarded` is assigned to but never used + | +35 | _ = 1 +36 | __ = 1 +37 | _discarded = 1 + | ^^^^^^^^^^ F841 + | + = help: Remove assignment to unused variable `_discarded` + +ℹ Suggested fix +34 34 | def f(): +35 35 | _ = 1 +36 36 | __ = 1 +37 |- _discarded = 1 +38 37 | +39 38 | +40 39 | a = 1 + +F841_0.py:51:9: F841 [*] Local variable `b` is assigned to but never used + | +49 | def c(): +50 | # F841 +51 | b = 1 + | ^ F841 +52 | +53 | def d(): + | + = help: Remove assignment to unused variable `b` + +ℹ Suggested fix +48 48 | +49 49 | def c(): +50 50 | # F841 +51 |- b = 1 + 51 |+ pass +52 52 | +53 53 | def d(): +54 54 | nonlocal b + +F841_0.py:79:26: F841 [*] Local variable `my_file` is assigned to but never used + | +78 | def f(): +79 | with open("file") as my_file, open("") as ((this, that)): + | ^^^^^^^ F841 +80 | print("hello") + | + = help: Remove assignment to unused variable `my_file` + +ℹ Suggested fix +76 76 | +77 77 | +78 78 | def f(): +79 |- with open("file") as my_file, open("") as ((this, that)): + 79 |+ with open("file"), open("") as ((this, that)): +80 80 | print("hello") +81 81 | +82 82 | + +F841_0.py:85:25: F841 [*] Local variable `my_file` is assigned to but never used + | +83 | def f(): +84 | with ( +85 | open("file") as my_file, + | ^^^^^^^ F841 +86 | open("") as ((this, that)), +87 | ): + | + = help: Remove assignment to unused variable `my_file` + +ℹ Suggested fix +82 82 | +83 83 | def f(): +84 84 | with ( +85 |- open("file") as my_file, + 85 |+ open("file"), +86 86 | open("") as ((this, that)), +87 87 | ): +88 88 | print("hello") + +F841_0.py:102:5: F841 [*] Local variable `msg3` is assigned to but never used + | +100 | msg1 = "Hello, world!" +101 | msg2 = "Hello, world!" +102 | msg3 = "Hello, world!" + | ^^^^ F841 +103 | match x: +104 | case 1: + | + = help: Remove assignment to unused variable `msg3` + +ℹ Suggested fix +99 99 | def f(x: int): +100 100 | msg1 = "Hello, world!" +101 101 | msg2 = "Hello, world!" +102 |- msg3 = "Hello, world!" +103 102 | match x: +104 103 | case 1: +105 104 | print(msg1) + +F841_0.py:115:5: F841 [*] Local variable `Baz` is assigned to but never used + | +113 | Foo = enum.Enum("Foo", "A B") +114 | Bar = enum.Enum("Bar", "A B") +115 | Baz = enum.Enum("Baz", "A B") + | ^^^ F841 +116 | +117 | match x: + | + = help: Remove assignment to unused variable `Baz` + +ℹ Suggested fix +112 112 | +113 113 | Foo = enum.Enum("Foo", "A B") +114 114 | Bar = enum.Enum("Bar", "A B") +115 |- Baz = enum.Enum("Baz", "A B") + 115 |+ enum.Enum("Baz", "A B") +116 116 | +117 117 | match x: +118 118 | case (Foo.A): + +F841_0.py:122:14: F841 Local variable `y` is assigned to but never used + | +120 | case [Bar.A, *_]: +121 | print("A") +122 | case y: + | ^ F841 +123 | pass + | + = help: Remove assignment to unused variable `y` + +F841_0.py:127:21: F841 Local variable `value` is assigned to but never used + | +126 | def f(): +127 | if any((key := (value := x)) for x in ["ok"]): + | ^^^^^ F841 +128 | print(key) + | + = help: Remove assignment to unused variable `value` + +F841_0.py:152:25: F841 [*] Local variable `_` is assigned to but never used + | +150 | try: +151 | pass +152 | except Exception as _: + | ^ F841 +153 | pass + | + = help: Remove assignment to unused variable `_` + +ℹ Fix +149 149 | def f(): +150 150 | try: +151 151 | pass +152 |- except Exception as _: + 152 |+ except Exception: +153 153 | pass + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__future_annotations.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__future_annotations.snap new file mode 100644 index 0000000000..b2a263440e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__future_annotations.snap @@ -0,0 +1,31 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +future_annotations.py:8:5: F401 [*] `models.Nut` imported but unused + | +6 | from models import ( +7 | Fruit, +8 | Nut, + | ^^^ F401 +9 | ) + | + = help: Remove unused import: `models.Nut` + +ℹ Fix +5 5 | +6 6 | from models import ( +7 7 | Fruit, +8 |- Nut, +9 8 | ) +10 9 | +11 10 | + +future_annotations.py:26:19: F821 Undefined name `Bar` + | +25 | @classmethod +26 | def c(cls) -> Bar: + | ^^^ F821 +27 | return cls(x=0, y=0) + | + + 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 new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__init.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_multiple_unbinds_from_module_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_multiple_unbinds_from_module_scope.snap new file mode 100644 index 0000000000..9f47661f4a --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_multiple_unbinds_from_module_scope.snap @@ -0,0 +1,44 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +:7:26: F841 [*] Local variable `x` is assigned to but never used + | +5 | try: +6 | pass +7 | except ValueError as x: + | ^ F841 +8 | pass + | + = help: Remove assignment to unused variable `x` + +ℹ Fix +4 4 | def f(): +5 5 | try: +6 6 | pass +7 |- except ValueError as x: + 7 |+ except ValueError: +8 8 | pass +9 9 | +10 10 | try: + +:12:26: F841 [*] Local variable `x` is assigned to but never used + | +10 | try: +11 | pass +12 | except ValueError as x: + | ^ F841 +13 | pass + | + = help: Remove assignment to unused variable `x` + +ℹ Fix +9 9 | +10 10 | try: +11 11 | pass +12 |- except ValueError as x: + 12 |+ except ValueError: +13 13 | pass +14 14 | +15 15 | # This should resolve to the `x` in `x = 1`. + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_class_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_class_scope.snap new file mode 100644 index 0000000000..9b02cf258f --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_class_scope.snap @@ -0,0 +1,32 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +:8:30: F841 [*] Local variable `x` is assigned to but never used + | +6 | try: +7 | pass +8 | except ValueError as x: + | ^ F841 +9 | pass + | + = help: Remove assignment to unused variable `x` + +ℹ Fix +5 5 | def f(): +6 6 | try: +7 7 | pass +8 |- except ValueError as x: + 8 |+ except ValueError: +9 9 | pass +10 10 | +11 11 | # This should raise an F821 error, rather than resolving to the + +:13:15: F821 Undefined name `x` + | +11 | # This should raise an F821 error, rather than resolving to the +12 | # `x` in `x = 1`. +13 | print(x) + | ^ F821 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_module_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_module_scope.snap new file mode 100644 index 0000000000..4cf6d6b2ae --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_module_scope.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +:7:26: F841 [*] Local variable `x` is assigned to but never used + | +5 | try: +6 | pass +7 | except ValueError as x: + | ^ F841 +8 | pass + | + = help: Remove assignment to unused variable `x` + +ℹ Fix +4 4 | def f(): +5 5 | try: +6 6 | pass +7 |- except ValueError as x: + 7 |+ except ValueError: +8 8 | pass +9 9 | +10 10 | # This should resolve to the `x` in `x = 1`. + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_nested_module_scope.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_nested_module_scope.snap new file mode 100644 index 0000000000..9776a1ff88 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__load_after_unbind_from_nested_module_scope.snap @@ -0,0 +1,44 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +:7:26: F841 [*] Local variable `x` is assigned to but never used + | +5 | try: +6 | pass +7 | except ValueError as x: + | ^ F841 +8 | pass + | + = help: Remove assignment to unused variable `x` + +ℹ Fix +4 4 | def f(): +5 5 | try: +6 6 | pass +7 |- except ValueError as x: + 7 |+ except ValueError: +8 8 | pass +9 9 | +10 10 | def g(): + +:13:30: F841 [*] Local variable `x` is assigned to but never used + | +11 | try: +12 | pass +13 | except ValueError as x: + | ^ F841 +14 | pass + | + = help: Remove assignment to unused variable `x` + +ℹ Fix +10 10 | def g(): +11 11 | try: +12 12 | pass +13 |- except ValueError as x: + 13 |+ except ValueError: +14 14 | pass +15 15 | +16 16 | # This should resolve to the `x` in `x = 1`. + + 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 new file mode 100644 index 0000000000..2209227eb9 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__multi_statement_lines.snap @@ -0,0 +1,325 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +multi_statement_lines.py:2:12: F401 [*] `foo1` imported but unused + | +1 | if True: +2 | import foo1; x = 1 + | ^^^^ F401 +3 | import foo2; x = 1 + | + = help: Remove unused import: `foo1` + +ℹ Fix +1 1 | if True: +2 |- import foo1; x = 1 + 2 |+ x = 1 +3 3 | import foo2; x = 1 +4 4 | +5 5 | if True: + +multi_statement_lines.py:3:12: F401 [*] `foo2` imported but unused + | +1 | if True: +2 | import foo1; x = 1 +3 | import foo2; x = 1 + | ^^^^ F401 +4 | +5 | if True: + | + = help: Remove unused import: `foo2` + +ℹ Fix +1 1 | if True: +2 2 | import foo1; x = 1 +3 |- import foo2; x = 1 + 3 |+ x = 1 +4 4 | +5 5 | if True: +6 6 | import foo3; \ + +multi_statement_lines.py:6:12: F401 [*] `foo3` imported but unused + | +5 | if True: +6 | import foo3; \ + | ^^^^ F401 +7 | x = 1 + | + = help: Remove unused import: `foo3` + +ℹ Fix +3 3 | import foo2; x = 1 +4 4 | +5 5 | if True: +6 |- import foo3; \ +7 |-x = 1 + 6 |+ x = 1 +8 7 | +9 8 | if True: +10 9 | import foo4 \ + +multi_statement_lines.py:10:12: F401 [*] `foo4` imported but unused + | + 9 | if True: +10 | import foo4 \ + | ^^^^ F401 +11 | ; x = 1 + | + = help: Remove unused import: `foo4` + +ℹ Fix +7 7 | x = 1 +8 8 | +9 9 | if True: +10 |- import foo4 \ +11 |- ; x = 1 + 10 |+ x = 1 +12 11 | +13 12 | if True: +14 13 | x = 1; import foo5 + +multi_statement_lines.py:14:19: F401 [*] `foo5` imported but unused + | +13 | if True: +14 | x = 1; import foo5 + | ^^^^ F401 + | + = help: Remove unused import: `foo5` + +ℹ Fix +11 11 | ; x = 1 +12 12 | +13 13 | if True: +14 |- x = 1; import foo5 + 14 |+ x = 1; +15 15 | +16 16 | +17 17 | if True: + +multi_statement_lines.py:19:17: F401 [*] `foo6` imported but unused + | +17 | if True: +18 | x = 1; \ +19 | import foo6 + | ^^^^ F401 +20 | +21 | if True: + | + = help: Remove unused import: `foo6` + +ℹ Fix +15 15 | +16 16 | +17 17 | if True: +18 |- x = 1; \ +19 |- import foo6 + 18 |+ x = 1; +20 19 | +21 20 | if True: +22 21 | x = 1 \ + +multi_statement_lines.py:23:18: F401 [*] `foo7` imported but unused + | +21 | if True: +22 | x = 1 \ +23 | ; import foo7 + | ^^^^ F401 +24 | +25 | if True: + | + = help: Remove unused import: `foo7` + +ℹ Fix +20 20 | +21 21 | if True: +22 22 | x = 1 \ +23 |- ; import foo7 + 23 |+ ; +24 24 | +25 25 | if True: +26 26 | x = 1; import foo8; x = 1 + +multi_statement_lines.py:26:19: F401 [*] `foo8` imported but unused + | +25 | if True: +26 | x = 1; import foo8; x = 1 + | ^^^^ F401 +27 | x = 1; import foo9; x = 1 + | + = help: Remove unused import: `foo8` + +ℹ Fix +23 23 | ; import foo7 +24 24 | +25 25 | if True: +26 |- x = 1; import foo8; x = 1 + 26 |+ x = 1; x = 1 +27 27 | x = 1; import foo9; x = 1 +28 28 | +29 29 | if True: + +multi_statement_lines.py:27:23: F401 [*] `foo9` imported but unused + | +25 | if True: +26 | x = 1; import foo8; x = 1 +27 | x = 1; import foo9; x = 1 + | ^^^^ F401 +28 | +29 | if True: + | + = help: Remove unused import: `foo9` + +ℹ Fix +24 24 | +25 25 | if True: +26 26 | x = 1; import foo8; x = 1 +27 |- x = 1; import foo9; x = 1 + 27 |+ x = 1; x = 1 +28 28 | +29 29 | if True: +30 30 | x = 1; \ + +multi_statement_lines.py:31:16: F401 [*] `foo10` imported but unused + | +29 | if True: +30 | x = 1; \ +31 | import foo10; \ + | ^^^^^ F401 +32 | x = 1 + | + = help: Remove unused import: `foo10` + +ℹ Fix +28 28 | +29 29 | if True: +30 30 | x = 1; \ +31 |- import foo10; \ +32 |- x = 1 + 31 |+ x = 1 +33 32 | +34 33 | if True: +35 34 | x = 1 \ + +multi_statement_lines.py:36:17: F401 [*] `foo11` imported but unused + | +34 | if True: +35 | x = 1 \ +36 | ;import foo11 \ + | ^^^^^ F401 +37 | ;x = 1 + | + = help: Remove unused import: `foo11` + +ℹ Fix +33 33 | +34 34 | if True: +35 35 | x = 1 \ +36 |- ;import foo11 \ +37 36 | ;x = 1 +38 37 | +39 38 | if True: + +multi_statement_lines.py:42:16: F401 [*] `foo12` imported but unused + | +40 | x = 1; \ +41 | \ +42 | import foo12 + | ^^^^^ F401 +43 | +44 | if True: + | + = help: Remove unused import: `foo12` + +ℹ Fix +37 37 | ;x = 1 +38 38 | +39 39 | if True: +40 |- x = 1; \ +41 |- \ +42 |- import foo12 + 40 |+ x = 1; +43 41 | +44 42 | if True: +45 43 | x = 1; \ + +multi_statement_lines.py:47:12: F401 [*] `foo13` imported but unused + | +45 | x = 1; \ +46 | \ +47 | import foo13 + | ^^^^^ F401 + | + = help: Remove unused import: `foo13` + +ℹ Fix +42 42 | import foo12 +43 43 | +44 44 | if True: +45 |- x = 1; \ +46 |-\ +47 |- import foo13 + 45 |+ x = 1; +48 46 | +49 47 | +50 48 | if True: + +multi_statement_lines.py:53:12: F401 [*] `foo14` imported but unused + | +51 | x = 1; \ +52 | # \ +53 | import foo14 + | ^^^^^ F401 +54 | +55 | # Continuation, but not as the last content in the file. + | + = help: Remove unused import: `foo14` + +ℹ Fix +50 50 | if True: +51 51 | x = 1; \ +52 52 | # \ +53 |- import foo14 +54 53 | +55 54 | # Continuation, but not as the last content in the file. +56 55 | x = 1; \ + +multi_statement_lines.py:57:8: F401 [*] `foo15` imported but unused + | +55 | # Continuation, but not as the last content in the file. +56 | x = 1; \ +57 | import foo15 + | ^^^^^ F401 +58 | +59 | # Continuation, followed by end-of-file. (Removing `import foo` would cause a syntax + | + = help: Remove unused import: `foo15` + +ℹ Fix +53 53 | import foo14 +54 54 | +55 55 | # Continuation, but not as the last content in the file. +56 |-x = 1; \ +57 |-import foo15 + 56 |+x = 1; +58 57 | +59 58 | # Continuation, followed by end-of-file. (Removing `import foo` would cause a syntax +60 59 | # error.) + +multi_statement_lines.py:62:8: F401 [*] `foo16` imported but unused + | +60 | # error.) +61 | x = 1; \ +62 | import foo16 + | ^^^^^ F401 + | + = help: Remove unused import: `foo16` + +ℹ Fix +58 58 | +59 59 | # Continuation, followed by end-of-file. (Removing `import foo` would cause a syntax +60 60 | # error.) +61 |-x = 1; \ +62 |-import foo16 + 61 |+x = 1; + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__nested_relative_typing_module.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__nested_relative_typing_module.snap new file mode 100644 index 0000000000..def4b156eb --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__nested_relative_typing_module.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +baz.py:26:17: F821 Undefined name `foo` + | +25 | # F821 +26 | x: Literal["foo"] + | ^^^ F821 + | + +baz.py:33:17: F821 Undefined name `foo` + | +32 | # F821 +33 | x: Literal["foo"] + | ^^^ F821 + | + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_double_shadowing_except.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_double_shadowing_except.snap new file mode 100644 index 0000000000..9de966e2c5 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_double_shadowing_except.snap @@ -0,0 +1,45 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +:7:26: F841 [*] Local variable `x` is assigned to but never used + | +5 | try: +6 | 1 / 0 +7 | except ValueError as x: + | ^ F841 +8 | pass +9 | except ImportError as x: + | + = help: Remove assignment to unused variable `x` + +ℹ Fix +4 4 | +5 5 | try: +6 6 | 1 / 0 +7 |- except ValueError as x: + 7 |+ except ValueError: +8 8 | pass +9 9 | except ImportError as x: +10 10 | pass + +:9:27: F841 [*] Local variable `x` is assigned to but never used + | + 7 | except ValueError as x: + 8 | pass + 9 | except ImportError as x: + | ^ F841 +10 | pass + | + = help: Remove assignment to unused variable `x` + +ℹ Fix +6 6 | 1 / 0 +7 7 | except ValueError as x: +8 8 | pass +9 |- except ImportError as x: + 9 |+ except ImportError: +10 10 | pass +11 11 | +12 12 | # No error here, though it should arguably be an F821 error. `x` will + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_shadowing_except.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_shadowing_except.snap new file mode 100644 index 0000000000..28c8c0638a --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_body_after_shadowing_except.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +:7:25: F841 [*] Local variable `x` is assigned to but never used + | +5 | try: +6 | 1 / 0 +7 | except Exception as x: + | ^ F841 +8 | pass + | + = help: Remove assignment to unused variable `x` + +ℹ Fix +4 4 | +5 5 | try: +6 6 | 1 / 0 +7 |- except Exception as x: + 7 |+ except Exception: +8 8 | pass +9 9 | +10 10 | # No error here, though it should arguably be an F821 error. `x` will + + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_if_else_after_shadowing_except.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_if_else_after_shadowing_except.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_if_else_after_shadowing_except.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_try_else_after_shadowing_except.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_try_else_after_shadowing_except.snap new file mode 100644 index 0000000000..d0b409f39e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__print_in_try_else_after_shadowing_except.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__relative_typing_module.snap b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__relative_typing_module.snap new file mode 100644 index 0000000000..d7f395ddde --- /dev/null +++ b/crates/ruff_linter/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__relative_typing_module.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/pyflakes/mod.rs +--- +bar.py:26:17: F821 Undefined name `foo` + | +25 | # F821 +26 | x: Literal["foo"] + | ^^^ F821 + | + + diff --git a/crates/ruff/src/rules/pygrep_hooks/mod.rs b/crates/ruff_linter/src/rules/pygrep_hooks/mod.rs similarity index 100% rename from crates/ruff/src/rules/pygrep_hooks/mod.rs rename to crates/ruff_linter/src/rules/pygrep_hooks/mod.rs diff --git a/crates/ruff/src/rules/pygrep_hooks/rules/blanket_noqa.rs b/crates/ruff_linter/src/rules/pygrep_hooks/rules/blanket_noqa.rs similarity index 100% rename from crates/ruff/src/rules/pygrep_hooks/rules/blanket_noqa.rs rename to crates/ruff_linter/src/rules/pygrep_hooks/rules/blanket_noqa.rs diff --git a/crates/ruff/src/rules/pygrep_hooks/rules/blanket_type_ignore.rs b/crates/ruff_linter/src/rules/pygrep_hooks/rules/blanket_type_ignore.rs similarity index 100% rename from crates/ruff/src/rules/pygrep_hooks/rules/blanket_type_ignore.rs rename to crates/ruff_linter/src/rules/pygrep_hooks/rules/blanket_type_ignore.rs diff --git a/crates/ruff/src/rules/pygrep_hooks/rules/deprecated_log_warn.rs b/crates/ruff_linter/src/rules/pygrep_hooks/rules/deprecated_log_warn.rs similarity index 100% rename from crates/ruff/src/rules/pygrep_hooks/rules/deprecated_log_warn.rs rename to crates/ruff_linter/src/rules/pygrep_hooks/rules/deprecated_log_warn.rs diff --git a/crates/ruff/src/rules/pygrep_hooks/rules/invalid_mock_access.rs b/crates/ruff_linter/src/rules/pygrep_hooks/rules/invalid_mock_access.rs similarity index 100% rename from crates/ruff/src/rules/pygrep_hooks/rules/invalid_mock_access.rs rename to crates/ruff_linter/src/rules/pygrep_hooks/rules/invalid_mock_access.rs diff --git a/crates/ruff/src/rules/pygrep_hooks/rules/mod.rs b/crates/ruff_linter/src/rules/pygrep_hooks/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/pygrep_hooks/rules/mod.rs rename to crates/ruff_linter/src/rules/pygrep_hooks/rules/mod.rs diff --git a/crates/ruff/src/rules/pygrep_hooks/rules/no_eval.rs b/crates/ruff_linter/src/rules/pygrep_hooks/rules/no_eval.rs similarity index 100% rename from crates/ruff/src/rules/pygrep_hooks/rules/no_eval.rs rename to crates/ruff_linter/src/rules/pygrep_hooks/rules/no_eval.rs diff --git a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH001_PGH001_0.py.snap b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH001_PGH001_0.py.snap new file mode 100644 index 0000000000..8dad4d98ac --- /dev/null +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH001_PGH001_0.py.snap @@ -0,0 +1,21 @@ +--- +source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs +--- +PGH001_0.py:3:1: PGH001 No builtin `eval()` allowed + | +1 | from ast import literal_eval +2 | +3 | eval("3 + 4") + | ^^^^ PGH001 +4 | +5 | literal_eval({1: 2}) + | + +PGH001_0.py:9:5: PGH001 No builtin `eval()` allowed + | +8 | def fn() -> None: +9 | eval("3 + 4") + | ^^^^ PGH001 + | + + diff --git a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH001_PGH001_1.py.snap b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH001_PGH001_1.py.snap new file mode 100644 index 0000000000..d5e81ab920 --- /dev/null +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH001_PGH001_1.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH002_PGH002_0.py.snap b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH002_PGH002_0.py.snap new file mode 100644 index 0000000000..d5e81ab920 --- /dev/null +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH002_PGH002_0.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH002_PGH002_1.py.snap b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH002_PGH002_1.py.snap new file mode 100644 index 0000000000..7c8d4bc827 --- /dev/null +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH002_PGH002_1.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs +--- +PGH002_1.py:4:1: PGH002 `warn` is deprecated in favor of `warning` + | +2 | from logging import warn +3 | +4 | logging.warn("this is not ok") + | ^^^^^^^^^^^^ PGH002 +5 | warn("not ok") + | + +PGH002_1.py:5:1: PGH002 `warn` is deprecated in favor of `warning` + | +4 | logging.warn("this is not ok") +5 | warn("not ok") + | ^^^^ PGH002 + | + + 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 new file mode 100644 index 0000000000..249a541990 --- /dev/null +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH003_PGH003_0.py.snap @@ -0,0 +1,40 @@ +--- +source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs +--- +PGH003_0.py:1:8: PGH003 Use specific rule codes when ignoring type issues + | +1 | x = 1 # type: ignore + | ^^^^^^^^^^^^^^ PGH003 +2 | x = 1 # type:ignore +3 | x = 1 # type: ignore[attr-defined] # type: ignore + | + +PGH003_0.py:2:8: PGH003 Use specific rule codes when ignoring type issues + | +1 | x = 1 # type: ignore +2 | x = 1 # type:ignore + | ^^^^^^^^^^^^^ PGH003 +3 | x = 1 # type: ignore[attr-defined] # type: ignore +4 | x = 1 # type: ignoreme # type: ignore + | + +PGH003_0.py:3:38: PGH003 Use specific rule codes when ignoring type issues + | +1 | x = 1 # type: ignore +2 | x = 1 # type:ignore +3 | x = 1 # type: ignore[attr-defined] # type: ignore + | ^^^^^^^^^^^^^^ PGH003 +4 | x = 1 # type: ignoreme # type: ignore + | + +PGH003_0.py:4:25: PGH003 Use specific rule codes when ignoring type issues + | +2 | x = 1 # type:ignore +3 | x = 1 # type: ignore[attr-defined] # type: ignore +4 | x = 1 # type: ignoreme # type: ignore + | ^^^^^^^^^^^^^^ PGH003 +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 new file mode 100644 index 0000000000..891fbef531 --- /dev/null +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH003_PGH003_1.py.snap @@ -0,0 +1,30 @@ +--- +source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs +--- +PGH003_1.py:1:8: PGH003 Use specific rule codes when ignoring type issues + | +1 | x = 1 # pyright: ignore + | ^^^^^^^^^^^^^^^^^ PGH003 +2 | x = 1 # pyright:ignore +3 | x = 1 # pyright: ignore[attr-defined] # pyright: ignore + | + +PGH003_1.py:2:8: PGH003 Use specific rule codes when ignoring type issues + | +1 | x = 1 # pyright: ignore +2 | x = 1 # pyright:ignore + | ^^^^^^^^^^^^^^^^ PGH003 +3 | x = 1 # pyright: ignore[attr-defined] # pyright: ignore + | + +PGH003_1.py:3:41: PGH003 Use specific rule codes when ignoring type issues + | +1 | x = 1 # pyright: ignore +2 | x = 1 # pyright:ignore +3 | x = 1 # pyright: ignore[attr-defined] # pyright: ignore + | ^^^^^^^^^^^^^^^^^ PGH003 +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 new file mode 100644 index 0000000000..45a79a3e85 --- /dev/null +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_0.py.snap @@ -0,0 +1,32 @@ +--- +source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs +--- +PGH004_0.py:1:8: PGH004 Use specific rule codes when using `noqa` + | +1 | x = 1 # noqa + | ^^^^^^ PGH004 +2 | x = 1 # NOQA:F401,W203 +3 | # noqa + | + +PGH004_0.py:3:1: PGH004 Use specific rule codes when using `noqa` + | +1 | x = 1 # noqa +2 | x = 1 # NOQA:F401,W203 +3 | # noqa + | ^^^^^^ PGH004 +4 | # NOQA +5 | # noqa:F401 + | + +PGH004_0.py:4:1: PGH004 Use specific rule codes when using `noqa` + | +2 | x = 1 # NOQA:F401,W203 +3 | # noqa +4 | # NOQA + | ^^^^^^ PGH004 +5 | # noqa:F401 +6 | # noqa:F401,W203 + | + + 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 new file mode 100644 index 0000000000..4172207cee --- /dev/null +++ b/crates/ruff_linter/src/rules/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH005_PGH005_0.py.snap @@ -0,0 +1,92 @@ +--- +source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs +--- +PGH005_0.py:2:8: PGH005 Non-existent mock method: `not_called` + | +1 | # Errors +2 | assert my_mock.not_called() + | ^^^^^^^^^^^^^^^^^^^^ PGH005 +3 | assert my_mock.called_once_with() +4 | assert my_mock.not_called + | + +PGH005_0.py:3:8: PGH005 Non-existent mock method: `called_once_with` + | +1 | # Errors +2 | assert my_mock.not_called() +3 | assert my_mock.called_once_with() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 +4 | assert my_mock.not_called +5 | assert my_mock.called_once_with + | + +PGH005_0.py:4:8: PGH005 Non-existent mock method: `not_called` + | +2 | assert my_mock.not_called() +3 | assert my_mock.called_once_with() +4 | assert my_mock.not_called + | ^^^^^^^^^^^^^^^^^^ PGH005 +5 | assert my_mock.called_once_with +6 | my_mock.assert_not_called + | + +PGH005_0.py:5:8: PGH005 Non-existent mock method: `called_once_with` + | +3 | assert my_mock.called_once_with() +4 | assert my_mock.not_called +5 | assert my_mock.called_once_with + | ^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 +6 | my_mock.assert_not_called +7 | my_mock.assert_called + | + +PGH005_0.py:6:1: PGH005 Mock method should be called: `assert_not_called` + | +4 | assert my_mock.not_called +5 | assert my_mock.called_once_with +6 | my_mock.assert_not_called + | ^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 +7 | my_mock.assert_called +8 | my_mock.assert_called_once_with + | + +PGH005_0.py:7:1: PGH005 Mock method should be called: `assert_called` + | +5 | assert my_mock.called_once_with +6 | my_mock.assert_not_called +7 | my_mock.assert_called + | ^^^^^^^^^^^^^^^^^^^^^ PGH005 +8 | my_mock.assert_called_once_with +9 | my_mock.assert_called_once_with + | + +PGH005_0.py:8:1: PGH005 Mock method should be called: `assert_called_once_with` + | + 6 | my_mock.assert_not_called + 7 | my_mock.assert_called + 8 | my_mock.assert_called_once_with + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 + 9 | my_mock.assert_called_once_with +10 | MyMock.assert_called_once_with + | + +PGH005_0.py:9:1: PGH005 Mock method should be called: `assert_called_once_with` + | + 7 | my_mock.assert_called + 8 | my_mock.assert_called_once_with + 9 | my_mock.assert_called_once_with + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 +10 | MyMock.assert_called_once_with + | + +PGH005_0.py:10:1: PGH005 Mock method should be called: `assert_called_once_with` + | + 8 | my_mock.assert_called_once_with + 9 | my_mock.assert_called_once_with +10 | MyMock.assert_called_once_with + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PGH005 +11 | +12 | # OK + | + + diff --git a/crates/ruff/src/rules/pylint/helpers.rs b/crates/ruff_linter/src/rules/pylint/helpers.rs similarity index 100% rename from crates/ruff/src/rules/pylint/helpers.rs rename to crates/ruff_linter/src/rules/pylint/helpers.rs diff --git a/crates/ruff/src/rules/pylint/mod.rs b/crates/ruff_linter/src/rules/pylint/mod.rs similarity index 100% rename from crates/ruff/src/rules/pylint/mod.rs rename to crates/ruff_linter/src/rules/pylint/mod.rs diff --git a/crates/ruff/src/rules/pylint/rules/assert_on_string_literal.rs b/crates/ruff_linter/src/rules/pylint/rules/assert_on_string_literal.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/assert_on_string_literal.rs rename to crates/ruff_linter/src/rules/pylint/rules/assert_on_string_literal.rs diff --git a/crates/ruff/src/rules/pylint/rules/await_outside_async.rs b/crates/ruff_linter/src/rules/pylint/rules/await_outside_async.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/await_outside_async.rs rename to crates/ruff_linter/src/rules/pylint/rules/await_outside_async.rs diff --git a/crates/ruff/src/rules/pylint/rules/bad_dunder_method_name.rs b/crates/ruff_linter/src/rules/pylint/rules/bad_dunder_method_name.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/bad_dunder_method_name.rs rename to crates/ruff_linter/src/rules/pylint/rules/bad_dunder_method_name.rs diff --git a/crates/ruff/src/rules/pylint/rules/bad_str_strip_call.rs b/crates/ruff_linter/src/rules/pylint/rules/bad_str_strip_call.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/bad_str_strip_call.rs rename to crates/ruff_linter/src/rules/pylint/rules/bad_str_strip_call.rs diff --git a/crates/ruff/src/rules/pylint/rules/bad_string_format_character.rs b/crates/ruff_linter/src/rules/pylint/rules/bad_string_format_character.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/bad_string_format_character.rs rename to crates/ruff_linter/src/rules/pylint/rules/bad_string_format_character.rs diff --git a/crates/ruff/src/rules/pylint/rules/bad_string_format_type.rs b/crates/ruff_linter/src/rules/pylint/rules/bad_string_format_type.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/bad_string_format_type.rs rename to crates/ruff_linter/src/rules/pylint/rules/bad_string_format_type.rs diff --git a/crates/ruff/src/rules/pylint/rules/bidirectional_unicode.rs b/crates/ruff_linter/src/rules/pylint/rules/bidirectional_unicode.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/bidirectional_unicode.rs rename to crates/ruff_linter/src/rules/pylint/rules/bidirectional_unicode.rs diff --git a/crates/ruff/src/rules/pylint/rules/binary_op_exception.rs b/crates/ruff_linter/src/rules/pylint/rules/binary_op_exception.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/binary_op_exception.rs rename to crates/ruff_linter/src/rules/pylint/rules/binary_op_exception.rs diff --git a/crates/ruff/src/rules/pylint/rules/collapsible_else_if.rs b/crates/ruff_linter/src/rules/pylint/rules/collapsible_else_if.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/collapsible_else_if.rs rename to crates/ruff_linter/src/rules/pylint/rules/collapsible_else_if.rs diff --git a/crates/ruff/src/rules/pylint/rules/compare_to_empty_string.rs b/crates/ruff_linter/src/rules/pylint/rules/compare_to_empty_string.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/compare_to_empty_string.rs rename to crates/ruff_linter/src/rules/pylint/rules/compare_to_empty_string.rs diff --git a/crates/ruff/src/rules/pylint/rules/comparison_of_constant.rs b/crates/ruff_linter/src/rules/pylint/rules/comparison_of_constant.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/comparison_of_constant.rs rename to crates/ruff_linter/src/rules/pylint/rules/comparison_of_constant.rs diff --git a/crates/ruff/src/rules/pylint/rules/comparison_with_itself.rs b/crates/ruff_linter/src/rules/pylint/rules/comparison_with_itself.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/comparison_with_itself.rs rename to crates/ruff_linter/src/rules/pylint/rules/comparison_with_itself.rs diff --git a/crates/ruff/src/rules/pylint/rules/continue_in_finally.rs b/crates/ruff_linter/src/rules/pylint/rules/continue_in_finally.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/continue_in_finally.rs rename to crates/ruff_linter/src/rules/pylint/rules/continue_in_finally.rs diff --git a/crates/ruff/src/rules/pylint/rules/duplicate_bases.rs b/crates/ruff_linter/src/rules/pylint/rules/duplicate_bases.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/duplicate_bases.rs rename to crates/ruff_linter/src/rules/pylint/rules/duplicate_bases.rs diff --git a/crates/ruff/src/rules/pylint/rules/eq_without_hash.rs b/crates/ruff_linter/src/rules/pylint/rules/eq_without_hash.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/eq_without_hash.rs rename to crates/ruff_linter/src/rules/pylint/rules/eq_without_hash.rs diff --git a/crates/ruff/src/rules/pylint/rules/global_statement.rs b/crates/ruff_linter/src/rules/pylint/rules/global_statement.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/global_statement.rs rename to crates/ruff_linter/src/rules/pylint/rules/global_statement.rs diff --git a/crates/ruff/src/rules/pylint/rules/global_variable_not_assigned.rs b/crates/ruff_linter/src/rules/pylint/rules/global_variable_not_assigned.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/global_variable_not_assigned.rs rename to crates/ruff_linter/src/rules/pylint/rules/global_variable_not_assigned.rs diff --git a/crates/ruff/src/rules/pylint/rules/import_self.rs b/crates/ruff_linter/src/rules/pylint/rules/import_self.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/import_self.rs rename to crates/ruff_linter/src/rules/pylint/rules/import_self.rs diff --git a/crates/ruff/src/rules/pylint/rules/invalid_all_format.rs b/crates/ruff_linter/src/rules/pylint/rules/invalid_all_format.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/invalid_all_format.rs rename to crates/ruff_linter/src/rules/pylint/rules/invalid_all_format.rs diff --git a/crates/ruff/src/rules/pylint/rules/invalid_all_object.rs b/crates/ruff_linter/src/rules/pylint/rules/invalid_all_object.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/invalid_all_object.rs rename to crates/ruff_linter/src/rules/pylint/rules/invalid_all_object.rs diff --git a/crates/ruff/src/rules/pylint/rules/invalid_envvar_default.rs b/crates/ruff_linter/src/rules/pylint/rules/invalid_envvar_default.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/invalid_envvar_default.rs rename to crates/ruff_linter/src/rules/pylint/rules/invalid_envvar_default.rs diff --git a/crates/ruff/src/rules/pylint/rules/invalid_envvar_value.rs b/crates/ruff_linter/src/rules/pylint/rules/invalid_envvar_value.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/invalid_envvar_value.rs rename to crates/ruff_linter/src/rules/pylint/rules/invalid_envvar_value.rs diff --git a/crates/ruff/src/rules/pylint/rules/invalid_str_return.rs b/crates/ruff_linter/src/rules/pylint/rules/invalid_str_return.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/invalid_str_return.rs rename to crates/ruff_linter/src/rules/pylint/rules/invalid_str_return.rs diff --git a/crates/ruff/src/rules/pylint/rules/invalid_string_characters.rs b/crates/ruff_linter/src/rules/pylint/rules/invalid_string_characters.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/invalid_string_characters.rs rename to crates/ruff_linter/src/rules/pylint/rules/invalid_string_characters.rs diff --git a/crates/ruff/src/rules/pylint/rules/iteration_over_set.rs b/crates/ruff_linter/src/rules/pylint/rules/iteration_over_set.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/iteration_over_set.rs rename to crates/ruff_linter/src/rules/pylint/rules/iteration_over_set.rs diff --git a/crates/ruff/src/rules/pylint/rules/load_before_global_declaration.rs b/crates/ruff_linter/src/rules/pylint/rules/load_before_global_declaration.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/load_before_global_declaration.rs rename to crates/ruff_linter/src/rules/pylint/rules/load_before_global_declaration.rs diff --git a/crates/ruff/src/rules/pylint/rules/logging.rs b/crates/ruff_linter/src/rules/pylint/rules/logging.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/logging.rs rename to crates/ruff_linter/src/rules/pylint/rules/logging.rs diff --git a/crates/ruff/src/rules/pylint/rules/magic_value_comparison.rs b/crates/ruff_linter/src/rules/pylint/rules/magic_value_comparison.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/magic_value_comparison.rs rename to crates/ruff_linter/src/rules/pylint/rules/magic_value_comparison.rs diff --git a/crates/ruff/src/rules/pylint/rules/manual_import_from.rs b/crates/ruff_linter/src/rules/pylint/rules/manual_import_from.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/manual_import_from.rs rename to crates/ruff_linter/src/rules/pylint/rules/manual_import_from.rs diff --git a/crates/ruff/src/rules/pylint/rules/mod.rs b/crates/ruff_linter/src/rules/pylint/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/mod.rs rename to crates/ruff_linter/src/rules/pylint/rules/mod.rs diff --git a/crates/ruff/src/rules/pylint/rules/named_expr_without_context.rs b/crates/ruff_linter/src/rules/pylint/rules/named_expr_without_context.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/named_expr_without_context.rs rename to crates/ruff_linter/src/rules/pylint/rules/named_expr_without_context.rs diff --git a/crates/ruff/src/rules/pylint/rules/nested_min_max.rs b/crates/ruff_linter/src/rules/pylint/rules/nested_min_max.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/nested_min_max.rs rename to crates/ruff_linter/src/rules/pylint/rules/nested_min_max.rs diff --git a/crates/ruff/src/rules/pylint/rules/no_self_use.rs b/crates/ruff_linter/src/rules/pylint/rules/no_self_use.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/no_self_use.rs rename to crates/ruff_linter/src/rules/pylint/rules/no_self_use.rs diff --git a/crates/ruff/src/rules/pylint/rules/nonlocal_without_binding.rs b/crates/ruff_linter/src/rules/pylint/rules/nonlocal_without_binding.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/nonlocal_without_binding.rs rename to crates/ruff_linter/src/rules/pylint/rules/nonlocal_without_binding.rs diff --git a/crates/ruff/src/rules/pylint/rules/property_with_parameters.rs b/crates/ruff_linter/src/rules/pylint/rules/property_with_parameters.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/property_with_parameters.rs rename to crates/ruff_linter/src/rules/pylint/rules/property_with_parameters.rs diff --git a/crates/ruff/src/rules/pylint/rules/redefined_loop_name.rs b/crates/ruff_linter/src/rules/pylint/rules/redefined_loop_name.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/redefined_loop_name.rs rename to crates/ruff_linter/src/rules/pylint/rules/redefined_loop_name.rs diff --git a/crates/ruff/src/rules/pylint/rules/repeated_equality_comparison.rs b/crates/ruff_linter/src/rules/pylint/rules/repeated_equality_comparison.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/repeated_equality_comparison.rs rename to crates/ruff_linter/src/rules/pylint/rules/repeated_equality_comparison.rs diff --git a/crates/ruff/src/rules/pylint/rules/repeated_isinstance_calls.rs b/crates/ruff_linter/src/rules/pylint/rules/repeated_isinstance_calls.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/repeated_isinstance_calls.rs rename to crates/ruff_linter/src/rules/pylint/rules/repeated_isinstance_calls.rs diff --git a/crates/ruff/src/rules/pylint/rules/return_in_init.rs b/crates/ruff_linter/src/rules/pylint/rules/return_in_init.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/return_in_init.rs rename to crates/ruff_linter/src/rules/pylint/rules/return_in_init.rs diff --git a/crates/ruff/src/rules/pylint/rules/self_assigning_variable.rs b/crates/ruff_linter/src/rules/pylint/rules/self_assigning_variable.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/self_assigning_variable.rs rename to crates/ruff_linter/src/rules/pylint/rules/self_assigning_variable.rs diff --git a/crates/ruff/src/rules/pylint/rules/single_string_slots.rs b/crates/ruff_linter/src/rules/pylint/rules/single_string_slots.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/single_string_slots.rs rename to crates/ruff_linter/src/rules/pylint/rules/single_string_slots.rs diff --git a/crates/ruff/src/rules/pylint/rules/subprocess_popen_preexec_fn.rs b/crates/ruff_linter/src/rules/pylint/rules/subprocess_popen_preexec_fn.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/subprocess_popen_preexec_fn.rs rename to crates/ruff_linter/src/rules/pylint/rules/subprocess_popen_preexec_fn.rs diff --git a/crates/ruff/src/rules/pylint/rules/subprocess_run_without_check.rs b/crates/ruff_linter/src/rules/pylint/rules/subprocess_run_without_check.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/subprocess_run_without_check.rs rename to crates/ruff_linter/src/rules/pylint/rules/subprocess_run_without_check.rs diff --git a/crates/ruff/src/rules/pylint/rules/sys_exit_alias.rs b/crates/ruff_linter/src/rules/pylint/rules/sys_exit_alias.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/sys_exit_alias.rs rename to crates/ruff_linter/src/rules/pylint/rules/sys_exit_alias.rs diff --git a/crates/ruff/src/rules/pylint/rules/too_many_arguments.rs b/crates/ruff_linter/src/rules/pylint/rules/too_many_arguments.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/too_many_arguments.rs rename to crates/ruff_linter/src/rules/pylint/rules/too_many_arguments.rs diff --git a/crates/ruff/src/rules/pylint/rules/too_many_branches.rs b/crates/ruff_linter/src/rules/pylint/rules/too_many_branches.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/too_many_branches.rs rename to crates/ruff_linter/src/rules/pylint/rules/too_many_branches.rs diff --git a/crates/ruff/src/rules/pylint/rules/too_many_public_methods.rs b/crates/ruff_linter/src/rules/pylint/rules/too_many_public_methods.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/too_many_public_methods.rs rename to crates/ruff_linter/src/rules/pylint/rules/too_many_public_methods.rs diff --git a/crates/ruff/src/rules/pylint/rules/too_many_return_statements.rs b/crates/ruff_linter/src/rules/pylint/rules/too_many_return_statements.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/too_many_return_statements.rs rename to crates/ruff_linter/src/rules/pylint/rules/too_many_return_statements.rs diff --git a/crates/ruff/src/rules/pylint/rules/too_many_statements.rs b/crates/ruff_linter/src/rules/pylint/rules/too_many_statements.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/too_many_statements.rs rename to crates/ruff_linter/src/rules/pylint/rules/too_many_statements.rs diff --git a/crates/ruff/src/rules/pylint/rules/type_bivariance.rs b/crates/ruff_linter/src/rules/pylint/rules/type_bivariance.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/type_bivariance.rs rename to crates/ruff_linter/src/rules/pylint/rules/type_bivariance.rs diff --git a/crates/ruff/src/rules/pylint/rules/type_name_incorrect_variance.rs b/crates/ruff_linter/src/rules/pylint/rules/type_name_incorrect_variance.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/type_name_incorrect_variance.rs rename to crates/ruff_linter/src/rules/pylint/rules/type_name_incorrect_variance.rs diff --git a/crates/ruff/src/rules/pylint/rules/type_param_name_mismatch.rs b/crates/ruff_linter/src/rules/pylint/rules/type_param_name_mismatch.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/type_param_name_mismatch.rs rename to crates/ruff_linter/src/rules/pylint/rules/type_param_name_mismatch.rs diff --git a/crates/ruff/src/rules/pylint/rules/unexpected_special_method_signature.rs b/crates/ruff_linter/src/rules/pylint/rules/unexpected_special_method_signature.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/unexpected_special_method_signature.rs rename to crates/ruff_linter/src/rules/pylint/rules/unexpected_special_method_signature.rs diff --git a/crates/ruff/src/rules/pylint/rules/unnecessary_direct_lambda_call.rs b/crates/ruff_linter/src/rules/pylint/rules/unnecessary_direct_lambda_call.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/unnecessary_direct_lambda_call.rs rename to crates/ruff_linter/src/rules/pylint/rules/unnecessary_direct_lambda_call.rs diff --git a/crates/ruff/src/rules/pylint/rules/useless_else_on_loop.rs b/crates/ruff_linter/src/rules/pylint/rules/useless_else_on_loop.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/useless_else_on_loop.rs rename to crates/ruff_linter/src/rules/pylint/rules/useless_else_on_loop.rs diff --git a/crates/ruff/src/rules/pylint/rules/useless_import_alias.rs b/crates/ruff_linter/src/rules/pylint/rules/useless_import_alias.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/useless_import_alias.rs rename to crates/ruff_linter/src/rules/pylint/rules/useless_import_alias.rs diff --git a/crates/ruff/src/rules/pylint/rules/useless_return.rs b/crates/ruff_linter/src/rules/pylint/rules/useless_return.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/useless_return.rs rename to crates/ruff_linter/src/rules/pylint/rules/useless_return.rs diff --git a/crates/ruff/src/rules/pylint/rules/yield_from_in_async_function.rs b/crates/ruff_linter/src/rules/pylint/rules/yield_from_in_async_function.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/yield_from_in_async_function.rs rename to crates/ruff_linter/src/rules/pylint/rules/yield_from_in_async_function.rs diff --git a/crates/ruff/src/rules/pylint/rules/yield_in_init.rs b/crates/ruff_linter/src/rules/pylint/rules/yield_in_init.rs similarity index 100% rename from crates/ruff/src/rules/pylint/rules/yield_in_init.rs rename to crates/ruff_linter/src/rules/pylint/rules/yield_in_init.rs diff --git a/crates/ruff/src/rules/pylint/settings.rs b/crates/ruff_linter/src/rules/pylint/settings.rs similarity index 100% rename from crates/ruff/src/rules/pylint/settings.rs rename to crates/ruff_linter/src/rules/pylint/settings.rs 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 new file mode 100644 index 0000000000..c65895174f --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0105_type_name_incorrect_variance.py.snap @@ -0,0 +1,318 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +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 | +5 | T = TypeVar("T", covariant=True) + | ^^^^^^^ PLC0105 +6 | T = TypeVar("T", covariant=True, contravariant=False) +7 | T = TypeVar("T", contravariant=True) + | + +type_name_incorrect_variance.py:6:5: PLC0105 `TypeVar` name "T" does not reflect its covariance; consider renaming it to "T_co" + | +5 | T = TypeVar("T", covariant=True) +6 | T = TypeVar("T", covariant=True, contravariant=False) + | ^^^^^^^ PLC0105 +7 | T = TypeVar("T", contravariant=True) +8 | T = TypeVar("T", covariant=False, contravariant=True) + | + +type_name_incorrect_variance.py:7:5: PLC0105 `TypeVar` name "T" does not reflect its contravariance; consider renaming it to "T_contra" + | +5 | T = TypeVar("T", covariant=True) +6 | T = TypeVar("T", covariant=True, contravariant=False) +7 | T = TypeVar("T", contravariant=True) + | ^^^^^^^ PLC0105 +8 | T = TypeVar("T", covariant=False, contravariant=True) +9 | P = ParamSpec("P", covariant=True) + | + +type_name_incorrect_variance.py:8:5: PLC0105 `TypeVar` name "T" does not reflect its contravariance; consider renaming it to "T_contra" + | + 6 | T = TypeVar("T", covariant=True, contravariant=False) + 7 | T = TypeVar("T", contravariant=True) + 8 | T = TypeVar("T", covariant=False, contravariant=True) + | ^^^^^^^ PLC0105 + 9 | P = ParamSpec("P", covariant=True) +10 | P = ParamSpec("P", covariant=True, contravariant=False) + | + +type_name_incorrect_variance.py:9:5: PLC0105 `ParamSpec` name "P" does not reflect its covariance; consider renaming it to "P_co" + | + 7 | T = TypeVar("T", contravariant=True) + 8 | T = TypeVar("T", covariant=False, contravariant=True) + 9 | P = ParamSpec("P", covariant=True) + | ^^^^^^^^^ PLC0105 +10 | P = ParamSpec("P", covariant=True, contravariant=False) +11 | P = ParamSpec("P", contravariant=True) + | + +type_name_incorrect_variance.py:10:5: PLC0105 `ParamSpec` name "P" does not reflect its covariance; consider renaming it to "P_co" + | + 8 | T = TypeVar("T", covariant=False, contravariant=True) + 9 | P = ParamSpec("P", covariant=True) +10 | P = ParamSpec("P", covariant=True, contravariant=False) + | ^^^^^^^^^ PLC0105 +11 | P = ParamSpec("P", contravariant=True) +12 | P = ParamSpec("P", covariant=False, contravariant=True) + | + +type_name_incorrect_variance.py:11:5: PLC0105 `ParamSpec` name "P" does not reflect its contravariance; consider renaming it to "P_contra" + | + 9 | P = ParamSpec("P", covariant=True) +10 | P = ParamSpec("P", covariant=True, contravariant=False) +11 | P = ParamSpec("P", contravariant=True) + | ^^^^^^^^^ PLC0105 +12 | P = ParamSpec("P", covariant=False, contravariant=True) + | + +type_name_incorrect_variance.py:12:5: PLC0105 `ParamSpec` name "P" does not reflect its contravariance; consider renaming it to "P_contra" + | +10 | P = ParamSpec("P", covariant=True, contravariant=False) +11 | P = ParamSpec("P", contravariant=True) +12 | P = ParamSpec("P", covariant=False, contravariant=True) + | ^^^^^^^^^ PLC0105 +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 | +14 | T_co = TypeVar("T_co") + | ^^^^^^^ PLC0105 +15 | T_co = TypeVar("T_co", covariant=False) +16 | T_co = TypeVar("T_co", contravariant=False) + | + +type_name_incorrect_variance.py:15:8: PLC0105 `TypeVar` name "T_co" does not reflect its invariance; consider renaming it to "T" + | +14 | T_co = TypeVar("T_co") +15 | T_co = TypeVar("T_co", covariant=False) + | ^^^^^^^ PLC0105 +16 | T_co = TypeVar("T_co", contravariant=False) +17 | T_co = TypeVar("T_co", covariant=False, contravariant=False) + | + +type_name_incorrect_variance.py:16:8: PLC0105 `TypeVar` name "T_co" does not reflect its invariance; consider renaming it to "T" + | +14 | T_co = TypeVar("T_co") +15 | T_co = TypeVar("T_co", covariant=False) +16 | T_co = TypeVar("T_co", contravariant=False) + | ^^^^^^^ PLC0105 +17 | T_co = TypeVar("T_co", covariant=False, contravariant=False) +18 | T_co = TypeVar("T_co", contravariant=True) + | + +type_name_incorrect_variance.py:17:8: PLC0105 `TypeVar` name "T_co" does not reflect its invariance; consider renaming it to "T" + | +15 | T_co = TypeVar("T_co", covariant=False) +16 | T_co = TypeVar("T_co", contravariant=False) +17 | T_co = TypeVar("T_co", covariant=False, contravariant=False) + | ^^^^^^^ PLC0105 +18 | T_co = TypeVar("T_co", contravariant=True) +19 | T_co = TypeVar("T_co", covariant=False, contravariant=True) + | + +type_name_incorrect_variance.py:18:8: PLC0105 `TypeVar` name "T_co" does not reflect its contravariance; consider renaming it to "T_contra" + | +16 | T_co = TypeVar("T_co", contravariant=False) +17 | T_co = TypeVar("T_co", covariant=False, contravariant=False) +18 | T_co = TypeVar("T_co", contravariant=True) + | ^^^^^^^ PLC0105 +19 | T_co = TypeVar("T_co", covariant=False, contravariant=True) +20 | P_co = ParamSpec("P_co") + | + +type_name_incorrect_variance.py:19:8: PLC0105 `TypeVar` name "T_co" does not reflect its contravariance; consider renaming it to "T_contra" + | +17 | T_co = TypeVar("T_co", covariant=False, contravariant=False) +18 | T_co = TypeVar("T_co", contravariant=True) +19 | T_co = TypeVar("T_co", covariant=False, contravariant=True) + | ^^^^^^^ PLC0105 +20 | P_co = ParamSpec("P_co") +21 | P_co = ParamSpec("P_co", covariant=False) + | + +type_name_incorrect_variance.py:20:8: PLC0105 `ParamSpec` name "P_co" does not reflect its invariance; consider renaming it to "P" + | +18 | T_co = TypeVar("T_co", contravariant=True) +19 | T_co = TypeVar("T_co", covariant=False, contravariant=True) +20 | P_co = ParamSpec("P_co") + | ^^^^^^^^^ PLC0105 +21 | P_co = ParamSpec("P_co", covariant=False) +22 | P_co = ParamSpec("P_co", contravariant=False) + | + +type_name_incorrect_variance.py:21:8: PLC0105 `ParamSpec` name "P_co" does not reflect its invariance; consider renaming it to "P" + | +19 | T_co = TypeVar("T_co", covariant=False, contravariant=True) +20 | P_co = ParamSpec("P_co") +21 | P_co = ParamSpec("P_co", covariant=False) + | ^^^^^^^^^ PLC0105 +22 | P_co = ParamSpec("P_co", contravariant=False) +23 | P_co = ParamSpec("P_co", covariant=False, contravariant=False) + | + +type_name_incorrect_variance.py:22:8: PLC0105 `ParamSpec` name "P_co" does not reflect its invariance; consider renaming it to "P" + | +20 | P_co = ParamSpec("P_co") +21 | P_co = ParamSpec("P_co", covariant=False) +22 | P_co = ParamSpec("P_co", contravariant=False) + | ^^^^^^^^^ PLC0105 +23 | P_co = ParamSpec("P_co", covariant=False, contravariant=False) +24 | P_co = ParamSpec("P_co", contravariant=True) + | + +type_name_incorrect_variance.py:23:8: PLC0105 `ParamSpec` name "P_co" does not reflect its invariance; consider renaming it to "P" + | +21 | P_co = ParamSpec("P_co", covariant=False) +22 | P_co = ParamSpec("P_co", contravariant=False) +23 | P_co = ParamSpec("P_co", covariant=False, contravariant=False) + | ^^^^^^^^^ PLC0105 +24 | P_co = ParamSpec("P_co", contravariant=True) +25 | P_co = ParamSpec("P_co", covariant=False, contravariant=True) + | + +type_name_incorrect_variance.py:24:8: PLC0105 `ParamSpec` name "P_co" does not reflect its contravariance; consider renaming it to "P_contra" + | +22 | P_co = ParamSpec("P_co", contravariant=False) +23 | P_co = ParamSpec("P_co", covariant=False, contravariant=False) +24 | P_co = ParamSpec("P_co", contravariant=True) + | ^^^^^^^^^ PLC0105 +25 | P_co = ParamSpec("P_co", covariant=False, contravariant=True) + | + +type_name_incorrect_variance.py:25:8: PLC0105 `ParamSpec` name "P_co" does not reflect its contravariance; consider renaming it to "P_contra" + | +23 | P_co = ParamSpec("P_co", covariant=False, contravariant=False) +24 | P_co = ParamSpec("P_co", contravariant=True) +25 | P_co = ParamSpec("P_co", covariant=False, contravariant=True) + | ^^^^^^^^^ PLC0105 +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 | +27 | T_contra = TypeVar("T_contra") + | ^^^^^^^ PLC0105 +28 | T_contra = TypeVar("T_contra", covariant=False) +29 | T_contra = TypeVar("T_contra", contravariant=False) + | + +type_name_incorrect_variance.py:28:12: PLC0105 `TypeVar` name "T_contra" does not reflect its invariance; consider renaming it to "T" + | +27 | T_contra = TypeVar("T_contra") +28 | T_contra = TypeVar("T_contra", covariant=False) + | ^^^^^^^ PLC0105 +29 | T_contra = TypeVar("T_contra", contravariant=False) +30 | T_contra = TypeVar("T_contra", covariant=False, contravariant=False) + | + +type_name_incorrect_variance.py:29:12: PLC0105 `TypeVar` name "T_contra" does not reflect its invariance; consider renaming it to "T" + | +27 | T_contra = TypeVar("T_contra") +28 | T_contra = TypeVar("T_contra", covariant=False) +29 | T_contra = TypeVar("T_contra", contravariant=False) + | ^^^^^^^ PLC0105 +30 | T_contra = TypeVar("T_contra", covariant=False, contravariant=False) +31 | T_contra = TypeVar("T_contra", covariant=True) + | + +type_name_incorrect_variance.py:30:12: PLC0105 `TypeVar` name "T_contra" does not reflect its invariance; consider renaming it to "T" + | +28 | T_contra = TypeVar("T_contra", covariant=False) +29 | T_contra = TypeVar("T_contra", contravariant=False) +30 | T_contra = TypeVar("T_contra", covariant=False, contravariant=False) + | ^^^^^^^ PLC0105 +31 | T_contra = TypeVar("T_contra", covariant=True) +32 | T_contra = TypeVar("T_contra", covariant=True, contravariant=False) + | + +type_name_incorrect_variance.py:31:12: PLC0105 `TypeVar` name "T_contra" does not reflect its covariance; consider renaming it to "T_co" + | +29 | T_contra = TypeVar("T_contra", contravariant=False) +30 | T_contra = TypeVar("T_contra", covariant=False, contravariant=False) +31 | T_contra = TypeVar("T_contra", covariant=True) + | ^^^^^^^ PLC0105 +32 | T_contra = TypeVar("T_contra", covariant=True, contravariant=False) +33 | P_contra = ParamSpec("P_contra") + | + +type_name_incorrect_variance.py:32:12: PLC0105 `TypeVar` name "T_contra" does not reflect its covariance; consider renaming it to "T_co" + | +30 | T_contra = TypeVar("T_contra", covariant=False, contravariant=False) +31 | T_contra = TypeVar("T_contra", covariant=True) +32 | T_contra = TypeVar("T_contra", covariant=True, contravariant=False) + | ^^^^^^^ PLC0105 +33 | P_contra = ParamSpec("P_contra") +34 | P_contra = ParamSpec("P_contra", covariant=False) + | + +type_name_incorrect_variance.py:33:12: PLC0105 `ParamSpec` name "P_contra" does not reflect its invariance; consider renaming it to "P" + | +31 | T_contra = TypeVar("T_contra", covariant=True) +32 | T_contra = TypeVar("T_contra", covariant=True, contravariant=False) +33 | P_contra = ParamSpec("P_contra") + | ^^^^^^^^^ PLC0105 +34 | P_contra = ParamSpec("P_contra", covariant=False) +35 | P_contra = ParamSpec("P_contra", contravariant=False) + | + +type_name_incorrect_variance.py:34:12: PLC0105 `ParamSpec` name "P_contra" does not reflect its invariance; consider renaming it to "P" + | +32 | T_contra = TypeVar("T_contra", covariant=True, contravariant=False) +33 | P_contra = ParamSpec("P_contra") +34 | P_contra = ParamSpec("P_contra", covariant=False) + | ^^^^^^^^^ PLC0105 +35 | P_contra = ParamSpec("P_contra", contravariant=False) +36 | P_contra = ParamSpec("P_contra", covariant=False, contravariant=False) + | + +type_name_incorrect_variance.py:35:12: PLC0105 `ParamSpec` name "P_contra" does not reflect its invariance; consider renaming it to "P" + | +33 | P_contra = ParamSpec("P_contra") +34 | P_contra = ParamSpec("P_contra", covariant=False) +35 | P_contra = ParamSpec("P_contra", contravariant=False) + | ^^^^^^^^^ PLC0105 +36 | P_contra = ParamSpec("P_contra", covariant=False, contravariant=False) +37 | P_contra = ParamSpec("P_contra", covariant=True) + | + +type_name_incorrect_variance.py:36:12: PLC0105 `ParamSpec` name "P_contra" does not reflect its invariance; consider renaming it to "P" + | +34 | P_contra = ParamSpec("P_contra", covariant=False) +35 | P_contra = ParamSpec("P_contra", contravariant=False) +36 | P_contra = ParamSpec("P_contra", covariant=False, contravariant=False) + | ^^^^^^^^^ PLC0105 +37 | P_contra = ParamSpec("P_contra", covariant=True) +38 | P_contra = ParamSpec("P_contra", covariant=True, contravariant=False) + | + +type_name_incorrect_variance.py:37:12: PLC0105 `ParamSpec` name "P_contra" does not reflect its covariance; consider renaming it to "P_co" + | +35 | P_contra = ParamSpec("P_contra", contravariant=False) +36 | P_contra = ParamSpec("P_contra", covariant=False, contravariant=False) +37 | P_contra = ParamSpec("P_contra", covariant=True) + | ^^^^^^^^^ PLC0105 +38 | P_contra = ParamSpec("P_contra", covariant=True, contravariant=False) + | + +type_name_incorrect_variance.py:38:12: PLC0105 `ParamSpec` name "P_contra" does not reflect its covariance; consider renaming it to "P_co" + | +36 | P_contra = ParamSpec("P_contra", covariant=False, contravariant=False) +37 | P_contra = ParamSpec("P_contra", covariant=True) +38 | P_contra = ParamSpec("P_contra", covariant=True, contravariant=False) + | ^^^^^^^^^ PLC0105 +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 new file mode 100644 index 0000000000..a1307834a0 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0131_type_bivariance.py.snap @@ -0,0 +1,40 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +type_bivariance.py:5:5: PLC0131 `TypeVar` "T" cannot be both covariant and contravariant + | +3 | # Errors. +4 | +5 | T = TypeVar("T", covariant=True, contravariant=True) + | ^^^^^^^ PLC0131 +6 | T = TypeVar(name="T", covariant=True, contravariant=True) + | + +type_bivariance.py:6:5: PLC0131 `TypeVar` "T" cannot be both covariant and contravariant + | +5 | T = TypeVar("T", covariant=True, contravariant=True) +6 | T = TypeVar(name="T", covariant=True, contravariant=True) + | ^^^^^^^ PLC0131 +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 | +8 | T = ParamSpec("T", covariant=True, contravariant=True) + | ^^^^^^^^^ PLC0131 +9 | T = ParamSpec(name="T", covariant=True, contravariant=True) + | + +type_bivariance.py:9:5: PLC0131 `ParamSpec` "T" cannot be both covariant and contravariant + | + 8 | T = ParamSpec("T", covariant=True, contravariant=True) + 9 | T = ParamSpec(name="T", covariant=True, contravariant=True) + | ^^^^^^^^^ PLC0131 +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 new file mode 100644 index 0000000000..0a02aed583 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0132_type_param_name_mismatch.py.snap @@ -0,0 +1,76 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +type_param_name_mismatch.py:5:5: PLC0132 `TypeVar` name `T` does not match assigned variable name `X` + | +3 | # Errors. +4 | +5 | X = TypeVar("T") + | ^^^^^^^^^^^^ PLC0132 +6 | X = TypeVar(name="T") + | + +type_param_name_mismatch.py:6:5: PLC0132 `TypeVar` name `T` does not match assigned variable name `X` + | +5 | X = TypeVar("T") +6 | X = TypeVar(name="T") + | ^^^^^^^^^^^^^^^^^ PLC0132 +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 | +8 | Y = ParamSpec("T") + | ^^^^^^^^^^^^^^ PLC0132 +9 | Y = ParamSpec(name="T") + | + +type_param_name_mismatch.py:9:5: PLC0132 `ParamSpec` name `T` does not match assigned variable name `Y` + | + 8 | Y = ParamSpec("T") + 9 | Y = ParamSpec(name="T") + | ^^^^^^^^^^^^^^^^^^^ PLC0132 +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 | +11 | Z = NewType("T", int) + | ^^^^^^^^^^^^^^^^^ PLC0132 +12 | Z = NewType(name="T", tp=int) + | + +type_param_name_mismatch.py:12:5: PLC0132 `NewType` name `T` does not match assigned variable name `Z` + | +11 | Z = NewType("T", int) +12 | Z = NewType(name="T", tp=int) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0132 +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 | +14 | Ws = TypeVarTuple("Ts") + | ^^^^^^^^^^^^^^^^^^ PLC0132 +15 | Ws = TypeVarTuple(name="Ts") + | + +type_param_name_mismatch.py:15:6: PLC0132 `TypeVarTuple` name `Ts` does not match assigned variable name `Ws` + | +14 | Ws = TypeVarTuple("Ts") +15 | Ws = TypeVarTuple(name="Ts") + | ^^^^^^^^^^^^^^^^^^^^^^^ PLC0132 +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 new file mode 100644 index 0000000000..f3c8693a68 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0205_single_string_slots.py.snap @@ -0,0 +1,32 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +single_string_slots.py:3:5: PLC0205 Class `__slots__` should be a non-string iterable + | +1 | # Errors. +2 | class Foo: +3 | __slots__ = "bar" + | ^^^^^^^^^^^^^^^^^ PLC0205 +4 | +5 | def __init__(self, bar): + | + +single_string_slots.py:10:5: PLC0205 Class `__slots__` should be a non-string iterable + | + 9 | class Foo: +10 | __slots__: str = "bar" + | ^^^^^^^^^^^^^^^^^^^^^^ PLC0205 +11 | +12 | def __init__(self, bar): + | + +single_string_slots.py:17:5: PLC0205 Class `__slots__` should be a non-string iterable + | +16 | class Foo: +17 | __slots__: str = f"bar" + | ^^^^^^^^^^^^^^^^^^^^^^^ PLC0205 +18 | +19 | def __init__(self, bar): + | + + 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 new file mode 100644 index 0000000000..9ff95583a0 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0208_iteration_over_set.py.snap @@ -0,0 +1,53 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +iteration_over_set.py:3:13: PLC0208 Use a sequence type instead of a `set` when iterating over values + | +1 | # Errors +2 | +3 | for item in {"apples", "lemons", "water"}: # flags in-line set literals + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0208 +4 | print(f"I like {item}.") + | + +iteration_over_set.py:6:28: PLC0208 Use a sequence type instead of a `set` when iterating over values + | +4 | print(f"I like {item}.") +5 | +6 | numbers_list = [i for i in {1, 2, 3}] # flags sets in list comprehensions + | ^^^^^^^^^ PLC0208 +7 | +8 | numbers_set = {i for i in {1, 2, 3}} # flags sets in set comprehensions + | + +iteration_over_set.py:8:27: PLC0208 Use a sequence type instead of a `set` when iterating over values + | + 6 | numbers_list = [i for i in {1, 2, 3}] # flags sets in list comprehensions + 7 | + 8 | numbers_set = {i for i in {1, 2, 3}} # flags sets in set comprehensions + | ^^^^^^^^^ PLC0208 + 9 | +10 | numbers_dict = {str(i): i for i in {1, 2, 3}} # flags sets in dict comprehensions + | + +iteration_over_set.py:10:36: PLC0208 Use a sequence type instead of a `set` when iterating over values + | + 8 | numbers_set = {i for i in {1, 2, 3}} # flags sets in set comprehensions + 9 | +10 | numbers_dict = {str(i): i for i in {1, 2, 3}} # flags sets in dict comprehensions + | ^^^^^^^^^ PLC0208 +11 | +12 | numbers_gen = (i for i in {1, 2, 3}) # flags sets in generator expressions + | + +iteration_over_set.py:12:27: PLC0208 Use a sequence type instead of a `set` when iterating over values + | +10 | numbers_dict = {str(i): i for i in {1, 2, 3}} # flags sets in dict comprehensions +11 | +12 | numbers_gen = (i for i in {1, 2, 3}) # flags sets in generator expressions + | ^^^^^^^^^ PLC0208 +13 | +14 | # Non-errors + | + + 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 new file mode 100644 index 0000000000..800e9671d8 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC0414_import_aliasing.py.snap @@ -0,0 +1,171 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +import_aliasing.py:6:8: PLC0414 [*] Import alias does not rename original package + | +4 | # 2. consider-using-from-import +5 | +6 | import collections as collections # [useless-import-alias] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0414 +7 | from collections import OrderedDict as OrderedDict # [useless-import-alias] +8 | from collections import OrderedDict as o_dict + | + = help: Remove import alias + +ℹ Suggested fix +3 3 | # 1. useless-import-alias +4 4 | # 2. consider-using-from-import +5 5 | +6 |-import collections as collections # [useless-import-alias] + 6 |+import collections # [useless-import-alias] +7 7 | from collections import OrderedDict as OrderedDict # [useless-import-alias] +8 8 | from collections import OrderedDict as o_dict +9 9 | import os.path as path # [consider-using-from-import] + +import_aliasing.py:7:25: PLC0414 [*] Import alias does not rename original package + | +6 | import collections as collections # [useless-import-alias] +7 | from collections import OrderedDict as OrderedDict # [useless-import-alias] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC0414 +8 | from collections import OrderedDict as o_dict +9 | import os.path as path # [consider-using-from-import] + | + = help: Remove import alias + +ℹ Suggested fix +4 4 | # 2. consider-using-from-import +5 5 | +6 6 | import collections as collections # [useless-import-alias] +7 |-from collections import OrderedDict as OrderedDict # [useless-import-alias] + 7 |+from collections import OrderedDict # [useless-import-alias] +8 8 | from collections import OrderedDict as o_dict +9 9 | import os.path as path # [consider-using-from-import] +10 10 | import os.path as p + +import_aliasing.py:16:15: PLC0414 [*] Import alias does not rename original package + | +14 | import os as OS +15 | from sys import version +16 | from . import bar as bar # [useless-import-alias] + | ^^^^^^^^^^ PLC0414 +17 | from . import bar as Bar +18 | from . import bar + | + = help: Remove import alias + +ℹ Suggested fix +13 13 | import os +14 14 | import os as OS +15 15 | from sys import version +16 |-from . import bar as bar # [useless-import-alias] + 16 |+from . import bar # [useless-import-alias] +17 17 | from . import bar as Bar +18 18 | from . import bar +19 19 | from ..foo import bar as bar # [useless-import-alias] + +import_aliasing.py:19:19: PLC0414 [*] Import alias does not rename original package + | +17 | from . import bar as Bar +18 | from . import bar +19 | from ..foo import bar as bar # [useless-import-alias] + | ^^^^^^^^^^ PLC0414 +20 | from ..foo.bar import foobar as foobar # [useless-import-alias] +21 | from ..foo.bar import foobar as anotherfoobar + | + = help: Remove import alias + +ℹ Suggested fix +16 16 | from . import bar as bar # [useless-import-alias] +17 17 | from . import bar as Bar +18 18 | from . import bar +19 |-from ..foo import bar as bar # [useless-import-alias] + 19 |+from ..foo import bar # [useless-import-alias] +20 20 | from ..foo.bar import foobar as foobar # [useless-import-alias] +21 21 | from ..foo.bar import foobar as anotherfoobar +22 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] + +import_aliasing.py:20:23: PLC0414 [*] Import alias does not rename original package + | +18 | from . import bar +19 | from ..foo import bar as bar # [useless-import-alias] +20 | from ..foo.bar import foobar as foobar # [useless-import-alias] + | ^^^^^^^^^^^^^^^^ PLC0414 +21 | from ..foo.bar import foobar as anotherfoobar +22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] + | + = help: Remove import alias + +ℹ Suggested fix +17 17 | from . import bar as Bar +18 18 | from . import bar +19 19 | from ..foo import bar as bar # [useless-import-alias] +20 |-from ..foo.bar import foobar as foobar # [useless-import-alias] + 20 |+from ..foo.bar import foobar # [useless-import-alias] +21 21 | from ..foo.bar import foobar as anotherfoobar +22 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] +23 23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] + +import_aliasing.py:22:15: PLC0414 [*] Import alias does not rename original package + | +20 | from ..foo.bar import foobar as foobar # [useless-import-alias] +21 | from ..foo.bar import foobar as anotherfoobar +22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] + | ^^^^^^^^^^ PLC0414 +23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] +24 | from . import foo as bar, foo2 as bar2 + | + = help: Remove import alias + +ℹ Suggested fix +19 19 | from ..foo import bar as bar # [useless-import-alias] +20 20 | from ..foo.bar import foobar as foobar # [useless-import-alias] +21 21 | from ..foo.bar import foobar as anotherfoobar +22 |-from . import foo as foo, foo2 as bar2 # [useless-import-alias] + 22 |+from . import foo, foo2 as bar2 # [useless-import-alias] +23 23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] +24 24 | from . import foo as bar, foo2 as bar2 +25 25 | from foo.bar import foobar as foobar # [useless-import-alias] + +import_aliasing.py:23:27: PLC0414 [*] Import alias does not rename original package + | +21 | from ..foo.bar import foobar as anotherfoobar +22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] +23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] + | ^^^^^^^^^^^^ PLC0414 +24 | from . import foo as bar, foo2 as bar2 +25 | from foo.bar import foobar as foobar # [useless-import-alias] + | + = help: Remove import alias + +ℹ Suggested fix +20 20 | from ..foo.bar import foobar as foobar # [useless-import-alias] +21 21 | from ..foo.bar import foobar as anotherfoobar +22 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] +23 |-from . import foo as bar, foo2 as foo2 # [useless-import-alias] + 23 |+from . import foo as bar, foo2 # [useless-import-alias] +24 24 | from . import foo as bar, foo2 as bar2 +25 25 | from foo.bar import foobar as foobar # [useless-import-alias] +26 26 | from foo.bar import foobar as foo + +import_aliasing.py:25:21: PLC0414 [*] Import alias does not rename original package + | +23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] +24 | from . import foo as bar, foo2 as bar2 +25 | from foo.bar import foobar as foobar # [useless-import-alias] + | ^^^^^^^^^^^^^^^^ PLC0414 +26 | from foo.bar import foobar as foo +27 | from .foo.bar import f as foobar + | + = help: Remove import alias + +ℹ Suggested fix +22 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] +23 23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] +24 24 | from . import foo as bar, foo2 as bar2 +25 |-from foo.bar import foobar as foobar # [useless-import-alias] + 25 |+from foo.bar import foobar # [useless-import-alias] +26 26 | from foo.bar import foobar as foo +27 27 | from .foo.bar import f as foobar +28 28 | from ............a import b # [relative-beyond-top-level] + + 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 new file mode 100644 index 0000000000..3db68b79bc --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC1901_compare_to_empty_string.py.snap @@ -0,0 +1,47 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +compare_to_empty_string.py:7:13: PLC1901 `x is ""` can be simplified to `not x` as an empty string is falsey + | +6 | def errors(): +7 | if x is "" or x == "": + | ^^ PLC1901 +8 | print("x is an empty string") + | + +compare_to_empty_string.py:7:24: PLC1901 `x == ""` can be simplified to `not x` as an empty string is falsey + | +6 | def errors(): +7 | if x is "" or x == "": + | ^^ PLC1901 +8 | print("x is an empty string") + | + +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 | +10 | if y is not "" or y != "": + | ^^ PLC1901 +11 | print("y is not an empty string") + | + +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 | +10 | if y is not "" or y != "": + | ^^ PLC1901 +11 | print("y is not an empty string") + | + +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 | +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__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 new file mode 100644 index 0000000000..d7a4c18d21 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLC3002_unnecessary_direct_lambda_call.py.snap @@ -0,0 +1,27 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +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 | +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] + | + +unnecessary_direct_lambda_call.py:5:9: PLC3002 Lambda expression called directly. Execute the expression inline instead. + | +4 | y = (lambda x: x**2 + 2*x + 1)(a) # [unnecessary-direct-lambda-call] +5 | y = max((lambda x: x**2)(a), (lambda x: x+1)(a)) # [unnecessary-direct-lambda-call,unnecessary-direct-lambda-call] + | ^^^^^^^^^^^^^^^^^^^ PLC3002 + | + +unnecessary_direct_lambda_call.py:5:30: PLC3002 Lambda expression called directly. Execute the expression inline instead. + | +4 | y = (lambda x: x**2 + 2*x + 1)(a) # [unnecessary-direct-lambda-call] +5 | y = max((lambda x: x**2)(a), (lambda x: x+1)(a)) # [unnecessary-direct-lambda-call,unnecessary-direct-lambda-call] + | ^^^^^^^^^^^^^^^^^^ PLC3002 + | + + 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 new file mode 100644 index 0000000000..a554c0200b --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0100_yield_in_init.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +yield_in_init.py:9:9: PLE0100 `__init__` method is a generator + | +7 | class A: +8 | def __init__(self): +9 | yield + | ^^^^^ PLE0100 + | + +yield_in_init.py:14:9: PLE0100 `__init__` method is a generator + | +12 | class B: +13 | def __init__(self): +14 | yield from self.gen() + | ^^^^^^^^^^^^^^^^^^^^^ PLE0100 +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 new file mode 100644 index 0000000000..c4866362ec --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0101_return_in_init.py.snap @@ -0,0 +1,23 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +return_in_init.py:14:9: PLE0101 Explicit return in `__init__` + | +12 | class B: +13 | def __init__(self): +14 | return 3 + | ^^^^^^^^ PLE0101 +15 | +16 | def gen(self): + | + +return_in_init.py:22:9: PLE0101 Explicit return in `__init__` + | +21 | def __init__(self): +22 | return 1 + | ^^^^^^^^ PLE0101 +23 | +24 | class MyClass2: + | + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0116_continue_in_finally.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0116_continue_in_finally.py.snap new file mode 100644 index 0000000000..6c123427ab --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0116_continue_in_finally.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0117_nonlocal_without_binding.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0117_nonlocal_without_binding.py.snap new file mode 100644 index 0000000000..6628e255a9 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0117_nonlocal_without_binding.py.snap @@ -0,0 +1,25 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +nonlocal_without_binding.py:5:14: PLE0117 Nonlocal name `x` found without binding + | +4 | def f(): +5 | nonlocal x + | ^ PLE0117 + | + +nonlocal_without_binding.py:9:14: PLE0117 Nonlocal name `y` found without binding + | +8 | def f(): +9 | nonlocal y + | ^ PLE0117 + | + +nonlocal_without_binding.py:19:18: PLE0117 Nonlocal name `y` found without binding + | +18 | def f(): +19 | nonlocal y + | ^ PLE0117 + | + + 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 new file mode 100644 index 0000000000..b754822615 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0118_load_before_global_declaration.py.snap @@ -0,0 +1,127 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +load_before_global_declaration.py:5:11: PLE0118 Name `x` is used prior to global declaration on line 7 + | +3 | ### +4 | def f(): +5 | print(x) + | ^ PLE0118 +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 | +15 | print(x) + | ^ PLE0118 +16 | +17 | global x + | + +load_before_global_declaration.py:23:11: PLE0118 Name `x` is used prior to global declaration on line 25 + | +22 | def f(): +23 | print(x) + | ^ PLE0118 +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 | +33 | print(x) + | ^ PLE0118 +34 | +35 | global x, y + | + +load_before_global_declaration.py:41:5: PLE0118 Name `x` is used prior to global declaration on line 43 + | +40 | def f(): +41 | x = 1 + | ^ PLE0118 +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 | +51 | x = 1 + | ^ PLE0118 +52 | +53 | global x + | + +load_before_global_declaration.py:59:9: PLE0118 Name `x` is used prior to global declaration on line 61 + | +58 | def f(): +59 | del x + | ^ PLE0118 +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 | +69 | del x + | ^ PLE0118 +70 | +71 | global x, y + | + +load_before_global_declaration.py:77:9: PLE0118 Name `x` is used prior to global declaration on line 79 + | +76 | def f(): +77 | del x + | ^ PLE0118 +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 | +87 | del x + | ^ PLE0118 +88 | +89 | global x + | + +load_before_global_declaration.py:95:9: PLE0118 Name `x` is used prior to global declaration on line 97 + | +94 | def f(): +95 | del x + | ^ PLE0118 +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 | +105 | del x + | ^ PLE0118 +106 | +107 | global x, y + | + +load_before_global_declaration.py:113:14: PLE0118 Name `x` is used prior to global declaration on line 114 + | +112 | def f(): +113 | print(f"{x=}") + | ^ PLE0118 +114 | global x + | + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0241_duplicate_bases.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0241_duplicate_bases.py.snap new file mode 100644 index 0000000000..ecacbd9b02 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0241_duplicate_bases.py.snap @@ -0,0 +1,11 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +duplicate_bases.py:8:12: PLE0241 Duplicate base `A` for class `B` + | +8 | class B(A, A): + | ^ PLE0241 +9 | ... + | + + 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 new file mode 100644 index 0000000000..54467d8ada --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0302_unexpected_special_method_signature.py.snap @@ -0,0 +1,75 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +unexpected_special_method_signature.py:5:9: PLE0302 The special method `__bool__` expects 1 parameter, 2 were given + | +3 | ... +4 | +5 | def __bool__(self, x): # too many mandatory args + | ^^^^^^^^ PLE0302 +6 | ... + | + +unexpected_special_method_signature.py:19:9: PLE0302 The special method `__bool__` expects 0 parameters, 1 was given + | +18 | @staticmethod +19 | def __bool__(x): # too many mandatory args + | ^^^^^^^^ PLE0302 +20 | ... + | + +unexpected_special_method_signature.py:32:9: PLE0302 The special method `__eq__` expects 2 parameters, 1 was given + | +30 | ... +31 | +32 | def __eq__(self): # too few mandatory args + | ^^^^^^ PLE0302 +33 | ... + | + +unexpected_special_method_signature.py:35:9: PLE0302 The special method `__eq__` expects 2 parameters, 3 were given + | +33 | ... +34 | +35 | def __eq__(self, other, other_other): # too many mandatory args + | ^^^^^^ PLE0302 +36 | ... + | + +unexpected_special_method_signature.py:44:9: PLE0302 The special method `__round__` expects between 1 and 2 parameters, 3 were given + | +42 | ... +43 | +44 | def __round__(self, x, y): # disallow 2 args + | ^^^^^^^^^ PLE0302 +45 | ... + | + +unexpected_special_method_signature.py:47:9: PLE0302 The special method `__round__` expects between 1 and 2 parameters, 4 were given + | +45 | ... +46 | +47 | def __round__(self, x, y, z=2): # disallow 3 args even when one is optional + | ^^^^^^^^^ PLE0302 +48 | ... + | + +unexpected_special_method_signature.py:56:9: PLE0302 The special method `__eq__` expects 2 parameters, 3 were given + | +54 | ... +55 | +56 | def __eq__(self, x, y, *args): # too many args with *args + | ^^^^^^ PLE0302 +57 | ... + | + +unexpected_special_method_signature.py:65:9: PLE0302 The special method `__round__` expects between 1 and 2 parameters, 3 were given + | +63 | ... +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__PLE0307_invalid_return_type_str.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0307_invalid_return_type_str.py.snap new file mode 100644 index 0000000000..492aa55038 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0307_invalid_return_type_str.py.snap @@ -0,0 +1,44 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +invalid_return_type_str.py:3:16: PLE0307 `__str__` does not return `str` + | +1 | class Str: +2 | def __str__(self): +3 | return 1 + | ^ PLE0307 +4 | +5 | class Float: + | + +invalid_return_type_str.py:7:16: PLE0307 `__str__` does not return `str` + | +5 | class Float: +6 | def __str__(self): +7 | return 3.05 + | ^^^^ PLE0307 +8 | +9 | class Int: + | + +invalid_return_type_str.py:11:16: PLE0307 `__str__` does not return `str` + | + 9 | class Int: +10 | def __str__(self): +11 | return 0 + | ^ PLE0307 +12 | +13 | class Bool: + | + +invalid_return_type_str.py:15:16: PLE0307 `__str__` does not return `str` + | +13 | class Bool: +14 | def __str__(self): +15 | return False + | ^^^^^ PLE0307 +16 | +17 | class Str2: + | + + 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 new file mode 100644 index 0000000000..520ac1d083 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0604_invalid_all_object.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +invalid_all_object.py:1:1: PLE0604 Invalid object in `__all__`, must contain only strings + | +1 | __all__ = ( + | ^^^^^^^ PLE0604 +2 | None, # [invalid-all-object] +3 | Fruit, + | + +invalid_all_object.py:7:1: PLE0604 Invalid object in `__all__`, must contain only strings + | +5 | ) +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 new file mode 100644 index 0000000000..9e96d3cb8f --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE0605_invalid_all_format.py.snap @@ -0,0 +1,112 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +invalid_all_format.py:1:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list` + | +1 | __all__ = "CONST" # [invalid-all-format] + | ^^^^^^^ PLE0605 +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 | +3 | __all__ = ["Hello"] + {"world"} # [invalid-all-format] + | ^^^^^^^ PLE0605 +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 | +5 | __all__ += {"world"} # [invalid-all-format] + | ^^^^^^^ PLE0605 +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 | +7 | __all__ = {"world"} + ["Hello"] # [invalid-all-format] + | ^^^^^^^ PLE0605 +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 | + 9 | __all__ = {"world"} + list(["Hello"]) # [invalid-all-format] + | ^^^^^^^ PLE0605 +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 | +11 | __all__ = list(["Hello"]) + {"world"} # [invalid-all-format] + | ^^^^^^^ PLE0605 +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 | +13 | __all__ = (x for x in ["Hello", "world"]) # [invalid-all-format] + | ^^^^^^^ PLE0605 +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 | +15 | __all__ = {x for x in ["Hello", "world"]} # [invalid-all-format] + | ^^^^^^^ PLE0605 +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 | +17 | __all__ = foo # [invalid-all-format] + | ^^^^^^^ PLE0605 +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 | +19 | __all__ = foo.bar # [invalid-all-format] + | ^^^^^^^ PLE0605 +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 | +21 | __all__ = foo["bar"] # [invalid-all-format] + | ^^^^^^^ PLE0605 +22 | +23 | __all__ = ["Hello"] + | + + 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 new file mode 100644 index 0000000000..a1f4507c82 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1142_await_outside_async.py.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +await_outside_async.py:12:11: PLE1142 `await` should be used within an async function + | +11 | def not_async(): +12 | print(await nested()) # [await-outside-async] + | ^^^^^^^^^^^^^^ PLE1142 + | + +await_outside_async.py:25:9: PLE1142 `await` should be used within an async function + | +23 | async def func2(): +24 | def inner_func(): +25 | await asyncio.sleep(1) # [await-outside-async] + | ^^^^^^^^^^^^^^^^^^^^^^ PLE1142 + | + + 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 new file mode 100644 index 0000000000..cdbccdbd75 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1205_logging_too_many_args.py.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +logging_too_many_args.py:3:1: PLE1205 Too many arguments for `logging` format string + | +1 | import logging +2 | +3 | logging.warning("Hello %s", "World!", "again") # [logging-too-many-args] + | ^^^^^^^^^^^^^^^ PLE1205 +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 | +5 | logging.warning("Hello %s", "World!", "again", something="else") + | ^^^^^^^^^^^^^^^ PLE1205 +6 | +7 | logging.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 new file mode 100644 index 0000000000..b46b420741 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1206_logging_too_few_args.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +logging_too_few_args.py:3:1: PLE1206 Not enough arguments for `logging` format string + | +1 | import logging +2 | +3 | logging.warning("Hello %s %s", "World!") # [logging-too-few-args] + | ^^^^^^^^^^^^^^^ PLE1206 +4 | +5 | # 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 new file mode 100644 index 0000000000..e0443ba9bd --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1300_bad_string_format_character.py.snap @@ -0,0 +1,64 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +bad_string_format_character.py:5:1: PLE1300 Unsupported format character 'z' + | +3 | ## Old style formatting +4 | +5 | "%s %z" % ("hello", "world") # [bad-format-character] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 +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 | +7 | "%s" "%z" % ("hello", "world") # [bad-format-character] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 +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 | + 9 | """%s %z""" % ("hello", "world") # [bad-format-character] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 +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 | +11 | """%s""" """%z""" % ("hello", "world") # [bad-format-character] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 +12 | +13 | ## New style formatting + | + +bad_string_format_character.py:15:1: PLE1300 Unsupported format character 'y' + | +13 | ## New style formatting +14 | +15 | "{:s} {:y}".format("hello", "world") # [bad-format-character] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 +16 | +17 | "{:*^30s}".format("centered") # OK + | + +bad_string_format_character.py:19:1: PLE1300 Unsupported format character 'y' + | +17 | "{:*^30s}".format("centered") # OK +18 | "{:{s}}".format("hello", s="s") # OK (nested placeholder value not checked) +19 | "{:{s:y}}".format("hello", s="s") # [bad-format-character] (nested placeholder format spec checked) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1300 +20 | "{0:.{prec}g}".format(1.23, prec=15) # OK (cannot validate after nested placeholder) +21 | "{0:.{foo}{bar}{foobar}y}".format(...) # OK (cannot validate after nested placeholders) + | + + 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 new file mode 100644 index 0000000000..cd3e86e327 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1307_bad_string_format_type.py.snap @@ -0,0 +1,131 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +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 | +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 | +4 | "foo %e bar %s" % ("1", 2) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 +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 | +6 | "%d" % "1" + | ^^^^^^^^^^ PLE1307 +7 | "%o" % "1" +8 | "%(key)d" % {"key": "1"} + | + +bad_string_format_type.py:7:1: PLE1307 Format type does not match argument type + | +6 | "%d" % "1" +7 | "%o" % "1" + | ^^^^^^^^^^ PLE1307 +8 | "%(key)d" % {"key": "1"} +9 | "%x" % 1.1 + | + +bad_string_format_type.py:8:1: PLE1307 Format type does not match argument type + | + 6 | "%d" % "1" + 7 | "%o" % "1" + 8 | "%(key)d" % {"key": "1"} + | ^^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 + 9 | "%x" % 1.1 +10 | "%(key)x" % {"key": 1.1} + | + +bad_string_format_type.py:9:1: PLE1307 Format type does not match argument type + | + 7 | "%o" % "1" + 8 | "%(key)d" % {"key": "1"} + 9 | "%x" % 1.1 + | ^^^^^^^^^^ PLE1307 +10 | "%(key)x" % {"key": 1.1} +11 | "%d" % [] + | + +bad_string_format_type.py:10:1: PLE1307 Format type does not match argument type + | + 8 | "%(key)d" % {"key": "1"} + 9 | "%x" % 1.1 +10 | "%(key)x" % {"key": 1.1} + | ^^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 +11 | "%d" % [] +12 | "%d" % ([],) + | + +bad_string_format_type.py:11:1: PLE1307 Format type does not match argument type + | + 9 | "%x" % 1.1 +10 | "%(key)x" % {"key": 1.1} +11 | "%d" % [] + | ^^^^^^^^^ PLE1307 +12 | "%d" % ([],) +13 | "%(key)d" % {"key": []} + | + +bad_string_format_type.py:12:1: PLE1307 Format type does not match argument type + | +10 | "%(key)x" % {"key": 1.1} +11 | "%d" % [] +12 | "%d" % ([],) + | ^^^^^^^^^^^^ PLE1307 +13 | "%(key)d" % {"key": []} +14 | print("%d" % ("%s" % ("nested",),)) + | + +bad_string_format_type.py:13:1: PLE1307 Format type does not match argument type + | +11 | "%d" % [] +12 | "%d" % ([],) +13 | "%(key)d" % {"key": []} + | ^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 +14 | print("%d" % ("%s" % ("nested",),)) +15 | "%d" % ((1, 2, 3),) + | + +bad_string_format_type.py:14:7: PLE1307 Format type does not match argument type + | +12 | "%d" % ([],) +13 | "%(key)d" % {"key": []} +14 | print("%d" % ("%s" % ("nested",),)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 +15 | "%d" % ((1, 2, 3),) +16 | "%d" % (1 if x > 0 else []) + | + +bad_string_format_type.py:15:1: PLE1307 Format type does not match argument type + | +13 | "%(key)d" % {"key": []} +14 | print("%d" % ("%s" % ("nested",),)) +15 | "%d" % ((1, 2, 3),) + | ^^^^^^^^^^^^^^^^^^^ PLE1307 +16 | "%d" % (1 if x > 0 else []) + | + +bad_string_format_type.py:16:1: PLE1307 Format type does not match argument type + | +14 | print("%d" % ("%s" % ("nested",),)) +15 | "%d" % ((1, 2, 3),) +16 | "%d" % (1 if x > 0 else []) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLE1307 +17 | +18 | # False negatives + | + + 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 new file mode 100644 index 0000000000..7f97ef8dfa --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1310_bad_str_strip_call.py.snap @@ -0,0 +1,160 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +bad_str_strip_call.py:2:21: PLE1310 String `strip` call contains duplicate characters + | +1 | # PLE1310 +2 | "Hello World".strip("Hello") + | ^^^^^^^ PLE1310 +3 | +4 | # PLE1310 + | + +bad_str_strip_call.py:5:21: PLE1310 String `strip` call contains duplicate characters + | +4 | # PLE1310 +5 | "Hello World".strip("Hello") + | ^^^^^^^ PLE1310 +6 | +7 | # PLE1310 + | + +bad_str_strip_call.py:8:21: PLE1310 String `strip` call contains duplicate characters + | + 7 | # PLE1310 + 8 | "Hello World".strip(u"Hello") + | ^^^^^^^^ PLE1310 + 9 | +10 | # PLE1310 + | + +bad_str_strip_call.py:11:21: PLE1310 String `strip` call contains duplicate characters + | +10 | # PLE1310 +11 | "Hello World".strip(r"Hello") + | ^^^^^^^^ PLE1310 +12 | +13 | # PLE1310 + | + +bad_str_strip_call.py:14:21: PLE1310 String `strip` call contains duplicate characters + | +13 | # PLE1310 +14 | "Hello World".strip("Hello\t") + | ^^^^^^^^^ PLE1310 +15 | +16 | # PLE1310 + | + +bad_str_strip_call.py:17:21: PLE1310 String `strip` call contains duplicate characters + | +16 | # PLE1310 +17 | "Hello World".strip(r"Hello\t") + | ^^^^^^^^^^ PLE1310 +18 | +19 | # PLE1310 + | + +bad_str_strip_call.py:20:21: PLE1310 String `strip` call contains duplicate characters + | +19 | # PLE1310 +20 | "Hello World".strip("Hello\\") + | ^^^^^^^^^ PLE1310 +21 | +22 | # PLE1310 + | + +bad_str_strip_call.py:23:21: PLE1310 String `strip` call contains duplicate characters + | +22 | # PLE1310 +23 | "Hello World".strip(r"Hello\\") + | ^^^^^^^^^^ PLE1310 +24 | +25 | # PLE1310 + | + +bad_str_strip_call.py:26:21: PLE1310 String `strip` call contains duplicate characters + | +25 | # PLE1310 +26 | "Hello World".strip("🤣🤣🤣🤣🙃👀😀") + | ^^^^^^^^^^^^^^^^ PLE1310 +27 | +28 | # PLE1310 + | + +bad_str_strip_call.py:30:5: PLE1310 String `strip` call contains duplicate characters + | +28 | # PLE1310 +29 | "Hello World".strip( +30 | """ + | _____^ +31 | | there are a lot of characters to strip +32 | | """ + | |___^ PLE1310 +33 | ) + | + +bad_str_strip_call.py:36:21: PLE1310 String `strip` call contains duplicate characters + | +35 | # PLE1310 +36 | "Hello World".strip("can we get a long " \ + | _____________________^ +37 | | "string of characters to strip " \ +38 | | "please?") + | |_____________________________^ PLE1310 +39 | +40 | # PLE1310 + | + +bad_str_strip_call.py:42:5: PLE1310 String `strip` call contains duplicate characters + | +40 | # PLE1310 +41 | "Hello World".strip( +42 | "can we get a long " + | _____^ +43 | | "string of characters to strip " +44 | | "please?" + | |_____________^ PLE1310 +45 | ) + | + +bad_str_strip_call.py:49:5: PLE1310 String `strip` call contains duplicate characters + | +47 | # PLE1310 +48 | "Hello World".strip( +49 | "can \t we get a long" + | _____^ +50 | | "string \t of characters to strip" +51 | | "please?" + | |_____________^ PLE1310 +52 | ) + | + +bad_str_strip_call.py:61:11: PLE1310 String `strip` call contains duplicate characters + | +60 | # PLE1310 +61 | u''.strip('http://') + | ^^^^^^^^^ PLE1310 +62 | +63 | # PLE1310 + | + +bad_str_strip_call.py:64:12: PLE1310 String `lstrip` call contains duplicate characters (did you mean `removeprefix`?) + | +63 | # PLE1310 +64 | u''.lstrip('http://') + | ^^^^^^^^^ PLE1310 +65 | +66 | # PLE1310 + | + +bad_str_strip_call.py:67:12: PLE1310 String `rstrip` call contains duplicate characters (did you mean `removesuffix`?) + | +66 | # PLE1310 +67 | b''.rstrip('http://') + | ^^^^^^^^^ PLE1310 +68 | +69 | # OK + | + + 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 new file mode 100644 index 0000000000..8bf3f89edb --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1507_invalid_envvar_value.py.snap @@ -0,0 +1,54 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +invalid_envvar_value.py:3:11: PLE1507 Invalid type for initial `os.getenv` argument; expected `str` + | +1 | import os +2 | +3 | os.getenv(1) # [invalid-envvar-value] + | ^ PLE1507 +4 | os.getenv("a") +5 | os.getenv("test") + | + +invalid_envvar_value.py:7:15: PLE1507 Invalid type for initial `os.getenv` argument; expected `str` + | +5 | os.getenv("test") +6 | os.getenv(key="testingAgain") +7 | os.getenv(key=11) # [invalid-envvar-value] + | ^^ PLE1507 +8 | os.getenv(["hello"]) # [invalid-envvar-value] +9 | os.getenv(key="foo", default="bar") + | + +invalid_envvar_value.py:8:11: PLE1507 Invalid type for initial `os.getenv` argument; expected `str` + | + 6 | os.getenv(key="testingAgain") + 7 | os.getenv(key=11) # [invalid-envvar-value] + 8 | os.getenv(["hello"]) # [invalid-envvar-value] + | ^^^^^^^^^ PLE1507 + 9 | os.getenv(key="foo", default="bar") +10 | os.getenv(key=f"foo", default="bar") + | + +invalid_envvar_value.py:12:15: PLE1507 Invalid type for initial `os.getenv` argument; expected `str` + | +10 | os.getenv(key=f"foo", default="bar") +11 | os.getenv(key="foo" + "bar", default=1) +12 | os.getenv(key=1 + "bar", default=1) # [invalid-envvar-value] + | ^^^^^^^^^ PLE1507 +13 | os.getenv("PATH_TEST" if using_clear_path else "PATH_ORIG") +14 | os.getenv(1 if using_clear_path else "PATH_ORIG") + | + +invalid_envvar_value.py:14:11: PLE1507 Invalid type for initial `os.getenv` argument; expected `str` + | +12 | os.getenv(key=1 + "bar", default=1) # [invalid-envvar-value] +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 | +16 | AA = "aa" + | + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1700_yield_from_in_async_function.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1700_yield_from_in_async_function.py.snap new file mode 100644 index 0000000000..8ead784695 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE1700_yield_from_in_async_function.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +yield_from_in_async_function.py:7:5: PLE1700 `yield from` statement in async function; use `async for` instead + | +5 | async def fail(): +6 | l = (1, 2, 3) +7 | yield from l + | ^^^^^^^^^^^^ PLE1700 + | + + 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 new file mode 100644 index 0000000000..76de26797c --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2502_bidirectional_unicode.py.snap @@ -0,0 +1,43 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +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 + | + +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 + | + +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 + | + +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 + | + + 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 new file mode 100644 index 0000000000..48a360b3c3 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2510_invalid_characters.py.snap @@ -0,0 +1,25 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +invalid_characters.py:15:6: PLE2510 [*] Invalid unescaped character backspace, use "\b" instead + | +13 | # (Pylint, "C3002") => Rule::UnnecessaryDirectLambdaCall, +14 | #foo = 'hi' +15 | b = '' + | PLE2510 +16 | +17 | b_ok = '\\b' + | + = help: Replace with escape sequence + +ℹ Fix +12 12 | # (Pylint, "C0414") => Rule::UselessImportAlias, +13 13 | # (Pylint, "C3002") => Rule::UnnecessaryDirectLambdaCall, +14 14 | #foo = 'hi' +15 |-b = '' + 15 |+b = '\b' +16 16 | +17 17 | b_ok = '\\b' +18 18 | + + 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 new file mode 100644 index 0000000000..eaab51876b --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2512_invalid_characters.py.snap @@ -0,0 +1,25 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +invalid_characters.py:21:12: PLE2512 [*] Invalid unescaped character SUB, use "\x1A" instead + | +19 | cr_ok = '\\r' +20 | +21 | sub = 'sub ' + | PLE2512 +22 | +23 | sub_ok = '\x1a' + | + = help: Replace with escape sequence + +ℹ Fix +18 18 | +19 19 | cr_ok = '\\r' +20 20 | +21 |-sub = 'sub ' + 21 |+sub = 'sub \x1A' +22 22 | +23 23 | sub_ok = '\x1a' +24 24 | + + 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 new file mode 100644 index 0000000000..ae13f2baba --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2513_invalid_characters.py.snap @@ -0,0 +1,25 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +invalid_characters.py:25:16: PLE2513 [*] Invalid unescaped character ESC, use "\x1B" instead + | +23 | sub_ok = '\x1a' +24 | +25 | esc = 'esc esc ' + | PLE2513 +26 | +27 | esc_ok = '\x1b' + | + = help: Replace with escape sequence + +ℹ Fix +22 22 | +23 23 | sub_ok = '\x1a' +24 24 | +25 |-esc = 'esc esc ' + 25 |+esc = 'esc esc \x1B' +26 26 | +27 27 | esc_ok = '\x1b' +28 28 | + + 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 new file mode 100644 index 0000000000..49a6a4f518 Binary files /dev/null and b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2514_invalid_characters.py.snap differ 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 new file mode 100644 index 0000000000..25210fb48e --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLE2515_invalid_characters.py.snap @@ -0,0 +1,73 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +invalid_characters.py:34:13: PLE2515 [*] Invalid unescaped character zero-width-space, use "\u200B" instead + | +32 | nul_ok = '\0' +33 | +34 | zwsp = 'zero​width' + | PLE2515 +35 | +36 | zwsp_ok = '\u200b' + | + = help: Replace with escape sequence + +ℹ Fix +31 31 | +32 32 | nul_ok = '\0' +33 33 | +34 |-zwsp = 'zero​width' + 34 |+zwsp = 'zero\u200bwidth' +35 35 | +36 36 | zwsp_ok = '\u200b' +37 37 | + +invalid_characters.py:38:36: PLE2515 [*] Invalid unescaped character zero-width-space, use "\u200B" instead + | +36 | zwsp_ok = '\u200b' +37 | +38 | zwsp_after_multibyte_character = "ಫ​" + | PLE2515 +39 | zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" + | + = help: Replace with escape sequence + +ℹ Fix +35 35 | +36 36 | zwsp_ok = '\u200b' +37 37 | +38 |-zwsp_after_multibyte_character = "ಫ​" + 38 |+zwsp_after_multibyte_character = "ಫ\u200b" +39 39 | zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" + +invalid_characters.py:39:60: PLE2515 [*] Invalid unescaped character zero-width-space, use "\u200B" instead + | +38 | zwsp_after_multibyte_character = "ಫ​" +39 | zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" + | PLE2515 + | + = help: Replace with escape sequence + +ℹ Fix +36 36 | zwsp_ok = '\u200b' +37 37 | +38 38 | zwsp_after_multibyte_character = "ಫ​" +39 |-zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" + 39 |+zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ \u200b​" + +invalid_characters.py:39:61: PLE2515 [*] Invalid unescaped character zero-width-space, use "\u200B" instead + | +38 | zwsp_after_multibyte_character = "ಫ​" +39 | zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" + | PLE2515 + | + = help: Replace with escape sequence + +ℹ Fix +36 36 | zwsp_ok = '\u200b' +37 37 | +38 38 | zwsp_after_multibyte_character = "ಫ​" +39 |-zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​​" + 39 |+zwsp_after_multicharacter_grapheme_cluster = "ಫ್ರಾನ್ಸಿಸ್ಕೊ ​\u200b" + + 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 new file mode 100644 index 0000000000..457daa38d5 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0124_comparison_with_itself.py.snap @@ -0,0 +1,123 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +comparison_with_itself.py:2:1: PLR0124 Name compared with itself, consider replacing `foo == foo` + | +1 | # Errors. +2 | foo == foo + | ^^^ PLR0124 +3 | +4 | foo != foo + | + +comparison_with_itself.py:4:1: PLR0124 Name compared with itself, consider replacing `foo != foo` + | +2 | foo == foo +3 | +4 | foo != foo + | ^^^ PLR0124 +5 | +6 | foo > foo + | + +comparison_with_itself.py:6:1: PLR0124 Name compared with itself, consider replacing `foo > foo` + | +4 | foo != foo +5 | +6 | foo > foo + | ^^^ PLR0124 +7 | +8 | foo >= foo + | + +comparison_with_itself.py:8:1: PLR0124 Name compared with itself, consider replacing `foo >= foo` + | + 6 | foo > foo + 7 | + 8 | foo >= foo + | ^^^ PLR0124 + 9 | +10 | foo < foo + | + +comparison_with_itself.py:10:1: PLR0124 Name compared with itself, consider replacing `foo < foo` + | + 8 | foo >= foo + 9 | +10 | foo < foo + | ^^^ PLR0124 +11 | +12 | foo <= foo + | + +comparison_with_itself.py:12:1: PLR0124 Name compared with itself, consider replacing `foo <= foo` + | +10 | foo < foo +11 | +12 | foo <= foo + | ^^^ PLR0124 +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 | +14 | foo is foo + | ^^^ PLR0124 +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 | +16 | foo is not foo + | ^^^ PLR0124 +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 | +18 | foo in foo + | ^^^ PLR0124 +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 | +20 | foo not in foo + | ^^^ PLR0124 +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 | +22 | id(foo) == id(foo) + | ^^^^^^^ PLR0124 +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 | +24 | len(foo) == len(foo) + | ^^^^^^^^ PLR0124 +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 new file mode 100644 index 0000000000..29f4192415 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0133_comparison_of_constant.py.snap @@ -0,0 +1,93 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +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 | +3 | if 100 == 100: # [comparison-of-constants] + | ^^^ PLR0133 +4 | pass + | + +comparison_of_constant.py:6:4: PLR0133 Two constants compared in a comparison, consider replacing `1 == 3` + | +4 | pass +5 | +6 | if 1 == 3: # [comparison-of-constants] + | ^ PLR0133 +7 | pass + | + +comparison_of_constant.py:9:4: PLR0133 Two constants compared in a comparison, consider replacing `1 != 3` + | + 7 | pass + 8 | + 9 | if 1 != 3: # [comparison-of-constants] + | ^ PLR0133 +10 | pass + | + +comparison_of_constant.py:13:4: PLR0133 Two constants compared in a comparison, consider replacing `4 == 3` + | +12 | x = 0 +13 | if 4 == 3 == x: # [comparison-of-constants] + | ^ PLR0133 +14 | pass + | + +comparison_of_constant.py:23:4: PLR0133 Two constants compared in a comparison, consider replacing `1 > 0` + | +21 | pass +22 | +23 | if 1 > 0: # [comparison-of-constants] + | ^ PLR0133 +24 | pass + | + +comparison_of_constant.py:29:4: PLR0133 Two constants compared in a comparison, consider replacing `1 >= 0` + | +27 | pass +28 | +29 | if 1 >= 0: # [comparison-of-constants] + | ^ PLR0133 +30 | pass + | + +comparison_of_constant.py:35:4: PLR0133 Two constants compared in a comparison, consider replacing `1 < 0` + | +33 | pass +34 | +35 | if 1 < 0: # [comparison-of-constants] + | ^ PLR0133 +36 | pass + | + +comparison_of_constant.py:41:4: PLR0133 Two constants compared in a comparison, consider replacing `1 <= 0` + | +39 | pass +40 | +41 | if 1 <= 0: # [comparison-of-constants] + | ^ PLR0133 +42 | pass + | + +comparison_of_constant.py:51:4: PLR0133 Two constants compared in a comparison, consider replacing `"hello" == ""` + | +49 | pass +50 | +51 | if "hello" == "": # [comparison-of-constants] + | ^^^^^^^ PLR0133 +52 | pass + | + +comparison_of_constant.py:58:4: PLR0133 Two constants compared in a comparison, consider replacing `True == False` + | +56 | pass +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__PLR0206_property_with_parameters.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0206_property_with_parameters.py.snap new file mode 100644 index 0000000000..d3a8e325da --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0206_property_with_parameters.py.snap @@ -0,0 +1,29 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +property_with_parameters.py:7:9: PLR0206 Cannot have defined parameters for properties + | +5 | class Cls: +6 | @property +7 | def attribute(self, param, param1): # [property-with-parameters] + | ^^^^^^^^^ PLR0206 +8 | return param + param1 + | + +property_with_parameters.py:11:9: PLR0206 Cannot have defined parameters for properties + | +10 | @property +11 | def attribute_keyword_only(self, *, param, param1): # [property-with-parameters] + | ^^^^^^^^^^^^^^^^^^^^^^ PLR0206 +12 | return param + param1 + | + +property_with_parameters.py:15:9: PLR0206 Cannot have defined parameters for properties + | +14 | @property +15 | def attribute_positional_only(self, param, param1, /): # [property-with-parameters] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLR0206 +16 | return param + param1 + | + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0402_import_aliasing.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0402_import_aliasing.py.snap new file mode 100644 index 0000000000..4c8e7efc7c --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0402_import_aliasing.py.snap @@ -0,0 +1,57 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +import_aliasing.py:9:8: PLR0402 [*] Use `from os import path` in lieu of alias + | + 7 | from collections import OrderedDict as OrderedDict # [useless-import-alias] + 8 | from collections import OrderedDict as o_dict + 9 | import os.path as path # [consider-using-from-import] + | ^^^^^^^^^^^^^^^ PLR0402 +10 | import os.path as p +11 | import foo.bar.foobar as foobar # [consider-using-from-import] + | + = help: Replace with `from os import path` + +ℹ Fix +6 6 | import collections as collections # [useless-import-alias] +7 7 | from collections import OrderedDict as OrderedDict # [useless-import-alias] +8 8 | from collections import OrderedDict as o_dict +9 |-import os.path as path # [consider-using-from-import] + 9 |+from os import path # [consider-using-from-import] +10 10 | import os.path as p +11 11 | import foo.bar.foobar as foobar # [consider-using-from-import] +12 12 | import foo.bar.foobar as foobar, sys # [consider-using-from-import] + +import_aliasing.py:11:8: PLR0402 [*] Use `from foo.bar import foobar` in lieu of alias + | + 9 | import os.path as path # [consider-using-from-import] +10 | import os.path as p +11 | import foo.bar.foobar as foobar # [consider-using-from-import] + | ^^^^^^^^^^^^^^^^^^^^^^^^ PLR0402 +12 | import foo.bar.foobar as foobar, sys # [consider-using-from-import] +13 | import os + | + = help: Replace with `from foo.bar import foobar` + +ℹ Fix +8 8 | from collections import OrderedDict as o_dict +9 9 | import os.path as path # [consider-using-from-import] +10 10 | import os.path as p +11 |-import foo.bar.foobar as foobar # [consider-using-from-import] + 11 |+from foo.bar import foobar # [consider-using-from-import] +12 12 | import foo.bar.foobar as foobar, sys # [consider-using-from-import] +13 13 | import os +14 14 | import os as OS + +import_aliasing.py:12:8: PLR0402 Use `from foo.bar import foobar` in lieu of alias + | +10 | import os.path as p +11 | import foo.bar.foobar as foobar # [consider-using-from-import] +12 | import foo.bar.foobar as foobar, sys # [consider-using-from-import] + | ^^^^^^^^^^^^^^^^^^^^^^^^ PLR0402 +13 | import os +14 | import os as OS + | + = help: Replace with `from foo.bar import foobar` + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0911_too_many_return_statements.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0911_too_many_return_statements.py.snap new file mode 100644 index 0000000000..9348c8d85f --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0911_too_many_return_statements.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +too_many_return_statements.py:4:5: PLR0911 Too many return statements (11 > 6) + | +2 | https://github.com/PyCQA/pylint/blob/69eca9b3f9856c3033957b769358803ee48e8e47/tests/functional/t/too/too_many_return_statements.py +3 | """ +4 | def stupid_function(arg): # [too-many-return-statements] + | ^^^^^^^^^^^^^^^ PLR0911 +5 | if arg == 1: +6 | return 1 + | + + 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 new file mode 100644 index 0000000000..690939ac3f --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0912_too_many_branches.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +too_many_branches.py:6:5: PLR0912 Too many branches (13 > 12) + | +4 | """ +5 | # pylint: disable=using-constant-test +6 | def wrong(): # [too-many-branches] + | ^^^^^ PLR0912 +7 | """ Has too many branches. """ +8 | if 1: + | + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0913_too_many_arguments.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0913_too_many_arguments.py.snap new file mode 100644 index 0000000000..6677bf7e05 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0913_too_many_arguments.py.snap @@ -0,0 +1,39 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +too_many_arguments.py:1:5: PLR0913 Too many arguments to function call (8 > 5) + | +1 | def f(x, y, z, t, u, v, w, r): # Too many arguments (8/5) + | ^ PLR0913 +2 | pass + | + +too_many_arguments.py:17:5: PLR0913 Too many arguments to function call (6 > 5) + | +17 | def f(x, y, z, u=1, v=1, r=1): # Too many arguments (6/5) + | ^ PLR0913 +18 | pass + | + +too_many_arguments.py:25:5: PLR0913 Too many arguments to function call (6 > 5) + | +25 | def f(x, y, z, /, u, v, w): # Too many arguments (6/5) + | ^ PLR0913 +26 | pass + | + +too_many_arguments.py:29:5: PLR0913 Too many arguments to function call (6 > 5) + | +29 | def f(x, y, z, *, u, v, w): # Too many arguments (6/5) + | ^ PLR0913 +30 | pass + | + +too_many_arguments.py:33:5: PLR0913 Too many arguments to function call (9 > 5) + | +33 | def f(x, y, z, a, b, c, *, u, v, w): # Too many arguments (9/5) + | ^ PLR0913 +34 | pass + | + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0915_too_many_statements.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0915_too_many_statements.py.snap new file mode 100644 index 0000000000..00d55f6846 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR0915_too_many_statements.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +too_many_statements.py:5:11: PLR0915 Too many statements (51 > 50) + | +5 | async def f(): # Too many statements (52/50) + | ^ PLR0915 +6 | print() +7 | print() + | + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1701_repeated_isinstance_calls.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1701_repeated_isinstance_calls.py.snap new file mode 100644 index 0000000000..a5a372e55d --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1701_repeated_isinstance_calls.py.snap @@ -0,0 +1,144 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +repeated_isinstance_calls.py:15:8: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[3], float | int)` + | +14 | # not merged +15 | if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True: # [consider-merging-isinstance] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 +16 | pass +17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] + | + = help: Replace with `isinstance(var[3], float | int)` + +ℹ Fix +12 12 | result = isinstance(var[2], (int, float)) +13 13 | +14 14 | # not merged +15 |- if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True: # [consider-merging-isinstance] + 15 |+ if isinstance(var[3], float | int): # [consider-merging-isinstance] +16 16 | pass +17 17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] +18 18 | + +repeated_isinstance_calls.py:17:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[4], float | int)` + | +15 | if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True: # [consider-merging-isinstance] +16 | pass +17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 +18 | +19 | result = isinstance(var[5], int) or True or isinstance(var[5], float) # [consider-merging-isinstance] + | + = help: Replace with `isinstance(var[4], float | int)` + +ℹ Fix +14 14 | # not merged +15 15 | if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True: # [consider-merging-isinstance] +16 16 | pass +17 |- result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] + 17 |+ result = isinstance(var[4], float | int) # [consider-merging-isinstance] +18 18 | +19 19 | result = isinstance(var[5], int) or True or isinstance(var[5], float) # [consider-merging-isinstance] +20 20 | + +repeated_isinstance_calls.py:19:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[5], float | int)` + | +17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] +18 | +19 | result = isinstance(var[5], int) or True or isinstance(var[5], float) # [consider-merging-isinstance] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 +20 | +21 | inferred_isinstance = isinstance + | + = help: Replace with `isinstance(var[5], float | int)` + +ℹ Fix +16 16 | pass +17 17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] +18 18 | +19 |- result = isinstance(var[5], int) or True or isinstance(var[5], float) # [consider-merging-isinstance] + 19 |+ result = isinstance(var[5], float | int) # [consider-merging-isinstance] +20 20 | +21 21 | inferred_isinstance = isinstance +22 22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] + +repeated_isinstance_calls.py:23:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[10], list | str)` + | +21 | inferred_isinstance = isinstance +22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] +23 | result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list) # [consider-merging-isinstance] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 +24 | result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float) # [consider-merging-isinstance] + | + = help: Replace with `isinstance(var[10], list | str)` + +ℹ Fix +20 20 | +21 21 | inferred_isinstance = isinstance +22 22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] +23 |- result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list) # [consider-merging-isinstance] + 23 |+ result = isinstance(var[10], list | str) # [consider-merging-isinstance] +24 24 | result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float) # [consider-merging-isinstance] +25 25 | +26 26 | result = isinstance(var[20]) + +repeated_isinstance_calls.py:24:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[11], float | int)` + | +22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] +23 | result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list) # [consider-merging-isinstance] +24 | result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float) # [consider-merging-isinstance] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 +25 | +26 | result = isinstance(var[20]) + | + = help: Replace with `isinstance(var[11], float | int)` + +ℹ Fix +21 21 | inferred_isinstance = isinstance +22 22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] +23 23 | result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list) # [consider-merging-isinstance] +24 |- result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float) # [consider-merging-isinstance] + 24 |+ result = isinstance(var[11], float | int) # [consider-merging-isinstance] +25 25 | +26 26 | result = isinstance(var[20]) +27 27 | result = isinstance() + +repeated_isinstance_calls.py:30:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[12], float | int | list)` + | +29 | # Combination merged and not merged +30 | result = isinstance(var[12], (int, float)) or isinstance(var[12], list) # [consider-merging-isinstance] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 +31 | +32 | # not merged but valid + | + = help: Replace with `isinstance(var[12], float | int | list)` + +ℹ Fix +27 27 | result = isinstance() +28 28 | +29 29 | # Combination merged and not merged +30 |- result = isinstance(var[12], (int, float)) or isinstance(var[12], list) # [consider-merging-isinstance] + 30 |+ result = isinstance(var[12], float | int | list) # [consider-merging-isinstance] +31 31 | +32 32 | # not merged but valid +33 33 | result = isinstance(var[5], int) and var[5] * 14 or isinstance(var[5], float) and var[5] * 14.4 + +repeated_isinstance_calls.py:42:3: PLR1701 [*] Merge `isinstance` calls: `isinstance(self.k, float | int)` + | +41 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722460483 +42 | if(isinstance(self.k, int)) or (isinstance(self.k, float)): + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 +43 | ... + | + = help: Replace with `isinstance(self.k, float | int)` + +ℹ Fix +39 39 | +40 40 | +41 41 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722460483 +42 |-if(isinstance(self.k, int)) or (isinstance(self.k, float)): + 42 |+if isinstance(self.k, float | int): +43 43 | ... + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1711_useless_return.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1711_useless_return.py.snap new file mode 100644 index 0000000000..726973dc33 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1711_useless_return.py.snap @@ -0,0 +1,109 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +useless_return.py:6:5: PLR1711 [*] Useless `return` statement at end of function + | +4 | def print_python_version(): +5 | print(sys.version) +6 | return None # [useless-return] + | ^^^^^^^^^^^ PLR1711 + | + = help: Remove useless `return` statement + +ℹ Fix +3 3 | +4 4 | def print_python_version(): +5 5 | print(sys.version) +6 |- return None # [useless-return] +7 6 | +8 7 | +9 8 | def print_python_version(): + +useless_return.py:11:5: PLR1711 [*] Useless `return` statement at end of function + | + 9 | def print_python_version(): +10 | print(sys.version) +11 | return None # [useless-return] + | ^^^^^^^^^^^ PLR1711 + | + = help: Remove useless `return` statement + +ℹ Fix +8 8 | +9 9 | def print_python_version(): +10 10 | print(sys.version) +11 |- return None # [useless-return] +12 11 | +13 12 | +14 13 | def print_python_version(): + +useless_return.py:16:5: PLR1711 [*] Useless `return` statement at end of function + | +14 | def print_python_version(): +15 | print(sys.version) +16 | return None # [useless-return] + | ^^^^^^^^^^^ PLR1711 + | + = help: Remove useless `return` statement + +ℹ Fix +13 13 | +14 14 | def print_python_version(): +15 15 | print(sys.version) +16 |- return None # [useless-return] +17 16 | +18 17 | +19 18 | class SomeClass: + +useless_return.py:22:9: PLR1711 [*] Useless `return` statement at end of function + | +20 | def print_python_version(self): +21 | print(sys.version) +22 | return None # [useless-return] + | ^^^^^^^^^^^ PLR1711 + | + = help: Remove useless `return` statement + +ℹ Fix +19 19 | class SomeClass: +20 20 | def print_python_version(self): +21 21 | print(sys.version) +22 |- return None # [useless-return] +23 22 | +24 23 | +25 24 | def print_python_version(): + +useless_return.py:50:5: PLR1711 [*] Useless `return` statement at end of function + | +48 | """This function returns None.""" +49 | print(sys.version) +50 | return None # [useless-return] + | ^^^^^^^^^^^ PLR1711 + | + = help: Remove useless `return` statement + +ℹ Fix +47 47 | def print_python_version(): +48 48 | """This function returns None.""" +49 49 | print(sys.version) +50 |- return None # [useless-return] +51 50 | +52 51 | +53 52 | class BaseCache: + +useless_return.py:60:9: PLR1711 [*] Useless `return` statement at end of function + | +58 | def get(self, key: str) -> None: +59 | print(f"{key} not found") +60 | return None + | ^^^^^^^^^^^ PLR1711 + | + = help: Remove useless `return` statement + +ℹ Fix +57 57 | +58 58 | def get(self, key: str) -> None: +59 59 | print(f"{key} not found") +60 |- return None + + 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 new file mode 100644 index 0000000000..5114033edf --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1714_repeated_equality_comparison.py.snap @@ -0,0 +1,143 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +repeated_equality_comparison.py:2:1: PLR1714 Consider merging multiple comparisons: `foo in ("a", "b")`. Use a `set` if the elements are hashable. + | +1 | # Errors. +2 | foo == "a" or foo == "b" + | ^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 +3 | +4 | foo != "a" and foo != "b" + | + +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 | +4 | foo != "a" and foo != "b" + | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 +5 | +6 | foo == "a" or foo == "b" or foo == "c" + | + +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 | +6 | foo == "a" or foo == "b" or foo == "c" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 +7 | +8 | foo != "a" and foo != "b" and foo != "c" + | + +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 | + 8 | foo != "a" and foo != "b" and foo != "c" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 + 9 | +10 | foo == a or foo == "b" or foo == 3 # Mixed types. + | + +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 | +10 | foo == a or foo == "b" or foo == 3 # Mixed types. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 +11 | +12 | "a" == foo or "b" == foo or "c" == foo + | + +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 | +12 | "a" == foo or "b" == foo or "c" == foo + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 +13 | +14 | "a" != foo and "b" != foo and "c" != foo + | + +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 | +14 | "a" != foo and "b" != foo and "c" != foo + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 +15 | +16 | "a" == foo or foo == "b" or "c" == foo + | + +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 | +16 | "a" == foo or foo == "b" or "c" == foo + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 +17 | +18 | foo == bar or baz == foo or qux == foo + | + +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 | +18 | foo == bar or baz == foo or qux == foo + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 +19 | +20 | foo == "a" or "b" == foo or foo == "c" + | + +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 | +20 | foo == "a" or "b" == foo or foo == "c" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 +21 | +22 | foo != "a" and "b" != foo and foo != "c" + | + +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 | +22 | foo != "a" and "b" != foo and foo != "c" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 +23 | +24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets + | + +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 | +24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 +25 | +26 | foo.bar == "a" or foo.bar == "b" # Attributes. + | + +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 | +24 | foo == "a" or foo == "b" or "c" == bar or "d" == bar # Multiple targets + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 +25 | +26 | foo.bar == "a" or foo.bar == "b" # Attributes. + | + +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 | +26 | foo.bar == "a" or foo.bar == "b" # Attributes. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1714 +27 | +28 | # OK + | + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap new file mode 100644 index 0000000000..397b48cabc --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap @@ -0,0 +1,77 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +sys_exit_alias_0.py:1:1: PLR1722 [*] Use `sys.exit()` instead of `exit` + | +1 | exit(0) + | ^^^^ PLR1722 +2 | quit(0) + | + = help: Replace `exit` with `sys.exit()` + +ℹ Suggested fix +1 |-exit(0) + 1 |+import sys + 2 |+sys.exit(0) +2 3 | quit(0) +3 4 | +4 5 | + +sys_exit_alias_0.py:2:1: PLR1722 [*] Use `sys.exit()` instead of `quit` + | +1 | exit(0) +2 | quit(0) + | ^^^^ PLR1722 + | + = help: Replace `quit` with `sys.exit()` + +ℹ Suggested fix + 1 |+import sys +1 2 | exit(0) +2 |-quit(0) + 3 |+sys.exit(0) +3 4 | +4 5 | +5 6 | def main(): + +sys_exit_alias_0.py:6:5: PLR1722 [*] Use `sys.exit()` instead of `exit` + | +5 | def main(): +6 | exit(2) + | ^^^^ PLR1722 +7 | quit(2) + | + = help: Replace `exit` with `sys.exit()` + +ℹ Suggested fix + 1 |+import sys +1 2 | exit(0) +2 3 | quit(0) +3 4 | +4 5 | +5 6 | def main(): +6 |- exit(2) + 7 |+ sys.exit(2) +7 8 | quit(2) + +sys_exit_alias_0.py:7:5: PLR1722 [*] Use `sys.exit()` instead of `quit` + | +5 | def main(): +6 | exit(2) +7 | quit(2) + | ^^^^ PLR1722 + | + = help: Replace `quit` with `sys.exit()` + +ℹ Suggested fix + 1 |+import sys +1 2 | exit(0) +2 3 | quit(0) +3 4 | +4 5 | +5 6 | def main(): +6 7 | exit(2) +7 |- quit(2) + 8 |+ sys.exit(2) + + 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 new file mode 100644 index 0000000000..aa9c93714b --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap @@ -0,0 +1,97 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +sys_exit_alias_1.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` + | +1 | import sys +2 | +3 | exit(0) + | ^^^^ PLR1722 +4 | quit(0) + | + = help: Replace `exit` with `sys.exit()` + +ℹ Suggested fix +1 1 | import sys +2 2 | +3 |-exit(0) + 3 |+sys.exit(0) +4 4 | quit(0) +5 5 | +6 6 | + +sys_exit_alias_1.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` + | +3 | exit(0) +4 | quit(0) + | ^^^^ PLR1722 + | + = help: Replace `quit` with `sys.exit()` + +ℹ Suggested fix +1 1 | import sys +2 2 | +3 3 | exit(0) +4 |-quit(0) + 4 |+sys.exit(0) +5 5 | +6 6 | +7 7 | def main(): + +sys_exit_alias_1.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` + | +7 | def main(): +8 | exit(1) + | ^^^^ PLR1722 +9 | quit(1) + | + = help: Replace `exit` with `sys.exit()` + +ℹ Suggested fix +5 5 | +6 6 | +7 7 | def main(): +8 |- exit(1) + 8 |+ sys.exit(1) +9 9 | quit(1) +10 10 | +11 11 | + +sys_exit_alias_1.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` + | +7 | def main(): +8 | exit(1) +9 | quit(1) + | ^^^^ PLR1722 + | + = help: Replace `quit` with `sys.exit()` + +ℹ Suggested fix +6 6 | +7 7 | def main(): +8 8 | exit(1) +9 |- quit(1) + 9 |+ sys.exit(1) +10 10 | +11 11 | +12 12 | def main(): + +sys_exit_alias_1.py:15:5: PLR1722 Use `sys.exit()` instead of `exit` + | +13 | sys = 1 +14 | +15 | exit(1) + | ^^^^ PLR1722 +16 | quit(1) + | + = help: Replace `exit` with `sys.exit()` + +sys_exit_alias_1.py:16:5: PLR1722 Use `sys.exit()` instead of `quit` + | +15 | exit(1) +16 | quit(1) + | ^^^^ PLR1722 + | + = help: Replace `quit` with `sys.exit()` + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_10.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_10.py.snap new file mode 100644 index 0000000000..9328cd82d4 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_10.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +sys_exit_alias_10.py:8:5: PLR1722 Use `sys.exit()` instead of `exit` + | +7 | def main(): +8 | exit(0) + | ^^^^ PLR1722 + | + = help: Replace `exit` with `sys.exit()` + + 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 new file mode 100644 index 0000000000..0fd61d5d82 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_11.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +sys_exit_alias_11.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` + | +1 | from sys import * +2 | +3 | exit(0) + | ^^^^ PLR1722 + | + = help: Replace `exit` with `sys.exit()` + +ℹ Suggested fix +1 1 | from sys import * + 2 |+import sys +2 3 | +3 |-exit(0) + 4 |+sys.exit(0) + + 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 new file mode 100644 index 0000000000..18c4cb9ace --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap @@ -0,0 +1,74 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +sys_exit_alias_2.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` + | +1 | import sys as sys2 +2 | +3 | exit(0) + | ^^^^ PLR1722 +4 | quit(0) + | + = help: Replace `exit` with `sys.exit()` + +ℹ Suggested fix +1 1 | import sys as sys2 +2 2 | +3 |-exit(0) + 3 |+sys2.exit(0) +4 4 | quit(0) +5 5 | +6 6 | + +sys_exit_alias_2.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` + | +3 | exit(0) +4 | quit(0) + | ^^^^ PLR1722 + | + = help: Replace `quit` with `sys.exit()` + +ℹ Suggested fix +1 1 | import sys as sys2 +2 2 | +3 3 | exit(0) +4 |-quit(0) + 4 |+sys2.exit(0) +5 5 | +6 6 | +7 7 | def main(): + +sys_exit_alias_2.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` + | +7 | def main(): +8 | exit(1) + | ^^^^ PLR1722 +9 | quit(1) + | + = help: Replace `exit` with `sys.exit()` + +ℹ Suggested fix +5 5 | +6 6 | +7 7 | def main(): +8 |- exit(1) + 8 |+ sys2.exit(1) +9 9 | quit(1) + +sys_exit_alias_2.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` + | +7 | def main(): +8 | exit(1) +9 | quit(1) + | ^^^^ PLR1722 + | + = help: Replace `quit` with `sys.exit()` + +ℹ Suggested fix +6 6 | +7 7 | def main(): +8 8 | exit(1) +9 |- quit(1) + 9 |+ sys2.exit(1) + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap new file mode 100644 index 0000000000..183ad4c910 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap @@ -0,0 +1,49 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +sys_exit_alias_3.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` + | +3 | exit(0) +4 | quit(0) + | ^^^^ PLR1722 + | + = help: Replace `quit` with `sys.exit()` + +ℹ Suggested fix +1 1 | from sys import exit +2 2 | +3 3 | exit(0) +4 |-quit(0) + 4 |+exit(0) +5 5 | +6 6 | +7 7 | def main(): + +sys_exit_alias_3.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` + | +7 | def main(): +8 | exit(1) +9 | quit(1) + | ^^^^ PLR1722 + | + = help: Replace `quit` with `sys.exit()` + +ℹ Suggested fix +6 6 | +7 7 | def main(): +8 8 | exit(1) +9 |- quit(1) + 9 |+ exit(1) +10 10 | +11 11 | +12 12 | def main(): + +sys_exit_alias_3.py:16:5: PLR1722 Use `sys.exit()` instead of `quit` + | +15 | exit(1) +16 | quit(1) + | ^^^^ PLR1722 + | + = help: Replace `quit` with `sys.exit()` + + 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 new file mode 100644 index 0000000000..8b17e15119 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap @@ -0,0 +1,74 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +sys_exit_alias_4.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` + | +1 | from sys import exit as exit2 +2 | +3 | exit(0) + | ^^^^ PLR1722 +4 | quit(0) + | + = help: Replace `exit` with `sys.exit()` + +ℹ Suggested fix +1 1 | from sys import exit as exit2 +2 2 | +3 |-exit(0) + 3 |+exit2(0) +4 4 | quit(0) +5 5 | +6 6 | + +sys_exit_alias_4.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` + | +3 | exit(0) +4 | quit(0) + | ^^^^ PLR1722 + | + = help: Replace `quit` with `sys.exit()` + +ℹ Suggested fix +1 1 | from sys import exit as exit2 +2 2 | +3 3 | exit(0) +4 |-quit(0) + 4 |+exit2(0) +5 5 | +6 6 | +7 7 | def main(): + +sys_exit_alias_4.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` + | +7 | def main(): +8 | exit(1) + | ^^^^ PLR1722 +9 | quit(1) + | + = help: Replace `exit` with `sys.exit()` + +ℹ Suggested fix +5 5 | +6 6 | +7 7 | def main(): +8 |- exit(1) + 8 |+ exit2(1) +9 9 | quit(1) + +sys_exit_alias_4.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` + | +7 | def main(): +8 | exit(1) +9 | quit(1) + | ^^^^ PLR1722 + | + = help: Replace `quit` with `sys.exit()` + +ℹ Suggested fix +6 6 | +7 7 | def main(): +8 8 | exit(1) +9 |- quit(1) + 9 |+ exit2(1) + + 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 new file mode 100644 index 0000000000..80b8423a35 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_5.py.snap @@ -0,0 +1,87 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +sys_exit_alias_5.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` + | +1 | from sys import * +2 | +3 | exit(0) + | ^^^^ PLR1722 +4 | quit(0) + | + = help: Replace `exit` with `sys.exit()` + +ℹ Suggested fix +1 1 | from sys import * + 2 |+import sys +2 3 | +3 |-exit(0) + 4 |+sys.exit(0) +4 5 | quit(0) +5 6 | +6 7 | + +sys_exit_alias_5.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` + | +3 | exit(0) +4 | quit(0) + | ^^^^ PLR1722 + | + = help: Replace `quit` with `sys.exit()` + +ℹ Suggested fix +1 1 | from sys import * + 2 |+import sys +2 3 | +3 4 | exit(0) +4 |-quit(0) + 5 |+sys.exit(0) +5 6 | +6 7 | +7 8 | def main(): + +sys_exit_alias_5.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` + | +7 | def main(): +8 | exit(1) + | ^^^^ PLR1722 +9 | quit(1) + | + = help: Replace `exit` with `sys.exit()` + +ℹ Suggested fix +1 1 | from sys import * + 2 |+import sys +2 3 | +3 4 | exit(0) +4 5 | quit(0) +5 6 | +6 7 | +7 8 | def main(): +8 |- exit(1) + 9 |+ sys.exit(1) +9 10 | quit(1) + +sys_exit_alias_5.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` + | +7 | def main(): +8 | exit(1) +9 | quit(1) + | ^^^^ PLR1722 + | + = help: Replace `quit` with `sys.exit()` + +ℹ Suggested fix +1 1 | from sys import * + 2 |+import sys +2 3 | +3 4 | exit(0) +4 5 | quit(0) +-------------------------------------------------------------------------------- +6 7 | +7 8 | def main(): +8 9 | exit(1) +9 |- quit(1) + 10 |+ sys.exit(1) + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap new file mode 100644 index 0000000000..b257b7b923 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap @@ -0,0 +1,37 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +sys_exit_alias_6.py:1:1: PLR1722 [*] Use `sys.exit()` instead of `exit` + | +1 | exit(0) + | ^^^^ PLR1722 +2 | quit(0) + | + = help: Replace `exit` with `sys.exit()` + +ℹ Suggested fix +1 |-exit(0) + 1 |+import sys + 2 |+sys.exit(0) +2 3 | quit(0) +3 4 | +4 5 | + +sys_exit_alias_6.py:2:1: PLR1722 [*] Use `sys.exit()` instead of `quit` + | +1 | exit(0) +2 | quit(0) + | ^^^^ PLR1722 + | + = help: Replace `quit` with `sys.exit()` + +ℹ Suggested fix + 1 |+import sys +1 2 | exit(0) +2 |-quit(0) + 3 |+sys.exit(0) +3 4 | +4 5 | +5 6 | def exit(e): + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap new file mode 100644 index 0000000000..5d64c2ee63 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap @@ -0,0 +1,21 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +sys_exit_alias_7.py:2:5: PLR1722 [*] Use `sys.exit()` instead of `exit` + | +1 | def main(): +2 | exit(0) + | ^^^^ PLR1722 + | + = help: Replace `exit` with `sys.exit()` + +ℹ Suggested fix + 1 |+import sys +1 2 | def main(): +2 |- exit(0) + 3 |+ sys.exit(0) +3 4 | +4 5 | +5 6 | import functools + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap new file mode 100644 index 0000000000..fa796c091f --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +sys_exit_alias_8.py:5:5: PLR1722 [*] Use `sys.exit()` instead of `exit` + | +4 | def main(): +5 | exit(0) + | ^^^^ PLR1722 + | + = help: Replace `exit` with `sys.exit()` + +ℹ Suggested fix +1 |-from sys import argv + 1 |+from sys import argv, exit +2 2 | +3 3 | +4 4 | def main(): + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap new file mode 100644 index 0000000000..99d5f3389f --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap @@ -0,0 +1,21 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +sys_exit_alias_9.py:2:5: PLR1722 [*] Use `sys.exit()` instead of `exit` + | +1 | def main(): +2 | exit(0) + | ^^^^ PLR1722 + | + = help: Replace `exit` with `sys.exit()` + +ℹ Suggested fix + 1 |+import sys +1 2 | def main(): +2 |- exit(0) + 3 |+ sys.exit(0) +3 4 | +4 5 | +5 6 | from sys import argv + + 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 new file mode 100644 index 0000000000..a27dc36b01 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR2004_magic_value_comparison.py.snap @@ -0,0 +1,49 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +magic_value_comparison.py:5:4: PLR2004 Magic value used in comparison, consider replacing 10 with a constant variable + | +3 | user_input = 10 +4 | +5 | if 10 > user_input: # [magic-value-comparison] + | ^^ PLR2004 +6 | pass + | + +magic_value_comparison.py:38:12: PLR2004 Magic value used in comparison, consider replacing 2 with a constant variable + | +36 | pass +37 | +38 | if argc != 2: # [magic-value-comparison] + | ^ PLR2004 +39 | pass + | + +magic_value_comparison.py:41:12: PLR2004 Magic value used in comparison, consider replacing -2 with a constant variable + | +39 | pass +40 | +41 | if argc != -2: # [magic-value-comparison] + | ^^ PLR2004 +42 | pass + | + +magic_value_comparison.py:44:12: PLR2004 Magic value used in comparison, consider replacing +2 with a constant variable + | +42 | pass +43 | +44 | if argc != +2: # [magic-value-comparison] + | ^^ PLR2004 +45 | pass + | + +magic_value_comparison.py:65:21: PLR2004 Magic value used in comparison, consider replacing 3.141592653589793 with a constant variable + | +63 | pi_estimation = 3.14 +64 | +65 | if pi_estimation == 3.141592653589793238: # [magic-value-comparison] + | ^^^^^^^^^^^^^^^^^^^^ PLR2004 +66 | pass + | + + 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 new file mode 100644 index 0000000000..0d369bcb04 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR5501_collapsible_else_if.py.snap @@ -0,0 +1,39 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +collapsible_else_if.py:37:5: PLR5501 Use `elif` instead of `else` then `if`, to reduce indentation + | +35 | if 1: +36 | pass +37 | else: + | _____^ +38 | | if 2: + | |________^ PLR5501 +39 | pass + | + +collapsible_else_if.py:45:5: PLR5501 Use `elif` instead of `else` then `if`, to reduce indentation + | +43 | if 1: +44 | pass +45 | else: + | _____^ +46 | | if 2: + | |________^ PLR5501 +47 | pass +48 | else: + | + +collapsible_else_if.py:58:5: PLR5501 Use `elif` instead of `else` then `if`, to reduce indentation + | +56 | elif True: +57 | print(2) +58 | else: + | _____^ +59 | | if True: + | |________^ PLR5501 +60 | print(3) +61 | else: + | + + 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 new file mode 100644 index 0000000000..405976321a --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLR6301_no_self_use.py.snap @@ -0,0 +1,39 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +no_self_use.py:5:28: PLR6301 Method `developer_greeting` could be a function or static method + | +4 | class Person: +5 | def developer_greeting(self, name): # [no-self-use] + | ^^^^ PLR6301 +6 | print(f"Greetings {name}!") + | + +no_self_use.py:8:20: PLR6301 Method `greeting_1` could be a function or static method + | +6 | print(f"Greetings {name}!") +7 | +8 | def greeting_1(self): # [no-self-use] + | ^^^^ PLR6301 +9 | print("Hello!") + | + +no_self_use.py:11:20: PLR6301 Method `greeting_2` could be a function or static method + | + 9 | print("Hello!") +10 | +11 | def greeting_2(self): # [no-self-use] + | ^^^^ PLR6301 +12 | print("Hi!") + | + +no_self_use.py:55:25: PLR6301 Method `abstract_method` could be a function or static method + | +53 | class Sub(Base): +54 | @override +55 | def abstract_method(self): + | ^^^^ PLR6301 +56 | print("concrete method") + | + + 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 new file mode 100644 index 0000000000..bed971a55b --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0120_useless_else_on_loop.py.snap @@ -0,0 +1,72 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +useless_else_on_loop.py:9:5: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it + | + 7 | if i % 2: + 8 | return i + 9 | else: # [useless-else-on-loop] + | ^^^^ PLW0120 +10 | print("math is broken") +11 | return None + | + +useless_else_on_loop.py:18:5: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it + | +16 | while True: +17 | return 1 +18 | else: # [useless-else-on-loop] + | ^^^^ PLW0120 +19 | print("math is broken") +20 | return None + | + +useless_else_on_loop.py:30:1: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it + | +28 | break +29 | +30 | else: # [useless-else-on-loop] + | ^^^^ PLW0120 +31 | print("or else!") + | + +useless_else_on_loop.py:37:1: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it + | +35 | while False: +36 | break +37 | else: # [useless-else-on-loop] + | ^^^^ PLW0120 +38 | print("or else!") + | + +useless_else_on_loop.py:42:1: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it + | +40 | for j in range(10): +41 | pass +42 | else: # [useless-else-on-loop] + | ^^^^ PLW0120 +43 | print("fat chance") +44 | for j in range(10): + | + +useless_else_on_loop.py:88:5: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it + | +86 | else: +87 | print("all right") +88 | else: # [useless-else-on-loop] + | ^^^^ PLW0120 +89 | return True +90 | return False + | + +useless_else_on_loop.py:98:9: PLW0120 `else` clause on loop without a `break` statement; remove the `else` and de-indent all the code inside it + | + 96 | for _ in range(3): + 97 | pass + 98 | else: + | ^^^^ PLW0120 + 99 | if 1 < 2: # pylint: disable=comparison-of-constants +100 | break + | + + 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 new file mode 100644 index 0000000000..80ecb80e58 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0127_self_assigning_variable.py.snap @@ -0,0 +1,362 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +self_assigning_variable.py:6:1: PLW0127 Self-assignment of variable `foo` + | +5 | # Errors. +6 | foo = foo + | ^^^ PLW0127 +7 | bar = bar +8 | foo, bar = foo, bar + | + +self_assigning_variable.py:7:1: PLW0127 Self-assignment of variable `bar` + | +5 | # Errors. +6 | foo = foo +7 | bar = bar + | ^^^ PLW0127 +8 | foo, bar = foo, bar +9 | bar, foo = bar, foo + | + +self_assigning_variable.py:8:1: PLW0127 Self-assignment of variable `foo` + | + 6 | foo = foo + 7 | bar = bar + 8 | foo, bar = foo, bar + | ^^^ PLW0127 + 9 | bar, foo = bar, foo +10 | (foo, bar) = (foo, bar) + | + +self_assigning_variable.py:8:6: PLW0127 Self-assignment of variable `bar` + | + 6 | foo = foo + 7 | bar = bar + 8 | foo, bar = foo, bar + | ^^^ PLW0127 + 9 | bar, foo = bar, foo +10 | (foo, bar) = (foo, bar) + | + +self_assigning_variable.py:9:1: PLW0127 Self-assignment of variable `bar` + | + 7 | bar = bar + 8 | foo, bar = foo, bar + 9 | bar, foo = bar, foo + | ^^^ PLW0127 +10 | (foo, bar) = (foo, bar) +11 | (bar, foo) = (bar, foo) + | + +self_assigning_variable.py:9:6: PLW0127 Self-assignment of variable `foo` + | + 7 | bar = bar + 8 | foo, bar = foo, bar + 9 | bar, foo = bar, foo + | ^^^ PLW0127 +10 | (foo, bar) = (foo, bar) +11 | (bar, foo) = (bar, foo) + | + +self_assigning_variable.py:10:2: PLW0127 Self-assignment of variable `foo` + | + 8 | foo, bar = foo, bar + 9 | bar, foo = bar, foo +10 | (foo, bar) = (foo, bar) + | ^^^ PLW0127 +11 | (bar, foo) = (bar, foo) +12 | foo, (bar, baz) = foo, (bar, baz) + | + +self_assigning_variable.py:10:7: PLW0127 Self-assignment of variable `bar` + | + 8 | foo, bar = foo, bar + 9 | bar, foo = bar, foo +10 | (foo, bar) = (foo, bar) + | ^^^ PLW0127 +11 | (bar, foo) = (bar, foo) +12 | foo, (bar, baz) = foo, (bar, baz) + | + +self_assigning_variable.py:11:2: PLW0127 Self-assignment of variable `bar` + | + 9 | bar, foo = bar, foo +10 | (foo, bar) = (foo, bar) +11 | (bar, foo) = (bar, foo) + | ^^^ PLW0127 +12 | foo, (bar, baz) = foo, (bar, baz) +13 | bar, (foo, baz) = bar, (foo, baz) + | + +self_assigning_variable.py:11:7: PLW0127 Self-assignment of variable `foo` + | + 9 | bar, foo = bar, foo +10 | (foo, bar) = (foo, bar) +11 | (bar, foo) = (bar, foo) + | ^^^ PLW0127 +12 | foo, (bar, baz) = foo, (bar, baz) +13 | bar, (foo, baz) = bar, (foo, baz) + | + +self_assigning_variable.py:12:1: PLW0127 Self-assignment of variable `foo` + | +10 | (foo, bar) = (foo, bar) +11 | (bar, foo) = (bar, foo) +12 | foo, (bar, baz) = foo, (bar, baz) + | ^^^ PLW0127 +13 | bar, (foo, baz) = bar, (foo, baz) +14 | (foo, bar), baz = (foo, bar), baz + | + +self_assigning_variable.py:12:7: PLW0127 Self-assignment of variable `bar` + | +10 | (foo, bar) = (foo, bar) +11 | (bar, foo) = (bar, foo) +12 | foo, (bar, baz) = foo, (bar, baz) + | ^^^ PLW0127 +13 | bar, (foo, baz) = bar, (foo, baz) +14 | (foo, bar), baz = (foo, bar), baz + | + +self_assigning_variable.py:12:12: PLW0127 Self-assignment of variable `baz` + | +10 | (foo, bar) = (foo, bar) +11 | (bar, foo) = (bar, foo) +12 | foo, (bar, baz) = foo, (bar, baz) + | ^^^ PLW0127 +13 | bar, (foo, baz) = bar, (foo, baz) +14 | (foo, bar), baz = (foo, bar), baz + | + +self_assigning_variable.py:13:1: PLW0127 Self-assignment of variable `bar` + | +11 | (bar, foo) = (bar, foo) +12 | foo, (bar, baz) = foo, (bar, baz) +13 | bar, (foo, baz) = bar, (foo, baz) + | ^^^ PLW0127 +14 | (foo, bar), baz = (foo, bar), baz +15 | (foo, (bar, baz)) = (foo, (bar, baz)) + | + +self_assigning_variable.py:13:7: PLW0127 Self-assignment of variable `foo` + | +11 | (bar, foo) = (bar, foo) +12 | foo, (bar, baz) = foo, (bar, baz) +13 | bar, (foo, baz) = bar, (foo, baz) + | ^^^ PLW0127 +14 | (foo, bar), baz = (foo, bar), baz +15 | (foo, (bar, baz)) = (foo, (bar, baz)) + | + +self_assigning_variable.py:13:12: PLW0127 Self-assignment of variable `baz` + | +11 | (bar, foo) = (bar, foo) +12 | foo, (bar, baz) = foo, (bar, baz) +13 | bar, (foo, baz) = bar, (foo, baz) + | ^^^ PLW0127 +14 | (foo, bar), baz = (foo, bar), baz +15 | (foo, (bar, baz)) = (foo, (bar, baz)) + | + +self_assigning_variable.py:14:2: PLW0127 Self-assignment of variable `foo` + | +12 | foo, (bar, baz) = foo, (bar, baz) +13 | bar, (foo, baz) = bar, (foo, baz) +14 | (foo, bar), baz = (foo, bar), baz + | ^^^ PLW0127 +15 | (foo, (bar, baz)) = (foo, (bar, baz)) +16 | foo, bar = foo, 1 + | + +self_assigning_variable.py:14:7: PLW0127 Self-assignment of variable `bar` + | +12 | foo, (bar, baz) = foo, (bar, baz) +13 | bar, (foo, baz) = bar, (foo, baz) +14 | (foo, bar), baz = (foo, bar), baz + | ^^^ PLW0127 +15 | (foo, (bar, baz)) = (foo, (bar, baz)) +16 | foo, bar = foo, 1 + | + +self_assigning_variable.py:14:13: PLW0127 Self-assignment of variable `baz` + | +12 | foo, (bar, baz) = foo, (bar, baz) +13 | bar, (foo, baz) = bar, (foo, baz) +14 | (foo, bar), baz = (foo, bar), baz + | ^^^ PLW0127 +15 | (foo, (bar, baz)) = (foo, (bar, baz)) +16 | foo, bar = foo, 1 + | + +self_assigning_variable.py:15:2: PLW0127 Self-assignment of variable `foo` + | +13 | bar, (foo, baz) = bar, (foo, baz) +14 | (foo, bar), baz = (foo, bar), baz +15 | (foo, (bar, baz)) = (foo, (bar, baz)) + | ^^^ PLW0127 +16 | foo, bar = foo, 1 +17 | bar, foo = bar, 1 + | + +self_assigning_variable.py:15:8: PLW0127 Self-assignment of variable `bar` + | +13 | bar, (foo, baz) = bar, (foo, baz) +14 | (foo, bar), baz = (foo, bar), baz +15 | (foo, (bar, baz)) = (foo, (bar, baz)) + | ^^^ PLW0127 +16 | foo, bar = foo, 1 +17 | bar, foo = bar, 1 + | + +self_assigning_variable.py:15:13: PLW0127 Self-assignment of variable `baz` + | +13 | bar, (foo, baz) = bar, (foo, baz) +14 | (foo, bar), baz = (foo, bar), baz +15 | (foo, (bar, baz)) = (foo, (bar, baz)) + | ^^^ PLW0127 +16 | foo, bar = foo, 1 +17 | bar, foo = bar, 1 + | + +self_assigning_variable.py:16:1: PLW0127 Self-assignment of variable `foo` + | +14 | (foo, bar), baz = (foo, bar), baz +15 | (foo, (bar, baz)) = (foo, (bar, baz)) +16 | foo, bar = foo, 1 + | ^^^ PLW0127 +17 | bar, foo = bar, 1 +18 | (foo, bar) = (foo, 1) + | + +self_assigning_variable.py:17:1: PLW0127 Self-assignment of variable `bar` + | +15 | (foo, (bar, baz)) = (foo, (bar, baz)) +16 | foo, bar = foo, 1 +17 | bar, foo = bar, 1 + | ^^^ PLW0127 +18 | (foo, bar) = (foo, 1) +19 | (bar, foo) = (bar, 1) + | + +self_assigning_variable.py:18:2: PLW0127 Self-assignment of variable `foo` + | +16 | foo, bar = foo, 1 +17 | bar, foo = bar, 1 +18 | (foo, bar) = (foo, 1) + | ^^^ PLW0127 +19 | (bar, foo) = (bar, 1) +20 | foo, (bar, baz) = foo, (bar, 1) + | + +self_assigning_variable.py:19:2: PLW0127 Self-assignment of variable `bar` + | +17 | bar, foo = bar, 1 +18 | (foo, bar) = (foo, 1) +19 | (bar, foo) = (bar, 1) + | ^^^ PLW0127 +20 | foo, (bar, baz) = foo, (bar, 1) +21 | bar, (foo, baz) = bar, (foo, 1) + | + +self_assigning_variable.py:20:1: PLW0127 Self-assignment of variable `foo` + | +18 | (foo, bar) = (foo, 1) +19 | (bar, foo) = (bar, 1) +20 | foo, (bar, baz) = foo, (bar, 1) + | ^^^ PLW0127 +21 | bar, (foo, baz) = bar, (foo, 1) +22 | (foo, bar), baz = (foo, bar), 1 + | + +self_assigning_variable.py:20:7: PLW0127 Self-assignment of variable `bar` + | +18 | (foo, bar) = (foo, 1) +19 | (bar, foo) = (bar, 1) +20 | foo, (bar, baz) = foo, (bar, 1) + | ^^^ PLW0127 +21 | bar, (foo, baz) = bar, (foo, 1) +22 | (foo, bar), baz = (foo, bar), 1 + | + +self_assigning_variable.py:21:1: PLW0127 Self-assignment of variable `bar` + | +19 | (bar, foo) = (bar, 1) +20 | foo, (bar, baz) = foo, (bar, 1) +21 | bar, (foo, baz) = bar, (foo, 1) + | ^^^ PLW0127 +22 | (foo, bar), baz = (foo, bar), 1 +23 | (foo, (bar, baz)) = (foo, (bar, 1)) + | + +self_assigning_variable.py:21:7: PLW0127 Self-assignment of variable `foo` + | +19 | (bar, foo) = (bar, 1) +20 | foo, (bar, baz) = foo, (bar, 1) +21 | bar, (foo, baz) = bar, (foo, 1) + | ^^^ PLW0127 +22 | (foo, bar), baz = (foo, bar), 1 +23 | (foo, (bar, baz)) = (foo, (bar, 1)) + | + +self_assigning_variable.py:22:2: PLW0127 Self-assignment of variable `foo` + | +20 | foo, (bar, baz) = foo, (bar, 1) +21 | bar, (foo, baz) = bar, (foo, 1) +22 | (foo, bar), baz = (foo, bar), 1 + | ^^^ PLW0127 +23 | (foo, (bar, baz)) = (foo, (bar, 1)) +24 | foo: int = foo + | + +self_assigning_variable.py:22:7: PLW0127 Self-assignment of variable `bar` + | +20 | foo, (bar, baz) = foo, (bar, 1) +21 | bar, (foo, baz) = bar, (foo, 1) +22 | (foo, bar), baz = (foo, bar), 1 + | ^^^ PLW0127 +23 | (foo, (bar, baz)) = (foo, (bar, 1)) +24 | foo: int = foo + | + +self_assigning_variable.py:23:2: PLW0127 Self-assignment of variable `foo` + | +21 | bar, (foo, baz) = bar, (foo, 1) +22 | (foo, bar), baz = (foo, bar), 1 +23 | (foo, (bar, baz)) = (foo, (bar, 1)) + | ^^^ PLW0127 +24 | foo: int = foo +25 | bar: int = bar + | + +self_assigning_variable.py:23:8: PLW0127 Self-assignment of variable `bar` + | +21 | bar, (foo, baz) = bar, (foo, 1) +22 | (foo, bar), baz = (foo, bar), 1 +23 | (foo, (bar, baz)) = (foo, (bar, 1)) + | ^^^ PLW0127 +24 | foo: int = foo +25 | bar: int = bar + | + +self_assigning_variable.py:24:1: PLW0127 Self-assignment of variable `foo` + | +22 | (foo, bar), baz = (foo, bar), 1 +23 | (foo, (bar, baz)) = (foo, (bar, 1)) +24 | foo: int = foo + | ^^^ PLW0127 +25 | bar: int = bar + | + +self_assigning_variable.py:25:1: PLW0127 Self-assignment of variable `bar` + | +23 | (foo, (bar, baz)) = (foo, (bar, 1)) +24 | foo: int = foo +25 | bar: int = bar + | ^^^ PLW0127 +26 | +27 | # Non-errors. + | + + 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 new file mode 100644 index 0000000000..6b87dcf58c --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0129_assert_on_string_literal.py.snap @@ -0,0 +1,99 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +assert_on_string_literal.py:3:12: PLW0129 Asserting on a non-empty string literal will always pass + | +1 | def test_division(): +2 | a = 9 / 3 +3 | assert "No ZeroDivisionError were raised" # [assert-on-string-literal] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0129 + | + +assert_on_string_literal.py:12:12: PLW0129 Asserting on a non-empty string literal will always pass + | +11 | try: +12 | assert "bad" # [assert-on-string-literal] + | ^^^^^ PLW0129 +13 | except: +14 | assert "bad again" # [assert-on-string-literal] + | + +assert_on_string_literal.py:14:12: PLW0129 Asserting on a non-empty string literal will always pass + | +12 | assert "bad" # [assert-on-string-literal] +13 | except: +14 | assert "bad again" # [assert-on-string-literal] + | ^^^^^^^^^^^ PLW0129 +15 | +16 | a = 12 + | + +assert_on_string_literal.py:17:8: PLW0129 Asserting on a non-empty string literal will always pass + | +16 | a = 12 +17 | assert f"hello {a}" # [assert-on-string-literal] + | ^^^^^^^^^^^^ PLW0129 +18 | assert f"{a}" # [assert-on-string-literal] +19 | assert f"" # [assert-on-string-literal] + | + +assert_on_string_literal.py:18:8: PLW0129 Asserting on a string literal may have unintended results + | +16 | a = 12 +17 | assert f"hello {a}" # [assert-on-string-literal] +18 | assert f"{a}" # [assert-on-string-literal] + | ^^^^^^ PLW0129 +19 | assert f"" # [assert-on-string-literal] +20 | assert "" # [assert-on-string-literal] + | + +assert_on_string_literal.py:19:8: PLW0129 Asserting on an empty string literal will never pass + | +17 | assert f"hello {a}" # [assert-on-string-literal] +18 | assert f"{a}" # [assert-on-string-literal] +19 | assert f"" # [assert-on-string-literal] + | ^^^ PLW0129 +20 | assert "" # [assert-on-string-literal] +21 | assert b"hello" # [assert-on-string-literal] + | + +assert_on_string_literal.py:20:8: PLW0129 Asserting on an empty string literal will never pass + | +18 | assert f"{a}" # [assert-on-string-literal] +19 | assert f"" # [assert-on-string-literal] +20 | assert "" # [assert-on-string-literal] + | ^^ PLW0129 +21 | assert b"hello" # [assert-on-string-literal] +22 | assert "", b"hi" # [assert-on-string-literal] + | + +assert_on_string_literal.py:21:8: PLW0129 Asserting on a non-empty string literal will always pass + | +19 | assert f"" # [assert-on-string-literal] +20 | assert "" # [assert-on-string-literal] +21 | assert b"hello" # [assert-on-string-literal] + | ^^^^^^^^ PLW0129 +22 | assert "", b"hi" # [assert-on-string-literal] +23 | assert "WhyNotHere?", "HereIsOk" # [assert-on-string-literal] + | + +assert_on_string_literal.py:22:8: PLW0129 Asserting on an empty string literal will never pass + | +20 | assert "" # [assert-on-string-literal] +21 | assert b"hello" # [assert-on-string-literal] +22 | assert "", b"hi" # [assert-on-string-literal] + | ^^ PLW0129 +23 | assert "WhyNotHere?", "HereIsOk" # [assert-on-string-literal] +24 | assert 12, "ok here" + | + +assert_on_string_literal.py:23:8: PLW0129 Asserting on a non-empty string literal will always pass + | +21 | assert b"hello" # [assert-on-string-literal] +22 | assert "", b"hi" # [assert-on-string-literal] +23 | assert "WhyNotHere?", "HereIsOk" # [assert-on-string-literal] + | ^^^^^^^^^^^^^ PLW0129 +24 | assert 12, "ok here" + | + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0131_named_expr_without_context.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0131_named_expr_without_context.py.snap new file mode 100644 index 0000000000..9a3730761b --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0131_named_expr_without_context.py.snap @@ -0,0 +1,28 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +named_expr_without_context.py:2:2: PLW0131 Named expression used without context + | +1 | # Errors +2 | (a := 42) + | ^^^^^^^ PLW0131 +3 | if True: +4 | (b := 1) + | + +named_expr_without_context.py:4:6: PLW0131 Named expression used without context + | +2 | (a := 42) +3 | if True: +4 | (b := 1) + | ^^^^^^ PLW0131 + | + +named_expr_without_context.py:8:6: PLW0131 Named expression used without context + | +7 | class Foo: +8 | (c := 1) + | ^^^^^^ PLW0131 + | + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0406_import_self__module.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0406_import_self__module.py.snap new file mode 100644 index 0000000000..e2be646568 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0406_import_self__module.py.snap @@ -0,0 +1,28 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +module.py:1:8: PLW0406 Module `import_self.module` imports itself + | +1 | import import_self.module + | ^^^^^^^^^^^^^^^^^^ PLW0406 +2 | from import_self import module +3 | from . import module + | + +module.py:2:25: PLW0406 Module `import_self.module` imports itself + | +1 | import import_self.module +2 | from import_self import module + | ^^^^^^ PLW0406 +3 | from . import module + | + +module.py:3:15: PLW0406 Module `import_self.module` imports itself + | +1 | import import_self.module +2 | from import_self import module +3 | from . import module + | ^^^^^^ PLW0406 + | + + 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 new file mode 100644 index 0000000000..61b98b457e --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0602_global_variable_not_assigned.py.snap @@ -0,0 +1,21 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +global_variable_not_assigned.py:5:12: PLW0602 Using global for `X` but no assignment is done + | +3 | ### +4 | def f(): +5 | global X + | ^ PLW0602 + | + +global_variable_not_assigned.py:9:12: PLW0602 Using global for `X` but no assignment is done + | + 8 | def f(): + 9 | global X + | ^ PLW0602 +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 new file mode 100644 index 0000000000..ad189b3ebb --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0603_global_statement.py.snap @@ -0,0 +1,102 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +global_statement.py:17:12: PLW0603 Using the global statement to update `CONSTANT` is discouraged + | +15 | def fix_constant(value): +16 | """All this is ok, but try not to use `global` ;)""" +17 | global CONSTANT # [global-statement] + | ^^^^^^^^ PLW0603 +18 | print(CONSTANT) +19 | CONSTANT = value + | + +global_statement.py:24:12: PLW0603 Using the global statement to update `sys` is discouraged + | +22 | def global_with_import(): +23 | """Should only warn for global-statement when using `Import` node""" +24 | global sys # [global-statement] + | ^^^ PLW0603 +25 | import sys + | + +global_statement.py:30:12: PLW0603 Using the global statement to update `namedtuple` is discouraged + | +28 | def global_with_import_from(): +29 | """Should only warn for global-statement when using `ImportFrom` node""" +30 | global namedtuple # [global-statement] + | ^^^^^^^^^^ PLW0603 +31 | from collections import namedtuple + | + +global_statement.py:36:12: PLW0603 Using the global statement to update `CONSTANT` is discouraged + | +34 | def global_del(): +35 | """Deleting the global name prevents `global-variable-not-assigned`""" +36 | global CONSTANT # [global-statement] + | ^^^^^^^^ PLW0603 +37 | print(CONSTANT) +38 | del CONSTANT + | + +global_statement.py:43:12: PLW0603 Using the global statement to update `CONSTANT` is discouraged + | +41 | def global_operator_assign(): +42 | """Operator assigns should only throw a global statement error""" +43 | global CONSTANT # [global-statement] + | ^^^^^^^^ PLW0603 +44 | print(CONSTANT) +45 | CONSTANT += 1 + | + +global_statement.py:50:12: PLW0603 Using the global statement to update `CONSTANT` is discouraged + | +48 | def global_function_assign(): +49 | """Function assigns should only throw a global statement error""" +50 | global CONSTANT # [global-statement] + | ^^^^^^^^ PLW0603 +51 | +52 | def CONSTANT(): + | + +global_statement.py:60:12: PLW0603 Using the global statement to update `FUNC` is discouraged + | +58 | def override_func(): +59 | """Overriding a function should only throw a global statement error""" +60 | global FUNC # [global-statement] + | ^^^^ PLW0603 +61 | +62 | def FUNC(): + | + +global_statement.py:70:12: PLW0603 Using the global statement to update `CLASS` is discouraged + | +68 | def override_class(): +69 | """Overriding a class should only throw a global statement error""" +70 | global CLASS # [global-statement] + | ^^^^^ PLW0603 +71 | +72 | class CLASS: + | + +global_statement.py:80:12: PLW0603 Using the global statement to update `CONSTANT` is discouraged + | +78 | def multiple_assignment(): +79 | """Should warn on every assignment.""" +80 | global CONSTANT # [global-statement] + | ^^^^^^^^ PLW0603 +81 | CONSTANT = 1 +82 | CONSTANT = 2 + | + +global_statement.py:80:12: PLW0603 Using the global statement to update `CONSTANT` is discouraged + | +78 | def multiple_assignment(): +79 | """Should warn on every assignment.""" +80 | global CONSTANT # [global-statement] + | ^^^^^^^^ PLW0603 +81 | CONSTANT = 1 +82 | CONSTANT = 2 + | + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0711_binary_op_exception.py.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0711_binary_op_exception.py.snap new file mode 100644 index 0000000000..e8300c00e3 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW0711_binary_op_exception.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +binary_op_exception.py:3:8: PLW0711 Exception to catch is the result of a binary `or` operation + | +1 | try: +2 | 1 / 0 +3 | except ZeroDivisionError or ValueError as e: # [binary-op-exception] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0711 +4 | pass + | + +binary_op_exception.py:8:8: PLW0711 Exception to catch is the result of a binary `and` operation + | +6 | try: +7 | raise ValueError +8 | except ZeroDivisionError and ValueError as e: # [binary-op-exception] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW0711 +9 | print(e) + | + + 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 new file mode 100644 index 0000000000..ff062bb700 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1508_invalid_envvar_default.py.snap @@ -0,0 +1,44 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +invalid_envvar_default.py:3:29: PLW1508 Invalid type for environment variable default; expected `str` or `None` + | +1 | import os +2 | +3 | tempVar = os.getenv("TEST", 12) # [invalid-envvar-default] + | ^^ PLW1508 +4 | goodVar = os.getenv("TESTING", None) +5 | dictVarBad = os.getenv("AAA", {"a", 7}) # [invalid-envvar-default] + | + +invalid_envvar_default.py:5:31: PLW1508 Invalid type for environment variable default; expected `str` or `None` + | +3 | tempVar = os.getenv("TEST", 12) # [invalid-envvar-default] +4 | goodVar = os.getenv("TESTING", None) +5 | dictVarBad = os.getenv("AAA", {"a", 7}) # [invalid-envvar-default] + | ^^^^^^^^ PLW1508 +6 | print(os.getenv("TEST", False)) # [invalid-envvar-default] +7 | os.getenv("AA", "GOOD") + | + +invalid_envvar_default.py:6:25: PLW1508 Invalid type for environment variable default; expected `str` or `None` + | +4 | goodVar = os.getenv("TESTING", None) +5 | dictVarBad = os.getenv("AAA", {"a", 7}) # [invalid-envvar-default] +6 | print(os.getenv("TEST", False)) # [invalid-envvar-default] + | ^^^^^ PLW1508 +7 | os.getenv("AA", "GOOD") +8 | os.getenv("AA", f"GOOD") + | + +invalid_envvar_default.py:10:17: PLW1508 Invalid type for environment variable default; expected `str` or `None` + | + 8 | os.getenv("AA", f"GOOD") + 9 | os.getenv("AA", "GOOD" + "BAD") +10 | os.getenv("AA", "GOOD" + 1) + | ^^^^^^^^^^ PLW1508 +11 | os.getenv("AA", "GOOD %s" % "BAD") +12 | os.getenv("B", Z) + | + + 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 new file mode 100644 index 0000000000..fd540da0f6 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1509_subprocess_popen_preexec_fn.py.snap @@ -0,0 +1,42 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +subprocess_popen_preexec_fn.py:9:18: PLW1509 `preexec_fn` argument is unsafe when using threads + | + 8 | # Errors. + 9 | subprocess.Popen(preexec_fn=foo) + | ^^^^^^^^^^^^^^ PLW1509 +10 | subprocess.Popen(["ls"], preexec_fn=foo) +11 | subprocess.Popen(preexec_fn=lambda: print("Hello, world!")) + | + +subprocess_popen_preexec_fn.py:10:26: PLW1509 `preexec_fn` argument is unsafe when using threads + | + 8 | # Errors. + 9 | subprocess.Popen(preexec_fn=foo) +10 | subprocess.Popen(["ls"], preexec_fn=foo) + | ^^^^^^^^^^^^^^ PLW1509 +11 | subprocess.Popen(preexec_fn=lambda: print("Hello, world!")) +12 | subprocess.Popen(["ls"], preexec_fn=lambda: print("Hello, world!")) + | + +subprocess_popen_preexec_fn.py:11:18: PLW1509 `preexec_fn` argument is unsafe when using threads + | + 9 | subprocess.Popen(preexec_fn=foo) +10 | subprocess.Popen(["ls"], preexec_fn=foo) +11 | subprocess.Popen(preexec_fn=lambda: print("Hello, world!")) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW1509 +12 | subprocess.Popen(["ls"], preexec_fn=lambda: print("Hello, world!")) + | + +subprocess_popen_preexec_fn.py:12:26: PLW1509 `preexec_fn` argument is unsafe when using threads + | +10 | subprocess.Popen(["ls"], preexec_fn=foo) +11 | subprocess.Popen(preexec_fn=lambda: print("Hello, world!")) +12 | subprocess.Popen(["ls"], preexec_fn=lambda: print("Hello, world!")) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW1509 +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 new file mode 100644 index 0000000000..b0306f17a2 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1510_subprocess_run_without_check.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +subprocess_run_without_check.py:4:1: PLW1510 `subprocess.run` without explicit `check` argument + | +3 | # Errors. +4 | subprocess.run("ls") + | ^^^^^^^^^^^^^^ PLW1510 +5 | subprocess.run("ls", shell=True) + | + +subprocess_run_without_check.py:5:1: PLW1510 `subprocess.run` without explicit `check` argument + | +3 | # Errors. +4 | subprocess.run("ls") +5 | subprocess.run("ls", shell=True) + | ^^^^^^^^^^^^^^ PLW1510 +6 | +7 | # Non-errors. + | + + 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 new file mode 100644 index 0000000000..416ed71902 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW1641_eq_without_hash.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +eq_without_hash.py:1:7: PLW1641 Object does not implement `__hash__` method + | +1 | class Person: # [eq-without-hash] + | ^^^^^^ PLW1641 +2 | def __init__(self): +3 | self.name = "monty" + | + + 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 new file mode 100644 index 0000000000..ee9c609b64 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW2901_redefined_loop_name.py.snap @@ -0,0 +1,252 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +redefined_loop_name.py:6:9: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + | +4 | # For -> for, variable reused +5 | for i in []: +6 | for i in []: # error + | ^ PLW2901 +7 | pass + | + +redefined_loop_name.py:11:9: PLW2901 `with` statement variable `i` overwritten by `for` loop target + | + 9 | # With -> for, variable reused +10 | with None as i: +11 | for i in []: # error + | ^ PLW2901 +12 | pass + | + +redefined_loop_name.py:16:18: PLW2901 `for` loop variable `i` overwritten by `with` statement target + | +14 | # For -> with, variable reused +15 | for i in []: +16 | with None as i: # error + | ^ PLW2901 +17 | pass + | + +redefined_loop_name.py:21:18: PLW2901 Outer `with` statement variable `i` overwritten by inner `with` statement target + | +19 | # With -> with, variable reused +20 | with None as i: +21 | with None as i: # error + | ^ PLW2901 +22 | pass + | + +redefined_loop_name.py:36:18: PLW2901 Outer `with` statement variable `i` overwritten by inner `with` statement target + | +34 | # Async with -> with, variable reused +35 | async with None as i: +36 | with None as i: # error + | ^ PLW2901 +37 | pass + | + +redefined_loop_name.py:46:9: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + | +44 | # Async for -> for, variable reused +45 | async for i in []: +46 | for i in []: # error + | ^ PLW2901 +47 | pass + | + +redefined_loop_name.py:52:13: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + | +50 | for i in []: +51 | for j in []: +52 | for i in []: # error + | ^ PLW2901 +53 | pass + | + +redefined_loop_name.py:58:13: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + | +56 | for i in []: +57 | for j in []: +58 | for i in []: # error + | ^ PLW2901 +59 | for j in []: # error +60 | pass + | + +redefined_loop_name.py:59:17: PLW2901 Outer `for` loop variable `j` overwritten by inner `for` loop target + | +57 | for j in []: +58 | for i in []: # error +59 | for j in []: # error + | ^ PLW2901 +60 | pass + | + +redefined_loop_name.py:67:5: PLW2901 `for` loop variable `i` overwritten by assignment target + | +65 | i = cast(int, i) +66 | i = typing.cast(int, i) +67 | i = 5 # error + | ^ PLW2901 +68 | +69 | # For -> augmented assignment + | + +redefined_loop_name.py:71:5: PLW2901 `for` loop variable `i` overwritten by assignment target + | +69 | # For -> augmented assignment +70 | for i in []: +71 | i += 5 # error + | ^ PLW2901 +72 | +73 | # For -> annotated assignment + | + +redefined_loop_name.py:75:5: PLW2901 `for` loop variable `i` overwritten by assignment target + | +73 | # For -> annotated assignment +74 | for i in []: +75 | i: int = 5 # error + | ^ PLW2901 +76 | +77 | # For -> annotated assignment without value + | + +redefined_loop_name.py:83:9: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + | +81 | # Async for -> for, variable reused +82 | async for i in []: +83 | for i in []: # error + | ^ PLW2901 +84 | pass + | + +redefined_loop_name.py:88:15: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + | +86 | # For -> async for, variable reused +87 | for i in []: +88 | async for i in []: # error + | ^ PLW2901 +89 | pass + | + +redefined_loop_name.py:93:9: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + | +91 | # For -> for, outer loop unpacks tuple +92 | for i, j in enumerate([]): +93 | for i in []: # error + | ^ PLW2901 +94 | pass + | + +redefined_loop_name.py:98:9: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + | +96 | # For -> for, inner loop unpacks tuple +97 | for i in []: +98 | for i, j in enumerate([]): # error + | ^ PLW2901 +99 | pass + | + +redefined_loop_name.py:103:9: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + | +101 | # For -> for, both loops unpack tuple +102 | for (i, (j, k)) in []: +103 | for i, j in enumerate([]): # two errors + | ^ PLW2901 +104 | pass + | + +redefined_loop_name.py:103:12: PLW2901 Outer `for` loop variable `j` overwritten by inner `for` loop target + | +101 | # For -> for, both loops unpack tuple +102 | for (i, (j, k)) in []: +103 | for i, j in enumerate([]): # two errors + | ^ PLW2901 +104 | pass + | + +redefined_loop_name.py:120:9: PLW2901 Outer `for` loop variable `j` overwritten by inner `for` loop target + | +118 | # For -> for, outer loop unpacks with asterisk +119 | for i, *j in []: +120 | for j in []: # error + | ^ PLW2901 +121 | pass + | + +redefined_loop_name.py:137:13: PLW2901 `for` loop variable `i` overwritten by assignment target + | +135 | def f(): +136 | for i in []: # no error +137 | i = 2 # error + | ^ PLW2901 +138 | +139 | # For -> class definition -> for -> for + | + +redefined_loop_name.py:143:17: PLW2901 Outer `for` loop variable `i` overwritten by inner `for` loop target + | +141 | class A: +142 | for i in []: # no error +143 | for i in []: # error + | ^ PLW2901 +144 | pass + | + +redefined_loop_name.py:158:5: PLW2901 `for` loop variable `a[0]` overwritten by assignment target + | +156 | # For target with subscript -> assignment +157 | for a[0] in []: +158 | a[0] = 2 # error + | ^^^^ PLW2901 +159 | a[1] = 2 # no error + | + +redefined_loop_name.py:163:5: PLW2901 `for` loop variable `a['i']` overwritten by assignment target + | +161 | # For target with subscript -> assignment +162 | for a['i'] in []: +163 | a['i'] = 2 # error + | ^^^^^^ PLW2901 +164 | a['j'] = 2 # no error + | + +redefined_loop_name.py:168:5: PLW2901 `for` loop variable `a.i` overwritten by assignment target + | +166 | # For target with attribute -> assignment +167 | for a.i in []: +168 | a.i = 2 # error + | ^^^ PLW2901 +169 | a.j = 2 # no error + | + +redefined_loop_name.py:173:5: PLW2901 `for` loop variable `a.i.j` overwritten by assignment target + | +171 | # For target with double nested attribute -> assignment +172 | for a.i.j in []: +173 | a.i.j = 2 # error + | ^^^^^ PLW2901 +174 | a.j.i = 2 # no error + | + +redefined_loop_name.py:178:5: PLW2901 `for` loop variable `a.i` overwritten by assignment target + | +176 | # For target with attribute -> assignment with different spacing +177 | for a.i in []: +178 | a. i = 2 # error + | ^^^^ PLW2901 +179 | for a. i in []: +180 | a.i = 2 # error + | + +redefined_loop_name.py:180:5: PLW2901 `for` loop variable `a.i` overwritten by assignment target + | +178 | a. i = 2 # error +179 | for a. i in []: +180 | a.i = 2 # error + | ^^^ PLW2901 + | + + 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 new file mode 100644 index 0000000000..47d5afe442 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3201_bad_dunder_method_name.py.snap @@ -0,0 +1,61 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +bad_dunder_method_name.py:5:9: PLW3201 Bad or misspelled dunder method name `_init_`. (bad-dunder-name) + | +4 | class Apples: +5 | def _init_(self): # [bad-dunder-name] + | ^^^^^^ PLW3201 +6 | pass + | + +bad_dunder_method_name.py:8:9: PLW3201 Bad or misspelled dunder method name `__hello__`. (bad-dunder-name) + | +6 | pass +7 | +8 | def __hello__(self): # [bad-dunder-name] + | ^^^^^^^^^ PLW3201 +9 | print("hello") + | + +bad_dunder_method_name.py:11:9: PLW3201 Bad or misspelled dunder method name `__init_`. (bad-dunder-name) + | + 9 | print("hello") +10 | +11 | def __init_(self): # [bad-dunder-name] + | ^^^^^^^ PLW3201 +12 | # author likely unintentionally misspelled the correct init dunder. +13 | pass + | + +bad_dunder_method_name.py:15:9: PLW3201 Bad or misspelled dunder method name `_init_`. (bad-dunder-name) + | +13 | pass +14 | +15 | def _init_(self): # [bad-dunder-name] + | ^^^^^^ PLW3201 +16 | # author likely unintentionally misspelled the correct init dunder. +17 | pass + | + +bad_dunder_method_name.py:19:9: PLW3201 Bad or misspelled dunder method name `___neg__`. (bad-dunder-name) + | +17 | pass +18 | +19 | def ___neg__(self): # [bad-dunder-name] + | ^^^^^^^^ PLW3201 +20 | # author likely accidentally added an additional `_` +21 | pass + | + +bad_dunder_method_name.py:23:9: PLW3201 Bad or misspelled dunder method name `__inv__`. (bad-dunder-name) + | +21 | pass +22 | +23 | def __inv__(self): # [bad-dunder-name] + | ^^^^^^^ PLW3201 +24 | # author likely meant to call the invert dunder method +25 | pass + | + + 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 new file mode 100644 index 0000000000..268f805ab8 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__PLW3301_nested_min_max.py.snap @@ -0,0 +1,296 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +nested_min_max.py:2:1: PLW3301 [*] Nested `min` calls can be flattened + | +1 | min(1, 2, 3) +2 | min(1, min(2, 3)) + | ^^^^^^^^^^^^^^^^^ PLW3301 +3 | min(1, min(2, min(3, 4))) +4 | min(1, foo("a", "b"), min(3, 4)) + | + = help: Flatten nested `min` calls + +ℹ Suggested fix +1 1 | min(1, 2, 3) +2 |-min(1, min(2, 3)) + 2 |+min(1, 2, 3) +3 3 | min(1, min(2, min(3, 4))) +4 4 | min(1, foo("a", "b"), min(3, 4)) +5 5 | min(1, max(2, 3)) + +nested_min_max.py:3:1: PLW3301 [*] Nested `min` calls can be flattened + | +1 | min(1, 2, 3) +2 | min(1, min(2, 3)) +3 | min(1, min(2, min(3, 4))) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 +4 | min(1, foo("a", "b"), min(3, 4)) +5 | min(1, max(2, 3)) + | + = help: Flatten nested `min` calls + +ℹ Suggested fix +1 1 | min(1, 2, 3) +2 2 | min(1, min(2, 3)) +3 |-min(1, min(2, min(3, 4))) + 3 |+min(1, 2, 3, 4) +4 4 | min(1, foo("a", "b"), min(3, 4)) +5 5 | min(1, max(2, 3)) +6 6 | max(1, 2, 3) + +nested_min_max.py:3:8: PLW3301 [*] Nested `min` calls can be flattened + | +1 | min(1, 2, 3) +2 | min(1, min(2, 3)) +3 | min(1, min(2, min(3, 4))) + | ^^^^^^^^^^^^^^^^^ PLW3301 +4 | min(1, foo("a", "b"), min(3, 4)) +5 | min(1, max(2, 3)) + | + = help: Flatten nested `min` calls + +ℹ Suggested fix +1 1 | min(1, 2, 3) +2 2 | min(1, min(2, 3)) +3 |-min(1, min(2, min(3, 4))) + 3 |+min(1, min(2, 3, 4)) +4 4 | min(1, foo("a", "b"), min(3, 4)) +5 5 | min(1, max(2, 3)) +6 6 | max(1, 2, 3) + +nested_min_max.py:4:1: PLW3301 [*] Nested `min` calls can be flattened + | +2 | min(1, min(2, 3)) +3 | min(1, min(2, min(3, 4))) +4 | min(1, foo("a", "b"), min(3, 4)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 +5 | min(1, max(2, 3)) +6 | max(1, 2, 3) + | + = help: Flatten nested `min` calls + +ℹ Suggested fix +1 1 | min(1, 2, 3) +2 2 | min(1, min(2, 3)) +3 3 | min(1, min(2, min(3, 4))) +4 |-min(1, foo("a", "b"), min(3, 4)) + 4 |+min(1, foo("a", "b"), 3, 4) +5 5 | min(1, max(2, 3)) +6 6 | max(1, 2, 3) +7 7 | max(1, max(2, 3)) + +nested_min_max.py:7:1: PLW3301 [*] Nested `max` calls can be flattened + | +5 | min(1, max(2, 3)) +6 | max(1, 2, 3) +7 | max(1, max(2, 3)) + | ^^^^^^^^^^^^^^^^^ PLW3301 +8 | max(1, max(2, max(3, 4))) +9 | max(1, foo("a", "b"), max(3, 4)) + | + = help: Flatten nested `max` calls + +ℹ Suggested fix +4 4 | min(1, foo("a", "b"), min(3, 4)) +5 5 | min(1, max(2, 3)) +6 6 | max(1, 2, 3) +7 |-max(1, max(2, 3)) + 7 |+max(1, 2, 3) +8 8 | max(1, max(2, max(3, 4))) +9 9 | max(1, foo("a", "b"), max(3, 4)) +10 10 | + +nested_min_max.py:8:1: PLW3301 [*] Nested `max` calls can be flattened + | +6 | max(1, 2, 3) +7 | max(1, max(2, 3)) +8 | max(1, max(2, max(3, 4))) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 +9 | max(1, foo("a", "b"), max(3, 4)) + | + = help: Flatten nested `max` calls + +ℹ Suggested fix +5 5 | min(1, max(2, 3)) +6 6 | max(1, 2, 3) +7 7 | max(1, max(2, 3)) +8 |-max(1, max(2, max(3, 4))) + 8 |+max(1, 2, 3, 4) +9 9 | max(1, foo("a", "b"), max(3, 4)) +10 10 | +11 11 | # These should not trigger; we do not flag cases with keyword args. + +nested_min_max.py:8:8: PLW3301 [*] Nested `max` calls can be flattened + | +6 | max(1, 2, 3) +7 | max(1, max(2, 3)) +8 | max(1, max(2, max(3, 4))) + | ^^^^^^^^^^^^^^^^^ PLW3301 +9 | max(1, foo("a", "b"), max(3, 4)) + | + = help: Flatten nested `max` calls + +ℹ Suggested fix +5 5 | min(1, max(2, 3)) +6 6 | max(1, 2, 3) +7 7 | max(1, max(2, 3)) +8 |-max(1, max(2, max(3, 4))) + 8 |+max(1, max(2, 3, 4)) +9 9 | max(1, foo("a", "b"), max(3, 4)) +10 10 | +11 11 | # These should not trigger; we do not flag cases with keyword args. + +nested_min_max.py:9:1: PLW3301 [*] Nested `max` calls can be flattened + | + 7 | max(1, max(2, 3)) + 8 | max(1, max(2, max(3, 4))) + 9 | max(1, foo("a", "b"), max(3, 4)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 +10 | +11 | # These should not trigger; we do not flag cases with keyword args. + | + = help: Flatten nested `max` calls + +ℹ Suggested fix +6 6 | max(1, 2, 3) +7 7 | max(1, max(2, 3)) +8 8 | max(1, max(2, max(3, 4))) +9 |-max(1, foo("a", "b"), max(3, 4)) + 9 |+max(1, foo("a", "b"), 3, 4) +10 10 | +11 11 | # These should not trigger; we do not flag cases with keyword args. +12 12 | min(1, min(2, 3), key=test) + +nested_min_max.py:15:1: PLW3301 [*] Nested `min` calls can be flattened + | +13 | min(1, min(2, 3, key=test)) +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 | +17 | # Don't provide a fix if there are comments within the call. + | + = help: Flatten nested `min` calls + +ℹ Suggested fix +12 12 | min(1, min(2, 3), key=test) +13 13 | min(1, min(2, 3, key=test)) +14 14 | # This will still trigger, to merge the calls without keyword args. +15 |-min(1, min(2, 3, key=test), min(4, 5)) + 15 |+min(1, min(2, 3, key=test), 4, 5) +16 16 | +17 17 | # Don't provide a fix if there are comments within the call. +18 18 | min( + +nested_min_max.py:18:1: PLW3301 Nested `min` calls can be flattened + | +17 | # Don't provide a fix if there are comments within the call. +18 | / min( +19 | | 1, # This is a comment. +20 | | min(2, 3), +21 | | ) + | |_^ PLW3301 +22 | +23 | # Handle iterable expressions. + | + = help: Flatten nested `min` calls + +nested_min_max.py:24:1: PLW3301 [*] Nested `min` calls can be flattened + | +23 | # Handle iterable expressions. +24 | min(1, min(a)) + | ^^^^^^^^^^^^^^ PLW3301 +25 | min(1, min(i for i in range(10))) +26 | max(1, max(a)) + | + = help: Flatten nested `min` calls + +ℹ Suggested fix +21 21 | ) +22 22 | +23 23 | # Handle iterable expressions. +24 |-min(1, min(a)) + 24 |+min(1, *a) +25 25 | min(1, min(i for i in range(10))) +26 26 | max(1, max(a)) +27 27 | max(1, max(i for i in range(10))) + +nested_min_max.py:25:1: PLW3301 [*] Nested `min` calls can be flattened + | +23 | # Handle iterable expressions. +24 | min(1, min(a)) +25 | min(1, min(i for i in range(10))) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 +26 | max(1, max(a)) +27 | max(1, max(i for i in range(10))) + | + = help: Flatten nested `min` calls + +ℹ Suggested fix +22 22 | +23 23 | # Handle iterable expressions. +24 24 | min(1, min(a)) +25 |-min(1, min(i for i in range(10))) + 25 |+min(1, *(i for i in range(10))) +26 26 | max(1, max(a)) +27 27 | max(1, max(i for i in range(10))) +28 28 | + +nested_min_max.py:26:1: PLW3301 [*] Nested `max` calls can be flattened + | +24 | min(1, min(a)) +25 | min(1, min(i for i in range(10))) +26 | max(1, max(a)) + | ^^^^^^^^^^^^^^ PLW3301 +27 | max(1, max(i for i in range(10))) + | + = help: Flatten nested `max` calls + +ℹ Suggested fix +23 23 | # Handle iterable expressions. +24 24 | min(1, min(a)) +25 25 | min(1, min(i for i in range(10))) +26 |-max(1, max(a)) + 26 |+max(1, *a) +27 27 | max(1, max(i for i in range(10))) +28 28 | +29 29 | tuples_list = [ + +nested_min_max.py:27:1: PLW3301 [*] Nested `max` calls can be flattened + | +25 | min(1, min(i for i in range(10))) +26 | max(1, max(a)) +27 | max(1, max(i for i in range(10))) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLW3301 +28 | +29 | tuples_list = [ + | + = help: Flatten nested `max` calls + +ℹ Suggested fix +24 24 | min(1, min(a)) +25 25 | min(1, min(i for i in range(10))) +26 26 | max(1, max(a)) +27 |-max(1, max(i for i in range(10))) + 27 |+max(1, *(i for i in range(10))) +28 28 | +29 29 | tuples_list = [ +30 30 | (1, 2), + +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 + | + = help: Flatten nested `max` calls + +ℹ Suggested fix +38 38 | max(max(tuples_list)) +39 39 | +40 40 | # Starred argument should be copied as it is. +41 |-max(1, max(*a)) + 41 |+max(1, *a) + + 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 new file mode 100644 index 0000000000..d810fbb1f5 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__allow_magic_value_types.snap @@ -0,0 +1,31 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +magic_value_comparison.py:59:22: PLR2004 Magic value used in comparison, consider replacing "Hunter2" with a constant variable + | +57 | pass +58 | +59 | if input_password == "Hunter2": # correct + | ^^^^^^^^^ PLR2004 +60 | pass + | + +magic_value_comparison.py:65:21: PLR2004 Magic value used in comparison, consider replacing 3.141592653589793 with a constant variable + | +63 | pi_estimation = 3.14 +64 | +65 | if pi_estimation == 3.141592653589793238: # [magic-value-comparison] + | ^^^^^^^^^^^^^^^^^^^^ PLR2004 +66 | pass + | + +magic_value_comparison.py:74:18: PLR2004 Magic value used in comparison, consider replacing b"something" with a constant variable + | +72 | user_input = b"Hello, There!" +73 | +74 | if user_input == b"something": # correct + | ^^^^^^^^^^^^ PLR2004 +75 | 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 new file mode 100644 index 0000000000..8b0ac4063f --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__continue_in_finally.snap @@ -0,0 +1,128 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +continue_in_finally.py:5:9: PLE0116 `continue` not supported inside `finally` clause + | +3 | pass +4 | finally: +5 | continue # [continue-in-finally] + | ^^^^^^^^ PLE0116 +6 | +7 | while True: + | + +continue_in_finally.py:16:13: PLE0116 `continue` not supported inside `finally` clause + | +14 | pass +15 | finally: +16 | continue # [continue-in-finally] + | ^^^^^^^^ PLE0116 +17 | pass + | + +continue_in_finally.py:26:17: PLE0116 `continue` not supported inside `finally` clause + | +24 | match test: +25 | case "aa": +26 | continue # [continue-in-finally] + | ^^^^^^^^ PLE0116 +27 | +28 | while True: + | + +continue_in_finally.py:33:13: PLE0116 `continue` not supported inside `finally` clause + | +31 | finally: +32 | with "aa" as f: +33 | continue # [continue-in-finally] + | ^^^^^^^^ PLE0116 +34 | +35 | while True: + | + +continue_in_finally.py:40:13: PLE0116 `continue` not supported inside `finally` clause + | +38 | finally: +39 | if True: +40 | continue # [continue-in-finally] + | ^^^^^^^^ PLE0116 +41 | continue # [continue-in-finally] + | + +continue_in_finally.py:41:9: PLE0116 `continue` not supported inside `finally` clause + | +39 | if True: +40 | continue # [continue-in-finally] +41 | continue # [continue-in-finally] + | ^^^^^^^^ PLE0116 +42 | +43 | def test(): + | + +continue_in_finally.py:49:17: PLE0116 `continue` not supported inside `finally` clause + | +47 | pass +48 | finally: +49 | continue # [continue-in-finally] + | ^^^^^^^^ PLE0116 + | + +continue_in_finally.py:56:9: PLE0116 `continue` not supported inside `finally` clause + | +54 | pass +55 | finally: +56 | continue # [continue-in-finally] + | ^^^^^^^^ PLE0116 +57 | +58 | def test(): + | + +continue_in_finally.py:69:9: PLE0116 `continue` not supported inside `finally` clause + | +67 | for i in range(12): +68 | continue +69 | continue # [continue-in-finally] + | ^^^^^^^^ PLE0116 +70 | +71 | while True: + | + +continue_in_finally.py:74:13: PLE0116 `continue` not supported inside `finally` clause + | +72 | pass +73 | else: +74 | continue # [continue-in-finally] + | ^^^^^^^^ PLE0116 +75 | +76 | def test(): + | + +continue_in_finally.py:89:13: PLE0116 `continue` not supported inside `finally` clause + | +87 | pass +88 | elif False: +89 | continue # [continue-in-finally] + | ^^^^^^^^ PLE0116 +90 | else: +91 | continue # [continue-in-finally] + | + +continue_in_finally.py:91:13: PLE0116 `continue` not supported inside `finally` clause + | +89 | continue # [continue-in-finally] +90 | else: +91 | continue # [continue-in-finally] + | ^^^^^^^^ PLE0116 +92 | for i in range(10): +93 | pass + | + +continue_in_finally.py:95:17: PLE0116 `continue` not supported inside `finally` clause + | +93 | pass +94 | else: +95 | continue # [continue-in-finally] + | ^^^^^^^^ PLE0116 + | + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_args.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_args.snap new file mode 100644 index 0000000000..48f493fdbb --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_args.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +too_many_arguments_params.py:3:5: PLR0913 Too many arguments to function call (6 > 4) + | +1 | # Too many args (6/4) for max_args=4 +2 | # OK for dummy_variable_rgx ~ "skip_.*" +3 | def f(x, y, z, skip_t, skip_u, skip_v): + | ^ PLR0913 +4 | pass + | + +too_many_arguments_params.py:9:5: PLR0913 Too many arguments to function call (6 > 4) + | + 7 | # Too many args (6/4) for max_args=4 + 8 | # Too many args (6/5) for dummy_variable_rgx ~ "skip_.*" + 9 | def f(x, y, z, t, u, v): + | ^ PLR0913 +10 | pass + | + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_args_with_dummy_variables.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_args_with_dummy_variables.snap new file mode 100644 index 0000000000..12a9a7fdcb --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_args_with_dummy_variables.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +too_many_arguments_params.py:9:5: PLR0913 Too many arguments to function call (6 > 5) + | + 7 | # Too many args (6/4) for max_args=4 + 8 | # Too many args (6/5) for dummy_variable_rgx ~ "skip_.*" + 9 | def f(x, y, z, t, u, v): + | ^ PLR0913 +10 | pass + | + + 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 new file mode 100644 index 0000000000..e35b9cad8e --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_branches.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +too_many_branches_params.py:6:5: PLR0912 Too many branches (2 > 1) + | +6 | def g(x): + | ^ PLR0912 +7 | if x: +8 | pass + | + +too_many_branches_params.py:15:9: PLR0912 Too many branches (2 > 1) + | +13 | return +14 | +15 | def i(x): + | ^ PLR0912 +16 | if x: +17 | pass + | + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_return_statements.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_return_statements.snap new file mode 100644 index 0000000000..974b8b8001 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_return_statements.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +too_many_return_statements_params.py:1:5: PLR0911 Too many return statements (2 > 1) + | +1 | def f(x): # Too many return statements (2/1) + | ^ PLR0911 +2 | if x == 1: +3 | return + | + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_statements.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_statements.snap new file mode 100644 index 0000000000..017e2b2b8b --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__max_statements.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +too_many_statements_params.py:6:5: PLR0915 Too many statements (2 > 1) + | +6 | def f(x): + | ^ PLR0915 +7 | def g(x): +8 | pass + | + + diff --git a/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__repeated_isinstance_calls.snap b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__repeated_isinstance_calls.snap new file mode 100644 index 0000000000..230e00c609 --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__repeated_isinstance_calls.snap @@ -0,0 +1,144 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +repeated_isinstance_calls.py:15:8: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[3], (float, int))` + | +14 | # not merged +15 | if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True: # [consider-merging-isinstance] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 +16 | pass +17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] + | + = help: Replace with `isinstance(var[3], (float, int))` + +ℹ Fix +12 12 | result = isinstance(var[2], (int, float)) +13 13 | +14 14 | # not merged +15 |- if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True: # [consider-merging-isinstance] + 15 |+ if isinstance(var[3], (float, int)): # [consider-merging-isinstance] +16 16 | pass +17 17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] +18 18 | + +repeated_isinstance_calls.py:17:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[4], (float, int))` + | +15 | if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True: # [consider-merging-isinstance] +16 | pass +17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 +18 | +19 | result = isinstance(var[5], int) or True or isinstance(var[5], float) # [consider-merging-isinstance] + | + = help: Replace with `isinstance(var[4], (float, int))` + +ℹ Fix +14 14 | # not merged +15 15 | if isinstance(var[3], int) or isinstance(var[3], float) or isinstance(var[3], list) and True: # [consider-merging-isinstance] +16 16 | pass +17 |- result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] + 17 |+ result = isinstance(var[4], (float, int)) # [consider-merging-isinstance] +18 18 | +19 19 | result = isinstance(var[5], int) or True or isinstance(var[5], float) # [consider-merging-isinstance] +20 20 | + +repeated_isinstance_calls.py:19:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[5], (float, int))` + | +17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] +18 | +19 | result = isinstance(var[5], int) or True or isinstance(var[5], float) # [consider-merging-isinstance] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 +20 | +21 | inferred_isinstance = isinstance + | + = help: Replace with `isinstance(var[5], (float, int))` + +ℹ Fix +16 16 | pass +17 17 | result = isinstance(var[4], int) or isinstance(var[4], float) or isinstance(var[5], list) and False # [consider-merging-isinstance] +18 18 | +19 |- result = isinstance(var[5], int) or True or isinstance(var[5], float) # [consider-merging-isinstance] + 19 |+ result = isinstance(var[5], (float, int)) # [consider-merging-isinstance] +20 20 | +21 21 | inferred_isinstance = isinstance +22 22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] + +repeated_isinstance_calls.py:23:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[10], (list, str))` + | +21 | inferred_isinstance = isinstance +22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] +23 | result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list) # [consider-merging-isinstance] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 +24 | result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float) # [consider-merging-isinstance] + | + = help: Replace with `isinstance(var[10], (list, str))` + +ℹ Fix +20 20 | +21 21 | inferred_isinstance = isinstance +22 22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] +23 |- result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list) # [consider-merging-isinstance] + 23 |+ result = isinstance(var[10], (list, str)) # [consider-merging-isinstance] +24 24 | result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float) # [consider-merging-isinstance] +25 25 | +26 26 | result = isinstance(var[20]) + +repeated_isinstance_calls.py:24:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[11], (float, int))` + | +22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] +23 | result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list) # [consider-merging-isinstance] +24 | result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float) # [consider-merging-isinstance] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 +25 | +26 | result = isinstance(var[20]) + | + = help: Replace with `isinstance(var[11], (float, int))` + +ℹ Fix +21 21 | inferred_isinstance = isinstance +22 22 | result = inferred_isinstance(var[6], int) or inferred_isinstance(var[6], float) or inferred_isinstance(var[6], list) and False # [consider-merging-isinstance] +23 23 | result = isinstance(var[10], str) or isinstance(var[10], int) and var[8] * 14 or isinstance(var[10], float) and var[5] * 14.4 or isinstance(var[10], list) # [consider-merging-isinstance] +24 |- result = isinstance(var[11], int) or isinstance(var[11], int) or isinstance(var[11], float) # [consider-merging-isinstance] + 24 |+ result = isinstance(var[11], (float, int)) # [consider-merging-isinstance] +25 25 | +26 26 | result = isinstance(var[20]) +27 27 | result = isinstance() + +repeated_isinstance_calls.py:30:14: PLR1701 [*] Merge `isinstance` calls: `isinstance(var[12], (float, int, list))` + | +29 | # Combination merged and not merged +30 | result = isinstance(var[12], (int, float)) or isinstance(var[12], list) # [consider-merging-isinstance] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 +31 | +32 | # not merged but valid + | + = help: Replace with `isinstance(var[12], (float, int, list))` + +ℹ Fix +27 27 | result = isinstance() +28 28 | +29 29 | # Combination merged and not merged +30 |- result = isinstance(var[12], (int, float)) or isinstance(var[12], list) # [consider-merging-isinstance] + 30 |+ result = isinstance(var[12], (float, int, list)) # [consider-merging-isinstance] +31 31 | +32 32 | # not merged but valid +33 33 | result = isinstance(var[5], int) and var[5] * 14 or isinstance(var[5], float) and var[5] * 14.4 + +repeated_isinstance_calls.py:42:3: PLR1701 [*] Merge `isinstance` calls: `isinstance(self.k, (float, int))` + | +41 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722460483 +42 | if(isinstance(self.k, int)) or (isinstance(self.k, float)): + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLR1701 +43 | ... + | + = help: Replace with `isinstance(self.k, (float, int))` + +ℹ Fix +39 39 | +40 40 | +41 41 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722460483 +42 |-if(isinstance(self.k, int)) or (isinstance(self.k, float)): + 42 |+if isinstance(self.k, (float, int)): +43 43 | ... + + 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 new file mode 100644 index 0000000000..f86c673e9b --- /dev/null +++ b/crates/ruff_linter/src/rules/pylint/snapshots/ruff_linter__rules__pylint__tests__too_many_public_methods.snap @@ -0,0 +1,46 @@ +--- +source: crates/ruff_linter/src/rules/pylint/mod.rs +--- +too_many_public_methods.py:1:1: PLR0904 Too many public methods (10 > 7) + | + 1 | / class Everything: + 2 | | foo = 1 + 3 | | + 4 | | def __init__(self): + 5 | | pass + 6 | | + 7 | | def _private(self): + 8 | | pass + 9 | | +10 | | def method1(self): +11 | | pass +12 | | +13 | | def method2(self): +14 | | pass +15 | | +16 | | def method3(self): +17 | | pass +18 | | +19 | | def method4(self): +20 | | pass +21 | | +22 | | def method5(self): +23 | | pass +24 | | +25 | | def method6(self): +26 | | pass +27 | | +28 | | def method7(self): +29 | | pass +30 | | +31 | | def method8(self): +32 | | pass +33 | | +34 | | def method9(self): +35 | | pass + | |____________^ PLR0904 +36 | +37 | class Small: + | + + diff --git a/crates/ruff/src/rules/pyupgrade/fixes.rs b/crates/ruff_linter/src/rules/pyupgrade/fixes.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/fixes.rs rename to crates/ruff_linter/src/rules/pyupgrade/fixes.rs diff --git a/crates/ruff/src/rules/pyupgrade/helpers.rs b/crates/ruff_linter/src/rules/pyupgrade/helpers.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/helpers.rs rename to crates/ruff_linter/src/rules/pyupgrade/helpers.rs diff --git a/crates/ruff/src/rules/pyupgrade/mod.rs b/crates/ruff_linter/src/rules/pyupgrade/mod.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/mod.rs rename to crates/ruff_linter/src/rules/pyupgrade/mod.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/datetime_utc_alias.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/datetime_utc_alias.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/datetime_utc_alias.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/datetime_utc_alias.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/deprecated_c_element_tree.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_c_element_tree.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/deprecated_c_element_tree.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_c_element_tree.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/deprecated_import.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_import.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/deprecated_import.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_import.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/deprecated_mock_import.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_mock_import.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/deprecated_mock_import.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_mock_import.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/deprecated_unittest_alias.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_unittest_alias.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/deprecated_unittest_alias.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_unittest_alias.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/extraneous_parentheses.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/extraneous_parentheses.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/extraneous_parentheses.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/extraneous_parentheses.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/f_strings.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/f_strings.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/f_strings.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/f_strings.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/format_literals.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/format_literals.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/format_literals.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/format_literals.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/lru_cache_with_maxsize_none.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/lru_cache_with_maxsize_none.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/lru_cache_with_maxsize_none.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/lru_cache_with_maxsize_none.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/lru_cache_without_parameters.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/lru_cache_without_parameters.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/lru_cache_without_parameters.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/lru_cache_without_parameters.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/mod.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/mod.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/mod.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/native_literals.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/native_literals.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/native_literals.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/native_literals.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/open_alias.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/open_alias.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/open_alias.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/open_alias.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/os_error_alias.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/os_error_alias.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/outdated_version_block.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/outdated_version_block.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/printf_string_formatting.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/printf_string_formatting.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/printf_string_formatting.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/printf_string_formatting.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/quoted_annotation.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/quoted_annotation.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/quoted_annotation.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/quoted_annotation.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/redundant_open_modes.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/redundant_open_modes.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/redundant_open_modes.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/redundant_open_modes.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/replace_stdout_stderr.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/replace_stdout_stderr.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/replace_stdout_stderr.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/replace_stdout_stderr.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/replace_universal_newlines.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/replace_universal_newlines.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/replace_universal_newlines.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/replace_universal_newlines.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/super_call_with_parameters.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/super_call_with_parameters.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/super_call_with_parameters.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/super_call_with_parameters.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/type_of_primitive.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/type_of_primitive.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/type_of_primitive.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/type_of_primitive.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/typing_text_str_alias.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/typing_text_str_alias.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/typing_text_str_alias.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/typing_text_str_alias.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/unicode_kind_prefix.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/unicode_kind_prefix.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/unicode_kind_prefix.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/unicode_kind_prefix.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/unnecessary_builtin_import.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_builtin_import.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/unnecessary_builtin_import.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_builtin_import.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/unnecessary_class_parentheses.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_class_parentheses.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/unnecessary_class_parentheses.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_class_parentheses.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/unnecessary_coding_comment.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_coding_comment.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/unnecessary_coding_comment.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_coding_comment.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/unnecessary_encode_utf8.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_encode_utf8.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/unnecessary_encode_utf8.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_encode_utf8.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/unnecessary_future_import.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_future_import.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/unnecessary_future_import.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_future_import.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/unpacked_list_comprehension.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/unpacked_list_comprehension.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/unpacked_list_comprehension.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/unpacked_list_comprehension.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/use_pep585_annotation.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep585_annotation.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/use_pep585_annotation.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/use_pep585_annotation.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/use_pep604_annotation.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/use_pep604_annotation.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/use_pep604_isinstance.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_isinstance.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/use_pep604_isinstance.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_isinstance.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/use_pep695_type_alias.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/use_pep695_type_alias.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/use_pep695_type_alias.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/use_pep695_type_alias.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/useless_metaclass_type.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/useless_metaclass_type.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/useless_metaclass_type.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/useless_metaclass_type.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/useless_object_inheritance.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/useless_object_inheritance.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/useless_object_inheritance.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/useless_object_inheritance.rs diff --git a/crates/ruff/src/rules/pyupgrade/rules/yield_in_for_loop.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/yield_in_for_loop.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/rules/yield_in_for_loop.rs rename to crates/ruff_linter/src/rules/pyupgrade/rules/yield_in_for_loop.rs diff --git a/crates/ruff/src/rules/pyupgrade/settings.rs b/crates/ruff_linter/src/rules/pyupgrade/settings.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/settings.rs rename to crates/ruff_linter/src/rules/pyupgrade/settings.rs 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 new file mode 100644 index 0000000000..f390514da7 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP001.py.snap @@ -0,0 +1,39 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP001.py:2:5: UP001 [*] `__metaclass__ = type` is implied + | +1 | class A: +2 | __metaclass__ = type + | ^^^^^^^^^^^^^^^^^^^^ UP001 + | + = help: Remove `metaclass = type` + +ℹ Fix +1 1 | class A: +2 |- __metaclass__ = type + 2 |+ pass +3 3 | +4 4 | +5 5 | class B: + +UP001.py:6:5: UP001 [*] `__metaclass__ = type` is implied + | +5 | class B: +6 | __metaclass__ = type + | ^^^^^^^^^^^^^^^^^^^^ UP001 +7 | +8 | def __init__(self) -> None: + | + = help: Remove `metaclass = type` + +ℹ Fix +3 3 | +4 4 | +5 5 | class B: +6 |- __metaclass__ = type +7 6 | +8 7 | def __init__(self) -> None: +9 8 | pass + + 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 new file mode 100644 index 0000000000..652e4edab8 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP003.py.snap @@ -0,0 +1,114 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP003.py:1:1: UP003 [*] Use `str` instead of `type(...)` + | +1 | type("") + | ^^^^^^^^ UP003 +2 | type(b"") +3 | type(0) + | + = help: Replace `type(...)` with `str` + +ℹ Fix +1 |-type("") + 1 |+str +2 2 | type(b"") +3 3 | type(0) +4 4 | type(0.0) + +UP003.py:2:1: UP003 [*] Use `bytes` instead of `type(...)` + | +1 | type("") +2 | type(b"") + | ^^^^^^^^^ UP003 +3 | type(0) +4 | type(0.0) + | + = help: Replace `type(...)` with `bytes` + +ℹ Fix +1 1 | type("") +2 |-type(b"") + 2 |+bytes +3 3 | type(0) +4 4 | type(0.0) +5 5 | type(0j) + +UP003.py:3:1: UP003 [*] Use `int` instead of `type(...)` + | +1 | type("") +2 | type(b"") +3 | type(0) + | ^^^^^^^ UP003 +4 | type(0.0) +5 | type(0j) + | + = help: Replace `type(...)` with `int` + +ℹ Fix +1 1 | type("") +2 2 | type(b"") +3 |-type(0) + 3 |+int +4 4 | type(0.0) +5 5 | type(0j) +6 6 | + +UP003.py:4:1: UP003 [*] Use `float` instead of `type(...)` + | +2 | type(b"") +3 | type(0) +4 | type(0.0) + | ^^^^^^^^^ UP003 +5 | type(0j) + | + = help: Replace `type(...)` with `float` + +ℹ Fix +1 1 | type("") +2 2 | type(b"") +3 3 | type(0) +4 |-type(0.0) + 4 |+float +5 5 | type(0j) +6 6 | +7 7 | # OK + +UP003.py:5:1: UP003 [*] Use `complex` instead of `type(...)` + | +3 | type(0) +4 | type(0.0) +5 | type(0j) + | ^^^^^^^^ UP003 +6 | +7 | # OK + | + = help: Replace `type(...)` with `complex` + +ℹ Fix +2 2 | type(b"") +3 3 | type(0) +4 4 | type(0.0) +5 |-type(0j) + 5 |+complex +6 6 | +7 7 | # OK +8 8 | type(arg)(" ") + +UP003.py:14:29: UP003 [*] Use `str` instead of `type(...)` + | +13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459841 +14 | assert isinstance(fullname, type("")is not True) + | ^^^^^^^^ UP003 + | + = help: Replace `type(...)` with `str` + +ℹ Fix +11 11 | y = x.dtype.type(0.0) +12 12 | +13 13 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459841 +14 |-assert isinstance(fullname, type("")is not True) + 14 |+assert isinstance(fullname, str is not True) + + 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 new file mode 100644 index 0000000000..65bd379d8b --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP004.py.snap @@ -0,0 +1,493 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP004.py:5:9: UP004 [*] Class `A` inherits from `object` + | +5 | class A(object): + | ^^^^^^ UP004 +6 | ... + | + = help: Remove `object` inheritance + +ℹ Fix +2 2 | ... +3 3 | +4 4 | +5 |-class A(object): + 5 |+class A: +6 6 | ... +7 7 | +8 8 | + +UP004.py:10:5: UP004 [*] Class `A` inherits from `object` + | + 9 | class A( +10 | object, + | ^^^^^^ UP004 +11 | ): +12 | ... + | + = help: Remove `object` inheritance + +ℹ Fix +6 6 | ... +7 7 | +8 8 | +9 |-class A( +10 |- object, +11 |-): + 9 |+class A: +12 10 | ... +13 11 | +14 12 | + +UP004.py:16:5: UP004 [*] Class `A` inherits from `object` + | +15 | class A( +16 | object, + | ^^^^^^ UP004 +17 | # +18 | ): + | + = help: Remove `object` inheritance + +ℹ Fix +12 12 | ... +13 13 | +14 14 | +15 |-class A( +16 |- object, +17 |- # +18 |-): + 15 |+class A: +19 16 | ... +20 17 | +21 18 | + +UP004.py:24:5: UP004 [*] Class `A` inherits from `object` + | +22 | class A( +23 | # +24 | object, + | ^^^^^^ UP004 +25 | ): +26 | ... + | + = help: Remove `object` inheritance + +ℹ Fix +19 19 | ... +20 20 | +21 21 | +22 |-class A( +23 |- # +24 |- object, +25 |-): + 22 |+class A: +26 23 | ... +27 24 | +28 25 | + +UP004.py:31:5: UP004 [*] Class `A` inherits from `object` + | +29 | class A( +30 | # +31 | object + | ^^^^^^ UP004 +32 | ): +33 | ... + | + = help: Remove `object` inheritance + +ℹ Fix +26 26 | ... +27 27 | +28 28 | +29 |-class A( +30 |- # +31 |- object +32 |-): + 29 |+class A: +33 30 | ... +34 31 | +35 32 | + +UP004.py:37:5: UP004 [*] Class `A` inherits from `object` + | +36 | class A( +37 | object + | ^^^^^^ UP004 +38 | # +39 | ): + | + = help: Remove `object` inheritance + +ℹ Fix +33 33 | ... +34 34 | +35 35 | +36 |-class A( +37 |- object +38 |- # +39 |-): + 36 |+class A: +40 37 | ... +41 38 | +42 39 | + +UP004.py:45:5: UP004 [*] Class `A` inherits from `object` + | +43 | class A( +44 | # +45 | object, + | ^^^^^^ UP004 +46 | # +47 | ): + | + = help: Remove `object` inheritance + +ℹ Fix +40 40 | ... +41 41 | +42 42 | +43 |-class A( +44 |- # +45 |- object, +46 |- # +47 |-): + 43 |+class A: +48 44 | ... +49 45 | +50 46 | + +UP004.py:53:5: UP004 [*] Class `A` inherits from `object` + | +51 | class A( +52 | # +53 | object, + | ^^^^^^ UP004 +54 | # +55 | ): + | + = help: Remove `object` inheritance + +ℹ Fix +48 48 | ... +49 49 | +50 50 | +51 |-class A( +52 |- # +53 |- object, +54 |- # +55 |-): + 51 |+class A: +56 52 | ... +57 53 | +58 54 | + +UP004.py:61:5: UP004 [*] Class `A` inherits from `object` + | +59 | class A( +60 | # +61 | object + | ^^^^^^ UP004 +62 | # +63 | ): + | + = help: Remove `object` inheritance + +ℹ Fix +56 56 | ... +57 57 | +58 58 | +59 |-class A( +60 |- # +61 |- object +62 |- # +63 |-): + 59 |+class A: +64 60 | ... +65 61 | +66 62 | + +UP004.py:69:5: UP004 [*] Class `A` inherits from `object` + | +67 | class A( +68 | # +69 | object + | ^^^^^^ UP004 +70 | # +71 | ): + | + = help: Remove `object` inheritance + +ℹ Fix +64 64 | ... +65 65 | +66 66 | +67 |-class A( +68 |- # +69 |- object +70 |- # +71 |-): + 67 |+class A: +72 68 | ... +73 69 | +74 70 | + +UP004.py:75:12: UP004 [*] Class `B` inherits from `object` + | +75 | class B(A, object): + | ^^^^^^ UP004 +76 | ... + | + = help: Remove `object` inheritance + +ℹ Fix +72 72 | ... +73 73 | +74 74 | +75 |-class B(A, object): + 75 |+class B(A): +76 76 | ... +77 77 | +78 78 | + +UP004.py:79:9: UP004 [*] Class `B` inherits from `object` + | +79 | class B(object, A): + | ^^^^^^ UP004 +80 | ... + | + = help: Remove `object` inheritance + +ℹ Fix +76 76 | ... +77 77 | +78 78 | +79 |-class B(object, A): + 79 |+class B(A): +80 80 | ... +81 81 | +82 82 | + +UP004.py:84:5: UP004 [*] Class `B` inherits from `object` + | +83 | class B( +84 | object, + | ^^^^^^ UP004 +85 | A, +86 | ): + | + = help: Remove `object` inheritance + +ℹ Fix +81 81 | +82 82 | +83 83 | class B( +84 |- object, +85 84 | A, +86 85 | ): +87 86 | ... + +UP004.py:92:5: UP004 [*] Class `B` inherits from `object` + | +90 | class B( +91 | A, +92 | object, + | ^^^^^^ UP004 +93 | ): +94 | ... + | + = help: Remove `object` inheritance + +ℹ Fix +89 89 | +90 90 | class B( +91 91 | A, +92 |- object, +93 92 | ): +94 93 | ... +95 94 | + +UP004.py:98:5: UP004 [*] Class `B` inherits from `object` + | + 97 | class B( + 98 | object, + | ^^^^^^ UP004 + 99 | # Comment on A. +100 | A, + | + = help: Remove `object` inheritance + +ℹ Fix +95 95 | +96 96 | +97 97 | class B( +98 |- object, +99 98 | # Comment on A. +100 99 | A, +101 100 | ): + +UP004.py:108:5: UP004 [*] Class `B` inherits from `object` + | +106 | # Comment on A. +107 | A, +108 | object, + | ^^^^^^ UP004 +109 | ): +110 | ... + | + = help: Remove `object` inheritance + +ℹ Fix +105 105 | class B( +106 106 | # Comment on A. +107 107 | A, +108 |- object, +109 108 | ): +110 109 | ... +111 110 | + +UP004.py:119:5: UP004 [*] Class `A` inherits from `object` + | +118 | class A( +119 | object, + | ^^^^^^ UP004 +120 | ): +121 | ... + | + = help: Remove `object` inheritance + +ℹ Fix +115 115 | ... +116 116 | +117 117 | +118 |-class A( +119 |- object, +120 |-): + 118 |+class A: +121 119 | ... +122 120 | +123 121 | + +UP004.py:125:5: UP004 [*] Class `A` inherits from `object` + | +124 | class A( +125 | object, # ) + | ^^^^^^ UP004 +126 | ): +127 | ... + | + = help: Remove `object` inheritance + +ℹ Fix +121 121 | ... +122 122 | +123 123 | +124 |-class A( +125 |- object, # ) +126 |-): + 124 |+class A: +127 125 | ... +128 126 | +129 127 | + +UP004.py:131:5: UP004 [*] Class `A` inherits from `object` + | +130 | class A( +131 | object # ) + | ^^^^^^ UP004 +132 | , +133 | ): + | + = help: Remove `object` inheritance + +ℹ Fix +127 127 | ... +128 128 | +129 129 | +130 |-class A( +131 |- object # ) +132 |- , +133 |-): + 130 |+class A: +134 131 | ... +135 132 | +136 133 | + +UP004.py:137:9: UP004 [*] Class `A` inherits from `object` + | +137 | class A(object, object): + | ^^^^^^ UP004 +138 | ... + | + = help: Remove `object` inheritance + +ℹ Fix +134 134 | ... +135 135 | +136 136 | +137 |-class A(object, object): + 137 |+class A(object): +138 138 | ... +139 139 | +140 140 | + +UP004.py:137:17: UP004 [*] Class `A` inherits from `object` + | +137 | class A(object, object): + | ^^^^^^ UP004 +138 | ... + | + = help: Remove `object` inheritance + +ℹ Fix +134 134 | ... +135 135 | +136 136 | +137 |-class A(object, object): + 137 |+class A(object): +138 138 | ... +139 139 | +140 140 | + +UP004.py:142:9: UP004 [*] Class `A` inherits from `object` + | +141 | @decorator() +142 | class A(object): + | ^^^^^^ UP004 +143 | ... + | + = help: Remove `object` inheritance + +ℹ Fix +139 139 | +140 140 | +141 141 | @decorator() +142 |-class A(object): + 142 |+class A: +143 143 | ... +144 144 | +145 145 | @decorator() # class A(object): + +UP004.py:146:9: UP004 [*] Class `A` inherits from `object` + | +145 | @decorator() # class A(object): +146 | class A(object): + | ^^^^^^ UP004 +147 | ... + | + = help: Remove `object` inheritance + +ℹ Fix +143 143 | ... +144 144 | +145 145 | @decorator() # class A(object): +146 |-class A(object): + 146 |+class A: +147 147 | ... +148 148 | +149 149 | + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP005.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP005.py.snap new file mode 100644 index 0000000000..eb262e3521 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP005.py.snap @@ -0,0 +1,80 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP005.py:6:9: UP005 [*] `assertEquals` is deprecated, use `assertEqual` + | +4 | class Suite(unittest.TestCase): +5 | def test(self) -> None: +6 | self.assertEquals (1, 2) + | ^^^^^^^^^^^^^^^^^ UP005 +7 | self.assertEquals(1, 2) +8 | self.assertEqual(3, 4) + | + = help: Replace `assertEqual` with `assertEquals` + +ℹ Suggested fix +3 3 | +4 4 | class Suite(unittest.TestCase): +5 5 | def test(self) -> None: +6 |- self.assertEquals (1, 2) + 6 |+ self.assertEqual (1, 2) +7 7 | self.assertEquals(1, 2) +8 8 | self.assertEqual(3, 4) +9 9 | self.failUnlessAlmostEqual(1, 1.1) + +UP005.py:7:9: UP005 [*] `assertEquals` is deprecated, use `assertEqual` + | +5 | def test(self) -> None: +6 | self.assertEquals (1, 2) +7 | self.assertEquals(1, 2) + | ^^^^^^^^^^^^^^^^^ UP005 +8 | self.assertEqual(3, 4) +9 | self.failUnlessAlmostEqual(1, 1.1) + | + = help: Replace `assertEqual` with `assertEquals` + +ℹ Suggested fix +4 4 | class Suite(unittest.TestCase): +5 5 | def test(self) -> None: +6 6 | self.assertEquals (1, 2) +7 |- self.assertEquals(1, 2) + 7 |+ self.assertEqual(1, 2) +8 8 | self.assertEqual(3, 4) +9 9 | self.failUnlessAlmostEqual(1, 1.1) +10 10 | self.assertNotRegexpMatches("a", "b") + +UP005.py:9:9: UP005 [*] `failUnlessAlmostEqual` is deprecated, use `assertAlmostEqual` + | + 7 | self.assertEquals(1, 2) + 8 | self.assertEqual(3, 4) + 9 | self.failUnlessAlmostEqual(1, 1.1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP005 +10 | self.assertNotRegexpMatches("a", "b") + | + = help: Replace `assertAlmostEqual` with `failUnlessAlmostEqual` + +ℹ Suggested fix +6 6 | self.assertEquals (1, 2) +7 7 | self.assertEquals(1, 2) +8 8 | self.assertEqual(3, 4) +9 |- self.failUnlessAlmostEqual(1, 1.1) + 9 |+ self.assertAlmostEqual(1, 1.1) +10 10 | self.assertNotRegexpMatches("a", "b") + +UP005.py:10:9: UP005 [*] `assertNotRegexpMatches` is deprecated, use `assertNotRegex` + | + 8 | self.assertEqual(3, 4) + 9 | self.failUnlessAlmostEqual(1, 1.1) +10 | self.assertNotRegexpMatches("a", "b") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP005 + | + = help: Replace `assertNotRegex` with `assertNotRegexpMatches` + +ℹ Suggested fix +7 7 | self.assertEquals(1, 2) +8 8 | self.assertEqual(3, 4) +9 9 | self.failUnlessAlmostEqual(1, 1.1) +10 |- self.assertNotRegexpMatches("a", "b") + 10 |+ self.assertNotRegex("a", "b") + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_0.py.snap new file mode 100644 index 0000000000..c102b6d608 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_0.py.snap @@ -0,0 +1,284 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP006_0.py:4:10: UP006 [*] Use `list` instead of `typing.List` for type annotation + | +4 | def f(x: typing.List[str]) -> None: + | ^^^^^^^^^^^ UP006 +5 | ... + | + = help: Replace with `list` + +ℹ Fix +1 1 | import typing +2 2 | +3 3 | +4 |-def f(x: typing.List[str]) -> None: + 4 |+def f(x: list[str]) -> None: +5 5 | ... +6 6 | +7 7 | + +UP006_0.py:11:10: UP006 [*] Use `list` instead of `List` for type annotation + | +11 | def f(x: List[str]) -> None: + | ^^^^ UP006 +12 | ... + | + = help: Replace with `list` + +ℹ Fix +8 8 | from typing import List +9 9 | +10 10 | +11 |-def f(x: List[str]) -> None: + 11 |+def f(x: list[str]) -> None: +12 12 | ... +13 13 | +14 14 | + +UP006_0.py:18:10: UP006 [*] Use `list` instead of `t.List` for type annotation + | +18 | def f(x: t.List[str]) -> None: + | ^^^^^^ UP006 +19 | ... + | + = help: Replace with `list` + +ℹ Fix +15 15 | import typing as t +16 16 | +17 17 | +18 |-def f(x: t.List[str]) -> None: + 18 |+def f(x: list[str]) -> None: +19 19 | ... +20 20 | +21 21 | + +UP006_0.py:25:10: UP006 [*] Use `list` instead of `IList` for type annotation + | +25 | def f(x: IList[str]) -> None: + | ^^^^^ UP006 +26 | ... + | + = help: Replace with `list` + +ℹ Fix +22 22 | from typing import List as IList +23 23 | +24 24 | +25 |-def f(x: IList[str]) -> None: + 25 |+def f(x: list[str]) -> None: +26 26 | ... +27 27 | +28 28 | + +UP006_0.py:29:11: UP006 [*] Use `list` instead of `List` for type annotation + | +29 | def f(x: "List[str]") -> None: + | ^^^^ UP006 +30 | ... + | + = help: Replace with `list` + +ℹ Fix +26 26 | ... +27 27 | +28 28 | +29 |-def f(x: "List[str]") -> None: + 29 |+def f(x: "list[str]") -> None: +30 30 | ... +31 31 | +32 32 | + +UP006_0.py:33:12: UP006 [*] Use `list` instead of `List` for type annotation + | +33 | def f(x: r"List[str]") -> None: + | ^^^^ UP006 +34 | ... + | + = help: Replace with `list` + +ℹ Fix +30 30 | ... +31 31 | +32 32 | +33 |-def f(x: r"List[str]") -> None: + 33 |+def f(x: r"list[str]") -> None: +34 34 | ... +35 35 | +36 36 | + +UP006_0.py:37:11: UP006 [*] Use `list` instead of `List` for type annotation + | +37 | def f(x: "List[str]") -> None: + | ^^^^ UP006 +38 | ... + | + = help: Replace with `list` + +ℹ Fix +34 34 | ... +35 35 | +36 36 | +37 |-def f(x: "List[str]") -> None: + 37 |+def f(x: "list[str]") -> None: +38 38 | ... +39 39 | +40 40 | + +UP006_0.py:41:13: UP006 [*] Use `list` instead of `List` for type annotation + | +41 | def f(x: """List[str]""") -> None: + | ^^^^ UP006 +42 | ... + | + = help: Replace with `list` + +ℹ Fix +38 38 | ... +39 39 | +40 40 | +41 |-def f(x: """List[str]""") -> None: + 41 |+def f(x: """list[str]""") -> None: +42 42 | ... +43 43 | +44 44 | + +UP006_0.py:45:10: UP006 Use `list` instead of `List` for type annotation + | +45 | def f(x: "Li" "st[str]") -> None: + | ^^^^^^^^^^^^^^ UP006 +46 | ... + | + = help: Replace with `list` + +UP006_0.py:49:11: UP006 [*] Use `list` instead of `List` for type annotation + | +49 | def f(x: "List['List[str]']") -> None: + | ^^^^ UP006 +50 | ... + | + = help: Replace with `list` + +ℹ Fix +46 46 | ... +47 47 | +48 48 | +49 |-def f(x: "List['List[str]']") -> None: + 49 |+def f(x: "list['List[str]']") -> None: +50 50 | ... +51 51 | +52 52 | + +UP006_0.py:49:17: UP006 [*] Use `list` instead of `List` for type annotation + | +49 | def f(x: "List['List[str]']") -> None: + | ^^^^ UP006 +50 | ... + | + = help: Replace with `list` + +ℹ Fix +46 46 | ... +47 47 | +48 48 | +49 |-def f(x: "List['List[str]']") -> None: + 49 |+def f(x: "List['list[str]']") -> None: +50 50 | ... +51 51 | +52 52 | + +UP006_0.py:53:11: UP006 [*] Use `list` instead of `List` for type annotation + | +53 | def f(x: "List['Li' 'st[str]']") -> None: + | ^^^^ UP006 +54 | ... + | + = help: Replace with `list` + +ℹ Fix +50 50 | ... +51 51 | +52 52 | +53 |-def f(x: "List['Li' 'st[str]']") -> None: + 53 |+def f(x: "list['Li' 'st[str]']") -> None: +54 54 | ... +55 55 | +56 56 | + +UP006_0.py:53:16: UP006 Use `list` instead of `List` for type annotation + | +53 | def f(x: "List['Li' 'st[str]']") -> None: + | ^^^^^^^^^^^^^^ UP006 +54 | ... + | + = help: Replace with `list` + +UP006_0.py:57:10: UP006 Use `list` instead of `List` for type annotation + | +57 | def f(x: "Li" "st['List[str]']") -> None: + | ^^^^^^^^^^^^^^^^^^^^^^ UP006 +58 | ... + | + = help: Replace with `list` + +UP006_0.py:57:10: UP006 Use `list` instead of `List` for type annotation + | +57 | def f(x: "Li" "st['List[str]']") -> None: + | ^^^^^^^^^^^^^^^^^^^^^^ UP006 +58 | ... + | + = help: Replace with `list` + +UP006_0.py:61:10: UP006 [*] Use `collections.deque` instead of `typing.Deque` for type annotation + | +61 | def f(x: typing.Deque[str]) -> None: + | ^^^^^^^^^^^^ UP006 +62 | ... + | + = help: Replace with `collections.deque` + +ℹ Suggested fix +20 20 | +21 21 | +22 22 | from typing import List as IList + 23 |+from collections import deque +23 24 | +24 25 | +25 26 | def f(x: IList[str]) -> None: +-------------------------------------------------------------------------------- +58 59 | ... +59 60 | +60 61 | +61 |-def f(x: typing.Deque[str]) -> None: + 62 |+def f(x: deque[str]) -> None: +62 63 | ... +63 64 | +64 65 | + +UP006_0.py:65:10: UP006 [*] Use `collections.defaultdict` instead of `typing.DefaultDict` for type annotation + | +65 | def f(x: typing.DefaultDict[str, str]) -> None: + | ^^^^^^^^^^^^^^^^^^ UP006 +66 | ... + | + = help: Replace with `collections.defaultdict` + +ℹ Suggested fix +20 20 | +21 21 | +22 22 | from typing import List as IList + 23 |+from collections import defaultdict +23 24 | +24 25 | +25 26 | def f(x: IList[str]) -> None: +-------------------------------------------------------------------------------- +62 63 | ... +63 64 | +64 65 | +65 |-def f(x: typing.DefaultDict[str, str]) -> None: + 66 |+def f(x: defaultdict[str, str]) -> None: +66 67 | ... + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_1.py.snap new file mode 100644 index 0000000000..1cf1741128 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_1.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP006_1.py:9:10: UP006 [*] Use `collections.defaultdict` instead of `typing.DefaultDict` for type annotation + | + 9 | def f(x: typing.DefaultDict[str, str]) -> None: + | ^^^^^^^^^^^^^^^^^^ UP006 +10 | ... + | + = help: Replace with `collections.defaultdict` + +ℹ Suggested fix +6 6 | from collections import defaultdict +7 7 | +8 8 | +9 |-def f(x: typing.DefaultDict[str, str]) -> None: + 9 |+def f(x: defaultdict[str, str]) -> None: +10 10 | ... + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_2.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_2.py.snap new file mode 100644 index 0000000000..a290ac1b56 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_2.py.snap @@ -0,0 +1,12 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP006_2.py:7:10: UP006 Use `collections.defaultdict` instead of `typing.DefaultDict` for type annotation + | +7 | def f(x: typing.DefaultDict[str, str]) -> None: + | ^^^^^^^^^^^^^^^^^^ UP006 +8 | ... + | + = help: Replace with `collections.defaultdict` + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_3.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_3.py.snap new file mode 100644 index 0000000000..58ea6c2c8a --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP006_3.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP006_3.py:7:11: UP006 [*] Use `collections.defaultdict` instead of `typing.DefaultDict` for type annotation + | +7 | def f(x: "typing.DefaultDict[str, str]") -> None: + | ^^^^^^^^^^^^^^^^^^ UP006 +8 | ... + | + = help: Replace with `collections.defaultdict` + +ℹ Suggested fix +4 4 | from collections import defaultdict +5 5 | +6 6 | +7 |-def f(x: "typing.DefaultDict[str, str]") -> None: + 7 |+def f(x: "defaultdict[str, str]") -> None: +8 8 | ... + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP007.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP007.py.snap new file mode 100644 index 0000000000..9f97cb0632 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP007.py.snap @@ -0,0 +1,417 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP007.py:6:10: UP007 [*] Use `X | Y` for type annotations + | +6 | def f(x: Optional[str]) -> None: + | ^^^^^^^^^^^^^ UP007 +7 | ... + | + = help: Convert to `X | Y` + +ℹ Suggested fix +3 3 | from typing import Union +4 4 | +5 5 | +6 |-def f(x: Optional[str]) -> None: + 6 |+def f(x: str | None) -> None: +7 7 | ... +8 8 | +9 9 | + +UP007.py:10:10: UP007 [*] Use `X | Y` for type annotations + | +10 | def f(x: typing.Optional[str]) -> None: + | ^^^^^^^^^^^^^^^^^^^^ UP007 +11 | ... + | + = help: Convert to `X | Y` + +ℹ Suggested fix +7 7 | ... +8 8 | +9 9 | +10 |-def f(x: typing.Optional[str]) -> None: + 10 |+def f(x: str | None) -> None: +11 11 | ... +12 12 | +13 13 | + +UP007.py:14:10: UP007 [*] Use `X | Y` for type annotations + | +14 | def f(x: Union[str, int, Union[float, bytes]]) -> None: + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP007 +15 | ... + | + = help: Convert to `X | Y` + +ℹ Suggested fix +11 11 | ... +12 12 | +13 13 | +14 |-def f(x: Union[str, int, Union[float, bytes]]) -> None: + 14 |+def f(x: str | (int | Union[float, bytes])) -> None: +15 15 | ... +16 16 | +17 17 | + +UP007.py:14:26: UP007 [*] Use `X | Y` for type annotations + | +14 | def f(x: Union[str, int, Union[float, bytes]]) -> None: + | ^^^^^^^^^^^^^^^^^^^ UP007 +15 | ... + | + = help: Convert to `X | Y` + +ℹ Suggested fix +11 11 | ... +12 12 | +13 13 | +14 |-def f(x: Union[str, int, Union[float, bytes]]) -> None: + 14 |+def f(x: Union[str, int, float | bytes]) -> None: +15 15 | ... +16 16 | +17 17 | + +UP007.py:18:10: UP007 [*] Use `X | Y` for type annotations + | +18 | def f(x: typing.Union[str, int]) -> None: + | ^^^^^^^^^^^^^^^^^^^^^^ UP007 +19 | ... + | + = help: Convert to `X | Y` + +ℹ Suggested fix +15 15 | ... +16 16 | +17 17 | +18 |-def f(x: typing.Union[str, int]) -> None: + 18 |+def f(x: str | int) -> None: +19 19 | ... +20 20 | +21 21 | + +UP007.py:22:10: UP007 [*] Use `X | Y` for type annotations + | +22 | def f(x: typing.Union[(str, int)]) -> None: + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP007 +23 | ... + | + = help: Convert to `X | Y` + +ℹ Suggested fix +19 19 | ... +20 20 | +21 21 | +22 |-def f(x: typing.Union[(str, int)]) -> None: + 22 |+def f(x: str | int) -> None: +23 23 | ... +24 24 | +25 25 | + +UP007.py:26:10: UP007 [*] Use `X | Y` for type annotations + | +26 | def f(x: typing.Union[(str, int), float]) -> None: + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP007 +27 | ... + | + = help: Convert to `X | Y` + +ℹ Suggested fix +23 23 | ... +24 24 | +25 25 | +26 |-def f(x: typing.Union[(str, int), float]) -> None: + 26 |+def f(x: str | int | float) -> None: +27 27 | ... +28 28 | +29 29 | + +UP007.py:30:10: UP007 [*] Use `X | Y` for type annotations + | +30 | def f(x: typing.Union[(int,)]) -> None: + | ^^^^^^^^^^^^^^^^^^^^ UP007 +31 | ... + | + = help: Convert to `X | Y` + +ℹ Suggested fix +27 27 | ... +28 28 | +29 29 | +30 |-def f(x: typing.Union[(int,)]) -> None: + 30 |+def f(x: int) -> None: +31 31 | ... +32 32 | +33 33 | + +UP007.py:34:10: UP007 [*] Use `X | Y` for type annotations + | +34 | def f(x: typing.Union[()]) -> None: + | ^^^^^^^^^^^^^^^^ UP007 +35 | ... + | + = help: Convert to `X | Y` + +ℹ Suggested fix +31 31 | ... +32 32 | +33 33 | +34 |-def f(x: typing.Union[()]) -> None: + 34 |+def f(x: ()) -> None: +35 35 | ... +36 36 | +37 37 | + +UP007.py:38:11: UP007 [*] Use `X | Y` for type annotations + | +38 | def f(x: "Union[str, int, Union[float, bytes]]") -> None: + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP007 +39 | ... + | + = help: Convert to `X | Y` + +ℹ Suggested fix +35 35 | ... +36 36 | +37 37 | +38 |-def f(x: "Union[str, int, Union[float, bytes]]") -> None: + 38 |+def f(x: "str | (int | Union[float, bytes])") -> None: +39 39 | ... +40 40 | +41 41 | + +UP007.py:38:27: UP007 [*] Use `X | Y` for type annotations + | +38 | def f(x: "Union[str, int, Union[float, bytes]]") -> None: + | ^^^^^^^^^^^^^^^^^^^ UP007 +39 | ... + | + = help: Convert to `X | Y` + +ℹ Suggested fix +35 35 | ... +36 36 | +37 37 | +38 |-def f(x: "Union[str, int, Union[float, bytes]]") -> None: + 38 |+def f(x: "Union[str, int, float | bytes]") -> None: +39 39 | ... +40 40 | +41 41 | + +UP007.py:42:11: UP007 [*] Use `X | Y` for type annotations + | +42 | def f(x: "typing.Union[str, int]") -> None: + | ^^^^^^^^^^^^^^^^^^^^^^ UP007 +43 | ... + | + = help: Convert to `X | Y` + +ℹ Suggested fix +39 39 | ... +40 40 | +41 41 | +42 |-def f(x: "typing.Union[str, int]") -> None: + 42 |+def f(x: "str | int") -> None: +43 43 | ... +44 44 | +45 45 | + +UP007.py:55:8: UP007 [*] Use `X | Y` for type annotations + | +54 | def f() -> None: +55 | x: Optional[str] + | ^^^^^^^^^^^^^ UP007 +56 | x = Optional[str] + | + = help: Convert to `X | Y` + +ℹ Suggested fix +52 52 | +53 53 | +54 54 | def f() -> None: +55 |- x: Optional[str] + 55 |+ x: str | None +56 56 | x = Optional[str] +57 57 | +58 58 | x = Union[str, int] + +UP007.py:56:9: UP007 Use `X | Y` for type annotations + | +54 | def f() -> None: +55 | x: Optional[str] +56 | x = Optional[str] + | ^^^^^^^^^^^^^ UP007 +57 | +58 | x = Union[str, int] + | + = help: Convert to `X | Y` + +UP007.py:58:9: UP007 Use `X | Y` for type annotations + | +56 | x = Optional[str] +57 | +58 | x = Union[str, int] + | ^^^^^^^^^^^^^^^ UP007 +59 | x = Union["str", "int"] +60 | x: Union[str, int] + | + = help: Convert to `X | Y` + +UP007.py:60:8: UP007 [*] Use `X | Y` for type annotations + | +58 | x = Union[str, int] +59 | x = Union["str", "int"] +60 | x: Union[str, int] + | ^^^^^^^^^^^^^^^ UP007 +61 | x: Union["str", "int"] + | + = help: Convert to `X | Y` + +ℹ Suggested fix +57 57 | +58 58 | x = Union[str, int] +59 59 | x = Union["str", "int"] +60 |- x: Union[str, int] + 60 |+ x: str | int +61 61 | x: Union["str", "int"] +62 62 | +63 63 | + +UP007.py:61:8: UP007 [*] Use `X | Y` for type annotations + | +59 | x = Union["str", "int"] +60 | x: Union[str, int] +61 | x: Union["str", "int"] + | ^^^^^^^^^^^^^^^^^^^ UP007 + | + = help: Convert to `X | Y` + +ℹ Suggested fix +58 58 | x = Union[str, int] +59 59 | x = Union["str", "int"] +60 60 | x: Union[str, int] +61 |- x: Union["str", "int"] + 61 |+ x: "str" | "int" +62 62 | +63 63 | +64 64 | def f(x: Union[int : float]) -> None: + +UP007.py:64:10: UP007 Use `X | Y` for type annotations + | +64 | def f(x: Union[int : float]) -> None: + | ^^^^^^^^^^^^^^^^^^ UP007 +65 | ... + | + = help: Convert to `X | Y` + +UP007.py:68:10: UP007 Use `X | Y` for type annotations + | +68 | def f(x: Union[str, int : float]) -> None: + | ^^^^^^^^^^^^^^^^^^^^^^^ UP007 +69 | ... + | + = help: Convert to `X | Y` + +UP007.py:72:10: UP007 Use `X | Y` for type annotations + | +72 | def f(x: Union[x := int]) -> None: + | ^^^^^^^^^^^^^^^ UP007 +73 | ... + | + = help: Convert to `X | Y` + +UP007.py:76:10: UP007 Use `X | Y` for type annotations + | +76 | def f(x: Union[str, x := int]) -> None: + | ^^^^^^^^^^^^^^^^^^^^ UP007 +77 | ... + | + = help: Convert to `X | Y` + +UP007.py:80:10: UP007 Use `X | Y` for type annotations + | +80 | def f(x: Union[lambda: int]) -> None: + | ^^^^^^^^^^^^^^^^^^ UP007 +81 | ... + | + = help: Convert to `X | Y` + +UP007.py:84:10: UP007 Use `X | Y` for type annotations + | +84 | def f(x: Union[str, lambda: int]) -> None: + | ^^^^^^^^^^^^^^^^^^^^^^^ UP007 +85 | ... + | + = help: Convert to `X | Y` + +UP007.py:88:10: UP007 Use `X | Y` for type annotations + | +88 | def f(x: Optional[int : float]) -> None: + | ^^^^^^^^^^^^^^^^^^^^^ UP007 +89 | ... + | + = help: Convert to `X | Y` + +UP007.py:92:10: UP007 Use `X | Y` for type annotations + | +92 | def f(x: Optional[str, int : float]) -> None: + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP007 +93 | ... + | + = help: Convert to `X | Y` + +UP007.py:96:10: UP007 Use `X | Y` for type annotations + | +96 | def f(x: Optional[int, float]) -> None: + | ^^^^^^^^^^^^^^^^^^^^ UP007 +97 | ... + | + = help: Convert to `X | Y` + +UP007.py:102:28: UP007 [*] Use `X | Y` for type annotations + | +100 | # Regression test for: https://github.com/astral-sh/ruff/issues/7131 +101 | class ServiceRefOrValue: +102 | service_specification: Optional[ + | ____________________________^ +103 | | list[ServiceSpecificationRef] +104 | | | list[ServiceSpecification] +105 | | ] = None + | |_____^ UP007 + | + = help: Convert to `X | Y` + +ℹ Suggested fix +99 99 | +100 100 | # Regression test for: https://github.com/astral-sh/ruff/issues/7131 +101 101 | class ServiceRefOrValue: +102 |- service_specification: Optional[ +103 |- list[ServiceSpecificationRef] +104 |- | list[ServiceSpecification] +105 |- ] = None + 102 |+ service_specification: list[ServiceSpecificationRef] | list[ServiceSpecification] | None = None +106 103 | +107 104 | +108 105 | # Regression test for: https://github.com/astral-sh/ruff/issues/7201 + +UP007.py:110:28: UP007 [*] Use `X | Y` for type annotations + | +108 | # Regression test for: https://github.com/astral-sh/ruff/issues/7201 +109 | class ServiceRefOrValue: +110 | service_specification: Optional[str]is not True = None + | ^^^^^^^^^^^^^ UP007 + | + = help: Convert to `X | Y` + +ℹ Suggested fix +107 107 | +108 108 | # Regression test for: https://github.com/astral-sh/ruff/issues/7201 +109 109 | class ServiceRefOrValue: +110 |- service_specification: Optional[str]is not True = None + 110 |+ service_specification: str | None is not True = None +111 111 | +112 112 | +113 113 | # Regression test for: https://github.com/astral-sh/ruff/issues/7452 + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP008.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP008.py.snap new file mode 100644 index 0000000000..0ff5607820 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP008.py.snap @@ -0,0 +1,110 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP008.py:17:23: UP008 [*] Use `super()` instead of `super(__class__, self)` + | +16 | def wrong(self): +17 | parent = super(Child, self) # wrong + | ^^^^^^^^^^^^^ UP008 +18 | super(Child, self).method # wrong +19 | super( + | + = help: Remove `super` parameters + +ℹ Suggested fix +14 14 | Parent.super(1, 2) # ok +15 15 | +16 16 | def wrong(self): +17 |- parent = super(Child, self) # wrong + 17 |+ parent = super() # wrong +18 18 | super(Child, self).method # wrong +19 19 | super( +20 20 | Child, + +UP008.py:18:14: UP008 [*] Use `super()` instead of `super(__class__, self)` + | +16 | def wrong(self): +17 | parent = super(Child, self) # wrong +18 | super(Child, self).method # wrong + | ^^^^^^^^^^^^^ UP008 +19 | super( +20 | Child, + | + = help: Remove `super` parameters + +ℹ Suggested fix +15 15 | +16 16 | def wrong(self): +17 17 | parent = super(Child, self) # wrong +18 |- super(Child, self).method # wrong + 18 |+ super().method # wrong +19 19 | super( +20 20 | Child, +21 21 | self, + +UP008.py:19:14: UP008 [*] Use `super()` instead of `super(__class__, self)` + | +17 | parent = super(Child, self) # wrong +18 | super(Child, self).method # wrong +19 | super( + | ______________^ +20 | | Child, +21 | | self, +22 | | ).method() # wrong + | |_________^ UP008 + | + = help: Remove `super` parameters + +ℹ Suggested fix +16 16 | def wrong(self): +17 17 | parent = super(Child, self) # wrong +18 18 | super(Child, self).method # wrong +19 |- super( +20 |- Child, +21 |- self, +22 |- ).method() # wrong + 19 |+ super().method() # wrong +23 20 | +24 21 | +25 22 | class BaseClass: + +UP008.py:36:14: UP008 [*] Use `super()` instead of `super(__class__, self)` + | +34 | class MyClass(BaseClass): +35 | def normal(self): +36 | super(MyClass, self).f() # can use super() + | ^^^^^^^^^^^^^^^ UP008 +37 | super().f() + | + = help: Remove `super` parameters + +ℹ Suggested fix +33 33 | +34 34 | class MyClass(BaseClass): +35 35 | def normal(self): +36 |- super(MyClass, self).f() # can use super() + 36 |+ super().f() # can use super() +37 37 | super().f() +38 38 | +39 39 | def different_argument(self, other): + +UP008.py:50:18: UP008 [*] Use `super()` instead of `super(__class__, self)` + | +49 | def inner_argument(self): +50 | super(MyClass, self).f() # can use super() + | ^^^^^^^^^^^^^^^ UP008 +51 | super().f() + | + = help: Remove `super` parameters + +ℹ Suggested fix +47 47 | super(MyClass, self).f() # CANNOT use super() +48 48 | +49 49 | def inner_argument(self): +50 |- super(MyClass, self).f() # can use super() + 50 |+ super().f() # can use super() +51 51 | super().f() +52 52 | +53 53 | outer_argument() + + 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 new file mode 100644 index 0000000000..4111b57965 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_0.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP009_0.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary + | +1 | # coding=utf8 + | ^^^^^^^^^^^^^ UP009 +2 | +3 | print("Hello world") + | + = help: Remove unnecessary coding comment + +ℹ Fix +1 |-# coding=utf8 +2 1 | +3 2 | print("Hello world") + + 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 new file mode 100644 index 0000000000..322ccb1070 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_1.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP009_1.py:2:1: UP009 [*] UTF-8 encoding declaration is unnecessary + | +1 | #!/usr/bin/python +2 | # -*- coding: utf-8 -*- + | ^^^^^^^^^^^^^^^^^^^^^^^ UP009 +3 | +4 | print('Hello world') + | + = help: Remove unnecessary coding comment + +ℹ Fix +1 1 | #!/usr/bin/python +2 |-# -*- coding: utf-8 -*- +3 2 | +4 3 | print('Hello world') + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_10.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_10.py.snap new file mode 100644 index 0000000000..2bacb5d540 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_10.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_2.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_2.py.snap new file mode 100644 index 0000000000..2bacb5d540 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_2.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_3.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_3.py.snap new file mode 100644 index 0000000000..2bacb5d540 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_3.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_4.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_4.py.snap new file mode 100644 index 0000000000..2bacb5d540 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_4.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_5.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_5.py.snap new file mode 100644 index 0000000000..2bacb5d540 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_5.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_6.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_6.py.snap new file mode 100644 index 0000000000..5901c6eb38 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_6.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP009_6.py:1:2: UP009 [*] UTF-8 encoding declaration is unnecessary + | +1 | # coding=utf8 + | ^^^^^^^^^^^^^ UP009 +2 | print("Hello world") + | + = help: Remove unnecessary coding comment + +ℹ Fix +1 |- # coding=utf8 +2 1 | print("Hello world") +3 2 | +4 3 | """ + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_7.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_7.py.snap new file mode 100644 index 0000000000..990598993f --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_7.py.snap @@ -0,0 +1,18 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP009_7.py:1:2: UP009 [*] UTF-8 encoding declaration is unnecessary + | +1 | # coding=utf8 + | ^^^^^^^^^^^^^ UP009 +2 | print("Hello world") + | + = help: Remove unnecessary coding comment + +ℹ Fix +1 |- # coding=utf8 +2 1 | print("Hello world") +3 2 | +4 3 | """ + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_8.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_8.py.snap new file mode 100644 index 0000000000..2bacb5d540 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_8.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_9.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_9.py.snap new file mode 100644 index 0000000000..2bacb5d540 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP009_9.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- + 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 new file mode 100644 index 0000000000..e6ec10b650 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP010.py.snap @@ -0,0 +1,185 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP010.py:1:1: UP010 [*] Unnecessary `__future__` imports `generators`, `nested_scopes` for target Python version + | +1 | from __future__ import nested_scopes, generators + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 +2 | from __future__ import with_statement, unicode_literals +3 | from __future__ import absolute_import, division + | + = help: Remove unnecessary `future` import + +ℹ Suggested fix +1 |-from __future__ import nested_scopes, generators +2 1 | from __future__ import with_statement, unicode_literals +3 2 | from __future__ import absolute_import, division +4 3 | from __future__ import generator_stop + +UP010.py:2:1: UP010 [*] Unnecessary `__future__` imports `unicode_literals`, `with_statement` for target Python version + | +1 | from __future__ import nested_scopes, generators +2 | from __future__ import with_statement, unicode_literals + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 +3 | from __future__ import absolute_import, division +4 | from __future__ import generator_stop + | + = help: Remove unnecessary `future` import + +ℹ Suggested fix +1 1 | from __future__ import nested_scopes, generators +2 |-from __future__ import with_statement, unicode_literals +3 2 | from __future__ import absolute_import, division +4 3 | from __future__ import generator_stop +5 4 | from __future__ import print_function, generator_stop + +UP010.py:3:1: UP010 [*] Unnecessary `__future__` imports `absolute_import`, `division` for target Python version + | +1 | from __future__ import nested_scopes, generators +2 | from __future__ import with_statement, unicode_literals +3 | from __future__ import absolute_import, division + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 +4 | from __future__ import generator_stop +5 | from __future__ import print_function, generator_stop + | + = help: Remove unnecessary `future` import + +ℹ Suggested fix +1 1 | from __future__ import nested_scopes, generators +2 2 | from __future__ import with_statement, unicode_literals +3 |-from __future__ import absolute_import, division +4 3 | from __future__ import generator_stop +5 4 | from __future__ import print_function, generator_stop +6 5 | from __future__ import invalid_module, generators + +UP010.py:4:1: UP010 [*] Unnecessary `__future__` import `generator_stop` for target Python version + | +2 | from __future__ import with_statement, unicode_literals +3 | from __future__ import absolute_import, division +4 | from __future__ import generator_stop + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 +5 | from __future__ import print_function, generator_stop +6 | from __future__ import invalid_module, generators + | + = help: Remove unnecessary `future` import + +ℹ Suggested fix +1 1 | from __future__ import nested_scopes, generators +2 2 | from __future__ import with_statement, unicode_literals +3 3 | from __future__ import absolute_import, division +4 |-from __future__ import generator_stop +5 4 | from __future__ import print_function, generator_stop +6 5 | from __future__ import invalid_module, generators +7 6 | + +UP010.py:5:1: UP010 [*] Unnecessary `__future__` imports `generator_stop`, `print_function` for target Python version + | +3 | from __future__ import absolute_import, division +4 | from __future__ import generator_stop +5 | from __future__ import print_function, generator_stop + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 +6 | from __future__ import invalid_module, generators + | + = help: Remove unnecessary `future` import + +ℹ Suggested fix +2 2 | from __future__ import with_statement, unicode_literals +3 3 | from __future__ import absolute_import, division +4 4 | from __future__ import generator_stop +5 |-from __future__ import print_function, generator_stop +6 5 | from __future__ import invalid_module, generators +7 6 | +8 7 | if True: + +UP010.py:6:1: UP010 [*] Unnecessary `__future__` import `generators` for target Python version + | +4 | from __future__ import generator_stop +5 | from __future__ import print_function, generator_stop +6 | from __future__ import invalid_module, generators + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 +7 | +8 | if True: + | + = help: Remove unnecessary `future` import + +ℹ Suggested fix +3 3 | from __future__ import absolute_import, division +4 4 | from __future__ import generator_stop +5 5 | from __future__ import print_function, generator_stop +6 |-from __future__ import invalid_module, generators + 6 |+from __future__ import invalid_module +7 7 | +8 8 | if True: +9 9 | from __future__ import generator_stop + +UP010.py:9:5: UP010 [*] Unnecessary `__future__` import `generator_stop` for target Python version + | + 8 | if True: + 9 | from __future__ import generator_stop + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 +10 | from __future__ import generators + | + = help: Remove unnecessary `future` import + +ℹ Suggested fix +6 6 | from __future__ import invalid_module, generators +7 7 | +8 8 | if True: +9 |- from __future__ import generator_stop +10 9 | from __future__ import generators +11 10 | +12 11 | if True: + +UP010.py:10:5: UP010 [*] Unnecessary `__future__` import `generators` for target Python version + | + 8 | if True: + 9 | from __future__ import generator_stop +10 | from __future__ import generators + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 +11 | +12 | if True: + | + = help: Remove unnecessary `future` import + +ℹ Suggested fix +7 7 | +8 8 | if True: +9 9 | from __future__ import generator_stop +10 |- from __future__ import generators +11 10 | +12 11 | if True: +13 12 | from __future__ import generator_stop + +UP010.py:13:5: UP010 [*] Unnecessary `__future__` import `generator_stop` for target Python version + | +12 | if True: +13 | from __future__ import generator_stop + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 +14 | from __future__ import invalid_module, generators + | + = help: Remove unnecessary `future` import + +ℹ Suggested fix +10 10 | from __future__ import generators +11 11 | +12 12 | if True: +13 |- from __future__ import generator_stop +14 13 | from __future__ import invalid_module, generators + +UP010.py:14:5: UP010 [*] Unnecessary `__future__` import `generators` for target Python version + | +12 | if True: +13 | from __future__ import generator_stop +14 | from __future__ import invalid_module, generators + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP010 + | + = help: Remove unnecessary `future` import + +ℹ Suggested fix +11 11 | +12 12 | if True: +13 13 | from __future__ import generator_stop +14 |- from __future__ import invalid_module, generators + 14 |+ from __future__ import invalid_module + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP011.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP011.py.snap new file mode 100644 index 0000000000..74e6ac8fba --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP011.py.snap @@ -0,0 +1,81 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP011.py:5:21: UP011 [*] Unnecessary parentheses to `functools.lru_cache` + | +5 | @functools.lru_cache() + | ^^ UP011 +6 | def fixme(): +7 | pass + | + = help: Remove unnecessary parentheses + +ℹ Fix +2 2 | from functools import lru_cache +3 3 | +4 4 | +5 |-@functools.lru_cache() + 5 |+@functools.lru_cache +6 6 | def fixme(): +7 7 | pass +8 8 | + +UP011.py:10:11: UP011 [*] Unnecessary parentheses to `functools.lru_cache` + | +10 | @lru_cache() + | ^^ UP011 +11 | def fixme(): +12 | pass + | + = help: Remove unnecessary parentheses + +ℹ Fix +7 7 | pass +8 8 | +9 9 | +10 |-@lru_cache() + 10 |+@lru_cache +11 11 | def fixme(): +12 12 | pass +13 13 | + +UP011.py:16:21: UP011 [*] Unnecessary parentheses to `functools.lru_cache` + | +15 | @other_decorator +16 | @functools.lru_cache() + | ^^ UP011 +17 | def fixme(): +18 | pass + | + = help: Remove unnecessary parentheses + +ℹ Fix +13 13 | +14 14 | +15 15 | @other_decorator +16 |-@functools.lru_cache() + 16 |+@functools.lru_cache +17 17 | def fixme(): +18 18 | pass +19 19 | + +UP011.py:21:21: UP011 [*] Unnecessary parentheses to `functools.lru_cache` + | +21 | @functools.lru_cache() + | ^^ UP011 +22 | @other_decorator +23 | def fixme(): + | + = help: Remove unnecessary parentheses + +ℹ Fix +18 18 | pass +19 19 | +20 20 | +21 |-@functools.lru_cache() + 21 |+@functools.lru_cache +22 22 | @other_decorator +23 23 | def fixme(): +24 24 | pass + + 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 new file mode 100644 index 0000000000..bf81c1e7b3 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP012.py.snap @@ -0,0 +1,570 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP012.py:2:1: UP012 [*] Unnecessary call to `encode` as UTF-8 + | +1 | # ASCII literals should be replaced by a bytes literal +2 | "foo".encode("utf-8") # b"foo" + | ^^^^^^^^^^^^^^^^^^^^^ UP012 +3 | "foo".encode("u8") # b"foo" +4 | "foo".encode() # b"foo" + | + = help: Rewrite as bytes literal + +ℹ Fix +1 1 | # ASCII literals should be replaced by a bytes literal +2 |-"foo".encode("utf-8") # b"foo" + 2 |+b"foo" # b"foo" +3 3 | "foo".encode("u8") # b"foo" +4 4 | "foo".encode() # b"foo" +5 5 | "foo".encode("UTF8") # b"foo" + +UP012.py:3:1: UP012 [*] Unnecessary call to `encode` as UTF-8 + | +1 | # ASCII literals should be replaced by a bytes literal +2 | "foo".encode("utf-8") # b"foo" +3 | "foo".encode("u8") # b"foo" + | ^^^^^^^^^^^^^^^^^^ UP012 +4 | "foo".encode() # b"foo" +5 | "foo".encode("UTF8") # b"foo" + | + = help: Rewrite as bytes literal + +ℹ Fix +1 1 | # ASCII literals should be replaced by a bytes literal +2 2 | "foo".encode("utf-8") # b"foo" +3 |-"foo".encode("u8") # b"foo" + 3 |+b"foo" # b"foo" +4 4 | "foo".encode() # b"foo" +5 5 | "foo".encode("UTF8") # b"foo" +6 6 | U"foo".encode("utf-8") # b"foo" + +UP012.py:4:1: UP012 [*] Unnecessary call to `encode` as UTF-8 + | +2 | "foo".encode("utf-8") # b"foo" +3 | "foo".encode("u8") # b"foo" +4 | "foo".encode() # b"foo" + | ^^^^^^^^^^^^^^ UP012 +5 | "foo".encode("UTF8") # b"foo" +6 | U"foo".encode("utf-8") # b"foo" + | + = help: Rewrite as bytes literal + +ℹ Fix +1 1 | # ASCII literals should be replaced by a bytes literal +2 2 | "foo".encode("utf-8") # b"foo" +3 3 | "foo".encode("u8") # b"foo" +4 |-"foo".encode() # b"foo" + 4 |+b"foo" # b"foo" +5 5 | "foo".encode("UTF8") # b"foo" +6 6 | U"foo".encode("utf-8") # b"foo" +7 7 | "foo".encode(encoding="utf-8") # b"foo" + +UP012.py:5:1: UP012 [*] Unnecessary call to `encode` as UTF-8 + | +3 | "foo".encode("u8") # b"foo" +4 | "foo".encode() # b"foo" +5 | "foo".encode("UTF8") # b"foo" + | ^^^^^^^^^^^^^^^^^^^^ UP012 +6 | U"foo".encode("utf-8") # b"foo" +7 | "foo".encode(encoding="utf-8") # b"foo" + | + = help: Rewrite as bytes literal + +ℹ Fix +2 2 | "foo".encode("utf-8") # b"foo" +3 3 | "foo".encode("u8") # b"foo" +4 4 | "foo".encode() # b"foo" +5 |-"foo".encode("UTF8") # b"foo" + 5 |+b"foo" # b"foo" +6 6 | U"foo".encode("utf-8") # b"foo" +7 7 | "foo".encode(encoding="utf-8") # b"foo" +8 8 | """ + +UP012.py:6:1: UP012 [*] Unnecessary call to `encode` as UTF-8 + | +4 | "foo".encode() # b"foo" +5 | "foo".encode("UTF8") # b"foo" +6 | U"foo".encode("utf-8") # b"foo" + | ^^^^^^^^^^^^^^^^^^^^^^ UP012 +7 | "foo".encode(encoding="utf-8") # b"foo" +8 | """ + | + = help: Rewrite as bytes literal + +ℹ Fix +3 3 | "foo".encode("u8") # b"foo" +4 4 | "foo".encode() # b"foo" +5 5 | "foo".encode("UTF8") # b"foo" +6 |-U"foo".encode("utf-8") # b"foo" + 6 |+b"foo" # b"foo" +7 7 | "foo".encode(encoding="utf-8") # b"foo" +8 8 | """ +9 9 | Lorem + +UP012.py:7:1: UP012 [*] Unnecessary call to `encode` as UTF-8 + | +5 | "foo".encode("UTF8") # b"foo" +6 | U"foo".encode("utf-8") # b"foo" +7 | "foo".encode(encoding="utf-8") # b"foo" + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 +8 | """ +9 | Lorem + | + = help: Rewrite as bytes literal + +ℹ Fix +4 4 | "foo".encode() # b"foo" +5 5 | "foo".encode("UTF8") # b"foo" +6 6 | U"foo".encode("utf-8") # b"foo" +7 |-"foo".encode(encoding="utf-8") # b"foo" + 7 |+b"foo" # b"foo" +8 8 | """ +9 9 | Lorem +10 10 | + +UP012.py:8:1: UP012 [*] Unnecessary call to `encode` as UTF-8 + | + 6 | U"foo".encode("utf-8") # b"foo" + 7 | "foo".encode(encoding="utf-8") # b"foo" + 8 | / """ + 9 | | Lorem +10 | | +11 | | Ipsum +12 | | """.encode( +13 | | "utf-8" +14 | | ) + | |_^ UP012 +15 | ( +16 | "Lorem " + | + = help: Rewrite as bytes literal + +ℹ Fix +5 5 | "foo".encode("UTF8") # b"foo" +6 6 | U"foo".encode("utf-8") # b"foo" +7 7 | "foo".encode(encoding="utf-8") # b"foo" +8 |-""" + 8 |+b""" +9 9 | Lorem +10 10 | +11 11 | Ipsum +12 |-""".encode( +13 |- "utf-8" +14 |-) + 12 |+""" +15 13 | ( +16 14 | "Lorem " +17 15 | "Ipsum".encode() + +UP012.py:16:5: UP012 [*] Unnecessary call to `encode` as UTF-8 + | +14 | ) +15 | ( +16 | "Lorem " + | _____^ +17 | | "Ipsum".encode() + | |____________________^ UP012 +18 | ) +19 | ( + | + = help: Rewrite as bytes literal + +ℹ Fix +13 13 | "utf-8" +14 14 | ) +15 15 | ( +16 |- "Lorem " +17 |- "Ipsum".encode() + 16 |+ b"Lorem " + 17 |+ b"Ipsum" +18 18 | ) +19 19 | ( +20 20 | "Lorem " # Comment + +UP012.py:20:5: UP012 [*] Unnecessary call to `encode` as UTF-8 + | +18 | ) +19 | ( +20 | "Lorem " # Comment + | _____^ +21 | | "Ipsum".encode() # Comment + | |____________________^ UP012 +22 | ) +23 | ( + | + = help: Rewrite as bytes literal + +ℹ Fix +17 17 | "Ipsum".encode() +18 18 | ) +19 19 | ( +20 |- "Lorem " # Comment +21 |- "Ipsum".encode() # Comment + 20 |+ b"Lorem " # Comment + 21 |+ b"Ipsum" # Comment +22 22 | ) +23 23 | ( +24 24 | "Lorem " "Ipsum".encode() + +UP012.py:24:5: UP012 [*] Unnecessary call to `encode` as UTF-8 + | +22 | ) +23 | ( +24 | "Lorem " "Ipsum".encode() + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 +25 | ) + | + = help: Rewrite as bytes literal + +ℹ Fix +21 21 | "Ipsum".encode() # Comment +22 22 | ) +23 23 | ( +24 |- "Lorem " "Ipsum".encode() + 24 |+ b"Lorem " b"Ipsum" +25 25 | ) +26 26 | +27 27 | # `encode` on variables should not be processed. + +UP012.py:32:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` + | +31 | bar = "bar" +32 | f"foo{bar}".encode("utf-8") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 +33 | encoding = "latin" +34 | "foo".encode(encoding) + | + = help: Remove unnecessary `encoding` argument + +ℹ Fix +29 29 | string.encode("utf-8") +30 30 | +31 31 | bar = "bar" +32 |-f"foo{bar}".encode("utf-8") + 32 |+f"foo{bar}".encode() +33 33 | encoding = "latin" +34 34 | "foo".encode(encoding) +35 35 | f"foo{bar}".encode(encoding) + +UP012.py:36:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` + | +34 | "foo".encode(encoding) +35 | f"foo{bar}".encode(encoding) +36 | / f"{a=} {b=}".encode( +37 | | "utf-8", +38 | | ) + | |_^ UP012 +39 | +40 | # `encode` with custom args and kwargs should not be processed. + | + = help: Remove unnecessary `encoding` argument + +ℹ Fix +33 33 | encoding = "latin" +34 34 | "foo".encode(encoding) +35 35 | f"foo{bar}".encode(encoding) +36 |-f"{a=} {b=}".encode( +37 |- "utf-8", +38 |-) + 36 |+f"{a=} {b=}".encode() +39 37 | +40 38 | # `encode` with custom args and kwargs should not be processed. +41 39 | "foo".encode("utf-8", errors="replace") + +UP012.py:53:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` + | +52 | # Unicode literals should only be stripped of default encoding. +53 | "unicode text©".encode("utf-8") # "unicode text©".encode() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 +54 | "unicode text©".encode() +55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() + | + = help: Remove unnecessary `encoding` argument + +ℹ Fix +50 50 | "unicode text©".encode(encoding="utf-8", errors="replace") +51 51 | +52 52 | # Unicode literals should only be stripped of default encoding. +53 |-"unicode text©".encode("utf-8") # "unicode text©".encode() + 53 |+"unicode text©".encode() # "unicode text©".encode() +54 54 | "unicode text©".encode() +55 55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() +56 56 | + +UP012.py:55:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` + | +53 | "unicode text©".encode("utf-8") # "unicode text©".encode() +54 | "unicode text©".encode() +55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 +56 | +57 | r"foo\o".encode("utf-8") # br"foo\o" + | + = help: Remove unnecessary `encoding` argument + +ℹ Fix +52 52 | # Unicode literals should only be stripped of default encoding. +53 53 | "unicode text©".encode("utf-8") # "unicode text©".encode() +54 54 | "unicode text©".encode() +55 |-"unicode text©".encode(encoding="UTF8") # "unicode text©".encode() + 55 |+"unicode text©".encode() # "unicode text©".encode() +56 56 | +57 57 | r"foo\o".encode("utf-8") # br"foo\o" +58 58 | u"foo".encode("utf-8") # b"foo" + +UP012.py:57:1: UP012 [*] Unnecessary call to `encode` as UTF-8 + | +55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() +56 | +57 | r"foo\o".encode("utf-8") # br"foo\o" + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP012 +58 | u"foo".encode("utf-8") # b"foo" +59 | R"foo\o".encode("utf-8") # br"foo\o" + | + = help: Rewrite as bytes literal + +ℹ Fix +54 54 | "unicode text©".encode() +55 55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() +56 56 | +57 |-r"foo\o".encode("utf-8") # br"foo\o" + 57 |+br"foo\o" # br"foo\o" +58 58 | u"foo".encode("utf-8") # b"foo" +59 59 | R"foo\o".encode("utf-8") # br"foo\o" +60 60 | U"foo".encode("utf-8") # b"foo" + +UP012.py:58:1: UP012 [*] Unnecessary call to `encode` as UTF-8 + | +57 | r"foo\o".encode("utf-8") # br"foo\o" +58 | u"foo".encode("utf-8") # b"foo" + | ^^^^^^^^^^^^^^^^^^^^^^ UP012 +59 | R"foo\o".encode("utf-8") # br"foo\o" +60 | U"foo".encode("utf-8") # b"foo" + | + = help: Rewrite as bytes literal + +ℹ Fix +55 55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode() +56 56 | +57 57 | r"foo\o".encode("utf-8") # br"foo\o" +58 |-u"foo".encode("utf-8") # b"foo" + 58 |+b"foo" # b"foo" +59 59 | R"foo\o".encode("utf-8") # br"foo\o" +60 60 | U"foo".encode("utf-8") # b"foo" +61 61 | print("foo".encode()) # print(b"foo") + +UP012.py:59:1: UP012 [*] Unnecessary call to `encode` as UTF-8 + | +57 | r"foo\o".encode("utf-8") # br"foo\o" +58 | u"foo".encode("utf-8") # b"foo" +59 | R"foo\o".encode("utf-8") # br"foo\o" + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP012 +60 | U"foo".encode("utf-8") # b"foo" +61 | print("foo".encode()) # print(b"foo") + | + = help: Rewrite as bytes literal + +ℹ Fix +56 56 | +57 57 | r"foo\o".encode("utf-8") # br"foo\o" +58 58 | u"foo".encode("utf-8") # b"foo" +59 |-R"foo\o".encode("utf-8") # br"foo\o" + 59 |+bR"foo\o" # br"foo\o" +60 60 | U"foo".encode("utf-8") # b"foo" +61 61 | print("foo".encode()) # print(b"foo") +62 62 | + +UP012.py:60:1: UP012 [*] Unnecessary call to `encode` as UTF-8 + | +58 | u"foo".encode("utf-8") # b"foo" +59 | R"foo\o".encode("utf-8") # br"foo\o" +60 | U"foo".encode("utf-8") # b"foo" + | ^^^^^^^^^^^^^^^^^^^^^^ UP012 +61 | print("foo".encode()) # print(b"foo") + | + = help: Rewrite as bytes literal + +ℹ Fix +57 57 | r"foo\o".encode("utf-8") # br"foo\o" +58 58 | u"foo".encode("utf-8") # b"foo" +59 59 | R"foo\o".encode("utf-8") # br"foo\o" +60 |-U"foo".encode("utf-8") # b"foo" + 60 |+b"foo" # b"foo" +61 61 | print("foo".encode()) # print(b"foo") +62 62 | +63 63 | # `encode` on parenthesized strings. + +UP012.py:61:7: UP012 [*] Unnecessary call to `encode` as UTF-8 + | +59 | R"foo\o".encode("utf-8") # br"foo\o" +60 | U"foo".encode("utf-8") # b"foo" +61 | print("foo".encode()) # print(b"foo") + | ^^^^^^^^^^^^^^ UP012 +62 | +63 | # `encode` on parenthesized strings. + | + = help: Rewrite as bytes literal + +ℹ Fix +58 58 | u"foo".encode("utf-8") # b"foo" +59 59 | R"foo\o".encode("utf-8") # br"foo\o" +60 60 | U"foo".encode("utf-8") # b"foo" +61 |-print("foo".encode()) # print(b"foo") + 61 |+print(b"foo") # print(b"foo") +62 62 | +63 63 | # `encode` on parenthesized strings. +64 64 | ( + +UP012.py:64:1: UP012 [*] Unnecessary call to `encode` as UTF-8 + | +63 | # `encode` on parenthesized strings. +64 | / ( +65 | | "abc" +66 | | "def" +67 | | ).encode() + | |__________^ UP012 +68 | +69 | (( + | + = help: Rewrite as bytes literal + +ℹ Fix +62 62 | +63 63 | # `encode` on parenthesized strings. +64 64 | ( +65 |- "abc" +66 |- "def" +67 |-).encode() + 65 |+ b"abc" + 66 |+ b"def" + 67 |+) +68 68 | +69 69 | (( +70 70 | "abc" + +UP012.py:69:1: UP012 [*] Unnecessary call to `encode` as UTF-8 + | +67 | ).encode() +68 | +69 | / (( +70 | | "abc" +71 | | "def" +72 | | )).encode() + | |___________^ UP012 +73 | +74 | (f"foo{bar}").encode("utf-8") + | + = help: Rewrite as bytes literal + +ℹ Fix +67 67 | ).encode() +68 68 | +69 69 | (( +70 |- "abc" +71 |- "def" +72 |-)).encode() + 70 |+ b"abc" + 71 |+ b"def" + 72 |+)) +73 73 | +74 74 | (f"foo{bar}").encode("utf-8") +75 75 | (f"foo{bar}").encode(encoding="utf-8") + +UP012.py:74:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` + | +72 | )).encode() +73 | +74 | (f"foo{bar}").encode("utf-8") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 +75 | (f"foo{bar}").encode(encoding="utf-8") +76 | ("unicode text©").encode("utf-8") + | + = help: Remove unnecessary `encoding` argument + +ℹ Fix +71 71 | "def" +72 72 | )).encode() +73 73 | +74 |-(f"foo{bar}").encode("utf-8") + 74 |+(f"foo{bar}").encode() +75 75 | (f"foo{bar}").encode(encoding="utf-8") +76 76 | ("unicode text©").encode("utf-8") +77 77 | ("unicode text©").encode(encoding="utf-8") + +UP012.py:75:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` + | +74 | (f"foo{bar}").encode("utf-8") +75 | (f"foo{bar}").encode(encoding="utf-8") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 +76 | ("unicode text©").encode("utf-8") +77 | ("unicode text©").encode(encoding="utf-8") + | + = help: Remove unnecessary `encoding` argument + +ℹ Fix +72 72 | )).encode() +73 73 | +74 74 | (f"foo{bar}").encode("utf-8") +75 |-(f"foo{bar}").encode(encoding="utf-8") + 75 |+(f"foo{bar}").encode() +76 76 | ("unicode text©").encode("utf-8") +77 77 | ("unicode text©").encode(encoding="utf-8") +78 78 | + +UP012.py:76:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` + | +74 | (f"foo{bar}").encode("utf-8") +75 | (f"foo{bar}").encode(encoding="utf-8") +76 | ("unicode text©").encode("utf-8") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 +77 | ("unicode text©").encode(encoding="utf-8") + | + = help: Remove unnecessary `encoding` argument + +ℹ Fix +73 73 | +74 74 | (f"foo{bar}").encode("utf-8") +75 75 | (f"foo{bar}").encode(encoding="utf-8") +76 |-("unicode text©").encode("utf-8") + 76 |+("unicode text©").encode() +77 77 | ("unicode text©").encode(encoding="utf-8") +78 78 | +79 79 | + +UP012.py:77:1: UP012 [*] Unnecessary UTF-8 `encoding` argument to `encode` + | +75 | (f"foo{bar}").encode(encoding="utf-8") +76 | ("unicode text©").encode("utf-8") +77 | ("unicode text©").encode(encoding="utf-8") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP012 + | + = help: Remove unnecessary `encoding` argument + +ℹ Fix +74 74 | (f"foo{bar}").encode("utf-8") +75 75 | (f"foo{bar}").encode(encoding="utf-8") +76 76 | ("unicode text©").encode("utf-8") +77 |-("unicode text©").encode(encoding="utf-8") + 77 |+("unicode text©").encode() +78 78 | +79 79 | +80 80 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459882 + +UP012.py:82:17: UP012 [*] Unnecessary call to `encode` as UTF-8 + | +80 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459882 +81 | def _match_ignore(line): +82 | input=stdin and'\n'.encode()or None + | ^^^^^^^^^^^^^ UP012 + | + = help: Rewrite as bytes literal + +ℹ Fix +79 79 | +80 80 | # Regression test for: https://github.com/astral-sh/ruff/issues/7455#issuecomment-1722459882 +81 81 | def _match_ignore(line): +82 |- input=stdin and'\n'.encode()or None + 82 |+ input=stdin and b'\n' or None + + 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 new file mode 100644 index 0000000000..7f6103fcdb --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP013.py.snap @@ -0,0 +1,255 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP013.py:5:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + | +4 | # dict literal +5 | MyType = TypedDict("MyType", {"a": int, "b": str}) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 +6 | +7 | # dict call + | + = help: Convert `MyType` to class syntax + +ℹ Suggested fix +2 2 | import typing +3 3 | +4 4 | # dict literal +5 |-MyType = TypedDict("MyType", {"a": int, "b": str}) + 5 |+class MyType(TypedDict): + 6 |+ a: int + 7 |+ b: str +6 8 | +7 9 | # dict call +8 10 | MyType = TypedDict("MyType", dict(a=int, b=str)) + +UP013.py:8:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + | + 7 | # dict call + 8 | MyType = TypedDict("MyType", dict(a=int, b=str)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 + 9 | +10 | # kwargs + | + = help: Convert `MyType` to class syntax + +ℹ Suggested fix +5 5 | MyType = TypedDict("MyType", {"a": int, "b": str}) +6 6 | +7 7 | # dict call +8 |-MyType = TypedDict("MyType", dict(a=int, b=str)) + 8 |+class MyType(TypedDict): + 9 |+ a: int + 10 |+ b: str +9 11 | +10 12 | # kwargs +11 13 | MyType = TypedDict("MyType", a=int, b=str) + +UP013.py:11:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + | +10 | # kwargs +11 | MyType = TypedDict("MyType", a=int, b=str) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 +12 | +13 | # Empty TypedDict + | + = help: Convert `MyType` to class syntax + +ℹ Suggested fix +8 8 | MyType = TypedDict("MyType", dict(a=int, b=str)) +9 9 | +10 10 | # kwargs +11 |-MyType = TypedDict("MyType", a=int, b=str) + 11 |+class MyType(TypedDict): + 12 |+ a: int + 13 |+ b: str +12 14 | +13 15 | # Empty TypedDict +14 16 | MyType = TypedDict("MyType") + +UP013.py:14:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + | +13 | # Empty TypedDict +14 | MyType = TypedDict("MyType") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 +15 | +16 | # Literal values + | + = help: Convert `MyType` to class syntax + +ℹ Suggested fix +11 11 | MyType = TypedDict("MyType", a=int, b=str) +12 12 | +13 13 | # Empty TypedDict +14 |-MyType = TypedDict("MyType") + 14 |+class MyType(TypedDict): + 15 |+ pass +15 16 | +16 17 | # Literal values +17 18 | MyType = TypedDict("MyType", {"a": "hello"}) + +UP013.py:17:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + | +16 | # Literal values +17 | MyType = TypedDict("MyType", {"a": "hello"}) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 +18 | MyType = TypedDict("MyType", a="hello") + | + = help: Convert `MyType` to class syntax + +ℹ Suggested fix +14 14 | MyType = TypedDict("MyType") +15 15 | +16 16 | # Literal values +17 |-MyType = TypedDict("MyType", {"a": "hello"}) + 17 |+class MyType(TypedDict): + 18 |+ a: "hello" +18 19 | MyType = TypedDict("MyType", a="hello") +19 20 | +20 21 | # NotRequired + +UP013.py:18:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + | +16 | # Literal values +17 | MyType = TypedDict("MyType", {"a": "hello"}) +18 | MyType = TypedDict("MyType", a="hello") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 +19 | +20 | # NotRequired + | + = help: Convert `MyType` to class syntax + +ℹ Suggested fix +15 15 | +16 16 | # Literal values +17 17 | MyType = TypedDict("MyType", {"a": "hello"}) +18 |-MyType = TypedDict("MyType", a="hello") + 18 |+class MyType(TypedDict): + 19 |+ a: "hello" +19 20 | +20 21 | # NotRequired +21 22 | MyType = TypedDict("MyType", {"a": NotRequired[dict]}) + +UP013.py:21:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + | +20 | # NotRequired +21 | MyType = TypedDict("MyType", {"a": NotRequired[dict]}) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 +22 | +23 | # total + | + = help: Convert `MyType` to class syntax + +ℹ Suggested fix +18 18 | MyType = TypedDict("MyType", a="hello") +19 19 | +20 20 | # NotRequired +21 |-MyType = TypedDict("MyType", {"a": NotRequired[dict]}) + 21 |+class MyType(TypedDict): + 22 |+ a: NotRequired[dict] +22 23 | +23 24 | # total +24 25 | MyType = TypedDict("MyType", {"x": int, "y": int}, total=False) + +UP013.py:24:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + | +23 | # total +24 | MyType = TypedDict("MyType", {"x": int, "y": int}, total=False) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 +25 | +26 | # using Literal type + | + = help: Convert `MyType` to class syntax + +ℹ Suggested fix +21 21 | MyType = TypedDict("MyType", {"a": NotRequired[dict]}) +22 22 | +23 23 | # total +24 |-MyType = TypedDict("MyType", {"x": int, "y": int}, total=False) + 24 |+class MyType(TypedDict, total=False): + 25 |+ x: int + 26 |+ y: int +25 27 | +26 28 | # using Literal type +27 29 | MyType = TypedDict("MyType", {"key": Literal["value"]}) + +UP013.py:27:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + | +26 | # using Literal type +27 | MyType = TypedDict("MyType", {"key": Literal["value"]}) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 +28 | +29 | # using namespace TypedDict + | + = help: Convert `MyType` to class syntax + +ℹ Suggested fix +24 24 | MyType = TypedDict("MyType", {"x": int, "y": int}, total=False) +25 25 | +26 26 | # using Literal type +27 |-MyType = TypedDict("MyType", {"key": Literal["value"]}) + 27 |+class MyType(TypedDict): + 28 |+ key: Literal["value"] +28 29 | +29 30 | # using namespace TypedDict +30 31 | MyType = typing.TypedDict("MyType", {"key": int}) + +UP013.py:30:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + | +29 | # using namespace TypedDict +30 | MyType = typing.TypedDict("MyType", {"key": int}) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 +31 | +32 | # invalid identifiers (OK) + | + = help: Convert `MyType` to class syntax + +ℹ Suggested fix +27 27 | MyType = TypedDict("MyType", {"key": Literal["value"]}) +28 28 | +29 29 | # using namespace TypedDict +30 |-MyType = typing.TypedDict("MyType", {"key": int}) + 30 |+class MyType(typing.TypedDict): + 31 |+ key: int +31 32 | +32 33 | # invalid identifiers (OK) +33 34 | MyType = TypedDict("MyType", {"in": int, "x-y": int}) + +UP013.py:40:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + | +39 | # Empty dict literal +40 | MyType = TypedDict("MyType", {}) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 +41 | +42 | # Empty dict call + | + = help: Convert `MyType` to class syntax + +ℹ Suggested fix +37 37 | MyType = TypedDict("MyType", {"a": int, "b": str, **c}) +38 38 | +39 39 | # Empty dict literal +40 |-MyType = TypedDict("MyType", {}) + 40 |+class MyType(TypedDict): + 41 |+ pass +41 42 | +42 43 | # Empty dict call +43 44 | MyType = TypedDict("MyType", dict()) + +UP013.py:43:1: UP013 [*] Convert `MyType` from `TypedDict` functional to class syntax + | +42 | # Empty dict call +43 | MyType = TypedDict("MyType", dict()) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP013 + | + = help: Convert `MyType` to class syntax + +ℹ Suggested fix +40 40 | MyType = TypedDict("MyType", {}) +41 41 | +42 42 | # Empty dict call +43 |-MyType = TypedDict("MyType", dict()) + 43 |+class MyType(TypedDict): + 44 |+ pass + + 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 new file mode 100644 index 0000000000..f7e9dd895e --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP014.py.snap @@ -0,0 +1,112 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP014.py:5:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax + | +4 | # with complex annotations +5 | MyType = NamedTuple("MyType", [("a", int), ("b", tuple[str, ...])]) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 +6 | +7 | # with namespace + | + = help: Convert `MyType` to class syntax + +ℹ Suggested fix +2 2 | import typing +3 3 | +4 4 | # with complex annotations +5 |-MyType = NamedTuple("MyType", [("a", int), ("b", tuple[str, ...])]) + 5 |+class MyType(NamedTuple): + 6 |+ a: int + 7 |+ b: tuple[str, ...] +6 8 | +7 9 | # with namespace +8 10 | MyType = typing.NamedTuple("MyType", [("a", int), ("b", str)]) + +UP014.py:8:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax + | + 7 | # with namespace + 8 | MyType = typing.NamedTuple("MyType", [("a", int), ("b", str)]) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 + 9 | +10 | # invalid identifiers (OK) + | + = help: Convert `MyType` to class syntax + +ℹ Suggested fix +5 5 | MyType = NamedTuple("MyType", [("a", int), ("b", tuple[str, ...])]) +6 6 | +7 7 | # with namespace +8 |-MyType = typing.NamedTuple("MyType", [("a", int), ("b", str)]) + 8 |+class MyType(typing.NamedTuple): + 9 |+ a: int + 10 |+ b: str +9 11 | +10 12 | # invalid identifiers (OK) +11 13 | MyType = NamedTuple("MyType", [("x-y", int), ("b", tuple[str, ...])]) + +UP014.py:14:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax + | +13 | # no fields +14 | MyType = typing.NamedTuple("MyType") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 +15 | +16 | # empty fields + | + = help: Convert `MyType` to class syntax + +ℹ Suggested fix +11 11 | MyType = NamedTuple("MyType", [("x-y", int), ("b", tuple[str, ...])]) +12 12 | +13 13 | # no fields +14 |-MyType = typing.NamedTuple("MyType") + 14 |+class MyType(typing.NamedTuple): + 15 |+ pass +15 16 | +16 17 | # empty fields +17 18 | MyType = typing.NamedTuple("MyType", []) + +UP014.py:17:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax + | +16 | # empty fields +17 | MyType = typing.NamedTuple("MyType", []) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 +18 | +19 | # keywords + | + = help: Convert `MyType` to class syntax + +ℹ Suggested fix +14 14 | MyType = typing.NamedTuple("MyType") +15 15 | +16 16 | # empty fields +17 |-MyType = typing.NamedTuple("MyType", []) + 17 |+class MyType(typing.NamedTuple): + 18 |+ pass +18 19 | +19 20 | # keywords +20 21 | MyType = typing.NamedTuple("MyType", a=int, b=tuple[str, ...]) + +UP014.py:20:1: UP014 [*] Convert `MyType` from `NamedTuple` functional to class syntax + | +19 | # keywords +20 | MyType = typing.NamedTuple("MyType", a=int, b=tuple[str, ...]) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP014 +21 | +22 | # unfixable + | + = help: Convert `MyType` to class syntax + +ℹ Suggested fix +17 17 | MyType = typing.NamedTuple("MyType", []) +18 18 | +19 19 | # keywords +20 |-MyType = typing.NamedTuple("MyType", a=int, b=tuple[str, ...]) + 20 |+class MyType(typing.NamedTuple): + 21 |+ a: int + 22 |+ b: tuple[str, ...] +21 23 | +22 24 | # unfixable +23 25 | MyType = typing.NamedTuple("MyType", [("a", int)], [("b", str)]) + + 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 new file mode 100644 index 0000000000..ad12951ee8 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP015.py.snap @@ -0,0 +1,902 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP015.py:1:1: UP015 [*] Unnecessary open mode parameters + | +1 | open("foo", "U") + | ^^^^^^^^^^^^^^^^ UP015 +2 | open("foo", "Ur") +3 | open("foo", "Ub") + | + = help: Remove open mode parameters + +ℹ Fix +1 |-open("foo", "U") + 1 |+open("foo") +2 2 | open("foo", "Ur") +3 3 | open("foo", "Ub") +4 4 | open("foo", "rUb") + +UP015.py:2:1: UP015 [*] Unnecessary open mode parameters + | +1 | open("foo", "U") +2 | open("foo", "Ur") + | ^^^^^^^^^^^^^^^^^ UP015 +3 | open("foo", "Ub") +4 | open("foo", "rUb") + | + = help: Remove open mode parameters + +ℹ Fix +1 1 | open("foo", "U") +2 |-open("foo", "Ur") + 2 |+open("foo") +3 3 | open("foo", "Ub") +4 4 | open("foo", "rUb") +5 5 | open("foo", "r") + +UP015.py:3:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" + | +1 | open("foo", "U") +2 | open("foo", "Ur") +3 | open("foo", "Ub") + | ^^^^^^^^^^^^^^^^^ UP015 +4 | open("foo", "rUb") +5 | open("foo", "r") + | + = help: Replace with ""rb"" + +ℹ Fix +1 1 | open("foo", "U") +2 2 | open("foo", "Ur") +3 |-open("foo", "Ub") + 3 |+open("foo", "rb") +4 4 | open("foo", "rUb") +5 5 | open("foo", "r") +6 6 | open("foo", "rt") + +UP015.py:4:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" + | +2 | open("foo", "Ur") +3 | open("foo", "Ub") +4 | open("foo", "rUb") + | ^^^^^^^^^^^^^^^^^^ UP015 +5 | open("foo", "r") +6 | open("foo", "rt") + | + = help: Replace with ""rb"" + +ℹ Fix +1 1 | open("foo", "U") +2 2 | open("foo", "Ur") +3 3 | open("foo", "Ub") +4 |-open("foo", "rUb") + 4 |+open("foo", "rb") +5 5 | open("foo", "r") +6 6 | open("foo", "rt") +7 7 | open("f", "r", encoding="UTF-8") + +UP015.py:5:1: UP015 [*] Unnecessary open mode parameters + | +3 | open("foo", "Ub") +4 | open("foo", "rUb") +5 | open("foo", "r") + | ^^^^^^^^^^^^^^^^ UP015 +6 | open("foo", "rt") +7 | open("f", "r", encoding="UTF-8") + | + = help: Remove open mode parameters + +ℹ Fix +2 2 | open("foo", "Ur") +3 3 | open("foo", "Ub") +4 4 | open("foo", "rUb") +5 |-open("foo", "r") + 5 |+open("foo") +6 6 | open("foo", "rt") +7 7 | open("f", "r", encoding="UTF-8") +8 8 | open("f", "wt") + +UP015.py:6:1: UP015 [*] Unnecessary open mode parameters + | +4 | open("foo", "rUb") +5 | open("foo", "r") +6 | open("foo", "rt") + | ^^^^^^^^^^^^^^^^^ UP015 +7 | open("f", "r", encoding="UTF-8") +8 | open("f", "wt") + | + = help: Remove open mode parameters + +ℹ Fix +3 3 | open("foo", "Ub") +4 4 | open("foo", "rUb") +5 5 | open("foo", "r") +6 |-open("foo", "rt") + 6 |+open("foo") +7 7 | open("f", "r", encoding="UTF-8") +8 8 | open("f", "wt") +9 9 | + +UP015.py:7:1: UP015 [*] Unnecessary open mode parameters + | +5 | open("foo", "r") +6 | open("foo", "rt") +7 | open("f", "r", encoding="UTF-8") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +8 | open("f", "wt") + | + = help: Remove open mode parameters + +ℹ Fix +4 4 | open("foo", "rUb") +5 5 | open("foo", "r") +6 6 | open("foo", "rt") +7 |-open("f", "r", encoding="UTF-8") + 7 |+open("f", encoding="UTF-8") +8 8 | open("f", "wt") +9 9 | +10 10 | with open("foo", "U") as f: + +UP015.py:8:1: UP015 [*] Unnecessary open mode parameters, use ""w"" + | + 6 | open("foo", "rt") + 7 | open("f", "r", encoding="UTF-8") + 8 | open("f", "wt") + | ^^^^^^^^^^^^^^^ UP015 + 9 | +10 | with open("foo", "U") as f: + | + = help: Replace with ""w"" + +ℹ Fix +5 5 | open("foo", "r") +6 6 | open("foo", "rt") +7 7 | open("f", "r", encoding="UTF-8") +8 |-open("f", "wt") + 8 |+open("f", "w") +9 9 | +10 10 | with open("foo", "U") as f: +11 11 | pass + +UP015.py:10:6: UP015 [*] Unnecessary open mode parameters + | + 8 | open("f", "wt") + 9 | +10 | with open("foo", "U") as f: + | ^^^^^^^^^^^^^^^^ UP015 +11 | pass +12 | with open("foo", "Ur") as f: + | + = help: Remove open mode parameters + +ℹ Fix +7 7 | open("f", "r", encoding="UTF-8") +8 8 | open("f", "wt") +9 9 | +10 |-with open("foo", "U") as f: + 10 |+with open("foo") as f: +11 11 | pass +12 12 | with open("foo", "Ur") as f: +13 13 | pass + +UP015.py:12:6: UP015 [*] Unnecessary open mode parameters + | +10 | with open("foo", "U") as f: +11 | pass +12 | with open("foo", "Ur") as f: + | ^^^^^^^^^^^^^^^^^ UP015 +13 | pass +14 | with open("foo", "Ub") as f: + | + = help: Remove open mode parameters + +ℹ Fix +9 9 | +10 10 | with open("foo", "U") as f: +11 11 | pass +12 |-with open("foo", "Ur") as f: + 12 |+with open("foo") as f: +13 13 | pass +14 14 | with open("foo", "Ub") as f: +15 15 | pass + +UP015.py:14:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" + | +12 | with open("foo", "Ur") as f: +13 | pass +14 | with open("foo", "Ub") as f: + | ^^^^^^^^^^^^^^^^^ UP015 +15 | pass +16 | with open("foo", "rUb") as f: + | + = help: Replace with ""rb"" + +ℹ Fix +11 11 | pass +12 12 | with open("foo", "Ur") as f: +13 13 | pass +14 |-with open("foo", "Ub") as f: + 14 |+with open("foo", "rb") as f: +15 15 | pass +16 16 | with open("foo", "rUb") as f: +17 17 | pass + +UP015.py:16:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" + | +14 | with open("foo", "Ub") as f: +15 | pass +16 | with open("foo", "rUb") as f: + | ^^^^^^^^^^^^^^^^^^ UP015 +17 | pass +18 | with open("foo", "r") as f: + | + = help: Replace with ""rb"" + +ℹ Fix +13 13 | pass +14 14 | with open("foo", "Ub") as f: +15 15 | pass +16 |-with open("foo", "rUb") as f: + 16 |+with open("foo", "rb") as f: +17 17 | pass +18 18 | with open("foo", "r") as f: +19 19 | pass + +UP015.py:18:6: UP015 [*] Unnecessary open mode parameters + | +16 | with open("foo", "rUb") as f: +17 | pass +18 | with open("foo", "r") as f: + | ^^^^^^^^^^^^^^^^ UP015 +19 | pass +20 | with open("foo", "rt") as f: + | + = help: Remove open mode parameters + +ℹ Fix +15 15 | pass +16 16 | with open("foo", "rUb") as f: +17 17 | pass +18 |-with open("foo", "r") as f: + 18 |+with open("foo") as f: +19 19 | pass +20 20 | with open("foo", "rt") as f: +21 21 | pass + +UP015.py:20:6: UP015 [*] Unnecessary open mode parameters + | +18 | with open("foo", "r") as f: +19 | pass +20 | with open("foo", "rt") as f: + | ^^^^^^^^^^^^^^^^^ UP015 +21 | pass +22 | with open("foo", "r", encoding="UTF-8") as f: + | + = help: Remove open mode parameters + +ℹ Fix +17 17 | pass +18 18 | with open("foo", "r") as f: +19 19 | pass +20 |-with open("foo", "rt") as f: + 20 |+with open("foo") as f: +21 21 | pass +22 22 | with open("foo", "r", encoding="UTF-8") as f: +23 23 | pass + +UP015.py:22:6: UP015 [*] Unnecessary open mode parameters + | +20 | with open("foo", "rt") as f: +21 | pass +22 | with open("foo", "r", encoding="UTF-8") as f: + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +23 | pass +24 | with open("foo", "wt") as f: + | + = help: Remove open mode parameters + +ℹ Fix +19 19 | pass +20 20 | with open("foo", "rt") as f: +21 21 | pass +22 |-with open("foo", "r", encoding="UTF-8") as f: + 22 |+with open("foo", encoding="UTF-8") as f: +23 23 | pass +24 24 | with open("foo", "wt") as f: +25 25 | pass + +UP015.py:24:6: UP015 [*] Unnecessary open mode parameters, use ""w"" + | +22 | with open("foo", "r", encoding="UTF-8") as f: +23 | pass +24 | with open("foo", "wt") as f: + | ^^^^^^^^^^^^^^^^^ UP015 +25 | pass + | + = help: Replace with ""w"" + +ℹ Fix +21 21 | pass +22 22 | with open("foo", "r", encoding="UTF-8") as f: +23 23 | pass +24 |-with open("foo", "wt") as f: + 24 |+with open("foo", "w") as f: +25 25 | pass +26 26 | +27 27 | open(f("a", "b", "c"), "U") + +UP015.py:27:1: UP015 [*] Unnecessary open mode parameters + | +25 | pass +26 | +27 | open(f("a", "b", "c"), "U") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +28 | open(f("a", "b", "c"), "Ub") + | + = help: Remove open mode parameters + +ℹ Fix +24 24 | with open("foo", "wt") as f: +25 25 | pass +26 26 | +27 |-open(f("a", "b", "c"), "U") + 27 |+open(f("a", "b", "c")) +28 28 | open(f("a", "b", "c"), "Ub") +29 29 | +30 30 | with open(f("a", "b", "c"), "U") as f: + +UP015.py:28:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" + | +27 | open(f("a", "b", "c"), "U") +28 | open(f("a", "b", "c"), "Ub") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +29 | +30 | with open(f("a", "b", "c"), "U") as f: + | + = help: Replace with ""rb"" + +ℹ Fix +25 25 | pass +26 26 | +27 27 | open(f("a", "b", "c"), "U") +28 |-open(f("a", "b", "c"), "Ub") + 28 |+open(f("a", "b", "c"), "rb") +29 29 | +30 30 | with open(f("a", "b", "c"), "U") as f: +31 31 | pass + +UP015.py:30:6: UP015 [*] Unnecessary open mode parameters + | +28 | open(f("a", "b", "c"), "Ub") +29 | +30 | with open(f("a", "b", "c"), "U") as f: + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +31 | pass +32 | with open(f("a", "b", "c"), "Ub") as f: + | + = help: Remove open mode parameters + +ℹ Fix +27 27 | open(f("a", "b", "c"), "U") +28 28 | open(f("a", "b", "c"), "Ub") +29 29 | +30 |-with open(f("a", "b", "c"), "U") as f: + 30 |+with open(f("a", "b", "c")) as f: +31 31 | pass +32 32 | with open(f("a", "b", "c"), "Ub") as f: +33 33 | pass + +UP015.py:32:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" + | +30 | with open(f("a", "b", "c"), "U") as f: +31 | pass +32 | with open(f("a", "b", "c"), "Ub") as f: + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +33 | pass + | + = help: Replace with ""rb"" + +ℹ Fix +29 29 | +30 30 | with open(f("a", "b", "c"), "U") as f: +31 31 | pass +32 |-with open(f("a", "b", "c"), "Ub") as f: + 32 |+with open(f("a", "b", "c"), "rb") as f: +33 33 | pass +34 34 | +35 35 | with open("foo", "U") as fa, open("bar", "U") as fb: + +UP015.py:35:6: UP015 [*] Unnecessary open mode parameters + | +33 | pass +34 | +35 | with open("foo", "U") as fa, open("bar", "U") as fb: + | ^^^^^^^^^^^^^^^^ UP015 +36 | pass +37 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: + | + = help: Remove open mode parameters + +ℹ Fix +32 32 | with open(f("a", "b", "c"), "Ub") as f: +33 33 | pass +34 34 | +35 |-with open("foo", "U") as fa, open("bar", "U") as fb: + 35 |+with open("foo") as fa, open("bar", "U") as fb: +36 36 | pass +37 37 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: +38 38 | pass + +UP015.py:35:30: UP015 [*] Unnecessary open mode parameters + | +33 | pass +34 | +35 | with open("foo", "U") as fa, open("bar", "U") as fb: + | ^^^^^^^^^^^^^^^^ UP015 +36 | pass +37 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: + | + = help: Remove open mode parameters + +ℹ Fix +32 32 | with open(f("a", "b", "c"), "Ub") as f: +33 33 | pass +34 34 | +35 |-with open("foo", "U") as fa, open("bar", "U") as fb: + 35 |+with open("foo", "U") as fa, open("bar") as fb: +36 36 | pass +37 37 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: +38 38 | pass + +UP015.py:37:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" + | +35 | with open("foo", "U") as fa, open("bar", "U") as fb: +36 | pass +37 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: + | ^^^^^^^^^^^^^^^^^ UP015 +38 | pass + | + = help: Replace with ""rb"" + +ℹ Fix +34 34 | +35 35 | with open("foo", "U") as fa, open("bar", "U") as fb: +36 36 | pass +37 |-with open("foo", "Ub") as fa, open("bar", "Ub") as fb: + 37 |+with open("foo", "rb") as fa, open("bar", "Ub") as fb: +38 38 | pass +39 39 | +40 40 | open("foo", mode="U") + +UP015.py:37:31: UP015 [*] Unnecessary open mode parameters, use ""rb"" + | +35 | with open("foo", "U") as fa, open("bar", "U") as fb: +36 | pass +37 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: + | ^^^^^^^^^^^^^^^^^ UP015 +38 | pass + | + = help: Replace with ""rb"" + +ℹ Fix +34 34 | +35 35 | with open("foo", "U") as fa, open("bar", "U") as fb: +36 36 | pass +37 |-with open("foo", "Ub") as fa, open("bar", "Ub") as fb: + 37 |+with open("foo", "Ub") as fa, open("bar", "rb") as fb: +38 38 | pass +39 39 | +40 40 | open("foo", mode="U") + +UP015.py:40:1: UP015 [*] Unnecessary open mode parameters + | +38 | pass +39 | +40 | open("foo", mode="U") + | ^^^^^^^^^^^^^^^^^^^^^ UP015 +41 | open(name="foo", mode="U") +42 | open(mode="U", name="foo") + | + = help: Remove open mode parameters + +ℹ Fix +37 37 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb: +38 38 | pass +39 39 | +40 |-open("foo", mode="U") + 40 |+open("foo") +41 41 | open(name="foo", mode="U") +42 42 | open(mode="U", name="foo") +43 43 | + +UP015.py:41:1: UP015 [*] Unnecessary open mode parameters + | +40 | open("foo", mode="U") +41 | open(name="foo", mode="U") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +42 | open(mode="U", name="foo") + | + = help: Remove open mode parameters + +ℹ Fix +38 38 | pass +39 39 | +40 40 | open("foo", mode="U") +41 |-open(name="foo", mode="U") + 41 |+open(name="foo") +42 42 | open(mode="U", name="foo") +43 43 | +44 44 | with open("foo", mode="U") as f: + +UP015.py:42:1: UP015 [*] Unnecessary open mode parameters + | +40 | open("foo", mode="U") +41 | open(name="foo", mode="U") +42 | open(mode="U", name="foo") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +43 | +44 | with open("foo", mode="U") as f: + | + = help: Remove open mode parameters + +ℹ Fix +39 39 | +40 40 | open("foo", mode="U") +41 41 | open(name="foo", mode="U") +42 |-open(mode="U", name="foo") + 42 |+open(name="foo") +43 43 | +44 44 | with open("foo", mode="U") as f: +45 45 | pass + +UP015.py:44:6: UP015 [*] Unnecessary open mode parameters + | +42 | open(mode="U", name="foo") +43 | +44 | with open("foo", mode="U") as f: + | ^^^^^^^^^^^^^^^^^^^^^ UP015 +45 | pass +46 | with open(name="foo", mode="U") as f: + | + = help: Remove open mode parameters + +ℹ Fix +41 41 | open(name="foo", mode="U") +42 42 | open(mode="U", name="foo") +43 43 | +44 |-with open("foo", mode="U") as f: + 44 |+with open("foo") as f: +45 45 | pass +46 46 | with open(name="foo", mode="U") as f: +47 47 | pass + +UP015.py:46:6: UP015 [*] Unnecessary open mode parameters + | +44 | with open("foo", mode="U") as f: +45 | pass +46 | with open(name="foo", mode="U") as f: + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +47 | pass +48 | with open(mode="U", name="foo") as f: + | + = help: Remove open mode parameters + +ℹ Fix +43 43 | +44 44 | with open("foo", mode="U") as f: +45 45 | pass +46 |-with open(name="foo", mode="U") as f: + 46 |+with open(name="foo") as f: +47 47 | pass +48 48 | with open(mode="U", name="foo") as f: +49 49 | pass + +UP015.py:48:6: UP015 [*] Unnecessary open mode parameters + | +46 | with open(name="foo", mode="U") as f: +47 | pass +48 | with open(mode="U", name="foo") as f: + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +49 | pass + | + = help: Remove open mode parameters + +ℹ Fix +45 45 | pass +46 46 | with open(name="foo", mode="U") as f: +47 47 | pass +48 |-with open(mode="U", name="foo") as f: + 48 |+with open(name="foo") as f: +49 49 | pass +50 50 | +51 51 | open("foo", mode="Ub") + +UP015.py:51:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" + | +49 | pass +50 | +51 | open("foo", mode="Ub") + | ^^^^^^^^^^^^^^^^^^^^^^ UP015 +52 | open(name="foo", mode="Ub") +53 | open(mode="Ub", name="foo") + | + = help: Replace with ""rb"" + +ℹ Fix +48 48 | with open(mode="U", name="foo") as f: +49 49 | pass +50 50 | +51 |-open("foo", mode="Ub") + 51 |+open("foo", mode="rb") +52 52 | open(name="foo", mode="Ub") +53 53 | open(mode="Ub", name="foo") +54 54 | + +UP015.py:52:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" + | +51 | open("foo", mode="Ub") +52 | open(name="foo", mode="Ub") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +53 | open(mode="Ub", name="foo") + | + = help: Replace with ""rb"" + +ℹ Fix +49 49 | pass +50 50 | +51 51 | open("foo", mode="Ub") +52 |-open(name="foo", mode="Ub") + 52 |+open(name="foo", mode="rb") +53 53 | open(mode="Ub", name="foo") +54 54 | +55 55 | with open("foo", mode="Ub") as f: + +UP015.py:53:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" + | +51 | open("foo", mode="Ub") +52 | open(name="foo", mode="Ub") +53 | open(mode="Ub", name="foo") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +54 | +55 | with open("foo", mode="Ub") as f: + | + = help: Replace with ""rb"" + +ℹ Fix +50 50 | +51 51 | open("foo", mode="Ub") +52 52 | open(name="foo", mode="Ub") +53 |-open(mode="Ub", name="foo") + 53 |+open(mode="rb", name="foo") +54 54 | +55 55 | with open("foo", mode="Ub") as f: +56 56 | pass + +UP015.py:55:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" + | +53 | open(mode="Ub", name="foo") +54 | +55 | with open("foo", mode="Ub") as f: + | ^^^^^^^^^^^^^^^^^^^^^^ UP015 +56 | pass +57 | with open(name="foo", mode="Ub") as f: + | + = help: Replace with ""rb"" + +ℹ Fix +52 52 | open(name="foo", mode="Ub") +53 53 | open(mode="Ub", name="foo") +54 54 | +55 |-with open("foo", mode="Ub") as f: + 55 |+with open("foo", mode="rb") as f: +56 56 | pass +57 57 | with open(name="foo", mode="Ub") as f: +58 58 | pass + +UP015.py:57:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" + | +55 | with open("foo", mode="Ub") as f: +56 | pass +57 | with open(name="foo", mode="Ub") as f: + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +58 | pass +59 | with open(mode="Ub", name="foo") as f: + | + = help: Replace with ""rb"" + +ℹ Fix +54 54 | +55 55 | with open("foo", mode="Ub") as f: +56 56 | pass +57 |-with open(name="foo", mode="Ub") as f: + 57 |+with open(name="foo", mode="rb") as f: +58 58 | pass +59 59 | with open(mode="Ub", name="foo") as f: +60 60 | pass + +UP015.py:59:6: UP015 [*] Unnecessary open mode parameters, use ""rb"" + | +57 | with open(name="foo", mode="Ub") as f: +58 | pass +59 | with open(mode="Ub", name="foo") as f: + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +60 | pass + | + = help: Replace with ""rb"" + +ℹ Fix +56 56 | pass +57 57 | with open(name="foo", mode="Ub") as f: +58 58 | pass +59 |-with open(mode="Ub", name="foo") as f: + 59 |+with open(mode="rb", name="foo") as f: +60 60 | pass +61 61 | +62 62 | open(file="foo", mode='U', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) + +UP015.py:62:1: UP015 [*] Unnecessary open mode parameters + | +60 | pass +61 | +62 | open(file="foo", mode='U', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +63 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') +64 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) + | + = help: Remove open mode parameters + +ℹ Fix +59 59 | with open(mode="Ub", name="foo") as f: +60 60 | pass +61 61 | +62 |-open(file="foo", mode='U', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) + 62 |+open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +63 63 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') +64 64 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) +65 65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) + +UP015.py:63:1: UP015 [*] Unnecessary open mode parameters + | +62 | open(file="foo", mode='U', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +63 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +64 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) +65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) + | + = help: Remove open mode parameters + +ℹ Fix +60 60 | pass +61 61 | +62 62 | open(file="foo", mode='U', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +63 |-open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') + 63 |+open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +64 64 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) +65 65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +66 66 | + +UP015.py:64:1: UP015 [*] Unnecessary open mode parameters + | +62 | open(file="foo", mode='U', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +63 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') +64 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) + | + = help: Remove open mode parameters + +ℹ Fix +61 61 | +62 62 | open(file="foo", mode='U', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +63 63 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') +64 |-open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) + 64 |+open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +65 65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +66 66 | +67 67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) + +UP015.py:65:1: UP015 [*] Unnecessary open mode parameters + | +63 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') +64 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) +65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +66 | +67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) + | + = help: Remove open mode parameters + +ℹ Fix +62 62 | open(file="foo", mode='U', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +63 63 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U') +64 64 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) +65 |-open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) + 65 |+open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +66 66 | +67 67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +68 68 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') + +UP015.py:67:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" + | +65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +66 | +67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +68 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') +69 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) + | + = help: Replace with ""rb"" + +ℹ Fix +64 64 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None) +65 65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +66 66 | +67 |-open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) + 67 |+open(file="foo", mode="rb", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +68 68 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') +69 69 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) +70 70 | open(mode='Ub', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) + +UP015.py:68:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" + | +67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +68 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +69 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) +70 | open(mode='Ub', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) + | + = help: Replace with ""rb"" + +ℹ Fix +65 65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +66 66 | +67 67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +68 |-open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') + 68 |+open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode="rb") +69 69 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) +70 70 | open(mode='Ub', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +71 71 | + +UP015.py:69:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" + | +67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +68 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') +69 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +70 | open(mode='Ub', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) + | + = help: Replace with ""rb"" + +ℹ Fix +66 66 | +67 67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +68 68 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') +69 |-open(file="foo", buffering=- 1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) + 69 |+open(file="foo", buffering=- 1, encoding=None, errors=None, mode="rb", newline=None, closefd=True, opener=None) +70 70 | open(mode='Ub', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +71 71 | +72 72 | open = 1 + +UP015.py:70:1: UP015 [*] Unnecessary open mode parameters, use ""rb"" + | +68 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') +69 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) +70 | open(mode='Ub', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP015 +71 | +72 | open = 1 + | + = help: Replace with ""rb"" + +ℹ Fix +67 67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +68 68 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub') +69 69 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None) +70 |-open(mode='Ub', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) + 70 |+open(mode="rb", file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None) +71 71 | +72 72 | open = 1 +73 73 | open("foo", "U") + + 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 new file mode 100644 index 0000000000..a43a4e9b9f --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP018.py.snap @@ -0,0 +1,317 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP018.py:37:1: UP018 [*] Unnecessary `str` call (rewrite as a literal) + | +36 | # These become string or byte literals +37 | str() + | ^^^^^ UP018 +38 | str("foo") +39 | str(""" + | + = help: Replace with empty string + +ℹ Fix +34 34 | int().denominator +35 35 | +36 36 | # These become string or byte literals +37 |-str() + 37 |+"" +38 38 | str("foo") +39 39 | str(""" +40 40 | foo""") + +UP018.py:38:1: UP018 [*] Unnecessary `str` call (rewrite as a literal) + | +36 | # These become string or byte literals +37 | str() +38 | str("foo") + | ^^^^^^^^^^ UP018 +39 | str(""" +40 | foo""") + | + = help: Replace with empty string + +ℹ Fix +35 35 | +36 36 | # These become string or byte literals +37 37 | str() +38 |-str("foo") + 38 |+"foo" +39 39 | str(""" +40 40 | foo""") +41 41 | bytes() + +UP018.py:39:1: UP018 [*] Unnecessary `str` call (rewrite as a literal) + | +37 | str() +38 | str("foo") +39 | / str(""" +40 | | foo""") + | |_______^ UP018 +41 | bytes() +42 | bytes(b"foo") + | + = help: Replace with empty string + +ℹ Fix +36 36 | # These become string or byte literals +37 37 | str() +38 38 | str("foo") +39 |-str(""" +40 |-foo""") + 39 |+""" + 40 |+foo""" +41 41 | bytes() +42 42 | bytes(b"foo") +43 43 | bytes(b""" + +UP018.py:41:1: UP018 [*] Unnecessary `bytes` call (rewrite as a literal) + | +39 | str(""" +40 | foo""") +41 | bytes() + | ^^^^^^^ UP018 +42 | bytes(b"foo") +43 | bytes(b""" + | + = help: Replace with empty bytes + +ℹ Fix +38 38 | str("foo") +39 39 | str(""" +40 40 | foo""") +41 |-bytes() + 41 |+b"" +42 42 | bytes(b"foo") +43 43 | bytes(b""" +44 44 | foo""") + +UP018.py:42:1: UP018 [*] Unnecessary `bytes` call (rewrite as a literal) + | +40 | foo""") +41 | bytes() +42 | bytes(b"foo") + | ^^^^^^^^^^^^^ UP018 +43 | bytes(b""" +44 | foo""") + | + = help: Replace with empty bytes + +ℹ Fix +39 39 | str(""" +40 40 | foo""") +41 41 | bytes() +42 |-bytes(b"foo") + 42 |+b"foo" +43 43 | bytes(b""" +44 44 | foo""") +45 45 | f"{str()}" + +UP018.py:43:1: UP018 [*] Unnecessary `bytes` call (rewrite as a literal) + | +41 | bytes() +42 | bytes(b"foo") +43 | / bytes(b""" +44 | | foo""") + | |_______^ UP018 +45 | f"{str()}" +46 | int() + | + = help: Replace with empty bytes + +ℹ Fix +40 40 | foo""") +41 41 | bytes() +42 42 | bytes(b"foo") +43 |-bytes(b""" +44 |-foo""") + 43 |+b""" + 44 |+foo""" +45 45 | f"{str()}" +46 46 | int() +47 47 | int(1) + +UP018.py:45:4: UP018 [*] Unnecessary `str` call (rewrite as a literal) + | +43 | bytes(b""" +44 | foo""") +45 | f"{str()}" + | ^^^^^ UP018 +46 | int() +47 | int(1) + | + = help: Replace with empty string + +ℹ Fix +42 42 | bytes(b"foo") +43 43 | bytes(b""" +44 44 | foo""") +45 |-f"{str()}" + 45 |+f"{''}" +46 46 | int() +47 47 | int(1) +48 48 | float() + +UP018.py:46:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) + | +44 | foo""") +45 | f"{str()}" +46 | int() + | ^^^^^ UP018 +47 | int(1) +48 | float() + | + = help: Replace with 0 + +ℹ Fix +43 43 | bytes(b""" +44 44 | foo""") +45 45 | f"{str()}" +46 |-int() + 46 |+0 +47 47 | int(1) +48 48 | float() +49 49 | float(1.0) + +UP018.py:47:1: UP018 [*] Unnecessary `int` call (rewrite as a literal) + | +45 | f"{str()}" +46 | int() +47 | int(1) + | ^^^^^^ UP018 +48 | float() +49 | float(1.0) + | + = help: Replace with 0 + +ℹ Fix +44 44 | foo""") +45 45 | f"{str()}" +46 46 | int() +47 |-int(1) + 47 |+1 +48 48 | float() +49 49 | float(1.0) +50 50 | bool() + +UP018.py:48:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) + | +46 | int() +47 | int(1) +48 | float() + | ^^^^^^^ UP018 +49 | float(1.0) +50 | bool() + | + = help: Replace with 0.0 + +ℹ Fix +45 45 | f"{str()}" +46 46 | int() +47 47 | int(1) +48 |-float() + 48 |+0.0 +49 49 | float(1.0) +50 50 | bool() +51 51 | bool(True) + +UP018.py:49:1: UP018 [*] Unnecessary `float` call (rewrite as a literal) + | +47 | int(1) +48 | float() +49 | float(1.0) + | ^^^^^^^^^^ UP018 +50 | bool() +51 | bool(True) + | + = help: Replace with 0.0 + +ℹ Fix +46 46 | int() +47 47 | int(1) +48 48 | float() +49 |-float(1.0) + 49 |+1.0 +50 50 | bool() +51 51 | bool(True) +52 52 | bool(False) + +UP018.py:50:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal) + | +48 | float() +49 | float(1.0) +50 | bool() + | ^^^^^^ UP018 +51 | bool(True) +52 | bool(False) + | + = help: Replace with `False` + +ℹ Fix +47 47 | int(1) +48 48 | float() +49 49 | float(1.0) +50 |-bool() + 50 |+False +51 51 | bool(True) +52 52 | bool(False) +53 53 | + +UP018.py:51:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal) + | +49 | float(1.0) +50 | bool() +51 | bool(True) + | ^^^^^^^^^^ UP018 +52 | bool(False) + | + = help: Replace with `False` + +ℹ Fix +48 48 | float() +49 49 | float(1.0) +50 50 | bool() +51 |-bool(True) + 51 |+True +52 52 | bool(False) +53 53 | +54 54 | # These become a literal but retain parentheses + +UP018.py:52:1: UP018 [*] Unnecessary `bool` call (rewrite as a literal) + | +50 | bool() +51 | bool(True) +52 | bool(False) + | ^^^^^^^^^^^ UP018 +53 | +54 | # These become a literal but retain parentheses + | + = help: Replace with `False` + +ℹ Fix +49 49 | float(1.0) +50 50 | bool() +51 51 | bool(True) +52 |-bool(False) + 52 |+False +53 53 | +54 54 | # These become a literal but retain parentheses +55 55 | int(1).denominator + +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 + | + = help: Replace with 0 + +ℹ Fix +52 52 | bool(False) +53 53 | +54 54 | # These become a literal but retain parentheses +55 |-int(1).denominator + 55 |+(1).denominator + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP019.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP019.py.snap new file mode 100644 index 0000000000..8bb3a507c1 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP019.py.snap @@ -0,0 +1,74 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP019.py:7:22: UP019 [*] `typing.Text` is deprecated, use `str` + | +7 | def print_word(word: Text) -> None: + | ^^^^ UP019 +8 | print(word) + | + = help: Replace with `str` + +ℹ Fix +4 4 | from typing import Text as Goodbye +5 5 | +6 6 | +7 |-def print_word(word: Text) -> None: + 7 |+def print_word(word: str) -> None: +8 8 | print(word) +9 9 | +10 10 | + +UP019.py:11:29: UP019 [*] `typing.Text` is deprecated, use `str` + | +11 | def print_second_word(word: typing.Text) -> None: + | ^^^^^^^^^^^ UP019 +12 | print(word) + | + = help: Replace with `str` + +ℹ Fix +8 8 | print(word) +9 9 | +10 10 | +11 |-def print_second_word(word: typing.Text) -> None: + 11 |+def print_second_word(word: str) -> None: +12 12 | print(word) +13 13 | +14 14 | + +UP019.py:15:28: UP019 [*] `typing.Text` is deprecated, use `str` + | +15 | def print_third_word(word: Hello.Text) -> None: + | ^^^^^^^^^^ UP019 +16 | print(word) + | + = help: Replace with `str` + +ℹ Fix +12 12 | print(word) +13 13 | +14 14 | +15 |-def print_third_word(word: Hello.Text) -> None: + 15 |+def print_third_word(word: str) -> None: +16 16 | print(word) +17 17 | +18 18 | + +UP019.py:19:29: UP019 [*] `typing.Text` is deprecated, use `str` + | +19 | def print_fourth_word(word: Goodbye) -> None: + | ^^^^^^^ UP019 +20 | print(word) + | + = help: Replace with `str` + +ℹ Fix +16 16 | print(word) +17 17 | +18 18 | +19 |-def print_fourth_word(word: Goodbye) -> None: + 19 |+def print_fourth_word(word: str) -> None: +20 20 | print(word) + + 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 new file mode 100644 index 0000000000..6638a8cc90 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP020.py.snap @@ -0,0 +1,33 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP020.py:3:6: UP020 [*] Use builtin `open` + | +1 | import io +2 | +3 | with io.open("f.txt", mode="r", buffering=-1, **kwargs) as f: + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP020 +4 | print(f.read()) + | + = help: Replace with builtin `open` + +ℹ Suggested fix +1 1 | import io +2 2 | +3 |-with io.open("f.txt", mode="r", buffering=-1, **kwargs) as f: + 3 |+with open("f.txt", mode="r", buffering=-1, **kwargs) as f: +4 4 | print(f.read()) +5 5 | +6 6 | from io import open + +UP020.py:8:6: UP020 Use builtin `open` + | +6 | from io import open +7 | +8 | with open("f.txt") as f: + | ^^^^^^^^^^^^^ UP020 +9 | print(f.read()) + | + = help: Replace with builtin `open` + + 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 new file mode 100644 index 0000000000..484e53f1d8 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP021.py.snap @@ -0,0 +1,65 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP021.py:5:25: UP021 [*] `universal_newlines` is deprecated, use `text` + | +4 | # Errors +5 | subprocess.run(["foo"], universal_newlines=True, check=True) + | ^^^^^^^^^^^^^^^^^^ UP021 +6 | subprocess.run(["foo"], universal_newlines=True, text=True) +7 | run(["foo"], universal_newlines=True, check=False) + | + = help: Replace with `text` keyword argument + +ℹ Suggested fix +2 2 | from subprocess import run +3 3 | +4 4 | # Errors +5 |-subprocess.run(["foo"], universal_newlines=True, check=True) + 5 |+subprocess.run(["foo"], text=True, check=True) +6 6 | subprocess.run(["foo"], universal_newlines=True, text=True) +7 7 | run(["foo"], universal_newlines=True, check=False) +8 8 | + +UP021.py:6:25: UP021 [*] `universal_newlines` is deprecated, use `text` + | +4 | # Errors +5 | subprocess.run(["foo"], universal_newlines=True, check=True) +6 | subprocess.run(["foo"], universal_newlines=True, text=True) + | ^^^^^^^^^^^^^^^^^^ UP021 +7 | run(["foo"], universal_newlines=True, check=False) + | + = help: Replace with `text` keyword argument + +ℹ Suggested fix +3 3 | +4 4 | # Errors +5 5 | subprocess.run(["foo"], universal_newlines=True, check=True) +6 |-subprocess.run(["foo"], universal_newlines=True, text=True) + 6 |+subprocess.run(["foo"], text=True) +7 7 | run(["foo"], universal_newlines=True, check=False) +8 8 | +9 9 | # OK + +UP021.py:7:14: UP021 [*] `universal_newlines` is deprecated, use `text` + | +5 | subprocess.run(["foo"], universal_newlines=True, check=True) +6 | subprocess.run(["foo"], universal_newlines=True, text=True) +7 | run(["foo"], universal_newlines=True, check=False) + | ^^^^^^^^^^^^^^^^^^ UP021 +8 | +9 | # OK + | + = help: Replace with `text` keyword argument + +ℹ Suggested fix +4 4 | # Errors +5 5 | subprocess.run(["foo"], universal_newlines=True, check=True) +6 6 | subprocess.run(["foo"], universal_newlines=True, text=True) +7 |-run(["foo"], universal_newlines=True, check=False) + 7 |+run(["foo"], text=True, check=False) +8 8 | +9 9 | # OK +10 10 | subprocess.run(["foo"], check=True) + + 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 new file mode 100644 index 0000000000..186db76254 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP022.py.snap @@ -0,0 +1,219 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP022.py:4:10: UP022 [*] Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` + | +2 | import subprocess +3 | +4 | output = run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP022 +5 | +6 | output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + | + = help: Replace with `capture_output` keyword argument + +ℹ Suggested fix +1 1 | from subprocess import run +2 2 | import subprocess +3 3 | +4 |-output = run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + 4 |+output = run(["foo"], capture_output=True) +5 5 | +6 6 | output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) +7 7 | + +UP022.py:6:10: UP022 [*] Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` + | +4 | output = run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) +5 | +6 | output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP022 +7 | +8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) + | + = help: Replace with `capture_output` keyword argument + +ℹ Suggested fix +3 3 | +4 4 | output = run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) +5 5 | +6 |-output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + 6 |+output = subprocess.run(["foo"], capture_output=True) +7 7 | +8 8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) +9 9 | + +UP022.py:8:10: UP022 [*] Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` + | + 6 | output = subprocess.run(["foo"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + 7 | + 8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP022 + 9 | +10 | output = subprocess.run( + | + = help: Replace with `capture_output` keyword argument + +ℹ Suggested fix +5 5 | +6 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) + 8 |+output = subprocess.run(capture_output=True, args=["foo"]) +9 9 | +10 10 | output = subprocess.run( +11 11 | ["foo"], stdout=subprocess.PIPE, check=True, stderr=subprocess.PIPE + +UP022.py:10:10: UP022 [*] Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` + | + 8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) + 9 | +10 | output = subprocess.run( + | __________^ +11 | | ["foo"], stdout=subprocess.PIPE, check=True, stderr=subprocess.PIPE +12 | | ) + | |_^ UP022 +13 | +14 | output = subprocess.run( + | + = help: Replace with `capture_output` keyword argument + +ℹ Suggested fix +8 8 | output = subprocess.run(stdout=subprocess.PIPE, args=["foo"], stderr=subprocess.PIPE) +9 9 | +10 10 | output = subprocess.run( +11 |- ["foo"], stdout=subprocess.PIPE, check=True, stderr=subprocess.PIPE + 11 |+ ["foo"], capture_output=True, check=True +12 12 | ) +13 13 | +14 14 | output = subprocess.run( + +UP022.py:14:10: UP022 [*] Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` + | +12 | ) +13 | +14 | output = subprocess.run( + | __________^ +15 | | ["foo"], stderr=subprocess.PIPE, check=True, stdout=subprocess.PIPE +16 | | ) + | |_^ UP022 +17 | +18 | output = subprocess.run( + | + = help: Replace with `capture_output` keyword argument + +ℹ Suggested fix +12 12 | ) +13 13 | +14 14 | output = subprocess.run( +15 |- ["foo"], stderr=subprocess.PIPE, check=True, stdout=subprocess.PIPE + 15 |+ ["foo"], capture_output=True, check=True +16 16 | ) +17 17 | +18 18 | output = subprocess.run( + +UP022.py:18:10: UP022 [*] Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` + | +16 | ) +17 | +18 | output = subprocess.run( + | __________^ +19 | | ["foo"], +20 | | stdout=subprocess.PIPE, +21 | | check=True, +22 | | stderr=subprocess.PIPE, +23 | | text=True, +24 | | encoding="utf-8", +25 | | close_fds=True, +26 | | ) + | |_^ UP022 +27 | +28 | if output: + | + = help: Replace with `capture_output` keyword argument + +ℹ Suggested fix +17 17 | +18 18 | output = subprocess.run( +19 19 | ["foo"], +20 |- stdout=subprocess.PIPE, + 20 |+ capture_output=True, +21 21 | check=True, +22 |- stderr=subprocess.PIPE, +23 22 | text=True, +24 23 | encoding="utf-8", +25 24 | close_fds=True, + +UP022.py:29:14: UP022 [*] Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` + | +28 | if output: +29 | output = subprocess.run( + | ______________^ +30 | | ["foo"], +31 | | stdout=subprocess.PIPE, +32 | | check=True, +33 | | stderr=subprocess.PIPE, +34 | | text=True, +35 | | encoding="utf-8", +36 | | ) + | |_____^ UP022 +37 | +38 | output = subprocess.run( + | + = help: Replace with `capture_output` keyword argument + +ℹ Suggested fix +28 28 | if output: +29 29 | output = subprocess.run( +30 30 | ["foo"], +31 |- stdout=subprocess.PIPE, + 31 |+ capture_output=True, +32 32 | check=True, +33 |- stderr=subprocess.PIPE, +34 33 | text=True, +35 34 | encoding="utf-8", +36 35 | ) + +UP022.py:38:10: UP022 Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` + | +36 | ) +37 | +38 | output = subprocess.run( + | __________^ +39 | | ["foo"], stdout=subprocess.PIPE, capture_output=True, stderr=subprocess.PIPE +40 | | ) + | |_^ UP022 +41 | +42 | output = subprocess.run( + | + = help: Replace with `capture_output` keyword argument + +UP022.py:42:10: UP022 Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` + | +40 | ) +41 | +42 | output = subprocess.run( + | __________^ +43 | | ["foo"], stdout=subprocess.PIPE, capture_output=False, stderr=subprocess.PIPE +44 | | ) + | |_^ UP022 +45 | +46 | output = subprocess.run( + | + = help: Replace with `capture_output` keyword argument + +UP022.py:46:10: UP022 Sending `stdout` and `stderr` to `PIPE` is deprecated, use `capture_output` + | +44 | ) +45 | +46 | output = subprocess.run( + | __________^ +47 | | ["foo"], capture_output=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE +48 | | ) + | |_^ UP022 +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 new file mode 100644 index 0000000000..6944c7925b --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP023.py.snap @@ -0,0 +1,208 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP023.py:2:1: UP023 [*] `cElementTree` is deprecated, use `ElementTree` + | +1 | # These two imports have something after cElementTree, so they should be fixed. +2 | from xml.etree.cElementTree import XML, Element, SubElement + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 +3 | import xml.etree.cElementTree as ET + | + = help: Replace with `ElementTree` + +ℹ Suggested fix +1 1 | # These two imports have something after cElementTree, so they should be fixed. +2 |-from xml.etree.cElementTree import XML, Element, SubElement + 2 |+from xml.etree.ElementTree import XML, Element, SubElement +3 3 | import xml.etree.cElementTree as ET +4 4 | +5 5 | # Weird spacing should not cause issues. + +UP023.py:3:8: UP023 [*] `cElementTree` is deprecated, use `ElementTree` + | +1 | # These two imports have something after cElementTree, so they should be fixed. +2 | from xml.etree.cElementTree import XML, Element, SubElement +3 | import xml.etree.cElementTree as ET + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 +4 | +5 | # Weird spacing should not cause issues. + | + = help: Replace with `ElementTree` + +ℹ Suggested fix +1 1 | # These two imports have something after cElementTree, so they should be fixed. +2 2 | from xml.etree.cElementTree import XML, Element, SubElement +3 |-import xml.etree.cElementTree as ET + 3 |+import xml.etree.ElementTree as ET +4 4 | +5 5 | # Weird spacing should not cause issues. +6 6 | from xml.etree.cElementTree import XML + +UP023.py:6:1: UP023 [*] `cElementTree` is deprecated, use `ElementTree` + | +5 | # Weird spacing should not cause issues. +6 | from xml.etree.cElementTree import XML + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 +7 | import xml.etree.cElementTree as ET + | + = help: Replace with `ElementTree` + +ℹ Suggested fix +3 3 | import xml.etree.cElementTree as ET +4 4 | +5 5 | # Weird spacing should not cause issues. +6 |-from xml.etree.cElementTree import XML + 6 |+from xml.etree.ElementTree import XML +7 7 | import xml.etree.cElementTree as ET +8 8 | +9 9 | # Multi line imports should also work fine. + +UP023.py:7:11: UP023 [*] `cElementTree` is deprecated, use `ElementTree` + | +5 | # Weird spacing should not cause issues. +6 | from xml.etree.cElementTree import XML +7 | import xml.etree.cElementTree as ET + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 +8 | +9 | # Multi line imports should also work fine. + | + = help: Replace with `ElementTree` + +ℹ Suggested fix +4 4 | +5 5 | # Weird spacing should not cause issues. +6 6 | from xml.etree.cElementTree import XML +7 |-import xml.etree.cElementTree as ET + 7 |+import xml.etree.ElementTree as ET +8 8 | +9 9 | # Multi line imports should also work fine. +10 10 | from xml.etree.cElementTree import ( + +UP023.py:10:1: UP023 [*] `cElementTree` is deprecated, use `ElementTree` + | + 9 | # Multi line imports should also work fine. +10 | / from xml.etree.cElementTree import ( +11 | | XML, +12 | | Element, +13 | | SubElement, +14 | | ) + | |_^ UP023 +15 | if True: +16 | import xml.etree.cElementTree as ET + | + = help: Replace with `ElementTree` + +ℹ Suggested fix +7 7 | import xml.etree.cElementTree as ET +8 8 | +9 9 | # Multi line imports should also work fine. +10 |-from xml.etree.cElementTree import ( + 10 |+from xml.etree.ElementTree import ( +11 11 | XML, +12 12 | Element, +13 13 | SubElement, + +UP023.py:16:12: UP023 [*] `cElementTree` is deprecated, use `ElementTree` + | +14 | ) +15 | if True: +16 | import xml.etree.cElementTree as ET + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 +17 | from xml.etree import cElementTree as CET + | + = help: Replace with `ElementTree` + +ℹ Suggested fix +13 13 | SubElement, +14 14 | ) +15 15 | if True: +16 |- import xml.etree.cElementTree as ET + 16 |+ import xml.etree.ElementTree as ET +17 17 | from xml.etree import cElementTree as CET +18 18 | +19 19 | from xml.etree import cElementTree as ET + +UP023.py:17:27: UP023 [*] `cElementTree` is deprecated, use `ElementTree` + | +15 | if True: +16 | import xml.etree.cElementTree as ET +17 | from xml.etree import cElementTree as CET + | ^^^^^^^^^^^^^^^^^^^ UP023 +18 | +19 | from xml.etree import cElementTree as ET + | + = help: Replace with `ElementTree` + +ℹ Suggested fix +14 14 | ) +15 15 | if True: +16 16 | import xml.etree.cElementTree as ET +17 |- from xml.etree import cElementTree as CET + 17 |+ from xml.etree import ElementTree as CET +18 18 | +19 19 | from xml.etree import cElementTree as ET +20 20 | + +UP023.py:19:23: UP023 [*] `cElementTree` is deprecated, use `ElementTree` + | +17 | from xml.etree import cElementTree as CET +18 | +19 | from xml.etree import cElementTree as ET + | ^^^^^^^^^^^^^^^^^^ UP023 +20 | +21 | import contextlib, xml.etree.cElementTree as ET + | + = help: Replace with `ElementTree` + +ℹ Suggested fix +16 16 | import xml.etree.cElementTree as ET +17 17 | from xml.etree import cElementTree as CET +18 18 | +19 |-from xml.etree import cElementTree as ET + 19 |+from xml.etree import ElementTree as ET +20 20 | +21 21 | import contextlib, xml.etree.cElementTree as ET +22 22 | + +UP023.py:21:20: UP023 [*] `cElementTree` is deprecated, use `ElementTree` + | +19 | from xml.etree import cElementTree as ET +20 | +21 | import contextlib, xml.etree.cElementTree as ET + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP023 +22 | +23 | # This should fix the second, but not the first invocation. + | + = help: Replace with `ElementTree` + +ℹ Suggested fix +18 18 | +19 19 | from xml.etree import cElementTree as ET +20 20 | +21 |-import contextlib, xml.etree.cElementTree as ET + 21 |+import contextlib, xml.etree.ElementTree as ET +22 22 | +23 23 | # This should fix the second, but not the first invocation. +24 24 | import xml.etree.cElementTree, xml.etree.cElementTree as ET + +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 | +26 | # The below items should NOT be changed. + | + = help: Replace with `ElementTree` + +ℹ Suggested fix +21 21 | import contextlib, xml.etree.cElementTree as ET +22 22 | +23 23 | # This should fix the second, but not the first invocation. +24 |-import xml.etree.cElementTree, xml.etree.cElementTree as ET + 24 |+import xml.etree.cElementTree, xml.etree.ElementTree as ET +25 25 | +26 26 | # The below items should NOT be changed. +27 27 | import xml.etree.cElementTree + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_0.py.snap new file mode 100644 index 0000000000..7ceec856fe --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_0.py.snap @@ -0,0 +1,285 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP024_0.py:6:8: UP024 [*] Replace aliased errors with `OSError` + | +4 | try: +5 | pass +6 | except EnvironmentError: + | ^^^^^^^^^^^^^^^^ UP024 +7 | pass + | + = help: Replace `EnvironmentError` with builtin `OSError` + +ℹ Fix +3 3 | # These should be fixed +4 4 | try: +5 5 | pass +6 |-except EnvironmentError: + 6 |+except OSError: +7 7 | pass +8 8 | +9 9 | try: + +UP024_0.py:11:8: UP024 [*] Replace aliased errors with `OSError` + | + 9 | try: +10 | pass +11 | except IOError: + | ^^^^^^^ UP024 +12 | pass + | + = help: Replace `IOError` with builtin `OSError` + +ℹ Fix +8 8 | +9 9 | try: +10 10 | pass +11 |-except IOError: + 11 |+except OSError: +12 12 | pass +13 13 | +14 14 | try: + +UP024_0.py:16:8: UP024 [*] Replace aliased errors with `OSError` + | +14 | try: +15 | pass +16 | except WindowsError: + | ^^^^^^^^^^^^ UP024 +17 | pass + | + = help: Replace `WindowsError` with builtin `OSError` + +ℹ Fix +13 13 | +14 14 | try: +15 15 | pass +16 |-except WindowsError: + 16 |+except OSError: +17 17 | pass +18 18 | +19 19 | try: + +UP024_0.py:21:8: UP024 [*] Replace aliased errors with `OSError` + | +19 | try: +20 | pass +21 | except mmap.error: + | ^^^^^^^^^^ UP024 +22 | pass + | + = help: Replace `mmap.error` with builtin `OSError` + +ℹ Fix +18 18 | +19 19 | try: +20 20 | pass +21 |-except mmap.error: + 21 |+except OSError: +22 22 | pass +23 23 | +24 24 | try: + +UP024_0.py:26:8: UP024 [*] Replace aliased errors with `OSError` + | +24 | try: +25 | pass +26 | except select.error: + | ^^^^^^^^^^^^ UP024 +27 | pass + | + = help: Replace `select.error` with builtin `OSError` + +ℹ Fix +23 23 | +24 24 | try: +25 25 | pass +26 |-except select.error: + 26 |+except OSError: +27 27 | pass +28 28 | +29 29 | try: + +UP024_0.py:31:8: UP024 [*] Replace aliased errors with `OSError` + | +29 | try: +30 | pass +31 | except socket.error: + | ^^^^^^^^^^^^ UP024 +32 | pass + | + = help: Replace `socket.error` with builtin `OSError` + +ℹ Fix +28 28 | +29 29 | try: +30 30 | pass +31 |-except socket.error: + 31 |+except OSError: +32 32 | pass +33 33 | +34 34 | try: + +UP024_0.py:36:8: UP024 [*] Replace aliased errors with `OSError` + | +34 | try: +35 | pass +36 | except error: + | ^^^^^ UP024 +37 | pass + | + = help: Replace `error` with builtin `OSError` + +ℹ Fix +33 33 | +34 34 | try: +35 35 | pass +36 |-except error: + 36 |+except OSError: +37 37 | pass +38 38 | +39 39 | # Should NOT be in parentheses when replaced + +UP024_0.py:43:8: UP024 [*] Replace aliased errors with `OSError` + | +41 | try: +42 | pass +43 | except (IOError,): + | ^^^^^^^^^^ UP024 +44 | pass +45 | try: + | + = help: Replace with builtin `OSError` + +ℹ Fix +40 40 | +41 41 | try: +42 42 | pass +43 |-except (IOError,): + 43 |+except OSError: +44 44 | pass +45 45 | try: +46 46 | pass + +UP024_0.py:47:8: UP024 [*] Replace aliased errors with `OSError` + | +45 | try: +46 | pass +47 | except (mmap.error,): + | ^^^^^^^^^^^^^ UP024 +48 | pass +49 | try: + | + = help: Replace with builtin `OSError` + +ℹ Fix +44 44 | pass +45 45 | try: +46 46 | pass +47 |-except (mmap.error,): + 47 |+except OSError: +48 48 | pass +49 49 | try: +50 50 | pass + +UP024_0.py:51:8: UP024 [*] Replace aliased errors with `OSError` + | +49 | try: +50 | pass +51 | except (EnvironmentError, IOError, OSError, select.error): + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP024 +52 | pass + | + = help: Replace with builtin `OSError` + +ℹ Fix +48 48 | pass +49 49 | try: +50 50 | pass +51 |-except (EnvironmentError, IOError, OSError, select.error): + 51 |+except OSError: +52 52 | pass +53 53 | +54 54 | # Should be kept in parentheses (because multiple) + +UP024_0.py:58:8: UP024 [*] Replace aliased errors with `OSError` + | +56 | try: +57 | pass +58 | except (IOError, KeyError, OSError): + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP024 +59 | pass + | + = help: Replace with builtin `OSError` + +ℹ Fix +55 55 | +56 56 | try: +57 57 | pass +58 |-except (IOError, KeyError, OSError): + 58 |+except (KeyError, OSError): +59 59 | pass +60 60 | +61 61 | # First should change, second should not + +UP024_0.py:65:8: UP024 [*] Replace aliased errors with `OSError` + | +63 | try: +64 | pass +65 | except (IOError, error): + | ^^^^^^^^^^^^^^^^ UP024 +66 | pass +67 | # These should not change + | + = help: Replace with builtin `OSError` + +ℹ Fix +62 62 | from .mmap import error +63 63 | try: +64 64 | pass +65 |-except (IOError, error): + 65 |+except (OSError, error): +66 66 | pass +67 67 | # These should not change +68 68 | + +UP024_0.py:87:8: UP024 [*] Replace aliased errors with `OSError` + | +85 | try: +86 | pass +87 | except (mmap).error: + | ^^^^^^^^^^^^ UP024 +88 | pass + | + = help: Replace `mmap.error` with builtin `OSError` + +ℹ Fix +84 84 | pass +85 85 | try: +86 86 | pass +87 |-except (mmap).error: + 87 |+except OSError: +88 88 | pass +89 89 | +90 90 | try: + +UP024_0.py:105:11: UP024 [*] Replace aliased errors with `OSError` + | +103 | try: +104 | mac_address = get_primary_mac_address() +105 | except(IOError, OSError) as ex: + | ^^^^^^^^^^^^^^^^^^ UP024 +106 | msg = 'Unable to query URL to get Owner ID: {u}\n{e}'.format(u=owner_id_url, e=ex) + | + = help: Replace with builtin `OSError` + +ℹ Fix +102 102 | def get_owner_id_from_mac_address(): +103 103 | try: +104 104 | mac_address = get_primary_mac_address() +105 |- except(IOError, OSError) as ex: + 105 |+ except OSError as ex: +106 106 | msg = 'Unable to query URL to get Owner ID: {u}\n{e}'.format(u=owner_id_url, e=ex) + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_1.py.snap new file mode 100644 index 0000000000..b72dbccc24 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_1.py.snap @@ -0,0 +1,72 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP024_1.py:5:8: UP024 [*] Replace aliased errors with `OSError` + | +3 | try: +4 | pass +5 | except (OSError, mmap.error, IOError): + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP024 +6 | pass +7 | except (OSError, socket.error, KeyError): + | + = help: Replace with builtin `OSError` + +ℹ Fix +2 2 | +3 3 | try: +4 4 | pass +5 |-except (OSError, mmap.error, IOError): + 5 |+except OSError: +6 6 | pass +7 7 | except (OSError, socket.error, KeyError): +8 8 | pass + +UP024_1.py:7:8: UP024 [*] Replace aliased errors with `OSError` + | +5 | except (OSError, mmap.error, IOError): +6 | pass +7 | except (OSError, socket.error, KeyError): + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP024 +8 | pass + | + = help: Replace with builtin `OSError` + +ℹ Fix +4 4 | pass +5 5 | except (OSError, mmap.error, IOError): +6 6 | pass +7 |-except (OSError, socket.error, KeyError): + 7 |+except (OSError, KeyError): +8 8 | pass +9 9 | +10 10 | try: + +UP024_1.py:12:8: UP024 [*] Replace aliased errors with `OSError` + | +10 | try: +11 | pass +12 | except ( + | ________^ +13 | | OSError, +14 | | select.error, +15 | | IOError, +16 | | ): + | |_^ UP024 +17 | pass + | + = help: Replace with builtin `OSError` + +ℹ Fix +9 9 | +10 10 | try: +11 11 | pass +12 |-except ( +13 |- OSError, +14 |- select.error, +15 |- IOError, +16 |-): + 12 |+except OSError: +17 13 | pass + + 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 new file mode 100644 index 0000000000..27acf0fc06 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_2.py.snap @@ -0,0 +1,404 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP024_2.py:10:7: UP024 [*] Replace aliased errors with `OSError` + | + 8 | # Testing the modules + 9 | import socket, mmap, select +10 | raise socket.error + | ^^^^^^^^^^^^ UP024 +11 | raise mmap.error +12 | raise select.error + | + = help: Replace `socket.error` with builtin `OSError` + +ℹ Fix +7 7 | +8 8 | # Testing the modules +9 9 | import socket, mmap, select +10 |-raise socket.error + 10 |+raise OSError +11 11 | raise mmap.error +12 12 | raise select.error +13 13 | + +UP024_2.py:11:7: UP024 [*] Replace aliased errors with `OSError` + | + 9 | import socket, mmap, select +10 | raise socket.error +11 | raise mmap.error + | ^^^^^^^^^^ UP024 +12 | raise select.error + | + = help: Replace `mmap.error` with builtin `OSError` + +ℹ Fix +8 8 | # Testing the modules +9 9 | import socket, mmap, select +10 10 | raise socket.error +11 |-raise mmap.error + 11 |+raise OSError +12 12 | raise select.error +13 13 | +14 14 | raise socket.error() + +UP024_2.py:12:7: UP024 [*] Replace aliased errors with `OSError` + | +10 | raise socket.error +11 | raise mmap.error +12 | raise select.error + | ^^^^^^^^^^^^ UP024 +13 | +14 | raise socket.error() + | + = help: Replace `select.error` with builtin `OSError` + +ℹ Fix +9 9 | import socket, mmap, select +10 10 | raise socket.error +11 11 | raise mmap.error +12 |-raise select.error + 12 |+raise OSError +13 13 | +14 14 | raise socket.error() +15 15 | raise mmap.error(1) + +UP024_2.py:14:7: UP024 [*] Replace aliased errors with `OSError` + | +12 | raise select.error +13 | +14 | raise socket.error() + | ^^^^^^^^^^^^ UP024 +15 | raise mmap.error(1) +16 | raise select.error(1, 2) + | + = help: Replace `socket.error` with builtin `OSError` + +ℹ Fix +11 11 | raise mmap.error +12 12 | raise select.error +13 13 | +14 |-raise socket.error() + 14 |+raise OSError() +15 15 | raise mmap.error(1) +16 16 | raise select.error(1, 2) +17 17 | + +UP024_2.py:15:7: UP024 [*] Replace aliased errors with `OSError` + | +14 | raise socket.error() +15 | raise mmap.error(1) + | ^^^^^^^^^^ UP024 +16 | raise select.error(1, 2) + | + = help: Replace `mmap.error` with builtin `OSError` + +ℹ Fix +12 12 | raise select.error +13 13 | +14 14 | raise socket.error() +15 |-raise mmap.error(1) + 15 |+raise OSError(1) +16 16 | raise select.error(1, 2) +17 17 | +18 18 | raise socket.error( + +UP024_2.py:16:7: UP024 [*] Replace aliased errors with `OSError` + | +14 | raise socket.error() +15 | raise mmap.error(1) +16 | raise select.error(1, 2) + | ^^^^^^^^^^^^ UP024 +17 | +18 | raise socket.error( + | + = help: Replace `select.error` with builtin `OSError` + +ℹ Fix +13 13 | +14 14 | raise socket.error() +15 15 | raise mmap.error(1) +16 |-raise select.error(1, 2) + 16 |+raise OSError(1, 2) +17 17 | +18 18 | raise socket.error( +19 19 | 1, + +UP024_2.py:18:7: UP024 [*] Replace aliased errors with `OSError` + | +16 | raise select.error(1, 2) +17 | +18 | raise socket.error( + | ^^^^^^^^^^^^ UP024 +19 | 1, +20 | 2, + | + = help: Replace `socket.error` with builtin `OSError` + +ℹ Fix +15 15 | raise mmap.error(1) +16 16 | raise select.error(1, 2) +17 17 | +18 |-raise socket.error( + 18 |+raise OSError( +19 19 | 1, +20 20 | 2, +21 21 | 3, + +UP024_2.py:25:7: UP024 [*] Replace aliased errors with `OSError` + | +24 | from mmap import error +25 | raise error + | ^^^^^ UP024 +26 | +27 | from socket import error + | + = help: Replace `error` with builtin `OSError` + +ℹ Fix +22 22 | ) +23 23 | +24 24 | from mmap import error +25 |-raise error + 25 |+raise OSError +26 26 | +27 27 | from socket import error +28 28 | raise error(1) + +UP024_2.py:28:7: UP024 [*] Replace aliased errors with `OSError` + | +27 | from socket import error +28 | raise error(1) + | ^^^^^ UP024 +29 | +30 | from select import error + | + = help: Replace `error` with builtin `OSError` + +ℹ Fix +25 25 | raise error +26 26 | +27 27 | from socket import error +28 |-raise error(1) + 28 |+raise OSError(1) +29 29 | +30 30 | from select import error +31 31 | raise error(1, 2) + +UP024_2.py:31:7: UP024 [*] Replace aliased errors with `OSError` + | +30 | from select import error +31 | raise error(1, 2) + | ^^^^^ UP024 +32 | +33 | # Testing the names + | + = help: Replace `error` with builtin `OSError` + +ℹ Fix +28 28 | raise error(1) +29 29 | +30 30 | from select import error +31 |-raise error(1, 2) + 31 |+raise OSError(1, 2) +32 32 | +33 33 | # Testing the names +34 34 | raise EnvironmentError + +UP024_2.py:34:7: UP024 [*] Replace aliased errors with `OSError` + | +33 | # Testing the names +34 | raise EnvironmentError + | ^^^^^^^^^^^^^^^^ UP024 +35 | raise IOError +36 | raise WindowsError + | + = help: Replace `EnvironmentError` with builtin `OSError` + +ℹ Fix +31 31 | raise error(1, 2) +32 32 | +33 33 | # Testing the names +34 |-raise EnvironmentError + 34 |+raise OSError +35 35 | raise IOError +36 36 | raise WindowsError +37 37 | + +UP024_2.py:35:7: UP024 [*] Replace aliased errors with `OSError` + | +33 | # Testing the names +34 | raise EnvironmentError +35 | raise IOError + | ^^^^^^^ UP024 +36 | raise WindowsError + | + = help: Replace `IOError` with builtin `OSError` + +ℹ Fix +32 32 | +33 33 | # Testing the names +34 34 | raise EnvironmentError +35 |-raise IOError + 35 |+raise OSError +36 36 | raise WindowsError +37 37 | +38 38 | raise EnvironmentError() + +UP024_2.py:36:7: UP024 [*] Replace aliased errors with `OSError` + | +34 | raise EnvironmentError +35 | raise IOError +36 | raise WindowsError + | ^^^^^^^^^^^^ UP024 +37 | +38 | raise EnvironmentError() + | + = help: Replace `WindowsError` with builtin `OSError` + +ℹ Fix +33 33 | # Testing the names +34 34 | raise EnvironmentError +35 35 | raise IOError +36 |-raise WindowsError + 36 |+raise OSError +37 37 | +38 38 | raise EnvironmentError() +39 39 | raise IOError(1) + +UP024_2.py:38:7: UP024 [*] Replace aliased errors with `OSError` + | +36 | raise WindowsError +37 | +38 | raise EnvironmentError() + | ^^^^^^^^^^^^^^^^ UP024 +39 | raise IOError(1) +40 | raise WindowsError(1, 2) + | + = help: Replace `EnvironmentError` with builtin `OSError` + +ℹ Fix +35 35 | raise IOError +36 36 | raise WindowsError +37 37 | +38 |-raise EnvironmentError() + 38 |+raise OSError() +39 39 | raise IOError(1) +40 40 | raise WindowsError(1, 2) +41 41 | + +UP024_2.py:39:7: UP024 [*] Replace aliased errors with `OSError` + | +38 | raise EnvironmentError() +39 | raise IOError(1) + | ^^^^^^^ UP024 +40 | raise WindowsError(1, 2) + | + = help: Replace `IOError` with builtin `OSError` + +ℹ Fix +36 36 | raise WindowsError +37 37 | +38 38 | raise EnvironmentError() +39 |-raise IOError(1) + 39 |+raise OSError(1) +40 40 | raise WindowsError(1, 2) +41 41 | +42 42 | raise EnvironmentError( + +UP024_2.py:40:7: UP024 [*] Replace aliased errors with `OSError` + | +38 | raise EnvironmentError() +39 | raise IOError(1) +40 | raise WindowsError(1, 2) + | ^^^^^^^^^^^^ UP024 +41 | +42 | raise EnvironmentError( + | + = help: Replace `WindowsError` with builtin `OSError` + +ℹ Fix +37 37 | +38 38 | raise EnvironmentError() +39 39 | raise IOError(1) +40 |-raise WindowsError(1, 2) + 40 |+raise OSError(1, 2) +41 41 | +42 42 | raise EnvironmentError( +43 43 | 1, + +UP024_2.py:42:7: UP024 [*] Replace aliased errors with `OSError` + | +40 | raise WindowsError(1, 2) +41 | +42 | raise EnvironmentError( + | ^^^^^^^^^^^^^^^^ UP024 +43 | 1, +44 | 2, + | + = help: Replace `EnvironmentError` with builtin `OSError` + +ℹ Fix +39 39 | raise IOError(1) +40 40 | raise WindowsError(1, 2) +41 41 | +42 |-raise EnvironmentError( + 42 |+raise OSError( +43 43 | 1, +44 44 | 2, +45 45 | 3, + +UP024_2.py:48:7: UP024 [*] Replace aliased errors with `OSError` + | +46 | ) +47 | +48 | raise WindowsError + | ^^^^^^^^^^^^ UP024 +49 | raise EnvironmentError(1) +50 | raise IOError(1, 2) + | + = help: Replace `WindowsError` with builtin `OSError` + +ℹ Fix +45 45 | 3, +46 46 | ) +47 47 | +48 |-raise WindowsError + 48 |+raise OSError +49 49 | raise EnvironmentError(1) +50 50 | raise IOError(1, 2) + +UP024_2.py:49:7: UP024 [*] Replace aliased errors with `OSError` + | +48 | raise WindowsError +49 | raise EnvironmentError(1) + | ^^^^^^^^^^^^^^^^ UP024 +50 | raise IOError(1, 2) + | + = help: Replace `EnvironmentError` with builtin `OSError` + +ℹ Fix +46 46 | ) +47 47 | +48 48 | raise WindowsError +49 |-raise EnvironmentError(1) + 49 |+raise OSError(1) +50 50 | raise IOError(1, 2) + +UP024_2.py:50:7: UP024 [*] Replace aliased errors with `OSError` + | +48 | raise WindowsError +49 | raise EnvironmentError(1) +50 | raise IOError(1, 2) + | ^^^^^^^ UP024 + | + = help: Replace `IOError` with builtin `OSError` + +ℹ Fix +47 47 | +48 48 | raise WindowsError +49 49 | raise EnvironmentError(1) +50 |-raise IOError(1, 2) + 50 |+raise OSError(1, 2) + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_3.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_3.py.snap new file mode 100644 index 0000000000..2bacb5d540 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_3.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_4.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_4.py.snap new file mode 100644 index 0000000000..59a38ba78a --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP024_4.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP024_4.py:9:8: UP024 [*] Replace aliased errors with `OSError` + | + 7 | conn.ensure_connection(max_retries=2) + 8 | conn._close() + 9 | except (socket.error, exceptions.OperationalError): + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP024 +10 | return HttpResponseServerError("cache: cannot connect to broker.") + | + = help: Replace with builtin `OSError` + +ℹ Fix +6 6 | conn = Connection(settings.CELERY_BROKER_URL) +7 7 | conn.ensure_connection(max_retries=2) +8 8 | conn._close() +9 |-except (socket.error, exceptions.OperationalError): + 9 |+except (OSError, exceptions.OperationalError): +10 10 | return HttpResponseServerError("cache: cannot connect to broker.") + + 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 new file mode 100644 index 0000000000..e5e4024876 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP025.py.snap @@ -0,0 +1,251 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP025.py:2:5: UP025 [*] Remove unicode literals from strings + | +1 | # These should change +2 | x = u"Hello" + | ^^^^^^^^ UP025 +3 | +4 | u'world' + | + = help: Remove unicode prefix + +ℹ Fix +1 1 | # These should change +2 |-x = u"Hello" + 2 |+x = "Hello" +3 3 | +4 4 | u'world' +5 5 | + +UP025.py:4:1: UP025 [*] Remove unicode literals from strings + | +2 | x = u"Hello" +3 | +4 | u'world' + | ^^^^^^^^ UP025 +5 | +6 | print(u"Hello") + | + = help: Remove unicode prefix + +ℹ Fix +1 1 | # These should change +2 2 | x = u"Hello" +3 3 | +4 |-u'world' + 4 |+'world' +5 5 | +6 6 | print(u"Hello") +7 7 | + +UP025.py:6:7: UP025 [*] Remove unicode literals from strings + | +4 | u'world' +5 | +6 | print(u"Hello") + | ^^^^^^^^ UP025 +7 | +8 | print(u'world') + | + = help: Remove unicode prefix + +ℹ Fix +3 3 | +4 4 | u'world' +5 5 | +6 |-print(u"Hello") + 6 |+print("Hello") +7 7 | +8 8 | print(u'world') +9 9 | + +UP025.py:8:7: UP025 [*] Remove unicode literals from strings + | + 6 | print(u"Hello") + 7 | + 8 | print(u'world') + | ^^^^^^^^ UP025 + 9 | +10 | import foo + | + = help: Remove unicode prefix + +ℹ Fix +5 5 | +6 6 | print(u"Hello") +7 7 | +8 |-print(u'world') + 8 |+print('world') +9 9 | +10 10 | import foo +11 11 | + +UP025.py:12:5: UP025 [*] Remove unicode literals from strings + | +10 | import foo +11 | +12 | foo(u"Hello", U"world", a=u"Hello", b=u"world") + | ^^^^^^^^ UP025 +13 | +14 | # These should stay quoted they way they are + | + = help: Remove unicode prefix + +ℹ Fix +9 9 | +10 10 | import foo +11 11 | +12 |-foo(u"Hello", U"world", a=u"Hello", b=u"world") + 12 |+foo("Hello", U"world", a=u"Hello", b=u"world") +13 13 | +14 14 | # These should stay quoted they way they are +15 15 | + +UP025.py:12:15: UP025 [*] Remove unicode literals from strings + | +10 | import foo +11 | +12 | foo(u"Hello", U"world", a=u"Hello", b=u"world") + | ^^^^^^^^ UP025 +13 | +14 | # These should stay quoted they way they are + | + = help: Remove unicode prefix + +ℹ Fix +9 9 | +10 10 | import foo +11 11 | +12 |-foo(u"Hello", U"world", a=u"Hello", b=u"world") + 12 |+foo(u"Hello", "world", a=u"Hello", b=u"world") +13 13 | +14 14 | # These should stay quoted they way they are +15 15 | + +UP025.py:12:27: UP025 [*] Remove unicode literals from strings + | +10 | import foo +11 | +12 | foo(u"Hello", U"world", a=u"Hello", b=u"world") + | ^^^^^^^^ UP025 +13 | +14 | # These should stay quoted they way they are + | + = help: Remove unicode prefix + +ℹ Fix +9 9 | +10 10 | import foo +11 11 | +12 |-foo(u"Hello", U"world", a=u"Hello", b=u"world") + 12 |+foo(u"Hello", U"world", a="Hello", b=u"world") +13 13 | +14 14 | # These should stay quoted they way they are +15 15 | + +UP025.py:12:39: UP025 [*] Remove unicode literals from strings + | +10 | import foo +11 | +12 | foo(u"Hello", U"world", a=u"Hello", b=u"world") + | ^^^^^^^^ UP025 +13 | +14 | # These should stay quoted they way they are + | + = help: Remove unicode prefix + +ℹ Fix +9 9 | +10 10 | import foo +11 11 | +12 |-foo(u"Hello", U"world", a=u"Hello", b=u"world") + 12 |+foo(u"Hello", U"world", a=u"Hello", b="world") +13 13 | +14 14 | # These should stay quoted they way they are +15 15 | + +UP025.py:16:5: UP025 [*] Remove unicode literals from strings + | +14 | # These should stay quoted they way they are +15 | +16 | x = u'hello' + | ^^^^^^^^ UP025 +17 | x = u"""hello""" +18 | x = u'''hello''' + | + = help: Remove unicode prefix + +ℹ Fix +13 13 | +14 14 | # These should stay quoted they way they are +15 15 | +16 |-x = u'hello' + 16 |+x = 'hello' +17 17 | x = u"""hello""" +18 18 | x = u'''hello''' +19 19 | x = u'Hello "World"' + +UP025.py:17:5: UP025 [*] Remove unicode literals from strings + | +16 | x = u'hello' +17 | x = u"""hello""" + | ^^^^^^^^^^^^ UP025 +18 | x = u'''hello''' +19 | x = u'Hello "World"' + | + = help: Remove unicode prefix + +ℹ Fix +14 14 | # These should stay quoted they way they are +15 15 | +16 16 | x = u'hello' +17 |-x = u"""hello""" + 17 |+x = """hello""" +18 18 | x = u'''hello''' +19 19 | x = u'Hello "World"' +20 20 | + +UP025.py:18:5: UP025 [*] Remove unicode literals from strings + | +16 | x = u'hello' +17 | x = u"""hello""" +18 | x = u'''hello''' + | ^^^^^^^^^^^^ UP025 +19 | x = u'Hello "World"' + | + = help: Remove unicode prefix + +ℹ Fix +15 15 | +16 16 | x = u'hello' +17 17 | x = u"""hello""" +18 |-x = u'''hello''' + 18 |+x = '''hello''' +19 19 | x = u'Hello "World"' +20 20 | +21 21 | # These should not change + +UP025.py:19:5: UP025 [*] Remove unicode literals from strings + | +17 | x = u"""hello""" +18 | x = u'''hello''' +19 | x = u'Hello "World"' + | ^^^^^^^^^^^^^^^^ UP025 +20 | +21 | # These should not change + | + = help: Remove unicode prefix + +ℹ Fix +16 16 | x = u'hello' +17 17 | x = u"""hello""" +18 18 | x = u'''hello''' +19 |-x = u'Hello "World"' + 19 |+x = 'Hello "World"' +20 20 | +21 21 | # These should not change +22 22 | u = "Hello" + + 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 new file mode 100644 index 0000000000..fb8ecac7ec --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP026.py.snap @@ -0,0 +1,607 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP026.py:3:12: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +1 | # Error (`from unittest import mock`) +2 | if True: +3 | import mock + | ^^^^ UP026 +4 | +5 | # Error (`from unittest import mock`) + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +1 1 | # Error (`from unittest import mock`) +2 2 | if True: +3 |- import mock + 3 |+ from unittest import mock +4 4 | +5 5 | # Error (`from unittest import mock`) +6 6 | if True: + +UP026.py:7:12: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +5 | # Error (`from unittest import mock`) +6 | if True: +7 | import mock, sys + | ^^^^ UP026 +8 | +9 | # Error (`from unittest.mock import *`) + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +4 4 | +5 5 | # Error (`from unittest import mock`) +6 6 | if True: +7 |- import mock, sys + 7 |+ import sys + 8 |+ from unittest import mock +8 9 | +9 10 | # Error (`from unittest.mock import *`) +10 11 | if True: + +UP026.py:11:5: UP026 [*] `mock` is deprecated, use `unittest.mock` + | + 9 | # Error (`from unittest.mock import *`) +10 | if True: +11 | from mock import * + | ^^^^^^^^^^^^^^^^^^ UP026 +12 | +13 | # Error (`from unittest import mock`) + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +8 8 | +9 9 | # Error (`from unittest.mock import *`) +10 10 | if True: +11 |- from mock import * + 11 |+ from unittest.mock import * +12 12 | +13 13 | # Error (`from unittest import mock`) +14 14 | import mock.mock + +UP026.py:14:8: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +13 | # Error (`from unittest import mock`) +14 | import mock.mock + | ^^^^^^^^^ UP026 +15 | +16 | # Error (`from unittest import mock`) + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +11 11 | from mock import * +12 12 | +13 13 | # Error (`from unittest import mock`) +14 |-import mock.mock + 14 |+from unittest import mock +15 15 | +16 16 | # Error (`from unittest import mock`) +17 17 | import contextlib, mock, sys + +UP026.py:17:20: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +16 | # Error (`from unittest import mock`) +17 | import contextlib, mock, sys + | ^^^^ UP026 +18 | +19 | # Error (`from unittest import mock`) + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +14 14 | import mock.mock +15 15 | +16 16 | # Error (`from unittest import mock`) +17 |-import contextlib, mock, sys + 17 |+import contextlib, sys + 18 |+from unittest import mock +18 19 | +19 20 | # Error (`from unittest import mock`) +20 21 | import mock, sys + +UP026.py:20:8: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +19 | # Error (`from unittest import mock`) +20 | import mock, sys + | ^^^^ UP026 +21 | x = "This code should be preserved one line below the mock" + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +17 17 | import contextlib, mock, sys +18 18 | +19 19 | # Error (`from unittest import mock`) +20 |-import mock, sys + 20 |+import sys + 21 |+from unittest import mock +21 22 | x = "This code should be preserved one line below the mock" +22 23 | +23 24 | # Error (`from unittest import mock`) + +UP026.py:24:1: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +23 | # Error (`from unittest import mock`) +24 | from mock import mock + | ^^^^^^^^^^^^^^^^^^^^^ UP026 +25 | +26 | # Error (keep trailing comma) + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +21 21 | x = "This code should be preserved one line below the mock" +22 22 | +23 23 | # Error (`from unittest import mock`) +24 |-from mock import mock + 24 |+from unittest import mock +25 25 | +26 26 | # Error (keep trailing comma) +27 27 | from mock import ( + +UP026.py:27:1: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +26 | # Error (keep trailing comma) +27 | / from mock import ( +28 | | mock, +29 | | a, +30 | | b, +31 | | c, +32 | | ) + | |_^ UP026 +33 | from mock import ( +34 | a, + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +24 24 | from mock import mock +25 25 | +26 26 | # Error (keep trailing comma) +27 |-from mock import ( +28 |- mock, + 27 |+from unittest.mock import ( +29 28 | a, +30 29 | b, +31 30 | c, +32 31 | ) + 32 |+from unittest import mock +33 33 | from mock import ( +34 34 | a, +35 35 | b, + +UP026.py:33:1: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +31 | c, +32 | ) +33 | / from mock import ( +34 | | a, +35 | | b, +36 | | c, +37 | | mock, +38 | | ) + | |_^ UP026 +39 | +40 | # Error (avoid trailing comma) + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +30 30 | b, +31 31 | c, +32 32 | ) +33 |-from mock import ( + 33 |+from unittest.mock import ( +34 34 | a, +35 35 | b, +36 36 | c, +37 |- mock, +38 37 | ) + 38 |+from unittest import mock +39 39 | +40 40 | # Error (avoid trailing comma) +41 41 | from mock import ( + +UP026.py:41:1: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +40 | # Error (avoid trailing comma) +41 | / from mock import ( +42 | | mock, +43 | | a, +44 | | b, +45 | | c +46 | | ) + | |_^ UP026 +47 | from mock import ( +48 | a, + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +38 38 | ) +39 39 | +40 40 | # Error (avoid trailing comma) +41 |-from mock import ( +42 |- mock, + 41 |+from unittest.mock import ( +43 42 | a, +44 43 | b, +45 44 | c +46 45 | ) + 46 |+from unittest import mock +47 47 | from mock import ( +48 48 | a, +49 49 | b, + +UP026.py:47:1: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +45 | c +46 | ) +47 | / from mock import ( +48 | | a, +49 | | b, +50 | | c, +51 | | mock +52 | | ) + | |_^ UP026 +53 | from mock import mock, a, b, c +54 | from mock import a, b, c, mock + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +44 44 | b, +45 45 | c +46 46 | ) +47 |-from mock import ( + 47 |+from unittest.mock import ( +48 48 | a, +49 49 | b, +50 |- c, +51 |- mock + 50 |+ c +52 51 | ) + 52 |+from unittest import mock +53 53 | from mock import mock, a, b, c +54 54 | from mock import a, b, c, mock +55 55 | + +UP026.py:53:1: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +51 | mock +52 | ) +53 | from mock import mock, a, b, c + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP026 +54 | from mock import a, b, c, mock + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +50 50 | c, +51 51 | mock +52 52 | ) +53 |-from mock import mock, a, b, c + 53 |+from unittest.mock import a, b, c + 54 |+from unittest import mock +54 55 | from mock import a, b, c, mock +55 56 | +56 57 | if True: + +UP026.py:54:1: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +52 | ) +53 | from mock import mock, a, b, c +54 | from mock import a, b, c, mock + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP026 +55 | +56 | if True: + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +51 51 | mock +52 52 | ) +53 53 | from mock import mock, a, b, c +54 |-from mock import a, b, c, mock + 54 |+from unittest.mock import a, b, c + 55 |+from unittest import mock +55 56 | +56 57 | if True: +57 58 | if False: + +UP026.py:58:9: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +56 | if True: +57 | if False: +58 | from mock import ( + | _________^ +59 | | mock, +60 | | a, +61 | | b, +62 | | c +63 | | ) + | |_________^ UP026 +64 | +65 | # OK + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +55 55 | +56 56 | if True: +57 57 | if False: +58 |- from mock import ( +59 |- mock, + 58 |+ from unittest.mock import ( +60 59 | a, +61 60 | b, +62 61 | c +63 62 | ) + 63 |+ from unittest import mock +64 64 | +65 65 | # OK +66 66 | import os, io + +UP026.py:69:8: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +68 | # Error (`from unittest import mock`) +69 | import mock, mock + | ^^^^ UP026 +70 | +71 | # Error (`from unittest import mock as foo`) + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +66 66 | import os, io +67 67 | +68 68 | # Error (`from unittest import mock`) +69 |-import mock, mock + 69 |+from unittest import mock + 70 |+from unittest import mock +70 71 | +71 72 | # Error (`from unittest import mock as foo`) +72 73 | import mock as foo + +UP026.py:69:14: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +68 | # Error (`from unittest import mock`) +69 | import mock, mock + | ^^^^ UP026 +70 | +71 | # Error (`from unittest import mock as foo`) + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +66 66 | import os, io +67 67 | +68 68 | # Error (`from unittest import mock`) +69 |-import mock, mock + 69 |+from unittest import mock + 70 |+from unittest import mock +70 71 | +71 72 | # Error (`from unittest import mock as foo`) +72 73 | import mock as foo + +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 | +74 | # Error (`from unittest import mock as foo`) + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +69 69 | import mock, mock +70 70 | +71 71 | # Error (`from unittest import mock as foo`) +72 |-import mock as foo + 72 |+from unittest import mock as foo +73 73 | +74 74 | # Error (`from unittest import mock as foo`) +75 75 | from mock import mock as foo + +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 | +77 | if True: + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +72 72 | import mock as foo +73 73 | +74 74 | # Error (`from unittest import mock as foo`) +75 |-from mock import mock as foo + 75 |+from unittest import mock as foo +76 76 | +77 77 | if True: +78 78 | # This should yield multiple, aliased imports. + +UP026.py:79:12: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +77 | if True: +78 | # This should yield multiple, aliased imports. +79 | import mock as foo, mock as bar, mock + | ^^^^^^^^^^^ UP026 +80 | +81 | # This should yield multiple, aliased imports, and preserve `os`. + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +76 76 | +77 77 | if True: +78 78 | # This should yield multiple, aliased imports. +79 |- import mock as foo, mock as bar, mock + 79 |+ from unittest import mock as foo + 80 |+ from unittest import mock as bar + 81 |+ from unittest import mock +80 82 | +81 83 | # This should yield multiple, aliased imports, and preserve `os`. +82 84 | import mock as foo, mock as bar, mock, os + +UP026.py:79:25: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +77 | if True: +78 | # This should yield multiple, aliased imports. +79 | import mock as foo, mock as bar, mock + | ^^^^^^^^^^^ UP026 +80 | +81 | # This should yield multiple, aliased imports, and preserve `os`. + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +76 76 | +77 77 | if True: +78 78 | # This should yield multiple, aliased imports. +79 |- import mock as foo, mock as bar, mock + 79 |+ from unittest import mock as foo + 80 |+ from unittest import mock as bar + 81 |+ from unittest import mock +80 82 | +81 83 | # This should yield multiple, aliased imports, and preserve `os`. +82 84 | import mock as foo, mock as bar, mock, os + +UP026.py:79:38: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +77 | if True: +78 | # This should yield multiple, aliased imports. +79 | import mock as foo, mock as bar, mock + | ^^^^ UP026 +80 | +81 | # This should yield multiple, aliased imports, and preserve `os`. + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +76 76 | +77 77 | if True: +78 78 | # This should yield multiple, aliased imports. +79 |- import mock as foo, mock as bar, mock + 79 |+ from unittest import mock as foo + 80 |+ from unittest import mock as bar + 81 |+ from unittest import mock +80 82 | +81 83 | # This should yield multiple, aliased imports, and preserve `os`. +82 84 | import mock as foo, mock as bar, mock, os + +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 | +84 | if True: + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +79 79 | import mock as foo, mock as bar, mock +80 80 | +81 81 | # This should yield multiple, aliased imports, and preserve `os`. +82 |- import mock as foo, mock as bar, mock, os + 82 |+ import os + 83 |+ from unittest import mock as foo + 84 |+ from unittest import mock as bar + 85 |+ from unittest import mock +83 86 | +84 87 | if True: +85 88 | # This should yield multiple, aliased imports. + +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 | +84 | if True: + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +79 79 | import mock as foo, mock as bar, mock +80 80 | +81 81 | # This should yield multiple, aliased imports, and preserve `os`. +82 |- import mock as foo, mock as bar, mock, os + 82 |+ import os + 83 |+ from unittest import mock as foo + 84 |+ from unittest import mock as bar + 85 |+ from unittest import mock +83 86 | +84 87 | if True: +85 88 | # This should yield multiple, aliased imports. + +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 | +84 | if True: + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +79 79 | import mock as foo, mock as bar, mock +80 80 | +81 81 | # This should yield multiple, aliased imports, and preserve `os`. +82 |- import mock as foo, mock as bar, mock, os + 82 |+ import os + 83 |+ from unittest import mock as foo + 84 |+ from unittest import mock as bar + 85 |+ from unittest import mock +83 86 | +84 87 | if True: +85 88 | # This should yield multiple, aliased imports. + +UP026.py:86:5: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +84 | if True: +85 | # This should yield multiple, aliased imports. +86 | from mock import mock as foo, mock as bar, mock + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP026 + | + = help: Import from `unittest.mock` instead + +ℹ Suggested fix +83 83 | +84 84 | if True: +85 85 | # This should yield multiple, aliased imports. +86 |- from mock import mock as foo, mock as bar, mock + 86 |+ from unittest import mock as foo + 87 |+ from unittest import mock as bar + 88 |+ from unittest import mock +87 89 | +88 90 | +89 91 | # OK. + +UP026.py:93:5: UP026 [*] `mock` is deprecated, use `unittest.mock` + | +92 | # Error (`mock.Mock()`). +93 | x = mock.mock.Mock() + | ^^^^^^^^^ UP026 + | + = help: Replace `mock.mock` with `mock` + +ℹ Suggested fix +90 90 | x = mock.Mock() +91 91 | +92 92 | # Error (`mock.Mock()`). +93 |-x = mock.mock.Mock() + 93 |+x = mock.Mock() + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP027.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP027.py.snap new file mode 100644 index 0000000000..db56ed7f7d --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP027.py.snap @@ -0,0 +1,114 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP027.py:2:17: UP027 [*] Replace unpacked list comprehension with a generator expression + | +1 | # Should change +2 | foo, bar, baz = [fn(x) for x in items] + | ^^^^^^^^^^^^^^^^^^^^^^ UP027 +3 | +4 | foo, bar, baz =[fn(x) for x in items] + | + = help: Replace with generator expression + +ℹ Suggested fix +1 1 | # Should change +2 |-foo, bar, baz = [fn(x) for x in items] + 2 |+foo, bar, baz = (fn(x) for x in items) +3 3 | +4 4 | foo, bar, baz =[fn(x) for x in items] +5 5 | + +UP027.py:4:16: UP027 [*] Replace unpacked list comprehension with a generator expression + | +2 | foo, bar, baz = [fn(x) for x in items] +3 | +4 | foo, bar, baz =[fn(x) for x in items] + | ^^^^^^^^^^^^^^^^^^^^^^ UP027 +5 | +6 | foo, bar, baz = [fn(x) for x in items] + | + = help: Replace with generator expression + +ℹ Suggested fix +1 1 | # Should change +2 2 | foo, bar, baz = [fn(x) for x in items] +3 3 | +4 |-foo, bar, baz =[fn(x) for x in items] + 4 |+foo, bar, baz =(fn(x) for x in items) +5 5 | +6 6 | foo, bar, baz = [fn(x) for x in items] +7 7 | + +UP027.py:6:26: UP027 [*] Replace unpacked list comprehension with a generator expression + | +4 | foo, bar, baz =[fn(x) for x in items] +5 | +6 | foo, bar, baz = [fn(x) for x in items] + | ^^^^^^^^^^^^^^^^^^^^^^ UP027 +7 | +8 | foo, bar, baz = [[i for i in fn(x)] for x in items] + | + = help: Replace with generator expression + +ℹ Suggested fix +3 3 | +4 4 | foo, bar, baz =[fn(x) for x in items] +5 5 | +6 |-foo, bar, baz = [fn(x) for x in items] + 6 |+foo, bar, baz = (fn(x) for x in items) +7 7 | +8 8 | foo, bar, baz = [[i for i in fn(x)] for x in items] +9 9 | + +UP027.py:8:17: UP027 [*] Replace unpacked list comprehension with a generator expression + | + 6 | foo, bar, baz = [fn(x) for x in items] + 7 | + 8 | foo, bar, baz = [[i for i in fn(x)] for x in items] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP027 + 9 | +10 | foo, bar, baz = [ + | + = help: Replace with generator expression + +ℹ Suggested fix +5 5 | +6 6 | foo, bar, baz = [fn(x) for x in items] +7 7 | +8 |-foo, bar, baz = [[i for i in fn(x)] for x in items] + 8 |+foo, bar, baz = ([i for i in fn(x)] for x in items) +9 9 | +10 10 | foo, bar, baz = [ +11 11 | fn(x) + +UP027.py:10:17: UP027 [*] Replace unpacked list comprehension with a generator expression + | + 8 | foo, bar, baz = [[i for i in fn(x)] for x in items] + 9 | +10 | foo, bar, baz = [ + | _________________^ +11 | | fn(x) +12 | | for x in items +13 | | ] + | |_^ UP027 +14 | +15 | # Should not change + | + = help: Replace with generator expression + +ℹ Suggested fix +7 7 | +8 8 | foo, bar, baz = [[i for i in fn(x)] for x in items] +9 9 | +10 |-foo, bar, baz = [ + 10 |+foo, bar, baz = ( +11 11 | fn(x) +12 12 | for x in items +13 |-] + 13 |+) +14 14 | +15 15 | # Should not change +16 16 | foo = [fn(x) for x in items] + + 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 new file mode 100644 index 0000000000..12c38221bf --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP028_0.py.snap @@ -0,0 +1,302 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP028_0.py:2:5: UP028 [*] Replace `yield` over `for` loop with `yield from` + | +1 | def f(): +2 | for x in y: + | _____^ +3 | | yield x + | |_______________^ UP028 + | + = help: Replace with `yield from` + +ℹ Suggested fix +1 1 | def f(): +2 |- for x in y: +3 |- yield x + 2 |+ yield from y +4 3 | +5 4 | +6 5 | def g(): + +UP028_0.py:7:5: UP028 [*] Replace `yield` over `for` loop with `yield from` + | +6 | def g(): +7 | for x, y in z: + | _____^ +8 | | yield (x, y) + | |____________________^ UP028 + | + = help: Replace with `yield from` + +ℹ Suggested fix +4 4 | +5 5 | +6 6 | def g(): +7 |- for x, y in z: +8 |- yield (x, y) + 7 |+ yield from z +9 8 | +10 9 | +11 10 | def h(): + +UP028_0.py:12:5: UP028 [*] Replace `yield` over `for` loop with `yield from` + | +11 | def h(): +12 | for x in [1, 2, 3]: + | _____^ +13 | | yield x + | |_______________^ UP028 + | + = help: Replace with `yield from` + +ℹ Suggested fix +9 9 | +10 10 | +11 11 | def h(): +12 |- for x in [1, 2, 3]: +13 |- yield x + 12 |+ yield from [1, 2, 3] +14 13 | +15 14 | +16 15 | def i(): + +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}: + | _____^ +18 | | yield x + | |_______________^ UP028 + | + = help: Replace with `yield from` + +ℹ Suggested fix +14 14 | +15 15 | +16 16 | def i(): +17 |- for x in {x for x in y}: +18 |- yield x + 17 |+ yield from {x for x in y} +19 18 | +20 19 | +21 20 | def j(): + +UP028_0.py:22:5: UP028 [*] Replace `yield` over `for` loop with `yield from` + | +21 | def j(): +22 | for x in (1, 2, 3): + | _____^ +23 | | yield x + | |_______________^ UP028 + | + = help: Replace with `yield from` + +ℹ Suggested fix +19 19 | +20 20 | +21 21 | def j(): +22 |- for x in (1, 2, 3): +23 |- yield x + 22 |+ yield from (1, 2, 3) +24 23 | +25 24 | +26 25 | def k(): + +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"}: + | _____^ +28 | | yield x, y + | |__________________^ UP028 + | + = help: Replace with `yield from` + +ℹ Suggested fix +24 24 | +25 25 | +26 26 | def k(): +27 |- for x, y in {3: "x", 6: "y"}: +28 |- yield x, y + 27 |+ yield from {3: "x", 6: "y"} +29 28 | +30 29 | +31 30 | def f(): # Comment one\n' + +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' + | _____^ +34 | | 3: "x", # Comment four\n' +35 | | # Comment five\n' +36 | | 6: "y", # Comment six\n' +37 | | }: # Comment seven\n' +38 | | # Comment eight\n' +39 | | yield x, y # Comment nine\n' + | |__________________^ UP028 +40 | # Comment ten', + | + = help: Replace with `yield from` + +ℹ Suggested fix +30 30 | +31 31 | def f(): # Comment one\n' +32 32 | # Comment two\n' +33 |- for x, y in { # Comment three\n' + 33 |+ yield from { # Comment three\n' +34 34 | 3: "x", # Comment four\n' +35 35 | # Comment five\n' +36 36 | 6: "y", # Comment six\n' +37 |- }: # Comment seven\n' +38 |- # Comment eight\n' +39 |- yield x, y # Comment nine\n' + 37 |+ } # Comment nine\n' +40 38 | # Comment ten', +41 39 | +42 40 | + +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"}]: + | _____^ +45 | | yield x, y + | |__________________^ UP028 + | + = help: Replace with `yield from` + +ℹ Suggested fix +41 41 | +42 42 | +43 43 | def f(): +44 |- for x, y in [{3: (3, [44, "long ss"]), 6: "y"}]: +45 |- yield x, y + 44 |+ yield from [{3: (3, [44, "long ss"]), 6: "y"}] +46 45 | +47 46 | +48 47 | def f(): + +UP028_0.py:49:5: UP028 [*] Replace `yield` over `for` loop with `yield from` + | +48 | def f(): +49 | for x, y in z(): + | _____^ +50 | | yield x, y + | |__________________^ UP028 +51 | +52 | def f(): + | + = help: Replace with `yield from` + +ℹ Suggested fix +46 46 | +47 47 | +48 48 | def f(): +49 |- for x, y in z(): +50 |- yield x, y + 49 |+ yield from z() +51 50 | +52 51 | def f(): +53 52 | def func(): + +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' + | _________^ +56 | | # Comment two\n' +57 | | yield x, y # Comment three\n' + | |______________________^ UP028 +58 | # Comment four\n' +59 | # Comment\n' + | + = help: Replace with `yield from` + +ℹ Suggested fix +52 52 | def f(): +53 53 | def func(): +54 54 | # This comment is preserved\n' +55 |- for x, y in z(): # Comment one\n' +56 |- # Comment two\n' +57 |- yield x, y # Comment three\n' + 55 |+ yield from z() # Comment three\n' +58 56 | # Comment four\n' +59 57 | # Comment\n' +60 58 | def g(): + +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: + | _____^ +68 | | yield z + | |_______________^ UP028 + | + = help: Replace with `yield from` + +ℹ Suggested fix +64 64 | def f(): +65 65 | for x in y: +66 66 | yield x +67 |- for z in x: +68 |- yield z + 67 |+ yield from x +69 68 | +70 69 | +71 70 | def f(): + +UP028_0.py:72:5: UP028 [*] Replace `yield` over `for` loop with `yield from` + | +71 | def f(): +72 | for x, y in z(): + | _____^ +73 | | yield x, y + | |__________________^ UP028 +74 | x = 1 + | + = help: Replace with `yield from` + +ℹ Suggested fix +69 69 | +70 70 | +71 71 | def f(): +72 |- for x, y in z(): +73 |- yield x, y + 72 |+ yield from z() +74 73 | x = 1 +75 74 | +76 75 | + +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 ( + | _____^ +80 | | TaggedText.from_file(args.input) +81 | | .markup(highlight=args.region) +82 | | ): +83 | | yield h + | |_______________^ UP028 + | + = help: Replace with `yield from` + +ℹ Suggested fix +76 76 | +77 77 | # Regression test for: https://github.com/astral-sh/ruff/issues/7103 +78 78 | def _serve_method(fn): +79 |- for h in ( + 79 |+ yield from ( +80 80 | TaggedText.from_file(args.input) +81 81 | .markup(highlight=args.region) +82 |- ): +83 |- yield h + 82 |+ ) + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP028_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP028_1.py.snap new file mode 100644 index 0000000000..2bacb5d540 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP028_1.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP029.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP029.py.snap new file mode 100644 index 0000000000..f094fbd50c --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP029.py.snap @@ -0,0 +1,78 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP029.py:1:1: UP029 [*] Unnecessary builtin import: `*` + | +1 | from builtins import * + | ^^^^^^^^^^^^^^^^^^^^^^ UP029 +2 | from builtins import ascii, bytes, compile +3 | from builtins import str as _str + | + = help: Remove unnecessary builtin import + +ℹ Suggested fix +1 |-from builtins import * +2 1 | from builtins import ascii, bytes, compile +3 2 | from builtins import str as _str +4 3 | from six.moves import filter, zip, zip_longest + +UP029.py:2:1: UP029 [*] Unnecessary builtin imports: `ascii`, `bytes` + | +1 | from builtins import * +2 | from builtins import ascii, bytes, compile + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP029 +3 | from builtins import str as _str +4 | from six.moves import filter, zip, zip_longest + | + = help: Remove unnecessary builtin import + +ℹ Suggested fix +1 1 | from builtins import * +2 |-from builtins import ascii, bytes, compile + 2 |+from builtins import compile +3 3 | from builtins import str as _str +4 4 | from six.moves import filter, zip, zip_longest +5 5 | from io import open + +UP029.py:4:1: UP029 [*] Unnecessary builtin imports: `filter`, `zip` + | +2 | from builtins import ascii, bytes, compile +3 | from builtins import str as _str +4 | from six.moves import filter, zip, zip_longest + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP029 +5 | from io import open +6 | import io + | + = help: Remove unnecessary builtin import + +ℹ Suggested fix +1 1 | from builtins import * +2 2 | from builtins import ascii, bytes, compile +3 3 | from builtins import str as _str +4 |-from six.moves import filter, zip, zip_longest + 4 |+from six.moves import zip_longest +5 5 | from io import open +6 6 | import io +7 7 | import six + +UP029.py:5:1: UP029 [*] Unnecessary builtin import: `open` + | +3 | from builtins import str as _str +4 | from six.moves import filter, zip, zip_longest +5 | from io import open + | ^^^^^^^^^^^^^^^^^^^ UP029 +6 | import io +7 | import six + | + = help: Remove unnecessary builtin import + +ℹ Suggested fix +2 2 | from builtins import ascii, bytes, compile +3 3 | from builtins import str as _str +4 4 | from six.moves import filter, zip, zip_longest +5 |-from io import open +6 5 | import io +7 6 | import six +8 7 | import six.moves + + 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 new file mode 100644 index 0000000000..58595ab3a7 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP030_0.py.snap @@ -0,0 +1,503 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP030_0.py:3:1: UP030 [*] Use implicit references for positional format fields + | +1 | # Invalid calls; errors expected. +2 | +3 | "{0}" "{1}" "{2}".format(1, 2, 3) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 +4 | +5 | "a {3} complicated {1} string with {0} {2}".format( + | + = help: Remove explicit positional indices + +ℹ Suggested fix +1 1 | # Invalid calls; errors expected. +2 2 | +3 |-"{0}" "{1}" "{2}".format(1, 2, 3) + 3 |+"{}" "{}" "{}".format(1, 2, 3) +4 4 | +5 5 | "a {3} complicated {1} string with {0} {2}".format( +6 6 | "first", "second", "third", "fourth" + +UP030_0.py:5:1: UP030 [*] Use implicit references for positional format fields + | +3 | "{0}" "{1}" "{2}".format(1, 2, 3) +4 | +5 | / "a {3} complicated {1} string with {0} {2}".format( +6 | | "first", "second", "third", "fourth" +7 | | ) + | |_^ UP030 +8 | +9 | '{0}'.format(1) + | + = help: Remove explicit positional indices + +ℹ Suggested fix +2 2 | +3 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" + 5 |+"a {} complicated {} string with {} {}".format( + 6 |+ "fourth", "second", "first", "third" +7 7 | ) +8 8 | +9 9 | '{0}'.format(1) + +UP030_0.py:9:1: UP030 [*] Use implicit references for positional format fields + | + 7 | ) + 8 | + 9 | '{0}'.format(1) + | ^^^^^^^^^^^^^^^ UP030 +10 | +11 | '{0:x}'.format(30) + | + = help: Remove explicit positional indices + +ℹ Suggested fix +6 6 | "first", "second", "third", "fourth" +7 7 | ) +8 8 | +9 |-'{0}'.format(1) + 9 |+'{}'.format(1) +10 10 | +11 11 | '{0:x}'.format(30) +12 12 | + +UP030_0.py:11:1: UP030 [*] Use implicit references for positional format fields + | + 9 | '{0}'.format(1) +10 | +11 | '{0:x}'.format(30) + | ^^^^^^^^^^^^^^^^^^ UP030 +12 | +13 | x = '{0}'.format(1) + | + = help: Remove explicit positional indices + +ℹ Suggested fix +8 8 | +9 9 | '{0}'.format(1) +10 10 | +11 |-'{0:x}'.format(30) + 11 |+'{:x}'.format(30) +12 12 | +13 13 | x = '{0}'.format(1) +14 14 | + +UP030_0.py:13:5: UP030 [*] Use implicit references for positional format fields + | +11 | '{0:x}'.format(30) +12 | +13 | x = '{0}'.format(1) + | ^^^^^^^^^^^^^^^ UP030 +14 | +15 | '''{0}\n{1}\n'''.format(1, 2) + | + = help: Remove explicit positional indices + +ℹ Suggested fix +10 10 | +11 11 | '{0:x}'.format(30) +12 12 | +13 |-x = '{0}'.format(1) + 13 |+x = '{}'.format(1) +14 14 | +15 15 | '''{0}\n{1}\n'''.format(1, 2) +16 16 | + +UP030_0.py:15:1: UP030 [*] Use implicit references for positional format fields + | +13 | x = '{0}'.format(1) +14 | +15 | '''{0}\n{1}\n'''.format(1, 2) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 +16 | +17 | x = "foo {0}" \ + | + = help: Remove explicit positional indices + +ℹ Suggested fix +12 12 | +13 13 | x = '{0}'.format(1) +14 14 | +15 |-'''{0}\n{1}\n'''.format(1, 2) + 15 |+'''{}\n{}\n'''.format(1, 2) +16 16 | +17 17 | x = "foo {0}" \ +18 18 | "bar {1}".format(1, 2) + +UP030_0.py:17:5: UP030 [*] Use implicit references for positional format fields + | +15 | '''{0}\n{1}\n'''.format(1, 2) +16 | +17 | x = "foo {0}" \ + | _____^ +18 | | "bar {1}".format(1, 2) + | |__________________________^ UP030 +19 | +20 | ("{0}").format(1) + | + = help: Remove explicit positional indices + +ℹ Suggested fix +14 14 | +15 15 | '''{0}\n{1}\n'''.format(1, 2) +16 16 | +17 |-x = "foo {0}" \ +18 |- "bar {1}".format(1, 2) + 17 |+x = "foo {}" \ + 18 |+ "bar {}".format(1, 2) +19 19 | +20 20 | ("{0}").format(1) +21 21 | + +UP030_0.py:20:1: UP030 [*] Use implicit references for positional format fields + | +18 | "bar {1}".format(1, 2) +19 | +20 | ("{0}").format(1) + | ^^^^^^^^^^^^^^^^^ UP030 +21 | +22 | "\N{snowman} {0}".format(1) + | + = help: Remove explicit positional indices + +ℹ Suggested fix +17 17 | x = "foo {0}" \ +18 18 | "bar {1}".format(1, 2) +19 19 | +20 |-("{0}").format(1) + 20 |+("{}").format(1) +21 21 | +22 22 | "\N{snowman} {0}".format(1) +23 23 | + +UP030_0.py:22:1: UP030 [*] Use implicit references for positional format fields + | +20 | ("{0}").format(1) +21 | +22 | "\N{snowman} {0}".format(1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 +23 | +24 | print( + | + = help: Remove explicit positional indices + +ℹ Suggested fix +19 19 | +20 20 | ("{0}").format(1) +21 21 | +22 |-"\N{snowman} {0}".format(1) + 22 |+"\N{snowman} {}".format(1) +23 23 | +24 24 | print( +25 25 | 'foo{0}' + +UP030_0.py:25:5: UP030 [*] Use implicit references for positional format fields + | +24 | print( +25 | 'foo{0}' + | _____^ +26 | | 'bar{1}'.format(1, 2) + | |_________________________^ UP030 +27 | ) + | + = help: Remove explicit positional indices + +ℹ Suggested fix +22 22 | "\N{snowman} {0}".format(1) +23 23 | +24 24 | print( +25 |- 'foo{0}' +26 |- 'bar{1}'.format(1, 2) + 25 |+ 'foo{}' + 26 |+ 'bar{}'.format(1, 2) +27 27 | ) +28 28 | +29 29 | print( + +UP030_0.py:30:5: UP030 [*] Use implicit references for positional format fields + | +29 | print( +30 | 'foo{0}' # ohai\n" + | _____^ +31 | | 'bar{1}'.format(1, 2) + | |_________________________^ UP030 +32 | ) + | + = help: Remove explicit positional indices + +ℹ Suggested fix +27 27 | ) +28 28 | +29 29 | print( +30 |- 'foo{0}' # ohai\n" +31 |- 'bar{1}'.format(1, 2) + 30 |+ 'foo{}' # ohai\n" + 31 |+ 'bar{}'.format(1, 2) +32 32 | ) +33 33 | +34 34 | '{' '0}'.format(1) + +UP030_0.py:34:1: UP030 Use implicit references for positional format fields + | +32 | ) +33 | +34 | '{' '0}'.format(1) + | ^^^^^^^^^^^^^^^^^^ UP030 +35 | +36 | args = list(range(10)) + | + = help: Remove explicit positional indices + +UP030_0.py:39:1: UP030 [*] Use implicit references for positional format fields + | +37 | kwargs = {x: x for x in range(10)} +38 | +39 | "{0}".format(*args) + | ^^^^^^^^^^^^^^^^^^^ UP030 +40 | +41 | "{0}".format(**kwargs) + | + = help: Remove explicit positional indices + +ℹ Suggested fix +36 36 | args = list(range(10)) +37 37 | kwargs = {x: x for x in range(10)} +38 38 | +39 |-"{0}".format(*args) + 39 |+"{}".format(*args) +40 40 | +41 41 | "{0}".format(**kwargs) +42 42 | + +UP030_0.py:41:1: UP030 [*] Use implicit references for positional format fields + | +39 | "{0}".format(*args) +40 | +41 | "{0}".format(**kwargs) + | ^^^^^^^^^^^^^^^^^^^^^^ UP030 +42 | +43 | "{0}_{1}".format(*args) + | + = help: Remove explicit positional indices + +ℹ Suggested fix +38 38 | +39 39 | "{0}".format(*args) +40 40 | +41 |-"{0}".format(**kwargs) + 41 |+"{}".format(**kwargs) +42 42 | +43 43 | "{0}_{1}".format(*args) +44 44 | + +UP030_0.py:43:1: UP030 [*] Use implicit references for positional format fields + | +41 | "{0}".format(**kwargs) +42 | +43 | "{0}_{1}".format(*args) + | ^^^^^^^^^^^^^^^^^^^^^^^ UP030 +44 | +45 | "{0}_{1}".format(1, *args) + | + = help: Remove explicit positional indices + +ℹ Suggested fix +40 40 | +41 41 | "{0}".format(**kwargs) +42 42 | +43 |-"{0}_{1}".format(*args) + 43 |+"{}_{}".format(*args) +44 44 | +45 45 | "{0}_{1}".format(1, *args) +46 46 | + +UP030_0.py:45:1: UP030 [*] Use implicit references for positional format fields + | +43 | "{0}_{1}".format(*args) +44 | +45 | "{0}_{1}".format(1, *args) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 +46 | +47 | "{0}_{1}".format(1, 2, *args) + | + = help: Remove explicit positional indices + +ℹ Suggested fix +42 42 | +43 43 | "{0}_{1}".format(*args) +44 44 | +45 |-"{0}_{1}".format(1, *args) + 45 |+"{}_{}".format(1, *args) +46 46 | +47 47 | "{0}_{1}".format(1, 2, *args) +48 48 | + +UP030_0.py:47:1: UP030 [*] Use implicit references for positional format fields + | +45 | "{0}_{1}".format(1, *args) +46 | +47 | "{0}_{1}".format(1, 2, *args) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 +48 | +49 | "{0}_{1}".format(*args, 1, 2) + | + = help: Remove explicit positional indices + +ℹ Suggested fix +44 44 | +45 45 | "{0}_{1}".format(1, *args) +46 46 | +47 |-"{0}_{1}".format(1, 2, *args) + 47 |+"{}_{}".format(1, 2, *args) +48 48 | +49 49 | "{0}_{1}".format(*args, 1, 2) +50 50 | + +UP030_0.py:49:1: UP030 [*] Use implicit references for positional format fields + | +47 | "{0}_{1}".format(1, 2, *args) +48 | +49 | "{0}_{1}".format(*args, 1, 2) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 +50 | +51 | "{0}_{1}_{2}".format(1, **kwargs) + | + = help: Remove explicit positional indices + +ℹ Suggested fix +46 46 | +47 47 | "{0}_{1}".format(1, 2, *args) +48 48 | +49 |-"{0}_{1}".format(*args, 1, 2) + 49 |+"{}_{}".format(*args, 1, 2) +50 50 | +51 51 | "{0}_{1}_{2}".format(1, **kwargs) +52 52 | + +UP030_0.py:51:1: UP030 [*] Use implicit references for positional format fields + | +49 | "{0}_{1}".format(*args, 1, 2) +50 | +51 | "{0}_{1}_{2}".format(1, **kwargs) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 +52 | +53 | "{0}_{1}_{2}".format(1, 2, **kwargs) + | + = help: Remove explicit positional indices + +ℹ Suggested fix +48 48 | +49 49 | "{0}_{1}".format(*args, 1, 2) +50 50 | +51 |-"{0}_{1}_{2}".format(1, **kwargs) + 51 |+"{}_{}_{}".format(1, **kwargs) +52 52 | +53 53 | "{0}_{1}_{2}".format(1, 2, **kwargs) +54 54 | + +UP030_0.py:53:1: UP030 [*] Use implicit references for positional format fields + | +51 | "{0}_{1}_{2}".format(1, **kwargs) +52 | +53 | "{0}_{1}_{2}".format(1, 2, **kwargs) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 +54 | +55 | "{0}_{1}_{2}".format(1, 2, 3, **kwargs) + | + = help: Remove explicit positional indices + +ℹ Suggested fix +50 50 | +51 51 | "{0}_{1}_{2}".format(1, **kwargs) +52 52 | +53 |-"{0}_{1}_{2}".format(1, 2, **kwargs) + 53 |+"{}_{}_{}".format(1, 2, **kwargs) +54 54 | +55 55 | "{0}_{1}_{2}".format(1, 2, 3, **kwargs) +56 56 | + +UP030_0.py:55:1: UP030 [*] Use implicit references for positional format fields + | +53 | "{0}_{1}_{2}".format(1, 2, **kwargs) +54 | +55 | "{0}_{1}_{2}".format(1, 2, 3, **kwargs) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 +56 | +57 | "{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) + | + = help: Remove explicit positional indices + +ℹ Suggested fix +52 52 | +53 53 | "{0}_{1}_{2}".format(1, 2, **kwargs) +54 54 | +55 |-"{0}_{1}_{2}".format(1, 2, 3, **kwargs) + 55 |+"{}_{}_{}".format(1, 2, 3, **kwargs) +56 56 | +57 57 | "{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) +58 58 | + +UP030_0.py:57:1: UP030 [*] Use implicit references for positional format fields + | +55 | "{0}_{1}_{2}".format(1, 2, 3, **kwargs) +56 | +57 | "{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 +58 | +59 | "{1}_{0}".format(1, 2, *args) + | + = help: Remove explicit positional indices + +ℹ Suggested fix +54 54 | +55 55 | "{0}_{1}_{2}".format(1, 2, 3, **kwargs) +56 56 | +57 |-"{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) + 57 |+"{}_{}_{}".format(1, 2, 3, *args, **kwargs) +58 58 | +59 59 | "{1}_{0}".format(1, 2, *args) +60 60 | + +UP030_0.py:59:1: UP030 [*] Use implicit references for positional format fields + | +57 | "{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) +58 | +59 | "{1}_{0}".format(1, 2, *args) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP030 +60 | +61 | "{1}_{0}".format(1, 2) + | + = help: Remove explicit positional indices + +ℹ Suggested fix +56 56 | +57 57 | "{0}_{1}_{2}".format(1, 2, 3, *args, **kwargs) +58 58 | +59 |-"{1}_{0}".format(1, 2, *args) + 59 |+"{}_{}".format(2, 1, ) +60 60 | +61 61 | "{1}_{0}".format(1, 2) + +UP030_0.py:61:1: UP030 [*] Use implicit references for positional format fields + | +59 | "{1}_{0}".format(1, 2, *args) +60 | +61 | "{1}_{0}".format(1, 2) + | ^^^^^^^^^^^^^^^^^^^^^^ UP030 + | + = help: Remove explicit positional indices + +ℹ Suggested fix +58 58 | +59 59 | "{1}_{0}".format(1, 2, *args) +60 60 | +61 |-"{1}_{0}".format(1, 2) + 61 |+"{}_{}".format(2, 1) + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP030_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP030_1.py.snap new file mode 100644 index 0000000000..2bacb5d540 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP030_1.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- + 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 new file mode 100644 index 0000000000..45ed171e74 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP031_0.py.snap @@ -0,0 +1,910 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP031_0.py:4:7: UP031 [*] Use format specifiers instead of percent format + | +3 | # UP031 +4 | print('%s %s' % (a, b)) + | ^^^^^^^^^^^^^^^^ UP031 +5 | +6 | print('%s%s' % (a, b)) + | + = help: Replace with format specifiers + +ℹ Suggested fix +1 1 | a, b, x, y = 1, 2, 3, 4 +2 2 | +3 3 | # UP031 +4 |-print('%s %s' % (a, b)) + 4 |+print('{} {}'.format(a, b)) +5 5 | +6 6 | print('%s%s' % (a, b)) +7 7 | + +UP031_0.py:6:7: UP031 [*] Use format specifiers instead of percent format + | +4 | print('%s %s' % (a, b)) +5 | +6 | print('%s%s' % (a, b)) + | ^^^^^^^^^^^^^^^ UP031 +7 | +8 | print("trivial" % ()) + | + = help: Replace with format specifiers + +ℹ Suggested fix +3 3 | # UP031 +4 4 | print('%s %s' % (a, b)) +5 5 | +6 |-print('%s%s' % (a, b)) + 6 |+print('{}{}'.format(a, b)) +7 7 | +8 8 | print("trivial" % ()) +9 9 | + +UP031_0.py:8:7: UP031 [*] Use format specifiers instead of percent format + | + 6 | print('%s%s' % (a, b)) + 7 | + 8 | print("trivial" % ()) + | ^^^^^^^^^^^^^^ UP031 + 9 | +10 | print("%s" % ("simple",)) + | + = help: Replace with format specifiers + +ℹ Suggested fix +5 5 | +6 6 | print('%s%s' % (a, b)) +7 7 | +8 |-print("trivial" % ()) + 8 |+print("trivial".format()) +9 9 | +10 10 | print("%s" % ("simple",)) +11 11 | + +UP031_0.py:10:7: UP031 [*] Use format specifiers instead of percent format + | + 8 | print("trivial" % ()) + 9 | +10 | print("%s" % ("simple",)) + | ^^^^^^^^^^^^^^^^^^ UP031 +11 | +12 | print("%s" % ("%s" % ("nested",),)) + | + = help: Replace with format specifiers + +ℹ Suggested fix +7 7 | +8 8 | print("trivial" % ()) +9 9 | +10 |-print("%s" % ("simple",)) + 10 |+print("{}".format("simple")) +11 11 | +12 12 | print("%s" % ("%s" % ("nested",),)) +13 13 | + +UP031_0.py:12:7: UP031 [*] Use format specifiers instead of percent format + | +10 | print("%s" % ("simple",)) +11 | +12 | print("%s" % ("%s" % ("nested",),)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 +13 | +14 | print("%s%% percent" % (15,)) + | + = help: Replace with format specifiers + +ℹ Suggested fix +9 9 | +10 10 | print("%s" % ("simple",)) +11 11 | +12 |-print("%s" % ("%s" % ("nested",),)) + 12 |+print("{}".format("%s" % ("nested",))) +13 13 | +14 14 | print("%s%% percent" % (15,)) +15 15 | + +UP031_0.py:12:15: UP031 [*] Use format specifiers instead of percent format + | +10 | print("%s" % ("simple",)) +11 | +12 | print("%s" % ("%s" % ("nested",),)) + | ^^^^^^^^^^^^^^^^^^ UP031 +13 | +14 | print("%s%% percent" % (15,)) + | + = help: Replace with format specifiers + +ℹ Suggested fix +9 9 | +10 10 | print("%s" % ("simple",)) +11 11 | +12 |-print("%s" % ("%s" % ("nested",),)) + 12 |+print("%s" % ("{}".format("nested"),)) +13 13 | +14 14 | print("%s%% percent" % (15,)) +15 15 | + +UP031_0.py:14:7: UP031 [*] Use format specifiers instead of percent format + | +12 | print("%s" % ("%s" % ("nested",),)) +13 | +14 | print("%s%% percent" % (15,)) + | ^^^^^^^^^^^^^^^^^^^^^^ UP031 +15 | +16 | print("%f" % (15,)) + | + = help: Replace with format specifiers + +ℹ Suggested fix +11 11 | +12 12 | print("%s" % ("%s" % ("nested",),)) +13 13 | +14 |-print("%s%% percent" % (15,)) + 14 |+print("{}% percent".format(15)) +15 15 | +16 16 | print("%f" % (15,)) +17 17 | + +UP031_0.py:16:7: UP031 [*] Use format specifiers instead of percent format + | +14 | print("%s%% percent" % (15,)) +15 | +16 | print("%f" % (15,)) + | ^^^^^^^^^^^^ UP031 +17 | +18 | print("%.f" % (15,)) + | + = help: Replace with format specifiers + +ℹ Suggested fix +13 13 | +14 14 | print("%s%% percent" % (15,)) +15 15 | +16 |-print("%f" % (15,)) + 16 |+print("{:f}".format(15)) +17 17 | +18 18 | print("%.f" % (15,)) +19 19 | + +UP031_0.py:18:7: UP031 [*] Use format specifiers instead of percent format + | +16 | print("%f" % (15,)) +17 | +18 | print("%.f" % (15,)) + | ^^^^^^^^^^^^^ UP031 +19 | +20 | print("%.3f" % (15,)) + | + = help: Replace with format specifiers + +ℹ Suggested fix +15 15 | +16 16 | print("%f" % (15,)) +17 17 | +18 |-print("%.f" % (15,)) + 18 |+print("{:.0f}".format(15)) +19 19 | +20 20 | print("%.3f" % (15,)) +21 21 | + +UP031_0.py:20:7: UP031 [*] Use format specifiers instead of percent format + | +18 | print("%.f" % (15,)) +19 | +20 | print("%.3f" % (15,)) + | ^^^^^^^^^^^^^^ UP031 +21 | +22 | print("%3f" % (15,)) + | + = help: Replace with format specifiers + +ℹ Suggested fix +17 17 | +18 18 | print("%.f" % (15,)) +19 19 | +20 |-print("%.3f" % (15,)) + 20 |+print("{:.3f}".format(15)) +21 21 | +22 22 | print("%3f" % (15,)) +23 23 | + +UP031_0.py:22:7: UP031 [*] Use format specifiers instead of percent format + | +20 | print("%.3f" % (15,)) +21 | +22 | print("%3f" % (15,)) + | ^^^^^^^^^^^^^ UP031 +23 | +24 | print("%-5f" % (5,)) + | + = help: Replace with format specifiers + +ℹ Suggested fix +19 19 | +20 20 | print("%.3f" % (15,)) +21 21 | +22 |-print("%3f" % (15,)) + 22 |+print("{:3f}".format(15)) +23 23 | +24 24 | print("%-5f" % (5,)) +25 25 | + +UP031_0.py:24:7: UP031 [*] Use format specifiers instead of percent format + | +22 | print("%3f" % (15,)) +23 | +24 | print("%-5f" % (5,)) + | ^^^^^^^^^^^^^ UP031 +25 | +26 | print("%9f" % (5,)) + | + = help: Replace with format specifiers + +ℹ Suggested fix +21 21 | +22 22 | print("%3f" % (15,)) +23 23 | +24 |-print("%-5f" % (5,)) + 24 |+print("{:<5f}".format(5)) +25 25 | +26 26 | print("%9f" % (5,)) +27 27 | + +UP031_0.py:26:7: UP031 [*] Use format specifiers instead of percent format + | +24 | print("%-5f" % (5,)) +25 | +26 | print("%9f" % (5,)) + | ^^^^^^^^^^^^ UP031 +27 | +28 | print("%#o" % (123,)) + | + = help: Replace with format specifiers + +ℹ Suggested fix +23 23 | +24 24 | print("%-5f" % (5,)) +25 25 | +26 |-print("%9f" % (5,)) + 26 |+print("{:9f}".format(5)) +27 27 | +28 28 | print("%#o" % (123,)) +29 29 | + +UP031_0.py:28:7: UP031 [*] Use format specifiers instead of percent format + | +26 | print("%9f" % (5,)) +27 | +28 | print("%#o" % (123,)) + | ^^^^^^^^^^^^^^ UP031 +29 | +30 | print("brace {} %s" % (1,)) + | + = help: Replace with format specifiers + +ℹ Suggested fix +25 25 | +26 26 | print("%9f" % (5,)) +27 27 | +28 |-print("%#o" % (123,)) + 28 |+print("{:#o}".format(123)) +29 29 | +30 30 | print("brace {} %s" % (1,)) +31 31 | + +UP031_0.py:30:7: UP031 [*] Use format specifiers instead of percent format + | +28 | print("%#o" % (123,)) +29 | +30 | print("brace {} %s" % (1,)) + | ^^^^^^^^^^^^^^^^^^^^ UP031 +31 | +32 | print( + | + = help: Replace with format specifiers + +ℹ Suggested fix +27 27 | +28 28 | print("%#o" % (123,)) +29 29 | +30 |-print("brace {} %s" % (1,)) + 30 |+print("brace {{}} {}".format(1)) +31 31 | +32 32 | print( +33 33 | "%s" % ( + +UP031_0.py:33:3: UP031 [*] Use format specifiers instead of percent format + | +32 | print( +33 | "%s" % ( + | ___^ +34 | | "trailing comma", +35 | | ) + | |_________^ UP031 +36 | ) + | + = help: Replace with format specifiers + +ℹ Suggested fix +30 30 | print("brace {} %s" % (1,)) +31 31 | +32 32 | print( +33 |- "%s" % ( + 33 |+ "{}".format( +34 34 | "trailing comma", +35 35 | ) +36 36 | ) + +UP031_0.py:38:7: UP031 [*] Use format specifiers instead of percent format + | +36 | ) +37 | +38 | print("foo %s " % (x,)) + | ^^^^^^^^^^^^^^^^ UP031 +39 | +40 | print("%(k)s" % {"k": "v"}) + | + = help: Replace with format specifiers + +ℹ Suggested fix +35 35 | ) +36 36 | ) +37 37 | +38 |-print("foo %s " % (x,)) + 38 |+print("foo {} ".format(x)) +39 39 | +40 40 | print("%(k)s" % {"k": "v"}) +41 41 | + +UP031_0.py:40:7: UP031 [*] Use format specifiers instead of percent format + | +38 | print("foo %s " % (x,)) +39 | +40 | print("%(k)s" % {"k": "v"}) + | ^^^^^^^^^^^^^^^^^^^^ UP031 +41 | +42 | print("%(k)s" % { + | + = help: Replace with format specifiers + +ℹ Suggested fix +37 37 | +38 38 | print("foo %s " % (x,)) +39 39 | +40 |-print("%(k)s" % {"k": "v"}) + 40 |+print("{k}".format(k="v")) +41 41 | +42 42 | print("%(k)s" % { +43 43 | "k": "v", + +UP031_0.py:42:7: UP031 [*] Use format specifiers instead of percent format + | +40 | print("%(k)s" % {"k": "v"}) +41 | +42 | print("%(k)s" % { + | _______^ +43 | | "k": "v", +44 | | "i": "j" +45 | | }) + | |_^ UP031 +46 | +47 | print("%(to_list)s" % {"to_list": []}) + | + = help: Replace with format specifiers + +ℹ Suggested fix +39 39 | +40 40 | print("%(k)s" % {"k": "v"}) +41 41 | +42 |-print("%(k)s" % { +43 |- "k": "v", +44 |- "i": "j" +45 |-}) + 42 |+print("{k}".format( + 43 |+ k="v", + 44 |+ i="j", + 45 |+)) +46 46 | +47 47 | print("%(to_list)s" % {"to_list": []}) +48 48 | + +UP031_0.py:47:7: UP031 [*] Use format specifiers instead of percent format + | +45 | }) +46 | +47 | print("%(to_list)s" % {"to_list": []}) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 +48 | +49 | print("%(k)s" % {"k": "v", "i": 1, "j": []}) + | + = help: Replace with format specifiers + +ℹ Suggested fix +44 44 | "i": "j" +45 45 | }) +46 46 | +47 |-print("%(to_list)s" % {"to_list": []}) + 47 |+print("{to_list}".format(to_list=[])) +48 48 | +49 49 | print("%(k)s" % {"k": "v", "i": 1, "j": []}) +50 50 | + +UP031_0.py:49:7: UP031 [*] Use format specifiers instead of percent format + | +47 | print("%(to_list)s" % {"to_list": []}) +48 | +49 | print("%(k)s" % {"k": "v", "i": 1, "j": []}) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 +50 | +51 | print("%(ab)s" % {"a" "b": 1}) + | + = help: Replace with format specifiers + +ℹ Suggested fix +46 46 | +47 47 | print("%(to_list)s" % {"to_list": []}) +48 48 | +49 |-print("%(k)s" % {"k": "v", "i": 1, "j": []}) + 49 |+print("{k}".format(k="v", i=1, j=[])) +50 50 | +51 51 | print("%(ab)s" % {"a" "b": 1}) +52 52 | + +UP031_0.py:51:7: UP031 [*] Use format specifiers instead of percent format + | +49 | print("%(k)s" % {"k": "v", "i": 1, "j": []}) +50 | +51 | print("%(ab)s" % {"a" "b": 1}) + | ^^^^^^^^^^^^^^^^^^^^^^^ UP031 +52 | +53 | print("%(a)s" % {"a" : 1}) + | + = help: Replace with format specifiers + +ℹ Suggested fix +48 48 | +49 49 | print("%(k)s" % {"k": "v", "i": 1, "j": []}) +50 50 | +51 |-print("%(ab)s" % {"a" "b": 1}) + 51 |+print("{ab}".format(ab=1)) +52 52 | +53 53 | print("%(a)s" % {"a" : 1}) +54 54 | + +UP031_0.py:53:7: UP031 [*] Use format specifiers instead of percent format + | +51 | print("%(ab)s" % {"a" "b": 1}) +52 | +53 | print("%(a)s" % {"a" : 1}) + | ^^^^^^^^^^^^^^^^^^^^^ UP031 +54 | +55 | print(( + | + = help: Replace with format specifiers + +ℹ Suggested fix +50 50 | +51 51 | print("%(ab)s" % {"a" "b": 1}) +52 52 | +53 |-print("%(a)s" % {"a" : 1}) + 53 |+print("{a}".format(a=1)) +54 54 | +55 55 | print(( +56 56 | "foo %s " + +UP031_0.py:56:5: UP031 [*] Use format specifiers instead of percent format + | +55 | print(( +56 | "foo %s " + | _____^ +57 | | "bar %s" % (x, y) + | |_____________________^ UP031 +58 | )) + | + = help: Replace with format specifiers + +ℹ Suggested fix +53 53 | print("%(a)s" % {"a" : 1}) +54 54 | +55 55 | print(( +56 |- "foo %s " +57 |- "bar %s" % (x, y) + 56 |+ "foo {} " + 57 |+ "bar {}".format(x, y) +58 58 | )) +59 59 | +60 60 | print( + +UP031_0.py:61:5: UP031 [*] Use format specifiers instead of percent format + | +60 | print( +61 | "foo %(foo)s " + | _____^ +62 | | "bar %(bar)s" % {"foo": x, "bar": y} + | |________________________________________^ UP031 +63 | ) + | + = help: Replace with format specifiers + +ℹ Suggested fix +58 58 | )) +59 59 | +60 60 | print( +61 |- "foo %(foo)s " +62 |- "bar %(bar)s" % {"foo": x, "bar": y} + 61 |+ "foo {foo} " + 62 |+ "bar {bar}".format(foo=x, bar=y) +63 63 | ) +64 64 | +65 65 | bar = {"bar": y} + +UP031_0.py:67:5: UP031 [*] Use format specifiers instead of percent format + | +65 | bar = {"bar": y} +66 | print( +67 | "foo %(foo)s " + | _____^ +68 | | "bar %(bar)s" % {"foo": x, **bar} + | |_____________________________________^ UP031 +69 | ) + | + = help: Replace with format specifiers + +ℹ Suggested fix +64 64 | +65 65 | bar = {"bar": y} +66 66 | print( +67 |- "foo %(foo)s " +68 |- "bar %(bar)s" % {"foo": x, **bar} + 67 |+ "foo {foo} " + 68 |+ "bar {bar}".format(foo=x, **bar) +69 69 | ) +70 70 | +71 71 | print("%s \N{snowman}" % (a,)) + +UP031_0.py:71:7: UP031 [*] Use format specifiers instead of percent format + | +69 | ) +70 | +71 | print("%s \N{snowman}" % (a,)) + | ^^^^^^^^^^^^^^^^^^^^^^^ UP031 +72 | +73 | print("%(foo)s \N{snowman}" % {"foo": 1}) + | + = help: Replace with format specifiers + +ℹ Suggested fix +68 68 | "bar %(bar)s" % {"foo": x, **bar} +69 69 | ) +70 70 | +71 |-print("%s \N{snowman}" % (a,)) + 71 |+print("{} \N{snowman}".format(a)) +72 72 | +73 73 | print("%(foo)s \N{snowman}" % {"foo": 1}) +74 74 | + +UP031_0.py:73:7: UP031 [*] Use format specifiers instead of percent format + | +71 | print("%s \N{snowman}" % (a,)) +72 | +73 | print("%(foo)s \N{snowman}" % {"foo": 1}) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 +74 | +75 | print(("foo %s " "bar %s") % (x, y)) + | + = help: Replace with format specifiers + +ℹ Suggested fix +70 70 | +71 71 | print("%s \N{snowman}" % (a,)) +72 72 | +73 |-print("%(foo)s \N{snowman}" % {"foo": 1}) + 73 |+print("{foo} \N{snowman}".format(foo=1)) +74 74 | +75 75 | print(("foo %s " "bar %s") % (x, y)) +76 76 | + +UP031_0.py:75:7: UP031 [*] Use format specifiers instead of percent format + | +73 | print("%(foo)s \N{snowman}" % {"foo": 1}) +74 | +75 | print(("foo %s " "bar %s") % (x, y)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 +76 | +77 | # Single-value expressions + | + = help: Replace with format specifiers + +ℹ Suggested fix +72 72 | +73 73 | print("%(foo)s \N{snowman}" % {"foo": 1}) +74 74 | +75 |-print(("foo %s " "bar %s") % (x, y)) + 75 |+print(("foo {} " "bar {}").format(x, y)) +76 76 | +77 77 | # Single-value expressions +78 78 | print('Hello %s' % "World") + +UP031_0.py:78:7: UP031 [*] Use format specifiers instead of percent format + | +77 | # Single-value expressions +78 | print('Hello %s' % "World") + | ^^^^^^^^^^^^^^^^^^^^ UP031 +79 | print('Hello %s' % f"World") +80 | print('Hello %s (%s)' % bar) + | + = help: Replace with format specifiers + +ℹ Suggested fix +75 75 | print(("foo %s " "bar %s") % (x, y)) +76 76 | +77 77 | # Single-value expressions +78 |-print('Hello %s' % "World") + 78 |+print('Hello {}'.format("World")) +79 79 | print('Hello %s' % f"World") +80 80 | print('Hello %s (%s)' % bar) +81 81 | print('Hello %s (%s)' % bar.baz) + +UP031_0.py:79:7: UP031 [*] Use format specifiers instead of percent format + | +77 | # Single-value expressions +78 | print('Hello %s' % "World") +79 | print('Hello %s' % f"World") + | ^^^^^^^^^^^^^^^^^^^^^ UP031 +80 | print('Hello %s (%s)' % bar) +81 | print('Hello %s (%s)' % bar.baz) + | + = help: Replace with format specifiers + +ℹ Suggested fix +76 76 | +77 77 | # Single-value expressions +78 78 | print('Hello %s' % "World") +79 |-print('Hello %s' % f"World") + 79 |+print('Hello {}'.format(f"World")) +80 80 | print('Hello %s (%s)' % bar) +81 81 | print('Hello %s (%s)' % bar.baz) +82 82 | print('Hello %s (%s)' % bar['bop']) + +UP031_0.py:80:7: UP031 [*] Use format specifiers instead of percent format + | +78 | print('Hello %s' % "World") +79 | print('Hello %s' % f"World") +80 | print('Hello %s (%s)' % bar) + | ^^^^^^^^^^^^^^^^^^^^^ UP031 +81 | print('Hello %s (%s)' % bar.baz) +82 | print('Hello %s (%s)' % bar['bop']) + | + = help: Replace with format specifiers + +ℹ Suggested fix +77 77 | # Single-value expressions +78 78 | print('Hello %s' % "World") +79 79 | print('Hello %s' % f"World") +80 |-print('Hello %s (%s)' % bar) + 80 |+print('Hello {} ({})'.format(*bar)) +81 81 | print('Hello %s (%s)' % bar.baz) +82 82 | print('Hello %s (%s)' % bar['bop']) +83 83 | print('Hello %(arg)s' % bar) + +UP031_0.py:81:7: UP031 [*] Use format specifiers instead of percent format + | +79 | print('Hello %s' % f"World") +80 | print('Hello %s (%s)' % bar) +81 | print('Hello %s (%s)' % bar.baz) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 +82 | print('Hello %s (%s)' % bar['bop']) +83 | print('Hello %(arg)s' % bar) + | + = help: Replace with format specifiers + +ℹ Suggested fix +78 78 | print('Hello %s' % "World") +79 79 | print('Hello %s' % f"World") +80 80 | print('Hello %s (%s)' % bar) +81 |-print('Hello %s (%s)' % bar.baz) + 81 |+print('Hello {} ({})'.format(*bar.baz)) +82 82 | print('Hello %s (%s)' % bar['bop']) +83 83 | print('Hello %(arg)s' % bar) +84 84 | print('Hello %(arg)s' % bar.baz) + +UP031_0.py:82:7: UP031 [*] Use format specifiers instead of percent format + | +80 | print('Hello %s (%s)' % bar) +81 | print('Hello %s (%s)' % bar.baz) +82 | print('Hello %s (%s)' % bar['bop']) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 +83 | print('Hello %(arg)s' % bar) +84 | print('Hello %(arg)s' % bar.baz) + | + = help: Replace with format specifiers + +ℹ Suggested fix +79 79 | print('Hello %s' % f"World") +80 80 | print('Hello %s (%s)' % bar) +81 81 | print('Hello %s (%s)' % bar.baz) +82 |-print('Hello %s (%s)' % bar['bop']) + 82 |+print('Hello {} ({})'.format(*bar['bop'])) +83 83 | print('Hello %(arg)s' % bar) +84 84 | print('Hello %(arg)s' % bar.baz) +85 85 | print('Hello %(arg)s' % bar['bop']) + +UP031_0.py:83:7: UP031 [*] Use format specifiers instead of percent format + | +81 | print('Hello %s (%s)' % bar.baz) +82 | print('Hello %s (%s)' % bar['bop']) +83 | print('Hello %(arg)s' % bar) + | ^^^^^^^^^^^^^^^^^^^^^ UP031 +84 | print('Hello %(arg)s' % bar.baz) +85 | print('Hello %(arg)s' % bar['bop']) + | + = help: Replace with format specifiers + +ℹ Suggested fix +80 80 | print('Hello %s (%s)' % bar) +81 81 | print('Hello %s (%s)' % bar.baz) +82 82 | print('Hello %s (%s)' % bar['bop']) +83 |-print('Hello %(arg)s' % bar) + 83 |+print('Hello {arg}'.format(**bar)) +84 84 | print('Hello %(arg)s' % bar.baz) +85 85 | print('Hello %(arg)s' % bar['bop']) +86 86 | + +UP031_0.py:84:7: UP031 [*] Use format specifiers instead of percent format + | +82 | print('Hello %s (%s)' % bar['bop']) +83 | print('Hello %(arg)s' % bar) +84 | print('Hello %(arg)s' % bar.baz) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 +85 | print('Hello %(arg)s' % bar['bop']) + | + = help: Replace with format specifiers + +ℹ Suggested fix +81 81 | print('Hello %s (%s)' % bar.baz) +82 82 | print('Hello %s (%s)' % bar['bop']) +83 83 | print('Hello %(arg)s' % bar) +84 |-print('Hello %(arg)s' % bar.baz) + 84 |+print('Hello {arg}'.format(**bar.baz)) +85 85 | print('Hello %(arg)s' % bar['bop']) +86 86 | +87 87 | # Hanging modulos + +UP031_0.py:85:7: UP031 [*] Use format specifiers instead of percent format + | +83 | print('Hello %(arg)s' % bar) +84 | print('Hello %(arg)s' % bar.baz) +85 | print('Hello %(arg)s' % bar['bop']) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP031 +86 | +87 | # Hanging modulos + | + = help: Replace with format specifiers + +ℹ Suggested fix +82 82 | print('Hello %s (%s)' % bar['bop']) +83 83 | print('Hello %(arg)s' % bar) +84 84 | print('Hello %(arg)s' % bar.baz) +85 |-print('Hello %(arg)s' % bar['bop']) + 85 |+print('Hello {arg}'.format(**bar['bop'])) +86 86 | +87 87 | # Hanging modulos +88 88 | ( + +UP031_0.py:88:1: UP031 [*] Use format specifiers instead of percent format + | +87 | # Hanging modulos +88 | / ( +89 | | "foo %s " +90 | | "bar %s" +91 | | ) % (x, y) + | |__________^ UP031 +92 | +93 | ( + | + = help: Replace with format specifiers + +ℹ Suggested fix +86 86 | +87 87 | # Hanging modulos +88 88 | ( +89 |- "foo %s " +90 |- "bar %s" +91 |-) % (x, y) + 89 |+ "foo {} " + 90 |+ "bar {}" + 91 |+).format(x, y) +92 92 | +93 93 | ( +94 94 | "foo %(foo)s " + +UP031_0.py:93:1: UP031 [*] Use format specifiers instead of percent format + | +91 | ) % (x, y) +92 | +93 | / ( +94 | | "foo %(foo)s " +95 | | "bar %(bar)s" +96 | | ) % {"foo": x, "bar": y} + | |________________________^ UP031 +97 | +98 | ( + | + = help: Replace with format specifiers + +ℹ Suggested fix +91 91 | ) % (x, y) +92 92 | +93 93 | ( +94 |- "foo %(foo)s " +95 |- "bar %(bar)s" +96 |-) % {"foo": x, "bar": y} + 94 |+ "foo {foo} " + 95 |+ "bar {bar}" + 96 |+).format(foo=x, bar=y) +97 97 | +98 98 | ( +99 99 | """foo %s""" + +UP031_0.py:99:5: UP031 [*] Use format specifiers instead of percent format + | + 98 | ( + 99 | """foo %s""" + | _____^ +100 | | % (x,) + | |__________^ UP031 +101 | ) + | + = help: Replace with format specifiers + +ℹ Suggested fix +96 96 | ) % {"foo": x, "bar": y} +97 97 | +98 98 | ( +99 |- """foo %s""" +100 |- % (x,) + 99 |+ """foo {}""".format(x) +101 100 | ) +102 101 | +103 102 | ( + +UP031_0.py:104:5: UP031 [*] Use format specifiers instead of percent format + | +103 | ( +104 | """ + | _____^ +105 | | foo %s +106 | | """ +107 | | % (x,) + | |__________^ UP031 +108 | ) + | + = help: Replace with format specifiers + +ℹ Suggested fix +102 102 | +103 103 | ( +104 104 | """ +105 |- foo %s +106 |- """ +107 |- % (x,) + 105 |+ foo {} + 106 |+ """.format(x) +108 107 | ) +109 108 | +110 109 | "%s" % ( + +UP031_0.py:110:1: UP031 Use format specifiers instead of percent format + | +108 | ) +109 | +110 | / "%s" % ( +111 | | x, # comment +112 | | ) + | |_^ UP031 + | + = help: Replace with format specifiers + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP031_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP031_1.py.snap new file mode 100644 index 0000000000..2bacb5d540 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP031_1.py.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- + 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 new file mode 100644 index 0000000000..8771bfd691 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_0.py.snap @@ -0,0 +1,959 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP032_0.py:5:1: UP032 [*] Use f-string instead of `format` call + | +3 | ### +4 | +5 | "{} {}".format(a, b) + | ^^^^^^^^^^^^^^^^^^^^ UP032 +6 | +7 | "{1} {0}".format(a, b) + | + = help: Convert to f-string + +ℹ Suggested fix +2 2 | # Errors +3 3 | ### +4 4 | +5 |-"{} {}".format(a, b) + 5 |+f"{a} {b}" +6 6 | +7 7 | "{1} {0}".format(a, b) +8 8 | + +UP032_0.py:7:1: UP032 [*] Use f-string instead of `format` call + | +5 | "{} {}".format(a, b) +6 | +7 | "{1} {0}".format(a, b) + | ^^^^^^^^^^^^^^^^^^^^^^ UP032 +8 | +9 | "{0} {1} {0}".format(a, b) + | + = help: Convert to f-string + +ℹ Suggested fix +4 4 | +5 5 | "{} {}".format(a, b) +6 6 | +7 |-"{1} {0}".format(a, b) + 7 |+f"{b} {a}" +8 8 | +9 9 | "{0} {1} {0}".format(a, b) +10 10 | + +UP032_0.py:9:1: UP032 [*] Use f-string instead of `format` call + | + 7 | "{1} {0}".format(a, b) + 8 | + 9 | "{0} {1} {0}".format(a, b) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 +10 | +11 | "{x.y}".format(x=z) + | + = help: Convert to f-string + +ℹ Suggested fix +6 6 | +7 7 | "{1} {0}".format(a, b) +8 8 | +9 |-"{0} {1} {0}".format(a, b) + 9 |+f"{a} {b} {a}" +10 10 | +11 11 | "{x.y}".format(x=z) +12 12 | + +UP032_0.py:11:1: UP032 [*] Use f-string instead of `format` call + | + 9 | "{0} {1} {0}".format(a, b) +10 | +11 | "{x.y}".format(x=z) + | ^^^^^^^^^^^^^^^^^^^ UP032 +12 | +13 | "{x} {y} {x}".format(x=a, y=b) + | + = help: Convert to f-string + +ℹ Suggested fix +8 8 | +9 9 | "{0} {1} {0}".format(a, b) +10 10 | +11 |-"{x.y}".format(x=z) + 11 |+f"{z.y}" +12 12 | +13 13 | "{x} {y} {x}".format(x=a, y=b) +14 14 | + +UP032_0.py:13:1: UP032 [*] Use f-string instead of `format` call + | +11 | "{x.y}".format(x=z) +12 | +13 | "{x} {y} {x}".format(x=a, y=b) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 +14 | +15 | "{.x} {.y}".format(a, b) + | + = help: Convert to f-string + +ℹ Suggested fix +10 10 | +11 11 | "{x.y}".format(x=z) +12 12 | +13 |-"{x} {y} {x}".format(x=a, y=b) + 13 |+f"{a} {b} {a}" +14 14 | +15 15 | "{.x} {.y}".format(a, b) +16 16 | + +UP032_0.py:15:1: UP032 [*] Use f-string instead of `format` call + | +13 | "{x} {y} {x}".format(x=a, y=b) +14 | +15 | "{.x} {.y}".format(a, b) + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 +16 | +17 | "{} {}".format(a.b, c.d) + | + = help: Convert to f-string + +ℹ Suggested fix +12 12 | +13 13 | "{x} {y} {x}".format(x=a, y=b) +14 14 | +15 |-"{.x} {.y}".format(a, b) + 15 |+f"{a.x} {b.y}" +16 16 | +17 17 | "{} {}".format(a.b, c.d) +18 18 | + +UP032_0.py:17:1: UP032 [*] Use f-string instead of `format` call + | +15 | "{.x} {.y}".format(a, b) +16 | +17 | "{} {}".format(a.b, c.d) + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 +18 | +19 | "{}".format(a()) + | + = help: Convert to f-string + +ℹ Suggested fix +14 14 | +15 15 | "{.x} {.y}".format(a, b) +16 16 | +17 |-"{} {}".format(a.b, c.d) + 17 |+f"{a.b} {c.d}" +18 18 | +19 19 | "{}".format(a()) +20 20 | + +UP032_0.py:19:1: UP032 [*] Use f-string instead of `format` call + | +17 | "{} {}".format(a.b, c.d) +18 | +19 | "{}".format(a()) + | ^^^^^^^^^^^^^^^^ UP032 +20 | +21 | "{}".format(a.b()) + | + = help: Convert to f-string + +ℹ Suggested fix +16 16 | +17 17 | "{} {}".format(a.b, c.d) +18 18 | +19 |-"{}".format(a()) + 19 |+f"{a()}" +20 20 | +21 21 | "{}".format(a.b()) +22 22 | + +UP032_0.py:21:1: UP032 [*] Use f-string instead of `format` call + | +19 | "{}".format(a()) +20 | +21 | "{}".format(a.b()) + | ^^^^^^^^^^^^^^^^^^ UP032 +22 | +23 | "{}".format(a.b().c()) + | + = help: Convert to f-string + +ℹ Suggested fix +18 18 | +19 19 | "{}".format(a()) +20 20 | +21 |-"{}".format(a.b()) + 21 |+f"{a.b()}" +22 22 | +23 23 | "{}".format(a.b().c()) +24 24 | + +UP032_0.py:23:1: UP032 [*] Use f-string instead of `format` call + | +21 | "{}".format(a.b()) +22 | +23 | "{}".format(a.b().c()) + | ^^^^^^^^^^^^^^^^^^^^^^ UP032 +24 | +25 | "hello {}!".format(name) + | + = help: Convert to f-string + +ℹ Suggested fix +20 20 | +21 21 | "{}".format(a.b()) +22 22 | +23 |-"{}".format(a.b().c()) + 23 |+f"{a.b().c()}" +24 24 | +25 25 | "hello {}!".format(name) +26 26 | + +UP032_0.py:25:1: UP032 [*] Use f-string instead of `format` call + | +23 | "{}".format(a.b().c()) +24 | +25 | "hello {}!".format(name) + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 +26 | +27 | "{}{b}{}".format(a, c, b=b) + | + = help: Convert to f-string + +ℹ Suggested fix +22 22 | +23 23 | "{}".format(a.b().c()) +24 24 | +25 |-"hello {}!".format(name) + 25 |+f"hello {name}!" +26 26 | +27 27 | "{}{b}{}".format(a, c, b=b) +28 28 | + +UP032_0.py:27:1: UP032 [*] Use f-string instead of `format` call + | +25 | "hello {}!".format(name) +26 | +27 | "{}{b}{}".format(a, c, b=b) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 +28 | +29 | "{}".format(0x0) + | + = help: Convert to f-string + +ℹ Suggested fix +24 24 | +25 25 | "hello {}!".format(name) +26 26 | +27 |-"{}{b}{}".format(a, c, b=b) + 27 |+f"{a}{b}{c}" +28 28 | +29 29 | "{}".format(0x0) +30 30 | + +UP032_0.py:29:1: UP032 [*] Use f-string instead of `format` call + | +27 | "{}{b}{}".format(a, c, b=b) +28 | +29 | "{}".format(0x0) + | ^^^^^^^^^^^^^^^^ UP032 +30 | +31 | "{} {}".format(a, b) + | + = help: Convert to f-string + +ℹ Suggested fix +26 26 | +27 27 | "{}{b}{}".format(a, c, b=b) +28 28 | +29 |-"{}".format(0x0) + 29 |+f"{0x0}" +30 30 | +31 31 | "{} {}".format(a, b) +32 32 | + +UP032_0.py:31:1: UP032 [*] Use f-string instead of `format` call + | +29 | "{}".format(0x0) +30 | +31 | "{} {}".format(a, b) + | ^^^^^^^^^^^^^^^^^^^^ UP032 +32 | +33 | """{} {}""".format(a, b) + | + = help: Convert to f-string + +ℹ Suggested fix +28 28 | +29 29 | "{}".format(0x0) +30 30 | +31 |-"{} {}".format(a, b) + 31 |+f"{a} {b}" +32 32 | +33 33 | """{} {}""".format(a, b) +34 34 | + +UP032_0.py:33:1: UP032 [*] Use f-string instead of `format` call + | +31 | "{} {}".format(a, b) +32 | +33 | """{} {}""".format(a, b) + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 +34 | +35 | "foo{}".format(1) + | + = help: Convert to f-string + +ℹ Suggested fix +30 30 | +31 31 | "{} {}".format(a, b) +32 32 | +33 |-"""{} {}""".format(a, b) + 33 |+f"""{a} {b}""" +34 34 | +35 35 | "foo{}".format(1) +36 36 | + +UP032_0.py:35:1: UP032 [*] Use f-string instead of `format` call + | +33 | """{} {}""".format(a, b) +34 | +35 | "foo{}".format(1) + | ^^^^^^^^^^^^^^^^^ UP032 +36 | +37 | r"foo{}".format(1) + | + = help: Convert to f-string + +ℹ Suggested fix +32 32 | +33 33 | """{} {}""".format(a, b) +34 34 | +35 |-"foo{}".format(1) + 35 |+f"foo{1}" +36 36 | +37 37 | r"foo{}".format(1) +38 38 | + +UP032_0.py:37:1: UP032 [*] Use f-string instead of `format` call + | +35 | "foo{}".format(1) +36 | +37 | r"foo{}".format(1) + | ^^^^^^^^^^^^^^^^^^ UP032 +38 | +39 | x = "{a}".format(a=1) + | + = help: Convert to f-string + +ℹ Suggested fix +34 34 | +35 35 | "foo{}".format(1) +36 36 | +37 |-r"foo{}".format(1) + 37 |+fr"foo{1}" +38 38 | +39 39 | x = "{a}".format(a=1) +40 40 | + +UP032_0.py:39:5: UP032 [*] Use f-string instead of `format` call + | +37 | r"foo{}".format(1) +38 | +39 | x = "{a}".format(a=1) + | ^^^^^^^^^^^^^^^^^ UP032 +40 | +41 | print("foo {} ".format(x)) + | + = help: Convert to f-string + +ℹ Suggested fix +36 36 | +37 37 | r"foo{}".format(1) +38 38 | +39 |-x = "{a}".format(a=1) + 39 |+x = f"{1}" +40 40 | +41 41 | print("foo {} ".format(x)) +42 42 | + +UP032_0.py:41:7: UP032 [*] Use f-string instead of `format` call + | +39 | x = "{a}".format(a=1) +40 | +41 | print("foo {} ".format(x)) + | ^^^^^^^^^^^^^^^^^^^ UP032 +42 | +43 | "{a[b]}".format(a=a) + | + = help: Convert to f-string + +ℹ Suggested fix +38 38 | +39 39 | x = "{a}".format(a=1) +40 40 | +41 |-print("foo {} ".format(x)) + 41 |+print(f"foo {x} ") +42 42 | +43 43 | "{a[b]}".format(a=a) +44 44 | + +UP032_0.py:43:1: UP032 [*] Use f-string instead of `format` call + | +41 | print("foo {} ".format(x)) +42 | +43 | "{a[b]}".format(a=a) + | ^^^^^^^^^^^^^^^^^^^^ UP032 +44 | +45 | "{a.a[b]}".format(a=a) + | + = help: Convert to f-string + +ℹ Suggested fix +40 40 | +41 41 | print("foo {} ".format(x)) +42 42 | +43 |-"{a[b]}".format(a=a) + 43 |+f"{a['b']}" +44 44 | +45 45 | "{a.a[b]}".format(a=a) +46 46 | + +UP032_0.py:45:1: UP032 [*] Use f-string instead of `format` call + | +43 | "{a[b]}".format(a=a) +44 | +45 | "{a.a[b]}".format(a=a) + | ^^^^^^^^^^^^^^^^^^^^^^ UP032 +46 | +47 | "{}{{}}{}".format(escaped, y) + | + = help: Convert to f-string + +ℹ Suggested fix +42 42 | +43 43 | "{a[b]}".format(a=a) +44 44 | +45 |-"{a.a[b]}".format(a=a) + 45 |+f"{a.a['b']}" +46 46 | +47 47 | "{}{{}}{}".format(escaped, y) +48 48 | + +UP032_0.py:47:1: UP032 [*] Use f-string instead of `format` call + | +45 | "{a.a[b]}".format(a=a) +46 | +47 | "{}{{}}{}".format(escaped, y) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 +48 | +49 | "{}".format(a) + | + = help: Convert to f-string + +ℹ Suggested fix +44 44 | +45 45 | "{a.a[b]}".format(a=a) +46 46 | +47 |-"{}{{}}{}".format(escaped, y) + 47 |+f"{escaped}{{}}{y}" +48 48 | +49 49 | "{}".format(a) +50 50 | + +UP032_0.py:49:1: UP032 [*] Use f-string instead of `format` call + | +47 | "{}{{}}{}".format(escaped, y) +48 | +49 | "{}".format(a) + | ^^^^^^^^^^^^^^ UP032 +50 | +51 | '({}={{0!e}})'.format(a) + | + = help: Convert to f-string + +ℹ Suggested fix +46 46 | +47 47 | "{}{{}}{}".format(escaped, y) +48 48 | +49 |-"{}".format(a) + 49 |+f"{a}" +50 50 | +51 51 | '({}={{0!e}})'.format(a) +52 52 | + +UP032_0.py:51:1: UP032 [*] Use f-string instead of `format` call + | +49 | "{}".format(a) +50 | +51 | '({}={{0!e}})'.format(a) + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 +52 | +53 | "{[b]}".format(a) + | + = help: Convert to f-string + +ℹ Suggested fix +48 48 | +49 49 | "{}".format(a) +50 50 | +51 |-'({}={{0!e}})'.format(a) + 51 |+f'({a}={{0!e}})' +52 52 | +53 53 | "{[b]}".format(a) +54 54 | + +UP032_0.py:53:1: UP032 [*] Use f-string instead of `format` call + | +51 | '({}={{0!e}})'.format(a) +52 | +53 | "{[b]}".format(a) + | ^^^^^^^^^^^^^^^^^ UP032 +54 | +55 | '{[b]}'.format(a) + | + = help: Convert to f-string + +ℹ Suggested fix +50 50 | +51 51 | '({}={{0!e}})'.format(a) +52 52 | +53 |-"{[b]}".format(a) + 53 |+f"{a['b']}" +54 54 | +55 55 | '{[b]}'.format(a) +56 56 | + +UP032_0.py:55:1: UP032 [*] Use f-string instead of `format` call + | +53 | "{[b]}".format(a) +54 | +55 | '{[b]}'.format(a) + | ^^^^^^^^^^^^^^^^^ UP032 +56 | +57 | """{[b]}""".format(a) + | + = help: Convert to f-string + +ℹ Suggested fix +52 52 | +53 53 | "{[b]}".format(a) +54 54 | +55 |-'{[b]}'.format(a) + 55 |+f'{a["b"]}' +56 56 | +57 57 | """{[b]}""".format(a) +58 58 | + +UP032_0.py:57:1: UP032 [*] Use f-string instead of `format` call + | +55 | '{[b]}'.format(a) +56 | +57 | """{[b]}""".format(a) + | ^^^^^^^^^^^^^^^^^^^^^ UP032 +58 | +59 | '''{[b]}'''.format(a) + | + = help: Convert to f-string + +ℹ Suggested fix +54 54 | +55 55 | '{[b]}'.format(a) +56 56 | +57 |-"""{[b]}""".format(a) + 57 |+f"""{a["b"]}""" +58 58 | +59 59 | '''{[b]}'''.format(a) +60 60 | + +UP032_0.py:59:1: UP032 [*] Use f-string instead of `format` call + | +57 | """{[b]}""".format(a) +58 | +59 | '''{[b]}'''.format(a) + | ^^^^^^^^^^^^^^^^^^^^^ UP032 +60 | +61 | "{}".format( + | + = help: Convert to f-string + +ℹ Suggested fix +56 56 | +57 57 | """{[b]}""".format(a) +58 58 | +59 |-'''{[b]}'''.format(a) + 59 |+f'''{a["b"]}''' +60 60 | +61 61 | "{}".format( +62 62 | 1 + +UP032_0.py:61:1: UP032 [*] Use f-string instead of `format` call + | +59 | '''{[b]}'''.format(a) +60 | +61 | / "{}".format( +62 | | 1 +63 | | ) + | |_^ UP032 +64 | +65 | "123456789 {}".format( + | + = help: Convert to f-string + +ℹ Suggested fix +58 58 | +59 59 | '''{[b]}'''.format(a) +60 60 | +61 |-"{}".format( +62 |- 1 +63 |-) + 61 |+f"{1}" +64 62 | +65 63 | "123456789 {}".format( +66 64 | 1111111111111111111111111111111111111111111111111111111111111111111111111, + +UP032_0.py:65:1: UP032 [*] Use f-string instead of `format` call + | +63 | ) +64 | +65 | / "123456789 {}".format( +66 | | 1111111111111111111111111111111111111111111111111111111111111111111111111, +67 | | ) + | |_^ UP032 +68 | +69 | """ + | + = help: Convert to f-string + +ℹ Suggested fix +62 62 | 1 +63 63 | ) +64 64 | +65 |-"123456789 {}".format( +66 |- 1111111111111111111111111111111111111111111111111111111111111111111111111, +67 |-) + 65 |+f"123456789 {1111111111111111111111111111111111111111111111111111111111111111111111111}" +68 66 | +69 67 | """ +70 68 | {} + +UP032_0.py:69:1: UP032 [*] Use f-string instead of `format` call + | +67 | ) +68 | +69 | / """ +70 | | {} +71 | | """.format(1) + | |_____________^ UP032 +72 | +73 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = """ + | + = help: Convert to f-string + +ℹ Suggested fix +66 66 | 1111111111111111111111111111111111111111111111111111111111111111111111111, +67 67 | ) +68 68 | + 69 |+f""" + 70 |+{1} +69 71 | """ +70 |-{} +71 |-""".format(1) +72 72 | +73 73 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = """ +74 74 | {} + +UP032_0.py:73:85: UP032 [*] Use f-string instead of `format` call + | +71 | """.format(1) +72 | +73 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = """ + | _____________________________________________________________________________________^ +74 | | {} +75 | | """.format( +76 | | 111111 +77 | | ) + | |_^ UP032 +78 | +79 | "{a}" "{b}".format(a=1, b=1) + | + = help: Convert to f-string + +ℹ Suggested fix +70 70 | {} +71 71 | """.format(1) +72 72 | +73 |-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = """ +74 |-{} +75 |-""".format( +76 |- 111111 +77 |-) + 73 |+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = f""" + 74 |+{111111} + 75 |+""" +78 76 | +79 77 | "{a}" "{b}".format(a=1, b=1) +80 78 | + +UP032_0.py:79:1: UP032 [*] Use f-string instead of `format` call + | +77 | ) +78 | +79 | "{a}" "{b}".format(a=1, b=1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 +80 | +81 | ( + | + = help: Convert to f-string + +ℹ Suggested fix +76 76 | 111111 +77 77 | ) +78 78 | +79 |-"{a}" "{b}".format(a=1, b=1) + 79 |+f"{1}" f"{1}" +80 80 | +81 81 | ( +82 82 | "{a}" + +UP032_0.py:81:1: UP032 [*] Use f-string instead of `format` call + | +79 | "{a}" "{b}".format(a=1, b=1) +80 | +81 | / ( +82 | | "{a}" +83 | | "{b}" +84 | | ).format(a=1, b=1) + | |__________________^ UP032 +85 | +86 | ( + | + = help: Convert to f-string + +ℹ Suggested fix +79 79 | "{a}" "{b}".format(a=1, b=1) +80 80 | +81 81 | ( +82 |- "{a}" +83 |- "{b}" +84 |-).format(a=1, b=1) + 82 |+ f"{1}" + 83 |+ f"{1}" + 84 |+) +85 85 | +86 86 | ( +87 87 | "{a}" + +UP032_0.py:86:1: UP032 [*] Use f-string instead of `format` call + | +84 | ).format(a=1, b=1) +85 | +86 | / ( +87 | | "{a}" +88 | | "" +89 | | "{b}" +90 | | "" +91 | | ).format(a=1, b=1) + | |__________________^ UP032 +92 | +93 | ( + | + = help: Convert to f-string + +ℹ Suggested fix +84 84 | ).format(a=1, b=1) +85 85 | +86 86 | ( +87 |- "{a}" + 87 |+ f"{1}" +88 88 | "" +89 |- "{b}" + 89 |+ f"{1}" +90 90 | "" +91 |-).format(a=1, b=1) + 91 |+) +92 92 | +93 93 | ( +94 94 | ( + +UP032_0.py:94:5: UP032 [*] Use f-string instead of `format` call + | + 93 | ( + 94 | ( + | _____^ + 95 | | # comment + 96 | | "{a}" + 97 | | # comment + 98 | | "{b}" + 99 | | ) +100 | | # comment +101 | | .format(a=1, b=1) + | |_____________________^ UP032 +102 | ) + | + = help: Convert to f-string + +ℹ Suggested fix +93 93 | ( +94 94 | ( +95 95 | # comment +96 |- "{a}" + 96 |+ f"{1}" +97 97 | # comment +98 |- "{b}" + 98 |+ f"{1}" +99 99 | ) +100 100 | # comment +101 |- .format(a=1, b=1) + 101 |+ +102 102 | ) +103 103 | +104 104 | ( + +UP032_0.py:104:1: UP032 [*] Use f-string instead of `format` call + | +102 | ) +103 | +104 | / ( +105 | | "{a}" +106 | | "b" +107 | | ).format(a=1) + | |_____________^ UP032 + | + = help: Convert to f-string + +ℹ Suggested fix +102 102 | ) +103 103 | +104 104 | ( +105 |- "{a}" + 105 |+ f"{1}" +106 106 | "b" +107 |-).format(a=1) + 107 |+) +108 108 | +109 109 | +110 110 | def d(osname, version, release): + +UP032_0.py:111:11: UP032 [*] Use f-string instead of `format` call + | +110 | def d(osname, version, release): +111 | return"{}-{}.{}".format(osname, version, release) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | + = help: Convert to f-string + +ℹ Suggested fix +108 108 | +109 109 | +110 110 | def d(osname, version, release): +111 |- return"{}-{}.{}".format(osname, version, release) + 111 |+ return f"{osname}-{version}.{release}" +112 112 | +113 113 | +114 114 | def e(): + +UP032_0.py:115:10: UP032 [*] Use f-string instead of `format` call + | +114 | def e(): +115 | yield"{}".format(1) + | ^^^^^^^^^^^^^^ UP032 + | + = help: Convert to f-string + +ℹ Suggested fix +112 112 | +113 113 | +114 114 | def e(): +115 |- yield"{}".format(1) + 115 |+ yield f"{1}" +116 116 | +117 117 | +118 118 | assert"{}".format(1) + +UP032_0.py:118:7: UP032 [*] Use f-string instead of `format` call + | +118 | assert"{}".format(1) + | ^^^^^^^^^^^^^^ UP032 + | + = help: Convert to f-string + +ℹ Suggested fix +115 115 | yield"{}".format(1) +116 116 | +117 117 | +118 |-assert"{}".format(1) + 118 |+assert f"{1}" +119 119 | +120 120 | +121 121 | async def c(): + +UP032_0.py:122:12: UP032 [*] Use f-string instead of `format` call + | +121 | async def c(): +122 | return "{}".format(await 3) + | ^^^^^^^^^^^^^^^^^^^^ UP032 + | + = help: Convert to f-string + +ℹ Suggested fix +119 119 | +120 120 | +121 121 | async def c(): +122 |- return "{}".format(await 3) + 122 |+ return f"{await 3}" +123 123 | +124 124 | +125 125 | async def c(): + +UP032_0.py:126:12: UP032 [*] Use f-string instead of `format` call + | +125 | async def c(): +126 | return "{}".format(1 + await 3) + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | + = help: Convert to f-string + +ℹ Suggested fix +123 123 | +124 124 | +125 125 | async def c(): +126 |- return "{}".format(1 + await 3) + 126 |+ return f"{1 + await 3}" +127 127 | +128 128 | +129 129 | "{}".format(1 * 2) + +UP032_0.py:129:1: UP032 [*] Use f-string instead of `format` call + | +129 | "{}".format(1 * 2) + | ^^^^^^^^^^^^^^^^^^ UP032 +130 | +131 | ### + | + = help: Convert to f-string + +ℹ Suggested fix +126 126 | return "{}".format(1 + await 3) +127 127 | +128 128 | +129 |-"{}".format(1 * 2) + 129 |+f"{1 * 2}" +130 130 | +131 131 | ### +132 132 | # Non-errors + +UP032_0.py:202:1: UP032 Use f-string instead of `format` call + | +200 | "{}".format(**c) +201 | +202 | / "{}".format( +203 | | 1 # comment +204 | | ) + | |_^ UP032 + | + = help: Convert to f-string + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_1.py.snap new file mode 100644 index 0000000000..1d879bf62a --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_1.py.snap @@ -0,0 +1,15 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP032_1.py:1:1: UP032 [*] Use f-string instead of `format` call + | +1 | "{} {}".format(a, b) # Intentionally at start-of-file, to ensure graceful handling. + | ^^^^^^^^^^^^^^^^^^^^ UP032 + | + = help: Convert to f-string + +ℹ Suggested fix +1 |-"{} {}".format(a, b) # Intentionally at start-of-file, to ensure graceful handling. + 1 |+f"{a} {b}" # Intentionally at start-of-file, to ensure graceful handling. + + 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 new file mode 100644 index 0000000000..5751783cf7 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_2.py.snap @@ -0,0 +1,443 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP032_2.py:2:1: UP032 [*] Use f-string instead of `format` call + | +1 | # Errors +2 | "{.real}".format(1) + | ^^^^^^^^^^^^^^^^^^^ UP032 +3 | "{0.real}".format(1) +4 | "{a.real}".format(a=1) + | + = help: Convert to f-string + +ℹ Suggested fix +1 1 | # Errors +2 |-"{.real}".format(1) + 2 |+f"{(1).real}" +3 3 | "{0.real}".format(1) +4 4 | "{a.real}".format(a=1) +5 5 | + +UP032_2.py:3:1: UP032 [*] Use f-string instead of `format` call + | +1 | # Errors +2 | "{.real}".format(1) +3 | "{0.real}".format(1) + | ^^^^^^^^^^^^^^^^^^^^ UP032 +4 | "{a.real}".format(a=1) + | + = help: Convert to f-string + +ℹ Suggested fix +1 1 | # Errors +2 2 | "{.real}".format(1) +3 |-"{0.real}".format(1) + 3 |+f"{(1).real}" +4 4 | "{a.real}".format(a=1) +5 5 | +6 6 | "{.real}".format(1.0) + +UP032_2.py:4:1: UP032 [*] Use f-string instead of `format` call + | +2 | "{.real}".format(1) +3 | "{0.real}".format(1) +4 | "{a.real}".format(a=1) + | ^^^^^^^^^^^^^^^^^^^^^^ UP032 +5 | +6 | "{.real}".format(1.0) + | + = help: Convert to f-string + +ℹ Suggested fix +1 1 | # Errors +2 2 | "{.real}".format(1) +3 3 | "{0.real}".format(1) +4 |-"{a.real}".format(a=1) + 4 |+f"{(1).real}" +5 5 | +6 6 | "{.real}".format(1.0) +7 7 | "{0.real}".format(1.0) + +UP032_2.py:6:1: UP032 [*] Use f-string instead of `format` call + | +4 | "{a.real}".format(a=1) +5 | +6 | "{.real}".format(1.0) + | ^^^^^^^^^^^^^^^^^^^^^ UP032 +7 | "{0.real}".format(1.0) +8 | "{a.real}".format(a=1.0) + | + = help: Convert to f-string + +ℹ Suggested fix +3 3 | "{0.real}".format(1) +4 4 | "{a.real}".format(a=1) +5 5 | +6 |-"{.real}".format(1.0) + 6 |+f"{1.0.real}" +7 7 | "{0.real}".format(1.0) +8 8 | "{a.real}".format(a=1.0) +9 9 | + +UP032_2.py:7:1: UP032 [*] Use f-string instead of `format` call + | +6 | "{.real}".format(1.0) +7 | "{0.real}".format(1.0) + | ^^^^^^^^^^^^^^^^^^^^^^ UP032 +8 | "{a.real}".format(a=1.0) + | + = help: Convert to f-string + +ℹ Suggested fix +4 4 | "{a.real}".format(a=1) +5 5 | +6 6 | "{.real}".format(1.0) +7 |-"{0.real}".format(1.0) + 7 |+f"{1.0.real}" +8 8 | "{a.real}".format(a=1.0) +9 9 | +10 10 | "{.real}".format(1j) + +UP032_2.py:8:1: UP032 [*] Use f-string instead of `format` call + | + 6 | "{.real}".format(1.0) + 7 | "{0.real}".format(1.0) + 8 | "{a.real}".format(a=1.0) + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + 9 | +10 | "{.real}".format(1j) + | + = help: Convert to f-string + +ℹ Suggested fix +5 5 | +6 6 | "{.real}".format(1.0) +7 7 | "{0.real}".format(1.0) +8 |-"{a.real}".format(a=1.0) + 8 |+f"{1.0.real}" +9 9 | +10 10 | "{.real}".format(1j) +11 11 | "{0.real}".format(1j) + +UP032_2.py:10:1: UP032 [*] Use f-string instead of `format` call + | + 8 | "{a.real}".format(a=1.0) + 9 | +10 | "{.real}".format(1j) + | ^^^^^^^^^^^^^^^^^^^^ UP032 +11 | "{0.real}".format(1j) +12 | "{a.real}".format(a=1j) + | + = help: Convert to f-string + +ℹ Suggested fix +7 7 | "{0.real}".format(1.0) +8 8 | "{a.real}".format(a=1.0) +9 9 | +10 |-"{.real}".format(1j) + 10 |+f"{1j.real}" +11 11 | "{0.real}".format(1j) +12 12 | "{a.real}".format(a=1j) +13 13 | + +UP032_2.py:11:1: UP032 [*] Use f-string instead of `format` call + | +10 | "{.real}".format(1j) +11 | "{0.real}".format(1j) + | ^^^^^^^^^^^^^^^^^^^^^ UP032 +12 | "{a.real}".format(a=1j) + | + = help: Convert to f-string + +ℹ Suggested fix +8 8 | "{a.real}".format(a=1.0) +9 9 | +10 10 | "{.real}".format(1j) +11 |-"{0.real}".format(1j) + 11 |+f"{1j.real}" +12 12 | "{a.real}".format(a=1j) +13 13 | +14 14 | "{.real}".format(0b01) + +UP032_2.py:12:1: UP032 [*] Use f-string instead of `format` call + | +10 | "{.real}".format(1j) +11 | "{0.real}".format(1j) +12 | "{a.real}".format(a=1j) + | ^^^^^^^^^^^^^^^^^^^^^^^ UP032 +13 | +14 | "{.real}".format(0b01) + | + = help: Convert to f-string + +ℹ Suggested fix +9 9 | +10 10 | "{.real}".format(1j) +11 11 | "{0.real}".format(1j) +12 |-"{a.real}".format(a=1j) + 12 |+f"{1j.real}" +13 13 | +14 14 | "{.real}".format(0b01) +15 15 | "{0.real}".format(0b01) + +UP032_2.py:14:1: UP032 [*] Use f-string instead of `format` call + | +12 | "{a.real}".format(a=1j) +13 | +14 | "{.real}".format(0b01) + | ^^^^^^^^^^^^^^^^^^^^^^ UP032 +15 | "{0.real}".format(0b01) +16 | "{a.real}".format(a=0b01) + | + = help: Convert to f-string + +ℹ Suggested fix +11 11 | "{0.real}".format(1j) +12 12 | "{a.real}".format(a=1j) +13 13 | +14 |-"{.real}".format(0b01) + 14 |+f"{0b01.real}" +15 15 | "{0.real}".format(0b01) +16 16 | "{a.real}".format(a=0b01) +17 17 | + +UP032_2.py:15:1: UP032 [*] Use f-string instead of `format` call + | +14 | "{.real}".format(0b01) +15 | "{0.real}".format(0b01) + | ^^^^^^^^^^^^^^^^^^^^^^^ UP032 +16 | "{a.real}".format(a=0b01) + | + = help: Convert to f-string + +ℹ Suggested fix +12 12 | "{a.real}".format(a=1j) +13 13 | +14 14 | "{.real}".format(0b01) +15 |-"{0.real}".format(0b01) + 15 |+f"{0b01.real}" +16 16 | "{a.real}".format(a=0b01) +17 17 | +18 18 | "{}".format(1 + 2) + +UP032_2.py:16:1: UP032 [*] Use f-string instead of `format` call + | +14 | "{.real}".format(0b01) +15 | "{0.real}".format(0b01) +16 | "{a.real}".format(a=0b01) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 +17 | +18 | "{}".format(1 + 2) + | + = help: Convert to f-string + +ℹ Suggested fix +13 13 | +14 14 | "{.real}".format(0b01) +15 15 | "{0.real}".format(0b01) +16 |-"{a.real}".format(a=0b01) + 16 |+f"{0b01.real}" +17 17 | +18 18 | "{}".format(1 + 2) +19 19 | "{}".format([1, 2]) + +UP032_2.py:18:1: UP032 [*] Use f-string instead of `format` call + | +16 | "{a.real}".format(a=0b01) +17 | +18 | "{}".format(1 + 2) + | ^^^^^^^^^^^^^^^^^^ UP032 +19 | "{}".format([1, 2]) +20 | "{}".format({1, 2}) + | + = help: Convert to f-string + +ℹ Suggested fix +15 15 | "{0.real}".format(0b01) +16 16 | "{a.real}".format(a=0b01) +17 17 | +18 |-"{}".format(1 + 2) + 18 |+f"{1 + 2}" +19 19 | "{}".format([1, 2]) +20 20 | "{}".format({1, 2}) +21 21 | "{}".format({1: 2, 3: 4}) + +UP032_2.py:19:1: UP032 [*] Use f-string instead of `format` call + | +18 | "{}".format(1 + 2) +19 | "{}".format([1, 2]) + | ^^^^^^^^^^^^^^^^^^^ UP032 +20 | "{}".format({1, 2}) +21 | "{}".format({1: 2, 3: 4}) + | + = help: Convert to f-string + +ℹ Suggested fix +16 16 | "{a.real}".format(a=0b01) +17 17 | +18 18 | "{}".format(1 + 2) +19 |-"{}".format([1, 2]) + 19 |+f"{[1, 2]}" +20 20 | "{}".format({1, 2}) +21 21 | "{}".format({1: 2, 3: 4}) +22 22 | "{}".format((i for i in range(2))) + +UP032_2.py:20:1: UP032 [*] Use f-string instead of `format` call + | +18 | "{}".format(1 + 2) +19 | "{}".format([1, 2]) +20 | "{}".format({1, 2}) + | ^^^^^^^^^^^^^^^^^^^ UP032 +21 | "{}".format({1: 2, 3: 4}) +22 | "{}".format((i for i in range(2))) + | + = help: Convert to f-string + +ℹ Suggested fix +17 17 | +18 18 | "{}".format(1 + 2) +19 19 | "{}".format([1, 2]) +20 |-"{}".format({1, 2}) + 20 |+f"{({1, 2})}" +21 21 | "{}".format({1: 2, 3: 4}) +22 22 | "{}".format((i for i in range(2))) +23 23 | + +UP032_2.py:21:1: UP032 [*] Use f-string instead of `format` call + | +19 | "{}".format([1, 2]) +20 | "{}".format({1, 2}) +21 | "{}".format({1: 2, 3: 4}) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 +22 | "{}".format((i for i in range(2))) + | + = help: Convert to f-string + +ℹ Suggested fix +18 18 | "{}".format(1 + 2) +19 19 | "{}".format([1, 2]) +20 20 | "{}".format({1, 2}) +21 |-"{}".format({1: 2, 3: 4}) + 21 |+f"{({1: 2, 3: 4})}" +22 22 | "{}".format((i for i in range(2))) +23 23 | +24 24 | "{.real}".format(1 + 2) + +UP032_2.py:22:1: UP032 [*] Use f-string instead of `format` call + | +20 | "{}".format({1, 2}) +21 | "{}".format({1: 2, 3: 4}) +22 | "{}".format((i for i in range(2))) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 +23 | +24 | "{.real}".format(1 + 2) + | + = help: Convert to f-string + +ℹ Suggested fix +19 19 | "{}".format([1, 2]) +20 20 | "{}".format({1, 2}) +21 21 | "{}".format({1: 2, 3: 4}) +22 |-"{}".format((i for i in range(2))) + 22 |+f"{(i for i in range(2))}" +23 23 | +24 24 | "{.real}".format(1 + 2) +25 25 | "{.real}".format([1, 2]) + +UP032_2.py:24:1: UP032 [*] Use f-string instead of `format` call + | +22 | "{}".format((i for i in range(2))) +23 | +24 | "{.real}".format(1 + 2) + | ^^^^^^^^^^^^^^^^^^^^^^^ UP032 +25 | "{.real}".format([1, 2]) +26 | "{.real}".format({1, 2}) + | + = help: Convert to f-string + +ℹ Suggested fix +21 21 | "{}".format({1: 2, 3: 4}) +22 22 | "{}".format((i for i in range(2))) +23 23 | +24 |-"{.real}".format(1 + 2) + 24 |+f"{(1 + 2).real}" +25 25 | "{.real}".format([1, 2]) +26 26 | "{.real}".format({1, 2}) +27 27 | "{.real}".format({1: 2, 3: 4}) + +UP032_2.py:25:1: UP032 [*] Use f-string instead of `format` call + | +24 | "{.real}".format(1 + 2) +25 | "{.real}".format([1, 2]) + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 +26 | "{.real}".format({1, 2}) +27 | "{.real}".format({1: 2, 3: 4}) + | + = help: Convert to f-string + +ℹ Suggested fix +22 22 | "{}".format((i for i in range(2))) +23 23 | +24 24 | "{.real}".format(1 + 2) +25 |-"{.real}".format([1, 2]) + 25 |+f"{[1, 2].real}" +26 26 | "{.real}".format({1, 2}) +27 27 | "{.real}".format({1: 2, 3: 4}) +28 28 | "{}".format((i for i in range(2))) + +UP032_2.py:26:1: UP032 [*] Use f-string instead of `format` call + | +24 | "{.real}".format(1 + 2) +25 | "{.real}".format([1, 2]) +26 | "{.real}".format({1, 2}) + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP032 +27 | "{.real}".format({1: 2, 3: 4}) +28 | "{}".format((i for i in range(2))) + | + = help: Convert to f-string + +ℹ Suggested fix +23 23 | +24 24 | "{.real}".format(1 + 2) +25 25 | "{.real}".format([1, 2]) +26 |-"{.real}".format({1, 2}) + 26 |+f"{({1, 2}).real}" +27 27 | "{.real}".format({1: 2, 3: 4}) +28 28 | "{}".format((i for i in range(2))) + +UP032_2.py:27:1: UP032 [*] Use f-string instead of `format` call + | +25 | "{.real}".format([1, 2]) +26 | "{.real}".format({1, 2}) +27 | "{.real}".format({1: 2, 3: 4}) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 +28 | "{}".format((i for i in range(2))) + | + = help: Convert to f-string + +ℹ Suggested fix +24 24 | "{.real}".format(1 + 2) +25 25 | "{.real}".format([1, 2]) +26 26 | "{.real}".format({1, 2}) +27 |-"{.real}".format({1: 2, 3: 4}) + 27 |+f"{({1: 2, 3: 4}).real}" +28 28 | "{}".format((i for i in range(2))) + +UP032_2.py:28:1: UP032 [*] Use f-string instead of `format` call + | +26 | "{.real}".format({1, 2}) +27 | "{.real}".format({1: 2, 3: 4}) +28 | "{}".format((i for i in range(2))) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP032 + | + = help: Convert to f-string + +ℹ Suggested fix +25 25 | "{.real}".format([1, 2]) +26 26 | "{.real}".format({1, 2}) +27 27 | "{.real}".format({1: 2, 3: 4}) +28 |-"{}".format((i for i in range(2))) + 28 |+f"{(i for i in range(2))}" + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_0.py.snap new file mode 100644 index 0000000000..48a3154a98 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_0.py.snap @@ -0,0 +1,62 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP033_0.py:4:21: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` + | +4 | @functools.lru_cache(maxsize=None) + | ^^^^^^^^^^^^^^ UP033 +5 | def fixme(): +6 | pass + | + = help: Rewrite with `@functools.cache + +ℹ Fix +1 1 | import functools +2 2 | +3 3 | +4 |-@functools.lru_cache(maxsize=None) + 4 |+@functools.cache +5 5 | def fixme(): +6 6 | pass +7 7 | + +UP033_0.py:10:21: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` + | + 9 | @other_decorator +10 | @functools.lru_cache(maxsize=None) + | ^^^^^^^^^^^^^^ UP033 +11 | def fixme(): +12 | pass + | + = help: Rewrite with `@functools.cache + +ℹ Fix +7 7 | +8 8 | +9 9 | @other_decorator +10 |-@functools.lru_cache(maxsize=None) + 10 |+@functools.cache +11 11 | def fixme(): +12 12 | pass +13 13 | + +UP033_0.py:15:21: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` + | +15 | @functools.lru_cache(maxsize=None) + | ^^^^^^^^^^^^^^ UP033 +16 | @other_decorator +17 | def fixme(): + | + = help: Rewrite with `@functools.cache + +ℹ Fix +12 12 | pass +13 13 | +14 14 | +15 |-@functools.lru_cache(maxsize=None) + 15 |+@functools.cache +16 16 | @other_decorator +17 17 | def fixme(): +18 18 | pass + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_1.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_1.py.snap new file mode 100644 index 0000000000..5e4cfa4b7a --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP033_1.py.snap @@ -0,0 +1,75 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP033_1.py:4:11: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` + | +4 | @lru_cache(maxsize=None) + | ^^^^^^^^^^^^^^ UP033 +5 | def fixme(): +6 | pass + | + = help: Rewrite with `@functools.cache + +ℹ Fix +1 |-from functools import lru_cache + 1 |+from functools import lru_cache, cache +2 2 | +3 3 | +4 |-@lru_cache(maxsize=None) + 4 |+@cache +5 5 | def fixme(): +6 6 | pass +7 7 | + +UP033_1.py:10:11: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` + | + 9 | @other_decorator +10 | @lru_cache(maxsize=None) + | ^^^^^^^^^^^^^^ UP033 +11 | def fixme(): +12 | pass + | + = help: Rewrite with `@functools.cache + +ℹ Fix +1 |-from functools import lru_cache + 1 |+from functools import lru_cache, cache +2 2 | +3 3 | +4 4 | @lru_cache(maxsize=None) +-------------------------------------------------------------------------------- +7 7 | +8 8 | +9 9 | @other_decorator +10 |-@lru_cache(maxsize=None) + 10 |+@cache +11 11 | def fixme(): +12 12 | pass +13 13 | + +UP033_1.py:15:11: UP033 [*] Use `@functools.cache` instead of `@functools.lru_cache(maxsize=None)` + | +15 | @lru_cache(maxsize=None) + | ^^^^^^^^^^^^^^ UP033 +16 | @other_decorator +17 | def fixme(): + | + = help: Rewrite with `@functools.cache + +ℹ Fix +1 |-from functools import lru_cache + 1 |+from functools import lru_cache, cache +2 2 | +3 3 | +4 4 | @lru_cache(maxsize=None) +-------------------------------------------------------------------------------- +12 12 | pass +13 13 | +14 14 | +15 |-@lru_cache(maxsize=None) + 15 |+@cache +16 16 | @other_decorator +17 17 | def fixme(): +18 18 | pass + + 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 new file mode 100644 index 0000000000..80779d2ad6 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP034.py.snap @@ -0,0 +1,209 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP034.py:2:7: UP034 [*] Avoid extraneous parentheses + | +1 | # UP034 +2 | print(("foo")) + | ^^^^^^^ UP034 +3 | +4 | # UP034 + | + = help: Remove extraneous parentheses + +ℹ Fix +1 1 | # UP034 +2 |-print(("foo")) + 2 |+print("foo") +3 3 | +4 4 | # UP034 +5 5 | print(("hell((goodybe))o")) + +UP034.py:5:7: UP034 [*] Avoid extraneous parentheses + | +4 | # UP034 +5 | print(("hell((goodybe))o")) + | ^^^^^^^^^^^^^^^^^^^^ UP034 +6 | +7 | # UP034 + | + = help: Remove extraneous parentheses + +ℹ Fix +2 2 | print(("foo")) +3 3 | +4 4 | # UP034 +5 |-print(("hell((goodybe))o")) + 5 |+print("hell((goodybe))o") +6 6 | +7 7 | # UP034 +8 8 | print((("foo"))) + +UP034.py:8:7: UP034 [*] Avoid extraneous parentheses + | + 7 | # UP034 + 8 | print((("foo"))) + | ^^^^^^^^^ UP034 + 9 | +10 | # UP034 + | + = help: Remove extraneous parentheses + +ℹ Fix +5 5 | print(("hell((goodybe))o")) +6 6 | +7 7 | # UP034 +8 |-print((("foo"))) + 8 |+print(("foo")) +9 9 | +10 10 | # UP034 +11 11 | print((((1)))) + +UP034.py:11:7: UP034 [*] Avoid extraneous parentheses + | +10 | # UP034 +11 | print((((1)))) + | ^^^^^^^ UP034 +12 | +13 | # UP034 + | + = help: Remove extraneous parentheses + +ℹ Fix +8 8 | print((("foo"))) +9 9 | +10 10 | # UP034 +11 |-print((((1)))) + 11 |+print(((1))) +12 12 | +13 13 | # UP034 +14 14 | print(("foo{}".format(1))) + +UP034.py:14:7: UP034 [*] Avoid extraneous parentheses + | +13 | # UP034 +14 | print(("foo{}".format(1))) + | ^^^^^^^^^^^^^^^^^^^ UP034 +15 | +16 | # UP034 + | + = help: Remove extraneous parentheses + +ℹ Fix +11 11 | print((((1)))) +12 12 | +13 13 | # UP034 +14 |-print(("foo{}".format(1))) + 14 |+print("foo{}".format(1)) +15 15 | +16 16 | # UP034 +17 17 | print( + +UP034.py:18:5: UP034 [*] Avoid extraneous parentheses + | +16 | # UP034 +17 | print( +18 | ("foo{}".format(1)) + | ^^^^^^^^^^^^^^^^^^^ UP034 +19 | ) + | + = help: Remove extraneous parentheses + +ℹ Fix +15 15 | +16 16 | # UP034 +17 17 | print( +18 |- ("foo{}".format(1)) + 18 |+ "foo{}".format(1) +19 19 | ) +20 20 | +21 21 | # UP034 + +UP034.py:23:5: UP034 [*] Avoid extraneous parentheses + | +21 | # UP034 +22 | print( +23 | ( + | _____^ +24 | | "foo" +25 | | ) + | |_____^ UP034 +26 | ) + | + = help: Remove extraneous parentheses + +ℹ Fix +20 20 | +21 21 | # UP034 +22 22 | print( +23 |- ( + 23 |+ +24 24 | "foo" +25 |- ) + 25 |+ +26 26 | ) +27 27 | +28 28 | # UP034 + +UP034.py:30:13: UP034 [*] Avoid extraneous parentheses + | +28 | # UP034 +29 | def f(): +30 | x = int(((yield 1))) + | ^^^^^^^^^^^ UP034 +31 | +32 | # UP034 + | + = help: Remove extraneous parentheses + +ℹ Fix +27 27 | +28 28 | # UP034 +29 29 | def f(): +30 |- x = int(((yield 1))) + 30 |+ x = int((yield 1)) +31 31 | +32 32 | # UP034 +33 33 | if True: + +UP034.py:35:9: UP034 [*] Avoid extraneous parentheses + | +33 | if True: +34 | print( +35 | ("foo{}".format(1)) + | ^^^^^^^^^^^^^^^^^^^ UP034 +36 | ) + | + = help: Remove extraneous parentheses + +ℹ Fix +32 32 | # UP034 +33 33 | if True: +34 34 | print( +35 |- ("foo{}".format(1)) + 35 |+ "foo{}".format(1) +36 36 | ) +37 37 | +38 38 | # UP034 + +UP034.py:39:7: UP034 [*] Avoid extraneous parentheses + | +38 | # UP034 +39 | print((x for x in range(3))) + | ^^^^^^^^^^^^^^^^^^^^^ UP034 +40 | +41 | # OK + | + = help: Remove extraneous parentheses + +ℹ Fix +36 36 | ) +37 37 | +38 38 | # UP034 +39 |-print((x for x in range(3))) + 39 |+print(x for x in range(3)) +40 40 | +41 41 | # OK +42 42 | print("foo") + + 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 new file mode 100644 index 0000000000..4f8c750737 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP035.py.snap @@ -0,0 +1,1033 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP035.py:2:1: UP035 [*] Import from `collections.abc` instead: `Mapping` + | +1 | # UP035 +2 | from collections import Mapping + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +3 | +4 | from collections import Mapping as MAP + | + = help: Import from `collections.abc` + +ℹ Suggested fix +1 1 | # UP035 +2 |-from collections import Mapping + 2 |+from collections.abc import Mapping +3 3 | +4 4 | from collections import Mapping as MAP +5 5 | + +UP035.py:4:1: UP035 [*] Import from `collections.abc` instead: `Mapping` + | +2 | from collections import Mapping +3 | +4 | from collections import Mapping as MAP + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +5 | +6 | from collections import Mapping, Sequence + | + = help: Import from `collections.abc` + +ℹ Suggested fix +1 1 | # UP035 +2 2 | from collections import Mapping +3 3 | +4 |-from collections import Mapping as MAP + 4 |+from collections.abc import Mapping as MAP +5 5 | +6 6 | from collections import Mapping, Sequence +7 7 | + +UP035.py:6:1: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Sequence` + | +4 | from collections import Mapping as MAP +5 | +6 | from collections import Mapping, Sequence + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +7 | +8 | from collections import Counter, Mapping + | + = help: Import from `collections.abc` + +ℹ Suggested fix +3 3 | +4 4 | from collections import Mapping as MAP +5 5 | +6 |-from collections import Mapping, Sequence + 6 |+from collections.abc import Mapping, Sequence +7 7 | +8 8 | from collections import Counter, Mapping +9 9 | + +UP035.py:8:1: UP035 [*] Import from `collections.abc` instead: `Mapping` + | + 6 | from collections import Mapping, Sequence + 7 | + 8 | from collections import Counter, Mapping + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + 9 | +10 | from collections import (Counter, Mapping) + | + = help: Import from `collections.abc` + +ℹ Suggested fix +5 5 | +6 6 | from collections import Mapping, Sequence +7 7 | +8 |-from collections import Counter, Mapping + 8 |+from collections import Counter + 9 |+from collections.abc import Mapping +9 10 | +10 11 | from collections import (Counter, Mapping) +11 12 | + +UP035.py:10:1: UP035 [*] Import from `collections.abc` instead: `Mapping` + | + 8 | from collections import Counter, Mapping + 9 | +10 | from collections import (Counter, Mapping) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +11 | +12 | from collections import (Counter, + | + = help: Import from `collections.abc` + +ℹ Suggested fix +7 7 | +8 8 | from collections import Counter, Mapping +9 9 | +10 |-from collections import (Counter, Mapping) + 10 |+from collections import (Counter) + 11 |+from collections.abc import Mapping +11 12 | +12 13 | from collections import (Counter, +13 14 | Mapping) + +UP035.py:12:1: UP035 [*] Import from `collections.abc` instead: `Mapping` + | +10 | from collections import (Counter, Mapping) +11 | +12 | / from collections import (Counter, +13 | | Mapping) + | |_________________________________^ UP035 +14 | +15 | from collections import Counter, \ + | + = help: Import from `collections.abc` + +ℹ Suggested fix +9 9 | +10 10 | from collections import (Counter, Mapping) +11 11 | +12 |-from collections import (Counter, +13 |- Mapping) + 12 |+from collections import (Counter) + 13 |+from collections.abc import Mapping +14 14 | +15 15 | from collections import Counter, \ +16 16 | Mapping + +UP035.py:15:1: UP035 [*] Import from `collections.abc` instead: `Mapping` + | +13 | Mapping) +14 | +15 | / from collections import Counter, \ +16 | | Mapping + | |________________________________^ UP035 +17 | +18 | from collections import Counter, Mapping, Sequence + | + = help: Import from `collections.abc` + +ℹ Suggested fix +12 12 | from collections import (Counter, +13 13 | Mapping) +14 14 | +15 |-from collections import Counter, \ +16 |- Mapping + 15 |+from collections import Counter + 16 |+from collections.abc import Mapping +17 17 | +18 18 | from collections import Counter, Mapping, Sequence +19 19 | + +UP035.py:18:1: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Sequence` + | +16 | Mapping +17 | +18 | from collections import Counter, Mapping, Sequence + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +19 | +20 | from collections import Mapping as mapping, Counter + | + = help: Import from `collections.abc` + +ℹ Suggested fix +15 15 | from collections import Counter, \ +16 16 | Mapping +17 17 | +18 |-from collections import Counter, Mapping, Sequence + 18 |+from collections import Counter + 19 |+from collections.abc import Mapping, Sequence +19 20 | +20 21 | from collections import Mapping as mapping, Counter +21 22 | + +UP035.py:20:1: UP035 [*] Import from `collections.abc` instead: `Mapping` + | +18 | from collections import Counter, Mapping, Sequence +19 | +20 | from collections import Mapping as mapping, Counter + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +21 | +22 | if True: + | + = help: Import from `collections.abc` + +ℹ Suggested fix +17 17 | +18 18 | from collections import Counter, Mapping, Sequence +19 19 | +20 |-from collections import Mapping as mapping, Counter + 20 |+from collections import Counter + 21 |+from collections.abc import Mapping as mapping +21 22 | +22 23 | if True: +23 24 | from collections import Mapping, Counter + +UP035.py:23:5: UP035 [*] Import from `collections.abc` instead: `Mapping` + | +22 | if True: +23 | from collections import Mapping, Counter + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +24 | +25 | if True: + | + = help: Import from `collections.abc` + +ℹ Suggested fix +20 20 | from collections import Mapping as mapping, Counter +21 21 | +22 22 | if True: +23 |- from collections import Mapping, Counter + 23 |+ from collections import Counter + 24 |+ from collections.abc import Mapping +24 25 | +25 26 | if True: +26 27 | if True: + +UP035.py:28:5: UP035 [*] Import from `collections.abc` instead: `Mapping` + | +26 | if True: +27 | pass +28 | from collections import Mapping, Counter + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +29 | +30 | if True: from collections import Mapping + | + = help: Import from `collections.abc` + +ℹ Suggested fix +25 25 | if True: +26 26 | if True: +27 27 | pass +28 |- from collections import Mapping, Counter + 28 |+ from collections import Counter + 29 |+ from collections.abc import Mapping +29 30 | +30 31 | if True: from collections import Mapping +31 32 | + +UP035.py:30:10: UP035 [*] Import from `collections.abc` instead: `Mapping` + | +28 | from collections import Mapping, Counter +29 | +30 | if True: from collections import Mapping + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +31 | +32 | import os + | + = help: Import from `collections.abc` + +ℹ Suggested fix +27 27 | pass +28 28 | from collections import Mapping, Counter +29 29 | +30 |-if True: from collections import Mapping + 30 |+if True: from collections.abc import Mapping +31 31 | +32 32 | import os +33 33 | from collections import Counter, Mapping + +UP035.py:33:1: UP035 [*] Import from `collections.abc` instead: `Mapping` + | +32 | import os +33 | from collections import Counter, Mapping + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +34 | import sys + | + = help: Import from `collections.abc` + +ℹ Suggested fix +30 30 | if True: from collections import Mapping +31 31 | +32 32 | import os +33 |-from collections import Counter, Mapping + 33 |+from collections import Counter + 34 |+from collections.abc import Mapping +34 35 | import sys +35 36 | +36 37 | if True: + +UP035.py:37:5: UP035 [*] Import from `collections.abc` instead: `Mapping`, `Callable` + | +36 | if True: +37 | from collections import ( + | _____^ +38 | | Mapping, +39 | | Callable, +40 | | Bad, +41 | | Good, +42 | | ) + | |_____^ UP035 +43 | +44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager + | + = help: Import from `collections.abc` + +ℹ Suggested fix +35 35 | +36 36 | if True: +37 37 | from collections import ( +38 |- Mapping, +39 |- Callable, +40 38 | Bad, +41 39 | Good, +42 40 | ) + 41 |+ from collections.abc import Mapping, Callable +43 42 | +44 43 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager +45 44 | + +UP035.py:44:1: UP035 [*] Import from `collections.abc` instead: `Callable` + | +42 | ) +43 | +44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +45 | +46 | if True: from collections import ( + | + = help: Import from `collections.abc` + +ℹ Suggested fix +41 41 | Good, +42 42 | ) +43 43 | +44 |-from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager + 44 |+from typing import Match, Pattern, List, OrderedDict, AbstractSet, ContextManager + 45 |+from collections.abc import Callable +45 46 | +46 47 | if True: from collections import ( +47 48 | Mapping, Counter) + +UP035.py:44:1: UP035 [*] Import from `collections` instead: `OrderedDict` + | +42 | ) +43 | +44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +45 | +46 | if True: from collections import ( + | + = help: Import from `collections` + +ℹ Suggested fix +41 41 | Good, +42 42 | ) +43 43 | +44 |-from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager + 44 |+from typing import Callable, Match, Pattern, List, AbstractSet, ContextManager + 45 |+from collections import OrderedDict +45 46 | +46 47 | if True: from collections import ( +47 48 | Mapping, Counter) + +UP035.py:44:1: UP035 [*] Import from `re` instead: `Match`, `Pattern` + | +42 | ) +43 | +44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +45 | +46 | if True: from collections import ( + | + = help: Import from `re` + +ℹ Suggested fix +41 41 | Good, +42 42 | ) +43 43 | +44 |-from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager + 44 |+from typing import Callable, List, OrderedDict, AbstractSet, ContextManager + 45 |+from re import Match, Pattern +45 46 | +46 47 | if True: from collections import ( +47 48 | Mapping, Counter) + +UP035.py:44:1: UP035 `typing.List` is deprecated, use `list` instead + | +42 | ) +43 | +44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +45 | +46 | if True: from collections import ( + | + +UP035.py:44:1: UP035 `typing.AbstractSet` is deprecated, use `collections.abc.Set` instead + | +42 | ) +43 | +44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +45 | +46 | if True: from collections import ( + | + +UP035.py:44:1: UP035 `typing.ContextManager` is deprecated, use `contextlib.AbstractContextManager` instead + | +42 | ) +43 | +44 | from typing import Callable, Match, Pattern, List, OrderedDict, AbstractSet, ContextManager + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +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 | +46 | if True: from collections import ( + | __________^ +47 | | Mapping, Counter) + | |_____________________^ UP035 +48 | +49 | # Bad imports from PYI027 that are now handled by PYI022 (UP035) + | + = help: Import from `collections.abc` + +UP035.py:50:1: UP035 `typing.ContextManager` is deprecated, use `contextlib.AbstractContextManager` instead + | +49 | # Bad imports from PYI027 that are now handled by PYI022 (UP035) +50 | from typing import ContextManager + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +51 | from typing import OrderedDict +52 | from typing_extensions import OrderedDict + | + +UP035.py:51:1: UP035 [*] Import from `collections` instead: `OrderedDict` + | +49 | # Bad imports from PYI027 that are now handled by PYI022 (UP035) +50 | from typing import ContextManager +51 | from typing import OrderedDict + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +52 | from typing_extensions import OrderedDict +53 | from typing import Callable + | + = help: Import from `collections` + +ℹ Suggested fix +48 48 | +49 49 | # Bad imports from PYI027 that are now handled by PYI022 (UP035) +50 50 | from typing import ContextManager +51 |-from typing import OrderedDict + 51 |+from collections import OrderedDict +52 52 | from typing_extensions import OrderedDict +53 53 | from typing import Callable +54 54 | from typing import ByteString + +UP035.py:52:1: UP035 [*] Import from `typing` instead: `OrderedDict` + | +50 | from typing import ContextManager +51 | from typing import OrderedDict +52 | from typing_extensions import OrderedDict + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +53 | from typing import Callable +54 | from typing import ByteString + | + = help: Import from `typing` + +ℹ Suggested fix +49 49 | # Bad imports from PYI027 that are now handled by PYI022 (UP035) +50 50 | from typing import ContextManager +51 51 | from typing import OrderedDict +52 |-from typing_extensions import OrderedDict + 52 |+from typing import OrderedDict +53 53 | from typing import Callable +54 54 | from typing import ByteString +55 55 | from typing import Container + +UP035.py:53:1: UP035 [*] Import from `collections.abc` instead: `Callable` + | +51 | from typing import OrderedDict +52 | from typing_extensions import OrderedDict +53 | from typing import Callable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +54 | from typing import ByteString +55 | from typing import Container + | + = help: Import from `collections.abc` + +ℹ Suggested fix +50 50 | from typing import ContextManager +51 51 | from typing import OrderedDict +52 52 | from typing_extensions import OrderedDict +53 |-from typing import Callable + 53 |+from collections.abc import Callable +54 54 | from typing import ByteString +55 55 | from typing import Container +56 56 | from typing import Hashable + +UP035.py:54:1: UP035 [*] Import from `collections.abc` instead: `ByteString` + | +52 | from typing_extensions import OrderedDict +53 | from typing import Callable +54 | from typing import ByteString + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +55 | from typing import Container +56 | from typing import Hashable + | + = help: Import from `collections.abc` + +ℹ Suggested fix +51 51 | from typing import OrderedDict +52 52 | from typing_extensions import OrderedDict +53 53 | from typing import Callable +54 |-from typing import ByteString + 54 |+from collections.abc import ByteString +55 55 | from typing import Container +56 56 | from typing import Hashable +57 57 | from typing import ItemsView + +UP035.py:55:1: UP035 [*] Import from `collections.abc` instead: `Container` + | +53 | from typing import Callable +54 | from typing import ByteString +55 | from typing import Container + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +56 | from typing import Hashable +57 | from typing import ItemsView + | + = help: Import from `collections.abc` + +ℹ Suggested fix +52 52 | from typing_extensions import OrderedDict +53 53 | from typing import Callable +54 54 | from typing import ByteString +55 |-from typing import Container + 55 |+from collections.abc import Container +56 56 | from typing import Hashable +57 57 | from typing import ItemsView +58 58 | from typing import Iterable + +UP035.py:56:1: UP035 [*] Import from `collections.abc` instead: `Hashable` + | +54 | from typing import ByteString +55 | from typing import Container +56 | from typing import Hashable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +57 | from typing import ItemsView +58 | from typing import Iterable + | + = help: Import from `collections.abc` + +ℹ Suggested fix +53 53 | from typing import Callable +54 54 | from typing import ByteString +55 55 | from typing import Container +56 |-from typing import Hashable + 56 |+from collections.abc import Hashable +57 57 | from typing import ItemsView +58 58 | from typing import Iterable +59 59 | from typing import Iterator + +UP035.py:57:1: UP035 [*] Import from `collections.abc` instead: `ItemsView` + | +55 | from typing import Container +56 | from typing import Hashable +57 | from typing import ItemsView + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +58 | from typing import Iterable +59 | from typing import Iterator + | + = help: Import from `collections.abc` + +ℹ Suggested fix +54 54 | from typing import ByteString +55 55 | from typing import Container +56 56 | from typing import Hashable +57 |-from typing import ItemsView + 57 |+from collections.abc import ItemsView +58 58 | from typing import Iterable +59 59 | from typing import Iterator +60 60 | from typing import KeysView + +UP035.py:58:1: UP035 [*] Import from `collections.abc` instead: `Iterable` + | +56 | from typing import Hashable +57 | from typing import ItemsView +58 | from typing import Iterable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +59 | from typing import Iterator +60 | from typing import KeysView + | + = help: Import from `collections.abc` + +ℹ Suggested fix +55 55 | from typing import Container +56 56 | from typing import Hashable +57 57 | from typing import ItemsView +58 |-from typing import Iterable + 58 |+from collections.abc import Iterable +59 59 | from typing import Iterator +60 60 | from typing import KeysView +61 61 | from typing import Mapping + +UP035.py:59:1: UP035 [*] Import from `collections.abc` instead: `Iterator` + | +57 | from typing import ItemsView +58 | from typing import Iterable +59 | from typing import Iterator + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +60 | from typing import KeysView +61 | from typing import Mapping + | + = help: Import from `collections.abc` + +ℹ Suggested fix +56 56 | from typing import Hashable +57 57 | from typing import ItemsView +58 58 | from typing import Iterable +59 |-from typing import Iterator + 59 |+from collections.abc import Iterator +60 60 | from typing import KeysView +61 61 | from typing import Mapping +62 62 | from typing import MappingView + +UP035.py:60:1: UP035 [*] Import from `collections.abc` instead: `KeysView` + | +58 | from typing import Iterable +59 | from typing import Iterator +60 | from typing import KeysView + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +61 | from typing import Mapping +62 | from typing import MappingView + | + = help: Import from `collections.abc` + +ℹ Suggested fix +57 57 | from typing import ItemsView +58 58 | from typing import Iterable +59 59 | from typing import Iterator +60 |-from typing import KeysView + 60 |+from collections.abc import KeysView +61 61 | from typing import Mapping +62 62 | from typing import MappingView +63 63 | from typing import MutableMapping + +UP035.py:61:1: UP035 [*] Import from `collections.abc` instead: `Mapping` + | +59 | from typing import Iterator +60 | from typing import KeysView +61 | from typing import Mapping + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +62 | from typing import MappingView +63 | from typing import MutableMapping + | + = help: Import from `collections.abc` + +ℹ Suggested fix +58 58 | from typing import Iterable +59 59 | from typing import Iterator +60 60 | from typing import KeysView +61 |-from typing import Mapping + 61 |+from collections.abc import Mapping +62 62 | from typing import MappingView +63 63 | from typing import MutableMapping +64 64 | from typing import MutableSequence + +UP035.py:62:1: UP035 [*] Import from `collections.abc` instead: `MappingView` + | +60 | from typing import KeysView +61 | from typing import Mapping +62 | from typing import MappingView + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +63 | from typing import MutableMapping +64 | from typing import MutableSequence + | + = help: Import from `collections.abc` + +ℹ Suggested fix +59 59 | from typing import Iterator +60 60 | from typing import KeysView +61 61 | from typing import Mapping +62 |-from typing import MappingView + 62 |+from collections.abc import MappingView +63 63 | from typing import MutableMapping +64 64 | from typing import MutableSequence +65 65 | from typing import MutableSet + +UP035.py:63:1: UP035 [*] Import from `collections.abc` instead: `MutableMapping` + | +61 | from typing import Mapping +62 | from typing import MappingView +63 | from typing import MutableMapping + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +64 | from typing import MutableSequence +65 | from typing import MutableSet + | + = help: Import from `collections.abc` + +ℹ Suggested fix +60 60 | from typing import KeysView +61 61 | from typing import Mapping +62 62 | from typing import MappingView +63 |-from typing import MutableMapping + 63 |+from collections.abc import MutableMapping +64 64 | from typing import MutableSequence +65 65 | from typing import MutableSet +66 66 | from typing import Sequence + +UP035.py:64:1: UP035 [*] Import from `collections.abc` instead: `MutableSequence` + | +62 | from typing import MappingView +63 | from typing import MutableMapping +64 | from typing import MutableSequence + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +65 | from typing import MutableSet +66 | from typing import Sequence + | + = help: Import from `collections.abc` + +ℹ Suggested fix +61 61 | from typing import Mapping +62 62 | from typing import MappingView +63 63 | from typing import MutableMapping +64 |-from typing import MutableSequence + 64 |+from collections.abc import MutableSequence +65 65 | from typing import MutableSet +66 66 | from typing import Sequence +67 67 | from typing import Sized + +UP035.py:65:1: UP035 [*] Import from `collections.abc` instead: `MutableSet` + | +63 | from typing import MutableMapping +64 | from typing import MutableSequence +65 | from typing import MutableSet + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +66 | from typing import Sequence +67 | from typing import Sized + | + = help: Import from `collections.abc` + +ℹ Suggested fix +62 62 | from typing import MappingView +63 63 | from typing import MutableMapping +64 64 | from typing import MutableSequence +65 |-from typing import MutableSet + 65 |+from collections.abc import MutableSet +66 66 | from typing import Sequence +67 67 | from typing import Sized +68 68 | from typing import ValuesView + +UP035.py:66:1: UP035 [*] Import from `collections.abc` instead: `Sequence` + | +64 | from typing import MutableSequence +65 | from typing import MutableSet +66 | from typing import Sequence + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +67 | from typing import Sized +68 | from typing import ValuesView + | + = help: Import from `collections.abc` + +ℹ Suggested fix +63 63 | from typing import MutableMapping +64 64 | from typing import MutableSequence +65 65 | from typing import MutableSet +66 |-from typing import Sequence + 66 |+from collections.abc import Sequence +67 67 | from typing import Sized +68 68 | from typing import ValuesView +69 69 | from typing import Awaitable + +UP035.py:67:1: UP035 [*] Import from `collections.abc` instead: `Sized` + | +65 | from typing import MutableSet +66 | from typing import Sequence +67 | from typing import Sized + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +68 | from typing import ValuesView +69 | from typing import Awaitable + | + = help: Import from `collections.abc` + +ℹ Suggested fix +64 64 | from typing import MutableSequence +65 65 | from typing import MutableSet +66 66 | from typing import Sequence +67 |-from typing import Sized + 67 |+from collections.abc import Sized +68 68 | from typing import ValuesView +69 69 | from typing import Awaitable +70 70 | from typing import AsyncIterator + +UP035.py:68:1: UP035 [*] Import from `collections.abc` instead: `ValuesView` + | +66 | from typing import Sequence +67 | from typing import Sized +68 | from typing import ValuesView + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +69 | from typing import Awaitable +70 | from typing import AsyncIterator + | + = help: Import from `collections.abc` + +ℹ Suggested fix +65 65 | from typing import MutableSet +66 66 | from typing import Sequence +67 67 | from typing import Sized +68 |-from typing import ValuesView + 68 |+from collections.abc import ValuesView +69 69 | from typing import Awaitable +70 70 | from typing import AsyncIterator +71 71 | from typing import AsyncIterable + +UP035.py:69:1: UP035 [*] Import from `collections.abc` instead: `Awaitable` + | +67 | from typing import Sized +68 | from typing import ValuesView +69 | from typing import Awaitable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +70 | from typing import AsyncIterator +71 | from typing import AsyncIterable + | + = help: Import from `collections.abc` + +ℹ Suggested fix +66 66 | from typing import Sequence +67 67 | from typing import Sized +68 68 | from typing import ValuesView +69 |-from typing import Awaitable + 69 |+from collections.abc import Awaitable +70 70 | from typing import AsyncIterator +71 71 | from typing import AsyncIterable +72 72 | from typing import Coroutine + +UP035.py:70:1: UP035 [*] Import from `collections.abc` instead: `AsyncIterator` + | +68 | from typing import ValuesView +69 | from typing import Awaitable +70 | from typing import AsyncIterator + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +71 | from typing import AsyncIterable +72 | from typing import Coroutine + | + = help: Import from `collections.abc` + +ℹ Suggested fix +67 67 | from typing import Sized +68 68 | from typing import ValuesView +69 69 | from typing import Awaitable +70 |-from typing import AsyncIterator + 70 |+from collections.abc import AsyncIterator +71 71 | from typing import AsyncIterable +72 72 | from typing import Coroutine +73 73 | from typing import Collection + +UP035.py:71:1: UP035 [*] Import from `collections.abc` instead: `AsyncIterable` + | +69 | from typing import Awaitable +70 | from typing import AsyncIterator +71 | from typing import AsyncIterable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +72 | from typing import Coroutine +73 | from typing import Collection + | + = help: Import from `collections.abc` + +ℹ Suggested fix +68 68 | from typing import ValuesView +69 69 | from typing import Awaitable +70 70 | from typing import AsyncIterator +71 |-from typing import AsyncIterable + 71 |+from collections.abc import AsyncIterable +72 72 | from typing import Coroutine +73 73 | from typing import Collection +74 74 | from typing import AsyncGenerator + +UP035.py:72:1: UP035 [*] Import from `collections.abc` instead: `Coroutine` + | +70 | from typing import AsyncIterator +71 | from typing import AsyncIterable +72 | from typing import Coroutine + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +73 | from typing import Collection +74 | from typing import AsyncGenerator + | + = help: Import from `collections.abc` + +ℹ Suggested fix +69 69 | from typing import Awaitable +70 70 | from typing import AsyncIterator +71 71 | from typing import AsyncIterable +72 |-from typing import Coroutine + 72 |+from collections.abc import Coroutine +73 73 | from typing import Collection +74 74 | from typing import AsyncGenerator +75 75 | from typing import Reversible + +UP035.py:73:1: UP035 [*] Import from `collections.abc` instead: `Collection` + | +71 | from typing import AsyncIterable +72 | from typing import Coroutine +73 | from typing import Collection + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +74 | from typing import AsyncGenerator +75 | from typing import Reversible + | + = help: Import from `collections.abc` + +ℹ Suggested fix +70 70 | from typing import AsyncIterator +71 71 | from typing import AsyncIterable +72 72 | from typing import Coroutine +73 |-from typing import Collection + 73 |+from collections.abc import Collection +74 74 | from typing import AsyncGenerator +75 75 | from typing import Reversible +76 76 | from typing import Generator + +UP035.py:74:1: UP035 [*] Import from `collections.abc` instead: `AsyncGenerator` + | +72 | from typing import Coroutine +73 | from typing import Collection +74 | from typing import AsyncGenerator + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +75 | from typing import Reversible +76 | from typing import Generator + | + = help: Import from `collections.abc` + +ℹ Suggested fix +71 71 | from typing import AsyncIterable +72 72 | from typing import Coroutine +73 73 | from typing import Collection +74 |-from typing import AsyncGenerator + 74 |+from collections.abc import AsyncGenerator +75 75 | from typing import Reversible +76 76 | from typing import Generator +77 77 | from typing import Callable + +UP035.py:75:1: UP035 [*] Import from `collections.abc` instead: `Reversible` + | +73 | from typing import Collection +74 | from typing import AsyncGenerator +75 | from typing import Reversible + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +76 | from typing import Generator +77 | from typing import Callable + | + = help: Import from `collections.abc` + +ℹ Suggested fix +72 72 | from typing import Coroutine +73 73 | from typing import Collection +74 74 | from typing import AsyncGenerator +75 |-from typing import Reversible + 75 |+from collections.abc import Reversible +76 76 | from typing import Generator +77 77 | from typing import Callable +78 78 | from typing import cast + +UP035.py:76:1: UP035 [*] Import from `collections.abc` instead: `Generator` + | +74 | from typing import AsyncGenerator +75 | from typing import Reversible +76 | from typing import Generator + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +77 | from typing import Callable +78 | from typing import cast + | + = help: Import from `collections.abc` + +ℹ Suggested fix +73 73 | from typing import Collection +74 74 | from typing import AsyncGenerator +75 75 | from typing import Reversible +76 |-from typing import Generator + 76 |+from collections.abc import Generator +77 77 | from typing import Callable +78 78 | from typing import cast +79 79 | + +UP035.py:77:1: UP035 [*] Import from `collections.abc` instead: `Callable` + | +75 | from typing import Reversible +76 | from typing import Generator +77 | from typing import Callable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +78 | from typing import cast + | + = help: Import from `collections.abc` + +ℹ Suggested fix +74 74 | from typing import AsyncGenerator +75 75 | from typing import Reversible +76 76 | from typing import Generator +77 |-from typing import Callable + 77 |+from collections.abc import Callable +78 78 | from typing import cast +79 79 | +80 80 | # OK + +UP035.py:87:1: UP035 [*] Import from `typing` instead: `NamedTuple` + | +86 | # Ok: `typing_extensions` contains backported improvements. +87 | from typing_extensions import NamedTuple + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 +88 | +89 | # Ok: `typing_extensions` supports `frozen_default` (backported from 3.12). + | + = help: Import from `typing` + +ℹ Suggested fix +84 84 | from typing_extensions import SupportsIndex +85 85 | +86 86 | # Ok: `typing_extensions` contains backported improvements. +87 |-from typing_extensions import NamedTuple + 87 |+from typing import NamedTuple +88 88 | +89 89 | # Ok: `typing_extensions` supports `frozen_default` (backported from 3.12). +90 90 | from typing_extensions import dataclass_transform + +UP035.py:90:1: UP035 [*] Import from `typing` instead: `dataclass_transform` + | +89 | # Ok: `typing_extensions` supports `frozen_default` (backported from 3.12). +90 | from typing_extensions import dataclass_transform + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP035 + | + = help: Import from `typing` + +ℹ Suggested fix +87 87 | from typing_extensions import NamedTuple +88 88 | +89 89 | # Ok: `typing_extensions` supports `frozen_default` (backported from 3.12). +90 |-from typing_extensions import dataclass_transform + 90 |+from typing import dataclass_transform + + 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 new file mode 100644 index 0000000000..8c181b6544 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_0.py.snap @@ -0,0 +1,688 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP036_0.py:3:4: UP036 [*] Version block is outdated for minimum Python version + | +1 | import sys +2 | +3 | if sys.version_info < (3,0): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +4 | print("py2") +5 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +1 1 | import sys +2 2 | +3 |-if sys.version_info < (3,0): +4 |- print("py2") +5 |-else: +6 |- print("py3") + 3 |+print("py3") +7 4 | +8 5 | if sys.version_info < (3,0): +9 6 | if True: + +UP036_0.py:8:4: UP036 [*] Version block is outdated for minimum Python version + | + 6 | print("py3") + 7 | + 8 | if sys.version_info < (3,0): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 + 9 | if True: +10 | print("py2!") + | + = help: Remove outdated version block + +ℹ Suggested fix +5 5 | else: +6 6 | print("py3") +7 7 | +8 |-if sys.version_info < (3,0): +9 |- if True: +10 |- print("py2!") +11 |- else: +12 |- print("???") +13 |-else: +14 |- print("py3") + 8 |+print("py3") +15 9 | +16 10 | if sys.version_info < (3,0): print("PY2!") +17 11 | else: print("PY3!") + +UP036_0.py:16:4: UP036 [*] Version block is outdated for minimum Python version + | +14 | print("py3") +15 | +16 | if sys.version_info < (3,0): print("PY2!") + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +17 | else: print("PY3!") + | + = help: Remove outdated version block + +ℹ Suggested fix +13 13 | else: +14 14 | print("py3") +15 15 | +16 |-if sys.version_info < (3,0): print("PY2!") +17 |-else: print("PY3!") + 16 |+print("PY3!") +18 17 | +19 18 | if True: +20 19 | if sys.version_info < (3,0): + +UP036_0.py:20:8: UP036 [*] Version block is outdated for minimum Python version + | +19 | if True: +20 | if sys.version_info < (3,0): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +21 | print("PY2") +22 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +17 17 | else: print("PY3!") +18 18 | +19 19 | if True: +20 |- if sys.version_info < (3,0): +21 |- print("PY2") +22 |- else: +23 |- print("PY3") + 20 |+ print("PY3") +24 21 | +25 22 | if sys.version_info < (3,0): print(1 if True else 3) +26 23 | else: + +UP036_0.py:25:4: UP036 [*] Version block is outdated for minimum Python version + | +23 | print("PY3") +24 | +25 | if sys.version_info < (3,0): print(1 if True else 3) + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +26 | else: +27 | print("py3") + | + = help: Remove outdated version block + +ℹ Suggested fix +22 22 | else: +23 23 | print("PY3") +24 24 | +25 |-if sys.version_info < (3,0): print(1 if True else 3) +26 |-else: +27 |- print("py3") + 25 |+print("py3") +28 26 | +29 27 | if sys.version_info < (3,0): +30 28 | def f(): + +UP036_0.py:29:4: UP036 [*] Version block is outdated for minimum Python version + | +27 | print("py3") +28 | +29 | if sys.version_info < (3,0): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +30 | def f(): +31 | print("py2") + | + = help: Remove outdated version block + +ℹ Suggested fix +26 26 | else: +27 27 | print("py3") +28 28 | +29 |-if sys.version_info < (3,0): +30 |- def f(): +31 |- print("py2") +32 |-else: +33 |- def f(): +34 |- print("py3") +35 |- print("This the next") + 29 |+def f(): + 30 |+ print("py3") + 31 |+ print("This the next") +36 32 | +37 33 | if sys.version_info > (3,0): +38 34 | print("py3") + +UP036_0.py:37:4: UP036 [*] Version block is outdated for minimum Python version + | +35 | print("This the next") +36 | +37 | if sys.version_info > (3,0): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +38 | print("py3") +39 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +34 34 | print("py3") +35 35 | print("This the next") +36 36 | +37 |-if sys.version_info > (3,0): +38 |- print("py3") +39 |-else: +40 |- print("py2") + 37 |+print("py3") +41 38 | +42 39 | +43 40 | x = 1 + +UP036_0.py:45:4: UP036 [*] Version block is outdated for minimum Python version + | +43 | x = 1 +44 | +45 | if sys.version_info > (3,0): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +46 | print("py3") +47 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +42 42 | +43 43 | x = 1 +44 44 | +45 |-if sys.version_info > (3,0): +46 |- print("py3") +47 |-else: +48 |- print("py2") + 45 |+print("py3") +49 46 | # ohai +50 47 | +51 48 | x = 1 + +UP036_0.py:53:4: UP036 [*] Version block is outdated for minimum Python version + | +51 | x = 1 +52 | +53 | if sys.version_info > (3,0): print("py3") + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +54 | else: print("py2") + | + = help: Remove outdated version block + +ℹ Suggested fix +50 50 | +51 51 | x = 1 +52 52 | +53 |-if sys.version_info > (3,0): print("py3") +54 |-else: print("py2") + 53 |+print("py3") +55 54 | +56 55 | if sys.version_info > (3,): +57 56 | print("py3") + +UP036_0.py:56:4: UP036 [*] Version block is outdated for minimum Python version + | +54 | else: print("py2") +55 | +56 | if sys.version_info > (3,): + | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 +57 | print("py3") +58 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +53 53 | if sys.version_info > (3,0): print("py3") +54 54 | else: print("py2") +55 55 | +56 |-if sys.version_info > (3,): +57 |- print("py3") +58 |-else: +59 |- print("py2") + 56 |+print("py3") +60 57 | +61 58 | if True: +62 59 | if sys.version_info > (3,): + +UP036_0.py:62:8: UP036 [*] Version block is outdated for minimum Python version + | +61 | if True: +62 | if sys.version_info > (3,): + | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 +63 | print("py3") +64 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +59 59 | print("py2") +60 60 | +61 61 | if True: +62 |- if sys.version_info > (3,): +63 |- print("py3") +64 |- else: +65 |- print("py2") + 62 |+ print("py3") +66 63 | +67 64 | if sys.version_info < (3,): +68 65 | print("py2") + +UP036_0.py:67:4: UP036 [*] Version block is outdated for minimum Python version + | +65 | print("py2") +66 | +67 | if sys.version_info < (3,): + | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 +68 | print("py2") +69 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +64 64 | else: +65 65 | print("py2") +66 66 | +67 |-if sys.version_info < (3,): +68 |- print("py2") +69 |-else: +70 |- print("py3") + 67 |+print("py3") +71 68 | +72 69 | def f(): +73 70 | if sys.version_info < (3,0): + +UP036_0.py:73:8: UP036 [*] Version block is outdated for minimum Python version + | +72 | def f(): +73 | if sys.version_info < (3,0): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +74 | try: +75 | yield + | + = help: Remove outdated version block + +ℹ Suggested fix +70 70 | print("py3") +71 71 | +72 72 | def f(): +73 |- if sys.version_info < (3,0): +74 |- try: +75 |- yield +76 |- finally: +77 |- pass +78 |- else: +79 |- yield + 73 |+ yield +80 74 | +81 75 | +82 76 | class C: + +UP036_0.py:86:8: UP036 [*] Version block is outdated for minimum Python version + | +84 | pass +85 | +86 | if sys.version_info < (3,0): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +87 | def f(py2): +88 | pass + | + = help: Remove outdated version block + +ℹ Suggested fix +83 83 | def g(): +84 84 | pass +85 85 | +86 |- if sys.version_info < (3,0): +87 |- def f(py2): +88 |- pass +89 |- else: +90 |- def f(py3): +91 |- pass + 86 |+ def f(py3): + 87 |+ pass +92 88 | +93 89 | def h(): +94 90 | pass + +UP036_0.py:97:8: UP036 [*] Version block is outdated for minimum Python version + | +96 | if True: +97 | if sys.version_info < (3,0): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +98 | 2 +99 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +94 94 | pass +95 95 | +96 96 | if True: +97 |- if sys.version_info < (3,0): +98 |- 2 +99 |- else: +100 |- 3 + 97 |+ 3 +101 98 | +102 99 | # comment +103 100 | + +UP036_0.py:104:4: UP036 [*] Version block is outdated for minimum Python version + | +102 | # comment +103 | +104 | if sys.version_info < (3,0): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +105 | def f(): +106 | print("py2") + | + = help: Remove outdated version block + +ℹ Suggested fix +101 101 | +102 102 | # comment +103 103 | +104 |-if sys.version_info < (3,0): +105 |- def f(): +106 |- print("py2") +107 |- def g(): +108 |- print("py2") +109 |-else: +110 |- def f(): +111 |- print("py3") +112 |- def g(): +113 |- print("py3") + 104 |+def f(): + 105 |+ print("py3") + 106 |+def g(): + 107 |+ print("py3") +114 108 | +115 109 | if True: +116 110 | if sys.version_info > (3,): + +UP036_0.py:116:8: UP036 [*] Version block is outdated for minimum Python version + | +115 | if True: +116 | if sys.version_info > (3,): + | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 +117 | print(3) +118 | # comment + | + = help: Remove outdated version block + +ℹ Suggested fix +113 113 | print("py3") +114 114 | +115 115 | if True: +116 |- if sys.version_info > (3,): +117 |- print(3) + 116 |+ print(3) +118 117 | # comment +119 118 | print(2+3) +120 119 | + +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 | +124 | if True: + | + = help: Remove outdated version block + +ℹ Suggested fix +119 119 | print(2+3) +120 120 | +121 121 | if True: +122 |- if sys.version_info > (3,): print(3) + 122 |+ print(3) +123 123 | +124 124 | if True: +125 125 | if sys.version_info > (3,): + +UP036_0.py:125:8: UP036 [*] Version block is outdated for minimum Python version + | +124 | if True: +125 | if sys.version_info > (3,): + | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 +126 | print(3) + | + = help: Remove outdated version block + +ℹ Suggested fix +122 122 | if sys.version_info > (3,): print(3) +123 123 | +124 124 | if True: +125 |- if sys.version_info > (3,): +126 |- print(3) + 125 |+ print(3) +127 126 | +128 127 | +129 128 | if True: + +UP036_0.py:130:8: UP036 [*] Version block is outdated for minimum Python version + | +129 | if True: +130 | if sys.version_info <= (3, 0): + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +131 | expected_error = [] +132 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +127 127 | +128 128 | +129 129 | if True: +130 |- if sys.version_info <= (3, 0): +131 |- expected_error = [] +132 |- else: +133 |- expected_error = [ + 130 |+ expected_error = [ +134 131 | ":1:5: Generator expression must be parenthesized", +135 132 | "max(1 for i in range(10), key=lambda x: x+1)", +136 133 | " ^", +137 |- ] + 134 |+ ] +138 135 | +139 136 | +140 137 | if sys.version_info <= (3, 0): + +UP036_0.py:140:4: UP036 [*] Version block is outdated for minimum Python version + | +140 | if sys.version_info <= (3, 0): + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +141 | expected_error = [] +142 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +137 137 | ] +138 138 | +139 139 | +140 |-if sys.version_info <= (3, 0): +141 |- expected_error = [] +142 |-else: +143 |- expected_error = [ + 140 |+expected_error = [ +144 141 | ":1:5: Generator expression must be parenthesized", +145 142 | "max(1 for i in range(10), key=lambda x: x+1)", +146 143 | " ^", +147 |- ] + 144 |+] +148 145 | +149 146 | +150 147 | if sys.version_info > (3,0): + +UP036_0.py:150:4: UP036 [*] Version block is outdated for minimum Python version + | +150 | if sys.version_info > (3,0): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +151 | """this +152 | is valid""" + | + = help: Remove outdated version block + +ℹ Suggested fix +147 147 | ] +148 148 | +149 149 | +150 |-if sys.version_info > (3,0): +151 |- """this + 150 |+"""this +152 151 | is valid""" +153 152 | +154 |- """the indentation on + 153 |+"""the indentation on +155 154 | this line is significant""" +156 155 | +157 |- "this is" \ + 156 |+"this is" \ +158 157 | "allowed too" +159 158 | +160 |- ("so is" +161 |- "this for some reason") + 159 |+("so is" + 160 |+ "this for some reason") +162 161 | +163 162 | if sys.version_info > (3, 0): expected_error = \ +164 163 | [] + +UP036_0.py:163:4: UP036 [*] Version block is outdated for minimum Python version + | +161 | "this for some reason") +162 | +163 | if sys.version_info > (3, 0): expected_error = \ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +164 | [] + | + = help: Remove outdated version block + +ℹ Suggested fix +160 160 | ("so is" +161 161 | "this for some reason") +162 162 | +163 |-if sys.version_info > (3, 0): expected_error = \ + 163 |+expected_error = \ +164 164 | [] +165 165 | +166 166 | if sys.version_info > (3, 0): expected_error = [] + +UP036_0.py:166:4: UP036 [*] Version block is outdated for minimum Python version + | +164 | [] +165 | +166 | if sys.version_info > (3, 0): expected_error = [] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +167 | +168 | if sys.version_info > (3, 0): \ + | + = help: Remove outdated version block + +ℹ Suggested fix +163 163 | if sys.version_info > (3, 0): expected_error = \ +164 164 | [] +165 165 | +166 |-if sys.version_info > (3, 0): expected_error = [] + 166 |+expected_error = [] +167 167 | +168 168 | if sys.version_info > (3, 0): \ +169 169 | expected_error = [] + +UP036_0.py:168:4: UP036 [*] Version block is outdated for minimum Python version + | +166 | if sys.version_info > (3, 0): expected_error = [] +167 | +168 | if sys.version_info > (3, 0): \ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +169 | expected_error = [] + | + = help: Remove outdated version block + +ℹ Suggested fix +165 165 | +166 166 | if sys.version_info > (3, 0): expected_error = [] +167 167 | +168 |-if sys.version_info > (3, 0): \ +169 |- expected_error = [] + 168 |+expected_error = [] +170 169 | +171 170 | if True: +172 171 | if sys.version_info > (3, 0): expected_error = \ + +UP036_0.py:172:8: UP036 [*] Version block is outdated for minimum Python version + | +171 | if True: +172 | if sys.version_info > (3, 0): expected_error = \ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +173 | [] + | + = help: Remove outdated version block + +ℹ Suggested fix +169 169 | expected_error = [] +170 170 | +171 171 | if True: +172 |- if sys.version_info > (3, 0): expected_error = \ + 172 |+ expected_error = \ +173 173 | [] +174 174 | +175 175 | if True: + +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 | +178 | if True: + | + = help: Remove outdated version block + +ℹ Suggested fix +173 173 | [] +174 174 | +175 175 | if True: +176 |- if sys.version_info > (3, 0): expected_error = [] + 176 |+ expected_error = [] +177 177 | +178 178 | if True: +179 179 | if sys.version_info > (3, 0): \ + +UP036_0.py:179:8: UP036 [*] Version block is outdated for minimum Python version + | +178 | if True: +179 | if sys.version_info > (3, 0): \ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +180 | expected_error = [] + | + = help: Remove outdated version block + +ℹ Suggested fix +176 176 | if sys.version_info > (3, 0): expected_error = [] +177 177 | +178 178 | if True: +179 |- if sys.version_info > (3, 0): \ +180 179 | expected_error = [] +181 180 | +182 181 | if sys.version_info < (3,12): + +UP036_0.py:182:4: UP036 [*] Version block is outdated for minimum Python version + | +180 | expected_error = [] +181 | +182 | if sys.version_info < (3,12): + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +183 | print("py3") + | + = help: Remove outdated version block + +ℹ Suggested fix +179 179 | if sys.version_info > (3, 0): \ +180 180 | expected_error = [] +181 181 | +182 |-if sys.version_info < (3,12): +183 |- print("py3") +184 182 | +185 183 | if sys.version_info <= (3,12): +186 184 | 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 new file mode 100644 index 0000000000..2a585cc3f9 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_1.py.snap @@ -0,0 +1,295 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP036_1.py:3:4: UP036 [*] Version block is outdated for minimum Python version + | +1 | import sys +2 | +3 | if sys.version_info == 2: + | ^^^^^^^^^^^^^^^^^^^^^ UP036 +4 | 2 +5 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +1 1 | import sys +2 2 | +3 |-if sys.version_info == 2: +4 |- 2 +5 |-else: +6 |- 3 + 3 |+3 +7 4 | +8 5 | if sys.version_info < (3,): +9 6 | 2 + +UP036_1.py:8:4: UP036 [*] Version block is outdated for minimum Python version + | + 6 | 3 + 7 | + 8 | if sys.version_info < (3,): + | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 + 9 | 2 +10 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +5 5 | else: +6 6 | 3 +7 7 | +8 |-if sys.version_info < (3,): +9 |- 2 +10 |-else: +11 |- 3 + 8 |+3 +12 9 | +13 10 | if sys.version_info < (3,0): +14 11 | 2 + +UP036_1.py:13:4: UP036 [*] Version block is outdated for minimum Python version + | +11 | 3 +12 | +13 | if sys.version_info < (3,0): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +14 | 2 +15 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +10 10 | else: +11 11 | 3 +12 12 | +13 |-if sys.version_info < (3,0): +14 |- 2 +15 |-else: +16 |- 3 + 13 |+3 +17 14 | +18 15 | if sys.version_info == 3: +19 16 | 3 + +UP036_1.py:18:4: UP036 [*] Version block is outdated for minimum Python version + | +16 | 3 +17 | +18 | if sys.version_info == 3: + | ^^^^^^^^^^^^^^^^^^^^^ UP036 +19 | 3 +20 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +15 15 | else: +16 16 | 3 +17 17 | +18 |-if sys.version_info == 3: +19 |- 3 +20 |-else: +21 |- 2 + 18 |+3 +22 19 | +23 20 | if sys.version_info > (3,): +24 21 | 3 + +UP036_1.py:23:4: UP036 [*] Version block is outdated for minimum Python version + | +21 | 2 +22 | +23 | if sys.version_info > (3,): + | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 +24 | 3 +25 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +20 20 | else: +21 21 | 2 +22 22 | +23 |-if sys.version_info > (3,): +24 |- 3 +25 |-else: +26 |- 2 + 23 |+3 +27 24 | +28 25 | if sys.version_info >= (3,): +29 26 | 3 + +UP036_1.py:28:4: UP036 [*] Version block is outdated for minimum Python version + | +26 | 2 +27 | +28 | if sys.version_info >= (3,): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +29 | 3 +30 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +25 25 | else: +26 26 | 2 +27 27 | +28 |-if sys.version_info >= (3,): +29 |- 3 +30 |-else: +31 |- 2 + 28 |+3 +32 29 | +33 30 | from sys import version_info +34 31 | + +UP036_1.py:35:4: UP036 [*] Version block is outdated for minimum Python version + | +33 | from sys import version_info +34 | +35 | if version_info > (3,): + | ^^^^^^^^^^^^^^^^^^^ UP036 +36 | 3 +37 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +32 32 | +33 33 | from sys import version_info +34 34 | +35 |-if version_info > (3,): +36 |- 3 +37 |-else: +38 |- 2 + 35 |+3 +39 36 | +40 37 | if True: +41 38 | print(1) + +UP036_1.py:42:6: UP036 [*] Version block is outdated for minimum Python version + | +40 | if True: +41 | print(1) +42 | elif sys.version_info < (3,0): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +43 | print(2) +44 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +39 39 | +40 40 | if True: +41 41 | print(1) +42 |-elif sys.version_info < (3,0): +43 |- print(2) +44 42 | else: +45 43 | print(3) +46 44 | + +UP036_1.py:49:6: UP036 [*] Version block is outdated for minimum Python version + | +47 | if True: +48 | print(1) +49 | elif sys.version_info > (3,): + | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 +50 | print(3) +51 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +46 46 | +47 47 | if True: +48 48 | print(1) +49 |-elif sys.version_info > (3,): + 49 |+else: +50 50 | print(3) +51 |-else: +52 |- print(2) +53 51 | +54 52 | if True: +55 53 | print(1) + +UP036_1.py:56:6: UP036 [*] Version block is outdated for minimum Python version + | +54 | if True: +55 | print(1) +56 | elif sys.version_info > (3,): + | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 +57 | print(3) + | + = help: Remove outdated version block + +ℹ Suggested fix +53 53 | +54 54 | if True: +55 55 | print(1) +56 |-elif sys.version_info > (3,): + 56 |+else: +57 57 | print(3) +58 58 | +59 59 | def f(): + +UP036_1.py:62:10: UP036 [*] Version block is outdated for minimum Python version + | +60 | if True: +61 | print(1) +62 | elif sys.version_info > (3,): + | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 +63 | print(3) + | + = help: Remove outdated version block + +ℹ Suggested fix +59 59 | def f(): +60 60 | if True: +61 61 | print(1) +62 |- elif sys.version_info > (3,): + 62 |+ else: +63 63 | print(3) +64 64 | +65 65 | if True: + +UP036_1.py:67:6: UP036 [*] Version block is outdated for minimum Python version + | +65 | if True: +66 | print(1) +67 | elif sys.version_info < (3,0): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +68 | print(2) +69 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +64 64 | +65 65 | if True: +66 66 | print(1) +67 |-elif sys.version_info < (3,0): +68 |- print(2) +69 67 | else: +70 68 | print(3) +71 69 | + +UP036_1.py:75:10: UP036 [*] Version block is outdated for minimum Python version + | +73 | if True: +74 | print(1) +75 | elif sys.version_info > (3,): + | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 +76 | print(3) + | + = help: Remove outdated version block + +ℹ Suggested fix +72 72 | def f(): +73 73 | if True: +74 74 | print(1) +75 |- elif sys.version_info > (3,): + 75 |+ else: +76 76 | print(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 new file mode 100644 index 0000000000..8e8332bdd9 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_2.py.snap @@ -0,0 +1,280 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP036_2.py:4:4: UP036 [*] Version block is outdated for minimum Python version + | +2 | from sys import version_info +3 | +4 | if sys.version_info > (3, 5): + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +5 | 3+6 +6 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +1 1 | import sys +2 2 | from sys import version_info +3 3 | +4 |-if sys.version_info > (3, 5): +5 |- 3+6 +6 |-else: +7 |- 3-5 + 4 |+3+6 +8 5 | +9 6 | if version_info > (3, 5): +10 7 | 3+6 + +UP036_2.py:9:4: UP036 [*] Version block is outdated for minimum Python version + | + 7 | 3-5 + 8 | + 9 | if version_info > (3, 5): + | ^^^^^^^^^^^^^^^^^^^^^ UP036 +10 | 3+6 +11 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +6 6 | else: +7 7 | 3-5 +8 8 | +9 |-if version_info > (3, 5): +10 |- 3+6 +11 |-else: +12 |- 3-5 + 9 |+3+6 +13 10 | +14 11 | if sys.version_info >= (3,6): +15 12 | 3+6 + +UP036_2.py:14:4: UP036 [*] Version block is outdated for minimum Python version + | +12 | 3-5 +13 | +14 | if sys.version_info >= (3,6): + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +15 | 3+6 +16 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +11 11 | else: +12 12 | 3-5 +13 13 | +14 |-if sys.version_info >= (3,6): +15 |- 3+6 +16 |-else: +17 |- 3-5 + 14 |+3+6 +18 15 | +19 16 | if version_info >= (3,6): +20 17 | 3+6 + +UP036_2.py:19:4: UP036 [*] Version block is outdated for minimum Python version + | +17 | 3-5 +18 | +19 | if version_info >= (3,6): + | ^^^^^^^^^^^^^^^^^^^^^ UP036 +20 | 3+6 +21 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +16 16 | else: +17 17 | 3-5 +18 18 | +19 |-if version_info >= (3,6): +20 |- 3+6 +21 |-else: +22 |- 3-5 + 19 |+3+6 +23 20 | +24 21 | if sys.version_info < (3,6): +25 22 | 3-5 + +UP036_2.py:24:4: UP036 [*] Version block is outdated for minimum Python version + | +22 | 3-5 +23 | +24 | if sys.version_info < (3,6): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +25 | 3-5 +26 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +21 21 | else: +22 22 | 3-5 +23 23 | +24 |-if sys.version_info < (3,6): +25 |- 3-5 +26 |-else: +27 |- 3+6 + 24 |+3+6 +28 25 | +29 26 | if sys.version_info <= (3,5): +30 27 | 3-5 + +UP036_2.py:29:4: UP036 [*] Version block is outdated for minimum Python version + | +27 | 3+6 +28 | +29 | if sys.version_info <= (3,5): + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +30 | 3-5 +31 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +26 26 | else: +27 27 | 3+6 +28 28 | +29 |-if sys.version_info <= (3,5): +30 |- 3-5 +31 |-else: +32 |- 3+6 + 29 |+3+6 +33 30 | +34 31 | if sys.version_info <= (3, 5): +35 32 | 3-5 + +UP036_2.py:34:4: UP036 [*] Version block is outdated for minimum Python version + | +32 | 3+6 +33 | +34 | if sys.version_info <= (3, 5): + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +35 | 3-5 +36 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +31 31 | else: +32 32 | 3+6 +33 33 | +34 |-if sys.version_info <= (3, 5): +35 |- 3-5 +36 |-else: +37 |- 3+6 + 34 |+3+6 +38 35 | +39 36 | if sys.version_info >= (3, 5): +40 37 | pass + +UP036_2.py:39:4: UP036 [*] Version block is outdated for minimum Python version + | +37 | 3+6 +38 | +39 | if sys.version_info >= (3, 5): + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +40 | pass + | + = help: Remove outdated version block + +ℹ Suggested fix +36 36 | else: +37 37 | 3+6 +38 38 | +39 |-if sys.version_info >= (3, 5): +40 |- pass + 39 |+pass +41 40 | +42 41 | if sys.version_info < (3,0): +43 42 | pass + +UP036_2.py:42:4: UP036 [*] Version block is outdated for minimum Python version + | +40 | pass +41 | +42 | if sys.version_info < (3,0): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +43 | pass + | + = help: Remove outdated version block + +ℹ Suggested fix +39 39 | if sys.version_info >= (3, 5): +40 40 | pass +41 41 | +42 |-if sys.version_info < (3,0): +43 |- pass +44 42 | +45 43 | if True: +46 44 | if sys.version_info < (3,0): + +UP036_2.py:46:8: UP036 [*] Version block is outdated for minimum Python version + | +45 | if True: +46 | if sys.version_info < (3,0): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +47 | pass + | + = help: Remove outdated version block + +ℹ Suggested fix +43 43 | pass +44 44 | +45 45 | if True: +46 |- if sys.version_info < (3,0): +47 |- pass + 46 |+ pass +48 47 | +49 48 | if sys.version_info < (3,0): +50 49 | pass + +UP036_2.py:49:4: UP036 [*] Version block is outdated for minimum Python version + | +47 | pass +48 | +49 | if sys.version_info < (3,0): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +50 | pass +51 | elif False: + | + = help: Remove outdated version block + +ℹ Suggested fix +46 46 | if sys.version_info < (3,0): +47 47 | pass +48 48 | +49 |-if sys.version_info < (3,0): +50 |- pass +51 |-elif False: + 49 |+if False: +52 50 | pass +53 51 | +54 52 | if sys.version_info > (3,): + +UP036_2.py:54:4: UP036 [*] Version block is outdated for minimum Python version + | +52 | pass +53 | +54 | if sys.version_info > (3,): + | ^^^^^^^^^^^^^^^^^^^^^^^ UP036 +55 | pass +56 | elif False: + | + = help: Remove outdated version block + +ℹ Suggested fix +51 51 | elif False: +52 52 | pass +53 53 | +54 |-if sys.version_info > (3,): +55 |- pass +56 |-elif False: +57 |- pass + 54 |+pass +58 55 | +59 56 | if sys.version_info[0] > "2": +60 57 | 3 + + 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 new file mode 100644 index 0000000000..d38cfd8b0b --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_3.py.snap @@ -0,0 +1,78 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP036_3.py:3:15: UP036 [*] Version block is outdated for minimum Python version + | +1 | import sys +2 | +3 | if sys.version_info < (3,0): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +4 | print("py2") +5 | for item in range(10): + | + = help: Remove outdated version block + +ℹ Suggested fix +1 1 | import sys +2 2 | +3 |-if sys.version_info < (3,0): +4 |- print("py2") +5 |- for item in range(10): +6 |- print(f"PY2-{item}") +7 |-else : +8 |- print("py3") +9 |- for item in range(10): +10 |- print(f"PY3-{item}") + 3 |+print("py3") + 4 |+for item in range(10): + 5 |+ print(f"PY3-{item}") +11 6 | +12 7 | if False: +13 8 | if sys.version_info < (3,0): + +UP036_3.py:13:19: UP036 [*] Version block is outdated for minimum Python version + | +12 | if False: +13 | if sys.version_info < (3,0): + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +14 | print("py2") +15 | for item in range(10): + | + = help: Remove outdated version block + +ℹ Suggested fix +10 10 | print(f"PY3-{item}") +11 11 | +12 12 | if False: +13 |- if sys.version_info < (3,0): +14 |- print("py2") +15 |- for item in range(10): +16 |- print(f"PY2-{item}") +17 |- else : +18 |- print("py3") +19 |- for item in range(10): +20 |- print(f"PY3-{item}") + 13 |+ print("py3") + 14 |+ for item in range(10): + 15 |+ print(f"PY3-{item}") +21 16 | +22 17 | +23 18 | if sys.version_info < (3,0): print("PY2!") + +UP036_3.py:23:15: UP036 [*] Version block is outdated for minimum Python version + | +23 | if sys.version_info < (3,0): print("PY2!") + | ^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +24 | else : print("PY3!") + | + = help: Remove outdated version block + +ℹ Suggested fix +20 20 | print(f"PY3-{item}") +21 21 | +22 22 | +23 |-if sys.version_info < (3,0): print("PY2!") +24 |-else : print("PY3!") + 23 |+print("PY3!") + + 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 new file mode 100644 index 0000000000..28701a4d0a --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_4.py.snap @@ -0,0 +1,173 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP036_4.py:4:8: UP036 [*] Version block is outdated for minimum Python version + | +3 | if True: +4 | if sys.version_info < (3, 3): + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +5 | cmd = [sys.executable, "-m", "test.regrtest"] + | + = help: Remove outdated version block + +ℹ Suggested fix +1 1 | import sys +2 2 | +3 3 | if True: +4 |- if sys.version_info < (3, 3): +5 |- cmd = [sys.executable, "-m", "test.regrtest"] + 4 |+ pass +6 5 | +7 6 | +8 7 | if True: + +UP036_4.py:11:10: UP036 [*] Version block is outdated for minimum Python version + | + 9 | if foo: +10 | print() +11 | elif sys.version_info < (3, 3): + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +12 | cmd = [sys.executable, "-m", "test.regrtest"] + | + = help: Remove outdated version block + +ℹ Suggested fix +8 8 | if True: +9 9 | if foo: +10 10 | print() +11 |- elif sys.version_info < (3, 3): +12 |- cmd = [sys.executable, "-m", "test.regrtest"] + 11 |+ +13 12 | +14 13 | if True: +15 14 | if foo: + +UP036_4.py:17:10: UP036 [*] Version block is outdated for minimum Python version + | +15 | if foo: +16 | print() +17 | elif sys.version_info < (3, 3): + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +18 | cmd = [sys.executable, "-m", "test.regrtest"] +19 | elif foo: + | + = help: Remove outdated version block + +ℹ Suggested fix +14 14 | if True: +15 15 | if foo: +16 16 | print() +17 |- elif sys.version_info < (3, 3): +18 |- cmd = [sys.executable, "-m", "test.regrtest"] +19 17 | elif foo: +20 18 | cmd = [sys.executable, "-m", "test", "-j0"] +21 19 | + +UP036_4.py:24:10: UP036 [*] Version block is outdated for minimum Python version + | +22 | if foo: +23 | print() +24 | elif sys.version_info < (3, 3): + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +25 | cmd = [sys.executable, "-m", "test.regrtest"] + | + = help: Remove outdated version block + +ℹ Suggested fix +21 21 | +22 22 | if foo: +23 23 | print() +24 |- elif sys.version_info < (3, 3): +25 |- cmd = [sys.executable, "-m", "test.regrtest"] + 24 |+ +26 25 | +27 26 | if sys.version_info < (3, 3): +28 27 | cmd = [sys.executable, "-m", "test.regrtest"] + +UP036_4.py:27:8: UP036 [*] Version block is outdated for minimum Python version + | +25 | cmd = [sys.executable, "-m", "test.regrtest"] +26 | +27 | if sys.version_info < (3, 3): + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +28 | cmd = [sys.executable, "-m", "test.regrtest"] + | + = help: Remove outdated version block + +ℹ Suggested fix +24 24 | elif sys.version_info < (3, 3): +25 25 | cmd = [sys.executable, "-m", "test.regrtest"] +26 26 | +27 |- if sys.version_info < (3, 3): +28 |- cmd = [sys.executable, "-m", "test.regrtest"] +29 27 | +30 28 | if foo: +31 29 | print() + +UP036_4.py:32:10: UP036 [*] Version block is outdated for minimum Python version + | +30 | if foo: +31 | print() +32 | elif sys.version_info < (3, 3): + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +33 | cmd = [sys.executable, "-m", "test.regrtest"] +34 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +29 29 | +30 30 | if foo: +31 31 | print() +32 |- elif sys.version_info < (3, 3): +33 |- cmd = [sys.executable, "-m", "test.regrtest"] +34 32 | else: +35 33 | cmd = [sys.executable, "-m", "test", "-j0"] +36 34 | + +UP036_4.py:37:8: UP036 [*] Version block is outdated for minimum Python version + | +35 | cmd = [sys.executable, "-m", "test", "-j0"] +36 | +37 | if sys.version_info < (3, 3): + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +38 | cmd = [sys.executable, "-m", "test.regrtest"] +39 | else: + | + = help: Remove outdated version block + +ℹ Suggested fix +34 34 | else: +35 35 | cmd = [sys.executable, "-m", "test", "-j0"] +36 36 | +37 |- if sys.version_info < (3, 3): +38 |- cmd = [sys.executable, "-m", "test.regrtest"] +39 |- else: +40 |- cmd = [sys.executable, "-m", "test", "-j0"] + 37 |+ cmd = [sys.executable, "-m", "test", "-j0"] +41 38 | +42 39 | if sys.version_info < (3, 3): +43 40 | cmd = [sys.executable, "-m", "test.regrtest"] + +UP036_4.py:42:8: UP036 [*] Version block is outdated for minimum Python version + | +40 | cmd = [sys.executable, "-m", "test", "-j0"] +41 | +42 | if sys.version_info < (3, 3): + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +43 | cmd = [sys.executable, "-m", "test.regrtest"] +44 | elif foo: + | + = help: Remove outdated version block + +ℹ Suggested fix +39 39 | else: +40 40 | cmd = [sys.executable, "-m", "test", "-j0"] +41 41 | +42 |- if sys.version_info < (3, 3): +43 |- cmd = [sys.executable, "-m", "test.regrtest"] +44 |- elif foo: + 42 |+ if foo: +45 43 | cmd = [sys.executable, "-m", "test", "-j0"] + + 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 new file mode 100644 index 0000000000..f4a5ed2787 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP036_5.py.snap @@ -0,0 +1,70 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP036_5.py:3:4: UP036 [*] Version block is outdated for minimum Python version + | +1 | import sys +2 | +3 | if sys.version_info < (3, 8): + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +4 | +5 | def a(): + | + = help: Remove outdated version block + +ℹ Suggested fix +1 1 | import sys +2 2 | +3 |-if sys.version_info < (3, 8): +4 |- +5 |- def a(): +6 |- if b: +7 |- print(1) +8 |- elif c: +9 |- print(2) +10 |- return None +11 |- +12 |-else: +13 |- pass + 3 |+pass +14 4 | +15 5 | +16 6 | import sys + +UP036_5.py:18:4: UP036 [*] Version block is outdated for minimum Python version + | +16 | import sys +17 | +18 | if sys.version_info < (3, 8): + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP036 +19 | pass + | + = help: Remove outdated version block + +ℹ Suggested fix +15 15 | +16 16 | import sys +17 17 | +18 |-if sys.version_info < (3, 8): +19 |- pass +20 |- +21 |-else: +22 |- +23 |- def a(): +24 |- if b: +25 |- print(1) +26 |- elif c: +27 |- print(2) +28 |- else: +29 |- print(3) +30 |- return None + 18 |+def a(): + 19 |+ if b: + 20 |+ print(1) + 21 |+ elif c: + 22 |+ print(2) + 23 |+ else: + 24 |+ print(3) + 25 |+ return None + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037.py.snap new file mode 100644 index 0000000000..e934936c49 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP037.py.snap @@ -0,0 +1,559 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP037.py:18:14: UP037 [*] Remove quotes from type annotation + | +18 | def foo(var: "MyClass") -> "MyClass": + | ^^^^^^^^^ UP037 +19 | x: "MyClass" + | + = help: Remove quotes + +ℹ Fix +15 15 | from mypy_extensions import Arg, DefaultArg, DefaultNamedArg, NamedArg, VarArg +16 16 | +17 17 | +18 |-def foo(var: "MyClass") -> "MyClass": + 18 |+def foo(var: MyClass) -> "MyClass": +19 19 | x: "MyClass" +20 20 | +21 21 | + +UP037.py:18:28: UP037 [*] Remove quotes from type annotation + | +18 | def foo(var: "MyClass") -> "MyClass": + | ^^^^^^^^^ UP037 +19 | x: "MyClass" + | + = help: Remove quotes + +ℹ Fix +15 15 | from mypy_extensions import Arg, DefaultArg, DefaultNamedArg, NamedArg, VarArg +16 16 | +17 17 | +18 |-def foo(var: "MyClass") -> "MyClass": + 18 |+def foo(var: "MyClass") -> MyClass: +19 19 | x: "MyClass" +20 20 | +21 21 | + +UP037.py:19:8: UP037 [*] Remove quotes from type annotation + | +18 | def foo(var: "MyClass") -> "MyClass": +19 | x: "MyClass" + | ^^^^^^^^^ UP037 + | + = help: Remove quotes + +ℹ Fix +16 16 | +17 17 | +18 18 | def foo(var: "MyClass") -> "MyClass": +19 |- x: "MyClass" + 19 |+ x: MyClass +20 20 | +21 21 | +22 22 | def foo(*, inplace: "bool"): + +UP037.py:22:21: UP037 [*] Remove quotes from type annotation + | +22 | def foo(*, inplace: "bool"): + | ^^^^^^ UP037 +23 | pass + | + = help: Remove quotes + +ℹ Fix +19 19 | x: "MyClass" +20 20 | +21 21 | +22 |-def foo(*, inplace: "bool"): + 22 |+def foo(*, inplace: bool): +23 23 | pass +24 24 | +25 25 | + +UP037.py:26:16: UP037 [*] Remove quotes from type annotation + | +26 | def foo(*args: "str", **kwargs: "int"): + | ^^^^^ UP037 +27 | pass + | + = help: Remove quotes + +ℹ Fix +23 23 | pass +24 24 | +25 25 | +26 |-def foo(*args: "str", **kwargs: "int"): + 26 |+def foo(*args: str, **kwargs: "int"): +27 27 | pass +28 28 | +29 29 | + +UP037.py:26:33: UP037 [*] Remove quotes from type annotation + | +26 | def foo(*args: "str", **kwargs: "int"): + | ^^^^^ UP037 +27 | pass + | + = help: Remove quotes + +ℹ Fix +23 23 | pass +24 24 | +25 25 | +26 |-def foo(*args: "str", **kwargs: "int"): + 26 |+def foo(*args: "str", **kwargs: int): +27 27 | pass +28 28 | +29 29 | + +UP037.py:30:10: UP037 [*] Remove quotes from type annotation + | +30 | x: Tuple["MyClass"] + | ^^^^^^^^^ UP037 +31 | +32 | x: Callable[["MyClass"], None] + | + = help: Remove quotes + +ℹ Fix +27 27 | pass +28 28 | +29 29 | +30 |-x: Tuple["MyClass"] + 30 |+x: Tuple[MyClass] +31 31 | +32 32 | x: Callable[["MyClass"], None] +33 33 | + +UP037.py:32:14: UP037 [*] Remove quotes from type annotation + | +30 | x: Tuple["MyClass"] +31 | +32 | x: Callable[["MyClass"], None] + | ^^^^^^^^^ UP037 + | + = help: Remove quotes + +ℹ Fix +29 29 | +30 30 | x: Tuple["MyClass"] +31 31 | +32 |-x: Callable[["MyClass"], None] + 32 |+x: Callable[[MyClass], None] +33 33 | +34 34 | +35 35 | class Foo(NamedTuple): + +UP037.py:36:8: UP037 [*] Remove quotes from type annotation + | +35 | class Foo(NamedTuple): +36 | x: "MyClass" + | ^^^^^^^^^ UP037 + | + = help: Remove quotes + +ℹ Fix +33 33 | +34 34 | +35 35 | class Foo(NamedTuple): +36 |- x: "MyClass" + 36 |+ x: MyClass +37 37 | +38 38 | +39 39 | class D(TypedDict): + +UP037.py:40:27: UP037 [*] Remove quotes from type annotation + | +39 | class D(TypedDict): +40 | E: TypedDict("E", foo="int", total=False) + | ^^^^^ UP037 + | + = help: Remove quotes + +ℹ Fix +37 37 | +38 38 | +39 39 | class D(TypedDict): +40 |- E: TypedDict("E", foo="int", total=False) + 40 |+ E: TypedDict("E", foo=int, total=False) +41 41 | +42 42 | +43 43 | class D(TypedDict): + +UP037.py:44:31: UP037 [*] Remove quotes from type annotation + | +43 | class D(TypedDict): +44 | E: TypedDict("E", {"foo": "int"}) + | ^^^^^ UP037 + | + = help: Remove quotes + +ℹ Fix +41 41 | +42 42 | +43 43 | class D(TypedDict): +44 |- E: TypedDict("E", {"foo": "int"}) + 44 |+ E: TypedDict("E", {"foo": int}) +45 45 | +46 46 | +47 47 | x: Annotated["str", "metadata"] + +UP037.py:47:14: UP037 [*] Remove quotes from type annotation + | +47 | x: Annotated["str", "metadata"] + | ^^^^^ UP037 +48 | +49 | x: Arg("str", "name") + | + = help: Remove quotes + +ℹ Fix +44 44 | E: TypedDict("E", {"foo": "int"}) +45 45 | +46 46 | +47 |-x: Annotated["str", "metadata"] + 47 |+x: Annotated[str, "metadata"] +48 48 | +49 49 | x: Arg("str", "name") +50 50 | + +UP037.py:49:8: UP037 [*] Remove quotes from type annotation + | +47 | x: Annotated["str", "metadata"] +48 | +49 | x: Arg("str", "name") + | ^^^^^ UP037 +50 | +51 | x: DefaultArg("str", "name") + | + = help: Remove quotes + +ℹ Fix +46 46 | +47 47 | x: Annotated["str", "metadata"] +48 48 | +49 |-x: Arg("str", "name") + 49 |+x: Arg(str, "name") +50 50 | +51 51 | x: DefaultArg("str", "name") +52 52 | + +UP037.py:51:15: UP037 [*] Remove quotes from type annotation + | +49 | x: Arg("str", "name") +50 | +51 | x: DefaultArg("str", "name") + | ^^^^^ UP037 +52 | +53 | x: NamedArg("str", "name") + | + = help: Remove quotes + +ℹ Fix +48 48 | +49 49 | x: Arg("str", "name") +50 50 | +51 |-x: DefaultArg("str", "name") + 51 |+x: DefaultArg(str, "name") +52 52 | +53 53 | x: NamedArg("str", "name") +54 54 | + +UP037.py:53:13: UP037 [*] Remove quotes from type annotation + | +51 | x: DefaultArg("str", "name") +52 | +53 | x: NamedArg("str", "name") + | ^^^^^ UP037 +54 | +55 | x: DefaultNamedArg("str", "name") + | + = help: Remove quotes + +ℹ Fix +50 50 | +51 51 | x: DefaultArg("str", "name") +52 52 | +53 |-x: NamedArg("str", "name") + 53 |+x: NamedArg(str, "name") +54 54 | +55 55 | x: DefaultNamedArg("str", "name") +56 56 | + +UP037.py:55:20: UP037 [*] Remove quotes from type annotation + | +53 | x: NamedArg("str", "name") +54 | +55 | x: DefaultNamedArg("str", "name") + | ^^^^^ UP037 +56 | +57 | x: DefaultNamedArg("str", name="name") + | + = help: Remove quotes + +ℹ Fix +52 52 | +53 53 | x: NamedArg("str", "name") +54 54 | +55 |-x: DefaultNamedArg("str", "name") + 55 |+x: DefaultNamedArg(str, "name") +56 56 | +57 57 | x: DefaultNamedArg("str", name="name") +58 58 | + +UP037.py:57:20: UP037 [*] Remove quotes from type annotation + | +55 | x: DefaultNamedArg("str", "name") +56 | +57 | x: DefaultNamedArg("str", name="name") + | ^^^^^ UP037 +58 | +59 | x: VarArg("str") + | + = help: Remove quotes + +ℹ Fix +54 54 | +55 55 | x: DefaultNamedArg("str", "name") +56 56 | +57 |-x: DefaultNamedArg("str", name="name") + 57 |+x: DefaultNamedArg(str, name="name") +58 58 | +59 59 | x: VarArg("str") +60 60 | + +UP037.py:59:11: UP037 [*] Remove quotes from type annotation + | +57 | x: DefaultNamedArg("str", name="name") +58 | +59 | x: VarArg("str") + | ^^^^^ UP037 +60 | +61 | x: List[List[List["MyClass"]]] + | + = help: Remove quotes + +ℹ Fix +56 56 | +57 57 | x: DefaultNamedArg("str", name="name") +58 58 | +59 |-x: VarArg("str") + 59 |+x: VarArg(str) +60 60 | +61 61 | x: List[List[List["MyClass"]]] +62 62 | + +UP037.py:61:19: UP037 [*] Remove quotes from type annotation + | +59 | x: VarArg("str") +60 | +61 | x: List[List[List["MyClass"]]] + | ^^^^^^^^^ UP037 +62 | +63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) + | + = help: Remove quotes + +ℹ Fix +58 58 | +59 59 | x: VarArg("str") +60 60 | +61 |-x: List[List[List["MyClass"]]] + 61 |+x: List[List[List[MyClass]]] +62 62 | +63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) +64 64 | + +UP037.py:63:29: UP037 [*] Remove quotes from type annotation + | +61 | x: List[List[List["MyClass"]]] +62 | +63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) + | ^^^^^ UP037 +64 | +65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) + | + = help: Remove quotes + +ℹ Fix +60 60 | +61 61 | x: List[List[List["MyClass"]]] +62 62 | +63 |-x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) + 63 |+x: NamedTuple("X", [("foo", int), ("bar", "str")]) +64 64 | +65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) +66 66 | + +UP037.py:63:45: UP037 [*] Remove quotes from type annotation + | +61 | x: List[List[List["MyClass"]]] +62 | +63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) + | ^^^^^ UP037 +64 | +65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) + | + = help: Remove quotes + +ℹ Fix +60 60 | +61 61 | x: List[List[List["MyClass"]]] +62 62 | +63 |-x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) + 63 |+x: NamedTuple("X", [("foo", "int"), ("bar", str)]) +64 64 | +65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) +66 66 | + +UP037.py:65:29: UP037 [*] Remove quotes from type annotation + | +63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) +64 | +65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) + | ^^^^^ UP037 +66 | +67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) + | + = help: Remove quotes + +ℹ Fix +62 62 | +63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) +64 64 | +65 |-x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) + 65 |+x: NamedTuple("X", fields=[(foo, "int"), ("bar", "str")]) +66 66 | +67 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) +68 68 | + +UP037.py:65:36: UP037 [*] Remove quotes from type annotation + | +63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) +64 | +65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) + | ^^^^^ UP037 +66 | +67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) + | + = help: Remove quotes + +ℹ Fix +62 62 | +63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) +64 64 | +65 |-x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) + 65 |+x: NamedTuple("X", fields=[("foo", int), ("bar", "str")]) +66 66 | +67 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) +68 68 | + +UP037.py:65:45: UP037 [*] Remove quotes from type annotation + | +63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) +64 | +65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) + | ^^^^^ UP037 +66 | +67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) + | + = help: Remove quotes + +ℹ Fix +62 62 | +63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) +64 64 | +65 |-x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) + 65 |+x: NamedTuple("X", fields=[("foo", "int"), (bar, "str")]) +66 66 | +67 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) +68 68 | + +UP037.py:65:52: UP037 [*] Remove quotes from type annotation + | +63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) +64 | +65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) + | ^^^^^ UP037 +66 | +67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) + | + = help: Remove quotes + +ℹ Fix +62 62 | +63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")]) +64 64 | +65 |-x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) + 65 |+x: NamedTuple("X", fields=[("foo", "int"), ("bar", str)]) +66 66 | +67 67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) +68 68 | + +UP037.py:67:24: UP037 [*] Remove quotes from type annotation + | +65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) +66 | +67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) + | ^^^ UP037 +68 | +69 | X: MyCallable("X") + | + = help: Remove quotes + +ℹ Fix +64 64 | +65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) +66 66 | +67 |-x: NamedTuple(typename="X", fields=[("foo", "int")]) + 67 |+x: NamedTuple(typename=X, fields=[("foo", "int")]) +68 68 | +69 69 | X: MyCallable("X") +70 70 | + +UP037.py:67:38: UP037 [*] Remove quotes from type annotation + | +65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) +66 | +67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) + | ^^^^^ UP037 +68 | +69 | X: MyCallable("X") + | + = help: Remove quotes + +ℹ Fix +64 64 | +65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) +66 66 | +67 |-x: NamedTuple(typename="X", fields=[("foo", "int")]) + 67 |+x: NamedTuple(typename="X", fields=[(foo, "int")]) +68 68 | +69 69 | X: MyCallable("X") +70 70 | + +UP037.py:67:45: UP037 [*] Remove quotes from type annotation + | +65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) +66 | +67 | x: NamedTuple(typename="X", fields=[("foo", "int")]) + | ^^^^^ UP037 +68 | +69 | X: MyCallable("X") + | + = help: Remove quotes + +ℹ Fix +64 64 | +65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")]) +66 66 | +67 |-x: NamedTuple(typename="X", fields=[("foo", "int")]) + 67 |+x: NamedTuple(typename="X", fields=[("foo", int)]) +68 68 | +69 69 | X: MyCallable("X") +70 70 | + + 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 new file mode 100644 index 0000000000..dcba7e8fcf --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP038.py.snap @@ -0,0 +1,37 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP038.py:1:1: UP038 [*] Use `X | Y` in `isinstance` call instead of `(X, Y)` + | +1 | isinstance(1, (int, float)) # UP038 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP038 +2 | issubclass("yes", (int, float, str)) # UP038 + | + = help: Convert to `X | Y` + +ℹ Suggested fix +1 |-isinstance(1, (int, float)) # UP038 + 1 |+isinstance(1, int | float) # UP038 +2 2 | issubclass("yes", (int, float, str)) # UP038 +3 3 | +4 4 | isinstance(1, int) # OK + +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 | +4 | isinstance(1, int) # OK + | + = help: Convert to `X | Y` + +ℹ Suggested fix +1 1 | isinstance(1, (int, float)) # UP038 +2 |-issubclass("yes", (int, float, str)) # UP038 + 2 |+issubclass("yes", int | float | str) # UP038 +3 3 | +4 4 | isinstance(1, int) # OK +5 5 | issubclass("yes", int) # OK + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP039.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP039.py.snap new file mode 100644 index 0000000000..3fc62823d0 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP039.py.snap @@ -0,0 +1,97 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP039.py:2:8: UP039 [*] Unnecessary parentheses after class definition + | +1 | # Errors +2 | class A(): + | ^^ UP039 +3 | pass + | + = help: Remove parentheses + +ℹ Fix +1 1 | # Errors +2 |-class A(): + 2 |+class A: +3 3 | pass +4 4 | +5 5 | + +UP039.py:6:8: UP039 [*] Unnecessary parentheses after class definition + | +6 | class A() \ + | ^^ UP039 +7 | : +8 | pass + | + = help: Remove parentheses + +ℹ Fix +3 3 | pass +4 4 | +5 5 | +6 |-class A() \ + 6 |+class A \ +7 7 | : +8 8 | pass +9 9 | + +UP039.py:12:9: UP039 [*] Unnecessary parentheses after class definition + | +11 | class A \ +12 | (): + | ^^ UP039 +13 | pass + | + = help: Remove parentheses + +ℹ Fix +9 9 | +10 10 | +11 11 | class A \ +12 |- (): + 12 |+ : +13 13 | pass +14 14 | +15 15 | + +UP039.py:17:8: UP039 [*] Unnecessary parentheses after class definition + | +16 | @decorator() +17 | class A(): + | ^^ UP039 +18 | pass + | + = help: Remove parentheses + +ℹ Fix +14 14 | +15 15 | +16 16 | @decorator() +17 |-class A(): + 17 |+class A: +18 18 | pass +19 19 | +20 20 | @decorator + +UP039.py:21:8: UP039 [*] Unnecessary parentheses after class definition + | +20 | @decorator +21 | class A(): + | ^^ UP039 +22 | pass + | + = help: Remove parentheses + +ℹ Fix +18 18 | pass +19 19 | +20 20 | @decorator +21 |-class A(): + 21 |+class A: +22 22 | pass +23 23 | +24 24 | # OK + + 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 new file mode 100644 index 0000000000..955401aad3 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP040.py.snap @@ -0,0 +1,233 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP040.py:5:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + | +4 | # UP040 +5 | x: typing.TypeAlias = int + | ^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 +6 | x: TypeAlias = int + | + = help: Use the `type` keyword + +ℹ Fix +2 2 | from typing import TypeAlias +3 3 | +4 4 | # UP040 +5 |-x: typing.TypeAlias = int + 5 |+type x = int +6 6 | x: TypeAlias = int +7 7 | +8 8 | # UP040 simple generic + +UP040.py:6:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + | +4 | # UP040 +5 | x: typing.TypeAlias = int +6 | x: TypeAlias = int + | ^^^^^^^^^^^^^^^^^^ UP040 +7 | +8 | # UP040 simple generic + | + = help: Use the `type` keyword + +ℹ Fix +3 3 | +4 4 | # UP040 +5 5 | x: typing.TypeAlias = int +6 |-x: TypeAlias = int + 6 |+type x = int +7 7 | +8 8 | # UP040 simple generic +9 9 | T = typing.TypeVar["T"] + +UP040.py:10:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + | + 8 | # UP040 simple generic + 9 | T = typing.TypeVar["T"] +10 | x: typing.TypeAlias = list[T] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 +11 | +12 | # UP040 call style generic + | + = help: Use the `type` keyword + +ℹ Fix +7 7 | +8 8 | # UP040 simple generic +9 9 | T = typing.TypeVar["T"] +10 |-x: typing.TypeAlias = list[T] + 10 |+type x[T] = list[T] +11 11 | +12 12 | # UP040 call style generic +13 13 | T = typing.TypeVar("T") + +UP040.py:14:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + | +12 | # UP040 call style generic +13 | T = typing.TypeVar("T") +14 | x: typing.TypeAlias = list[T] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 +15 | +16 | # UP040 bounded generic + | + = help: Use the `type` keyword + +ℹ Fix +11 11 | +12 12 | # UP040 call style generic +13 13 | T = typing.TypeVar("T") +14 |-x: typing.TypeAlias = list[T] + 14 |+type x[T] = list[T] +15 15 | +16 16 | # UP040 bounded generic +17 17 | T = typing.TypeVar("T", bound=int) + +UP040.py:18:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + | +16 | # UP040 bounded generic +17 | T = typing.TypeVar("T", bound=int) +18 | x: typing.TypeAlias = list[T] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 +19 | +20 | # UP040 constrained generic + | + = help: Use the `type` keyword + +ℹ Fix +15 15 | +16 16 | # UP040 bounded generic +17 17 | T = typing.TypeVar("T", bound=int) +18 |-x: typing.TypeAlias = list[T] + 18 |+type x[T: int] = list[T] +19 19 | +20 20 | # UP040 constrained generic +21 21 | T = typing.TypeVar("T", int, str) + +UP040.py:22:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + | +20 | # UP040 constrained generic +21 | T = typing.TypeVar("T", int, str) +22 | x: typing.TypeAlias = list[T] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 +23 | +24 | # UP040 contravariant generic + | + = help: Use the `type` keyword + +ℹ Fix +19 19 | +20 20 | # UP040 constrained generic +21 21 | T = typing.TypeVar("T", int, str) +22 |-x: typing.TypeAlias = list[T] + 22 |+type x[T: (int, str)] = list[T] +23 23 | +24 24 | # UP040 contravariant generic +25 25 | T = typing.TypeVar("T", contravariant=True) + +UP040.py:26:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + | +24 | # UP040 contravariant generic +25 | T = typing.TypeVar("T", contravariant=True) +26 | x: typing.TypeAlias = list[T] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 +27 | +28 | # UP040 covariant generic + | + = help: Use the `type` keyword + +ℹ Fix +23 23 | +24 24 | # UP040 contravariant generic +25 25 | T = typing.TypeVar("T", contravariant=True) +26 |-x: typing.TypeAlias = list[T] + 26 |+type x[T] = list[T] +27 27 | +28 28 | # UP040 covariant generic +29 29 | T = typing.TypeVar("T", covariant=True) + +UP040.py:30:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + | +28 | # UP040 covariant generic +29 | T = typing.TypeVar("T", covariant=True) +30 | x: typing.TypeAlias = list[T] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 +31 | +32 | # UP040 in class scope + | + = help: Use the `type` keyword + +ℹ Fix +27 27 | +28 28 | # UP040 covariant generic +29 29 | T = typing.TypeVar("T", covariant=True) +30 |-x: typing.TypeAlias = list[T] + 30 |+type x[T] = list[T] +31 31 | +32 32 | # UP040 in class scope +33 33 | T = typing.TypeVar["T"] + +UP040.py:36:5: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + | +34 | class Foo: +35 | # reference to global variable +36 | x: typing.TypeAlias = list[T] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 +37 | +38 | # reference to class variable + | + = help: Use the `type` keyword + +ℹ Fix +33 33 | T = typing.TypeVar["T"] +34 34 | class Foo: +35 35 | # reference to global variable +36 |- x: typing.TypeAlias = list[T] + 36 |+ type x[T] = list[T] +37 37 | +38 38 | # reference to class variable +39 39 | TCLS = typing.TypeVar["TCLS"] + +UP040.py:40:5: UP040 [*] Type alias `y` uses `TypeAlias` annotation instead of the `type` keyword + | +38 | # reference to class variable +39 | TCLS = typing.TypeVar["TCLS"] +40 | y: typing.TypeAlias = list[TCLS] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 +41 | +42 | # UP040 wont add generics in fix + | + = help: Use the `type` keyword + +ℹ Fix +37 37 | +38 38 | # reference to class variable +39 39 | TCLS = typing.TypeVar["TCLS"] +40 |- y: typing.TypeAlias = list[TCLS] + 40 |+ type y[TCLS] = list[TCLS] +41 41 | +42 42 | # UP040 wont add generics in fix +43 43 | T = typing.TypeVar(*args) + +UP040.py:44:1: UP040 [*] Type alias `x` uses `TypeAlias` annotation instead of the `type` keyword + | +42 | # UP040 wont add generics in fix +43 | T = typing.TypeVar(*args) +44 | x: typing.TypeAlias = list[T] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP040 +45 | +46 | # OK + | + = help: Use the `type` keyword + +ℹ Fix +41 41 | +42 42 | # UP040 wont add generics in fix +43 43 | T = typing.TypeVar(*args) +44 |-x: typing.TypeAlias = list[T] + 44 |+type x = list[T] +45 45 | +46 46 | # OK +47 47 | x: TypeAlias + + 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 new file mode 100644 index 0000000000..3cde302538 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__datetime_utc_alias_py311.snap @@ -0,0 +1,77 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +UP017.py:7:7: UP017 [*] Use `datetime.UTC` alias + | +6 | print(datetime.timezone(-1)) +7 | print(timezone.utc) + | ^^^^^^^^^^^^ UP017 +8 | print(tz.utc) + | + = help: Convert to `datetime.UTC` alias + +ℹ Suggested fix +4 4 | from datetime import timezone as tz +5 5 | +6 6 | print(datetime.timezone(-1)) +7 |-print(timezone.utc) + 7 |+print(datetime.UTC) +8 8 | print(tz.utc) +9 9 | +10 10 | print(datetime.timezone.utc) + +UP017.py:8:7: UP017 [*] Use `datetime.UTC` alias + | + 6 | print(datetime.timezone(-1)) + 7 | print(timezone.utc) + 8 | print(tz.utc) + | ^^^^^^ UP017 + 9 | +10 | print(datetime.timezone.utc) + | + = help: Convert to `datetime.UTC` alias + +ℹ Suggested fix +5 5 | +6 6 | print(datetime.timezone(-1)) +7 7 | print(timezone.utc) +8 |-print(tz.utc) + 8 |+print(datetime.UTC) +9 9 | +10 10 | print(datetime.timezone.utc) +11 11 | print(dt.timezone.utc) + +UP017.py:10:7: UP017 [*] Use `datetime.UTC` alias + | + 8 | print(tz.utc) + 9 | +10 | print(datetime.timezone.utc) + | ^^^^^^^^^^^^^^^^^^^^^ UP017 +11 | print(dt.timezone.utc) + | + = help: Convert to `datetime.UTC` alias + +ℹ Suggested fix +7 7 | print(timezone.utc) +8 8 | print(tz.utc) +9 9 | +10 |-print(datetime.timezone.utc) + 10 |+print(datetime.UTC) +11 11 | print(dt.timezone.utc) + +UP017.py:11:7: UP017 [*] Use `datetime.UTC` alias + | +10 | print(datetime.timezone.utc) +11 | print(dt.timezone.utc) + | ^^^^^^^^^^^^^^^ UP017 + | + = help: Convert to `datetime.UTC` alias + +ℹ Suggested fix +8 8 | print(tz.utc) +9 9 | +10 10 | print(datetime.timezone.utc) +11 |-print(dt.timezone.utc) + 11 |+print(datetime.UTC) + + 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 new file mode 100644 index 0000000000..93eff066ec --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p310.snap @@ -0,0 +1,75 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +future_annotations.py:34:18: UP006 [*] Use `list` instead of `List` for type annotation + | +34 | def f(x: int) -> List[int]: + | ^^^^ UP006 +35 | y = List[int]() +36 | y.append(x) + | + = help: Replace with `list` + +ℹ Fix +31 31 | return cls(x=0, y=0) +32 32 | +33 33 | +34 |-def f(x: int) -> List[int]: + 34 |+def f(x: int) -> list[int]: +35 35 | y = List[int]() +36 36 | y.append(x) +37 37 | return y + +future_annotations.py:35:9: UP006 [*] Use `list` instead of `List` for type annotation + | +34 | def f(x: int) -> List[int]: +35 | y = List[int]() + | ^^^^ UP006 +36 | y.append(x) +37 | return y + | + = help: Replace with `list` + +ℹ Fix +32 32 | +33 33 | +34 34 | def f(x: int) -> List[int]: +35 |- y = List[int]() + 35 |+ y = list[int]() +36 36 | y.append(x) +37 37 | return y +38 38 | + +future_annotations.py:42:27: UP006 [*] Use `list` instead of `List` for type annotation + | +40 | x: Optional[int] = None +41 | +42 | MyList: TypeAlias = Union[List[int], List[str]] + | ^^^^ UP006 + | + = help: Replace with `list` + +ℹ Fix +39 39 | +40 40 | x: Optional[int] = None +41 41 | +42 |-MyList: TypeAlias = Union[List[int], List[str]] + 42 |+MyList: TypeAlias = Union[list[int], List[str]] + +future_annotations.py:42:38: UP006 [*] Use `list` instead of `List` for type annotation + | +40 | x: Optional[int] = None +41 | +42 | MyList: TypeAlias = Union[List[int], List[str]] + | ^^^^ UP006 + | + = help: Replace with `list` + +ℹ Fix +39 39 | +40 40 | x: Optional[int] = None +41 41 | +42 |-MyList: TypeAlias = Union[List[int], List[str]] + 42 |+MyList: TypeAlias = Union[List[int], list[str]] + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p37.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p37.snap new file mode 100644 index 0000000000..2bacb5d540 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_keep_runtime_typing_p37.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_p37.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_p37.snap new file mode 100644 index 0000000000..3914eea5ed --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_p37.snap @@ -0,0 +1,23 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +future_annotations.py:34:18: UP006 [*] Use `list` instead of `List` for type annotation + | +34 | def f(x: int) -> List[int]: + | ^^^^ UP006 +35 | y = List[int]() +36 | y.append(x) + | + = help: Replace with `list` + +ℹ Fix +31 31 | return cls(x=0, y=0) +32 32 | +33 33 | +34 |-def f(x: int) -> List[int]: + 34 |+def f(x: int) -> list[int]: +35 35 | y = List[int]() +36 36 | y.append(x) +37 37 | return y + + 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 new file mode 100644 index 0000000000..93eff066ec --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_585_py310.snap @@ -0,0 +1,75 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +future_annotations.py:34:18: UP006 [*] Use `list` instead of `List` for type annotation + | +34 | def f(x: int) -> List[int]: + | ^^^^ UP006 +35 | y = List[int]() +36 | y.append(x) + | + = help: Replace with `list` + +ℹ Fix +31 31 | return cls(x=0, y=0) +32 32 | +33 33 | +34 |-def f(x: int) -> List[int]: + 34 |+def f(x: int) -> list[int]: +35 35 | y = List[int]() +36 36 | y.append(x) +37 37 | return y + +future_annotations.py:35:9: UP006 [*] Use `list` instead of `List` for type annotation + | +34 | def f(x: int) -> List[int]: +35 | y = List[int]() + | ^^^^ UP006 +36 | y.append(x) +37 | return y + | + = help: Replace with `list` + +ℹ Fix +32 32 | +33 33 | +34 34 | def f(x: int) -> List[int]: +35 |- y = List[int]() + 35 |+ y = list[int]() +36 36 | y.append(x) +37 37 | return y +38 38 | + +future_annotations.py:42:27: UP006 [*] Use `list` instead of `List` for type annotation + | +40 | x: Optional[int] = None +41 | +42 | MyList: TypeAlias = Union[List[int], List[str]] + | ^^^^ UP006 + | + = help: Replace with `list` + +ℹ Fix +39 39 | +40 40 | x: Optional[int] = None +41 41 | +42 |-MyList: TypeAlias = Union[List[int], List[str]] + 42 |+MyList: TypeAlias = Union[list[int], List[str]] + +future_annotations.py:42:38: UP006 [*] Use `list` instead of `List` for type annotation + | +40 | x: Optional[int] = None +41 | +42 | MyList: TypeAlias = Union[List[int], List[str]] + | ^^^^ UP006 + | + = help: Replace with `list` + +ℹ Fix +39 39 | +40 40 | x: Optional[int] = None +41 41 | +42 |-MyList: TypeAlias = Union[List[int], List[str]] + 42 |+MyList: TypeAlias = Union[List[int], list[str]] + + 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 new file mode 100644 index 0000000000..6c62e6ffb7 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_p37.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +future_annotations.py:40:4: UP007 [*] Use `X | Y` for type annotations + | +40 | x: Optional[int] = None + | ^^^^^^^^^^^^^ UP007 +41 | +42 | MyList: TypeAlias = Union[List[int], List[str]] + | + = help: Convert to `X | Y` + +ℹ Suggested fix +37 37 | return y +38 38 | +39 39 | +40 |-x: Optional[int] = None + 40 |+x: int | None = None +41 41 | +42 42 | MyList: TypeAlias = Union[List[int], List[str]] + + 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 new file mode 100644 index 0000000000..c9e4008d7a --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__future_annotations_pep_604_py310.snap @@ -0,0 +1,38 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- +future_annotations.py:40:4: UP007 [*] Use `X | Y` for type annotations + | +40 | x: Optional[int] = None + | ^^^^^^^^^^^^^ UP007 +41 | +42 | MyList: TypeAlias = Union[List[int], List[str]] + | + = help: Convert to `X | Y` + +ℹ Suggested fix +37 37 | return y +38 38 | +39 39 | +40 |-x: Optional[int] = None + 40 |+x: int | None = None +41 41 | +42 42 | MyList: TypeAlias = Union[List[int], List[str]] + +future_annotations.py:42:21: UP007 [*] Use `X | Y` for type annotations + | +40 | x: Optional[int] = None +41 | +42 | MyList: TypeAlias = Union[List[int], List[str]] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ UP007 + | + = help: Convert to `X | Y` + +ℹ Suggested fix +39 39 | +40 40 | x: Optional[int] = None +41 41 | +42 |-MyList: TypeAlias = Union[List[int], List[str]] + 42 |+MyList: TypeAlias = List[int] | List[str] + + diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__non_pep695_type_alias_not_applied_py311.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__non_pep695_type_alias_not_applied_py311.snap new file mode 100644 index 0000000000..2bacb5d540 --- /dev/null +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__non_pep695_type_alias_not_applied_py311.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/pyupgrade/mod.rs +--- + diff --git a/crates/ruff/src/rules/pyupgrade/types.rs b/crates/ruff_linter/src/rules/pyupgrade/types.rs similarity index 100% rename from crates/ruff/src/rules/pyupgrade/types.rs rename to crates/ruff_linter/src/rules/pyupgrade/types.rs diff --git a/crates/ruff/src/rules/refurb/helpers.rs b/crates/ruff_linter/src/rules/refurb/helpers.rs similarity index 100% rename from crates/ruff/src/rules/refurb/helpers.rs rename to crates/ruff_linter/src/rules/refurb/helpers.rs diff --git a/crates/ruff/src/rules/refurb/mod.rs b/crates/ruff_linter/src/rules/refurb/mod.rs similarity index 100% rename from crates/ruff/src/rules/refurb/mod.rs rename to crates/ruff_linter/src/rules/refurb/mod.rs diff --git a/crates/ruff/src/rules/refurb/rules/check_and_remove_from_set.rs b/crates/ruff_linter/src/rules/refurb/rules/check_and_remove_from_set.rs similarity index 100% rename from crates/ruff/src/rules/refurb/rules/check_and_remove_from_set.rs rename to crates/ruff_linter/src/rules/refurb/rules/check_and_remove_from_set.rs diff --git a/crates/ruff/src/rules/refurb/rules/delete_full_slice.rs b/crates/ruff_linter/src/rules/refurb/rules/delete_full_slice.rs similarity index 100% rename from crates/ruff/src/rules/refurb/rules/delete_full_slice.rs rename to crates/ruff_linter/src/rules/refurb/rules/delete_full_slice.rs diff --git a/crates/ruff/src/rules/refurb/rules/mod.rs b/crates/ruff_linter/src/rules/refurb/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/refurb/rules/mod.rs rename to crates/ruff_linter/src/rules/refurb/rules/mod.rs diff --git a/crates/ruff/src/rules/refurb/rules/reimplemented_starmap.rs b/crates/ruff_linter/src/rules/refurb/rules/reimplemented_starmap.rs similarity index 100% rename from crates/ruff/src/rules/refurb/rules/reimplemented_starmap.rs rename to crates/ruff_linter/src/rules/refurb/rules/reimplemented_starmap.rs diff --git a/crates/ruff/src/rules/refurb/rules/repeated_append.rs b/crates/ruff_linter/src/rules/refurb/rules/repeated_append.rs similarity index 100% rename from crates/ruff/src/rules/refurb/rules/repeated_append.rs rename to crates/ruff_linter/src/rules/refurb/rules/repeated_append.rs diff --git a/crates/ruff/src/rules/refurb/rules/slice_copy.rs b/crates/ruff_linter/src/rules/refurb/rules/slice_copy.rs similarity index 100% rename from crates/ruff/src/rules/refurb/rules/slice_copy.rs rename to crates/ruff_linter/src/rules/refurb/rules/slice_copy.rs diff --git a/crates/ruff/src/rules/refurb/rules/unnecessary_enumerate.rs b/crates/ruff_linter/src/rules/refurb/rules/unnecessary_enumerate.rs similarity index 100% rename from crates/ruff/src/rules/refurb/rules/unnecessary_enumerate.rs rename to crates/ruff_linter/src/rules/refurb/rules/unnecessary_enumerate.rs 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 new file mode 100644 index 0000000000..4ce5ab6cd5 --- /dev/null +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB113_FURB113.py.snap @@ -0,0 +1,335 @@ +--- +source: crates/ruff_linter/src/rules/refurb/mod.rs +--- +FURB113.py:23:1: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly calling `nums.append()` + | +22 | # FURB113 +23 | / nums.append(1) +24 | | nums.append(2) + | |______________^ FURB113 +25 | pass + | + = help: Replace with `nums.extend((1, 2))` + +ℹ Suggested fix +20 20 | +21 21 | +22 22 | # FURB113 +23 |-nums.append(1) +24 |-nums.append(2) + 23 |+nums.extend((1, 2)) +25 24 | pass +26 25 | +27 26 | + +FURB113.py:29:1: FURB113 [*] Use `nums3.extend((1, 2))` instead of repeatedly calling `nums3.append()` + | +28 | # FURB113 +29 | / nums3.append(1) +30 | | nums3.append(2) + | |_______________^ FURB113 +31 | pass + | + = help: Replace with `nums3.extend((1, 2))` + +ℹ Suggested fix +26 26 | +27 27 | +28 28 | # FURB113 +29 |-nums3.append(1) +30 |-nums3.append(2) + 29 |+nums3.extend((1, 2)) +31 30 | pass +32 31 | +33 32 | + +FURB113.py:35:1: FURB113 [*] Use `nums4.extend((1, 2))` instead of repeatedly calling `nums4.append()` + | +34 | # FURB113 +35 | / nums4.append(1) +36 | | nums4.append(2) + | |_______________^ FURB113 +37 | pass + | + = help: Replace with `nums4.extend((1, 2))` + +ℹ Suggested fix +32 32 | +33 33 | +34 34 | # FURB113 +35 |-nums4.append(1) +36 |-nums4.append(2) + 35 |+nums4.extend((1, 2)) +37 36 | pass +38 37 | +39 38 | + +FURB113.py:41:1: FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` + | +40 | # FURB113 +41 | / nums.append(1) +42 | | nums2.append(1) +43 | | nums.append(2) +44 | | nums.append(3) + | |______________^ FURB113 +45 | pass + | + = help: Replace with `nums.extend((1, 2, 3))` + +FURB113.py:49:1: FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` + | +48 | # FURB113 +49 | / nums.append(1) +50 | | nums2.append(1) +51 | | nums.append(2) +52 | | # FURB113 +53 | | nums3.append(1) +54 | | nums.append(3) + | |______________^ FURB113 +55 | # FURB113 +56 | nums4.append(1) + | + = help: Replace with `nums.extend((1, 2, 3))` + +FURB113.py:53:1: FURB113 Use `nums3.extend((1, 2))` instead of repeatedly calling `nums3.append()` + | +51 | nums.append(2) +52 | # FURB113 +53 | / nums3.append(1) +54 | | nums.append(3) +55 | | # FURB113 +56 | | nums4.append(1) +57 | | nums4.append(2) +58 | | nums3.append(2) + | |_______________^ FURB113 +59 | pass + | + = help: Replace with `nums3.extend((1, 2))` + +FURB113.py:56:1: FURB113 [*] Use `nums4.extend((1, 2))` instead of repeatedly calling `nums4.append()` + | +54 | nums.append(3) +55 | # FURB113 +56 | / nums4.append(1) +57 | | nums4.append(2) + | |_______________^ FURB113 +58 | nums3.append(2) +59 | pass + | + = help: Replace with `nums4.extend((1, 2))` + +ℹ Suggested fix +53 53 | nums3.append(1) +54 54 | nums.append(3) +55 55 | # FURB113 +56 |-nums4.append(1) +57 |-nums4.append(2) + 56 |+nums4.extend((1, 2)) +58 57 | nums3.append(2) +59 58 | pass +60 59 | + +FURB113.py:62:1: FURB113 [*] Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` + | +61 | # FURB113 +62 | / nums.append(1) +63 | | nums.append(2) +64 | | nums.append(3) + | |______________^ FURB113 + | + = help: Replace with `nums.extend((1, 2, 3))` + +ℹ Suggested fix +59 59 | pass +60 60 | +61 61 | # FURB113 +62 |-nums.append(1) +63 |-nums.append(2) +64 |-nums.append(3) + 62 |+nums.extend((1, 2, 3)) +65 63 | +66 64 | +67 65 | if True: + +FURB113.py:69:5: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly calling `nums.append()` + | +67 | if True: +68 | # FURB113 +69 | nums.append(1) + | _____^ +70 | | nums.append(2) + | |__________________^ FURB113 + | + = help: Replace with `nums.extend((1, 2))` + +ℹ Suggested fix +66 66 | +67 67 | if True: +68 68 | # FURB113 +69 |- nums.append(1) +70 |- nums.append(2) + 69 |+ nums.extend((1, 2)) +71 70 | +72 71 | +73 72 | if True: + +FURB113.py:75:5: FURB113 [*] Use `nums.extend((1, 2))` instead of repeatedly calling `nums.append()` + | +73 | if True: +74 | # FURB113 +75 | nums.append(1) + | _____^ +76 | | nums.append(2) + | |__________________^ FURB113 +77 | pass + | + = help: Replace with `nums.extend((1, 2))` + +ℹ Suggested fix +72 72 | +73 73 | if True: +74 74 | # FURB113 +75 |- nums.append(1) +76 |- nums.append(2) + 75 |+ nums.extend((1, 2)) +77 76 | pass +78 77 | +79 78 | + +FURB113.py:82:5: FURB113 Use `nums.extend((1, 2, 3))` instead of repeatedly calling `nums.append()` + | +80 | if True: +81 | # FURB113 +82 | nums.append(1) + | _____^ +83 | | nums2.append(1) +84 | | nums.append(2) +85 | | nums.append(3) + | |__________________^ FURB113 + | + = help: Replace with `nums.extend((1, 2, 3))` + +FURB113.py:90:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` + | +88 | def yes_one(x: list[int]): +89 | # FURB113 +90 | x.append(1) + | _____^ +91 | | x.append(2) + | |_______________^ FURB113 + | + = help: Replace with `x.extend((1, 2))` + +ℹ Suggested fix +87 87 | +88 88 | def yes_one(x: list[int]): +89 89 | # FURB113 +90 |- x.append(1) +91 |- x.append(2) + 90 |+ x.extend((1, 2)) +92 91 | +93 92 | +94 93 | def yes_two(x: List[int]): + +FURB113.py:96:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` + | +94 | def yes_two(x: List[int]): +95 | # FURB113 +96 | x.append(1) + | _____^ +97 | | x.append(2) + | |_______________^ FURB113 + | + = help: Replace with `x.extend((1, 2))` + +ℹ Suggested fix +93 93 | +94 94 | def yes_two(x: List[int]): +95 95 | # FURB113 +96 |- x.append(1) +97 |- x.append(2) + 96 |+ x.extend((1, 2)) +98 97 | +99 98 | +100 99 | def yes_three(*, x: list[int]): + +FURB113.py:102:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` + | +100 | def yes_three(*, x: list[int]): +101 | # FURB113 +102 | x.append(1) + | _____^ +103 | | x.append(2) + | |_______________^ FURB113 + | + = help: Replace with `x.extend((1, 2))` + +ℹ Suggested fix +99 99 | +100 100 | def yes_three(*, x: list[int]): +101 101 | # FURB113 +102 |- x.append(1) +103 |- x.append(2) + 102 |+ x.extend((1, 2)) +104 103 | +105 104 | +106 105 | def yes_four(x: list[int], /): + +FURB113.py:108:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` + | +106 | def yes_four(x: list[int], /): +107 | # FURB113 +108 | x.append(1) + | _____^ +109 | | x.append(2) + | |_______________^ FURB113 + | + = help: Replace with `x.extend((1, 2))` + +ℹ Suggested fix +105 105 | +106 106 | def yes_four(x: list[int], /): +107 107 | # FURB113 +108 |- x.append(1) +109 |- x.append(2) + 108 |+ x.extend((1, 2)) +110 109 | +111 110 | +112 111 | def yes_five(x: list[int], y: list[int]): + +FURB113.py:114:5: FURB113 Use `x.extend((1, 2, 3))` instead of repeatedly calling `x.append()` + | +112 | def yes_five(x: list[int], y: list[int]): +113 | # FURB113 +114 | x.append(1) + | _____^ +115 | | x.append(2) +116 | | y.append(1) +117 | | x.append(3) + | |_______________^ FURB113 + | + = help: Replace with `x.extend((1, 2, 3))` + +FURB113.py:122:5: FURB113 [*] Use `x.extend((1, 2))` instead of repeatedly calling `x.append()` + | +120 | def yes_six(x: list): +121 | # FURB113 +122 | x.append(1) + | _____^ +123 | | x.append(2) + | |_______________^ FURB113 + | + = help: Replace with `x.extend((1, 2))` + +ℹ Suggested fix +119 119 | +120 120 | def yes_six(x: list): +121 121 | # FURB113 +122 |- x.append(1) +123 |- x.append(2) + 122 |+ x.extend((1, 2)) +124 123 | +125 124 | +126 125 | # Non-errors. + + 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 new file mode 100644 index 0000000000..14ad4d9c3c --- /dev/null +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB131_FURB131.py.snap @@ -0,0 +1,132 @@ +--- +source: crates/ruff_linter/src/rules/refurb/mod.rs +--- +FURB131.py:11:1: FURB131 [*] Prefer `clear` over deleting a full slice + | +10 | # FURB131 +11 | del nums[:] + | ^^^^^^^^^^^ FURB131 + | + = help: Replace with `clear()` + +ℹ Suggested fix +8 8 | # these should match +9 9 | +10 10 | # FURB131 +11 |-del nums[:] + 11 |+nums.clear() +12 12 | +13 13 | +14 14 | # FURB131 + +FURB131.py:15:1: FURB131 [*] Prefer `clear` over deleting a full slice + | +14 | # FURB131 +15 | del names[:] + | ^^^^^^^^^^^^ FURB131 + | + = help: Replace with `clear()` + +ℹ Suggested fix +12 12 | +13 13 | +14 14 | # FURB131 +15 |-del names[:] + 15 |+names.clear() +16 16 | +17 17 | +18 18 | # FURB131 + +FURB131.py:19:1: FURB131 Prefer `clear` over deleting a full slice + | +18 | # FURB131 +19 | del x, nums[:] + | ^^^^^^^^^^^^^^ FURB131 + | + = help: Replace with `clear()` + +FURB131.py:23:1: FURB131 Prefer `clear` over deleting a full slice + | +22 | # FURB131 +23 | del y, names[:], x + | ^^^^^^^^^^^^^^^^^^ FURB131 + | + = help: Replace with `clear()` + +FURB131.py:28:5: FURB131 [*] Prefer `clear` over deleting a full slice + | +26 | def yes_one(x: list[int]): +27 | # FURB131 +28 | del x[:] + | ^^^^^^^^ FURB131 + | + = help: Replace with `clear()` + +ℹ Suggested fix +25 25 | +26 26 | def yes_one(x: list[int]): +27 27 | # FURB131 +28 |- del x[:] + 28 |+ x.clear() +29 29 | +30 30 | +31 31 | def yes_two(x: dict[int, str]): + +FURB131.py:33:5: FURB131 [*] Prefer `clear` over deleting a full slice + | +31 | def yes_two(x: dict[int, str]): +32 | # FURB131 +33 | del x[:] + | ^^^^^^^^ FURB131 + | + = help: Replace with `clear()` + +ℹ Suggested fix +30 30 | +31 31 | def yes_two(x: dict[int, str]): +32 32 | # FURB131 +33 |- del x[:] + 33 |+ x.clear() +34 34 | +35 35 | +36 36 | def yes_three(x: List[int]): + +FURB131.py:38:5: FURB131 [*] Prefer `clear` over deleting a full slice + | +36 | def yes_three(x: List[int]): +37 | # FURB131 +38 | del x[:] + | ^^^^^^^^ FURB131 + | + = help: Replace with `clear()` + +ℹ Suggested fix +35 35 | +36 36 | def yes_three(x: List[int]): +37 37 | # FURB131 +38 |- del x[:] + 38 |+ x.clear() +39 39 | +40 40 | +41 41 | def yes_four(x: Dict[int, str]): + +FURB131.py:43:5: FURB131 [*] Prefer `clear` over deleting a full slice + | +41 | def yes_four(x: Dict[int, str]): +42 | # FURB131 +43 | del x[:] + | ^^^^^^^^ FURB131 + | + = help: Replace with `clear()` + +ℹ Suggested fix +40 40 | +41 41 | def yes_four(x: Dict[int, str]): +42 42 | # FURB131 +43 |- del x[:] + 43 |+ x.clear() +44 44 | +45 45 | +46 46 | # these should not + + diff --git a/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB132_FURB132.py.snap b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB132_FURB132.py.snap new file mode 100644 index 0000000000..25c2e3746b --- /dev/null +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB132_FURB132.py.snap @@ -0,0 +1,84 @@ +--- +source: crates/ruff_linter/src/rules/refurb/mod.rs +--- +FURB132.py:12:1: FURB132 [*] Use `s.discard("x")` instead of check and `remove` + | +11 | # FURB132 +12 | / if "x" in s: +13 | | s.remove("x") + | |_________________^ FURB132 + | + = help: Replace with `s.discard("x")` + +ℹ Suggested fix +9 9 | # these should match +10 10 | +11 11 | # FURB132 +12 |-if "x" in s: +13 |- s.remove("x") + 12 |+s.discard("x") +14 13 | +15 14 | +16 15 | # FURB132 + +FURB132.py:22:1: FURB132 [*] Use `s3.discard("x")` instead of check and `remove` + | +21 | # FURB132 +22 | / if "x" in s3: +23 | | s3.remove("x") + | |__________________^ FURB132 + | + = help: Replace with `s3.discard("x")` + +ℹ Suggested fix +19 19 | +20 20 | +21 21 | # FURB132 +22 |-if "x" in s3: +23 |- s3.remove("x") + 22 |+s3.discard("x") +24 23 | +25 24 | +26 25 | var = "y" + +FURB132.py:28:1: FURB132 [*] Use `s.discard(var)` instead of check and `remove` + | +26 | var = "y" +27 | # FURB132 +28 | / if var in s: +29 | | s.remove(var) + | |_________________^ FURB132 + | + = help: Replace with `s.discard(var)` + +ℹ Suggested fix +25 25 | +26 26 | var = "y" +27 27 | # FURB132 +28 |-if var in s: +29 |- s.remove(var) + 28 |+s.discard(var) +30 29 | +31 30 | +32 31 | if f"{var}:{var}" in s: + +FURB132.py:32:1: FURB132 [*] Use `s.discard(f"{var}:{var}")` instead of check and `remove` + | +32 | / if f"{var}:{var}" in s: +33 | | s.remove(f"{var}:{var}") + | |____________________________^ FURB132 + | + = help: Replace with `s.discard(f"{var}:{var}")` + +ℹ Suggested fix +29 29 | s.remove(var) +30 30 | +31 31 | +32 |-if f"{var}:{var}" in s: +33 |- s.remove(f"{var}:{var}") + 32 |+s.discard(f"{var}:{var}") +34 33 | +35 34 | +36 35 | def identity(x): + + 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 new file mode 100644 index 0000000000..1e7691809d --- /dev/null +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB140_FURB140.py.snap @@ -0,0 +1,136 @@ +--- +source: crates/ruff_linter/src/rules/refurb/mod.rs +--- +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 | +9 | # FURB140 + | + = help: Replace with `itertools.starmap` + +ℹ Suggested fix + 1 |+from itertools import starmap +1 2 | def zipped(): +2 3 | return zip([1, 2, 3], "ABC") +3 4 | +4 5 | # Errors. +5 6 | +6 7 | # FURB140 +7 |-[print(x, y) for x, y in zipped()] + 8 |+list(starmap(print, zipped())) +8 9 | +9 10 | # FURB140 +10 11 | (print(x, y) for x, y in zipped()) + +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 | +12 | # FURB140 + | + = help: Replace with `itertools.starmap` + +ℹ Suggested fix + 1 |+from itertools import starmap +1 2 | def zipped(): +2 3 | return zip([1, 2, 3], "ABC") +3 4 | +-------------------------------------------------------------------------------- +7 8 | [print(x, y) for x, y in zipped()] +8 9 | +9 10 | # FURB140 +10 |-(print(x, y) for x, y in zipped()) + 11 |+starmap(print, zipped()) +11 12 | +12 13 | # FURB140 +13 14 | {print(x, y) for x, y in zipped()} + +FURB140.py:13:1: FURB140 [*] Use `itertools.starmap` instead of the generator + | +12 | # FURB140 +13 | {print(x, y) for x, y in zipped()} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FURB140 + | + = help: Replace with `itertools.starmap` + +ℹ Suggested fix + 1 |+from itertools import starmap +1 2 | def zipped(): +2 3 | return zip([1, 2, 3], "ABC") +3 4 | +-------------------------------------------------------------------------------- +10 11 | (print(x, y) for x, y in zipped()) +11 12 | +12 13 | # FURB140 +13 |-{print(x, y) for x, y in zipped()} + 14 |+set(starmap(print, zipped())) +14 15 | +15 16 | +16 17 | from itertools import starmap as sm + +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 | +21 | # FURB140 + | + = help: Replace with `itertools.starmap` + +ℹ Suggested fix +16 16 | from itertools import starmap as sm +17 17 | +18 18 | # FURB140 +19 |-[print(x, y) for x, y in zipped()] + 19 |+list(sm(print, zipped())) +20 20 | +21 21 | # FURB140 +22 22 | (print(x, y) for x, y in zipped()) + +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 | +24 | # FURB140 + | + = help: Replace with `itertools.starmap` + +ℹ Suggested fix +19 19 | [print(x, y) for x, y in zipped()] +20 20 | +21 21 | # FURB140 +22 |-(print(x, y) for x, y in zipped()) + 22 |+sm(print, zipped()) +23 23 | +24 24 | # FURB140 +25 25 | {print(x, y) for x, y in zipped()} + +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 | +27 | # Non-errors. + | + = help: Replace with `itertools.starmap` + +ℹ Suggested fix +22 22 | (print(x, y) for x, y in zipped()) +23 23 | +24 24 | # FURB140 +25 |-{print(x, y) for x, y in zipped()} + 25 |+set(sm(print, zipped())) +26 26 | +27 27 | # Non-errors. +28 28 | + + 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 new file mode 100644 index 0000000000..742f089ebf --- /dev/null +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB145_FURB145.py.snap @@ -0,0 +1,128 @@ +--- +source: crates/ruff_linter/src/rules/refurb/mod.rs +--- +FURB145.py:4:5: FURB145 [*] Prefer `copy` method over slicing + | +3 | # Errors. +4 | a = l[:] + | ^^^^ FURB145 +5 | b, c = 1, l[:] +6 | d, e = l[:], 1 + | + = help: Replace with `copy()` + +ℹ Suggested fix +1 1 | l = [1, 2, 3, 4, 5] +2 2 | +3 3 | # Errors. +4 |-a = l[:] + 4 |+a = l.copy() +5 5 | b, c = 1, l[:] +6 6 | d, e = l[:], 1 +7 7 | m = l[::] + +FURB145.py:5:11: FURB145 [*] Prefer `copy` method over slicing + | +3 | # Errors. +4 | a = l[:] +5 | b, c = 1, l[:] + | ^^^^ FURB145 +6 | d, e = l[:], 1 +7 | m = l[::] + | + = help: Replace with `copy()` + +ℹ Suggested fix +2 2 | +3 3 | # Errors. +4 4 | a = l[:] +5 |-b, c = 1, l[:] + 5 |+b, c = 1, l.copy() +6 6 | d, e = l[:], 1 +7 7 | m = l[::] +8 8 | l[:] + +FURB145.py:6:8: FURB145 [*] Prefer `copy` method over slicing + | +4 | a = l[:] +5 | b, c = 1, l[:] +6 | d, e = l[:], 1 + | ^^^^ FURB145 +7 | m = l[::] +8 | l[:] + | + = help: Replace with `copy()` + +ℹ Suggested fix +3 3 | # Errors. +4 4 | a = l[:] +5 5 | b, c = 1, l[:] +6 |-d, e = l[:], 1 + 6 |+d, e = l.copy(), 1 +7 7 | m = l[::] +8 8 | l[:] +9 9 | print(l[:]) + +FURB145.py:7:5: FURB145 [*] Prefer `copy` method over slicing + | +5 | b, c = 1, l[:] +6 | d, e = l[:], 1 +7 | m = l[::] + | ^^^^^ FURB145 +8 | l[:] +9 | print(l[:]) + | + = help: Replace with `copy()` + +ℹ Suggested fix +4 4 | a = l[:] +5 5 | b, c = 1, l[:] +6 6 | d, e = l[:], 1 +7 |-m = l[::] + 7 |+m = l.copy() +8 8 | l[:] +9 9 | print(l[:]) +10 10 | + +FURB145.py:8:1: FURB145 [*] Prefer `copy` method over slicing + | +6 | d, e = l[:], 1 +7 | m = l[::] +8 | l[:] + | ^^^^ FURB145 +9 | print(l[:]) + | + = help: Replace with `copy()` + +ℹ Suggested fix +5 5 | b, c = 1, l[:] +6 6 | d, e = l[:], 1 +7 7 | m = l[::] +8 |-l[:] + 8 |+l.copy() +9 9 | print(l[:]) +10 10 | +11 11 | # False negatives. + +FURB145.py:9:7: FURB145 [*] Prefer `copy` method over slicing + | + 7 | m = l[::] + 8 | l[:] + 9 | print(l[:]) + | ^^^^ FURB145 +10 | +11 | # False negatives. + | + = help: Replace with `copy()` + +ℹ Suggested fix +6 6 | d, e = l[:], 1 +7 7 | m = l[::] +8 8 | l[:] +9 |-print(l[:]) + 9 |+print(l.copy()) +10 10 | +11 11 | # False negatives. +12 12 | aa = a[:] # Type inference. + + 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 new file mode 100644 index 0000000000..198097f8fe --- /dev/null +++ b/crates/ruff_linter/src/rules/refurb/snapshots/ruff_linter__rules__refurb__tests__FURB148_FURB148.py.snap @@ -0,0 +1,323 @@ +--- +source: crates/ruff_linter/src/rules/refurb/mod.rs +--- +FURB148.py:4:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead + | +3 | # Errors +4 | for index, _ in enumerate(books): + | ^^^^^^^^^ FURB148 +5 | print(index) + | + = help: Replace with `range(len(...))` + +ℹ Suggested fix +1 1 | books = ["Dune", "Foundation", "Neuromancer"] +2 2 | +3 3 | # Errors +4 |-for index, _ in enumerate(books): + 4 |+for index in range(len(books)): +5 5 | print(index) +6 6 | +7 7 | for index, _ in enumerate(books, start=0): + +FURB148.py:7:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead + | +5 | print(index) +6 | +7 | for index, _ in enumerate(books, start=0): + | ^^^^^^^^^ FURB148 +8 | print(index) + | + = help: Replace with `range(len(...))` + +ℹ Suggested fix +4 4 | for index, _ in enumerate(books): +5 5 | print(index) +6 6 | +7 |-for index, _ in enumerate(books, start=0): + 7 |+for index in range(len(books)): +8 8 | print(index) +9 9 | +10 10 | for index, _ in enumerate(books, 0): + +FURB148.py:10:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead + | + 8 | print(index) + 9 | +10 | for index, _ in enumerate(books, 0): + | ^^^^^^^^^ FURB148 +11 | print(index) + | + = help: Replace with `range(len(...))` + +ℹ Suggested fix +7 7 | for index, _ in enumerate(books, start=0): +8 8 | print(index) +9 9 | +10 |-for index, _ in enumerate(books, 0): + 10 |+for index in range(len(books)): +11 11 | print(index) +12 12 | +13 13 | for index, _ in enumerate(books, start=1): + +FURB148.py:13:17: FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead + | +11 | print(index) +12 | +13 | for index, _ in enumerate(books, start=1): + | ^^^^^^^^^ FURB148 +14 | print(index) + | + = help: Replace with `range(len(...))` + +FURB148.py:16:17: FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead + | +14 | print(index) +15 | +16 | for index, _ in enumerate(books, 1): + | ^^^^^^^^^ FURB148 +17 | print(index) + | + = help: Replace with `range(len(...))` + +FURB148.py:19:17: FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead + | +17 | print(index) +18 | +19 | for index, _ in enumerate(books, start=x): + | ^^^^^^^^^ FURB148 +20 | print(book) + | + = help: Replace with `range(len(...))` + +FURB148.py:22:17: FURB148 `enumerate` value is unused, use `for x in range(len(y))` instead + | +20 | print(book) +21 | +22 | for index, _ in enumerate(books, x): + | ^^^^^^^^^ FURB148 +23 | print(book) + | + = help: Replace with `range(len(...))` + +FURB148.py:25:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead + | +23 | print(book) +24 | +25 | for _, book in enumerate(books): + | ^^^^^^^^^ FURB148 +26 | print(book) + | + = help: Remove `enumerate` + +ℹ Suggested fix +22 22 | for index, _ in enumerate(books, x): +23 23 | print(book) +24 24 | +25 |-for _, book in enumerate(books): + 25 |+for book in books: +26 26 | print(book) +27 27 | +28 28 | for _, book in enumerate(books, start=0): + +FURB148.py:28:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead + | +26 | print(book) +27 | +28 | for _, book in enumerate(books, start=0): + | ^^^^^^^^^ FURB148 +29 | print(book) + | + = help: Remove `enumerate` + +ℹ Suggested fix +25 25 | for _, book in enumerate(books): +26 26 | print(book) +27 27 | +28 |-for _, book in enumerate(books, start=0): + 28 |+for book in books: +29 29 | print(book) +30 30 | +31 31 | for _, book in enumerate(books, 0): + +FURB148.py:31:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead + | +29 | print(book) +30 | +31 | for _, book in enumerate(books, 0): + | ^^^^^^^^^ FURB148 +32 | print(book) + | + = help: Remove `enumerate` + +ℹ Suggested fix +28 28 | for _, book in enumerate(books, start=0): +29 29 | print(book) +30 30 | +31 |-for _, book in enumerate(books, 0): + 31 |+for book in books: +32 32 | print(book) +33 33 | +34 34 | for _, book in enumerate(books, start=1): + +FURB148.py:34:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead + | +32 | print(book) +33 | +34 | for _, book in enumerate(books, start=1): + | ^^^^^^^^^ FURB148 +35 | print(book) + | + = help: Remove `enumerate` + +ℹ Suggested fix +31 31 | for _, book in enumerate(books, 0): +32 32 | print(book) +33 33 | +34 |-for _, book in enumerate(books, start=1): + 34 |+for book in books: +35 35 | print(book) +36 36 | +37 37 | for _, book in enumerate(books, 1): + +FURB148.py:37:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead + | +35 | print(book) +36 | +37 | for _, book in enumerate(books, 1): + | ^^^^^^^^^ FURB148 +38 | print(book) + | + = help: Remove `enumerate` + +ℹ Suggested fix +34 34 | for _, book in enumerate(books, start=1): +35 35 | print(book) +36 36 | +37 |-for _, book in enumerate(books, 1): + 37 |+for book in books: +38 38 | print(book) +39 39 | +40 40 | for _, book in enumerate(books, start=x): + +FURB148.py:40:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead + | +38 | print(book) +39 | +40 | for _, book in enumerate(books, start=x): + | ^^^^^^^^^ FURB148 +41 | print(book) + | + = help: Remove `enumerate` + +ℹ Suggested fix +37 37 | for _, book in enumerate(books, 1): +38 38 | print(book) +39 39 | +40 |-for _, book in enumerate(books, start=x): + 40 |+for book in books: +41 41 | print(book) +42 42 | +43 43 | for _, book in enumerate(books, x): + +FURB148.py:43:16: FURB148 [*] `enumerate` index is unused, use `for x in y` instead + | +41 | print(book) +42 | +43 | for _, book in enumerate(books, x): + | ^^^^^^^^^ FURB148 +44 | print(book) + | + = help: Remove `enumerate` + +ℹ Suggested fix +40 40 | for _, book in enumerate(books, start=x): +41 41 | print(book) +42 42 | +43 |-for _, book in enumerate(books, x): + 43 |+for book in books: +44 44 | print(book) +45 45 | +46 46 | for index, (_, _) in enumerate(books): + +FURB148.py:46:22: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead + | +44 | print(book) +45 | +46 | for index, (_, _) in enumerate(books): + | ^^^^^^^^^ FURB148 +47 | print(index) + | + = help: Replace with `range(len(...))` + +ℹ Suggested fix +43 43 | for _, book in enumerate(books, x): +44 44 | print(book) +45 45 | +46 |-for index, (_, _) in enumerate(books): + 46 |+for index in range(len(books)): +47 47 | print(index) +48 48 | +49 49 | for (_, _), book in enumerate(books): + +FURB148.py:49:21: FURB148 [*] `enumerate` index is unused, use `for x in y` instead + | +47 | print(index) +48 | +49 | for (_, _), book in enumerate(books): + | ^^^^^^^^^ FURB148 +50 | print(book) + | + = help: Remove `enumerate` + +ℹ Suggested fix +46 46 | for index, (_, _) in enumerate(books): +47 47 | print(index) +48 48 | +49 |-for (_, _), book in enumerate(books): + 49 |+for book in books: +50 50 | print(book) +51 51 | +52 52 | for(index, _)in enumerate(books): + +FURB148.py:52:17: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead + | +50 | print(book) +51 | +52 | for(index, _)in enumerate(books): + | ^^^^^^^^^ FURB148 +53 | print(index) + | + = help: Replace with `range(len(...))` + +ℹ Suggested fix +49 49 | for (_, _), book in enumerate(books): +50 50 | print(book) +51 51 | +52 |-for(index, _)in enumerate(books): + 52 |+for index in range(len(books)): +53 53 | print(index) +54 54 | +55 55 | for(index), _ in enumerate(books): + +FURB148.py:55:18: FURB148 [*] `enumerate` value is unused, use `for x in range(len(y))` instead + | +53 | print(index) +54 | +55 | for(index), _ in enumerate(books): + | ^^^^^^^^^ FURB148 +56 | print(index) + | + = help: Replace with `range(len(...))` + +ℹ Suggested fix +52 52 | for(index, _)in enumerate(books): +53 53 | print(index) +54 54 | +55 |-for(index), _ in enumerate(books): + 55 |+for index in range(len(books)): +56 56 | print(index) +57 57 | +58 58 | # OK + + diff --git a/crates/ruff/src/rules/ruff/mod.rs b/crates/ruff_linter/src/rules/ruff/mod.rs similarity index 100% rename from crates/ruff/src/rules/ruff/mod.rs rename to crates/ruff_linter/src/rules/ruff/mod.rs diff --git a/crates/ruff/src/rules/ruff/rules/ambiguous_unicode_character.rs b/crates/ruff_linter/src/rules/ruff/rules/ambiguous_unicode_character.rs similarity index 100% rename from crates/ruff/src/rules/ruff/rules/ambiguous_unicode_character.rs rename to crates/ruff_linter/src/rules/ruff/rules/ambiguous_unicode_character.rs diff --git a/crates/ruff/src/rules/ruff/rules/asyncio_dangling_task.rs b/crates/ruff_linter/src/rules/ruff/rules/asyncio_dangling_task.rs similarity index 100% rename from crates/ruff/src/rules/ruff/rules/asyncio_dangling_task.rs rename to crates/ruff_linter/src/rules/ruff/rules/asyncio_dangling_task.rs diff --git a/crates/ruff/src/rules/ruff/rules/collection_literal_concatenation.rs b/crates/ruff_linter/src/rules/ruff/rules/collection_literal_concatenation.rs similarity index 100% rename from crates/ruff/src/rules/ruff/rules/collection_literal_concatenation.rs rename to crates/ruff_linter/src/rules/ruff/rules/collection_literal_concatenation.rs diff --git a/crates/ruff/src/rules/ruff/rules/confusables.rs b/crates/ruff_linter/src/rules/ruff/rules/confusables.rs similarity index 100% rename from crates/ruff/src/rules/ruff/rules/confusables.rs rename to crates/ruff_linter/src/rules/ruff/rules/confusables.rs diff --git a/crates/ruff/src/rules/ruff/rules/explicit_f_string_type_conversion.rs b/crates/ruff_linter/src/rules/ruff/rules/explicit_f_string_type_conversion.rs similarity index 100% rename from crates/ruff/src/rules/ruff/rules/explicit_f_string_type_conversion.rs rename to crates/ruff_linter/src/rules/ruff/rules/explicit_f_string_type_conversion.rs diff --git a/crates/ruff/src/rules/ruff/rules/function_call_in_dataclass_default.rs b/crates/ruff_linter/src/rules/ruff/rules/function_call_in_dataclass_default.rs similarity index 100% rename from crates/ruff/src/rules/ruff/rules/function_call_in_dataclass_default.rs rename to crates/ruff_linter/src/rules/ruff/rules/function_call_in_dataclass_default.rs diff --git a/crates/ruff/src/rules/ruff/rules/helpers.rs b/crates/ruff_linter/src/rules/ruff/rules/helpers.rs similarity index 100% rename from crates/ruff/src/rules/ruff/rules/helpers.rs rename to crates/ruff_linter/src/rules/ruff/rules/helpers.rs diff --git a/crates/ruff/src/rules/ruff/rules/implicit_optional.rs b/crates/ruff_linter/src/rules/ruff/rules/implicit_optional.rs similarity index 100% rename from crates/ruff/src/rules/ruff/rules/implicit_optional.rs rename to crates/ruff_linter/src/rules/ruff/rules/implicit_optional.rs diff --git a/crates/ruff/src/rules/ruff/rules/invalid_index_type.rs b/crates/ruff_linter/src/rules/ruff/rules/invalid_index_type.rs similarity index 100% rename from crates/ruff/src/rules/ruff/rules/invalid_index_type.rs rename to crates/ruff_linter/src/rules/ruff/rules/invalid_index_type.rs diff --git a/crates/ruff/src/rules/ruff/rules/invalid_pyproject_toml.rs b/crates/ruff_linter/src/rules/ruff/rules/invalid_pyproject_toml.rs similarity index 100% rename from crates/ruff/src/rules/ruff/rules/invalid_pyproject_toml.rs rename to crates/ruff_linter/src/rules/ruff/rules/invalid_pyproject_toml.rs diff --git a/crates/ruff/src/rules/ruff/rules/mod.rs b/crates/ruff_linter/src/rules/ruff/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/ruff/rules/mod.rs rename to crates/ruff_linter/src/rules/ruff/rules/mod.rs diff --git a/crates/ruff/src/rules/ruff/rules/mutable_class_default.rs b/crates/ruff_linter/src/rules/ruff/rules/mutable_class_default.rs similarity index 100% rename from crates/ruff/src/rules/ruff/rules/mutable_class_default.rs rename to crates/ruff_linter/src/rules/ruff/rules/mutable_class_default.rs diff --git a/crates/ruff/src/rules/ruff/rules/mutable_dataclass_default.rs b/crates/ruff_linter/src/rules/ruff/rules/mutable_dataclass_default.rs similarity index 100% rename from crates/ruff/src/rules/ruff/rules/mutable_dataclass_default.rs rename to crates/ruff_linter/src/rules/ruff/rules/mutable_dataclass_default.rs diff --git a/crates/ruff/src/rules/ruff/rules/pairwise_over_zipped.rs b/crates/ruff_linter/src/rules/ruff/rules/pairwise_over_zipped.rs similarity index 100% rename from crates/ruff/src/rules/ruff/rules/pairwise_over_zipped.rs rename to crates/ruff_linter/src/rules/ruff/rules/pairwise_over_zipped.rs diff --git a/crates/ruff/src/rules/ruff/rules/quadratic_list_summation.rs b/crates/ruff_linter/src/rules/ruff/rules/quadratic_list_summation.rs similarity index 100% rename from crates/ruff/src/rules/ruff/rules/quadratic_list_summation.rs rename to crates/ruff_linter/src/rules/ruff/rules/quadratic_list_summation.rs diff --git a/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__assert.py.md.snap b/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__assert.py.md.snap new file mode 100644 index 0000000000..50dcab6daa --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__assert.py.md.snap @@ -0,0 +1,97 @@ +--- +source: crates/ruff_linter/src/rules/ruff/rules/unreachable.rs +description: "This is a Mermaid graph. You can use https://mermaid.live to visualize it as a diagram." +--- +## Function 0 +### Source +```python +def func(): + assert True +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1[["Exception raised"]] + block2["assert True\n"] + + start --> block2 + block2 -- "True" --> block0 + block2 -- "else" --> block1 + block1 --> return + block0 --> return +``` + +## Function 1 +### Source +```python +def func(): + assert False +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1[["Exception raised"]] + block2["assert False\n"] + + start --> block2 + block2 -- "False" --> block0 + block2 -- "else" --> block1 + block1 --> return + block0 --> return +``` + +## Function 2 +### Source +```python +def func(): + assert True, "oops" +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1[["Exception raised"]] + block2["assert True, #quot;oops#quot;\n"] + + start --> block2 + block2 -- "True" --> block0 + block2 -- "else" --> block1 + block1 --> return + block0 --> return +``` + +## Function 3 +### Source +```python +def func(): + assert False, "oops" +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1[["Exception raised"]] + block2["assert False, #quot;oops#quot;\n"] + + start --> block2 + block2 -- "False" --> block0 + block2 -- "else" --> block1 + block1 --> return + block0 --> return +``` + + diff --git a/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__async-for.py.md.snap b/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__async-for.py.md.snap new file mode 100644 index 0000000000..2847a7d873 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__async-for.py.md.snap @@ -0,0 +1,241 @@ +--- +source: crates/ruff_linter/src/rules/ruff/rules/unreachable.rs +description: "This is a Mermaid graph. You can use https://mermaid.live to visualize it as a diagram." +--- +## Function 0 +### Source +```python +def func(): + async for i in range(5): + print(i) +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["print(i)\n"] + block2["async for i in range(5): + print(i)\n"] + + start --> block2 + block2 -- "range(5)" --> block1 + block2 -- "else" --> block0 + block1 --> block2 + block0 --> return +``` + +## Function 1 +### Source +```python +def func(): + async for i in range(20): + print(i) + else: + return 0 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["print(i)\n"] + block1["return 0\n"] + block2["async for i in range(20): + print(i) + else: + return 0\n"] + + start --> block2 + block2 -- "range(20)" --> block0 + block2 -- "else" --> block1 + block1 --> return + block0 --> return +``` + +## Function 2 +### Source +```python +def func(): + async for i in range(10): + if i == 5: + return 1 + return 0 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 0\n"] + block1["return 1\n"] + block2["if i == 5: + return 1\n"] + block3["async for i in range(10): + if i == 5: + return 1\n"] + + start --> block3 + block3 -- "range(10)" --> block2 + block3 -- "else" --> block0 + block2 -- "i == 5" --> block1 + block2 -- "else" --> block3 + block1 --> return + block0 --> return +``` + +## Function 3 +### Source +```python +def func(): + async for i in range(111): + if i == 5: + return 1 + else: + return 0 + return 2 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 2\n"] + block1["return 1\n"] + block2["if i == 5: + return 1\n"] + block3["return 0\n"] + block4["async for i in range(111): + if i == 5: + return 1 + else: + return 0\n"] + + start --> block4 + block4 -- "range(111)" --> block2 + block4 -- "else" --> block3 + block3 --> return + block2 -- "i == 5" --> block1 + block2 -- "else" --> block4 + block1 --> return + block0 --> return +``` + +## Function 4 +### Source +```python +def func(): + async for i in range(12): + continue +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["continue\n"] + block2["async for i in range(12): + continue\n"] + + start --> block2 + block2 -- "range(12)" --> block1 + block2 -- "else" --> block0 + block1 --> block2 + block0 --> return +``` + +## Function 5 +### Source +```python +def func(): + async for i in range(1110): + if True: + continue +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["continue\n"] + block2["if True: + continue\n"] + block3["async for i in range(1110): + if True: + continue\n"] + + start --> block3 + block3 -- "range(1110)" --> block2 + block3 -- "else" --> block0 + block2 -- "True" --> block1 + block2 -- "else" --> block3 + block1 --> block3 + block0 --> return +``` + +## Function 6 +### Source +```python +def func(): + async for i in range(13): + break +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["break\n"] + block2["async for i in range(13): + break\n"] + + start --> block2 + block2 -- "range(13)" --> block1 + block2 -- "else" --> block0 + block1 --> block0 + block0 --> return +``` + +## Function 7 +### Source +```python +def func(): + async for i in range(1110): + if True: + break +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["break\n"] + block2["if True: + break\n"] + block3["async for i in range(1110): + if True: + break\n"] + + start --> block3 + block3 -- "range(1110)" --> block2 + block3 -- "else" --> block0 + block2 -- "True" --> block1 + block2 -- "else" --> block3 + block1 --> block0 + block0 --> return +``` + + diff --git a/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__for.py.md.snap b/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__for.py.md.snap new file mode 100644 index 0000000000..e93710e8ed --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__for.py.md.snap @@ -0,0 +1,241 @@ +--- +source: crates/ruff_linter/src/rules/ruff/rules/unreachable.rs +description: "This is a Mermaid graph. You can use https://mermaid.live to visualize it as a diagram." +--- +## Function 0 +### Source +```python +def func(): + for i in range(5): + print(i) +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["print(i)\n"] + block2["for i in range(5): + print(i)\n"] + + start --> block2 + block2 -- "range(5)" --> block1 + block2 -- "else" --> block0 + block1 --> block2 + block0 --> return +``` + +## Function 1 +### Source +```python +def func(): + for i in range(20): + print(i) + else: + return 0 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["print(i)\n"] + block1["return 0\n"] + block2["for i in range(20): + print(i) + else: + return 0\n"] + + start --> block2 + block2 -- "range(20)" --> block0 + block2 -- "else" --> block1 + block1 --> return + block0 --> return +``` + +## Function 2 +### Source +```python +def func(): + for i in range(10): + if i == 5: + return 1 + return 0 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 0\n"] + block1["return 1\n"] + block2["if i == 5: + return 1\n"] + block3["for i in range(10): + if i == 5: + return 1\n"] + + start --> block3 + block3 -- "range(10)" --> block2 + block3 -- "else" --> block0 + block2 -- "i == 5" --> block1 + block2 -- "else" --> block3 + block1 --> return + block0 --> return +``` + +## Function 3 +### Source +```python +def func(): + for i in range(111): + if i == 5: + return 1 + else: + return 0 + return 2 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 2\n"] + block1["return 1\n"] + block2["if i == 5: + return 1\n"] + block3["return 0\n"] + block4["for i in range(111): + if i == 5: + return 1 + else: + return 0\n"] + + start --> block4 + block4 -- "range(111)" --> block2 + block4 -- "else" --> block3 + block3 --> return + block2 -- "i == 5" --> block1 + block2 -- "else" --> block4 + block1 --> return + block0 --> return +``` + +## Function 4 +### Source +```python +def func(): + for i in range(12): + continue +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["continue\n"] + block2["for i in range(12): + continue\n"] + + start --> block2 + block2 -- "range(12)" --> block1 + block2 -- "else" --> block0 + block1 --> block2 + block0 --> return +``` + +## Function 5 +### Source +```python +def func(): + for i in range(1110): + if True: + continue +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["continue\n"] + block2["if True: + continue\n"] + block3["for i in range(1110): + if True: + continue\n"] + + start --> block3 + block3 -- "range(1110)" --> block2 + block3 -- "else" --> block0 + block2 -- "True" --> block1 + block2 -- "else" --> block3 + block1 --> block3 + block0 --> return +``` + +## Function 6 +### Source +```python +def func(): + for i in range(13): + break +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["break\n"] + block2["for i in range(13): + break\n"] + + start --> block2 + block2 -- "range(13)" --> block1 + block2 -- "else" --> block0 + block1 --> block0 + block0 --> return +``` + +## Function 7 +### Source +```python +def func(): + for i in range(1110): + if True: + break +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["break\n"] + block2["if True: + break\n"] + block3["for i in range(1110): + if True: + break\n"] + + start --> block3 + block3 -- "range(1110)" --> block2 + block3 -- "else" --> block0 + block2 -- "True" --> block1 + block2 -- "else" --> block3 + block1 --> block0 + block0 --> return +``` + + diff --git a/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__if.py.md.snap b/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__if.py.md.snap new file mode 100644 index 0000000000..6899a85774 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__if.py.md.snap @@ -0,0 +1,553 @@ +--- +source: crates/ruff_linter/src/rules/ruff/rules/unreachable.rs +description: "This is a Mermaid graph. You can use https://mermaid.live to visualize it as a diagram." +--- +## Function 0 +### Source +```python +def func(): + if False: + return 0 + return 1 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 1\n"] + block1["return 0\n"] + block2["if False: + return 0\n"] + + start --> block2 + block2 -- "False" --> block1 + block2 -- "else" --> block0 + block1 --> return + block0 --> return +``` + +## Function 1 +### Source +```python +def func(): + if True: + return 1 + return 0 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 0\n"] + block1["return 1\n"] + block2["if True: + return 1\n"] + + start --> block2 + block2 -- "True" --> block1 + block2 -- "else" --> block0 + block1 --> return + block0 --> return +``` + +## Function 2 +### Source +```python +def func(): + if False: + return 0 + else: + return 1 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 0\n"] + block1["return 1\n"] + block2["if False: + return 0 + else: + return 1\n"] + + start --> block2 + block2 -- "False" --> block0 + block2 -- "else" --> block1 + block1 --> return + block0 --> return +``` + +## Function 3 +### Source +```python +def func(): + if True: + return 1 + else: + return 0 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 1\n"] + block1["return 0\n"] + block2["if True: + return 1 + else: + return 0\n"] + + start --> block2 + block2 -- "True" --> block0 + block2 -- "else" --> block1 + block1 --> return + block0 --> return +``` + +## Function 4 +### Source +```python +def func(): + if False: + return 0 + else: + return 1 + return "unreachable" +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return #quot;unreachable#quot;\n"] + block1["return 0\n"] + block2["return 1\n"] + block3["if False: + return 0 + else: + return 1\n"] + + start --> block3 + block3 -- "False" --> block1 + block3 -- "else" --> block2 + block2 --> return + block1 --> return + block0 --> return +``` + +## Function 5 +### Source +```python +def func(): + if True: + return 1 + else: + return 0 + return "unreachable" +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return #quot;unreachable#quot;\n"] + block1["return 1\n"] + block2["return 0\n"] + block3["if True: + return 1 + else: + return 0\n"] + + start --> block3 + block3 -- "True" --> block1 + block3 -- "else" --> block2 + block2 --> return + block1 --> return + block0 --> return +``` + +## Function 6 +### Source +```python +def func(): + if True: + if True: + return 1 + return 2 + else: + return 3 + return "unreachable2" +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return #quot;unreachable2#quot;\n"] + block1["return 2\n"] + block2["return 1\n"] + block3["if True: + return 1\n"] + block4["return 3\n"] + block5["if True: + if True: + return 1 + return 2 + else: + return 3\n"] + + start --> block5 + block5 -- "True" --> block3 + block5 -- "else" --> block4 + block4 --> return + block3 -- "True" --> block2 + block3 -- "else" --> block1 + block2 --> return + block1 --> return + block0 --> return +``` + +## Function 7 +### Source +```python +def func(): + if False: + return 0 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["return 0\n"] + block2["if False: + return 0\n"] + + start --> block2 + block2 -- "False" --> block1 + block2 -- "else" --> block0 + block1 --> return + block0 --> return +``` + +## Function 8 +### Source +```python +def func(): + if True: + return 1 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["return 1\n"] + block2["if True: + return 1\n"] + + start --> block2 + block2 -- "True" --> block1 + block2 -- "else" --> block0 + block1 --> return + block0 --> return +``` + +## Function 9 +### Source +```python +def func(): + if True: + return 1 + elif False: + return 2 + else: + return 0 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 1\n"] + block1["return 0\n"] + block2["return 2\n"] + block3["if True: + return 1 + elif False: + return 2 + else: + return 0\n"] + block4["if True: + return 1 + elif False: + return 2 + else: + return 0\n"] + + start --> block4 + block4 -- "True" --> block0 + block4 -- "else" --> block3 + block3 -- "False" --> block2 + block3 -- "else" --> block1 + block2 --> return + block1 --> return + block0 --> return +``` + +## Function 10 +### Source +```python +def func(): + if False: + return 1 + elif True: + return 2 + else: + return 0 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 1\n"] + block1["return 0\n"] + block2["return 2\n"] + block3["if False: + return 1 + elif True: + return 2 + else: + return 0\n"] + block4["if False: + return 1 + elif True: + return 2 + else: + return 0\n"] + + start --> block4 + block4 -- "False" --> block0 + block4 -- "else" --> block3 + block3 -- "True" --> block2 + block3 -- "else" --> block1 + block2 --> return + block1 --> return + block0 --> return +``` + +## Function 11 +### Source +```python +def func(): + if True: + if False: + return 0 + elif True: + return 1 + else: + return 2 + return 3 + elif True: + return 4 + else: + return 5 + return 6 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 6\n"] + block1["return 3\n"] + block2["return 0\n"] + block3["return 2\n"] + block4["return 1\n"] + block5["if False: + return 0 + elif True: + return 1 + else: + return 2\n"] + block6["if False: + return 0 + elif True: + return 1 + else: + return 2\n"] + block7["return 5\n"] + block8["return 4\n"] + block9["if True: + if False: + return 0 + elif True: + return 1 + else: + return 2 + return 3 + elif True: + return 4 + else: + return 5\n"] + block10["if True: + if False: + return 0 + elif True: + return 1 + else: + return 2 + return 3 + elif True: + return 4 + else: + return 5\n"] + + start --> block10 + block10 -- "True" --> block6 + block10 -- "else" --> block9 + block9 -- "True" --> block8 + block9 -- "else" --> block7 + block8 --> return + block7 --> return + block6 -- "False" --> block2 + block6 -- "else" --> block5 + block5 -- "True" --> block4 + block5 -- "else" --> block3 + block4 --> return + block3 --> return + block2 --> return + block1 --> return + block0 --> return +``` + +## Function 12 +### Source +```python +def func(): + if False: + return "unreached" + elif False: + return "also unreached" + return "reached" +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return #quot;reached#quot;\n"] + block1["return #quot;unreached#quot;\n"] + block2["return #quot;also unreached#quot;\n"] + block3["if False: + return #quot;unreached#quot; + elif False: + return #quot;also unreached#quot;\n"] + block4["if False: + return #quot;unreached#quot; + elif False: + return #quot;also unreached#quot;\n"] + + start --> block4 + block4 -- "False" --> block1 + block4 -- "else" --> block3 + block3 -- "False" --> block2 + block3 -- "else" --> block0 + block2 --> return + block1 --> return + block0 --> return +``` + +## Function 13 +### Source +```python +def func(self, obj: BytesRep) -> bytes: + data = obj["data"] + + if isinstance(data, str): + return base64.b64decode(data) + elif isinstance(data, Buffer): + buffer = data + else: + id = data["id"] + + if id in self._buffers: + buffer = self._buffers[id] + else: + self.error(f"can't resolve buffer '{id}'") + + return buffer.data +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return buffer.data\n"] + block1["return base64.b64decode(data)\n"] + block2["buffer = self._buffers[id]\n"] + block3["self.error(f#quot;can't resolve buffer '{id}'#quot;)\n"] + block4["id = data[#quot;id#quot;]\nif id in self._buffers: + buffer = self._buffers[id] + else: + self.error(f#quot;can't resolve buffer '{id}'#quot;)\n"] + block5["buffer = data\n"] + block6["if isinstance(data, str): + return base64.b64decode(data) + elif isinstance(data, Buffer): + buffer = data + else: + id = data[#quot;id#quot;] + + if id in self._buffers: + buffer = self._buffers[id] + else: + self.error(f#quot;can't resolve buffer '{id}'#quot;)\n"] + block7["data = obj[#quot;data#quot;]\nif isinstance(data, str): + return base64.b64decode(data) + elif isinstance(data, Buffer): + buffer = data + else: + id = data[#quot;id#quot;] + + if id in self._buffers: + buffer = self._buffers[id] + else: + self.error(f#quot;can't resolve buffer '{id}'#quot;)\n"] + + start --> block7 + block7 -- "isinstance(data, str)" --> block1 + block7 -- "else" --> block6 + block6 -- "isinstance(data, Buffer)" --> block5 + block6 -- "else" --> block4 + block5 --> block0 + block4 -- "id in self._buffers" --> block2 + block4 -- "else" --> block3 + block3 --> block0 + block2 --> block0 + block1 --> return + block0 --> return +``` + + diff --git a/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__match.py.md.snap b/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__match.py.md.snap new file mode 100644 index 0000000000..54cb336e95 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__match.py.md.snap @@ -0,0 +1,776 @@ +--- +source: crates/ruff_linter/src/rules/ruff/rules/unreachable.rs +description: "This is a Mermaid graph. You can use https://mermaid.live to visualize it as a diagram." +--- +## Function 0 +### Source +```python +def func(status): + match status: + case _: + return 0 + return "unreachable" +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return #quot;unreachable#quot;\n"] + block1["return 0\n"] + block2["match status: + case _: + return 0\n"] + + start --> block2 + block2 --> block1 + block1 --> return + block0 --> return +``` + +## Function 1 +### Source +```python +def func(status): + match status: + case 1: + return 1 + return 0 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 0\n"] + block1["return 1\n"] + block2["match status: + case 1: + return 1\n"] + + start --> block2 + block2 -- "case 1" --> block1 + block2 -- "else" --> block0 + block1 --> return + block0 --> return +``` + +## Function 2 +### Source +```python +def func(status): + match status: + case 1: + return 1 + case _: + return 0 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 0\n"] + block1["match status: + case 1: + return 1 + case _: + return 0\n"] + block2["return 1\n"] + block3["match status: + case 1: + return 1 + case _: + return 0\n"] + + start --> block3 + block3 -- "case 1" --> block2 + block3 -- "else" --> block1 + block2 --> return + block1 --> block0 + block0 --> return +``` + +## Function 3 +### Source +```python +def func(status): + match status: + case 1 | 2 | 3: + return 5 + return 6 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 6\n"] + block1["return 5\n"] + block2["match status: + case 1 | 2 | 3: + return 5\n"] + + start --> block2 + block2 -- "case 1 | 2 | 3" --> block1 + block2 -- "else" --> block0 + block1 --> return + block0 --> return +``` + +## Function 4 +### Source +```python +def func(status): + match status: + case 1 | 2 | 3: + return 5 + case _: + return 10 + return 0 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 0\n"] + block1["return 10\n"] + block2["match status: + case 1 | 2 | 3: + return 5 + case _: + return 10\n"] + block3["return 5\n"] + block4["match status: + case 1 | 2 | 3: + return 5 + case _: + return 10\n"] + + start --> block4 + block4 -- "case 1 | 2 | 3" --> block3 + block4 -- "else" --> block2 + block3 --> return + block2 --> block1 + block1 --> return + block0 --> return +``` + +## Function 5 +### Source +```python +def func(status): + match status: + case 0: + return 0 + case 1: + return 1 + case 1: + return "1 again" + case _: + return 3 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 3\n"] + block1["match status: + case 0: + return 0 + case 1: + return 1 + case 1: + return #quot;1 again#quot; + case _: + return 3\n"] + block2["return #quot;1 again#quot;\n"] + block3["match status: + case 0: + return 0 + case 1: + return 1 + case 1: + return #quot;1 again#quot; + case _: + return 3\n"] + block4["return 1\n"] + block5["match status: + case 0: + return 0 + case 1: + return 1 + case 1: + return #quot;1 again#quot; + case _: + return 3\n"] + block6["return 0\n"] + block7["match status: + case 0: + return 0 + case 1: + return 1 + case 1: + return #quot;1 again#quot; + case _: + return 3\n"] + + start --> block7 + block7 -- "case 0" --> block6 + block7 -- "else" --> block5 + block6 --> return + block5 -- "case 1" --> block4 + block5 -- "else" --> block3 + block4 --> return + block3 -- "case 1" --> block2 + block3 -- "else" --> block1 + block2 --> return + block1 --> block0 + block0 --> return +``` + +## Function 6 +### Source +```python +def func(status): + i = 0 + match status, i: + case _, _: + return 0 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["return 0\n"] + block2["match status, i: + case _, _: + return 0\n"] + block3["i = 0\n"] + + start --> block3 + block3 --> block2 + block2 -- "case _, _" --> block1 + block2 -- "else" --> block0 + block1 --> return + block0 --> return +``` + +## Function 7 +### Source +```python +def func(status): + i = 0 + match status, i: + case _, 0: + return 0 + case _, 2: + return 0 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["return 0\n"] + block2["match status, i: + case _, 0: + return 0 + case _, 2: + return 0\n"] + block3["return 0\n"] + block4["match status, i: + case _, 0: + return 0 + case _, 2: + return 0\n"] + block5["i = 0\n"] + + start --> block5 + block5 --> block4 + block4 -- "case _, 0" --> block3 + block4 -- "else" --> block2 + block3 --> return + block2 -- "case _, 2" --> block1 + block2 -- "else" --> block0 + block1 --> return + block0 --> return +``` + +## Function 8 +### Source +```python +def func(point): + match point: + case (0, 0): + print("Origin") + case _: + raise ValueError("oops") +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["raise ValueError(#quot;oops#quot;)\n"] + block2["match point: + case (0, 0): + print(#quot;Origin#quot;) + case _: + raise ValueError(#quot;oops#quot;)\n"] + block3["print(#quot;Origin#quot;)\n"] + block4["match point: + case (0, 0): + print(#quot;Origin#quot;) + case _: + raise ValueError(#quot;oops#quot;)\n"] + + start --> block4 + block4 -- "case (0, 0)" --> block3 + block4 -- "else" --> block2 + block3 --> block0 + block2 --> block1 + block1 --> return + block0 --> return +``` + +## Function 9 +### Source +```python +def func(point): + match point: + case (0, 0): + print("Origin") + case (0, y): + print(f"Y={y}") + case (x, 0): + print(f"X={x}") + case (x, y): + print(f"X={x}, Y={y}") + case _: + raise ValueError("Not a point") +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["raise ValueError(#quot;Not a point#quot;)\n"] + block2["match point: + case (0, 0): + print(#quot;Origin#quot;) + case (0, y): + print(f#quot;Y={y}#quot;) + case (x, 0): + print(f#quot;X={x}#quot;) + case (x, y): + print(f#quot;X={x}, Y={y}#quot;) + case _: + raise ValueError(#quot;Not a point#quot;)\n"] + block3["print(f#quot;X={x}, Y={y}#quot;)\n"] + block4["match point: + case (0, 0): + print(#quot;Origin#quot;) + case (0, y): + print(f#quot;Y={y}#quot;) + case (x, 0): + print(f#quot;X={x}#quot;) + case (x, y): + print(f#quot;X={x}, Y={y}#quot;) + case _: + raise ValueError(#quot;Not a point#quot;)\n"] + block5["print(f#quot;X={x}#quot;)\n"] + block6["match point: + case (0, 0): + print(#quot;Origin#quot;) + case (0, y): + print(f#quot;Y={y}#quot;) + case (x, 0): + print(f#quot;X={x}#quot;) + case (x, y): + print(f#quot;X={x}, Y={y}#quot;) + case _: + raise ValueError(#quot;Not a point#quot;)\n"] + block7["print(f#quot;Y={y}#quot;)\n"] + block8["match point: + case (0, 0): + print(#quot;Origin#quot;) + case (0, y): + print(f#quot;Y={y}#quot;) + case (x, 0): + print(f#quot;X={x}#quot;) + case (x, y): + print(f#quot;X={x}, Y={y}#quot;) + case _: + raise ValueError(#quot;Not a point#quot;)\n"] + block9["print(#quot;Origin#quot;)\n"] + block10["match point: + case (0, 0): + print(#quot;Origin#quot;) + case (0, y): + print(f#quot;Y={y}#quot;) + case (x, 0): + print(f#quot;X={x}#quot;) + case (x, y): + print(f#quot;X={x}, Y={y}#quot;) + case _: + raise ValueError(#quot;Not a point#quot;)\n"] + + start --> block10 + block10 -- "case (0, 0)" --> block9 + block10 -- "else" --> block8 + block9 --> block0 + block8 -- "case (0, y)" --> block7 + block8 -- "else" --> block6 + block7 --> block0 + block6 -- "case (x, 0)" --> block5 + block6 -- "else" --> block4 + block5 --> block0 + block4 -- "case (x, y)" --> block3 + block4 -- "else" --> block2 + block3 --> block0 + block2 --> block1 + block1 --> return + block0 --> return +``` + +## Function 10 +### Source +```python +def where_is(point): + class Point: + x: int + y: int + + match point: + case Point(x=0, y=0): + print("Origin") + case Point(x=0, y=y): + print(f"Y={y}") + case Point(x=x, y=0): + print(f"X={x}") + case Point(): + print("Somewhere else") + case _: + print("Not a point") +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["print(#quot;Not a point#quot;)\n"] + block2["match point: + case Point(x=0, y=0): + print(#quot;Origin#quot;) + case Point(x=0, y=y): + print(f#quot;Y={y}#quot;) + case Point(x=x, y=0): + print(f#quot;X={x}#quot;) + case Point(): + print(#quot;Somewhere else#quot;) + case _: + print(#quot;Not a point#quot;)\n"] + block3["print(#quot;Somewhere else#quot;)\n"] + block4["match point: + case Point(x=0, y=0): + print(#quot;Origin#quot;) + case Point(x=0, y=y): + print(f#quot;Y={y}#quot;) + case Point(x=x, y=0): + print(f#quot;X={x}#quot;) + case Point(): + print(#quot;Somewhere else#quot;) + case _: + print(#quot;Not a point#quot;)\n"] + block5["print(f#quot;X={x}#quot;)\n"] + block6["match point: + case Point(x=0, y=0): + print(#quot;Origin#quot;) + case Point(x=0, y=y): + print(f#quot;Y={y}#quot;) + case Point(x=x, y=0): + print(f#quot;X={x}#quot;) + case Point(): + print(#quot;Somewhere else#quot;) + case _: + print(#quot;Not a point#quot;)\n"] + block7["print(f#quot;Y={y}#quot;)\n"] + block8["match point: + case Point(x=0, y=0): + print(#quot;Origin#quot;) + case Point(x=0, y=y): + print(f#quot;Y={y}#quot;) + case Point(x=x, y=0): + print(f#quot;X={x}#quot;) + case Point(): + print(#quot;Somewhere else#quot;) + case _: + print(#quot;Not a point#quot;)\n"] + block9["print(#quot;Origin#quot;)\n"] + block10["match point: + case Point(x=0, y=0): + print(#quot;Origin#quot;) + case Point(x=0, y=y): + print(f#quot;Y={y}#quot;) + case Point(x=x, y=0): + print(f#quot;X={x}#quot;) + case Point(): + print(#quot;Somewhere else#quot;) + case _: + print(#quot;Not a point#quot;)\n"] + block11["class Point: + x: int + y: int\n"] + + start --> block11 + block11 --> block10 + block10 -- "case Point(x=0, y=0)" --> block9 + block10 -- "else" --> block8 + block9 --> block0 + block8 -- "case Point(x=0, y=y)" --> block7 + block8 -- "else" --> block6 + block7 --> block0 + block6 -- "case Point(x=x, y=0)" --> block5 + block6 -- "else" --> block4 + block5 --> block0 + block4 -- "case Point()" --> block3 + block4 -- "else" --> block2 + block3 --> block0 + block2 --> block1 + block1 --> block0 + block0 --> return +``` + +## Function 11 +### Source +```python +def func(points): + match points: + case []: + print("No points") + case [Point(0, 0)]: + print("The origin") + case [Point(x, y)]: + print(f"Single point {x}, {y}") + case [Point(0, y1), Point(0, y2)]: + print(f"Two on the Y axis at {y1}, {y2}") + case _: + print("Something else") +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["print(#quot;Something else#quot;)\n"] + block2["match points: + case []: + print(#quot;No points#quot;) + case [Point(0, 0)]: + print(#quot;The origin#quot;) + case [Point(x, y)]: + print(f#quot;Single point {x}, {y}#quot;) + case [Point(0, y1), Point(0, y2)]: + print(f#quot;Two on the Y axis at {y1}, {y2}#quot;) + case _: + print(#quot;Something else#quot;)\n"] + block3["print(f#quot;Two on the Y axis at {y1}, {y2}#quot;)\n"] + block4["match points: + case []: + print(#quot;No points#quot;) + case [Point(0, 0)]: + print(#quot;The origin#quot;) + case [Point(x, y)]: + print(f#quot;Single point {x}, {y}#quot;) + case [Point(0, y1), Point(0, y2)]: + print(f#quot;Two on the Y axis at {y1}, {y2}#quot;) + case _: + print(#quot;Something else#quot;)\n"] + block5["print(f#quot;Single point {x}, {y}#quot;)\n"] + block6["match points: + case []: + print(#quot;No points#quot;) + case [Point(0, 0)]: + print(#quot;The origin#quot;) + case [Point(x, y)]: + print(f#quot;Single point {x}, {y}#quot;) + case [Point(0, y1), Point(0, y2)]: + print(f#quot;Two on the Y axis at {y1}, {y2}#quot;) + case _: + print(#quot;Something else#quot;)\n"] + block7["print(#quot;The origin#quot;)\n"] + block8["match points: + case []: + print(#quot;No points#quot;) + case [Point(0, 0)]: + print(#quot;The origin#quot;) + case [Point(x, y)]: + print(f#quot;Single point {x}, {y}#quot;) + case [Point(0, y1), Point(0, y2)]: + print(f#quot;Two on the Y axis at {y1}, {y2}#quot;) + case _: + print(#quot;Something else#quot;)\n"] + block9["print(#quot;No points#quot;)\n"] + block10["match points: + case []: + print(#quot;No points#quot;) + case [Point(0, 0)]: + print(#quot;The origin#quot;) + case [Point(x, y)]: + print(f#quot;Single point {x}, {y}#quot;) + case [Point(0, y1), Point(0, y2)]: + print(f#quot;Two on the Y axis at {y1}, {y2}#quot;) + case _: + print(#quot;Something else#quot;)\n"] + + start --> block10 + block10 -- "case []" --> block9 + block10 -- "else" --> block8 + block9 --> block0 + block8 -- "case [Point(0, 0)]" --> block7 + block8 -- "else" --> block6 + block7 --> block0 + block6 -- "case [Point(x, y)]" --> block5 + block6 -- "else" --> block4 + block5 --> block0 + block4 -- "case [Point(0, y1), Point(0, y2)]" --> block3 + block4 -- "else" --> block2 + block3 --> block0 + block2 --> block1 + block1 --> block0 + block0 --> return +``` + +## Function 12 +### Source +```python +def func(point): + match point: + case Point(x, y) if x == y: + print(f"Y=X at {x}") + case Point(x, y): + print(f"Not on the diagonal") +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["print(f#quot;Not on the diagonal#quot;)\n"] + block2["match point: + case Point(x, y) if x == y: + print(f#quot;Y=X at {x}#quot;) + case Point(x, y): + print(f#quot;Not on the diagonal#quot;)\n"] + block3["print(f#quot;Y=X at {x}#quot;)\n"] + block4["match point: + case Point(x, y) if x == y: + print(f#quot;Y=X at {x}#quot;) + case Point(x, y): + print(f#quot;Not on the diagonal#quot;)\n"] + + start --> block4 + block4 -- "case Point(x, y) if x == y" --> block3 + block4 -- "else" --> block2 + block3 --> block0 + block2 -- "case Point(x, y)" --> block1 + block2 -- "else" --> block0 + block1 --> block0 + block0 --> return +``` + +## Function 13 +### Source +```python +def func(): + from enum import Enum + class Color(Enum): + RED = 'red' + GREEN = 'green' + BLUE = 'blue' + + color = Color(input("Enter your choice of 'red', 'blue' or 'green': ")) + + match color: + case Color.RED: + print("I see red!") + case Color.GREEN: + print("Grass is green") + case Color.BLUE: + print("I'm feeling the blues :(") +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["print(#quot;I'm feeling the blues :(#quot;)\n"] + block2["match color: + case Color.RED: + print(#quot;I see red!#quot;) + case Color.GREEN: + print(#quot;Grass is green#quot;) + case Color.BLUE: + print(#quot;I'm feeling the blues :(#quot;)\n"] + block3["print(#quot;Grass is green#quot;)\n"] + block4["match color: + case Color.RED: + print(#quot;I see red!#quot;) + case Color.GREEN: + print(#quot;Grass is green#quot;) + case Color.BLUE: + print(#quot;I'm feeling the blues :(#quot;)\n"] + block5["print(#quot;I see red!#quot;)\n"] + block6["match color: + case Color.RED: + print(#quot;I see red!#quot;) + case Color.GREEN: + print(#quot;Grass is green#quot;) + case Color.BLUE: + print(#quot;I'm feeling the blues :(#quot;)\n"] + block7["from enum import Enum\nclass Color(Enum): + RED = 'red' + GREEN = 'green' + BLUE = 'blue'\ncolor = Color(input(#quot;Enter your choice of 'red', 'blue' or 'green': #quot;))\n"] + + start --> block7 + block7 --> block6 + block6 -- "case Color.RED" --> block5 + block6 -- "else" --> block4 + block5 --> block0 + block4 -- "case Color.GREEN" --> block3 + block4 -- "else" --> block2 + block3 --> block0 + block2 -- "case Color.BLUE" --> block1 + block2 -- "else" --> block0 + block1 --> block0 + block0 --> return +``` + + diff --git a/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__raise.py.md.snap b/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__raise.py.md.snap new file mode 100644 index 0000000000..d0265fa698 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__raise.py.md.snap @@ -0,0 +1,41 @@ +--- +source: crates/ruff_linter/src/rules/ruff/rules/unreachable.rs +description: "This is a Mermaid graph. You can use https://mermaid.live to visualize it as a diagram." +--- +## Function 0 +### Source +```python +def func(): + raise Exception +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["raise Exception\n"] + + start --> block0 + block0 --> return +``` + +## Function 1 +### Source +```python +def func(): + raise "a glass!" +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["raise #quot;a glass!#quot;\n"] + + start --> block0 + block0 --> return +``` + + diff --git a/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__simple.py.md.snap b/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__simple.py.md.snap new file mode 100644 index 0000000000..015cf43dcc --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__simple.py.md.snap @@ -0,0 +1,136 @@ +--- +source: crates/ruff_linter/src/rules/ruff/rules/unreachable.rs +description: "This is a Mermaid graph. You can use https://mermaid.live to visualize it as a diagram." +--- +## Function 0 +### Source +```python +def func(): + pass +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["pass\n"] + + start --> block0 + block0 --> return +``` + +## Function 1 +### Source +```python +def func(): + pass +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["pass\n"] + + start --> block0 + block0 --> return +``` + +## Function 2 +### Source +```python +def func(): + return +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return\n"] + + start --> block0 + block0 --> return +``` + +## Function 3 +### Source +```python +def func(): + return 1 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 1\n"] + + start --> block0 + block0 --> return +``` + +## Function 4 +### Source +```python +def func(): + return 1 + return "unreachable" +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return #quot;unreachable#quot;\n"] + block1["return 1\n"] + + start --> block1 + block1 --> return + block0 --> return +``` + +## Function 5 +### Source +```python +def func(): + i = 0 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["i = 0\n"] + + start --> block0 + block0 --> return +``` + +## Function 6 +### Source +```python +def func(): + i = 0 + i += 2 + return i +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["i = 0\ni += 2\nreturn i\n"] + + start --> block0 + block0 --> return +``` + + diff --git a/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__while.py.md.snap b/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__while.py.md.snap new file mode 100644 index 0000000000..3491d2b7e2 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/rules/snapshots/ruff_linter__rules__ruff__rules__unreachable__tests__while.py.md.snap @@ -0,0 +1,527 @@ +--- +source: crates/ruff_linter/src/rules/ruff/rules/unreachable.rs +description: "This is a Mermaid graph. You can use https://mermaid.live to visualize it as a diagram." +--- +## Function 0 +### Source +```python +def func(): + while False: + return "unreachable" + return 1 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 1\n"] + block1["return #quot;unreachable#quot;\n"] + block2["while False: + return #quot;unreachable#quot;\n"] + + start --> block2 + block2 -- "False" --> block1 + block2 -- "else" --> block0 + block1 --> return + block0 --> return +``` + +## Function 1 +### Source +```python +def func(): + while False: + return "unreachable" + else: + return 1 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return #quot;unreachable#quot;\n"] + block1["return 1\n"] + block2["while False: + return #quot;unreachable#quot; + else: + return 1\n"] + + start --> block2 + block2 -- "False" --> block0 + block2 -- "else" --> block1 + block1 --> return + block0 --> return +``` + +## Function 2 +### Source +```python +def func(): + while False: + return "unreachable" + else: + return 1 + return "also unreachable" +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return #quot;also unreachable#quot;\n"] + block1["return #quot;unreachable#quot;\n"] + block2["return 1\n"] + block3["while False: + return #quot;unreachable#quot; + else: + return 1\n"] + + start --> block3 + block3 -- "False" --> block1 + block3 -- "else" --> block2 + block2 --> return + block1 --> return + block0 --> return +``` + +## Function 3 +### Source +```python +def func(): + while True: + return 1 + return "unreachable" +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return #quot;unreachable#quot;\n"] + block1["return 1\n"] + block2["while True: + return 1\n"] + + start --> block2 + block2 -- "True" --> block1 + block2 -- "else" --> block0 + block1 --> return + block0 --> return +``` + +## Function 4 +### Source +```python +def func(): + while True: + return 1 + else: + return "unreachable" +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 1\n"] + block1["return #quot;unreachable#quot;\n"] + block2["while True: + return 1 + else: + return #quot;unreachable#quot;\n"] + + start --> block2 + block2 -- "True" --> block0 + block2 -- "else" --> block1 + block1 --> return + block0 --> return +``` + +## Function 5 +### Source +```python +def func(): + while True: + return 1 + else: + return "unreachable" + return "also unreachable" +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return #quot;also unreachable#quot;\n"] + block1["return 1\n"] + block2["return #quot;unreachable#quot;\n"] + block3["while True: + return 1 + else: + return #quot;unreachable#quot;\n"] + + start --> block3 + block3 -- "True" --> block1 + block3 -- "else" --> block2 + block2 --> return + block1 --> return + block0 --> return +``` + +## Function 6 +### Source +```python +def func(): + i = 0 + while False: + i += 1 + return i +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return i\n"] + block1["i += 1\n"] + block2["i = 0\nwhile False: + i += 1\n"] + + start --> block2 + block2 -- "False" --> block1 + block2 -- "else" --> block0 + block1 --> block2 + block0 --> return +``` + +## Function 7 +### Source +```python +def func(): + i = 0 + while True: + i += 1 + return i +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return i\n"] + block1["i += 1\n"] + block2["i = 0\nwhile True: + i += 1\n"] + + start --> block2 + block2 -- "True" --> block1 + block2 -- "else" --> block0 + block1 --> block2 + block0 --> return +``` + +## Function 8 +### Source +```python +def func(): + while True: + pass + return 1 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 1\n"] + block1["pass\n"] + block2["while True: + pass\n"] + + start --> block2 + block2 -- "True" --> block1 + block2 -- "else" --> block0 + block1 --> block2 + block0 --> return +``` + +## Function 9 +### Source +```python +def func(): + i = 0 + while True: + if True: + print("ok") + i += 1 + return i +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return i\n"] + block1["i += 1\n"] + block2["print(#quot;ok#quot;)\n"] + block3["if True: + print(#quot;ok#quot;)\n"] + block4["i = 0\nwhile True: + if True: + print(#quot;ok#quot;) + i += 1\n"] + + start --> block4 + block4 -- "True" --> block3 + block4 -- "else" --> block0 + block3 -- "True" --> block2 + block3 -- "else" --> block1 + block2 --> block1 + block1 --> block4 + block0 --> return +``` + +## Function 10 +### Source +```python +def func(): + i = 0 + while True: + if False: + print("ok") + i += 1 + return i +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return i\n"] + block1["i += 1\n"] + block2["print(#quot;ok#quot;)\n"] + block3["if False: + print(#quot;ok#quot;)\n"] + block4["i = 0\nwhile True: + if False: + print(#quot;ok#quot;) + i += 1\n"] + + start --> block4 + block4 -- "True" --> block3 + block4 -- "else" --> block0 + block3 -- "False" --> block2 + block3 -- "else" --> block1 + block2 --> block1 + block1 --> block4 + block0 --> return +``` + +## Function 11 +### Source +```python +def func(): + while True: + if True: + return 1 + return 0 +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0["return 0\n"] + block1["return 1\n"] + block2["if True: + return 1\n"] + block3["while True: + if True: + return 1\n"] + + start --> block3 + block3 -- "True" --> block2 + block3 -- "else" --> block0 + block2 -- "True" --> block1 + block2 -- "else" --> block3 + block1 --> return + block0 --> return +``` + +## Function 12 +### Source +```python +def func(): + while True: + continue +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["continue\n"] + block2["while True: + continue\n"] + + start --> block2 + block2 -- "True" --> block1 + block2 -- "else" --> block0 + block1 --> block2 + block0 --> return +``` + +## Function 13 +### Source +```python +def func(): + while False: + continue +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["continue\n"] + block2["while False: + continue\n"] + + start --> block2 + block2 -- "False" --> block1 + block2 -- "else" --> block0 + block1 --> block2 + block0 --> return +``` + +## Function 14 +### Source +```python +def func(): + while True: + break +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["break\n"] + block2["while True: + break\n"] + + start --> block2 + block2 -- "True" --> block1 + block2 -- "else" --> block0 + block1 --> block0 + block0 --> return +``` + +## Function 15 +### Source +```python +def func(): + while False: + break +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["break\n"] + block2["while False: + break\n"] + + start --> block2 + block2 -- "False" --> block1 + block2 -- "else" --> block0 + block1 --> block0 + block0 --> return +``` + +## Function 16 +### Source +```python +def func(): + while True: + if True: + continue +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["continue\n"] + block2["if True: + continue\n"] + block3["while True: + if True: + continue\n"] + + start --> block3 + block3 -- "True" --> block2 + block3 -- "else" --> block0 + block2 -- "True" --> block1 + block2 -- "else" --> block3 + block1 --> block3 + block0 --> return +``` + +## Function 17 +### Source +```python +def func(): + while True: + if True: + break +``` + +### Control Flow Graph +```mermaid +flowchart TD + start(("Start")) + return(("End")) + block0[["`*(empty)*`"]] + block1["break\n"] + block2["if True: + break\n"] + block3["while True: + if True: + break\n"] + + start --> block3 + block3 -- "True" --> block2 + block3 -- "else" --> block0 + block2 -- "True" --> block1 + block2 -- "else" --> block3 + block1 --> block0 + block0 --> return +``` + + diff --git a/crates/ruff/src/rules/ruff/rules/static_key_dict_comprehension.rs b/crates/ruff_linter/src/rules/ruff/rules/static_key_dict_comprehension.rs similarity index 100% rename from crates/ruff/src/rules/ruff/rules/static_key_dict_comprehension.rs rename to crates/ruff_linter/src/rules/ruff/rules/static_key_dict_comprehension.rs diff --git a/crates/ruff/src/rules/ruff/rules/unnecessary_iterable_allocation_for_first_element.rs b/crates/ruff_linter/src/rules/ruff/rules/unnecessary_iterable_allocation_for_first_element.rs similarity index 100% rename from crates/ruff/src/rules/ruff/rules/unnecessary_iterable_allocation_for_first_element.rs rename to crates/ruff_linter/src/rules/ruff/rules/unnecessary_iterable_allocation_for_first_element.rs diff --git a/crates/ruff/src/rules/ruff/rules/unreachable.rs b/crates/ruff_linter/src/rules/ruff/rules/unreachable.rs similarity index 100% rename from crates/ruff/src/rules/ruff/rules/unreachable.rs rename to crates/ruff_linter/src/rules/ruff/rules/unreachable.rs diff --git a/crates/ruff/src/rules/ruff/rules/unused_noqa.rs b/crates/ruff_linter/src/rules/ruff/rules/unused_noqa.rs similarity index 100% rename from crates/ruff/src/rules/ruff/rules/unused_noqa.rs rename to crates/ruff_linter/src/rules/ruff/rules/unused_noqa.rs diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_0.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_0.py.snap new file mode 100644 index 0000000000..f472f1f9f2 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_0.py.snap @@ -0,0 +1,416 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF013_0.py:21:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +21 | def f(arg: int = None): # RUF013 + | ^^^ RUF013 +22 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +18 18 | pass +19 19 | +20 20 | +21 |-def f(arg: int = None): # RUF013 + 21 |+def f(arg: Optional[int] = None): # RUF013 +22 22 | pass +23 23 | +24 24 | + +RUF013_0.py:25:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +25 | def f(arg: str = None): # RUF013 + | ^^^ RUF013 +26 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +22 22 | pass +23 23 | +24 24 | +25 |-def f(arg: str = None): # RUF013 + 25 |+def f(arg: Optional[str] = None): # RUF013 +26 26 | pass +27 27 | +28 28 | + +RUF013_0.py:29:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +29 | def f(arg: typing.List[str] = None): # RUF013 + | ^^^^^^^^^^^^^^^^ RUF013 +30 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +26 26 | pass +27 27 | +28 28 | +29 |-def f(arg: typing.List[str] = None): # RUF013 + 29 |+def f(arg: Optional[typing.List[str]] = None): # RUF013 +30 30 | pass +31 31 | +32 32 | + +RUF013_0.py:33:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +33 | def f(arg: Tuple[str] = None): # RUF013 + | ^^^^^^^^^^ RUF013 +34 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +30 30 | pass +31 31 | +32 32 | +33 |-def f(arg: Tuple[str] = None): # RUF013 + 33 |+def f(arg: Optional[Tuple[str]] = None): # RUF013 +34 34 | pass +35 35 | +36 36 | + +RUF013_0.py:71:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +71 | def f(arg: Union = None): # RUF013 + | ^^^^^ RUF013 +72 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +68 68 | pass +69 69 | +70 70 | +71 |-def f(arg: Union = None): # RUF013 + 71 |+def f(arg: Optional[Union] = None): # RUF013 +72 72 | pass +73 73 | +74 74 | + +RUF013_0.py:75:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +75 | def f(arg: Union[int] = None): # RUF013 + | ^^^^^^^^^^ RUF013 +76 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +72 72 | pass +73 73 | +74 74 | +75 |-def f(arg: Union[int] = None): # RUF013 + 75 |+def f(arg: Optional[Union[int]] = None): # RUF013 +76 76 | pass +77 77 | +78 78 | + +RUF013_0.py:79:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +79 | def f(arg: Union[int, str] = None): # RUF013 + | ^^^^^^^^^^^^^^^ RUF013 +80 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +76 76 | pass +77 77 | +78 78 | +79 |-def f(arg: Union[int, str] = None): # RUF013 + 79 |+def f(arg: Optional[Union[int, str]] = None): # RUF013 +80 80 | pass +81 81 | +82 82 | + +RUF013_0.py:83:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +83 | def f(arg: typing.Union[int, str] = None): # RUF013 + | ^^^^^^^^^^^^^^^^^^^^^^ RUF013 +84 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +80 80 | pass +81 81 | +82 82 | +83 |-def f(arg: typing.Union[int, str] = None): # RUF013 + 83 |+def f(arg: Optional[typing.Union[int, str]] = None): # RUF013 +84 84 | pass +85 85 | +86 86 | + +RUF013_0.py:102:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +102 | def f(arg: int | float = None): # RUF013 + | ^^^^^^^^^^^ RUF013 +103 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +99 99 | pass +100 100 | +101 101 | +102 |-def f(arg: int | float = None): # RUF013 + 102 |+def f(arg: Optional[int | float] = None): # RUF013 +103 103 | pass +104 104 | +105 105 | + +RUF013_0.py:106:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +106 | def f(arg: int | float | str | bytes = None): # RUF013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 +107 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +103 103 | pass +104 104 | +105 105 | +106 |-def f(arg: int | float | str | bytes = None): # RUF013 + 106 |+def f(arg: Optional[int | float | str | bytes] = None): # RUF013 +107 107 | pass +108 108 | +109 109 | + +RUF013_0.py:125:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +125 | def f(arg: Literal[1] = None): # RUF013 + | ^^^^^^^^^^ RUF013 +126 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +122 122 | pass +123 123 | +124 124 | +125 |-def f(arg: Literal[1] = None): # RUF013 + 125 |+def f(arg: Optional[Literal[1]] = None): # RUF013 +126 126 | pass +127 127 | +128 128 | + +RUF013_0.py:129:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +129 | def f(arg: Literal[1, "foo"] = None): # RUF013 + | ^^^^^^^^^^^^^^^^^ RUF013 +130 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +126 126 | pass +127 127 | +128 128 | +129 |-def f(arg: Literal[1, "foo"] = None): # RUF013 + 129 |+def f(arg: Optional[Literal[1, "foo"]] = None): # RUF013 +130 130 | pass +131 131 | +132 132 | + +RUF013_0.py:133:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +133 | def f(arg: typing.Literal[1, "foo", True] = None): # RUF013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 +134 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +130 130 | pass +131 131 | +132 132 | +133 |-def f(arg: typing.Literal[1, "foo", True] = None): # RUF013 + 133 |+def f(arg: Optional[typing.Literal[1, "foo", True]] = None): # RUF013 +134 134 | pass +135 135 | +136 136 | + +RUF013_0.py:152:22: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +152 | def f(arg: Annotated[int, ...] = None): # RUF013 + | ^^^ RUF013 +153 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +149 149 | pass +150 150 | +151 151 | +152 |-def f(arg: Annotated[int, ...] = None): # RUF013 + 152 |+def f(arg: Annotated[Optional[int], ...] = None): # RUF013 +153 153 | pass +154 154 | +155 155 | + +RUF013_0.py:156:32: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +156 | def f(arg: Annotated[Annotated[int | str, ...], ...] = None): # RUF013 + | ^^^^^^^^^ RUF013 +157 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +153 153 | pass +154 154 | +155 155 | +156 |-def f(arg: Annotated[Annotated[int | str, ...], ...] = None): # RUF013 + 156 |+def f(arg: Annotated[Annotated[Optional[int | str], ...], ...] = None): # RUF013 +157 157 | pass +158 158 | +159 159 | + +RUF013_0.py:172:11: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +171 | def f( +172 | arg1: int = None, # RUF013 + | ^^^ RUF013 +173 | arg2: Union[int, float] = None, # RUF013 +174 | arg3: Literal[1, 2, 3] = None, # RUF013 + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +169 169 | +170 170 | +171 171 | def f( +172 |- arg1: int = None, # RUF013 + 172 |+ arg1: Optional[int] = None, # RUF013 +173 173 | arg2: Union[int, float] = None, # RUF013 +174 174 | arg3: Literal[1, 2, 3] = None, # RUF013 +175 175 | ): + +RUF013_0.py:173:11: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +171 | def f( +172 | arg1: int = None, # RUF013 +173 | arg2: Union[int, float] = None, # RUF013 + | ^^^^^^^^^^^^^^^^^ RUF013 +174 | arg3: Literal[1, 2, 3] = None, # RUF013 +175 | ): + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +170 170 | +171 171 | def f( +172 172 | arg1: int = None, # RUF013 +173 |- arg2: Union[int, float] = None, # RUF013 + 173 |+ arg2: Optional[Union[int, float]] = None, # RUF013 +174 174 | arg3: Literal[1, 2, 3] = None, # RUF013 +175 175 | ): +176 176 | pass + +RUF013_0.py:174:11: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +172 | arg1: int = None, # RUF013 +173 | arg2: Union[int, float] = None, # RUF013 +174 | arg3: Literal[1, 2, 3] = None, # RUF013 + | ^^^^^^^^^^^^^^^^ RUF013 +175 | ): +176 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +171 171 | def f( +172 172 | arg1: int = None, # RUF013 +173 173 | arg2: Union[int, float] = None, # RUF013 +174 |- arg3: Literal[1, 2, 3] = None, # RUF013 + 174 |+ arg3: Optional[Literal[1, 2, 3]] = None, # RUF013 +175 175 | ): +176 176 | pass +177 177 | + +RUF013_0.py:202:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +202 | def f(arg: Union[Annotated[int, ...], Union[str, bytes]] = None): # RUF013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 +203 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +199 199 | pass +200 200 | +201 201 | +202 |-def f(arg: Union[Annotated[int, ...], Union[str, bytes]] = None): # RUF013 + 202 |+def f(arg: Optional[Union[Annotated[int, ...], Union[str, bytes]]] = None): # RUF013 +203 203 | pass +204 204 | +205 205 | + +RUF013_0.py:209:13: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +209 | def f(arg: "int" = None): # RUF013 + | ^^^ RUF013 +210 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +206 206 | # Quoted +207 207 | +208 208 | +209 |-def f(arg: "int" = None): # RUF013 + 209 |+def f(arg: "Optional[int]" = None): # RUF013 +210 210 | pass +211 211 | +212 212 | + +RUF013_0.py:213:13: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +213 | def f(arg: "str" = None): # RUF013 + | ^^^ RUF013 +214 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +210 210 | pass +211 211 | +212 212 | +213 |-def f(arg: "str" = None): # RUF013 + 213 |+def f(arg: "Optional[str]" = None): # RUF013 +214 214 | pass +215 215 | +216 216 | + +RUF013_0.py:217:12: RUF013 PEP 484 prohibits implicit `Optional` + | +217 | def f(arg: "st" "r" = None): # RUF013 + | ^^^^^^^^ RUF013 +218 | pass + | + = help: Convert to `Optional[T]` + +RUF013_0.py:225:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +225 | def f(arg: Union["int", "str"] = None): # RUF013 + | ^^^^^^^^^^^^^^^^^^^ RUF013 +226 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +222 222 | pass +223 223 | +224 224 | +225 |-def f(arg: Union["int", "str"] = None): # RUF013 + 225 |+def f(arg: Optional[Union["int", "str"]] = None): # RUF013 +226 226 | pass +227 227 | +228 228 | + + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_1.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_1.py.snap new file mode 100644 index 0000000000..6647c65948 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__PY39_RUF013_RUF013_1.py.snap @@ -0,0 +1,21 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF013_1.py:4:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +4 | def f(arg: int = None): # RUF011 + | ^^^ RUF013 +5 | pass + | + = help: Convert to `Optional[T]` + +ℹ Suggested fix +1 1 | # No `typing.Optional` import + 2 |+from typing import Optional +2 3 | +3 4 | +4 |-def f(arg: int = None): # RUF011 + 5 |+def f(arg: Optional[int] = None): # RUF011 +5 6 | pass + + 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 new file mode 100644 index 0000000000..baf307a873 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF005_RUF005.py.snap @@ -0,0 +1,357 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF005.py:4:1: RUF005 Consider `[*foo]` instead of concatenation + | +2 | # Non-fixable Errors. +3 | ### +4 | / foo + [ # This will be preserved. +5 | | ] + | |_^ RUF005 +6 | [*foo] + [ # This will be preserved. +7 | ] + | + = help: Replace with `[*foo]` + +RUF005.py:6:1: RUF005 Consider `[*foo]` instead of concatenation + | +4 | foo + [ # This will be preserved. +5 | ] +6 | / [*foo] + [ # This will be preserved. +7 | | ] + | |_^ RUF005 +8 | first = [ +9 | # The order + | + = help: Replace with `[*foo]` + +RUF005.py:16:10: RUF005 Consider `[*first, 4, 5, 6]` instead of concatenation + | +14 | # to preserve +15 | ] +16 | second = first + [ + | __________^ +17 | | # please +18 | | 4, +19 | | # don't +20 | | 5, +21 | | # touch +22 | | 6, +23 | | ] + | |_^ RUF005 + | + = help: Replace with `[*first, 4, 5, 6]` + +RUF005.py:39:7: RUF005 [*] Consider `[1, 2, 3, *foo]` instead of concatenation + | +38 | foo = [4, 5, 6] +39 | bar = [1, 2, 3] + foo + | ^^^^^^^^^^^^^^^ RUF005 +40 | zoob = tuple(bar) +41 | quux = (7, 8, 9) + zoob + | + = help: Replace with `[1, 2, 3, *foo]` + +ℹ Suggested fix +36 36 | yay = Fun().yay +37 37 | +38 38 | foo = [4, 5, 6] +39 |-bar = [1, 2, 3] + foo + 39 |+bar = [1, 2, 3, *foo] +40 40 | zoob = tuple(bar) +41 41 | quux = (7, 8, 9) + zoob +42 42 | spam = quux + (10, 11, 12) + +RUF005.py:41:8: RUF005 [*] Consider `(7, 8, 9, *zoob)` instead of concatenation + | +39 | bar = [1, 2, 3] + foo +40 | zoob = tuple(bar) +41 | quux = (7, 8, 9) + zoob + | ^^^^^^^^^^^^^^^^ RUF005 +42 | spam = quux + (10, 11, 12) +43 | spom = list(spam) + | + = help: Replace with `(7, 8, 9, *zoob)` + +ℹ Suggested fix +38 38 | foo = [4, 5, 6] +39 39 | bar = [1, 2, 3] + foo +40 40 | zoob = tuple(bar) +41 |-quux = (7, 8, 9) + zoob + 41 |+quux = (7, 8, 9, *zoob) +42 42 | spam = quux + (10, 11, 12) +43 43 | spom = list(spam) +44 44 | eggs = spom + [13, 14, 15] + +RUF005.py:42:8: RUF005 [*] Consider `(*quux, 10, 11, 12)` instead of concatenation + | +40 | zoob = tuple(bar) +41 | quux = (7, 8, 9) + zoob +42 | spam = quux + (10, 11, 12) + | ^^^^^^^^^^^^^^^^^^^ RUF005 +43 | spom = list(spam) +44 | eggs = spom + [13, 14, 15] + | + = help: Replace with `(*quux, 10, 11, 12)` + +ℹ Suggested fix +39 39 | bar = [1, 2, 3] + foo +40 40 | zoob = tuple(bar) +41 41 | quux = (7, 8, 9) + zoob +42 |-spam = quux + (10, 11, 12) + 42 |+spam = (*quux, 10, 11, 12) +43 43 | spom = list(spam) +44 44 | eggs = spom + [13, 14, 15] +45 45 | elatement = ("we all say",) + yay() + +RUF005.py:44:8: RUF005 [*] Consider `[*spom, 13, 14, 15]` instead of concatenation + | +42 | spam = quux + (10, 11, 12) +43 | spom = list(spam) +44 | eggs = spom + [13, 14, 15] + | ^^^^^^^^^^^^^^^^^^^ RUF005 +45 | elatement = ("we all say",) + yay() +46 | excitement = ("we all think",) + Fun().yay() + | + = help: Replace with `[*spom, 13, 14, 15]` + +ℹ Suggested fix +41 41 | quux = (7, 8, 9) + zoob +42 42 | spam = quux + (10, 11, 12) +43 43 | spom = list(spam) +44 |-eggs = spom + [13, 14, 15] + 44 |+eggs = [*spom, 13, 14, 15] +45 45 | elatement = ("we all say",) + yay() +46 46 | excitement = ("we all think",) + Fun().yay() +47 47 | astonishment = ("we all feel",) + Fun.words + +RUF005.py:45:13: RUF005 [*] Consider `("we all say", *yay())` instead of concatenation + | +43 | spom = list(spam) +44 | eggs = spom + [13, 14, 15] +45 | elatement = ("we all say",) + yay() + | ^^^^^^^^^^^^^^^^^^^^^^^ RUF005 +46 | excitement = ("we all think",) + Fun().yay() +47 | astonishment = ("we all feel",) + Fun.words + | + = help: Replace with `("we all say", *yay())` + +ℹ Suggested fix +42 42 | spam = quux + (10, 11, 12) +43 43 | spom = list(spam) +44 44 | eggs = spom + [13, 14, 15] +45 |-elatement = ("we all say",) + yay() + 45 |+elatement = ("we all say", *yay()) +46 46 | excitement = ("we all think",) + Fun().yay() +47 47 | astonishment = ("we all feel",) + Fun.words +48 48 | + +RUF005.py:46:14: RUF005 [*] Consider `("we all think", *Fun().yay())` instead of concatenation + | +44 | eggs = spom + [13, 14, 15] +45 | elatement = ("we all say",) + yay() +46 | excitement = ("we all think",) + Fun().yay() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 +47 | astonishment = ("we all feel",) + Fun.words + | + = help: Replace with `("we all think", *Fun().yay())` + +ℹ Suggested fix +43 43 | spom = list(spam) +44 44 | eggs = spom + [13, 14, 15] +45 45 | elatement = ("we all say",) + yay() +46 |-excitement = ("we all think",) + Fun().yay() + 46 |+excitement = ("we all think", *Fun().yay()) +47 47 | astonishment = ("we all feel",) + Fun.words +48 48 | +49 49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) + +RUF005.py:47:16: RUF005 [*] Consider `("we all feel", *Fun.words)` instead of concatenation + | +45 | elatement = ("we all say",) + yay() +46 | excitement = ("we all think",) + Fun().yay() +47 | astonishment = ("we all feel",) + Fun.words + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 +48 | +49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) + | + = help: Replace with `("we all feel", *Fun.words)` + +ℹ Suggested fix +44 44 | eggs = spom + [13, 14, 15] +45 45 | elatement = ("we all say",) + yay() +46 46 | excitement = ("we all think",) + Fun().yay() +47 |-astonishment = ("we all feel",) + Fun.words + 47 |+astonishment = ("we all feel", *Fun.words) +48 48 | +49 49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) +50 50 | + +RUF005.py:49:9: RUF005 [*] Consider iterable unpacking instead of concatenation + | +47 | astonishment = ("we all feel",) + Fun.words +48 | +49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 +50 | +51 | baz = () + zoob + | + = help: Replace with iterable unpacking + +ℹ Suggested fix +46 46 | excitement = ("we all think",) + Fun().yay() +47 47 | astonishment = ("we all feel",) + Fun.words +48 48 | +49 |-chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) + 49 |+chain = ["a", "b", "c", *eggs, *list(("yes", "no", "pants") + zoob)] +50 50 | +51 51 | baz = () + zoob +52 52 | + +RUF005.py:49:39: RUF005 [*] Consider `("yes", "no", "pants", *zoob)` instead of concatenation + | +47 | astonishment = ("we all feel",) + Fun.words +48 | +49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 +50 | +51 | baz = () + zoob + | + = help: Replace with `("yes", "no", "pants", *zoob)` + +ℹ Suggested fix +46 46 | excitement = ("we all think",) + Fun().yay() +47 47 | astonishment = ("we all feel",) + Fun.words +48 48 | +49 |-chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) + 49 |+chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants", *zoob)) +50 50 | +51 51 | baz = () + zoob +52 52 | + +RUF005.py:51:7: RUF005 [*] Consider `(*zoob,)` instead of concatenation + | +49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) +50 | +51 | baz = () + zoob + | ^^^^^^^^^ RUF005 +52 | +53 | [] + foo + [ + | + = help: Replace with `(*zoob,)` + +ℹ Suggested fix +48 48 | +49 49 | chain = ["a", "b", "c"] + eggs + list(("yes", "no", "pants") + zoob) +50 50 | +51 |-baz = () + zoob + 51 |+baz = (*zoob,) +52 52 | +53 53 | [] + foo + [ +54 54 | ] + +RUF005.py:53:1: RUF005 [*] Consider `[*foo]` instead of concatenation + | +51 | baz = () + zoob +52 | +53 | / [] + foo + [ +54 | | ] + | |_^ RUF005 +55 | +56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] + | + = help: Replace with `[*foo]` + +ℹ Suggested fix +50 50 | +51 51 | baz = () + zoob +52 52 | +53 |-[] + foo + [ +54 |-] + 53 |+[*foo] +55 54 | +56 55 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] +57 56 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) + +RUF005.py:56:15: RUF005 [*] Consider `[sys.executable, "-m", "pylint", *args, path]` instead of concatenation + | +54 | ] +55 | +56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 +57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) +58 | b = a + [2, 3] + [4] + | + = help: Replace with `[sys.executable, "-m", "pylint", *args, path]` + +ℹ Suggested fix +53 53 | [] + foo + [ +54 54 | ] +55 55 | +56 |-pylint_call = [sys.executable, "-m", "pylint"] + args + [path] + 56 |+pylint_call = [sys.executable, "-m", "pylint", *args, path] +57 57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) +58 58 | b = a + [2, 3] + [4] +59 59 | + +RUF005.py:57:21: RUF005 [*] Consider iterable unpacking instead of concatenation + | +56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] +57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF005 +58 | b = a + [2, 3] + [4] + | + = help: Replace with iterable unpacking + +ℹ Suggested fix +54 54 | ] +55 55 | +56 56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] +57 |-pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) + 57 |+pylint_call_tuple = (sys.executable, "-m", "pylint", *args, path, path2) +58 58 | b = a + [2, 3] + [4] +59 59 | +60 60 | # Uses the non-preferred quote style, which should be retained. + +RUF005.py:58:5: RUF005 [*] Consider `[*a, 2, 3, 4]` instead of concatenation + | +56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] +57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) +58 | b = a + [2, 3] + [4] + | ^^^^^^^^^^^^^^^^ RUF005 +59 | +60 | # Uses the non-preferred quote style, which should be retained. + | + = help: Replace with `[*a, 2, 3, 4]` + +ℹ Suggested fix +55 55 | +56 56 | pylint_call = [sys.executable, "-m", "pylint"] + args + [path] +57 57 | pylint_call_tuple = (sys.executable, "-m", "pylint") + args + (path, path2) +58 |-b = a + [2, 3] + [4] + 58 |+b = [*a, 2, 3, 4] +59 59 | +60 60 | # Uses the non-preferred quote style, which should be retained. +61 61 | f"{a() + ['b']}" + +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 | +63 | ### + | + = help: Replace with `[*a(), 'b']` + +ℹ Suggested fix +58 58 | b = a + [2, 3] + [4] +59 59 | +60 60 | # Uses the non-preferred quote style, which should be retained. +61 |-f"{a() + ['b']}" + 61 |+f"{[*a(), 'b']}" +62 62 | +63 63 | ### +64 64 | # Non-errors. + + 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 new file mode 100644 index 0000000000..b91ea21408 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF006_RUF006.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF006.py:6:5: RUF006 Store a reference to the return value of `asyncio.create_task` + | +4 | # Error +5 | def f(): +6 | asyncio.create_task(coordinator.ws_connect()) # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF006 + | + +RUF006.py:11:5: RUF006 Store a reference to the return value of `asyncio.ensure_future` + | + 9 | # Error +10 | def f(): +11 | asyncio.ensure_future(coordinator.ws_connect()) # Error + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF006 + | + + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF007_RUF007.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF007_RUF007.py.snap new file mode 100644 index 0000000000..7735d986db --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF007_RUF007.py.snap @@ -0,0 +1,100 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF007.py:16:1: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + | +15 | # Errors +16 | zip(input, input[1:]) + | ^^^ RUF007 +17 | zip(input, input[1::1]) +18 | zip(input[:-1], input[1:]) + | + +RUF007.py:17:1: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + | +15 | # Errors +16 | zip(input, input[1:]) +17 | zip(input, input[1::1]) + | ^^^ RUF007 +18 | zip(input[:-1], input[1:]) +19 | zip(input[1:], input[2:]) + | + +RUF007.py:18:1: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + | +16 | zip(input, input[1:]) +17 | zip(input, input[1::1]) +18 | zip(input[:-1], input[1:]) + | ^^^ RUF007 +19 | zip(input[1:], input[2:]) +20 | zip(input[1:-1], input[2:]) + | + +RUF007.py:19:1: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + | +17 | zip(input, input[1::1]) +18 | zip(input[:-1], input[1:]) +19 | zip(input[1:], input[2:]) + | ^^^ RUF007 +20 | zip(input[1:-1], input[2:]) +21 | list(zip(input, input[1:])) + | + +RUF007.py:20:1: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + | +18 | zip(input[:-1], input[1:]) +19 | zip(input[1:], input[2:]) +20 | zip(input[1:-1], input[2:]) + | ^^^ RUF007 +21 | list(zip(input, input[1:])) +22 | list(zip(input[:-1], input[1:])) + | + +RUF007.py:21:6: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + | +19 | zip(input[1:], input[2:]) +20 | zip(input[1:-1], input[2:]) +21 | list(zip(input, input[1:])) + | ^^^ RUF007 +22 | list(zip(input[:-1], input[1:])) +23 | zip(foo[:-1], foo[1:], strict=True) + | + +RUF007.py:22:6: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + | +20 | zip(input[1:-1], input[2:]) +21 | list(zip(input, input[1:])) +22 | list(zip(input[:-1], input[1:])) + | ^^^ RUF007 +23 | zip(foo[:-1], foo[1:], strict=True) +24 | zip(foo[:-1], foo[1:], strict=False) + | + +RUF007.py:23:1: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + | +21 | list(zip(input, input[1:])) +22 | list(zip(input[:-1], input[1:])) +23 | zip(foo[:-1], foo[1:], strict=True) + | ^^^ RUF007 +24 | zip(foo[:-1], foo[1:], strict=False) +25 | zip(foo[:-1], foo[1:], strict=bool(foo)) + | + +RUF007.py:24:1: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + | +22 | list(zip(input[:-1], input[1:])) +23 | zip(foo[:-1], foo[1:], strict=True) +24 | zip(foo[:-1], foo[1:], strict=False) + | ^^^ RUF007 +25 | zip(foo[:-1], foo[1:], strict=bool(foo)) + | + +RUF007.py:25:1: RUF007 Prefer `itertools.pairwise()` over `zip()` when iterating over successive pairs + | +23 | zip(foo[:-1], foo[1:], strict=True) +24 | zip(foo[:-1], foo[1:], strict=False) +25 | zip(foo[:-1], foo[1:], strict=bool(foo)) + | ^^^ RUF007 + | + + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF008_RUF008.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF008_RUF008.py.snap new file mode 100644 index 0000000000..97ea363c77 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF008_RUF008.py.snap @@ -0,0 +1,24 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF008.py:10:34: RUF008 Do not use mutable default values for dataclass attributes + | + 8 | @dataclass + 9 | class A: +10 | mutable_default: list[int] = [] + | ^^ RUF008 +11 | immutable_annotation: typing.Sequence[int] = [] +12 | without_annotation = [] + | + +RUF008.py:20:34: RUF008 Do not use mutable default values for dataclass attributes + | +18 | @dataclass +19 | class B: +20 | mutable_default: list[int] = [] + | ^^ RUF008 +21 | immutable_annotation: Sequence[int] = [] +22 | without_annotation = [] + | + + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF009_RUF009.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF009_RUF009.py.snap new file mode 100644 index 0000000000..c9c3e9ed84 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF009_RUF009.py.snap @@ -0,0 +1,44 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF009.py:20:41: RUF009 Do not perform function call `default_function` in dataclass defaults + | +18 | @dataclass() +19 | class A: +20 | hidden_mutable_default: list[int] = default_function() + | ^^^^^^^^^^^^^^^^^^ RUF009 +21 | class_variable: typing.ClassVar[list[int]] = default_function() +22 | another_class_var: ClassVar[list[int]] = default_function() + | + +RUF009.py:43:41: RUF009 Do not perform function call `default_function` in dataclass defaults + | +41 | @dataclass +42 | class B: +43 | hidden_mutable_default: list[int] = default_function() + | ^^^^^^^^^^^^^^^^^^ RUF009 +44 | another_dataclass: A = A() +45 | not_optimal: ImmutableType = ImmutableType(20) + | + +RUF009.py:44:28: RUF009 Do not perform function call `A` in dataclass defaults + | +42 | class B: +43 | hidden_mutable_default: list[int] = default_function() +44 | another_dataclass: A = A() + | ^^^ RUF009 +45 | not_optimal: ImmutableType = ImmutableType(20) +46 | good_variant: ImmutableType = DEFAULT_IMMUTABLETYPE_FOR_ALL_DATACLASSES + | + +RUF009.py:45:34: RUF009 Do not perform function call `ImmutableType` in dataclass defaults + | +43 | hidden_mutable_default: list[int] = default_function() +44 | another_dataclass: A = A() +45 | not_optimal: ImmutableType = ImmutableType(20) + | ^^^^^^^^^^^^^^^^^ RUF009 +46 | good_variant: ImmutableType = DEFAULT_IMMUTABLETYPE_FOR_ALL_DATACLASSES +47 | okay_variant: A = DEFAULT_A_FOR_ALL_DATACLASSES + | + + 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 new file mode 100644 index 0000000000..c9fac2091d --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF010_RUF010.py.snap @@ -0,0 +1,249 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF010.py:9:4: RUF010 [*] Use explicit conversion flag + | + 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 + | ^^^^^^^^ RUF010 +10 | +11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 + | + = help: Replace with conversion flag + +ℹ Fix +6 6 | pass +7 7 | +8 8 | +9 |-f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 + 9 |+f"{bla!s}, {repr(bla)}, {ascii(bla)}" # RUF010 +10 10 | +11 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 +12 12 | + +RUF010.py:9:16: RUF010 [*] Use explicit conversion flag + | + 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 + | ^^^^^^^^^ RUF010 +10 | +11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 + | + = help: Replace with conversion flag + +ℹ Fix +6 6 | pass +7 7 | +8 8 | +9 |-f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 + 9 |+f"{str(bla)}, {bla!r}, {ascii(bla)}" # RUF010 +10 10 | +11 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 +12 12 | + +RUF010.py:9:29: RUF010 [*] Use explicit conversion flag + | + 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 + | ^^^^^^^^^^ RUF010 +10 | +11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 + | + = help: Replace with conversion flag + +ℹ Fix +6 6 | pass +7 7 | +8 8 | +9 |-f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 + 9 |+f"{str(bla)}, {repr(bla)}, {bla!a}" # RUF010 +10 10 | +11 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 +12 12 | + +RUF010.py:11:4: RUF010 [*] Use explicit conversion flag + | + 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 +10 | +11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 + | ^^^^^^^^^^^ RUF010 +12 | +13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 + | + = help: Replace with conversion flag + +ℹ Fix +8 8 | +9 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 +10 10 | +11 |-f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 + 11 |+f"{d['a']!s}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 +12 12 | +13 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 +14 14 | + +RUF010.py:11:19: RUF010 [*] Use explicit conversion flag + | + 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 +10 | +11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 + | ^^^^^^^^^^^^ RUF010 +12 | +13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 + | + = help: Replace with conversion flag + +ℹ Fix +8 8 | +9 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 +10 10 | +11 |-f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 + 11 |+f"{str(d['a'])}, {d['b']!r}, {ascii(d['c'])}" # RUF010 +12 12 | +13 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 +14 14 | + +RUF010.py:11:35: RUF010 [*] Use explicit conversion flag + | + 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 +10 | +11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 + | ^^^^^^^^^^^^^ RUF010 +12 | +13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 + | + = help: Replace with conversion flag + +ℹ Fix +8 8 | +9 9 | f"{str(bla)}, {repr(bla)}, {ascii(bla)}" # RUF010 +10 10 | +11 |-f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 + 11 |+f"{str(d['a'])}, {repr(d['b'])}, {d['c']!a}" # RUF010 +12 12 | +13 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 +14 14 | + +RUF010.py:13:5: RUF010 [*] Use explicit conversion flag + | +11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 +12 | +13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 + | ^^^^^^^^ RUF010 +14 | +15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 + | + = help: Replace with conversion flag + +ℹ Fix +10 10 | +11 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 +12 12 | +13 |-f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 + 13 |+f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 +14 14 | +15 15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 +16 16 | + +RUF010.py:13:19: RUF010 [*] Use explicit conversion flag + | +11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 +12 | +13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 + | ^^^^^^^^^ RUF010 +14 | +15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 + | + = help: Replace with conversion flag + +ℹ Fix +10 10 | +11 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 +12 12 | +13 |-f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 + 13 |+f"{(str(bla))}, {bla!r}, {(ascii(bla))}" # RUF010 +14 14 | +15 15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 +16 16 | + +RUF010.py:13:34: RUF010 [*] Use explicit conversion flag + | +11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 +12 | +13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 + | ^^^^^^^^^^ RUF010 +14 | +15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 + | + = help: Replace with conversion flag + +ℹ Fix +10 10 | +11 11 | f"{str(d['a'])}, {repr(d['b'])}, {ascii(d['c'])}" # RUF010 +12 12 | +13 |-f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 + 13 |+f"{(str(bla))}, {(repr(bla))}, {bla!a}" # RUF010 +14 14 | +15 15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 +16 16 | + +RUF010.py:15:14: RUF010 [*] Use explicit conversion flag + | +13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 +14 | +15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 + | ^^^^^^^^^ RUF010 +16 | +17 | f"{foo(bla)}" # OK + | + = help: Replace with conversion flag + +ℹ Fix +12 12 | +13 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 +14 14 | +15 |-f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 + 15 |+f"{bla!s}, {bla!r}, {(ascii(bla))}" # RUF010 +16 16 | +17 17 | f"{foo(bla)}" # OK +18 18 | + +RUF010.py:15:29: RUF010 [*] Use explicit conversion flag + | +13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 +14 | +15 | f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 + | ^^^^^^^^^^ RUF010 +16 | +17 | f"{foo(bla)}" # OK + | + = help: Replace with conversion flag + +ℹ Fix +12 12 | +13 13 | f"{(str(bla))}, {(repr(bla))}, {(ascii(bla))}" # RUF010 +14 14 | +15 |-f"{bla!s}, {(repr(bla))}, {(ascii(bla))}" # RUF010 + 15 |+f"{bla!s}, {(repr(bla))}, {bla!a}" # RUF010 +16 16 | +17 17 | f"{foo(bla)}" # OK +18 18 | + +RUF010.py:35:20: RUF010 [*] Use explicit conversion flag + | +33 | f"Member of tuple mismatches type at index {i}. Expected {of_shape_i}. Got " +34 | " intermediary content " +35 | f" that flows {repr(obj)} of type {type(obj)}.{additional_message}" # RUF010 + | ^^^^^^^^^ RUF010 +36 | ) + | + = help: Replace with conversion flag + +ℹ Fix +32 32 | ( +33 33 | f"Member of tuple mismatches type at index {i}. Expected {of_shape_i}. Got " +34 34 | " intermediary content " +35 |- f" that flows {repr(obj)} of type {type(obj)}.{additional_message}" # RUF010 + 35 |+ f" that flows {obj!r} of type {type(obj)}.{additional_message}" # RUF010 +36 36 | ) +37 37 | +38 38 | + + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF011_RUF011.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF011_RUF011.py.snap new file mode 100644 index 0000000000..e522dfb723 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF011_RUF011.py.snap @@ -0,0 +1,40 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF011.py:10:2: RUF011 Dictionary comprehension uses static key: `"key"` + | + 9 | # Errors +10 | {"key": value.upper() for value in data} + | ^^^^^ RUF011 +11 | {True: value.upper() for value in data} +12 | {0: value.upper() for value in data} + | + +RUF011.py:11:2: RUF011 Dictionary comprehension uses static key: `True` + | + 9 | # Errors +10 | {"key": value.upper() for value in data} +11 | {True: value.upper() for value in data} + | ^^^^ RUF011 +12 | {0: value.upper() for value in data} +13 | {(1, "a"): value.upper() for value in data} # constant tuple + | + +RUF011.py:12:2: RUF011 Dictionary comprehension uses static key: `0` + | +10 | {"key": value.upper() for value in data} +11 | {True: value.upper() for value in data} +12 | {0: value.upper() for value in data} + | ^ RUF011 +13 | {(1, "a"): value.upper() for value in data} # constant tuple + | + +RUF011.py:13:2: RUF011 Dictionary comprehension uses static key: `(1, "a")` + | +11 | {True: value.upper() for value in data} +12 | {0: value.upper() for value in data} +13 | {(1, "a"): value.upper() for value in data} # constant tuple + | ^^^^^^^^ RUF011 + | + + 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 new file mode 100644 index 0000000000..c6c9873efc --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF012_RUF012.py.snap @@ -0,0 +1,34 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF012.py:9:34: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + | + 7 | } + 8 | + 9 | mutable_default: list[int] = [] + | ^^ RUF012 +10 | immutable_annotation: Sequence[int] = [] +11 | without_annotation = [] + | + +RUF012.py:11:26: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + | + 9 | mutable_default: list[int] = [] +10 | immutable_annotation: Sequence[int] = [] +11 | without_annotation = [] + | ^^ RUF012 +12 | class_variable: ClassVar[list[int]] = [] +13 | final_variable: Final[list[int]] = [] + | + +RUF012.py:25:26: RUF012 Mutable class attributes should be annotated with `typing.ClassVar` + | +23 | mutable_default: list[int] = [] +24 | immutable_annotation: Sequence[int] = [] +25 | without_annotation = [] + | ^^ RUF012 +26 | perfectly_fine: list[int] = field(default_factory=list) +27 | class_variable: ClassVar[list[int]] = [] + | + + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_0.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_0.py.snap new file mode 100644 index 0000000000..10634c0520 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_0.py.snap @@ -0,0 +1,416 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF013_0.py:21:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +21 | def f(arg: int = None): # RUF013 + | ^^^ RUF013 +22 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +18 18 | pass +19 19 | +20 20 | +21 |-def f(arg: int = None): # RUF013 + 21 |+def f(arg: int | None = None): # RUF013 +22 22 | pass +23 23 | +24 24 | + +RUF013_0.py:25:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +25 | def f(arg: str = None): # RUF013 + | ^^^ RUF013 +26 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +22 22 | pass +23 23 | +24 24 | +25 |-def f(arg: str = None): # RUF013 + 25 |+def f(arg: str | None = None): # RUF013 +26 26 | pass +27 27 | +28 28 | + +RUF013_0.py:29:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +29 | def f(arg: typing.List[str] = None): # RUF013 + | ^^^^^^^^^^^^^^^^ RUF013 +30 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +26 26 | pass +27 27 | +28 28 | +29 |-def f(arg: typing.List[str] = None): # RUF013 + 29 |+def f(arg: typing.List[str] | None = None): # RUF013 +30 30 | pass +31 31 | +32 32 | + +RUF013_0.py:33:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +33 | def f(arg: Tuple[str] = None): # RUF013 + | ^^^^^^^^^^ RUF013 +34 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +30 30 | pass +31 31 | +32 32 | +33 |-def f(arg: Tuple[str] = None): # RUF013 + 33 |+def f(arg: Tuple[str] | None = None): # RUF013 +34 34 | pass +35 35 | +36 36 | + +RUF013_0.py:71:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +71 | def f(arg: Union = None): # RUF013 + | ^^^^^ RUF013 +72 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +68 68 | pass +69 69 | +70 70 | +71 |-def f(arg: Union = None): # RUF013 + 71 |+def f(arg: Union | None = None): # RUF013 +72 72 | pass +73 73 | +74 74 | + +RUF013_0.py:75:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +75 | def f(arg: Union[int] = None): # RUF013 + | ^^^^^^^^^^ RUF013 +76 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +72 72 | pass +73 73 | +74 74 | +75 |-def f(arg: Union[int] = None): # RUF013 + 75 |+def f(arg: Union[int] | None = None): # RUF013 +76 76 | pass +77 77 | +78 78 | + +RUF013_0.py:79:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +79 | def f(arg: Union[int, str] = None): # RUF013 + | ^^^^^^^^^^^^^^^ RUF013 +80 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +76 76 | pass +77 77 | +78 78 | +79 |-def f(arg: Union[int, str] = None): # RUF013 + 79 |+def f(arg: Union[int, str] | None = None): # RUF013 +80 80 | pass +81 81 | +82 82 | + +RUF013_0.py:83:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +83 | def f(arg: typing.Union[int, str] = None): # RUF013 + | ^^^^^^^^^^^^^^^^^^^^^^ RUF013 +84 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +80 80 | pass +81 81 | +82 82 | +83 |-def f(arg: typing.Union[int, str] = None): # RUF013 + 83 |+def f(arg: typing.Union[int, str] | None = None): # RUF013 +84 84 | pass +85 85 | +86 86 | + +RUF013_0.py:102:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +102 | def f(arg: int | float = None): # RUF013 + | ^^^^^^^^^^^ RUF013 +103 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +99 99 | pass +100 100 | +101 101 | +102 |-def f(arg: int | float = None): # RUF013 + 102 |+def f(arg: int | float | None = None): # RUF013 +103 103 | pass +104 104 | +105 105 | + +RUF013_0.py:106:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +106 | def f(arg: int | float | str | bytes = None): # RUF013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 +107 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +103 103 | pass +104 104 | +105 105 | +106 |-def f(arg: int | float | str | bytes = None): # RUF013 + 106 |+def f(arg: int | float | str | bytes | None = None): # RUF013 +107 107 | pass +108 108 | +109 109 | + +RUF013_0.py:125:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +125 | def f(arg: Literal[1] = None): # RUF013 + | ^^^^^^^^^^ RUF013 +126 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +122 122 | pass +123 123 | +124 124 | +125 |-def f(arg: Literal[1] = None): # RUF013 + 125 |+def f(arg: Literal[1] | None = None): # RUF013 +126 126 | pass +127 127 | +128 128 | + +RUF013_0.py:129:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +129 | def f(arg: Literal[1, "foo"] = None): # RUF013 + | ^^^^^^^^^^^^^^^^^ RUF013 +130 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +126 126 | pass +127 127 | +128 128 | +129 |-def f(arg: Literal[1, "foo"] = None): # RUF013 + 129 |+def f(arg: Literal[1, "foo"] | None = None): # RUF013 +130 130 | pass +131 131 | +132 132 | + +RUF013_0.py:133:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +133 | def f(arg: typing.Literal[1, "foo", True] = None): # RUF013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 +134 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +130 130 | pass +131 131 | +132 132 | +133 |-def f(arg: typing.Literal[1, "foo", True] = None): # RUF013 + 133 |+def f(arg: typing.Literal[1, "foo", True] | None = None): # RUF013 +134 134 | pass +135 135 | +136 136 | + +RUF013_0.py:152:22: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +152 | def f(arg: Annotated[int, ...] = None): # RUF013 + | ^^^ RUF013 +153 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +149 149 | pass +150 150 | +151 151 | +152 |-def f(arg: Annotated[int, ...] = None): # RUF013 + 152 |+def f(arg: Annotated[int | None, ...] = None): # RUF013 +153 153 | pass +154 154 | +155 155 | + +RUF013_0.py:156:32: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +156 | def f(arg: Annotated[Annotated[int | str, ...], ...] = None): # RUF013 + | ^^^^^^^^^ RUF013 +157 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +153 153 | pass +154 154 | +155 155 | +156 |-def f(arg: Annotated[Annotated[int | str, ...], ...] = None): # RUF013 + 156 |+def f(arg: Annotated[Annotated[int | str | None, ...], ...] = None): # RUF013 +157 157 | pass +158 158 | +159 159 | + +RUF013_0.py:172:11: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +171 | def f( +172 | arg1: int = None, # RUF013 + | ^^^ RUF013 +173 | arg2: Union[int, float] = None, # RUF013 +174 | arg3: Literal[1, 2, 3] = None, # RUF013 + | + = help: Convert to `T | None` + +ℹ Suggested fix +169 169 | +170 170 | +171 171 | def f( +172 |- arg1: int = None, # RUF013 + 172 |+ arg1: int | None = None, # RUF013 +173 173 | arg2: Union[int, float] = None, # RUF013 +174 174 | arg3: Literal[1, 2, 3] = None, # RUF013 +175 175 | ): + +RUF013_0.py:173:11: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +171 | def f( +172 | arg1: int = None, # RUF013 +173 | arg2: Union[int, float] = None, # RUF013 + | ^^^^^^^^^^^^^^^^^ RUF013 +174 | arg3: Literal[1, 2, 3] = None, # RUF013 +175 | ): + | + = help: Convert to `T | None` + +ℹ Suggested fix +170 170 | +171 171 | def f( +172 172 | arg1: int = None, # RUF013 +173 |- arg2: Union[int, float] = None, # RUF013 + 173 |+ arg2: Union[int, float] | None = None, # RUF013 +174 174 | arg3: Literal[1, 2, 3] = None, # RUF013 +175 175 | ): +176 176 | pass + +RUF013_0.py:174:11: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +172 | arg1: int = None, # RUF013 +173 | arg2: Union[int, float] = None, # RUF013 +174 | arg3: Literal[1, 2, 3] = None, # RUF013 + | ^^^^^^^^^^^^^^^^ RUF013 +175 | ): +176 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +171 171 | def f( +172 172 | arg1: int = None, # RUF013 +173 173 | arg2: Union[int, float] = None, # RUF013 +174 |- arg3: Literal[1, 2, 3] = None, # RUF013 + 174 |+ arg3: Literal[1, 2, 3] | None = None, # RUF013 +175 175 | ): +176 176 | pass +177 177 | + +RUF013_0.py:202:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +202 | def f(arg: Union[Annotated[int, ...], Union[str, bytes]] = None): # RUF013 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF013 +203 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +199 199 | pass +200 200 | +201 201 | +202 |-def f(arg: Union[Annotated[int, ...], Union[str, bytes]] = None): # RUF013 + 202 |+def f(arg: Union[Annotated[int, ...], Union[str, bytes]] | None = None): # RUF013 +203 203 | pass +204 204 | +205 205 | + +RUF013_0.py:209:13: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +209 | def f(arg: "int" = None): # RUF013 + | ^^^ RUF013 +210 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +206 206 | # Quoted +207 207 | +208 208 | +209 |-def f(arg: "int" = None): # RUF013 + 209 |+def f(arg: "int | None" = None): # RUF013 +210 210 | pass +211 211 | +212 212 | + +RUF013_0.py:213:13: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +213 | def f(arg: "str" = None): # RUF013 + | ^^^ RUF013 +214 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +210 210 | pass +211 211 | +212 212 | +213 |-def f(arg: "str" = None): # RUF013 + 213 |+def f(arg: "str | None" = None): # RUF013 +214 214 | pass +215 215 | +216 216 | + +RUF013_0.py:217:12: RUF013 PEP 484 prohibits implicit `Optional` + | +217 | def f(arg: "st" "r" = None): # RUF013 + | ^^^^^^^^ RUF013 +218 | pass + | + = help: Convert to `T | None` + +RUF013_0.py:225:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +225 | def f(arg: Union["int", "str"] = None): # RUF013 + | ^^^^^^^^^^^^^^^^^^^ RUF013 +226 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +222 222 | pass +223 223 | +224 224 | +225 |-def f(arg: Union["int", "str"] = None): # RUF013 + 225 |+def f(arg: Union["int", "str"] | None = None): # RUF013 +226 226 | pass +227 227 | +228 228 | + + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_1.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_1.py.snap new file mode 100644 index 0000000000..df81fc0f7f --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF013_RUF013_1.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF013_1.py:4:12: RUF013 [*] PEP 484 prohibits implicit `Optional` + | +4 | def f(arg: int = None): # RUF011 + | ^^^ RUF013 +5 | pass + | + = help: Convert to `T | None` + +ℹ Suggested fix +1 1 | # No `typing.Optional` import +2 2 | +3 3 | +4 |-def f(arg: int = None): # RUF011 + 4 |+def f(arg: int | None = None): # RUF011 +5 5 | pass + + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF014_RUF014.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF014_RUF014.py.snap new file mode 100644 index 0000000000..a30be8cd6e --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF014_RUF014.py.snap @@ -0,0 +1,249 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF014.py:3:5: RUF014 Unreachable code in after_return + | +1 | def after_return(): +2 | return "reachable" +3 | return "unreachable" + | ^^^^^^^^^^^^^^^^^^^^ RUF014 +4 | +5 | async def also_works_on_async_functions(): + | + +RUF014.py:7:5: RUF014 Unreachable code in also_works_on_async_functions + | +5 | async def also_works_on_async_functions(): +6 | return "reachable" +7 | return "unreachable" + | ^^^^^^^^^^^^^^^^^^^^ RUF014 +8 | +9 | def if_always_true(): + | + +RUF014.py:12:5: RUF014 Unreachable code in if_always_true + | +10 | if True: +11 | return "reachable" +12 | return "unreachable" + | ^^^^^^^^^^^^^^^^^^^^ RUF014 +13 | +14 | def if_always_false(): + | + +RUF014.py:16:9: RUF014 Unreachable code in if_always_false + | +14 | def if_always_false(): +15 | if False: +16 | return "unreachable" + | ^^^^^^^^^^^^^^^^^^^^ RUF014 +17 | return "reachable" + | + +RUF014.py:21:9: RUF014 Unreachable code in if_elif_always_false + | +19 | def if_elif_always_false(): +20 | if False: +21 | return "unreachable" + | ^^^^^^^^^^^^^^^^^^^^ RUF014 +22 | elif False: +23 | return "also unreachable" + | + +RUF014.py:23:9: RUF014 Unreachable code in if_elif_always_false + | +21 | return "unreachable" +22 | elif False: +23 | return "also unreachable" + | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF014 +24 | return "reachable" + | + +RUF014.py:28:9: RUF014 Unreachable code in if_elif_always_true + | +26 | def if_elif_always_true(): +27 | if False: +28 | return "unreachable" + | ^^^^^^^^^^^^^^^^^^^^ RUF014 +29 | elif True: +30 | return "reachable" + | + +RUF014.py:31:5: RUF014 Unreachable code in if_elif_always_true + | +29 | elif True: +30 | return "reachable" +31 | return "also unreachable" + | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF014 +32 | +33 | def ends_with_if(): + | + +RUF014.py:35:9: RUF014 Unreachable code in ends_with_if + | +33 | def ends_with_if(): +34 | if False: +35 | return "unreachable" + | ^^^^^^^^^^^^^^^^^^^^ RUF014 +36 | else: +37 | return "reachable" + | + +RUF014.py:42:5: RUF014 Unreachable code in infinite_loop + | +40 | while True: +41 | continue +42 | return "unreachable" + | ^^^^^^^^^^^^^^^^^^^^ RUF014 +43 | +44 | ''' TODO: we could determine these, but we don't yet. + | + +RUF014.py:75:5: RUF014 Unreachable code in match_wildcard + | +73 | case _: +74 | return "reachable" +75 | return "unreachable" + | ^^^^^^^^^^^^^^^^^^^^ RUF014 +76 | +77 | def match_case_and_wildcard(status): + | + +RUF014.py:83:5: RUF014 Unreachable code in match_case_and_wildcard + | +81 | case _: +82 | return "reachable" +83 | return "unreachable" + | ^^^^^^^^^^^^^^^^^^^^ RUF014 +84 | +85 | def raise_exception(): + | + +RUF014.py:87:5: RUF014 Unreachable code in raise_exception + | +85 | def raise_exception(): +86 | raise Exception +87 | return "unreachable" + | ^^^^^^^^^^^^^^^^^^^^ RUF014 +88 | +89 | def while_false(): + | + +RUF014.py:91:9: RUF014 Unreachable code in while_false + | +89 | def while_false(): +90 | while False: +91 | return "unreachable" + | ^^^^^^^^^^^^^^^^^^^^ RUF014 +92 | return "reachable" + | + +RUF014.py:96:9: RUF014 Unreachable code in while_false_else + | +94 | def while_false_else(): +95 | while False: +96 | return "unreachable" + | ^^^^^^^^^^^^^^^^^^^^ RUF014 +97 | else: +98 | return "reachable" + | + +RUF014.py:102:9: RUF014 Unreachable code in while_false_else_return + | +100 | def while_false_else_return(): +101 | while False: +102 | return "unreachable" + | ^^^^^^^^^^^^^^^^^^^^ RUF014 +103 | else: +104 | return "reachable" + | + +RUF014.py:105:5: RUF014 Unreachable code in while_false_else_return + | +103 | else: +104 | return "reachable" +105 | return "also unreachable" + | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF014 +106 | +107 | def while_true(): + | + +RUF014.py:110:5: RUF014 Unreachable code in while_true + | +108 | while True: +109 | return "reachable" +110 | return "unreachable" + | ^^^^^^^^^^^^^^^^^^^^ RUF014 +111 | +112 | def while_true_else(): + | + +RUF014.py:116:9: RUF014 Unreachable code in while_true_else + | +114 | return "reachable" +115 | else: +116 | return "unreachable" + | ^^^^^^^^^^^^^^^^^^^^ RUF014 +117 | +118 | def while_true_else_return(): + | + +RUF014.py:122:9: RUF014 Unreachable code in while_true_else_return + | +120 | return "reachable" +121 | else: +122 | return "unreachable" + | ^^^^^^^^^^^^^^^^^^^^ RUF014 +123 | return "also unreachable" + | + +RUF014.py:123:5: RUF014 Unreachable code in while_true_else_return + | +121 | else: +122 | return "unreachable" +123 | return "also unreachable" + | ^^^^^^^^^^^^^^^^^^^^^^^^^ RUF014 +124 | +125 | def while_false_var_i(): + | + +RUF014.py:128:9: RUF014 Unreachable code in while_false_var_i + | +126 | i = 0 +127 | while False: +128 | i += 1 + | ^^^^^^ RUF014 +129 | return i + | + +RUF014.py:135:5: RUF014 Unreachable code in while_true_var_i + | +133 | while True: +134 | i += 1 +135 | return i + | ^^^^^^^^ RUF014 +136 | +137 | def while_infinite(): + | + +RUF014.py:140:5: RUF014 Unreachable code in while_infinite + | +138 | while True: +139 | pass +140 | return "unreachable" + | ^^^^^^^^^^^^^^^^^^^^ RUF014 +141 | +142 | def while_if_true(): + | + +RUF014.py:146:5: RUF014 Unreachable code in while_if_true + | +144 | if True: +145 | return "reachable" +146 | return "unreachable" + | ^^^^^^^^^^^^^^^^^^^^ RUF014 +147 | +148 | # Test case found in the Bokeh repository that trigger a false positive. + | + + 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 new file mode 100644 index 0000000000..6e7933a411 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF015_RUF015.py.snap @@ -0,0 +1,254 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF015.py:4:1: RUF015 [*] Prefer `next(iter(x))` over single element slice + | +3 | # RUF015 +4 | list(x)[0] + | ^^^^^^^^^^ RUF015 +5 | tuple(x)[0] +6 | list(i for i in x)[0] + | + = help: Replace with `next(iter(x))` + +ℹ Suggested fix +1 1 | x = range(10) +2 2 | +3 3 | # RUF015 +4 |-list(x)[0] + 4 |+next(iter(x)) +5 5 | tuple(x)[0] +6 6 | list(i for i in x)[0] +7 7 | [i for i in x][0] + +RUF015.py:5:1: RUF015 [*] Prefer `next(iter(x))` over single element slice + | +3 | # RUF015 +4 | list(x)[0] +5 | tuple(x)[0] + | ^^^^^^^^^^^ RUF015 +6 | list(i for i in x)[0] +7 | [i for i in x][0] + | + = help: Replace with `next(iter(x))` + +ℹ Suggested fix +2 2 | +3 3 | # RUF015 +4 4 | list(x)[0] +5 |-tuple(x)[0] + 5 |+next(iter(x)) +6 6 | list(i for i in x)[0] +7 7 | [i for i in x][0] +8 8 | + +RUF015.py:6:1: RUF015 [*] Prefer `next(iter(x))` over single element slice + | +4 | list(x)[0] +5 | tuple(x)[0] +6 | list(i for i in x)[0] + | ^^^^^^^^^^^^^^^^^^^^^ RUF015 +7 | [i for i in x][0] + | + = help: Replace with `next(iter(x))` + +ℹ Suggested fix +3 3 | # RUF015 +4 4 | list(x)[0] +5 5 | tuple(x)[0] +6 |-list(i for i in x)[0] + 6 |+next(iter(x)) +7 7 | [i for i in x][0] +8 8 | +9 9 | # OK (not indexing (solely) the first element) + +RUF015.py:7:1: RUF015 [*] Prefer `next(iter(x))` over single element slice + | +5 | tuple(x)[0] +6 | list(i for i in x)[0] +7 | [i for i in x][0] + | ^^^^^^^^^^^^^^^^^ RUF015 +8 | +9 | # OK (not indexing (solely) the first element) + | + = help: Replace with `next(iter(x))` + +ℹ Suggested fix +4 4 | list(x)[0] +5 5 | tuple(x)[0] +6 6 | list(i for i in x)[0] +7 |-[i for i in x][0] + 7 |+next(iter(x)) +8 8 | +9 9 | # OK (not indexing (solely) the first element) +10 10 | list(x) + +RUF015.py:29:1: RUF015 [*] Prefer `next(i + 1 for i in x)` over single element slice + | +28 | # RUF015 (doesn't mirror the underlying list) +29 | [i + 1 for i in x][0] + | ^^^^^^^^^^^^^^^^^^^^^ RUF015 +30 | [i for i in x if i > 5][0] +31 | [(i, i + 1) for i in x][0] + | + = help: Replace with `next(i + 1 for i in x)` + +ℹ Suggested fix +26 26 | [i for i in x][::] +27 27 | +28 28 | # RUF015 (doesn't mirror the underlying list) +29 |-[i + 1 for i in x][0] + 29 |+next(i + 1 for i in x) +30 30 | [i for i in x if i > 5][0] +31 31 | [(i, i + 1) for i in x][0] +32 32 | + +RUF015.py:30:1: RUF015 [*] Prefer `next(i for i in x if i > 5)` over single element slice + | +28 | # RUF015 (doesn't mirror the underlying list) +29 | [i + 1 for i in x][0] +30 | [i for i in x if i > 5][0] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF015 +31 | [(i, i + 1) for i in x][0] + | + = help: Replace with `next(i for i in x if i > 5)` + +ℹ Suggested fix +27 27 | +28 28 | # RUF015 (doesn't mirror the underlying list) +29 29 | [i + 1 for i in x][0] +30 |-[i for i in x if i > 5][0] + 30 |+next(i for i in x if i > 5) +31 31 | [(i, i + 1) for i in x][0] +32 32 | +33 33 | # RUF015 (multiple generators) + +RUF015.py:31:1: RUF015 [*] Prefer `next((i, i + 1) for i in x)` over single element slice + | +29 | [i + 1 for i in x][0] +30 | [i for i in x if i > 5][0] +31 | [(i, i + 1) for i in x][0] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF015 +32 | +33 | # RUF015 (multiple generators) + | + = help: Replace with `next((i, i + 1) for i in x)` + +ℹ Suggested fix +28 28 | # RUF015 (doesn't mirror the underlying list) +29 29 | [i + 1 for i in x][0] +30 30 | [i for i in x if i > 5][0] +31 |-[(i, i + 1) for i in x][0] + 31 |+next((i, i + 1) for i in x) +32 32 | +33 33 | # RUF015 (multiple generators) +34 34 | y = range(10) + +RUF015.py:35:1: RUF015 [*] Prefer `next(i + j for i in x for j in y)` over single element slice + | +33 | # RUF015 (multiple generators) +34 | y = range(10) +35 | [i + j for i in x for j in y][0] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF015 +36 | +37 | # RUF015 + | + = help: Replace with `next(i + j for i in x for j in y)` + +ℹ Suggested fix +32 32 | +33 33 | # RUF015 (multiple generators) +34 34 | y = range(10) +35 |-[i + j for i in x for j in y][0] + 35 |+next(i + j for i in x for j in y) +36 36 | +37 37 | # RUF015 +38 38 | list(range(10))[0] + +RUF015.py:38:1: RUF015 [*] Prefer `next(iter(range(10)))` over single element slice + | +37 | # RUF015 +38 | list(range(10))[0] + | ^^^^^^^^^^^^^^^^^^ RUF015 +39 | list(x.y)[0] +40 | list(x["y"])[0] + | + = help: Replace with `next(iter(range(10)))` + +ℹ Suggested fix +35 35 | [i + j for i in x for j in y][0] +36 36 | +37 37 | # RUF015 +38 |-list(range(10))[0] + 38 |+next(iter(range(10))) +39 39 | list(x.y)[0] +40 40 | list(x["y"])[0] +41 41 | + +RUF015.py:39:1: RUF015 [*] Prefer `next(iter(x.y))` over single element slice + | +37 | # RUF015 +38 | list(range(10))[0] +39 | list(x.y)[0] + | ^^^^^^^^^^^^ RUF015 +40 | list(x["y"])[0] + | + = help: Replace with `next(iter(x.y))` + +ℹ Suggested fix +36 36 | +37 37 | # RUF015 +38 38 | list(range(10))[0] +39 |-list(x.y)[0] + 39 |+next(iter(x.y)) +40 40 | list(x["y"])[0] +41 41 | +42 42 | # RUF015 (multi-line) + +RUF015.py:40:1: RUF015 [*] Prefer `next(iter(x["y"]))` over single element slice + | +38 | list(range(10))[0] +39 | list(x.y)[0] +40 | list(x["y"])[0] + | ^^^^^^^^^^^^^^^ RUF015 +41 | +42 | # RUF015 (multi-line) + | + = help: Replace with `next(iter(x["y"]))` + +ℹ Suggested fix +37 37 | # RUF015 +38 38 | list(range(10))[0] +39 39 | list(x.y)[0] +40 |-list(x["y"])[0] + 40 |+next(iter(x["y"])) +41 41 | +42 42 | # RUF015 (multi-line) +43 43 | revision_heads_map_ast = [ + +RUF015.py:43:26: RUF015 [*] Prefer `next(...)` over single element slice + | +42 | # RUF015 (multi-line) +43 | revision_heads_map_ast = [ + | __________________________^ +44 | | a +45 | | for a in revision_heads_map_ast_obj.body +46 | | if isinstance(a, ast.Assign) and a.targets[0].id == "REVISION_HEADS_MAP" +47 | | ][0] + | |____^ RUF015 + | + = help: Replace with `next(...)` + +ℹ Suggested fix +40 40 | list(x["y"])[0] +41 41 | +42 42 | # RUF015 (multi-line) +43 |-revision_heads_map_ast = [ + 43 |+revision_heads_map_ast = next( +44 44 | a +45 45 | for a in revision_heads_map_ast_obj.body +46 46 | if isinstance(a, ast.Assign) and a.targets[0].id == "REVISION_HEADS_MAP" +47 |-][0] + 47 |+) + + 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 new file mode 100644 index 0000000000..64f5e5f0d8 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF016_RUF016.py.snap @@ -0,0 +1,379 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF016.py:20:13: RUF016 Indexed access to type `str` uses type `str` instead of an integer or slice. + | +19 | # Should emit for invalid access on strings +20 | var = "abc"["x"] + | ^^^ RUF016 +21 | var = f"abc"["x"] + | + +RUF016.py:21:14: RUF016 Indexed access to type `str` uses type `str` instead of an integer or slice. + | +19 | # Should emit for invalid access on strings +20 | var = "abc"["x"] +21 | var = f"abc"["x"] + | ^^^ RUF016 +22 | +23 | # Should emit for invalid access on bytes + | + +RUF016.py:24:14: RUF016 Indexed access to type `bytes` uses type `str` instead of an integer or slice. + | +23 | # Should emit for invalid access on bytes +24 | var = b"abc"["x"] + | ^^^ RUF016 +25 | +26 | # Should emit for invalid access on lists and tuples + | + +RUF016.py:27:17: RUF016 Indexed access to type `list` uses type `str` instead of an integer or slice. + | +26 | # Should emit for invalid access on lists and tuples +27 | var = [1, 2, 3]["x"] + | ^^^ RUF016 +28 | var = (1, 2, 3)["x"] + | + +RUF016.py:28:17: RUF016 Indexed access to type `tuple` uses type `str` instead of an integer or slice. + | +26 | # Should emit for invalid access on lists and tuples +27 | var = [1, 2, 3]["x"] +28 | var = (1, 2, 3)["x"] + | ^^^ RUF016 +29 | +30 | # Should emit for invalid access on list comprehensions + | + +RUF016.py:31:30: RUF016 Indexed access to type `list comprehension` uses type `str` instead of an integer or slice. + | +30 | # Should emit for invalid access on list comprehensions +31 | var = [x for x in range(10)]["x"] + | ^^^ RUF016 +32 | +33 | # Should emit for invalid access using tuple + | + +RUF016.py:34:13: RUF016 Indexed access to type `str` uses type `tuple` instead of an integer or slice. + | +33 | # Should emit for invalid access using tuple +34 | var = "abc"[1, 2] + | ^^^^ RUF016 +35 | +36 | # Should emit for invalid access using string + | + +RUF016.py:37:14: RUF016 Indexed access to type `list` uses type `str` instead of an integer or slice. + | +36 | # Should emit for invalid access using string +37 | var = [1, 2]["x"] + | ^^^ RUF016 +38 | +39 | # Should emit for invalid access using float + | + +RUF016.py:40:14: RUF016 Indexed access to type `list` uses type `float` instead of an integer or slice. + | +39 | # Should emit for invalid access using float +40 | var = [1, 2][0.25] + | ^^^^ RUF016 +41 | +42 | # Should emit for invalid access using dict + | + +RUF016.py:43:14: RUF016 Indexed access to type `list` uses type `dict` instead of an integer or slice. + | +42 | # Should emit for invalid access using dict +43 | var = [1, 2][{"x": "y"}] + | ^^^^^^^^^^ RUF016 +44 | +45 | # Should emit for invalid access using dict comp + | + +RUF016.py:46:14: RUF016 Indexed access to type `list` uses type `dict comprehension` instead of an integer or slice. + | +45 | # Should emit for invalid access using dict comp +46 | var = [1, 2][{x: "y" for x in range(2)}] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF016 +47 | +48 | # Should emit for invalid access using list + | + +RUF016.py:49:14: RUF016 Indexed access to type `list` uses type `tuple` instead of an integer or slice. + | +48 | # Should emit for invalid access using list +49 | var = [1, 2][2, 3] + | ^^^^ RUF016 +50 | +51 | # Should emit for invalid access using list comp + | + +RUF016.py:52:14: RUF016 Indexed access to type `list` uses type `list comprehension` instead of an integer or slice. + | +51 | # Should emit for invalid access using list comp +52 | var = [1, 2][[x for x in range(2)]] + | ^^^^^^^^^^^^^^^^^^^^^ RUF016 +53 | +54 | # Should emit on invalid access using set + | + +RUF016.py:55:14: RUF016 Indexed access to type `list` uses type `set` instead of an integer or slice. + | +54 | # Should emit on invalid access using set +55 | var = [1, 2][{"x", "y"}] + | ^^^^^^^^^^ RUF016 +56 | +57 | # Should emit on invalid access using set comp + | + +RUF016.py:58:14: RUF016 Indexed access to type `list` uses type `set comprehension` instead of an integer or slice. + | +57 | # Should emit on invalid access using set comp +58 | var = [1, 2][{x for x in range(2)}] + | ^^^^^^^^^^^^^^^^^^^^^ RUF016 +59 | +60 | # Should emit on invalid access using bytes + | + +RUF016.py:61:14: RUF016 Indexed access to type `list` uses type `bytes` instead of an integer or slice. + | +60 | # Should emit on invalid access using bytes +61 | var = [1, 2][b"x"] + | ^^^^ RUF016 +62 | +63 | # Should emit for non-integer slice start + | + +RUF016.py:64:17: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer. + | +63 | # Should emit for non-integer slice start +64 | var = [1, 2, 3]["x":2] + | ^^^ RUF016 +65 | var = [1, 2, 3][f"x":2] +66 | var = [1, 2, 3][1.2:2] + | + +RUF016.py:65:17: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer. + | +63 | # Should emit for non-integer slice start +64 | var = [1, 2, 3]["x":2] +65 | var = [1, 2, 3][f"x":2] + | ^^^^ RUF016 +66 | var = [1, 2, 3][1.2:2] +67 | var = [1, 2, 3][{"x"}:2] + | + +RUF016.py:66:17: RUF016 Slice in indexed access to type `list` uses type `float` instead of an integer. + | +64 | var = [1, 2, 3]["x":2] +65 | var = [1, 2, 3][f"x":2] +66 | var = [1, 2, 3][1.2:2] + | ^^^ RUF016 +67 | var = [1, 2, 3][{"x"}:2] +68 | var = [1, 2, 3][{x for x in range(2)}:2] + | + +RUF016.py:67:17: RUF016 Slice in indexed access to type `list` uses type `set` instead of an integer. + | +65 | var = [1, 2, 3][f"x":2] +66 | var = [1, 2, 3][1.2:2] +67 | var = [1, 2, 3][{"x"}:2] + | ^^^^^ RUF016 +68 | var = [1, 2, 3][{x for x in range(2)}:2] +69 | var = [1, 2, 3][{"x": x for x in range(2)}:2] + | + +RUF016.py:68:17: RUF016 Slice in indexed access to type `list` uses type `set comprehension` instead of an integer. + | +66 | var = [1, 2, 3][1.2:2] +67 | var = [1, 2, 3][{"x"}:2] +68 | var = [1, 2, 3][{x for x in range(2)}:2] + | ^^^^^^^^^^^^^^^^^^^^^ RUF016 +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.py:69:17: RUF016 Slice in indexed access to type `list` uses type `dict comprehension` instead of an integer. + | +67 | var = [1, 2, 3][{"x"}:2] +68 | var = [1, 2, 3][{x for x in range(2)}:2] +69 | var = [1, 2, 3][{"x": x for x in range(2)}:2] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF016 +70 | var = [1, 2, 3][[x for x in range(2)]:2] + | + +RUF016.py:70:17: RUF016 Slice in indexed access to type `list` uses type `list comprehension` instead of an integer. + | +68 | var = [1, 2, 3][{x for x in range(2)}:2] +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 | +72 | # Should emit for non-integer slice end + | + +RUF016.py:73:19: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer. + | +72 | # Should emit for non-integer slice end +73 | var = [1, 2, 3][0:"x"] + | ^^^ RUF016 +74 | var = [1, 2, 3][0:f"x"] +75 | var = [1, 2, 3][0:1.2] + | + +RUF016.py:74:19: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer. + | +72 | # Should emit for non-integer slice end +73 | var = [1, 2, 3][0:"x"] +74 | var = [1, 2, 3][0:f"x"] + | ^^^^ RUF016 +75 | var = [1, 2, 3][0:1.2] +76 | var = [1, 2, 3][0:{"x"}] + | + +RUF016.py:75:19: RUF016 Slice in indexed access to type `list` uses type `float` instead of an integer. + | +73 | var = [1, 2, 3][0:"x"] +74 | var = [1, 2, 3][0:f"x"] +75 | var = [1, 2, 3][0:1.2] + | ^^^ RUF016 +76 | var = [1, 2, 3][0:{"x"}] +77 | var = [1, 2, 3][0:{x for x in range(2)}] + | + +RUF016.py:76:19: RUF016 Slice in indexed access to type `list` uses type `set` instead of an integer. + | +74 | var = [1, 2, 3][0:f"x"] +75 | var = [1, 2, 3][0:1.2] +76 | var = [1, 2, 3][0:{"x"}] + | ^^^^^ RUF016 +77 | var = [1, 2, 3][0:{x for x in range(2)}] +78 | var = [1, 2, 3][0:{"x": x for x in range(2)}] + | + +RUF016.py:77:19: RUF016 Slice in indexed access to type `list` uses type `set comprehension` instead of an integer. + | +75 | var = [1, 2, 3][0:1.2] +76 | var = [1, 2, 3][0:{"x"}] +77 | var = [1, 2, 3][0:{x for x in range(2)}] + | ^^^^^^^^^^^^^^^^^^^^^ RUF016 +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.py:78:19: RUF016 Slice in indexed access to type `list` uses type `dict comprehension` instead of an integer. + | +76 | var = [1, 2, 3][0:{"x"}] +77 | var = [1, 2, 3][0:{x for x in range(2)}] +78 | var = [1, 2, 3][0:{"x": x for x in range(2)}] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF016 +79 | var = [1, 2, 3][0:[x for x in range(2)]] + | + +RUF016.py:79:19: RUF016 Slice in indexed access to type `list` uses type `list comprehension` instead of an integer. + | +77 | var = [1, 2, 3][0:{x for x in range(2)}] +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 | +81 | # Should emit for non-integer slice step + | + +RUF016.py:82:21: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer. + | +81 | # Should emit for non-integer slice step +82 | var = [1, 2, 3][0:1:"x"] + | ^^^ RUF016 +83 | var = [1, 2, 3][0:1:f"x"] +84 | var = [1, 2, 3][0:1:1.2] + | + +RUF016.py:83:21: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer. + | +81 | # Should emit for non-integer slice step +82 | var = [1, 2, 3][0:1:"x"] +83 | var = [1, 2, 3][0:1:f"x"] + | ^^^^ RUF016 +84 | var = [1, 2, 3][0:1:1.2] +85 | var = [1, 2, 3][0:1:{"x"}] + | + +RUF016.py:84:21: RUF016 Slice in indexed access to type `list` uses type `float` instead of an integer. + | +82 | var = [1, 2, 3][0:1:"x"] +83 | var = [1, 2, 3][0:1:f"x"] +84 | var = [1, 2, 3][0:1:1.2] + | ^^^ RUF016 +85 | var = [1, 2, 3][0:1:{"x"}] +86 | var = [1, 2, 3][0:1:{x for x in range(2)}] + | + +RUF016.py:85:21: RUF016 Slice in indexed access to type `list` uses type `set` instead of an integer. + | +83 | var = [1, 2, 3][0:1:f"x"] +84 | var = [1, 2, 3][0:1:1.2] +85 | var = [1, 2, 3][0:1:{"x"}] + | ^^^^^ RUF016 +86 | var = [1, 2, 3][0:1:{x for x in range(2)}] +87 | var = [1, 2, 3][0:1:{"x": x for x in range(2)}] + | + +RUF016.py:86:21: RUF016 Slice in indexed access to type `list` uses type `set comprehension` instead of an integer. + | +84 | var = [1, 2, 3][0:1:1.2] +85 | var = [1, 2, 3][0:1:{"x"}] +86 | var = [1, 2, 3][0:1:{x for x in range(2)}] + | ^^^^^^^^^^^^^^^^^^^^^ RUF016 +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.py:87:21: RUF016 Slice in indexed access to type `list` uses type `dict comprehension` instead of an integer. + | +85 | var = [1, 2, 3][0:1:{"x"}] +86 | var = [1, 2, 3][0:1:{x for x in range(2)}] +87 | var = [1, 2, 3][0:1:{"x": x for x in range(2)}] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF016 +88 | var = [1, 2, 3][0:1:[x for x in range(2)]] + | + +RUF016.py:88:21: RUF016 Slice in indexed access to type `list` uses type `list comprehension` instead of an integer. + | +86 | var = [1, 2, 3][0:1:{x for x in range(2)}] +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 | +90 | # Should emit for non-integer slice start and end; should emit twice with specific ranges + | + +RUF016.py:91:17: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer. + | +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 | +93 | # Should emit once for repeated invalid access + | + +RUF016.py:91:21: RUF016 Slice in indexed access to type `list` uses type `str` instead of an integer. + | +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 | +93 | # Should emit once for repeated invalid access + | + +RUF016.py:94:17: RUF016 Indexed access to type `list` uses type `str` instead of an integer or slice. + | +93 | # Should emit once for repeated invalid access +94 | var = [1, 2, 3]["x"]["y"]["z"] + | ^^^ RUF016 +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.py.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017.py.snap new file mode 100644 index 0000000000..17f12d211c --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF017_RUF017.py.snap @@ -0,0 +1,150 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF017.py:5:1: RUF017 [*] Avoid quadratic list summation + | +4 | # RUF017 +5 | sum([x, y], start=[]) + | ^^^^^^^^^^^^^^^^^^^^^ RUF017 +6 | sum([x, y], []) +7 | sum([[1, 2, 3], [4, 5, 6]], start=[]) + | + = help: Replace with `functools.reduce` + +ℹ Suggested fix + 1 |+import functools + 2 |+import operator +1 3 | x = [1, 2, 3] +2 4 | y = [4, 5, 6] +3 5 | +4 6 | # RUF017 +5 |-sum([x, y], start=[]) + 7 |+functools.reduce(operator.iadd, [x, y], []) +6 8 | sum([x, y], []) +7 9 | sum([[1, 2, 3], [4, 5, 6]], start=[]) +8 10 | sum([[1, 2, 3], [4, 5, 6]], []) + +RUF017.py:6:1: RUF017 [*] Avoid quadratic list summation + | +4 | # RUF017 +5 | sum([x, y], start=[]) +6 | sum([x, y], []) + | ^^^^^^^^^^^^^^^ RUF017 +7 | sum([[1, 2, 3], [4, 5, 6]], start=[]) +8 | sum([[1, 2, 3], [4, 5, 6]], []) + | + = help: Replace with `functools.reduce` + +ℹ Suggested fix + 1 |+import functools + 2 |+import operator +1 3 | x = [1, 2, 3] +2 4 | y = [4, 5, 6] +3 5 | +4 6 | # RUF017 +5 7 | sum([x, y], start=[]) +6 |-sum([x, y], []) + 8 |+functools.reduce(operator.iadd, [x, y], []) +7 9 | sum([[1, 2, 3], [4, 5, 6]], start=[]) +8 10 | sum([[1, 2, 3], [4, 5, 6]], []) +9 11 | sum([[1, 2, 3], [4, 5, 6]], + +RUF017.py:7:1: RUF017 [*] Avoid quadratic list summation + | +5 | sum([x, y], start=[]) +6 | sum([x, y], []) +7 | sum([[1, 2, 3], [4, 5, 6]], start=[]) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF017 +8 | sum([[1, 2, 3], [4, 5, 6]], []) +9 | sum([[1, 2, 3], [4, 5, 6]], + | + = help: Replace with `functools.reduce` + +ℹ Suggested fix + 1 |+import functools + 2 |+import operator +1 3 | x = [1, 2, 3] +2 4 | y = [4, 5, 6] +3 5 | +4 6 | # RUF017 +5 7 | sum([x, y], start=[]) +6 8 | sum([x, y], []) +7 |-sum([[1, 2, 3], [4, 5, 6]], start=[]) + 9 |+functools.reduce(operator.iadd, [[1, 2, 3], [4, 5, 6]], []) +8 10 | sum([[1, 2, 3], [4, 5, 6]], []) +9 11 | sum([[1, 2, 3], [4, 5, 6]], +10 12 | []) + +RUF017.py:8:1: RUF017 [*] Avoid quadratic list summation + | + 6 | sum([x, y], []) + 7 | sum([[1, 2, 3], [4, 5, 6]], start=[]) + 8 | sum([[1, 2, 3], [4, 5, 6]], []) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF017 + 9 | sum([[1, 2, 3], [4, 5, 6]], +10 | []) + | + = help: Replace with `functools.reduce` + +ℹ Suggested fix + 1 |+import functools + 2 |+import operator +1 3 | x = [1, 2, 3] +2 4 | y = [4, 5, 6] +3 5 | +-------------------------------------------------------------------------------- +5 7 | sum([x, y], start=[]) +6 8 | sum([x, y], []) +7 9 | sum([[1, 2, 3], [4, 5, 6]], start=[]) +8 |-sum([[1, 2, 3], [4, 5, 6]], []) + 10 |+functools.reduce(operator.iadd, [[1, 2, 3], [4, 5, 6]], []) +9 11 | sum([[1, 2, 3], [4, 5, 6]], +10 12 | []) +11 13 | + +RUF017.py:9:1: RUF017 [*] Avoid quadratic list summation + | + 7 | sum([[1, 2, 3], [4, 5, 6]], start=[]) + 8 | sum([[1, 2, 3], [4, 5, 6]], []) + 9 | / sum([[1, 2, 3], [4, 5, 6]], +10 | | []) + | |_______^ RUF017 +11 | +12 | # OK + | + = help: Replace with `functools.reduce` + +ℹ Suggested fix + 1 |+import functools + 2 |+import operator +1 3 | x = [1, 2, 3] +2 4 | y = [4, 5, 6] +3 5 | +-------------------------------------------------------------------------------- +6 8 | sum([x, y], []) +7 9 | sum([[1, 2, 3], [4, 5, 6]], start=[]) +8 10 | sum([[1, 2, 3], [4, 5, 6]], []) +9 |-sum([[1, 2, 3], [4, 5, 6]], +10 |- []) + 11 |+functools.reduce(operator.iadd, [[1, 2, 3], [4, 5, 6]], []) +11 12 | +12 13 | # OK +13 14 | sum([x, y]) + +RUF017.py:21:5: RUF017 [*] Avoid quadratic list summation + | +19 | import functools, operator +20 | +21 | sum([x, y], []) + | ^^^^^^^^^^^^^^^ RUF017 + | + = help: Replace with `functools.reduce` + +ℹ Suggested fix +18 18 | def func(): +19 19 | import functools, operator +20 20 | +21 |- sum([x, y], []) + 21 |+ functools.reduce(operator.iadd, [x, y], []) + + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_bleach.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_bleach.snap new file mode 100644 index 0000000000..7d974f8ffe --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_bleach.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +pyproject.toml:5:16: RUF200 Failed to parse pyproject.toml: Version specifier `>=1.1.0<1.2` doesn't match PEP 440 rules +tinycss2>=1.1.0<1.2 + ^^^^^^^^^^^ + | +3 | version = "0.1.0" +4 | # There's a comma missing here +5 | dependencies = [ + | ________________^ +6 | | "tinycss2>=1.1.0<1.2", +7 | | ] + | |_^ RUF200 + | + + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_invalid_author.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_invalid_author.snap new file mode 100644 index 0000000000..5ce8729604 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_invalid_author.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +pyproject.toml:6:84: RUF200 Failed to parse pyproject.toml: invalid type: integer `1`, expected a string + | +4 | # Ensure that the spans from toml handle utf-8 correctly +5 | authors = [ +6 | { name = "Z͑ͫ̓ͪ̂ͫ̽͏̴̙̤̞͉͚̯̞̠͍A̴̵̜̰͔ͫ͗͢L̠ͨͧͩ͘G̴̻͈͍͔̹̑͗̎̅͛́Ǫ̵̹̻̝̳͂̌̌͘", email = 1 } + | ^ RUF200 +7 | ] + | + + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_maturin.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_maturin.snap new file mode 100644 index 0000000000..7f58cfd724 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_maturin.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_maturin_gh_1615.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_maturin_gh_1615.snap new file mode 100644 index 0000000000..8d9104c7ec --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__RUF200_maturin_gh_1615.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +pyproject.toml:9:17: RUF200 Failed to parse pyproject.toml: wanted string or table + | + 7 | [project] + 8 | name = "..." + 9 | license-files = [ "license.txt",] + | ^^^^^^^^^^^^^^^^^ RUF200 +10 | requires-python = ">=3.8" +11 | requires-dist = [ "maturin>=0.14", "...",] + | + + 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 new file mode 100644 index 0000000000..db682dfb23 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__confusables.snap @@ -0,0 +1,62 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +confusables.py:1:6: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? + | +1 | x = "𝐁ad string" + | ^ RUF001 +2 | y = "−" + | + +confusables.py:6:56: RUF002 Docstring contains ambiguous `)` (FULLWIDTH RIGHT PARENTHESIS). Did you mean `)` (RIGHT PARENTHESIS)? + | +5 | def f(): +6 | """Here's a docstring with an unusual parenthesis: )""" + | ^^ RUF002 +7 | # And here's a comment with an unusual punctuation mark: ᜵ +8 | ... + | + +confusables.py:7:62: RUF003 Comment contains ambiguous `᜵` (PHILIPPINE SINGLE PUNCTUATION). Did you mean `/` (SOLIDUS)? + | +5 | def f(): +6 | """Here's a docstring with an unusual parenthesis: )""" +7 | # And here's a comment with an unusual punctuation mark: ᜵ + | ^ RUF003 +8 | ... + | + +confusables.py:17:6: RUF001 String contains ambiguous `𝐁` (MATHEMATICAL BOLD CAPITAL B). Did you mean `B` (LATIN CAPITAL LETTER B)? + | +17 | x = "𝐁ad string" + | ^ RUF001 +18 | x = "−" + | + +confusables.py:26:10: RUF001 String contains ambiguous `α` (GREEK SMALL LETTER ALPHA). Did you mean `a` (LATIN SMALL LETTER A)? + | +24 | # The first word should be ignored, while the second should be included, since it +25 | # contains ASCII. +26 | x = "βα Bαd" + | ^ RUF001 +27 | +28 | # The two characters should be flagged here. The first character is a "word" + | + +confusables.py:31:6: RUF001 String contains ambiguous `Р` (CYRILLIC CAPITAL LETTER ER). Did you mean `P` (LATIN CAPITAL LETTER P)? + | +29 | # consisting of a single ambiguous character, while the second character is a "word +30 | # boundary" (whitespace) that it itself ambiguous. +31 | x = "Р усский" + | ^ RUF001 + | + +confusables.py:31:7: RUF001 String contains ambiguous ` ` (EN QUAD). Did you mean ` ` (SPACE)? + | +29 | # consisting of a single ambiguous character, while the second character is a "word +30 | # boundary" (whitespace) that it itself ambiguous. +31 | x = "Р усский" + | ^ RUF001 + | + + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__flake8_noqa.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__flake8_noqa.snap new file mode 100644 index 0000000000..7f58cfd724 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__flake8_noqa.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__noqa.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__noqa.snap new file mode 100644 index 0000000000..17d3c4a376 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__noqa.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +noqa.py:23:5: F841 [*] Local variable `I` is assigned to but never used + | +21 | def f(): +22 | # Only `E741` should be ignored by the `noqa`. +23 | I = 1 # noqa: E741.F841 + | ^ F841 + | + = help: Remove assignment to unused variable `I` + +ℹ Suggested fix +20 20 | +21 21 | def f(): +22 22 | # Only `E741` should be ignored by the `noqa`. +23 |- I = 1 # noqa: E741.F841 + 23 |+ pass # noqa: E741.F841 + + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__redirects.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__redirects.snap new file mode 100644 index 0000000000..7f58cfd724 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__redirects.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- + 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 new file mode 100644 index 0000000000..ab6ee7ff6f --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_0.snap @@ -0,0 +1,267 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF100_0.py:9:12: RUF100 [*] Unused blanket `noqa` directive + | + 8 | # Invalid + 9 | c = 1 # noqa + | ^^^^^^ RUF100 +10 | print(c) + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +6 6 | b = 2 # noqa: F841 +7 7 | +8 8 | # Invalid +9 |- c = 1 # noqa + 9 |+ c = 1 +10 10 | print(c) +11 11 | +12 12 | # Invalid + +RUF100_0.py:13:12: RUF100 [*] Unused `noqa` directive (unused: `E501`) + | +12 | # Invalid +13 | d = 1 # noqa: E501 + | ^^^^^^^^^^^^ RUF100 +14 | +15 | # Invalid + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +10 10 | print(c) +11 11 | +12 12 | # Invalid +13 |- d = 1 # noqa: E501 + 13 |+ d = 1 +14 14 | +15 15 | # Invalid +16 16 | d = 1 # noqa: F841, E501 + +RUF100_0.py:16:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `E501`) + | +15 | # Invalid +16 | d = 1 # noqa: F841, E501 + | ^^^^^^^^^^^^^^^^^^ RUF100 +17 | +18 | # Invalid (and unimplemented or not enabled) + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +13 13 | d = 1 # noqa: E501 +14 14 | +15 15 | # Invalid +16 |- d = 1 # noqa: F841, E501 + 16 |+ d = 1 +17 17 | +18 18 | # Invalid (and unimplemented or not enabled) +19 19 | d = 1 # noqa: F841, W191, F821 + +RUF100_0.py:19:12: RUF100 [*] Unused `noqa` directive (unused: `F841`, `W191`; non-enabled: `F821`) + | +18 | # Invalid (and unimplemented or not enabled) +19 | d = 1 # noqa: F841, W191, F821 + | ^^^^^^^^^^^^^^^^^^^^^^^^ RUF100 +20 | +21 | # Invalid (but external) + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +16 16 | d = 1 # noqa: F841, E501 +17 17 | +18 18 | # Invalid (and unimplemented or not enabled) +19 |- d = 1 # noqa: F841, W191, F821 + 19 |+ d = 1 +20 20 | +21 21 | # Invalid (but external) +22 22 | d = 1 # noqa: F841, V101 + +RUF100_0.py:22:12: RUF100 [*] Unused `noqa` directive (unused: `F841`) + | +21 | # Invalid (but external) +22 | d = 1 # noqa: F841, V101 + | ^^^^^^^^^^^^^^^^^^ RUF100 +23 | +24 | # fmt: off + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +19 19 | d = 1 # noqa: F841, W191, F821 +20 20 | +21 21 | # Invalid (but external) +22 |- d = 1 # noqa: F841, V101 + 22 |+ d = 1 # noqa: V101 +23 23 | +24 24 | # fmt: off +25 25 | # Invalid - no space before # + +RUF100_0.py:26:10: RUF100 [*] Unused `noqa` directive (unused: `E501`) + | +24 | # fmt: off +25 | # Invalid - no space before # +26 | d = 1# noqa: E501 + | ^^^^^^^^^^^^ RUF100 +27 | +28 | # Invalid - many spaces before # + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +23 23 | +24 24 | # fmt: off +25 25 | # Invalid - no space before # +26 |- d = 1# noqa: E501 + 26 |+ d = 1 +27 27 | +28 28 | # Invalid - many spaces before # +29 29 | d = 1 # noqa: E501 + +RUF100_0.py:29:5: F841 [*] Local variable `d` is assigned to but never used + | +28 | # Invalid - many spaces before # +29 | d = 1 # noqa: E501 + | ^ F841 +30 | # fmt: on + | + = help: Remove assignment to unused variable `d` + +ℹ Suggested fix +26 26 | d = 1# noqa: E501 +27 27 | +28 28 | # Invalid - many spaces before # +29 |- d = 1 # noqa: E501 +30 29 | # fmt: on +31 30 | +32 31 | + +RUF100_0.py:29:33: RUF100 [*] Unused `noqa` directive (unused: `E501`) + | +28 | # Invalid - many spaces before # +29 | d = 1 # noqa: E501 + | ^^^^^^^^^^^^ RUF100 +30 | # fmt: on + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +26 26 | d = 1# noqa: E501 +27 27 | +28 28 | # Invalid - many spaces before # +29 |- d = 1 # noqa: E501 + 29 |+ d = 1 +30 30 | # fmt: on +31 31 | +32 32 | + +RUF100_0.py:55:6: RUF100 [*] Unused `noqa` directive (unused: `F841`) + | +54 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. +55 | """ # noqa: E501, F841 + | ^^^^^^^^^^^^^^^^^^ RUF100 +56 | +57 | # Invalid + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +52 52 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 +53 53 | +54 54 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. +55 |-""" # noqa: E501, F841 + 55 |+""" # noqa: E501 +56 56 | +57 57 | # Invalid +58 58 | _ = """Lorem ipsum dolor sit amet. + +RUF100_0.py:63:6: RUF100 [*] Unused `noqa` directive (unused: `E501`) + | +62 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. +63 | """ # noqa: E501 + | ^^^^^^^^^^^^ RUF100 +64 | +65 | # Invalid + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +60 60 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 +61 61 | +62 62 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. +63 |-""" # noqa: E501 + 63 |+""" +64 64 | +65 65 | # Invalid +66 66 | _ = """Lorem ipsum dolor sit amet. + +RUF100_0.py:71:6: RUF100 [*] Unused blanket `noqa` directive + | +70 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. +71 | """ # noqa + | ^^^^^^ RUF100 +72 | +73 | # Valid + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +68 68 | https://github.com/PyCQA/pycodestyle/pull/258/files#diff-841c622497a8033d10152bfdfb15b20b92437ecdea21a260944ea86b77b51533 +69 69 | +70 70 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. +71 |-""" # noqa + 71 |+""" +72 72 | +73 73 | # Valid +74 74 | # this is a veryyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy long comment # noqa: E501 + +RUF100_0.py:85:8: F401 [*] `shelve` imported but unused + | +83 | import collections # noqa +84 | import os # noqa: F401, RUF100 +85 | import shelve # noqa: RUF100 + | ^^^^^^ F401 +86 | import sys # noqa: F401, RUF100 + | + = help: Remove unused import: `shelve` + +ℹ Fix +82 82 | +83 83 | import collections # noqa +84 84 | import os # noqa: F401, RUF100 +85 |-import shelve # noqa: RUF100 +86 85 | import sys # noqa: F401, RUF100 +87 86 | +88 87 | print(sys.path) + +RUF100_0.py:90:89: E501 Line too long (103 > 88 characters) + | +88 | print(sys.path) +89 | +90 | "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 + | + +RUF100_0.py:90:92: RUF100 [*] Unused `noqa` directive (unused: `F401`) + | +88 | print(sys.path) +89 | +90 | "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 + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +87 87 | +88 88 | print(sys.path) +89 89 | +90 |-"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 + 90 |+"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]" +91 91 | +92 92 | +93 93 | def f(): + + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_1.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_1.snap new file mode 100644 index 0000000000..288d46d007 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_1.snap @@ -0,0 +1,154 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF100_1.py:37:9: F401 [*] `typing.Union` imported but unused + | +35 | from typing import ( +36 | Mapping, # noqa: F401 +37 | Union, + | ^^^^^ F401 +38 | ) + | + = help: Remove unused import: `typing.Union` + +ℹ Fix +34 34 | # This should ignore the first error. +35 35 | from typing import ( +36 36 | Mapping, # noqa: F401 +37 |- Union, +38 |- ) + 37 |+ ) +39 38 | +40 39 | +41 40 | def f(): + +RUF100_1.py:52:20: RUF100 [*] Unused `noqa` directive (unused: `F401`) + | +50 | # This should ignore the error, but the inner noqa should be marked as unused. +51 | from typing import ( # noqa: F401 +52 | Optional, # noqa: F401 + | ^^^^^^^^^^^^ RUF100 +53 | ) + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +49 49 | def f(): +50 50 | # This should ignore the error, but the inner noqa should be marked as unused. +51 51 | from typing import ( # noqa: F401 +52 |- Optional, # noqa: F401 + 52 |+ Optional, +53 53 | ) +54 54 | +55 55 | + +RUF100_1.py:59:20: RUF100 [*] Unused `noqa` directive (unused: `F401`) + | +57 | # This should ignore the error, but the inner noqa should be marked as unused. +58 | from typing import ( # noqa +59 | Optional, # noqa: F401 + | ^^^^^^^^^^^^ RUF100 +60 | ) + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +56 56 | def f(): +57 57 | # This should ignore the error, but the inner noqa should be marked as unused. +58 58 | from typing import ( # noqa +59 |- Optional, # noqa: F401 + 59 |+ Optional, +60 60 | ) +61 61 | +62 62 | + +RUF100_1.py:66:16: RUF100 [*] Unused `noqa` directive (non-enabled: `F501`) + | +64 | # This should ignore the error, but mark F501 as unused. +65 | from typing import ( # noqa: F401 +66 | Dict, # noqa: F501 + | ^^^^^^^^^^^^ RUF100 +67 | ) + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +63 63 | def f(): +64 64 | # This should ignore the error, but mark F501 as unused. +65 65 | from typing import ( # noqa: F401 +66 |- Dict, # noqa: F501 + 66 |+ Dict, +67 67 | ) +68 68 | +69 69 | + +RUF100_1.py:72:27: RUF100 [*] Unused `noqa` directive (non-enabled: `F501`) + | +70 | def f(): +71 | # This should ignore the error, but mark F501 as unused. +72 | from typing import ( # noqa: F501 + | ^^^^^^^^^^^^ RUF100 +73 | Tuple, # noqa: F401 +74 | ) + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +69 69 | +70 70 | def f(): +71 71 | # This should ignore the error, but mark F501 as unused. +72 |- from typing import ( # noqa: F501 + 72 |+ from typing import ( +73 73 | Tuple, # noqa: F401 +74 74 | ) +75 75 | + +RUF100_1.py:89:24: F401 [*] `typing.Awaitable` imported but unused + | +87 | def f(): +88 | # This should mark F501 as unused. +89 | from typing import Awaitable, AwaitableGenerator # noqa: F501 + | ^^^^^^^^^ F401 + | + = help: Remove unused import + +ℹ Fix +86 86 | +87 87 | def f(): +88 88 | # This should mark F501 as unused. +89 |- from typing import Awaitable, AwaitableGenerator # noqa: F501 + 89 |+ pass # noqa: F501 + +RUF100_1.py:89:35: F401 [*] `typing.AwaitableGenerator` imported but unused + | +87 | def f(): +88 | # This should mark F501 as unused. +89 | from typing import Awaitable, AwaitableGenerator # noqa: F501 + | ^^^^^^^^^^^^^^^^^^ F401 + | + = help: Remove unused import + +ℹ Fix +86 86 | +87 87 | def f(): +88 88 | # This should mark F501 as unused. +89 |- from typing import Awaitable, AwaitableGenerator # noqa: F501 + 89 |+ pass # noqa: F501 + +RUF100_1.py:89:55: RUF100 [*] Unused `noqa` directive (non-enabled: `F501`) + | +87 | def f(): +88 | # This should mark F501 as unused. +89 | from typing import Awaitable, AwaitableGenerator # noqa: F501 + | ^^^^^^^^^^^^ RUF100 + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +86 86 | +87 87 | def f(): +88 88 | # This should mark F501 as unused. +89 |- from typing import Awaitable, AwaitableGenerator # noqa: F501 + 89 |+ from typing import Awaitable, AwaitableGenerator + + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_2.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_2.snap new file mode 100644 index 0000000000..3de393b1c9 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_2.snap @@ -0,0 +1,15 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF100_2.py:1:19: RUF100 [*] Unused `noqa` directive (unused: `F401`) + | +1 | import itertools # noqa: F401 + | ^^^^^^^^^^^^ RUF100 + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +1 |-import itertools # noqa: F401 + 1 |+import itertools + + 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 new file mode 100644 index 0000000000..f7c08b2403 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_3.snap @@ -0,0 +1,382 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF100_3.py:1:1: RUF100 [*] Unused blanket `noqa` directive + | +1 | # noqa + | ^^^^^^ RUF100 +2 | # noqa # comment +3 | print() # noqa + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +1 |-# noqa +2 1 | # noqa # comment +3 2 | print() # noqa +4 3 | print() # noqa # comment + +RUF100_3.py:2:1: RUF100 [*] Unused blanket `noqa` directive + | +1 | # noqa +2 | # noqa # comment + | ^^^^^^ RUF100 +3 | print() # noqa +4 | print() # noqa # comment + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +1 1 | # noqa +2 |-# noqa # comment + 2 |+# comment +3 3 | print() # noqa +4 4 | print() # noqa # comment +5 5 | print() # noqa # comment + +RUF100_3.py:3:10: RUF100 [*] Unused blanket `noqa` directive + | +1 | # noqa +2 | # noqa # comment +3 | print() # noqa + | ^^^^^^ RUF100 +4 | print() # noqa # comment +5 | print() # noqa # comment + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +1 1 | # noqa +2 2 | # noqa # comment +3 |-print() # noqa + 3 |+print() +4 4 | print() # noqa # comment +5 5 | print() # noqa # comment +6 6 | print() # noqa comment + +RUF100_3.py:4:10: RUF100 [*] Unused blanket `noqa` directive + | +2 | # noqa # comment +3 | print() # noqa +4 | print() # noqa # comment + | ^^^^^^ RUF100 +5 | print() # noqa # comment +6 | print() # noqa comment + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +1 1 | # noqa +2 2 | # noqa # comment +3 3 | print() # noqa +4 |-print() # noqa # comment + 4 |+print() # comment +5 5 | print() # noqa # comment +6 6 | print() # noqa comment +7 7 | print() # noqa comment + +RUF100_3.py:5:10: RUF100 [*] Unused blanket `noqa` directive + | +3 | print() # noqa +4 | print() # noqa # comment +5 | print() # noqa # comment + | ^^^^^^ RUF100 +6 | print() # noqa comment +7 | print() # noqa comment + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +2 2 | # noqa # comment +3 3 | print() # noqa +4 4 | print() # noqa # comment +5 |-print() # noqa # comment + 5 |+print() # comment +6 6 | print() # noqa comment +7 7 | print() # noqa comment +8 8 | print(a) # noqa + +RUF100_3.py:6:10: RUF100 [*] Unused blanket `noqa` directive + | +4 | print() # noqa # comment +5 | print() # noqa # comment +6 | print() # noqa comment + | ^^^^^^ RUF100 +7 | print() # noqa comment +8 | print(a) # noqa + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +3 3 | print() # noqa +4 4 | print() # noqa # comment +5 5 | print() # noqa # comment +6 |-print() # noqa comment + 6 |+print() # comment +7 7 | print() # noqa comment +8 8 | print(a) # noqa +9 9 | print(a) # noqa # comment + +RUF100_3.py:7:10: RUF100 [*] Unused blanket `noqa` directive + | +5 | print() # noqa # comment +6 | print() # noqa comment +7 | print() # noqa comment + | ^^^^^^ RUF100 +8 | print(a) # noqa +9 | print(a) # noqa # comment + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +4 4 | print() # noqa # comment +5 5 | print() # noqa # comment +6 6 | print() # noqa comment +7 |-print() # noqa comment + 7 |+print() # comment +8 8 | print(a) # noqa +9 9 | print(a) # noqa # comment +10 10 | print(a) # noqa # comment + +RUF100_3.py:14:1: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) + | +12 | print(a) # noqa comment +13 | +14 | # noqa: E501, F821 + | ^^^^^^^^^^^^^^^^^^ RUF100 +15 | # noqa: E501, F821 # comment +16 | print() # noqa: E501, F821 + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +11 11 | print(a) # noqa comment +12 12 | print(a) # noqa comment +13 13 | +14 |-# noqa: E501, F821 +15 14 | # noqa: E501, F821 # comment +16 15 | print() # noqa: E501, F821 +17 16 | print() # noqa: E501, F821 # comment + +RUF100_3.py:15:1: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) + | +14 | # noqa: E501, F821 +15 | # noqa: E501, F821 # comment + | ^^^^^^^^^^^^^^^^^^ RUF100 +16 | print() # noqa: E501, F821 +17 | print() # noqa: E501, F821 # comment + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +12 12 | print(a) # noqa comment +13 13 | +14 14 | # noqa: E501, F821 +15 |-# noqa: E501, F821 # comment + 15 |+# comment +16 16 | print() # noqa: E501, F821 +17 17 | print() # noqa: E501, F821 # comment +18 18 | print() # noqa: E501, F821 # comment + +RUF100_3.py:16:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) + | +14 | # noqa: E501, F821 +15 | # noqa: E501, F821 # comment +16 | print() # noqa: E501, F821 + | ^^^^^^^^^^^^^^^^^^ RUF100 +17 | print() # noqa: E501, F821 # comment +18 | print() # noqa: E501, F821 # comment + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +13 13 | +14 14 | # noqa: E501, F821 +15 15 | # noqa: E501, F821 # comment +16 |-print() # noqa: E501, F821 + 16 |+print() +17 17 | print() # noqa: E501, F821 # comment +18 18 | print() # noqa: E501, F821 # comment +19 19 | print() # noqa: E501, F821 comment + +RUF100_3.py:17:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) + | +15 | # noqa: E501, F821 # comment +16 | print() # noqa: E501, F821 +17 | print() # noqa: E501, F821 # comment + | ^^^^^^^^^^^^^^^^^^ RUF100 +18 | print() # noqa: E501, F821 # comment +19 | print() # noqa: E501, F821 comment + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +14 14 | # noqa: E501, F821 +15 15 | # noqa: E501, F821 # comment +16 16 | print() # noqa: E501, F821 +17 |-print() # noqa: E501, F821 # comment + 17 |+print() # comment +18 18 | print() # noqa: E501, F821 # comment +19 19 | print() # noqa: E501, F821 comment +20 20 | print() # noqa: E501, F821 comment + +RUF100_3.py:18:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) + | +16 | print() # noqa: E501, F821 +17 | print() # noqa: E501, F821 # comment +18 | print() # noqa: E501, F821 # comment + | ^^^^^^^^^^^^^^^^^^ RUF100 +19 | print() # noqa: E501, F821 comment +20 | print() # noqa: E501, F821 comment + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +15 15 | # noqa: E501, F821 # comment +16 16 | print() # noqa: E501, F821 +17 17 | print() # noqa: E501, F821 # comment +18 |-print() # noqa: E501, F821 # comment + 18 |+print() # comment +19 19 | print() # noqa: E501, F821 comment +20 20 | print() # noqa: E501, F821 comment +21 21 | print(a) # noqa: E501, F821 + +RUF100_3.py:19:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) + | +17 | print() # noqa: E501, F821 # comment +18 | print() # noqa: E501, F821 # comment +19 | print() # noqa: E501, F821 comment + | ^^^^^^^^^^^^^^^^^^ RUF100 +20 | print() # noqa: E501, F821 comment +21 | print(a) # noqa: E501, F821 + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +16 16 | print() # noqa: E501, F821 +17 17 | print() # noqa: E501, F821 # comment +18 18 | print() # noqa: E501, F821 # comment +19 |-print() # noqa: E501, F821 comment + 19 |+print() # comment +20 20 | print() # noqa: E501, F821 comment +21 21 | print(a) # noqa: E501, F821 +22 22 | print(a) # noqa: E501, F821 # comment + +RUF100_3.py:20:10: RUF100 [*] Unused `noqa` directive (unused: `E501`, `F821`) + | +18 | print() # noqa: E501, F821 # comment +19 | print() # noqa: E501, F821 comment +20 | print() # noqa: E501, F821 comment + | ^^^^^^^^^^^^^^^^^^ RUF100 +21 | print(a) # noqa: E501, F821 +22 | print(a) # noqa: E501, F821 # comment + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +17 17 | print() # noqa: E501, F821 # comment +18 18 | print() # noqa: E501, F821 # comment +19 19 | print() # noqa: E501, F821 comment +20 |-print() # noqa: E501, F821 comment + 20 |+print() # comment +21 21 | print(a) # noqa: E501, F821 +22 22 | print(a) # noqa: E501, F821 # comment +23 23 | print(a) # noqa: E501, F821 # comment + +RUF100_3.py:21:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) + | +19 | print() # noqa: E501, F821 comment +20 | print() # noqa: E501, F821 comment +21 | print(a) # noqa: E501, F821 + | ^^^^^^^^^^^^^^^^^^ RUF100 +22 | print(a) # noqa: E501, F821 # comment +23 | print(a) # noqa: E501, F821 # comment + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +18 18 | print() # noqa: E501, F821 # comment +19 19 | print() # noqa: E501, F821 comment +20 20 | print() # noqa: E501, F821 comment +21 |-print(a) # noqa: E501, F821 + 21 |+print(a) # noqa: F821 +22 22 | print(a) # noqa: E501, F821 # comment +23 23 | print(a) # noqa: E501, F821 # comment +24 24 | print(a) # noqa: E501, F821 comment + +RUF100_3.py:22:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) + | +20 | print() # noqa: E501, F821 comment +21 | print(a) # noqa: E501, F821 +22 | print(a) # noqa: E501, F821 # comment + | ^^^^^^^^^^^^^^^^^^ RUF100 +23 | print(a) # noqa: E501, F821 # comment +24 | print(a) # noqa: E501, F821 comment + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +19 19 | print() # noqa: E501, F821 comment +20 20 | print() # noqa: E501, F821 comment +21 21 | print(a) # noqa: E501, F821 +22 |-print(a) # noqa: E501, F821 # comment + 22 |+print(a) # noqa: F821 # comment +23 23 | print(a) # noqa: E501, F821 # comment +24 24 | print(a) # noqa: E501, F821 comment +25 25 | print(a) # noqa: E501, F821 comment + +RUF100_3.py:23:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) + | +21 | print(a) # noqa: E501, F821 +22 | print(a) # noqa: E501, F821 # comment +23 | print(a) # noqa: E501, F821 # comment + | ^^^^^^^^^^^^^^^^^^ RUF100 +24 | print(a) # noqa: E501, F821 comment +25 | print(a) # noqa: E501, F821 comment + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +20 20 | print() # noqa: E501, F821 comment +21 21 | print(a) # noqa: E501, F821 +22 22 | print(a) # noqa: E501, F821 # comment +23 |-print(a) # noqa: E501, F821 # comment + 23 |+print(a) # noqa: F821 # comment +24 24 | print(a) # noqa: E501, F821 comment +25 25 | print(a) # noqa: E501, F821 comment + +RUF100_3.py:24:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) + | +22 | print(a) # noqa: E501, F821 # comment +23 | print(a) # noqa: E501, F821 # comment +24 | print(a) # noqa: E501, F821 comment + | ^^^^^^^^^^^^^^^^^^ RUF100 +25 | print(a) # noqa: E501, F821 comment + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +21 21 | print(a) # noqa: E501, F821 +22 22 | print(a) # noqa: E501, F821 # comment +23 23 | print(a) # noqa: E501, F821 # comment +24 |-print(a) # noqa: E501, F821 comment + 24 |+print(a) # noqa: F821 comment +25 25 | print(a) # noqa: E501, F821 comment + +RUF100_3.py:25:11: RUF100 [*] Unused `noqa` directive (unused: `E501`) + | +23 | print(a) # noqa: E501, F821 # comment +24 | print(a) # noqa: E501, F821 comment +25 | print(a) # noqa: E501, F821 comment + | ^^^^^^^^^^^^^^^^^^ RUF100 + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +22 22 | print(a) # noqa: E501, F821 # comment +23 23 | print(a) # noqa: E501, F821 # comment +24 24 | print(a) # noqa: E501, F821 comment +25 |-print(a) # noqa: E501, F821 comment + 25 |+print(a) # noqa: F821 comment + + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_4.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_4.snap new file mode 100644 index 0000000000..7f58cfd724 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_4.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- + 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 new file mode 100644 index 0000000000..0808aaab05 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruf100_5.snap @@ -0,0 +1,50 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +RUF100_5.py:7:5: ERA001 [*] Found commented-out code + | +5 | # "key1": 123, # noqa: ERA001 +6 | # "key2": 456, # noqa +7 | # "key3": 789, + | ^^^^^^^^^^^^^^ ERA001 +8 | } + | + = help: Remove commented-out code + +ℹ Possible fix +4 4 | dictionary = { +5 5 | # "key1": 123, # noqa: ERA001 +6 6 | # "key2": 456, # noqa +7 |- # "key3": 789, +8 7 | } +9 8 | +10 9 | + +RUF100_5.py:11:1: ERA001 [*] Found commented-out code + | +11 | #import os # noqa: E501 + | ^^^^^^^^^^^^^^^^^^^^^^^^ ERA001 + | + = help: Remove commented-out code + +ℹ Possible fix +8 8 | } +9 9 | +10 10 | +11 |-#import os # noqa: E501 + +RUF100_5.py:11:13: RUF100 [*] Unused `noqa` directive (unused: `E501`) + | +11 | #import os # noqa: E501 + | ^^^^^^^^^^^^ RUF100 + | + = help: Remove unused `noqa` directive + +ℹ Suggested fix +8 8 | } +9 9 | +10 10 | +11 |-#import os # noqa: E501 + 11 |+#import os + + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_all.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_all.snap new file mode 100644 index 0000000000..7f58cfd724 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_all.snap @@ -0,0 +1,4 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_codes.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_codes.snap new file mode 100644 index 0000000000..974eba08c4 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_codes.snap @@ -0,0 +1,19 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +ruff_noqa_codes.py:8:5: F841 [*] Local variable `x` is assigned to but never used + | +7 | def f(): +8 | x = 1 + | ^ F841 + | + = help: Remove assignment to unused variable `x` + +ℹ Suggested fix +5 5 | +6 6 | +7 7 | def f(): +8 |- x = 1 + 8 |+ pass + + diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_invalid.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_invalid.snap new file mode 100644 index 0000000000..c267b245b6 --- /dev/null +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__ruff_noqa_invalid.snap @@ -0,0 +1,32 @@ +--- +source: crates/ruff_linter/src/rules/ruff/mod.rs +--- +ruff_noqa_invalid.py:1:8: F401 [*] `os` imported but unused + | +1 | import os # ruff: noqa: F401 + | ^^ F401 + | + = help: Remove unused import: `os` + +ℹ Fix +1 |-import os # ruff: noqa: F401 +2 1 | +3 2 | +4 3 | def f(): + +ruff_noqa_invalid.py:5:5: F841 [*] Local variable `x` is assigned to but never used + | +4 | def f(): +5 | x = 1 + | ^ F841 + | + = help: Remove assignment to unused variable `x` + +ℹ Suggested fix +2 2 | +3 3 | +4 4 | def f(): +5 |- x = 1 + 5 |+ pass + + diff --git a/crates/ruff/src/rules/ruff/typing.rs b/crates/ruff_linter/src/rules/ruff/typing.rs similarity index 100% rename from crates/ruff/src/rules/ruff/typing.rs rename to crates/ruff_linter/src/rules/ruff/typing.rs diff --git a/crates/ruff/src/rules/tryceratops/helpers.rs b/crates/ruff_linter/src/rules/tryceratops/helpers.rs similarity index 100% rename from crates/ruff/src/rules/tryceratops/helpers.rs rename to crates/ruff_linter/src/rules/tryceratops/helpers.rs diff --git a/crates/ruff/src/rules/tryceratops/mod.rs b/crates/ruff_linter/src/rules/tryceratops/mod.rs similarity index 100% rename from crates/ruff/src/rules/tryceratops/mod.rs rename to crates/ruff_linter/src/rules/tryceratops/mod.rs diff --git a/crates/ruff/src/rules/tryceratops/rules/error_instead_of_exception.rs b/crates/ruff_linter/src/rules/tryceratops/rules/error_instead_of_exception.rs similarity index 100% rename from crates/ruff/src/rules/tryceratops/rules/error_instead_of_exception.rs rename to crates/ruff_linter/src/rules/tryceratops/rules/error_instead_of_exception.rs diff --git a/crates/ruff/src/rules/tryceratops/rules/mod.rs b/crates/ruff_linter/src/rules/tryceratops/rules/mod.rs similarity index 100% rename from crates/ruff/src/rules/tryceratops/rules/mod.rs rename to crates/ruff_linter/src/rules/tryceratops/rules/mod.rs diff --git a/crates/ruff/src/rules/tryceratops/rules/raise_vanilla_args.rs b/crates/ruff_linter/src/rules/tryceratops/rules/raise_vanilla_args.rs similarity index 100% rename from crates/ruff/src/rules/tryceratops/rules/raise_vanilla_args.rs rename to crates/ruff_linter/src/rules/tryceratops/rules/raise_vanilla_args.rs diff --git a/crates/ruff/src/rules/tryceratops/rules/raise_vanilla_class.rs b/crates/ruff_linter/src/rules/tryceratops/rules/raise_vanilla_class.rs similarity index 100% rename from crates/ruff/src/rules/tryceratops/rules/raise_vanilla_class.rs rename to crates/ruff_linter/src/rules/tryceratops/rules/raise_vanilla_class.rs diff --git a/crates/ruff/src/rules/tryceratops/rules/raise_within_try.rs b/crates/ruff_linter/src/rules/tryceratops/rules/raise_within_try.rs similarity index 100% rename from crates/ruff/src/rules/tryceratops/rules/raise_within_try.rs rename to crates/ruff_linter/src/rules/tryceratops/rules/raise_within_try.rs diff --git a/crates/ruff/src/rules/tryceratops/rules/reraise_no_cause.rs b/crates/ruff_linter/src/rules/tryceratops/rules/reraise_no_cause.rs similarity index 100% rename from crates/ruff/src/rules/tryceratops/rules/reraise_no_cause.rs rename to crates/ruff_linter/src/rules/tryceratops/rules/reraise_no_cause.rs diff --git a/crates/ruff/src/rules/tryceratops/rules/try_consider_else.rs b/crates/ruff_linter/src/rules/tryceratops/rules/try_consider_else.rs similarity index 100% rename from crates/ruff/src/rules/tryceratops/rules/try_consider_else.rs rename to crates/ruff_linter/src/rules/tryceratops/rules/try_consider_else.rs diff --git a/crates/ruff/src/rules/tryceratops/rules/type_check_without_type_error.rs b/crates/ruff_linter/src/rules/tryceratops/rules/type_check_without_type_error.rs similarity index 100% rename from crates/ruff/src/rules/tryceratops/rules/type_check_without_type_error.rs rename to crates/ruff_linter/src/rules/tryceratops/rules/type_check_without_type_error.rs diff --git a/crates/ruff/src/rules/tryceratops/rules/useless_try_except.rs b/crates/ruff_linter/src/rules/tryceratops/rules/useless_try_except.rs similarity index 100% rename from crates/ruff/src/rules/tryceratops/rules/useless_try_except.rs rename to crates/ruff_linter/src/rules/tryceratops/rules/useless_try_except.rs diff --git a/crates/ruff/src/rules/tryceratops/rules/verbose_log_message.rs b/crates/ruff_linter/src/rules/tryceratops/rules/verbose_log_message.rs similarity index 100% rename from crates/ruff/src/rules/tryceratops/rules/verbose_log_message.rs rename to crates/ruff_linter/src/rules/tryceratops/rules/verbose_log_message.rs diff --git a/crates/ruff/src/rules/tryceratops/rules/verbose_raise.rs b/crates/ruff_linter/src/rules/tryceratops/rules/verbose_raise.rs similarity index 100% rename from crates/ruff/src/rules/tryceratops/rules/verbose_raise.rs rename to crates/ruff_linter/src/rules/tryceratops/rules/verbose_raise.rs 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 new file mode 100644 index 0000000000..4eb4aad7a1 --- /dev/null +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__error-instead-of-exception_TRY400.py.snap @@ -0,0 +1,72 @@ +--- +source: crates/ruff_linter/src/rules/tryceratops/mod.rs +--- +TRY400.py:16:9: TRY400 Use `logging.exception` instead of `logging.error` + | +14 | a = 1 +15 | except Exception: +16 | logging.error("Context message here") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 +17 | +18 | if True: + | + +TRY400.py:19:13: TRY400 Use `logging.exception` instead of `logging.error` + | +18 | if True: +19 | logging.error("Context message here") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 + | + +TRY400.py:26:9: TRY400 Use `logging.exception` instead of `logging.error` + | +24 | a = 1 +25 | except Exception: +26 | logger.error("Context message here") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 +27 | +28 | if True: + | + +TRY400.py:29:13: TRY400 Use `logging.exception` instead of `logging.error` + | +28 | if True: +29 | logger.error("Context message here") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 + | + +TRY400.py:36:9: TRY400 Use `logging.exception` instead of `logging.error` + | +34 | a = 1 +35 | except Exception: +36 | log.error("Context message here") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 +37 | +38 | if True: + | + +TRY400.py:39:13: TRY400 Use `logging.exception` instead of `logging.error` + | +38 | if True: +39 | log.error("Context message here") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 + | + +TRY400.py:46:9: TRY400 Use `logging.exception` instead of `logging.error` + | +44 | a = 1 +45 | except Exception: +46 | self.logger.error("Context message here") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 +47 | +48 | if True: + | + +TRY400.py:49:13: TRY400 Use `logging.exception` instead of `logging.error` + | +48 | if True: +49 | self.logger.error("Context message here") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY400 + | + + diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-vanilla-args_TRY003.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-vanilla-args_TRY003.py.snap new file mode 100644 index 0000000000..23b37ca793 --- /dev/null +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-vanilla-args_TRY003.py.snap @@ -0,0 +1,38 @@ +--- +source: crates/ruff_linter/src/rules/tryceratops/mod.rs +--- +TRY003.py:8:15: TRY003 Avoid specifying long messages outside the exception class + | + 6 | a = 1 + 7 | if a == 1: + 8 | raise CustomException("Long message") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY003 + 9 | elif a == 2: +10 | raise CustomException("Short") # This is acceptable + | + +TRY003.py:34:15: TRY003 Avoid specifying long messages outside the exception class + | +32 | def bad(a): +33 | if a % 2 == 0: +34 | raise BadArgCantBeEven(f"The argument '{a}' should be even") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY003 + | + +TRY003.py:39:15: TRY003 Avoid specifying long messages outside the exception class + | +37 | def another_bad(a): +38 | if a % 2 == 0: +39 | raise BadArgCantBeEven(f"The argument {a} should not be odd.") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY003 + | + +TRY003.py:44:15: TRY003 Avoid specifying long messages outside the exception class + | +42 | def and_another_bad(a): +43 | if a % 2 == 0: +44 | raise BadArgCantBeEven("The argument `a` should not be odd.") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY003 + | + + 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 new file mode 100644 index 0000000000..17ce8ae689 --- /dev/null +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-vanilla-class_TRY002.py.snap @@ -0,0 +1,22 @@ +--- +source: crates/ruff_linter/src/rules/tryceratops/mod.rs +--- +TRY002.py:13:15: TRY002 Create your own exception + | +11 | a = 1 +12 | if a == 1: +13 | raise Exception("Custom message") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY002 +14 | +15 | b = 1 + | + +TRY002.py:17:15: TRY002 Create your own exception + | +15 | b = 1 +16 | if b == 1: +17 | raise Exception + | ^^^^^^^^^ TRY002 + | + + 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 new file mode 100644 index 0000000000..f89e2f4b53 --- /dev/null +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__raise-within-try_TRY301.py.snap @@ -0,0 +1,64 @@ +--- +source: crates/ruff_linter/src/rules/tryceratops/mod.rs +--- +TRY301.py:14:13: TRY301 Abstract `raise` to an inner function + | +12 | a = process() +13 | if not a: +14 | raise MyException(a) + | ^^^^^^^^^^^^^^^^^^^^ TRY301 +15 | +16 | raise MyException(a) + | + +TRY301.py:16:9: TRY301 Abstract `raise` to an inner function + | +14 | raise MyException(a) +15 | +16 | raise MyException(a) + | ^^^^^^^^^^^^^^^^^^^^ TRY301 +17 | +18 | try: + | + +TRY301.py:21:17: TRY301 Abstract `raise` to an inner function + | +19 | b = process() +20 | if not b: +21 | raise MyException(b) + | ^^^^^^^^^^^^^^^^^^^^ TRY301 +22 | except Exception: +23 | logger.exception("something failed") + | + +TRY301.py:32:13: TRY301 Abstract `raise` to an inner function + | +30 | a = process() +31 | if not a: +32 | raise MyException(a) + | ^^^^^^^^^^^^^^^^^^^^ TRY301 +33 | +34 | raise MyException(a) + | + +TRY301.py:34:9: TRY301 Abstract `raise` to an inner function + | +32 | raise MyException(a) +33 | +34 | raise MyException(a) + | ^^^^^^^^^^^^^^^^^^^^ TRY301 +35 | +36 | try: + | + +TRY301.py:39:17: TRY301 Abstract `raise` to an inner function + | +37 | b = process() +38 | if not b: +39 | raise MyException(b) + | ^^^^^^^^^^^^^^^^^^^^ TRY301 +40 | except* Exception: +41 | logger.exception("something failed") + | + + diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__reraise-no-cause_TRY200.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__reraise-no-cause_TRY200.py.snap new file mode 100644 index 0000000000..dd34fcc552 --- /dev/null +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__reraise-no-cause_TRY200.py.snap @@ -0,0 +1,20 @@ +--- +source: crates/ruff_linter/src/rules/tryceratops/mod.rs +--- +TRY200.py:15:9: TRY200 Use `raise from` to specify exception cause + | +13 | a = 1 +14 | except Exception: +15 | raise MyException() + | ^^^^^^^^^^^^^^^^^^^ TRY200 + | + +TRY200.py:23:13: TRY200 Use `raise from` to specify exception cause + | +21 | except Exception: +22 | if True: +23 | raise MyException() + | ^^^^^^^^^^^^^^^^^^^ TRY200 + | + + diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__try-consider-else_TRY300.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__try-consider-else_TRY300.py.snap new file mode 100644 index 0000000000..3217f019c2 --- /dev/null +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__try-consider-else_TRY300.py.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/rules/tryceratops/mod.rs +--- +TRY300.py:20:9: TRY300 Consider moving this statement to an `else` block + | +18 | a = 1 +19 | b = process() +20 | return b + | ^^^^^^^^ TRY300 +21 | except MyException: +22 | logger.exception("process failed") + | + + 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 new file mode 100644 index 0000000000..014682e8e9 --- /dev/null +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__type-check-without-type-error_TRY004.py.snap @@ -0,0 +1,299 @@ +--- +source: crates/ruff_linter/src/rules/tryceratops/mod.rs +--- +TRY004.py:12:9: TRY004 Prefer `TypeError` exception for invalid type + | +10 | pass +11 | else: +12 | raise Exception("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:19:9: TRY004 Prefer `TypeError` exception for invalid type + | +17 | pass +18 | else: +19 | raise Exception("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:30:9: TRY004 Prefer `TypeError` exception for invalid type + | +28 | pass +29 | else: +30 | raise Exception("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:37:9: TRY004 Prefer `TypeError` exception for invalid type + | +35 | pass +36 | else: +37 | raise Exception("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:44:9: TRY004 Prefer `TypeError` exception for invalid type + | +42 | pass +43 | else: +44 | raise ArithmeticError("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:51:9: TRY004 Prefer `TypeError` exception for invalid type + | +49 | pass +50 | else: +51 | raise AssertionError("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:58:9: TRY004 Prefer `TypeError` exception for invalid type + | +56 | pass +57 | else: +58 | raise AttributeError("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:65:9: TRY004 Prefer `TypeError` exception for invalid type + | +63 | pass +64 | else: +65 | raise BufferError # should be typeerror + | ^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:72:9: TRY004 Prefer `TypeError` exception for invalid type + | +70 | pass +71 | else: +72 | raise EOFError("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:79:9: TRY004 Prefer `TypeError` exception for invalid type + | +77 | pass +78 | else: +79 | raise ImportError("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:86:9: TRY004 Prefer `TypeError` exception for invalid type + | +84 | pass +85 | else: +86 | raise LookupError("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +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( + | _________^ +96 | | "..." +97 | | ) + | |_________^ TRY004 + | + +TRY004.py:104:9: TRY004 Prefer `TypeError` exception for invalid type + | +102 | pass +103 | else: +104 | raise NameError("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:111:9: TRY004 Prefer `TypeError` exception for invalid type + | +109 | pass +110 | else: +111 | raise ReferenceError("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:118:9: TRY004 Prefer `TypeError` exception for invalid type + | +116 | pass +117 | else: +118 | raise RuntimeError("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:125:9: TRY004 Prefer `TypeError` exception for invalid type + | +123 | pass +124 | else: +125 | raise SyntaxError("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:132:9: TRY004 Prefer `TypeError` exception for invalid type + | +130 | pass +131 | else: +132 | raise SystemError("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:139:9: TRY004 Prefer `TypeError` exception for invalid type + | +137 | pass +138 | else: +139 | raise ValueError("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:146:9: TRY004 Prefer `TypeError` exception for invalid type + | +144 | pass +145 | else: +146 | raise Exception("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:153:9: TRY004 Prefer `TypeError` exception for invalid type + | +151 | pass +152 | else: +153 | raise Exception("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:160:9: TRY004 Prefer `TypeError` exception for invalid type + | +158 | pass +159 | else: +160 | raise Exception("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:167:9: TRY004 Prefer `TypeError` exception for invalid type + | +165 | pass +166 | else: +167 | raise Exception("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:174:9: TRY004 Prefer `TypeError` exception for invalid type + | +172 | pass +173 | else: +174 | raise Exception("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:181:9: TRY004 Prefer `TypeError` exception for invalid type + | +179 | pass +180 | else: +181 | raise Exception("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:188:9: TRY004 Prefer `TypeError` exception for invalid type + | +186 | pass +187 | else: +188 | raise Exception("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:195:9: TRY004 Prefer `TypeError` exception for invalid type + | +193 | pass +194 | else: +195 | raise Exception("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:202:9: TRY004 Prefer `TypeError` exception for invalid type + | +200 | pass +201 | else: +202 | raise Exception("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:209:9: TRY004 Prefer `TypeError` exception for invalid type + | +207 | pass +208 | else: +209 | raise Exception("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:216:9: TRY004 Prefer `TypeError` exception for invalid type + | +214 | pass +215 | else: +216 | raise Exception("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:223:9: TRY004 Prefer `TypeError` exception for invalid type + | +221 | pass +222 | else: +223 | raise Exception("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:230:9: TRY004 Prefer `TypeError` exception for invalid type + | +228 | pass +229 | elif isinstance(arg2, int): +230 | raise Exception("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:239:9: TRY004 Prefer `TypeError` exception for invalid type + | +237 | pass +238 | else: +239 | raise Exception("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:276:9: TRY004 Prefer `TypeError` exception for invalid type + | +274 | def check_body(some_args): +275 | if isinstance(some_args, int): +276 | raise ValueError("...") # should be typeerror + | ^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + +TRY004.py:286:9: TRY004 Prefer `TypeError` exception for invalid type + | +284 | def multiple_elifs(some_args): +285 | if not isinstance(some_args, int): +286 | raise ValueError("...") # should be typerror + | ^^^^^^^^^^^^^^^^^^^^^^^ TRY004 +287 | elif some_args < 3: +288 | raise ValueError("...") # this is ok + | + +TRY004.py:297:9: TRY004 Prefer `TypeError` exception for invalid type + | +295 | def multiple_ifs(some_args): +296 | if not isinstance(some_args, int): +297 | raise ValueError("...") # should be typerror + | ^^^^^^^^^^^^^^^^^^^^^^^ TRY004 +298 | else: +299 | if some_args < 3: + | + +TRY004.py:316:9: TRY004 Prefer `TypeError` exception for invalid type + | +314 | return "CronExpression" +315 | else: +316 | raise Exception(f"Unknown object type: {obj.__class__.__name__}") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TRY004 + | + + diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__useless-try-except_TRY302.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__useless-try-except_TRY302.py.snap new file mode 100644 index 0000000000..e897335967 --- /dev/null +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__useless-try-except_TRY302.py.snap @@ -0,0 +1,150 @@ +--- +source: crates/ruff_linter/src/rules/tryceratops/mod.rs +--- +TRY302.py:12:5: TRY302 Remove exception handler; error is immediately re-raised + | +10 | try: +11 | process() +12 | except Exception: + | _____^ +13 | | raise + | |_____________^ TRY302 +14 | +15 | def bad(): + | + +TRY302.py:18:5: TRY302 Remove exception handler; error is immediately re-raised + | +16 | try: +17 | process() +18 | except Exception: + | _____^ +19 | | raise +20 | | print("this code is pointless!") + | |________________________________________^ TRY302 +21 | +22 | def bad(): + | + +TRY302.py:25:5: TRY302 Remove exception handler; error is immediately re-raised + | +23 | try: +24 | process() +25 | except: + | _____^ +26 | | # I am a comment, not a statement! +27 | | raise + | |_____________^ TRY302 +28 | +29 | def bad(): + | + +TRY302.py:32:5: TRY302 Remove exception handler; error is immediately re-raised + | +30 | try: +31 | process() +32 | except Exception: + | _____^ +33 | | raise + | |_____________^ TRY302 +34 | +35 | def bad(): + | + +TRY302.py:38:5: TRY302 Remove exception handler; error is immediately re-raised + | +36 | try: +37 | process() +38 | except Exception as e: + | _____^ +39 | | raise + | |_____________^ TRY302 +40 | +41 | def bad(): + | + +TRY302.py:44:5: TRY302 Remove exception handler; error is immediately re-raised + | +42 | try: +43 | process() +44 | except Exception as e: + | _____^ +45 | | raise e + | |_______________^ TRY302 +46 | +47 | def bad(): + | + +TRY302.py:50:5: TRY302 Remove exception handler; error is immediately re-raised + | +48 | try: +49 | process() +50 | except MyException: + | _____^ +51 | | raise + | |_____________^ TRY302 +52 | except Exception: +53 | raise + | + +TRY302.py:52:5: TRY302 Remove exception handler; error is immediately re-raised + | +50 | except MyException: +51 | raise +52 | except Exception: + | _____^ +53 | | raise + | |_____________^ TRY302 +54 | +55 | def bad(): + | + +TRY302.py:58:5: TRY302 Remove exception handler; error is immediately re-raised + | +56 | try: +57 | process() +58 | except MyException as e: + | _____^ +59 | | raise e + | |_______________^ TRY302 +60 | except Exception as e: +61 | raise e + | + +TRY302.py:60:5: TRY302 Remove exception handler; error is immediately re-raised + | +58 | except MyException as e: +59 | raise e +60 | except Exception as e: + | _____^ +61 | | raise e + | |_______________^ TRY302 +62 | +63 | def bad(): + | + +TRY302.py:66:5: TRY302 Remove exception handler; error is immediately re-raised + | +64 | try: +65 | process() +66 | except MyException as ex: + | _____^ +67 | | raise ex + | |________________^ TRY302 +68 | except Exception as e: +69 | raise e + | + +TRY302.py:68:5: TRY302 Remove exception handler; error is immediately re-raised + | +66 | except MyException as ex: +67 | raise ex +68 | except Exception as e: + | _____^ +69 | | raise e + | |_______________^ TRY302 +70 | +71 | def fine(): + | + + 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 new file mode 100644 index 0000000000..7143686b87 --- /dev/null +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-log-message_TRY401.py.snap @@ -0,0 +1,92 @@ +--- +source: crates/ruff_linter/src/rules/tryceratops/mod.rs +--- +TRY401.py:8:45: TRY401 Redundant exception object included in `logging.exception` call + | +6 | finish() +7 | except Exception as ex: +8 | logger.exception(f"Found an error: {ex}") # TRY401 + | ^^ TRY401 + | + +TRY401.py:19:53: TRY401 Redundant exception object included in `logging.exception` call + | +17 | if True is False: +18 | for i in range(10): +19 | logger.exception(f"Found an error: {bad} {good}") # TRY401 + | ^^^ TRY401 +20 | except IndexError as bad: +21 | logger.exception(f"Found an error: {bad} {bad}") # TRY401 + | + +TRY401.py:21:45: TRY401 Redundant exception object included in `logging.exception` call + | +19 | logger.exception(f"Found an error: {bad} {good}") # TRY401 +20 | except IndexError as bad: +21 | logger.exception(f"Found an error: {bad} {bad}") # TRY401 + | ^^^ TRY401 +22 | except Exception as bad: +23 | logger.exception(f"Found an error: {bad}") # TRY401 + | + +TRY401.py:21:51: TRY401 Redundant exception object included in `logging.exception` call + | +19 | logger.exception(f"Found an error: {bad} {good}") # TRY401 +20 | except IndexError as bad: +21 | logger.exception(f"Found an error: {bad} {bad}") # TRY401 + | ^^^ TRY401 +22 | except Exception as bad: +23 | logger.exception(f"Found an error: {bad}") # TRY401 + | + +TRY401.py:23:45: TRY401 Redundant exception object included in `logging.exception` call + | +21 | logger.exception(f"Found an error: {bad} {bad}") # TRY401 +22 | except Exception as bad: +23 | logger.exception(f"Found an error: {bad}") # TRY401 + | ^^^ TRY401 +24 | logger.exception(f"Found an error: {bad}") # TRY401 + | + +TRY401.py:24:45: TRY401 Redundant exception object included in `logging.exception` call + | +22 | except Exception as bad: +23 | logger.exception(f"Found an error: {bad}") # TRY401 +24 | logger.exception(f"Found an error: {bad}") # TRY401 + | ^^^ TRY401 +25 | +26 | if True: + | + +TRY401.py:27:49: TRY401 Redundant exception object included in `logging.exception` call + | +26 | if True: +27 | logger.exception(f"Found an error: {bad}") # TRY401 + | ^^^ TRY401 + | + +TRY401.py:39:47: TRY401 Redundant exception object included in `logging.exception` call + | +37 | ... +38 | except Exception as ex: +39 | logger.exception(f"Logging an error: {ex}") # TRY401 + | ^^ TRY401 + | + +TRY401.py:46:53: TRY401 Redundant exception object included in `logging.exception` call + | +44 | ... +45 | except Exception as ex: +46 | logger.exception("Logging an error: " + str(ex)) # TRY401 + | ^^ TRY401 + | + +TRY401.py:53:47: TRY401 Redundant exception object included in `logging.exception` call + | +51 | ... +52 | except Exception as ex: +53 | logger.exception("Logging an error:", ex) # TRY401 + | ^^ TRY401 + | + + diff --git a/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-raise_TRY201.py.snap b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-raise_TRY201.py.snap new file mode 100644 index 0000000000..6a15b3815f --- /dev/null +++ b/crates/ruff_linter/src/rules/tryceratops/snapshots/ruff_linter__rules__tryceratops__tests__verbose-raise_TRY201.py.snap @@ -0,0 +1,57 @@ +--- +source: crates/ruff_linter/src/rules/tryceratops/mod.rs +--- +TRY201.py:20:15: TRY201 [*] Use `raise` without specifying exception name + | +18 | except MyException as e: +19 | logger.exception("process failed") +20 | raise e + | ^ TRY201 + | + = help: Remove exception name + +ℹ Suggested fix +17 17 | process() +18 18 | except MyException as e: +19 19 | logger.exception("process failed") +20 |- raise e + 20 |+ raise +21 21 | +22 22 | +23 23 | def good(): + +TRY201.py:63:19: TRY201 [*] Use `raise` without specifying exception name + | +61 | logger.exception("process failed") +62 | if True: +63 | raise e + | ^ TRY201 + | + = help: Remove exception name + +ℹ Suggested fix +60 60 | except MyException as e: +61 61 | logger.exception("process failed") +62 62 | if True: +63 |- raise e + 63 |+ raise +64 64 | +65 65 | +66 66 | def bad_that_needs_recursion_2(): + +TRY201.py:74:23: TRY201 [*] Use `raise` without specifying exception name + | +73 | def foo(): +74 | raise e + | ^ TRY201 + | + = help: Remove exception name + +ℹ Suggested fix +71 71 | if True: +72 72 | +73 73 | def foo(): +74 |- raise e + 74 |+ raise + + diff --git a/crates/ruff/src/settings/defaults.rs b/crates/ruff_linter/src/settings/defaults.rs similarity index 100% rename from crates/ruff/src/settings/defaults.rs rename to crates/ruff_linter/src/settings/defaults.rs diff --git a/crates/ruff/src/settings/flags.rs b/crates/ruff_linter/src/settings/flags.rs similarity index 100% rename from crates/ruff/src/settings/flags.rs rename to crates/ruff_linter/src/settings/flags.rs diff --git a/crates/ruff/src/settings/mod.rs b/crates/ruff_linter/src/settings/mod.rs similarity index 100% rename from crates/ruff/src/settings/mod.rs rename to crates/ruff_linter/src/settings/mod.rs diff --git a/crates/ruff/src/settings/rule_table.rs b/crates/ruff_linter/src/settings/rule_table.rs similarity index 100% rename from crates/ruff/src/settings/rule_table.rs rename to crates/ruff_linter/src/settings/rule_table.rs diff --git a/crates/ruff/src/settings/types.rs b/crates/ruff_linter/src/settings/types.rs similarity index 100% rename from crates/ruff/src/settings/types.rs rename to crates/ruff_linter/src/settings/types.rs 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 new file mode 100644 index 0000000000..60c9a48409 --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__import_sorting.snap @@ -0,0 +1,89 @@ +--- +source: crates/ruff_linter/src/linter.rs +--- +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 +5 | import collections +6 | # Newline should be added here + | + = help: Organize imports + +ℹ Fix + 1 |+import math + 2 |+import random +1 3 | from pathlib import Path +2 |-import random +3 |-import math +4 4 | from typing import Any +5 5 | import collections +6 6 | # Newline should be added here + +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 +4 | def foo(): +5 | pass + | + = help: Organize imports + +ℹ Fix +1 1 | from pathlib import Path +2 2 | import random +3 3 | import math + 4 |+import collections +4 5 | from typing import Any +5 |-import collections + 6 |+ + 7 |+ +6 8 | # Newline should be added here +7 9 | def foo(): +8 10 | pass + +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 +5 | --inline + | + = help: Organize imports + +ℹ Fix +6 6 | # Newline should be added here +7 7 | def foo(): +8 8 | pass + 9 |+import sys +9 10 | from pathlib import Path +10 |-import sys +11 11 | +12 12 | %matplotlib \ +13 13 | --inline + +isort.ipynb:cell 3:7:1: I001 [*] Import block is un-sorted or un-formatted + | +5 | --inline +6 | +7 | / import math +8 | | import abc + | + = help: Organize imports + +ℹ Fix +12 12 | %matplotlib \ +13 13 | --inline +14 14 | + 15 |+import abc +15 16 | import math +16 |-import abc + + 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 new file mode 100644 index 0000000000..d90b6dbef4 --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__ipy_escape_command.snap @@ -0,0 +1,23 @@ +--- +source: crates/ruff_linter/src/linter.rs +--- +ipy_escape_command.ipynb:cell 1:5:8: F401 [*] `os` imported but unused + | +3 | %matplotlib inline +4 | +5 | import os + | ^^ F401 +6 | +7 | _ = math.pi + | + = help: Remove unused import: `os` + +ℹ Fix +2 2 | +3 3 | %matplotlib inline +4 4 | +5 |-import os +6 5 | +7 6 | _ = math.pi + + diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__unused_variable.snap b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__unused_variable.snap new file mode 100644 index 0000000000..24253dc073 --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__linter__tests__unused_variable.snap @@ -0,0 +1,72 @@ +--- +source: crates/ruff_linter/src/linter.rs +--- +unused_variable.ipynb:cell 1:2:5: F841 [*] Local variable `foo1` is assigned to but never used + | +1 | def f(): +2 | foo1 = %matplotlib --list + | ^^^^ F841 +3 | foo2: list[str] = %matplotlib --list + | + = help: Remove assignment to unused variable `foo1` + +ℹ Suggested fix +1 1 | def f(): +2 |- foo1 = %matplotlib --list + 2 |+ %matplotlib --list +3 3 | foo2: list[str] = %matplotlib --list +4 4 | def f(): +5 5 | bar1 = !pwd + +unused_variable.ipynb:cell 1:3:5: F841 [*] Local variable `foo2` is assigned to but never used + | +1 | def f(): +2 | foo1 = %matplotlib --list +3 | foo2: list[str] = %matplotlib --list + | ^^^^ F841 + | + = help: Remove assignment to unused variable `foo2` + +ℹ Suggested fix +1 1 | def f(): +2 2 | foo1 = %matplotlib --list +3 |- foo2: list[str] = %matplotlib --list + 3 |+ %matplotlib --list +4 4 | def f(): +5 5 | bar1 = !pwd +6 6 | bar2: str = !pwd + +unused_variable.ipynb:cell 2:2:5: F841 [*] Local variable `bar1` is assigned to but never used + | +1 | def f(): +2 | bar1 = !pwd + | ^^^^ F841 +3 | bar2: str = !pwd + | + = help: Remove assignment to unused variable `bar1` + +ℹ Suggested fix +2 2 | foo1 = %matplotlib --list +3 3 | foo2: list[str] = %matplotlib --list +4 4 | def f(): +5 |- bar1 = !pwd + 5 |+ !pwd +6 6 | bar2: str = !pwd + +unused_variable.ipynb:cell 2:3:5: F841 [*] Local variable `bar2` is assigned to but never used + | +1 | def f(): +2 | bar1 = !pwd +3 | bar2: str = !pwd + | ^^^^ F841 + | + = help: Remove assignment to unused variable `bar2` + +ℹ Suggested fix +3 3 | foo2: list[str] = %matplotlib --list +4 4 | def f(): +5 5 | bar1 = !pwd +6 |- bar2: str = !pwd + 6 |+ !pwd + + diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__flake8_exemption_all.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__flake8_exemption_all.snap new file mode 100644 index 0000000000..4fab59ef1b --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__flake8_exemption_all.snap @@ -0,0 +1,9 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "ParsedFileExemption::try_extract(source)" +--- +Ok( + Some( + All, + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__flake8_exemption_all_case_insensitive.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__flake8_exemption_all_case_insensitive.snap new file mode 100644 index 0000000000..4fab59ef1b --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__flake8_exemption_all_case_insensitive.snap @@ -0,0 +1,9 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "ParsedFileExemption::try_extract(source)" +--- +Ok( + Some( + All, + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__flake8_exemption_all_no_space.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__flake8_exemption_all_no_space.snap new file mode 100644 index 0000000000..4fab59ef1b --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__flake8_exemption_all_no_space.snap @@ -0,0 +1,9 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "ParsedFileExemption::try_extract(source)" +--- +Ok( + Some( + All, + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__flake8_exemption_codes.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__flake8_exemption_codes.snap new file mode 100644 index 0000000000..ab2330d822 --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__flake8_exemption_codes.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "ParsedFileExemption::try_extract(source)" +--- +Ok( + Some( + Codes( + [ + "F401", + "F841", + ], + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_all.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_all.snap new file mode 100644 index 0000000000..1f82ec4cee --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_all.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + All( + All { + range: 0..6, + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_all_case_insensitive.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_all_case_insensitive.snap new file mode 100644 index 0000000000..1f82ec4cee --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_all_case_insensitive.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + All( + All { + range: 0..6, + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_all_leading_comment.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_all_leading_comment.snap new file mode 100644 index 0000000000..34691c9c16 --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_all_leading_comment.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + All( + All { + range: 35..41, + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_all_multi_space.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_all_multi_space.snap new file mode 100644 index 0000000000..79d3acb35e --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_all_multi_space.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + All( + All { + range: 0..7, + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_all_no_space.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_all_no_space.snap new file mode 100644 index 0000000000..4e20a49851 --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_all_no_space.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + All( + All { + range: 0..5, + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_all_trailing_comment.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_all_trailing_comment.snap new file mode 100644 index 0000000000..1f82ec4cee --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_all_trailing_comment.snap @@ -0,0 +1,13 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + All( + All { + range: 0..6, + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_code.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_code.snap new file mode 100644 index 0000000000..07816b5efd --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_code.snap @@ -0,0 +1,16 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + Codes( + Codes { + range: 0..12, + codes: [ + "F401", + ], + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_code_case_insensitive.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_code_case_insensitive.snap new file mode 100644 index 0000000000..07816b5efd --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_code_case_insensitive.snap @@ -0,0 +1,16 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + Codes( + Codes { + range: 0..12, + codes: [ + "F401", + ], + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_code_leading_comment.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_code_leading_comment.snap new file mode 100644 index 0000000000..19232e9536 --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_code_leading_comment.snap @@ -0,0 +1,16 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + Codes( + Codes { + range: 35..47, + codes: [ + "F401", + ], + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_code_multi_space.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_code_multi_space.snap new file mode 100644 index 0000000000..7e234cf35c --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_code_multi_space.snap @@ -0,0 +1,16 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + Codes( + Codes { + range: 0..13, + codes: [ + "F401", + ], + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_code_no_space.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_code_no_space.snap new file mode 100644 index 0000000000..ef3c293f4a --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_code_no_space.snap @@ -0,0 +1,16 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + Codes( + Codes { + range: 0..10, + codes: [ + "F401", + ], + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_code_trailing_comment.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_code_trailing_comment.snap new file mode 100644 index 0000000000..07816b5efd --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_code_trailing_comment.snap @@ -0,0 +1,16 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + Codes( + Codes { + range: 0..12, + codes: [ + "F401", + ], + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_codes.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_codes.snap new file mode 100644 index 0000000000..963295d753 --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_codes.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + Codes( + Codes { + range: 0..18, + codes: [ + "F401", + "F841", + ], + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_codes_case_insensitive.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_codes_case_insensitive.snap new file mode 100644 index 0000000000..963295d753 --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_codes_case_insensitive.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + Codes( + Codes { + range: 0..18, + codes: [ + "F401", + "F841", + ], + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_codes_leading_comment.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_codes_leading_comment.snap new file mode 100644 index 0000000000..de80036fa3 --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_codes_leading_comment.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + Codes( + Codes { + range: 35..53, + codes: [ + "F401", + "F841", + ], + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_codes_multi_space.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_codes_multi_space.snap new file mode 100644 index 0000000000..b1c959457b --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_codes_multi_space.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + Codes( + Codes { + range: 0..20, + codes: [ + "F401", + "F841", + ], + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_codes_no_space.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_codes_no_space.snap new file mode 100644 index 0000000000..ecaf222875 --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_codes_no_space.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + Codes( + Codes { + range: 0..15, + codes: [ + "F401", + "F841", + ], + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_codes_trailing_comment.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_codes_trailing_comment.snap new file mode 100644 index 0000000000..963295d753 --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_codes_trailing_comment.snap @@ -0,0 +1,17 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + Codes( + Codes { + range: 0..18, + codes: [ + "F401", + "F841", + ], + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_invalid_codes.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_invalid_codes.snap new file mode 100644 index 0000000000..751f9e693b --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_invalid_codes.snap @@ -0,0 +1,7 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Err( + MissingCodes, +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_invalid_suffix.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_invalid_suffix.snap new file mode 100644 index 0000000000..1852dbd27b --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_invalid_suffix.snap @@ -0,0 +1,7 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Err( + InvalidSuffix, +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_leading_space.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_leading_space.snap new file mode 100644 index 0000000000..ce6476bfe5 --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_leading_space.snap @@ -0,0 +1,16 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + Codes( + Codes { + range: 4..16, + codes: [ + "F401", + ], + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_trailing_space.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_trailing_space.snap new file mode 100644 index 0000000000..07816b5efd --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__noqa_trailing_space.snap @@ -0,0 +1,16 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "Directive::try_extract(source, TextSize::default())" +--- +Ok( + Some( + Codes( + Codes { + range: 0..12, + codes: [ + "F401", + ], + }, + ), + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__ruff_exemption_all.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__ruff_exemption_all.snap new file mode 100644 index 0000000000..4fab59ef1b --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__ruff_exemption_all.snap @@ -0,0 +1,9 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "ParsedFileExemption::try_extract(source)" +--- +Ok( + Some( + All, + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__ruff_exemption_all_case_insensitive.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__ruff_exemption_all_case_insensitive.snap new file mode 100644 index 0000000000..4fab59ef1b --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__ruff_exemption_all_case_insensitive.snap @@ -0,0 +1,9 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "ParsedFileExemption::try_extract(source)" +--- +Ok( + Some( + All, + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__ruff_exemption_all_no_space.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__ruff_exemption_all_no_space.snap new file mode 100644 index 0000000000..4fab59ef1b --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__ruff_exemption_all_no_space.snap @@ -0,0 +1,9 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "ParsedFileExemption::try_extract(source)" +--- +Ok( + Some( + All, + ), +) diff --git a/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__ruff_exemption_codes.snap b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__ruff_exemption_codes.snap new file mode 100644 index 0000000000..ab2330d822 --- /dev/null +++ b/crates/ruff_linter/src/snapshots/ruff_linter__noqa__tests__ruff_exemption_codes.snap @@ -0,0 +1,14 @@ +--- +source: crates/ruff_linter/src/noqa.rs +expression: "ParsedFileExemption::try_extract(source)" +--- +Ok( + Some( + Codes( + [ + "F401", + "F841", + ], + ), + ), +) diff --git a/crates/ruff/src/source_kind.rs b/crates/ruff_linter/src/source_kind.rs similarity index 100% rename from crates/ruff/src/source_kind.rs rename to crates/ruff_linter/src/source_kind.rs diff --git a/crates/ruff/src/test.rs b/crates/ruff_linter/src/test.rs similarity index 100% rename from crates/ruff/src/test.rs rename to crates/ruff_linter/src/test.rs diff --git a/crates/ruff/src/upstream_categories.rs b/crates/ruff_linter/src/upstream_categories.rs similarity index 100% rename from crates/ruff/src/upstream_categories.rs rename to crates/ruff_linter/src/upstream_categories.rs diff --git a/crates/ruff_wasm/Cargo.toml b/crates/ruff_wasm/Cargo.toml index 3ecc3ad702..1a21e814a8 100644 --- a/crates/ruff_wasm/Cargo.toml +++ b/crates/ruff_wasm/Cargo.toml @@ -18,7 +18,7 @@ crate-type = ["cdylib", "rlib"] default = ["console_error_panic_hook"] [dependencies] -ruff = { path = "../ruff" } +ruff_linter = { path = "../ruff_linter" } ruff_diagnostics = { path = "../ruff_diagnostics" } ruff_python_ast = { path = "../ruff_python_ast" } ruff_python_codegen = { path = "../ruff_python_codegen" } diff --git a/crates/ruff_wasm/src/lib.rs b/crates/ruff_wasm/src/lib.rs index 2ab51cf77a..007395d001 100644 --- a/crates/ruff_wasm/src/lib.rs +++ b/crates/ruff_wasm/src/lib.rs @@ -5,14 +5,14 @@ use js_sys::Error; use serde::{Deserialize, Serialize}; use wasm_bindgen::prelude::*; -use ruff::directives; -use ruff::line_width::{LineLength, TabSize}; -use ruff::linter::{check_path, LinterResult}; -use ruff::registry::AsRule; -use ruff::settings::types::{PreviewMode, PythonVersion}; -use ruff::settings::{defaults, flags, Settings}; -use ruff::source_kind::SourceKind; use ruff_formatter::{FormatResult, Formatted, LineWidth}; +use ruff_linter::directives; +use ruff_linter::line_width::{LineLength, TabSize}; +use ruff_linter::linter::{check_path, LinterResult}; +use ruff_linter::registry::AsRule; +use ruff_linter::settings::types::{PreviewMode, PythonVersion}; +use ruff_linter::settings::{defaults, flags, Settings}; +use ruff_linter::source_kind::SourceKind; use ruff_python_ast::{Mod, PySourceType}; use ruff_python_codegen::Stylist; use ruff_python_formatter::{format_node, pretty_comments, PyFormatContext, PyFormatOptions}; @@ -101,7 +101,7 @@ pub struct Workspace { #[wasm_bindgen] impl Workspace { pub fn version() -> String { - ruff::VERSION.to_string() + ruff_linter::VERSION.to_string() } #[wasm_bindgen(constructor)] diff --git a/crates/ruff_wasm/tests/api.rs b/crates/ruff_wasm/tests/api.rs index 85cae83782..a88e3026a7 100644 --- a/crates/ruff_wasm/tests/api.rs +++ b/crates/ruff_wasm/tests/api.rs @@ -2,7 +2,7 @@ use wasm_bindgen_test::wasm_bindgen_test; -use ruff::registry::Rule; +use ruff_linter::registry::Rule; use ruff_source_file::{OneIndexed, SourceLocation}; use ruff_wasm::{ExpandedMessage, Workspace}; diff --git a/crates/ruff_workspace/Cargo.toml b/crates/ruff_workspace/Cargo.toml index 927477297a..3240b49124 100644 --- a/crates/ruff_workspace/Cargo.toml +++ b/crates/ruff_workspace/Cargo.toml @@ -13,7 +13,7 @@ license = { workspace = true } [lib] [dependencies] -ruff = { path = "../ruff" } +ruff_linter = { path = "../ruff_linter" } ruff_cache = { path = "../ruff_cache" } ruff_macros = { path = "../ruff_macros" } diff --git a/crates/ruff_workspace/src/configuration.rs b/crates/ruff_workspace/src/configuration.rs index 82ffa2ed49..51ea5afd98 100644 --- a/crates/ruff_workspace/src/configuration.rs +++ b/crates/ruff_workspace/src/configuration.rs @@ -17,18 +17,22 @@ use crate::options::{ use anyhow::{anyhow, Result}; use glob::{glob, GlobError, Paths, PatternError}; use regex::Regex; -use ruff::line_width::{LineLength, TabSize}; -use ruff::registry::RuleNamespace; -use ruff::registry::{Rule, RuleSet, INCOMPATIBLE_CODES}; -use ruff::rule_selector::Specificity; -use ruff::settings::rule_table::RuleTable; -use ruff::settings::types::{ +use ruff_cache::cache_dir; +use ruff_linter::line_width::{LineLength, TabSize}; +use ruff_linter::registry::RuleNamespace; +use ruff_linter::registry::{Rule, RuleSet, INCOMPATIBLE_CODES}; +use ruff_linter::rule_selector::Specificity; +use ruff_linter::settings::rule_table::RuleTable; +use ruff_linter::settings::types::{ FilePattern, FilePatternSet, PerFileIgnore, PreviewMode, PythonVersion, SerializationFormat, Version, }; -use ruff::settings::{defaults, resolve_per_file_ignores, AllSettings, CliSettings, Settings}; -use ruff::{fs, warn_user, warn_user_once, warn_user_once_by_id, RuleSelector, RUFF_PKG_VERSION}; -use ruff_cache::cache_dir; +use ruff_linter::settings::{ + defaults, resolve_per_file_ignores, AllSettings, CliSettings, Settings, +}; +use ruff_linter::{ + fs, warn_user, warn_user_once, warn_user_once_by_id, RuleSelector, RUFF_PKG_VERSION, +}; use rustc_hash::{FxHashMap, FxHashSet}; use shellexpand; use shellexpand::LookupError; @@ -802,10 +806,10 @@ pub fn resolve_src(src: &[String], project_root: &Path) -> Result> #[cfg(test)] mod tests { use crate::configuration::{Configuration, RuleSelection}; - use ruff::codes::{Flake8Copyright, Pycodestyle, Refurb}; - use ruff::registry::{Linter, Rule, RuleSet}; - use ruff::settings::types::PreviewMode; - use ruff::RuleSelector; + use ruff_linter::codes::{Flake8Copyright, Pycodestyle, Refurb}; + use ruff_linter::registry::{Linter, Rule, RuleSet}; + use ruff_linter::settings::types::PreviewMode; + use ruff_linter::RuleSelector; const NURSERY_RULES: &[Rule] = &[ Rule::MissingCopyrightNotice, diff --git a/crates/ruff_workspace/src/lib.rs b/crates/ruff_workspace/src/lib.rs index 69431d271f..cc464ffd49 100644 --- a/crates/ruff_workspace/src/lib.rs +++ b/crates/ruff_workspace/src/lib.rs @@ -10,6 +10,6 @@ mod tests { use std::path::Path; pub(crate) fn test_resource_path(path: impl AsRef) -> std::path::PathBuf { - Path::new("../ruff/resources/test/").join(path) + Path::new("../ruff_linter/resources/test/").join(path) } } diff --git a/crates/ruff_workspace/src/options.rs b/crates/ruff_workspace/src/options.rs index 2cc069d081..4f63504a6f 100644 --- a/crates/ruff_workspace/src/options.rs +++ b/crates/ruff_workspace/src/options.rs @@ -1,21 +1,23 @@ use regex::Regex; -use ruff::line_width::{LineLength, TabSize}; -use ruff::rules::flake8_pytest_style::settings::SettingsError; -use ruff::rules::flake8_pytest_style::types; -use ruff::rules::flake8_quotes::settings::Quote; -use ruff::rules::flake8_tidy_imports::settings::{ApiBan, Strictness}; -use ruff::rules::isort::settings::RelativeImportsOrder; -use ruff::rules::isort::{ImportSection, ImportType}; -use ruff::rules::pydocstyle::settings::Convention; -use ruff::rules::pylint::settings::ConstantType; -use ruff::rules::{ +use ruff_linter::line_width::{LineLength, TabSize}; +use ruff_linter::rules::flake8_pytest_style::settings::SettingsError; +use ruff_linter::rules::flake8_pytest_style::types; +use ruff_linter::rules::flake8_quotes::settings::Quote; +use ruff_linter::rules::flake8_tidy_imports::settings::{ApiBan, Strictness}; +use ruff_linter::rules::isort::settings::RelativeImportsOrder; +use ruff_linter::rules::isort::{ImportSection, ImportType}; +use ruff_linter::rules::pydocstyle::settings::Convention; +use ruff_linter::rules::pylint::settings::ConstantType; +use ruff_linter::rules::{ flake8_copyright, flake8_errmsg, flake8_gettext, flake8_implicit_str_concat, flake8_import_conventions, flake8_pytest_style, flake8_quotes, flake8_self, flake8_tidy_imports, flake8_type_checking, flake8_unused_arguments, isort, mccabe, pep8_naming, pycodestyle, pydocstyle, pyflakes, pylint, pyupgrade, }; -use ruff::settings::types::{IdentifierPattern, PythonVersion, SerializationFormat, Version}; -use ruff::{warn_user_once, RuleSelector}; +use ruff_linter::settings::types::{ + IdentifierPattern, PythonVersion, SerializationFormat, Version, +}; +use ruff_linter::{warn_user_once, RuleSelector}; use ruff_macros::{CombineOptions, ConfigurationOptions}; use rustc_hash::{FxHashMap, FxHashSet}; use serde::{Deserialize, Serialize}; @@ -683,8 +685,8 @@ pub struct Flake8AnnotationsOptions { } impl Flake8AnnotationsOptions { - pub fn into_settings(self) -> ruff::rules::flake8_annotations::settings::Settings { - ruff::rules::flake8_annotations::settings::Settings { + pub fn into_settings(self) -> ruff_linter::rules::flake8_annotations::settings::Settings { + ruff_linter::rules::flake8_annotations::settings::Settings { mypy_init_return: self.mypy_init_return.unwrap_or(false), suppress_dummy_args: self.suppress_dummy_args.unwrap_or(false), suppress_none_returning: self.suppress_none_returning.unwrap_or(false), @@ -727,11 +729,11 @@ pub struct Flake8BanditOptions { } impl Flake8BanditOptions { - pub fn into_settings(self) -> ruff::rules::flake8_bandit::settings::Settings { - ruff::rules::flake8_bandit::settings::Settings { + pub fn into_settings(self) -> ruff_linter::rules::flake8_bandit::settings::Settings { + ruff_linter::rules::flake8_bandit::settings::Settings { hardcoded_tmp_directory: self .hardcoded_tmp_directory - .unwrap_or_else(ruff::rules::flake8_bandit::settings::default_tmp_dirs) + .unwrap_or_else(ruff_linter::rules::flake8_bandit::settings::default_tmp_dirs) .into_iter() .chain(self.hardcoded_tmp_directory_extend.unwrap_or_default()) .collect(), @@ -764,8 +766,8 @@ pub struct Flake8BugbearOptions { } impl Flake8BugbearOptions { - pub fn into_settings(self) -> ruff::rules::flake8_bugbear::settings::Settings { - ruff::rules::flake8_bugbear::settings::Settings { + pub fn into_settings(self) -> ruff_linter::rules::flake8_bugbear::settings::Settings { + ruff_linter::rules::flake8_bugbear::settings::Settings { extend_immutable_calls: self.extend_immutable_calls.unwrap_or_default(), } } @@ -786,8 +788,8 @@ pub struct Flake8BuiltinsOptions { } impl Flake8BuiltinsOptions { - pub fn into_settings(self) -> ruff::rules::flake8_builtins::settings::Settings { - ruff::rules::flake8_builtins::settings::Settings { + pub fn into_settings(self) -> ruff_linter::rules::flake8_builtins::settings::Settings { + ruff_linter::rules::flake8_builtins::settings::Settings { builtins_ignorelist: self.builtins_ignorelist.unwrap_or_default(), } } @@ -808,8 +810,8 @@ pub struct Flake8ComprehensionsOptions { } impl Flake8ComprehensionsOptions { - pub fn into_settings(self) -> ruff::rules::flake8_comprehensions::settings::Settings { - ruff::rules::flake8_comprehensions::settings::Settings { + pub fn into_settings(self) -> ruff_linter::rules::flake8_comprehensions::settings::Settings { + ruff_linter::rules::flake8_comprehensions::settings::Settings { allow_dict_calls_with_keyword_arguments: self .allow_dict_calls_with_keyword_arguments .unwrap_or_default(), @@ -2241,7 +2243,7 @@ impl PyUpgradeOptions { #[cfg(test)] mod tests { use crate::options::Flake8SelfOptions; - use ruff::rules::flake8_self; + use ruff_linter::rules::flake8_self; #[test] fn flake8_self_options() { diff --git a/crates/ruff_workspace/src/pyproject.rs b/crates/ruff_workspace/src/pyproject.rs index 8fbeda1d93..cf6fb30893 100644 --- a/crates/ruff_workspace/src/pyproject.rs +++ b/crates/ruff_workspace/src/pyproject.rs @@ -2,13 +2,15 @@ use std::path::{Path, PathBuf}; -use crate::options::Options; use anyhow::Result; use log::debug; use pep440_rs::VersionSpecifiers; -use ruff::settings::types::PythonVersion; use serde::{Deserialize, Serialize}; +use ruff_linter::settings::types::PythonVersion; + +use crate::options::Options; + #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] struct Tools { ruff: Option, @@ -152,14 +154,16 @@ pub fn load_options>(path: P) -> Result { mod tests { use std::str::FromStr; + use anyhow::Result; + use rustc_hash::FxHashMap; + + use ruff_linter::codes; + use ruff_linter::line_width::LineLength; + use ruff_linter::settings::types::PatternPrefixPair; + use crate::options::Options; use crate::pyproject::{find_settings_toml, parse_pyproject_toml, Pyproject, Tools}; use crate::tests::test_resource_path; - use anyhow::Result; - use ruff::codes; - use ruff::line_width::LineLength; - use ruff::settings::types::PatternPrefixPair; - use rustc_hash::FxHashMap; #[test] diff --git a/crates/ruff_workspace/src/resolver.rs b/crates/ruff_workspace/src/resolver.rs index ae8fcb2244..783b27e325 100644 --- a/crates/ruff_workspace/src/resolver.rs +++ b/crates/ruff_workspace/src/resolver.rs @@ -13,12 +13,13 @@ use log::debug; use path_absolutize::path_dedot; use rustc_hash::{FxHashMap, FxHashSet}; +use ruff_linter::fs; +use ruff_linter::packaging::is_package; +use ruff_linter::settings::{AllSettings, Settings}; + use crate::configuration::Configuration; use crate::pyproject; use crate::pyproject::settings_toml; -use ruff::fs; -use ruff::packaging::is_package; -use ruff::settings::{AllSettings, Settings}; /// The configuration information from a `pyproject.toml` file. pub struct PyprojectConfig { @@ -503,11 +504,11 @@ mod tests { use path_absolutize::Absolutize; use tempfile::TempDir; + use ruff_linter::settings::types::FilePattern; + use ruff_linter::settings::AllSettings; + use crate::configuration::Configuration; use crate::pyproject::find_settings_toml; - use ruff::settings::types::FilePattern; - use ruff::settings::AllSettings; - use crate::resolver::{ is_file_excluded, match_exclusion, python_files_in_path, resolve_settings_with_processor, ConfigProcessor, PyprojectConfig, PyprojectDiscoveryStrategy, Relativity, Resolver, diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 9d2cf37846..bce1c8f9f3 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -19,7 +19,7 @@ cargo-fuzz = true [dependencies] arbitrary = { version = "1.3.0", features = ["derive"] } libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer", default-features = false } -ruff = { path = "../crates/ruff" } +ruff_linter = { path = "../crates/ruff_linter" } ruff_python_ast = { path = "../crates/ruff_python_ast" } ruff_python_codegen = { path = "../crates/ruff_python_codegen" } ruff_python_formatter = { path = "../crates/ruff_python_formatter" } diff --git a/fuzz/README.md b/fuzz/README.md index 406fc4c913..2c3a8b76f6 100644 --- a/fuzz/README.md +++ b/fuzz/README.md @@ -98,6 +98,6 @@ fuzzer, but this may be too strict of a restriction for initial testing. ### `ruff_fix_validity` This fuzz harness checks that fixes applied by Ruff do not introduce new errors using the existing -[`ruff::test::test_snippet`](../crates/ruff/src/test.rs) testing utility. +[`ruff_linter::test::test_snippet`](../crates/ruff_linter/src/test.rs) testing utility. It currently is only configured to use default settings, but may be extended in future versions to test non-default linter settings. diff --git a/fuzz/fuzz_targets/ruff_fix_validity.rs b/fuzz/fuzz_targets/ruff_fix_validity.rs index 7f70cd1b12..8bebda3c93 100644 --- a/fuzz/fuzz_targets/ruff_fix_validity.rs +++ b/fuzz/fuzz_targets/ruff_fix_validity.rs @@ -4,22 +4,24 @@ #![no_main] use libfuzzer_sys::{fuzz_target, Corpus}; -use ruff::settings::Settings; +use ruff_linter::settings::Settings; use std::sync::OnceLock; static SETTINGS: OnceLock = OnceLock::new(); fn do_fuzz(case: &[u8]) -> Corpus { // throw away inputs which aren't utf-8 - let Ok(code) = std::str::from_utf8(case) else { return Corpus::Reject; }; + let Ok(code) = std::str::from_utf8(case) else { + return Corpus::Reject; + }; // the settings are immutable to test_snippet, so we avoid re-initialising here let settings = SETTINGS.get_or_init(Settings::default); - ruff::test::set_max_iterations(usize::MAX); + ruff_linter::test::set_max_iterations(usize::MAX); // unlike in the test framework, where the number of iterations is well-defined, we are only // looking for situations where a fix is bad; thus, we set the iterations to "infinite" - let _ = ruff::test::test_snippet(code, settings); + let _ = ruff_linter::test::test_snippet(code, settings); Corpus::Keep } diff --git a/fuzz/init-fuzzer.sh b/fuzz/init-fuzzer.sh index cc99cdee27..70e07650ca 100755 --- a/fuzz/init-fuzzer.sh +++ b/fuzz/init-fuzzer.sh @@ -18,7 +18,7 @@ if [ ! -d corpus/ruff_fix_validity ]; then curl -L 'https://zenodo.org/record/3628784/files/python-corpus.tar.gz?download=1' | tar xz fi curl -L 'https://github.com/python/cpython/archive/refs/tags/v3.12.0b2.tar.gz' | tar xz - cp -r "../../../crates/ruff/resources/test" . + cp -r "../../../crates/ruff_linter/resources/test" . cd - cargo fuzz cmin -s none ruff_fix_validity fi diff --git a/fuzz/reinit-fuzzer.sh b/fuzz/reinit-fuzzer.sh index 9ff9fd1ad1..dbe5820549 100644 --- a/fuzz/reinit-fuzzer.sh +++ b/fuzz/reinit-fuzzer.sh @@ -7,7 +7,7 @@ cd "$SCRIPT_DIR" cd corpus/ruff_fix_validity curl -L 'https://github.com/python/cpython/archive/refs/tags/v3.12.0b2.tar.gz' | tar xz -cp -r "../../../crates/ruff/resources/test" . +cp -r "../../../crates/ruff_linter/resources/test" . cd - cargo fuzz cmin -s none ruff_fix_validity diff --git a/pyproject.toml b/pyproject.toml index b8cf4ab775..14a2bd48d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,20 +50,20 @@ module-name = "ruff" python-source = "python" strip = true exclude = [ - "crates/ruff/resources/test/fixtures/**/*", - "crates/ruff/src/rules/*/snapshots/**/*" + "crates/ruff_linter/resources/test/fixtures/**/*", + "crates/ruff_linter/src/rules/*/snapshots/**/*" ] [tool.ruff] extend-exclude = [ - "crates/ruff/resources/", + "crates/ruff_linter/resources/", "crates/ruff_python_formatter/resources/" ] [tool.black] force-exclude = ''' /( - | crates/ruff/resources + | crates/ruff_linter/resources | crates/ruff_python_formatter/resources )/ ''' diff --git a/scripts/add_plugin.py b/scripts/add_plugin.py index 219cfa42ad..e930398c65 100755 --- a/scripts/add_plugin.py +++ b/scripts/add_plugin.py @@ -18,12 +18,12 @@ from _utils import ROOT_DIR, dir_name, get_indent, pascal_case def main(*, plugin: str, url: str, prefix_code: str) -> None: """Generate boilerplate for a new plugin.""" # Create the test fixture folder. - (ROOT_DIR / "crates/ruff/resources/test/fixtures" / dir_name(plugin)).mkdir( + (ROOT_DIR / "crates/ruff_linter/resources/test/fixtures" / dir_name(plugin)).mkdir( exist_ok=True, ) # Create the Plugin rules module. - plugin_dir = ROOT_DIR / "crates/ruff/src/rules" / dir_name(plugin) + plugin_dir = ROOT_DIR / "crates/ruff_linter/src/rules" / dir_name(plugin) plugin_dir.mkdir(exist_ok=True) with (plugin_dir / "mod.rs").open("w+") as fp: @@ -67,16 +67,16 @@ mod tests { (plugin_dir / "snapshots").mkdir(exist_ok=True) # Add the plugin to `rules/mod.rs`. - rules_mod_path = ROOT_DIR / "crates/ruff/src/rules/mod.rs" + rules_mod_path = ROOT_DIR / "crates/ruff_linter/src/rules/mod.rs" lines = rules_mod_path.read_text().strip().splitlines() lines.append(f"pub mod {dir_name(plugin)};") lines.sort() rules_mod_path.write_text("\n".join(lines) + "\n") # Add the relevant sections to `src/registry.rs`. - content = (ROOT_DIR / "crates/ruff/src/registry.rs").read_text() + content = (ROOT_DIR / "crates/ruff_linter/src/registry.rs").read_text() - with (ROOT_DIR / "crates/ruff/src/registry.rs").open("w") as fp: + with (ROOT_DIR / "crates/ruff_linter/src/registry.rs").open("w") as fp: for line in content.splitlines(): indent = get_indent(line) @@ -94,14 +94,14 @@ mod tests { fp.write("\n") text = "" - with (ROOT_DIR / "crates/ruff/src/codes.rs").open("r") as fp: + with (ROOT_DIR / "crates/ruff_linter/src/codes.rs").open("r") as fp: while (line := next(fp)).strip() != "// ruff": text += line text += " " * 8 + f"// {plugin}\n\n" text += line text += fp.read() - with (ROOT_DIR / "crates/ruff/src/codes.rs").open("w") as fp: + with (ROOT_DIR / "crates/ruff_linter/src/codes.rs").open("w") as fp: fp.write(text) diff --git a/scripts/add_rule.py b/scripts/add_rule.py index ad478666a4..841088b9b5 100755 --- a/scripts/add_rule.py +++ b/scripts/add_rule.py @@ -23,7 +23,7 @@ def main(*, name: str, prefix: str, code: str, linter: str) -> None: filestem = f"{prefix}{code}" if linter != "pylint" else snake_case(name) with ( ROOT_DIR - / "crates/ruff/resources/test/fixtures" + / "crates/ruff_linter/resources/test/fixtures" / dir_name(linter) / f"{filestem}.py" ).open( @@ -31,7 +31,7 @@ def main(*, name: str, prefix: str, code: str, linter: str) -> None: ): pass - plugin_module = ROOT_DIR / "crates/ruff/src/rules" / dir_name(linter) + plugin_module = ROOT_DIR / "crates/ruff_linter/src/rules" / dir_name(linter) rule_name_snake = snake_case(name) # Add the relevant `#testcase` macro. @@ -128,7 +128,7 @@ pub(crate) fn {rule_name_snake}(checker: &mut Checker) {{}} ) text = "" - with (ROOT_DIR / "crates/ruff/src/codes.rs").open("r") as fp: + with (ROOT_DIR / "crates/ruff_linter/src/codes.rs").open("r") as fp: while (line := next(fp)).strip() != f"// {linter}": text += line text += line @@ -147,7 +147,7 @@ pub(crate) fn {rule_name_snake}(checker: &mut Checker) {{}} text += "".join(lines) text += "\n" text += fp.read() - with (ROOT_DIR / "crates/ruff/src/codes.rs").open("w") as fp: + with (ROOT_DIR / "crates/ruff_linter/src/codes.rs").open("w") as fp: fp.write(text) _rustfmt(rules_mod) diff --git a/scripts/benchmarks/run.sh b/scripts/benchmarks/run.sh index f06d8a6119..c0d6337298 100755 --- a/scripts/benchmarks/run.sh +++ b/scripts/benchmarks/run.sh @@ -5,4 +5,4 @@ ### cargo build --release && hyperfine --ignore-failure --warmup 10 \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache" + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache" diff --git a/scripts/benchmarks/run_all.sh b/scripts/benchmarks/run_all.sh index f6f2300ab0..67a0c21046 100755 --- a/scripts/benchmarks/run_all.sh +++ b/scripts/benchmarks/run_all.sh @@ -20,7 +20,7 @@ # }) hyperfine --ignore-failure --warmup 5 \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --select ALL" \ - "flake8 crates/ruff/resources/test/cpython -qq --docstring-convention=all" \ - "pycodestyle crates/ruff/resources/test/cpython -qq" \ - "pylint crates/ruff/resources/test/cpython -j 0 --recursive=y --disable=E,W,C,R" + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --select ALL" \ + "flake8 crates/ruff_linter/resources/test/cpython -qq --docstring-convention=all" \ + "pycodestyle crates/ruff_linter/resources/test/cpython -qq" \ + "pylint crates/ruff_linter/resources/test/cpython -j 0 --recursive=y --disable=E,W,C,R" diff --git a/scripts/benchmarks/run_comparisons.sh b/scripts/benchmarks/run_comparisons.sh index 31646f4959..696d3345e5 100755 --- a/scripts/benchmarks/run_comparisons.sh +++ b/scripts/benchmarks/run_comparisons.sh @@ -5,8 +5,8 @@ ### hyperfine --ignore-failure --warmup 5 \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache" \ - "pyflakes crates/ruff/resources/test/cpython" \ - "autoflake --recursive --expand-star-imports --remove-all-unused-imports --remove-unused-variables --remove-duplicate-keys crates/ruff/resources/test/cpython" \ - "pycodestyle crates/ruff/resources/test/cpython" \ - "flake8 crates/ruff/resources/test/cpython" + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache" \ + "pyflakes crates/ruff_linter/resources/test/cpython" \ + "autoflake --recursive --expand-star-imports --remove-all-unused-imports --remove-unused-variables --remove-duplicate-keys crates/ruff_linter/resources/test/cpython" \ + "pycodestyle crates/ruff_linter/resources/test/cpython" \ + "flake8 crates/ruff_linter/resources/test/cpython" diff --git a/scripts/benchmarks/run_plugins.sh b/scripts/benchmarks/run_plugins.sh index 25be0a6d40..83e1e9a149 100644 --- a/scripts/benchmarks/run_plugins.sh +++ b/scripts/benchmarks/run_plugins.sh @@ -5,39 +5,39 @@ ### cargo build --release && hyperfine --ignore-failure --warmup 10 \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select C90" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select I" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select D" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select UP" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select N" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select YTT" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select ANN" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select S" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select BLE" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select FBT" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select B" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select A" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select C4" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select T10" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select EM" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select ISC" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select ICN" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select T20" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select PT" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select Q" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select RET" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select SIM" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select TID" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select ARG" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select DTZ" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select ERA" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select PD" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select PGH" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select PLC" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select PLE" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select PLR" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select PLW" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select PIE" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select COM" \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent --extend-select RUF" + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select C90" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select I" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select D" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select UP" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select N" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select YTT" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select ANN" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select S" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select BLE" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select FBT" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select B" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select A" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select C4" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select T10" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select EM" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select ISC" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select ICN" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select T20" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select PT" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select Q" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select RET" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select SIM" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select TID" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select ARG" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select DTZ" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select ERA" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select PD" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select PGH" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select PLC" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select PLE" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select PLR" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select PLW" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select PIE" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select COM" \ + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent --extend-select RUF" diff --git a/scripts/benchmarks/run_silent.sh b/scripts/benchmarks/run_silent.sh index 7940baa177..d7d7d25808 100755 --- a/scripts/benchmarks/run_silent.sh +++ b/scripts/benchmarks/run_silent.sh @@ -6,7 +6,7 @@ ### hyperfine --ignore-failure --warmup 5 \ - "./target/release/ruff ./crates/ruff/resources/test/cpython/ --no-cache --silent" \ - "pycodestyle ./crates/ruff/resources/test/cpython -qq" \ - "flake8 ./crates/ruff/resources/test/cpython -qq" \ - "pylint ./crates/ruff/resources/test/cpython -j 0 --recursive=y --disable=E,W,C,R" + "./target/release/ruff ./crates/ruff_linter/resources/test/cpython/ --no-cache --silent" \ + "pycodestyle ./crates/ruff_linter/resources/test/cpython -qq" \ + "flake8 ./crates/ruff_linter/resources/test/cpython -qq" \ + "pylint ./crates/ruff_linter/resources/test/cpython -j 0 --recursive=y --disable=E,W,C,R" diff --git a/scripts/benchmarks/setup.sh b/scripts/benchmarks/setup.sh index 7024ab9a7d..8caed7c113 100755 --- a/scripts/benchmarks/setup.sh +++ b/scripts/benchmarks/setup.sh @@ -4,4 +4,4 @@ # Setup the CPython repository to enable benchmarking. ### -git clone --branch 3.10 https://github.com/python/cpython.git crates/ruff/resources/test/cpython --filter=blob:none +git clone --branch 3.10 https://github.com/python/cpython.git crates/ruff_linter/resources/test/cpython --filter=blob:none diff --git a/scripts/update_ambiguous_characters.py b/scripts/update_ambiguous_characters.py index bfd6920e2b..0d0c20543f 100644 --- a/scripts/update_ambiguous_characters.py +++ b/scripts/update_ambiguous_characters.py @@ -5,7 +5,7 @@ import json import subprocess from pathlib import Path -CONFUSABLES_RS_PATH = "crates/ruff/src/rules/ruff/rules/confusables.rs" +CONFUSABLES_RS_PATH = "crates/ruff_linter/src/rules/ruff/rules/confusables.rs" AMBIGUOUS_JSON_URL = "https://raw.githubusercontent.com/hediet/vscode-unicode-data/main/out/ambiguous.json" prelude = """