Skip to content

Commit 59b35ac

Browse files
committed
make mypy happy
1 parent 0170ccb commit 59b35ac

8 files changed

Lines changed: 24 additions & 21 deletions

File tree

codeflash/api/aiservice.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,9 @@ def optimize_code_refinement(self, request: list[AIServiceRefinerRequest]) -> li
414414
List of refined optimization candidates
415415
416416
"""
417-
payload = []
417+
payload: list[dict[str, Any]] = []
418418
for opt in request:
419-
item = {
419+
item: dict[str, Any] = {
420420
"optimization_id": opt.optimization_id,
421421
"original_source_code": opt.original_source_code,
422422
"read_only_dependency_code": opt.read_only_dependency_code,

codeflash/benchmarking/plugin/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class Benchmark: # noqa: D106
236236
def __init__(self, request: pytest.FixtureRequest) -> None:
237237
self.request = request
238238

239-
def __call__(self, func, *args, **kwargs): # type: ignore # noqa: ANN001, ANN002, ANN003, ANN204, PGH003
239+
def __call__(self, func, *args, **kwargs): # noqa: ANN001, ANN002, ANN003, ANN204
240240
"""Handle both direct function calls and decorator usage."""
241241
if args or kwargs:
242242
# Used as benchmark(func, *args, **kwargs)

codeflash/code_utils/env_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ def get_cached_gh_event_data() -> dict[str, Any]:
155155
if not event_path:
156156
return {}
157157
with open(event_path, encoding="utf-8") as f: # noqa: PTH123
158-
return json.load(f) # type: ignore # noqa
158+
result: dict[str, Any] = json.load(f)
159+
return result
159160

160161

161162
def is_repo_a_fork() -> bool:

codeflash/code_utils/tabulate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ def tabulate(
649649
headersalign=None,
650650
rowalign=None,
651651
maxheadercolwidths=None,
652-
):
652+
) -> str:
653653
if tabular_data is None:
654654
tabular_data = []
655655

codeflash/context/code_context_extractor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from libcst import CSTNode
4040

4141
from codeflash.context.unused_definition_remover import UsageInfo
42+
from codeflash.languages.base import HelperFunction
4243

4344

4445
def build_testgen_context(
@@ -265,7 +266,7 @@ def get_code_optimization_context_for_language(
265266
target_relative_path = function_to_optimize.file_path
266267

267268
# Group helpers by file path
268-
helpers_by_file: dict[Path, list] = defaultdict(list)
269+
helpers_by_file: dict[Path, list[HelperFunction]] = defaultdict(list)
269270
helper_function_sources = []
270271

271272
for helper in code_context.helper_functions:

codeflash/result/create_pr.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,19 @@ def existing_tests_source_for(
5959
# Include both behavior and benchmarking paths since test results might come from either
6060
instrumented_to_original: dict[Path, Path] = {}
6161
if test_files_registry:
62-
for tf in test_files_registry.test_files:
63-
if tf.original_file_path:
64-
if tf.instrumented_behavior_file_path:
65-
instrumented_to_original[tf.instrumented_behavior_file_path.resolve()] = (
66-
tf.original_file_path.resolve()
62+
for registry_tf in test_files_registry.test_files:
63+
if registry_tf.original_file_path:
64+
if registry_tf.instrumented_behavior_file_path:
65+
instrumented_to_original[registry_tf.instrumented_behavior_file_path.resolve()] = (
66+
registry_tf.original_file_path.resolve()
6767
)
6868
logger.debug(
69-
f"[PR-DEBUG] Mapping (behavior): {tf.instrumented_behavior_file_path.name} -> {tf.original_file_path.name}"
69+
f"[PR-DEBUG] Mapping (behavior): {registry_tf.instrumented_behavior_file_path.name} -> {registry_tf.original_file_path.name}"
7070
)
71-
if tf.benchmarking_file_path:
72-
instrumented_to_original[tf.benchmarking_file_path.resolve()] = tf.original_file_path.resolve()
71+
if registry_tf.benchmarking_file_path:
72+
instrumented_to_original[registry_tf.benchmarking_file_path.resolve()] = registry_tf.original_file_path.resolve()
7373
logger.debug(
74-
f"[PR-DEBUG] Mapping (perf): {tf.benchmarking_file_path.name} -> {tf.original_file_path.name}"
74+
f"[PR-DEBUG] Mapping (perf): {registry_tf.benchmarking_file_path.name} -> {registry_tf.original_file_path.name}"
7575
)
7676

7777
# Resolve all paths to absolute for consistent comparison
@@ -249,19 +249,19 @@ def existing_tests_source_for(
249249
f"{perf_gain}%✅",
250250
]
251251
)
252-
output_existing += tabulate( # type: ignore[no-untyped-call]
252+
output_existing += tabulate(
253253
headers=headers, tabular_data=rows_existing, tablefmt="pipe", colglobalalign=None, preserve_whitespace=True
254254
)
255255
output_existing += "\n"
256256
if len(rows_existing) == 0:
257257
output_existing = ""
258-
output_concolic += tabulate( # type: ignore[no-untyped-call]
258+
output_concolic += tabulate(
259259
headers=headers, tabular_data=rows_concolic, tablefmt="pipe", colglobalalign=None, preserve_whitespace=True
260260
)
261261
output_concolic += "\n"
262262
if len(rows_concolic) == 0:
263263
output_concolic = ""
264-
output_replay += tabulate( # type: ignore[no-untyped-call]
264+
output_replay += tabulate(
265265
headers=headers, tabular_data=rows_replay, tablefmt="pipe", colglobalalign=None, preserve_whitespace=True
266266
)
267267
output_replay += "\n"

codeflash/result/critic.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
MIN_THROUGHPUT_IMPROVEMENT_THRESHOLD,
1313
)
1414
from codeflash.models import models
15+
from codeflash.models.test_type import TestType
1516

1617
if TYPE_CHECKING:
1718
from codeflash.models.models import ConcurrencyMetrics, CoverageData, OptimizedCandidateResult, OriginalCodeBaseline
@@ -200,7 +201,7 @@ def quantity_of_tests_critic(candidate_result: OptimizedCandidateResult | Origin
200201
if pass_count >= MIN_TESTCASE_PASSED_THRESHOLD:
201202
return True
202203
# If one or more tests passed, check if least one of them was a successful REPLAY_TEST
203-
return bool(pass_count >= 1 and report[models.TestType.REPLAY_TEST]["passed"] >= 1) # type: ignore # noqa: PGH003
204+
return bool(pass_count >= 1 and report[TestType.REPLAY_TEST]["passed"] >= 1)
204205

205206

206207
def coverage_critic(original_code_coverage: CoverageData | None) -> bool:

codeflash/verification/comparator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def comparator(orig: Any, new: Any, superset_obj=False) -> bool: # noqa: ANN001
280280
return comparator(dict(orig), dict(new), superset_obj)
281281

282282
if HAS_NUMPY:
283-
import numpy as np # type: ignore # noqa: PGH003
283+
import numpy as np
284284

285285
if isinstance(orig, (np.datetime64, np.timedelta64)):
286286
# Handle NaT (Not a Time) - numpy's equivalent of NaN for datetime
@@ -343,7 +343,7 @@ def comparator(orig: Any, new: Any, superset_obj=False) -> bool: # noqa: ANN001
343343
return (orig != new).nnz == 0
344344

345345
if HAS_PANDAS:
346-
import pandas # type: ignore # noqa: ICN001, PGH003
346+
import pandas # noqa: ICN001
347347

348348
if isinstance(
349349
orig, (pandas.DataFrame, pandas.Series, pandas.Index, pandas.Categorical, pandas.arrays.SparseArray)

0 commit comments

Comments
 (0)