Skip to content

Commit

Permalink
remove unused variable in walrus operation
Browse files Browse the repository at this point in the history
  • Loading branch information
clavedeluna committed Jan 30, 2024
1 parent ce4ae84 commit 88bbd84
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/codemodder/dependency_management/setup_py_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def visit_Module(self, _: cst.Module) -> bool:
return is_setup_py_file(self.filename)

def leave_Call(self, original_node: cst.Call, updated_node: cst.Call):
if (true_name := self.find_base_name(original_node.func)) != "setuptools.setup":
if self.find_base_name(original_node.func) != "setuptools.setup":
return original_node

new_args = self.replace_arg(original_node)
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/django_receiver_on_top.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def leave_FunctionDef(
# that that have different start/end numbers.
maybe_receiver_with_index = None
for i, decorator in enumerate(original_node.decorators):
if (true_name := self.find_base_name(decorator.decorator)) == "django.dispatch.receiver":
if self.find_base_name(decorator.decorator) == "django.dispatch.receiver":
maybe_receiver_with_index = (i, decorator)

if maybe_receiver_with_index:
Expand Down
8 changes: 4 additions & 4 deletions src/core_codemods/flask_json_response_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ def _is_tuple_with_json_string_response(
case cst.Tuple():
elements = node.elements
first = elements[0].value
if maybe_vuln := self._is_json_dumps_call(
if self._is_json_dumps_call(first) or self._is_make_response_with_json(
first
) or self._is_make_response_with_json(first):
):
return node
return None

Expand Down Expand Up @@ -152,7 +152,7 @@ def _is_json_dumps_call(self, node: cst.BaseExpression) -> Optional[cst.Call]:
expr = self.resolve_expression(node)
match expr:
case cst.Call():
if (true_name := self.find_base_name(expr)) == "json.dumps":
if self.find_base_name(expr) == "json.dumps":
return expr
return None

Expand All @@ -162,7 +162,7 @@ def _is_make_response_with_json(
expr = self.resolve_expression(node)
match expr:
case cst.Call(args=[cst.Arg(first_arg), *_]):
if (true_name := self.find_base_name(expr)) != "flask.make_response":
if self.find_base_name(expr) != "flask.make_response":
return None
match first_arg:
case cst.Tuple():
Expand Down
2 changes: 1 addition & 1 deletion src/core_codemods/secure_flask_session_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def flask_app_is_assigned(self):
return bool(self.flask_app_name)

def leave_Call(self, original_node: cst.Call, updated_node: cst.Call):
if (true_name := self.find_base_name(original_node.func)) == "flask.Flask":
if self.find_base_name(original_node.func) == "flask.Flask":
self._store_flask_app(original_node)

if self.flask_app_is_assigned and self._is_config_update_call(original_node):
Expand Down

0 comments on commit 88bbd84

Please sign in to comment.