diff options
author | Julian Berman <Julian@GrayVines.com> | 2022-08-20 11:20:05 +0300 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2022-08-20 11:24:02 +0300 |
commit | 7215038a88f958d2bd87f694f69d92c84b4c07ae (patch) | |
tree | e1bde3a8a10e94138be0b57e816c43042ef060ec | |
parent | cf3ed2313189b01cd4d7a5950e97f31779d2f1f6 (diff) | |
download | jsonschema-7215038a88f958d2bd87f694f69d92c84b4c07ae.tar.gz |
Fix mypy types for protocols.Validator
iter_errors returns an iterable, and doesn't guarantee it's an
iterator (this is present in the text documentation).
And instances are any Python object, not just dicts.
(CC @sirosen just FYI and in case I made some silly error).
-rw-r--r-- | jsonschema/protocols.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/jsonschema/protocols.py b/jsonschema/protocols.py index 0e96eff..7658a35 100644 --- a/jsonschema/protocols.py +++ b/jsonschema/protocols.py @@ -7,7 +7,7 @@ typing.Protocol classes for jsonschema interfaces. from __future__ import annotations -from typing import TYPE_CHECKING, Any, ClassVar, Iterator +from typing import TYPE_CHECKING, Any, ClassVar, Iterable import sys # doing these imports with `try ... except ImportError` doesn't pass mypy @@ -113,7 +113,7 @@ class Validator(Protocol): is not a known type. """ - def is_valid(self, instance: dict) -> bool: + def is_valid(self, instance: Any) -> bool: """ Check if the instance is valid under the current `schema`. @@ -124,7 +124,7 @@ class Validator(Protocol): False """ - def iter_errors(self, instance: dict) -> Iterator[ValidationError]: + def iter_errors(self, instance: Any) -> Iterable[ValidationError]: r""" Lazily yield each of the validation errors in the given instance. @@ -143,7 +143,7 @@ class Validator(Protocol): [2, 3, 4] is too long """ - def validate(self, instance: dict) -> None: + def validate(self, instance: Any) -> None: """ Check if the instance is valid under the current `schema`. |