MCPcopy Index your code
hub / github.com/RustPython/RustPython / fields

Function fields

Lib/dataclasses.py:1445–1460  ·  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

1443
1444
1445def fields(class_or_instance):
1446 """Return a tuple describing the fields of this dataclass.
1447
1448 Accepts a dataclass or an instance of one. Tuple elements are of
1449 type Field.
1450 """
1451
1452 # Might it be worth caching this, per class?
1453 try:
1454 fields = getattr(class_or_instance, _FIELDS)
1455 except AttributeError:
1456 raise TypeError('must be called with a dataclass type or instance') from None
1457
1458 # Exclude pseudo-fields. Note that fields is sorted by insertion
1459 # order, so the order of the tuple is as the fields were defined.
1460 return tuple(f for f in fields.values() if f._field_type is _FIELD)
1461
1462
1463def _is_dataclass_instance(obj):

Callers 15

create_autospecFunction · 0.90
suspendMethod · 0.90
_dataclass_getstateFunction · 0.85
_dataclass_setstateFunction · 0.85
_add_slotsFunction · 0.85
_asdict_innerFunction · 0.85
_astuple_innerFunction · 0.85
test_no_fieldsMethod · 0.85
test_class_markerMethod · 0.85
test_field_orderMethod · 0.85
test_class_varMethod · 0.85

Calls 2

getattrFunction · 0.85
valuesMethod · 0.45