id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
1,632 | import warnings
from .std import TqdmExperimentalWarning
from .asyncio import tqdm as asyncio_tqdm
from .std import tqdm as std_tqdm
if notebook_tqdm != std_tqdm:
class tqdm(notebook_tqdm, asyncio_tqdm): # pylint: disable=inconsistent-mro
pass
else:
tqdm = asyncio_tqdm
tqdm = tqdm_asyncio
class tqdm(... | A shortcut for `tqdm.auto.tqdm(range(*args), **kwargs)`. |
1,633 | import re
from warnings import warn
from .std import TqdmExperimentalWarning
from .std import tqdm as std_tqdm
class tqdm_gui(std_tqdm): # pragma: no cover
"""Experimental Matplotlib GUI version of tqdm!"""
# TODO: @classmethod: write() on GUI?
def __init__(self, *args, **kwargs):
from collections ... | Shortcut for `tqdm.gui.tqdm(range(*args), **kwargs)`. |
1,634 | import typing
from ._compat import _AnnotationExtractor
from ._make import NOTHING, Factory, pipe
class _AnnotationExtractor:
"""
Extract type annotations from a callable, returning None whenever there
is none.
"""
__slots__ = ["sig"]
def __init__(self, callable):
try:
sel... | A converter that allows an attribute to be optional. An optional attribute is one which can be set to ``None``. Type annotations will be inferred from the wrapped converter's, if it has any. :param callable converter: the converter that is used for non-``None`` values. .. versionadded:: 17.1.0 |
1,635 | import typing
from ._compat import _AnnotationExtractor
from ._make import NOTHING, Factory, pipe
NOTHING = _Nothing.NOTHING
class Factory:
"""
Stores a factory callable.
If passed as the default value to `attrs... | A converter that allows to replace ``None`` values by *default* or the result of *factory*. :param default: Value to be used if ``None`` is passed. Passing an instance of `attrs.Factory` is supported, however the ``takes_self`` option is *not*. :param callable factory: A callable that takes no parameters whose result i... |
1,636 | import typing
from ._compat import _AnnotationExtractor
from ._make import NOTHING, Factory, pipe
The provided code snippet includes necessary dependencies for implementing the `to_bool` function. Write a Python function `def to_bool(val)` to solve the following problem:
Convert "boolean" strings (e.g., from env. vars... | Convert "boolean" strings (e.g., from env. vars.) to real booleans. Values mapping to :code:`True`: - :code:`True` - :code:`"true"` / :code:`"t"` - :code:`"yes"` / :code:`"y"` - :code:`"on"` - :code:`"1"` - :code:`1` Values mapping to :code:`False`: - :code:`False` - :code:`"false"` / :code:`"f"` - :code:`"no"` / :code... |
1,640 | import functools
import types
from ._make import _make_ne
def _make_init():
"""
Create __init__ method.
"""
def __init__(self, value):
"""
Initialize object with *value*.
"""
self.value = value
return __init__
def _make_operator(name, func):
"""
Create operato... | Create a class that can be passed into `attr.ib`'s ``eq``, ``order``, and ``cmp`` arguments to customize field comparison. The resulting class will have a full set of ordering methods if at least one of ``{lt, le, gt, ge}`` and ``eq`` are provided. :param Optional[callable] eq: `callable` used to evaluate equality of t... |
1,641 | from . import _config
from .exceptions import FrozenAttributeError
The provided code snippet includes necessary dependencies for implementing the `validate` function. Write a Python function `def validate(instance, attrib, new_value)` to solve the following problem:
Run *attrib*'s validator on *new_value* if it has on... | Run *attrib*'s validator on *new_value* if it has one. .. versionadded:: 20.1.0 |
1,642 | from . import _config
from .exceptions import FrozenAttributeError
The provided code snippet includes necessary dependencies for implementing the `convert` function. Write a Python function `def convert(instance, attrib, new_value)` to solve the following problem:
Run *attrib*'s converter -- if it has one -- on *new_v... | Run *attrib*'s converter -- if it has one -- on *new_value* and return the result. .. versionadded:: 20.1.0 |
1,643 | from ._make import Attribute
def _split_what(what):
"""
Returns a tuple of `frozenset`s of classes and attributes.
"""
return (
frozenset(cls for cls in what if isinstance(cls, type)),
frozenset(cls for cls in what if isinstance(cls, Attribute)),
)
The provided code snippet includes... | Include *what*. :param what: What to include. :type what: `list` of `type` or `attrs.Attribute`\\ s :rtype: `callable` |
1,644 | from ._make import Attribute
def _split_what(what):
"""
Returns a tuple of `frozenset`s of classes and attributes.
"""
return (
frozenset(cls for cls in what if isinstance(cls, type)),
frozenset(cls for cls in what if isinstance(cls, Attribute)),
)
The provided code snippet includes... | Exclude *what*. :param what: What to exclude. :type what: `list` of classes or `attrs.Attribute`\\ s. :rtype: `callable` |
1,645 | import operator
import re
from contextlib import contextmanager
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .exceptions import NotCallableError
def set_run_validators(run):
"""
Set whether or not ... | Globally disable or enable running validators. By default, they are run. :param disabled: If ``True``, disable running all validators. :type disabled: bool .. warning:: This function is not thread-safe! .. versionadded:: 21.3.0 |
1,646 | import operator
import re
from contextlib import contextmanager
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .exceptions import NotCallableError
def get_run_validators():
"""
Return whether or not ... | Return a bool indicating whether validators are currently disabled or not. :return: ``True`` if validators are currently disabled. :rtype: bool .. versionadded:: 21.3.0 |
1,647 | import operator
import re
from contextlib import contextmanager
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .exceptions import NotCallableError
def set_run_validators(run):
"""
Set whether or not ... | Context manager that disables running validators within its context. .. warning:: This context manager is not thread-safe! .. versionadded:: 21.3.0 |
1,648 | import operator
import re
from contextlib import contextmanager
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .exceptions import NotCallableError
class _InstanceOfValidator:
type = attrib()
def __cal... | A validator that raises a `TypeError` if the initializer is called with a wrong type for this particular attribute (checks are performed using `isinstance` therefore it's also valid to pass a tuple of types). :param type: The type to check for. :type type: type or tuple of type :raises TypeError: With a human readable ... |
1,649 | import operator
import re
from contextlib import contextmanager
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .exceptions import NotCallableError
try:
Pattern = re.Pattern
except AttributeError: # Pytho... | r""" A validator that raises `ValueError` if the initializer is called with a string that doesn't match *regex*. :param regex: a regex string or precompiled pattern to match against :param int flags: flags that will be passed to the underlying re function (default 0) :param callable func: which underlying `re` function... |
1,650 | import operator
import re
from contextlib import contextmanager
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .exceptions import NotCallableError
class _ProvidesValidator:
interface = attrib()
def __... | A validator that raises a `TypeError` if the initializer is called with an object that does not provide the requested *interface* (checks are performed using ``interface.providedBy(value)`` (see `zope.interface <https://zopeinterface.readthedocs.io/en/latest/>`_). :param interface: The interface to check for. :type int... |
1,651 | import operator
import re
from contextlib import contextmanager
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .exceptions import NotCallableError
class _OptionalValidator:
validator = attrib()
def __... | A validator that makes an attribute optional. An optional attribute is one which can be set to ``None`` in addition to satisfying the requirements of the sub-validator. :param validator: A validator (or a list of validators) that is used for non-``None`` values. :type validator: callable or `list` of callables. .. vers... |
1,652 | import operator
import re
from contextlib import contextmanager
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .exceptions import NotCallableError
class _InValidator:
options = attrib()
def __call__(s... | A validator that raises a `ValueError` if the initializer is called with a value that does not belong in the options provided. The check is performed using ``value in options``. :param options: Allowed options. :type options: list, tuple, `enum.Enum`, ... :raises ValueError: With a human readable error message, the att... |
1,653 | import operator
import re
from contextlib import contextmanager
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .exceptions import NotCallableError
class _IsCallableValidator:
def __call__(self, inst, attr... | A validator that raises a `attr.exceptions.NotCallableError` if the initializer is called with a value for this particular attribute that is not callable. .. versionadded:: 19.1.0 :raises `attr.exceptions.NotCallableError`: With a human readable error message containing the attribute (`attrs.Attribute`) name, and the v... |
1,654 | import operator
import re
from contextlib import contextmanager
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .exceptions import NotCallableError
class _DeepIterable:
member_validator = attrib(validator=... | A validator that performs deep validation of an iterable. :param member_validator: Validator(s) to apply to iterable members :param iterable_validator: Validator to apply to iterable itself (optional) .. versionadded:: 19.1.0 :raises TypeError: if any sub-validators fail |
1,655 | import operator
import re
from contextlib import contextmanager
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .exceptions import NotCallableError
class _DeepMapping:
key_validator = attrib(validator=is_c... | A validator that performs deep validation of a dictionary. :param key_validator: Validator to apply to dictionary keys :param value_validator: Validator to apply to dictionary values :param mapping_validator: Validator to apply to top-level mapping attribute (optional) .. versionadded:: 19.1.0 :raises TypeError: if any... |
1,656 | import operator
import re
from contextlib import contextmanager
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .exceptions import NotCallableError
class _NumberValidator:
bound = attrib()
compare_op =... | A validator that raises `ValueError` if the initializer is called with a number larger or equal to *val*. :param val: Exclusive upper bound for values .. versionadded:: 21.3.0 |
1,657 | import operator
import re
from contextlib import contextmanager
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .exceptions import NotCallableError
class _NumberValidator:
bound = attrib()
compare_op =... | A validator that raises `ValueError` if the initializer is called with a number greater than *val*. :param val: Inclusive upper bound for values .. versionadded:: 21.3.0 |
1,658 | import operator
import re
from contextlib import contextmanager
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .exceptions import NotCallableError
class _NumberValidator:
bound = attrib()
compare_op =... | A validator that raises `ValueError` if the initializer is called with a number smaller than *val*. :param val: Inclusive lower bound for values .. versionadded:: 21.3.0 |
1,659 | import operator
import re
from contextlib import contextmanager
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .exceptions import NotCallableError
class _NumberValidator:
bound = attrib()
compare_op =... | A validator that raises `ValueError` if the initializer is called with a number smaller or equal to *val*. :param val: Exclusive lower bound for values .. versionadded:: 21.3.0 |
1,660 | import operator
import re
from contextlib import contextmanager
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .exceptions import NotCallableError
class _MaxLengthValidator:
max_length = attrib()
def ... | A validator that raises `ValueError` if the initializer is called with a string or iterable that is longer than *length*. :param int length: Maximum length of the string or iterable .. versionadded:: 21.3.0 |
1,661 | import operator
import re
from contextlib import contextmanager
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .exceptions import NotCallableError
class _MinLengthValidator:
min_length = attrib()
def ... | A validator that raises `ValueError` if the initializer is called with a string or iterable that is shorter than *length*. :param int length: Minimum length of the string or iterable .. versionadded:: 22.1.0 |
1,662 | import operator
import re
from contextlib import contextmanager
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .exceptions import NotCallableError
class _SubclassOfValidator:
type = attrib()
def __cal... | A validator that raises a `TypeError` if the initializer is called with a wrong type for this particular attribute (checks are performed using `issubclass` therefore it's also valid to pass a tuple of types). :param type: The type to check for. :type type: type or tuple of types :raises TypeError: With a human readable... |
1,663 | import operator
import re
from contextlib import contextmanager
from ._config import get_run_validators, set_run_validators
from ._make import _AndValidator, and_, attrib, attrs
from .converters import default_if_none
from .exceptions import NotCallableError
class _NotValidator:
validator = attrib()
msg = attri... | A validator that wraps and logically 'inverts' the validator passed to it. It will raise a `ValueError` if the provided validator *doesn't* raise a `ValueError` or `TypeError` (by default), and will suppress the exception if the provided validator *does*. Intended to be used with existing validators to compose logic wi... |
1,668 | import copy
from ._make import NOTHING, _obj_setattr, fields
from .exceptions import AttrsAttributeNotFoundError
def has(cls):
"""
Check whether *cls* is a class with ``attrs`` attributes.
:param type cls: Class to introspect.
:raise TypeError: If *cls* is not a class.
:rtype: bool
"""
retur... | Return the ``attrs`` attribute values of *inst* as a tuple. Optionally recurse into other ``attrs``-decorated classes. :param inst: Instance of an ``attrs``-decorated class. :param bool recurse: Recurse into classes that are also ``attrs``-decorated. :param callable filter: A callable whose return code determines wheth... |
1,669 | import copy
from ._make import NOTHING, _obj_setattr, fields
from .exceptions import AttrsAttributeNotFoundError
_obj_setattr = object.__setattr__
NOTHING = _Nothing.NOTHING
def fields(cls):
"""
Return the tuple of ``attrs`` attributes for a ... | Copy *inst* and apply *changes*. :param inst: Instance of a class with ``attrs`` attributes. :param changes: Keyword changes in the new copy. :return: A copy of inst with *changes* incorporated. :raise attr.exceptions.AttrsAttributeNotFoundError: If *attr_name* couldn't be found on *cls*. :raise attr.exceptions.NotAnAt... |
1,670 | import copy
from ._make import NOTHING, _obj_setattr, fields
from .exceptions import AttrsAttributeNotFoundError
def fields(cls):
"""
Return the tuple of ``attrs`` attributes for a class.
The tuple also allows accessing the fields by their names (see below for
examples).
:param type cls: Class to... | Create a new instance, based on *inst* with *changes* applied. :param inst: Instance of a class with ``attrs`` attributes. :param changes: Keyword changes in the new copy. :return: A copy of inst with *changes* incorporated. :raise TypeError: If *attr_name* couldn't be found in the class ``__init__``. :raise attr.excep... |
1,671 | import copy
from ._make import NOTHING, _obj_setattr, fields
from .exceptions import AttrsAttributeNotFoundError
_obj_setattr = object.__setattr__
def fields(cls):
"""
Return the tuple of ``attrs`` attributes for a class.
The tuple also ... | Resolve any strings and forward annotations in type annotations. This is only required if you need concrete types in `Attribute`'s *type* field. In other words, you don't need to resolve your types if you only use them for static type checking. With no arguments, names will be looked up in the module in which the class... |
1,672 | import inspect
import platform
import sys
import threading
import types
import warnings
from collections.abc import Mapping, Sequence
PYPY = platform.python_implementation() == "PyPy"
def just_warn(*args, **kw):
warnings.warn(
"Running interpreter doesn't sufficiently support code object "
"introsp... | Return a function of two arguments (cell, value) which sets the value stored in the closure cell `cell` to `value`. |
1,673 | from functools import partial
from . import setters
from ._funcs import asdict as _asdict
from ._funcs import astuple as _astuple
from ._make import (
NOTHING,
_frozen_setattrs,
_ng_default_on_setattr,
attrib,
attrs,
)
from .exceptions import UnannotatedAttributeError
_ng_default_on_setattr = sette... | r""" Define an ``attrs`` class. Differences to the classic `attr.s` that it uses underneath: - Automatically detect whether or not *auto_attribs* should be `True` (c.f. *auto_attribs* parameter). - If *frozen* is `False`, run converters and validators when setting an attribute by default. - *slots=True* .. caution:: Us... |
1,674 | from functools import partial
from . import setters
from ._funcs import asdict as _asdict
from ._funcs import astuple as _astuple
from ._make import (
NOTHING,
_frozen_setattrs,
_ng_default_on_setattr,
attrib,
attrs,
)
from .exceptions import UnannotatedAttributeError
NOTHING = _Nothing.NOTHING
... | Identical to `attr.ib`, except keyword-only and with some arguments removed. .. versionadded:: 20.1.0 |
1,675 | from functools import partial
from . import setters
from ._funcs import asdict as _asdict
from ._funcs import astuple as _astuple
from ._make import (
NOTHING,
_frozen_setattrs,
_ng_default_on_setattr,
attrib,
attrs,
)
from .exceptions import UnannotatedAttributeError
The provided code snippet incl... | Same as `attr.asdict`, except that collections types are always retained and dict is always used as *dict_factory*. .. versionadded:: 21.3.0 |
1,676 | from functools import partial
from . import setters
from ._funcs import asdict as _asdict
from ._funcs import astuple as _astuple
from ._make import (
NOTHING,
_frozen_setattrs,
_ng_default_on_setattr,
attrib,
attrs,
)
from .exceptions import UnannotatedAttributeError
The provided code snippet incl... | Same as `attr.astuple`, except that collections types are always retained and `tuple` is always used as the *tuple_factory*. .. versionadded:: 21.3.0 |
1,697 | import copy
import enum
import linecache
import sys
import types
import typing
from operator import itemgetter
from . import _compat, _config, setters
from ._compat import PY310, PYPY, _AnnotationExtractor, set_closure_cell
from .exceptions import (
DefaultAlreadySetError,
FrozenInstanceError,
NotAnAttrsCla... | Transform all `_CountingAttr`s on a class into `Attribute`s. If *these* is passed, use that and don't look for them on the class. *collect_by_mro* is True, collect them in the correct MRO order, otherwise use the old -- incorrect -- order. See #428. Return an `_Attributes`. |
1,698 | import copy
import enum
import linecache
import sys
import types
import typing
from operator import itemgetter
from . import _compat, _config, setters
from ._compat import PY310, PYPY, _AnnotationExtractor, set_closure_cell
from .exceptions import (
DefaultAlreadySetError,
FrozenInstanceError,
NotAnAttrsCla... | Attached to frozen classes as __delattr__. |
1,699 | import copy
import enum
import linecache
import sys
import types
import typing
from operator import itemgetter
from . import _compat, _config, setters
from ._compat import PY310, PYPY, _AnnotationExtractor, set_closure_cell
from .exceptions import (
DefaultAlreadySetError,
FrozenInstanceError,
NotAnAttrsCla... | Add a hash method to *cls*. |
1,700 | import copy
import enum
import linecache
import sys
import types
import typing
from operator import itemgetter
from . import _compat, _config, setters
from ._compat import PY310, PYPY, _AnnotationExtractor, set_closure_cell
from .exceptions import (
DefaultAlreadySetError,
FrozenInstanceError,
NotAnAttrsCla... | Create ordering methods for *cls* with *attrs*. |
1,701 | import copy
import enum
import linecache
import sys
import types
import typing
from operator import itemgetter
from . import _compat, _config, setters
from ._compat import PY310, PYPY, _AnnotationExtractor, set_closure_cell
from .exceptions import (
DefaultAlreadySetError,
FrozenInstanceError,
NotAnAttrsCla... | Add equality methods to *cls* with *attrs*. |
1,702 | import copy
import enum
import linecache
import sys
import types
import typing
from operator import itemgetter
from . import _compat, _config, setters
from ._compat import PY310, PYPY, _AnnotationExtractor, set_closure_cell
from .exceptions import (
DefaultAlreadySetError,
FrozenInstanceError,
NotAnAttrsCla... | Add a repr method to *cls*. |
1,703 | import copy
import enum
import linecache
import sys
import types
import typing
from operator import itemgetter
from . import _compat, _config, setters
from ._compat import PY310, PYPY, _AnnotationExtractor, set_closure_cell
from .exceptions import (
DefaultAlreadySetError,
FrozenInstanceError,
NotAnAttrsCla... | Return an ordered dictionary of ``attrs`` attributes for a class, whose keys are the attribute names. :param type cls: Class to introspect. :raise TypeError: If *cls* is not a class. :raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs`` class. :rtype: dict .. versionadded:: 18.1.0 |
1,704 | import copy
import enum
import linecache
import sys
import types
import typing
from operator import itemgetter
from . import _compat, _config, setters
from ._compat import PY310, PYPY, _AnnotationExtractor, set_closure_cell
from .exceptions import (
DefaultAlreadySetError,
FrozenInstanceError,
NotAnAttrsCla... | Validate all attributes on *inst* that have a validator. Leaves all exceptions through. :param inst: Instance of a class with ``attrs`` attributes. |
1,705 | import copy
import enum
import linecache
import sys
import types
import typing
from operator import itemgetter
from . import _compat, _config, setters
from ._compat import PY310, PYPY, _AnnotationExtractor, set_closure_cell
from .exceptions import (
DefaultAlreadySetError,
FrozenInstanceError,
NotAnAttrsCla... | A quick way to create a new class called *name* with *attrs*. :param str name: The name for the new class. :param attrs: A list of names or a dictionary of mappings of names to attributes. The order is deduced from the order of the names or attributes inside *attrs*. Otherwise the order of the definition of the attribu... |
1,706 | import asyncio
import signal
import socket
from abc import ABC, abstractmethod
from typing import Any, List, Optional, Set
from yarl import URL
from .web_app import Application
from .web_server import Server
class GracefulExit(SystemExit):
code = 1
def _raise_graceful_exit() -> None:
raise GracefulExit() | null |
1,707 | import base64
import binascii
import json
import re
import uuid
import warnings
import zlib
from collections import deque
from types import TracebackType
from typing import (
TYPE_CHECKING,
Any,
AsyncIterator,
Deque,
Dict,
Iterator,
List,
Mapping,
Optional,
Sequence,
Tuple,
... | null |
1,708 | import base64
import binascii
import json
import re
import uuid
import warnings
import zlib
from collections import deque
from types import TracebackType
from typing import (
TYPE_CHECKING,
Any,
AsyncIterator,
Deque,
Dict,
Iterator,
List,
Mapping,
Optional,
Sequence,
Tuple,
... | null |
1,709 | import asyncio
import enum
import io
import json
import mimetypes
import os
import warnings
from abc import ABC, abstractmethod
from itertools import chain
from typing import (
IO,
TYPE_CHECKING,
Any,
ByteString,
Dict,
Iterable,
Optional,
TextIO,
Tuple,
Type,
Union,
)
from mu... | null |
1,710 | import asyncio
import enum
import io
import json
import mimetypes
import os
import warnings
from abc import ABC, abstractmethod
from itertools import chain
from typing import (
IO,
TYPE_CHECKING,
Any,
ByteString,
Dict,
Iterable,
Optional,
TextIO,
Tuple,
Type,
Union,
)
from mu... | null |
1,711 | import abc
import asyncio
import base64
import hashlib
import inspect
import keyword
import os
import re
import warnings
from contextlib import contextmanager
from functools import wraps
from pathlib import Path
from types import MappingProxyType
from typing import (
TYPE_CHECKING,
Any,
Awaitable,
Calla... | Default handler for Expect header. Just send "100 Continue" to client. raise HTTPExpectationFailed if value of header is not "100-continue" |
1,712 | import abc
import asyncio
import base64
import hashlib
import inspect
import keyword
import os
import re
import warnings
from contextlib import contextmanager
from functools import wraps
from pathlib import Path
from types import MappingProxyType
from typing import (
TYPE_CHECKING,
Any,
Awaitable,
Calla... | null |
1,713 | import abc
import asyncio
import base64
import hashlib
import inspect
import keyword
import os
import re
import warnings
from contextlib import contextmanager
from functools import wraps
from pathlib import Path
from types import MappingProxyType
from typing import (
TYPE_CHECKING,
Any,
Awaitable,
Calla... | null |
1,714 | import asyncio
import codecs
import functools
import io
import re
import sys
import traceback
import warnings
from hashlib import md5, sha1, sha256
from http.cookies import CookieError, Morsel, SimpleCookie
from types import MappingProxyType, TracebackType
from typing import (
TYPE_CHECKING,
Any,
Dict,
... | null |
1,715 | import asyncio
import codecs
import functools
import io
import re
import sys
import traceback
import warnings
from hashlib import md5, sha1, sha256
from http.cookies import CookieError, Morsel, SimpleCookie
from types import MappingProxyType, TracebackType
from typing import (
TYPE_CHECKING,
Any,
Dict,
... | null |
1,716 | import asyncio
import zlib
from typing import Any, Awaitable, Callable, NamedTuple, Optional, Union
from multidict import CIMultiDict
from .abc import AbstractStreamWriter
from .base_protocol import BaseProtocol
from .helpers import NO_EXTENSIONS
def _safe_header(string: str) -> str:
if "\r" in string or "\n" in s... | null |
1,717 | import asyncio
import collections
import json
import random
import re
import sys
import zlib
from enum import IntEnum
from struct import Struct
from typing import Any, Callable, List, Optional, Pattern, Set, Tuple, Union, cast
from .base_protocol import BaseProtocol
from .helpers import NO_EXTENSIONS
from .streams impo... | Websocket masking function. `mask` is a `bytes` object of length 4; `data` is a `bytearray` object of any length. The contents of `data` are masked with `mask`, as specified in section 5.3 of RFC 6455. Note that this function mutates the `data` argument. This pure-python implementation may be replaced by an optimized v... |
1,718 | import asyncio
import collections
import json
import random
import re
import sys
import zlib
from enum import IntEnum
from struct import Struct
from typing import Any, Callable, List, Optional, Pattern, Set, Tuple, Union, cast
from .base_protocol import BaseProtocol
from .helpers import NO_EXTENSIONS
from .streams impo... | null |
1,719 | import asyncio
import collections
import json
import random
import re
import sys
import zlib
from enum import IntEnum
from struct import Struct
from typing import Any, Callable, List, Optional, Pattern, Set, Tuple, Union, cast
from .base_protocol import BaseProtocol
from .helpers import NO_EXTENSIONS
from .streams impo... | null |
1,720 | import re
from typing import TYPE_CHECKING, Awaitable, Callable, Tuple, Type, TypeVar
from .typedefs import Handler
from .web_exceptions import HTTPPermanentRedirect, _HTTPMove
from .web_request import Request
from .web_response import StreamResponse
from .web_urldispatcher import SystemRoute
async def _check_request_r... | Factory for producing a middleware that normalizes the path of a request. Normalizing means: - Add or remove a trailing slash to the path. - Double slashes are replaced by one. The middleware returns as soon as it finds a path that resolves correctly. The order if both merge and append/remove are enabled is 1) merge sl... |
1,721 | import re
from typing import TYPE_CHECKING, Awaitable, Callable, Tuple, Type, TypeVar
from .typedefs import Handler
from .web_exceptions import HTTPPermanentRedirect, _HTTPMove
from .web_request import Request
from .web_response import StreamResponse
from .web_urldispatcher import SystemRoute
def middleware(f: _Func) -... | null |
1,722 | import abc
import os
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Iterator,
List,
Optional,
Sequence,
Type,
Union,
overload,
)
import attr
from . import hdrs
from .abc import AbstractView
from .typedefs import Handler, PathLike
_HandlerType = Union[Type[AbstractV... | null |
1,723 | import abc
import os
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Iterator,
List,
Optional,
Sequence,
Type,
Union,
overload,
)
import attr
from . import hdrs
from .abc import AbstractView
from .typedefs import Handler, PathLike
_HandlerType = Union[Type[AbstractV... | null |
1,724 | import abc
import os
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Iterator,
List,
Optional,
Sequence,
Type,
Union,
overload,
)
import attr
from . import hdrs
from .abc import AbstractView
from .typedefs import Handler, PathLike
_HandlerType = Union[Type[AbstractV... | null |
1,725 | import abc
import os
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Iterator,
List,
Optional,
Sequence,
Type,
Union,
overload,
)
import attr
from . import hdrs
from .abc import AbstractView
from .typedefs import Handler, PathLike
_HandlerType = Union[Type[AbstractV... | null |
1,726 | import abc
import os
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Iterator,
List,
Optional,
Sequence,
Type,
Union,
overload,
)
import attr
from . import hdrs
from .abc import AbstractView
from .typedefs import Handler, PathLike
_HandlerType = Union[Type[AbstractV... | null |
1,727 | import abc
import os
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Iterator,
List,
Optional,
Sequence,
Type,
Union,
overload,
)
import attr
from . import hdrs
from .abc import AbstractView
from .typedefs import Handler, PathLike
_HandlerType = Union[Type[AbstractV... | null |
1,728 | import abc
import os
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Iterator,
List,
Optional,
Sequence,
Type,
Union,
overload,
)
import attr
from . import hdrs
from .abc import AbstractView
from .typedefs import Handler, PathLike
class RouteDef(AbstractRouteDef):
... | null |
1,729 | import abc
import os
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
Iterator,
List,
Optional,
Sequence,
Type,
Union,
overload,
)
import attr
from . import hdrs
from .abc import AbstractView
from .typedefs import Handler, PathLike
class StaticDef(AbstractRouteDef):
... | null |
1,730 | import asyncio
import socket
from contextlib import suppress
from typing import Optional
def tcp_keepalive(transport: asyncio.Transport) -> None:
sock = transport.get_extra_info("socket")
if sock is not None:
sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) | null |
1,731 | import asyncio
import socket
from contextlib import suppress
from typing import Optional
def tcp_keepalive(transport: asyncio.Transport) -> None: # pragma: no cover
pass | null |
1,732 | import asyncio
import socket
from contextlib import suppress
from typing import Optional
def tcp_nodelay(transport: asyncio.Transport, value: bool) -> None:
sock = transport.get_extra_info("socket")
if sock is None:
return
if sock.family not in (socket.AF_INET, socket.AF_INET6):
return
... | null |
1,733 | import asyncio
import base64
import hashlib
import json
import os
import sys
import traceback
import warnings
from contextlib import suppress
from types import SimpleNamespace, TracebackType
from typing import (
Any,
Awaitable,
Callable,
Coroutine,
FrozenSet,
Generator,
Generic,
Iterable... | Constructs and sends a request. Returns response object. method - HTTP method url - request url params - (optional) Dictionary or bytes to be sent in the query string of the new request data - (optional) Dictionary, bytes, or file-like object to send in the body of the request json - (optional) Any json compatible pyth... |
1,734 | import asyncio
import logging
import socket
import sys
from argparse import ArgumentParser
from collections.abc import Iterable
from importlib import import_module
from typing import (
Any,
Awaitable,
Callable,
Iterable as TypingIterable,
List,
Optional,
Set,
Type,
Union,
cast,
)... | Run an app locally |
1,735 | import asyncio
import base64
import binascii
import datetime
import functools
import inspect
import netrc
import os
import platform
import re
import sys
import time
import warnings
import weakref
from collections import namedtuple
from contextlib import suppress
from email.parser import HeaderParser
from email.utils im... | null |
1,736 | import asyncio
import base64
import binascii
import datetime
import functools
import inspect
import netrc
import os
import platform
import re
import sys
import time
import warnings
import weakref
from collections import namedtuple
from contextlib import suppress
from email.parser import HeaderParser
from email.utils im... | null |
1,737 | import asyncio
import base64
import binascii
import datetime
import functools
import inspect
import netrc
import os
import platform
import re
import sys
import time
import warnings
import weakref
from collections import namedtuple
from contextlib import suppress
from email.parser import HeaderParser
from email.utils im... | Get a permitted proxy for the given URL from the env. |
1,738 | import asyncio
import base64
import binascii
import datetime
import functools
import inspect
import netrc
import os
import platform
import re
import sys
import time
import warnings
import weakref
from collections import namedtuple
from contextlib import suppress
from email.parser import HeaderParser
from email.utils im... | Parses a MIME type into its components. mimetype is a MIME type string. Returns a MimeType object. Example: >>> parse_mimetype('text/html; charset=utf-8') MimeType(type='text', subtype='html', suffix='', parameters={'charset': 'utf-8'}) |
1,739 | import asyncio
import base64
import binascii
import datetime
import functools
import inspect
import netrc
import os
import platform
import re
import sys
import time
import warnings
import weakref
from collections import namedtuple
from contextlib import suppress
from email.parser import HeaderParser
from email.utils im... | null |
1,740 | import asyncio
import base64
import binascii
import datetime
import functools
import inspect
import netrc
import os
import platform
import re
import sys
import time
import warnings
import weakref
from collections import namedtuple
from contextlib import suppress
from email.parser import HeaderParser
from email.utils im... | Sets ``Content-Disposition`` header for MIME. This is the MIME payload Content-Disposition header from RFC 2183 and RFC 7579 section 4.2, not the HTTP Content-Disposition from RFC 6266. disptype is a disposition type: inline, attachment, form-data. Should be valid extension token (see RFC 2183) quote_fields performs va... |
1,741 | import asyncio
import base64
import binascii
import datetime
import functools
import inspect
import netrc
import os
import platform
import re
import sys
import time
import warnings
import weakref
from collections import namedtuple
from contextlib import suppress
from email.parser import HeaderParser
from email.utils im... | null |
1,742 | import asyncio
import base64
import binascii
import datetime
import functools
import inspect
import netrc
import os
import platform
import re
import sys
import time
import warnings
import weakref
from collections import namedtuple
from contextlib import suppress
from email.parser import HeaderParser
from email.utils im... | null |
1,743 | import asyncio
import base64
import binascii
import datetime
import functools
import inspect
import netrc
import os
import platform
import re
import sys
import time
import warnings
import weakref
from collections import namedtuple
from contextlib import suppress
from email.parser import HeaderParser
from email.utils im... | Return current time rounded up to the next whole second. |
1,744 | import asyncio
import base64
import binascii
import datetime
import functools
import inspect
import netrc
import os
import platform
import re
import sys
import time
import warnings
import weakref
from collections import namedtuple
from contextlib import suppress
from email.parser import HeaderParser
from email.utils im... | null |
1,745 | import asyncio
import base64
import binascii
import datetime
import functools
import inspect
import netrc
import os
import platform
import re
import sys
import time
import warnings
import weakref
from collections import namedtuple
from contextlib import suppress
from email.parser import HeaderParser
from email.utils im... | null |
1,746 | import asyncio
import base64
import binascii
import datetime
import functools
import inspect
import netrc
import os
import platform
import re
import sys
import time
import warnings
import weakref
from collections import namedtuple
from contextlib import suppress
from email.parser import HeaderParser
from email.utils im... | null |
1,747 | import asyncio
import base64
import binascii
import datetime
import functools
import inspect
import netrc
import os
import platform
import re
import sys
import time
import warnings
import weakref
from collections import namedtuple
from contextlib import suppress
from email.parser import HeaderParser
from email.utils im... | null |
1,748 | import asyncio
import base64
import binascii
import datetime
import functools
import inspect
import netrc
import os
import platform
import re
import sys
import time
import warnings
import weakref
from collections import namedtuple
from contextlib import suppress
from email.parser import HeaderParser
from email.utils im... | null |
1,749 | import asyncio
import base64
import binascii
import datetime
import functools
import inspect
import netrc
import os
import platform
import re
import sys
import time
import warnings
import weakref
from collections import namedtuple
from contextlib import suppress
from email.parser import HeaderParser
from email.utils im... | null |
1,750 | import asyncio
import base64
import binascii
import datetime
import functools
import inspect
import netrc
import os
import platform
import re
import sys
import time
import warnings
import weakref
from collections import namedtuple
from contextlib import suppress
from email.parser import HeaderParser
from email.utils im... | null |
1,751 | import asyncio
import base64
import binascii
import datetime
import functools
import inspect
import netrc
import os
import platform
import re
import sys
import time
import warnings
import weakref
from collections import namedtuple
from contextlib import suppress
from email.parser import HeaderParser
from email.utils im... | Process a date string, return a datetime object |
1,752 | import asyncio
import collections.abc
import datetime
import enum
import json
import math
import time
import warnings
import zlib
from concurrent.futures import Executor
from http.cookies import Morsel, SimpleCookie
from typing import (
TYPE_CHECKING,
Any,
Dict,
Iterator,
Mapping,
MutableMapping... | null |
1,753 | from __future__ import absolute_import
import binascii
import codecs
import os
from io import BytesIO
from .fields import RequestField
from .packages import six
from .packages.six import b
The provided code snippet includes necessary dependencies for implementing the `iter_fields` function. Write a Python function `de... | .. deprecated:: 1.6 Iterate over fields. The addition of :class:`~urllib3.fields.RequestField` makes this function obsolete. Instead, use :func:`iter_field_objects`, which returns :class:`~urllib3.fields.RequestField` objects. Supports list of (k, v) tuples and dicts. |
1,754 | from __future__ import absolute_import
import binascii
import codecs
import os
from io import BytesIO
from .fields import RequestField
from .packages import six
from .packages.six import b
writer = codecs.lookup("utf-8")[3]
def choose_boundary():
"""
Our embarrassingly-simple replacement for mimetools.choose_bo... | Encode a dictionary of ``fields`` using the multipart/form-data MIME format. :param fields: Dictionary of fields or list of (key, :class:`~urllib3.fields.RequestField`). :param boundary: If not specified, then a random boundary will be generated using :func:`urllib3.filepost.choose_boundary`. |
1,755 | from __future__ import absolute_import
import platform
from ctypes import (
CDLL,
CFUNCTYPE,
POINTER,
c_bool,
c_byte,
c_char_p,
c_int32,
c_long,
c_size_t,
c_uint32,
c_ulong,
c_void_p,
)
from ctypes.util import find_library
from ...packages.six import raise_from
version_in... | Loads a CDLL by name, falling back to known path on 10.16+ |
1,756 | import base64
import ctypes
import itertools
import os
import re
import ssl
import struct
import tempfile
from .bindings import CFConst, CoreFoundation, Security
CoreFoundation = load_cdll(
"CoreFoundation",
"/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation",
)
The provided code snippet incl... | Given a list of Python tuples, create an associated CFDictionary. |
1,757 | import base64
import ctypes
import itertools
import os
import re
import ssl
import struct
import tempfile
from .bindings import CFConst, CoreFoundation, Security
def _cfstr(py_bstr):
"""
Given a Python binary data, create a CFString.
The string must be CFReleased by the caller.
"""
c_str = ctypes.c_... | Given a list of Python binary data, create an associated CFMutableArray. The array must be CFReleased by the caller. Raises an ssl.SSLError on failure. |
1,758 | import base64
import ctypes
import itertools
import os
import re
import ssl
import struct
import tempfile
from .bindings import CFConst, CoreFoundation, Security
_PEM_CERTS_RE = re.compile(
b"-----BEGIN CERTIFICATE-----\n(.*?)\n-----END CERTIFICATE-----", re.DOTALL
)
def _cf_data_from_bytes(bytestring):
"""
... | Given a bundle of certs in PEM format, turns them into a CFArray of certs that can be used to validate a cert chain. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.