Skip to content

Commit d12553c

Browse files
authored
Merge pull request #1195 from codeflash-ai/liniting_issues
remove ignored linting issues
2 parents 7bf9f99 + 1d3aeb9 commit d12553c

48 files changed

Lines changed: 185 additions & 223 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

codeflash/api/aiservice.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def optimize_python_code_line_profiler( # noqa: D417
253253
line_profiler_results: str,
254254
n_candidates: int,
255255
experiment_metadata: ExperimentMetadata | None = None,
256-
is_numerical_code: bool | None = None, # noqa: FBT001
256+
is_numerical_code: bool | None = None,
257257
) -> list[OptimizedCandidate]:
258258
"""Optimize the given python code for performance using line profiler results.
259259
@@ -646,7 +646,7 @@ def generate_regression_tests( # noqa: D417
646646
test_timeout: int,
647647
trace_id: str,
648648
test_index: int,
649-
is_numerical_code: bool | None = None, # noqa: FBT001
649+
is_numerical_code: bool | None = None,
650650
) -> tuple[str, str, str] | None:
651651
"""Generate regression tests for the given function by making a request to the Django endpoint.
652652
@@ -706,7 +706,7 @@ def generate_regression_tests( # noqa: D417
706706
error = response.json()["error"]
707707
logger.error(f"Error generating tests: {response.status_code} - {error}")
708708
ph("cli-testgen-error-response", {"response_status_code": response.status_code, "error": error})
709-
return None # noqa: TRY300
709+
return None
710710
except Exception:
711711
logger.error(f"Error generating tests: {response.status_code} - {response.text}")
712712
ph("cli-testgen-error-response", {"response_status_code": response.status_code, "error": response.text})
@@ -722,7 +722,6 @@ def get_optimization_review(
722722
function_trace_id: str,
723723
coverage_message: str,
724724
replay_tests: str,
725-
concolic_tests: str, # noqa: ARG002
726725
calling_fn_details: str,
727726
) -> OptimizationReviewResult:
728727
"""Compute the optimization review of current Pull Request.

codeflash/api/cfapi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def make_cfapi_request(
8181
else:
8282
response = requests.get(url, headers=cfapi_headers, params=params, timeout=60)
8383
response.raise_for_status()
84-
return response # noqa: TRY300
84+
return response
8585
except requests.exceptions.HTTPError:
8686
# response may be either a string or JSON, so we handle both cases
8787
error_message = ""
@@ -102,7 +102,7 @@ def make_cfapi_request(
102102

103103

104104
@lru_cache(maxsize=1)
105-
def get_user_id(api_key: Optional[str] = None) -> Optional[str]: # noqa: PLR0911
105+
def get_user_id(api_key: Optional[str] = None) -> Optional[str]:
106106
"""Retrieve the user's userid by making a request to the /cfapi/cli-get-user endpoint.
107107
108108
:param api_key: The API key to use. If None, uses get_codeflash_api_key().
@@ -396,7 +396,7 @@ def get_blocklisted_functions() -> dict[str, set[str]] | dict[str, Any]:
396396

397397
def is_function_being_optimized_again(
398398
owner: str, repo: str, pr_number: int, code_contexts: list[dict[str, str]]
399-
) -> Any: # noqa: ANN401
399+
) -> Any:
400400
"""Check if the function being optimized is being optimized again."""
401401
response = make_cfapi_request(
402402
"/is-already-optimized",

codeflash/benchmarking/codeflash_trace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def __call__(self, func: Callable) -> Callable:
108108
func_id = (func.__module__, func.__name__)
109109

110110
@functools.wraps(func)
111-
def wrapper(*args, **kwargs) -> Any: # noqa: ANN002, ANN003, ANN401
111+
def wrapper(*args, **kwargs) -> Any: # noqa: ANN002, ANN003
112112
# Initialize thread-local active functions set if it doesn't exist
113113
if not hasattr(self._thread_local, "active_functions"):
114114
self._thread_local.active_functions = set()

codeflash/benchmarking/instrument_codeflash_trace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def leave_FunctionDef(self, original_node: FunctionDef, updated_node: FunctionDe
5353

5454
return updated_node
5555

56-
def leave_Module(self, original_node: cst.Module, updated_node: cst.Module) -> cst.Module: # noqa: ARG002
56+
def leave_Module(self, original_node: cst.Module, updated_node: cst.Module) -> cst.Module:
5757
# Create import statement for codeflash_trace
5858
if not self.added_codeflash_trace:
5959
return updated_node

codeflash/benchmarking/plugin/plugin.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def get_function_benchmark_timings(trace_path: Path) -> dict[str, dict[Benchmark
110110

111111
# Process each row
112112
for row in cursor.fetchall():
113-
module_name, class_name, function_name, benchmark_file, benchmark_func, benchmark_line, time_ns = row
113+
module_name, class_name, function_name, benchmark_file, benchmark_func, _benchmark_line, time_ns = row
114114

115115
# Create the function key (module_name.class_name.function_name)
116116
if class_name:
@@ -172,7 +172,7 @@ def get_benchmark_timings(trace_path: Path) -> dict[BenchmarkKey, int]:
172172

173173
# Process overhead information
174174
for row in cursor.fetchall():
175-
benchmark_file, benchmark_func, benchmark_line, total_overhead_ns = row
175+
benchmark_file, benchmark_func, _benchmark_line, total_overhead_ns = row
176176
benchmark_key = BenchmarkKey(module_path=benchmark_file, function_name=benchmark_func)
177177
overhead_by_benchmark[benchmark_key] = total_overhead_ns or 0 # Handle NULL sum case
178178

@@ -184,7 +184,7 @@ def get_benchmark_timings(trace_path: Path) -> dict[BenchmarkKey, int]:
184184

185185
# Process each row and subtract overhead
186186
for row in cursor.fetchall():
187-
benchmark_file, benchmark_func, benchmark_line, time_ns = row
187+
benchmark_file, benchmark_func, _benchmark_line, time_ns = row
188188

189189
# Create the benchmark key (file::function::line)
190190
benchmark_key = BenchmarkKey(module_path=benchmark_file, function_name=benchmark_func)
@@ -200,7 +200,7 @@ def get_benchmark_timings(trace_path: Path) -> dict[BenchmarkKey, int]:
200200

201201
# Pytest hooks
202202
@pytest.hookimpl
203-
def pytest_sessionfinish(self, session, exitstatus) -> None: # noqa: ANN001, ARG002
203+
def pytest_sessionfinish(self, session, exitstatus) -> None: # noqa: ANN001
204204
"""Execute after whole test run is completed."""
205205
# Write any remaining benchmark timings to the database
206206
codeflash_trace.close()
@@ -218,7 +218,7 @@ def pytest_collection_modifyitems(config: pytest.Config, items: list[pytest.Item
218218
skip_no_benchmark = pytest.mark.skip(reason="Test requires benchmark fixture")
219219
for item in items:
220220
# Check for direct benchmark fixture usage
221-
has_fixture = hasattr(item, "fixturenames") and "benchmark" in item.fixturenames
221+
has_fixture = hasattr(item, "fixturenames") and "benchmark" in item.fixturenames # ty:ignore[unsupported-operator]
222222

223223
# Check for @pytest.mark.benchmark marker
224224
has_marker = False
@@ -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)
@@ -249,7 +249,7 @@ def wrapped_func(*args, **kwargs): # noqa: ANN002, ANN003, ANN202
249249
self._run_benchmark(func)
250250
return wrapped_func
251251

252-
def _run_benchmark(self, func, *args, **kwargs): # noqa: ANN001, ANN002, ANN003, ANN202
252+
def _run_benchmark(self, func, *args, **kwargs): # noqa: ANN002, ANN003, ANN202
253253
"""Actual benchmark implementation."""
254254
node_path = getattr(self.request.node, "path", None) or getattr(self.request.node, "fspath", None)
255255
if node_path is None:

codeflash/cli_cmds/cli_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def inquirer_wrapper(func: Callable[..., str | bool], *args: str | bool, **kwarg
4343
return func(*new_args, **new_kwargs)
4444

4545

46-
def split_string_to_cli_width(string: str, is_confirm: bool = False) -> list[str]: # noqa: FBT001, FBT002
46+
def split_string_to_cli_width(string: str, is_confirm: bool = False) -> list[str]:
4747
cli_width, _ = shutil.get_terminal_size()
4848
# split string to lines that accommodate "[?] " prefix
4949
cli_width -= len("[?] ")

codeflash/cli_cmds/cmd_init.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ def create_empty_pyproject_toml(pyproject_toml_path: Path) -> None:
663663
apologize_and_exit()
664664

665665

666-
def install_github_actions(override_formatter_check: bool = False) -> None: # noqa: FBT001, FBT002
666+
def install_github_actions(override_formatter_check: bool = False) -> None:
667667
try:
668668
config, _config_file_path = parse_config_file(override_formatter_check=override_formatter_check)
669669

@@ -1089,11 +1089,12 @@ def install_github_actions(override_formatter_check: bool = False) -> None: # n
10891089
apologize_and_exit()
10901090

10911091

1092-
def determine_dependency_manager(pyproject_data: dict[str, Any]) -> DependencyManager: # noqa: PLR0911
1092+
def determine_dependency_manager(pyproject_data: dict[str, Any]) -> DependencyManager:
10931093
"""Determine which dependency manager is being used based on pyproject.toml contents."""
1094-
if (Path.cwd() / "poetry.lock").exists():
1094+
cwd = Path.cwd()
1095+
if (cwd / "poetry.lock").exists():
10951096
return DependencyManager.POETRY
1096-
if (Path.cwd() / "uv.lock").exists():
1097+
if (cwd / "uv.lock").exists():
10971098
return DependencyManager.UV
10981099
if "tool" not in pyproject_data:
10991100
return DependencyManager.PIP
@@ -1251,10 +1252,7 @@ def collect_repo_files_for_workflow(git_root: Path) -> dict[str, Any]:
12511252

12521253

12531254
def generate_dynamic_workflow_content(
1254-
optimize_yml_content: str,
1255-
config: tuple[dict[str, Any], Path],
1256-
git_root: Path,
1257-
benchmark_mode: bool = False, # noqa: FBT001, FBT002
1255+
optimize_yml_content: str, config: tuple[dict[str, Any], Path], git_root: Path, benchmark_mode: bool = False
12581256
) -> str:
12591257
"""Generate workflow content with dynamic steps from AI service, falling back to static template.
12601258
@@ -1378,10 +1376,7 @@ def generate_dynamic_workflow_content(
13781376

13791377

13801378
def customize_codeflash_yaml_content(
1381-
optimize_yml_content: str,
1382-
config: tuple[dict[str, Any], Path],
1383-
git_root: Path,
1384-
benchmark_mode: bool = False, # noqa: FBT001, FBT002
1379+
optimize_yml_content: str, config: tuple[dict[str, Any], Path], git_root: Path, benchmark_mode: bool = False
13851380
) -> str:
13861381
module_path = str(Path(config["module_root"]).relative_to(git_root) / "**")
13871382
optimize_yml_content = optimize_yml_content.replace("{{ codeflash_module_path }}", module_path)

0 commit comments

Comments
 (0)