33import json
44import os
55import sys
6- import git
76from functools import lru_cache
87from pathlib import Path
9- from typing import TYPE_CHECKING , Any , Dict , Optional , Tuple , List
8+ from typing import TYPE_CHECKING , Any , Optional
109
10+ import git
1111import requests
1212import sentry_sdk
1313from pydantic .json import pydantic_encoder
1414
1515from codeflash .cli_cmds .console import console , logger
1616from codeflash .code_utils .env_utils import ensure_codeflash_api_key , get_codeflash_api_key , get_pr_number
17- from codeflash .version import __version__
1817from codeflash .code_utils .git_utils import get_repo_owner_and_name
18+ from codeflash .version import __version__
1919
2020if TYPE_CHECKING :
2121 from requests import Response
@@ -194,7 +194,9 @@ def get_blocklisted_functions() -> dict[str, set[str]] | dict[str, Any]:
194194 return {Path (k ).name : {v .replace ("()" , "" ) for v in values } for k , values in content .items ()}
195195
196196
197- def is_function_being_optimized_again (owner : str , repo : str , pr_number : int , code_contexts : List [Dict [str , str ]]) -> Dict :
197+ def is_function_being_optimized_again (
198+ owner : str , repo : str , pr_number : int , code_contexts : list [dict [str , str ]]
199+ ) -> dict :
198200 """Check if the function being optimized is being optimized again."""
199201 response = make_cfapi_request (
200202 "/is-already-optimized" ,
@@ -204,8 +206,9 @@ def is_function_being_optimized_again(owner: str, repo: str, pr_number: int, cod
204206 response .raise_for_status ()
205207 return response .json ()
206208
207- def add_code_context_hash ( code_context_hash : str ):
208- """Add code context to the DB cache"""
209+
210+ def add_code_context_hash (code_context_hash : str ) -> None :
211+ """Add code context to the DB cache."""
209212 pr_number = get_pr_number ()
210213 if pr_number is None :
211214 return
@@ -215,16 +218,9 @@ def add_code_context_hash( code_context_hash: str):
215218 except git .exc .InvalidGitRepositoryError :
216219 return
217220
218-
219221 if owner and repo and pr_number is not None :
220222 make_cfapi_request (
221223 "/add-code-hash" ,
222224 "POST" ,
223- {
224- "owner" : owner ,
225- "repo" : repo ,
226- "pr_number" : pr_number ,
227- "code_context_hash" : code_context_hash
228- }
225+ {"owner" : owner , "repo" : repo , "pr_number" : pr_number , "code_hash" : code_context_hash },
229226 )
230-
0 commit comments