From f33277a057d02b1c6c59b86a09133aa7fc617cf1 Mon Sep 17 00:00:00 2001 From: Chris Pryer <14341145+cnpryer@users.noreply.github.com> Date: Sun, 27 Aug 2023 04:54:42 -0400 Subject: [PATCH 1/7] Update playground README.md (#6909) --- playground/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/playground/README.md b/playground/README.md index 6613d376f867c..082b7a9f15984 100644 --- a/playground/README.md +++ b/playground/README.md @@ -4,11 +4,11 @@ In-browser playground for Ruff. Available [https://play.ruff.rs/](https://play.r ## Getting started -First, build the WASM module by running `npm run build:wasm` (release build) or -`npm run build:wasm` (debug build) from the `./playground` directory. +In order to build the WASM module install [`wasm-pack`](https://rustwasm.github.io/wasm-pack/). -Then, install TypeScript dependencies with `npm install`, and run the development server with -`npm run dev`. +Next, build the WASM module by running `npm run build:wasm` (release build) or `npm run dev:wasm` (debug build) from the `./playground` directory. + +Finally, install TypeScript dependencies with `npm install`, and run the development server with `npm run dev`. To run the datastore, which is based on [Workers KV](https://developers.cloudflare.com/workers/runtime-apis/kv/), install the [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/install-and-update/), From 3f3494ad447a2efe819da9e5a4de875c095638fe Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Sun, 27 Aug 2023 15:03:11 +0200 Subject: [PATCH 2/7] Implement ConfigProcessor on non-ref type (#6915) --- crates/ruff/src/resolver.rs | 21 ++++++++------------- crates/ruff_cli/src/args.rs | 2 +- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/crates/ruff/src/resolver.rs b/crates/ruff/src/resolver.rs index 4a84e997ade07..1df92b8b0a503 100644 --- a/crates/ruff/src/resolver.rs +++ b/crates/ruff/src/resolver.rs @@ -119,12 +119,13 @@ impl Resolver { } } -pub trait ConfigProcessor: Copy + Send + Sync { +pub trait ConfigProcessor: Sync { fn process_config(&self, config: &mut Configuration); } struct NoOpProcessor; -impl ConfigProcessor for &NoOpProcessor { + +impl ConfigProcessor for NoOpProcessor { fn process_config(&self, _config: &mut Configuration) {} } @@ -137,7 +138,7 @@ impl ConfigProcessor for &NoOpProcessor { pub fn resolve_configuration( pyproject: &Path, relativity: &Relativity, - processor: impl ConfigProcessor, + processor: &dyn ConfigProcessor, ) -> Result { let mut seen = FxHashSet::default(); let mut stack = vec![]; @@ -183,7 +184,7 @@ pub fn resolve_configuration( pub fn resolve_scoped_settings( pyproject: &Path, relativity: &Relativity, - processor: impl ConfigProcessor, + processor: &dyn ConfigProcessor, ) -> Result<(PathBuf, AllSettings)> { let configuration = resolve_configuration(pyproject, relativity, processor)?; let project_root = relativity.resolve(pyproject); @@ -191,18 +192,12 @@ pub fn resolve_scoped_settings( Ok((project_root, settings)) } -/// Extract the [`Settings`] from a given `pyproject.toml`. -pub fn resolve_settings(pyproject: &Path, relativity: &Relativity) -> Result { - let (_project_root, settings) = resolve_scoped_settings(pyproject, relativity, &NoOpProcessor)?; - Ok(settings) -} - /// Extract the [`Settings`] from a given `pyproject.toml` and process the /// configuration with the given [`ConfigProcessor`]. pub fn resolve_settings_with_processor( pyproject: &Path, relativity: &Relativity, - processor: impl ConfigProcessor, + processor: &dyn ConfigProcessor, ) -> Result { let (_project_root, settings) = resolve_scoped_settings(pyproject, relativity, processor)?; Ok(settings) @@ -222,7 +217,7 @@ fn match_exclusion, R: AsRef>( pub fn python_files_in_path( paths: &[PathBuf], pyproject_config: &PyprojectConfig, - processor: impl ConfigProcessor, + processor: &dyn ConfigProcessor, ) -> Result<(Vec>, Resolver)> { // Normalize every path (e.g., convert from relative to absolute). let mut paths: Vec = paths.iter().map(fs::normalize_path).unique().collect(); @@ -368,7 +363,7 @@ pub fn python_files_in_path( pub fn python_file_at_path( path: &Path, pyproject_config: &PyprojectConfig, - processor: impl ConfigProcessor, + processor: &dyn ConfigProcessor, ) -> Result { if !pyproject_config.settings.lib.force_exclude { return Ok(true); diff --git a/crates/ruff_cli/src/args.rs b/crates/ruff_cli/src/args.rs index aa299cad602c6..3fa194ceb41b0 100644 --- a/crates/ruff_cli/src/args.rs +++ b/crates/ruff_cli/src/args.rs @@ -513,7 +513,7 @@ pub struct Overrides { pub show_fixes: Option, } -impl ConfigProcessor for &Overrides { +impl ConfigProcessor for Overrides { fn process_config(&self, config: &mut ruff::settings::configuration::Configuration) { if let Some(cache_dir) = &self.cache_dir { config.cache_dir = Some(cache_dir.clone()); From 7c480236e0efb9cf8cb0169aef05c93d10516e43 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Sun, 27 Aug 2023 15:54:01 +0200 Subject: [PATCH 3/7] Use dyn dispatch for `any_over_*` (#6912) --- crates/ruff_python_ast/src/helpers.rs | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/crates/ruff_python_ast/src/helpers.rs b/crates/ruff_python_ast/src/helpers.rs index 522bdcd19bd5b..e27ab6f450793 100644 --- a/crates/ruff_python_ast/src/helpers.rs +++ b/crates/ruff_python_ast/src/helpers.rs @@ -114,10 +114,7 @@ where /// Call `func` over every `Expr` in `expr`, returning `true` if any expression /// returns `true`.. -pub fn any_over_expr(expr: &Expr, func: &F) -> bool -where - F: Fn(&Expr) -> bool, -{ +pub fn any_over_expr(expr: &Expr, func: &dyn Fn(&Expr) -> bool) -> bool { if func(expr) { return true; } @@ -248,10 +245,7 @@ where } } -pub fn any_over_type_param(type_param: &TypeParam, func: &F) -> bool -where - F: Fn(&Expr) -> bool, -{ +pub fn any_over_type_param(type_param: &TypeParam, func: &dyn Fn(&Expr) -> bool) -> bool { match type_param { TypeParam::TypeVar(ast::TypeParamTypeVar { bound, .. }) => bound .as_ref() @@ -261,10 +255,7 @@ where } } -pub fn any_over_pattern(pattern: &Pattern, func: &F) -> bool -where - F: Fn(&Expr) -> bool, -{ +pub fn any_over_pattern(pattern: &Pattern, func: &dyn Fn(&Expr) -> bool) -> bool { match pattern { Pattern::MatchValue(ast::PatternMatchValue { value, range: _ }) => { any_over_expr(value, func) @@ -300,10 +291,7 @@ where } } -pub fn any_over_stmt(stmt: &Stmt, func: &F) -> bool -where - F: Fn(&Expr) -> bool, -{ +pub fn any_over_stmt(stmt: &Stmt, func: &dyn Fn(&Expr) -> bool) -> bool { match stmt { Stmt::FunctionDef(ast::StmtFunctionDef { parameters, @@ -526,10 +514,7 @@ where } } -pub fn any_over_body(body: &[Stmt], func: &F) -> bool -where - F: Fn(&Expr) -> bool, -{ +pub fn any_over_body(body: &[Stmt], func: &dyn Fn(&Expr) -> bool) -> bool { body.iter().any(|stmt| any_over_stmt(stmt, func)) } From 381fc5b2a86a635d40f0db545d7ee8685b520ec1 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sun, 27 Aug 2023 11:04:02 -0400 Subject: [PATCH 4/7] Increase ecosystem CI coverage to 40 projects (#6916) ## Summary Roughly doubles the number of covered projects. --- scripts/check_ecosystem.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scripts/check_ecosystem.py b/scripts/check_ecosystem.py index 607819b263918..663cc0d51b56b 100755 --- a/scripts/check_ecosystem.py +++ b/scripts/check_ecosystem.py @@ -107,12 +107,29 @@ async def _get_commit(self: Self, checkout_dir: Path) -> str: REPOSITORIES: list[Repository] = [ Repository("DisnakeDev", "disnake", "master"), + Repository("PostHog", "HouseWatch", "main"), + Repository("RasaHQ", "rasa", "main"), + Repository("Snowflake-Labs", "snowcli", "main"), + Repository("aiven", "aiven-client", "main"), + Repository("alteryx", "featuretools", "main"), Repository("apache", "airflow", "main", select="ALL"), + Repository("aws", "aws-sam-cli", "develop"), + Repository("bloomberg", "pytest-memray", "main"), Repository("bokeh", "bokeh", "branch-3.3", select="ALL"), Repository("commaai", "openpilot", "master"), + Repository("demisto", "content", "master"), + Repository("docker", "docker-py", "main"), Repository("freedomofpress", "securedrop", "develop"), + Repository("fronzbot", "blinkpy", "dev"), Repository("ibis-project", "ibis", "master"), + Repository("ing-bank", "probatus", "main"), Repository("jrnl-org", "jrnl", "develop"), + Repository("latchbio", "latch", "main"), + Repository("lnbits", "lnbits", "main"), + Repository("milvus-io", "pymilvus", "master"), + Repository("mlflow", "mlflow", "master"), + Repository("model-bakers", "model_bakery", "main"), + Repository("pandas-dev", "pandas", "main"), Repository("pypa", "build", "main"), Repository("pypa", "cibuildwheel", "main"), Repository("pypa", "pip", "main"), @@ -120,10 +137,14 @@ async def _get_commit(self: Self, checkout_dir: Path) -> str: Repository("python", "mypy", "master"), Repository("python", "typeshed", "main", select="PYI"), Repository("python-poetry", "poetry", "master"), + Repository("reflex-dev", "reflex", "main"), + Repository("rotki", "rotki", "develop"), Repository("scikit-build", "scikit-build", "main"), Repository("scikit-build", "scikit-build-core", "main"), Repository("sphinx-doc", "sphinx", "master"), + Repository("spruceid", "siwe-py", "main"), Repository("tiangolo", "fastapi", "master"), + Repository("yandex", "ch-backup", "main"), Repository("zulip", "zulip", "main", select="ALL"), ] From d0b051e447a6159f7a94ab9bba8ac190c3eea949 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sun, 27 Aug 2023 11:27:07 -0400 Subject: [PATCH 5/7] Fix ranges for global usages (#6917) ## Summary The range of the usage from `Globals` should be the range of the identifier, not the range of the full `global pandas` statement. Closes https://github.com/astral-sh/ruff/issues/6914. --- .../flake8_import_conventions/tricky.py | 9 +++++ crates/ruff/src/checkers/ast/mod.rs | 2 + .../rules/flake8_import_conventions/mod.rs | 24 +++++++---- ...onventions__tests__override_defaults.snap} | 0 ..._conventions__tests__remove_defaults.snap} | 0 ...ke8_import_conventions__tests__tricky.snap | 26 ++++++++++++ ...t__tests__PLW0603_global_statement.py.snap | 40 +++++++++---------- crates/ruff_python_semantic/src/globals.rs | 6 +-- 8 files changed, 77 insertions(+), 30 deletions(-) create mode 100644 crates/ruff/resources/test/fixtures/flake8_import_conventions/tricky.py rename crates/ruff/src/rules/flake8_import_conventions/snapshots/{ruff__rules__flake8_import_conventions__tests__override_default.snap => ruff__rules__flake8_import_conventions__tests__override_defaults.snap} (100%) rename crates/ruff/src/rules/flake8_import_conventions/snapshots/{ruff__rules__flake8_import_conventions__tests__remove_default.snap => ruff__rules__flake8_import_conventions__tests__remove_defaults.snap} (100%) create mode 100644 crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__tricky.snap diff --git a/crates/ruff/resources/test/fixtures/flake8_import_conventions/tricky.py b/crates/ruff/resources/test/fixtures/flake8_import_conventions/tricky.py new file mode 100644 index 0000000000000..7360a7485afd1 --- /dev/null +++ b/crates/ruff/resources/test/fixtures/flake8_import_conventions/tricky.py @@ -0,0 +1,9 @@ +"""Test cases for difficult renames.""" + + +def rename_global(): + try: + global pandas + import pandas + except ImportError: + return False diff --git a/crates/ruff/src/checkers/ast/mod.rs b/crates/ruff/src/checkers/ast/mod.rs index d19d212b1979e..a22111f266108 100644 --- a/crates/ruff/src/checkers/ast/mod.rs +++ b/crates/ruff/src/checkers/ast/mod.rs @@ -1895,6 +1895,8 @@ impl<'a> Checker<'a> { for (name, range) in exports { if let Some(binding_id) = self.semantic.global_scope().get(name) { // Mark anything referenced in `__all__` as used. + // TODO(charlie): `range` here should be the range of the name in `__all__`, not + // the range of `__all__` itself. self.semantic.add_global_reference(binding_id, range); } else { if self.semantic.global_scope().uses_star_imports() { diff --git a/crates/ruff/src/rules/flake8_import_conventions/mod.rs b/crates/ruff/src/rules/flake8_import_conventions/mod.rs index 3df13cbea42ef..46fc75fd89188 100644 --- a/crates/ruff/src/rules/flake8_import_conventions/mod.rs +++ b/crates/ruff/src/rules/flake8_import_conventions/mod.rs @@ -20,7 +20,7 @@ mod tests { Path::new("flake8_import_conventions/defaults.py"), &Settings::for_rule(Rule::UnconventionalImportAlias), )?; - assert_messages!("defaults", diagnostics); + assert_messages!(diagnostics); Ok(()) } @@ -42,7 +42,7 @@ mod tests { ..Settings::for_rule(Rule::UnconventionalImportAlias) }, )?; - assert_messages!("custom", diagnostics); + assert_messages!(diagnostics); Ok(()) } @@ -75,7 +75,7 @@ mod tests { ..Settings::for_rule(Rule::BannedImportAlias) }, )?; - assert_messages!("custom_banned", diagnostics); + assert_messages!(diagnostics); Ok(()) } @@ -98,7 +98,7 @@ mod tests { ..Settings::for_rule(Rule::BannedImportFrom) }, )?; - assert_messages!("custom_banned_from", diagnostics); + assert_messages!(diagnostics); Ok(()) } @@ -122,7 +122,7 @@ mod tests { ..Settings::for_rule(Rule::UnconventionalImportAlias) }, )?; - assert_messages!("remove_default", diagnostics); + assert_messages!(diagnostics); Ok(()) } @@ -144,7 +144,7 @@ mod tests { ..Settings::for_rule(Rule::UnconventionalImportAlias) }, )?; - assert_messages!("override_default", diagnostics); + assert_messages!(diagnostics); Ok(()) } @@ -169,7 +169,17 @@ mod tests { ..Settings::for_rule(Rule::UnconventionalImportAlias) }, )?; - assert_messages!("from_imports", diagnostics); + assert_messages!(diagnostics); + Ok(()) + } + + #[test] + fn tricky() -> Result<()> { + let diagnostics = test_path( + Path::new("flake8_import_conventions/tricky.py"), + &Settings::for_rule(Rule::UnconventionalImportAlias), + )?; + assert_messages!(diagnostics); Ok(()) } } diff --git a/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__override_default.snap b/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__override_defaults.snap similarity index 100% rename from crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__override_default.snap rename to crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__override_defaults.snap diff --git a/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__remove_default.snap b/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__remove_defaults.snap similarity index 100% rename from crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__remove_default.snap rename to crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__remove_defaults.snap 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 new file mode 100644 index 0000000000000..1d936082662a3 --- /dev/null +++ b/crates/ruff/src/rules/flake8_import_conventions/snapshots/ruff__rules__flake8_import_conventions__tests__tricky.snap @@ -0,0 +1,26 @@ +--- +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/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 index 910f5d31fc14b..c84a187a2db71 100644 --- 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 @@ -1,100 +1,100 @@ --- source: crates/ruff/src/rules/pylint/mod.rs --- -global_statement.py:17:5: PLW0603 Using the global statement to update `CONSTANT` is discouraged +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 + | ^^^^^^^^ PLW0603 18 | print(CONSTANT) 19 | CONSTANT = value | -global_statement.py:24:5: PLW0603 Using the global statement to update `sys` is discouraged +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 + | ^^^ PLW0603 25 | import sys | -global_statement.py:30:5: PLW0603 Using the global statement to update `namedtuple` is discouraged +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 + | ^^^^^^^^^^ PLW0603 31 | from collections import namedtuple | -global_statement.py:36:5: PLW0603 Using the global statement to update `CONSTANT` is discouraged +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 + | ^^^^^^^^ PLW0603 37 | print(CONSTANT) 38 | del CONSTANT | -global_statement.py:43:5: PLW0603 Using the global statement to update `CONSTANT` is discouraged +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 + | ^^^^^^^^ PLW0603 44 | print(CONSTANT) 45 | CONSTANT += 1 | -global_statement.py:50:5: PLW0603 Using the global statement to update `CONSTANT` is discouraged +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 + | ^^^^^^^^ PLW0603 51 | 52 | def CONSTANT(): | -global_statement.py:60:5: PLW0603 Using the global statement to update `FUNC` is discouraged +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 + | ^^^^ PLW0603 61 | 62 | def FUNC(): | -global_statement.py:70:5: PLW0603 Using the global statement to update `CLASS` is discouraged +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 + | ^^^^^ PLW0603 71 | 72 | class CLASS: | -global_statement.py:80:5: PLW0603 Using the global statement to update `CONSTANT` is discouraged +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 + | ^^^^^^^^ PLW0603 81 | CONSTANT = 1 82 | CONSTANT = 2 | -global_statement.py:80:5: PLW0603 Using the global statement to update `CONSTANT` is discouraged +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 + | ^^^^^^^^ PLW0603 81 | CONSTANT = 1 82 | CONSTANT = 2 | diff --git a/crates/ruff_python_semantic/src/globals.rs b/crates/ruff_python_semantic/src/globals.rs index ffaf1b16f9dcc..03cdb687ced3e 100644 --- a/crates/ruff_python_semantic/src/globals.rs +++ b/crates/ruff_python_semantic/src/globals.rs @@ -5,7 +5,7 @@ use std::ops::Index; use ruff_python_ast as ast; -use ruff_python_ast::Stmt; +use ruff_python_ast::{Ranged, Stmt}; use ruff_text_size::TextRange; use rustc_hash::FxHashMap; @@ -75,9 +75,9 @@ impl<'a> GlobalsVisitor<'a> { impl<'a> StatementVisitor<'a> for GlobalsVisitor<'a> { fn visit_stmt(&mut self, stmt: &'a Stmt) { match stmt { - Stmt::Global(ast::StmtGlobal { names, range }) => { + Stmt::Global(ast::StmtGlobal { names, range: _ }) => { for name in names { - self.0.insert(name.as_str(), *range); + self.0.insert(name.as_str(), name.range()); } } Stmt::FunctionDef(_) | Stmt::ClassDef(_) => { From 88c8bece38ad6d3d5037f43364f92918c5fea812 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Sun, 27 Aug 2023 11:07:50 -0500 Subject: [PATCH 6/7] Add `PrefectHQ/prefect` to ecosystem checks (#6918) At least I will generally be familiar with the patterns over there --- scripts/check_ecosystem.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/check_ecosystem.py b/scripts/check_ecosystem.py index 663cc0d51b56b..cbce193023319 100755 --- a/scripts/check_ecosystem.py +++ b/scripts/check_ecosystem.py @@ -130,6 +130,7 @@ async def _get_commit(self: Self, checkout_dir: Path) -> str: Repository("mlflow", "mlflow", "master"), Repository("model-bakers", "model_bakery", "main"), Repository("pandas-dev", "pandas", "main"), + Repository("prefecthq", "prefect", "main"), Repository("pypa", "build", "main"), Repository("pypa", "cibuildwheel", "main"), Repository("pypa", "pip", "main"), From fc89976c24d1c8b9d13d88ef70b619e8a2ac393a Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sun, 27 Aug 2023 14:12:51 -0400 Subject: [PATCH 7/7] Move `Ranged` into `ruff_text_size` (#6919) ## Summary The motivation here is that this enables us to implement `Ranged` in crates that don't depend on `ruff_python_ast`. Largely a mechanical refactor with a lot of regex, Clippy help, and manual fixups. ## Test Plan `cargo test` --- crates/ruff/src/autofix/codemods.rs | 3 +- crates/ruff/src/autofix/edits.rs | 8 ++--- crates/ruff/src/autofix/mod.rs | 4 +-- .../ruff/src/checkers/ast/analyze/bindings.rs | 2 +- .../checkers/ast/analyze/deferred_scopes.rs | 2 +- .../src/checkers/ast/analyze/definitions.rs | 3 +- .../checkers/ast/analyze/except_handler.rs | 3 +- .../src/checkers/ast/analyze/expression.rs | 3 +- .../src/checkers/ast/analyze/parameter.rs | 3 +- .../src/checkers/ast/analyze/statement.rs | 5 ++- crates/ruff/src/checkers/ast/mod.rs | 6 ++-- crates/ruff/src/checkers/imports.rs | 5 ++- crates/ruff/src/checkers/logical_lines.rs | 3 +- crates/ruff/src/checkers/noqa.rs | 3 +- crates/ruff/src/directives.rs | 2 +- crates/ruff/src/doc_lines.rs | 4 +-- crates/ruff/src/docstrings/mod.rs | 4 +-- crates/ruff/src/docstrings/sections.rs | 3 +- crates/ruff/src/importer/insertion.rs | 4 +-- crates/ruff/src/importer/mod.rs | 4 +-- crates/ruff/src/message/text.rs | 2 +- crates/ruff/src/noqa.rs | 3 +- crates/ruff/src/renamer.rs | 2 +- .../rules/airflow/rules/task_variable_name.rs | 3 +- .../src/rules/flake8_2020/rules/compare.rs | 3 +- .../flake8_2020/rules/name_or_attribute.rs | 3 +- .../src/rules/flake8_2020/rules/subscript.rs | 3 +- .../flake8_annotations/rules/definition.rs | 3 +- .../flake8_async/rules/blocking_http_call.rs | 3 +- .../flake8_async/rules/blocking_os_call.rs | 3 +- .../rules/open_sleep_or_subprocess_call.rs | 3 +- .../rules/flake8_bandit/rules/assert_used.rs | 3 +- .../rules/bad_file_permissions.rs | 3 +- .../rules/flake8_bandit/rules/exec_used.rs | 3 +- .../rules/hardcoded_password_default.rs | 3 +- .../rules/hardcoded_password_func_arg.rs | 3 +- .../rules/hardcoded_password_string.rs | 4 +-- .../rules/hardcoded_sql_expression.rs | 3 +- .../rules/hardcoded_tmp_directory.rs | 3 +- .../rules/hashlib_insecure_hash_functions.rs | 3 +- .../rules/jinja2_autoescape_false.rs | 3 +- .../rules/logging_config_insecure_listen.rs | 3 +- .../flake8_bandit/rules/paramiko_calls.rs | 3 +- .../rules/request_with_no_cert_validation.rs | 3 +- .../rules/request_without_timeout.rs | 3 +- .../flake8_bandit/rules/shell_injection.rs | 3 +- .../rules/snmp_insecure_version.rs | 3 +- .../rules/snmp_weak_cryptography.rs | 3 +- .../rules/suspicious_function_call.rs | 3 +- .../rules/try_except_continue.rs | 3 +- .../flake8_bandit/rules/try_except_pass.rs | 3 +- .../flake8_bandit/rules/unsafe_yaml_load.rs | 3 +- .../flake8_blind_except/rules/blind_except.rs | 3 +- ...olean_default_value_positional_argument.rs | 3 +- .../rules/boolean_positional_value_in_call.rs | 3 +- .../boolean_type_hint_positional_argument.rs | 5 ++- .../rules/abstract_base_class.rs | 3 +- .../flake8_bugbear/rules/assert_false.rs | 4 +-- .../rules/assert_raises_exception.rs | 3 +- .../rules/assignment_to_os_environ.rs | 3 +- .../rules/cached_instance_method.rs | 3 +- .../rules/duplicate_exceptions.rs | 4 +-- .../flake8_bugbear/rules/duplicate_value.rs | 3 +- .../rules/except_with_empty_tuple.rs | 3 +- .../except_with_non_exception_classes.rs | 3 +- .../function_call_in_argument_default.rs | 4 +-- .../rules/function_uses_loop_variable.rs | 3 +- .../rules/getattr_with_constant.rs | 3 +- .../rules/jump_statement_in_finally.rs | 3 +- .../rules/loop_variable_overrides_iterator.rs | 3 +- .../rules/mutable_argument_default.rs | 3 +- .../rules/no_explicit_stacklevel.rs | 3 +- .../flake8_bugbear/rules/raise_literal.rs | 3 +- .../rules/re_sub_positional_args.rs | 3 +- .../redundant_tuple_in_exception_handler.rs | 3 +- .../rules/reuse_of_groupby_generator.rs | 3 +- .../rules/setattr_with_constant.rs | 4 +-- .../star_arg_unpacking_after_keyword_arg.rs | 3 +- .../rules/strip_with_multi_characters.rs | 3 +- .../rules/unary_prefix_increment_decrement.rs | 3 +- .../rules/unintentional_type_annotation.rs | 3 +- .../rules/unreliable_callable_check.rs | 3 +- .../rules/unused_loop_control_variable.rs | 3 +- .../rules/useless_comparison.rs | 3 +- .../rules/useless_contextlib_suppress.rs | 3 +- .../rules/useless_expression.rs | 3 +- .../rules/zip_without_explicit_strict.rs | 3 +- .../rules/builtin_argument_shadowing.rs | 3 +- .../src/rules/flake8_comprehensions/fixes.rs | 4 +-- .../rules/unnecessary_call_around_sorted.rs | 3 +- .../rules/unnecessary_collection_call.rs | 3 +- .../rules/unnecessary_comprehension.rs | 3 +- .../unnecessary_comprehension_any_all.rs | 3 +- .../unnecessary_double_cast_or_process.rs | 3 +- .../rules/unnecessary_generator_dict.rs | 3 +- .../rules/unnecessary_generator_list.rs | 3 +- .../rules/unnecessary_generator_set.rs | 3 +- .../rules/unnecessary_list_call.rs | 3 +- .../unnecessary_list_comprehension_dict.rs | 3 +- .../unnecessary_list_comprehension_set.rs | 3 +- .../rules/unnecessary_literal_dict.rs | 3 +- .../rules/unnecessary_literal_set.rs | 3 +- .../unnecessary_literal_within_dict_call.rs | 3 +- .../unnecessary_literal_within_list_call.rs | 3 +- .../unnecessary_literal_within_tuple_call.rs | 3 +- .../rules/unnecessary_map.rs | 3 +- .../rules/unnecessary_subscript_reversal.rs | 3 +- .../rules/call_datetime_fromtimestamp.rs | 3 +- .../rules/call_datetime_now_without_tzinfo.rs | 3 +- .../call_datetime_strptime_without_zone.rs | 3 +- .../rules/call_datetime_without_tzinfo.rs | 3 +- .../rules/flake8_debugger/rules/debugger.rs | 3 +- .../rules/all_with_model_form.rs | 3 +- .../rules/exclude_with_model_form.rs | 3 +- .../rules/locals_in_render_function.rs | 3 +- .../rules/model_without_dunder_str.rs | 3 +- .../rules/non_leading_receiver_decorator.rs | 3 +- .../rules/nullable_model_string_field.rs | 3 +- .../rules/unordered_body_content_in_model.rs | 3 +- .../rules/string_in_exception.rs | 4 +-- .../rules/shebang_missing_executable_file.rs | 2 +- .../rules/shebang_not_executable.rs | 2 +- .../rules/future_required_type_annotation.rs | 3 +- .../future_rewritable_type_annotation.rs | 3 +- .../rules/f_string_in_gettext_func_call.rs | 3 +- .../rules/format_in_gettext_func_call.rs | 3 +- .../rules/printf_in_gettext_func_call.rs | 3 +- .../rules/explicit.rs | 3 +- .../rules/implicit.rs | 2 +- .../rules/banned_import_alias.rs | 3 +- .../rules/banned_import_from.rs | 3 +- .../rules/unconventional_import_alias.rs | 2 +- .../rules/logging_call.rs | 3 +- .../rules/duplicate_class_field_definition.rs | 3 +- .../rules/multiple_starts_ends_with.rs | 4 +-- .../flake8_pie/rules/no_unnecessary_pass.rs | 3 +- .../flake8_pie/rules/non_unique_enums.rs | 3 +- .../rules/reimplemented_list_builtin.rs | 3 +- .../rules/unnecessary_dict_kwargs.rs | 3 +- .../rules/unnecessary_range_start.rs | 3 +- .../flake8_pie/rules/unnecessary_spread.rs | 3 +- .../rules/flake8_print/rules/print_call.rs | 3 +- .../flake8_pyi/rules/any_eq_ne_annotation.rs | 3 +- .../rules/bad_version_info_comparison.rs | 3 +- .../rules/collections_named_tuple.rs | 2 +- .../rules/complex_if_statement_in_stub.rs | 3 +- .../rules/custom_type_var_return_type.rs | 3 +- .../flake8_pyi/rules/docstring_in_stubs.rs | 3 +- .../rules/duplicate_union_member.rs | 3 +- .../rules/ellipsis_in_non_empty_class_body.rs | 3 +- .../flake8_pyi/rules/exit_annotations.rs | 3 +- .../rules/iter_method_return_iterable.rs | 3 +- .../rules/no_return_argument_annotation.rs | 3 +- .../flake8_pyi/rules/non_empty_stub_body.rs | 3 +- .../rules/numeric_literal_too_long.rs | 4 +-- .../flake8_pyi/rules/pass_in_class_body.rs | 3 +- .../rules/pass_statement_stub_body.rs | 3 +- .../flake8_pyi/rules/prefix_type_params.rs | 3 +- .../rules/redundant_literal_union.rs | 3 +- .../rules/redundant_numeric_union.rs | 3 +- .../rules/flake8_pyi/rules/simple_defaults.rs | 5 +-- .../rules/string_or_bytes_too_long.rs | 3 +- .../unaliased_collections_abc_set_import.rs | 2 +- .../rules/unnecessary_literal_union.rs | 3 +- .../rules/unnecessary_type_union.rs | 3 +- .../flake8_pyi/rules/unrecognized_platform.rs | 3 +- .../rules/unrecognized_version_info.rs | 3 +- .../rules/unsupported_method_call_on_all.rs | 3 +- .../rules/unused_private_type_definition.rs | 3 +- .../flake8_pytest_style/rules/assertion.rs | 3 +- .../rules/flake8_pytest_style/rules/fail.rs | 3 +- .../flake8_pytest_style/rules/fixture.rs | 3 +- .../flake8_pytest_style/rules/imports.rs | 3 +- .../rules/flake8_pytest_style/rules/marks.rs | 3 +- .../flake8_pytest_style/rules/parametrize.rs | 4 +-- .../rules/flake8_pytest_style/rules/patch.rs | 3 +- .../rules/flake8_pytest_style/rules/raises.rs | 3 +- .../unnecessary_paren_on_raise_exception.rs | 3 +- .../ruff/src/rules/flake8_return/helpers.rs | 4 +-- .../src/rules/flake8_return/rules/function.rs | 4 +-- .../rules/private_member_access.rs | 3 +- .../flake8_simplify/rules/ast_bool_op.rs | 4 +-- .../rules/flake8_simplify/rules/ast_expr.rs | 4 +-- .../src/rules/flake8_simplify/rules/ast_if.rs | 5 ++- .../rules/flake8_simplify/rules/ast_ifexp.rs | 4 +-- .../flake8_simplify/rules/ast_unary_op.rs | 4 +-- .../rules/flake8_simplify/rules/ast_with.rs | 4 +-- .../rules/flake8_simplify/rules/fix_with.rs | 5 +-- .../flake8_simplify/rules/key_in_dict.rs | 4 +-- .../rules/open_file_with_context_handler.rs | 3 +- .../rules/reimplemented_builtin.rs | 5 ++- .../rules/return_in_try_except_finally.rs | 3 +- .../rules/suppressible_exception.rs | 3 +- .../flake8_simplify/rules/yoda_conditions.rs | 3 +- .../flake8_tidy_imports/rules/banned_api.rs | 3 +- .../rules/banned_module_level_imports.rs | 2 +- .../rules/relative_imports.rs | 4 +-- .../rules/empty_type_checking_block.rs | 2 +- .../runtime_import_in_type_checking_block.rs | 3 +- .../rules/typing_only_runtime_import.rs | 3 +- .../rules/unused_arguments.rs | 3 +- .../flake8_use_pathlib/rules/os_sep_split.rs | 3 +- .../rules/replaceable_by_pathlib.rs | 4 +-- .../flynt/rules/static_join_to_fstring.rs | 4 +-- crates/ruff/src/rules/isort/annotate.rs | 4 +-- crates/ruff/src/rules/isort/block.rs | 4 +-- crates/ruff/src/rules/isort/comments.rs | 3 +- crates/ruff/src/rules/isort/helpers.rs | 4 +-- .../rules/isort/rules/add_required_imports.rs | 4 +-- .../src/rules/isort/rules/organize_imports.rs | 4 +-- .../rules/numpy/rules/deprecated_function.rs | 3 +- .../numpy/rules/deprecated_type_alias.rs | 3 +- .../src/rules/numpy/rules/legacy_random.rs | 3 +- .../pandas_vet/rules/assignment_to_df.rs | 3 +- .../ruff/src/rules/pandas_vet/rules/attr.rs | 3 +- .../ruff/src/rules/pandas_vet/rules/call.rs | 3 +- .../pandas_vet/rules/inplace_argument.rs | 3 +- .../rules/nunique_constant_series_check.rs | 3 +- .../src/rules/pandas_vet/rules/pd_merge.rs | 3 +- .../src/rules/pandas_vet/rules/read_table.rs | 3 +- .../src/rules/pandas_vet/rules/subscript.rs | 3 +- .../rules/camelcase_imported_as_acronym.rs | 3 +- .../rules/camelcase_imported_as_constant.rs | 3 +- .../rules/camelcase_imported_as_lowercase.rs | 3 +- .../constant_imported_as_non_constant.rs | 3 +- .../rules/invalid_argument_name.rs | 3 +- ...id_first_argument_name_for_class_method.rs | 3 +- .../invalid_first_argument_name_for_method.rs | 3 +- .../pep8_naming/rules/invalid_module_name.rs | 3 +- .../lowercase_imported_as_non_lowercase.rs | 3 +- .../mixed_case_variable_in_class_scope.rs | 3 +- .../mixed_case_variable_in_global_scope.rs | 3 +- .../non_lowercase_variable_in_function.rs | 3 +- .../perflint/rules/incorrect_dict_iterator.rs | 2 +- .../perflint/rules/try_except_in_loop.rs | 3 +- .../perflint/rules/unnecessary_list_cast.rs | 5 ++- crates/ruff/src/rules/pycodestyle/helpers.rs | 4 +-- .../pycodestyle/rules/ambiguous_class_name.rs | 3 +- .../rules/ambiguous_function_name.rs | 3 +- .../src/rules/pycodestyle/rules/imports.rs | 3 +- .../pycodestyle/rules/lambda_assignment.rs | 5 ++- .../pycodestyle/rules/literal_comparisons.rs | 3 +- .../logical_lines/extraneous_whitespace.rs | 3 +- .../rules/logical_lines/missing_whitespace.rs | 3 +- .../missing_whitespace_after_keyword.rs | 2 +- .../missing_whitespace_around_operator.rs | 2 +- .../pycodestyle/rules/logical_lines/mod.rs | 3 +- .../logical_lines/space_around_operator.rs | 3 +- .../whitespace_around_keywords.rs | 3 +- ...hitespace_around_named_parameter_equals.rs | 3 +- .../whitespace_before_comment.rs | 3 +- .../whitespace_before_parameters.rs | 3 +- .../src/rules/pycodestyle/rules/not_tests.rs | 3 +- .../pycodestyle/rules/trailing_whitespace.rs | 3 +- .../pycodestyle/rules/type_comparison.rs | 3 +- .../src/rules/pydocstyle/rules/backslashes.rs | 2 +- .../pydocstyle/rules/blank_after_summary.rs | 2 +- .../rules/blank_before_after_class.rs | 2 +- .../rules/blank_before_after_function.rs | 2 +- .../src/rules/pydocstyle/rules/capitalized.rs | 2 +- .../pydocstyle/rules/ends_with_period.rs | 2 +- .../pydocstyle/rules/ends_with_punctuation.rs | 2 +- .../ruff/src/rules/pydocstyle/rules/indent.rs | 2 +- .../rules/multi_line_summary_start.rs | 4 +-- .../rules/newline_after_last_paragraph.rs | 2 +- .../rules/pydocstyle/rules/no_signature.rs | 2 +- .../rules/no_surrounding_whitespace.rs | 2 +- .../pydocstyle/rules/non_imperative_mood.rs | 2 +- .../src/rules/pydocstyle/rules/not_empty.rs | 2 +- .../src/rules/pydocstyle/rules/one_liner.rs | 2 +- .../src/rules/pydocstyle/rules/sections.rs | 4 +-- .../pydocstyle/rules/starts_with_this.rs | 2 +- .../rules/pydocstyle/rules/triple_quotes.rs | 2 +- crates/ruff/src/rules/pyflakes/fixes.rs | 3 +- .../src/rules/pyflakes/rules/assert_tuple.rs | 3 +- .../pyflakes/rules/break_outside_loop.rs | 3 +- .../pyflakes/rules/continue_outside_loop.rs | 3 +- .../rules/f_string_missing_placeholders.rs | 7 ++-- .../rules/future_feature_not_defined.rs | 3 +- .../ruff/src/rules/pyflakes/rules/if_tuple.rs | 3 +- .../rules/invalid_literal_comparisons.rs | 3 +- .../pyflakes/rules/invalid_print_syntax.rs | 3 +- .../pyflakes/rules/raise_not_implemented.rs | 3 +- .../src/rules/pyflakes/rules/repeated_keys.rs | 3 +- .../pyflakes/rules/return_outside_function.rs | 3 +- .../ruff/src/rules/pyflakes/rules/strings.rs | 4 +-- .../rules/pyflakes/rules/undefined_local.rs | 2 +- .../rules/pyflakes/rules/unused_annotation.rs | 2 +- .../src/rules/pyflakes/rules/unused_import.rs | 3 +- .../rules/pyflakes/rules/unused_variable.rs | 4 +-- .../pyflakes/rules/yield_outside_function.rs | 3 +- .../rules/pygrep_hooks/rules/blanket_noqa.rs | 3 +- .../pygrep_hooks/rules/blanket_type_ignore.rs | 2 +- .../pygrep_hooks/rules/deprecated_log_warn.rs | 3 +- .../pygrep_hooks/rules/invalid_mock_access.rs | 3 +- .../src/rules/pygrep_hooks/rules/no_eval.rs | 3 +- .../pylint/rules/assert_on_string_literal.rs | 3 +- .../rules/pylint/rules/await_outside_async.rs | 3 +- .../rules/pylint/rules/bad_str_strip_call.rs | 3 +- .../rules/bad_string_format_character.rs | 4 +-- .../pylint/rules/bad_string_format_type.rs | 4 +-- .../rules/pylint/rules/binary_op_exception.rs | 3 +- .../rules/pylint/rules/collapsible_else_if.rs | 4 +-- .../pylint/rules/compare_to_empty_string.rs | 3 +- .../pylint/rules/comparison_of_constant.rs | 3 +- .../pylint/rules/comparison_with_itself.rs | 3 +- .../rules/pylint/rules/continue_in_finally.rs | 3 +- .../src/rules/pylint/rules/duplicate_bases.rs | 3 +- .../src/rules/pylint/rules/eq_without_hash.rs | 3 +- .../src/rules/pylint/rules/import_self.rs | 3 +- .../rules/pylint/rules/invalid_all_format.rs | 2 +- .../rules/pylint/rules/invalid_all_object.rs | 2 +- .../pylint/rules/invalid_envvar_default.rs | 3 +- .../pylint/rules/invalid_envvar_value.rs | 3 +- .../rules/pylint/rules/invalid_str_return.rs | 3 +- .../rules/pylint/rules/iteration_over_set.rs | 3 +- .../rules/load_before_global_declaration.rs | 3 +- crates/ruff/src/rules/pylint/rules/logging.rs | 3 +- .../pylint/rules/magic_value_comparison.rs | 3 +- .../rules/pylint/rules/manual_import_from.rs | 4 +-- .../src/rules/pylint/rules/nested_min_max.rs | 4 +-- .../src/rules/pylint/rules/no_self_use.rs | 3 +- .../rules/pylint/rules/redefined_loop_name.rs | 3 +- .../repeated_equality_comparison_target.rs | 3 +- .../pylint/rules/repeated_isinstance_calls.rs | 3 +- .../src/rules/pylint/rules/return_in_init.rs | 3 +- .../pylint/rules/self_assigning_variable.rs | 3 +- .../rules/subprocess_popen_preexec_fn.rs | 3 +- .../rules/subprocess_run_without_check.rs | 2 +- .../src/rules/pylint/rules/sys_exit_alias.rs | 3 +- .../src/rules/pylint/rules/type_bivariance.rs | 3 +- .../rules/type_name_incorrect_variance.rs | 3 +- .../pylint/rules/type_param_name_mismatch.rs | 3 +- .../rules/unnecessary_direct_lambda_call.rs | 3 +- .../pylint/rules/useless_import_alias.rs | 3 +- .../src/rules/pylint/rules/useless_return.rs | 3 +- .../rules/yield_from_in_async_function.rs | 3 +- .../src/rules/pylint/rules/yield_in_init.rs | 3 +- ...convert_named_tuple_functional_to_class.rs | 4 +-- .../convert_typed_dict_functional_to_class.rs | 4 +-- .../pyupgrade/rules/datetime_utc_alias.rs | 3 +- .../rules/deprecated_c_element_tree.rs | 4 +-- .../pyupgrade/rules/deprecated_import.rs | 3 +- .../pyupgrade/rules/deprecated_mock_import.rs | 3 +- .../rules/deprecated_unittest_alias.rs | 3 +- .../pyupgrade/rules/extraneous_parentheses.rs | 2 +- .../src/rules/pyupgrade/rules/f_strings.rs | 4 +-- .../rules/pyupgrade/rules/format_literals.rs | 3 +- .../rules/lru_cache_with_maxsize_none.rs | 4 +-- .../rules/lru_cache_without_parameters.rs | 4 +-- .../rules/pyupgrade/rules/native_literals.rs | 3 +- .../src/rules/pyupgrade/rules/open_alias.rs | 3 +- .../rules/pyupgrade/rules/os_error_alias.rs | 4 +-- .../pyupgrade/rules/outdated_version_block.rs | 4 +-- .../rules/printf_string_formatting.rs | 4 +-- .../pyupgrade/rules/redundant_open_modes.rs | 4 +-- .../pyupgrade/rules/replace_stdout_stderr.rs | 3 +- .../rules/replace_universal_newlines.rs | 3 +- .../rules/super_call_with_parameters.rs | 4 +-- .../pyupgrade/rules/type_of_primitive.rs | 3 +- .../pyupgrade/rules/typing_text_str_alias.rs | 3 +- .../pyupgrade/rules/unicode_kind_prefix.rs | 5 ++- .../rules/unnecessary_builtin_import.rs | 3 +- .../rules/unnecessary_class_parentheses.rs | 3 +- .../rules/unnecessary_coding_comment.rs | 2 +- .../rules/unnecessary_encode_utf8.rs | 4 +-- .../rules/unnecessary_future_import.rs | 3 +- .../rules/unpacked_list_comprehension.rs | 3 +- .../pyupgrade/rules/use_pep585_annotation.rs | 3 +- .../pyupgrade/rules/use_pep604_annotation.rs | 3 +- .../pyupgrade/rules/use_pep604_isinstance.rs | 5 ++- .../pyupgrade/rules/use_pep695_type_alias.rs | 6 ++-- .../pyupgrade/rules/useless_metaclass_type.rs | 3 +- .../rules/useless_object_inheritance.rs | 3 +- .../pyupgrade/rules/yield_in_for_loop.rs | 3 +- .../ruff/rules/ambiguous_unicode_character.rs | 5 +-- .../rules/ruff/rules/asyncio_dangling_task.rs | 3 +- .../rules/collection_literal_concatenation.rs | 4 +-- .../explicit_f_string_type_conversion.rs | 3 +- .../function_call_in_dataclass_default.rs | 3 +- .../src/rules/ruff/rules/implicit_optional.rs | 6 ++-- .../rules/ruff/rules/invalid_index_type.rs | 3 +- .../rules/ruff/rules/mutable_class_default.rs | 3 +- .../ruff/rules/mutable_dataclass_default.rs | 3 +- .../rules/ruff/rules/pairwise_over_zipped.rs | 3 +- .../ruff/rules/quadratic_list_summation.rs | 3 +- .../rules/static_key_dict_comprehension.rs | 3 +- ...y_iterable_allocation_for_first_element.rs | 4 +-- .../ruff/src/rules/ruff/rules/unreachable.rs | 8 ++--- .../rules/error_instead_of_exception.rs | 3 +- .../tryceratops/rules/raise_vanilla_args.rs | 3 +- .../tryceratops/rules/raise_vanilla_class.rs | 3 +- .../tryceratops/rules/raise_within_try.rs | 3 +- .../tryceratops/rules/try_consider_else.rs | 3 +- .../rules/type_check_without_type_error.rs | 3 +- .../tryceratops/rules/useless_try_except.rs | 3 +- .../tryceratops/rules/verbose_log_message.rs | 3 +- .../rules/tryceratops/rules/verbose_raise.rs | 3 +- .../ruff_formatter/src/format_extensions.rs | 4 +-- crates/ruff_python_ast/src/expression.rs | 4 +-- crates/ruff_python_ast/src/helpers.rs | 5 ++- crates/ruff_python_ast/src/identifier.rs | 4 +-- crates/ruff_python_ast/src/lib.rs | 34 ++----------------- crates/ruff_python_ast/src/node.rs | 6 ++-- crates/ruff_python_ast/src/nodes.rs | 10 +++--- crates/ruff_python_ast/src/parenthesize.rs | 4 +-- crates/ruff_python_ast/src/stmt_if.rs | 4 +-- crates/ruff_python_ast/src/whitespace.rs | 4 +-- crates/ruff_python_formatter/src/builders.rs | 3 +- .../src/comments/debug.rs | 6 ++-- .../src/comments/format.rs | 3 +- .../ruff_python_formatter/src/comments/mod.rs | 4 +-- .../src/comments/placement.rs | 4 +-- .../src/comments/visitor.rs | 4 +-- .../src/expression/expr_attribute.rs | 4 +-- .../src/expression/expr_constant.rs | 4 +-- .../src/expression/expr_dict.rs | 3 +- .../src/expression/expr_ipy_escape_command.rs | 3 +- .../src/expression/expr_list.rs | 3 +- .../src/expression/expr_name.rs | 3 +- .../src/expression/expr_set.rs | 3 +- .../src/expression/expr_slice.rs | 10 ++---- .../src/expression/expr_tuple.rs | 3 +- .../src/expression/expr_unary_op.rs | 4 +-- .../src/expression/expr_yield.rs | 4 +-- .../src/expression/number.rs | 4 +-- .../src/expression/parentheses.rs | 3 +- .../src/expression/string.rs | 4 +-- .../src/other/arguments.rs | 4 +-- .../src/other/comprehension.rs | 3 +- .../src/other/identifier.rs | 7 ++-- .../src/other/parameters.rs | 4 +-- .../ruff_python_formatter/src/pattern/mod.rs | 3 +- .../src/pattern/pattern_arguments.rs | 4 +-- .../src/pattern/pattern_match_mapping.rs | 4 +-- .../src/pattern/pattern_match_sequence.rs | 4 +-- .../src/statement/clause.rs | 14 ++++---- .../src/statement/stmt_class_def.rs | 3 +- .../src/statement/stmt_delete.rs | 3 +- .../src/statement/stmt_for.rs | 3 +- .../src/statement/stmt_function_def.rs | 3 +- .../src/statement/stmt_import_from.rs | 3 +- .../src/statement/stmt_ipy_escape_command.rs | 3 +- .../src/statement/stmt_try.rs | 3 +- .../src/statement/stmt_while.rs | 3 +- .../src/statement/stmt_with.rs | 6 ++-- .../src/statement/suite.rs | 4 +-- .../src/type_param/type_params.rs | 11 +++--- crates/ruff_python_formatter/src/verbatim.rs | 4 +-- .../ruff_python_index/src/comment_ranges.rs | 2 +- crates/ruff_python_index/src/indexer.rs | 8 ++--- crates/ruff_python_parser/src/function.rs | 4 +-- crates/ruff_python_parser/src/lib.rs | 4 +-- crates/ruff_python_parser/src/python.lalrpop | 4 +-- crates/ruff_python_parser/src/python.rs | 10 +++--- crates/ruff_python_parser/src/string.rs | 4 +-- crates/ruff_python_semantic/src/binding.rs | 3 +- crates/ruff_python_semantic/src/definition.rs | 4 +-- crates/ruff_python_semantic/src/globals.rs | 5 ++- crates/ruff_python_semantic/src/model.rs | 4 +-- crates/ruff_python_semantic/src/nodes.rs | 4 +-- crates/ruff_python_semantic/src/reference.rs | 6 ++-- crates/ruff_python_trivia/src/whitespace.rs | 5 +-- crates/ruff_shrinking/src/main.rs | 4 +-- crates/ruff_source_file/src/locator.rs | 22 ++++++------ crates/ruff_text_size/src/lib.rs | 2 +- crates/ruff_text_size/src/range.rs | 8 ++--- crates/ruff_text_size/src/traits.rs | 33 +++++++++++++++++- 468 files changed, 940 insertions(+), 706 deletions(-) diff --git a/crates/ruff/src/autofix/codemods.rs b/crates/ruff/src/autofix/codemods.rs index be7028d5f3ec9..52f04bbeac9fb 100644 --- a/crates/ruff/src/autofix/codemods.rs +++ b/crates/ruff/src/autofix/codemods.rs @@ -4,10 +4,11 @@ use anyhow::{bail, Result}; use libcst_native::{ Codegen, CodegenState, ImportNames, ParenthesizableWhitespace, SmallStatement, Statement, }; -use ruff_python_ast::{Ranged, Stmt}; +use ruff_python_ast::Stmt; use ruff_python_codegen::Stylist; use ruff_source_file::Locator; +use ruff_text_size::Ranged; use crate::cst::helpers::compose_module_path; use crate::cst::matchers::match_statement; diff --git a/crates/ruff/src/autofix/edits.rs b/crates/ruff/src/autofix/edits.rs index 4f02de6c3238e..02b18bdf0a9cd 100644 --- a/crates/ruff/src/autofix/edits.rs +++ b/crates/ruff/src/autofix/edits.rs @@ -3,15 +3,14 @@ use anyhow::{Context, Result}; use ruff_diagnostics::Edit; -use ruff_python_ast::{self as ast, Arguments, ExceptHandler, Expr, Keyword, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Arguments, ExceptHandler, Expr, Keyword, Stmt}; use ruff_python_codegen::Stylist; use ruff_python_index::Indexer; - use ruff_python_trivia::{ has_leading_content, is_python_whitespace, PythonWhitespace, SimpleTokenKind, SimpleTokenizer, }; use ruff_source_file::{Locator, NewlineWithTrailingNewline}; -use ruff_text_size::{TextLen, TextSize}; +use ruff_text_size::{Ranged, TextLen, TextSize}; use crate::autofix::codemods; @@ -254,10 +253,9 @@ fn next_stmt_break(semicolon: TextSize, locator: &Locator) -> TextSize { mod tests { use anyhow::Result; - use ruff_python_ast::Ranged; use ruff_python_parser::parse_suite; use ruff_source_file::Locator; - use ruff_text_size::TextSize; + use ruff_text_size::{Ranged, TextSize}; use crate::autofix::edits::{next_stmt_break, trailing_semicolon}; diff --git a/crates/ruff/src/autofix/mod.rs b/crates/ruff/src/autofix/mod.rs index 358a693cc0bcb..f402e7cb7d1b9 100644 --- a/crates/ruff/src/autofix/mod.rs +++ b/crates/ruff/src/autofix/mod.rs @@ -140,9 +140,7 @@ fn cmp_fix(rule1: Rule, rule2: Rule, fix1: &Fix, fix2: &Fix) -> std::cmp::Orderi mod tests { use ruff_text_size::TextSize; - use ruff_diagnostics::Diagnostic; - use ruff_diagnostics::Edit; - use ruff_diagnostics::Fix; + use ruff_diagnostics::{Diagnostic, Edit, Fix}; use ruff_source_file::Locator; use crate::autofix::source_map::SourceMarker; diff --git a/crates/ruff/src/checkers/ast/analyze/bindings.rs b/crates/ruff/src/checkers/ast/analyze/bindings.rs index face2218220c7..fca537a63cea7 100644 --- a/crates/ruff/src/checkers/ast/analyze/bindings.rs +++ b/crates/ruff/src/checkers/ast/analyze/bindings.rs @@ -1,5 +1,5 @@ use ruff_diagnostics::{Diagnostic, Fix}; -use ruff_python_ast::Ranged; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::codes::Rule; diff --git a/crates/ruff/src/checkers/ast/analyze/deferred_scopes.rs b/crates/ruff/src/checkers/ast/analyze/deferred_scopes.rs index 32bea594b9272..493186ec444ec 100644 --- a/crates/ruff/src/checkers/ast/analyze/deferred_scopes.rs +++ b/crates/ruff/src/checkers/ast/analyze/deferred_scopes.rs @@ -1,7 +1,7 @@ use ruff_diagnostics::Diagnostic; -use ruff_python_ast::Ranged; use ruff_python_semantic::analyze::visibility; use ruff_python_semantic::{Binding, BindingKind, ScopeKind}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::codes::Rule; diff --git a/crates/ruff/src/checkers/ast/analyze/definitions.rs b/crates/ruff/src/checkers/ast/analyze/definitions.rs index a6d86cad5d7db..10ea4c7394463 100644 --- a/crates/ruff/src/checkers/ast/analyze/definitions.rs +++ b/crates/ruff/src/checkers/ast/analyze/definitions.rs @@ -1,6 +1,5 @@ use ruff_python_ast::str::raw_contents_range; -use ruff_python_ast::Ranged; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use ruff_python_semantic::{BindingKind, ContextualizedDefinition, Export}; diff --git a/crates/ruff/src/checkers/ast/analyze/except_handler.rs b/crates/ruff/src/checkers/ast/analyze/except_handler.rs index 428198e231b67..d278f4c8f016b 100644 --- a/crates/ruff/src/checkers/ast/analyze/except_handler.rs +++ b/crates/ruff/src/checkers/ast/analyze/except_handler.rs @@ -1,4 +1,5 @@ -use ruff_python_ast::{self as ast, ExceptHandler, Ranged}; +use ruff_python_ast::{self as ast, ExceptHandler}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/checkers/ast/analyze/expression.rs b/crates/ruff/src/checkers/ast/analyze/expression.rs index 20352a1067f51..4825b24f6b545 100644 --- a/crates/ruff/src/checkers/ast/analyze/expression.rs +++ b/crates/ruff/src/checkers/ast/analyze/expression.rs @@ -1,4 +1,4 @@ -use ruff_python_ast::{self as ast, Arguments, Constant, Expr, ExprContext, Operator, Ranged}; +use ruff_python_ast::{self as ast, Arguments, Constant, Expr, ExprContext, Operator}; use ruff_python_literal::cformat::{CFormatError, CFormatErrorType}; use ruff_diagnostics::Diagnostic; @@ -6,6 +6,7 @@ use ruff_diagnostics::Diagnostic; use ruff_python_ast::types::Node; use ruff_python_semantic::analyze::typing; use ruff_python_semantic::ScopeKind; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/checkers/ast/analyze/parameter.rs b/crates/ruff/src/checkers/ast/analyze/parameter.rs index 5e6e527c524e1..5f40646ce1e72 100644 --- a/crates/ruff/src/checkers/ast/analyze/parameter.rs +++ b/crates/ruff/src/checkers/ast/analyze/parameter.rs @@ -1,4 +1,5 @@ -use ruff_python_ast::{Parameter, Ranged}; +use ruff_python_ast::Parameter; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::codes::Rule; diff --git a/crates/ruff/src/checkers/ast/analyze/statement.rs b/crates/ruff/src/checkers/ast/analyze/statement.rs index 892653835c37e..ed68db699437c 100644 --- a/crates/ruff/src/checkers/ast/analyze/statement.rs +++ b/crates/ruff/src/checkers/ast/analyze/statement.rs @@ -1,11 +1,10 @@ -use ruff_python_ast::{self as ast, Expr, Ranged, Stmt}; - use ruff_diagnostics::Diagnostic; use ruff_python_ast::helpers; - use ruff_python_ast::types::Node; +use ruff_python_ast::{self as ast, Expr, Stmt}; use ruff_python_semantic::analyze::typing; use ruff_python_semantic::ScopeKind; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/checkers/ast/mod.rs b/crates/ruff/src/checkers/ast/mod.rs index a22111f266108..c4ea4e8b2808d 100644 --- a/crates/ruff/src/checkers/ast/mod.rs +++ b/crates/ruff/src/checkers/ast/mod.rs @@ -32,10 +32,10 @@ use itertools::Itertools; use log::error; use ruff_python_ast::{ self as ast, Arguments, Comprehension, Constant, ElifElseClause, ExceptHandler, Expr, - ExprContext, Keyword, MatchCase, Parameter, ParameterWithDefault, Parameters, Pattern, Ranged, - Stmt, Suite, UnaryOp, + ExprContext, Keyword, MatchCase, Parameter, ParameterWithDefault, Parameters, Pattern, Stmt, + Suite, UnaryOp, }; -use ruff_text_size::{TextRange, TextSize}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use ruff_diagnostics::{Diagnostic, IsolationLevel}; use ruff_python_ast::all::{extract_all_names, DunderAllFlags}; diff --git a/crates/ruff/src/checkers/imports.rs b/crates/ruff/src/checkers/imports.rs index d0ee5096577f9..58ff35fa64ea5 100644 --- a/crates/ruff/src/checkers/imports.rs +++ b/crates/ruff/src/checkers/imports.rs @@ -2,16 +2,15 @@ use std::borrow::Cow; use std::path::Path; -use ruff_python_ast::{self as ast, PySourceType, Ranged, Stmt, Suite}; - use ruff_diagnostics::Diagnostic; use ruff_python_ast::helpers::to_module_path; use ruff_python_ast::imports::{ImportMap, ModuleImport}; use ruff_python_ast::statement_visitor::StatementVisitor; +use ruff_python_ast::{self as ast, PySourceType, Stmt, Suite}; use ruff_python_codegen::Stylist; use ruff_python_index::Indexer; - use ruff_source_file::Locator; +use ruff_text_size::Ranged; use crate::directives::IsortDirectives; use crate::registry::Rule; diff --git a/crates/ruff/src/checkers/logical_lines.rs b/crates/ruff/src/checkers/logical_lines.rs index b02514ab65364..5f464dd0e0019 100644 --- a/crates/ruff/src/checkers/logical_lines.rs +++ b/crates/ruff/src/checkers/logical_lines.rs @@ -1,10 +1,9 @@ use ruff_diagnostics::{Diagnostic, DiagnosticKind}; -use ruff_python_ast::Ranged; use ruff_python_codegen::Stylist; use ruff_python_parser::lexer::LexResult; use ruff_python_parser::TokenKind; use ruff_source_file::Locator; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::registry::{AsRule, Rule}; use crate::rules::pycodestyle::rules::logical_lines::{ diff --git a/crates/ruff/src/checkers/noqa.rs b/crates/ruff/src/checkers/noqa.rs index e234fc80393ba..594c758c1a254 100644 --- a/crates/ruff/src/checkers/noqa.rs +++ b/crates/ruff/src/checkers/noqa.rs @@ -3,8 +3,7 @@ use std::path::Path; use itertools::Itertools; -use ruff_python_ast::Ranged; -use ruff_text_size::{TextLen, TextRange, TextSize}; +use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; use ruff_diagnostics::{Diagnostic, Edit, Fix}; use ruff_source_file::Locator; diff --git a/crates/ruff/src/directives.rs b/crates/ruff/src/directives.rs index 59b2a4c572cd1..af41fbac0981e 100644 --- a/crates/ruff/src/directives.rs +++ b/crates/ruff/src/directives.rs @@ -5,7 +5,7 @@ use std::str::FromStr; use bitflags::bitflags; use ruff_python_parser::lexer::LexResult; use ruff_python_parser::Tok; -use ruff_text_size::{TextLen, TextRange, TextSize}; +use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; use ruff_python_index::Indexer; use ruff_source_file::Locator; diff --git a/crates/ruff/src/doc_lines.rs b/crates/ruff/src/doc_lines.rs index c072eb867096d..d513c3339bd81 100644 --- a/crates/ruff/src/doc_lines.rs +++ b/crates/ruff/src/doc_lines.rs @@ -3,10 +3,10 @@ use std::iter::FusedIterator; -use ruff_python_ast::{self as ast, Constant, Expr, Ranged, Stmt, Suite}; +use ruff_python_ast::{self as ast, Constant, Expr, Stmt, Suite}; use ruff_python_parser::lexer::LexResult; use ruff_python_parser::Tok; -use ruff_text_size::TextSize; +use ruff_text_size::{Ranged, TextSize}; use ruff_python_ast::statement_visitor::{walk_stmt, StatementVisitor}; use ruff_source_file::{Locator, UniversalNewlineIterator}; diff --git a/crates/ruff/src/docstrings/mod.rs b/crates/ruff/src/docstrings/mod.rs index 92726c8d97aa0..4ed8e9baaaca7 100644 --- a/crates/ruff/src/docstrings/mod.rs +++ b/crates/ruff/src/docstrings/mod.rs @@ -1,9 +1,9 @@ use std::fmt::{Debug, Formatter}; use std::ops::Deref; -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_python_semantic::Definition; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; pub(crate) mod extraction; pub(crate) mod google; diff --git a/crates/ruff/src/docstrings/sections.rs b/crates/ruff/src/docstrings/sections.rs index 58d8339e101c1..603173e1c1e9b 100644 --- a/crates/ruff/src/docstrings/sections.rs +++ b/crates/ruff/src/docstrings/sections.rs @@ -2,8 +2,7 @@ use std::fmt::{Debug, Formatter}; use std::iter::FusedIterator; use ruff_python_ast::docstrings::{leading_space, leading_words}; -use ruff_python_ast::Ranged; -use ruff_text_size::{TextLen, TextRange, TextSize}; +use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; use strum_macros::EnumIter; use ruff_source_file::{Line, UniversalNewlineIterator, UniversalNewlines}; diff --git a/crates/ruff/src/importer/insertion.rs b/crates/ruff/src/importer/insertion.rs index 92c335a2df582..13447499f2858 100644 --- a/crates/ruff/src/importer/insertion.rs +++ b/crates/ruff/src/importer/insertion.rs @@ -1,9 +1,9 @@ //! Insert statements into Python code. use std::ops::Add; -use ruff_python_ast::{PySourceType, Ranged, Stmt}; +use ruff_python_ast::{PySourceType, Stmt}; use ruff_python_parser::{lexer, AsMode, Tok}; -use ruff_text_size::TextSize; +use ruff_text_size::{Ranged, TextSize}; use ruff_diagnostics::Edit; use ruff_python_ast::helpers::is_docstring_stmt; diff --git a/crates/ruff/src/importer/mod.rs b/crates/ruff/src/importer/mod.rs index ed4e3d6728c82..939b147b38af6 100644 --- a/crates/ruff/src/importer/mod.rs +++ b/crates/ruff/src/importer/mod.rs @@ -7,8 +7,8 @@ use std::error::Error; use anyhow::Result; use libcst_native::{ImportAlias, Name, NameOrAttribute}; -use ruff_python_ast::{self as ast, PySourceType, Ranged, Stmt, Suite}; -use ruff_text_size::TextSize; +use ruff_python_ast::{self as ast, PySourceType, Stmt, Suite}; +use ruff_text_size::{Ranged, TextSize}; use ruff_diagnostics::Edit; use ruff_python_ast::imports::{AnyImport, Import, ImportFrom}; diff --git a/crates/ruff/src/message/text.rs b/crates/ruff/src/message/text.rs index f0f0df6f169cf..d712a5ed4a433 100644 --- a/crates/ruff/src/message/text.rs +++ b/crates/ruff/src/message/text.rs @@ -8,7 +8,7 @@ use bitflags::bitflags; use colored::Colorize; use ruff_source_file::{OneIndexed, SourceLocation}; -use ruff_text_size::{TextRange, TextSize}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::fs::relativize_path; use crate::jupyter::{Notebook, NotebookIndex}; diff --git a/crates/ruff/src/noqa.rs b/crates/ruff/src/noqa.rs index 4711149a9ab9b..f2be0b7073d99 100644 --- a/crates/ruff/src/noqa.rs +++ b/crates/ruff/src/noqa.rs @@ -8,8 +8,7 @@ use std::path::Path; use anyhow::Result; use itertools::Itertools; use log::warn; -use ruff_python_ast::Ranged; -use ruff_text_size::{TextLen, TextRange, TextSize}; +use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; use ruff_diagnostics::Diagnostic; use ruff_python_trivia::indentation_at_offset; diff --git a/crates/ruff/src/renamer.rs b/crates/ruff/src/renamer.rs index 2671cd63fe466..be17627829619 100644 --- a/crates/ruff/src/renamer.rs +++ b/crates/ruff/src/renamer.rs @@ -4,8 +4,8 @@ use anyhow::{anyhow, Result}; use itertools::Itertools; use ruff_diagnostics::Edit; -use ruff_python_ast::Ranged; use ruff_python_semantic::{Binding, BindingKind, Scope, ScopeId, SemanticModel}; +use ruff_text_size::Ranged; pub(crate) struct Renamer; diff --git a/crates/ruff/src/rules/airflow/rules/task_variable_name.rs b/crates/ruff/src/rules/airflow/rules/task_variable_name.rs index 6a33944448fdf..fccf1a79aade1 100644 --- a/crates/ruff/src/rules/airflow/rules/task_variable_name.rs +++ b/crates/ruff/src/rules/airflow/rules/task_variable_name.rs @@ -2,7 +2,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast as ast; use ruff_python_ast::Constant; -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_2020/rules/compare.rs b/crates/ruff/src/rules/flake8_2020/rules/compare.rs index ff0508164e565..58a8f808386e9 100644 --- a/crates/ruff/src/rules/flake8_2020/rules/compare.rs +++ b/crates/ruff/src/rules/flake8_2020/rules/compare.rs @@ -1,8 +1,9 @@ use num_bigint::BigInt; -use ruff_python_ast::{self as ast, CmpOp, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, CmpOp, Constant, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/rules/flake8_2020/rules/name_or_attribute.rs b/crates/ruff/src/rules/flake8_2020/rules/name_or_attribute.rs index a64164d9fe06f..bdd1a7d452660 100644 --- a/crates/ruff/src/rules/flake8_2020/rules/name_or_attribute.rs +++ b/crates/ruff/src/rules/flake8_2020/rules/name_or_attribute.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_2020/rules/subscript.rs b/crates/ruff/src/rules/flake8_2020/rules/subscript.rs index 20542c8dd9519..9c21064ce09d4 100644 --- a/crates/ruff/src/rules/flake8_2020/rules/subscript.rs +++ b/crates/ruff/src/rules/flake8_2020/rules/subscript.rs @@ -1,8 +1,9 @@ use num_bigint::BigInt; -use ruff_python_ast::{self as ast, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/rules/flake8_annotations/rules/definition.rs b/crates/ruff/src/rules/flake8_annotations/rules/definition.rs index fc1678aae22b9..0748e663a69b9 100644 --- a/crates/ruff/src/rules/flake8_annotations/rules/definition.rs +++ b/crates/ruff/src/rules/flake8_annotations/rules/definition.rs @@ -3,11 +3,12 @@ use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::ReturnStatementVisitor; use ruff_python_ast::identifier::Identifier; use ruff_python_ast::statement_visitor::StatementVisitor; -use ruff_python_ast::{self as ast, Constant, Expr, ParameterWithDefault, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Constant, Expr, ParameterWithDefault, Stmt}; use ruff_python_parser::typing::parse_type_annotation; use ruff_python_semantic::analyze::visibility; use ruff_python_semantic::Definition; use ruff_python_stdlib::typing::simple_magic_return_type; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::{AsRule, Rule}; diff --git a/crates/ruff/src/rules/flake8_async/rules/blocking_http_call.rs b/crates/ruff/src/rules/flake8_async/rules/blocking_http_call.rs index 41541d51006f6..eabe27f54fb44 100644 --- a/crates/ruff/src/rules/flake8_async/rules/blocking_http_call.rs +++ b/crates/ruff/src/rules/flake8_async/rules/blocking_http_call.rs @@ -1,9 +1,10 @@ use ruff_python_ast as ast; -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::CallPath; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_async/rules/blocking_os_call.rs b/crates/ruff/src/rules/flake8_async/rules/blocking_os_call.rs index 212736b4d611b..48081ad5e3ef3 100644 --- a/crates/ruff/src/rules/flake8_async/rules/blocking_os_call.rs +++ b/crates/ruff/src/rules/flake8_async/rules/blocking_os_call.rs @@ -1,9 +1,10 @@ use ruff_python_ast as ast; -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::CallPath; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_async/rules/open_sleep_or_subprocess_call.rs b/crates/ruff/src/rules/flake8_async/rules/open_sleep_or_subprocess_call.rs index 220b8f31626d1..bdc05e598ec0a 100644 --- a/crates/ruff/src/rules/flake8_async/rules/open_sleep_or_subprocess_call.rs +++ b/crates/ruff/src/rules/flake8_async/rules/open_sleep_or_subprocess_call.rs @@ -1,9 +1,10 @@ use ruff_python_ast as ast; -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::CallPath; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bandit/rules/assert_used.rs b/crates/ruff/src/rules/flake8_bandit/rules/assert_used.rs index 88a22adced056..4112c6ae7ad90 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/assert_used.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/assert_used.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Ranged, Stmt}; +use ruff_python_ast::Stmt; use ruff_text_size::{TextLen, TextRange}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; /// ## What it does /// Checks for uses of the `assert` keyword. diff --git a/crates/ruff/src/rules/flake8_bandit/rules/bad_file_permissions.rs b/crates/ruff/src/rules/flake8_bandit/rules/bad_file_permissions.rs index 1da82b46816e8..0fdf07cd12751 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/bad_file_permissions.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/bad_file_permissions.rs @@ -3,8 +3,9 @@ use num_traits::ToPrimitive; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::CallPath; -use ruff_python_ast::{self as ast, Constant, Expr, Operator, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr, Operator}; use ruff_python_semantic::SemanticModel; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bandit/rules/exec_used.rs b/crates/ruff/src/rules/flake8_bandit/rules/exec_used.rs index f41ac62cdbf3e..6271e47de175d 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/exec_used.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/exec_used.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_password_default.rs b/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_password_default.rs index a0bcc73899401..06c087c09ef3b 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_password_default.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_password_default.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Parameter, ParameterWithDefault, Parameters, Ranged}; +use ruff_python_ast::{Expr, Parameter, ParameterWithDefault, Parameters}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_password_func_arg.rs b/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_password_func_arg.rs index 70a60e0df3c89..3c5d48ac19a9f 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_password_func_arg.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_password_func_arg.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Keyword, Ranged}; +use ruff_python_ast::Keyword; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_password_string.rs b/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_password_string.rs index 37d816f93c276..0a3702251a9a1 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_password_string.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_password_string.rs @@ -1,7 +1,7 @@ -use ruff_python_ast::{self as ast, Constant, Expr, Ranged}; - use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_python_ast::{self as ast, Constant, Expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_sql_expression.rs b/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_sql_expression.rs index 9d82380f4e447..d54e0a0b23afa 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_sql_expression.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_sql_expression.rs @@ -1,11 +1,12 @@ use once_cell::sync::Lazy; use regex::Regex; -use ruff_python_ast::{self as ast, Expr, Operator, Ranged}; +use ruff_python_ast::{self as ast, Expr, Operator}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::any_over_expr; use ruff_python_semantic::SemanticModel; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_tmp_directory.rs b/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_tmp_directory.rs index c677e9e909f2c..58e9180806ac5 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_tmp_directory.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/hardcoded_tmp_directory.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bandit/rules/hashlib_insecure_hash_functions.rs b/crates/ruff/src/rules/flake8_bandit/rules/hashlib_insecure_hash_functions.rs index df5b8534f8b09..f362858fc62e1 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/hashlib_insecure_hash_functions.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/hashlib_insecure_hash_functions.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_false; -use ruff_python_ast::{self as ast, Arguments, Ranged}; +use ruff_python_ast::{self as ast, Arguments}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bandit/rules/jinja2_autoescape_false.rs b/crates/ruff/src/rules/flake8_bandit/rules/jinja2_autoescape_false.rs index 799a1268df113..9d7093b35a1b8 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/jinja2_autoescape_false.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/jinja2_autoescape_false.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bandit/rules/logging_config_insecure_listen.rs b/crates/ruff/src/rules/flake8_bandit/rules/logging_config_insecure_listen.rs index 5c936a87d615c..69814c123dae5 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/logging_config_insecure_listen.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/logging_config_insecure_listen.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Ranged}; +use ruff_python_ast::{self as ast}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bandit/rules/paramiko_calls.rs b/crates/ruff/src/rules/flake8_bandit/rules/paramiko_calls.rs index adf916e97c8c1..d0ccc8c91351e 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/paramiko_calls.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/paramiko_calls.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bandit/rules/request_with_no_cert_validation.rs b/crates/ruff/src/rules/flake8_bandit/rules/request_with_no_cert_validation.rs index 843d31733547f..56f02b6655d81 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/request_with_no_cert_validation.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/request_with_no_cert_validation.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_python_ast as ast; use ruff_python_ast::helpers::is_const_false; -use ruff_python_ast::{self as ast, Ranged}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bandit/rules/request_without_timeout.rs b/crates/ruff/src/rules/flake8_bandit/rules/request_without_timeout.rs index 37bf931fabd22..423e4a902636f 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/request_without_timeout.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/request_without_timeout.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_python_ast as ast; use ruff_python_ast::helpers::is_const_none; -use ruff_python_ast::{self as ast, Ranged}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bandit/rules/shell_injection.rs b/crates/ruff/src/rules/flake8_bandit/rules/shell_injection.rs index 93e6c0c27ea6a..7e79b8f3e8d7b 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/shell_injection.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/shell_injection.rs @@ -3,8 +3,9 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::Truthiness; -use ruff_python_ast::{self as ast, Arguments, Constant, Expr, Keyword, Ranged}; +use ruff_python_ast::{self as ast, Arguments, Constant, Expr, Keyword}; use ruff_python_semantic::SemanticModel; +use ruff_text_size::Ranged; use crate::{ checkers::ast::Checker, registry::Rule, rules::flake8_bandit::helpers::string_literal, diff --git a/crates/ruff/src/rules/flake8_bandit/rules/snmp_insecure_version.rs b/crates/ruff/src/rules/flake8_bandit/rules/snmp_insecure_version.rs index 845dc3affc2f1..6e6b2b8aed620 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/snmp_insecure_version.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/snmp_insecure_version.rs @@ -2,7 +2,8 @@ use num_traits::{One, Zero}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bandit/rules/snmp_weak_cryptography.rs b/crates/ruff/src/rules/flake8_bandit/rules/snmp_weak_cryptography.rs index 3dd991664d76f..0f43bffb9f4c4 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/snmp_weak_cryptography.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/snmp_weak_cryptography.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Ranged}; +use ruff_python_ast::{self as ast}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bandit/rules/suspicious_function_call.rs b/crates/ruff/src/rules/flake8_bandit/rules/suspicious_function_call.rs index 7e706dae54327..bb24f3b9a46b4 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/suspicious_function_call.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/suspicious_function_call.rs @@ -1,10 +1,11 @@ //! Check for calls to suspicious functions, or calls into suspicious modules. //! //! See: -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{Diagnostic, DiagnosticKind, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_bandit/rules/try_except_continue.rs b/crates/ruff/src/rules/flake8_bandit/rules/try_except_continue.rs index 25dbe835bd258..7c73f1cc5aed0 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/try_except_continue.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/try_except_continue.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{ExceptHandler, Expr, Ranged, Stmt}; +use ruff_python_ast::{ExceptHandler, Expr, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::flake8_bandit::helpers::is_untyped_exception; diff --git a/crates/ruff/src/rules/flake8_bandit/rules/try_except_pass.rs b/crates/ruff/src/rules/flake8_bandit/rules/try_except_pass.rs index 0a92793052951..02ecf816e4371 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/try_except_pass.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/try_except_pass.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{ExceptHandler, Expr, Ranged, Stmt}; +use ruff_python_ast::{ExceptHandler, Expr, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::flake8_bandit::helpers::is_untyped_exception; diff --git a/crates/ruff/src/rules/flake8_bandit/rules/unsafe_yaml_load.rs b/crates/ruff/src/rules/flake8_bandit/rules/unsafe_yaml_load.rs index 3ae1a7689f012..68b8f59647361 100644 --- a/crates/ruff/src/rules/flake8_bandit/rules/unsafe_yaml_load.rs +++ b/crates/ruff/src/rules/flake8_bandit/rules/unsafe_yaml_load.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_blind_except/rules/blind_except.rs b/crates/ruff/src/rules/flake8_blind_except/rules/blind_except.rs index 4fa9474d01af0..0dece92c29397 100644 --- a/crates/ruff/src/rules/flake8_blind_except/rules/blind_except.rs +++ b/crates/ruff/src/rules/flake8_blind_except/rules/blind_except.rs @@ -1,8 +1,9 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_true; -use ruff_python_ast::{self as ast, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Expr, Stmt}; use ruff_python_semantic::analyze::logging; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_boolean_trap/rules/boolean_default_value_positional_argument.rs b/crates/ruff/src/rules/flake8_boolean_trap/rules/boolean_default_value_positional_argument.rs index b80bff7752d3b..63ec019bab764 100644 --- a/crates/ruff/src/rules/flake8_boolean_trap/rules/boolean_default_value_positional_argument.rs +++ b/crates/ruff/src/rules/flake8_boolean_trap/rules/boolean_default_value_positional_argument.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::collect_call_path; -use ruff_python_ast::{Decorator, ParameterWithDefault, Parameters, Ranged}; +use ruff_python_ast::{Decorator, ParameterWithDefault, Parameters}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::flake8_boolean_trap::helpers::{is_allowed_func_def, is_boolean}; diff --git a/crates/ruff/src/rules/flake8_boolean_trap/rules/boolean_positional_value_in_call.rs b/crates/ruff/src/rules/flake8_boolean_trap/rules/boolean_positional_value_in_call.rs index 0f6bf1fca7f9e..c278730437b0c 100644 --- a/crates/ruff/src/rules/flake8_boolean_trap/rules/boolean_positional_value_in_call.rs +++ b/crates/ruff/src/rules/flake8_boolean_trap/rules/boolean_positional_value_in_call.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::flake8_boolean_trap::helpers::{allow_boolean_trap, is_boolean}; diff --git a/crates/ruff/src/rules/flake8_boolean_trap/rules/boolean_type_hint_positional_argument.rs b/crates/ruff/src/rules/flake8_boolean_trap/rules/boolean_type_hint_positional_argument.rs index cfe52b282997f..f6178b7cf13d2 100644 --- a/crates/ruff/src/rules/flake8_boolean_trap/rules/boolean_type_hint_positional_argument.rs +++ b/crates/ruff/src/rules/flake8_boolean_trap/rules/boolean_type_hint_positional_argument.rs @@ -1,11 +1,10 @@ -use ruff_python_ast::{ - self as ast, Constant, Decorator, Expr, ParameterWithDefault, Parameters, Ranged, -}; +use ruff_python_ast::{self as ast, Constant, Decorator, Expr, ParameterWithDefault, Parameters}; use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Violation; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::collect_call_path; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::flake8_boolean_trap::helpers::is_allowed_func_def; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/abstract_base_class.rs b/crates/ruff/src/rules/flake8_bugbear/rules/abstract_base_class.rs index 43307aa5c1f3f..2913efc3f9efc 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/abstract_base_class.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/abstract_base_class.rs @@ -1,10 +1,11 @@ -use ruff_python_ast::{self as ast, Arguments, Constant, Expr, Keyword, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Arguments, Constant, Expr, Keyword, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::identifier::Identifier; use ruff_python_semantic::analyze::visibility::{is_abstract, is_overload}; use ruff_python_semantic::SemanticModel; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/assert_false.rs b/crates/ruff/src/rules/flake8_bugbear/rules/assert_false.rs index 776110f707904..209a79d719895 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/assert_false.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/assert_false.rs @@ -1,5 +1,5 @@ -use ruff_python_ast::{self as ast, Arguments, Expr, ExprContext, Ranged, Stmt}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, Arguments, Expr, ExprContext, Stmt}; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/assert_raises_exception.rs b/crates/ruff/src/rules/flake8_bugbear/rules/assert_raises_exception.rs index 908fd6e7de548..f17ad3938dd3d 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/assert_raises_exception.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/assert_raises_exception.rs @@ -2,7 +2,8 @@ use std::fmt; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Expr, Ranged, WithItem}; +use ruff_python_ast::{self as ast, Expr, WithItem}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/assignment_to_os_environ.rs b/crates/ruff/src/rules/flake8_bugbear/rules/assignment_to_os_environ.rs index 12f45ff2d8518..9f0fef6c38be3 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/assignment_to_os_environ.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/assignment_to_os_environ.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/cached_instance_method.rs b/crates/ruff/src/rules/flake8_bugbear/rules/cached_instance_method.rs index 61e99ed49126e..083954116a68b 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/cached_instance_method.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/cached_instance_method.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Decorator, Expr, Ranged}; +use ruff_python_ast::{self as ast, Decorator, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_semantic::SemanticModel; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/duplicate_exceptions.rs b/crates/ruff/src/rules/flake8_bugbear/rules/duplicate_exceptions.rs index f09a7f9a2a5cc..b8daa83ffc705 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/duplicate_exceptions.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/duplicate_exceptions.rs @@ -1,6 +1,6 @@ use itertools::Itertools; -use ruff_python_ast::{self as ast, ExceptHandler, Expr, ExprContext, Ranged}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, ExceptHandler, Expr, ExprContext}; +use ruff_text_size::{Ranged, TextRange}; use rustc_hash::{FxHashMap, FxHashSet}; use ruff_diagnostics::{AlwaysAutofixableViolation, Violation}; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/duplicate_value.rs b/crates/ruff/src/rules/flake8_bugbear/rules/duplicate_value.rs index acd7052598955..8dbd3d5efb900 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/duplicate_value.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/duplicate_value.rs @@ -1,9 +1,10 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use rustc_hash::FxHashSet; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::comparable::ComparableExpr; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/except_with_empty_tuple.rs b/crates/ruff/src/rules/flake8_bugbear/rules/except_with_empty_tuple.rs index c0d555e118c08..f89f84862e4c6 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/except_with_empty_tuple.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/except_with_empty_tuple.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Ranged}; +use ruff_python_ast::{self as ast}; use ruff_python_ast::{ExceptHandler, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/except_with_non_exception_classes.rs b/crates/ruff/src/rules/flake8_bugbear/rules/except_with_non_exception_classes.rs index 2c5a027a0f9bb..78557f0bc7181 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/except_with_non_exception_classes.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/except_with_non_exception_classes.rs @@ -1,9 +1,10 @@ use std::collections::VecDeque; -use ruff_python_ast::{self as ast, ExceptHandler, Expr, Ranged}; +use ruff_python_ast::{self as ast, ExceptHandler, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/function_call_in_argument_default.rs b/crates/ruff/src/rules/flake8_bugbear/rules/function_call_in_argument_default.rs index 66c68f3fae532..964026d5f09e0 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/function_call_in_argument_default.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/function_call_in_argument_default.rs @@ -1,5 +1,5 @@ -use ruff_python_ast::{self as ast, Expr, ParameterWithDefault, Parameters, Ranged}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, Expr, ParameterWithDefault, Parameters}; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::Violation; use ruff_diagnostics::{Diagnostic, DiagnosticKind}; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/function_uses_loop_variable.rs b/crates/ruff/src/rules/flake8_bugbear/rules/function_uses_loop_variable.rs index 7cbb231fbd322..daf0fe389e9d6 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/function_uses_loop_variable.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/function_uses_loop_variable.rs @@ -3,7 +3,8 @@ use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::types::Node; use ruff_python_ast::visitor; use ruff_python_ast::visitor::Visitor; -use ruff_python_ast::{self as ast, Arguments, Comprehension, Expr, ExprContext, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Arguments, Comprehension, Expr, ExprContext, Stmt}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/getattr_with_constant.rs b/crates/ruff/src/rules/flake8_bugbear/rules/getattr_with_constant.rs index c7c5944c81aa8..df32792a4154b 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/getattr_with_constant.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/getattr_with_constant.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_stdlib::identifiers::{is_identifier, is_mangled_private}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/jump_statement_in_finally.rs b/crates/ruff/src/rules/flake8_bugbear/rules/jump_statement_in_finally.rs index 5c5ca90cb7310..23c23d2f11d73 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/jump_statement_in_finally.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/jump_statement_in_finally.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/loop_variable_overrides_iterator.rs b/crates/ruff/src/rules/flake8_bugbear/rules/loop_variable_overrides_iterator.rs index 45439b11418c8..6ee9ba0c21cb4 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/loop_variable_overrides_iterator.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/loop_variable_overrides_iterator.rs @@ -1,10 +1,11 @@ -use ruff_python_ast::{self as ast, Expr, ParameterWithDefault, Ranged}; +use ruff_python_ast::{self as ast, Expr, ParameterWithDefault}; use rustc_hash::FxHashMap; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::visitor; use ruff_python_ast::visitor::Visitor; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/mutable_argument_default.rs b/crates/ruff/src/rules/flake8_bugbear/rules/mutable_argument_default.rs index f00944d1e813d..bf3c0fc5317b9 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/mutable_argument_default.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/mutable_argument_default.rs @@ -2,12 +2,13 @@ use ast::call_path::{from_qualified_name, CallPath}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_docstring_stmt; -use ruff_python_ast::{self as ast, Expr, Parameter, ParameterWithDefault, Ranged}; +use ruff_python_ast::{self as ast, Expr, Parameter, ParameterWithDefault}; use ruff_python_codegen::{Generator, Stylist}; use ruff_python_index::Indexer; use ruff_python_semantic::analyze::typing::{is_immutable_annotation, is_mutable_expr}; use ruff_python_trivia::{indentation_at_offset, textwrap}; use ruff_source_file::Locator; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/no_explicit_stacklevel.rs b/crates/ruff/src/rules/flake8_bugbear/rules/no_explicit_stacklevel.rs index c964e54d682cc..aa2a9b9e5cb19 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/no_explicit_stacklevel.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/no_explicit_stacklevel.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Ranged}; +use ruff_python_ast::{self as ast}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/raise_literal.rs b/crates/ruff/src/rules/flake8_bugbear/rules/raise_literal.rs index 169398dcbd7d6..65534e540e593 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/raise_literal.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/raise_literal.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/re_sub_positional_args.rs b/crates/ruff/src/rules/flake8_bugbear/rules/re_sub_positional_args.rs index ebf89e57e49de..328c9bc711efd 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/re_sub_positional_args.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/re_sub_positional_args.rs @@ -1,9 +1,10 @@ use std::fmt; -use ruff_python_ast::{self as ast, Ranged}; +use ruff_python_ast::{self as ast}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/redundant_tuple_in_exception_handler.rs b/crates/ruff/src/rules/flake8_bugbear/rules/redundant_tuple_in_exception_handler.rs index 844c32d123dd8..68accc1b65836 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/redundant_tuple_in_exception_handler.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/redundant_tuple_in_exception_handler.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, ExceptHandler, Expr, Ranged}; +use ruff_python_ast::{self as ast, ExceptHandler, Expr}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/reuse_of_groupby_generator.rs b/crates/ruff/src/rules/flake8_bugbear/rules/reuse_of_groupby_generator.rs index 1ffe1b59050d8..3bc93c22eb882 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/reuse_of_groupby_generator.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/reuse_of_groupby_generator.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Comprehension, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Comprehension, Expr, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::visitor::{self, Visitor}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/setattr_with_constant.rs b/crates/ruff/src/rules/flake8_bugbear/rules/setattr_with_constant.rs index 9bb1802b857b2..8b615947f7008 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/setattr_with_constant.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/setattr_with_constant.rs @@ -1,5 +1,5 @@ -use ruff_python_ast::{self as ast, Constant, Expr, ExprContext, Identifier, Ranged, Stmt}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, Constant, Expr, ExprContext, Identifier, Stmt}; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/star_arg_unpacking_after_keyword_arg.rs b/crates/ruff/src/rules/flake8_bugbear/rules/star_arg_unpacking_after_keyword_arg.rs index 850fe175db16f..a281b9316389a 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/star_arg_unpacking_after_keyword_arg.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/star_arg_unpacking_after_keyword_arg.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Keyword, Ranged}; +use ruff_python_ast::{Expr, Keyword}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/strip_with_multi_characters.rs b/crates/ruff/src/rules/flake8_bugbear/rules/strip_with_multi_characters.rs index 3d4ad06ae8bd8..90637bd09f0ea 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/strip_with_multi_characters.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/strip_with_multi_characters.rs @@ -1,8 +1,9 @@ use itertools::Itertools; -use ruff_python_ast::{self as ast, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/unary_prefix_increment_decrement.rs b/crates/ruff/src/rules/flake8_bugbear/rules/unary_prefix_increment_decrement.rs index de6ffc4d11761..e193385239b8a 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/unary_prefix_increment_decrement.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/unary_prefix_increment_decrement.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged, UnaryOp}; +use ruff_python_ast::{self as ast, Expr, UnaryOp}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/unintentional_type_annotation.rs b/crates/ruff/src/rules/flake8_bugbear/rules/unintentional_type_annotation.rs index d50c91d486f39..69f8c5505d4e6 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/unintentional_type_annotation.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/unintentional_type_annotation.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Expr, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/unreliable_callable_check.rs b/crates/ruff/src/rules/flake8_bugbear/rules/unreliable_callable_check.rs index eefcf16bd7d5e..9a89bd4733888 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/unreliable_callable_check.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/unreliable_callable_check.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/unused_loop_control_variable.rs b/crates/ruff/src/rules/flake8_bugbear/rules/unused_loop_control_variable.rs index d8b37dac1abca..b2a40527b4a2a 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/unused_loop_control_variable.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/unused_loop_control_variable.rs @@ -3,8 +3,9 @@ use rustc_hash::FxHashMap; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::visitor::Visitor; -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_python_ast::{helpers, visitor}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/useless_comparison.rs b/crates/ruff/src/rules/flake8_bugbear/rules/useless_comparison.rs index 8cdcf2eeefd75..698f94e6f5216 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/useless_comparison.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/useless_comparison.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/useless_contextlib_suppress.rs b/crates/ruff/src/rules/flake8_bugbear/rules/useless_contextlib_suppress.rs index 207f452f9c567..a5761990ac001 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/useless_contextlib_suppress.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/useless_contextlib_suppress.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/useless_expression.rs b/crates/ruff/src/rules/flake8_bugbear/rules/useless_expression.rs index cdef77fcd68ad..5b98107290e1a 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/useless_expression.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/useless_expression.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::contains_effect; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_bugbear/rules/zip_without_explicit_strict.rs b/crates/ruff/src/rules/flake8_bugbear/rules/zip_without_explicit_strict.rs index c1ca58886be85..c7a807a50c16c 100644 --- a/crates/ruff/src/rules/flake8_bugbear/rules/zip_without_explicit_strict.rs +++ b/crates/ruff/src/rules/flake8_bugbear/rules/zip_without_explicit_strict.rs @@ -1,8 +1,9 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_none; -use ruff_python_ast::{self as ast, Arguments, Expr, Ranged}; +use ruff_python_ast::{self as ast, Arguments, Expr}; use ruff_python_semantic::SemanticModel; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_builtins/rules/builtin_argument_shadowing.rs b/crates/ruff/src/rules/flake8_builtins/rules/builtin_argument_shadowing.rs index 5f8418838bfb3..9406879f2fff5 100644 --- a/crates/ruff/src/rules/flake8_builtins/rules/builtin_argument_shadowing.rs +++ b/crates/ruff/src/rules/flake8_builtins/rules/builtin_argument_shadowing.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Parameter, Ranged}; +use ruff_python_ast::Parameter; use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Violation; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_comprehensions/fixes.rs b/crates/ruff/src/rules/flake8_comprehensions/fixes.rs index 8887808b5c09c..d9ccc5f92fde3 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/fixes.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/fixes.rs @@ -7,8 +7,8 @@ use libcst_native::{ RightParen, RightSquareBracket, Set, SetComp, SimpleString, SimpleWhitespace, TrailingWhitespace, Tuple, }; -use ruff_python_ast::{Expr, Ranged}; -use ruff_text_size::TextRange; +use ruff_python_ast::Expr; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{Edit, Fix}; use ruff_python_codegen::Stylist; diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs index ae09498b2995d..d85048b553f30 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_call_around_sorted.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_collection_call.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_collection_call.rs index abae945c1929c..8f8ec3fc26f64 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_collection_call.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_collection_call.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{Expr, Keyword, Ranged}; +use ruff_python_ast::{Expr, Keyword}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension.rs index 9fe91e5ee71fa..307225f7bcd31 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Comprehension, Expr, Ranged}; +use ruff_python_ast::{self as ast, Comprehension, Expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension_any_all.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension_any_all.rs index 00cdcfea4d55b..a1eb9eef177f4 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension_any_all.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_comprehension_any_all.rs @@ -1,9 +1,10 @@ -use ruff_python_ast::{self as ast, Expr, Keyword, Ranged}; +use ruff_python_ast::{self as ast, Expr, Keyword}; use ruff_diagnostics::Violation; use ruff_diagnostics::{AutofixKind, Diagnostic}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::any_over_expr; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_double_cast_or_process.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_double_cast_or_process.rs index cdf893625d618..7c682f7126671 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_double_cast_or_process.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_double_cast_or_process.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::comparable::ComparableKeyword; -use ruff_python_ast::{self as ast, Arguments, Expr, Keyword, Ranged}; +use ruff_python_ast::{self as ast, Arguments, Expr, Keyword}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_dict.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_dict.rs index 26e1fe42a25d5..955ddb9e8e04d 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_dict.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_dict.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Expr, Keyword, Ranged}; +use ruff_python_ast::{self as ast, Expr, Keyword}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs index 8f46043c17577..bdb5e0da2d78f 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Keyword, Ranged}; +use ruff_python_ast::{Expr, Keyword}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs index e89399719beb3..352f39d81ae2b 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Keyword, Ranged}; +use ruff_python_ast::{Expr, Keyword}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_call.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_call.rs index 18f980291ecfe..a8690718ed6a2 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_call.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_call.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_dict.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_dict.rs index 2cc597ae60eda..13b78e3af16d0 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_dict.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_dict.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Expr, Keyword, Ranged}; +use ruff_python_ast::{self as ast, Expr, Keyword}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_set.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_set.rs index 20d45cdf1ad9d..f3630147393cd 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_set.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_set.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Keyword, Ranged}; +use ruff_python_ast::{Expr, Keyword}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_dict.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_dict.rs index d1b098962c52c..c498d1c0821cb 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_dict.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_dict.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Expr, Keyword, Ranged}; +use ruff_python_ast::{self as ast, Expr, Keyword}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_set.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_set.rs index ccf78fb94ad88..35524e7db7f6e 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_set.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_set.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Keyword, Ranged}; +use ruff_python_ast::{Expr, Keyword}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_dict_call.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_dict_call.rs index c43259f52816f..52c7db6a2de83 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_dict_call.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_dict_call.rs @@ -1,9 +1,10 @@ use std::fmt; -use ruff_python_ast::{Expr, Keyword, Ranged}; +use ruff_python_ast::{Expr, Keyword}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_list_call.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_list_call.rs index 8d625d6115893..f76023080d9e7 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_list_call.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_list_call.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{Expr, Keyword, Ranged}; +use ruff_python_ast::{Expr, Keyword}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs index 10bc9dd19f6d8..a15d44559f192 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Keyword, Ranged}; +use ruff_python_ast::{Expr, Keyword}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_map.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_map.rs index 11c0d1a6094b7..25ccf295d6d35 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_map.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_map.rs @@ -5,7 +5,8 @@ use ruff_diagnostics::{Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::visitor; use ruff_python_ast::visitor::Visitor; -use ruff_python_ast::{self as ast, Arguments, Expr, ExprContext, Parameters, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Arguments, Expr, ExprContext, Parameters, Stmt}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_subscript_reversal.rs b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_subscript_reversal.rs index 092713ab4ec42..ab00f7892d926 100644 --- a/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_subscript_reversal.rs +++ b/crates/ruff/src/rules/flake8_comprehensions/rules/unnecessary_subscript_reversal.rs @@ -2,7 +2,8 @@ use num_bigint::BigInt; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Constant, Expr, Ranged, UnaryOp}; +use ruff_python_ast::{self as ast, Constant, Expr, UnaryOp}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs b/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs index 25c86ae1ecb62..1db65f233e6e8 100644 --- a/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs +++ b/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_none; -use ruff_python_ast::{self as ast, Ranged}; +use ruff_python_ast::{self as ast}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::flake8_datetimez::rules::helpers::has_non_none_keyword; diff --git a/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_now_without_tzinfo.rs b/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_now_without_tzinfo.rs index 73dd721684817..1d7b839fd9217 100644 --- a/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_now_without_tzinfo.rs +++ b/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_now_without_tzinfo.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_none; -use ruff_python_ast::{self as ast, Ranged}; +use ruff_python_ast::{self as ast}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::flake8_datetimez::rules::helpers::has_non_none_keyword; diff --git a/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_strptime_without_zone.rs b/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_strptime_without_zone.rs index c516f9c3ab9d2..bde872c4dac64 100644 --- a/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_strptime_without_zone.rs +++ b/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_strptime_without_zone.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::flake8_datetimez::rules::helpers::has_non_none_keyword; diff --git a/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs b/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs index cc0cb486a23f2..4de1f85ac803a 100644 --- a/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs +++ b/crates/ruff/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_none; -use ruff_python_ast::{self as ast, Ranged}; +use ruff_python_ast::{self as ast}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::flake8_datetimez::rules::helpers::has_non_none_keyword; diff --git a/crates/ruff/src/rules/flake8_debugger/rules/debugger.rs b/crates/ruff/src/rules/flake8_debugger/rules/debugger.rs index 86f3962ab4c80..5cfc68a2bfea7 100644 --- a/crates/ruff/src/rules/flake8_debugger/rules/debugger.rs +++ b/crates/ruff/src/rules/flake8_debugger/rules/debugger.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Expr, Ranged, Stmt}; +use ruff_python_ast::{Expr, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::{format_call_path, from_unqualified_name, CallPath}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::flake8_debugger::types::DebuggerUsingType; diff --git a/crates/ruff/src/rules/flake8_django/rules/all_with_model_form.rs b/crates/ruff/src/rules/flake8_django/rules/all_with_model_form.rs index a54f7e08d260d..50a7f98c55a44 100644 --- a/crates/ruff/src/rules/flake8_django/rules/all_with_model_form.rs +++ b/crates/ruff/src/rules/flake8_django/rules/all_with_model_form.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Arguments, Constant, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Arguments, Constant, Expr, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::flake8_django::rules::helpers::is_model_form; diff --git a/crates/ruff/src/rules/flake8_django/rules/exclude_with_model_form.rs b/crates/ruff/src/rules/flake8_django/rules/exclude_with_model_form.rs index af99c84cc8cc0..41661892bb9d6 100644 --- a/crates/ruff/src/rules/flake8_django/rules/exclude_with_model_form.rs +++ b/crates/ruff/src/rules/flake8_django/rules/exclude_with_model_form.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Arguments, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Arguments, Expr, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::flake8_django::rules::helpers::is_model_form; diff --git a/crates/ruff/src/rules/flake8_django/rules/locals_in_render_function.rs b/crates/ruff/src/rules/flake8_django/rules/locals_in_render_function.rs index eb7c62682ff15..c46657684d236 100644 --- a/crates/ruff/src/rules/flake8_django/rules/locals_in_render_function.rs +++ b/crates/ruff/src/rules/flake8_django/rules/locals_in_render_function.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_python_semantic::SemanticModel; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_django/rules/model_without_dunder_str.rs b/crates/ruff/src/rules/flake8_django/rules/model_without_dunder_str.rs index ed310166bc66c..9228d04753e4e 100644 --- a/crates/ruff/src/rules/flake8_django/rules/model_without_dunder_str.rs +++ b/crates/ruff/src/rules/flake8_django/rules/model_without_dunder_str.rs @@ -1,9 +1,10 @@ -use ruff_python_ast::{self as ast, Arguments, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Arguments, Expr, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_true; use ruff_python_semantic::SemanticModel; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_django/rules/non_leading_receiver_decorator.rs b/crates/ruff/src/rules/flake8_django/rules/non_leading_receiver_decorator.rs index fc75278c45046..8c7b3ab7a39d0 100644 --- a/crates/ruff/src/rules/flake8_django/rules/non_leading_receiver_decorator.rs +++ b/crates/ruff/src/rules/flake8_django/rules/non_leading_receiver_decorator.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Decorator, Ranged}; +use ruff_python_ast::Decorator; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_django/rules/nullable_model_string_field.rs b/crates/ruff/src/rules/flake8_django/rules/nullable_model_string_field.rs index 1d14bd14d56b2..42034271e8f91 100644 --- a/crates/ruff/src/rules/flake8_django/rules/nullable_model_string_field.rs +++ b/crates/ruff/src/rules/flake8_django/rules/nullable_model_string_field.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Arguments, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Arguments, Expr, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_true; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_django/rules/unordered_body_content_in_model.rs b/crates/ruff/src/rules/flake8_django/rules/unordered_body_content_in_model.rs index c623842abc4f4..01a63d4e342f9 100644 --- a/crates/ruff/src/rules/flake8_django/rules/unordered_body_content_in_model.rs +++ b/crates/ruff/src/rules/flake8_django/rules/unordered_body_content_in_model.rs @@ -1,10 +1,11 @@ use std::fmt; -use ruff_python_ast::{self as ast, Arguments, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Arguments, Expr, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_semantic::SemanticModel; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_errmsg/rules/string_in_exception.rs b/crates/ruff/src/rules/flake8_errmsg/rules/string_in_exception.rs index 928d6eb873d7c..d3668322a1aac 100644 --- a/crates/ruff/src/rules/flake8_errmsg/rules/string_in_exception.rs +++ b/crates/ruff/src/rules/flake8_errmsg/rules/string_in_exception.rs @@ -1,5 +1,5 @@ -use ruff_python_ast::{self as ast, Arguments, Constant, Expr, ExprContext, Ranged, Stmt}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, Arguments, Constant, Expr, ExprContext, Stmt}; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; diff --git a/crates/ruff/src/rules/flake8_executable/rules/shebang_missing_executable_file.rs b/crates/ruff/src/rules/flake8_executable/rules/shebang_missing_executable_file.rs index 6ad2e3e20259a..6ff0dedd3159b 100644 --- a/crates/ruff/src/rules/flake8_executable/rules/shebang_missing_executable_file.rs +++ b/crates/ruff/src/rules/flake8_executable/rules/shebang_missing_executable_file.rs @@ -2,7 +2,7 @@ use std::path::Path; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use wsl; use ruff_diagnostics::{Diagnostic, Violation}; diff --git a/crates/ruff/src/rules/flake8_executable/rules/shebang_not_executable.rs b/crates/ruff/src/rules/flake8_executable/rules/shebang_not_executable.rs index 4df36e3335b03..4bc71a4c160f0 100644 --- a/crates/ruff/src/rules/flake8_executable/rules/shebang_not_executable.rs +++ b/crates/ruff/src/rules/flake8_executable/rules/shebang_not_executable.rs @@ -2,7 +2,7 @@ use std::path::Path; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use wsl; use ruff_diagnostics::{Diagnostic, Violation}; diff --git a/crates/ruff/src/rules/flake8_future_annotations/rules/future_required_type_annotation.rs b/crates/ruff/src/rules/flake8_future_annotations/rules/future_required_type_annotation.rs index 445b5c35de8da..b994378a34e2f 100644 --- a/crates/ruff/src/rules/flake8_future_annotations/rules/future_required_type_annotation.rs +++ b/crates/ruff/src/rules/flake8_future_annotations/rules/future_required_type_annotation.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use std::fmt; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_future_annotations/rules/future_rewritable_type_annotation.rs b/crates/ruff/src/rules/flake8_future_annotations/rules/future_rewritable_type_annotation.rs index 5fb3f5708c02b..ceb47b1471c07 100644 --- a/crates/ruff/src/rules/flake8_future_annotations/rules/future_rewritable_type_annotation.rs +++ b/crates/ruff/src/rules/flake8_future_annotations/rules/future_rewritable_type_annotation.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::format_call_path; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_gettext/rules/f_string_in_gettext_func_call.rs b/crates/ruff/src/rules/flake8_gettext/rules/f_string_in_gettext_func_call.rs index 2b38343ad7202..b61e15b96d0e0 100644 --- a/crates/ruff/src/rules/flake8_gettext/rules/f_string_in_gettext_func_call.rs +++ b/crates/ruff/src/rules/flake8_gettext/rules/f_string_in_gettext_func_call.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_gettext/rules/format_in_gettext_func_call.rs b/crates/ruff/src/rules/flake8_gettext/rules/format_in_gettext_func_call.rs index 883476fd13d52..33f29c3b294d3 100644 --- a/crates/ruff/src/rules/flake8_gettext/rules/format_in_gettext_func_call.rs +++ b/crates/ruff/src/rules/flake8_gettext/rules/format_in_gettext_func_call.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_gettext/rules/printf_in_gettext_func_call.rs b/crates/ruff/src/rules/flake8_gettext/rules/printf_in_gettext_func_call.rs index 14396ab18afe1..865ad9a4261f0 100644 --- a/crates/ruff/src/rules/flake8_gettext/rules/printf_in_gettext_func_call.rs +++ b/crates/ruff/src/rules/flake8_gettext/rules/printf_in_gettext_func_call.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Constant, Expr, Operator, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr, Operator}; use crate::checkers::ast::Checker; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; /// ## What it does /// Checks for printf-style formatted strings in `gettext` function calls. diff --git a/crates/ruff/src/rules/flake8_implicit_str_concat/rules/explicit.rs b/crates/ruff/src/rules/flake8_implicit_str_concat/rules/explicit.rs index f34fb79fa7c9e..6934e720ac697 100644 --- a/crates/ruff/src/rules/flake8_implicit_str_concat/rules/explicit.rs +++ b/crates/ruff/src/rules/flake8_implicit_str_concat/rules/explicit.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Constant, Expr, Operator, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr, Operator}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_source_file::Locator; +use ruff_text_size::Ranged; /// ## What it does /// Checks for string literals that are explicitly concatenated (using the diff --git a/crates/ruff/src/rules/flake8_implicit_str_concat/rules/implicit.rs b/crates/ruff/src/rules/flake8_implicit_str_concat/rules/implicit.rs index e516cd56e8a51..0a2e381a55a9a 100644 --- a/crates/ruff/src/rules/flake8_implicit_str_concat/rules/implicit.rs +++ b/crates/ruff/src/rules/flake8_implicit_str_concat/rules/implicit.rs @@ -1,6 +1,6 @@ use itertools::Itertools; use ruff_python_parser::lexer::LexResult; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; diff --git a/crates/ruff/src/rules/flake8_import_conventions/rules/banned_import_alias.rs b/crates/ruff/src/rules/flake8_import_conventions/rules/banned_import_alias.rs index ef20772a1c9fa..dec35f17cba54 100644 --- a/crates/ruff/src/rules/flake8_import_conventions/rules/banned_import_alias.rs +++ b/crates/ruff/src/rules/flake8_import_conventions/rules/banned_import_alias.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Ranged, Stmt}; +use ruff_python_ast::Stmt; use rustc_hash::FxHashMap; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; /// ## What it does /// Checks for imports that use non-standard naming conventions, like diff --git a/crates/ruff/src/rules/flake8_import_conventions/rules/banned_import_from.rs b/crates/ruff/src/rules/flake8_import_conventions/rules/banned_import_from.rs index 7c76fe31c94a6..23566137318fa 100644 --- a/crates/ruff/src/rules/flake8_import_conventions/rules/banned_import_from.rs +++ b/crates/ruff/src/rules/flake8_import_conventions/rules/banned_import_from.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Ranged, Stmt}; +use ruff_python_ast::Stmt; use rustc_hash::FxHashSet; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; /// ## What it does /// Checks for member imports that should instead be accessed by importing the diff --git a/crates/ruff/src/rules/flake8_import_conventions/rules/unconventional_import_alias.rs b/crates/ruff/src/rules/flake8_import_conventions/rules/unconventional_import_alias.rs index 4ee2cf7b46931..4fb54aa1c531a 100644 --- a/crates/ruff/src/rules/flake8_import_conventions/rules/unconventional_import_alias.rs +++ b/crates/ruff/src/rules/flake8_import_conventions/rules/unconventional_import_alias.rs @@ -2,8 +2,8 @@ use rustc_hash::FxHashMap; use ruff_diagnostics::{AutofixKind, Diagnostic, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_semantic::{Binding, Imported}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_logging_format/rules/logging_call.rs b/crates/ruff/src/rules/flake8_logging_format/rules/logging_call.rs index 0a9cc72ecc71f..29b2b9711b602 100644 --- a/crates/ruff/src/rules/flake8_logging_format/rules/logging_call.rs +++ b/crates/ruff/src/rules/flake8_logging_format/rules/logging_call.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{Diagnostic, Edit, Fix}; -use ruff_python_ast::{self as ast, Arguments, Constant, Expr, Keyword, Operator, Ranged}; +use ruff_python_ast::{self as ast, Arguments, Constant, Expr, Keyword, Operator}; use ruff_python_semantic::analyze::logging; use ruff_python_stdlib::logging::LoggingLevel; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::{AsRule, Rule}; diff --git a/crates/ruff/src/rules/flake8_pie/rules/duplicate_class_field_definition.rs b/crates/ruff/src/rules/flake8_pie/rules/duplicate_class_field_definition.rs index df9a36c219a3b..07c49fcd41529 100644 --- a/crates/ruff/src/rules/flake8_pie/rules/duplicate_class_field_definition.rs +++ b/crates/ruff/src/rules/flake8_pie/rules/duplicate_class_field_definition.rs @@ -3,7 +3,8 @@ use rustc_hash::FxHashSet; use ruff_diagnostics::Diagnostic; use ruff_diagnostics::{AlwaysAutofixableViolation, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Expr, Stmt}; +use ruff_text_size::Ranged; use crate::autofix; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_pie/rules/multiple_starts_ends_with.rs b/crates/ruff/src/rules/flake8_pie/rules/multiple_starts_ends_with.rs index c071007f60a47..9a1f55194d537 100644 --- a/crates/ruff/src/rules/flake8_pie/rules/multiple_starts_ends_with.rs +++ b/crates/ruff/src/rules/flake8_pie/rules/multiple_starts_ends_with.rs @@ -3,9 +3,9 @@ use std::iter; use itertools::Either::{Left, Right}; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; -use ruff_python_ast::{self as ast, Arguments, BoolOp, Expr, ExprContext, Identifier, Ranged}; +use ruff_python_ast::{self as ast, Arguments, BoolOp, Expr, ExprContext, Identifier}; use ruff_diagnostics::AlwaysAutofixableViolation; use ruff_diagnostics::{Diagnostic, Edit, Fix}; diff --git a/crates/ruff/src/rules/flake8_pie/rules/no_unnecessary_pass.rs b/crates/ruff/src/rules/flake8_pie/rules/no_unnecessary_pass.rs index 96999f479ce24..569c8a66d87a4 100644 --- a/crates/ruff/src/rules/flake8_pie/rules/no_unnecessary_pass.rs +++ b/crates/ruff/src/rules/flake8_pie/rules/no_unnecessary_pass.rs @@ -1,10 +1,11 @@ -use ruff_python_ast::{Ranged, Stmt}; +use ruff_python_ast::Stmt; use ruff_diagnostics::AlwaysAutofixableViolation; use ruff_diagnostics::{Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_docstring_stmt; use ruff_python_ast::whitespace::trailing_comment_start_offset; +use ruff_text_size::Ranged; use crate::autofix; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_pie/rules/non_unique_enums.rs b/crates/ruff/src/rules/flake8_pie/rules/non_unique_enums.rs index 7603fa3d44bd1..6a0e62b47c307 100644 --- a/crates/ruff/src/rules/flake8_pie/rules/non_unique_enums.rs +++ b/crates/ruff/src/rules/flake8_pie/rules/non_unique_enums.rs @@ -4,7 +4,8 @@ use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Violation; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::comparable::ComparableExpr; -use ruff_python_ast::{self as ast, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Expr, Stmt}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_pie/rules/reimplemented_list_builtin.rs b/crates/ruff/src/rules/flake8_pie/rules/reimplemented_list_builtin.rs index 2c5a8bae51231..3903b7cfe6027 100644 --- a/crates/ruff/src/rules/flake8_pie/rules/reimplemented_list_builtin.rs +++ b/crates/ruff/src/rules/flake8_pie/rules/reimplemented_list_builtin.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Expr, ExprLambda, Ranged}; +use ruff_python_ast::{self as ast, Expr, ExprLambda}; use ruff_diagnostics::{AutofixKind, Violation}; use ruff_diagnostics::{Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_pie/rules/unnecessary_dict_kwargs.rs b/crates/ruff/src/rules/flake8_pie/rules/unnecessary_dict_kwargs.rs index 92f14a08f597a..550892b3f379a 100644 --- a/crates/ruff/src/rules/flake8_pie/rules/unnecessary_dict_kwargs.rs +++ b/crates/ruff/src/rules/flake8_pie/rules/unnecessary_dict_kwargs.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Constant, Expr, Keyword, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr, Keyword}; use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Violation; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use ruff_python_stdlib::identifiers::is_identifier; diff --git a/crates/ruff/src/rules/flake8_pie/rules/unnecessary_range_start.rs b/crates/ruff/src/rules/flake8_pie/rules/unnecessary_range_start.rs index a6d619a432c45..a6275ac602644 100644 --- a/crates/ruff/src/rules/flake8_pie/rules/unnecessary_range_start.rs +++ b/crates/ruff/src/rules/flake8_pie/rules/unnecessary_range_start.rs @@ -3,7 +3,8 @@ use num_bigint::BigInt; use ruff_diagnostics::Diagnostic; use ruff_diagnostics::{AlwaysAutofixableViolation, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr}; +use ruff_text_size::Ranged; use crate::autofix::edits::{remove_argument, Parentheses}; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_pie/rules/unnecessary_spread.rs b/crates/ruff/src/rules/flake8_pie/rules/unnecessary_spread.rs index ca8bf06920aaa..5edc51da5393d 100644 --- a/crates/ruff/src/rules/flake8_pie/rules/unnecessary_spread.rs +++ b/crates/ruff/src/rules/flake8_pie/rules/unnecessary_spread.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Violation; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_print/rules/print_call.rs b/crates/ruff/src/rules/flake8_print/rules/print_call.rs index 4b52aea891230..5ce49ce83eb69 100644 --- a/crates/ruff/src/rules/flake8_print/rules/print_call.rs +++ b/crates/ruff/src/rules/flake8_print/rules/print_call.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_none; -use ruff_python_ast::{self as ast, Ranged}; +use ruff_python_ast::{self as ast}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/any_eq_ne_annotation.rs b/crates/ruff/src/rules/flake8_pyi/rules/any_eq_ne_annotation.rs index ef1edc80649d4..d26879e414b77 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/any_eq_ne_annotation.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/any_eq_ne_annotation.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Parameters, Ranged}; +use ruff_python_ast::Parameters; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/bad_version_info_comparison.rs b/crates/ruff/src/rules/flake8_pyi/rules/bad_version_info_comparison.rs index dd46a4b2bfeb7..aac064960692c 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/bad_version_info_comparison.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/bad_version_info_comparison.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, CmpOp, Expr, Ranged}; +use ruff_python_ast::{self as ast, CmpOp, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/collections_named_tuple.rs b/crates/ruff/src/rules/flake8_pyi/rules/collections_named_tuple.rs index 81233fbfb0e39..6166d1aee1bad 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/collections_named_tuple.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/collections_named_tuple.rs @@ -2,7 +2,7 @@ use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/complex_if_statement_in_stub.rs b/crates/ruff/src/rules/flake8_pyi/rules/complex_if_statement_in_stub.rs index fd22dfd8e7c26..87e68fec1e226 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/complex_if_statement_in_stub.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/complex_if_statement_in_stub.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs b/crates/ruff/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs index 3528a580905a6..da360b76dd715 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs @@ -2,10 +2,11 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast as ast; use ruff_python_ast::helpers::map_subscript; -use ruff_python_ast::{Decorator, Expr, Parameters, Ranged, TypeParam, TypeParams}; +use ruff_python_ast::{Decorator, Expr, Parameters, TypeParam, TypeParams}; use ruff_python_semantic::analyze::visibility::{ is_abstract, is_classmethod, is_new, is_overload, is_staticmethod, }; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/docstring_in_stubs.rs b/crates/ruff/src/rules/flake8_pyi/rules/docstring_in_stubs.rs index 2646ab9918c98..6f96e8d29ef5a 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/docstring_in_stubs.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/docstring_in_stubs.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/duplicate_union_member.rs b/crates/ruff/src/rules/flake8_pyi/rules/duplicate_union_member.rs index 74b15ad9c5703..150beae73bccb 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/duplicate_union_member.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/duplicate_union_member.rs @@ -1,4 +1,4 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use rustc_hash::FxHashSet; use std::collections::HashSet; @@ -8,6 +8,7 @@ use crate::rules::flake8_pyi::helpers::traverse_union; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::comparable::ComparableExpr; +use ruff_text_size::Ranged; #[violation] pub struct DuplicateUnionMember { diff --git a/crates/ruff/src/rules/flake8_pyi/rules/ellipsis_in_non_empty_class_body.rs b/crates/ruff/src/rules/flake8_pyi/rules/ellipsis_in_non_empty_class_body.rs index 6b9d15327c285..c29b24697de53 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/ellipsis_in_non_empty_class_body.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/ellipsis_in_non_empty_class_body.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{Constant, Expr, ExprConstant, Ranged, Stmt, StmtExpr}; +use ruff_python_ast::{Constant, Expr, ExprConstant, Stmt, StmtExpr}; +use ruff_text_size::Ranged; use crate::autofix; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/exit_annotations.rs b/crates/ruff/src/rules/flake8_pyi/rules/exit_annotations.rs index 5a183d94d9b92..4add4c70abfc9 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/exit_annotations.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/exit_annotations.rs @@ -2,7 +2,7 @@ use std::fmt::{Display, Formatter}; use ruff_python_ast::{ Expr, ExprBinOp, ExprSubscript, ExprTuple, Identifier, Operator, ParameterWithDefault, - Parameters, Ranged, + Parameters, }; use smallvec::SmallVec; @@ -10,6 +10,7 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_none; use ruff_python_semantic::SemanticModel; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/iter_method_return_iterable.rs b/crates/ruff/src/rules/flake8_pyi/rules/iter_method_return_iterable.rs index a183b409b408a..db954557ef8bb 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/iter_method_return_iterable.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/iter_method_return_iterable.rs @@ -1,8 +1,7 @@ -use ruff_python_ast::Ranged; - use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::map_subscript; +use ruff_text_size::Ranged; use ruff_python_semantic::{Definition, Member, MemberKind}; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/no_return_argument_annotation.rs b/crates/ruff/src/rules/flake8_pyi/rules/no_return_argument_annotation.rs index e95b6c53047a5..7dd300115b4ae 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/no_return_argument_annotation.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/no_return_argument_annotation.rs @@ -1,10 +1,9 @@ use std::fmt; -use ruff_python_ast::Ranged; - use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::Parameters; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::settings::types::PythonVersion::Py311; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/non_empty_stub_body.rs b/crates/ruff/src/rules/flake8_pyi/rules/non_empty_stub_body.rs index ea165f358cd0f..9ac914d2f97dc 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/non_empty_stub_body.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/non_empty_stub_body.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Constant, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Constant, Expr, Stmt}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/numeric_literal_too_long.rs b/crates/ruff/src/rules/flake8_pyi/rules/numeric_literal_too_long.rs index 1e594e8da8a31..2eaaf64a27edb 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/numeric_literal_too_long.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/numeric_literal_too_long.rs @@ -1,5 +1,5 @@ -use ruff_python_ast::{Expr, Ranged}; -use ruff_text_size::TextSize; +use ruff_python_ast::Expr; +use ruff_text_size::{Ranged, TextSize}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/pass_in_class_body.rs b/crates/ruff/src/rules/flake8_pyi/rules/pass_in_class_body.rs index f5d071132e568..81028788408b8 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/pass_in_class_body.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/pass_in_class_body.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Ranged}; +use ruff_python_ast::{self as ast}; +use ruff_text_size::Ranged; use crate::autofix; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/pass_statement_stub_body.rs b/crates/ruff/src/rules/flake8_pyi/rules/pass_statement_stub_body.rs index b9d957b819e0c..e85433a9c5c8a 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/pass_statement_stub_body.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/pass_statement_stub_body.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{Ranged, Stmt}; +use ruff_python_ast::Stmt; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/prefix_type_params.rs b/crates/ruff/src/rules/flake8_pyi/rules/prefix_type_params.rs index 7273b312535a9..299594124e2e6 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/prefix_type_params.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/prefix_type_params.rs @@ -1,9 +1,10 @@ use std::fmt; -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/redundant_literal_union.rs b/crates/ruff/src/rules/flake8_pyi/rules/redundant_literal_union.rs index b1c112c0f9f9f..ea33fb736b773 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/redundant_literal_union.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/redundant_literal_union.rs @@ -1,11 +1,12 @@ use rustc_hash::FxHashSet; use std::fmt; -use ast::{Constant, Ranged}; +use ast::Constant; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::{self as ast, Expr}; use ruff_python_semantic::SemanticModel; +use ruff_text_size::Ranged; use crate::{checkers::ast::Checker, rules::flake8_pyi::helpers::traverse_union}; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/redundant_numeric_union.rs b/crates/ruff/src/rules/flake8_pyi/rules/redundant_numeric_union.rs index e9e3a7855e9ce..5a14dd3c14cab 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/redundant_numeric_union.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/redundant_numeric_union.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Parameters, Ranged}; +use ruff_python_ast::{Expr, Parameters}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::flake8_pyi::helpers::traverse_union; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/simple_defaults.rs b/crates/ruff/src/rules/flake8_pyi/rules/simple_defaults.rs index 355930bfa7311..85708ad0707c0 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/simple_defaults.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/simple_defaults.rs @@ -2,11 +2,12 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix, Violat use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::CallPath; use ruff_python_ast::{ - self as ast, Arguments, Constant, Expr, Operator, ParameterWithDefault, Parameters, Ranged, - Stmt, UnaryOp, + self as ast, Arguments, Constant, Expr, Operator, ParameterWithDefault, Parameters, Stmt, + UnaryOp, }; use ruff_python_semantic::{ScopeKind, SemanticModel}; use ruff_source_file::Locator; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::importer::ImportRequest; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/string_or_bytes_too_long.rs b/crates/ruff/src/rules/flake8_pyi/rules/string_or_bytes_too_long.rs index c66ecf894f5e6..bbf20bda6273c 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/string_or_bytes_too_long.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/string_or_bytes_too_long.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_docstring_stmt; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/unaliased_collections_abc_set_import.rs b/crates/ruff/src/rules/flake8_pyi/rules/unaliased_collections_abc_set_import.rs index a272e18385ab6..8ec902316e95a 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/unaliased_collections_abc_set_import.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/unaliased_collections_abc_set_import.rs @@ -1,8 +1,8 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_semantic::Imported; use ruff_python_semantic::{Binding, BindingKind}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/unnecessary_literal_union.rs b/crates/ruff/src/rules/flake8_pyi/rules/unnecessary_literal_union.rs index fd74996f9b94c..55dd35f6687f5 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/unnecessary_literal_union.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/unnecessary_literal_union.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::flake8_pyi::helpers::traverse_union; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/unnecessary_type_union.rs b/crates/ruff/src/rules/flake8_pyi/rules/unnecessary_type_union.rs index 8c0cac5c9763e..9c723411c4d12 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/unnecessary_type_union.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/unnecessary_type_union.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; +use ruff_text_size::Ranged; use crate::{checkers::ast::Checker, rules::flake8_pyi::helpers::traverse_union}; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/unrecognized_platform.rs b/crates/ruff/src/rules/flake8_pyi/rules/unrecognized_platform.rs index 75d48b7326b31..5793c24ae498b 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/unrecognized_platform.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/unrecognized_platform.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, CmpOp, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, CmpOp, Constant, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/unrecognized_version_info.rs b/crates/ruff/src/rules/flake8_pyi/rules/unrecognized_version_info.rs index 3f4c07209b131..4df6441d9358e 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/unrecognized_version_info.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/unrecognized_version_info.rs @@ -1,10 +1,11 @@ use num_bigint::BigInt; use num_traits::{One, Zero}; -use ruff_python_ast::{self as ast, CmpOp, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, CmpOp, Constant, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::map_subscript; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/unsupported_method_call_on_all.rs b/crates/ruff/src/rules/flake8_pyi/rules/unsupported_method_call_on_all.rs index bab2dad76ed92..5183fa580e725 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/unsupported_method_call_on_all.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/unsupported_method_call_on_all.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_pyi/rules/unused_private_type_definition.rs b/crates/ruff/src/rules/flake8_pyi/rules/unused_private_type_definition.rs index 3a306d064923e..094d1697c9f06 100644 --- a/crates/ruff/src/rules/flake8_pyi/rules/unused_private_type_definition.rs +++ b/crates/ruff/src/rules/flake8_pyi/rules/unused_private_type_definition.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Expr, Stmt}; use ruff_python_semantic::Scope; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/assertion.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/assertion.rs index 0201096a05b58..08f1b3b8f6854 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/assertion.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/assertion.rs @@ -13,11 +13,12 @@ use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::Truthiness; use ruff_python_ast::visitor::Visitor; use ruff_python_ast::{ - self as ast, Arguments, BoolOp, ExceptHandler, Expr, Keyword, Ranged, Stmt, UnaryOp, + self as ast, Arguments, BoolOp, ExceptHandler, Expr, Keyword, Stmt, UnaryOp, }; use ruff_python_ast::{visitor, whitespace}; use ruff_python_codegen::Stylist; use ruff_source_file::Locator; +use ruff_text_size::Ranged; use crate::autofix::codemods::CodegenStylist; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/fail.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/fail.rs index 6f469d9bf6c98..b23dd65b91511 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/fail.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/fail.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Ranged}; +use ruff_python_ast::{self as ast}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/fixture.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/fixture.rs index 0e2ec919a8b32..4e401c6b44d12 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/fixture.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/fixture.rs @@ -8,9 +8,10 @@ use ruff_python_ast::identifier::Identifier; use ruff_python_ast::visitor; use ruff_python_ast::visitor::Visitor; use ruff_python_ast::Decorator; -use ruff_python_ast::{self as ast, Expr, ParameterWithDefault, Parameters, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Expr, ParameterWithDefault, Parameters, Stmt}; use ruff_python_semantic::analyze::visibility::is_abstract; use ruff_python_semantic::SemanticModel; +use ruff_text_size::Ranged; use ruff_text_size::{TextLen, TextRange}; use crate::autofix::edits; diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/imports.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/imports.rs index 3d689ce76522a..ec1539d99f1ea 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/imports.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/imports.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Ranged, Stmt}; +use ruff_python_ast::Stmt; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; /// ## What it does /// Checks for incorrect import of pytest. diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/marks.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/marks.rs index 7a26b7ff2a1e7..01a3d3fc60da4 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/marks.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/marks.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Arguments, Decorator, Expr, Ranged}; +use ruff_python_ast::{self as ast, Arguments, Decorator, Expr}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::CallPath; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::{AsRule, Rule}; diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/parametrize.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/parametrize.rs index 3e12e82e67959..221b017e6ca80 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/parametrize.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/parametrize.rs @@ -7,10 +7,10 @@ use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::comparable::ComparableExpr; use ruff_python_ast::node::AstNode; use ruff_python_ast::parenthesize::parenthesized_range; -use ruff_python_ast::{self as ast, Arguments, Constant, Decorator, Expr, ExprContext, Ranged}; +use ruff_python_ast::{self as ast, Arguments, Constant, Decorator, Expr, ExprContext}; use ruff_python_codegen::Generator; use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; -use ruff_text_size::{TextRange, TextSize}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::checkers::ast::Checker; use crate::registry::{AsRule, Rule}; diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/patch.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/patch.rs index 229c13a28bbac..8232ed794fd7a 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/patch.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/patch.rs @@ -3,7 +3,8 @@ use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::collect_call_path; use ruff_python_ast::visitor; use ruff_python_ast::visitor::Visitor; -use ruff_python_ast::{self as ast, Expr, Parameters, Ranged}; +use ruff_python_ast::{self as ast, Expr, Parameters}; +use ruff_text_size::Ranged; /// ## What it does /// Checks for mocked calls that use a dummy `lambda` function instead of diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/raises.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/raises.rs index 9510b294c7b14..ec457155bd1e4 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/raises.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/raises.rs @@ -2,8 +2,9 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::format_call_path; use ruff_python_ast::helpers::is_compound_statement; -use ruff_python_ast::{self as ast, Expr, Ranged, Stmt, WithItem}; +use ruff_python_ast::{self as ast, Expr, Stmt, WithItem}; use ruff_python_semantic::SemanticModel; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/rules/flake8_raise/rules/unnecessary_paren_on_raise_exception.rs b/crates/ruff/src/rules/flake8_raise/rules/unnecessary_paren_on_raise_exception.rs index aa934d45d2246..2b8895dc60f3d 100644 --- a/crates/ruff/src/rules/flake8_raise/rules/unnecessary_paren_on_raise_exception.rs +++ b/crates/ruff/src/rules/flake8_raise/rules/unnecessary_paren_on_raise_exception.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_return/helpers.rs b/crates/ruff/src/rules/flake8_return/helpers.rs index a24cae600ff23..6b7f185b7d283 100644 --- a/crates/ruff/src/rules/flake8_return/helpers.rs +++ b/crates/ruff/src/rules/flake8_return/helpers.rs @@ -1,6 +1,6 @@ use ruff_python_ast as ast; -use ruff_python_ast::{Expr, Ranged, Stmt}; -use ruff_text_size::TextSize; +use ruff_python_ast::{Expr, Stmt}; +use ruff_text_size::{Ranged, TextSize}; use ruff_source_file::{Locator, UniversalNewlines}; diff --git a/crates/ruff/src/rules/flake8_return/rules/function.rs b/crates/ruff/src/rules/flake8_return/rules/function.rs index 5d604c6e4a60e..c041296372027 100644 --- a/crates/ruff/src/rules/flake8_return/rules/function.rs +++ b/crates/ruff/src/rules/flake8_return/rules/function.rs @@ -1,7 +1,7 @@ use std::ops::Add; -use ruff_python_ast::{self as ast, ElifElseClause, Expr, Ranged, Stmt}; -use ruff_text_size::{TextRange, TextSize}; +use ruff_python_ast::{self as ast, ElifElseClause, Expr, Stmt}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use ruff_diagnostics::{AlwaysAutofixableViolation, Violation}; use ruff_diagnostics::{Diagnostic, Edit, Fix}; diff --git a/crates/ruff/src/rules/flake8_self/rules/private_member_access.rs b/crates/ruff/src/rules/flake8_self/rules/private_member_access.rs index 8749d54b524dc..543c4d36d7348 100644 --- a/crates/ruff/src/rules/flake8_self/rules/private_member_access.rs +++ b/crates/ruff/src/rules/flake8_self/rules/private_member_access.rs @@ -1,8 +1,9 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::collect_call_path; -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_python_semantic::{BindingKind, ScopeKind}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_bool_op.rs b/crates/ruff/src/rules/flake8_simplify/rules/ast_bool_op.rs index d744ccdcb1dae..cbd348cc382f3 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/ast_bool_op.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/ast_bool_op.rs @@ -3,8 +3,8 @@ use std::iter; use itertools::Either::{Left, Right}; use itertools::Itertools; -use ruff_python_ast::{self as ast, Arguments, BoolOp, CmpOp, Expr, ExprContext, Ranged, UnaryOp}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, Arguments, BoolOp, CmpOp, Expr, ExprContext, UnaryOp}; +use ruff_text_size::{Ranged, TextRange}; use rustc_hash::FxHashMap; use ruff_diagnostics::{AlwaysAutofixableViolation, AutofixKind, Diagnostic, Edit, Fix, Violation}; diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_expr.rs b/crates/ruff/src/rules/flake8_simplify/rules/ast_expr.rs index 380a71bf0d270..8e1037e2cb3df 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/ast_expr.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/ast_expr.rs @@ -1,5 +1,5 @@ -use ruff_python_ast::{self as ast, Arguments, Constant, Expr, Ranged}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, Arguments, Constant, Expr}; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{AlwaysAutofixableViolation, AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_if.rs b/crates/ruff/src/rules/flake8_simplify/rules/ast_if.rs index 27d1b551421c8..d7b8ee3d2460d 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/ast_if.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/ast_if.rs @@ -1,9 +1,8 @@ use log::error; use ruff_python_ast::{ - self as ast, Arguments, CmpOp, Constant, ElifElseClause, Expr, ExprContext, Identifier, Ranged, - Stmt, + self as ast, Arguments, CmpOp, Constant, ElifElseClause, Expr, ExprContext, Identifier, Stmt, }; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use rustc_hash::FxHashSet; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_ifexp.rs b/crates/ruff/src/rules/flake8_simplify/rules/ast_ifexp.rs index 921ac370ee2eb..44cd2861a7545 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/ast_ifexp.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/ast_ifexp.rs @@ -1,5 +1,5 @@ -use ruff_python_ast::{self as ast, Arguments, Expr, ExprContext, Ranged, UnaryOp}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, Arguments, Expr, ExprContext, UnaryOp}; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{AlwaysAutofixableViolation, AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_unary_op.rs b/crates/ruff/src/rules/flake8_simplify/rules/ast_unary_op.rs index f5da2c443bddf..e6139e551a64b 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/ast_unary_op.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/ast_unary_op.rs @@ -1,5 +1,5 @@ -use ruff_python_ast::{self as ast, Arguments, CmpOp, Expr, ExprContext, Ranged, Stmt, UnaryOp}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, Arguments, CmpOp, Expr, ExprContext, Stmt, UnaryOp}; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; diff --git a/crates/ruff/src/rules/flake8_simplify/rules/ast_with.rs b/crates/ruff/src/rules/flake8_simplify/rules/ast_with.rs index 95fe3d66bebef..9fb96c0716c0f 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/ast_with.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/ast_with.rs @@ -3,10 +3,10 @@ use log::error; use ruff_diagnostics::{AutofixKind, Violation}; use ruff_diagnostics::{Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Ranged, Stmt, WithItem}; +use ruff_python_ast::{self as ast, Stmt, WithItem}; use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; use ruff_source_file::UniversalNewlines; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::checkers::ast::Checker; use crate::line_width::LineWidth; diff --git a/crates/ruff/src/rules/flake8_simplify/rules/fix_with.rs b/crates/ruff/src/rules/flake8_simplify/rules/fix_with.rs index 36d1f6eb962d8..3e0f6f0b13832 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/fix_with.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/fix_with.rs @@ -1,13 +1,14 @@ use anyhow::{bail, Result}; use libcst_native::{CompoundStatement, Statement, Suite, With}; -use ruff_python_ast::{self as ast, Ranged}; -use crate::autofix::codemods::CodegenStylist; use ruff_diagnostics::Edit; +use ruff_python_ast as ast; use ruff_python_ast::whitespace; use ruff_python_codegen::Stylist; use ruff_source_file::Locator; +use ruff_text_size::Ranged; +use crate::autofix::codemods::CodegenStylist; use crate::cst::matchers::{match_function_def, match_indented_block, match_statement, match_with}; /// (SIM117) Convert `with a: with b:` to `with a, b:`. diff --git a/crates/ruff/src/rules/flake8_simplify/rules/key_in_dict.rs b/crates/ruff/src/rules/flake8_simplify/rules/key_in_dict.rs index ac25976452be3..f6bf6cf940a78 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/key_in_dict.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/key_in_dict.rs @@ -3,8 +3,8 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::node::AnyNodeRef; use ruff_python_ast::parenthesize::parenthesized_range; -use ruff_python_ast::{self as ast, Arguments, CmpOp, Comprehension, Expr, Ranged}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, Arguments, CmpOp, Comprehension, Expr}; +use ruff_text_size::{Ranged, TextRange}; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flake8_simplify/rules/open_file_with_context_handler.rs b/crates/ruff/src/rules/flake8_simplify/rules/open_file_with_context_handler.rs index 5fd3a79c6d776..a55c49d8808c3 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/open_file_with_context_handler.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/open_file_with_context_handler.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Expr, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_semantic::SemanticModel; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_simplify/rules/reimplemented_builtin.rs b/crates/ruff/src/rules/flake8_simplify/rules/reimplemented_builtin.rs index 6246da0da370a..52f7465d731a6 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/reimplemented_builtin.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/reimplemented_builtin.rs @@ -1,8 +1,7 @@ use ruff_python_ast::{ - self as ast, Arguments, CmpOp, Comprehension, Constant, Expr, ExprContext, Ranged, Stmt, - UnaryOp, + self as ast, Arguments, CmpOp, Comprehension, Constant, Expr, ExprContext, Stmt, UnaryOp, }; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; diff --git a/crates/ruff/src/rules/flake8_simplify/rules/return_in_try_except_finally.rs b/crates/ruff/src/rules/flake8_simplify/rules/return_in_try_except_finally.rs index 6eb8ce649febe..055cd0548b399 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/return_in_try_except_finally.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/return_in_try_except_finally.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, ExceptHandler, Ranged, Stmt}; +use ruff_python_ast::{self as ast, ExceptHandler, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_simplify/rules/suppressible_exception.rs b/crates/ruff/src/rules/flake8_simplify/rules/suppressible_exception.rs index 1dd245089bcd4..1d9571324e128 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/suppressible_exception.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/suppressible_exception.rs @@ -1,10 +1,11 @@ -use ruff_python_ast::{self as ast, Constant, ExceptHandler, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Constant, ExceptHandler, Expr, Stmt}; use ruff_text_size::{TextLen, TextRange}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::compose_call_path; use ruff_python_ast::helpers; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::importer::ImportRequest; diff --git a/crates/ruff/src/rules/flake8_simplify/rules/yoda_conditions.rs b/crates/ruff/src/rules/flake8_simplify/rules/yoda_conditions.rs index f65dd7665d3df..99ae4f5a39970 100644 --- a/crates/ruff/src/rules/flake8_simplify/rules/yoda_conditions.rs +++ b/crates/ruff/src/rules/flake8_simplify/rules/yoda_conditions.rs @@ -3,10 +3,11 @@ use libcst_native::CompOp; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, CmpOp, Expr, Ranged, UnaryOp}; +use ruff_python_ast::{self as ast, CmpOp, Expr, UnaryOp}; use ruff_python_codegen::Stylist; use ruff_python_stdlib::str::{self}; use ruff_source_file::Locator; +use ruff_text_size::Ranged; use crate::autofix::snippet::SourceCodeSnippet; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_tidy_imports/rules/banned_api.rs b/crates/ruff/src/rules/flake8_tidy_imports/rules/banned_api.rs index a2e8e8ad255b0..98ea3ab488887 100644 --- a/crates/ruff/src/rules/flake8_tidy_imports/rules/banned_api.rs +++ b/crates/ruff/src/rules/flake8_tidy_imports/rules/banned_api.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::from_qualified_name; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::flake8_tidy_imports::matchers::NameMatchPolicy; diff --git a/crates/ruff/src/rules/flake8_tidy_imports/rules/banned_module_level_imports.rs b/crates/ruff/src/rules/flake8_tidy_imports/rules/banned_module_level_imports.rs index 283b8f90a4abe..61c0006544553 100644 --- a/crates/ruff/src/rules/flake8_tidy_imports/rules/banned_module_level_imports.rs +++ b/crates/ruff/src/rules/flake8_tidy_imports/rules/banned_module_level_imports.rs @@ -1,6 +1,6 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::flake8_tidy_imports::matchers::NameMatchPolicy; diff --git a/crates/ruff/src/rules/flake8_tidy_imports/rules/relative_imports.rs b/crates/ruff/src/rules/flake8_tidy_imports/rules/relative_imports.rs index a56f205127c17..30947874c9b47 100644 --- a/crates/ruff/src/rules/flake8_tidy_imports/rules/relative_imports.rs +++ b/crates/ruff/src/rules/flake8_tidy_imports/rules/relative_imports.rs @@ -1,5 +1,5 @@ -use ruff_python_ast::{self as ast, Identifier, Int, Ranged, Stmt}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, Identifier, Int, Stmt}; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; diff --git a/crates/ruff/src/rules/flake8_type_checking/rules/empty_type_checking_block.rs b/crates/ruff/src/rules/flake8_type_checking/rules/empty_type_checking_block.rs index eee9638e21c67..1a00637c85b80 100644 --- a/crates/ruff/src/rules/flake8_type_checking/rules/empty_type_checking_block.rs +++ b/crates/ruff/src/rules/flake8_type_checking/rules/empty_type_checking_block.rs @@ -1,8 +1,8 @@ use ruff_python_ast as ast; -use ruff_python_ast::Ranged; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::autofix; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs b/crates/ruff/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs index a3a01523f3ad4..3f39d4ad542af 100644 --- a/crates/ruff/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs +++ b/crates/ruff/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs @@ -5,9 +5,8 @@ use rustc_hash::FxHashMap; use ruff_diagnostics::{AutofixKind, Diagnostic, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_semantic::{AnyImport, Imported, NodeId, ResolvedReferenceId, Scope}; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::autofix; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs b/crates/ruff/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs index abb1bff8efb6f..eb933f2c31e9a 100644 --- a/crates/ruff/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs +++ b/crates/ruff/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs @@ -5,9 +5,8 @@ use rustc_hash::FxHashMap; use ruff_diagnostics::{AutofixKind, Diagnostic, DiagnosticKind, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_semantic::{AnyImport, Binding, Imported, NodeId, ResolvedReferenceId, Scope}; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::autofix; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_unused_arguments/rules/unused_arguments.rs b/crates/ruff/src/rules/flake8_unused_arguments/rules/unused_arguments.rs index 986ab3599659c..0d962d389665a 100644 --- a/crates/ruff/src/rules/flake8_unused_arguments/rules/unused_arguments.rs +++ b/crates/ruff/src/rules/flake8_unused_arguments/rules/unused_arguments.rs @@ -2,13 +2,14 @@ use std::iter; use regex::Regex; use ruff_python_ast as ast; -use ruff_python_ast::{Parameter, Parameters, Ranged}; +use ruff_python_ast::{Parameter, Parameters}; use ruff_diagnostics::DiagnosticKind; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_semantic::analyze::{function_type, visibility}; use ruff_python_semantic::{Scope, ScopeKind, SemanticModel}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/rules/flake8_use_pathlib/rules/os_sep_split.rs b/crates/ruff/src/rules/flake8_use_pathlib/rules/os_sep_split.rs index e502b074e2241..3cba8016e2cd6 100644 --- a/crates/ruff/src/rules/flake8_use_pathlib/rules/os_sep_split.rs +++ b/crates/ruff/src/rules/flake8_use_pathlib/rules/os_sep_split.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Expr, ExprAttribute, Ranged}; +use ruff_python_ast::{self as ast, Expr, ExprAttribute}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/flake8_use_pathlib/rules/replaceable_by_pathlib.rs b/crates/ruff/src/rules/flake8_use_pathlib/rules/replaceable_by_pathlib.rs index 2048d05b71f4d..7e65c574559a8 100644 --- a/crates/ruff/src/rules/flake8_use_pathlib/rules/replaceable_by_pathlib.rs +++ b/crates/ruff/src/rules/flake8_use_pathlib/rules/replaceable_by_pathlib.rs @@ -1,6 +1,6 @@ -use ruff_python_ast::{Expr, Ranged}; - use ruff_diagnostics::{Diagnostic, DiagnosticKind}; +use ruff_python_ast::Expr; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/flynt/rules/static_join_to_fstring.rs b/crates/ruff/src/rules/flynt/rules/static_join_to_fstring.rs index 980680bb85b2b..d89e98a444060 100644 --- a/crates/ruff/src/rules/flynt/rules/static_join_to_fstring.rs +++ b/crates/ruff/src/rules/flynt/rules/static_join_to_fstring.rs @@ -2,8 +2,8 @@ use itertools::Itertools; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Arguments, Constant, Expr, Ranged}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, Arguments, Constant, Expr}; +use ruff_text_size::{Ranged, TextRange}; use crate::autofix::snippet::SourceCodeSnippet; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/isort/annotate.rs b/crates/ruff/src/rules/isort/annotate.rs index d434d0bde769f..6d4659134f46d 100644 --- a/crates/ruff/src/rules/isort/annotate.rs +++ b/crates/ruff/src/rules/isort/annotate.rs @@ -1,5 +1,5 @@ -use ruff_python_ast::{self as ast, PySourceType, Ranged, Stmt}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, PySourceType, Stmt}; +use ruff_text_size::{Ranged, TextRange}; use ruff_source_file::Locator; diff --git a/crates/ruff/src/rules/isort/block.rs b/crates/ruff/src/rules/isort/block.rs index cc32b50a50e45..b4fdee6d44778 100644 --- a/crates/ruff/src/rules/isort/block.rs +++ b/crates/ruff/src/rules/isort/block.rs @@ -1,5 +1,5 @@ -use ruff_python_ast::{self as ast, ElifElseClause, ExceptHandler, MatchCase, Ranged, Stmt}; -use ruff_text_size::{TextRange, TextSize}; +use ruff_python_ast::{self as ast, ElifElseClause, ExceptHandler, MatchCase, Stmt}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use std::iter::Peekable; use std::slice; diff --git a/crates/ruff/src/rules/isort/comments.rs b/crates/ruff/src/rules/isort/comments.rs index b492ce6309cc4..daec232098375 100644 --- a/crates/ruff/src/rules/isort/comments.rs +++ b/crates/ruff/src/rules/isort/comments.rs @@ -1,9 +1,8 @@ use std::borrow::Cow; -use ruff_python_ast::Ranged; use ruff_python_index::Indexer; use ruff_source_file::Locator; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; #[derive(Debug)] pub(crate) struct Comment<'a> { diff --git a/crates/ruff/src/rules/isort/helpers.rs b/crates/ruff/src/rules/isort/helpers.rs index 00f9504ac3212..38cd8be521608 100644 --- a/crates/ruff/src/rules/isort/helpers.rs +++ b/crates/ruff/src/rules/isort/helpers.rs @@ -1,8 +1,8 @@ -use ruff_python_ast::{PySourceType, Ranged, Stmt}; +use ruff_python_ast::{PySourceType, Stmt}; use ruff_python_parser::{lexer, AsMode, Tok}; - use ruff_python_trivia::PythonWhitespace; use ruff_source_file::{Locator, UniversalNewlines}; +use ruff_text_size::Ranged; use crate::rules::isort::types::TrailingComma; diff --git a/crates/ruff/src/rules/isort/rules/add_required_imports.rs b/crates/ruff/src/rules/isort/rules/add_required_imports.rs index dd71b1e552638..73a5dc0da6433 100644 --- a/crates/ruff/src/rules/isort/rules/add_required_imports.rs +++ b/crates/ruff/src/rules/isort/rules/add_required_imports.rs @@ -1,14 +1,14 @@ use log::error; -use ruff_python_ast::{self as ast, PySourceType, Stmt, Suite}; -use ruff_text_size::{TextRange, TextSize}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_docstring_stmt; use ruff_python_ast::imports::{Alias, AnyImport, FutureImport, Import, ImportFrom}; +use ruff_python_ast::{self as ast, PySourceType, Stmt, Suite}; use ruff_python_codegen::Stylist; use ruff_python_parser::parse_suite; use ruff_source_file::Locator; +use ruff_text_size::{TextRange, TextSize}; use crate::importer::Importer; use crate::registry::Rule; diff --git a/crates/ruff/src/rules/isort/rules/organize_imports.rs b/crates/ruff/src/rules/isort/rules/organize_imports.rs index 3681ba1af61ff..53dfcb86846eb 100644 --- a/crates/ruff/src/rules/isort/rules/organize_imports.rs +++ b/crates/ruff/src/rules/isort/rules/organize_imports.rs @@ -5,12 +5,12 @@ use itertools::{EitherOrBoth, Itertools}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::whitespace::trailing_lines_end; -use ruff_python_ast::{PySourceType, Ranged, Stmt}; +use ruff_python_ast::{PySourceType, Stmt}; use ruff_python_codegen::Stylist; use ruff_python_index::Indexer; use ruff_python_trivia::{leading_indentation, textwrap::indent, PythonWhitespace}; use ruff_source_file::{Locator, UniversalNewlines}; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::line_width::LineWidth; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/numpy/rules/deprecated_function.rs b/crates/ruff/src/rules/numpy/rules/deprecated_function.rs index e29bc489c4c99..6c422c0cc03cf 100644 --- a/crates/ruff/src/rules/numpy/rules/deprecated_function.rs +++ b/crates/ruff/src/rules/numpy/rules/deprecated_function.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/numpy/rules/deprecated_type_alias.rs b/crates/ruff/src/rules/numpy/rules/deprecated_type_alias.rs index ae7d58e473dc8..3fcba94b3f31e 100644 --- a/crates/ruff/src/rules/numpy/rules/deprecated_type_alias.rs +++ b/crates/ruff/src/rules/numpy/rules/deprecated_type_alias.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/numpy/rules/legacy_random.rs b/crates/ruff/src/rules/numpy/rules/legacy_random.rs index 1d0f5f5762c29..d76507a8c709e 100644 --- a/crates/ruff/src/rules/numpy/rules/legacy_random.rs +++ b/crates/ruff/src/rules/numpy/rules/legacy_random.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pandas_vet/rules/assignment_to_df.rs b/crates/ruff/src/rules/pandas_vet/rules/assignment_to_df.rs index bb4be919c721e..bdca4d20317d7 100644 --- a/crates/ruff/src/rules/pandas_vet/rules/assignment_to_df.rs +++ b/crates/ruff/src/rules/pandas_vet/rules/assignment_to_df.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; /// ## What it does /// Checks for assignments to the variable `df`. diff --git a/crates/ruff/src/rules/pandas_vet/rules/attr.rs b/crates/ruff/src/rules/pandas_vet/rules/attr.rs index 05f3505db79a8..9d54b58cd7e62 100644 --- a/crates/ruff/src/rules/pandas_vet/rules/attr.rs +++ b/crates/ruff/src/rules/pandas_vet/rules/attr.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Expr, ExprContext, Ranged}; +use ruff_python_ast::{self as ast, Expr, ExprContext}; use ruff_diagnostics::Violation; use ruff_diagnostics::{Diagnostic, DiagnosticKind}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/rules/pandas_vet/rules/call.rs b/crates/ruff/src/rules/pandas_vet/rules/call.rs index 17e95c61f5ab8..98788ed06f6c3 100644 --- a/crates/ruff/src/rules/pandas_vet/rules/call.rs +++ b/crates/ruff/src/rules/pandas_vet/rules/call.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::Violation; use ruff_diagnostics::{Diagnostic, DiagnosticKind}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/rules/pandas_vet/rules/inplace_argument.rs b/crates/ruff/src/rules/pandas_vet/rules/inplace_argument.rs index cecd169ad0eb0..a7d9dc9f7e8d7 100644 --- a/crates/ruff/src/rules/pandas_vet/rules/inplace_argument.rs +++ b/crates/ruff/src/rules/pandas_vet/rules/inplace_argument.rs @@ -1,8 +1,9 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_true; -use ruff_python_ast::{self as ast, Keyword, Ranged}; +use ruff_python_ast::{self as ast, Keyword}; use ruff_source_file::Locator; +use ruff_text_size::Ranged; use crate::autofix::edits::{remove_argument, Parentheses}; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pandas_vet/rules/nunique_constant_series_check.rs b/crates/ruff/src/rules/pandas_vet/rules/nunique_constant_series_check.rs index b5fe027486d64..6147f18a878f7 100644 --- a/crates/ruff/src/rules/pandas_vet/rules/nunique_constant_series_check.rs +++ b/crates/ruff/src/rules/pandas_vet/rules/nunique_constant_series_check.rs @@ -1,9 +1,10 @@ use num_traits::One; -use ruff_python_ast::{self as ast, CmpOp, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, CmpOp, Constant, Expr}; use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Violation; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::pandas_vet::helpers::{test_expression, Resolution}; diff --git a/crates/ruff/src/rules/pandas_vet/rules/pd_merge.rs b/crates/ruff/src/rules/pandas_vet/rules/pd_merge.rs index 1bc605dc91c61..3c2c0eb381aef 100644 --- a/crates/ruff/src/rules/pandas_vet/rules/pd_merge.rs +++ b/crates/ruff/src/rules/pandas_vet/rules/pd_merge.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use crate::checkers::ast::Checker; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; /// ## What it does /// Checks for uses of `pd.merge` on Pandas objects. diff --git a/crates/ruff/src/rules/pandas_vet/rules/read_table.rs b/crates/ruff/src/rules/pandas_vet/rules/read_table.rs index fb03d56ef29ec..4d4aafb9ee275 100644 --- a/crates/ruff/src/rules/pandas_vet/rules/read_table.rs +++ b/crates/ruff/src/rules/pandas_vet/rules/read_table.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast as ast; -use ruff_python_ast::{Constant, Expr, Ranged}; +use ruff_python_ast::{Constant, Expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pandas_vet/rules/subscript.rs b/crates/ruff/src/rules/pandas_vet/rules/subscript.rs index c5b08a5227b9f..149ffa00a1eef 100644 --- a/crates/ruff/src/rules/pandas_vet/rules/subscript.rs +++ b/crates/ruff/src/rules/pandas_vet/rules/subscript.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::Violation; use ruff_diagnostics::{Diagnostic, DiagnosticKind}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/rules/pep8_naming/rules/camelcase_imported_as_acronym.rs b/crates/ruff/src/rules/pep8_naming/rules/camelcase_imported_as_acronym.rs index 3747063d778f7..29b746db208fc 100644 --- a/crates/ruff/src/rules/pep8_naming/rules/camelcase_imported_as_acronym.rs +++ b/crates/ruff/src/rules/pep8_naming/rules/camelcase_imported_as_acronym.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Alias, Ranged, Stmt}; +use ruff_python_ast::{Alias, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_stdlib::str::{self}; +use ruff_text_size::Ranged; use crate::rules::pep8_naming::helpers; use crate::settings::types::IdentifierPattern; diff --git a/crates/ruff/src/rules/pep8_naming/rules/camelcase_imported_as_constant.rs b/crates/ruff/src/rules/pep8_naming/rules/camelcase_imported_as_constant.rs index 21f5caba4b247..651403e1f293d 100644 --- a/crates/ruff/src/rules/pep8_naming/rules/camelcase_imported_as_constant.rs +++ b/crates/ruff/src/rules/pep8_naming/rules/camelcase_imported_as_constant.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Alias, Ranged, Stmt}; +use ruff_python_ast::{Alias, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_stdlib::str::{self}; +use ruff_text_size::Ranged; use crate::rules::pep8_naming::helpers; use crate::settings::types::IdentifierPattern; diff --git a/crates/ruff/src/rules/pep8_naming/rules/camelcase_imported_as_lowercase.rs b/crates/ruff/src/rules/pep8_naming/rules/camelcase_imported_as_lowercase.rs index 707fe2bfc04d3..84aa326331bc9 100644 --- a/crates/ruff/src/rules/pep8_naming/rules/camelcase_imported_as_lowercase.rs +++ b/crates/ruff/src/rules/pep8_naming/rules/camelcase_imported_as_lowercase.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Alias, Ranged, Stmt}; +use ruff_python_ast::{Alias, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::rules::pep8_naming::helpers; use crate::settings::types::IdentifierPattern; diff --git a/crates/ruff/src/rules/pep8_naming/rules/constant_imported_as_non_constant.rs b/crates/ruff/src/rules/pep8_naming/rules/constant_imported_as_non_constant.rs index b0c57ed3bd0ac..6d85174bbc268 100644 --- a/crates/ruff/src/rules/pep8_naming/rules/constant_imported_as_non_constant.rs +++ b/crates/ruff/src/rules/pep8_naming/rules/constant_imported_as_non_constant.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Alias, Ranged, Stmt}; +use ruff_python_ast::{Alias, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_stdlib::str; +use ruff_text_size::Ranged; use crate::settings::types::IdentifierPattern; diff --git a/crates/ruff/src/rules/pep8_naming/rules/invalid_argument_name.rs b/crates/ruff/src/rules/pep8_naming/rules/invalid_argument_name.rs index e196920eb391e..daa14b7cb2aca 100644 --- a/crates/ruff/src/rules/pep8_naming/rules/invalid_argument_name.rs +++ b/crates/ruff/src/rules/pep8_naming/rules/invalid_argument_name.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Parameter, Ranged}; +use ruff_python_ast::Parameter; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_stdlib::str; +use ruff_text_size::Ranged; use crate::settings::types::IdentifierPattern; diff --git a/crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_class_method.rs b/crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_class_method.rs index 07cce7e9e75ae..ff0846786d5ee 100644 --- a/crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_class_method.rs +++ b/crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_class_method.rs @@ -1,9 +1,10 @@ -use ruff_python_ast::{Decorator, ParameterWithDefault, Parameters, Ranged}; +use ruff_python_ast::{Decorator, ParameterWithDefault, Parameters}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_semantic::analyze::function_type; use ruff_python_semantic::Scope; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_method.rs b/crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_method.rs index e3cbe3c49e1fe..4e18781e624e6 100644 --- a/crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_method.rs +++ b/crates/ruff/src/rules/pep8_naming/rules/invalid_first_argument_name_for_method.rs @@ -1,9 +1,10 @@ -use ruff_python_ast::{Decorator, Parameters, Ranged}; +use ruff_python_ast::{Decorator, Parameters}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_semantic::analyze::function_type; use ruff_python_semantic::Scope; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pep8_naming/rules/invalid_module_name.rs b/crates/ruff/src/rules/pep8_naming/rules/invalid_module_name.rs index 62bdb4bd54f87..4d64c0c34d96f 100644 --- a/crates/ruff/src/rules/pep8_naming/rules/invalid_module_name.rs +++ b/crates/ruff/src/rules/pep8_naming/rules/invalid_module_name.rs @@ -1,11 +1,10 @@ use std::ffi::OsStr; use std::path::Path; -use ruff_text_size::TextRange; - use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_stdlib::identifiers::{is_migration_name, is_module_name}; +use ruff_text_size::TextRange; use crate::settings::types::IdentifierPattern; diff --git a/crates/ruff/src/rules/pep8_naming/rules/lowercase_imported_as_non_lowercase.rs b/crates/ruff/src/rules/pep8_naming/rules/lowercase_imported_as_non_lowercase.rs index 3160810014e6d..9c0491176c93d 100644 --- a/crates/ruff/src/rules/pep8_naming/rules/lowercase_imported_as_non_lowercase.rs +++ b/crates/ruff/src/rules/pep8_naming/rules/lowercase_imported_as_non_lowercase.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Alias, Ranged, Stmt}; +use ruff_python_ast::{Alias, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_stdlib::str; +use ruff_text_size::Ranged; use crate::settings::types::IdentifierPattern; diff --git a/crates/ruff/src/rules/pep8_naming/rules/mixed_case_variable_in_class_scope.rs b/crates/ruff/src/rules/pep8_naming/rules/mixed_case_variable_in_class_scope.rs index ac796dfe7962b..43269ecd91ae2 100644 --- a/crates/ruff/src/rules/pep8_naming/rules/mixed_case_variable_in_class_scope.rs +++ b/crates/ruff/src/rules/pep8_naming/rules/mixed_case_variable_in_class_scope.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Arguments, Expr, Ranged}; +use ruff_python_ast::{Arguments, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::pep8_naming::helpers; diff --git a/crates/ruff/src/rules/pep8_naming/rules/mixed_case_variable_in_global_scope.rs b/crates/ruff/src/rules/pep8_naming/rules/mixed_case_variable_in_global_scope.rs index 4eb648fe8f28d..b08aeb2a79dab 100644 --- a/crates/ruff/src/rules/pep8_naming/rules/mixed_case_variable_in_global_scope.rs +++ b/crates/ruff/src/rules/pep8_naming/rules/mixed_case_variable_in_global_scope.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::pep8_naming::helpers; diff --git a/crates/ruff/src/rules/pep8_naming/rules/non_lowercase_variable_in_function.rs b/crates/ruff/src/rules/pep8_naming/rules/non_lowercase_variable_in_function.rs index 41a7fea0caed9..9cbb325e5356e 100644 --- a/crates/ruff/src/rules/pep8_naming/rules/non_lowercase_variable_in_function.rs +++ b/crates/ruff/src/rules/pep8_naming/rules/non_lowercase_variable_in_function.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_stdlib::str; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::pep8_naming::helpers; diff --git a/crates/ruff/src/rules/perflint/rules/incorrect_dict_iterator.rs b/crates/ruff/src/rules/perflint/rules/incorrect_dict_iterator.rs index 8d25a2509dab6..0ed8dac1c307e 100644 --- a/crates/ruff/src/rules/perflint/rules/incorrect_dict_iterator.rs +++ b/crates/ruff/src/rules/perflint/rules/incorrect_dict_iterator.rs @@ -3,9 +3,9 @@ use std::fmt; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast as ast; -use ruff_python_ast::Ranged; use ruff_python_ast::{Arguments, Expr}; use ruff_python_semantic::SemanticModel; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/perflint/rules/try_except_in_loop.rs b/crates/ruff/src/rules/perflint/rules/try_except_in_loop.rs index 84e14e5386a6a..d5c57ce2ef679 100644 --- a/crates/ruff/src/rules/perflint/rules/try_except_in_loop.rs +++ b/crates/ruff/src/rules/perflint/rules/try_except_in_loop.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::statement_visitor::{walk_stmt, StatementVisitor}; -use ruff_python_ast::{self as ast, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Stmt}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::settings::types::PythonVersion; diff --git a/crates/ruff/src/rules/perflint/rules/unnecessary_list_cast.rs b/crates/ruff/src/rules/perflint/rules/unnecessary_list_cast.rs index 94385fca3b6bc..a9d062554a90f 100644 --- a/crates/ruff/src/rules/perflint/rules/unnecessary_list_cast.rs +++ b/crates/ruff/src/rules/perflint/rules/unnecessary_list_cast.rs @@ -1,9 +1,8 @@ -use ruff_python_ast::{self as ast, Arguments, Expr}; -use ruff_text_size::TextRange; - use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::Stmt; +use ruff_python_ast::{self as ast, Arguments, Expr}; +use ruff_text_size::TextRange; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pycodestyle/helpers.rs b/crates/ruff/src/rules/pycodestyle/helpers.rs index 46b728b224533..bead20f8b5a5a 100644 --- a/crates/ruff/src/rules/pycodestyle/helpers.rs +++ b/crates/ruff/src/rules/pycodestyle/helpers.rs @@ -2,9 +2,9 @@ use unicode_width::UnicodeWidthStr; use ruff_python_ast::node::AnyNodeRef; use ruff_python_ast::parenthesize::parenthesized_range; -use ruff_python_ast::{CmpOp, Expr, Ranged}; +use ruff_python_ast::{CmpOp, Expr}; use ruff_source_file::{Line, Locator}; -use ruff_text_size::{TextLen, TextRange}; +use ruff_text_size::{Ranged, TextLen, TextRange}; use crate::line_width::{LineLength, LineWidth, TabSize}; diff --git a/crates/ruff/src/rules/pycodestyle/rules/ambiguous_class_name.rs b/crates/ruff/src/rules/pycodestyle/rules/ambiguous_class_name.rs index e0b78659f6c96..687f3f592a77d 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/ambiguous_class_name.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/ambiguous_class_name.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Identifier, Ranged}; +use ruff_python_ast::Identifier; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::rules::pycodestyle::helpers::is_ambiguous_name; diff --git a/crates/ruff/src/rules/pycodestyle/rules/ambiguous_function_name.rs b/crates/ruff/src/rules/pycodestyle/rules/ambiguous_function_name.rs index 5a7a2dc80490a..678f48d5b8730 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/ambiguous_function_name.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/ambiguous_function_name.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Identifier, Ranged}; +use ruff_python_ast::Identifier; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::rules::pycodestyle::helpers::is_ambiguous_name; diff --git a/crates/ruff/src/rules/pycodestyle/rules/imports.rs b/crates/ruff/src/rules/pycodestyle/rules/imports.rs index 8e20077d34ac3..4a037d7d0d438 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/imports.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/imports.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{Alias, Ranged, Stmt}; +use ruff_python_ast::{Alias, Stmt}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pycodestyle/rules/lambda_assignment.rs b/crates/ruff/src/rules/pycodestyle/rules/lambda_assignment.rs index 2ad00759e5c63..5f45d647bd840 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/lambda_assignment.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/lambda_assignment.rs @@ -1,8 +1,7 @@ use ruff_python_ast::{ - self as ast, Constant, Expr, Identifier, Parameter, ParameterWithDefault, Parameters, Ranged, - Stmt, + self as ast, Constant, Expr, Identifier, Parameter, ParameterWithDefault, Parameters, Stmt, }; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; diff --git a/crates/ruff/src/rules/pycodestyle/rules/literal_comparisons.rs b/crates/ruff/src/rules/pycodestyle/rules/literal_comparisons.rs index 9c7f525b6ca72..1d8885b115f26 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/literal_comparisons.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/literal_comparisons.rs @@ -4,7 +4,8 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers; use ruff_python_ast::helpers::is_const_none; -use ruff_python_ast::{self as ast, CmpOp, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, CmpOp, Constant, Expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::codes::Rule; diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs index 94bbd34e2f4b8..3d01fad8dbd21 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs @@ -3,9 +3,8 @@ use ruff_diagnostics::Diagnostic; use ruff_diagnostics::Edit; use ruff_diagnostics::Fix; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_parser::TokenKind; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::checkers::logical_lines::LogicalLinesContext; diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace.rs b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace.rs index 6c90b80bc9c62..89a6d038c1abc 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace.rs @@ -1,9 +1,8 @@ use ruff_diagnostics::Edit; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_parser::TokenKind; -use ruff_text_size::TextSize; +use ruff_text_size::{Ranged, TextSize}; use crate::checkers::logical_lines::LogicalLinesContext; diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_after_keyword.rs b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_after_keyword.rs index c0df9e5d210de..0dc26221e8b52 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_after_keyword.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_after_keyword.rs @@ -1,7 +1,7 @@ use ruff_diagnostics::Violation; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_parser::TokenKind; +use ruff_text_size::Ranged; use crate::checkers::logical_lines::LogicalLinesContext; use crate::rules::pycodestyle::rules::logical_lines::LogicalLine; diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_around_operator.rs b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_around_operator.rs index ea1764daf0ba2..644443c4e80b7 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_around_operator.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_around_operator.rs @@ -1,7 +1,7 @@ use ruff_diagnostics::{DiagnosticKind, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_parser::TokenKind; +use ruff_text_size::Ranged; use crate::checkers::logical_lines::LogicalLinesContext; use crate::rules::pycodestyle::rules::logical_lines::LogicalLine; diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/mod.rs b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/mod.rs index 60fbb03998271..f736d6cb2fadd 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/mod.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/mod.rs @@ -13,9 +13,8 @@ use std::fmt::{Debug, Formatter}; use std::iter::FusedIterator; use bitflags::bitflags; -use ruff_python_ast::Ranged; use ruff_python_parser::lexer::LexResult; -use ruff_text_size::{TextLen, TextRange, TextSize}; +use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; use ruff_python_parser::TokenKind; use ruff_python_trivia::is_python_whitespace; diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs index e8347d18c7624..72e4d0c53caa5 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs @@ -1,8 +1,7 @@ use ruff_diagnostics::Violation; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_parser::TokenKind; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::checkers::logical_lines::LogicalLinesContext; diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_around_keywords.rs b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_around_keywords.rs index 2a2af9a0f1db4..650f92797d829 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_around_keywords.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_around_keywords.rs @@ -1,7 +1,6 @@ use ruff_diagnostics::Violation; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::checkers::logical_lines::LogicalLinesContext; diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_around_named_parameter_equals.rs b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_around_named_parameter_equals.rs index d7af34968ef4c..1c18184888437 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_around_named_parameter_equals.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_around_named_parameter_equals.rs @@ -1,8 +1,7 @@ use ruff_diagnostics::Violation; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_parser::TokenKind; -use ruff_text_size::{TextRange, TextSize}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::checkers::logical_lines::LogicalLinesContext; use crate::rules::pycodestyle::rules::logical_lines::{LogicalLine, LogicalLineToken}; diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_comment.rs b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_comment.rs index f6b1a9f4f72a7..366fc675b2311 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_comment.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_comment.rs @@ -1,10 +1,9 @@ use ruff_diagnostics::Violation; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_parser::TokenKind; use ruff_python_trivia::PythonWhitespace; use ruff_source_file::Locator; -use ruff_text_size::{TextLen, TextRange, TextSize}; +use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; use crate::checkers::logical_lines::LogicalLinesContext; use crate::rules::pycodestyle::rules::logical_lines::LogicalLine; diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_parameters.rs b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_parameters.rs index 0d3c6fe32f58c..0afe2e8ffb326 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_parameters.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_parameters.rs @@ -1,8 +1,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_parser::TokenKind; -use ruff_text_size::{TextRange, TextSize}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::checkers::logical_lines::LogicalLinesContext; use crate::rules::pycodestyle::rules::logical_lines::LogicalLine; diff --git a/crates/ruff/src/rules/pycodestyle/rules/not_tests.rs b/crates/ruff/src/rules/pycodestyle/rules/not_tests.rs index 7aba04d41aa0e..4eff0c967041f 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/not_tests.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/not_tests.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, CmpOp, Expr, Ranged}; +use ruff_python_ast::{self as ast, CmpOp, Expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::{AsRule, Rule}; diff --git a/crates/ruff/src/rules/pycodestyle/rules/trailing_whitespace.rs b/crates/ruff/src/rules/pycodestyle/rules/trailing_whitespace.rs index bbea9d4cef4d0..6f62451dc8c39 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/trailing_whitespace.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/trailing_whitespace.rs @@ -1,9 +1,8 @@ -use ruff_text_size::{TextLen, TextRange, TextSize}; - use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_index::Indexer; use ruff_source_file::{Line, Locator}; +use ruff_text_size::{TextLen, TextRange, TextSize}; use crate::registry::Rule; use crate::settings::Settings; diff --git a/crates/ruff/src/rules/pycodestyle/rules/type_comparison.rs b/crates/ruff/src/rules/pycodestyle/rules/type_comparison.rs index d0ae2d70a9cf5..b8ff329a3ee5b 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/type_comparison.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/type_comparison.rs @@ -2,7 +2,8 @@ use itertools::Itertools; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_none; -use ruff_python_ast::{self as ast, CmpOp, Expr, Ranged}; +use ruff_python_ast::{self as ast, CmpOp, Expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pydocstyle/rules/backslashes.rs b/crates/ruff/src/rules/pydocstyle/rules/backslashes.rs index 508d0dd85ce5d..91cc414c3bdc3 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/backslashes.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/backslashes.rs @@ -2,7 +2,7 @@ use memchr::memchr_iter; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::docstrings::Docstring; diff --git a/crates/ruff/src/rules/pydocstyle/rules/blank_after_summary.rs b/crates/ruff/src/rules/pydocstyle/rules/blank_after_summary.rs index b4d7f4531566a..05acc242c9b78 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/blank_after_summary.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/blank_after_summary.rs @@ -1,7 +1,7 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_source_file::{UniversalNewlineIterator, UniversalNewlines}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::docstrings::Docstring; diff --git a/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs b/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs index 3b97c4f80cb28..d57c5183a9603 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_class.rs @@ -1,8 +1,8 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_trivia::PythonWhitespace; use ruff_source_file::{UniversalNewlineIterator, UniversalNewlines}; +use ruff_text_size::Ranged; use ruff_text_size::{TextLen, TextRange}; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_function.rs b/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_function.rs index 8ae76d05380f0..66428fa76ecf8 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_function.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/blank_before_after_function.rs @@ -3,9 +3,9 @@ use regex::Regex; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_trivia::PythonWhitespace; use ruff_source_file::{UniversalNewlineIterator, UniversalNewlines}; +use ruff_text_size::Ranged; use ruff_text_size::{TextLen, TextRange}; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pydocstyle/rules/capitalized.rs b/crates/ruff/src/rules/pydocstyle/rules/capitalized.rs index f329672405669..afcc313c80f6d 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/capitalized.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/capitalized.rs @@ -1,6 +1,6 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; +use ruff_text_size::Ranged; use ruff_text_size::{TextLen, TextRange}; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pydocstyle/rules/ends_with_period.rs b/crates/ruff/src/rules/pydocstyle/rules/ends_with_period.rs index 7d16b5bcce52e..65cea763f0396 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/ends_with_period.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/ends_with_period.rs @@ -3,8 +3,8 @@ use strum::IntoEnumIterator; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_source_file::{UniversalNewlineIterator, UniversalNewlines}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::docstrings::sections::SectionKind; diff --git a/crates/ruff/src/rules/pydocstyle/rules/ends_with_punctuation.rs b/crates/ruff/src/rules/pydocstyle/rules/ends_with_punctuation.rs index aa06dafc5f87b..39b42105d59fc 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/ends_with_punctuation.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/ends_with_punctuation.rs @@ -3,8 +3,8 @@ use strum::IntoEnumIterator; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_source_file::{UniversalNewlineIterator, UniversalNewlines}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::docstrings::sections::SectionKind; diff --git a/crates/ruff/src/rules/pydocstyle/rules/indent.rs b/crates/ruff/src/rules/pydocstyle/rules/indent.rs index 663ee9cae3fde..c33bbea24a6d8 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/indent.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/indent.rs @@ -2,8 +2,8 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Violation}; use ruff_diagnostics::{Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::docstrings::{clean_space, leading_space}; -use ruff_python_ast::Ranged; use ruff_source_file::NewlineWithTrailingNewline; +use ruff_text_size::Ranged; use ruff_text_size::{TextLen, TextRange}; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pydocstyle/rules/multi_line_summary_start.rs b/crates/ruff/src/rules/pydocstyle/rules/multi_line_summary_start.rs index 1d58abeb56cb8..f78caf5987f45 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/multi_line_summary_start.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/multi_line_summary_start.rs @@ -1,11 +1,9 @@ -use ruff_python_ast::Ranged; -use ruff_text_size::{TextRange, TextSize}; - use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::str::{is_triple_quote, leading_quote}; use ruff_python_semantic::Definition; use ruff_source_file::{NewlineWithTrailingNewline, UniversalNewlineIterator}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::checkers::ast::Checker; use crate::docstrings::Docstring; diff --git a/crates/ruff/src/rules/pydocstyle/rules/newline_after_last_paragraph.rs b/crates/ruff/src/rules/pydocstyle/rules/newline_after_last_paragraph.rs index 3d61be2540a32..09ce6d84e9ff5 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/newline_after_last_paragraph.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/newline_after_last_paragraph.rs @@ -1,10 +1,10 @@ -use ruff_python_ast::Ranged; use ruff_text_size::{TextLen, TextSize}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::docstrings::clean_space; use ruff_source_file::{NewlineWithTrailingNewline, UniversalNewlines}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::docstrings::Docstring; diff --git a/crates/ruff/src/rules/pydocstyle/rules/no_signature.rs b/crates/ruff/src/rules/pydocstyle/rules/no_signature.rs index 5ba744a56b6de..b9e186c0929e9 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/no_signature.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/no_signature.rs @@ -1,7 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_source_file::UniversalNewlines; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::docstrings::Docstring; diff --git a/crates/ruff/src/rules/pydocstyle/rules/no_surrounding_whitespace.rs b/crates/ruff/src/rules/pydocstyle/rules/no_surrounding_whitespace.rs index d2a30fee7119c..f4f4223255146 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/no_surrounding_whitespace.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/no_surrounding_whitespace.rs @@ -1,7 +1,7 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_source_file::NewlineWithTrailingNewline; +use ruff_text_size::Ranged; use ruff_text_size::{TextLen, TextRange}; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pydocstyle/rules/non_imperative_mood.rs b/crates/ruff/src/rules/pydocstyle/rules/non_imperative_mood.rs index fc61f13a6dc09..ca6f210d0abd8 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/non_imperative_mood.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/non_imperative_mood.rs @@ -6,9 +6,9 @@ use once_cell::sync::Lazy; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::{from_qualified_name, CallPath}; -use ruff_python_ast::Ranged; use ruff_python_semantic::analyze::visibility::{is_property, is_test}; use ruff_source_file::UniversalNewlines; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::docstrings::Docstring; diff --git a/crates/ruff/src/rules/pydocstyle/rules/not_empty.rs b/crates/ruff/src/rules/pydocstyle/rules/not_empty.rs index c8b893fe173b8..9d3f8ec2e4d79 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/not_empty.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/not_empty.rs @@ -1,6 +1,6 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::docstrings::Docstring; diff --git a/crates/ruff/src/rules/pydocstyle/rules/one_liner.rs b/crates/ruff/src/rules/pydocstyle/rules/one_liner.rs index 97d79244ed271..dea59eae98ce2 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/one_liner.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/one_liner.rs @@ -1,8 +1,8 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::str::{leading_quote, trailing_quote}; -use ruff_python_ast::Ranged; use ruff_source_file::NewlineWithTrailingNewline; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::docstrings::Docstring; diff --git a/crates/ruff/src/rules/pydocstyle/rules/sections.rs b/crates/ruff/src/rules/pydocstyle/rules/sections.rs index 44da66e7076f9..5303b77a77f2e 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/sections.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/sections.rs @@ -8,11 +8,11 @@ use ruff_diagnostics::{Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::docstrings::{clean_space, leading_space}; use ruff_python_ast::identifier::Identifier; -use ruff_python_ast::{ParameterWithDefault, Ranged}; +use ruff_python_ast::ParameterWithDefault; use ruff_python_semantic::analyze::visibility::is_staticmethod; use ruff_python_trivia::{textwrap::dedent, PythonWhitespace}; use ruff_source_file::NewlineWithTrailingNewline; -use ruff_text_size::{TextLen, TextRange, TextSize}; +use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; use crate::checkers::ast::Checker; use crate::docstrings::sections::{SectionContext, SectionContexts, SectionKind}; diff --git a/crates/ruff/src/rules/pydocstyle/rules/starts_with_this.rs b/crates/ruff/src/rules/pydocstyle/rules/starts_with_this.rs index f5f36da599f2a..0cd38e1114c3a 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/starts_with_this.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/starts_with_this.rs @@ -1,6 +1,6 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::docstrings::Docstring; diff --git a/crates/ruff/src/rules/pydocstyle/rules/triple_quotes.rs b/crates/ruff/src/rules/pydocstyle/rules/triple_quotes.rs index 28a8604393059..c8b7d6208a80c 100644 --- a/crates/ruff/src/rules/pydocstyle/rules/triple_quotes.rs +++ b/crates/ruff/src/rules/pydocstyle/rules/triple_quotes.rs @@ -1,7 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_codegen::Quote; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::docstrings::Docstring; diff --git a/crates/ruff/src/rules/pyflakes/fixes.rs b/crates/ruff/src/rules/pyflakes/fixes.rs index 9a1aa46fb498c..0ac3ff97dbfbd 100644 --- a/crates/ruff/src/rules/pyflakes/fixes.rs +++ b/crates/ruff/src/rules/pyflakes/fixes.rs @@ -1,11 +1,12 @@ use anyhow::{Context, Ok, Result}; use ruff_diagnostics::Edit; -use ruff_python_ast::{self as ast, Ranged}; +use ruff_python_ast as ast; use ruff_python_codegen::Stylist; use ruff_python_semantic::Binding; use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; use ruff_source_file::Locator; +use ruff_text_size::Ranged; use crate::cst::matchers::{match_call_mut, match_dict, transform_expression}; diff --git a/crates/ruff/src/rules/pyflakes/rules/assert_tuple.rs b/crates/ruff/src/rules/pyflakes/rules/assert_tuple.rs index b83e60914e425..0fde7fb5aed01 100644 --- a/crates/ruff/src/rules/pyflakes/rules/assert_tuple.rs +++ b/crates/ruff/src/rules/pyflakes/rules/assert_tuple.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Expr, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyflakes/rules/break_outside_loop.rs b/crates/ruff/src/rules/pyflakes/rules/break_outside_loop.rs index 0fb29fcc041aa..0765f117dd118 100644 --- a/crates/ruff/src/rules/pyflakes/rules/break_outside_loop.rs +++ b/crates/ruff/src/rules/pyflakes/rules/break_outside_loop.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; /// ## What it does /// Checks for `break` statements outside of loops. diff --git a/crates/ruff/src/rules/pyflakes/rules/continue_outside_loop.rs b/crates/ruff/src/rules/pyflakes/rules/continue_outside_loop.rs index 15a0accc9cb9d..894295a01b55f 100644 --- a/crates/ruff/src/rules/pyflakes/rules/continue_outside_loop.rs +++ b/crates/ruff/src/rules/pyflakes/rules/continue_outside_loop.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; /// ## What it does /// Checks for `continue` statements outside of loops. diff --git a/crates/ruff/src/rules/pyflakes/rules/f_string_missing_placeholders.rs b/crates/ruff/src/rules/pyflakes/rules/f_string_missing_placeholders.rs index 5606cb74c32e5..3e2dc1a50458b 100644 --- a/crates/ruff/src/rules/pyflakes/rules/f_string_missing_placeholders.rs +++ b/crates/ruff/src/rules/pyflakes/rules/f_string_missing_placeholders.rs @@ -1,10 +1,9 @@ -use ruff_python_ast::{Expr, PySourceType, Ranged}; -use ruff_python_parser::{lexer, AsMode, StringKind, Tok}; -use ruff_text_size::{TextRange, TextSize}; - use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_python_ast::{Expr, PySourceType}; +use ruff_python_parser::{lexer, AsMode, StringKind, Tok}; use ruff_source_file::Locator; +use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pyflakes/rules/future_feature_not_defined.rs b/crates/ruff/src/rules/pyflakes/rules/future_feature_not_defined.rs index ff6aa3918518c..18af0d3e303ad 100644 --- a/crates/ruff/src/rules/pyflakes/rules/future_feature_not_defined.rs +++ b/crates/ruff/src/rules/pyflakes/rules/future_feature_not_defined.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Alias, Ranged}; +use ruff_python_ast::Alias; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_stdlib::future::is_feature_name; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyflakes/rules/if_tuple.rs b/crates/ruff/src/rules/pyflakes/rules/if_tuple.rs index 4644adac01d09..540065a6b968d 100644 --- a/crates/ruff/src/rules/pyflakes/rules/if_tuple.rs +++ b/crates/ruff/src/rules/pyflakes/rules/if_tuple.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Expr, Ranged, StmtIf}; +use ruff_python_ast::{self as ast, Expr, StmtIf}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::stmt_if::if_elif_branches; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyflakes/rules/invalid_literal_comparisons.rs b/crates/ruff/src/rules/pyflakes/rules/invalid_literal_comparisons.rs index c29012cd200fd..c4d0364b28456 100644 --- a/crates/ruff/src/rules/pyflakes/rules/invalid_literal_comparisons.rs +++ b/crates/ruff/src/rules/pyflakes/rules/invalid_literal_comparisons.rs @@ -1,10 +1,11 @@ use log::error; -use ruff_python_ast::{CmpOp, Expr, Ranged}; +use ruff_python_ast::{CmpOp, Expr}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers; use ruff_python_parser::locate_cmp_ops; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pyflakes/rules/invalid_print_syntax.rs b/crates/ruff/src/rules/pyflakes/rules/invalid_print_syntax.rs index e68a348b314d6..74acdca403167 100644 --- a/crates/ruff/src/rules/pyflakes/rules/invalid_print_syntax.rs +++ b/crates/ruff/src/rules/pyflakes/rules/invalid_print_syntax.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyflakes/rules/raise_not_implemented.rs b/crates/ruff/src/rules/pyflakes/rules/raise_not_implemented.rs index a51440439e2c9..6fad3fde6d869 100644 --- a/crates/ruff/src/rules/pyflakes/rules/raise_not_implemented.rs +++ b/crates/ruff/src/rules/pyflakes/rules/raise_not_implemented.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pyflakes/rules/repeated_keys.rs b/crates/ruff/src/rules/pyflakes/rules/repeated_keys.rs index 7fe38263ef348..68f93038bff72 100644 --- a/crates/ruff/src/rules/pyflakes/rules/repeated_keys.rs +++ b/crates/ruff/src/rules/pyflakes/rules/repeated_keys.rs @@ -1,11 +1,12 @@ use std::hash::BuildHasherDefault; -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use rustc_hash::{FxHashMap, FxHashSet}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::comparable::ComparableExpr; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::{AsRule, Rule}; diff --git a/crates/ruff/src/rules/pyflakes/rules/return_outside_function.rs b/crates/ruff/src/rules/pyflakes/rules/return_outside_function.rs index c6416d5e3d543..4398d5afad06d 100644 --- a/crates/ruff/src/rules/pyflakes/rules/return_outside_function.rs +++ b/crates/ruff/src/rules/pyflakes/rules/return_outside_function.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Ranged, Stmt}; +use ruff_python_ast::Stmt; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_semantic::ScopeKind; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyflakes/rules/strings.rs b/crates/ruff/src/rules/pyflakes/rules/strings.rs index 1fdfb10e47a3c..3d4de1a14808a 100644 --- a/crates/ruff/src/rules/pyflakes/rules/strings.rs +++ b/crates/ruff/src/rules/pyflakes/rules/strings.rs @@ -1,11 +1,11 @@ use std::string::ToString; -use ruff_python_ast::{self as ast, Constant, Expr, Identifier, Keyword, Ranged}; -use ruff_text_size::TextRange; use rustc_hash::FxHashSet; use ruff_diagnostics::{AlwaysAutofixableViolation, AutofixKind, Diagnostic, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_python_ast::{self as ast, Constant, Expr, Identifier, Keyword}; +use ruff_text_size::{Ranged, TextRange}; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pyflakes/rules/undefined_local.rs b/crates/ruff/src/rules/pyflakes/rules/undefined_local.rs index 7e2d9fb8827e0..c727464f8bda2 100644 --- a/crates/ruff/src/rules/pyflakes/rules/undefined_local.rs +++ b/crates/ruff/src/rules/pyflakes/rules/undefined_local.rs @@ -2,8 +2,8 @@ use std::string::ToString; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_semantic::{Scope, ScopeId}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyflakes/rules/unused_annotation.rs b/crates/ruff/src/rules/pyflakes/rules/unused_annotation.rs index 4b7e56c1bf3a4..b6e0bd9e9ad21 100644 --- a/crates/ruff/src/rules/pyflakes/rules/unused_annotation.rs +++ b/crates/ruff/src/rules/pyflakes/rules/unused_annotation.rs @@ -1,7 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_semantic::Scope; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyflakes/rules/unused_import.rs b/crates/ruff/src/rules/pyflakes/rules/unused_import.rs index 3c6c184289666..d9899a483f1cd 100644 --- a/crates/ruff/src/rules/pyflakes/rules/unused_import.rs +++ b/crates/ruff/src/rules/pyflakes/rules/unused_import.rs @@ -5,9 +5,8 @@ use rustc_hash::FxHashMap; use ruff_diagnostics::{AutofixKind, Diagnostic, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_semantic::{AnyImport, Exceptions, Imported, NodeId, Scope}; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::autofix; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyflakes/rules/unused_variable.rs b/crates/ruff/src/rules/pyflakes/rules/unused_variable.rs index a748f2c433e2d..4058c3e7480f5 100644 --- a/crates/ruff/src/rules/pyflakes/rules/unused_variable.rs +++ b/crates/ruff/src/rules/pyflakes/rules/unused_variable.rs @@ -3,11 +3,11 @@ use itertools::Itertools; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::contains_effect; -use ruff_python_ast::{self as ast, PySourceType, Ranged, Stmt}; +use ruff_python_ast::{self as ast, PySourceType, Stmt}; use ruff_python_parser::{lexer, AsMode, Tok}; use ruff_python_semantic::{Binding, Scope}; use ruff_source_file::Locator; -use ruff_text_size::{TextRange, TextSize}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::autofix::edits::delete_stmt; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyflakes/rules/yield_outside_function.rs b/crates/ruff/src/rules/pyflakes/rules/yield_outside_function.rs index c58400e5819ee..4fa5d3e8d0bd3 100644 --- a/crates/ruff/src/rules/pyflakes/rules/yield_outside_function.rs +++ b/crates/ruff/src/rules/pyflakes/rules/yield_outside_function.rs @@ -2,7 +2,8 @@ use std::fmt; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pygrep_hooks/rules/blanket_noqa.rs b/crates/ruff/src/rules/pygrep_hooks/rules/blanket_noqa.rs index 5f68fc9ec6576..068485ea8655c 100644 --- a/crates/ruff/src/rules/pygrep_hooks/rules/blanket_noqa.rs +++ b/crates/ruff/src/rules/pygrep_hooks/rules/blanket_noqa.rs @@ -1,9 +1,8 @@ -use ruff_python_ast::Ranged; - use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_index::Indexer; use ruff_source_file::Locator; +use ruff_text_size::Ranged; use crate::noqa::Directive; diff --git a/crates/ruff/src/rules/pygrep_hooks/rules/blanket_type_ignore.rs b/crates/ruff/src/rules/pygrep_hooks/rules/blanket_type_ignore.rs index 3f7cad84451b7..e618f3aecd67f 100644 --- a/crates/ruff/src/rules/pygrep_hooks/rules/blanket_type_ignore.rs +++ b/crates/ruff/src/rules/pygrep_hooks/rules/blanket_type_ignore.rs @@ -2,12 +2,12 @@ use anyhow::{anyhow, Result}; use memchr::memchr_iter; use once_cell::sync::Lazy; use regex::Regex; -use ruff_text_size::TextSize; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_index::Indexer; use ruff_source_file::Locator; +use ruff_text_size::TextSize; /// ## What it does /// Check for `type: ignore` annotations that suppress all type warnings, as diff --git a/crates/ruff/src/rules/pygrep_hooks/rules/deprecated_log_warn.rs b/crates/ruff/src/rules/pygrep_hooks/rules/deprecated_log_warn.rs index 934acc590aebf..c91566f365532 100644 --- a/crates/ruff/src/rules/pygrep_hooks/rules/deprecated_log_warn.rs +++ b/crates/ruff/src/rules/pygrep_hooks/rules/deprecated_log_warn.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pygrep_hooks/rules/invalid_mock_access.rs b/crates/ruff/src/rules/pygrep_hooks/rules/invalid_mock_access.rs index 0839fa943d44f..06b513485a3d0 100644 --- a/crates/ruff/src/rules/pygrep_hooks/rules/invalid_mock_access.rs +++ b/crates/ruff/src/rules/pygrep_hooks/rules/invalid_mock_access.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pygrep_hooks/rules/no_eval.rs b/crates/ruff/src/rules/pygrep_hooks/rules/no_eval.rs index 59fd8d2ccde7e..a9d49f7689fcc 100644 --- a/crates/ruff/src/rules/pygrep_hooks/rules/no_eval.rs +++ b/crates/ruff/src/rules/pygrep_hooks/rules/no_eval.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/assert_on_string_literal.rs b/crates/ruff/src/rules/pylint/rules/assert_on_string_literal.rs index b88987fbae885..8cf05d436be43 100644 --- a/crates/ruff/src/rules/pylint/rules/assert_on_string_literal.rs +++ b/crates/ruff/src/rules/pylint/rules/assert_on_string_literal.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/await_outside_async.rs b/crates/ruff/src/rules/pylint/rules/await_outside_async.rs index 4bf34f4a590c1..636ea35953b07 100644 --- a/crates/ruff/src/rules/pylint/rules/await_outside_async.rs +++ b/crates/ruff/src/rules/pylint/rules/await_outside_async.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/bad_str_strip_call.rs b/crates/ruff/src/rules/pylint/rules/bad_str_strip_call.rs index a1f768bd553f1..0b0ea74cdf3fa 100644 --- a/crates/ruff/src/rules/pylint/rules/bad_str_strip_call.rs +++ b/crates/ruff/src/rules/pylint/rules/bad_str_strip_call.rs @@ -1,10 +1,11 @@ use std::fmt; -use ruff_python_ast::{self as ast, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr}; use rustc_hash::FxHashSet; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::settings::types::PythonVersion; diff --git a/crates/ruff/src/rules/pylint/rules/bad_string_format_character.rs b/crates/ruff/src/rules/pylint/rules/bad_string_format_character.rs index cd8002bca0b43..31c8c9628c005 100644 --- a/crates/ruff/src/rules/pylint/rules/bad_string_format_character.rs +++ b/crates/ruff/src/rules/pylint/rules/bad_string_format_character.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::str::{leading_quote, trailing_quote}; -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_python_literal::{ cformat::{CFormatErrorType, CFormatString}, format::FormatPart, @@ -11,7 +11,7 @@ use ruff_python_literal::{ format::{FormatSpec, FormatSpecError, FormatString}, }; use ruff_python_parser::{lexer, Mode}; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/bad_string_format_type.rs b/crates/ruff/src/rules/pylint/rules/bad_string_format_type.rs index 7ae0e648fefa5..46de450182829 100644 --- a/crates/ruff/src/rules/pylint/rules/bad_string_format_type.rs +++ b/crates/ruff/src/rules/pylint/rules/bad_string_format_type.rs @@ -1,9 +1,9 @@ use std::str::FromStr; -use ruff_python_ast::{self as ast, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr}; use ruff_python_literal::cformat::{CFormatPart, CFormatSpec, CFormatStrOrBytes, CFormatString}; use ruff_python_parser::{lexer, AsMode}; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use rustc_hash::FxHashMap; use ruff_diagnostics::{Diagnostic, Violation}; diff --git a/crates/ruff/src/rules/pylint/rules/binary_op_exception.rs b/crates/ruff/src/rules/pylint/rules/binary_op_exception.rs index 4ec244fc93ceb..9870895c3fed9 100644 --- a/crates/ruff/src/rules/pylint/rules/binary_op_exception.rs +++ b/crates/ruff/src/rules/pylint/rules/binary_op_exception.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, ExceptHandler, Expr, Ranged}; +use ruff_python_ast::{self as ast, ExceptHandler, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/collapsible_else_if.rs b/crates/ruff/src/rules/pylint/rules/collapsible_else_if.rs index 28b9728defa62..3cee804326cef 100644 --- a/crates/ruff/src/rules/pylint/rules/collapsible_else_if.rs +++ b/crates/ruff/src/rules/pylint/rules/collapsible_else_if.rs @@ -1,5 +1,5 @@ -use ruff_python_ast::{ElifElseClause, Ranged, Stmt}; -use ruff_text_size::TextRange; +use ruff_python_ast::{ElifElseClause, Stmt}; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; diff --git a/crates/ruff/src/rules/pylint/rules/compare_to_empty_string.rs b/crates/ruff/src/rules/pylint/rules/compare_to_empty_string.rs index a6d34938fd68c..98d2f0a426d88 100644 --- a/crates/ruff/src/rules/pylint/rules/compare_to_empty_string.rs +++ b/crates/ruff/src/rules/pylint/rules/compare_to_empty_string.rs @@ -1,9 +1,10 @@ use anyhow::bail; use itertools::Itertools; -use ruff_python_ast::{self as ast, CmpOp, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, CmpOp, Constant, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/comparison_of_constant.rs b/crates/ruff/src/rules/pylint/rules/comparison_of_constant.rs index 10efc9839196b..1544a526f003d 100644 --- a/crates/ruff/src/rules/pylint/rules/comparison_of_constant.rs +++ b/crates/ruff/src/rules/pylint/rules/comparison_of_constant.rs @@ -1,8 +1,9 @@ use itertools::Itertools; -use ruff_python_ast::{self as ast, CmpOp, Expr, Ranged}; +use ruff_python_ast::{self as ast, CmpOp, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::pylint::helpers::CmpOpExt; diff --git a/crates/ruff/src/rules/pylint/rules/comparison_with_itself.rs b/crates/ruff/src/rules/pylint/rules/comparison_with_itself.rs index f6d94f67fa9c0..eeac46ef6d4a5 100644 --- a/crates/ruff/src/rules/pylint/rules/comparison_with_itself.rs +++ b/crates/ruff/src/rules/pylint/rules/comparison_with_itself.rs @@ -2,7 +2,8 @@ use itertools::Itertools; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{CmpOp, Expr, Ranged}; +use ruff_python_ast::{CmpOp, Expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::pylint::helpers::CmpOpExt; diff --git a/crates/ruff/src/rules/pylint/rules/continue_in_finally.rs b/crates/ruff/src/rules/pylint/rules/continue_in_finally.rs index 78e4ae85aaf74..e1b2ef94be44c 100644 --- a/crates/ruff/src/rules/pylint/rules/continue_in_finally.rs +++ b/crates/ruff/src/rules/pylint/rules/continue_in_finally.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/duplicate_bases.rs b/crates/ruff/src/rules/pylint/rules/duplicate_bases.rs index 8793244068917..85fdaa839022f 100644 --- a/crates/ruff/src/rules/pylint/rules/duplicate_bases.rs +++ b/crates/ruff/src/rules/pylint/rules/duplicate_bases.rs @@ -1,10 +1,11 @@ use std::hash::BuildHasherDefault; -use ruff_python_ast::{self as ast, Arguments, Expr, Ranged}; +use ruff_python_ast::{self as ast, Arguments, Expr}; use rustc_hash::FxHashSet; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/eq_without_hash.rs b/crates/ruff/src/rules/pylint/rules/eq_without_hash.rs index 134538534e22c..8add44f2c2f37 100644 --- a/crates/ruff/src/rules/pylint/rules/eq_without_hash.rs +++ b/crates/ruff/src/rules/pylint/rules/eq_without_hash.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_none; -use ruff_python_ast::{self as ast, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Expr, Stmt}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/import_self.rs b/crates/ruff/src/rules/pylint/rules/import_self.rs index bcd7f26c0a772..641aeea887118 100644 --- a/crates/ruff/src/rules/pylint/rules/import_self.rs +++ b/crates/ruff/src/rules/pylint/rules/import_self.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Alias, Ranged}; +use ruff_python_ast::Alias; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::resolve_imported_module_path; +use ruff_text_size::Ranged; /// ## What it does /// Checks for import statements that import the current module. diff --git a/crates/ruff/src/rules/pylint/rules/invalid_all_format.rs b/crates/ruff/src/rules/pylint/rules/invalid_all_format.rs index 8af36075dc4a6..cd258c35e94a0 100644 --- a/crates/ruff/src/rules/pylint/rules/invalid_all_format.rs +++ b/crates/ruff/src/rules/pylint/rules/invalid_all_format.rs @@ -1,7 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_semantic::Binding; +use ruff_text_size::Ranged; /// ## What it does /// Checks for invalid assignments to `__all__`. diff --git a/crates/ruff/src/rules/pylint/rules/invalid_all_object.rs b/crates/ruff/src/rules/pylint/rules/invalid_all_object.rs index 2a1fdffe434d2..ce3be45884125 100644 --- a/crates/ruff/src/rules/pylint/rules/invalid_all_object.rs +++ b/crates/ruff/src/rules/pylint/rules/invalid_all_object.rs @@ -1,7 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::Ranged; use ruff_python_semantic::Binding; +use ruff_text_size::Ranged; /// ## What it does /// Checks for the inclusion of invalid objects in `__all__`. diff --git a/crates/ruff/src/rules/pylint/rules/invalid_envvar_default.rs b/crates/ruff/src/rules/pylint/rules/invalid_envvar_default.rs index a6972b1d26be1..b5a22c153cb5c 100644 --- a/crates/ruff/src/rules/pylint/rules/invalid_envvar_default.rs +++ b/crates/ruff/src/rules/pylint/rules/invalid_envvar_default.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Constant, Expr, Operator, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr, Operator}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/invalid_envvar_value.rs b/crates/ruff/src/rules/pylint/rules/invalid_envvar_value.rs index 174a6a1359743..1aa03fff485a8 100644 --- a/crates/ruff/src/rules/pylint/rules/invalid_envvar_value.rs +++ b/crates/ruff/src/rules/pylint/rules/invalid_envvar_value.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Ranged}; +use ruff_python_ast::{self as ast}; use ruff_python_semantic::analyze::type_inference::{PythonType, ResolvedPythonType}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/invalid_str_return.rs b/crates/ruff/src/rules/pylint/rules/invalid_str_return.rs index 3dd341a8f5f28..60b79c01cdd93 100644 --- a/crates/ruff/src/rules/pylint/rules/invalid_str_return.rs +++ b/crates/ruff/src/rules/pylint/rules/invalid_str_return.rs @@ -1,9 +1,10 @@ -use ruff_python_ast::{Ranged, Stmt}; +use ruff_python_ast::Stmt; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::{helpers::ReturnStatementVisitor, statement_visitor::StatementVisitor}; use ruff_python_semantic::analyze::type_inference::{PythonType, ResolvedPythonType}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/iteration_over_set.rs b/crates/ruff/src/rules/pylint/rules/iteration_over_set.rs index 0c3ea8e17b5bc..4501737ef660a 100644 --- a/crates/ruff/src/rules/pylint/rules/iteration_over_set.rs +++ b/crates/ruff/src/rules/pylint/rules/iteration_over_set.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/load_before_global_declaration.rs b/crates/ruff/src/rules/pylint/rules/load_before_global_declaration.rs index f34d20d14254b..da980e90ec8c4 100644 --- a/crates/ruff/src/rules/pylint/rules/load_before_global_declaration.rs +++ b/crates/ruff/src/rules/pylint/rules/load_before_global_declaration.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_source_file::OneIndexed; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/logging.rs b/crates/ruff/src/rules/pylint/rules/logging.rs index 1c05df692f16f..ac1f47e68a19d 100644 --- a/crates/ruff/src/rules/pylint/rules/logging.rs +++ b/crates/ruff/src/rules/pylint/rules/logging.rs @@ -1,8 +1,9 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr}; use ruff_python_semantic::analyze::logging; use ruff_python_stdlib::logging::LoggingLevel; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/rules/pylint/rules/magic_value_comparison.rs b/crates/ruff/src/rules/pylint/rules/magic_value_comparison.rs index 3f96d789c2f11..256ad1c77efbb 100644 --- a/crates/ruff/src/rules/pylint/rules/magic_value_comparison.rs +++ b/crates/ruff/src/rules/pylint/rules/magic_value_comparison.rs @@ -1,8 +1,9 @@ use itertools::Itertools; -use ruff_python_ast::{self as ast, Constant, Expr, Ranged, UnaryOp}; +use ruff_python_ast::{self as ast, Constant, Expr, UnaryOp}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::pylint::settings::ConstantType; diff --git a/crates/ruff/src/rules/pylint/rules/manual_import_from.rs b/crates/ruff/src/rules/pylint/rules/manual_import_from.rs index 578377340ab97..b9b0180567060 100644 --- a/crates/ruff/src/rules/pylint/rules/manual_import_from.rs +++ b/crates/ruff/src/rules/pylint/rules/manual_import_from.rs @@ -1,5 +1,5 @@ -use ruff_python_ast::{self as ast, Alias, Identifier, Int, Ranged, Stmt}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, Alias, Identifier, Int, Stmt}; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; diff --git a/crates/ruff/src/rules/pylint/rules/nested_min_max.rs b/crates/ruff/src/rules/pylint/rules/nested_min_max.rs index b342a4edc46af..bca28e484e005 100644 --- a/crates/ruff/src/rules/pylint/rules/nested_min_max.rs +++ b/crates/ruff/src/rules/pylint/rules/nested_min_max.rs @@ -1,5 +1,5 @@ -use ruff_python_ast::{self as ast, Arguments, Expr, Keyword, Ranged}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, Arguments, Expr, Keyword}; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; diff --git a/crates/ruff/src/rules/pylint/rules/no_self_use.rs b/crates/ruff/src/rules/pylint/rules/no_self_use.rs index 3aa6e8d9e0cfd..10734618ef2dd 100644 --- a/crates/ruff/src/rules/pylint/rules/no_self_use.rs +++ b/crates/ruff/src/rules/pylint/rules/no_self_use.rs @@ -1,11 +1,12 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::{from_qualified_name, CallPath}; -use ruff_python_ast::{self as ast, ParameterWithDefault, Ranged}; +use ruff_python_ast::{self as ast, ParameterWithDefault}; use ruff_python_semantic::{ analyze::{function_type, visibility}, Scope, ScopeKind, }; +use ruff_text_size::Ranged; use crate::{checkers::ast::Checker, rules::flake8_unused_arguments::helpers}; diff --git a/crates/ruff/src/rules/pylint/rules/redefined_loop_name.rs b/crates/ruff/src/rules/pylint/rules/redefined_loop_name.rs index 23ec06ba31f28..92d6c7b6f336c 100644 --- a/crates/ruff/src/rules/pylint/rules/redefined_loop_name.rs +++ b/crates/ruff/src/rules/pylint/rules/redefined_loop_name.rs @@ -1,13 +1,14 @@ use std::{fmt, iter}; use regex::Regex; -use ruff_python_ast::{self as ast, Arguments, Expr, ExprContext, Ranged, Stmt, WithItem}; +use ruff_python_ast::{self as ast, Arguments, Expr, ExprContext, Stmt, WithItem}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::comparable::ComparableExpr; use ruff_python_ast::statement_visitor::{walk_stmt, StatementVisitor}; use ruff_python_semantic::SemanticModel; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/repeated_equality_comparison_target.rs b/crates/ruff/src/rules/pylint/rules/repeated_equality_comparison_target.rs index a426c8e1ca7ba..7198f79e73bdf 100644 --- a/crates/ruff/src/rules/pylint/rules/repeated_equality_comparison_target.rs +++ b/crates/ruff/src/rules/pylint/rules/repeated_equality_comparison_target.rs @@ -8,8 +8,9 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::comparable::ComparableExpr; use ruff_python_ast::hashable::HashableExpr; -use ruff_python_ast::{self as ast, BoolOp, CmpOp, Expr, Ranged}; +use ruff_python_ast::{self as ast, BoolOp, CmpOp, Expr}; use ruff_source_file::Locator; +use ruff_text_size::Ranged; use crate::autofix::snippet::SourceCodeSnippet; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/repeated_isinstance_calls.rs b/crates/ruff/src/rules/pylint/rules/repeated_isinstance_calls.rs index 22e59a43d266f..662b2c0cea9d8 100644 --- a/crates/ruff/src/rules/pylint/rules/repeated_isinstance_calls.rs +++ b/crates/ruff/src/rules/pylint/rules/repeated_isinstance_calls.rs @@ -1,10 +1,11 @@ use itertools::Itertools; -use ruff_python_ast::{self as ast, Arguments, BoolOp, Expr, Ranged}; +use ruff_python_ast::{self as ast, Arguments, BoolOp, Expr}; use rustc_hash::{FxHashMap, FxHashSet}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::hashable::HashableExpr; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pylint/rules/return_in_init.rs b/crates/ruff/src/rules/pylint/rules/return_in_init.rs index 0a4dadc530467..7e18303678f7a 100644 --- a/crates/ruff/src/rules/pylint/rules/return_in_init.rs +++ b/crates/ruff/src/rules/pylint/rules/return_in_init.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_none; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::pylint::helpers::in_dunder_init; diff --git a/crates/ruff/src/rules/pylint/rules/self_assigning_variable.rs b/crates/ruff/src/rules/pylint/rules/self_assigning_variable.rs index 4176626a339dc..a30b6294acc43 100644 --- a/crates/ruff/src/rules/pylint/rules/self_assigning_variable.rs +++ b/crates/ruff/src/rules/pylint/rules/self_assigning_variable.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/subprocess_popen_preexec_fn.rs b/crates/ruff/src/rules/pylint/rules/subprocess_popen_preexec_fn.rs index 4094991b5adf6..a5cf3ad75d390 100644 --- a/crates/ruff/src/rules/pylint/rules/subprocess_popen_preexec_fn.rs +++ b/crates/ruff/src/rules/pylint/rules/subprocess_popen_preexec_fn.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_none; -use ruff_python_ast::{self as ast, Ranged}; +use ruff_python_ast::{self as ast}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/subprocess_run_without_check.rs b/crates/ruff/src/rules/pylint/rules/subprocess_run_without_check.rs index f147e8446c270..4758de8d017b9 100644 --- a/crates/ruff/src/rules/pylint/rules/subprocess_run_without_check.rs +++ b/crates/ruff/src/rules/pylint/rules/subprocess_run_without_check.rs @@ -1,7 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast as ast; -use ruff_python_ast::Ranged; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/sys_exit_alias.rs b/crates/ruff/src/rules/pylint/rules/sys_exit_alias.rs index 32de0d6b19398..3fe8cacf5036d 100644 --- a/crates/ruff/src/rules/pylint/rules/sys_exit_alias.rs +++ b/crates/ruff/src/rules/pylint/rules/sys_exit_alias.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::importer::ImportRequest; diff --git a/crates/ruff/src/rules/pylint/rules/type_bivariance.rs b/crates/ruff/src/rules/pylint/rules/type_bivariance.rs index fdeefdad7992f..ffe53bc5e7f5c 100644 --- a/crates/ruff/src/rules/pylint/rules/type_bivariance.rs +++ b/crates/ruff/src/rules/pylint/rules/type_bivariance.rs @@ -3,7 +3,8 @@ use std::fmt; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_true; -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::pylint::helpers::type_param_name; diff --git a/crates/ruff/src/rules/pylint/rules/type_name_incorrect_variance.rs b/crates/ruff/src/rules/pylint/rules/type_name_incorrect_variance.rs index c4ddf8976333b..ff5d9feaf2861 100644 --- a/crates/ruff/src/rules/pylint/rules/type_name_incorrect_variance.rs +++ b/crates/ruff/src/rules/pylint/rules/type_name_incorrect_variance.rs @@ -3,7 +3,8 @@ use std::fmt; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_true; -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::pylint::helpers::type_param_name; diff --git a/crates/ruff/src/rules/pylint/rules/type_param_name_mismatch.rs b/crates/ruff/src/rules/pylint/rules/type_param_name_mismatch.rs index 31db9780d7ea4..a3afd61505e34 100644 --- a/crates/ruff/src/rules/pylint/rules/type_param_name_mismatch.rs +++ b/crates/ruff/src/rules/pylint/rules/type_param_name_mismatch.rs @@ -2,7 +2,8 @@ use std::fmt; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::pylint::helpers::type_param_name; diff --git a/crates/ruff/src/rules/pylint/rules/unnecessary_direct_lambda_call.rs b/crates/ruff/src/rules/pylint/rules/unnecessary_direct_lambda_call.rs index 197b6dc8002fd..510f8292effcd 100644 --- a/crates/ruff/src/rules/pylint/rules/unnecessary_direct_lambda_call.rs +++ b/crates/ruff/src/rules/pylint/rules/unnecessary_direct_lambda_call.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/useless_import_alias.rs b/crates/ruff/src/rules/pylint/rules/useless_import_alias.rs index c62b3a17f64ef..fabdc4e91cc4e 100644 --- a/crates/ruff/src/rules/pylint/rules/useless_import_alias.rs +++ b/crates/ruff/src/rules/pylint/rules/useless_import_alias.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Alias, Ranged}; +use ruff_python_ast::Alias; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pylint/rules/useless_return.rs b/crates/ruff/src/rules/pylint/rules/useless_return.rs index eaa8be21c65d8..6df823f386ee8 100644 --- a/crates/ruff/src/rules/pylint/rules/useless_return.rs +++ b/crates/ruff/src/rules/pylint/rules/useless_return.rs @@ -1,9 +1,10 @@ -use ruff_python_ast::{self as ast, Constant, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Constant, Expr, Stmt}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::{is_const_none, ReturnStatementVisitor}; use ruff_python_ast::statement_visitor::StatementVisitor; +use ruff_text_size::Ranged; use crate::autofix; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/yield_from_in_async_function.rs b/crates/ruff/src/rules/pylint/rules/yield_from_in_async_function.rs index a94f388a03691..9567dfc7fc072 100644 --- a/crates/ruff/src/rules/pylint/rules/yield_from_in_async_function.rs +++ b/crates/ruff/src/rules/pylint/rules/yield_from_in_async_function.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Ranged}; +use ruff_python_ast::{self as ast}; use ruff_python_semantic::ScopeKind; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pylint/rules/yield_in_init.rs b/crates/ruff/src/rules/pylint/rules/yield_in_init.rs index 9d3aa3987dcac..fb7febaf2de3e 100644 --- a/crates/ruff/src/rules/pylint/rules/yield_in_init.rs +++ b/crates/ruff/src/rules/pylint/rules/yield_in_init.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::pylint::helpers::in_dunder_init; diff --git a/crates/ruff/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs b/crates/ruff/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs index 927716050f0ea..08619c6de219e 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs @@ -1,9 +1,9 @@ use anyhow::{bail, Result}; use log::debug; use ruff_python_ast::{ - self as ast, Arguments, Constant, Expr, ExprContext, Identifier, Keyword, Ranged, Stmt, + self as ast, Arguments, Constant, Expr, ExprContext, Identifier, Keyword, Stmt, }; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; diff --git a/crates/ruff/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs b/crates/ruff/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs index 6312bcaa86d86..b0b4602fb3809 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs @@ -5,12 +5,12 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_dunder; use ruff_python_ast::{ - self as ast, Arguments, Constant, Expr, ExprContext, Identifier, Keyword, Ranged, Stmt, + self as ast, Arguments, Constant, Expr, ExprContext, Identifier, Keyword, Stmt, }; use ruff_python_codegen::Generator; use ruff_python_semantic::SemanticModel; use ruff_python_stdlib::identifiers::is_identifier; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pyupgrade/rules/datetime_utc_alias.rs b/crates/ruff/src/rules/pyupgrade/rules/datetime_utc_alias.rs index 1f6e195ea7113..7c8314083f8b1 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/datetime_utc_alias.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/datetime_utc_alias.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::importer::ImportRequest; diff --git a/crates/ruff/src/rules/pyupgrade/rules/deprecated_c_element_tree.rs b/crates/ruff/src/rules/pyupgrade/rules/deprecated_c_element_tree.rs index 6d41e1aeb0c38..8d6a566250366 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/deprecated_c_element_tree.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/deprecated_c_element_tree.rs @@ -1,7 +1,7 @@ -use ruff_python_ast::{self as ast, Ranged, Stmt}; - use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_python_ast::{self as ast, Stmt}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pyupgrade/rules/deprecated_import.rs b/crates/ruff/src/rules/pyupgrade/rules/deprecated_import.rs index 6ec2ad0148b56..b4898f8a07069 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/deprecated_import.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/deprecated_import.rs @@ -1,11 +1,12 @@ use itertools::Itertools; -use ruff_python_ast::{Alias, Ranged, Stmt}; +use ruff_python_ast::{Alias, Stmt}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::whitespace::indentation; use ruff_python_codegen::Stylist; use ruff_source_file::Locator; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/rules/pyupgrade/rules/deprecated_mock_import.rs b/crates/ruff/src/rules/pyupgrade/rules/deprecated_mock_import.rs index 08b1efffc93a8..85fe6c73e89aa 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/deprecated_mock_import.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/deprecated_mock_import.rs @@ -4,7 +4,7 @@ use libcst_native::{ ImportNames, Name, NameOrAttribute, ParenthesizableWhitespace, }; use log::error; -use ruff_python_ast::{self as ast, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Expr, Stmt}; use crate::autofix::codemods::CodegenStylist; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; @@ -13,6 +13,7 @@ use ruff_python_ast::call_path::collect_call_path; use ruff_python_ast::whitespace::indentation; use ruff_python_codegen::Stylist; use ruff_source_file::Locator; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::cst::matchers::{match_import, match_import_from, match_statement}; diff --git a/crates/ruff/src/rules/pyupgrade/rules/deprecated_unittest_alias.rs b/crates/ruff/src/rules/pyupgrade/rules/deprecated_unittest_alias.rs index a939672f303b9..3f64f64395b5b 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/deprecated_unittest_alias.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/deprecated_unittest_alias.rs @@ -1,9 +1,10 @@ use once_cell::sync::Lazy; -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use rustc_hash::FxHashMap; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pyupgrade/rules/extraneous_parentheses.rs b/crates/ruff/src/rules/pyupgrade/rules/extraneous_parentheses.rs index 0ff81975207a3..824b7634618b3 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/extraneous_parentheses.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/extraneous_parentheses.rs @@ -1,6 +1,6 @@ use ruff_python_parser::lexer::LexResult; use ruff_python_parser::Tok; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; diff --git a/crates/ruff/src/rules/pyupgrade/rules/f_strings.rs b/crates/ruff/src/rules/pyupgrade/rules/f_strings.rs index b086532130e45..4e04aca02d9d5 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/f_strings.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/f_strings.rs @@ -6,13 +6,13 @@ use rustc_hash::FxHashMap; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::str::{leading_quote, trailing_quote}; -use ruff_python_ast::{self as ast, Constant, Expr, Keyword, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr, Keyword}; use ruff_python_literal::format::{ FieldName, FieldNamePart, FieldType, FormatPart, FormatString, FromTemplate, }; use ruff_python_parser::{lexer, Mode, Tok}; use ruff_source_file::Locator; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::checkers::ast::Checker; use crate::line_width::LineLength; diff --git a/crates/ruff/src/rules/pyupgrade/rules/format_literals.rs b/crates/ruff/src/rules/pyupgrade/rules/format_literals.rs index 00e5acb4af7c5..0f1764d58042a 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/format_literals.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/format_literals.rs @@ -5,9 +5,10 @@ use regex::Regex; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_python_codegen::Stylist; use ruff_source_file::Locator; +use ruff_text_size::Ranged; use crate::autofix::codemods::CodegenStylist; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyupgrade/rules/lru_cache_with_maxsize_none.rs b/crates/ruff/src/rules/pyupgrade/rules/lru_cache_with_maxsize_none.rs index 1f50c974474d2..accf01c3fc463 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/lru_cache_with_maxsize_none.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/lru_cache_with_maxsize_none.rs @@ -1,5 +1,5 @@ -use ruff_python_ast::{self as ast, Arguments, Decorator, Expr, Keyword, Ranged}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, Arguments, Decorator, Expr, Keyword}; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; diff --git a/crates/ruff/src/rules/pyupgrade/rules/lru_cache_without_parameters.rs b/crates/ruff/src/rules/pyupgrade/rules/lru_cache_without_parameters.rs index 09ba48c0ba27d..7553ca937a0e3 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/lru_cache_without_parameters.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/lru_cache_without_parameters.rs @@ -1,7 +1,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Decorator, Expr, Ranged}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, Decorator, Expr}; +use ruff_text_size::{Ranged, TextRange}; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pyupgrade/rules/native_literals.rs b/crates/ruff/src/rules/pyupgrade/rules/native_literals.rs index a106efcaa9a87..7e067aada1304 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/native_literals.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/native_literals.rs @@ -5,7 +5,8 @@ use num_bigint::BigInt; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pyupgrade/rules/open_alias.rs b/crates/ruff/src/rules/pyupgrade/rules/open_alias.rs index 85fe77c588c6d..7b93725354b7c 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/open_alias.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/open_alias.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pyupgrade/rules/os_error_alias.rs b/crates/ruff/src/rules/pyupgrade/rules/os_error_alias.rs index 9ec667999d5b9..1e4e659c925cd 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/os_error_alias.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/os_error_alias.rs @@ -1,5 +1,5 @@ -use ruff_python_ast::{self as ast, ExceptHandler, Expr, ExprContext, Ranged}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, ExceptHandler, Expr, ExprContext}; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; diff --git a/crates/ruff/src/rules/pyupgrade/rules/outdated_version_block.rs b/crates/ruff/src/rules/pyupgrade/rules/outdated_version_block.rs index d8c5fdcb8203f..fe32ef24da493 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/outdated_version_block.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/outdated_version_block.rs @@ -1,13 +1,13 @@ use std::cmp::Ordering; use num_bigint::{BigInt, Sign}; -use ruff_python_ast::{self as ast, CmpOp, Constant, ElifElseClause, Expr, Ranged, StmtIf}; -use ruff_text_size::{TextLen, TextRange}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::stmt_if::{if_elif_branches, BranchKind, IfElifBranch}; use ruff_python_ast::whitespace::indentation; +use ruff_python_ast::{self as ast, CmpOp, Constant, ElifElseClause, Expr, StmtIf}; +use ruff_text_size::{Ranged, TextLen, TextRange}; use crate::autofix::edits::delete_stmt; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyupgrade/rules/printf_string_formatting.rs b/crates/ruff/src/rules/pyupgrade/rules/printf_string_formatting.rs index 68032f5b9ff7f..893db2cbbf498 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/printf_string_formatting.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/printf_string_formatting.rs @@ -1,11 +1,11 @@ use std::str::FromStr; -use ruff_python_ast::{self as ast, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr}; use ruff_python_literal::cformat::{ CConversionFlags, CFormatPart, CFormatPrecision, CFormatQuantity, CFormatString, }; use ruff_python_parser::{lexer, AsMode, Tok}; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; diff --git a/crates/ruff/src/rules/pyupgrade/rules/redundant_open_modes.rs b/crates/ruff/src/rules/pyupgrade/rules/redundant_open_modes.rs index 0a99e7a3f72a8..5716156cff1f1 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/redundant_open_modes.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/redundant_open_modes.rs @@ -4,11 +4,11 @@ use anyhow::{anyhow, Result}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Constant, Expr, PySourceType, Ranged}; +use ruff_python_ast::{self as ast, Constant, Expr, PySourceType}; use ruff_python_parser::{lexer, AsMode}; use ruff_python_semantic::SemanticModel; use ruff_source_file::Locator; -use ruff_text_size::TextSize; +use ruff_text_size::{Ranged, TextSize}; use crate::checkers::ast::Checker; use crate::registry::Rule; diff --git a/crates/ruff/src/rules/pyupgrade/rules/replace_stdout_stderr.rs b/crates/ruff/src/rules/pyupgrade/rules/replace_stdout_stderr.rs index df120210f4c3e..86094b21fb720 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/replace_stdout_stderr.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/replace_stdout_stderr.rs @@ -2,7 +2,8 @@ use anyhow::Result; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Keyword, Ranged}; +use ruff_python_ast::{self as ast, Keyword}; +use ruff_text_size::Ranged; use crate::autofix::edits::{remove_argument, Parentheses}; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyupgrade/rules/replace_universal_newlines.rs b/crates/ruff/src/rules/pyupgrade/rules/replace_universal_newlines.rs index b8938400a319f..46b8f96e88e48 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/replace_universal_newlines.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/replace_universal_newlines.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Ranged}; +use ruff_python_ast::{self as ast}; +use ruff_text_size::Ranged; use ruff_text_size::{TextLen, TextRange}; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyupgrade/rules/super_call_with_parameters.rs b/crates/ruff/src/rules/pyupgrade/rules/super_call_with_parameters.rs index 8b247f26747ff..b118baa3859ed 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/super_call_with_parameters.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/super_call_with_parameters.rs @@ -1,7 +1,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Expr, Parameter, ParameterWithDefault, Ranged, Stmt}; -use ruff_text_size::TextSize; +use ruff_python_ast::{self as ast, Expr, Parameter, ParameterWithDefault, Stmt}; +use ruff_text_size::{Ranged, TextSize}; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pyupgrade/rules/type_of_primitive.rs b/crates/ruff/src/rules/pyupgrade/rules/type_of_primitive.rs index c4baff5ef3357..e7c51a391afa3 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/type_of_primitive.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/type_of_primitive.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pyupgrade/rules/typing_text_str_alias.rs b/crates/ruff/src/rules/pyupgrade/rules/typing_text_str_alias.rs index 1abac409ad1d6..fe749515c776b 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/typing_text_str_alias.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/typing_text_str_alias.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pyupgrade/rules/unicode_kind_prefix.rs b/crates/ruff/src/rules/pyupgrade/rules/unicode_kind_prefix.rs index fe61b19b1c43e..8947927764e2e 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/unicode_kind_prefix.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/unicode_kind_prefix.rs @@ -1,8 +1,7 @@ -use ruff_python_ast::{Expr, Ranged}; -use ruff_text_size::{TextRange, TextSize}; - use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_python_ast::Expr; +use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pyupgrade/rules/unnecessary_builtin_import.rs b/crates/ruff/src/rules/pyupgrade/rules/unnecessary_builtin_import.rs index 919a26bff6097..6a1f0553d18d1 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/unnecessary_builtin_import.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/unnecessary_builtin_import.rs @@ -1,8 +1,9 @@ use itertools::Itertools; -use ruff_python_ast::{Alias, Ranged, Stmt}; +use ruff_python_ast::{Alias, Stmt}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::autofix; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyupgrade/rules/unnecessary_class_parentheses.rs b/crates/ruff/src/rules/pyupgrade/rules/unnecessary_class_parentheses.rs index b45b3a5e3f5a3..989cdb67304cf 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/unnecessary_class_parentheses.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/unnecessary_class_parentheses.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Ranged}; +use ruff_python_ast::{self as ast}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pyupgrade/rules/unnecessary_coding_comment.rs b/crates/ruff/src/rules/pyupgrade/rules/unnecessary_coding_comment.rs index 72e55a6b11ab6..f8c0ee8f63792 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/unnecessary_coding_comment.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/unnecessary_coding_comment.rs @@ -5,7 +5,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_index::Indexer; use ruff_source_file::Locator; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::registry::AsRule; use crate::settings::Settings; diff --git a/crates/ruff/src/rules/pyupgrade/rules/unnecessary_encode_utf8.rs b/crates/ruff/src/rules/pyupgrade/rules/unnecessary_encode_utf8.rs index 0c48fdcc55570..57d997fd6b585 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/unnecessary_encode_utf8.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/unnecessary_encode_utf8.rs @@ -1,9 +1,9 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Arguments, Constant, Expr, Keyword, PySourceType, Ranged}; +use ruff_python_ast::{self as ast, Arguments, Constant, Expr, Keyword, PySourceType}; use ruff_python_parser::{lexer, AsMode, Tok}; use ruff_source_file::Locator; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::autofix::edits::{remove_argument, Parentheses}; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyupgrade/rules/unnecessary_future_import.rs b/crates/ruff/src/rules/pyupgrade/rules/unnecessary_future_import.rs index 402de0a9a3653..4a7a432ce1579 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/unnecessary_future_import.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/unnecessary_future_import.rs @@ -1,8 +1,9 @@ use itertools::Itertools; -use ruff_python_ast::{Alias, Ranged, Stmt}; +use ruff_python_ast::{Alias, Stmt}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::autofix; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyupgrade/rules/unpacked_list_comprehension.rs b/crates/ruff/src/rules/pyupgrade/rules/unpacked_list_comprehension.rs index 147f73c9b2201..3765e55b66d96 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/unpacked_list_comprehension.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/unpacked_list_comprehension.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::any_over_expr; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pyupgrade/rules/use_pep585_annotation.rs b/crates/ruff/src/rules/pyupgrade/rules/use_pep585_annotation.rs index 30f04f90c84a3..aaeef4bba0ffb 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/use_pep585_annotation.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/use_pep585_annotation.rs @@ -1,9 +1,10 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::compose_call_path; use ruff_python_semantic::analyze::typing::ModuleMember; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::importer::ImportRequest; diff --git a/crates/ruff/src/rules/pyupgrade/rules/use_pep604_annotation.rs b/crates/ruff/src/rules/pyupgrade/rules/use_pep604_annotation.rs index 482eaad976256..2b492d7138808 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/use_pep604_annotation.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/use_pep604_annotation.rs @@ -1,11 +1,12 @@ use itertools::Either::{Left, Right}; use itertools::Itertools; -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_semantic::analyze::typing::Pep604Operator; use ruff_source_file::Locator; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pyupgrade/rules/use_pep604_isinstance.rs b/crates/ruff/src/rules/pyupgrade/rules/use_pep604_isinstance.rs index 4fcfdb6d5e7bf..3da0483432a2b 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/use_pep604_isinstance.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/use_pep604_isinstance.rs @@ -1,10 +1,9 @@ use std::fmt; -use ruff_python_ast::{self as ast, Expr, Operator, Ranged}; -use ruff_text_size::TextRange; - use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_python_ast::{self as ast, Expr, Operator}; +use ruff_text_size::{Ranged, TextRange}; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/pyupgrade/rules/use_pep695_type_alias.rs b/crates/ruff/src/rules/pyupgrade/rules/use_pep695_type_alias.rs index 4c51960ec9325..3adb84f7f38ac 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/use_pep695_type_alias.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/use_pep695_type_alias.rs @@ -2,15 +2,15 @@ use ast::{Constant, ExprCall, ExprConstant}; use ruff_python_ast::{ self as ast, visitor::{self, Visitor}, - Expr, ExprName, ExprSubscript, Identifier, Ranged, Stmt, StmtAnnAssign, StmtAssign, - StmtTypeAlias, TypeParam, TypeParamTypeVar, + Expr, ExprName, ExprSubscript, Identifier, Stmt, StmtAnnAssign, StmtAssign, StmtTypeAlias, + TypeParam, TypeParamTypeVar, }; use ruff_python_semantic::SemanticModel; use crate::{registry::AsRule, settings::types::PythonVersion}; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyupgrade/rules/useless_metaclass_type.rs b/crates/ruff/src/rules/pyupgrade/rules/useless_metaclass_type.rs index df5795f5d967e..f089ae91ab4df 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/useless_metaclass_type.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/useless_metaclass_type.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Expr, Stmt}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::autofix; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyupgrade/rules/useless_object_inheritance.rs b/crates/ruff/src/rules/pyupgrade/rules/useless_object_inheritance.rs index 2e2de98529305..a3a6093deed08 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/useless_object_inheritance.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/useless_object_inheritance.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; +use ruff_text_size::Ranged; use crate::autofix::edits::{remove_argument, Parentheses}; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/pyupgrade/rules/yield_in_for_loop.rs b/crates/ruff/src/rules/pyupgrade/rules/yield_in_for_loop.rs index 0662a0c0404fa..20830480d274c 100644 --- a/crates/ruff/src/rules/pyupgrade/rules/yield_in_for_loop.rs +++ b/crates/ruff/src/rules/pyupgrade/rules/yield_in_for_loop.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Expr, Stmt}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff/src/rules/ruff/rules/ambiguous_unicode_character.rs b/crates/ruff/src/rules/ruff/rules/ambiguous_unicode_character.rs index 72487210702b1..0a95e4359c2bf 100644 --- a/crates/ruff/src/rules/ruff/rules/ambiguous_unicode_character.rs +++ b/crates/ruff/src/rules/ruff/rules/ambiguous_unicode_character.rs @@ -1,10 +1,11 @@ -use bitflags::bitflags; -use ruff_text_size::{TextLen, TextRange, TextSize}; use std::fmt; +use bitflags::bitflags; + use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, DiagnosticKind, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_source_file::Locator; +use ruff_text_size::{TextLen, TextRange, TextSize}; use crate::registry::AsRule; use crate::rules::ruff::rules::confusables::confusable; diff --git a/crates/ruff/src/rules/ruff/rules/asyncio_dangling_task.rs b/crates/ruff/src/rules/ruff/rules/asyncio_dangling_task.rs index 806b0e71fe852..e69377476801f 100644 --- a/crates/ruff/src/rules/ruff/rules/asyncio_dangling_task.rs +++ b/crates/ruff/src/rules/ruff/rules/asyncio_dangling_task.rs @@ -1,9 +1,10 @@ use std::fmt; -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/ruff/rules/collection_literal_concatenation.rs b/crates/ruff/src/rules/ruff/rules/collection_literal_concatenation.rs index 604b81a88c2d0..012fab42a3659 100644 --- a/crates/ruff/src/rules/ruff/rules/collection_literal_concatenation.rs +++ b/crates/ruff/src/rules/ruff/rules/collection_literal_concatenation.rs @@ -1,7 +1,7 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Expr, ExprContext, Operator, Ranged}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, Expr, ExprContext, Operator}; +use ruff_text_size::{Ranged, TextRange}; use crate::autofix::snippet::SourceCodeSnippet; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/ruff/rules/explicit_f_string_type_conversion.rs b/crates/ruff/src/rules/ruff/rules/explicit_f_string_type_conversion.rs index f8957b82b244f..00b658ccc2351 100644 --- a/crates/ruff/src/rules/ruff/rules/explicit_f_string_type_conversion.rs +++ b/crates/ruff/src/rules/ruff/rules/explicit_f_string_type_conversion.rs @@ -5,9 +5,10 @@ use libcst_native::{ use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Arguments, Expr, Ranged}; +use ruff_python_ast::{self as ast, Arguments, Expr}; use ruff_python_codegen::Stylist; use ruff_source_file::Locator; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::cst::matchers::{match_call_mut, match_name, transform_expression}; diff --git a/crates/ruff/src/rules/ruff/rules/function_call_in_dataclass_default.rs b/crates/ruff/src/rules/ruff/rules/function_call_in_dataclass_default.rs index 262f2db8f8cba..f8d5af0672698 100644 --- a/crates/ruff/src/rules/ruff/rules/function_call_in_dataclass_default.rs +++ b/crates/ruff/src/rules/ruff/rules/function_call_in_dataclass_default.rs @@ -1,10 +1,11 @@ -use ruff_python_ast::{self as ast, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Expr, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::call_path::compose_call_path; use ruff_python_ast::call_path::{from_qualified_name, CallPath}; use ruff_python_semantic::analyze::typing::is_immutable_func; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::ruff::rules::helpers::{ diff --git a/crates/ruff/src/rules/ruff/rules/implicit_optional.rs b/crates/ruff/src/rules/ruff/rules/implicit_optional.rs index fbda0f5ede2ae..1674a028a8291 100644 --- a/crates/ruff/src/rules/ruff/rules/implicit_optional.rs +++ b/crates/ruff/src/rules/ruff/rules/implicit_optional.rs @@ -1,15 +1,13 @@ use std::fmt; use anyhow::Result; -use ruff_python_ast::{ - self as ast, Constant, Expr, Operator, ParameterWithDefault, Parameters, Ranged, -}; -use ruff_text_size::TextRange; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_const_none; +use ruff_python_ast::{self as ast, Constant, Expr, Operator, ParameterWithDefault, Parameters}; use ruff_python_parser::typing::parse_type_annotation; +use ruff_text_size::{Ranged, TextRange}; use crate::checkers::ast::Checker; use crate::importer::ImportRequest; diff --git a/crates/ruff/src/rules/ruff/rules/invalid_index_type.rs b/crates/ruff/src/rules/ruff/rules/invalid_index_type.rs index 74be4ac75bec7..3db7162124c05 100644 --- a/crates/ruff/src/rules/ruff/rules/invalid_index_type.rs +++ b/crates/ruff/src/rules/ruff/rules/invalid_index_type.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{Constant, Expr, ExprConstant, ExprSlice, ExprSubscript, Ranged}; +use ruff_python_ast::{Constant, Expr, ExprConstant, ExprSlice, ExprSubscript}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use std::fmt; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/ruff/rules/mutable_class_default.rs b/crates/ruff/src/rules/ruff/rules/mutable_class_default.rs index d411a6fadb49b..85ac38c5fd208 100644 --- a/crates/ruff/src/rules/ruff/rules/mutable_class_default.rs +++ b/crates/ruff/src/rules/ruff/rules/mutable_class_default.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_semantic::analyze::typing::{is_immutable_annotation, is_mutable_expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::ruff::rules::helpers::{ diff --git a/crates/ruff/src/rules/ruff/rules/mutable_dataclass_default.rs b/crates/ruff/src/rules/ruff/rules/mutable_dataclass_default.rs index e916d6de18fde..f12d8cf87a128 100644 --- a/crates/ruff/src/rules/ruff/rules/mutable_dataclass_default.rs +++ b/crates/ruff/src/rules/ruff/rules/mutable_dataclass_default.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_semantic::analyze::typing::{is_immutable_annotation, is_mutable_expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::ruff::rules::helpers::{is_class_var_annotation, is_dataclass}; diff --git a/crates/ruff/src/rules/ruff/rules/pairwise_over_zipped.rs b/crates/ruff/src/rules/ruff/rules/pairwise_over_zipped.rs index a4a16e32b426c..cd366d64fad3f 100644 --- a/crates/ruff/src/rules/ruff/rules/pairwise_over_zipped.rs +++ b/crates/ruff/src/rules/ruff/rules/pairwise_over_zipped.rs @@ -1,8 +1,9 @@ use num_traits::ToPrimitive; -use ruff_python_ast::{self as ast, Constant, Expr, Ranged, UnaryOp}; +use ruff_python_ast::{self as ast, Constant, Expr, UnaryOp}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/ruff/rules/quadratic_list_summation.rs b/crates/ruff/src/rules/ruff/rules/quadratic_list_summation.rs index 427f1d052c6cd..70ae7bbc7fcef 100644 --- a/crates/ruff/src/rules/ruff/rules/quadratic_list_summation.rs +++ b/crates/ruff/src/rules/ruff/rules/quadratic_list_summation.rs @@ -2,8 +2,9 @@ use anyhow::Result; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Arguments, Expr, Ranged}; +use ruff_python_ast::{self as ast, Arguments, Expr}; use ruff_python_semantic::SemanticModel; +use ruff_text_size::Ranged; use crate::importer::ImportRequest; use crate::{checkers::ast::Checker, registry::Rule}; diff --git a/crates/ruff/src/rules/ruff/rules/static_key_dict_comprehension.rs b/crates/ruff/src/rules/ruff/rules/static_key_dict_comprehension.rs index 061e54bd4f92e..fd7487e8abbac 100644 --- a/crates/ruff/src/rules/ruff/rules/static_key_dict_comprehension.rs +++ b/crates/ruff/src/rules/ruff/rules/static_key_dict_comprehension.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{Expr, Ranged}; +use ruff_python_ast::Expr; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::is_constant; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/ruff/rules/unnecessary_iterable_allocation_for_first_element.rs b/crates/ruff/src/rules/ruff/rules/unnecessary_iterable_allocation_for_first_element.rs index fcb3caa2c5e0e..fe574e09a633d 100644 --- a/crates/ruff/src/rules/ruff/rules/unnecessary_iterable_allocation_for_first_element.rs +++ b/crates/ruff/src/rules/ruff/rules/unnecessary_iterable_allocation_for_first_element.rs @@ -4,9 +4,9 @@ use num_traits::Zero; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Arguments, Comprehension, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, Arguments, Comprehension, Constant, Expr}; use ruff_python_semantic::SemanticModel; -use ruff_text_size::{TextRange, TextSize}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::autofix::snippet::SourceCodeSnippet; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/ruff/rules/unreachable.rs b/crates/ruff/src/rules/ruff/rules/unreachable.rs index 180bd84e6c29d..e52fe4889bf27 100644 --- a/crates/ruff/src/rules/ruff/rules/unreachable.rs +++ b/crates/ruff/src/rules/ruff/rules/unreachable.rs @@ -2,10 +2,10 @@ use std::{fmt, iter, usize}; use log::error; use ruff_python_ast::{ - Expr, Identifier, MatchCase, Pattern, PatternMatchAs, Ranged, Stmt, StmtFor, StmtMatch, - StmtReturn, StmtTry, StmtWhile, StmtWith, + Expr, Identifier, MatchCase, Pattern, PatternMatchAs, Stmt, StmtFor, StmtMatch, StmtReturn, + StmtTry, StmtWhile, StmtWith, }; -use ruff_text_size::{TextRange, TextSize}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_index::{IndexSlice, IndexVec}; @@ -1020,8 +1020,8 @@ mod tests { use std::fs; use std::path::PathBuf; - use ruff_python_ast::Ranged; use ruff_python_parser::{parse, Mode}; + use ruff_text_size::Ranged; use std::fmt::Write; use test_case::test_case; diff --git a/crates/ruff/src/rules/tryceratops/rules/error_instead_of_exception.rs b/crates/ruff/src/rules/tryceratops/rules/error_instead_of_exception.rs index 3a55d2535ea2e..2d0404a50406a 100644 --- a/crates/ruff/src/rules/tryceratops/rules/error_instead_of_exception.rs +++ b/crates/ruff/src/rules/tryceratops/rules/error_instead_of_exception.rs @@ -1,9 +1,10 @@ -use ruff_python_ast::{self as ast, ExceptHandler, Expr, Ranged}; +use ruff_python_ast::{self as ast, ExceptHandler, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::visitor::Visitor; use ruff_python_semantic::analyze::logging::exc_info; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::tryceratops::helpers::LoggerCandidateVisitor; diff --git a/crates/ruff/src/rules/tryceratops/rules/raise_vanilla_args.rs b/crates/ruff/src/rules/tryceratops/rules/raise_vanilla_args.rs index aadfa930c49f7..bb07a670b1b02 100644 --- a/crates/ruff/src/rules/tryceratops/rules/raise_vanilla_args.rs +++ b/crates/ruff/src/rules/tryceratops/rules/raise_vanilla_args.rs @@ -1,6 +1,7 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; -use ruff_python_ast::{self as ast, Arguments, Constant, Expr, Ranged}; +use ruff_python_ast::{self as ast, Arguments, Constant, Expr}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/tryceratops/rules/raise_vanilla_class.rs b/crates/ruff/src/rules/tryceratops/rules/raise_vanilla_class.rs index 4edc10f21b656..0c1b742ba56c1 100644 --- a/crates/ruff/src/rules/tryceratops/rules/raise_vanilla_class.rs +++ b/crates/ruff/src/rules/tryceratops/rules/raise_vanilla_class.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, Expr, Ranged}; +use ruff_python_ast::{self as ast, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/tryceratops/rules/raise_within_try.rs b/crates/ruff/src/rules/tryceratops/rules/raise_within_try.rs index 7748651468dc8..3c1ba73451434 100644 --- a/crates/ruff/src/rules/tryceratops/rules/raise_within_try.rs +++ b/crates/ruff/src/rules/tryceratops/rules/raise_within_try.rs @@ -1,4 +1,4 @@ -use ruff_python_ast::{self as ast, ExceptHandler, Ranged, Stmt}; +use ruff_python_ast::{self as ast, ExceptHandler, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; @@ -7,6 +7,7 @@ use ruff_python_ast::{ helpers::{self, map_callable}, statement_visitor::{walk_stmt, StatementVisitor}, }; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/tryceratops/rules/try_consider_else.rs b/crates/ruff/src/rules/tryceratops/rules/try_consider_else.rs index 60746761cc301..60aa30e7ca751 100644 --- a/crates/ruff/src/rules/tryceratops/rules/try_consider_else.rs +++ b/crates/ruff/src/rules/tryceratops/rules/try_consider_else.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, ExceptHandler, Ranged, Stmt}; +use ruff_python_ast::{self as ast, ExceptHandler, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::helpers::contains_effect; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/tryceratops/rules/type_check_without_type_error.rs b/crates/ruff/src/rules/tryceratops/rules/type_check_without_type_error.rs index 91e1d25b4cc48..eaa8c5e7494aa 100644 --- a/crates/ruff/src/rules/tryceratops/rules/type_check_without_type_error.rs +++ b/crates/ruff/src/rules/tryceratops/rules/type_check_without_type_error.rs @@ -1,7 +1,8 @@ use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::statement_visitor::{walk_stmt, StatementVisitor}; -use ruff_python_ast::{self as ast, Expr, Ranged, Stmt, StmtIf}; +use ruff_python_ast::{self as ast, Expr, Stmt, StmtIf}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/tryceratops/rules/useless_try_except.rs b/crates/ruff/src/rules/tryceratops/rules/useless_try_except.rs index a7fc01fb988f5..755f849bc9522 100644 --- a/crates/ruff/src/rules/tryceratops/rules/useless_try_except.rs +++ b/crates/ruff/src/rules/tryceratops/rules/useless_try_except.rs @@ -1,7 +1,8 @@ -use ruff_python_ast::{self as ast, ExceptHandler, ExceptHandlerExceptHandler, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, ExceptHandler, ExceptHandlerExceptHandler, Expr, Stmt}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; diff --git a/crates/ruff/src/rules/tryceratops/rules/verbose_log_message.rs b/crates/ruff/src/rules/tryceratops/rules/verbose_log_message.rs index 800b36ff4f975..4ddf0009b5892 100644 --- a/crates/ruff/src/rules/tryceratops/rules/verbose_log_message.rs +++ b/crates/ruff/src/rules/tryceratops/rules/verbose_log_message.rs @@ -1,9 +1,10 @@ -use ruff_python_ast::{self as ast, ExceptHandler, Expr, Ranged}; +use ruff_python_ast::{self as ast, ExceptHandler, Expr}; use ruff_diagnostics::{Diagnostic, Violation}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::visitor; use ruff_python_ast::visitor::Visitor; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::rules::tryceratops::helpers::LoggerCandidateVisitor; diff --git a/crates/ruff/src/rules/tryceratops/rules/verbose_raise.rs b/crates/ruff/src/rules/tryceratops/rules/verbose_raise.rs index 70ff1e3c2137d..10c11798700cb 100644 --- a/crates/ruff/src/rules/tryceratops/rules/verbose_raise.rs +++ b/crates/ruff/src/rules/tryceratops/rules/verbose_raise.rs @@ -1,8 +1,9 @@ -use ruff_python_ast::{self as ast, ExceptHandler, Expr, Ranged, Stmt}; +use ruff_python_ast::{self as ast, ExceptHandler, Expr, Stmt}; use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix}; use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::statement_visitor::{walk_stmt, StatementVisitor}; +use ruff_text_size::Ranged; use crate::checkers::ast::Checker; use crate::registry::AsRule; diff --git a/crates/ruff_formatter/src/format_extensions.rs b/crates/ruff_formatter/src/format_extensions.rs index b1fb33d6b6cad..1964ad246b4ca 100644 --- a/crates/ruff_formatter/src/format_extensions.rs +++ b/crates/ruff_formatter/src/format_extensions.rs @@ -17,7 +17,7 @@ pub trait MemoizeFormat { /// use std::cell::Cell; /// use ruff_formatter::{format, write}; /// use ruff_formatter::prelude::*; - /// use ruff_text_size::TextSize; + /// use ruff_text_size::{Ranged, TextSize}; /// /// struct MyFormat { /// value: Cell @@ -98,7 +98,7 @@ where /// use std::cell::Cell; /// use ruff_formatter::{format, write}; /// use ruff_formatter::prelude::*; - /// use ruff_text_size::TextSize; + /// use ruff_text_size::{Ranged, TextSize}; /// /// #[derive(Default)] /// struct Counter { diff --git a/crates/ruff_python_ast/src/expression.rs b/crates/ruff_python_ast/src/expression.rs index c76b093faba4d..562c68495281d 100644 --- a/crates/ruff_python_ast/src/expression.rs +++ b/crates/ruff_python_ast/src/expression.rs @@ -1,7 +1,7 @@ -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::node::AnyNodeRef; -use crate::{self as ast, Expr, Ranged}; +use crate::{self as ast, Expr}; /// Unowned pendant to [`ast::Expr`] that stores a reference instead of a owned value. #[derive(Copy, Clone, Debug, PartialEq)] diff --git a/crates/ruff_python_ast/src/helpers.rs b/crates/ruff_python_ast/src/helpers.rs index e27ab6f450793..8c97f9a172c03 100644 --- a/crates/ruff_python_ast/src/helpers.rs +++ b/crates/ruff_python_ast/src/helpers.rs @@ -4,13 +4,12 @@ use std::path::Path; use num_traits::Zero; use smallvec::SmallVec; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::call_path::CallPath; use crate::statement_visitor::{walk_body, walk_stmt, StatementVisitor}; use crate::{ - self as ast, Arguments, Constant, ExceptHandler, Expr, MatchCase, Pattern, Ranged, Stmt, - TypeParam, + self as ast, Arguments, Constant, ExceptHandler, Expr, MatchCase, Pattern, Stmt, TypeParam, }; /// Return `true` if the `Stmt` is a compound statement (as opposed to a simple statement). diff --git a/crates/ruff_python_ast/src/identifier.rs b/crates/ruff_python_ast/src/identifier.rs index 2ff690ebc88a6..ffbb8c152f17c 100644 --- a/crates/ruff_python_ast/src/identifier.rs +++ b/crates/ruff_python_ast/src/identifier.rs @@ -10,8 +10,8 @@ //! //! This module can be used to identify the [`TextRange`] of the `except` token. -use crate::{self as ast, Alias, ExceptHandler, Parameter, ParameterWithDefault, Ranged, Stmt}; -use ruff_text_size::{TextLen, TextRange, TextSize}; +use crate::{self as ast, Alias, ExceptHandler, Parameter, ParameterWithDefault, Stmt}; +use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; use ruff_python_trivia::{is_python_whitespace, Cursor}; diff --git a/crates/ruff_python_ast/src/lib.rs b/crates/ruff_python_ast/src/lib.rs index 8f8a5ad4f2ce1..9b605994e82fa 100644 --- a/crates/ruff_python_ast/src/lib.rs +++ b/crates/ruff_python_ast/src/lib.rs @@ -1,6 +1,8 @@ -use ruff_text_size::{TextRange, TextSize}; use std::path::Path; +pub use expression::*; +pub use nodes::*; + pub mod all; pub mod call_path; pub mod comparable; @@ -22,36 +24,6 @@ pub mod types; pub mod visitor; pub mod whitespace; -pub use expression::*; -pub use nodes::*; - -pub trait Ranged { - fn range(&self) -> TextRange; - - fn start(&self) -> TextSize { - self.range().start() - } - - fn end(&self) -> TextSize { - self.range().end() - } -} - -impl Ranged for TextRange { - fn range(&self) -> TextRange { - *self - } -} - -impl Ranged for &T -where - T: Ranged, -{ - fn range(&self) -> TextRange { - T::range(self) - } -} - #[derive(Clone, Copy, Debug, Default, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum PySourceType { diff --git a/crates/ruff_python_ast/src/node.rs b/crates/ruff_python_ast/src/node.rs index 988a2164c7467..8c96479221d6a 100644 --- a/crates/ruff_python_ast/src/node.rs +++ b/crates/ruff_python_ast/src/node.rs @@ -2,10 +2,10 @@ use crate::visitor::preorder::PreorderVisitor; use crate::{ self as ast, Alias, Arguments, Comprehension, Decorator, ExceptHandler, Expr, Keyword, MatchCase, Mod, Parameter, ParameterWithDefault, Parameters, Pattern, PatternArguments, - PatternKeyword, Ranged, Stmt, TypeParam, TypeParamParamSpec, TypeParamTypeVar, - TypeParamTypeVarTuple, TypeParams, WithItem, + PatternKeyword, Stmt, TypeParam, TypeParamParamSpec, TypeParamTypeVar, TypeParamTypeVarTuple, + TypeParams, WithItem, }; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use std::ptr::NonNull; pub trait AstNode: Ranged { diff --git a/crates/ruff_python_ast/src/nodes.rs b/crates/ruff_python_ast/src/nodes.rs index c02d00f9f79ae..514ed6c8ff82e 100644 --- a/crates/ruff_python_ast/src/nodes.rs +++ b/crates/ruff_python_ast/src/nodes.rs @@ -1,12 +1,13 @@ #![allow(clippy::derive_partial_eq_without_eq)] -use crate::Ranged; -use num_bigint::BigInt; -use ruff_text_size::{TextRange, TextSize}; use std::fmt; use std::fmt::Debug; use std::ops::Deref; +use num_bigint::BigInt; + +use ruff_text_size::{Ranged, TextRange, TextSize}; + /// See also [mod](https://docs.python.org/3/library/ast.html#ast.mod) #[derive(Clone, Debug, PartialEq, is_macro::Is)] pub enum Mod { @@ -3087,9 +3088,10 @@ impl Ranged for crate::nodes::ParameterWithDefault { #[cfg(target_pointer_width = "64")] mod size_assertions { + use static_assertions::assert_eq_size; + #[allow(clippy::wildcard_imports)] use super::*; - use static_assertions::assert_eq_size; assert_eq_size!(Stmt, [u8; 144]); assert_eq_size!(StmtFunctionDef, [u8; 144]); diff --git a/crates/ruff_python_ast/src/parenthesize.rs b/crates/ruff_python_ast/src/parenthesize.rs index e8dfee57762c9..f86f09028b0d7 100644 --- a/crates/ruff_python_ast/src/parenthesize.rs +++ b/crates/ruff_python_ast/src/parenthesize.rs @@ -1,8 +1,8 @@ use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; -use ruff_text_size::{TextRange, TextSize}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::node::AnyNodeRef; -use crate::{ExpressionRef, Ranged}; +use crate::ExpressionRef; /// Returns the [`TextRange`] of a given expression including parentheses, if the expression is /// parenthesized; or `None`, if the expression is not parenthesized. diff --git a/crates/ruff_python_ast/src/stmt_if.rs b/crates/ruff_python_ast/src/stmt_if.rs index c8a1e34e836ce..e0d11978d6755 100644 --- a/crates/ruff_python_ast/src/stmt_if.rs +++ b/crates/ruff_python_ast/src/stmt_if.rs @@ -1,6 +1,6 @@ -use crate::{ElifElseClause, Expr, Ranged, Stmt, StmtIf}; +use crate::{ElifElseClause, Expr, Stmt, StmtIf}; use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use std::iter; /// Return the `Range` of the first `Elif` or `Else` token in an `If` statement. diff --git a/crates/ruff_python_ast/src/whitespace.rs b/crates/ruff_python_ast/src/whitespace.rs index 6f89365efb6da..f3b906d6b92ec 100644 --- a/crates/ruff_python_ast/src/whitespace.rs +++ b/crates/ruff_python_ast/src/whitespace.rs @@ -1,8 +1,8 @@ use ruff_python_trivia::{indentation_at_offset, is_python_whitespace, PythonWhitespace}; use ruff_source_file::{newlines::UniversalNewlineIterator, Locator}; -use ruff_text_size::{TextRange, TextSize}; +use ruff_text_size::{Ranged, TextRange, TextSize}; -use crate::{Ranged, Stmt}; +use crate::Stmt; /// Extract the leading indentation from a line. #[inline] diff --git a/crates/ruff_python_formatter/src/builders.rs b/crates/ruff_python_formatter/src/builders.rs index 56f2936b7c975..40327ce7da87f 100644 --- a/crates/ruff_python_formatter/src/builders.rs +++ b/crates/ruff_python_formatter/src/builders.rs @@ -1,6 +1,5 @@ use ruff_formatter::{format_args, write, Argument, Arguments}; -use ruff_python_ast::Ranged; -use ruff_text_size::{TextRange, TextSize}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::context::{NodeLevel, WithNodeLevel}; use crate::other::commas::has_magic_trailing_comma; diff --git a/crates/ruff_python_formatter/src/comments/debug.rs b/crates/ruff_python_formatter/src/comments/debug.rs index 578b463b4987c..baaf405f11ad3 100644 --- a/crates/ruff_python_formatter/src/comments/debug.rs +++ b/crates/ruff_python_formatter/src/comments/debug.rs @@ -1,9 +1,9 @@ use std::fmt::{Debug, Formatter, Write}; use itertools::Itertools; -use ruff_python_ast::Ranged; use ruff_formatter::SourceCode; +use ruff_text_size::Ranged; use crate::comments::node_key::NodeRefEqualityKey; use crate::comments::{CommentsMap, SourceComment}; @@ -178,11 +178,11 @@ impl Debug for DebugNodeCommentSlice<'_> { #[cfg(test)] mod tests { use insta::assert_debug_snapshot; - use ruff_python_ast::{StmtBreak, StmtContinue}; - use ruff_text_size::{TextRange, TextSize}; use ruff_formatter::SourceCode; use ruff_python_ast::node::AnyNode; + use ruff_python_ast::{StmtBreak, StmtContinue}; + use ruff_text_size::{TextRange, TextSize}; use crate::comments::map::MultiMap; use crate::comments::{CommentLinePosition, Comments, CommentsMap, SourceComment}; diff --git a/crates/ruff_python_formatter/src/comments/format.rs b/crates/ruff_python_formatter/src/comments/format.rs index 7a36a3a406c2a..0f0c65232bd01 100644 --- a/crates/ruff_python_formatter/src/comments/format.rs +++ b/crates/ruff_python_formatter/src/comments/format.rs @@ -1,5 +1,4 @@ -use ruff_python_ast::Ranged; -use ruff_text_size::{TextLen, TextRange, TextSize}; +use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; use ruff_formatter::{format_args, write, FormatError, SourceCode}; use ruff_python_ast::node::{AnyNodeRef, AstNode}; diff --git a/crates/ruff_python_formatter/src/comments/mod.rs b/crates/ruff_python_formatter/src/comments/mod.rs index d46014ae29711..57ded7ba08ffc 100644 --- a/crates/ruff_python_formatter/src/comments/mod.rs +++ b/crates/ruff_python_formatter/src/comments/mod.rs @@ -87,12 +87,12 @@ //! //! It is possible to add an additional optional label to [`SourceComment`] If ever the need arises to distinguish two *dangling comments* in the formatting logic, -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use std::cell::Cell; use std::fmt::Debug; use std::rc::Rc; -use ruff_python_ast::{Mod, Ranged}; +use ruff_python_ast::Mod; pub(crate) use format::{ dangling_comments, dangling_node_comments, dangling_open_parenthesis_comments, diff --git a/crates/ruff_python_formatter/src/comments/placement.rs b/crates/ruff_python_formatter/src/comments/placement.rs index 8a4cf95abbb3d..967a9c2bfedf5 100644 --- a/crates/ruff_python_formatter/src/comments/placement.rs +++ b/crates/ruff_python_formatter/src/comments/placement.rs @@ -2,12 +2,12 @@ use std::cmp::Ordering; use ruff_python_ast::node::AnyNodeRef; use ruff_python_ast::whitespace::indentation; -use ruff_python_ast::{self as ast, Comprehension, Expr, MatchCase, Parameters, Ranged}; +use ruff_python_ast::{self as ast, Comprehension, Expr, MatchCase, Parameters}; use ruff_python_trivia::{ find_only_token_in_range, indentation_at_offset, SimpleToken, SimpleTokenKind, SimpleTokenizer, }; use ruff_source_file::Locator; -use ruff_text_size::{TextLen, TextRange}; +use ruff_text_size::{Ranged, TextLen, TextRange}; use crate::comments::visitor::{CommentPlacement, DecoratedComment}; use crate::expression::expr_slice::{assign_comment_in_slice, ExprSliceCommentSection}; diff --git a/crates/ruff_python_formatter/src/comments/visitor.rs b/crates/ruff_python_formatter/src/comments/visitor.rs index f779820a35a40..c6aa5abb7ccdc 100644 --- a/crates/ruff_python_formatter/src/comments/visitor.rs +++ b/crates/ruff_python_formatter/src/comments/visitor.rs @@ -1,7 +1,7 @@ use std::iter::Peekable; -use ruff_python_ast::{Mod, Ranged, Stmt}; -use ruff_text_size::{TextRange, TextSize}; +use ruff_python_ast::{Mod, Stmt}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use ruff_formatter::{SourceCode, SourceCodeSlice}; use ruff_python_ast::node::AnyNodeRef; diff --git a/crates/ruff_python_formatter/src/expression/expr_attribute.rs b/crates/ruff_python_formatter/src/expression/expr_attribute.rs index e322f294282c6..b2566242cb508 100644 --- a/crates/ruff_python_formatter/src/expression/expr_attribute.rs +++ b/crates/ruff_python_formatter/src/expression/expr_attribute.rs @@ -1,8 +1,8 @@ use ruff_formatter::{write, FormatRuleWithOptions}; use ruff_python_ast::node::AnyNodeRef; -use ruff_python_ast::{Constant, Expr, ExprAttribute, ExprConstant, Ranged}; +use ruff_python_ast::{Constant, Expr, ExprAttribute, ExprConstant}; use ruff_python_trivia::{find_only_token_in_range, SimpleTokenKind}; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::comments::{dangling_comments, SourceComment}; use crate::expression::parentheses::{ diff --git a/crates/ruff_python_formatter/src/expression/expr_constant.rs b/crates/ruff_python_formatter/src/expression/expr_constant.rs index 501c932c5e7e0..8f3de76916a80 100644 --- a/crates/ruff_python_formatter/src/expression/expr_constant.rs +++ b/crates/ruff_python_formatter/src/expression/expr_constant.rs @@ -1,7 +1,7 @@ use ruff_formatter::FormatRuleWithOptions; use ruff_python_ast::node::AnyNodeRef; -use ruff_python_ast::{Constant, ExprConstant, Ranged}; -use ruff_text_size::{TextLen, TextRange}; +use ruff_python_ast::{Constant, ExprConstant}; +use ruff_text_size::{Ranged, TextLen, TextRange}; use crate::comments::SourceComment; use crate::expression::number::{FormatComplex, FormatFloat, FormatInt}; diff --git a/crates/ruff_python_formatter/src/expression/expr_dict.rs b/crates/ruff_python_formatter/src/expression/expr_dict.rs index 3486fdb4388a9..851898ee87736 100644 --- a/crates/ruff_python_formatter/src/expression/expr_dict.rs +++ b/crates/ruff_python_formatter/src/expression/expr_dict.rs @@ -1,8 +1,7 @@ use ruff_formatter::{format_args, write}; use ruff_python_ast::node::AnyNodeRef; -use ruff_python_ast::Ranged; use ruff_python_ast::{Expr, ExprDict}; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::comments::{leading_comments, SourceComment}; use crate::expression::parentheses::{ diff --git a/crates/ruff_python_formatter/src/expression/expr_ipy_escape_command.rs b/crates/ruff_python_formatter/src/expression/expr_ipy_escape_command.rs index 2989ba94913f2..e225a8eaae77e 100644 --- a/crates/ruff_python_formatter/src/expression/expr_ipy_escape_command.rs +++ b/crates/ruff_python_formatter/src/expression/expr_ipy_escape_command.rs @@ -1,4 +1,5 @@ -use ruff_python_ast::{ExprIpyEscapeCommand, Ranged}; +use ruff_python_ast::ExprIpyEscapeCommand; +use ruff_text_size::Ranged; use crate::prelude::*; diff --git a/crates/ruff_python_formatter/src/expression/expr_list.rs b/crates/ruff_python_formatter/src/expression/expr_list.rs index b89c36de0f748..e7e522a84c2bf 100644 --- a/crates/ruff_python_formatter/src/expression/expr_list.rs +++ b/crates/ruff_python_formatter/src/expression/expr_list.rs @@ -1,6 +1,7 @@ use ruff_formatter::prelude::format_with; use ruff_python_ast::node::AnyNodeRef; -use ruff_python_ast::{ExprList, Ranged}; +use ruff_python_ast::ExprList; +use ruff_text_size::Ranged; use crate::comments::SourceComment; use crate::expression::parentheses::{ diff --git a/crates/ruff_python_formatter/src/expression/expr_name.rs b/crates/ruff_python_formatter/src/expression/expr_name.rs index 80d4169accccf..e0585f55abee5 100644 --- a/crates/ruff_python_formatter/src/expression/expr_name.rs +++ b/crates/ruff_python_formatter/src/expression/expr_name.rs @@ -50,9 +50,8 @@ impl NeedsParentheses for ExprName { #[cfg(test)] mod tests { - use ruff_python_ast::Ranged; use ruff_python_parser::parse_program; - use ruff_text_size::{TextRange, TextSize}; + use ruff_text_size::{Ranged, TextRange, TextSize}; #[test] fn name_range_with_comments() { diff --git a/crates/ruff_python_formatter/src/expression/expr_set.rs b/crates/ruff_python_formatter/src/expression/expr_set.rs index 3ef1c1f150228..109227c5d1a4f 100644 --- a/crates/ruff_python_formatter/src/expression/expr_set.rs +++ b/crates/ruff_python_formatter/src/expression/expr_set.rs @@ -1,5 +1,6 @@ use ruff_python_ast::node::AnyNodeRef; -use ruff_python_ast::{ExprSet, Ranged}; +use ruff_python_ast::ExprSet; +use ruff_text_size::Ranged; use crate::comments::SourceComment; use crate::expression::parentheses::{parenthesized, NeedsParentheses, OptionalParentheses}; diff --git a/crates/ruff_python_formatter/src/expression/expr_slice.rs b/crates/ruff_python_formatter/src/expression/expr_slice.rs index 4587bd3e606f2..01a49f852f3a7 100644 --- a/crates/ruff_python_formatter/src/expression/expr_slice.rs +++ b/crates/ruff_python_formatter/src/expression/expr_slice.rs @@ -2,7 +2,7 @@ use ruff_formatter::{write, FormatError}; use ruff_python_ast::node::{AnyNodeRef, AstNode}; use ruff_python_ast::{Expr, ExprSlice, ExprUnaryOp, UnaryOp}; use ruff_python_trivia::{SimpleToken, SimpleTokenKind, SimpleTokenizer}; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::comments::{dangling_comments, SourceComment}; use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses}; @@ -158,9 +158,7 @@ pub(crate) fn find_colons( lower: Option<&Expr>, upper: Option<&Expr>, ) -> FormatResult<(SimpleToken, Option)> { - let after_lower = lower - .as_ref() - .map_or(range.start(), ruff_python_ast::Ranged::end); + let after_lower = lower.as_ref().map_or(range.start(), Ranged::end); let mut tokens = SimpleTokenizer::new(contents, TextRange::new(after_lower, range.end())) .skip_trivia() .skip_while(|token| token.kind == SimpleTokenKind::RParen); @@ -173,9 +171,7 @@ pub(crate) fn find_colons( )); } - let after_upper = upper - .as_ref() - .map_or(first_colon.end(), ruff_python_ast::Ranged::end); + let after_upper = upper.as_ref().map_or(first_colon.end(), Ranged::end); let mut tokens = SimpleTokenizer::new(contents, TextRange::new(after_upper, range.end())) .skip_trivia() .skip_while(|token| token.kind == SimpleTokenKind::RParen); diff --git a/crates/ruff_python_formatter/src/expression/expr_tuple.rs b/crates/ruff_python_formatter/src/expression/expr_tuple.rs index 94d93f373f5c7..4e4284419b229 100644 --- a/crates/ruff_python_formatter/src/expression/expr_tuple.rs +++ b/crates/ruff_python_formatter/src/expression/expr_tuple.rs @@ -1,9 +1,8 @@ use ruff_formatter::{format_args, write, FormatRuleWithOptions}; use ruff_python_ast::node::AnyNodeRef; use ruff_python_ast::ExprTuple; -use ruff_python_ast::Ranged; use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::builders::parenthesize_if_expands; use crate::comments::SourceComment; diff --git a/crates/ruff_python_formatter/src/expression/expr_unary_op.rs b/crates/ruff_python_formatter/src/expression/expr_unary_op.rs index a5e8be6e2b9de..f83ac33a4c637 100644 --- a/crates/ruff_python_formatter/src/expression/expr_unary_op.rs +++ b/crates/ruff_python_formatter/src/expression/expr_unary_op.rs @@ -1,8 +1,8 @@ use ruff_python_ast::node::AnyNodeRef; +use ruff_python_ast::ExprUnaryOp; use ruff_python_ast::UnaryOp; -use ruff_python_ast::{ExprUnaryOp, Ranged}; use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; -use ruff_text_size::{TextLen, TextRange}; +use ruff_text_size::{Ranged, TextLen, TextRange}; use crate::comments::trailing_comments; use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses}; diff --git a/crates/ruff_python_formatter/src/expression/expr_yield.rs b/crates/ruff_python_formatter/src/expression/expr_yield.rs index ad6956c073844..4d8334c64f525 100644 --- a/crates/ruff_python_formatter/src/expression/expr_yield.rs +++ b/crates/ruff_python_formatter/src/expression/expr_yield.rs @@ -1,7 +1,7 @@ use ruff_formatter::write; use ruff_python_ast::node::AnyNodeRef; -use ruff_python_ast::{Expr, ExprYield, ExprYieldFrom, Ranged}; -use ruff_text_size::TextRange; +use ruff_python_ast::{Expr, ExprYield, ExprYieldFrom}; +use ruff_text_size::{Ranged, TextRange}; use crate::expression::maybe_parenthesize_expression; use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses, Parenthesize}; diff --git a/crates/ruff_python_formatter/src/expression/number.rs b/crates/ruff_python_formatter/src/expression/number.rs index 3a5836dec010e..bef3b476e073a 100644 --- a/crates/ruff_python_formatter/src/expression/number.rs +++ b/crates/ruff_python_formatter/src/expression/number.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; -use ruff_python_ast::{ExprConstant, Ranged}; -use ruff_text_size::TextSize; +use ruff_python_ast::ExprConstant; +use ruff_text_size::{Ranged, TextSize}; use crate::prelude::*; diff --git a/crates/ruff_python_formatter/src/expression/parentheses.rs b/crates/ruff_python_formatter/src/expression/parentheses.rs index ed6dd49fb7ab8..0a0b85a864d5e 100644 --- a/crates/ruff_python_formatter/src/expression/parentheses.rs +++ b/crates/ruff_python_formatter/src/expression/parentheses.rs @@ -1,8 +1,9 @@ use ruff_formatter::prelude::tag::Condition; use ruff_formatter::{format_args, write, Argument, Arguments, FormatContext, FormatOptions}; use ruff_python_ast::node::AnyNodeRef; -use ruff_python_ast::{ExpressionRef, Ranged}; +use ruff_python_ast::ExpressionRef; use ruff_python_trivia::{first_non_trivia_token, SimpleToken, SimpleTokenKind, SimpleTokenizer}; +use ruff_text_size::Ranged; use crate::comments::{ dangling_comments, dangling_open_parenthesis_comments, trailing_comments, SourceComment, diff --git a/crates/ruff_python_formatter/src/expression/string.rs b/crates/ruff_python_formatter/src/expression/string.rs index 49319f9389582..ec900abca7c0e 100644 --- a/crates/ruff_python_formatter/src/expression/string.rs +++ b/crates/ruff_python_formatter/src/expression/string.rs @@ -4,11 +4,11 @@ use bitflags::bitflags; use ruff_formatter::{format_args, write, FormatError, FormatOptions, TabWidth}; use ruff_python_ast::node::AnyNodeRef; -use ruff_python_ast::{self as ast, ExprConstant, ExprFString, Ranged}; +use ruff_python_ast::{self as ast, ExprConstant, ExprFString}; use ruff_python_parser::lexer::{lex_starts_at, LexicalError, LexicalErrorType}; use ruff_python_parser::{Mode, Tok}; use ruff_source_file::Locator; -use ruff_text_size::{TextLen, TextRange, TextSize}; +use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; use crate::comments::{leading_comments, trailing_comments}; use crate::expression::parentheses::{ diff --git a/crates/ruff_python_formatter/src/other/arguments.rs b/crates/ruff_python_formatter/src/other/arguments.rs index 05d95f2382922..f0c2651361d2b 100644 --- a/crates/ruff_python_formatter/src/other/arguments.rs +++ b/crates/ruff_python_formatter/src/other/arguments.rs @@ -1,8 +1,8 @@ use ruff_formatter::write; use ruff_python_ast::node::AstNode; -use ruff_python_ast::{Arguments, Expr, Ranged}; +use ruff_python_ast::{Arguments, Expr}; use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; -use ruff_text_size::{TextRange, TextSize}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::comments::SourceComment; use crate::expression::expr_generator_exp::GeneratorExpParentheses; diff --git a/crates/ruff_python_formatter/src/other/comprehension.rs b/crates/ruff_python_formatter/src/other/comprehension.rs index dad7d14880e70..0a58fbfc3809f 100644 --- a/crates/ruff_python_formatter/src/other/comprehension.rs +++ b/crates/ruff_python_formatter/src/other/comprehension.rs @@ -1,5 +1,6 @@ use ruff_formatter::{format_args, write, Buffer, FormatResult}; -use ruff_python_ast::{Comprehension, Expr, Ranged}; +use ruff_python_ast::{Comprehension, Expr}; +use ruff_text_size::Ranged; use crate::comments::{leading_comments, trailing_comments, SourceComment}; use crate::expression::expr_tuple::TupleParentheses; diff --git a/crates/ruff_python_formatter/src/other/identifier.rs b/crates/ruff_python_formatter/src/other/identifier.rs index 4c81c3e8e3c78..b889589302210 100644 --- a/crates/ruff_python_formatter/src/other/identifier.rs +++ b/crates/ruff_python_formatter/src/other/identifier.rs @@ -1,7 +1,8 @@ -use crate::prelude::*; - use ruff_formatter::{FormatOwnedWithRule, FormatRefWithRule}; -use ruff_python_ast::{Identifier, Ranged}; +use ruff_python_ast::Identifier; +use ruff_text_size::Ranged; + +use crate::prelude::*; pub struct FormatIdentifier; diff --git a/crates/ruff_python_formatter/src/other/parameters.rs b/crates/ruff_python_formatter/src/other/parameters.rs index 55da9b69520fe..2e6c451ae444f 100644 --- a/crates/ruff_python_formatter/src/other/parameters.rs +++ b/crates/ruff_python_formatter/src/other/parameters.rs @@ -2,9 +2,9 @@ use std::usize; use ruff_formatter::{format_args, write, FormatRuleWithOptions}; use ruff_python_ast::node::{AnyNodeRef, AstNode}; -use ruff_python_ast::{Parameters, Ranged}; +use ruff_python_ast::Parameters; use ruff_python_trivia::{SimpleToken, SimpleTokenKind, SimpleTokenizer}; -use ruff_text_size::{TextRange, TextSize}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::comments::{ dangling_comments, dangling_open_parenthesis_comments, leading_comments, leading_node_comments, diff --git a/crates/ruff_python_formatter/src/pattern/mod.rs b/crates/ruff_python_formatter/src/pattern/mod.rs index 6f59e8a7ee6b9..d0f44e258a346 100644 --- a/crates/ruff_python_formatter/src/pattern/mod.rs +++ b/crates/ruff_python_formatter/src/pattern/mod.rs @@ -1,7 +1,8 @@ use ruff_formatter::{FormatOwnedWithRule, FormatRefWithRule, FormatRule, FormatRuleWithOptions}; use ruff_python_ast::node::AnyNodeRef; -use ruff_python_ast::{Pattern, Ranged}; +use ruff_python_ast::Pattern; use ruff_python_trivia::{first_non_trivia_token, SimpleToken, SimpleTokenKind, SimpleTokenizer}; +use ruff_text_size::Ranged; use crate::expression::parentheses::{ parenthesized, NeedsParentheses, OptionalParentheses, Parentheses, diff --git a/crates/ruff_python_formatter/src/pattern/pattern_arguments.rs b/crates/ruff_python_formatter/src/pattern/pattern_arguments.rs index ed57656c79cdc..8dd05a91f50b5 100644 --- a/crates/ruff_python_formatter/src/pattern/pattern_arguments.rs +++ b/crates/ruff_python_formatter/src/pattern/pattern_arguments.rs @@ -1,8 +1,8 @@ use ruff_formatter::write; use ruff_python_ast::node::AstNode; -use ruff_python_ast::{Pattern, PatternArguments, Ranged}; +use ruff_python_ast::{Pattern, PatternArguments}; use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; -use ruff_text_size::{TextRange, TextSize}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::comments::SourceComment; use crate::expression::parentheses::{empty_parenthesized, parenthesized, Parentheses}; diff --git a/crates/ruff_python_formatter/src/pattern/pattern_match_mapping.rs b/crates/ruff_python_formatter/src/pattern/pattern_match_mapping.rs index ab722e4eb3281..f6584be7a792e 100644 --- a/crates/ruff_python_formatter/src/pattern/pattern_match_mapping.rs +++ b/crates/ruff_python_formatter/src/pattern/pattern_match_mapping.rs @@ -1,9 +1,9 @@ use ruff_formatter::{format_args, write}; use ruff_python_ast::node::AnyNodeRef; use ruff_python_ast::PatternMatchMapping; -use ruff_python_ast::{Expr, Identifier, Pattern, Ranged}; +use ruff_python_ast::{Expr, Identifier, Pattern}; use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::comments::{leading_comments, trailing_comments, SourceComment}; use crate::expression::parentheses::{ diff --git a/crates/ruff_python_formatter/src/pattern/pattern_match_sequence.rs b/crates/ruff_python_formatter/src/pattern/pattern_match_sequence.rs index 1e039ffe56d6f..7d8cea85f1011 100644 --- a/crates/ruff_python_formatter/src/pattern/pattern_match_sequence.rs +++ b/crates/ruff_python_formatter/src/pattern/pattern_match_sequence.rs @@ -1,8 +1,8 @@ use ruff_formatter::{Format, FormatResult}; use ruff_python_ast::node::AnyNodeRef; -use ruff_python_ast::{PatternMatchSequence, Ranged}; +use ruff_python_ast::PatternMatchSequence; use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::expression::parentheses::{ empty_parenthesized, optional_parentheses, parenthesized, NeedsParentheses, OptionalParentheses, diff --git a/crates/ruff_python_formatter/src/statement/clause.rs b/crates/ruff_python_formatter/src/statement/clause.rs index 5e1644cf40cba..348de0e4fa14b 100644 --- a/crates/ruff_python_formatter/src/statement/clause.rs +++ b/crates/ruff_python_formatter/src/statement/clause.rs @@ -1,11 +1,11 @@ use ruff_formatter::{write, Argument, Arguments, FormatError}; use ruff_python_ast::node::AnyNodeRef; use ruff_python_ast::{ - ElifElseClause, ExceptHandlerExceptHandler, MatchCase, Ranged, StmtClassDef, StmtFor, - StmtFunctionDef, StmtIf, StmtMatch, StmtTry, StmtWhile, StmtWith, Suite, + ElifElseClause, ExceptHandlerExceptHandler, MatchCase, StmtClassDef, StmtFor, StmtFunctionDef, + StmtIf, StmtMatch, StmtTry, StmtWhile, StmtWith, Suite, }; use ruff_python_trivia::{SimpleToken, SimpleTokenKind, SimpleTokenizer}; -use ruff_text_size::{TextRange, TextSize}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::comments::{ leading_alternate_branch_comments, trailing_comments, SourceComment, SuppressionKind, @@ -60,11 +60,9 @@ impl<'a> ClauseHeader<'a> { | ClauseHeader::With(_) | ClauseHeader::OrElse(_) => last_child_end, - ClauseHeader::ExceptHandler(handler) => handler - .name - .as_ref() - .map(ruff_python_ast::Ranged::end) - .or(last_child_end), + ClauseHeader::ExceptHandler(handler) => { + handler.name.as_ref().map(Ranged::end).or(last_child_end) + } }; let colon = colon_range(end.unwrap_or(keyword_range.end()), source)?; diff --git a/crates/ruff_python_formatter/src/statement/stmt_class_def.rs b/crates/ruff_python_formatter/src/statement/stmt_class_def.rs index 2f64bbdb7dcf3..4ac84c26f003c 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_class_def.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_class_def.rs @@ -1,6 +1,7 @@ use ruff_formatter::write; -use ruff_python_ast::{Decorator, Ranged, StmtClassDef}; +use ruff_python_ast::{Decorator, StmtClassDef}; use ruff_python_trivia::lines_after_ignoring_trivia; +use ruff_text_size::Ranged; use crate::comments::{leading_comments, trailing_comments, SourceComment}; use crate::prelude::*; diff --git a/crates/ruff_python_formatter/src/statement/stmt_delete.rs b/crates/ruff_python_formatter/src/statement/stmt_delete.rs index 67654507e26d1..485a317ae3715 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_delete.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_delete.rs @@ -1,5 +1,6 @@ use ruff_formatter::write; -use ruff_python_ast::{Ranged, StmtDelete}; +use ruff_python_ast::StmtDelete; +use ruff_text_size::Ranged; use crate::builders::{parenthesize_if_expands, PyFormatterExtensions}; use crate::comments::{dangling_node_comments, SourceComment, SuppressionKind}; diff --git a/crates/ruff_python_formatter/src/statement/stmt_for.rs b/crates/ruff_python_formatter/src/statement/stmt_for.rs index 360c6839a28a1..66a3012e817b8 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_for.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_for.rs @@ -1,5 +1,6 @@ use ruff_formatter::{format_args, write}; -use ruff_python_ast::{Expr, Ranged, Stmt, StmtFor}; +use ruff_python_ast::{Expr, Stmt, StmtFor}; +use ruff_text_size::Ranged; use crate::comments::SourceComment; use crate::expression::expr_tuple::TupleParentheses; diff --git a/crates/ruff_python_formatter/src/statement/stmt_function_def.rs b/crates/ruff_python_formatter/src/statement/stmt_function_def.rs index 1e547481dda01..10c47ca8afe44 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_function_def.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_function_def.rs @@ -1,6 +1,7 @@ use ruff_formatter::write; -use ruff_python_ast::{Parameters, Ranged, StmtFunctionDef}; +use ruff_python_ast::{Parameters, StmtFunctionDef}; use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; +use ruff_text_size::Ranged; use crate::comments::SourceComment; use crate::expression::maybe_parenthesize_expression; diff --git a/crates/ruff_python_formatter/src/statement/stmt_import_from.rs b/crates/ruff_python_formatter/src/statement/stmt_import_from.rs index dcfa27233921f..5881d6e4125cb 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_import_from.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_import_from.rs @@ -1,6 +1,7 @@ use ruff_formatter::write; use ruff_python_ast::node::AstNode; -use ruff_python_ast::{Ranged, StmtImportFrom}; +use ruff_python_ast::StmtImportFrom; +use ruff_text_size::Ranged; use crate::builders::{parenthesize_if_expands, PyFormatterExtensions, TrailingComma}; use crate::comments::{SourceComment, SuppressionKind}; diff --git a/crates/ruff_python_formatter/src/statement/stmt_ipy_escape_command.rs b/crates/ruff_python_formatter/src/statement/stmt_ipy_escape_command.rs index 2cbef034c2839..50add1990ffde 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_ipy_escape_command.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_ipy_escape_command.rs @@ -1,4 +1,5 @@ -use ruff_python_ast::{Ranged, StmtIpyEscapeCommand}; +use ruff_python_ast::StmtIpyEscapeCommand; +use ruff_text_size::Ranged; use crate::comments::{SourceComment, SuppressionKind}; use crate::prelude::*; diff --git a/crates/ruff_python_formatter/src/statement/stmt_try.rs b/crates/ruff_python_formatter/src/statement/stmt_try.rs index 39a98f54294d9..63bbcd4096b50 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_try.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_try.rs @@ -1,5 +1,6 @@ use ruff_formatter::{write, FormatRuleWithOptions}; -use ruff_python_ast::{ExceptHandler, Ranged, StmtTry}; +use ruff_python_ast::{ExceptHandler, StmtTry}; +use ruff_text_size::Ranged; use crate::comments; use crate::comments::leading_alternate_branch_comments; diff --git a/crates/ruff_python_formatter/src/statement/stmt_while.rs b/crates/ruff_python_formatter/src/statement/stmt_while.rs index cb13a9063a1f5..b9212831ddfb1 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_while.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_while.rs @@ -1,6 +1,7 @@ use ruff_formatter::{format_args, write}; use ruff_python_ast::node::AstNode; -use ruff_python_ast::{Ranged, Stmt, StmtWhile}; +use ruff_python_ast::{Stmt, StmtWhile}; +use ruff_text_size::Ranged; use crate::comments::SourceComment; use crate::expression::maybe_parenthesize_expression; diff --git a/crates/ruff_python_formatter/src/statement/stmt_with.rs b/crates/ruff_python_formatter/src/statement/stmt_with.rs index 55383ef564c80..481d3925ae928 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_with.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_with.rs @@ -1,8 +1,8 @@ use ruff_formatter::{format_args, write, FormatError}; use ruff_python_ast::node::AstNode; -use ruff_python_ast::{Ranged, StmtWith}; +use ruff_python_ast::StmtWith; use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::builders::parenthesize_if_expands; use crate::comments::SourceComment; @@ -12,7 +12,7 @@ use crate::expression::parentheses::{ use crate::other::commas; use crate::prelude::*; use crate::statement::clause::{clause_body, clause_header, ClauseHeader}; -use crate::{FormatNodeRule, PyFormatOptions}; +use crate::PyFormatOptions; #[derive(Default)] pub struct FormatStmtWith; diff --git a/crates/ruff_python_formatter/src/statement/suite.rs b/crates/ruff_python_formatter/src/statement/suite.rs index 55a386a6b7194..bb29230c1ee4e 100644 --- a/crates/ruff_python_formatter/src/statement/suite.rs +++ b/crates/ruff_python_formatter/src/statement/suite.rs @@ -1,9 +1,9 @@ use ruff_formatter::{write, FormatOwnedWithRule, FormatRefWithRule, FormatRuleWithOptions}; use ruff_python_ast::helpers::is_compound_statement; use ruff_python_ast::node::AnyNodeRef; -use ruff_python_ast::{self as ast, Constant, Expr, ExprConstant, Ranged, Stmt, Suite}; +use ruff_python_ast::{self as ast, Constant, Expr, ExprConstant, Stmt, Suite}; use ruff_python_trivia::{lines_after_ignoring_trivia, lines_before}; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::comments::{leading_comments, trailing_comments, Comments}; use crate::context::{NodeLevel, WithNodeLevel}; diff --git a/crates/ruff_python_formatter/src/type_param/type_params.rs b/crates/ruff_python_formatter/src/type_param/type_params.rs index 456d54d5e0f5c..cac5b8b33f577 100644 --- a/crates/ruff_python_formatter/src/type_param/type_params.rs +++ b/crates/ruff_python_formatter/src/type_param/type_params.rs @@ -1,12 +1,13 @@ -use crate::builders::PyFormatterExtensions; -use crate::comments::{trailing_comments, SourceComment}; -use crate::expression::parentheses::parenthesized; -use crate::prelude::*; use ruff_formatter::write; use ruff_formatter::FormatResult; use ruff_python_ast::node::AstNode; +use ruff_python_ast::TypeParams; +use ruff_text_size::Ranged; -use ruff_python_ast::{Ranged, TypeParams}; +use crate::builders::PyFormatterExtensions; +use crate::comments::{trailing_comments, SourceComment}; +use crate::expression::parentheses::parenthesized; +use crate::prelude::*; #[derive(Default)] pub struct FormatTypeParams; diff --git a/crates/ruff_python_formatter/src/verbatim.rs b/crates/ruff_python_formatter/src/verbatim.rs index eb3322d11f898..f50aac90a90e0 100644 --- a/crates/ruff_python_formatter/src/verbatim.rs +++ b/crates/ruff_python_formatter/src/verbatim.rs @@ -5,12 +5,12 @@ use unicode_width::UnicodeWidthStr; use ruff_formatter::{write, FormatError}; use ruff_python_ast::node::AnyNodeRef; -use ruff_python_ast::{Ranged, Stmt}; +use ruff_python_ast::Stmt; use ruff_python_parser::lexer::{lex_starts_at, LexResult}; use ruff_python_parser::{Mode, Tok}; use ruff_python_trivia::lines_before; use ruff_source_file::Locator; -use ruff_text_size::{TextRange, TextSize}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::comments::format::{empty_lines, format_comment}; use crate::comments::{leading_comments, trailing_comments, SourceComment}; diff --git a/crates/ruff_python_index/src/comment_ranges.rs b/crates/ruff_python_index/src/comment_ranges.rs index 16e778c2a8a4d..9376d91e020d0 100644 --- a/crates/ruff_python_index/src/comment_ranges.rs +++ b/crates/ruff_python_index/src/comment_ranges.rs @@ -3,7 +3,7 @@ use std::fmt::{Debug, Formatter}; use std::ops::Deref; use ruff_python_parser::Tok; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; /// Stores the ranges of comments sorted by [`TextRange::start`] in increasing order. No two ranges are overlapping. #[derive(Clone)] diff --git a/crates/ruff_python_index/src/indexer.rs b/crates/ruff_python_index/src/indexer.rs index 536661d04d03e..aec33f087ab7b 100644 --- a/crates/ruff_python_index/src/indexer.rs +++ b/crates/ruff_python_index/src/indexer.rs @@ -1,14 +1,14 @@ //! Struct used to index source code, to enable efficient lookup of tokens that //! are omitted from the AST (e.g., commented lines). -use ruff_python_ast::{Ranged, Stmt}; +use ruff_python_ast::Stmt; use ruff_python_parser::lexer::LexResult; use ruff_python_parser::{StringKind, Tok}; use ruff_python_trivia::{has_leading_content, has_trailing_content, is_python_whitespace}; -use ruff_text_size::{TextRange, TextSize}; +use ruff_source_file::Locator; +use ruff_text_size::{Ranged, TextRange, TextSize}; use super::comment_ranges::{CommentRanges, CommentRangesBuilder}; -use ruff_source_file::Locator; pub struct Indexer { comment_ranges: CommentRanges, @@ -276,10 +276,10 @@ impl Indexer { mod tests { use ruff_python_parser::lexer::LexResult; use ruff_python_parser::{lexer, Mode}; + use ruff_source_file::Locator; use ruff_text_size::{TextRange, TextSize}; use crate::Indexer; - use ruff_source_file::Locator; #[test] fn continuation() { diff --git a/crates/ruff_python_parser/src/function.rs b/crates/ruff_python_parser/src/function.rs index eeab6cfd5c71d..9d20186c597e7 100644 --- a/crates/ruff_python_parser/src/function.rs +++ b/crates/ruff_python_parser/src/function.rs @@ -2,8 +2,8 @@ use std::hash::BuildHasherDefault; // Contains functions that perform validation and parsing of arguments and parameters. // Checks apply both to functions and to lambdas. use crate::lexer::{LexicalError, LexicalErrorType}; -use ruff_python_ast::{self as ast, Ranged}; -use ruff_text_size::{TextRange, TextSize}; +use ruff_python_ast::{self as ast}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use rustc_hash::FxHashSet; pub(crate) struct ArgumentList { diff --git a/crates/ruff_python_parser/src/lib.rs b/crates/ruff_python_parser/src/lib.rs index 8cb1774d29bb1..fca224f6f80d3 100644 --- a/crates/ruff_python_parser/src/lib.rs +++ b/crates/ruff_python_parser/src/lib.rs @@ -113,8 +113,8 @@ pub use parser::{ parse, parse_expression, parse_expression_starts_at, parse_program, parse_starts_at, parse_suite, parse_tokens, ParseError, ParseErrorType, }; -use ruff_python_ast::{CmpOp, Expr, Mod, PySourceType, Ranged, Suite}; -use ruff_text_size::{TextRange, TextSize}; +use ruff_python_ast::{CmpOp, Expr, Mod, PySourceType, Suite}; +use ruff_text_size::{Ranged, TextRange, TextSize}; pub use string::FStringErrorType; pub use token::{StringKind, Tok, TokenKind}; diff --git a/crates/ruff_python_parser/src/python.lalrpop b/crates/ruff_python_parser/src/python.lalrpop index 4a27c3cdf2a36..85be9d859f6fd 100644 --- a/crates/ruff_python_parser/src/python.lalrpop +++ b/crates/ruff_python_parser/src/python.lalrpop @@ -4,8 +4,8 @@ // See also: https://greentreesnakes.readthedocs.io/en/latest/nodes.html#keyword use num_bigint::BigInt; -use ruff_text_size::TextSize; -use ruff_python_ast::{self as ast, Ranged, IpyEscapeKind}; +use ruff_text_size::{Ranged, TextSize}; +use ruff_python_ast::{self as ast, IpyEscapeKind}; use crate::{ Mode, lexer::{LexicalError, LexicalErrorType}, diff --git a/crates/ruff_python_parser/src/python.rs b/crates/ruff_python_parser/src/python.rs index d981a9409ee5d..1e0d84f9fe084 100644 --- a/crates/ruff_python_parser/src/python.rs +++ b/crates/ruff_python_parser/src/python.rs @@ -1,8 +1,8 @@ // auto-generated: "lalrpop 0.20.0" -// sha3: 36e9f9ff3ebd5d67d7d1da7c36eccc5d84ab98bbd3b297652afd916650498fcc +// sha3: 775b210bb49d67488594b3367cf46ced8b5d43213ea80fa21d2d4b96b5bece3d use num_bigint::BigInt; -use ruff_text_size::TextSize; -use ruff_python_ast::{self as ast, Ranged, IpyEscapeKind}; +use ruff_text_size::{Ranged, TextSize}; +use ruff_python_ast::{self as ast, IpyEscapeKind}; use crate::{ Mode, lexer::{LexicalError, LexicalErrorType}, @@ -24,8 +24,8 @@ extern crate alloc; mod __parse__Top { use num_bigint::BigInt; - use ruff_text_size::TextSize; - use ruff_python_ast::{self as ast, Ranged, IpyEscapeKind}; + use ruff_text_size::{Ranged, TextSize}; + use ruff_python_ast::{self as ast, IpyEscapeKind}; use crate::{ Mode, lexer::{LexicalError, LexicalErrorType}, diff --git a/crates/ruff_python_parser/src/string.rs b/crates/ruff_python_parser/src/string.rs index beeb5b9dc0942..c182ea52eeb6d 100644 --- a/crates/ruff_python_parser/src/string.rs +++ b/crates/ruff_python_parser/src/string.rs @@ -1,6 +1,6 @@ +use ruff_python_ast::ConversionFlag; use ruff_python_ast::{self as ast, BytesConstant, Constant, Expr, StringConstant}; -use ruff_python_ast::{ConversionFlag, Ranged}; -use ruff_text_size::{TextLen, TextRange, TextSize}; +use ruff_text_size::{Ranged, TextLen, TextRange, TextSize}; // Contains the logic for parsing string literals (mostly concerned with f-strings.) // diff --git a/crates/ruff_python_semantic/src/binding.rs b/crates/ruff_python_semantic/src/binding.rs index ea4113e6c8afe..e357bc7f3ea2c 100644 --- a/crates/ruff_python_semantic/src/binding.rs +++ b/crates/ruff_python_semantic/src/binding.rs @@ -5,9 +5,8 @@ use bitflags::bitflags; use ruff_index::{newtype_index, IndexSlice, IndexVec}; use ruff_python_ast::call_path::format_call_path; -use ruff_python_ast::Ranged; use ruff_source_file::Locator; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use crate::context::ExecutionContext; use crate::model::SemanticModel; diff --git a/crates/ruff_python_semantic/src/definition.rs b/crates/ruff_python_semantic/src/definition.rs index 9c0a20297130b..1ea933a5c226b 100644 --- a/crates/ruff_python_semantic/src/definition.rs +++ b/crates/ruff_python_semantic/src/definition.rs @@ -5,8 +5,8 @@ use std::fmt::Debug; use std::ops::Deref; use ruff_index::{newtype_index, IndexSlice, IndexVec}; -use ruff_python_ast::{self as ast, Ranged, Stmt}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, Stmt}; +use ruff_text_size::{Ranged, TextRange}; use crate::analyze::visibility::{ class_visibility, function_visibility, method_visibility, ModuleSource, Visibility, diff --git a/crates/ruff_python_semantic/src/globals.rs b/crates/ruff_python_semantic/src/globals.rs index 03cdb687ced3e..5b3ff8baf00f7 100644 --- a/crates/ruff_python_semantic/src/globals.rs +++ b/crates/ruff_python_semantic/src/globals.rs @@ -4,9 +4,8 @@ use std::ops::Index; -use ruff_python_ast as ast; -use ruff_python_ast::{Ranged, Stmt}; -use ruff_text_size::TextRange; +use ruff_python_ast::{self as ast, Stmt}; +use ruff_text_size::{Ranged, TextRange}; use rustc_hash::FxHashMap; use ruff_index::{newtype_index, IndexVec}; diff --git a/crates/ruff_python_semantic/src/model.rs b/crates/ruff_python_semantic/src/model.rs index ed01d5382dcc3..51d44ab364365 100644 --- a/crates/ruff_python_semantic/src/model.rs +++ b/crates/ruff_python_semantic/src/model.rs @@ -6,10 +6,10 @@ use smallvec::smallvec; use ruff_python_ast::call_path::{collect_call_path, from_unqualified_name, CallPath}; use ruff_python_ast::helpers::from_relative_import; -use ruff_python_ast::{self as ast, Expr, Operator, Ranged, Stmt}; +use ruff_python_ast::{self as ast, Expr, Operator, Stmt}; use ruff_python_stdlib::path::is_python_stub_file; use ruff_python_stdlib::typing::is_typing_extension; -use ruff_text_size::{TextRange, TextSize}; +use ruff_text_size::{Ranged, TextRange, TextSize}; use crate::binding::{ Binding, BindingFlags, BindingId, BindingKind, Bindings, Exceptions, FromImport, Import, diff --git a/crates/ruff_python_semantic/src/nodes.rs b/crates/ruff_python_semantic/src/nodes.rs index 506623c57e843..3a95b2e8e2c3c 100644 --- a/crates/ruff_python_semantic/src/nodes.rs +++ b/crates/ruff_python_semantic/src/nodes.rs @@ -1,8 +1,8 @@ use std::ops::Index; use ruff_index::{newtype_index, IndexVec}; -use ruff_python_ast::{Expr, Ranged, Stmt}; -use ruff_text_size::TextRange; +use ruff_python_ast::{Expr, Stmt}; +use ruff_text_size::{Ranged, TextRange}; use crate::BranchId; diff --git a/crates/ruff_python_semantic/src/reference.rs b/crates/ruff_python_semantic/src/reference.rs index 80a3fdef8d72c..a963895b21e69 100644 --- a/crates/ruff_python_semantic/src/reference.rs +++ b/crates/ruff_python_semantic/src/reference.rs @@ -1,10 +1,10 @@ -use bitflags::bitflags; -use ruff_text_size::TextRange; use std::ops::Deref; +use bitflags::bitflags; + use ruff_index::{newtype_index, IndexSlice, IndexVec}; -use ruff_python_ast::Ranged; use ruff_source_file::Locator; +use ruff_text_size::{Ranged, TextRange}; use crate::context::ExecutionContext; use crate::scope::ScopeId; diff --git a/crates/ruff_python_trivia/src/whitespace.rs b/crates/ruff_python_trivia/src/whitespace.rs index 5209164870582..78688f5e4a152 100644 --- a/crates/ruff_python_trivia/src/whitespace.rs +++ b/crates/ruff_python_trivia/src/whitespace.rs @@ -82,10 +82,11 @@ impl PythonWhitespace for str { #[cfg(test)] mod tests { - use crate::has_trailing_content; - use ruff_python_ast::Ranged; use ruff_python_parser::{parse_suite, ParseError}; use ruff_source_file::Locator; + use ruff_text_size::Ranged; + + use crate::has_trailing_content; #[test] fn trailing_content() -> Result<(), ParseError> { diff --git a/crates/ruff_shrinking/src/main.rs b/crates/ruff_shrinking/src/main.rs index 1847eb9a8fd54..2ffee84e7bc7e 100644 --- a/crates/ruff_shrinking/src/main.rs +++ b/crates/ruff_shrinking/src/main.rs @@ -35,9 +35,9 @@ use fs_err as fs; use regex::Regex; use ruff_python_ast::statement_visitor::{walk_body, walk_stmt, StatementVisitor}; use ruff_python_ast::visitor::{walk_expr, Visitor}; -use ruff_python_ast::{Expr, Ranged, Stmt, Suite}; +use ruff_python_ast::{Expr, Stmt, Suite}; use ruff_python_parser::Mode; -use ruff_text_size::TextRange; +use ruff_text_size::{Ranged, TextRange}; use std::collections::HashMap; use std::path::{Path, PathBuf}; use std::process::{Command, ExitCode}; diff --git a/crates/ruff_source_file/src/locator.rs b/crates/ruff_source_file/src/locator.rs index 92b01bfc1dfb2..85a5f65c505b8 100644 --- a/crates/ruff_source_file/src/locator.rs +++ b/crates/ruff_source_file/src/locator.rs @@ -95,7 +95,7 @@ impl<'a> Locator<'a> { /// ## Examples /// /// ``` - /// # use ruff_text_size::{TextRange, TextSize}; + /// # use ruff_text_size::{Ranged, TextRange, TextSize}; /// # use ruff_source_file::Locator; /// /// let locator = Locator::new("First line\nsecond line\r\nthird line"); @@ -122,7 +122,7 @@ impl<'a> Locator<'a> { /// ## Examples /// /// ``` - /// # use ruff_text_size::{TextRange, TextSize}; + /// # use ruff_text_size::{Ranged, TextRange, TextSize}; /// # use ruff_source_file::Locator; /// /// let locator = Locator::new("First line\nsecond line\r\nthird line"); @@ -152,7 +152,7 @@ impl<'a> Locator<'a> { /// ## Examples /// /// ``` - /// # use ruff_text_size::{TextRange, TextSize}; + /// # use ruff_text_size::{Ranged, TextRange, TextSize}; /// # use ruff_source_file::Locator; /// /// let locator = Locator::new("First line\nsecond line\r\nthird line"); @@ -176,7 +176,7 @@ impl<'a> Locator<'a> { /// ## Examples /// /// ``` - /// # use ruff_text_size::{TextRange, TextSize}; + /// # use ruff_text_size::{Ranged, TextRange, TextSize}; /// # use ruff_source_file::Locator; /// /// let locator = Locator::new("First line\nsecond line\r\nthird line"); @@ -199,7 +199,7 @@ impl<'a> Locator<'a> { /// ## Examples /// /// ``` - /// # use ruff_text_size::{TextRange, TextSize}; + /// # use ruff_text_size::{Ranged, TextRange, TextSize}; /// # use ruff_source_file::Locator; /// /// let locator = Locator::new("First line\nsecond line\r\nthird line"); @@ -222,7 +222,7 @@ impl<'a> Locator<'a> { /// ## Examples /// /// ``` - /// # use ruff_text_size::{TextRange, TextSize}; + /// # use ruff_text_size::{Ranged, TextRange, TextSize}; /// # use ruff_source_file::Locator; /// /// let locator = Locator::new("First line\nsecond line\r\nthird line"); @@ -246,7 +246,7 @@ impl<'a> Locator<'a> { /// ## Examples /// /// ``` - /// # use ruff_text_size::{TextRange, TextSize}; + /// # use ruff_text_size::{Ranged, TextRange, TextSize}; /// # use ruff_source_file::Locator; /// /// let locator = Locator::new("First line\nsecond line\r\nthird line"); @@ -278,7 +278,7 @@ impl<'a> Locator<'a> { /// ## Examples /// /// ``` - /// # use ruff_text_size::{TextRange, TextSize}; + /// # use ruff_text_size::{Ranged, TextRange, TextSize}; /// # use ruff_source_file::Locator; /// /// let locator = Locator::new("First line\nsecond line\r\nthird line"); @@ -302,7 +302,7 @@ impl<'a> Locator<'a> { /// Returns true if the text of `range` contains any line break. /// /// ``` - /// # use ruff_text_size::{TextRange, TextSize}; + /// # use ruff_text_size::{Ranged, TextRange, TextSize}; /// # use ruff_source_file::Locator; /// /// let locator = Locator::new("First line\nsecond line\r\nthird line"); @@ -327,7 +327,7 @@ impl<'a> Locator<'a> { /// ## Examples /// /// ``` - /// # use ruff_text_size::{TextRange, TextSize}; + /// # use ruff_text_size::{Ranged, TextRange, TextSize}; /// # use ruff_source_file::Locator; /// /// let locator = Locator::new("First line\nsecond line\r\nthird line"); @@ -355,7 +355,7 @@ impl<'a> Locator<'a> { /// ## Examples /// /// ``` - /// # use ruff_text_size::{TextRange, TextSize}; + /// # use ruff_text_size::{Ranged, TextRange, TextSize}; /// # use ruff_source_file::Locator; /// /// let locator = Locator::new("First line\nsecond line\r\nthird line"); diff --git a/crates/ruff_text_size/src/lib.rs b/crates/ruff_text_size/src/lib.rs index fd27c65523eb8..ea1b197dfaa6a 100644 --- a/crates/ruff_text_size/src/lib.rs +++ b/crates/ruff_text_size/src/lib.rs @@ -28,7 +28,7 @@ mod schemars_impls; #[cfg(feature = "serde")] mod serde_impls; -pub use crate::{range::TextRange, size::TextSize, traits::TextLen}; +pub use crate::{range::TextRange, size::TextSize, traits::Ranged, traits::TextLen}; #[cfg(target_pointer_width = "16")] compile_error!("text-size assumes usize >= u32 and does not work on 16-bit targets"); diff --git a/crates/ruff_text_size/src/range.rs b/crates/ruff_text_size/src/range.rs index 2703bf3b6ed8a..aa51734549837 100644 --- a/crates/ruff_text_size/src/range.rs +++ b/crates/ruff_text_size/src/range.rs @@ -352,7 +352,7 @@ impl TextRange { /// ## Examples /// /// ``` - /// use ruff_text_size::{TextRange, TextSize}; + /// use ruff_text_size::{Ranged, TextRange, TextSize}; /// /// let range = TextRange::new(TextSize::from(5), TextSize::from(10)); /// assert_eq!(range.sub_start(TextSize::from(2)), TextRange::new(TextSize::from(3), TextSize::from(10))); @@ -371,7 +371,7 @@ impl TextRange { /// ## Examples /// /// ``` - /// use ruff_text_size::{TextRange, TextSize}; + /// use ruff_text_size::{Ranged, TextRange, TextSize}; /// /// let range = TextRange::new(TextSize::from(5), TextSize::from(10)); /// assert_eq!(range.add_start(TextSize::from(3)), TextRange::new(TextSize::from(8), TextSize::from(10))); @@ -391,7 +391,7 @@ impl TextRange { /// ## Examples /// /// ``` - /// use ruff_text_size::{TextRange, TextSize}; + /// use ruff_text_size::{Ranged, TextRange, TextSize}; /// /// let range = TextRange::new(TextSize::from(5), TextSize::from(10)); /// assert_eq!(range.sub_end(TextSize::from(2)), TextRange::new(TextSize::from(5), TextSize::from(8))); @@ -411,7 +411,7 @@ impl TextRange { /// ## Examples /// /// ``` - /// use ruff_text_size::{TextRange, TextSize}; + /// use ruff_text_size::{Ranged, TextRange, TextSize}; /// /// let range = TextRange::new(TextSize::from(5), TextSize::from(10)); /// assert_eq!(range.add_end(TextSize::from(2)), TextRange::new(TextSize::from(5), TextSize::from(12))); diff --git a/crates/ruff_text_size/src/traits.rs b/crates/ruff_text_size/src/traits.rs index 3f5261bfd80e3..cec7d72190dab 100644 --- a/crates/ruff_text_size/src/traits.rs +++ b/crates/ruff_text_size/src/traits.rs @@ -1,4 +1,4 @@ -use {crate::TextSize, std::convert::TryInto}; +use {crate::TextRange, crate::TextSize, std::convert::TryInto}; use priv_in_pub::Sealed; mod priv_in_pub { @@ -35,3 +35,34 @@ impl TextLen for char { (self.len_utf8() as u32).into() } } + +/// A ranged item in the source text. +pub trait Ranged { + /// The range of this item in the source text. + fn range(&self) -> TextRange; + + /// The start offset of this item in the source text. + fn start(&self) -> TextSize { + self.range().start() + } + + /// The end offset of this item in the source text. + fn end(&self) -> TextSize { + self.range().end() + } +} + +impl Ranged for TextRange { + fn range(&self) -> TextRange { + *self + } +} + +impl Ranged for &T +where + T: Ranged, +{ + fn range(&self) -> TextRange { + T::range(self) + } +}