VersionedDataclass
version
class setting (int) andversion
read-only class property- Should probably subclass
DictDataclass
, ensures thatversion
property is stored in dict- Or could make it implicit, setting
version
to aClassVar
withsuppress
field settingFalse
- Or could make it implicit, setting
@version
decorator (with required integer argument)- Augments base type with
VersionedDataclass
- Allows you to define multiple classes with the same name; stores distinct
version
ClassVar
attributes and registers them with the same name - Initialization looks up the version number in the registry; if only newer exists:
- If
strict=True
, raises an error; otherwise, attempts to coerce and issues a warning
- If
- Error if duplicate versions are set
- Augments base type with
def migrate(self, version)
method from object of one version to another- Singleton
VersionRegistry
object viaregistry
property- Helper methods like
get_version
,get_available_versions
,has_version
- Avoid cyclic references (
weakref
?)
- Helper methods like
- Deal with namespace collision? E.g. use
globals()
to ensure the latest version is the only one accessible within module's namespace, even if it is defined earlier than the others. - With
ArgparseDataclass
, include a--version
argument like:parser.add_argument('--version', action='version', version='%(prog)s {version}')
- Provide class settings flag letting user turn this off?
- documentation
- Dataclass mixins/settings
- For now,
dataclass
decorator is required - Note purpose of
flattened=True
(good for tabular data like CSV/SQL) - Advanced: how to handle name collisions in settings for multiple inheritance (e.g.
ArgparseDataclass
/SubprocessDataclass
)
- For now,
- JSON
- TOML
- CLI
- SQL
- Primary key (default
_id
) - Relationships
- Primary key (default
- Subprocess
- Config
- Defining new mixins (what dunders need to be set)
- Top-level settings, field-level settings
- Collisions
- Colliding
FieldSettings
and custom adapters
- Colliding
- Dataclass mixins/settings
- General-purpose validator mixin?
- Does type-checking post-init, with ability to supply custom validation functions
- Have most other mixins inherit from this?
from_dict
in the case where custom__init__
doesn't line up with dataclass fields?alias
metadata field for dict conversion- Field converters
PromptDataclass
to prompt user for each value type- Be able to supply validator functions
- Specify behavior on error (bail or loop)
- Ctrl-C to break out one level of loop
TabularDataclass
? CSV/TSV/parquet/feather- Simplest if single class can save/load all these file types
- Convert to/from
pandas
Series
andDataFrame
?- If so, make
pandas
an optional dependency - Easy to implement conversion via
dict
, if we subclassDictDataclass
- If so, make
JSON5Dataclass
?- Field metadata
- Be strict about unknown field metadata keys? (Maybe issue warning?)
- Might be annoying if people want to store extra metadata.
- PEP 712 (
converter
argument for dataclass fields) - Allow
Annotated
as an alternative tofield.metadata
- Esp. with
Doc
: this could auto-populate JSON schema, argparse description
- Esp. with
BinaryDataclass
?
- Be strict about unknown field metadata keys? (Maybe issue warning?)
- Tiered configs?
- Improve
mkdocs
documentation- Auto-generate per-field descriptions via PEP 727?
- Auto-generate dataclass field docs?
- Automatic JSON schema generation (see
pydantic
)- Borrow/use: https://github.com/Peter554/dc_schema/tree/master?tab=MIT-1-ov-file#readme
- Attribution?
- Borrow/use: https://github.com/Peter554/dc_schema/tree/master?tab=MIT-1-ov-file#readme
- Validation
- More robust type validation when
validate=True
inDictDataclass
ValidatedDataclass
to validate at construction time?
- More robust type validation when
- More test coverage
- More complex examples
- Cover more data types (dynamically generate dataclass types)
- Performance benchmarks
pydantic
might have some? Obviously won't beat those.- Identify bottlenecks and focus on those.
- Memory usage & speed
- Use slots? (can set this in dataclass options: does it break other things?)
- Optional dependencies
- Allow
tomlkit
for now, makesql
optional - May be overkill unless dependencies are heavy
- Document this
- Allow