Skip to content

Commit ce38eb4

Browse files
committed
update vendored dependencies
1 parent b1cc918 commit ce38eb4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+14373
-9871
lines changed

src/poetry/core/_vendor/attr/__init__.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
# SPDX-License-Identifier: MIT
2+
13
from __future__ import absolute_import, division, print_function
24

35
import sys
46

57
from functools import partial
68

79
from . import converters, exceptions, filters, setters, validators
10+
from ._cmp import cmp_using
811
from ._config import get_run_validators, set_run_validators
912
from ._funcs import asdict, assoc, astuple, evolve, has, resolve_types
1013
from ._make import (
@@ -21,7 +24,7 @@
2124
from ._version_info import VersionInfo
2225

2326

24-
__version__ = "20.3.0"
27+
__version__ = "21.4.0"
2528
__version_info__ = VersionInfo._from_version_string(__version__)
2629

2730
__title__ = "attrs"
@@ -52,6 +55,7 @@
5255
"attrib",
5356
"attributes",
5457
"attrs",
58+
"cmp_using",
5559
"converters",
5660
"evolve",
5761
"exceptions",
@@ -71,6 +75,6 @@
7175
]
7276

7377
if sys.version_info[:2] >= (3, 6):
74-
from ._next_gen import define, field, frozen, mutable
78+
from ._next_gen import define, field, frozen, mutable # noqa: F401
7579

76-
__all__.extend((define, field, frozen, mutable))
80+
__all__.extend(("define", "field", "frozen", "mutable"))

src/poetry/core/_vendor/attr/_cmp.py

+154
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# SPDX-License-Identifier: MIT
2+
3+
from __future__ import absolute_import, division, print_function
4+
5+
import functools
6+
7+
from ._compat import new_class
8+
from ._make import _make_ne
9+
10+
11+
_operation_names = {"eq": "==", "lt": "<", "le": "<=", "gt": ">", "ge": ">="}
12+
13+
14+
def cmp_using(
15+
eq=None,
16+
lt=None,
17+
le=None,
18+
gt=None,
19+
ge=None,
20+
require_same_type=True,
21+
class_name="Comparable",
22+
):
23+
"""
24+
Create a class that can be passed into `attr.ib`'s ``eq``, ``order``, and
25+
``cmp`` arguments to customize field comparison.
26+
27+
The resulting class will have a full set of ordering methods if
28+
at least one of ``{lt, le, gt, ge}`` and ``eq`` are provided.
29+
30+
:param Optional[callable] eq: `callable` used to evaluate equality
31+
of two objects.
32+
:param Optional[callable] lt: `callable` used to evaluate whether
33+
one object is less than another object.
34+
:param Optional[callable] le: `callable` used to evaluate whether
35+
one object is less than or equal to another object.
36+
:param Optional[callable] gt: `callable` used to evaluate whether
37+
one object is greater than another object.
38+
:param Optional[callable] ge: `callable` used to evaluate whether
39+
one object is greater than or equal to another object.
40+
41+
:param bool require_same_type: When `True`, equality and ordering methods
42+
will return `NotImplemented` if objects are not of the same type.
43+
44+
:param Optional[str] class_name: Name of class. Defaults to 'Comparable'.
45+
46+
See `comparison` for more details.
47+
48+
.. versionadded:: 21.1.0
49+
"""
50+
51+
body = {
52+
"__slots__": ["value"],
53+
"__init__": _make_init(),
54+
"_requirements": [],
55+
"_is_comparable_to": _is_comparable_to,
56+
}
57+
58+
# Add operations.
59+
num_order_functions = 0
60+
has_eq_function = False
61+
62+
if eq is not None:
63+
has_eq_function = True
64+
body["__eq__"] = _make_operator("eq", eq)
65+
body["__ne__"] = _make_ne()
66+
67+
if lt is not None:
68+
num_order_functions += 1
69+
body["__lt__"] = _make_operator("lt", lt)
70+
71+
if le is not None:
72+
num_order_functions += 1
73+
body["__le__"] = _make_operator("le", le)
74+
75+
if gt is not None:
76+
num_order_functions += 1
77+
body["__gt__"] = _make_operator("gt", gt)
78+
79+
if ge is not None:
80+
num_order_functions += 1
81+
body["__ge__"] = _make_operator("ge", ge)
82+
83+
type_ = new_class(class_name, (object,), {}, lambda ns: ns.update(body))
84+
85+
# Add same type requirement.
86+
if require_same_type:
87+
type_._requirements.append(_check_same_type)
88+
89+
# Add total ordering if at least one operation was defined.
90+
if 0 < num_order_functions < 4:
91+
if not has_eq_function:
92+
# functools.total_ordering requires __eq__ to be defined,
93+
# so raise early error here to keep a nice stack.
94+
raise ValueError(
95+
"eq must be define is order to complete ordering from "
96+
"lt, le, gt, ge."
97+
)
98+
type_ = functools.total_ordering(type_)
99+
100+
return type_
101+
102+
103+
def _make_init():
104+
"""
105+
Create __init__ method.
106+
"""
107+
108+
def __init__(self, value):
109+
"""
110+
Initialize object with *value*.
111+
"""
112+
self.value = value
113+
114+
return __init__
115+
116+
117+
def _make_operator(name, func):
118+
"""
119+
Create operator method.
120+
"""
121+
122+
def method(self, other):
123+
if not self._is_comparable_to(other):
124+
return NotImplemented
125+
126+
result = func(self.value, other.value)
127+
if result is NotImplemented:
128+
return NotImplemented
129+
130+
return result
131+
132+
method.__name__ = "__%s__" % (name,)
133+
method.__doc__ = "Return a %s b. Computed by attrs." % (
134+
_operation_names[name],
135+
)
136+
137+
return method
138+
139+
140+
def _is_comparable_to(self, other):
141+
"""
142+
Check whether `other` is comparable to `self`.
143+
"""
144+
for func in self._requirements:
145+
if not func(self, other):
146+
return False
147+
return True
148+
149+
150+
def _check_same_type(self, other):
151+
"""
152+
Return True if *self* and *other* are of the same type, False otherwise.
153+
"""
154+
return other.value.__class__ is self.value.__class__

