MCPcopy
hub / github.com/python-attrs/attrs / Attribute

Class Attribute

src/attr/_make.py:2429–2667  ·  src/attr/_make.py::Attribute

*Read-only* representation of an attribute. .. warning:: You should never instantiate this class yourself. The class has *all* arguments of `attr.ib` (except for ``factory`` which is only syntactic sugar for ``default=Factory(...)`` plus the following: - ``name`` (`st

Source from the content-addressed store, hash-verified

2427
2428
2429class Attribute:
2430 class="st">"""
2431 *Read-only* representation of an attribute.
2432
2433 .. warning::
2434
2435 You should never instantiate this class yourself.
2436
2437 The class has *all* arguments of `attr.ib` (except for ``factory`` which is
2438 only syntactic sugar for ``default=Factory(...)`` plus the following:
2439
2440 - ``name`` (`str`): The name of the attribute.
2441 - ``alias`` (`str`): The __init__ parameter name of the attribute, after
2442 any explicit overrides and default private-attribute-name handling.
2443 - ``alias_is_default`` (`bool`): Whether the ``alias`` was automatically
2444 generated (``True``) or explicitly provided by the user (``False``).
2445 - ``inherited`` (`bool`): Whether or not that attribute has been inherited
2446 from a base class.
2447 - ``eq_key`` and ``order_key`` (`typing.Callable` or `None`): The
2448 callables that are used for comparing and ordering objects by this
2449 attribute, respectively. These are set by passing a callable to
2450 `attr.ib`&class="cm">#x27;s ``eq``, ``order``, or ``cmp`` arguments. See also
2451 :ref:`comparison customization <custom-comparison>`.
2452
2453 Instances of this class are frequently used for introspection purposes
2454 like:
2455
2456 - `fields` returns a tuple of them.
2457 - Validators get them passed as the first argument.
2458 - The :ref:`field transformer <transform-fields>` hook receives a list of
2459 them.
2460 - The ``alias`` property exposes the __init__ parameter name of the field,
2461 with any overrides and default private-attribute handling applied.
2462
2463
2464 .. versionadded:: 20.1.0 *inherited*
2465 .. versionadded:: 20.1.0 *on_setattr*
2466 .. versionchanged:: 20.2.0 *inherited* is not taken into account for
2467 equality checks and hashing anymore.
2468 .. versionadded:: 21.1.0 *eq_key* and *order_key*
2469 .. versionadded:: 22.2.0 *alias*
2470 .. versionadded:: 26.1.0 *alias_is_default*
2471
2472 For the full version history of the fields, see `attr.ib`.
2473 class="st">"""
2474
2475 class="cm"># These slots must NOT be reordered because we use them later for
2476 class="cm"># instantiation.
2477 __slots__ = ( class="cm"># noqa: RUF023
2478 class="st">"name",
2479 class="st">"default",
2480 class="st">"validator",
2481 class="st">"repr",
2482 class="st">"eq",
2483 class="st">"eq_key",
2484 class="st">"order",
2485 class="st">"order_key",
2486 class="st">"hash",

Callers 6

simple_attrFunction · 0.90
test_fieldsMethod · 0.90
test_programmaticMethod · 0.90
_make.pyFile · 0.85
_CountingAttrClass · 0.85

Calls

no outgoing calls

Tested by 3

test_fieldsMethod · 0.72
test_programmaticMethod · 0.72