Skip to content

Commit

Permalink
Another attempt to fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
hbldh committed Apr 29, 2024
1 parent 9f490c1 commit 9b71945
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
from builtins import type as Type
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(
Expand All @@ -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
Expand All @@ -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]
Expand Down

0 comments on commit 9b71945

Please sign in to comment.