Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion stubs/jsonschema/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
jsonschema._format.is_css21_color
jsonschema._format.is_css3_color
jsonschema._format.is_css_color_code
jsonschema._format.is_datetime
jsonschema._format.is_duration
jsonschema._format.is_host_name
jsonschema._format.is_idn_host_name
jsonschema._format.is_iri
jsonschema._format.is_iri_reference
Expand Down
2 changes: 1 addition & 1 deletion stubs/jsonschema/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "3.2.*"
version = "4.2.*"
4 changes: 4 additions & 0 deletions stubs/jsonschema/jsonschema/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ from jsonschema._format import (
draft4_format_checker as draft4_format_checker,
draft6_format_checker as draft6_format_checker,
draft7_format_checker as draft7_format_checker,
draft201909_format_checker as draft201909_format_checker,
draft202012_format_checker as draft202012_format_checker,
)
from jsonschema._types import TypeChecker as TypeChecker
from jsonschema.exceptions import (
Expand All @@ -18,6 +20,8 @@ from jsonschema.validators import (
Draft4Validator as Draft4Validator,
Draft6Validator as Draft6Validator,
Draft7Validator as Draft7Validator,
Draft201909Validator as Draft201909Validator,
Draft202012Validator as Draft202012Validator,
RefResolver as RefResolver,
validate as validate,
)
61 changes: 34 additions & 27 deletions stubs/jsonschema/jsonschema/_format.pyi
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
from typing import Any
from typing import Any, Iterable

class FormatChecker:
checkers: Any
def __init__(self, formats: Any | None = ...) -> None: ...
def __init__(self, formats: Iterable[str] | None = ...) -> None: ...
def checks(self, format, raises=...): ...
cls_checks: Any
def check(self, instance, format) -> None: ...
def conforms(self, instance, format): ...
def conforms(self, instance, format) -> bool: ...

draft3_format_checker: Any
draft4_format_checker: Any
draft6_format_checker: Any
draft7_format_checker: Any
draft3_format_checker: FormatChecker
draft4_format_checker: FormatChecker
draft6_format_checker: FormatChecker
draft7_format_checker: FormatChecker
draft201909_format_checker: FormatChecker
draft202012_format_checker: FormatChecker

def is_email(instance): ...
def is_ipv4(instance): ...
def is_ipv6(instance): ...
def is_host_name(instance): ...
def is_idn_host_name(instance): ...
def is_uri(instance): ...
def is_uri_reference(instance): ...
def is_iri(instance): ...
def is_iri_reference(instance): ...
def is_datetime(instance): ...
def is_time(instance): ...
def is_regex(instance): ...
def is_date(instance): ...
def is_draft3_time(instance): ...
def is_css_color_code(instance): ...
def is_css21_color(instance): ...
def is_css3_color(instance): ...
def is_json_pointer(instance): ...
def is_relative_json_pointer(instance): ...
def is_uri_template(instance, template_validator=...): ...
def is_email(instance) -> bool: ...
def is_ipv4(instance) -> bool: ...
def is_ipv6(instance) -> bool: ...

# is_host_name is only defined if fqdn is installed.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: It would be better to put these comments to the allowlist. You can add comments to end of line, e.g.

jsonschema._format.is_host_name  # defined only if fqdn is installed

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually like them in the source file as well as the allowlist is basically invisible when developing with the stubs, while the comment in the source are visible when jumping into the stub file.

def is_host_name(instance) -> bool: ...
def is_idn_host_name(instance) -> bool: ...
def is_uri(instance) -> bool: ...
def is_uri_reference(instance) -> bool: ...
def is_iri(instance) -> bool: ...
def is_iri_reference(instance) -> bool: ...
def is_datetime(instance) -> bool: ...
def is_time(instance) -> bool: ...
def is_regex(instance) -> bool: ...
def is_date(instance) -> bool: ...
def is_draft3_time(instance) -> bool: ...
def is_css_color_code(instance) -> bool: ...
def is_css21_color(instance) -> bool: ...
def is_json_pointer(instance) -> bool: ...
def is_relative_json_pointer(instance) -> bool: ...
def is_uri_template(instance) -> bool: ...

# is_duration is only defined if isoduration is installed.
def is_duration(instance) -> bool: ...
def is_uuid(instance) -> bool: ...
7 changes: 7 additions & 0 deletions stubs/jsonschema/jsonschema/_legacy_validators.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
from typing import Any, ItemsView

def ignore_ref_siblings(schema) -> list[tuple[str, Any]] | ItemsView[str, Any]: ...
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: ...
def extends_draft3(validator, extends, instance, schema) -> None: ...
def items_draft3_draft4(validator, items, instance, schema) -> None: ...
def items_draft6_draft7_draft201909(validator, items, instance, schema) -> None: ...
def minimum_draft3_draft4(validator, minimum, instance, schema) -> None: ...
def maximum_draft3_draft4(validator, maximum, instance, schema) -> None: ...
def properties_draft3(validator, properties, instance, schema) -> None: ...
def type_draft3(validator, types, instance, schema) -> None: ...
def contains_draft6_draft7(validator, contains, instance, schema) -> None: ...
def recursiveRef(validator, recursiveRef, instance, schema) -> None: ...
42 changes: 20 additions & 22 deletions stubs/jsonschema/jsonschema/_types.pyi
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
from typing import Any
from typing import Callable, Iterable, Mapping

def is_array(checker, instance): ...
def is_bool(checker, instance): ...
def is_integer(checker, instance): ...
def is_null(checker, instance): ...
def is_number(checker, instance): ...
def is_object(checker, instance): ...
def is_string(checker, instance): ...
def is_any(checker, instance): ...
def is_array(checker, instance) -> bool: ...
def is_bool(checker, instance) -> bool: ...
def is_integer(checker, instance) -> bool: ...
def is_null(checker, instance) -> bool: ...
def is_number(checker, instance) -> bool: ...
def is_object(checker, instance) -> bool: ...
def is_string(checker, instance) -> bool: ...
def is_any(checker, instance) -> bool: ...

class TypeChecker:
def is_type(self, instance, type): ...
def redefine(self, type, fn): ...
def redefine_many(self, definitions=...): ...
def remove(self, *types): ...
def __init__(self, type_checkers=...) -> None: ...
def __lt__(self, other): ...
def __le__(self, other): ...
def __gt__(self, other): ...
def __ge__(self, other): ...
def __init__(self, type_checkers: Mapping[str, Callable[[object], bool]] = ...) -> None: ...
def is_type(self, instance, type: str) -> bool: ...
def redefine(self, type: str, fn: Callable[..., bool]) -> TypeChecker: ...
def redefine_many(self, definitions=...) -> TypeChecker: ...
def remove(self, *types: Iterable[str]) -> TypeChecker: ...

draft3_type_checker: Any
draft4_type_checker: Any
draft6_type_checker: Any
draft7_type_checker: Any
draft3_type_checker: TypeChecker
draft4_type_checker: TypeChecker
draft6_type_checker: TypeChecker
draft7_type_checker: TypeChecker
draft201909_type_checker: TypeChecker
draft202012_type_checker: TypeChecker
23 changes: 11 additions & 12 deletions stubs/jsonschema/jsonschema/_utils.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Any, MutableMapping
from typing import Any, Generator, Iterable, Mapping, MutableMapping, Sized

class URIDict(MutableMapping[Any, Any]):
def normalize(self, uri): ...
store: Any
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: ...
Expand All @@ -13,13 +13,12 @@ class URIDict(MutableMapping[Any, Any]):
class Unset: ...

def load_schema(name): ...
def indent(string, times: int = ...): ...
def format_as_index(indices): ...
def find_additional_properties(instance, schema) -> None: ...
def extras_msg(extras): ...
def types_msg(instance, types): ...
def flatten(suitable_for_isinstance): ...
def ensure_list(thing): ...
def equal(one, two): ...
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 equal(one, two) -> bool: ...
def unbool(element, true=..., false=...): ...
def uniq(container): ...
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]: ...
7 changes: 6 additions & 1 deletion stubs/jsonschema/jsonschema/_validators.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ def pattern(validator, patrn, instance, schema) -> None: ...
def format(validator, format, instance, schema) -> None: ...
def minLength(validator, mL, instance, schema) -> None: ...
def maxLength(validator, mL, instance, schema) -> None: ...
def dependencies(validator, dependencies, instance, schema) -> None: ...
def dependentRequired(validator, dependentRequired, instance, schema) -> None: ...
def dependentSchemas(validator, dependentSchemas, instance, schema) -> None: ...
def enum(validator, enums, instance, schema) -> None: ...
def ref(validator, ref, instance, schema) -> None: ...
def dynamicRef(validator, dynamicRef, instance, schema) -> None: ...
def type(validator, types, instance, schema) -> None: ...
def properties(validator, properties, instance, schema) -> None: ...
def required(validator, required, instance, schema) -> None: ...
Expand All @@ -30,3 +32,6 @@ def anyOf(validator, anyOf, instance, schema) -> None: ...
def oneOf(validator, oneOf, instance, schema) -> None: ...
def not_(validator, not_schema, instance, schema) -> None: ...
def if_(validator, if_schema, instance, schema) -> None: ...
def unevaluatedItems(validator, unevaluatedItems, instance, schema) -> None: ...
def unevaluatedProperties(validator, unevaluatedProperties, instance, schema) -> None: ...
def prefixItems(validator, prefixItems, instance, schema) -> None: ...
28 changes: 25 additions & 3 deletions stubs/jsonschema/jsonschema/cli.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
from typing import Any

