Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential bug risks and fix anti-patterns #32

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Fix potential bug risks and fix anti-patterns #32

wants to merge 6 commits into from

Conversation

tusharnankani
Copy link

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
Copy link
Author

@RameenAbdal Any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant