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_args
on raw types - #5:
to_tuple
with too-long input - #18: handling of
types.UnionType
- #25: delinted using
pyrefly
- #27:
str
toint
conversion when the string has decimal places - #28:
float
todatetime
conversion; added UTC timezone - #29: handling an untyped default value in a class
Changed
- #14:
TypeForm
comment 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_to
tocasts
and 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_type
error - #6: additional
datetime
formats - #7: custom casts to
castfit
(closes #7) - #11: more README examples
- #12: more complete docstrings for the public API
- #15: cache for fetching
get_origin
andget_args
information - #16:
DEFAULT_ENCODING
constant forto_bytes
andto_str
- #17: alternatives to README
- #20: infer types based on class field defaults
- #31: more negative tests
Removed
- #21:
castfit
on 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
TypeGuard
in older versions of python, but it didn't work. - #23: Started and rolled back
is_callable
becausecastfit
can't currently do anything with a callable that is the wrong type. - #26: Rolled back having a
checks
parameter that overrides how types are checked. - #32: Tried fixing
TypeForm
to be the union oftype[T]
and_SpecialForm
, but onlypyright
was able to handle it.mypy
still can't handle it andty
isn't mature enough yet.