from jsonschema._reflect import namedAny as namedAny
from jsonschema.validators import validator_for as validator_for
class _CannotLoadFile(Exception): ...

class _Outputter:
def __init__(self, formatter, stdout, stderr): ...
@classmethod
def from_arguments(cls, arguments, stdout, stderr): ...
def load(self, path): ...
def filenotfound_error(self, **kwargs) -> None: ...
def parsing_error(self, **kwargs) -> None: ...
def validation_error(self, **kwargs) -> None: ...
def validation_success(self, **kwargs) -> None: ...

class _PrettyFormatter:
def filenotfound_error(self, path, exc_info): ...
def parsing_error(self, path, exc_info): ...
def validation_error(self, instance_path, error): ...
def validation_success(self, instance_path): ...

class _PlainFormatter:
def __init__(self, error_format): ...
def filenotfound_error(self, path, exc_info): ...
def parsing_error(self, path, exc_info): ...
def validation_error(self, instance_path, error): ...
def validation_success(self, instance_path): ...

parser: Any

def parse_args(args): ...
def main(args=...) -> None: ...
def run(arguments, stdout=..., stderr=...): ...
def run(arguments, stdout=..., stderr=..., stdin=...): ...
Empty file.
12 changes: 3 additions & 9 deletions stubs/jsonschema/jsonschema/exceptions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,35 @@ class _Error(Exception):
schema_path=...,
parent: Any | None = ...,
) -> None: ...
def __unicode__(self): ...
@classmethod
def create_from(cls, other): ...
@property
def absolute_path(self): ...
@property
def absolute_schema_path(self): ...
@property
def json_path(self): ...

