Skip to content

Commit c4ed6e3

Browse files
committed
fix: resolve pre-existing mypy errors in PrComment, concolic_utils, pytest_parallelization
- PrComment.py: rename loop variable to avoid shadowing the result dict - concolic_utils.py: add None guard for tree, annotate new_body as list[ast.stmt] - pytest_parallelization.py: separate set/list variables, annotate result_groups
1 parent 773e5a5 commit c4ed6e3

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

codeflash/code_utils/concolic_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ def clean_concolic_tests(test_suite_code: str) -> str:
105105
can_parse = False
106106
tree = None
107107

108-
if not can_parse:
108+
if not can_parse or tree is None:
109109
return AssertCleanup().transform_asserts(test_suite_code)
110110

111111
for node in ast.walk(tree):
112112
if isinstance(node, ast.FunctionDef) and node.name.startswith("test_"):
113-
new_body = []
113+
new_body: list[ast.stmt] = []
114114
for stmt in node.body:
115115
if isinstance(stmt, ast.Assert):
116116
if isinstance(stmt.test, ast.Compare) and isinstance(stmt.test.left, ast.Call):

codeflash/github/PrComment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ class PrComment:
2626

2727
def to_json(self) -> dict[str, Union[str, int, dict[str, dict[str, int]], list[BenchmarkDetail], None]]:
2828
report_table: dict[str, dict[str, int]] = {}
29-
for test_type, result in self.winning_behavior_test_results.get_test_pass_fail_report_by_type().items():
29+
for test_type, counts in self.winning_behavior_test_results.get_test_pass_fail_report_by_type().items():
3030
name = test_type.to_name()
3131
if name:
32-
report_table[name] = result
32+
report_table[name] = counts
3333

3434
result: dict[str, Union[str, int, dict[str, dict[str, int]], list[BenchmarkDetail], None]] = {
3535
"optimization_explanation": self.optimization_explanation,

codeflash/tracing/pytest_parallelization.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def pytest_split(
3333

3434
except ImportError:
3535
return None, None
36-
test_files = set()
36+
test_files_set: set[str] = set()
3737

3838
# Find all test_*.py files recursively in the directory
3939
for test_path in test_paths:
@@ -42,20 +42,20 @@ def pytest_split(
4242
return None, None
4343
if _test_path.is_dir():
4444
# Find all test files matching the pattern test_*.py
45-
test_files.update(map(str, _test_path.rglob("test_*.py")))
46-
test_files.update(map(str, _test_path.rglob("*_test.py")))
45+
test_files_set.update(map(str, _test_path.rglob("test_*.py")))
46+
test_files_set.update(map(str, _test_path.rglob("*_test.py")))
4747
elif _test_path.is_file():
48-
test_files.add(str(_test_path))
48+
test_files_set.add(str(_test_path))
4949

50-
if not test_files:
50+
if not test_files_set:
5151
return [[]], None
5252

5353
# Determine number of splits
5454
if num_splits is None:
5555
num_splits = os.cpu_count() or 4
5656

5757
# randomize to increase chances of all splits being balanced
58-
test_files = list(test_files)
58+
test_files = list(test_files_set)
5959
shuffle(test_files)
6060

6161
# Apply limit if specified
@@ -75,7 +75,7 @@ def pytest_split(
7575
chunk_size = ceil(total_files / num_splits)
7676

7777
# Initialize result groups
78-
result_groups = [[] for _ in range(num_splits)]
78+
result_groups: list[list[str]] = [[] for _ in range(num_splits)]
7979

8080
# Distribute files across groups
8181
for i, test_file in enumerate(test_files):

0 commit comments

Comments
 (0)