TypeShape
- class emmet.core.types.introspection.TypeShape(kind, tp, args=(), metadata=(), origin=None, namespace=<factory>)
Bases:
objectThe shape of one annotation, see classify.
- Attributes:
kind: What kind of type this is. tp: The annotation as classified. Wrappers which carry no information
on their own (NotRequired, TypeVar, forward references) have been resolved.
args: The immediate component types, see Kind. metadata: Annotated metadata (only for Kind.ANNOTATED). origin: The class itself (for ENUM, MODEL, TYPEDDICT, MSONABLE
and CLASS).
- namespace: Namespace in which forward references found in the
components of this type are resolved.
- Parameters:
kind (Kind)
tp (Any)
args (tuple[Any, ...])
metadata (tuple[Any, ...])
origin (Any)
namespace (Mapping[str, Any])
- child(tp)
Classify a component of this type, e.g. one of args.
- Return type:
- Parameters:
tp (Any)
- fields(*, include_excluded=False, include_aliases=False)
Annotations of the fields of a MODEL or TYPEDDICT.
For models, type_overrides (see emmet.core.utils.type_override) replace the annotation of a field, and metadata which pydantic split off a field’s annotation is re-attached with Annotated.
- Return type:
dict[str,Any]- Parameters:
include_excluded (bool)
include_aliases (bool)
- Args:
- include_excluded: Include fields with Field(exclude=True). These
are left out of serialized models, but may be present in documents obtained from elsewhere, e.g. a database.
- include_aliases: Also list fields of models under their alias,
with the same annotation. Documents may hold either name.