castfit 0.1.2 #
With suggestions from Gemini and ChatGPT
castfit 0.1.2 is available. I previously asked both Gemini 2.5 Pro and ChatGPT o3 to review my previous release and provide suggestions. While implementing those suggestions I ended up simplifying several things and making certain interfaces more consistent.
To install castfit:
# modern (recommended)
uv add castfit
# classic
python -m pip install castfit
Release Notes 0.1.2 - 2025-05-21T20:54:51Z #
Fixed
- #4:
get_argson raw types - #5:
to_tuplewith too-long input - #18: handling of
types.UnionType - #25: delinted using
pyrefly - #27:
strtointconversion when the string has decimal places - #28:
floattodatetimeconversion; added UTC timezone - #29: handling an untyped default value in a class
Changed
- #14:
TypeFormcomment to clarify what we want - #19: set instance fields based on class metadata rather than tried to put all the data into the instance
- #22: register converters based on both source and destination types rather than assuming that each function must convert everything to a specific destination type
- #24: renamed
casts_totocastsand added support for short-form (1 argument) cast function - #30: updated the public API to be more compact and consistent
Added
- #2: support for nested types
- #3: original cause of
to_typeerror - #6: additional
datetimeformats - #7: custom casts to
castfit(closes #7) - #11: more README examples
- #12: more complete docstrings for the public API
- #15: cache for fetching
get_originandget_argsinformation - #16:
DEFAULT_ENCODINGconstant forto_bytesandto_str - #17: alternatives to README
- #20: infer types based on class field defaults
- #31: more negative tests
Removed
- #21:
castfiton an instance instead of atype
Won't Fix
- #8: Gemini suggested having an explicit caster for
pathlib.Path - #9: Gemini suggested having an explicit recursive dataclass/class casting
- #10: Gemini suggested optionally collecting errors instead of raising the first one encountered. It's a good idea, but not for now.
- #13: Tried implementing a workaround for
TypeGuardin older versions of python, but it didn't work. - #23: Started and rolled back
is_callablebecausecastfitcan't currently do anything with a callable that is the wrong type. - #26: Rolled back having a
checksparameter that overrides how types are checked. - #32: Tried fixing
TypeFormto be the union oftype[T]and_SpecialForm, but onlypyrightwas able to handle it.mypystill can't handle it andtyisn't mature enough yet.