From fe35c8e8268b9c4ed1875df324a83ecbc62429e9 Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Tue, 26 May 2026 21:18:55 +0000 Subject: [PATCH] test: fix mypy errors in IE-exclude test - annotate monkeypatch fixture as pytest.MonkeyPatch - import invest_engine parser module directly instead of via imap_mod.ie_parser (mypy's strict "no implicit re-export" rule trips on the indirection) Co-Authored-By: Claude Opus 4.7 --- tests/providers/test_imap.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/providers/test_imap.py b/tests/providers/test_imap.py index 1abe587..fcb4a0f 100644 --- a/tests/providers/test_imap.py +++ b/tests/providers/test_imap.py @@ -2,8 +2,12 @@ from __future__ import annotations from datetime import UTC, date, datetime from decimal import Decimal +from typing import TYPE_CHECKING from broker_sync.models import AccountType, Activity, ActivityType + +if TYPE_CHECKING: + from pytest import MonkeyPatch from broker_sync.providers.imap import ( _IE_GIA_ACCOUNT_ID, _IE_ISA_ACCOUNT_ID, @@ -101,11 +105,12 @@ def test_non_ie_activities_passed_through_unchanged() -> None: assert routed[0].account_type is AccountType.GIA -def test_exclude_invest_engine_skips_ie_emails(monkeypatch) -> None: +def test_exclude_invest_engine_skips_ie_emails(monkeypatch: "MonkeyPatch") -> None: """BROKER_SYNC_IMAP_EXCLUDE_PROVIDERS=invest-engine should skip IE messages so we don't duplicate IE buys already ingested via the bearer-token API path. Schwab routing must remain unaffected.""" from broker_sync.providers import imap as imap_mod + from broker_sync.providers.parsers import invest_engine as ie_parser ie_email = ( b"From: noreply@investengine.com\r\n" @@ -120,8 +125,7 @@ def test_exclude_invest_engine_skips_ie_emails(monkeypatch) -> None: b"no-op\r\n" ) monkeypatch.setattr(imap_mod, "_fetch_all", lambda _: [ie_email, schwab_email]) - monkeypatch.setattr(imap_mod.ie_parser, "parse_invest_engine_email", - lambda raw: [object()]) + monkeypatch.setattr(ie_parser, "parse_invest_engine_email", lambda raw: [object()]) monkeypatch.setattr(imap_mod, "parse_schwab_email", lambda html: [object()]) creds = imap_mod.ImapCreds(host="h", user="u", password="p", directory="d")