Features
- Advanced parsing of user-defined classes (including pydantic/attrs/dataclasses/namedtuple).
- Support parsing of typeddict/dict.
- Improved error message precision/accuracy/helpfulness.
- New convenience types:
UInt8,Int8,UInt16,Int16,Uint32,Int32,Json. NumberandPathvalidators now work with sequences (e.g.list[Path]).- Additional
POSITIONAL_ONLYparameters may follow an iterablePOSITIONAL_ONLYparameter. This allows for programs like:@app.default def foo(inputs: list[Path], output: Path, /): pass
$ python my-program.py input_files/*.txt output.txt - Now supports the bare
--special token for forcing all subsequent CLI tokens to be parsed as positional argument. This mimics getopt behavior. - Add "new" group validator
cyclopts.validators.MutuallyExclusive. Performs same action as the defaultLimitedChoice(), but may be more intuitive/obvious for developers reading application code. - Improved help-page formatting.
- Various minor bug fixes.
Breaking Changes/Features
-
Drop python3.8 support; add python3.13 support.
-
Remove
Group.converterandApp.converter. Their use-cases are a bit contrived, don't provide much value, and increase the maintenance burden of the Cyclopts codebase. -
Change in custom
Parameter.converter. Previously, the converter had signature:def converter(type_, *values: str): ...
The new signature is:
def converter(type_, tokens: Sequence[Token]): ...
See the new
Tokenclass. This allows for raising aCoercionErrorfor the particular offending token, which will result in a more helpful error message for the user. -
App.parse_argsandApp.parse_known_argsnow return an additional value,ignored, which is a dictionary mapping python-variable-names to their type annotation of parameters withparse=False. -
Different CLI parsing scheme that is more directly similar to python's function rules. If a python variable is
POSITIONAL_OR_KEYWORD, and a value is specified by keyword, subsequentPOSITIONAL_OR_KEYWORDparameters in the function signature must be specified by keyword. -
When an iterable-like datatype is specified by keyword, only a single element's worth of tokens will be consumed. To restore the old behavior where tokens are consumed until an option-like argument is reached, set
Parameter.consume_multiple = True. -
Parameter.negative_boolvalues must no longer start with--. E.g. if it was previously--no-, it should now beno-. AValueErroris raised if it starts with a hyphen. -
Parameter.negative_iterablevalues must no longer start with--. E.g. if it was previously--empty-, it should now beempty-. AValueErroris raised if it starts with a hyphen. -
Parameter.requiredfield actually impacts whether or not the Parameter is mandatory. Previously it was only reflected in the help page.