mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:47 +00:00
Improve performance of import matching code (#744)
This commit is contained in:
parent
fea029ae35
commit
f67727b13c
13 changed files with 238 additions and 150 deletions
|
@ -7,7 +7,7 @@ use crate::check_ast::Checker;
|
|||
use crate::checks::{Check, CheckCode, CheckKind};
|
||||
|
||||
fn is_sys(checker: &Checker, expr: &Expr, target: &str) -> bool {
|
||||
match_module_member(expr, &format!("sys.{target}"), &checker.from_imports)
|
||||
match_module_member(expr, "sys", target, &checker.from_imports)
|
||||
}
|
||||
|
||||
/// YTT101, YTT102, YTT301, YTT303
|
||||
|
@ -181,7 +181,7 @@ pub fn compare(checker: &mut Checker, left: &Expr, ops: &[Cmpop], comparators: &
|
|||
|
||||
/// YTT202
|
||||
pub fn name_or_attribute(checker: &mut Checker, expr: &Expr) {
|
||||
if match_module_member(expr, "six.PY3", &checker.from_imports) {
|
||||
if match_module_member(expr, "six", "PY3", &checker.from_imports) {
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::SixPY3Referenced,
|
||||
Range::from_located(expr),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue