classify

emmet.core.types.introspection.classify(tp, namespace=None)

Say what kind of type an annotation is, and what it is made of.

Return type:

TypeShape

Parameters:
  • tp (Any)

  • namespace (Mapping[str, Any] | None)

Args:

tp: The annotation. namespace: Namespace to resolve forward references in, if tp or its

components contain any. Use TypeShape.child to classify the components of a type, which takes care of this.

Returns:

The shape of tp. NotRequired, Required, ReadOnly, forward references, and TypeVar`s are resolved to what they wrap: for the latter that is its second constraint, which for the type variables in `emmet.core.types.pymatgen_types is the TypedDict describing the serialized form of the object.