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

Function fields

src/licensedcode/_vendor/attr/_make.py:2029–2054  ·  view source on GitHub ↗

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*

(cls)

Source from the content-addressed store, hash-verified

2027
2028
2029def fields(cls):
2030 """
2031 Return the tuple of ``attrs`` attributes for a class.
2032
2033 The tuple also allows accessing the fields by their names (see below for
2034 examples).
2035
2036 :param type cls: Class to introspect.
2037
2038 :raise TypeError: If *cls* is not a class.
2039 :raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs``
2040 class.
2041
2042 :rtype: tuple (with name accessors) of `attrs.Attribute`
2043
2044 .. versionchanged:: 16.2.0 Returned tuple allows accessing the fields
2045 by name.
2046 """
2047 if not isclass(cls):
2048 raise TypeError("Passed object must be a class.")
2049 attrs = getattr(cls, "__attrs_attrs__", None)
2050 if attrs is None:
2051 raise NotAnAttrsClassError(
2052 "{cls!r} is not an attrs-decorated class.".format(cls=cls)
2053 )
2054 return attrs
2055
2056
2057def fields_dict(cls):

Callers 6

validateFunction · 0.85
asdictFunction · 0.85
astupleFunction · 0.85
assocFunction · 0.85
evolveFunction · 0.85
resolve_typesFunction · 0.85

Calls 3

isclassFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected