mirror of
https://github.com/codeflash-ai/codeflash.git
synced 2026-05-04 18:25:17 +00:00
style: fix ruff lint errors in cfapi connection error handling
Remove duplicate Response import from TYPE_CHECKING block and remove private _content access (SLF001) by not setting response body on mock 503. Co-authored-by: mohammed ahmed <undefined@users.noreply.github.com>
This commit is contained in:
parent
856f6eed68
commit
36e9090e80
2 changed files with 1 additions and 6 deletions
|
|
@ -9,9 +9,9 @@ from typing import TYPE_CHECKING, Any, Optional
|
|||
|
||||
import git
|
||||
import requests
|
||||
from requests import Response
|
||||
import sentry_sdk
|
||||
from pydantic.json import pydantic_encoder
|
||||
from requests import Response
|
||||
|
||||
from codeflash.cli_cmds.console import console, logger
|
||||
from codeflash.code_utils.code_utils import exit_with_message
|
||||
|
|
@ -22,8 +22,6 @@ from codeflash.lsp.helpers import is_LSP_enabled
|
|||
from codeflash.version import __version__
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from requests import Response
|
||||
|
||||
from codeflash.result.explanation import Explanation
|
||||
|
||||
from packaging import version
|
||||
|
|
@ -112,7 +110,6 @@ def make_cfapi_request(
|
|||
# Create a mock Response object with 503 status to indicate service unavailable
|
||||
mock_response = Response()
|
||||
mock_response.status_code = 503
|
||||
mock_response._content = error_message.encode('utf-8')
|
||||
mock_response.url = url
|
||||
return mock_response
|
||||
|
||||
|
|
|
|||
|
|
@ -49,8 +49,6 @@ class TestMakeCfapiRequest:
|
|||
assert response is not None
|
||||
assert hasattr(response, 'status_code')
|
||||
assert response.status_code == 503
|
||||
assert hasattr(response, 'text')
|
||||
assert 'Connection' in response.text or 'refused' in response.text.lower()
|
||||
|
||||
@patch("codeflash.api.cfapi.get_codeflash_api_key")
|
||||
@patch("requests.post")
|
||||
|
|
|
|||
Loading…
Reference in a new issue