From 7d8ed2d102e3f7c2746ed148f029ff27f79a2610 Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Wed, 1 Oct 2025 02:23:53 +0530 Subject: [PATCH] ruff-fix --- tests/llm/handlers/test_base.py | 1 - tests/llm/handlers/test_google.py | 1 - tests/llm/handlers/test_handler_creator.py | 1 - tests/llm/handlers/test_openai.py | 2 -- tests/llm/test_google_llm.py | 1 - tests/llm/test_openai_llm.py | 1 - tests/parser/file/test_html_parser.py | 1 - tests/parser/file/test_image_parser.py | 1 - tests/parser/file/test_json_parser.py | 4 ++-- tests/parser/file/test_markdown_parser.py | 10 ++++++---- tests/parser/file/test_pptx_parser.py | 6 ++++-- 11 files changed, 12 insertions(+), 17 deletions(-) diff --git a/tests/llm/handlers/test_base.py b/tests/llm/handlers/test_base.py index 30d987f9..8e70793c 100644 --- a/tests/llm/handlers/test_base.py +++ b/tests/llm/handlers/test_base.py @@ -1,4 +1,3 @@ -import pytest from unittest.mock import Mock, patch from typing import Any, Dict, Generator diff --git a/tests/llm/handlers/test_google.py b/tests/llm/handlers/test_google.py index 78e5d940..8fc00e1e 100644 --- a/tests/llm/handlers/test_google.py +++ b/tests/llm/handlers/test_google.py @@ -1,4 +1,3 @@ -import pytest from unittest.mock import Mock, patch from types import SimpleNamespace import uuid diff --git a/tests/llm/handlers/test_handler_creator.py b/tests/llm/handlers/test_handler_creator.py index a2e50667..eea098df 100644 --- a/tests/llm/handlers/test_handler_creator.py +++ b/tests/llm/handlers/test_handler_creator.py @@ -1,4 +1,3 @@ -import pytest from application.llm.handlers.handler_creator import LLMHandlerCreator from application.llm.handlers.base import LLMHandler diff --git a/tests/llm/handlers/test_openai.py b/tests/llm/handlers/test_openai.py index 5b9c4a11..86ad5096 100644 --- a/tests/llm/handlers/test_openai.py +++ b/tests/llm/handlers/test_openai.py @@ -1,5 +1,3 @@ -import pytest -from unittest.mock import Mock from types import SimpleNamespace from application.llm.handlers.openai import OpenAILLMHandler diff --git a/tests/llm/test_google_llm.py b/tests/llm/test_google_llm.py index 7cb0ce6f..0862c727 100644 --- a/tests/llm/test_google_llm.py +++ b/tests/llm/test_google_llm.py @@ -1,4 +1,3 @@ -import sys import types import pytest diff --git a/tests/llm/test_openai_llm.py b/tests/llm/test_openai_llm.py index 0b049f0a..82596359 100644 --- a/tests/llm/test_openai_llm.py +++ b/tests/llm/test_openai_llm.py @@ -1,4 +1,3 @@ -import json import types import pytest diff --git a/tests/parser/file/test_html_parser.py b/tests/parser/file/test_html_parser.py index 5d71a74b..1bbfd21d 100644 --- a/tests/parser/file/test_html_parser.py +++ b/tests/parser/file/test_html_parser.py @@ -27,7 +27,6 @@ def test_html_parser_parse_file(): mock_doc.page_content = "Extracted HTML content" mock_doc.metadata = {"source": "test.html"} - import types, sys fake_lc = types.ModuleType("langchain_community") fake_dl = types.ModuleType("langchain_community.document_loaders") diff --git a/tests/parser/file/test_image_parser.py b/tests/parser/file/test_image_parser.py index c5df48b4..0af66b93 100644 --- a/tests/parser/file/test_image_parser.py +++ b/tests/parser/file/test_image_parser.py @@ -1,4 +1,3 @@ -import pytest from pathlib import Path from unittest.mock import patch, MagicMock, mock_open diff --git a/tests/parser/file/test_json_parser.py b/tests/parser/file/test_json_parser.py index 68f0f6dd..93b8381c 100644 --- a/tests/parser/file/test_json_parser.py +++ b/tests/parser/file/test_json_parser.py @@ -1,4 +1,3 @@ -import pytest from pathlib import Path from unittest.mock import patch, mock_open @@ -40,7 +39,8 @@ def test_json_parser_row_joiner_config(): def test_json_parser_forwards_json_config(): - pf = lambda s: 1.23 + def pf(s): + return 1.23 parser = JSONParser(json_config={"parse_float": pf}) with patch("builtins.open", mock_open(read_data="[]")): with patch("json.load", return_value=[]) as mock_load: diff --git a/tests/parser/file/test_markdown_parser.py b/tests/parser/file/test_markdown_parser.py index 69aff387..826671f3 100644 --- a/tests/parser/file/test_markdown_parser.py +++ b/tests/parser/file/test_markdown_parser.py @@ -2,17 +2,19 @@ from pathlib import Path from unittest.mock import mock_open, patch import pytest +import tiktoken + +from application.parser.file.markdown_parser import MarkdownParser + class _Enc: def encode(self, s: str): return list(s) + @pytest.fixture(autouse=True) def _patch_tokenizer(monkeypatch): - import application.parser.file.markdown_parser as mdp - monkeypatch.setattr(mdp.tiktoken, "get_encoding", lambda _: _Enc()) - -from application.parser.file.markdown_parser import MarkdownParser + monkeypatch.setattr(tiktoken, "get_encoding", lambda _: _Enc()) def test_markdown_init_parser(): parser = MarkdownParser() diff --git a/tests/parser/file/test_pptx_parser.py b/tests/parser/file/test_pptx_parser.py index 1ea415c2..720db389 100644 --- a/tests/parser/file/test_pptx_parser.py +++ b/tests/parser/file/test_pptx_parser.py @@ -30,7 +30,8 @@ def _fake_presentation_with(slides_shapes_texts): def test_pptx_parser_concat_true(): slides = [["Hello ", "World"], ["Slide2"]] FakePres = _fake_presentation_with(slides) - import sys, types + import sys + import types fake_pptx = types.ModuleType("pptx") fake_pptx.Presentation = FakePres parser = PPTXParser() @@ -42,7 +43,8 @@ def test_pptx_parser_concat_true(): def test_pptx_parser_list_mode(): slides = [[" A ", "B"], [" C "]] FakePres = _fake_presentation_with(slides) - import sys, types + import sys + import types fake_pptx = types.ModuleType("pptx") fake_pptx.Presentation = FakePres parser = PPTXParser()