Introduce a ruff_python_semantic crate (#3865)

This commit is contained in:
Charlie Marsh 2023-04-04 12:50:47 -04:00 committed by GitHub
parent 46bcb1f725
commit d919adc13c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
64 changed files with 267 additions and 225 deletions

View file

@ -13,7 +13,6 @@ use rustpython_parser::{lexer, Mode, Tok};
use smallvec::SmallVec;
use crate::call_path::CallPath;
use crate::context::Context;
use crate::source_code::{Generator, Indexer, Locator, Stylist};
use crate::types::Range;
use crate::visitor;
@ -50,14 +49,6 @@ pub fn unparse_constant(constant: &Constant, stylist: &Stylist) -> String {
generator.generate()
}
/// Return `true` if the `Expr` contains a reference to `${module}.${target}`.
pub fn contains_call_path(ctx: &Context, expr: &Expr, target: &[&str]) -> bool {
any_over_expr(expr, &|expr| {
ctx.resolve_call_path(expr)
.map_or(false, |call_path| call_path.as_slice() == target)
})
}
/// Return `true` if the `Expr` contains an expression that appears to include a
/// side-effect (like a function call).
///