From 9b71945072c3ce210f4695ef64cc64323cbe4fbe Mon Sep 17 00:00:00 2001 From: Henrik Blidh Date: Mon, 29 Apr 2024 09:46:18 +0200 Subject: [PATCH] Another attempt to fix mypy --- tests/test_exceptions.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index e03bf44..0a5d462 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -1,5 +1,5 @@ +from builtins import type as Type from collections import namedtuple -import sys from typing import Union import pytest @@ -7,10 +7,6 @@ import bankid -if sys.version_info < (3, 9): - from typing import Type as GenericType -else: - GenericType = type @pytest.mark.parametrize( @@ -26,7 +22,7 @@ (bankid.exceptions.BankIDError, None), ], ) -def test_exceptions(exception_class: GenericType[Exception], rfa: Union[int, None]) -> None: +def test_exceptions(exception_class: Type[Exception], rfa: Union[int, None]) -> None: e = exception_class() assert isinstance(e, bankid.exceptions.BankIDError) assert e.rfa == rfa @@ -45,7 +41,7 @@ def test_exceptions(exception_class: GenericType[Exception], rfa: Union[int, Non (bankid.exceptions.BankIDError, "Unknown error code"), ], ) -def test_error_class_factory(exception_class: GenericType[Exception], error_code: str) -> None: +def test_error_class_factory(exception_class: Type[Exception], error_code: str) -> None: MockResponse = namedtuple("MockResponse", ["json"]) response = MockResponse(json=lambda: {"errorCode": error_code}) # error: Argument 1 to "get_json_error_class" has incompatible type "MockResponse@41"; expected "Response" [arg-type]