class ValidationError(_Error): ...
class SchemaError(_Error): ...

class RefResolutionError(Exception):
def __init__(self, cause) -> None: ...
def __lt__(self, other): ...
def __le__(self, other): ...
def __gt__(self, other): ...
def __ge__(self, other): ...
def __init__(self, cause: str) -> None: ...

class UndefinedTypeCheck(Exception):
type: Any
def __init__(self, type) -> None: ...
def __unicode__(self): ...

class UnknownType(Exception):
type: Any
instance: Any
schema: Any
def __init__(self, type, instance, schema) -> None: ...
def __unicode__(self): ...

class FormatError(Exception):
message: Any
cause: Any
def __init__(self, message, cause: Any | None = ...) -> None: ...
def __unicode__(self): ...

class ErrorTree:
errors: Any
Expand Down
27 changes: 5 additions & 22 deletions stubs/jsonschema/jsonschema/validators.pyi
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
from typing import Any
from typing import Any, Callable

from jsonschema import exceptions as exceptions
from jsonschema.exceptions import ErrorTree as ErrorTree

class _DontDoThat(Exception): ...

validators: Any
meta_schemas: Any

def validates(version): ...

class _DefaultTypesDeprecatingMetaClass(type):
DEFAULT_TYPES: Any

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

Draft3Validator: Any
Draft4Validator: Any
Draft6Validator: Any
Draft7Validator: Any
Draft201909Validator: Any
Draft202012Validator: Any

class RefResolver:
referrer: Any
Expand Down