MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / fields

Function fields

tools/python-3.11.9-amd64/Lib/dataclasses.py:1235–1250  ·  view source on GitHub ↗

Return a tuple describing the fields of this dataclass. Accepts a dataclass or an instance of one. Tuple elements are of type Field.

(class_or_instance)

Source from the content-addressed store, hash-verified

1233
1234
1235def fields(class_or_instance):
1236 """Return a tuple describing the fields of this dataclass.
1237
1238 Accepts a dataclass or an instance of one. Tuple elements are of
1239 type Field.
1240 """
1241
1242 # Might it be worth caching this, per class?
1243 try:
1244 fields = getattr(class_or_instance, _FIELDS)
1245 except AttributeError:
1246 raise TypeError('must be called with a dataclass type or instance') from None
1247
1248 # Exclude pseudo-fields. Note that fields is sorted by insertion
1249 # order, so the order of the tuple is as the fields were defined.
1250 return tuple(f for f in fields.values() if f._field_type is _FIELD)
1251
1252
1253def _is_dataclass_instance(obj):

Callers 6

_traverseFunction · 0.90
_dataclass_getstateFunction · 0.85
_dataclass_setstateFunction · 0.85
_add_slotsFunction · 0.85
_asdict_innerFunction · 0.85
_astuple_innerFunction · 0.85

Calls 2

tupleClass · 0.85
valuesMethod · 0.45

Tested by

no test coverage detected