Repository navigation
v4.0.0
#240
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
v4.0.0
This release realigns Cloup with Click 8.5, removes the compatibility layers accumulated across the Click 8.1-8.4 line, and hands a few long-standing Cloup features back to Click now that Click implements them itself. The headline addition is that Cloup now re-exports Click's public top-level namespace, so most applications can import from
cloupalone.Cloup follows semantic versioning rigorously: any known breaking change causes a major-version bump, even when it is unlikely to affect most users. Apart from the new minimum Python and Click versions, most projects should be able to upgrade from Cloup 3.x without changing their code.
This release also includes a comprehensive overhaul of the development tooling. See the final section if you contribute to Cloup.
Dropped support
>= 8.1.0, < 9.0). The compatibility code for older Click versions has been removed. (Remove compatibility code related to click < 8.2 #219)Breaking changes
Apart from the new minimum Python and Click versions, no supported public calling interface has been removed or narrowed. The intentional API-level compatibility changes affect subclasses and method overrides:
Command.deprecatedandGroup.deprecatednow acceptbool | str. Subclasses that narrow this attribute or the corresponding constructor argument toboolshould widen their annotation. (Fix drift wrt click>=8.2: in commands, supportdeprecatedof typestrto displayf"(DEPRECATED: {deprecated})"#212)HelpFormatter.write_dl()now accepts anIterableof rows instead of aSequence, matching Click. Callers are unaffected because everySequenceis anIterable, but an override annotated withSequenceis now narrower than the base method. Such overrides should acceptIterableand materialize it first if they need to traverse the rows more than once. (Typing error for click>=8.4 #214)HelpTheme.dark()andHelpTheme.light()are now class methods rather than static methods, andHelpTheme.with_()returnsSelf. Existing calls are unaffected. Subclasses overriding a preset should use@classmethodto satisfy type checkers and preserve the subclass type.Some uncommon patterns can observe additional compatibility changes even though no supported function or class calling convention is broken:
cloup.Argumentis now an alias ofclick.Argument, soisinstance(arg, cloup.Argument)matches every Click argument. Code that used this check to distinguish Cloup's former argument subclass from a plain Click argument should be updated.from cloup import *no longer binds_versionorwarnings. They remain available ascloup._versionandcloup.warnings, andcloup.__version__is unchanged.cloup._params.GroupedOptionhas been removed. It has not been available ascloup.GroupedOptionsince v0.14.0 and was never visible to type checkers; usecloup.Option.(DEPRECATED), instead of the former(Deprecated)prefix. Tests that assert exact help output may need updating.New Features and enhancements
Cloup now re-exports Click's public top-level namespace. Public Click core classes, decorators, exceptions, parameter types, terminal helpers, and utilities are available from
cloupand included incloup.__all__, while Cloup's enhanced implementations intentionally replace the corresponding Click symbols. Click's lazily exposed deprecated names (BaseCommand,MultiCommand,OptionParser,get_binary_stream, andget_text_stream) are mirrored without emitting warnings merely from importing Cloup.Command decorators work without parentheses.
@cloup.commandis now equivalent to@cloup.command(), matching Click, and the same applies tocloup.group,Group.command, andGroup.group.The
clsargument can be passed positionally to command and group decorators, matching Click:Commands, groups, and arguments accept a string for
deprecated. A string produces a custom label such as(DEPRECATED: use new-command instead), whiledeprecated=Truecontinues to produce(DEPRECATED). (Fix drift wrt click>=8.2: in commands, supportdeprecatedof typestrto displayf"(DEPRECATED: {deprecated})"#212, Fix positional arguments section: click.Argument do not lose theirhelp+ deprecation labels #223)cloup.Argumentnow delegates to Click. It is an alias ofclick.Argument, which natively supports argument help and deprecation in Click 8.5. The@cloup.argumentdecorator remains available with more detailed annotations, and Cloup's positional-argument help section continues to work as before.Subcommand suggestions now use Click's
NoSuchCommand. Aliases participate in the suggestions, the exception exposes the possible matches, and message formatting follows Click.A wrapped option-group constraint is now separated from the option list that follows it by a blank line. (fix(formatting): separate wrapped constraints from option lists #208)
ArgumentKwargsandOptionKwargsare new publicTypedDicts. They document the standard arguments accepted by@argumentand@option, improve IDE completion, and allow type checkers to report misspelled or invalid keyword arguments. Custom parameter classes can still accept their own additional keywords.HelpTheme.dark(),HelpTheme.light(), andHelpTheme.with_()now preserve subclasses.with_()also forwards additional keyword arguments todataclasses.replace(), allowing subclasses to define and replace their own fields.Fixes
click.Argumentor a custom subclass no longer lose their help text in Cloup's argument help section. (cloup.Argumentandclick.Argumentdiverge now that Click 8.5.0 has argumenthelp#210, Fix positional arguments section: click.Argument do not lose theirhelp+ deprecation labels #223)The following fixes are mostly refinements to Cloup's public typing contract and alignment with Click 8.5. They are unlikely to affect most users:
Styleremains hashable after it has been called. Previously, its internal cache mutated a frozen dataclass field into an unhashable dictionary. The cache and its private field have been removed. (Styleis unhashable #224)HelpFormatter.write_dl()signature was aligned to Click one and now accepts anyIterableof rows, not necessarily aSequenceof rows. (Typing error for click>=8.4 #214)Option.get_help_record()implementations that returnNone, allowing an option subclass to omit itself from help output for reasons other than being hidden.HelpFormatter.write()now matches Click's keyword-compatiblewrite(string="", *strings)signature while preserving Cloup's multi-string convenience.Style.fgandStyle.bgnow accept Click's complete color specification:int | tuple[int, int, int] | str | None. This fixes false type errors for 256-color and truecolor values. (AcceptStyle.fgandbgof typeint | tuple[int, int, int] | str | None#229)clsis supplied and expose the complete set of Cloup-specific group options. Theformatter_settingsannotation no longer advertises a mutable default.Option.groupis now visible to static type checkers.get_current_context()now mirrors Click'sLiteraloverload, sosilent=Falseproduces a non-optionalContext;pass_context()also preserves the wrapped callback's parameter and return types._params.pyare now inline rather than stored in a shadowing_params.pyi. This ensures the implementation itself is type-checked and makes its complete public surface visible to type checkers and generated API documentation.For contributors
Most of the changes in this release are not user-visible: the development, packaging, documentation, and CI infrastructure has been extensively modernized.
CONTRIBUTING.rsthas been rewritten for the new workflow and is the best starting point for an existing checkout or open pull request.Project layout and packaging
cloup/to asrc/cloup/layout. Open pull requests that modify package sources will need to be rebased accordingly. (Move package to src layout #220)setup.pyandsetup.cfghave been removed; project metadata and build configuration now live inpyproject.toml. (Unpinsetup_requiresfromsetuptools_scm<10#206)pylock.code.toml,pylock.docs.toml, andpylock.package.toml._params.pyihas been removed in favor of inline types so static checkers and AutoAPI inspect the same implementation.Development commands: Tox and Make to Hatch and Task
hatch.toml, and the Makefile has been replaced by Task configuration intaskfile.yml. Runtask --listto list the available commands.click == 8.5.*environment on Python 3.14.task test-envs:upgrade-clickrefreshes Click in existing environments.Linting and formatting
typingimports and unnecessary quoted annotations; replaced percent formatting with f-strings; and organized imports.Type checking
task typingruns Pyrefly first and then Mypy, while the full workflows run both checkers across every compatibility environment.@override.tests/test_typing.pyandtests/test_namespace.pymodules protect the public typing contract and Click namespace re-export, including calls expected to be rejected.CI and coverage
ci.yml, and all YAML files use the.ymlextension._version.pymodule is excluded from coverage.latest-supportedto reflect Cloup's< 9upper bound.Documentation and repository maintenance
sphinx-panelshas been replaced bysphinx-design, with accompanying template and CSS fixes.task docs:servenow watchesdocs/_static/styles, so stylesheet changes trigger live rebuilds.installer = "uv"withlocked = trueuninstalls the editable root project (dev-mode = true) pypa/hatch#2372.AGENTS.mddocuments the repository's sources of truth and expected development workflow. YAML naming, TOML editor settings, and local-tool ignore rules have also been standardized.New Contributors
deprecatedof typestrto displayf"(DEPRECATED: {deprecated})"#212Full Changelog: v3.1.0...v4.0.0
This discussion was created from the release v4.0.0.
All reactions