Skip to content

Commit

Permalink
Fix for mypy in 3.7 and 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
hbldh committed Apr 29, 2024
1 parent 0c63e65 commit 9f490c1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
from collections import namedtuple
import sys
from typing import Union

import pytest

import bankid


if sys.version_info < (3, 9):
from typing import Type as GenericType
else:
GenericType = type


@pytest.mark.parametrize(
"exception_class,rfa",
[
Expand All @@ -19,7 +26,7 @@
(bankid.exceptions.BankIDError, None),
],
)
def test_exceptions(exception_class: type[Exception], rfa: Union[int, None]) -> None:
def test_exceptions(exception_class: GenericType[Exception], rfa: Union[int, None]) -> None:
e = exception_class()
assert isinstance(e, bankid.exceptions.BankIDError)
assert e.rfa == rfa
Expand All @@ -38,7 +45,7 @@ def test_exceptions(exception_class: type[Exception], rfa: Union[int, None]) ->
(bankid.exceptions.BankIDError, "Unknown error code"),
],
)
def test_error_class_factory(exception_class: type[Exception], error_code: str) -> None:
def test_error_class_factory(exception_class: GenericType[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]
Expand Down

0 comments on commit 9f490c1

Please sign in to comment.