src/poetry/core/_vendor/attr/_compat.py

+32-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1+
# SPDX-License-Identifier: MIT
2+
13
from __future__ import absolute_import, division, print_function
24

35
import platform
46
import sys
7+
import threading
58
import types
69
import warnings
710

811

912
PY2 = sys.version_info[0] == 2
1013
PYPY = platform.python_implementation() == "PyPy"
14+
PY36 = sys.version_info[:2] >= (3, 6)
15+
HAS_F_STRINGS = PY36
16+
PY310 = sys.version_info[:2] >= (3, 10)
1117

1218

13-
if PYPY or sys.version_info[:2] >= (3, 6):
19+
if PYPY or PY36:
1420
ordered_dict = dict
1521
else:
1622
from collections import OrderedDict
@@ -28,6 +34,15 @@
2834
def isclass(klass):
2935
return isinstance(klass, (type, types.ClassType))
3036

37+
def new_class(name, bases, kwds, exec_body):
38+
"""
39+
A minimal stub of types.new_class that we need for make_class.
40+
"""
41+
ns = {}
42+
exec_body(ns)
43+
44+
return type(name, bases, ns)
45+
3146
# TYPE is used in exceptions, repr(int) is different on Python 2 and 3.
3247
TYPE = "type"
3348

@@ -97,7 +112,6 @@ def just_warn(*args, **kw): # pragma: no cover
97112
consequences of not setting the cell on Python 2.
98113
"""
99114

100-
101115
else: # Python 3 and later.
102116
from collections.abc import Mapping, Sequence # noqa
103117

@@ -122,6 +136,8 @@ def isclass(klass):
122136
def iteritems(d):
123137
return d.items()
124138

139+
new_class = types.new_class
140+
125141
def metadata_proxy(d):
126142
return types.MappingProxyType(dict(d))
127143

@@ -229,3 +245,17 @@ def func():
229245

230246

231247
set_closure_cell = make_set_closure_cell()
248+
249+
# Thread-local global to track attrs instances which are already being repr'd.
250+
# This is needed because there is no other (thread-safe) way to pass info
251+
# about the instances that are already being repr'd through the call stack
252+
# in order to ensure we don't perform infinite recursion.
253+
#
254+
# For instance, if an instance contains a dict which contains that instance,
255+
# we need to know that we're already repr'ing the outside instance from within
256+
# the dict's repr() call.
257+
#
258+
# This lives here rather than in _make.py so that the functions in _make.py
259+
# don't have a direct reference to the thread-local in their globals dict.
260+
# If they have such a reference, it breaks cloudpickle.
261+
repr_context = threading.local()

src/poetry/core/_vendor/attr/_config.py

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# SPDX-License-Identifier: MIT
2+
13
from __future__ import absolute_import, division, print_function
24

35

@@ -9,6 +11,10 @@
911
def set_run_validators(run):
1012
"""
1113
Set whether or not validators are run. By default, they are run.
14+
15+
.. deprecated:: 21.3.0 It will not be removed, but it also will not be
16+
moved to new ``attrs`` namespace. Use `attrs.validators.set_disabled()`
17+
instead.
1218
"""
1319
if not isinstance(run, bool):
1420
raise TypeError("'run' must be bool.")
@@ -19,5 +25,9 @@ def set_run_validators(run):
1925
def get_run_validators():
2026
"""
2127
Return whether or not validators are run.
28+
29+
.. deprecated:: 21.3.0 It will not be removed, but it also will not be
30+
moved to new ``attrs`` namespace. Use `attrs.validators.get_disabled()`
31+
instead.
2232
"""
2333
return _run_validators

0 commit comments

Comments
 (0)