mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 05:45:24 +00:00
[red-knot] don't emit divide-by-zero error if we can't be sure (#13799)
If the LHS is just `int` or `float` type, that type includes custom subclasses which can arbitrarily override division behavior, so we shouldn't emit a divide-by-zero error in those cases. Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
5e6de4e0c6
commit
5c537b6dbb
2 changed files with 13 additions and 5 deletions
|
@ -540,9 +540,6 @@ impl<'db> TypeInferenceBuilder<'db> {
|
|||
fn check_division_by_zero(&mut self, expr: &ast::ExprBinOp, left: Type<'db>) {
|
||||
match left {
|
||||
Type::IntLiteral(_) => {}
|
||||
Type::Instance(cls)
|
||||
if cls.is_known(self.db, KnownClass::Float)
|
||||
|| cls.is_known(self.db, KnownClass::Int) => {}
|
||||
_ => return,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue