Skip to content

Annotate parts of jsonschema.validators #7025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stubs/jsonschema/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "4.3.*"
version = "4.4.*"
19 changes: 10 additions & 9 deletions stubs/jsonschema/jsonschema/_utils.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from typing import Any, Generator, Iterable, Mapping, MutableMapping, Sized
from _typeshed import SupportsKeysAndGetItem
from typing import Any, Generator, Iterable, Iterator, Mapping, MutableMapping, Sized

class URIDict(MutableMapping[Any, Any]):
class URIDict(MutableMapping[str, str]):
def normalize(self, uri: str) -> str: ...
store: dict[Any, Any]
def __init__(self, *args, **kwargs) -> None: ...
def __getitem__(self, uri): ...
def __setitem__(self, uri, value) -> None: ...
def __delitem__(self, uri) -> None: ...
def __iter__(self): ...
def __len__(self): ...
store: dict[str, str]
def __init__(self, __m: SupportsKeysAndGetItem[str, str] | Iterable[tuple[str, str]], **kwargs: str) -> None: ...
def __getitem__(self, uri: str) -> str: ...
def __setitem__(self, uri: str, value: str) -> None: ...
def __delitem__(self, uri: str) -> None: ...
def __iter__(self) -> Iterator[str]: ...
def __len__(self) -> int: ...

class Unset: ...

Expand Down
60 changes: 44 additions & 16 deletions stubs/jsonschema/jsonschema/validators.pyi
Original file line number Diff line number Diff line change
@@ -1,28 +1,56 @@
from typing import Any, Callable
from _typeshed import SupportsKeysAndGetItem
from collections.abc import Callable, Generator, Iterable
from typing import Any, ClassVar

from ._utils import URIDict

# This class does not exist runtime. Compatible classes are created at
# runtime by create().
class _Validator:
VALIDATORS: ClassVar[dict[Any, Any]]
META_SCHEMA: ClassVar[dict[Any, Any]]
TYPE_CHECKER: Any
@staticmethod
def ID_OF(): ...
schema: Any
resolver: Any
format_checker: Any
evolve: Any
@classmethod
def check_schema(cls, schema) -> None: ...
def iter_errors(self, instance, _schema: Any | None = ...) -> Generator[Any, None, None]: ...
def descend(self, instance, schema, path: Any | None = ..., schema_path: Any | None = ...) -> Generator[Any, None, None]: ...
def validate(self, *args, **kwargs) -> None: ...
def is_type(self, instance, type): ...
def is_valid(self, instance, _schema: Any | None = ...) -> bool: ...

def validates(version: str) -> Callable[..., Any]: ...
def create(meta_schema, validators=..., version: Any | None = ..., type_checker=..., id_of=..., applicable_validators=...): ...
def create(
meta_schema, validators=..., version: Any | None = ..., type_checker=..., id_of=..., applicable_validators=...
) -> type[_Validator]: ...
def extend(validator, validators=..., version: Any | None = ..., type_checker: Any | None = ...): ...

Draft3Validator: Any
Draft4Validator: Any
Draft6Validator: Any
Draft7Validator: Any
Draft201909Validator: Any
Draft202012Validator: Any
Draft3Validator: type[_Validator]
Draft4Validator: type[_Validator]
Draft6Validator: type[_Validator]
Draft7Validator: type[_Validator]
Draft201909Validator: type[_Validator]
Draft202012Validator: type[_Validator]

_Handler = Callable[[str], Any]

class RefResolver:
referrer: Any
referrer: str
cache_remote: Any
handlers: Any
store: Any
handlers: dict[str, _Handler]
store: URIDict
def __init__(
self,
base_uri,
referrer,
store=...,
base_uri: str,
referrer: str,
store: SupportsKeysAndGetItem[str, str] | Iterable[tuple[str, str]] = ...,
cache_remote: bool = ...,
handlers=...,
handlers: SupportsKeysAndGetItem[str, _Handler] | Iterable[tuple[str, _Handler]] = ...,
urljoin_cache: Any | None = ...,
remote_cache: Any | None = ...,
) -> None: ...
Expand All @@ -41,5 +69,5 @@ class RefResolver:
def resolve_fragment(self, document, fragment): ...
def resolve_remote(self, uri): ...

def validate(instance, schema, cls: Any | None = ..., *args, **kwargs) -> None: ...
def validate(instance: object, schema: object, cls: type[_Validator] | None = ..., *args: Any, **kwargs: Any) -> None: ...
def validator_for(schema, default=...): ...