mirror of https://github.com/astral-sh/ruff
Avoid false-positive in chained type calls (#2663)
This commit is contained in:
parent
9f9f25ff7c
commit
7482a4a5b8
|
|
@ -10,3 +10,4 @@ y = x.dtype.type(0.0)
|
|||
# OK
|
||||
type = lambda *args, **kwargs: None
|
||||
type("")
|
||||
type(arg)(" ")
|
||||
|
|
|
|||
|
|
@ -2280,7 +2280,7 @@ where
|
|||
|
||||
// pyupgrade
|
||||
if self.settings.rules.enabled(&Rule::TypeOfPrimitive) {
|
||||
pyupgrade::rules::type_of_primitive(self, expr, func, args);
|
||||
pyupgrade::rules::type_of_primitive(self, expr, args);
|
||||
}
|
||||
if self.settings.rules.enabled(&Rule::DeprecatedUnittestAlias) {
|
||||
pyupgrade::rules::deprecated_unittest_alias(self, func);
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ impl AlwaysAutofixableViolation for TypeOfPrimitive {
|
|||
}
|
||||
|
||||
/// UP003
|
||||
pub fn type_of_primitive(checker: &mut Checker, expr: &Expr, func: &Expr, args: &[Expr]) {
|
||||
pub fn type_of_primitive(checker: &mut Checker, expr: &Expr, args: &[Expr]) {
|
||||
if args.len() != 1 {
|
||||
return;
|
||||
}
|
||||
if !checker
|
||||
.resolve_call_path(func)
|
||||
.resolve_call_path(expr)
|
||||
.map_or(false, |call_path| call_path.as_slice() == ["", "type"])
|
||||
{
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in New Issue