Commit ad6f023b authored by Jan Reimes's avatar Jan Reimes
Browse files

refactor(runner): remove redundant import of functools in Runner class

* Cleaned up import statements by removing duplicate import of functools.
* Improved code readability and maintainability.
parent c2a9e389
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
from __future__ import annotations

import asyncio
import functools
from collections.abc import Callable
from concurrent.futures import Executor
from typing import Any, TypeVar
@@ -85,8 +86,6 @@ class Runner:

        # Run function in executor
        if kwargs:
            import functools

            return await self._loop.run_in_executor(self._executor, functools.partial(func, *args, **kwargs))
        return await self._loop.run_in_executor(self._executor, func, *args)

+2 −2
Original line number Diff line number Diff line
@@ -168,9 +168,9 @@ def checkout_tdoc(
            with suppress(FileNotFoundError):
                (downloads_dir / filename).unlink()

    import importlib
    import importlib  # noqa: PLC0415

    from tdoc_crawler.cli.helpers import prepare_tdoc_file
    from tdoc_crawler.cli.helpers import prepare_tdoc_file  # noqa: PLC0415

    cli_helpers = importlib.import_module("tdoc_crawler.cli.helpers")
    original_download = cli_helpers.download_to_path
+1 −12
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

from __future__ import annotations

from decimal import Decimal
from pathlib import Path
from unittest.mock import MagicMock, patch

@@ -453,10 +454,6 @@ class TestOpenCommand:
        5. whatthespec returns valid metadata
        6. TDoc is inserted and file is opened
        """
        from decimal import Decimal

        from tdoc_crawler.models import TDocMetadata

        mock_db = MagicMock(spec=TDocDatabase)
        mock_db_class.return_value.__enter__.return_value = mock_db
        # Database returns no results initially
@@ -536,10 +533,6 @@ class TestOpenCommand:
        3. whatthespec resolver provides metadata
        4. TDoc is opened without requiring portal credentials
        """
        from decimal import Decimal

        from tdoc_crawler.models import TDocMetadata

        mock_db = MagicMock(spec=TDocDatabase)
        mock_db_class.return_value.__enter__.return_value = mock_db
        mock_db.query_tdocs.return_value = []
@@ -620,10 +613,6 @@ class TestCheckoutCommand:
        4. whatthespec fallback resolves TDocs
        5. checkout_tdoc called for resolved TDocs
        """
        from decimal import Decimal

        from tdoc_crawler.models import TDocMetadata

        mock_db = MagicMock(spec=TDocDatabase)
        mock_db_class.return_value.__enter__.return_value = mock_db
        mock_db.query_tdocs.return_value = []
+2 −2
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ class TestMeetingDocumentList:
        with pytest.raises(Exception):  # DocumentListError or pandas error
            parse_excel_document_list(excel_content, meeting_id=12345)

    def test_fetch_meeting_document_list_network_error(self) -> None:
    def test_fetch_meeting_document_list_network_error(self, tmp_path: Path) -> None:
        """Test handling of network errors."""
        with patch("tdoc_crawler.crawlers.meeting_doclist.create_cached_session") as mock_session:
            mock_response = MagicMock()
@@ -117,7 +117,7 @@ class TestMeetingDocumentList:
            with pytest.raises(DocumentListError):
                fetch_meeting_document_list(
                    meeting_id=12345,
                    cache_dir=Path("/tmp"),
                    cache_dir=tmp_path,
                )

    def test_hybrid_crawler_document_list_only(self) -> None: