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

Function attrib

src/attr/_make.py:106–213  ·  src/attr/_make.py::attrib

Create a new field / attribute on a class. Identical to `attrs.field`, except it's not keyword-only. Consider using `attrs.field` in new code (``attr.ib`` will *never* go away, though). .. warning:: Does **nothing** unless the class is also decorated with `a

(
    default=NOTHING,
    validator=None,
    repr=True,
    cmp=None,
    hash=None,
    init=True,
    metadata=None,
    type=None,
    converter=None,
    factory=None,
    kw_only=None,
    eq=None,
    order=None,
    on_setattr=None,
    alias=None,
)

Source from the content-addressed store, hash-verified

104
105
106def attrib(
107 default=NOTHING,
108 validator=None,
109 repr=True,
110 cmp=None,
111 hash=None,
112 init=True,
113 metadata=None,
114 type=None,
115 converter=None,
116 factory=None,
117 kw_only=None,
118 eq=None,
119 order=None,
120 on_setattr=None,
121 alias=None,
122):
123 class="st">"""
124 Create a new field / attribute on a class.
125
126 Identical to `attrs.field`, except it&class="cm">#x27;s not keyword-only.
127
128 Consider using `attrs.field` in new code (``attr.ib`` will *never* go away,
129 though).
130
131 .. warning::
132
133 Does **nothing** unless the class is also decorated with
134 `attr.s` (or similar)!
135
136
137 .. versionadded:: 15.2.0 *convert*
138 .. versionadded:: 16.3.0 *metadata*
139 .. versionchanged:: 17.1.0 *validator* can be a ``list`` now.
140 .. versionchanged:: 17.1.0
141 *hash* is `None` and therefore mirrors *eq* by default.
142 .. versionadded:: 17.3.0 *type*
143 .. deprecated:: 17.4.0 *convert*
144 .. versionadded:: 17.4.0
145 *converter* as a replacement for the deprecated *convert* to achieve
146 consistency with other noun-based arguments.
147 .. versionadded:: 18.1.0
148 ``factory=f`` is syntactic sugar for ``default=attr.Factory(f)``.
149 .. versionadded:: 18.2.0 *kw_only*
150 .. versionchanged:: 19.2.0 *convert* keyword argument removed.
151 .. versionchanged:: 19.2.0 *repr* also accepts a custom callable.
152 .. deprecated:: 19.2.0 *cmp* Removal on or after 2021-06-01.
153 .. versionadded:: 19.2.0 *eq* and *order*
154 .. versionadded:: 20.1.0 *on_setattr*
155 .. versionchanged:: 20.3.0 *kw_only* backported to Python 2
156 .. versionchanged:: 21.1.0
157 *eq*, *order*, and *cmp* also accept a custom callable
158 .. versionchanged:: 21.1.0 *cmp* undeprecated
159 .. versionadded:: 22.2.0 *alias*
160 .. versionchanged:: 25.4.0
161 *kw_only* can now be None, and its default is also changed from False to
162 None.
163 class="st">"""

Callers 15

CClass · 0.90
CClass · 0.90
CClass · 0.90
fieldFunction · 0.85
_transform_attrsFunction · 0.85
make_classFunction · 0.85
_AndValidatorClass · 0.85
VersionInfoClass · 0.85
_MatchesReValidatorClass · 0.85
_OptionalValidatorClass · 0.85
_InValidatorClass · 0.85

Calls 5

FactoryClass · 0.85
and_Function · 0.85
_CountingAttrClass · 0.85
pipeFunction · 0.70

Tested by

no test coverage detected