Skip to content

Commit 297d9bd

Browse files
committed
apply pre-commit lint fixes
1 parent 2c49ec7 commit 297d9bd

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

codeflash/api/aiservice.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def optimize_python_code( # noqa: D417
107107
"python_version": platform.python_version(),
108108
"experiment_metadata": experiment_metadata,
109109
"codeflash_version": codeflash_version,
110-
"current_username" : get_last_commit_author_if_pr_exists(None),
110+
"current_username": get_last_commit_author_if_pr_exists(None),
111111
"repo_owner": git_repo_owner,
112112
"repo_name": git_repo_name,
113113
}

codeflash/api/cfapi.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,13 @@ def add_code_context_hash(code_context_hash: str) -> None:
225225
{"owner": owner, "repo": repo, "pr_number": pr_number, "code_hash": code_context_hash},
226226
)
227227

228-
def mark_optimization_success(trace_id: str, is_optimization_found: bool) -> Response:
228+
229+
def mark_optimization_success(trace_id: str, *, is_optimization_found: bool) -> Response:
229230
"""Mark an optimization event as success or not.
230231
231232
:param trace_id: The unique identifier for the optimization event.
232233
:param is_optimization_found: Boolean indicating whether the optimization was found.
233234
:return: The response object from the API.
234235
"""
235-
payload = {
236-
"trace_id": trace_id,
237-
"is_optimization_found": is_optimization_found,
238-
}
239-
return make_cfapi_request(
240-
endpoint="/mark-as-success", method="POST", payload=payload
241-
)
236+
payload = {"trace_id": trace_id, "is_optimization_found": is_optimization_found}
237+
return make_cfapi_request(endpoint="/mark-as-success", method="POST", payload=payload)

codeflash/code_utils/git_utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,17 @@ def remove_git_worktrees(worktree_root: Path | None, worktrees: list[Path]) -> N
180180

181181

182182
def get_last_commit_author_if_pr_exists(repo: Repo | None = None) -> str | None:
183-
"""
184-
Return the author's name of the last commit in the current branch if PR_NUMBER is set.
183+
"""Return the author's name of the last commit in the current branch if PR_NUMBER is set.
184+
185185
Otherwise, return None.
186186
"""
187+
if "PR_NUMBER" not in os.environ:
188+
return None
187189
try:
188-
if "PR_NUMBER" not in os.environ:
189-
return None
190-
191190
repository: Repo = repo if repo else git.Repo(search_parent_directories=True)
192191
last_commit = repository.head.commit
193-
return last_commit.author.name
194-
except Exception as e:
192+
except Exception:
195193
logger.exception("Failed to get last commit author.")
196194
return None
195+
else:
196+
return last_commit.author.name

codeflash/optimization/function_optimizer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,7 @@ def optimize_function(self) -> Result[BestOptimization, str]: # noqa: PLR0911
390390
else:
391391
# Mark optimization success since no PR will be created
392392
mark_optimization_success(
393-
trace_id=self.function_trace_id,
394-
is_optimization_found=best_optimization is not None
393+
trace_id=self.function_trace_id, is_optimization_found=best_optimization is not None
395394
)
396395
self.log_successful_optimization(explanation, generated_tests, exp_type)
397396

0 commit comments

Comments
 (0)