-
Notifications
You must be signed in to change notification settings - Fork 54
Conversation
- Replace mutable default function parameters - Make function names lower case - Refactor to remove variables that might be referenced before assignment - Add some type hinting - Remove unused variables and imports
The functions that use etlMods module cannot be tested at the moment, so the changes have been reversed
def _handle_response( | ||
batch | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The format of this param looks a bit odd here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely! Thank you for catching this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are a ton of improvements! Thanks for taking care of this.
I left comments with some minor questions but everything seems fine to move on. 🙌
response_json, total_images, tries = None, 0, 0 | ||
for tries in range(retries): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
Apparently, the code problems fixed in this PR do cause errors when running the scripts using Airflow dags, like this:
So, it is important to fix them. |
Signed-off-by: Olga Bulat <[email protected]>
This PR fixes several types of code problems highlighted by Pycharm's code inspection.
Changes:
Replace mutable default parameters
Python creates a default parameter once when the function is defined. The same value is used every time the function is called. This causes a problem if the value is mutable, such as a dictionary or a list. If this value is ever changed inside the function, the changed value is used for subsequent function calls, instead of the default value.
Make function names lower case, separating words with underscores:
sanitize_string
instead ofsanitizeString
Refactor to remove variables that might be referenced before assignment
Remove unused variables and imports
Add some type hinting