Skip to content
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

Stubs for jsonschema #5784

Merged
merged 9 commits into from
Jul 15, 2021
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
1 change: 1 addition & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"stubs/httplib2",
"stubs/Jinja2",
"stubs/jmespath",
"stubs/jsonschema",
"stubs/Markdown",
"stubs/oauthlib",
"stubs/Pillow",
Expand Down
13 changes: 13 additions & 0 deletions stubs/jsonschema/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
jsonschema._format.is_css21_color
jsonschema._format.is_css3_color
jsonschema._format.is_css_color_code
jsonschema._format.is_datetime
jsonschema._format.is_idn_host_name
jsonschema._format.is_iri
jsonschema._format.is_iri_reference
jsonschema._format.is_json_pointer
jsonschema._format.is_relative_json_pointer
jsonschema._format.is_time
jsonschema._format.is_uri
jsonschema._format.is_uri_reference
jsonschema._format.is_uri_template
1 change: 1 addition & 0 deletions stubs/jsonschema/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = "3.2"
23 changes: 23 additions & 0 deletions stubs/jsonschema/jsonschema/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from jsonschema._format import (
FormatChecker as FormatChecker,
draft3_format_checker as draft3_format_checker,
draft4_format_checker as draft4_format_checker,
draft6_format_checker as draft6_format_checker,
draft7_format_checker as draft7_format_checker,
)
from jsonschema._types import TypeChecker as TypeChecker
from jsonschema.exceptions import (
ErrorTree as ErrorTree,
FormatError as FormatError,
RefResolutionError as RefResolutionError,
SchemaError as SchemaError,
ValidationError as ValidationError,
)
from jsonschema.validators import (
Draft3Validator as Draft3Validator,
Draft4Validator as Draft4Validator,
Draft6Validator as Draft6Validator,
Draft7Validator as Draft7Validator,
RefResolver as RefResolver,
validate as validate,
)
35 changes: 35 additions & 0 deletions stubs/jsonschema/jsonschema/_format.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from typing import Any

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

draft3_format_checker: Any
draft4_format_checker: Any
draft6_format_checker: Any
draft7_format_checker: Any

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=...): ...
8 changes: 8 additions & 0 deletions stubs/jsonschema/jsonschema/_legacy_validators.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def dependencies_draft3(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 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: ...
7 changes: 7 additions & 0 deletions stubs/jsonschema/jsonschema/_reflect.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class _NoModuleFound(Exception): ...
class InvalidName(ValueError): ...
class ModuleNotFound(InvalidName): ...
class ObjectNotFound(InvalidName): ...

def reraise(exception, traceback) -> None: ...
def namedAny(name): ...
26 changes: 26 additions & 0 deletions stubs/jsonschema/jsonschema/_types.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from typing import Any

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): ...

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): ...

draft3_type_checker: Any
draft4_type_checker: Any
draft6_type_checker: Any
draft7_type_checker: Any
25 changes: 25 additions & 0 deletions stubs/jsonschema/jsonschema/_utils.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from typing import Any, MutableMapping

class URIDict(MutableMapping[Any, Any]):
def normalize(self, uri): ...
store: 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): ...

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 unbool(element, true=..., false=...): ...
def uniq(container): ...
32 changes: 32 additions & 0 deletions stubs/jsonschema/jsonschema/_validators.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
def patternProperties(validator, patternProperties, instance, schema) -> None: ...
def propertyNames(validator, propertyNames, instance, schema) -> None: ...
def additionalProperties(validator, aP, instance, schema) -> None: ...
def items(validator, items, instance, schema) -> None: ...
def additionalItems(validator, aI, instance, schema) -> None: ...
def const(validator, const, instance, schema) -> None: ...
def contains(validator, contains, instance, schema) -> None: ...
def exclusiveMinimum(validator, minimum, instance, schema) -> None: ...
def exclusiveMaximum(validator, maximum, instance, schema) -> None: ...
def minimum(validator, minimum, instance, schema) -> None: ...
def maximum(validator, maximum, instance, schema) -> None: ...
def multipleOf(validator, dB, instance, schema) -> None: ...
def minItems(validator, mI, instance, schema) -> None: ...
def maxItems(validator, mI, instance, schema) -> None: ...
def uniqueItems(validator, uI, instance, schema) -> None: ...
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 enum(validator, enums, instance, schema) -> None: ...
def ref(validator, ref, instance, schema) -> None: ...
def type(validator, types, instance, schema) -> None: ...
def properties(validator, properties, instance, schema) -> None: ...
def required(validator, required, instance, schema) -> None: ...
def minProperties(validator, mP, instance, schema) -> None: ...
def maxProperties(validator, mP, instance, schema) -> None: ...
def allOf(validator, allOf, instance, schema) -> None: ...
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: ...
10 changes: 10 additions & 0 deletions stubs/jsonschema/jsonschema/cli.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from typing import Any

from jsonschema._reflect import namedAny as namedAny
from jsonschema.validators import validator_for as validator_for

parser: Any

def parse_args(args): ...
def main(args=...) -> None: ...
def run(arguments, stdout=..., stderr=...): ...
Empty file.
81 changes: 81 additions & 0 deletions stubs/jsonschema/jsonschema/exceptions.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
from typing import Any

WEAK_MATCHES: Any
STRONG_MATCHES: Any

class _Error(Exception):
message: Any
path: Any
schema_path: Any
context: Any
cause: Any
validator: Any
validator_value: Any
instance: Any
schema: Any
parent: Any
def __init__(
self,
message,
validator=...,
path=...,
cause: Any | None = ...,
context=...,
validator_value=...,
instance=...,
schema=...,
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): ...

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): ...

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
def __init__(self, errors=...) -> None: ...
def __contains__(self, index): ...
def __getitem__(self, index): ...
def __setitem__(self, index, value) -> None: ...
def __iter__(self): ...
def __len__(self): ...
@property
def total_errors(self): ...

def by_relevance(weak=..., strong=...): ...

relevance: Any

def best_match(errors, key=...): ...
62 changes: 62 additions & 0 deletions stubs/jsonschema/jsonschema/validators.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from typing import Any

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 extend(validator, validators=..., version: Any | None = ..., type_checker: Any | None = ...): ...

Draft3Validator: Any
Draft4Validator: Any
Draft6Validator: Any
Draft7Validator: Any

class RefResolver:
referrer: Any
cache_remote: Any
handlers: Any
store: Any
def __init__(
self,
base_uri,
referrer,
store=...,
cache_remote: bool = ...,
handlers=...,
urljoin_cache: Any | None = ...,
remote_cache: Any | None = ...,
) -> None: ...
@classmethod
def from_schema(cls, schema, id_of=..., *args, **kwargs): ...
def push_scope(self, scope) -> None: ...
def pop_scope(self) -> None: ...
@property
def resolution_scope(self): ...
@property
def base_uri(self): ...
def in_scope(self, scope) -> None: ...
def resolving(self, ref) -> None: ...
def resolve(self, ref): ...
def resolve_from_url(self, url): ...
def resolve_fragment(self, document, fragment): ...
def resolve_remote(self, uri): ...

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