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

Hardening suggestions for codemodder-python / sonar-timezone #803

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/core_codemods/timezone_aware_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ def leave_Call(self, original_node: cst.Call, updated_node: cst.Call):
return updated_node

def _determine_module_and_kwarg(self, original_node: cst.Call):
maybe_name = self.get_aliased_prefix_name(original_node, self._module_name)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaces multiple expressions involving if operator with 'walrus' operator.

if maybe_name:
if maybe_name := self.get_aliased_prefix_name(original_node, self._module_name):
# it's a regular import OR alias import
if maybe_name == self._module_name:
module = "datetime.datetime"
Expand Down