Skip to content

Commit c40ced5

Browse files
committed
fix: add proper type hints to test mocks for mypy
1 parent be171cb commit c40ced5

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

tests/app/test_main.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from contextlib import contextmanager
2+
from typing import Optional
23
from unittest.mock import MagicMock
34

45
import pytest
@@ -64,7 +65,7 @@ def __init__(
6465
self.brevo_client = brevo_client
6566
self.language_list_id = language_list_id
6667
self.non_language_list_id = non_language_list_id
67-
self.sync_called_with = None
68+
self.sync_called_with: Optional[int] = None
6869

6970
def sync(self, max_rows_per_type: int) -> None:
7071
self.sync_called_with = max_rows_per_type
@@ -76,7 +77,7 @@ def __init__(
7677
) -> None:
7778
self.connection = connection
7879
self.brevo_client = brevo_client
79-
self.sync_called_with = None
80+
self.sync_called_with: Optional[int] = None
8081

8182
def sync(self, max_rows: int) -> None:
8283
self.sync_called_with = max_rows
@@ -230,7 +231,10 @@ def fake_configure_logging(log_level: str) -> None:
230231
logger.info = MagicMock()
231232
import logging
232233

233-
logging.getLogger = lambda name: logger
234+
def fake_get_logger(name: Optional[str] = None): # type: ignore[assignment]
235+
return logger
236+
237+
logging.getLogger = fake_get_logger
234238
return None
235239

236240
monkeypatch.setattr(app_main, "load_settings", fake_load_settings)

0 commit comments

Comments
 (0)