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

Fix jsonschema._format.pyi to match upstream #8673

Merged
merged 4 commits into from
Sep 3, 2022
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
16 changes: 2 additions & 14 deletions stubs/jsonschema/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,2 @@
jsonschema._format.is_css21_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
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
# TODO: remove _FormatCheckCallable when mypy 0.980 is released
jsonschema._format._FormatCheckCallable
3 changes: 3 additions & 0 deletions stubs/jsonschema/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
version = "4.15.*"

[tool.stubtest]
extras = ["format"]
11 changes: 6 additions & 5 deletions stubs/jsonschema/jsonschema/_format.pyi
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
from collections.abc import Callable, Iterable
from typing import Any, TypeVar, Union
from typing import TypeVar, Union
from typing_extensions import TypeAlias

_F = TypeVar("_F", bound=Callable[..., Any])
_FormatCheckCallable: TypeAlias = Callable[[object], bool]
_F = TypeVar("_F", bound=_FormatCheckCallable)
_RaisesType: TypeAlias = Union[type[Exception], tuple[type[Exception], ...]]

class FormatChecker:
checkers: dict[str, tuple[Callable[[Any], bool], _RaisesType]]
checkers: dict[str, tuple[_FormatCheckCallable, _RaisesType]]

def __init__(self, formats: Iterable[str] | None = ...) -> None: ...
def checks(self, format: str, raises: _RaisesType = ...) -> Callable[[_F], _F]: ...
@classmethod
def cls_checks(cls, format: str, raises: _RaisesType = ...) -> Callable[[_F], _F]: ...
def check(self, instance: Any, format: str) -> None: ...
def conforms(self, instance: Any, format: str) -> bool: ...
def check(self, instance: object, format: str) -> None: ...
def conforms(self, instance: object, format: str) -> bool: ...

draft3_format_checker: FormatChecker
draft4_format_checker: FormatChecker
Expand Down