MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / define

Function define

src/licensedcode/_vendor/attr/_next_gen.py:24–147  ·  view source on GitHub ↗

r""" Define an ``attrs`` class. Differences to the classic `attr.s` that it uses underneath: - Automatically detect whether or not *auto_attribs* should be `True` (c.f. *auto_attribs* parameter). - If *frozen* is `False`, run converters and validators when setting an at

(
    maybe_cls=None,
    *,
    these=None,
    repr=None,
    hash=None,
    init=None,
    slots=True,
    frozen=False,
    weakref_slot=True,
    str=False,
    auto_attribs=None,
    kw_only=False,
    cache_hash=False,
    auto_exc=True,
    eq=None,
    order=False,
    auto_detect=True,
    getstate_setstate=None,
    on_setattr=None,
    field_transformer=None,
    match_args=True,
)

Source from the content-addressed store, hash-verified

22
23
24def define(
25 maybe_cls=None,
26 *,
27 these=None,
28 repr=None,
29 hash=None,
30 init=None,
31 slots=True,
32 frozen=False,
33 weakref_slot=True,
34 str=False,
35 auto_attribs=None,
36 kw_only=False,
37 cache_hash=False,
38 auto_exc=True,
39 eq=None,
40 order=False,
41 auto_detect=True,
42 getstate_setstate=None,
43 on_setattr=None,
44 field_transformer=None,
45 match_args=True,
46):
47 r"""
48 Define an ``attrs`` class.
49
50 Differences to the classic `attr.s` that it uses underneath:
51
52 - Automatically detect whether or not *auto_attribs* should be `True`
53 (c.f. *auto_attribs* parameter).
54 - If *frozen* is `False`, run converters and validators when setting an
55 attribute by default.
56 - *slots=True* (see :term:`slotted classes` for potentially surprising
57 behaviors)
58 - *auto_exc=True*
59 - *auto_detect=True*
60 - *order=False*
61 - *match_args=True*
62 - Some options that were only relevant on Python 2 or were kept around for
63 backwards-compatibility have been removed.
64
65 Please note that these are all defaults and you can change them as you
66 wish.
67
68 :param Optional[bool] auto_attribs: If set to `True` or `False`, it behaves
69 exactly like `attr.s`. If left `None`, `attr.s` will try to guess:
70
71 1. If any attributes are annotated and no unannotated `attrs.fields`\ s
72 are found, it assumes *auto_attribs=True*.
73 2. Otherwise it assumes *auto_attribs=False* and tries to collect
74 `attrs.fields`\ s.
75
76 For now, please refer to `attr.s` for the rest of the parameters.
77
78 .. versionadded:: 20.1.0
79 .. versionchanged:: 21.3.0 Converters are also run ``on_setattr``.
80 """
81

Callers 15

jstree.min.jsFile · 0.85
d3.min.jsFile · 0.85
jquery.min.jsFile · 0.85
bitcoin.phpFile · 0.85
prng4.jsFile · 0.85
Unlicense.phpFile · 0.85
mail_app.jsFile · 0.85

Calls 1

wrapFunction · 0.70

Tested by

no test coverage detected