Skip to content

v5.0.0a7

Pre-release
Pre-release

Choose a tag to compare

@BrianPugh BrianPugh released this 23 Jun 00:57

v5 changes up to this point. Most notably in this release we re-introduced the rich-rst dependency now that licensing issues have been resolved.

Breaking

  • Removed fuzzy command-matching. Command names must match exactly.

    • It was a temporary v4 backwards-compat shim (#666) for the PascalCasepascal-case name-transform change, retrying by stripping dashes/underscores on no exact match. Removed as cleanup for the major release.
    @app.command
    def MyCommand(): ...   # registers as "my-command"
    # v4: `mycommand` fuzzy-matched -> my-command
    # v5: `mycommand` no longer resolves; use `my-command`

Features

  • Variable token-lengths within a Union. Members that consume a different
    number of tokens can now coexist. Order matters: the longer (multi-token)
    member should come first so it gets first claim on the tokens.

    def main(value: tuple[int, int] | int): ...
    # --value 5      -> 5
    # --value 1 2    -> (1, 2)

    On v4 this raises Cannot Union types that consume different numbers of tokens.

  • list[Union[...]] with differing token-lengths. Each element is matched
    independently against the union members.

    def main(coords: list[tuple[int, int] | int]): ...
  • null/none (case-insensitive) parse to None. Applies to optional
    types. Union ordering decides the result: a member that legitimately accepts
    the literal string wins first.

    def main(value: int | None): ...      # --value none  -> None
    def main(path: Path | None): ...      # --path none   -> Path("none")  (Path matches first)
    def main(value: str | None): ...      # --value none  -> "none"        (str matches first)
    # works inside collections too:  list[int | None]  "1 none 3" -> [1, None, 3]

Misc

  • RST help now uses rich-rst v2 (has friendly licensing). Dependency pin moved
    from rich-rst>=1.3.1,<3 to rich-rst>=2.0.1,<3.