0.2.2 is the first 0.2.x release published to PyPI. The 0.2.0 and 0.2.1 tags exist in git, but their publish runs were cancelled, so upgrading from PyPI goes straight from 0.1.16 to 0.2.2. The notes below cover every change in that jump.
Added:
python_introspect.choices.LabelledChoices: a declared source's choices with their labels, read together, so CLI labels and validation feedback use one enumeration.
Fixed:
- A broken dataclass declaration propagates from the analysis owner instead of being swallowed.
- Factory retry control stays aligned with propagated failures.
- Distributions include the inline typing marker (
py.typed).
Changed (the stored form of some fields changes; there is no reader for the old form):
- A dataclass field whose declared type admits several classes is stored as
{tag: fields}, anddataclass_from_mappingreads the class from the tag. Before, the member of a union was guessed from which fields were present: two members with the same fields could not be told apart and the stored value did not say which class it was. Three declarations form such a family (MemberFamily.declared_by): a union with two or more dataclass members (other arms such asNoneorstrstay untagged), an abstract dataclass (its concrete subclasses are the members), and a class whose metaclass isAutoRegisterMeta. The tag is the member's registry key when it is registered, so it survives a module move or a rename; otherwise it is the class name. The rule holds insidetuple,list,Sequence,Mapping, optional andAnnotateddeclarations. - An unknown tag is a
ValueErrornaming the known members. A value whose class is not a member of the declared family is aTypeErrorwhen encoding. Two members with the same tag are aTypeError. to_jsonablereads the declared field types of every dataclass it encodes, so those annotations must resolve at run time (a name imported only underTYPE_CHECKINGno longer encodes).
Added:
RegisteredClassChoicesvalidates in pydantic: a field annotated with it accepts a member class or its registry key, serializes to the key, and publishes the keys as a JSON-schema enum, so pydantic-built tool schemas (for example MCP) accept family-valued fields.
Added:
dataclass_from_mappingdecodes a field annotatedtype[Family], whereFamilyis anAutoRegisterMetafamily, from the registry key thatto_jsonablewrites for the class. A key outside the family fails loudly. Decoding goes throughregistered_class_from_key, which dispatches on the family's metaclass, so a family whose boundary spelling is not its registry key registers its own decoder.RegisteredClassChoices(family): theAnnotationChoicesof a field holding one class of a registered family, labelled by registry key.
Added:
FieldLabel:Annotatedmetadata declaring the display label of a field whose name does not read well to users, anddeclared_field_labelto read it. Form and table builders derive every other label from the field name.
Fixed:
- Inline field documentation (a string literal under a dataclass field) is extracted again on Python 3.13 and later. Class source lookup used
inspect._ClassFinder, a private helper that Python 3.13 removed, so every dataclass came back with no field help. Classes are now located by qualified name from the module AST directly. CI now tests Python 3.13.
Fixed:
dataclass_from_mappingandvalidate_annotated_dataclassno longer raiseRecursionErroron Python 3.10 for fields declared with a recursive type alias such asV = str | list["V"] | dict[str, "V"]. Since 0.2.1, nested type strings were expanded on 3.10 with no stop, so a self-reference expanded forever. Expansion now stops at a self-reference and leaves it as aForwardRef, which is whatget_type_hintsreturns on Python 3.11 and later, so the decoder sees the same declaration on every version.
Added:
AnnotationChoices:Annotatedmetadata declaring the finite values a field may hold. Annotation validation checks each value (or each item of a sequence value) against the declared choices, anddeclared_annotation_choicesfinds the declaration throughAnnotated,Optionaland homogeneous containers for form builders;enum_input_valuesreturns choice labels.type[X]annotations are validated: the value must be a class and a subclass ofX.
Added:
to_jsonable, with theJsonValue,JsonObjectandJsonScalaraliases. It is the JSON-native encoder paired withdataclass_from_mapping: dataclasses are encoded by their declared fields, along with mappings, sequences, enums, paths (str(path)), callables (by import identity) andAutoRegisterMetatypes (by registry key). More types can be added withto_jsonable.register.- Module public-surface helpers:
declared_public_names,exported_public_names,public_names_from_objectsandis_declared_public_name. lazy_exports(globals(), {owner_module: names}). It installs a PEP 562__getattr__/__dir__pair and returns the exported names for__all__.
- Recursive sequence declarations now resolve on Python 3.10.
- Release readiness is now derived from the declared project metadata.
- Breaking:
UnifiedParameterInfowas removed. Dataclass presentation is now derived from the canonical parameter declarations. - Immutable declaration docs are now prepared through the existing source cache.