MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / local_dataclass_fields

Function local_dataclass_fields

lib/sqlalchemy/util/compat.py:273–288  ·  view source on GitHub ↗

Return a sequence of all dataclasses.Field objects associated with an already processed dataclass, excluding those that originate from a superclass. The class must **already be a dataclass** for Field objects to be returned.

(cls: Type[Any])

Source from the content-addressed store, hash-verified

271
272
273def local_dataclass_fields(cls: Type[Any]) -> Iterable[dataclasses.Field[Any]]:
274 """Return a sequence of all dataclasses.Field objects associated with
275 an already processed dataclass, excluding those that originate from a
276 superclass.
277
278 The class must **already be a dataclass** for Field objects to be returned.
279
280 """
281
282 if dataclasses.is_dataclass(cls):
283 super_fields: Set[dataclasses.Field[Any]] = set()
284 for sup in cls.__bases__:
285 super_fields.update(dataclass_fields(sup))
286 return [f for f in dataclasses.fields(cls) if f not in super_fields]
287 else:
288 return []
289
290
291if freethreading:

Callers

nothing calls this directly

Calls 2

dataclass_fieldsFunction · 0.85
updateMethod · 0.45

Tested by

no test coverage detected