Skip to content

Commit c3c6ef3

Browse files
committed
minor update
1 parent 3fb81d8 commit c3c6ef3

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

codeflash/verification/verification_utils.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,34 @@ def delete_multiple_if_name_main(test_ast: ast.Module) -> ast.Module:
3131

3232

3333
class ModifyInspiredTests(ast.NodeTransformer):
34-
"""This isn't being used right now"""
34+
"""Transformer for modifying inspired test classes.
3535
36-
def __init__(self, import_list, test_framework):
36+
Class is currently not in active use.
37+
"""
38+
39+
def __init__(self, import_list: list[ast.AST], test_framework: str) -> None:
3740
self.import_list = import_list
3841
self.test_framework = test_framework
3942

40-
def visit_Import(self, node: ast.Import):
43+
def visit_Import(self, node: ast.Import) -> None:
4144
self.import_list.append(node)
4245

43-
def visit_ImportFrom(self, node: ast.ImportFrom):
46+
def visit_ImportFrom(self, node: ast.ImportFrom) -> None:
4447
self.import_list.append(node)
4548

46-
def visit_ClassDef(self, node: ast.ClassDef):
49+
def visit_ClassDef(self, node: ast.ClassDef) -> ast.ClassDef:
4750
if self.test_framework != "unittest":
4851
return node
4952
found = False
5053
if node.bases:
5154
for base in node.bases:
52-
if isinstance(base, ast.Attribute):
53-
if base.attr == "TestCase" and base.value.id == "unittest":
54-
found = True
55-
break
56-
if isinstance(base, ast.Name):
57-
# TODO: Possibility that this is not a unittest.TestCase
58-
if base.id == "TestCase":
59-
found = True
60-
break
55+
if isinstance(base, ast.Attribute) and base.attr == "TestCase" and base.value.id == "unittest":
56+
found = True
57+
break
58+
# TODO: Check if this is actually a unittest.TestCase
59+
if isinstance(base, ast.Name) and base.id == "TestCase":
60+
found = True
61+
break
6162
if not found:
6263
return node
6364
node.name = node.name + "Inspired"

codeflash/verification/verifier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def merge_unit_tests(unit_test_source: str, inspired_unit_tests: str, test_frame
7171
except SyntaxError as e:
7272
logger.exception(f"Syntax error in code: {e}")
7373
return unit_test_source
74-
import_list: list[ast.stmt] = list()
74+
import_list: list[ast.stmt] = []
7575
modified_ast = ModifyInspiredTests(import_list, test_framework).visit(inspired_unit_tests_ast)
7676
if test_framework == "pytest":
7777
# Because we only want to modify the top level test functions

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,14 @@ ignore = [
176176
"TD003",
177177
"TD004",
178178
"PLR2004",
179-
"UP007"
179+
"UP007",
180+
"N802", # we use a lot of stdlib which follows this convention
180181
]
181182

182183
[tool.ruff.lint.flake8-type-checking]
183184
strict = true
184185
runtime-evaluated-base-classes = ["pydantic.BaseModel"]
185-
runtime-evaluated-decorators = ["pydantic.validate_call"]
186+
runtime-evaluated-decorators = ["pydantic.validate_call", "pydantic.dataclasses.dataclass"]
186187

187188
[tool.ruff.lint.pep8-naming]
188189
classmethod-decorators = [

0 commit comments

Comments
 (0)