typespecs package#
- class typespecs.Spec[source]#
Bases:
dict[str,Any]Type specification.
This class is essentially a dictionary and should be used to distinguish type specification from other type annotations.
- typespecs.from_annotated(obj: HasAnnotations, /, data: str | None = 'data', merge: bool = True, separator: str = '/', type: str | None = 'type') DataFrame[source]#
Create a specification DataFrame from given object with annotations.
- Parameters:
obj – The object to convert.
data – Name of the column for the actual data of the annotations.
merge – Whether to merge all subtypes into a single row.
separator – Separator for concatenating root and sub-indices.
type – Name of the column for the metadata-stripped annotations.
- Returns:
Created specification DataFrame.
- typespecs.from_annotation(obj: Any, /, *, index: str = 'root', merge: bool = True, separator: str = '/', type: str | None = 'type') DataFrame[source]#
Create a specification DataFrame from given annotation.
- Parameters:
obj – The annotation to convert.
index – Root index of the created specification DataFrame.
merge – Whether to merge all subtypes into a single row.
separator – Separator for concatenating root and sub-indices.
type – Name of the column for the metadata-stripped annotations.
- Returns:
Created specification DataFrame.