From 1bb5feb20ed47e3609cf9d12e5929e3eb6e5ed2e Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Wed, 14 Jul 2021 15:56:13 +0100 Subject: [PATCH 1/9] Add stubs for jsonschema --- pyrightconfig.stricter.json | 1 + stubs/jsonschema/METADATA.toml | 1 + stubs/jsonschema/jsonschema/__init__.pyi | 23 ++++++ stubs/jsonschema/jsonschema/_format.pyi | 37 +++++++++ .../jsonschema/_legacy_validators.pyi | 11 +++ stubs/jsonschema/jsonschema/_reflect.pyi | 9 ++ stubs/jsonschema/jsonschema/_types.pyi | 28 +++++++ stubs/jsonschema/jsonschema/_utils.pyi | 26 ++++++ stubs/jsonschema/jsonschema/_validators.pyi | 44 ++++++++++ .../jsonschema/benchmarks/__init__.pyi | 0 .../jsonschema/benchmarks/issue232.pyi | 4 + stubs/jsonschema/jsonschema/cli.pyi | 9 ++ stubs/jsonschema/jsonschema/compat.pyi | 13 +++ stubs/jsonschema/jsonschema/exceptions.pyi | 82 +++++++++++++++++++ stubs/jsonschema/jsonschema/validators.pyi | 73 +++++++++++++++++ 15 files changed, 361 insertions(+) create mode 100644 stubs/jsonschema/METADATA.toml create mode 100644 stubs/jsonschema/jsonschema/__init__.pyi create mode 100644 stubs/jsonschema/jsonschema/_format.pyi create mode 100644 stubs/jsonschema/jsonschema/_legacy_validators.pyi create mode 100644 stubs/jsonschema/jsonschema/_reflect.pyi create mode 100644 stubs/jsonschema/jsonschema/_types.pyi create mode 100644 stubs/jsonschema/jsonschema/_utils.pyi create mode 100644 stubs/jsonschema/jsonschema/_validators.pyi create mode 100644 stubs/jsonschema/jsonschema/benchmarks/__init__.pyi create mode 100644 stubs/jsonschema/jsonschema/benchmarks/issue232.pyi create mode 100644 stubs/jsonschema/jsonschema/cli.pyi create mode 100644 stubs/jsonschema/jsonschema/compat.pyi create mode 100644 stubs/jsonschema/jsonschema/exceptions.pyi create mode 100644 stubs/jsonschema/jsonschema/validators.pyi diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index 23326c753e1b..8fedbb53c3a0 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -39,6 +39,7 @@ "stubs/httplib2", "stubs/Jinja2", "stubs/jmespath", + "stubs/jsonschema", "stubs/Markdown", "stubs/oauthlib", "stubs/Pillow", diff --git a/stubs/jsonschema/METADATA.toml b/stubs/jsonschema/METADATA.toml new file mode 100644 index 000000000000..ffc5a1c5e98b --- /dev/null +++ b/stubs/jsonschema/METADATA.toml @@ -0,0 +1 @@ +version = "3.2" diff --git a/stubs/jsonschema/jsonschema/__init__.pyi b/stubs/jsonschema/jsonschema/__init__.pyi new file mode 100644 index 000000000000..87b8e96f56b7 --- /dev/null +++ b/stubs/jsonschema/jsonschema/__init__.pyi @@ -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, +) diff --git a/stubs/jsonschema/jsonschema/_format.pyi b/stubs/jsonschema/jsonschema/_format.pyi new file mode 100644 index 000000000000..5805a4854965 --- /dev/null +++ b/stubs/jsonschema/jsonschema/_format.pyi @@ -0,0 +1,37 @@ +from jsonschema.compat import str_types as str_types +from jsonschema.exceptions import FormatError as FormatError +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=...): ... diff --git a/stubs/jsonschema/jsonschema/_legacy_validators.pyi b/stubs/jsonschema/jsonschema/_legacy_validators.pyi new file mode 100644 index 000000000000..a69c65654aa1 --- /dev/null +++ b/stubs/jsonschema/jsonschema/_legacy_validators.pyi @@ -0,0 +1,11 @@ +from jsonschema.compat import iteritems as iteritems +from jsonschema.exceptions import ValidationError as ValidationError + +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: ... diff --git a/stubs/jsonschema/jsonschema/_reflect.pyi b/stubs/jsonschema/jsonschema/_reflect.pyi new file mode 100644 index 000000000000..9d3b0c55ba60 --- /dev/null +++ b/stubs/jsonschema/jsonschema/_reflect.pyi @@ -0,0 +1,9 @@ +from jsonschema.compat import PY3 as PY3 + +class _NoModuleFound(Exception): ... +class InvalidName(ValueError): ... +class ModuleNotFound(InvalidName): ... +class ObjectNotFound(InvalidName): ... + +def reraise(exception, traceback) -> None: ... +def namedAny(name): ... diff --git a/stubs/jsonschema/jsonschema/_types.pyi b/stubs/jsonschema/jsonschema/_types.pyi new file mode 100644 index 000000000000..b01d2b4bc182 --- /dev/null +++ b/stubs/jsonschema/jsonschema/_types.pyi @@ -0,0 +1,28 @@ +from jsonschema.compat import int_types as int_types, str_types as str_types +from jsonschema.exceptions import UndefinedTypeCheck as UndefinedTypeCheck +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 = draft6_type_checker diff --git a/stubs/jsonschema/jsonschema/_utils.pyi b/stubs/jsonschema/jsonschema/_utils.pyi new file mode 100644 index 000000000000..121aa54867d8 --- /dev/null +++ b/stubs/jsonschema/jsonschema/_utils.pyi @@ -0,0 +1,26 @@ +from jsonschema.compat import MutableMapping as MutableMapping, str_types as str_types, urlsplit as urlsplit +from typing import Any + +class URIDict(MutableMapping): + 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): ... diff --git a/stubs/jsonschema/jsonschema/_validators.pyi b/stubs/jsonschema/jsonschema/_validators.pyi new file mode 100644 index 000000000000..0d465b1b22ae --- /dev/null +++ b/stubs/jsonschema/jsonschema/_validators.pyi @@ -0,0 +1,44 @@ +from jsonschema._utils import ( + ensure_list as ensure_list, + equal as equal, + extras_msg as extras_msg, + find_additional_properties as find_additional_properties, + types_msg as types_msg, + unbool as unbool, + uniq as uniq, +) +from jsonschema.compat import iteritems as iteritems +from jsonschema.exceptions import FormatError as FormatError, ValidationError as ValidationError + +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: ... diff --git a/stubs/jsonschema/jsonschema/benchmarks/__init__.pyi b/stubs/jsonschema/jsonschema/benchmarks/__init__.pyi new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/stubs/jsonschema/jsonschema/benchmarks/issue232.pyi b/stubs/jsonschema/jsonschema/benchmarks/issue232.pyi new file mode 100644 index 000000000000..2ffaaa5b7fef --- /dev/null +++ b/stubs/jsonschema/jsonschema/benchmarks/issue232.pyi @@ -0,0 +1,4 @@ +from jsonschema.tests._suite import Version as Version +from typing import Any + +issue232: Any diff --git a/stubs/jsonschema/jsonschema/cli.pyi b/stubs/jsonschema/jsonschema/cli.pyi new file mode 100644 index 000000000000..8c5193a17232 --- /dev/null +++ b/stubs/jsonschema/jsonschema/cli.pyi @@ -0,0 +1,9 @@ +from jsonschema._reflect import namedAny as namedAny +from jsonschema.validators import validator_for as validator_for +from typing import Any + +parser: Any + +def parse_args(args): ... +def main(args=...) -> None: ... +def run(arguments, stdout=..., stderr=...): ... diff --git a/stubs/jsonschema/jsonschema/compat.pyi b/stubs/jsonschema/jsonschema/compat.pyi new file mode 100644 index 000000000000..44211657229e --- /dev/null +++ b/stubs/jsonschema/jsonschema/compat.pyi @@ -0,0 +1,13 @@ +from collections import MutableMapping as MutableMapping, Sequence as Sequence +from functools import lru_cache as lru_cache +from typing import Any +from urllib.parse import SplitResult as SplitResult, unquote as unquote, urljoin as urljoin +from urllib.request import pathname2url as pathname2url, urlopen as urlopen + +PY3: Any +zip = zip +str_types: Any +int_types: Any +iteritems: Any + +def urldefrag(url): ... diff --git a/stubs/jsonschema/jsonschema/exceptions.pyi b/stubs/jsonschema/jsonschema/exceptions.pyi new file mode 100644 index 000000000000..e066550c21cb --- /dev/null +++ b/stubs/jsonschema/jsonschema/exceptions.pyi @@ -0,0 +1,82 @@ +from jsonschema.compat import PY3 as PY3, iteritems as iteritems +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=...): ... diff --git a/stubs/jsonschema/jsonschema/validators.pyi b/stubs/jsonschema/jsonschema/validators.pyi new file mode 100644 index 000000000000..cd1b11b3ffba --- /dev/null +++ b/stubs/jsonschema/jsonschema/validators.pyi @@ -0,0 +1,73 @@ +from jsonschema import exceptions as exceptions +from jsonschema.compat import ( + Sequence as Sequence, + int_types as int_types, + iteritems as iteritems, + lru_cache as lru_cache, + str_types as str_types, + unquote as unquote, + urldefrag as urldefrag, + urljoin as urljoin, + urlopen as urlopen, + urlsplit as urlsplit, +) +from jsonschema.exceptions import ErrorTree as ErrorTree +from typing import Any + +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=...): ... From 6dcd512c268570118b47aa6b059e0fe61b643395 Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Wed, 14 Jul 2021 15:57:17 +0100 Subject: [PATCH 2/9] Remove benchmarks --- stubs/jsonschema/jsonschema/benchmarks/__init__.pyi | 0 stubs/jsonschema/jsonschema/benchmarks/issue232.pyi | 4 ---- 2 files changed, 4 deletions(-) delete mode 100644 stubs/jsonschema/jsonschema/benchmarks/__init__.pyi delete mode 100644 stubs/jsonschema/jsonschema/benchmarks/issue232.pyi diff --git a/stubs/jsonschema/jsonschema/benchmarks/__init__.pyi b/stubs/jsonschema/jsonschema/benchmarks/__init__.pyi deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/stubs/jsonschema/jsonschema/benchmarks/issue232.pyi b/stubs/jsonschema/jsonschema/benchmarks/issue232.pyi deleted file mode 100644 index 2ffaaa5b7fef..000000000000 --- a/stubs/jsonschema/jsonschema/benchmarks/issue232.pyi +++ /dev/null @@ -1,4 +0,0 @@ -from jsonschema.tests._suite import Version as Version -from typing import Any - -issue232: Any From 1349e59f181b4eef7e6ed601c1a445ade09bbddd Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Wed, 14 Jul 2021 15:58:36 +0100 Subject: [PATCH 3/9] Fix some imports --- stubs/jsonschema/jsonschema/_utils.pyi | 3 +-- stubs/jsonschema/jsonschema/validators.pyi | 12 ------------ 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/stubs/jsonschema/jsonschema/_utils.pyi b/stubs/jsonschema/jsonschema/_utils.pyi index 121aa54867d8..d70c8508ff5c 100644 --- a/stubs/jsonschema/jsonschema/_utils.pyi +++ b/stubs/jsonschema/jsonschema/_utils.pyi @@ -1,5 +1,4 @@ -from jsonschema.compat import MutableMapping as MutableMapping, str_types as str_types, urlsplit as urlsplit -from typing import Any +from typing import Any, MutableMapping class URIDict(MutableMapping): def normalize(self, uri): ... diff --git a/stubs/jsonschema/jsonschema/validators.pyi b/stubs/jsonschema/jsonschema/validators.pyi index cd1b11b3ffba..64410e550364 100644 --- a/stubs/jsonschema/jsonschema/validators.pyi +++ b/stubs/jsonschema/jsonschema/validators.pyi @@ -1,16 +1,4 @@ from jsonschema import exceptions as exceptions -from jsonschema.compat import ( - Sequence as Sequence, - int_types as int_types, - iteritems as iteritems, - lru_cache as lru_cache, - str_types as str_types, - unquote as unquote, - urldefrag as urldefrag, - urljoin as urljoin, - urlopen as urlopen, - urlsplit as urlsplit, -) from jsonschema.exceptions import ErrorTree as ErrorTree from typing import Any From 9741a1f0ae4acd8b8aebecf7bcad1759b8827c93 Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Thu, 15 Jul 2021 13:47:11 +0100 Subject: [PATCH 4/9] isort --- stubs/jsonschema/jsonschema/_format.pyi | 3 ++- stubs/jsonschema/jsonschema/_types.pyi | 3 ++- stubs/jsonschema/jsonschema/cli.pyi | 3 ++- stubs/jsonschema/jsonschema/exceptions.pyi | 3 ++- stubs/jsonschema/jsonschema/validators.pyi | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/stubs/jsonschema/jsonschema/_format.pyi b/stubs/jsonschema/jsonschema/_format.pyi index 5805a4854965..f91895ded125 100644 --- a/stubs/jsonschema/jsonschema/_format.pyi +++ b/stubs/jsonschema/jsonschema/_format.pyi @@ -1,6 +1,7 @@ +from typing import Any + from jsonschema.compat import str_types as str_types from jsonschema.exceptions import FormatError as FormatError -from typing import Any class FormatChecker: checkers: Any diff --git a/stubs/jsonschema/jsonschema/_types.pyi b/stubs/jsonschema/jsonschema/_types.pyi index b01d2b4bc182..eefec95946b7 100644 --- a/stubs/jsonschema/jsonschema/_types.pyi +++ b/stubs/jsonschema/jsonschema/_types.pyi @@ -1,6 +1,7 @@ +from typing import Any + from jsonschema.compat import int_types as int_types, str_types as str_types from jsonschema.exceptions import UndefinedTypeCheck as UndefinedTypeCheck -from typing import Any def is_array(checker, instance): ... def is_bool(checker, instance): ... diff --git a/stubs/jsonschema/jsonschema/cli.pyi b/stubs/jsonschema/jsonschema/cli.pyi index 8c5193a17232..1ccff3f60407 100644 --- a/stubs/jsonschema/jsonschema/cli.pyi +++ b/stubs/jsonschema/jsonschema/cli.pyi @@ -1,6 +1,7 @@ +from typing import Any + from jsonschema._reflect import namedAny as namedAny from jsonschema.validators import validator_for as validator_for -from typing import Any parser: Any diff --git a/stubs/jsonschema/jsonschema/exceptions.pyi b/stubs/jsonschema/jsonschema/exceptions.pyi index e066550c21cb..0994b797ccff 100644 --- a/stubs/jsonschema/jsonschema/exceptions.pyi +++ b/stubs/jsonschema/jsonschema/exceptions.pyi @@ -1,6 +1,7 @@ -from jsonschema.compat import PY3 as PY3, iteritems as iteritems from typing import Any +from jsonschema.compat import PY3 as PY3, iteritems as iteritems + WEAK_MATCHES: Any STRONG_MATCHES: Any diff --git a/stubs/jsonschema/jsonschema/validators.pyi b/stubs/jsonschema/jsonschema/validators.pyi index 64410e550364..b9a078e601f9 100644 --- a/stubs/jsonschema/jsonschema/validators.pyi +++ b/stubs/jsonschema/jsonschema/validators.pyi @@ -1,6 +1,7 @@ +from typing import Any + from jsonschema import exceptions as exceptions from jsonschema.exceptions import ErrorTree as ErrorTree -from typing import Any class _DontDoThat(Exception): ... From 79128f0b75217b344c2bfbe32b4765791e25c442 Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Thu, 15 Jul 2021 13:49:51 +0100 Subject: [PATCH 5/9] Remove py2/3 compat stuff --- stubs/jsonschema/jsonschema/_format.pyi | 1 - stubs/jsonschema/jsonschema/_legacy_validators.pyi | 1 - stubs/jsonschema/jsonschema/_reflect.pyi | 2 -- stubs/jsonschema/jsonschema/_types.pyi | 1 - stubs/jsonschema/jsonschema/_validators.pyi | 1 - stubs/jsonschema/jsonschema/compat.pyi | 13 ------------- stubs/jsonschema/jsonschema/exceptions.pyi | 2 -- 7 files changed, 21 deletions(-) diff --git a/stubs/jsonschema/jsonschema/_format.pyi b/stubs/jsonschema/jsonschema/_format.pyi index f91895ded125..b49fe49645c4 100644 --- a/stubs/jsonschema/jsonschema/_format.pyi +++ b/stubs/jsonschema/jsonschema/_format.pyi @@ -1,6 +1,5 @@ from typing import Any -from jsonschema.compat import str_types as str_types from jsonschema.exceptions import FormatError as FormatError class FormatChecker: diff --git a/stubs/jsonschema/jsonschema/_legacy_validators.pyi b/stubs/jsonschema/jsonschema/_legacy_validators.pyi index a69c65654aa1..b33618a51310 100644 --- a/stubs/jsonschema/jsonschema/_legacy_validators.pyi +++ b/stubs/jsonschema/jsonschema/_legacy_validators.pyi @@ -1,4 +1,3 @@ -from jsonschema.compat import iteritems as iteritems from jsonschema.exceptions import ValidationError as ValidationError def dependencies_draft3(validator, dependencies, instance, schema) -> None: ... diff --git a/stubs/jsonschema/jsonschema/_reflect.pyi b/stubs/jsonschema/jsonschema/_reflect.pyi index 9d3b0c55ba60..a19c6f9d8bf2 100644 --- a/stubs/jsonschema/jsonschema/_reflect.pyi +++ b/stubs/jsonschema/jsonschema/_reflect.pyi @@ -1,5 +1,3 @@ -from jsonschema.compat import PY3 as PY3 - class _NoModuleFound(Exception): ... class InvalidName(ValueError): ... class ModuleNotFound(InvalidName): ... diff --git a/stubs/jsonschema/jsonschema/_types.pyi b/stubs/jsonschema/jsonschema/_types.pyi index eefec95946b7..3eb50ccae55b 100644 --- a/stubs/jsonschema/jsonschema/_types.pyi +++ b/stubs/jsonschema/jsonschema/_types.pyi @@ -1,6 +1,5 @@ from typing import Any -from jsonschema.compat import int_types as int_types, str_types as str_types from jsonschema.exceptions import UndefinedTypeCheck as UndefinedTypeCheck def is_array(checker, instance): ... diff --git a/stubs/jsonschema/jsonschema/_validators.pyi b/stubs/jsonschema/jsonschema/_validators.pyi index 0d465b1b22ae..cedc0818a9e5 100644 --- a/stubs/jsonschema/jsonschema/_validators.pyi +++ b/stubs/jsonschema/jsonschema/_validators.pyi @@ -7,7 +7,6 @@ from jsonschema._utils import ( unbool as unbool, uniq as uniq, ) -from jsonschema.compat import iteritems as iteritems from jsonschema.exceptions import FormatError as FormatError, ValidationError as ValidationError def patternProperties(validator, patternProperties, instance, schema) -> None: ... diff --git a/stubs/jsonschema/jsonschema/compat.pyi b/stubs/jsonschema/jsonschema/compat.pyi index 44211657229e..e69de29bb2d1 100644 --- a/stubs/jsonschema/jsonschema/compat.pyi +++ b/stubs/jsonschema/jsonschema/compat.pyi @@ -1,13 +0,0 @@ -from collections import MutableMapping as MutableMapping, Sequence as Sequence -from functools import lru_cache as lru_cache -from typing import Any -from urllib.parse import SplitResult as SplitResult, unquote as unquote, urljoin as urljoin -from urllib.request import pathname2url as pathname2url, urlopen as urlopen - -PY3: Any -zip = zip -str_types: Any -int_types: Any -iteritems: Any - -def urldefrag(url): ... diff --git a/stubs/jsonschema/jsonschema/exceptions.pyi b/stubs/jsonschema/jsonschema/exceptions.pyi index 0994b797ccff..078d44b643c2 100644 --- a/stubs/jsonschema/jsonschema/exceptions.pyi +++ b/stubs/jsonschema/jsonschema/exceptions.pyi @@ -1,7 +1,5 @@ from typing import Any -from jsonschema.compat import PY3 as PY3, iteritems as iteritems - WEAK_MATCHES: Any STRONG_MATCHES: Any From c275657362ad5312e69bc69f93efe1ea71eeb3ab Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Thu, 15 Jul 2021 13:54:23 +0100 Subject: [PATCH 6/9] Fix signature --- stubs/jsonschema/jsonschema/_types.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/jsonschema/jsonschema/_types.pyi b/stubs/jsonschema/jsonschema/_types.pyi index 3eb50ccae55b..45a6718a8462 100644 --- a/stubs/jsonschema/jsonschema/_types.pyi +++ b/stubs/jsonschema/jsonschema/_types.pyi @@ -16,7 +16,7 @@ class TypeChecker: def redefine(self, type, fn): ... def redefine_many(self, definitions=...): ... def remove(self, *types): ... - def __init__(self, type_checkers) -> None: ... + def __init__(self, type_checkers=...) -> None: ... def __lt__(self, other): ... def __le__(self, other): ... def __gt__(self, other): ... From 710bd607dd9bc112a0695ca30e8ef800faf28fe1 Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Thu, 15 Jul 2021 13:56:45 +0100 Subject: [PATCH 7/9] Clean up more imports --- stubs/jsonschema/jsonschema/_format.pyi | 2 -- stubs/jsonschema/jsonschema/_legacy_validators.pyi | 2 -- stubs/jsonschema/jsonschema/_types.pyi | 2 -- stubs/jsonschema/jsonschema/_validators.pyi | 11 ----------- 4 files changed, 17 deletions(-) diff --git a/stubs/jsonschema/jsonschema/_format.pyi b/stubs/jsonschema/jsonschema/_format.pyi index b49fe49645c4..fdab126bb1fa 100644 --- a/stubs/jsonschema/jsonschema/_format.pyi +++ b/stubs/jsonschema/jsonschema/_format.pyi @@ -1,7 +1,5 @@ from typing import Any -from jsonschema.exceptions import FormatError as FormatError - class FormatChecker: checkers: Any def __init__(self, formats: Any | None = ...) -> None: ... diff --git a/stubs/jsonschema/jsonschema/_legacy_validators.pyi b/stubs/jsonschema/jsonschema/_legacy_validators.pyi index b33618a51310..40e61896d73a 100644 --- a/stubs/jsonschema/jsonschema/_legacy_validators.pyi +++ b/stubs/jsonschema/jsonschema/_legacy_validators.pyi @@ -1,5 +1,3 @@ -from jsonschema.exceptions import ValidationError as ValidationError - def dependencies_draft3(validator, dependencies, instance, schema) -> None: ... def disallow_draft3(validator, disallow, instance, schema) -> None: ... def extends_draft3(validator, extends, instance, schema) -> None: ... diff --git a/stubs/jsonschema/jsonschema/_types.pyi b/stubs/jsonschema/jsonschema/_types.pyi index 45a6718a8462..f93c84a0a494 100644 --- a/stubs/jsonschema/jsonschema/_types.pyi +++ b/stubs/jsonschema/jsonschema/_types.pyi @@ -1,7 +1,5 @@ from typing import Any -from jsonschema.exceptions import UndefinedTypeCheck as UndefinedTypeCheck - def is_array(checker, instance): ... def is_bool(checker, instance): ... def is_integer(checker, instance): ... diff --git a/stubs/jsonschema/jsonschema/_validators.pyi b/stubs/jsonschema/jsonschema/_validators.pyi index cedc0818a9e5..8afcc3c07b4c 100644 --- a/stubs/jsonschema/jsonschema/_validators.pyi +++ b/stubs/jsonschema/jsonschema/_validators.pyi @@ -1,14 +1,3 @@ -from jsonschema._utils import ( - ensure_list as ensure_list, - equal as equal, - extras_msg as extras_msg, - find_additional_properties as find_additional_properties, - types_msg as types_msg, - unbool as unbool, - uniq as uniq, -) -from jsonschema.exceptions import FormatError as FormatError, ValidationError as ValidationError - def patternProperties(validator, patternProperties, instance, schema) -> None: ... def propertyNames(validator, propertyNames, instance, schema) -> None: ... def additionalProperties(validator, aP, instance, schema) -> None: ... From 85cd084fadadce138d757c0630f5d50777baac21 Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Thu, 15 Jul 2021 15:49:53 +0100 Subject: [PATCH 8/9] Fixes --- stubs/jsonschema/jsonschema/_types.pyi | 2 +- stubs/jsonschema/jsonschema/_utils.pyi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/jsonschema/jsonschema/_types.pyi b/stubs/jsonschema/jsonschema/_types.pyi index f93c84a0a494..efbe6ba4e56d 100644 --- a/stubs/jsonschema/jsonschema/_types.pyi +++ b/stubs/jsonschema/jsonschema/_types.pyi @@ -23,4 +23,4 @@ class TypeChecker: draft3_type_checker: Any draft4_type_checker: Any draft6_type_checker: Any -draft7_type_checker = draft6_type_checker +draft7_type_checker: Any diff --git a/stubs/jsonschema/jsonschema/_utils.pyi b/stubs/jsonschema/jsonschema/_utils.pyi index d70c8508ff5c..596ec6472f06 100644 --- a/stubs/jsonschema/jsonschema/_utils.pyi +++ b/stubs/jsonschema/jsonschema/_utils.pyi @@ -1,6 +1,6 @@ from typing import Any, MutableMapping -class URIDict(MutableMapping): +class URIDict(MutableMapping[Any, Any]): def normalize(self, uri): ... store: Any def __init__(self, *args, **kwargs) -> None: ... From d4406c96aca2ab0c17797b73a7be368617ba8e88 Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Thu, 15 Jul 2021 16:11:24 +0100 Subject: [PATCH 9/9] Add stubtest_allowlist.txt --- stubs/jsonschema/@tests/stubtest_allowlist.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 stubs/jsonschema/@tests/stubtest_allowlist.txt diff --git a/stubs/jsonschema/@tests/stubtest_allowlist.txt b/stubs/jsonschema/@tests/stubtest_allowlist.txt new file mode 100644 index 000000000000..5f66c81014d0 --- /dev/null +++ b/stubs/jsonschema/@tests/stubtest_allowlist.txt @@ -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