Skip to content

Commit

Permalink
Small typing and variables cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
andrecsilva committed Nov 9, 2023
1 parent bf49fef commit e604a21
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
8 changes: 1 addition & 7 deletions src/codemodder/codemods/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,7 @@ def __init__(
self,
replacements: dict[
cst.CSTNode,
dict[
str,
cst.CSTNode
| cst.FlattenSentinel
| cst.RemovalSentinel
| dict[str, Any],
],
cst.CSTNode | cst.FlattenSentinel | cst.RemovalSentinel | dict[str, Any],
],
):
self.replacements = replacements
Expand Down
11 changes: 4 additions & 7 deletions src/core_codemods/sql_parameterization.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from typing import Optional, Tuple
from typing import Any, Optional, Tuple
import itertools
import libcst as cst
from libcst import FormattedString, SimpleWhitespace, ensure_type, matchers
Expand Down Expand Up @@ -38,10 +38,6 @@

parameter_token = "?"

literal_number = matchers.Integer() | matchers.Float() | matchers.Imaginary()
literal_string = matchers.SimpleString()
literal = literal_number | literal_string

quote_pattern = re.compile(r"(?<!\\)\\'|(?<!\\)'")
raw_quote_pattern = re.compile(r"(?<!\\)'")

Expand Down Expand Up @@ -78,7 +74,8 @@ def __init__(
*codemod_args,
) -> None:
self.changed_nodes: dict[
cst.CSTNode, cst.CSTNode | cst.RemovalSentinel | cst.FlattenSentinel
cst.CSTNode,
cst.CSTNode | cst.RemovalSentinel | cst.FlattenSentinel | dict[str, Any],
] = {}
BaseCodemod.__init__(self, file_context, *codemod_args)
UtilsMixin.__init__(self, [])
Expand Down Expand Up @@ -237,7 +234,7 @@ def _fix_injection(

new_raw_value = raw_value[quote_span.end() :]
append_raw_value = raw_value[: quote_span.start()]
match end:
match current_end:
case cst.SimpleString():
# gather string up to quote to parameter
if append_raw_value:
Expand Down

0 comments on commit e604a21

Please sign in to comment.