diff --git a/src/canonicaljson/__init__.py b/src/canonicaljson/__init__.py index d481262..ef33332 100644 --- a/src/canonicaljson/__init__.py +++ b/src/canonicaljson/__init__.py @@ -15,12 +15,12 @@ # limitations under the License. import platform -from typing import Any, Generator, Optional, Type +from typing import Any, Generator, Iterator, Optional, Type try: from typing import Protocol except ImportError: # pragma: no cover - from typing_extensions import Protocol # type: ignore[misc] + from typing_extensions import Protocol # type: ignore[assignment] frozendict_type: Optional[Type[Any]] try: @@ -44,15 +44,17 @@ class Encoder(Protocol): # pragma: no cover def encode(self, data: object) -> str: pass - def iterencode(self, data: object) -> Generator[str, None, None]: + def iterencode(self, data: object) -> Iterator[str]: pass - def __call__(self, *args: Any, **kwargs: Any) -> "Encoder": + def __init__(self, *args: Any, **kwargs: Any) -> None: pass -class JsonLibrary(Protocol): - JSONEncoder: Encoder +class JsonLibrary(Protocol): # pragma: no cover + @property + def JSONEncoder(self) -> Type[Encoder]: + pass # Declare these in the module scope, but they get configured in diff --git a/tox.ini b/tox.ini index bdbf91e..a893107 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = packaging, pep8, black, py37, py38, py39, py310, pypy3 +envlist = packaging, pep8, black, py37, py38, py39, py310, pypy3, mypy, isort isolated_build = True [testenv:py] @@ -32,7 +32,7 @@ commands = python -m black --check --diff src tests [testenv:mypy] deps = - mypy==0.942 + mypy==1.0 types-frozendict==2.0.8 types-simplejson==3.17.5 types-setuptools==57.4.14