r""" A class decorator that adds :term:`dunder methods` according to the specified attributes using `attr.ib` or the *these* argument. Consider using `attrs.define` / `attrs.frozen` in new code (``attr.s`` will *never* go away, though). Args: repr_ns (str):
(
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,
match_args=True,
unsafe_hash=None,
force_kw_only=True,
)
| 1323 | |
| 1324 | |
| 1325 | def attrs( |
| 1326 | maybe_cls=None, |
| 1327 | these=None, |
| 1328 | repr_ns=None, |
| 1329 | repr=None, |
| 1330 | cmp=None, |
| 1331 | hash=None, |
| 1332 | init=None, |
| 1333 | slots=False, |
| 1334 | frozen=False, |
| 1335 | weakref_slot=True, |
| 1336 | str=False, |
| 1337 | auto_attribs=False, |
| 1338 | kw_only=False, |
| 1339 | cache_hash=False, |
| 1340 | auto_exc=False, |
| 1341 | eq=None, |
| 1342 | order=None, |
| 1343 | auto_detect=False, |
| 1344 | collect_by_mro=False, |
| 1345 | getstate_setstate=None, |
| 1346 | on_setattr=None, |
| 1347 | field_transformer=None, |
| 1348 | match_args=True, |
| 1349 | unsafe_hash=None, |
| 1350 | force_kw_only=True, |
| 1351 | ): |
| 1352 | r""" |
| 1353 | A class decorator that adds :term:`dunder methods` according to the |
| 1354 | specified attributes using `attr.ib` or the *these* argument. |
| 1355 | |
| 1356 | Consider using `attrs.define` / `attrs.frozen` in new code (``attr.s`` will |
| 1357 | *never* go away, though). |
| 1358 | |
| 1359 | Args: |
| 1360 | repr_ns (str): |
| 1361 | When using nested classes, there was no way in Python 2 to |
| 1362 | automatically detect that. This argument allows to set a custom |
| 1363 | name for a more meaningful ``repr`` output. This argument is |
| 1364 | pointless in Python 3 and is therefore deprecated. |
| 1365 | |
| 1366 | .. caution:: |
| 1367 | Refer to `attrs.define` for the rest of the parameters, but note that they |
| 1368 | can have different defaults. |
| 1369 | |
| 1370 | Notably, leaving *on_setattr* as `None` will **not** add any hooks. |
| 1371 | |
| 1372 | .. versionadded:: 16.0.0 *slots* |
| 1373 | .. versionadded:: 16.1.0 *frozen* |
| 1374 | .. versionadded:: 16.3.0 *str* |
| 1375 | .. versionadded:: 16.3.0 Support for ``__attrs_post_init__``. |
| 1376 | .. versionchanged:: 17.1.0 |
| 1377 | *hash* supports `None` as value which is also the default now. |
| 1378 | .. versionadded:: 17.3.0 *auto_attribs* |
| 1379 | .. versionchanged:: 18.1.0 |
| 1380 | If *these* is passed, no attributes are deleted from the class body. |
| 1381 | .. versionchanged:: 18.1.0 If *these* is ordered, the order is retained. |
| 1382 | .. versionadded:: 18.2.0 *weakref_slot* |
no test coverage detected