StyleFlow
StyleFlow copied to clipboard
Fix potential bug risks and fix anti-patterns
This PR includes:
-
Remove unused imported modules [Anti-pattern]
-
Remove unnecessary
else
/elif
used afterreturn
orraise
-
return
statement causes the control flow to be disrupted, making theelse
/elif
block here unnecessary. This doesn't mean you can not use it, but it is recommended to refactor this for better readability.
-
-
Remove unnecessary use of comprehension.
- It is unnecessary to use a comprehension just to loop over the iterable and create a
list
/set
/dict
out of it. Python has a specialized set of tools for this task: thelist
/set
/dict
constructors, which are faster and more readable.
- It is unnecessary to use a comprehension just to loop over the iterable and create a
-
Changing the default arguments.
- It is recommended not to use a mutable like list or dictionary as a default value to an argument. Python’s default arguments are evaluated once when the function is defined. Using a mutable default argument and mutating it will mutate that object for all future calls to the function as well.
@RameenAbdal Any updates?