StyleFlow icon indicating copy to clipboard operation
StyleFlow copied to clipboard

Fix potential bug risks and fix anti-patterns

Open tusharnankani opened this issue 3 years ago • 1 comments

This PR includes:

  • Remove unused imported modules [Anti-pattern]

  • Remove unnecessary else / elif used after return or raise

    • return statement causes the control flow to be disrupted, making the else / 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: the list/set/dict constructors, which are faster and more readable.
  • 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.

tusharnankani avatar Jan 11 '21 15:01 tusharnankani

@RameenAbdal Any updates?

tusharnankani avatar Jan 13 '21 14:01 tusharnankani