Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project attempts to adhere to Semantic Versioning.
Unreleased
0.8.3
2025-04-27
Added
DictDataclassaliasfield setting sets an alternate key for converting both to and from a dict.
Changed
ArgparseDataclass- Positional arguments will be placed before subcommands, regardless of the order they occur in the dataclass fields.
Fixed
ArgparseDataclass- Fix bug with resolving PEP 563 stringized type annotations.
- Forbid name collisions with nested
ArgparseDataclassfields. Users must now explicitly provide adestvariable in the metadata to disambiguate such fields.
0.8.2
2025-03-29
Fixed
ArgparseDataclass- Fix bug with resolving PEP 563 stringized type annotations.
0.8.1
2025-01-20
Fixed
ArgparseDataclass- Support
"count"action with integer fields. Literal-typed fields- Support
Optional[Literal[...]]fields. - Validate that parsed values match permitted values.
- Support
- Support
0.8.0
2025-01-13
Changed
- Remove
strictflag fromDictDataclass.from_dict, instead making it a class-level setting. - Implicitly convert between
pathlib.Pathandstrfor dict conversion inJSONDataclass/TOMLDataclass(#1).
Fixed
- Relax type signatures in
TextFileSerializableprivate methods to avoid "incompatible definition"mypyerror (#3).
0.7.4
2025-01-07
Fixed
- Bug with
Optional[List[...]]dataclass fields inArgparseDataclass.
0.7.3
2024-10-27
Added
- New flag,
default_help, for both the class-levelArgparseDataclassSettingsandArgparseDataclassFieldSettings.- If set to
True, this includes a field's default value in its help string. - If set at the class level, applies this behavior to all fields that have a default (unless overridden by field-level setting).
- If set to
0.7.2
2024-10-20
Added
- Coverage for Python 3.13 in test configurations.
Fixed
- Resolving string annotations (or postponed annotations) properly in
ArgparseDataclass.configure_argument. - Type annotations for
mypy 1.12.1.
0.7.1
2024-09-15
Fixed
- Bug with dict value conversion of union types constructed with
|operator (Python 3.10 and above). - Bug with dataclass coercion for nested dicts.
TOMLDataclassformatting of nested dicts.
0.7.0
2024-07-29
Added
TOMLDataclass- Support for top-level and field comments
TOMLDataclassSettingsto configure top-level commentscomment: set comment explicitlydoc_as_comment: flag indicating to use class docstring as comment
DocFieldSettingsto extract documentation from dataclass fields (supports PEP 727)- New module,
fancy_dataclass.settings, for mixin and field settings
Changed
DictDataclassSettings- Removed
fully_qualifiedflag - Instead,
store_typeis now a string, one of'auto'(default),'off','name','qualname'JSONDataclasswill raiseTypeErrorif a subclass does not set it to a value other than'auto'JSONBaseDataclasssets it to'qualname'
- Removed
- Improved
TOMLDataclassserialization - Renamed
DataclassMixinSettingstoMixinSettings - Mixin and field settings now keyword-only if possible
DictDataclassSettings: removequalified_typeflag in favor of new field,store_typewith string designating how to store the type in the dict
Fixed
- Improved handling of unevaluated type annotations via
typing.get_type_hints, see PEP 563
0.6.1
2024-06-14
Added
ArgparseDataclass: support for--versionoption (viaversionaction)- User may set the
versionattribute inArgparseDataclassSettingsduring inheritance
- User may set the
Fixed
ArgparseDataclass: Behavior of optional subcommands- By default, command-line subcommand optional if the field type is
Optional(even without a default) requiredflag in field metadata overrides default behaviorrequiredmust beTrueif field is non-Optionalwithout a default
- By default, command-line subcommand optional if the field type is
0.6.0
2024-06-10
Added
- New
ArgparseDataclassSettingsfields:formatter_class: controls help formatter class for parent parser and subcommands (can be overridden by subcommands)help_descr_brief: subcommand help format (brief), used in subcommand help menu- By default, this will match the full subcommand help, but lowercased with trailing period removed.
Changed
- (Breaking)
ArgparseDataclass:parser_classandparser_descriptionclassmethods have becomeArgparseDataclassSettingsfieldsparser_classandhelp_descr.
0.5.0
2024-06-02
Added
- Explicit
requiredmetadata flag inArgparseDataclass - More details in web docs for
JSONDataclass,TOMLDataclass
Changed
- (Breaking)
JSONDataclassmethodsjson_encoderandjson_key_decodernow public
Fixed
- Bugs in
ArgparseDataclass
0.4.5
2024-05-30
Changed
ArgparseDataclasssubcommandproperty tosubcommand_name
Fixed
-
ArgparseDataclass- Preserve snake case for positional arguments instead of replacing
_with-
- Preserve snake case for positional arguments instead of replacing
-
DictDataclass- Support
numpyscalars and arrays - Handle string type annotations (see PEP 563)
- Support
0.4.4
2024-05-06
Added
- Groups, mutually exclusive groups, and subparsers for
ArgparseDataclass- Nested
ArgparseDataclasscan be used as subparser ifsubcommand=Trueis set in field metadata CLIDataclass.runwill invoke subcommand if applicable
- Nested
Fixed
ArgparseDataclassboolean flag field properly handlesaction="store_false"with field defaultTrue- Field
suppress=Falseoverridessuppress_defaults=True
0.4.3
2024-04-30
Added
fancy_dataclass.funcmodule withfunc_dataclasswrapper- Converts an ordinary function into a parametrized dataclass type
- Documentation and tests for the above
0.4.2
2024-04-29
Added
fancy_dataclass/docssubfolder containing HTML documentation (accessible without Internet access)
Changed
- Using
gadzooksrepo for the followingpre-commithooks:build-docs: rebuild docs if any source markdown files changedloc-summarize: print lines of code summarycheck-version: check version consistency (package, Git tag, built distribution, changelog)
0.4.1
2024-04-22
Added
DictConfigclass for configs stored as untyped dictDataclassAdaptablemixin to convert one dataclass to another- Can be used to handle field name collisions in
DataclassMixinsettings
- Can be used to handle field name collisions in
saveandloadconvenience methods forFileSerializable(includesJSONDataclassandTOMLDataclass)
Changed
Config.get_configreturns reference instead of deepcopy- Class hierarchy of
FileSerializable- Split into
TextSerializable,BinarySerializable TextFileSerializablesubclassesBinaryFileSerializable
- Split into
0.3.1
2024-04-16
Added
- Documentation: Badges in README (workflow passing, coverage, docs, etc.)
- CI:
- More GH Actions code checks
- Testing Python versions 3.8-3.12 via
hatchmatrix
Changed
- Top-level
*-imports mostly limited to mixin classes via__all__ - Renamed
Config.configurecontext manager toas_config - Renamed
SubprocessDataclass.argsmethod toget_args
Fixed
- Support for Python 3.8, 3.9 (which lack some newer type annotation features)
0.3.0
2024-04-14
Added
TOMLDataclassfor saving/loading TOML viatomlkit- Support for loading TOML configurations in
ConfigDataclass
- Support for loading TOML configurations in
FileSerializableandDictFileSerializableDataclassmixins to factor out shared functionality between JSON/TOML serialization- Documentation
- Usage examples for
TOMLDataclassandConfigDataclass - Hosting on Read the Docs here
- Usage examples for
- CI: Github Actions to automate building/linting/testing
0.2.0
2024-04-13
Added
ConfigDataclassmixin for global configurations- Customization of
DataclassMixin:DataclassMixinSettingsfor mixin class configurationFieldSettingsfor field-specific settings__post_dataclass_wrap__hook to customize behavior afterdataclassdecorator is applied (e.g. validating fields at definition time)
- Documentation
- Reference pages via
mkdocs-materialandmkdocstrings - Basic usage examples for main mixin classes
- CHANGELOG
- Reference pages via
- Linting via
ruff - Unit tests
- Over 90% code coverage, via
pytest-cov
- Over 90% code coverage, via
Changed
- Build via
hatch - Better flattened/nested dataclass conversions
Fixed
- More robust type handling
0.1.0
2022-06-06
Added
DataclassMixinclass providing extra dataclass featuresArgparseDataclass: command-line argument parsingCLIDataclass: command-line argument parsing andmainfunctionDictDataclass: conversion to/from Python dictJSONDataclass: conversion to/from JSONSQLDataclass: SQL persistence viasqlalchemySubprocessDataclass: call out to another program viasubprocess