aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorzubchick <zubchick@yandex-team.ru>2022-02-10 16:48:22 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:22 +0300
commitdd8b8ab59eaee9938ca16f368506d69ef2509b74 (patch)
tree5c9577458a79ca3e1acff2fd150ca398031a66e7 /contrib
parent01fa2667d0e5e868b18424bc1906146e5ee340db (diff)
downloadydb-dd8b8ab59eaee9938ca16f368506d69ef2509b74.tar.gz
Restoring authorship annotation for <zubchick@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/python/attrs/.dist-info/METADATA8
-rw-r--r--contrib/python/attrs/README.rst2
-rw-r--r--contrib/python/attrs/attr/__init__.py2
-rw-r--r--contrib/python/attrs/attr/__init__.pyi458
-rw-r--r--contrib/python/attrs/attr/_compat.py190
-rw-r--r--contrib/python/attrs/attr/_funcs.py8
-rw-r--r--contrib/python/attrs/attr/_make.py508
-rw-r--r--contrib/python/attrs/attr/converters.py4
-rw-r--r--contrib/python/attrs/attr/converters.pyi12
-rw-r--r--contrib/python/attrs/attr/exceptions.py36
-rw-r--r--contrib/python/attrs/attr/exceptions.pyi28
-rw-r--r--contrib/python/attrs/attr/filters.py10
-rw-r--r--contrib/python/attrs/attr/filters.pyi8
-rw-r--r--contrib/python/attrs/attr/validators.py220
-rw-r--r--contrib/python/attrs/attr/validators.pyi114
-rw-r--r--contrib/python/attrs/ya.make2
-rw-r--r--contrib/python/pytest/py2/_pytest/tmpdir.py2
17 files changed, 806 insertions, 806 deletions
diff --git a/contrib/python/attrs/.dist-info/METADATA b/contrib/python/attrs/.dist-info/METADATA
index ceca5b9adf..f26701d0f7 100644
--- a/contrib/python/attrs/.dist-info/METADATA
+++ b/contrib/python/attrs/.dist-info/METADATA
@@ -36,12 +36,12 @@ Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
-Description-Content-Type: text/x-rst
+Description-Content-Type: text/x-rst
Provides-Extra: dev
Requires-Dist: coverage[toml] (>=5.0.2) ; extra == 'dev'
Requires-Dist: hypothesis ; extra == 'dev'
Requires-Dist: pympler ; extra == 'dev'
-Requires-Dist: pytest (>=4.3.0) ; extra == 'dev'
+Requires-Dist: pytest (>=4.3.0) ; extra == 'dev'
Requires-Dist: six ; extra == 'dev'
Requires-Dist: mypy ; extra == 'dev'
Requires-Dist: pytest-mypy-plugins ; extra == 'dev'
@@ -59,7 +59,7 @@ Provides-Extra: tests
Requires-Dist: coverage[toml] (>=5.0.2) ; extra == 'tests'
Requires-Dist: hypothesis ; extra == 'tests'
Requires-Dist: pympler ; extra == 'tests'
-Requires-Dist: pytest (>=4.3.0) ; extra == 'tests'
+Requires-Dist: pytest (>=4.3.0) ; extra == 'tests'
Requires-Dist: six ; extra == 'tests'
Requires-Dist: mypy ; extra == 'tests'
Requires-Dist: pytest-mypy-plugins ; extra == 'tests'
@@ -128,7 +128,7 @@ After *declaring* your attributes ``attrs`` gives you:
- a concise and explicit overview of the class's attributes,
- a nice human-readable ``__repr__``,
-- a complete set of comparison methods (equality and ordering),
+- a complete set of comparison methods (equality and ordering),
- an initializer,
- and much more,
diff --git a/contrib/python/attrs/README.rst b/contrib/python/attrs/README.rst
index d080f1de81..bbb5112fab 100644
--- a/contrib/python/attrs/README.rst
+++ b/contrib/python/attrs/README.rst
@@ -72,7 +72,7 @@ After *declaring* your attributes ``attrs`` gives you:
- a concise and explicit overview of the class's attributes,
- a nice human-readable ``__repr__``,
-- a complete set of comparison methods (equality and ordering),
+- a complete set of comparison methods (equality and ordering),
- an initializer,
- and much more,
diff --git a/contrib/python/attrs/attr/__init__.py b/contrib/python/attrs/attr/__init__.py
index b1ce7fe248..75ef04c578 100644
--- a/contrib/python/attrs/attr/__init__.py
+++ b/contrib/python/attrs/attr/__init__.py
@@ -23,7 +23,7 @@ from ._version_info import VersionInfo
__version__ = "21.2.0"
-__version_info__ = VersionInfo._from_version_string(__version__)
+__version_info__ = VersionInfo._from_version_string(__version__)
__title__ = "attrs"
__description__ = "Classes Without Boilerplate"
diff --git a/contrib/python/attrs/attr/__init__.pyi b/contrib/python/attrs/attr/__init__.pyi
index 3503b073b4..a5608fe09a 100644
--- a/contrib/python/attrs/attr/__init__.pyi
+++ b/contrib/python/attrs/attr/__init__.pyi
@@ -1,50 +1,50 @@
import sys
-from typing import (
- Any,
- Callable,
- Dict,
- Generic,
- List,
+from typing import (
+ Any,
+ Callable,
+ Dict,
+ Generic,
+ List,
Mapping,
- Optional,
- Sequence,
- Tuple,
- Type,
- TypeVar,
- Union,
- overload,
-)
-
-# `import X as X` is required to make these public
+ Optional,
+ Sequence,
+ Tuple,
+ Type,
+ TypeVar,
+ Union,
+ overload,
+)
+
+# `import X as X` is required to make these public
from . import converters as converters
-from . import exceptions as exceptions
-from . import filters as filters
+from . import exceptions as exceptions
+from . import filters as filters
from . import setters as setters
-from . import validators as validators
+from . import validators as validators
from ._version_info import VersionInfo
-
-
-__version__: str
-__version_info__: VersionInfo
-__title__: str
-__description__: str
-__url__: str
-__uri__: str
-__author__: str
-__email__: str
-__license__: str
-__copyright__: str
-
-_T = TypeVar("_T")
-_C = TypeVar("_C", bound=type)
-
+
+
+__version__: str
+__version_info__: VersionInfo
+__title__: str
+__description__: str
+__url__: str
+__uri__: str
+__author__: str
+__email__: str
+__license__: str
+__copyright__: str
+
+_T = TypeVar("_T")
+_C = TypeVar("_C", bound=type)
+
_EqOrderType = Union[bool, Callable[[Any], Any]]
-_ValidatorType = Callable[[Any, Attribute[_T], _T], Any]
+_ValidatorType = Callable[[Any, Attribute[_T], _T], Any]
_ConverterType = Callable[[Any], Any]
-_FilterType = Callable[[Attribute[_T], _T], bool]
-_ReprType = Callable[[Any], str]
-_ReprArgType = Union[bool, _ReprType]
+_FilterType = Callable[[Attribute[_T], _T], bool]
+_ReprType = Callable[[Any], str]
+_ReprArgType = Union[bool, _ReprType]
_OnSetAttrType = Callable[[Any, Attribute[Any], Any], Any]
_OnSetAttrArgType = Union[
_OnSetAttrType, List[_OnSetAttrType], setters._NoOpType
@@ -53,18 +53,18 @@ _FieldTransformer = Callable[[type, List[Attribute[Any]]], List[Attribute[Any]]]
# FIXME: in reality, if multiple validators are passed they must be in a list
# or tuple, but those are invariant and so would prevent subtypes of
# _ValidatorType from working when passed in a list or tuple.
-_ValidatorArgType = Union[_ValidatorType[_T], Sequence[_ValidatorType[_T]]]
-
-# _make --
-
-NOTHING: object
-
+_ValidatorArgType = Union[_ValidatorType[_T], Sequence[_ValidatorType[_T]]]
+
+# _make --
+
+NOTHING: object
+
# NOTE: Factory lies about its return type to make this possible:
# `x: List[int] # = Factory(list)`
-# Work around mypy issue #4554 in the common case by using an overload.
+# Work around mypy issue #4554 in the common case by using an overload.
if sys.version_info >= (3, 8):
from typing import Literal
-
+
@overload
def Factory(factory: Callable[[], _T]) -> _T: ...
@overload
@@ -102,124 +102,124 @@ def __dataclass_transform__(
field_descriptors: Tuple[Union[type, Callable[..., Any]], ...] = (()),
) -> Callable[[_T], _T]: ...
-class Attribute(Generic[_T]):
- name: str
- default: Optional[_T]
- validator: Optional[_ValidatorType[_T]]
- repr: _ReprArgType
+class Attribute(Generic[_T]):
+ name: str
+ default: Optional[_T]
+ validator: Optional[_ValidatorType[_T]]
+ repr: _ReprArgType
cmp: _EqOrderType
eq: _EqOrderType
order: _EqOrderType
- hash: Optional[bool]
- init: bool
+ hash: Optional[bool]
+ init: bool
converter: Optional[_ConverterType]
- metadata: Dict[Any, Any]
- type: Optional[Type[_T]]
- kw_only: bool
+ metadata: Dict[Any, Any]
+ type: Optional[Type[_T]]
+ kw_only: bool
on_setattr: _OnSetAttrType
-
+
def evolve(self, **changes: Any) -> "Attribute[Any]": ...
-# NOTE: We had several choices for the annotation to use for type arg:
-# 1) Type[_T]
-# - Pros: Handles simple cases correctly
+# NOTE: We had several choices for the annotation to use for type arg:
+# 1) Type[_T]
+# - Pros: Handles simple cases correctly
# - Cons: Might produce less informative errors in the case of conflicting
# TypeVars e.g. `attr.ib(default='bad', type=int)`
-# 2) Callable[..., _T]
-# - Pros: Better error messages than #1 for conflicting TypeVars
-# - Cons: Terrible error messages for validator checks.
-# e.g. attr.ib(type=int, validator=validate_str)
-# -> error: Cannot infer function type argument
-# 3) type (and do all of the work in the mypy plugin)
-# - Pros: Simple here, and we could customize the plugin with our own errors.
-# - Cons: Would need to write mypy plugin code to handle all the cases.
-# We chose option #1.
-
-# `attr` lies about its return type to make the following possible:
-# attr() -> Any
-# attr(8) -> int
-# attr(validator=<some callable>) -> Whatever the callable expects.
-# This makes this type of assignments possible:
-# x: int = attr(8)
-#
+# 2) Callable[..., _T]
+# - Pros: Better error messages than #1 for conflicting TypeVars
+# - Cons: Terrible error messages for validator checks.
+# e.g. attr.ib(type=int, validator=validate_str)
+# -> error: Cannot infer function type argument
+# 3) type (and do all of the work in the mypy plugin)
+# - Pros: Simple here, and we could customize the plugin with our own errors.
+# - Cons: Would need to write mypy plugin code to handle all the cases.
+# We chose option #1.
+
+# `attr` lies about its return type to make the following possible:
+# attr() -> Any
+# attr(8) -> int
+# attr(validator=<some callable>) -> Whatever the callable expects.
+# This makes this type of assignments possible:
+# x: int = attr(8)
+#
# This form catches explicit None or no default but with no other arguments
# returns Any.
-@overload
-def attrib(
- default: None = ...,
- validator: None = ...,
- repr: _ReprArgType = ...,
+@overload
+def attrib(
+ default: None = ...,
+ validator: None = ...,
+ repr: _ReprArgType = ...,
cmp: Optional[_EqOrderType] = ...,
- hash: Optional[bool] = ...,
- init: bool = ...,
- metadata: Optional[Mapping[Any, Any]] = ...,
- type: None = ...,
- converter: None = ...,
- factory: None = ...,
- kw_only: bool = ...,
+ hash: Optional[bool] = ...,
+ init: bool = ...,
+ metadata: Optional[Mapping[Any, Any]] = ...,
+ type: None = ...,
+ converter: None = ...,
+ factory: None = ...,
+ kw_only: bool = ...,
eq: Optional[_EqOrderType] = ...,
order: Optional[_EqOrderType] = ...,
on_setattr: Optional[_OnSetAttrArgType] = ...,
-) -> Any: ...
-
+) -> Any: ...
+
# This form catches an explicit None or no default and infers the type from the
# other arguments.
-@overload
-def attrib(
- default: None = ...,
- validator: Optional[_ValidatorArgType[_T]] = ...,
- repr: _ReprArgType = ...,
+@overload
+def attrib(
+ default: None = ...,
+ validator: Optional[_ValidatorArgType[_T]] = ...,
+ repr: _ReprArgType = ...,
cmp: Optional[_EqOrderType] = ...,
- hash: Optional[bool] = ...,
- init: bool = ...,
- metadata: Optional[Mapping[Any, Any]] = ...,
- type: Optional[Type[_T]] = ...,
+ hash: Optional[bool] = ...,
+ init: bool = ...,
+ metadata: Optional[Mapping[Any, Any]] = ...,
+ type: Optional[Type[_T]] = ...,
converter: Optional[_ConverterType] = ...,
- factory: Optional[Callable[[], _T]] = ...,
- kw_only: bool = ...,
+ factory: Optional[Callable[[], _T]] = ...,
+ kw_only: bool = ...,
eq: Optional[_EqOrderType] = ...,
order: Optional[_EqOrderType] = ...,
on_setattr: Optional[_OnSetAttrArgType] = ...,
-) -> _T: ...
-
-# This form catches an explicit default argument.
-@overload
-def attrib(
- default: _T,
- validator: Optional[_ValidatorArgType[_T]] = ...,
- repr: _ReprArgType = ...,
+) -> _T: ...
+
+# This form catches an explicit default argument.
+@overload
+def attrib(
+ default: _T,
+ validator: Optional[_ValidatorArgType[_T]] = ...,
+ repr: _ReprArgType = ...,
cmp: Optional[_EqOrderType] = ...,
- hash: Optional[bool] = ...,
- init: bool = ...,
- metadata: Optional[Mapping[Any, Any]] = ...,
- type: Optional[Type[_T]] = ...,
+ hash: Optional[bool] = ...,
+ init: bool = ...,
+ metadata: Optional[Mapping[Any, Any]] = ...,
+ type: Optional[Type[_T]] = ...,
converter: Optional[_ConverterType] = ...,
- factory: Optional[Callable[[], _T]] = ...,
- kw_only: bool = ...,
+ factory: Optional[Callable[[], _T]] = ...,
+ kw_only: bool = ...,
eq: Optional[_EqOrderType] = ...,
order: Optional[_EqOrderType] = ...,
on_setattr: Optional[_OnSetAttrArgType] = ...,
-) -> _T: ...
-
-# This form covers type=non-Type: e.g. forward references (str), Any
-@overload
-def attrib(
- default: Optional[_T] = ...,
- validator: Optional[_ValidatorArgType[_T]] = ...,
- repr: _ReprArgType = ...,
+) -> _T: ...
+
+# This form covers type=non-Type: e.g. forward references (str), Any
+@overload
+def attrib(
+ default: Optional[_T] = ...,
+ validator: Optional[_ValidatorArgType[_T]] = ...,
+ repr: _ReprArgType = ...,
cmp: Optional[_EqOrderType] = ...,
- hash: Optional[bool] = ...,
- init: bool = ...,
- metadata: Optional[Mapping[Any, Any]] = ...,
- type: object = ...,
+ hash: Optional[bool] = ...,
+ init: bool = ...,
+ metadata: Optional[Mapping[Any, Any]] = ...,
+ type: object = ...,
converter: Optional[_ConverterType] = ...,
- factory: Optional[Callable[[], _T]] = ...,
- kw_only: bool = ...,
+ factory: Optional[Callable[[], _T]] = ...,
+ kw_only: bool = ...,
eq: Optional[_EqOrderType] = ...,
order: Optional[_EqOrderType] = ...,
on_setattr: Optional[_OnSetAttrArgType] = ...,
-) -> Any: ...
-@overload
+) -> Any: ...
+@overload
def field(
*,
default: None = ...,
@@ -292,22 +292,22 @@ def field(
) -> Any: ...
@overload
@__dataclass_transform__(order_default=True, field_descriptors=(attrib, field))
-def attrs(
- maybe_cls: _C,
- these: Optional[Dict[str, Any]] = ...,
- repr_ns: Optional[str] = ...,
- repr: bool = ...,
+def attrs(
+ maybe_cls: _C,
+ these: Optional[Dict[str, Any]] = ...,
+ repr_ns: Optional[str] = ...,
+ repr: bool = ...,
cmp: Optional[_EqOrderType] = ...,
- hash: Optional[bool] = ...,
- init: bool = ...,
- slots: bool = ...,
- frozen: bool = ...,
- weakref_slot: bool = ...,
- str: bool = ...,
- auto_attribs: bool = ...,
- kw_only: bool = ...,
- cache_hash: bool = ...,
- auto_exc: bool = ...,
+ hash: Optional[bool] = ...,
+ init: bool = ...,
+ slots: bool = ...,
+ frozen: bool = ...,
+ weakref_slot: bool = ...,
+ str: bool = ...,
+ auto_attribs: bool = ...,
+ kw_only: bool = ...,
+ cache_hash: bool = ...,
+ auto_exc: bool = ...,
eq: Optional[_EqOrderType] = ...,
order: Optional[_EqOrderType] = ...,
auto_detect: bool = ...,
@@ -315,25 +315,25 @@ def attrs(
getstate_setstate: Optional[bool] = ...,
on_setattr: Optional[_OnSetAttrArgType] = ...,
field_transformer: Optional[_FieldTransformer] = ...,
-) -> _C: ...
-@overload
+) -> _C: ...
+@overload
@__dataclass_transform__(order_default=True, field_descriptors=(attrib, field))
-def attrs(
- maybe_cls: None = ...,
- these: Optional[Dict[str, Any]] = ...,
- repr_ns: Optional[str] = ...,
- repr: bool = ...,
+def attrs(
+ maybe_cls: None = ...,
+ these: Optional[Dict[str, Any]] = ...,
+ repr_ns: Optional[str] = ...,
+ repr: bool = ...,
cmp: Optional[_EqOrderType] = ...,
- hash: Optional[bool] = ...,
- init: bool = ...,
- slots: bool = ...,
- frozen: bool = ...,
- weakref_slot: bool = ...,
- str: bool = ...,
- auto_attribs: bool = ...,
- kw_only: bool = ...,
- cache_hash: bool = ...,
- auto_exc: bool = ...,
+ hash: Optional[bool] = ...,
+ init: bool = ...,
+ slots: bool = ...,
+ frozen: bool = ...,
+ weakref_slot: bool = ...,
+ str: bool = ...,
+ auto_attribs: bool = ...,
+ kw_only: bool = ...,
+ cache_hash: bool = ...,
+ auto_exc: bool = ...,
eq: Optional[_EqOrderType] = ...,
order: Optional[_EqOrderType] = ...,
auto_detect: bool = ...,
@@ -341,7 +341,7 @@ def attrs(
getstate_setstate: Optional[bool] = ...,
on_setattr: Optional[_OnSetAttrArgType] = ...,
field_transformer: Optional[_FieldTransformer] = ...,
-) -> Callable[[_C], _C]: ...
+) -> Callable[[_C], _C]: ...
@overload
@__dataclass_transform__(field_descriptors=(attrib, field))
def define(
@@ -390,86 +390,86 @@ def define(
on_setattr: Optional[_OnSetAttrArgType] = ...,
field_transformer: Optional[_FieldTransformer] = ...,
) -> Callable[[_C], _C]: ...
-
+
mutable = define
frozen = define # they differ only in their defaults
-# TODO: add support for returning NamedTuple from the mypy plugin
-class _Fields(Tuple[Attribute[Any], ...]):
- def __getattr__(self, name: str) -> Attribute[Any]: ...
-
-def fields(cls: type) -> _Fields: ...
-def fields_dict(cls: type) -> Dict[str, Attribute[Any]]: ...
-def validate(inst: Any) -> None: ...
+# TODO: add support for returning NamedTuple from the mypy plugin
+class _Fields(Tuple[Attribute[Any], ...]):
+ def __getattr__(self, name: str) -> Attribute[Any]: ...
+
+def fields(cls: type) -> _Fields: ...
+def fields_dict(cls: type) -> Dict[str, Attribute[Any]]: ...
+def validate(inst: Any) -> None: ...
def resolve_types(
cls: _C,
globalns: Optional[Dict[str, Any]] = ...,
localns: Optional[Dict[str, Any]] = ...,
attribs: Optional[List[Attribute[Any]]] = ...,
) -> _C: ...
-
-# TODO: add support for returning a proper attrs class from the mypy plugin
+
+# TODO: add support for returning a proper attrs class from the mypy plugin
# we use Any instead of _CountingAttr so that e.g. `make_class('Foo',
# [attr.ib()])` is valid
-def make_class(
- name: str,
- attrs: Union[List[str], Tuple[str, ...], Dict[str, Any]],
- bases: Tuple[type, ...] = ...,
- repr_ns: Optional[str] = ...,
- repr: bool = ...,
+def make_class(
+ name: str,
+ attrs: Union[List[str], Tuple[str, ...], Dict[str, Any]],
+ bases: Tuple[type, ...] = ...,
+ repr_ns: Optional[str] = ...,
+ repr: bool = ...,
cmp: Optional[_EqOrderType] = ...,
- hash: Optional[bool] = ...,
- init: bool = ...,
- slots: bool = ...,
- frozen: bool = ...,
- weakref_slot: bool = ...,
- str: bool = ...,
- auto_attribs: bool = ...,
- kw_only: bool = ...,
- cache_hash: bool = ...,
- auto_exc: bool = ...,
+ hash: Optional[bool] = ...,
+ init: bool = ...,
+ slots: bool = ...,
+ frozen: bool = ...,
+ weakref_slot: bool = ...,
+ str: bool = ...,
+ auto_attribs: bool = ...,
+ kw_only: bool = ...,
+ cache_hash: bool = ...,
+ auto_exc: bool = ...,
eq: Optional[_EqOrderType] = ...,
order: Optional[_EqOrderType] = ...,
collect_by_mro: bool = ...,
on_setattr: Optional[_OnSetAttrArgType] = ...,
field_transformer: Optional[_FieldTransformer] = ...,
-) -> type: ...
-
-# _funcs --
-
-# TODO: add support for returning TypedDict from the mypy plugin
+) -> type: ...
+
+# _funcs --
+
+# TODO: add support for returning TypedDict from the mypy plugin
# FIXME: asdict/astuple do not honor their factory args. Waiting on one of
# these:
-# https://github.com/python/mypy/issues/4236
-# https://github.com/python/typing/issues/253
-def asdict(
- inst: Any,
- recurse: bool = ...,
- filter: Optional[_FilterType[Any]] = ...,
- dict_factory: Type[Mapping[Any, Any]] = ...,
- retain_collection_types: bool = ...,
+# https://github.com/python/mypy/issues/4236
+# https://github.com/python/typing/issues/253
+def asdict(
+ inst: Any,
+ recurse: bool = ...,
+ filter: Optional[_FilterType[Any]] = ...,
+ dict_factory: Type[Mapping[Any, Any]] = ...,
+ retain_collection_types: bool = ...,
value_serializer: Optional[Callable[[type, Attribute[Any], Any], Any]] = ...,
-) -> Dict[str, Any]: ...
-
-# TODO: add support for returning NamedTuple from the mypy plugin
-def astuple(
- inst: Any,
- recurse: bool = ...,
- filter: Optional[_FilterType[Any]] = ...,
- tuple_factory: Type[Sequence[Any]] = ...,
- retain_collection_types: bool = ...,
-) -> Tuple[Any, ...]: ...
-def has(cls: type) -> bool: ...
-def assoc(inst: _T, **changes: Any) -> _T: ...
-def evolve(inst: _T, **changes: Any) -> _T: ...
-
-# _config --
-
-def set_run_validators(run: bool) -> None: ...
-def get_run_validators() -> bool: ...
-
-# aliases --
-
-s = attributes = attrs
-ib = attr = attrib
-dataclass = attrs # Technically, partial(attrs, auto_attribs=True) ;)
+) -> Dict[str, Any]: ...
+
+# TODO: add support for returning NamedTuple from the mypy plugin
+def astuple(
+ inst: Any,
+ recurse: bool = ...,
+ filter: Optional[_FilterType[Any]] = ...,
+ tuple_factory: Type[Sequence[Any]] = ...,
+ retain_collection_types: bool = ...,
+) -> Tuple[Any, ...]: ...
+def has(cls: type) -> bool: ...
+def assoc(inst: _T, **changes: Any) -> _T: ...
+def evolve(inst: _T, **changes: Any) -> _T: ...
+
+# _config --
+
+def set_run_validators(run: bool) -> None: ...
+def get_run_validators() -> bool: ...
+
+# aliases --
+
+s = attributes = attrs
+ib = attr = attrib
+dataclass = attrs # Technically, partial(attrs, auto_attribs=True) ;)
diff --git a/contrib/python/attrs/attr/_compat.py b/contrib/python/attrs/attr/_compat.py
index 6939f338da..1aa6c9413a 100644
--- a/contrib/python/attrs/attr/_compat.py
+++ b/contrib/python/attrs/attr/_compat.py
@@ -19,7 +19,7 @@ else:
if PY2:
- from collections import Mapping, Sequence
+ from collections import Mapping, Sequence
from UserDict import IterableUserDict
@@ -116,8 +116,8 @@ else: # Python 3 and later.
consequences of not setting the cell on Python 2.
"""
warnings.warn(
- "Running interpreter doesn't sufficiently support code object "
- "introspection. Some features like bare super() or accessing "
+ "Running interpreter doesn't sufficiently support code object "
+ "introspection. Some features like bare super() or accessing "
"__class__ will not work with slotted classes.",
RuntimeWarning,
stacklevel=2,
@@ -138,105 +138,105 @@ else: # Python 3 and later.
def make_set_closure_cell():
- """Return a function of two arguments (cell, value) which sets
- the value stored in the closure cell `cell` to `value`.
+ """Return a function of two arguments (cell, value) which sets
+ the value stored in the closure cell `cell` to `value`.
"""
- # pypy makes this easy. (It also supports the logic below, but
- # why not do the easy/fast thing?)
+ # pypy makes this easy. (It also supports the logic below, but
+ # why not do the easy/fast thing?)
if PYPY:
def set_closure_cell(cell, value):
cell.__setstate__((value,))
- return set_closure_cell
-
- # Otherwise gotta do it the hard way.
-
- # Create a function that will set its first cellvar to `value`.
- def set_first_cellvar_to(value):
- x = value
- return
-
- # This function will be eliminated as dead code, but
- # not before its reference to `x` forces `x` to be
- # represented as a closure cell rather than a local.
- def force_x_to_be_a_cell(): # pragma: no cover
- return x
-
- try:
- # Extract the code object and make sure our assumptions about
- # the closure behavior are correct.
- if PY2:
- co = set_first_cellvar_to.func_code
- else:
- co = set_first_cellvar_to.__code__
- if co.co_cellvars != ("x",) or co.co_freevars != ():
- raise AssertionError # pragma: no cover
-
- # Convert this code object to a code object that sets the
- # function's first _freevar_ (not cellvar) to the argument.
- if sys.version_info >= (3, 8):
- # CPython 3.8+ has an incompatible CodeType signature
- # (added a posonlyargcount argument) but also added
- # CodeType.replace() to do this without counting parameters.
- set_first_freevar_code = co.replace(
- co_cellvars=co.co_freevars, co_freevars=co.co_cellvars
- )
- else:
- args = [co.co_argcount]
- if not PY2:
- args.append(co.co_kwonlyargcount)
- args.extend(
- [
- co.co_nlocals,
- co.co_stacksize,
- co.co_flags,
- co.co_code,
- co.co_consts,
- co.co_names,
- co.co_varnames,
- co.co_filename,
- co.co_name,
- co.co_firstlineno,
- co.co_lnotab,
- # These two arguments are reversed:
- co.co_cellvars,
- co.co_freevars,
- ]
- )
- set_first_freevar_code = types.CodeType(*args)
-
- def set_closure_cell(cell, value):
- # Create a function using the set_first_freevar_code,
- # whose first closure cell is `cell`. Calling it will
- # change the value of that cell.
- setter = types.FunctionType(
- set_first_freevar_code, {}, "setter", (), (cell,)
- )
- # And call it to set the cell.
- setter(value)
-
- # Make sure it works on this interpreter:
- def make_func_with_cell():
- x = None
-
- def func():
- return x # pragma: no cover
-
- return func
-
- if PY2:
- cell = make_func_with_cell().func_closure[0]
- else:
- cell = make_func_with_cell().__closure__[0]
- set_closure_cell(cell, 100)
- if cell.cell_contents != 100:
- raise AssertionError # pragma: no cover
-
- except Exception:
- return just_warn
+ return set_closure_cell
+
+ # Otherwise gotta do it the hard way.
+
+ # Create a function that will set its first cellvar to `value`.
+ def set_first_cellvar_to(value):
+ x = value
+ return
+
+ # This function will be eliminated as dead code, but
+ # not before its reference to `x` forces `x` to be
+ # represented as a closure cell rather than a local.
+ def force_x_to_be_a_cell(): # pragma: no cover
+ return x
+
+ try:
+ # Extract the code object and make sure our assumptions about
+ # the closure behavior are correct.
+ if PY2:
+ co = set_first_cellvar_to.func_code
+ else:
+ co = set_first_cellvar_to.__code__
+ if co.co_cellvars != ("x",) or co.co_freevars != ():
+ raise AssertionError # pragma: no cover
+
+ # Convert this code object to a code object that sets the
+ # function's first _freevar_ (not cellvar) to the argument.
+ if sys.version_info >= (3, 8):
+ # CPython 3.8+ has an incompatible CodeType signature
+ # (added a posonlyargcount argument) but also added
+ # CodeType.replace() to do this without counting parameters.
+ set_first_freevar_code = co.replace(
+ co_cellvars=co.co_freevars, co_freevars=co.co_cellvars
+ )
+ else:
+ args = [co.co_argcount]
+ if not PY2:
+ args.append(co.co_kwonlyargcount)
+ args.extend(
+ [
+ co.co_nlocals,
+ co.co_stacksize,
+ co.co_flags,
+ co.co_code,
+ co.co_consts,
+ co.co_names,
+ co.co_varnames,
+ co.co_filename,
+ co.co_name,
+ co.co_firstlineno,
+ co.co_lnotab,
+ # These two arguments are reversed:
+ co.co_cellvars,
+ co.co_freevars,
+ ]
+ )
+ set_first_freevar_code = types.CodeType(*args)
+
+ def set_closure_cell(cell, value):
+ # Create a function using the set_first_freevar_code,
+ # whose first closure cell is `cell`. Calling it will
+ # change the value of that cell.
+ setter = types.FunctionType(
+ set_first_freevar_code, {}, "setter", (), (cell,)
+ )
+ # And call it to set the cell.
+ setter(value)
+
+ # Make sure it works on this interpreter:
+ def make_func_with_cell():
+ x = None
+
+ def func():
+ return x # pragma: no cover
+
+ return func
+
+ if PY2:
+ cell = make_func_with_cell().func_closure[0]
+ else:
+ cell = make_func_with_cell().__closure__[0]
+ set_closure_cell(cell, 100)
+ if cell.cell_contents != 100:
+ raise AssertionError # pragma: no cover
+
+ except Exception:
+ return just_warn
else:
- return set_closure_cell
+ return set_closure_cell
set_closure_cell = make_set_closure_cell()
diff --git a/contrib/python/attrs/attr/_funcs.py b/contrib/python/attrs/attr/_funcs.py
index fda508c5c4..51c4a2e638 100644
--- a/contrib/python/attrs/attr/_funcs.py
+++ b/contrib/python/attrs/attr/_funcs.py
@@ -25,7 +25,7 @@ def asdict(
``attrs``-decorated.
:param callable filter: A callable whose return code determines whether an
attribute or element is included (``True``) or dropped (``False``). Is
- called with the `attr.Attribute` as the first argument and the
+ called with the `attr.Attribute` as the first argument and the
value as the second argument.
:param callable dict_factory: A callable to produce dictionaries from. For
example, to produce ordered dictionaries instead of normal Python
@@ -181,7 +181,7 @@ def astuple(
``attrs``-decorated.
:param callable filter: A callable whose return code determines whether an
attribute or element is included (``True``) or dropped (``False``). Is
- called with the `attr.Attribute` as the first argument and the
+ called with the `attr.Attribute` as the first argument and the
value as the second argument.
:param callable tuple_factory: A callable to produce tuples from. For
example, to produce lists instead of tuples.
@@ -271,7 +271,7 @@ def has(cls):
:param type cls: Class to introspect.
:raise TypeError: If *cls* is not a class.
- :rtype: bool
+ :rtype: bool
"""
return getattr(cls, "__attrs_attrs__", None) is not None
@@ -291,7 +291,7 @@ def assoc(inst, **changes):
class.
.. deprecated:: 17.1.0
- Use `evolve` instead.
+ Use `evolve` instead.
"""
import warnings
diff --git a/contrib/python/attrs/attr/_make.py b/contrib/python/attrs/attr/_make.py
index a1912b1233..d00b783881 100644
--- a/contrib/python/attrs/attr/_make.py
+++ b/contrib/python/attrs/attr/_make.py
@@ -5,7 +5,7 @@ import inspect
import linecache
import sys
import threading
-import uuid
+import uuid
import warnings
from operator import itemgetter
@@ -54,10 +54,10 @@ _hash_cache_field = "_attrs_cached_hash"
_empty_metadata_singleton = metadata_proxy({})
-# Unique object for unequivocal getattr() defaults.
-_sentinel = object()
-
+# Unique object for unequivocal getattr() defaults.
+_sentinel = object()
+
class _Nothing(object):
"""
Sentinel class to indicate the lack of a value when ``None`` is ambiguous.
@@ -119,7 +119,7 @@ def attrib(
default=NOTHING,
validator=None,
repr=True,
- cmp=None,
+ cmp=None,
hash=None,
init=True,
metadata=None,
@@ -127,8 +127,8 @@ def attrib(
converter=None,
factory=None,
kw_only=False,
- eq=None,
- order=None,
+ eq=None,
+ order=None,
on_setattr=None,
):
"""
@@ -137,30 +137,30 @@ def attrib(
.. warning::
Does *not* do anything unless the class is also decorated with
- `attr.s`!
+ `attr.s`!
:param default: A value that is used if an ``attrs``-generated ``__init__``
is used and no value is passed while instantiating or the attribute is
excluded using ``init=False``.
- If the value is an instance of `Factory`, its callable will be
+ If the value is an instance of `Factory`, its callable will be
used to construct a new value (useful for mutable data types like lists
or dicts).
If a default is not set (or set manually to `attr.NOTHING`), a value
- *must* be supplied when instantiating; otherwise a `TypeError`
+ *must* be supplied when instantiating; otherwise a `TypeError`
will be raised.
The default can also be set using decorator notation as shown below.
- :type default: Any value
+ :type default: Any value
:param callable factory: Syntactic sugar for
``default=attr.Factory(factory)``.
- :param validator: `callable` that is called by ``attrs``-generated
+ :param validator: `callable` that is called by ``attrs``-generated
``__init__`` methods after the instance has been initialized. They
- receive the initialized instance, the `Attribute`, and the
+ receive the initialized instance, the `Attribute`, and the
passed value.
The return value is *not* inspected so the validator has to throw an
@@ -170,30 +170,30 @@ def attrib(
all pass.
Validators can be globally disabled and re-enabled using
- `get_run_validators`.
+ `get_run_validators`.
The validator can also be set using decorator notation as shown below.
:type validator: `callable` or a `list` of `callable`\\ s.
- :param repr: Include this attribute in the generated ``__repr__``
- method. If ``True``, include the attribute; if ``False``, omit it. By
- default, the built-in ``repr()`` function is used. To override how the
- attribute value is formatted, pass a ``callable`` that takes a single
- value and returns a string. Note that the resulting string is used
- as-is, i.e. it will be used directly *instead* of calling ``repr()``
- (the default).
+ :param repr: Include this attribute in the generated ``__repr__``
+ method. If ``True``, include the attribute; if ``False``, omit it. By
+ default, the built-in ``repr()`` function is used. To override how the
+ attribute value is formatted, pass a ``callable`` that takes a single
+ value and returns a string. Note that the resulting string is used
+ as-is, i.e. it will be used directly *instead* of calling ``repr()``
+ (the default).
:type repr: a `bool` or a `callable` to use a custom function.
:param eq: If ``True`` (default), include this attribute in the
- generated ``__eq__`` and ``__ne__`` methods that check two instances
+ generated ``__eq__`` and ``__ne__`` methods that check two instances
for equality. To override how the attribute value is compared,
pass a ``callable`` that takes a single value and returns the value
to be compared.
:type eq: a `bool` or a `callable`.
:param order: If ``True`` (default), include this attributes in the
- generated ``__lt__``, ``__le__``, ``__gt__`` and ``__ge__`` methods.
+ generated ``__lt__``, ``__le__``, ``__gt__`` and ``__ge__`` methods.
To override how the attribute value is ordered,
pass a ``callable`` that takes a single value and returns the value
to be ordered.
@@ -211,13 +211,13 @@ def attrib(
method. It is possible to set this to ``False`` and set a default
value. In that case this attributed is unconditionally initialized
with the specified default value or factory.
- :param callable converter: `callable` that is called by
+ :param callable converter: `callable` that is called by
``attrs``-generated ``__init__`` methods to convert attribute's value
to the desired format. It is given the passed-in value, and the
returned value will be used as the new value of the attribute. The
value is converted before being passed to the validator, if any.
:param metadata: An arbitrary mapping, to be used by third-party
- components. See `extending_metadata`.
+ components. See `extending_metadata`.
:param type: The type of the attribute. In Python 3.6 or greater, the
preferred method to specify the type is using a variable annotation
(see `PEP 526 <https://www.python.org/dev/peps/pep-0526/>`_).
@@ -227,7 +227,7 @@ def attrib(
Please note that ``attrs`` doesn't do anything with this metadata by
itself. You can use it as part of your own code or for
- `static type checking <types>`.
+ `static type checking <types>`.
:param kw_only: Make this attribute keyword-only (Python 3+)
in the generated ``__init__`` (if ``init`` is ``False``, this
parameter is ignored).
@@ -242,7 +242,7 @@ def attrib(
.. versionadded:: 16.3.0 *metadata*
.. versionchanged:: 17.1.0 *validator* can be a ``list`` now.
.. versionchanged:: 17.1.0
- *hash* is ``None`` and therefore mirrors *eq* by default.
+ *hash* is ``None`` and therefore mirrors *eq* by default.
.. versionadded:: 17.3.0 *type*
.. deprecated:: 17.4.0 *convert*
.. versionadded:: 17.4.0 *converter* as a replacement for the deprecated
@@ -251,9 +251,9 @@ def attrib(
``factory=f`` is syntactic sugar for ``default=attr.Factory(f)``.
.. versionadded:: 18.2.0 *kw_only*
.. versionchanged:: 19.2.0 *convert* keyword argument removed.
- .. versionchanged:: 19.2.0 *repr* also accepts a custom callable.
- .. deprecated:: 19.2.0 *cmp* Removal on or after 2021-06-01.
- .. versionadded:: 19.2.0 *eq* and *order*
+ .. versionchanged:: 19.2.0 *repr* also accepts a custom callable.
+ .. deprecated:: 19.2.0 *cmp* Removal on or after 2021-06-01.
+ .. versionadded:: 19.2.0 *eq* and *order*
.. versionadded:: 20.1.0 *on_setattr*
.. versionchanged:: 20.3.0 *kw_only* backported to Python 2
.. versionchanged:: 21.1.0
@@ -263,7 +263,7 @@ def attrib(
eq, eq_key, order, order_key = _determine_attrib_eq_order(
cmp, eq, order, True
)
-
+
if hash is not None and hash is not True and hash is not False:
raise TypeError(
"Invalid value for hash. Must be True, False, or None."
@@ -296,16 +296,16 @@ def attrib(
default=default,
validator=validator,
repr=repr,
- cmp=None,
+ cmp=None,
hash=hash,
init=init,
converter=converter,
metadata=metadata,
type=type,
kw_only=kw_only,
- eq=eq,
+ eq=eq,
eq_key=eq_key,
- order=order,
+ order=order,
order_key=order_key,
on_setattr=on_setattr,
)
@@ -581,19 +581,19 @@ def _transform_attrs(
attrs = AttrsClass(base_attrs + own_attrs)
- # Mandatory vs non-mandatory attr order only matters when they are part of
- # the __init__ signature and when they aren't kw_only (which are moved to
- # the end and can be mandatory or non-mandatory in any order, as they will
- # be specified as keyword args anyway). Check the order of those attrs:
+ # Mandatory vs non-mandatory attr order only matters when they are part of
+ # the __init__ signature and when they aren't kw_only (which are moved to
+ # the end and can be mandatory or non-mandatory in any order, as they will
+ # be specified as keyword args anyway). Check the order of those attrs:
had_default = False
- for a in (a for a in attrs if a.init is not False and a.kw_only is False):
- if had_default is True and a.default is NOTHING:
+ for a in (a for a in attrs if a.init is not False and a.kw_only is False):
+ if had_default is True and a.default is NOTHING:
raise ValueError(
"No mandatory attributes allowed after an attribute with a "
"default value or factory. Attribute in question: %r" % (a,)
)
-
- if had_default is False and a.default is not NOTHING:
+
+ if had_default is False and a.default is not NOTHING:
had_default = True
if field_transformer is not None:
@@ -937,10 +937,10 @@ class _ClassBuilder(object):
def add_hash(self):
self._cls_dict["__hash__"] = self._add_method_dunders(
_make_hash(
- self._cls,
- self._attrs,
- frozen=self._frozen,
- cache_hash=self._cache_hash,
+ self._cls,
+ self._attrs,
+ frozen=self._frozen,
+ cache_hash=self._cache_hash,
)
)
@@ -949,7 +949,7 @@ class _ClassBuilder(object):
def add_init(self):
self._cls_dict["__init__"] = self._add_method_dunders(
_make_init(
- self._cls,
+ self._cls,
self._attrs,
self._has_pre_init,
self._has_post_init,
@@ -986,7 +986,7 @@ class _ClassBuilder(object):
return self
- def add_eq(self):
+ def add_eq(self):
cd = self._cls_dict
cd["__eq__"] = self._add_method_dunders(
@@ -996,16 +996,16 @@ class _ClassBuilder(object):
return self
- def add_order(self):
- cd = self._cls_dict
-
- cd["__lt__"], cd["__le__"], cd["__gt__"], cd["__ge__"] = (
- self._add_method_dunders(meth)
- for meth in _make_order(self._cls, self._attrs)
- )
-
- return self
-
+ def add_order(self):
+ cd = self._cls_dict
+
+ cd["__lt__"], cd["__le__"], cd["__gt__"], cd["__ge__"] = (
+ self._add_method_dunders(meth)
+ for meth in _make_order(self._cls, self._attrs)
+ )
+
+ return self
+
def add_setattr(self):
if self._frozen:
return self
@@ -1068,38 +1068,38 @@ class _ClassBuilder(object):
return method
-_CMP_DEPRECATION = (
- "The usage of `cmp` is deprecated and will be removed on or after "
- "2021-06-01. Please use `eq` and `order` instead."
-)
-
-
+_CMP_DEPRECATION = (
+ "The usage of `cmp` is deprecated and will be removed on or after "
+ "2021-06-01. Please use `eq` and `order` instead."
+)
+
+
def _determine_attrs_eq_order(cmp, eq, order, default_eq):
- """
- Validate the combination of *cmp*, *eq*, and *order*. Derive the effective
+ """
+ Validate the combination of *cmp*, *eq*, and *order*. Derive the effective
values of eq and order. If *eq* is None, set it to *default_eq*.
- """
- if cmp is not None and any((eq is not None, order is not None)):
- raise ValueError("Don't mix `cmp` with `eq' and `order`.")
-
- # cmp takes precedence due to bw-compatibility.
- if cmp is not None:
- return cmp, cmp
-
+ """
+ if cmp is not None and any((eq is not None, order is not None)):
+ raise ValueError("Don't mix `cmp` with `eq' and `order`.")
+
+ # cmp takes precedence due to bw-compatibility.
+ if cmp is not None:
+ return cmp, cmp
+
# If left None, equality is set to the specified default and ordering
# mirrors equality.
- if eq is None:
+ if eq is None:
eq = default_eq
-
- if order is None:
- order = eq
-
- if eq is False and order is True:
- raise ValueError("`order` can only be True if `eq` is True too.")
-
- return eq, order
-
-
+
+ if order is None:
+ order = eq
+
+ if eq is False and order is True:
+ raise ValueError("`order` can only be True if `eq` is True too.")
+
+ return eq, order
+
+
def _determine_attrib_eq_order(cmp, eq, order, default_eq):
"""
Validate the combination of *cmp*, *eq*, and *order*. Derive the effective
@@ -1174,7 +1174,7 @@ def attrs(
these=None,
repr_ns=None,
repr=None,
- cmp=None,
+ cmp=None,
hash=None,
init=None,
slots=False,
@@ -1185,8 +1185,8 @@ def attrs(
kw_only=False,
cache_hash=False,
auto_exc=False,
- eq=None,
- order=None,
+ eq=None,
+ order=None,
auto_detect=False,
collect_by_mro=False,
getstate_setstate=None,
@@ -1196,9 +1196,9 @@ def attrs(
r"""
A class decorator that adds `dunder
<https://wiki.python.org/moin/DunderAlias>`_\ -methods according to the
- specified attributes using `attr.ib` or the *these* argument.
+ specified attributes using `attr.ib` or the *these* argument.
- :param these: A dictionary of name to `attr.ib` mappings. This is
+ :param these: A dictionary of name to `attr.ib` mappings. This is
useful to avoid the definition of your attributes within the class body
because you can't (e.g. if you want to add ``__repr__`` methods to
Django models) or don't want to.
@@ -1206,12 +1206,12 @@ def attrs(
If *these* is not ``None``, ``attrs`` will *not* search the class body
for attributes and will *not* remove any attributes from it.
- If *these* is an ordered dict (`dict` on Python 3.6+,
- `collections.OrderedDict` otherwise), the order is deduced from
+ If *these* is an ordered dict (`dict` on Python 3.6+,
+ `collections.OrderedDict` otherwise), the order is deduced from
the order of the attributes inside *these*. Otherwise the order
of the definition of the attributes is used.
- :type these: `dict` of `str` to `attr.ib`
+ :type these: `dict` of `str` to `attr.ib`
:param str repr_ns: When using nested classes, there's no way in Python 2
to automatically detect that. Therefore it's possible to set the
@@ -1246,11 +1246,11 @@ def attrs(
representation of ``attrs`` attributes..
:param bool str: Create a ``__str__`` method that is identical to
``__repr__``. This is usually not necessary except for
- `Exception`\ s.
+ `Exception`\ s.
:param Optional[bool] eq: If ``True`` or ``None`` (default), add ``__eq__``
and ``__ne__`` methods that check two instances for equality.
-
- They compare the instances as if they were tuples of their ``attrs``
+
+ They compare the instances as if they were tuples of their ``attrs``
attributes if and only if the types of both classes are *identical*!
:param Optional[bool] order: If ``True``, add ``__lt__``, ``__le__``,
``__gt__``, and ``__ge__`` methods that behave like *eq* above and
@@ -1262,9 +1262,9 @@ def attrs(
is generated according how *eq* and *frozen* are set.
1. If *both* are True, ``attrs`` will generate a ``__hash__`` for you.
- 2. If *eq* is True and *frozen* is False, ``__hash__`` will be set to
+ 2. If *eq* is True and *frozen* is False, ``__hash__`` will be set to
None, marking it unhashable (which it is).
- 3. If *eq* is False, ``__hash__`` will be left untouched meaning the
+ 3. If *eq* is False, ``__hash__`` will be left untouched meaning the
``__hash__`` method of the base class will be used (if base class is
``object``, this means it will fall back to id-based hashing.).
@@ -1273,10 +1273,10 @@ def attrs(
didn't freeze it programmatically) by passing ``True`` or not. Both of
these cases are rather special and should be used carefully.
- See our documentation on `hashing`, Python's documentation on
- `object.__hash__`, and the `GitHub issue that led to the default \
- behavior <https://github.com/python-attrs/attrs/issues/136>`_ for more
- details.
+ See our documentation on `hashing`, Python's documentation on
+ `object.__hash__`, and the `GitHub issue that led to the default \
+ behavior <https://github.com/python-attrs/attrs/issues/136>`_ for more
+ details.
:param bool init: Create a ``__init__`` method that initializes the
``attrs`` attributes. Leading underscores are stripped for the argument
name. If a ``__attrs_pre_init__`` method exists on the class, it will
@@ -1288,13 +1288,13 @@ def attrs(
injected instead. This allows you to define a custom ``__init__``
method that can do pre-init work such as ``super().__init__()``,
and then call ``__attrs_init__()`` and ``__attrs_post_init__()``.
- :param bool slots: Create a `slotted class <slotted classes>` that's more
+ :param bool slots: Create a `slotted class <slotted classes>` that's more
memory-efficient. Slotted classes are generally superior to the default
dict classes, but have some gotchas you should know about, so we
encourage you to read the `glossary entry <slotted classes>`.
:param bool frozen: Make instances immutable after initialization. If
someone attempts to modify a frozen instance,
- `attr.exceptions.FrozenInstanceError` is raised.
+ `attr.exceptions.FrozenInstanceError` is raised.
.. note::
@@ -1303,7 +1303,7 @@ def attrs(
2. True immutability is impossible in Python.
- 3. This *does* have a minor a runtime performance `impact
+ 3. This *does* have a minor a runtime performance `impact
<how-frozen>` when initializing new instances. In other words:
``__init__`` is slightly slower with ``frozen=True``.
@@ -1320,18 +1320,18 @@ def attrs(
attributes (Python 3.6 and later only) from the class body.
In this case, you **must** annotate every field. If ``attrs``
- encounters a field that is set to an `attr.ib` but lacks a type
- annotation, an `attr.exceptions.UnannotatedAttributeError` is
+ encounters a field that is set to an `attr.ib` but lacks a type
+ annotation, an `attr.exceptions.UnannotatedAttributeError` is
raised. Use ``field_name: typing.Any = attr.ib(...)`` if you don't
want to set a type.
If you assign a value to those attributes (e.g. ``x: int = 42``), that
value becomes the default value like if it were passed using
- ``attr.ib(default=42)``. Passing an instance of `Factory` also
+ ``attr.ib(default=42)``. Passing an instance of `Factory` also
works as expected in most cases (see warning below).
- Attributes annotated as `typing.ClassVar`, and attributes that are
- neither annotated nor set to an `attr.ib` are **ignored**.
+ Attributes annotated as `typing.ClassVar`, and attributes that are
+ neither annotated nor set to an `attr.ib` are **ignored**.
.. warning::
For features that use the attribute name to create decorators (e.g.
@@ -1353,15 +1353,15 @@ def attrs(
fields involved in hash code computation or mutations of the objects
those fields point to after object creation. If such changes occur,
the behavior of the object's hash code is undefined.
- :param bool auto_exc: If the class subclasses `BaseException`
+ :param bool auto_exc: If the class subclasses `BaseException`
(which implicitly includes any subclass of any exception), the
following happens to behave like a well-behaved Python exceptions
class:
- - the values for *eq*, *order*, and *hash* are ignored and the
- instances compare and hash by the instance's ids (N.B. ``attrs`` will
- *not* remove existing implementations of ``__hash__`` or the equality
- methods. It just won't add own ones.),
+ - the values for *eq*, *order*, and *hash* are ignored and the
+ instances compare and hash by the instance's ids (N.B. ``attrs`` will
+ *not* remove existing implementations of ``__hash__`` or the equality
+ methods. It just won't add own ones.),
- all attributes that are either passed into ``__init__`` or have a
default value are additionally available as a tuple in the ``args``
attribute,
@@ -1420,17 +1420,17 @@ def attrs(
.. versionadded:: 18.2.0 *weakref_slot*
.. deprecated:: 18.2.0
``__lt__``, ``__le__``, ``__gt__``, and ``__ge__`` now raise a
- `DeprecationWarning` if the classes compared are subclasses of
+ `DeprecationWarning` if the classes compared are subclasses of
each other. ``__eq`` and ``__ne__`` never tried to compared subclasses
to each other.
- .. versionchanged:: 19.2.0
- ``__lt__``, ``__le__``, ``__gt__``, and ``__ge__`` now do not consider
- subclasses comparable anymore.
+ .. versionchanged:: 19.2.0
+ ``__lt__``, ``__le__``, ``__gt__``, and ``__ge__`` now do not consider
+ subclasses comparable anymore.
.. versionadded:: 18.2.0 *kw_only*
.. versionadded:: 18.2.0 *cache_hash*
.. versionadded:: 19.1.0 *auto_exc*
- .. deprecated:: 19.2.0 *cmp* Removal on or after 2021-06-01.
- .. versionadded:: 19.2.0 *eq* and *order*
+ .. deprecated:: 19.2.0 *cmp* Removal on or after 2021-06-01.
+ .. versionadded:: 19.2.0 *eq* and *order*
.. versionadded:: 20.1.0 *auto_detect*
.. versionadded:: 20.1.0 *collect_by_mro*
.. versionadded:: 20.1.0 *getstate_setstate*
@@ -1499,11 +1499,11 @@ def attrs(
cls, eq_, auto_detect, ("__eq__", "__ne__")
)
if not is_exc and eq is True:
- builder.add_eq()
+ builder.add_eq()
if not is_exc and _determine_whether_to_implement(
cls, order_, auto_detect, ("__lt__", "__le__", "__gt__", "__ge__")
):
- builder.add_order()
+ builder.add_order()
builder.add_setattr()
@@ -1520,9 +1520,9 @@ def attrs(
raise TypeError(
"Invalid value for hash. Must be True, False, or None."
)
- elif hash is False or (hash is None and eq is False) or is_exc:
- # Don't do anything. Should fall back to __object__'s __hash__
- # which is by id.
+ elif hash is False or (hash is None and eq is False) or is_exc:
+ # Don't do anything. Should fall back to __object__'s __hash__
+ # which is by id.
if cache_hash:
raise TypeError(
"Invalid value for cache_hash. To use hash caching,"
@@ -1532,10 +1532,10 @@ def attrs(
elif hash is True or (
hash is None and eq is True and is_frozen is True
):
- # Build a __hash__ if told so, or if it's safe.
+ # Build a __hash__ if told so, or if it's safe.
builder.add_hash()
else:
- # Raise TypeError on attempts to hash.
+ # Raise TypeError on attempts to hash.
if cache_hash:
raise TypeError(
"Invalid value for cache_hash. To use hash caching,"
@@ -1597,44 +1597,44 @@ else:
return cls.__setattr__ == _frozen_setattrs
-def _generate_unique_filename(cls, func_name):
- """
- Create a "filename" suitable for a function being generated.
- """
- unique_id = uuid.uuid4()
- extra = ""
- count = 1
-
- while True:
- unique_filename = "<attrs generated {0} {1}.{2}{3}>".format(
- func_name,
- cls.__module__,
- getattr(cls, "__qualname__", cls.__name__),
- extra,
- )
- # To handle concurrency we essentially "reserve" our spot in
- # the linecache with a dummy line. The caller can then
- # set this value correctly.
- cache_line = (1, None, (str(unique_id),), unique_filename)
- if (
- linecache.cache.setdefault(unique_filename, cache_line)
- == cache_line
- ):
- return unique_filename
-
- # Looks like this spot is taken. Try again.
- count += 1
- extra = "-{0}".format(count)
-
-
-def _make_hash(cls, attrs, frozen, cache_hash):
+def _generate_unique_filename(cls, func_name):
+ """
+ Create a "filename" suitable for a function being generated.
+ """
+ unique_id = uuid.uuid4()
+ extra = ""
+ count = 1
+
+ while True:
+ unique_filename = "<attrs generated {0} {1}.{2}{3}>".format(
+ func_name,
+ cls.__module__,
+ getattr(cls, "__qualname__", cls.__name__),
+ extra,
+ )
+ # To handle concurrency we essentially "reserve" our spot in
+ # the linecache with a dummy line. The caller can then
+ # set this value correctly.
+ cache_line = (1, None, (str(unique_id),), unique_filename)
+ if (
+ linecache.cache.setdefault(unique_filename, cache_line)
+ == cache_line
+ ):
+ return unique_filename
+
+ # Looks like this spot is taken. Try again.
+ count += 1
+ extra = "-{0}".format(count)
+
+
+def _make_hash(cls, attrs, frozen, cache_hash):
attrs = tuple(
- a for a in attrs if a.hash is True or (a.hash is None and a.eq is True)
+ a for a in attrs if a.hash is True or (a.hash is None and a.eq is True)
)
tab = " "
- unique_filename = _generate_unique_filename(cls, "hash")
+ unique_filename = _generate_unique_filename(cls, "hash")
type_hash = hash(unique_filename)
hash_def = "def __hash__(self"
@@ -1697,7 +1697,7 @@ def _add_hash(cls, attrs):
"""
Add a hash method to *cls*.
"""
- cls.__hash__ = _make_hash(cls, attrs, frozen=False, cache_hash=False)
+ cls.__hash__ = _make_hash(cls, attrs, frozen=False, cache_hash=False)
return cls
@@ -1720,13 +1720,13 @@ def _make_ne():
return __ne__
-def _make_eq(cls, attrs):
+def _make_eq(cls, attrs):
"""
Create __eq__ method for *cls* with *attrs*.
"""
- attrs = [a for a in attrs if a.eq]
+ attrs = [a for a in attrs if a.eq]
- unique_filename = _generate_unique_filename(cls, "eq")
+ unique_filename = _generate_unique_filename(cls, "eq")
lines = [
"def __eq__(self, other):",
" if other.__class__ is not self.__class__:",
@@ -1771,13 +1771,13 @@ def _make_eq(cls, attrs):
return _make_method("__eq__", script, unique_filename, globs)
-
-def _make_order(cls, attrs):
+
+def _make_order(cls, attrs):
"""
Create ordering methods for *cls* with *attrs*.
"""
- attrs = [a for a in attrs if a.order]
-
+ attrs = [a for a in attrs if a.order]
+
def attrs_to_tuple(obj):
"""
Save us some typing.
@@ -1793,44 +1793,44 @@ def _make_order(cls, attrs):
"""
Automatically created by attrs.
"""
- if other.__class__ is self.__class__:
+ if other.__class__ is self.__class__:
return attrs_to_tuple(self) < attrs_to_tuple(other)
- return NotImplemented
-
+ return NotImplemented
+
def __le__(self, other):
"""
Automatically created by attrs.
"""
- if other.__class__ is self.__class__:
+ if other.__class__ is self.__class__:
return attrs_to_tuple(self) <= attrs_to_tuple(other)
- return NotImplemented
-
+ return NotImplemented
+
def __gt__(self, other):
"""
Automatically created by attrs.
"""
- if other.__class__ is self.__class__:
+ if other.__class__ is self.__class__:
return attrs_to_tuple(self) > attrs_to_tuple(other)
- return NotImplemented
-
+ return NotImplemented
+
def __ge__(self, other):
"""
Automatically created by attrs.
"""
- if other.__class__ is self.__class__:
+ if other.__class__ is self.__class__:
return attrs_to_tuple(self) >= attrs_to_tuple(other)
- return NotImplemented
-
- return __lt__, __le__, __gt__, __ge__
+ return NotImplemented
+ return __lt__, __le__, __gt__, __ge__
-def _add_eq(cls, attrs=None):
+
+def _add_eq(cls, attrs=None):
"""
- Add equality methods to *cls* with *attrs*.
+ Add equality methods to *cls* with *attrs*.
"""
if attrs is None:
attrs = cls.__attrs_attrs__
@@ -1846,18 +1846,18 @@ _already_repring = threading.local()
def _make_repr(attrs, ns):
"""
- Make a repr method that includes relevant *attrs*, adding *ns* to the full
- name.
+ Make a repr method that includes relevant *attrs*, adding *ns* to the full
+ name.
"""
- # Figure out which attributes to include, and which function to use to
- # format them. The a.repr value can be either bool or a custom callable.
- attr_names_with_reprs = tuple(
- (a.name, repr if a.repr is True else a.repr)
- for a in attrs
- if a.repr is not False
- )
-
+ # Figure out which attributes to include, and which function to use to
+ # format them. The a.repr value can be either bool or a custom callable.
+ attr_names_with_reprs = tuple(
+ (a.name, repr if a.repr is True else a.repr)
+ for a in attrs
+ if a.repr is not False
+ )
+
def __repr__(self):
"""
Automatically created by attrs.
@@ -1888,14 +1888,14 @@ def _make_repr(attrs, ns):
try:
result = [class_name, "("]
first = True
- for name, attr_repr in attr_names_with_reprs:
+ for name, attr_repr in attr_names_with_reprs:
if first:
first = False
else:
result.append(", ")
- result.extend(
- (name, "=", attr_repr(getattr(self, name, NOTHING)))
- )
+ result.extend(
+ (name, "=", attr_repr(getattr(self, name, NOTHING)))
+ )
return "".join(result) + ")"
finally:
working_set.remove(id(self))
@@ -1927,7 +1927,7 @@ def fields(cls):
:raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs``
class.
- :rtype: tuple (with name accessors) of `attr.Attribute`
+ :rtype: tuple (with name accessors) of `attr.Attribute`
.. versionchanged:: 16.2.0 Returned tuple allows accessing the fields
by name.
@@ -1954,7 +1954,7 @@ def fields_dict(cls):
class.
:rtype: an ordered dict where keys are attribute names and values are
- `attr.Attribute`\\ s. This will be a `dict` if it's
+ `attr.Attribute`\\ s. This will be a `dict` if it's
naturally ordered like on Python 3.6+ or an
:class:`~collections.OrderedDict` otherwise.
@@ -2485,8 +2485,8 @@ class Attribute(object):
:attribute inherited: Whether or not that attribute has been inherited from
a base class.
- Plus *all* arguments of `attr.ib` (except for ``factory``
- which is only syntactic sugar for ``default=Factory(...)``.
+ Plus *all* arguments of `attr.ib` (except for ``factory``
+ which is only syntactic sugar for ``default=Factory(...)``.
.. versionadded:: 20.1.0 *inherited*
.. versionadded:: 20.1.0 *on_setattr*
@@ -2502,9 +2502,9 @@ class Attribute(object):
"default",
"validator",
"repr",
- "eq",
+ "eq",
"eq_key",
- "order",
+ "order",
"order_key",
"hash",
"init",
@@ -2522,7 +2522,7 @@ class Attribute(object):
default,
validator,
repr,
- cmp, # XXX: unused, remove along with other cmp code.
+ cmp, # XXX: unused, remove along with other cmp code.
hash,
init,
inherited,
@@ -2530,16 +2530,16 @@ class Attribute(object):
type=None,
converter=None,
kw_only=False,
- eq=None,
+ eq=None,
eq_key=None,
- order=None,
+ order=None,
order_key=None,
on_setattr=None,
):
eq, eq_key, order, order_key = _determine_attrib_eq_order(
cmp, eq_key or eq, order_key or order, True
)
-
+
# Cache this descriptor here to speed things up later.
bound_setattr = _obj_setattr.__get__(self, Attribute)
@@ -2549,9 +2549,9 @@ class Attribute(object):
bound_setattr("default", default)
bound_setattr("validator", validator)
bound_setattr("repr", repr)
- bound_setattr("eq", eq)
+ bound_setattr("eq", eq)
bound_setattr("eq_key", eq_key)
- bound_setattr("order", order)
+ bound_setattr("order", order)
bound_setattr("order_key", order_key)
bound_setattr("hash", hash)
bound_setattr("init", init)
@@ -2598,20 +2598,20 @@ class Attribute(object):
validator=ca._validator,
default=ca._default,
type=type,
- cmp=None,
+ cmp=None,
inherited=False,
**inst_dict
)
- @property
- def cmp(self):
- """
- Simulate the presence of a cmp attribute and warn.
- """
- warnings.warn(_CMP_DEPRECATION, DeprecationWarning, stacklevel=2)
-
- return self.eq and self.order
-
+ @property
+ def cmp(self):
+ """
+ Simulate the presence of a cmp attribute and warn.
+ """
+ warnings.warn(_CMP_DEPRECATION, DeprecationWarning, stacklevel=2)
+
+ return self.eq and self.order
+
# Don't use attr.evolve since fields(Attribute) doesn't work
def evolve(self, **changes):
"""
@@ -2666,9 +2666,9 @@ _a = [
default=NOTHING,
validator=None,
repr=True,
- cmp=None,
- eq=True,
- order=False,
+ cmp=None,
+ eq=True,
+ order=False,
hash=(name != "metadata"),
init=True,
inherited=False,
@@ -2698,9 +2698,9 @@ class _CountingAttr(object):
"counter",
"_default",
"repr",
- "eq",
+ "eq",
"eq_key",
- "order",
+ "order",
"order_key",
"hash",
"init",
@@ -2717,40 +2717,40 @@ class _CountingAttr(object):
default=NOTHING,
validator=None,
repr=True,
- cmp=None,
+ cmp=None,
hash=True,
init=True,
kw_only=False,
- eq=True,
+ eq=True,
eq_key=None,
- order=False,
+ order=False,
order_key=None,
inherited=False,
on_setattr=None,
)
- for name in (
- "counter",
- "_default",
- "repr",
- "eq",
- "order",
- "hash",
- "init",
+ for name in (
+ "counter",
+ "_default",
+ "repr",
+ "eq",
+ "order",
+ "hash",
+ "init",
"on_setattr",
- )
+ )
) + (
Attribute(
name="metadata",
default=None,
validator=None,
repr=True,
- cmp=None,
+ cmp=None,
hash=False,
init=True,
kw_only=False,
- eq=True,
+ eq=True,
eq_key=None,
- order=False,
+ order=False,
order_key=None,
inherited=False,
on_setattr=None,
@@ -2770,9 +2770,9 @@ class _CountingAttr(object):
metadata,
type,
kw_only,
- eq,
+ eq,
eq_key,
- order,
+ order,
order_key,
on_setattr,
):
@@ -2782,9 +2782,9 @@ class _CountingAttr(object):
self._validator = validator
self.converter = converter
self.repr = repr
- self.eq = eq
+ self.eq = eq
self.eq_key = eq_key
- self.order = order
+ self.order = order
self.order_key = order_key
self.hash = hash
self.init = init
@@ -2825,14 +2825,14 @@ class _CountingAttr(object):
return meth
-_CountingAttr = _add_eq(_add_repr(_CountingAttr))
+_CountingAttr = _add_eq(_add_repr(_CountingAttr))
class Factory(object):
"""
Stores a factory callable.
- If passed as the default value to `attr.ib`, the factory is used to
+ If passed as the default value to `attr.ib`, the factory is used to
generate a new value.
:param callable factory: A callable that takes either none or exactly one
@@ -2895,15 +2895,15 @@ def make_class(name, attrs, bases=(object,), **attributes_arguments):
:param attrs: A list of names or a dictionary of mappings of names to
attributes.
- If *attrs* is a list or an ordered dict (`dict` on Python 3.6+,
- `collections.OrderedDict` otherwise), the order is deduced from
+ If *attrs* is a list or an ordered dict (`dict` on Python 3.6+,
+ `collections.OrderedDict` otherwise), the order is deduced from
the order of the names or attributes inside *attrs*. Otherwise the
order of the definition of the attributes is used.
- :type attrs: `list` or `dict`
+ :type attrs: `list` or `dict`
:param tuple bases: Classes that the new class will subclass.
- :param attributes_arguments: Passed unmodified to `attr.s`.
+ :param attributes_arguments: Passed unmodified to `attr.s`.
:return: A new class with *attrs*.
:rtype: type
@@ -2943,8 +2943,8 @@ def make_class(name, attrs, bases=(object,), **attributes_arguments):
except (AttributeError, ValueError):
pass
- # We do it here for proper warnings with meaningful stacklevel.
- cmp = attributes_arguments.pop("cmp", None)
+ # We do it here for proper warnings with meaningful stacklevel.
+ cmp = attributes_arguments.pop("cmp", None)
(
attributes_arguments["eq"],
attributes_arguments["order"],
@@ -2953,8 +2953,8 @@ def make_class(name, attrs, bases=(object,), **attributes_arguments):
attributes_arguments.get("eq"),
attributes_arguments.get("order"),
True,
- )
-
+ )
+
return _attrs(these=cls_dict, **attributes_arguments)(type_)
diff --git a/contrib/python/attrs/attr/converters.py b/contrib/python/attrs/attr/converters.py
index 2777db6d0a..ba7389283b 100644
--- a/contrib/python/attrs/attr/converters.py
+++ b/contrib/python/attrs/attr/converters.py
@@ -65,14 +65,14 @@ def default_if_none(default=NOTHING, factory=None):
result of *factory*.
:param default: Value to be used if ``None`` is passed. Passing an instance
- of `attr.Factory` is supported, however the ``takes_self`` option
+ of `attr.Factory` is supported, however the ``takes_self`` option
is *not*.
:param callable factory: A callable that takes no parameters whose result
is used if ``None`` is passed.
:raises TypeError: If **neither** *default* or *factory* is passed.
:raises TypeError: If **both** *default* and *factory* are passed.
- :raises ValueError: If an instance of `attr.Factory` is passed with
+ :raises ValueError: If an instance of `attr.Factory` is passed with
``takes_self=True``.
.. versionadded:: 18.2.0
diff --git a/contrib/python/attrs/attr/converters.pyi b/contrib/python/attrs/attr/converters.pyi
index 84a57590b0..de4d63fac5 100644
--- a/contrib/python/attrs/attr/converters.pyi
+++ b/contrib/python/attrs/attr/converters.pyi
@@ -1,13 +1,13 @@
from typing import Callable, Optional, TypeVar, overload
-from . import _ConverterType
-
-
-_T = TypeVar("_T")
+from . import _ConverterType
+
+_T = TypeVar("_T")
+
def pipe(*validators: _ConverterType) -> _ConverterType: ...
def optional(converter: _ConverterType) -> _ConverterType: ...
-@overload
+@overload
def default_if_none(default: _T) -> _ConverterType: ...
-@overload
+@overload
def default_if_none(*, factory: Callable[[], _T]) -> _ConverterType: ...
diff --git a/contrib/python/attrs/attr/exceptions.py b/contrib/python/attrs/attr/exceptions.py
index f6f9861bea..10cb9d6004 100644
--- a/contrib/python/attrs/attr/exceptions.py
+++ b/contrib/python/attrs/attr/exceptions.py
@@ -7,7 +7,7 @@ class FrozenError(AttributeError):
modified.
It mirrors the behavior of ``namedtuples`` by using the same error message
- and subclassing `AttributeError`.
+ and subclassing `AttributeError`.
.. versionadded:: 20.1.0
"""
@@ -73,20 +73,20 @@ class PythonTooOldError(RuntimeError):
.. versionadded:: 18.2.0
"""
-
-
-class NotCallableError(TypeError):
- """
- A ``attr.ib()`` requiring a callable has been set with a value
- that is not callable.
-
- .. versionadded:: 19.2.0
- """
-
- def __init__(self, msg, value):
- super(TypeError, self).__init__(msg, value)
- self.msg = msg
- self.value = value
-
- def __str__(self):
- return str(self.msg)
+
+
+class NotCallableError(TypeError):
+ """
+ A ``attr.ib()`` requiring a callable has been set with a value
+ that is not callable.
+
+ .. versionadded:: 19.2.0
+ """
+
+ def __init__(self, msg, value):
+ super(TypeError, self).__init__(msg, value)
+ self.msg = msg
+ self.value = value
+
+ def __str__(self):
+ return str(self.msg)
diff --git a/contrib/python/attrs/attr/exceptions.pyi b/contrib/python/attrs/attr/exceptions.pyi
index a800fb26bb..1aaa057f8b 100644
--- a/contrib/python/attrs/attr/exceptions.pyi
+++ b/contrib/python/attrs/attr/exceptions.pyi
@@ -1,18 +1,18 @@
-from typing import Any
-
+from typing import Any
+
class FrozenError(AttributeError):
- msg: str = ...
-
+ msg: str = ...
+
class FrozenInstanceError(FrozenError): ...
class FrozenAttributeError(FrozenError): ...
-class AttrsAttributeNotFoundError(ValueError): ...
-class NotAnAttrsClassError(ValueError): ...
-class DefaultAlreadySetError(RuntimeError): ...
-class UnannotatedAttributeError(RuntimeError): ...
-class PythonTooOldError(RuntimeError): ...
-
-class NotCallableError(TypeError):
- msg: str = ...
- value: Any = ...
- def __init__(self, msg: str, value: Any) -> None: ...
+class AttrsAttributeNotFoundError(ValueError): ...
+class NotAnAttrsClassError(ValueError): ...
+class DefaultAlreadySetError(RuntimeError): ...
+class UnannotatedAttributeError(RuntimeError): ...
+class PythonTooOldError(RuntimeError): ...
+
+class NotCallableError(TypeError):
+ msg: str = ...
+ value: Any = ...
+ def __init__(self, msg: str, value: Any) -> None: ...
diff --git a/contrib/python/attrs/attr/filters.py b/contrib/python/attrs/attr/filters.py
index dc47e8fa38..2bc21706cb 100644
--- a/contrib/python/attrs/attr/filters.py
+++ b/contrib/python/attrs/attr/filters.py
@@ -1,5 +1,5 @@
"""
-Commonly useful filters for `attr.asdict`.
+Commonly useful filters for `attr.asdict`.
"""
from __future__ import absolute_import, division, print_function
@@ -23,9 +23,9 @@ def include(*what):
Whitelist *what*.
:param what: What to whitelist.
- :type what: `list` of `type` or `attr.Attribute`\\ s
+ :type what: `list` of `type` or `attr.Attribute`\\ s
- :rtype: `callable`
+ :rtype: `callable`
"""
cls, attrs = _split_what(what)
@@ -40,9 +40,9 @@ def exclude(*what):
Blacklist *what*.
:param what: What to blacklist.
- :type what: `list` of classes or `attr.Attribute`\\ s.
+ :type what: `list` of classes or `attr.Attribute`\\ s.
- :rtype: `callable`
+ :rtype: `callable`
"""
cls, attrs = _split_what(what)
diff --git a/contrib/python/attrs/attr/filters.pyi b/contrib/python/attrs/attr/filters.pyi
index f7b63f1bb4..cc83b50534 100644
--- a/contrib/python/attrs/attr/filters.pyi
+++ b/contrib/python/attrs/attr/filters.pyi
@@ -1,7 +1,7 @@
from typing import Any, Union
-from . import Attribute, _FilterType
+from . import Attribute, _FilterType
+
-
-def include(*what: Union[type, Attribute[Any]]) -> _FilterType[Any]: ...
-def exclude(*what: Union[type, Attribute[Any]]) -> _FilterType[Any]: ...
+def include(*what: Union[type, Attribute[Any]]) -> _FilterType[Any]: ...
+def exclude(*what: Union[type, Attribute[Any]]) -> _FilterType[Any]: ...
diff --git a/contrib/python/attrs/attr/validators.py b/contrib/python/attrs/attr/validators.py
index b9a73054e9..22b741be17 100644
--- a/contrib/python/attrs/attr/validators.py
+++ b/contrib/python/attrs/attr/validators.py
@@ -4,23 +4,23 @@ Commonly useful validators.
from __future__ import absolute_import, division, print_function
-import re
-
+import re
+
from ._make import _AndValidator, and_, attrib, attrs
-from .exceptions import NotCallableError
+from .exceptions import NotCallableError
-__all__ = [
- "and_",
- "deep_iterable",
- "deep_mapping",
- "in_",
- "instance_of",
- "is_callable",
- "matches_re",
- "optional",
- "provides",
-]
+__all__ = [
+ "and_",
+ "deep_iterable",
+ "deep_mapping",
+ "in_",
+ "instance_of",
+ "is_callable",
+ "matches_re",
+ "optional",
+ "provides",
+]
@attrs(repr=False, slots=True, hash=True)
@@ -53,92 +53,92 @@ class _InstanceOfValidator(object):
def instance_of(type):
"""
- A validator that raises a `TypeError` if the initializer is called
+ 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).
+ `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 types
:raises TypeError: With a human readable error message, the attribute
- (of type `attr.Attribute`), the expected type, and the value it
+ (of type `attr.Attribute`), the expected type, and the value it
got.
"""
return _InstanceOfValidator(type)
@attrs(repr=False, frozen=True, slots=True)
-class _MatchesReValidator(object):
- regex = attrib()
- flags = attrib()
- match_func = attrib()
-
- def __call__(self, inst, attr, value):
- """
- We use a callable class to be able to change the ``__repr__``.
- """
- if not self.match_func(value):
- raise ValueError(
- "'{name}' must match regex {regex!r}"
- " ({value!r} doesn't)".format(
- name=attr.name, regex=self.regex.pattern, value=value
- ),
- attr,
- self.regex,
- value,
- )
-
- def __repr__(self):
- return "<matches_re validator for pattern {regex!r}>".format(
- regex=self.regex
- )
-
-
-def matches_re(regex, flags=0, func=None):
- r"""
- A validator that raises `ValueError` if the initializer is called
- with a string that doesn't match *regex*.
-
- :param str regex: a regex string 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 to call (options
- are `re.fullmatch`, `re.search`, `re.match`, default
- is ``None`` which means either `re.fullmatch` or an emulation of
- it on Python 2). For performance reasons, they won't be used directly
- but on a pre-`re.compile`\ ed pattern.
-
- .. versionadded:: 19.2.0
- """
- fullmatch = getattr(re, "fullmatch", None)
- valid_funcs = (fullmatch, None, re.search, re.match)
- if func not in valid_funcs:
- raise ValueError(
- "'func' must be one of %s."
- % (
- ", ".join(
- sorted(
- e and e.__name__ or "None" for e in set(valid_funcs)
- )
- ),
- )
- )
-
- pattern = re.compile(regex, flags)
- if func is re.match:
- match_func = pattern.match
- elif func is re.search:
- match_func = pattern.search
- else:
- if fullmatch:
- match_func = pattern.fullmatch
- else:
- pattern = re.compile(r"(?:{})\Z".format(regex), flags)
- match_func = pattern.match
-
- return _MatchesReValidator(pattern, flags, match_func)
-
-
+class _MatchesReValidator(object):
+ regex = attrib()
+ flags = attrib()
+ match_func = attrib()
+
+ def __call__(self, inst, attr, value):
+ """
+ We use a callable class to be able to change the ``__repr__``.
+ """
+ if not self.match_func(value):
+ raise ValueError(
+ "'{name}' must match regex {regex!r}"
+ " ({value!r} doesn't)".format(
+ name=attr.name, regex=self.regex.pattern, value=value
+ ),
+ attr,
+ self.regex,
+ value,
+ )
+
+ def __repr__(self):
+ return "<matches_re validator for pattern {regex!r}>".format(
+ regex=self.regex
+ )
+
+
+def matches_re(regex, flags=0, func=None):
+ r"""
+ A validator that raises `ValueError` if the initializer is called
+ with a string that doesn't match *regex*.
+
+ :param str regex: a regex string 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 to call (options
+ are `re.fullmatch`, `re.search`, `re.match`, default
+ is ``None`` which means either `re.fullmatch` or an emulation of
+ it on Python 2). For performance reasons, they won't be used directly
+ but on a pre-`re.compile`\ ed pattern.
+
+ .. versionadded:: 19.2.0
+ """
+ fullmatch = getattr(re, "fullmatch", None)
+ valid_funcs = (fullmatch, None, re.search, re.match)
+ if func not in valid_funcs:
+ raise ValueError(
+ "'func' must be one of %s."
+ % (
+ ", ".join(
+ sorted(
+ e and e.__name__ or "None" for e in set(valid_funcs)
+ )
+ ),
+ )
+ )
+
+ pattern = re.compile(regex, flags)
+ if func is re.match:
+ match_func = pattern.match
+ elif func is re.search:
+ match_func = pattern.search
+ else:
+ if fullmatch:
+ match_func = pattern.fullmatch
+ else:
+ pattern = re.compile(r"(?:{})\Z".format(regex), flags)
+ match_func = pattern.match
+
+ return _MatchesReValidator(pattern, flags, match_func)
+
+
@attrs(repr=False, slots=True, hash=True)
class _ProvidesValidator(object):
interface = attrib()
@@ -166,7 +166,7 @@ class _ProvidesValidator(object):
def provides(interface):
"""
- A validator that raises a `TypeError` if the initializer is called
+ 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/>`_).
@@ -175,7 +175,7 @@ def provides(interface):
:type interface: ``zope.interface.Interface``
:raises TypeError: With a human readable error message, the attribute
- (of type `attr.Attribute`), the expected interface, and the
+ (of type `attr.Attribute`), the expected interface, and the
value it got.
"""
return _ProvidesValidator(interface)
@@ -205,7 +205,7 @@ def optional(validator):
:param validator: A validator (or a list of validators) that is used for
non-``None`` values.
- :type validator: callable or `list` of callables.
+ :type validator: callable or `list` of callables.
.. versionadded:: 15.1.0
.. versionchanged:: 17.1.0 *validator* can be a list of validators.
@@ -240,15 +240,15 @@ class _InValidator(object):
def in_(options):
"""
- A validator that raises a `ValueError` if the initializer is called
+ 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`, ...
+ :type options: list, tuple, `enum.Enum`, ...
:raises ValueError: With a human readable error message, the attribute (of
- type `attr.Attribute`), the expected options, and the value it
+ type `attr.Attribute`), the expected options, and the value it
got.
.. versionadded:: 17.1.0
@@ -263,16 +263,16 @@ class _IsCallableValidator(object):
We use a callable class to be able to change the ``__repr__``.
"""
if not callable(value):
- message = (
- "'{name}' must be callable "
- "(got {value!r} that is a {actual!r})."
- )
- raise NotCallableError(
- msg=message.format(
- name=attr.name, value=value, actual=value.__class__
- ),
- value=value,
- )
+ message = (
+ "'{name}' must be callable "
+ "(got {value!r} that is a {actual!r})."
+ )
+ raise NotCallableError(
+ msg=message.format(
+ name=attr.name, value=value, actual=value.__class__
+ ),
+ value=value,
+ )
def __repr__(self):
return "<is_callable validator>"
@@ -280,15 +280,15 @@ class _IsCallableValidator(object):
def is_callable():
"""
- A validator that raises a `attr.exceptions.NotCallableError` if the
- initializer is called with a value for this particular attribute
- that is not callable.
+ 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 (`attr.Attribute`) name,
- and the value it got.
+ :raises `attr.exceptions.NotCallableError`: With a human readable error
+ message containing the attribute (`attr.Attribute`) name,
+ and the value it got.
"""
return _IsCallableValidator()
diff --git a/contrib/python/attrs/attr/validators.pyi b/contrib/python/attrs/attr/validators.pyi
index fe92aac421..9cb339ec97 100644
--- a/contrib/python/attrs/attr/validators.pyi
+++ b/contrib/python/attrs/attr/validators.pyi
@@ -1,68 +1,68 @@
-from typing import (
+from typing import (
Any,
AnyStr,
Callable,
- Container,
+ Container,
Iterable,
- List,
+ List,
Mapping,
Match,
- Optional,
- Tuple,
+ Optional,
+ Tuple,
Type,
TypeVar,
Union,
- overload,
-)
+ overload,
+)
-from . import _ValidatorType
+from . import _ValidatorType
+
-
-_T = TypeVar("_T")
-_T1 = TypeVar("_T1")
-_T2 = TypeVar("_T2")
-_T3 = TypeVar("_T3")
-_I = TypeVar("_I", bound=Iterable)
-_K = TypeVar("_K")
-_V = TypeVar("_V")
-_M = TypeVar("_M", bound=Mapping)
-
-# To be more precise on instance_of use some overloads.
-# If there are more than 3 items in the tuple then we fall back to Any
-@overload
-def instance_of(type: Type[_T]) -> _ValidatorType[_T]: ...
-@overload
-def instance_of(type: Tuple[Type[_T]]) -> _ValidatorType[_T]: ...
-@overload
-def instance_of(
- type: Tuple[Type[_T1], Type[_T2]]
-) -> _ValidatorType[Union[_T1, _T2]]: ...
-@overload
-def instance_of(
- type: Tuple[Type[_T1], Type[_T2], Type[_T3]]
-) -> _ValidatorType[Union[_T1, _T2, _T3]]: ...
-@overload
-def instance_of(type: Tuple[type, ...]) -> _ValidatorType[Any]: ...
-def provides(interface: Any) -> _ValidatorType[Any]: ...
-def optional(
- validator: Union[_ValidatorType[_T], List[_ValidatorType[_T]]]
-) -> _ValidatorType[Optional[_T]]: ...
-def in_(options: Container[_T]) -> _ValidatorType[_T]: ...
-def and_(*validators: _ValidatorType[_T]) -> _ValidatorType[_T]: ...
-def matches_re(
- regex: AnyStr,
- flags: int = ...,
- func: Optional[
- Callable[[AnyStr, AnyStr, int], Optional[Match[AnyStr]]]
- ] = ...,
-) -> _ValidatorType[AnyStr]: ...
-def deep_iterable(
- member_validator: _ValidatorType[_T],
- iterable_validator: Optional[_ValidatorType[_I]] = ...,
-) -> _ValidatorType[_I]: ...
-def deep_mapping(
- key_validator: _ValidatorType[_K],
- value_validator: _ValidatorType[_V],
- mapping_validator: Optional[_ValidatorType[_M]] = ...,
-) -> _ValidatorType[_M]: ...
-def is_callable() -> _ValidatorType[_T]: ...
+_T = TypeVar("_T")
+_T1 = TypeVar("_T1")
+_T2 = TypeVar("_T2")
+_T3 = TypeVar("_T3")
+_I = TypeVar("_I", bound=Iterable)
+_K = TypeVar("_K")
+_V = TypeVar("_V")
+_M = TypeVar("_M", bound=Mapping)
+
+# To be more precise on instance_of use some overloads.
+# If there are more than 3 items in the tuple then we fall back to Any
+@overload
+def instance_of(type: Type[_T]) -> _ValidatorType[_T]: ...
+@overload
+def instance_of(type: Tuple[Type[_T]]) -> _ValidatorType[_T]: ...
+@overload
+def instance_of(
+ type: Tuple[Type[_T1], Type[_T2]]
+) -> _ValidatorType[Union[_T1, _T2]]: ...
+@overload
+def instance_of(
+ type: Tuple[Type[_T1], Type[_T2], Type[_T3]]
+) -> _ValidatorType[Union[_T1, _T2, _T3]]: ...
+@overload
+def instance_of(type: Tuple[type, ...]) -> _ValidatorType[Any]: ...
+def provides(interface: Any) -> _ValidatorType[Any]: ...
+def optional(
+ validator: Union[_ValidatorType[_T], List[_ValidatorType[_T]]]
+) -> _ValidatorType[Optional[_T]]: ...
+def in_(options: Container[_T]) -> _ValidatorType[_T]: ...
+def and_(*validators: _ValidatorType[_T]) -> _ValidatorType[_T]: ...
+def matches_re(
+ regex: AnyStr,
+ flags: int = ...,
+ func: Optional[
+ Callable[[AnyStr, AnyStr, int], Optional[Match[AnyStr]]]
+ ] = ...,
+) -> _ValidatorType[AnyStr]: ...
+def deep_iterable(
+ member_validator: _ValidatorType[_T],
+ iterable_validator: Optional[_ValidatorType[_I]] = ...,
+) -> _ValidatorType[_I]: ...
+def deep_mapping(
+ key_validator: _ValidatorType[_K],
+ value_validator: _ValidatorType[_V],
+ mapping_validator: Optional[_ValidatorType[_M]] = ...,
+) -> _ValidatorType[_M]: ...
+def is_callable() -> _ValidatorType[_T]: ...
diff --git a/contrib/python/attrs/ya.make b/contrib/python/attrs/ya.make
index 15fb4c423b..e07de1ad22 100644
--- a/contrib/python/attrs/ya.make
+++ b/contrib/python/attrs/ya.make
@@ -43,7 +43,7 @@ RESOURCE_FILES(
PREFIX contrib/python/attrs/
.dist-info/METADATA
.dist-info/top_level.txt
- attr/py.typed
+ attr/py.typed
)
END()
diff --git a/contrib/python/pytest/py2/_pytest/tmpdir.py b/contrib/python/pytest/py2/_pytest/tmpdir.py
index a8a7037713..6ae95623e8 100644
--- a/contrib/python/pytest/py2/_pytest/tmpdir.py
+++ b/contrib/python/pytest/py2/_pytest/tmpdir.py
@@ -32,7 +32,7 @@ class TempPathFactory(object):
# using os.path.abspath() to get absolute path instead of resolve() as it
# does not work the same in all platforms (see #4427)
# Path.absolute() exists, but it is not public (see https://bugs.python.org/issue25012)
- converter=attr.converters.optional(
+ converter=attr.converters.optional(
lambda p: Path(os.path.abspath(six.text_type(p)))
)
)