attr
Attribute = _add_hash(_add_eq(_add_repr(Attribute, attrs=_a), attrs=[a for a in _a if a.name != 'inherited']), attrs=[a for a in _a if a.hash and a.name != 'inherited'])
module-attribute
Read-only representation of an attribute.
Instances of this class are frequently used for introspection purposes like:
fields
returns a tuple of them.- Validators get them passed as the first argument.
- The field transformer hook receives a list of them.
:attribute name: The name of the attribute. :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(...)
.
.. versionadded:: 20.1.0 inherited .. versionadded:: 20.1.0 on_setattr .. versionchanged:: 20.2.0 inherited is not taken into account for equality checks and hashing anymore. .. versionadded:: 21.1.0 eq_key and order_key
For the full version history of the fields, see attr.ib
.
Factory = _add_hash(_add_eq(_add_repr(Factory, attrs=_f), attrs=_f), attrs=_f)
module-attribute
Stores a factory callable.
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 mandatory positional argument depending on takes_self. :param bool takes_self: Pass the partially initialized instance that is being initialized as a positional argument.
.. versionadded:: 17.1.0 takes_self
NOTHING = _Nothing()
module-attribute
Sentinel to indicate the lack of a value when None
is ambiguous.
asdict(inst, recurse=True, filter=None, dict_factory=dict, retain_collection_types=False, value_serializer=None)
Return the attrs
attribute values of inst as a dict.
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 whether an attribute or element is included (True
) or dropped (False
). Is 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 dictionaries, pass in collections.OrderedDict
. :param bool retain_collection_types: Do not convert to list
when encountering an attribute whose type is tuple
or set
. Only meaningful if recurse
is True
. :param Optional[callable] value_serializer: A hook that is called for every attribute or dict key/value. It receives the current instance, field and value and must return the (updated) value. The hook is run after the optional filter has been applied.
:rtype: return type of dict_factory
:raise attr.exceptions.NotAnAttrsClassError: If cls is not an attrs
class.
.. versionadded:: 16.0.0 dict_factory .. versionadded:: 16.1.0 retain_collection_types .. versionadded:: 20.3.0 value_serializer
Source code in client/ayon_fusion/vendor/attr/_funcs.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
assoc(inst, **changes)
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.NotAnAttrsClassError: If cls is not an attrs
class.
.. deprecated:: 17.1.0 Use evolve
instead.
Source code in client/ayon_fusion/vendor/attr/_funcs.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
|
astuple(inst, recurse=True, filter=None, tuple_factory=tuple, retain_collection_types=False)
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 whether an attribute or element is included (True
) or dropped (False
). Is 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. :param bool retain_collection_types: Do not convert to list
or dict
when encountering an attribute which type is tuple
, dict
or set
. Only meaningful if recurse
is True
.
:rtype: return type of tuple_factory
:raise attr.exceptions.NotAnAttrsClassError: If cls is not an attrs
class.
.. versionadded:: 16.2.0
Source code in client/ayon_fusion/vendor/attr/_funcs.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
|
attrib(default=NOTHING, validator=None, repr=True, cmp=None, hash=None, init=True, metadata=None, type=None, converter=None, factory=None, kw_only=False, eq=None, order=None, on_setattr=None)
Create a new attribute on a class.
.. warning::
Does *not* do anything unless the class is also decorated with
`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
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`
will be raised.
The default can also be set using decorator notation as shown below.
:type default: Any value
:param callable factory: Syntactic sugar for default=attr.Factory(factory)
.
: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 passed value.
The return value is *not* inspected so the validator has to throw an
exception itself.
If a `list` is passed, its items are treated as validators and must
all pass.
Validators can be globally disabled and re-enabled using
`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). :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 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. To override how the attribute value is ordered, pass a callable
that takes a single value and returns the value to be ordered. :type order: a bool
or a callable
.
:param cmp: Setting cmp is equivalent to setting eq and order to the same value. Must not be mixed with eq or order. :type cmp: a bool
or a callable
.
:param Optional[bool] hash: Include this attribute in the generated __hash__
method. If None
(default), mirror eq's value. This is the correct behavior according the Python spec. Setting this value to anything else than None
is discouraged. :param bool init: Include this attribute in the generated __init__
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 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
. :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/>
_). This argument is provided for backward compatibility. Regardless of the approach used, the type will be stored on Attribute.type
.
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>`.
:param kw_only: Make this attribute keyword-only (Python 3+) in the generated __init__
(if init
is False
, this parameter is ignored). :param on_setattr: Allows to overwrite the on_setattr setting from attr.s
. If left None
, the on_setattr value from attr.s
is used. Set to attr.setters.NO_OP
to run no setattr
hooks for this attribute -- regardless of the setting in attr.s
. :type on_setattr: callable
, or a list of callables, or None
, or attr.setters.NO_OP
.. versionadded:: 15.2.0 convert .. 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. .. versionadded:: 17.3.0 type .. deprecated:: 17.4.0 convert .. versionadded:: 17.4.0 converter as a replacement for the deprecated convert to achieve consistency with other noun-based arguments. .. versionadded:: 18.1.0 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 .. versionadded:: 20.1.0 on_setattr .. versionchanged:: 20.3.0 kw_only backported to Python 2 .. versionchanged:: 21.1.0 eq, order, and cmp also accept a custom callable .. versionchanged:: 21.1.0 cmp undeprecated
Source code in client/ayon_fusion/vendor/attr/_make.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
|
attrs(maybe_cls=None, these=None, repr_ns=None, repr=None, cmp=None, hash=None, init=None, slots=False, frozen=False, weakref_slot=True, str=False, auto_attribs=False, kw_only=False, cache_hash=False, auto_exc=False, eq=None, order=None, auto_detect=False, collect_by_mro=False, getstate_setstate=None, on_setattr=None, field_transformer=None)
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.
: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.
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
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
: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 namespace explicitly for a more meaningful repr
output. :param bool auto_detect: Instead of setting the init, repr, eq, order, and hash arguments explicitly, assume they are set to True
unless any of the involved methods for one of the arguments is implemented in the current class (i.e. it is not inherited from some base class).
So for example by implementing ``__eq__`` on a class yourself,
``attrs`` will deduce ``eq=False`` and will create *neither*
``__eq__`` *nor* ``__ne__`` (but Python classes come with a sensible
``__ne__`` by default, so it *should* be enough to only implement
``__eq__`` in most cases).
.. warning::
If you prevent ``attrs`` from creating the ordering methods for you
(``order=False``, e.g. by implementing ``__le__``), it becomes
*your* responsibility to make sure its ordering is sound. The best
way is to use the `functools.total_ordering` decorator.
Passing ``True`` or ``False`` to *init*, *repr*, *eq*, *order*,
*cmp*, or *hash* overrides whatever *auto_detect* would determine.
*auto_detect* requires Python 3. Setting it ``True`` on Python 2 raises
a `PythonTooOldError`.
:param bool repr: Create a __repr__
method with a human readable 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. :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``
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 allow instances to be ordered. If None
(default) mirror value of eq. :param Optional[bool] cmp: Setting cmp is equivalent to setting eq and order to the same value. Must not be mixed with eq or order. :param Optional[bool] hash: If None
(default), the __hash__
method 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
None, marking it unhashable (which it is).
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.).
Although not recommended, you can decide for yourself and force
``attrs`` to create one (e.g. if the class is immutable even though you
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.
: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 be called before the class is initialized. If a __attrs_post_init__
method exists on the class, it will be called after the class is fully initialized.
If ``init`` is ``False``, an ``__attrs_init__`` method will be
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 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.
.. note::
1. This is achieved by installing a custom ``__setattr__`` method
on your class, so you can't implement your own.
2. True immutability is impossible in Python.
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``.
4. If a class is frozen, you cannot modify ``self`` in
``__attrs_post_init__`` or a self-written ``__init__``. You can
circumvent that limitation by using
``object.__setattr__(self, "attribute_name", value)``.
5. Subclasses of a frozen class are frozen too.
:param bool weakref_slot: Make instances weak-referenceable. This has no effect unless slots
is also enabled. :param bool auto_attribs: If True
, collect PEP 526
_-annotated 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
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
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**.
.. warning::
For features that use the attribute name to create decorators (e.g.
`validators <validators>`), you still *must* assign `attr.ib` to
them. Otherwise Python will either not find the name or try to use
the default value to call e.g. ``validator`` on it.
These errors can be quite confusing and probably the most common bug
report on our bug tracker.
.. _`PEP 526`: https://www.python.org/dev/peps/pep-0526/
:param bool kw_only: Make all attributes keyword-only (Python 3+) in the generated __init__
(if init
is False
, this parameter is ignored). :param bool cache_hash: Ensure that the object's hash code is computed only once and stored on the object. If this is set to True
, hashing must be either explicitly or implicitly enabled for this class. If the hash code is cached, avoid any reassignments of 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
(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.),
- all attributes that are either passed into ``__init__`` or have a
default value are additionally available as a tuple in the ``args``
attribute,
- the value of *str* is ignored leaving ``__str__`` to base classes.
:param bool collect_by_mro: Setting this to True
fixes the way attrs
collects attributes from base classes. The default behavior is incorrect in certain cases of multiple inheritance. It should be on by default but is kept off for backward-compatability.
See issue #428 <https://github.com/python-attrs/attrs/issues/428>
_ for more details.
:param Optional[bool] getstate_setstate: .. note:: This is usually only interesting for slotted classes and you should probably just set auto_detect to True
.
If True
, __getstate__
and __setstate__
are generated and attached to the class. This is necessary for slotted classes to be pickleable. If left None
, it's True
by default for slotted classes and False
for dict classes.
If auto_detect is True
, and getstate_setstate is left None
, and either __getstate__
or __setstate__
is detected directly on the class (i.e. not inherited), it is set to False
(this is usually what you want).
:param on_setattr: A callable that is run whenever the user attempts to set an attribute (either by assignment like i.x = 42
or by using setattr
like setattr(i, "x", 42)
). It receives the same arguments as validators: the instance, the attribute that is being modified, and the new value.
If no exception is raised, the attribute is set to the return value of
the callable.
If a list of callables is passed, they're automatically wrapped in an
`attr.setters.pipe`.
:param Optional[callable] field_transformer: A function that is called with the original class object and all fields right before attrs
finalizes the class. You can use this, e.g., to automatically add converters or validators to fields based on their types. See transform-fields
for more details.
.. versionadded:: 16.0.0 slots .. versionadded:: 16.1.0 frozen .. versionadded:: 16.3.0 str .. versionadded:: 16.3.0 Support for __attrs_post_init__
. .. versionchanged:: 17.1.0 hash supports None
as value which is also the default now. .. versionadded:: 17.3.0 auto_attribs .. versionchanged:: 18.1.0 If these is passed, no attributes are deleted from the class body. .. versionchanged:: 18.1.0 If these is ordered, the order is retained. .. 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 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. .. 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 .. versionadded:: 20.1.0 auto_detect .. versionadded:: 20.1.0 collect_by_mro .. versionadded:: 20.1.0 getstate_setstate .. versionadded:: 20.1.0 on_setattr .. versionadded:: 20.3.0 field_transformer .. versionchanged:: 21.1.0 init=False
injects __attrs_init__
.. versionchanged:: 21.1.0 Support for __attrs_pre_init__
.. versionchanged:: 21.1.0 cmp undeprecated
Source code in client/ayon_fusion/vendor/attr/_make.py
1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 |
|
cmp_using(eq=None, lt=None, le=None, gt=None, ge=None, require_same_type=True, class_name='Comparable')
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 two objects. :param Optional[callable] lt: callable
used to evaluate whether one object is less than another object. :param Optional[callable] le: callable
used to evaluate whether one object is less than or equal to another object. :param Optional[callable] gt: callable
used to evaluate whether one object is greater than another object. :param Optional[callable] ge: callable
used to evaluate whether one object is greater than or equal to another object.
:param bool require_same_type: When True
, equality and ordering methods will return NotImplemented
if objects are not of the same type.
:param Optional[str] class_name: Name of class. Defaults to 'Comparable'.
See comparison
for more details.
.. versionadded:: 21.1.0
Source code in client/ayon_fusion/vendor/attr/_cmp.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
evolve(inst, **changes)
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.exceptions.NotAnAttrsClassError: If cls is not an attrs
class.
.. versionadded:: 17.1.0
Source code in client/ayon_fusion/vendor/attr/_funcs.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
|
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 introspect.
:raise TypeError: If cls is not a class. :raise attr.exceptions.NotAnAttrsClassError: If cls is not an attrs
class.
:rtype: tuple (with name accessors) of attr.Attribute
.. versionchanged:: 16.2.0 Returned tuple allows accessing the fields by name.
Source code in client/ayon_fusion/vendor/attr/_make.py
1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 |
|
fields_dict(cls)
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: an ordered dict where keys are attribute names and values are attr.Attribute
\ s. This will be a dict
if it's naturally ordered like on Python 3.6+ or an :class:~collections.OrderedDict
otherwise.
.. versionadded:: 18.1.0
Source code in client/ayon_fusion/vendor/attr/_make.py
1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 |
|
get_run_validators()
Return whether or not validators are run.
Source code in client/ayon_fusion/vendor/attr/_config.py
19 20 21 22 23 |
|
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
Source code in client/ayon_fusion/vendor/attr/_funcs.py
267 268 269 270 271 272 273 274 275 276 |
|
make_class(name, attrs, bases=(object,), **attributes_arguments)
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.
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
:param tuple bases: Classes that the new class will subclass.
:param attributes_arguments: Passed unmodified to attr.s
.
:return: A new class with attrs. :rtype: type
.. versionadded:: 17.1.0 bases .. versionchanged:: 18.1.0 If attrs is ordered, the order is retained.
Source code in client/ayon_fusion/vendor/attr/_make.py
2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 |
|
resolve_types(cls, globalns=None, localns=None, attribs=None)
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 was created. If this is not what you want, e.g. if the name only exists inside a method, you may pass globalns or localns to specify other dictionaries in which to look up these names. See the docs of typing.get_type_hints
for more details.
:param type cls: Class to resolve. :param Optional[dict] globalns: Dictionary containing global variables. :param Optional[dict] localns: Dictionary containing local variables. :param Optional[list] attribs: List of attribs for the given class. This is necessary when calling from inside a field_transformer
since cls is not an attrs
class yet.
:raise TypeError: If cls is not a class. :raise attr.exceptions.NotAnAttrsClassError: If cls is not an attrs
class and you didn't pass any attribs. :raise NameError: If types cannot be resolved because of missing variables.
:returns: cls so you can use this function also as a class decorator. Please note that you have to apply it after attr.s
. That means the decorator has to come in the line before attr.s
.
.. versionadded:: 20.1.0 .. versionadded:: 21.1.0 attribs
Source code in client/ayon_fusion/vendor/attr/_funcs.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
|
set_run_validators(run)
Set whether or not validators are run. By default, they are run.
Source code in client/ayon_fusion/vendor/attr/_config.py
9 10 11 12 13 14 15 16 |
|
validate(inst)
Validate all attributes on inst that have a validator.
Leaves all exceptions through.
:param inst: Instance of a class with attrs
attributes.
Source code in client/ayon_fusion/vendor/attr/_make.py
1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 |
|