Skip to content

v4.1.0

Choose a tag to compare

@BrianPugh BrianPugh released this 28 Oct 18:23
· 794 commits to main since this release
2fdc12c

Features

  • Support pydantic Secret-types (SecretStr, SecretBytes, etc) by @BrianPugh in #620

  • Parameter.count for int counting-flags (e.g., verbosity -vvv). by @BrianPugh in #622

    from cyclopts import Parameter
    
    def main(verbose: Annotated[int, Parameter(alias="-v", count=True)] = 0):
        print(f"Verbosity level: {verbose}")  # -vvv → 3
  • Add App.help_epilogue, which prints a message at the bottom of the app's help-page. by @BrianPugh in #628

    app = App(help_epilogue="For more info, visit: https://cyclopts.readthedocs.io")
    
    @app.default
    def main(name: str):
        """Greet someone."""
        print(f"Hello {name}")
    
    # ╭─ Parameters ───────────────────────────────╮
    # │ *  NAME  [required]                        │
    # ╰────────────────────────────────────────────╯
    #
    # For more info, visit: https://cyclopts.readthedocs.io
  • Add help from dataclass/attrs metadata to the resolution hierarchy. by @BrianPugh in #642

    from dataclasses import dataclass, field
    
    @dataclass
    class Config:
        port: int = field(default=8080, metadata={"help": "Server port"})
  • Add GNU-style combined short options support by @BrianPugh in #639

    from typing import Annotated
    from cyclopts import Parameter
    
    def main(
        verbose: Annotated[bool, Parameter(alias="-v")],
        user: Annotated[str, Parameter(alias="-u")],
    ):
        pass
    
    # -v -uroot         → verbose=True, user="root"
    # -vuroot           → verbose=True, user="root"  (GNU-style combined)
    # -vu root          → verbose=True, user="root"
  • More powerful ArgumentCollection.__getitem__ to support looking up by parameter name by @isoschiz in #635

    arg = argument_collection["param_name"]  # Lookup by parameter name

Bug Fixes

  • Resolve the default version to the nearest explicitly set App.version value instead of root-app version value. by @BrianPugh in #632
  • Have MutuallyExclusive group validator accurately report the user-specified option name instead of the first positive name. by @BrianPugh in #634
  • Have MissingArgumentError accurately report the user-specified option name instead of the first positive name. by @BrianPugh in #638
  • Fix the negative-flag showing up twice for Optional[bool] in the help-page. by @BrianPugh in #633
  • Fix incorrect deleting of help/version flag commands when overwriting their respective flag attributes. by @BrianPugh in #644
  • Fix unexpected exception when both --help and --version are passed to a subcommand. --help takes precedence. by @BrianPugh in #650
  • Allow positional elements of kw-only dataclass. by @BrianPugh in #651
  • Fix cyclopts.__version__ not being updated (due to uv migration). by @BrianPugh in #657
  • Add parse=False to App.version_print handlers. by @BrianPugh in #656
  • Fix kw-only dataclass object instantiation by @BrianPugh in #658
  • Misc (mostly internal) type hinting improvements by @BrianPugh in #659
  • Fix config command filtering logic. by @BrianPugh in #660

Special thanks to @isoschiz for thorough testing and bug reporting!

Documentation

  • Add documentation on using multiple config sources. by @BrianPugh in #640

New Contributors

Full Changelog: v4.0.0...v4.1.0