id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
172,478 | import io
import re
import typing as t
import warnings
from functools import partial
from functools import update_wrapper
from itertools import chain
from ._internal import _make_encode_wrapper
from ._internal import _to_bytes
from ._internal import _to_str
from .sansio import utils as _sansio_utils
from .sansio.utils ... | Return the ``PATH_INFO`` from the WSGI environment and decode it unless ``charset`` is ``None``. :param environ: WSGI environment to get the path from. :param charset: The charset for the path info, or ``None`` if no decoding should be performed. :param errors: The decoding error handling. .. versionadded:: 0.9 |
172,479 | import io
import re
import typing as t
import warnings
from functools import partial
from functools import update_wrapper
from itertools import chain
from ._internal import _make_encode_wrapper
from ._internal import _to_bytes
from ._internal import _to_str
from .sansio import utils as _sansio_utils
from .sansio.utils ... | Return the ``SCRIPT_NAME`` from the WSGI environment and decode it unless `charset` is set to ``None``. :param environ: WSGI environment to get the path from. :param charset: The charset for the path, or ``None`` if no decoding should be performed. :param errors: The decoding error handling. .. deprecated:: 2.2 Will be... |
172,480 | import io
import re
import typing as t
import warnings
from functools import partial
from functools import update_wrapper
from itertools import chain
from ._internal import _make_encode_wrapper
from ._internal import _to_bytes
from ._internal import _to_str
from .sansio import utils as _sansio_utils
from .sansio.utils ... | Removes and returns the next segment of `PATH_INFO`, pushing it onto `SCRIPT_NAME`. Returns `None` if there is nothing left on `PATH_INFO`. If the `charset` is set to `None` bytes are returned. If there are empty segments (``'/foo//bar``) these are ignored but properly pushed to the `SCRIPT_NAME`: >>> env = {'SCRIPT_NA... |
172,481 | import io
import re
import typing as t
import warnings
from functools import partial
from functools import update_wrapper
from itertools import chain
from ._internal import _make_encode_wrapper
from ._internal import _to_bytes
from ._internal import _to_str
from .sansio import utils as _sansio_utils
from .sansio.utils ... | Returns the next segment on the `PATH_INFO` or `None` if there is none. Works like :func:`pop_path_info` without modifying the environment: >>> env = {'SCRIPT_NAME': '/foo', 'PATH_INFO': '/a/b'} >>> peek_path_info(env) 'a' >>> peek_path_info(env) 'a' If the `charset` is set to `None` bytes are returned. .. deprecated::... |
172,482 | import io
import re
import typing as t
import warnings
from functools import partial
from functools import update_wrapper
from itertools import chain
from ._internal import _make_encode_wrapper
from ._internal import _to_bytes
from ._internal import _to_str
from .sansio import utils as _sansio_utils
from .sansio.utils ... | Extracts the path info from the given URL (or WSGI environment) and path. The path info returned is a string. The URLs might also be IRIs. If the path info could not be determined, `None` is returned. Some examples: >>> extract_path_info('http://example.com/app', '/app/hello') '/hello' >>> extract_path_info('http://exa... |
172,483 | import io
import re
import typing as t
import warnings
from functools import partial
from functools import update_wrapper
from itertools import chain
from ._internal import _make_encode_wrapper
from ._internal import _to_bytes
from ._internal import _to_str
from .sansio import utils as _sansio_utils
from .sansio.utils ... | Safely iterates line-based over an input stream. If the input stream is not a :class:`LimitedStream` the `limit` parameter is mandatory. This uses the stream's :meth:`~file.read` method internally as opposite to the :meth:`~file.readline` method that is unsafe and can only be used in violation of the WSGI specification... |
172,484 | import typing as t
from types import TracebackType
from urllib.parse import urlparse
from warnings import warn
from ..datastructures import Headers
from ..http import is_entity_header
from ..wsgi import FileWrapper
if t.TYPE_CHECKING:
from _typeshed.wsgi import StartResponse
from _typeshed.wsgi import WSGIAppli... | null |
172,485 | import itertools
import linecache
import os
import re
import sys
import sysconfig
import traceback
import typing as t
from markupsafe import escape
from ..utils import cached_property
from .console import Console
class DebugFrameSummary(traceback.FrameSummary):
"""A :class:`traceback.FrameSummary` that can evaluate... | null |
172,486 | import itertools
import linecache
import os
import re
import sys
import sysconfig
import traceback
import typing as t
from markupsafe import escape
from ..utils import cached_property
from .console import Console
CONSOLE_HTML = (
HEADER
+ """\
<h1>Interactive Console</h1>
<div class="explanation">
In this conso... | null |
172,487 | import codecs
import re
import sys
import typing as t
from collections import deque
from traceback import format_exception_only
from markupsafe import escape
class DebugReprGenerator:
def __init__(self) -> None:
self._stack: t.List[t.Any] = []
list_repr = _sequence_repr_maker("[", "]", list)
tuple_r... | Creates a debug repr of an object as HTML string. |
172,488 | import codecs
import re
import sys
import typing as t
from collections import deque
from traceback import format_exception_only
from markupsafe import escape
missing = object()
class DebugReprGenerator:
def __init__(self) -> None:
self._stack: t.List[t.Any] = []
list_repr = _sequence_repr_maker("[", "]"... | Print the object details to stdout._write (for the interactive console of the web debugger. |
172,489 | import codecs
import re
import sys
import typing as t
from collections import deque
from traceback import format_exception_only
from markupsafe import escape
def _add_subclass_info(
inner: str, obj: object, base: t.Union[t.Type, t.Tuple[t.Type, ...]]
) -> str:
if isinstance(base, tuple):
for cls in base... | null |
172,490 | import codecs
import hashlib
import io
import json
import os
import sys
import atexit
import shutil
import tempfile
The provided code snippet includes necessary dependencies for implementing the `get_filename4code` function. Write a Python function `def get_filename4code(module, content, ext=None)` to solve the follow... | Generate filename based on content The function ensures that the (temporary) directory exists, so that the file can be written. By default, the directory won't be cleaned up, so a filter can use the directory as a cache and decide not to regenerate if there's no change. In case the user preferres the files to be tempor... |
172,491 | import codecs
import hashlib
import io
import json
import os
import sys
import atexit
import shutil
import tempfile
def get_value(kv, key, value = None):
"""get value from the keyvalues (options)"""
res = []
for k, v in kv:
if k == key:
value = v
else:
res.append([k, ... | get caption from the keyvalues (options) Example: if key == 'CodeBlock': [[ident, classes, keyvals], code] = value caption, typef, keyvals = get_caption(keyvals) ... return Para([Image([ident, [], keyvals], caption, [filename, typef])]) |
172,492 | import codecs
import hashlib
import io
import json
import os
import sys
import atexit
import shutil
import tempfile
The provided code snippet includes necessary dependencies for implementing the `get_extension` function. Write a Python function `def get_extension(format, default, **alternates)` to solve the following ... | get the extension for the result, needs a default and some specialisations Example: filetype = get_extension(format, "png", html="svg", latex="eps") |
172,493 | import codecs
import hashlib
import io
import json
import os
import sys
import atexit
import shutil
import tempfile
def toJSONFilters(actions):
"""Generate a JSON-to-JSON filter from stdin to stdout
The filter:
* reads a JSON-formatted pandoc document from stdin
* transforms it by walking the tree and p... | Like `toJSONFilters`, but takes a single action as argument. |
172,494 | import codecs
import hashlib
import io
import json
import os
import sys
import atexit
import shutil
import tempfile
The provided code snippet includes necessary dependencies for implementing the `attributes` function. Write a Python function `def attributes(attrs)` to solve the following problem:
Returns an attribute ... | Returns an attribute list, constructed from the dictionary attrs. |
172,495 | import codecs
import hashlib
import io
import json
import os
import sys
import atexit
import shutil
import tempfile
def elt(eltType, numargs):
def fun(*args):
lenargs = len(args)
if lenargs != numargs:
raise ValueError(eltType + ' expects ' + str(numargs) +
... | null |
172,496 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
_marker = object()
if hasattr(typing, 'Final') and sys.version_info[:2] >= (3, 7):
Final = typing.Final
# 3.7
else:
Final = _FinalForm('Final',
... | Check correct count for parameters of a generic cls (internal helper). This gives a nice error message in case of count mismatch. |
172,497 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
The provided code snippet includes necessary dependencies for implementing the `final` function. Write a Python function `def final(f)` to solve the follo... | This decorator can be used to indicate to type checkers that the decorated method cannot be overridden, and decorated class cannot be subclassed. For example: class Base: @final def done(self) -> None: ... class Sub(Base): def done(self) -> None: # Error reported by type checker ... @final class Leaf: ... class Other(L... |
172,498 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
class TypeVar(typing.TypeVar, _DefaultMixin, _root=True):
"""Type variable."""
__module__ = 'typing'
def __init__(self, name, *constraints, bou... | null |
172,499 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
_overload_dummy = typing._overload_dummy
The provided code snippet includes necessary dependencies for implementing the `overload` function. Write a Pytho... | Decorator for overloaded functions/methods. In a stub file, place two or more stub definitions for the same function in a row, each decorated with @overload. For example: @overload def utf8(value: None) -> None: ... @overload def utf8(value: bytes) -> bytes: ... @overload def utf8(value: str) -> bytes: ... In a non-stu... |
172,500 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
The provided code snippet includes necessary dependencies for implementing the `get_overloads` function. Write a Python function `def get_overloads(func)`... | Return all defined overloads for *func* as a sequence. |
172,501 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
The provided code snippet includes necessary dependencies for implementing the `clear_overloads` function. Write a Python function `def clear_overloads()`... | Clear all overloads in the registry. |
172,502 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
def _get_protocol_attrs(cls):
attrs = set()
for base in cls.__mro__[:-1]: # without object
if base.__name__ in ('Protocol', 'Generic'):
... | null |
172,503 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
def _collect_type_vars(types, typevar_types=None):
"""Collect all type variable contained in types in order of
first appearance (lexicographic orde... | Helper function used in Protocol.__init_subclass__ and _TypedDictMeta.__new__. The contents of this function are very similar to logic found in typing.Generic.__init_subclass__ on the CPython main branch. |
172,504 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
def _no_init(self, *args, **kwargs):
if type(self)._is_protocol:
raise TypeError('Protocols cannot be instantiated') | null |
172,505 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
if hasattr(typing, 'Protocol'):
Protocol = typing.Protocol
# 3.7
else:
class _ProtocolMeta(abc.ABCMeta): # noqa: B024
# This metaclass is ... | Mark a protocol class as a runtime protocol, so that it can be used with isinstance() and issubclass(). Raise TypeError if applied to a non-protocol class. This allows a simple-minded structural check very similar to the one-offs in collections.abc such as Hashable. |
172,506 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
if sys.version_info >= (3, 10):
elif sys.version_info >= (3, 9):
else:
if sys.version_info >= (3, 11):
from typing import Any
else:
if sys.version_info... | null |
172,507 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
def _dict_new(*args, **kwargs):
if not args:
raise TypeError('TypedDict.__new__(): not enough arguments')
_, args = args[0], a... | null |
172,508 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
if sys.version_info >= (3, 10):
elif sys.version_info >= (3, 9):
else:
if sys.version_info >= (3, 11):
from typing import Any
else:
if sys.version_info... | null |
172,509 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
The provided code snippet includes necessary dependencies for implementing the `is_typeddict` function. Write a Python function `def is_typeddict(tp)` to ... | Check if an annotation is a TypedDict class For example:: class Film(TypedDict): title: str year: int is_typeddict(Film) # => True is_typeddict(Union[list, str]) # => False |
172,510 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
The provided code snippet includes necessary dependencies for implementing the `assert_type` function. Write a Python function `def assert_type(__val, __t... | Assert (to the type checker) that the value is of the given type. When the type checker encounters a call to assert_type(), it emits an error if the value is not of the specified type:: def greet(name: str) -> None: assert_type(name, str) # ok assert_type(name, int) # type checker error At runtime this returns the firs... |
172,511 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
if hasattr(typing, 'Final') and sys.version_info[:2] >= (3, 7):
Final = typing.Final
# 3.7
else:
Final = _FinalForm('Final',
... | Return type hints for an object. This is often the same as obj.__annotations__, but it handles forward references encoded as string literals, adds Optional[t] if a default value equal to None is set and recursively replaces all 'Annotated[T, ...]', 'Required[T]' or 'NotRequired[T]' with 'T' (unless 'include_extras=True... |
172,512 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
if hasattr(typing, 'Annotated'):
Annotated = typing.Annotated
# Not exported and not a public API, but needed for get_origin() and get_args()
#... | Get type arguments with all substitutions performed. For unions, basic simplifications used by Union constructor are performed. Examples:: get_args(Dict[str, int]) == (str, int) get_args(int) == () get_args(Union[int, Union[T, int], str][int]) == (int, str) get_args(Union[int, Tuple[T, int]][str]) == (int, Tuple[str, i... |
172,513 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
The provided code snippet includes necessary dependencies for implementing the `TypeAlias` function. Write a Python function `def TypeAlias(self, paramete... | Special marker indicating that an assignment should be recognized as a proper type alias definition by type checkers. For example:: Predicate: TypeAlias = Callable[..., bool] It's invalid when used anywhere except as in the example above. |
172,514 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
def _concatenate_getitem(self, parameters):
if parameters == ():
raise TypeError("Cannot take a Concatenate of no types.")
if not isinstanc... | Used in conjunction with ``ParamSpec`` and ``Callable`` to represent a higher order function which adds, removes or transforms parameters of a callable. For example:: Callable[Concatenate[int, P], int] See PEP 612 for detailed information. |
172,515 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
The provided code snippet includes necessary dependencies for implementing the `TypeGuard` function. Write a Python function `def TypeGuard(self, paramete... | Special typing form used to annotate the return type of a user-defined type guard function. ``TypeGuard`` only accepts a single type argument. At runtime, functions marked this way should return a boolean. ``TypeGuard`` aims to benefit *type narrowing* -- a technique used by static type checkers to determine a more pre... |
172,516 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
The provided code snippet includes necessary dependencies for implementing the `LiteralString` function. Write a Python function `def LiteralString(self, ... | Represents an arbitrary literal string. Example:: from typing_extensions import LiteralString def query(sql: LiteralString) -> ...: ... query("SELECT * FROM table") # ok query(f"SELECT * FROM {input()}") # not ok See PEP 675 for details. |
172,517 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
The provided code snippet includes necessary dependencies for implementing the `Self` function. Write a Python function `def Self(self, params)` to solve ... | Used to spell the type of "self" in classes. Example:: from typing import Self class ReturnsSelf: def parse(self, data: bytes) -> Self: ... return self |
172,518 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
if hasattr(typing, "Unpack"): # 3.11+
Unpack = typing.Unpack
elif sys.version_info[:2] >= (3, 9):
class _UnpackAlias(typing._GenericAlias, _root=T... | A special typing construct to unpack a variadic type. For example: Shape = TypeVarTuple('Shape') Batch = NewType('Batch', int) def add_batch_axis( x: Array[Unpack[Shape]] ) -> Array[Batch, Unpack[Shape]]: ... |
172,519 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
if sys.version_info >= (3, 10):
elif sys.version_info >= (3, 9):
else:
T = typing.TypeVar('T')
if sys.version_info >= (3, 11):
from typing import ... | Reveal the inferred type of a variable. When a static type checker encounters a call to ``reveal_type()``, it will emit the inferred type of the argument:: x: int = 1 reveal_type(x) Running a static type checker (e.g., ``mypy``) on this example will produce output similar to 'Revealed type is "builtins.int"'. At runtim... |
172,520 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
if hasattr(typing, "Never"):
Never = typing.Never
else:
def Never(self, params):
"""The bottom type, a type that has no members.
Th... | Assert to the type checker that a line of code is unreachable. Example:: def int_or_str(arg: int | str) -> None: match arg: case int(): print("It's an int") case str(): print("It's a str") case _: assert_never(arg) If a type checker finds that a call to assert_never() is reachable, it will emit an error. At runtime, th... |
172,521 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
T = typing.TypeVar('T')
if sys.version_info >= (3, 11):
from typing import Any
else:
class Any(metaclass=_AnyMeta):
"""Special type in... | Decorator that marks a function, class, or metaclass as providing dataclass-like behavior. Example: from typing_extensions import dataclass_transform _T = TypeVar("_T") # Used on a decorator function @dataclass_transform() def create_model(cls: type[_T]) -> type[_T]: ... return cls @create_model class CustomerModel: id... |
172,522 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
The provided code snippet includes necessary dependencies for implementing the `override` function. Write a Python function `def override(__arg: _F) -> _F... | Indicate that a method is intended to override a method in a base class. Usage: class Base: def method(self) -> None: ... pass class Child(Base): @override def method(self) -> None: super().method() When this decorator is applied to a method, the type checker will validate that it overrides a method with the same name ... |
172,523 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
Type = typing.Type
The provided code snippet includes necessary dependencies for implementing the `deprecated` function. Write a Python function `def depr... | Indicate that a class, function or overload is deprecated. Usage: @deprecated("Use B instead") class A: pass @deprecated("Use g instead") def f(): pass @overload @deprecated("int support is deprecated") def g(x: int) -> int: ... @overload def g(x: str) -> int: ... When this decorator is applied to an object, the type c... |
172,524 | import abc
import collections
import collections.abc
import functools
import inspect
import operator
import sys
import types as _types
import typing
import warnings
if sys.version_info >= (3, 11):
NamedTuple = typing.NamedTuple
else:
_prohibited_namedtuple_fields = typing._prohibited
_special_namedtuple_fie... | null |
172,525 | from collections.abc import Mapping, MutableMapping, Sequence
from urllib.parse import urlsplit
import itertools
import json
import re
import sys
The provided code snippet includes necessary dependencies for implementing the `load_schema` function. Write a Python function `def load_schema(name)` to solve the following... | Load a schema from ./schemas/``name``.json and return it. |
172,526 | from collections.abc import Mapping, MutableMapping, Sequence
from urllib.parse import urlsplit
import itertools
import json
import re
import sys
The provided code snippet includes necessary dependencies for implementing the `format_as_index` function. Write a Python function `def format_as_index(container, indices)` ... | Construct a single string containing indexing operations for the indices. For example for a container ``bar``, [1, 2, "foo"] -> bar[1][2]["foo"] Arguments: container (str): A word to use for the thing being indexed indices (sequence): The indices to format. |
172,527 | from json import JSONDecodeError
from textwrap import dedent
import argparse
import json
import sys
import traceback
import warnings
import attr
from jsonschema.exceptions import SchemaError
from jsonschema.validators import RefResolver, validator_for
def _resolve_name_with_default(name):
if "." not in name:
... | null |
172,528 | from json import JSONDecodeError
from textwrap import dedent
import argparse
import json
import sys
import traceback
import warnings
import attr
from jsonschema.exceptions import SchemaError
from jsonschema.validators import RefResolver, validator_for
parser = argparse.ArgumentParser(
description="JSON Schema Valid... | null |
172,529 | from json import JSONDecodeError
from textwrap import dedent
import argparse
import json
import sys
import traceback
import warnings
import attr
from jsonschema.exceptions import SchemaError
from jsonschema.validators import RefResolver, validator_for
class _CannotLoadFile(Exception):
pass
class _Outputter:
_fo... | null |
172,530 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
_F = typing.TypeVar("_F", bound=_FormatCheckCallable)
class FormatChecker:
"""
A ``format`` property che... | null |
172,531 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
def is_email(instance: object) -> bool:
if not isinstance(instance, str):
return True
return "@... | null |
172,532 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
def is_ipv4(instance: object) -> bool:
if not isinstance(instance, str):
return True
return boo... | null |
172,533 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
def is_ipv6(instance: object) -> bool:
if not isinstance(instance, str):
return True
address = ... | null |
172,534 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
def is_host_name(instance: object) -> bool:
if not isinstance(instance, str):
return True
... | null |
172,535 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
def is_idn_host_name(instance: object) -> bool:
if not isinstance(instance, str):
return Tr... | null |
172,536 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
def validate_rfc3986(url, rule='URI'):
"""
Validates strings according to RFC3986
:param url: Stri... | null |
172,537 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
def validate_rfc3986(url, rule='URI'):
"""
Validates strings according to RFC3986
:param url: Stri... | null |
172,538 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
try:
import rfc3987
except ImportError:
with suppress(ImportError):
from rfc3986_validator impor... | null |
172,539 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
try:
import rfc3987
except ImportError:
with suppress(ImportError):
from rfc3986_validator impor... | null |
172,540 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
try:
import rfc3987
except ImportError:
with suppress(ImportError):
from rfc3986_validator impor... | null |
172,541 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
try:
import rfc3987
except ImportError:
with suppress(ImportError):
from rfc3986_validator impor... | null |
172,542 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
try:
import rfc3987
except ImportError:
with suppress(ImportError):
from rfc3986_validator impor... | null |
172,543 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
def is_regex(instance: object) -> bool:
if not isinstance(instance, str):
return True
return bo... | null |
172,544 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
def is_date(instance: object) -> bool:
if not isinstance(instance, str):
return True
return boo... | null |
172,545 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
def is_draft3_time(instance: object) -> bool:
if not isinstance(instance, str):
return True
ret... | null |
172,546 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
try:
import rfc3987
except ImportError:
with suppress(ImportError):
from rfc3986_validator impor... | null |
172,547 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
def is_json_pointer(instance: object) -> bool:
if not isinstance(instance, str):
return Tru... | null |
172,548 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
def is_relative_json_pointer(instance: object) -> bool:
# Definition taken from:
# https://tool... | null |
172,549 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
def is_uri_template(instance: object) -> bool:
if not isinstance(instance, str):
return Tru... | null |
172,550 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
def is_duration(instance: object) -> bool:
if not isinstance(instance, str):
return True
... | null |
172,551 | from __future__ import annotations
from contextlib import suppress
from uuid import UUID
import datetime
import ipaddress
import re
import typing
import warnings
from jsonschema.exceptions import FormatError
class UUID:
if sys.version_info >= (3, 7):
def __init__(
self,
hex: Optiona... | null |
172,552 | from jsonschema import _utils
from jsonschema.exceptions import ValidationError
def id_of_ignore_ref(property="$id"):
def id_of(schema):
"""
Ignore an ``$id`` sibling of ``$ref`` if it is present.
Otherwise, return the ID of the given schema.
"""
if schema is True or schema... | null |
172,553 | from jsonschema import _utils
from jsonschema.exceptions import ValidationError
The provided code snippet includes necessary dependencies for implementing the `ignore_ref_siblings` function. Write a Python function `def ignore_ref_siblings(schema)` to solve the following problem:
Ignore siblings of ``$ref`` if it is p... | Ignore siblings of ``$ref`` if it is present. Otherwise, return all keywords. Suitable for use with `create`'s ``applicable_validators`` argument. |
172,554 | from jsonschema import _utils
from jsonschema.exceptions import ValidationError
class ValidationError(_Error):
"""
An instance was invalid under a provided schema.
"""
_word_for_schema_in_error_message = "schema"
_word_for_instance_in_error_message = "instance"
def dependencies_draft3(validator, ... | null |
172,555 | from jsonschema import _utils
from jsonschema.exceptions import ValidationError
class ValidationError(_Error):
"""
An instance was invalid under a provided schema.
"""
_word_for_schema_in_error_message = "schema"
_word_for_instance_in_error_message = "instance"
The provided code snippet includes ... | Support for the ``dependencies`` keyword from pre-draft 2019-09. In later drafts, the keyword was split into separate ``dependentRequired`` and ``dependentSchemas`` validators. |
172,556 | from jsonschema import _utils
from jsonschema.exceptions import ValidationError
class ValidationError(_Error):
"""
An instance was invalid under a provided schema.
"""
_word_for_schema_in_error_message = "schema"
_word_for_instance_in_error_message = "instance"
def disallow_draft3(validator, disa... | null |
172,557 | from jsonschema import _utils
from jsonschema.exceptions import ValidationError
def extends_draft3(validator, extends, instance, schema):
if validator.is_type(extends, "object"):
yield from validator.descend(instance, extends)
return
for index, subschema in enumerate(extends):
yield fro... | null |
172,558 | from jsonschema import _utils
from jsonschema.exceptions import ValidationError
def items_draft3_draft4(validator, items, instance, schema):
if not validator.is_type(instance, "array"):
return
if validator.is_type(items, "object"):
for index, item in enumerate(instance):
yield from... | null |
172,559 | from jsonschema import _utils
from jsonschema.exceptions import ValidationError
def items_draft6_draft7_draft201909(validator, items, instance, schema):
if not validator.is_type(instance, "array"):
return
if validator.is_type(items, "array"):
for (index, item), subschema in zip(enumerate(insta... | null |
172,560 | from jsonschema import _utils
from jsonschema.exceptions import ValidationError
class ValidationError(_Error):
def minimum_draft3_draft4(validator, minimum, instance, schema):
if not validator.is_type(instance, "number"):
return
if schema.get("exclusiveMinimum", False):
failed = instance <= m... | null |
172,561 | from jsonschema import _utils
from jsonschema.exceptions import ValidationError
class ValidationError(_Error):
"""
An instance was invalid under a provided schema.
"""
_word_for_schema_in_error_message = "schema"
_word_for_instance_in_error_message = "instance"
def maximum_draft3_draft4(validator... | null |
172,562 | from jsonschema import _utils
from jsonschema.exceptions import ValidationError
class ValidationError(_Error):
"""
An instance was invalid under a provided schema.
"""
_word_for_schema_in_error_message = "schema"
_word_for_instance_in_error_message = "instance"
def properties_draft3(validator, pr... | null |
172,563 | from jsonschema import _utils
from jsonschema.exceptions import ValidationError
class ValidationError(_Error):
"""
An instance was invalid under a provided schema.
"""
_word_for_schema_in_error_message = "schema"
_word_for_instance_in_error_message = "instance"
def type_draft3(validator, types, i... | null |
172,564 | from jsonschema import _utils
from jsonschema.exceptions import ValidationError
class ValidationError(_Error):
"""
An instance was invalid under a provided schema.
"""
_word_for_schema_in_error_message = "schema"
_word_for_instance_in_error_message = "instance"
def contains_draft6_draft7(validato... | null |
172,565 | from jsonschema import _utils
from jsonschema.exceptions import ValidationError
def recursiveRef(validator, recursiveRef, instance, schema):
lookup_url, target = validator.resolver.resolution_scope, validator.schema
for each in reversed(validator.resolver._scopes_stack[1:]):
lookup_url, next_target = ... | null |
172,566 | from jsonschema import _utils
from jsonschema.exceptions import ValidationError
def find_evaluated_item_indexes_by_schema(validator, instance, schema):
"""
Get all indexes of items that get evaluated under the current schema
Covers all keywords related to unevaluatedItems: items, prefixItems, if,
then, ... | null |
172,567 | from fractions import Fraction
from urllib.parse import urldefrag, urljoin
import re
from jsonschema._utils import (
ensure_list,
equal,
extras_msg,
find_additional_properties,
find_evaluated_item_indexes_by_schema,
find_evaluated_property_keys_by_schema,
unbool,
uniq,
)
from jsonschema.... | null |
172,568 | from fractions import Fraction
from urllib.parse import urldefrag, urljoin
import re
from jsonschema._utils import (
ensure_list,
equal,
extras_msg,
find_additional_properties,
find_evaluated_item_indexes_by_schema,
find_evaluated_property_keys_by_schema,
unbool,
uniq,
)
from jsonschema.... | null |
172,569 | from fractions import Fraction
from urllib.parse import urldefrag, urljoin
import re
from jsonschema._utils import (
ensure_list,
equal,
extras_msg,
find_additional_properties,
find_evaluated_item_indexes_by_schema,
find_evaluated_property_keys_by_schema,
unbool,
uniq,
)
from jsonschema.... | null |
172,570 | from fractions import Fraction
from urllib.parse import urldefrag, urljoin
import re
from jsonschema._utils import (
ensure_list,
equal,
extras_msg,
find_additional_properties,
find_evaluated_item_indexes_by_schema,
find_evaluated_property_keys_by_schema,
unbool,
uniq,
)
from jsonschema.... | null |
172,571 | from fractions import Fraction
from urllib.parse import urldefrag, urljoin
import re
from jsonschema._utils import (
ensure_list,
equal,
extras_msg,
find_additional_properties,
find_evaluated_item_indexes_by_schema,
find_evaluated_property_keys_by_schema,
unbool,
uniq,
)
from jsonschema.... | null |
172,572 | from fractions import Fraction
from urllib.parse import urldefrag, urljoin
import re
from jsonschema._utils import (
ensure_list,
equal,
extras_msg,
find_additional_properties,
find_evaluated_item_indexes_by_schema,
find_evaluated_property_keys_by_schema,
unbool,
uniq,
)
from jsonschema.... | null |
172,573 | from fractions import Fraction
from urllib.parse import urldefrag, urljoin
import re
from jsonschema._utils import (
ensure_list,
equal,
extras_msg,
find_additional_properties,
find_evaluated_item_indexes_by_schema,
find_evaluated_property_keys_by_schema,
unbool,
uniq,
)
from jsonschema.... | null |
172,574 | from fractions import Fraction
from urllib.parse import urldefrag, urljoin
import re
from jsonschema._utils import (
ensure_list,
equal,
extras_msg,
find_additional_properties,
find_evaluated_item_indexes_by_schema,
find_evaluated_property_keys_by_schema,
unbool,
uniq,
)
from jsonschema.... | null |
172,575 | from fractions import Fraction
from urllib.parse import urldefrag, urljoin
import re
from jsonschema._utils import (
ensure_list,
equal,
extras_msg,
find_additional_properties,
find_evaluated_item_indexes_by_schema,
find_evaluated_property_keys_by_schema,
unbool,
uniq,
)
from jsonschema.... | null |
172,576 | from fractions import Fraction
from urllib.parse import urldefrag, urljoin
import re
from jsonschema._utils import (
ensure_list,
equal,
extras_msg,
find_additional_properties,
find_evaluated_item_indexes_by_schema,
find_evaluated_property_keys_by_schema,
unbool,
uniq,
)
from jsonschema.... | null |
172,577 | from fractions import Fraction
from urllib.parse import urldefrag, urljoin
import re
from jsonschema._utils import (
ensure_list,
equal,
extras_msg,
find_additional_properties,
find_evaluated_item_indexes_by_schema,
find_evaluated_property_keys_by_schema,
unbool,
uniq,
)
from jsonschema.... | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.