mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-28 06:36:54 +08:00
[jsonschema] Use Incomplete instead of Any (#10451)
Replace `Any` with `Incomplete`
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from _typeshed import Incomplete
|
||||
from collections.abc import ItemsView
|
||||
from typing import Any
|
||||
|
||||
def ignore_ref_siblings(schema) -> list[tuple[str, Any]] | ItemsView[str, Any]: ...
|
||||
def ignore_ref_siblings(schema) -> list[tuple[str, Incomplete]] | ItemsView[str, Incomplete]: ...
|
||||
def dependencies_draft3(validator, dependencies, instance, schema) -> None: ...
|
||||
def dependencies_draft4_draft6_draft7(validator, dependencies, instance, schema) -> None: ...
|
||||
def disallow_draft3(validator, disallow, instance, schema) -> None: ...
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from _typeshed import SupportsKeysAndGetItem
|
||||
from _typeshed import Incomplete, SupportsKeysAndGetItem
|
||||
from collections.abc import Generator, Iterable, Iterator, Mapping, MutableMapping, Sized
|
||||
from typing import Any
|
||||
|
||||
class URIDict(MutableMapping[str, str]):
|
||||
def normalize(self, uri: str) -> str: ...
|
||||
@@ -16,11 +15,13 @@ class Unset: ...
|
||||
|
||||
def load_schema(name): ...
|
||||
def format_as_index(container: str, indices) -> str: ...
|
||||
def find_additional_properties(instance: Iterable[Any], schema: Mapping[Any, Any]) -> Generator[Any, None, None]: ...
|
||||
def extras_msg(extras: Iterable[Any] | Sized) -> str: ...
|
||||
def ensure_list(thing) -> list[Any]: ...
|
||||
def find_additional_properties(
|
||||
instance: Iterable[Incomplete], schema: Mapping[Incomplete, Incomplete]
|
||||
) -> Generator[Incomplete, None, None]: ...
|
||||
def extras_msg(extras: Iterable[Incomplete] | Sized) -> str: ...
|
||||
def ensure_list(thing) -> list[Incomplete]: ...
|
||||
def equal(one, two) -> bool: ...
|
||||
def unbool(element, true=..., false=...): ...
|
||||
def uniq(container) -> bool: ...
|
||||
def find_evaluated_item_indexes_by_schema(validator, instance, schema) -> list[Any]: ...
|
||||
def find_evaluated_property_keys_by_schema(validator, instance, schema) -> list[Any]: ...
|
||||
def find_evaluated_item_indexes_by_schema(validator, instance, schema) -> list[Incomplete]: ...
|
||||
def find_evaluated_property_keys_by_schema(validator, instance, schema) -> list[Incomplete]: ...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any
|
||||
from _typeshed import Incomplete
|
||||
|
||||
class _CannotLoadFile(Exception): ...
|
||||
|
||||
@@ -25,7 +25,7 @@ class _PlainFormatter:
|
||||
def validation_error(self, instance_path, error): ...
|
||||
def validation_success(self, instance_path): ...
|
||||
|
||||
parser: Any
|
||||
parser: Incomplete
|
||||
|
||||
def parse_args(args): ...
|
||||
def main(args=...) -> None: ...
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from _typeshed import Incomplete, SupportsRichComparison
|
||||
from collections import deque
|
||||
from collections.abc import Callable, Container, Iterable, Sequence
|
||||
from typing import Any
|
||||
from typing_extensions import Self, TypeAlias
|
||||
|
||||
from jsonschema import _utils, protocols
|
||||
@@ -21,9 +20,9 @@ class _Error(Exception):
|
||||
context: list[ValidationError] | None
|
||||
cause: Exception | None
|
||||
validator: protocols.Validator | None
|
||||
validator_value: Any
|
||||
instance: Any
|
||||
schema: Any
|
||||
validator_value: Incomplete
|
||||
instance: Incomplete
|
||||
schema: Incomplete
|
||||
parent: _Error | None
|
||||
def __init__(
|
||||
self,
|
||||
@@ -33,8 +32,8 @@ class _Error(Exception):
|
||||
cause: Incomplete | None = None,
|
||||
context: Sequence[ValidationError] = (),
|
||||
validator_value=...,
|
||||
instance: Any = ...,
|
||||
schema: Any = ...,
|
||||
instance: Incomplete = ...,
|
||||
schema: Incomplete = ...,
|
||||
schema_path: Sequence[str | int] = (),
|
||||
parent: _Error | None = None,
|
||||
type_checker: _utils.Unset | TypeChecker = ...,
|
||||
@@ -49,7 +48,7 @@ class _Error(Exception):
|
||||
def json_path(self) -> str: ...
|
||||
# TODO: this type could be made more precise using TypedDict to
|
||||
# enumerate the types of the members
|
||||
def _contents(self) -> dict[str, Any]: ...
|
||||
def _contents(self) -> dict[str, Incomplete]: ...
|
||||
|
||||
class ValidationError(_Error): ...
|
||||
class SchemaError(_Error): ...
|
||||
@@ -58,22 +57,22 @@ class RefResolutionError(Exception):
|
||||
def __init__(self, cause: str) -> None: ...
|
||||
|
||||
class UndefinedTypeCheck(Exception):
|
||||
type: Any
|
||||
type: Incomplete
|
||||
def __init__(self, type) -> None: ...
|
||||
|
||||
class UnknownType(Exception):
|
||||
type: Any
|
||||
instance: Any
|
||||
schema: Any
|
||||
type: Incomplete
|
||||
instance: Incomplete
|
||||
schema: Incomplete
|
||||
def __init__(self, type, instance, schema) -> None: ...
|
||||
|
||||
class FormatError(Exception):
|
||||
message: Any
|
||||
cause: Any
|
||||
message: Incomplete
|
||||
cause: Incomplete
|
||||
def __init__(self, message, cause: Incomplete | None = None) -> None: ...
|
||||
|
||||
class ErrorTree:
|
||||
errors: Any
|
||||
errors: Incomplete
|
||||
def __init__(self, errors=()) -> None: ...
|
||||
def __contains__(self, index): ...
|
||||
def __getitem__(self, index): ...
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from _typeshed import Incomplete
|
||||
from collections.abc import Iterator, Mapping, Sequence
|
||||
from typing import Any, ClassVar, Protocol
|
||||
from typing import ClassVar, Protocol
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from jsonschema._format import FormatChecker
|
||||
@@ -10,16 +11,19 @@ from jsonschema.validators import RefResolver
|
||||
_JsonParameter: TypeAlias = str | int | float | bool | None | Mapping[str, _JsonParameter] | Sequence[_JsonParameter]
|
||||
|
||||
class Validator(Protocol):
|
||||
META_SCHEMA: ClassVar[dict[Any, Any]]
|
||||
VALIDATORS: ClassVar[dict[Any, Any]]
|
||||
META_SCHEMA: ClassVar[dict[Incomplete, Incomplete]]
|
||||
VALIDATORS: ClassVar[dict[Incomplete, Incomplete]]
|
||||
TYPE_CHECKER: ClassVar[TypeChecker]
|
||||
FORMAT_CHECKER: ClassVar[FormatChecker]
|
||||
schema: dict[Any, Any] | bool
|
||||
schema: dict[Incomplete, Incomplete] | bool
|
||||
def __init__(
|
||||
self, schema: dict[Any, Any] | bool, resolver: RefResolver | None = None, format_checker: FormatChecker | None = None
|
||||
self,
|
||||
schema: dict[Incomplete, Incomplete] | bool,
|
||||
resolver: RefResolver | None = None,
|
||||
format_checker: FormatChecker | None = None,
|
||||
) -> None: ...
|
||||
@classmethod
|
||||
def check_schema(cls, schema: dict[Any, Any]) -> None: ...
|
||||
def check_schema(cls, schema: dict[Incomplete, Incomplete]) -> None: ...
|
||||
def is_type(self, instance: _JsonParameter, type: str) -> bool: ...
|
||||
def is_valid(self, instance: _JsonParameter) -> bool: ...
|
||||
def iter_errors(self, instance: _JsonParameter) -> Iterator[ValidationError]: ...
|
||||
|
||||
@@ -19,28 +19,28 @@ _Schema: TypeAlias = Mapping[str, Any]
|
||||
# This class does not exist at runtime. Compatible classes are created at
|
||||
# runtime by create().
|
||||
class _Validator:
|
||||
VALIDATORS: ClassVar[dict[Any, Any]]
|
||||
META_SCHEMA: ClassVar[dict[Any, Any]]
|
||||
TYPE_CHECKER: ClassVar[Any]
|
||||
FORMAT_CHECKER: ClassVar[Any]
|
||||
VALIDATORS: ClassVar[dict[Incomplete, Incomplete]]
|
||||
META_SCHEMA: ClassVar[dict[Incomplete, Incomplete]]
|
||||
TYPE_CHECKER: ClassVar[Incomplete]
|
||||
FORMAT_CHECKER: ClassVar[Incomplete]
|
||||
@staticmethod
|
||||
def ID_OF(schema: _Schema) -> str: ...
|
||||
schema: _Schema
|
||||
resolver: Any
|
||||
format_checker: Any
|
||||
evolve: Any
|
||||
resolver: Incomplete
|
||||
format_checker: Incomplete
|
||||
evolve: Incomplete
|
||||
def __init__(self, schema: _Schema, resolver: Incomplete | None = ..., format_checker: Incomplete | None = ...) -> None: ...
|
||||
@classmethod
|
||||
def check_schema(cls, schema: _Schema, format_checker: FormatChecker | Unset = ...) -> None: ...
|
||||
def iter_errors(self, instance, _schema: _Schema | None = ...) -> Generator[Any, None, None]: ...
|
||||
def iter_errors(self, instance, _schema: _Schema | None = ...) -> Generator[Incomplete, None, None]: ...
|
||||
def descend(
|
||||
self, instance, schema: _Schema, path: Incomplete | None = ..., schema_path: Incomplete | None = ...
|
||||
) -> Generator[Any, None, None]: ...
|
||||
) -> Generator[Incomplete, None, None]: ...
|
||||
def validate(self, *args, **kwargs) -> None: ...
|
||||
def is_type(self, instance, type): ...
|
||||
def is_valid(self, instance, _schema: _Schema | None = ...) -> bool: ...
|
||||
|
||||
def validates(version: str) -> Callable[..., Any]: ...
|
||||
def validates(version: str) -> Callable[..., Incomplete]: ...
|
||||
def create(
|
||||
meta_schema: _Schema,
|
||||
validators: Mapping[str, _ValidatorCallback] | tuple[()] = (),
|
||||
@@ -66,17 +66,17 @@ class Draft7Validator(_Validator): ...
|
||||
class Draft201909Validator(_Validator): ...
|
||||
class Draft202012Validator(_Validator): ...
|
||||
|
||||
_Handler: TypeAlias = Callable[[str], Any]
|
||||
_Handler: TypeAlias = Callable[[str], Incomplete]
|
||||
|
||||
class RefResolver:
|
||||
referrer: dict[str, Any]
|
||||
cache_remote: Any
|
||||
referrer: dict[str, Incomplete]
|
||||
cache_remote: Incomplete
|
||||
handlers: dict[str, _Handler]
|
||||
store: URIDict
|
||||
def __init__(
|
||||
self,
|
||||
base_uri: str,
|
||||
referrer: dict[str, Any],
|
||||
referrer: dict[str, Incomplete],
|
||||
store: SupportsKeysAndGetItem[str, str] | Iterable[tuple[str, str]] = ...,
|
||||
cache_remote: bool = True,
|
||||
handlers: SupportsKeysAndGetItem[str, _Handler] | Iterable[tuple[str, _Handler]] = (),
|
||||
|
||||
Reference in New Issue
Block a user