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.
[0.7.3]
Added
- New flag,
default_help
, for both the class-levelArgparseDataclassSettings
andArgparseDataclassFieldSettings
.- 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.
TOMLDataclass
formatting of nested dicts.
0.7.0
2024-07-29
Added
TOMLDataclass
- Support for top-level and field comments
TOMLDataclassSettings
to configure top-level commentscomment
: set comment explicitlydoc_as_comment
: flag indicating to use class docstring as comment
DocFieldSettings
to extract documentation from dataclass fields (supports PEP 727)- New module,
fancy_dataclass.settings
, for mixin and field settings
Changed
DictDataclassSettings
- Removed
fully_qualified
flag - Instead,
store_type
is now a string, one of'auto'
(default),'off'
,'name'
,'qualname'
JSONDataclass
will raiseTypeError
if a subclass does not set it to a value other than'auto'
JSONBaseDataclass
sets it to'qualname'
- Removed
- Improved
TOMLDataclass
serialization - Renamed
DataclassMixinSettings
toMixinSettings
- Mixin and field settings now keyword-only if possible
DictDataclassSettings
: removequalified_type
flag in favor of new field,store_type
with 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--version
option (viaversion
action)- User may set the
version
attribute inArgparseDataclassSettings
during 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) required
flag in field metadata overrides default behaviorrequired
must beTrue
if field is non-Optional
without a default
- By default, command-line subcommand optional if the field type is
0.6.0
2024-06-10
Added
- New
ArgparseDataclassSettings
fields: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_class
andparser_description
classmethods have becomeArgparseDataclassSettings
fieldsparser_class
andhelp_descr
.
0.5.0
2024-06-02
Added
- Explicit
required
metadata flag inArgparseDataclass
- More details in web docs for
JSONDataclass
,TOMLDataclass
Changed
- (Breaking)
JSONDataclass
methodsjson_encoder
andjson_key_decoder
now public
Fixed
- Bugs in
ArgparseDataclass
0.4.5
2024-05-30
Changed
ArgparseDataclass
subcommand
property 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
numpy
scalars 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
ArgparseDataclass
can be used as subparser ifsubcommand=True
is set in field metadata CLIDataclass.run
will invoke subcommand if applicable
- Nested
Fixed
ArgparseDataclass
boolean flag field properly handlesaction="store_false"
with field defaultTrue
- Field
suppress=False
overridessuppress_defaults=True
0.4.3
2024-04-30
Added
fancy_dataclass.func
module withfunc_dataclass
wrapper- Converts an ordinary function into a parametrized dataclass type
- Documentation and tests for the above
0.4.2
2024-04-29
Added
fancy_dataclass/docs
subfolder containing HTML documentation (accessible without Internet access)
Changed
- Using
gadzooks
repo for the followingpre-commit
hooks: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
DictConfig
class for configs stored as untyped dictDataclassAdaptable
mixin to convert one dataclass to another- Can be used to handle field name collisions in
DataclassMixin
settings
- Can be used to handle field name collisions in
save
andload
convenience methods forFileSerializable
(includesJSONDataclass
andTOMLDataclass
)
Changed
Config.get_config
returns reference instead of deepcopy- Class hierarchy of
FileSerializable
- Split into
TextSerializable
,BinarySerializable
TextFileSerializable
subclassesBinaryFileSerializable
- 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
hatch
matrix
Changed
- Top-level
*
-imports mostly limited to mixin classes via__all__
- Renamed
Config.configure
context manager toas_config
- Renamed
SubprocessDataclass.args
method toget_args
Fixed
- Support for Python 3.8, 3.9 (which lack some newer type annotation features)
0.3.0
2024-04-14
Added
TOMLDataclass
for saving/loading TOML viatomlkit
- Support for loading TOML configurations in
ConfigDataclass
- Support for loading TOML configurations in
FileSerializable
andDictFileSerializableDataclass
mixins to factor out shared functionality between JSON/TOML serialization- Documentation
- Usage examples for
TOMLDataclass
andConfigDataclass
- Hosting on Read the Docs here
- Usage examples for
- CI: Github Actions to automate building/linting/testing
0.2.0
2024-04-13
Added
ConfigDataclass
mixin for global configurations- Customization of
DataclassMixin
:DataclassMixinSettings
for mixin class configurationFieldSettings
for field-specific settings__post_dataclass_wrap__
hook to customize behavior afterdataclass
decorator is applied (e.g. validating fields at definition time)
- Documentation
- Reference pages via
mkdocs-material
andmkdocstrings
- 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
DataclassMixin
class providing extra dataclass featuresArgparseDataclass
: command-line argument parsingCLIDataclass
: command-line argument parsing andmain
functionDictDataclass
: conversion to/from Python dictJSONDataclass
: conversion to/from JSONSQLDataclass
: SQL persistence viasqlalchemy
SubprocessDataclass
: call out to another program viasubprocess