Skip to content

Type Aliases

The following type aliases are used throughout the anyschema codebase:

anyschema.typing

Adapter: TypeAlias = Callable[[Any], FieldSpecIterable] module-attribute

Adapter expected signature.

An adapter is a callable that adapts a spec into field specifications.

FieldSpec: TypeAlias = tuple[FieldName, FieldType, FieldMetadata] module-attribute

Field specification: alias for a tuple of (str, type, tuple(metadata, ...)).

FieldSpecIterable: TypeAlias = Generator[FieldSpec, None, None] module-attribute

Return type of an adapter.

IntoOrderedDict: TypeAlias = Mapping[str, type] | Sequence[tuple[str, type]] module-attribute

An object that can be converted into a python OrderedDict.

We check for the object to be either a mapping or a sequence of sized 2 tuples.

IntoParserPipeline: TypeAlias = Literal['auto'] | Sequence[ParserStep] module-attribute

An object that can be converted into a ParserPipeline.

Either "auto" or a sequence of ParserStep.

Spec: TypeAlias = 'Schema | IntoOrderedDict | type[BaseModel] | DataclassType | TypedDictType | AttrsClassType | UnknownSpec' module-attribute

Input specification supported directly by AnySchema.