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 exception types for jsonschema._format #7990

Merged
merged 4 commits into from
May 30, 2022
Merged
Changes from 2 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
9 changes: 5 additions & 4 deletions stubs/jsonschema/jsonschema/_format.pyi
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from collections.abc import Callable, Iterable
from typing import Any, TypeVar
from typing import Any, TypeVar, Union

_F = TypeVar("_F", bound=Callable[..., Any])
_RaisesType = Union[type[Exception], tuple[type[Exception], ...]]
AlexWaygood marked this conversation as resolved.
Show resolved Hide resolved

class FormatChecker:
checkers: dict[str, tuple[Callable[[Any], bool], Exception | tuple[Exception, ...]]]
checkers: dict[str, tuple[Callable[[Any], bool], _RaisesType]]

def __init__(self, formats: Iterable[str] | None = ...) -> None: ...
def checks(self, format: str, raises: Exception | tuple[Exception, ...] = ...) -> Callable[[_F], _F]: ...
def checks(self, format: str, raises: _RaisesType = ...) -> Callable[[_F], _F]: ...
@classmethod
def cls_checks(cls, format: str, raises: Exception | tuple[Exception, ...] = ...) -> Callable[[_F], _F]: ...
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: ...

Expand Down