Python

Python

By DeepSource

Implicit enumerate calls found PTC-W0060
Anti-pattern
Autofix

Using range(len(...)) is not pythonic. Python does not have not index-based loops. Instead, it uses collection iterators. Python has a built-in method enumerate which adds a counter to an iterable.

Pythagorean calculation detected with sub-optimal numerics PTC-W0028
Anti-pattern
Autofix

Calculating the length of the hypotenuse using the standard formula c = sqrt(a**2 + b**2) may lead to overflow if the two other sides are both very large. Even though c will not be much bigger than max(a, b), either a**2 or b**2 (or both) could be. Thus, the calculation could overflow, even though the result is well within representable range. It is recommended to use the built-in function hypot(a,b) from the math library.

Simplify boolean expression PYL-R1709
Anti-pattern

The boolean expression with redundant pre-python 2.5 ternary syntax is used and can be simplified for better readability. Please look at the issue text for suggestion.

Unnecessary delete statement in a local scope PTC-W0043
Anti-pattern
Autofix

Passing a local variable to a del statement results in that variable being removed from the local namespace. When exiting a function all local variables are deleted, so it is unnecessary to explicitly delete variables in such cases.