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

Function fields_dict

src/attr/_make.py:1942–1968  ·  view source on GitHub ↗

Return an ordered dictionary of *attrs* attributes for a class, whose keys are the attribute names. Args: cls (type): Class to introspect. Raises: TypeError: If *cls* is not a class. attrs.exceptions.NotAnAttrsClassError: If *cls* is not an *at

(cls)

Source from the content-addressed store, hash-verified

1940
1941
1942def fields_dict(cls):
1943 """
1944 Return an ordered dictionary of *attrs* attributes for a class, whose keys
1945 are the attribute names.
1946
1947 Args:
1948 cls (type): Class to introspect.
1949
1950 Raises:
1951 TypeError: If *cls* is not a class.
1952
1953 attrs.exceptions.NotAnAttrsClassError:
1954 If *cls* is not an *attrs* class.
1955
1956 Returns:
1957 dict[str, attrs.Attribute]: Dict of attribute name to definition
1958
1959 .. versionadded:: 18.1.0
1960 """
1961 if not isinstance(cls, type):
1962 msg = "Passed object must be a class."
1963 raise TypeError(msg)
1964 attrs = getattr(cls, "__attrs_attrs__", None)
1965 if attrs is None:
1966 msg = f"{cls!r} is not an attrs-decorated class."
1967 raise NotAnAttrsClassError(msg)
1968 return {a.name: a for a in attrs}
1969
1970
1971def validate(inst):

Calls 1