mirror of https://github.com/astral-sh/ruff
ZeroDivisionError for `complex` too
This commit is contained in:
parent
3aa91a853e
commit
dec1d2e8fc
|
|
@ -143,6 +143,9 @@ bool(1) / False
|
||||||
# error: "Cannot divide object of type `float` by zero"
|
# error: "Cannot divide object of type `float` by zero"
|
||||||
reveal_type(1.0 / 0) # revealed: int | float
|
reveal_type(1.0 / 0) # revealed: int | float
|
||||||
|
|
||||||
|
# error: "Cannot divide object of type `complex` by zero"
|
||||||
|
reveal_type(0j / 0) # revealed: int | float | complex
|
||||||
|
|
||||||
class MyInt(int): ...
|
class MyInt(int): ...
|
||||||
|
|
||||||
# No error for a subclass of int
|
# No error for a subclass of int
|
||||||
|
|
|
||||||
|
|
@ -6444,7 +6444,10 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Type::NominalInstance(instance)
|
Type::NominalInstance(instance)
|
||||||
if matches!(instance.class.known(self.db()), Some(KnownClass::Float)) =>
|
if matches!(
|
||||||
|
instance.class.known(self.db()),
|
||||||
|
Some(KnownClass::Float | KnownClass::Complex)
|
||||||
|
) =>
|
||||||
{
|
{
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue