unnecessary-cast-to-int (RUF046)
Added in 0.10.0 · Related issues · View source
Fix is always available.
What it does
Checks for int conversions of values that are already integers.
Why is this bad?
Such a conversion is unnecessary.
Known problems
This rule may produce false positives for round, math.ceil, math.floor,
and math.trunc calls when values override the __round__, __ceil__, __floor__,
or __trunc__ operators such that they don't return an integer.
Example
Use instead:
Fix safety
The fix for round, math.ceil, math.floor, and math.truncate is unsafe
because removing the int conversion can change the semantics for values
overriding the __round__, __ceil__, __floor__, or __trunc__ dunder methods
such that they don't return an integer.