Skip to content

Commit

Permalink
Move refurb/helpers utils to ruff_python_semantic for broader use (
Browse files Browse the repository at this point in the history
…#6990)

## Summary

The utils added for `refurb` in its `helpers.rs` file could be useful
for many other plugins. (Such as the PERF4XX codes, see e.g.
#6132 ).

This PR moves them to `ruff_python_semantic::analyzers::typing` as
suggested in
#6132 (comment)

## Test Plan

Confirmed `refurb` and all other tests still work
  • Loading branch information
qdegraaf authored Aug 29, 2023
1 parent 5de95d7 commit f3aaf84
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 199 deletions.
193 changes: 0 additions & 193 deletions crates/ruff/src/rules/refurb/helpers.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/ruff/src/rules/refurb/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Rules from [refurb](https://pypi.org/project/refurb/)/
mod helpers;
pub(crate) mod rules;

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use ruff_python_ast::comparable::ComparableExpr;
use ruff_python_ast::helpers::contains_effect;
use ruff_python_ast::{self as ast, CmpOp, Expr, Stmt};
use ruff_python_codegen::Generator;
use ruff_python_semantic::analyze::typing::is_set;
use ruff_text_size::{Ranged, TextRange};

use crate::autofix::snippet::SourceCodeSnippet;
use crate::checkers::ast::Checker;
use crate::registry::AsRule;
use crate::rules::refurb::helpers::is_set;

/// ## What it does
/// Checks for uses of `set#remove` that can be replaced with `set#discard`.
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff/src/rules/refurb/rules/delete_full_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::{self as ast, Expr};
use ruff_python_codegen::Generator;
use ruff_python_semantic::analyze::typing::{is_dict, is_list};
use ruff_python_semantic::{Binding, SemanticModel};
use ruff_text_size::{Ranged, TextRange};

use crate::checkers::ast::Checker;
use crate::registry::AsRule;
use crate::rules::refurb::helpers::{is_dict, is_list};

/// ## What it does
/// Checks for `del` statements that delete the entire slice of a list or
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff/src/rules/refurb/rules/repeated_append.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_ast::{self as ast, Expr, Stmt};
use ruff_python_codegen::Generator;
use ruff_python_semantic::analyze::typing::is_list;
use ruff_python_semantic::{Binding, BindingId, DefinitionId, SemanticModel};
use ruff_text_size::{Ranged, TextRange};

use crate::autofix::snippet::SourceCodeSnippet;
use crate::checkers::ast::Checker;
use crate::registry::AsRule;
use crate::rules::refurb::helpers::is_list;

/// ## What it does
/// Checks for consecutive calls to `append`.
Expand Down
Loading

0 comments on commit f3aaf84

Please sign in to comment.