Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
IMladjenovic committed Dec 13, 2024
1 parent 876613c commit f3c9abe
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion backend/src/agents/agent.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from abc import ABC
import json
import logging
from typing import List, Type, TypeVar, Optional
from typing import List, Type, TypeVar
from src.llm import LLM, get_llm
from src.utils.log_publisher import LogPrefix, publish_log_info

Expand Down
1 change: 0 additions & 1 deletion backend/src/agents/materiality_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from pathlib import Path
import logging

from src.agents import agent
from src.llm import LLMFileFromPath
from src.agents import Agent
from src.prompts import PromptEngine
Expand Down
1 change: 0 additions & 1 deletion backend/src/agents/report_agent.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json
import logging

from src.agents import agent
from src.agents import Agent
from src.prompts import PromptEngine

Expand Down
2 changes: 1 addition & 1 deletion backend/src/utils/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def handle_file_upload(file: UploadFile) -> FileUpload:
raise HTTPException(status_code=413, detail=f"File upload must be less than {MAX_FILE_SIZE} bytes")

if not file.filename:
raise HTTPException(status_code=400, detail=f"File upload must have a filename")
raise HTTPException(status_code=400, detail="Filename missing from file upload")

if "application/pdf" == file.content_type:
start_time = time.time()
Expand Down
17 changes: 12 additions & 5 deletions backend/tests/utils/file_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

from src.utils.file_utils import handle_file_upload

def test_handle_file_upload_size():

def test_handle_file_upload_size():
with pytest.raises(HTTPException) as err:
handle_file_upload(UploadFile(file=BinaryIO(), size=15*1024*1024))

Expand All @@ -17,16 +17,24 @@ def test_handle_file_upload_size():


def test_handle_file_upload_unsupported_type():

Check failure on line 19 in backend/tests/utils/file_utils_test.py

View workflow job for this annotation

GitHub Actions / Type Checking Backend

Function declaration "test_handle_file_upload_unsupported_type" is obscured by a declaration of the same name (reportRedeclaration)

headers = Headers({"content-type": "text/html"})
with pytest.raises(HTTPException) as err:
handle_file_upload(UploadFile(file=BinaryIO(), size=15*1024, headers=headers))
handle_file_upload(UploadFile(file=BinaryIO(), size=15*1024, headers=headers, filename="test.txt"))

assert err.value.status_code == 400
assert err.value.detail == 'File upload must be supported type (text/plain or application/pdf)'

def test_handle_file_upload_text(mocker):

def test_handle_file_upload_unsupported_type():

Check failure on line 28 in backend/tests/utils/file_utils_test.py

View workflow job for this annotation

GitHub Actions / Linting Backend

Ruff (F811)

backend/tests/utils/file_utils_test.py:28:5: F811 Redefinition of unused `test_handle_file_upload_unsupported_type` from line 19
headers = Headers({"content-type": "text/html"})
with pytest.raises(HTTPException) as err:
handle_file_upload(UploadFile(file=BytesIO(b"test content"), size=12, headers=headers))

assert err.value.status_code == 400
assert err.value.detail == 'Filename missing from file upload'


def test_handle_file_upload_text(mocker):
mock = mocker.patch("src.utils.file_utils.update_session_file_uploads", MagicMock())

headers = Headers({"content-type": "text/plain"})
Expand All @@ -37,7 +45,6 @@ def test_handle_file_upload_text(mocker):


def test_handle_file_upload_pdf(mocker):

mock = mocker.patch("src.utils.file_utils.update_session_file_uploads", MagicMock())
pdf_mock = mocker.patch("src.utils.file_utils.PdfReader", MagicMock())

Expand Down

0 comments on commit f3c9abe

Please sign in to comment.