From 0f4738df88e3ea47c40a4a442103596a61cfee79 Mon Sep 17 00:00:00 2001 From: Kevin Deldycke Date: Fri, 17 Jul 2026 11:33:21 +0200 Subject: [PATCH] Fix docs and changelog --- CHANGES.md | 15 +++++++++++---- docs/arguments.md | 2 +- docs/documentation.md | 4 ++-- docs/option-decorators.md | 2 ++ docs/shell-completion.md | 4 ++-- docs/utils.md | 13 ++++++++----- src/click/_compat.py | 2 +- src/click/core.py | 2 +- src/click/shell_completion.py | 4 ++-- src/click/termui.py | 4 ++-- src/click/utils.py | 2 +- 11 files changed, 33 insertions(+), 21 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index e15823bf7..f7ff22b32 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,7 +5,7 @@ Unreleased - Add built-in shell completion support for PowerShell (Windows PowerShell 5.1+ and pwsh 7+) alongside the existing `bash`, `zsh`, and `fish` completers. Use `_FOO_BAR_COMPLETE=powershell_source foo-bar` to generate - the completion script. + the completion script. {issue}`2672` {pr}`3637` - Supported versions of Windows enable ANSI terminal styles by default. Colorama is no longer a dependency and is not used. {issue}`2986` {pr}`3505` - {class}`Argument` accepts a `help` parameter, and help output includes @@ -15,12 +15,16 @@ Unreleased This stripping was lost in `8.4.0` when {pr}`2969` began writing the prompt with `input()` directly. {issue}`3572` {pr}`3653` - Fix test failures when using pytest >= 9.1. {pr}`3656` +- {class}`Path` with `allow_dash=True` no longer triggers a `BytesWarning`, + an error under `python -bb`, when checking a value against the `-` + convention. {issue}`2877` {pr}`3642` - Add {func}`custom_version_option`, a `--version` option whose output is produced by a callback, covering cases {func}`version_option` intentionally does not. The feature set of {func}`version_option` is now frozen; see [discussion #3527](https://github.com/pallets/click/discussions/3527). {pr}`3581` - `style()` and `secho()` no longer silently drop the 256-color index `0` - (black) passed as `fg` or `bg`, and now validate color arguments. {pr}`3677` + (black) passed as `fg` or `bg`, and now validate color arguments. Invalid + colors raise a `ValueError` instead of a `TypeError`. {pr}`3677` - The automatic help option stores its value under the reserved name `_click_default_help` instead of `help`, so a parameter named `help` no longer breaks parsing. The new name is visible in @@ -30,12 +34,15 @@ Unreleased share a name to compete for the same value (feature switches). {issue}`2819` {pr}`3678` - `unstyle` and the ANSI handling behind help-text wrapping now strip the full - CSI escape-sequence grammar. + CSI escape-sequence grammar. {pr}`3681` - Streamline `Option` flag handling: the flag-kind, type, lazy-default and validation steps in `Option.__init__` move into focused helpers, and `flag_value` and `default` keep their unset sentinel at construction (resolved lazily on read) so `is UNSET` reliably tells a user-supplied value - from an auto-derived one. Behavior is unchanged. {pr}`3641` + from an auto-derived one. Runtime behavior is unchanged, but + {meth}`Parameter.to_info_dict` now resolves `default=True` on a feature + switch to its `flag_value`, matching what the function receives at call + time. {pr}`3641` - {func}`get_binary_stream` and {func}`get_text_stream` are deprecated and will be removed in Click 9.0. {issue}`3481` {pr}`3695` - The following `click.utils` names were never intentionally public and are diff --git a/docs/arguments.md b/docs/arguments.md index 81b331bd5..c981adb2c 100644 --- a/docs/arguments.md +++ b/docs/arguments.md @@ -10,7 +10,7 @@ Arguments are: * Are positional in nature. * Similar to a limited version of {ref}`options ` that can take an arbitrary number of inputs -* Can take an optional `help` string shown in the ``Positional arguments`` +* Can take an optional `help` string shown in the `Positional arguments` section of the help page, or be {ref}`documented in the command docstring `. diff --git a/docs/documentation.md b/docs/documentation.md index ae3f188e4..87505d893 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -15,7 +15,7 @@ Simple example: .. click:example:: @click.command() - @click.argument('name', help='The name to print') + @click.argument('name', help='The name to print.') @click.option('--count', default=1, help='number of greetings') def hello(name: str, count: int): """This script prints hello and a name one or more times.""" @@ -114,7 +114,7 @@ The help epilog is printed at the end of the help and is useful for showing exam ## Documenting Arguments {class}`click.argument` accepts an optional `help` parameter that is shown in -the ``Positional arguments`` section of the help page. You can still document +the `Positional arguments` section of the help page. You can still document arguments in the command docstring, especially when you want to describe them in the main help text by name. diff --git a/docs/option-decorators.md b/docs/option-decorators.md index 37a426dd4..9a2e33e49 100644 --- a/docs/option-decorators.md +++ b/docs/option-decorators.md @@ -84,3 +84,5 @@ replaced with the :func:`confirmation_option` decorator: ## Version Option {func}`version_option` adds a `--version` option which immediately prints the version number and exits the program. + +The message and values it can show are intentionally limited, and its feature set is frozen. If you need values it does not expose, such as the Python version or git metadata, use {func}`custom_version_option` and produce the output yourself in a callback. diff --git a/docs/shell-completion.md b/docs/shell-completion.md index 38368197d..82f64be3a 100644 --- a/docs/shell-completion.md +++ b/docs/shell-completion.md @@ -5,8 +5,8 @@ ```{currentmodule} click.shell_completion ``` -Click provides tab completion support for Bash (version 4.4 and up), Zsh, and Fish. It is possible to add support for -other shells too, and suggestions can be customized at multiple levels. +Click provides tab completion support for Bash (version 4.4 and up), Zsh, Fish, and PowerShell. It is possible to add +support for other shells too, and suggestions can be customized at multiple levels. Shell completion suggests command names, option names, and values for choice, file, and path parameter types. Options are only listed if at least a dash has been entered. Hidden commands and options are not shown. diff --git a/docs/utils.md b/docs/utils.md index 6d7d9e0a3..8b5a333eb 100644 --- a/docs/utils.md +++ b/docs/utils.md @@ -56,13 +56,14 @@ The {func}`echo` function supports ANSI colors and styles. It will automatically strip ANSI color codes if the stream is not connected to a terminal. -:::{admonition} Older Windows Support +```{admonition} Older Windows Support :class: note -Recent Windows 11 supports ANSI styling by default, in both Terminal and cmd.exe. -If you need to support color output on older versions of Windows, install +Recent versions of Windows 11 support ANSI styling by default, in both +Windows Terminal and cmd.exe. If you need to support color output on older +versions of Windows, install [colorama](https://pypi.org/project/colorama/) and call `colorama.init()`. -::: +``` For styling a string, the {func}`style` function can be used: @@ -124,7 +125,9 @@ that instead: print(idx, file=pager) ``` -```{hint} Why print instead of echo? +```{admonition} Why print() instead of echo()? +:class: hint + The pager object deals with ANSI color and style codes itself: they are kept or stripped depending on what the pager supports, exactly as {func}`echo` would do. Any code that writes to a file, including plain {func}`print`, can therefore be diff --git a/src/click/_compat.py b/src/click/_compat.py index 9c6968824..5672f2534 100644 --- a/src/click/_compat.py +++ b/src/click/_compat.py @@ -513,7 +513,7 @@ def should_strip_ansi( return not color -# double check is needed so mypy does not analyze this on Linux +# Double check is needed so mypy does not analyze this on Linux. if sys.platform.startswith("win") and WIN: from ._winconsole import _get_windows_console_stream diff --git a/src/click/core.py b/src/click/core.py index 6f483675d..f29dc4651 100644 --- a/src/click/core.py +++ b/src/click/core.py @@ -3662,7 +3662,7 @@ class Argument(Parameter): :param help: the help string. - .. versionchanged:: 8.5 + .. versionchanged:: 8.5.0 Added the ``help`` parameter. """ diff --git a/src/click/shell_completion.py b/src/click/shell_completion.py index 62f5c82a6..8a2668b09 100644 --- a/src/click/shell_completion.py +++ b/src/click/shell_completion.py @@ -521,7 +521,7 @@ def format_completion(self, item: CompletionItem[str]) -> str: class PowerShellComplete(ShellComplete): """Shell completion for PowerShell (Windows PowerShell 5.1+ and pwsh 7+). - .. versionadded:: 8.5 + .. versionadded:: 8.5.0 """ name: t.ClassVar[str] = "powershell" @@ -623,7 +623,7 @@ def split_arg_string(string: str) -> list[str]: lex = shlex.shlex(string, posix=True) lex.whitespace_split = True lex.commenters = "" - out = [] # type: list[str] + out: list[str] = [] try: out.extend(lex) diff --git a/src/click/termui.py b/src/click/termui.py index 34b575708..bb53f9c4d 100644 --- a/src/click/termui.py +++ b/src/click/termui.py @@ -712,9 +712,9 @@ def style( string which means that styles do not carry over. This can be disabled to compose styles. - .. versionchanged:: 8.5 + .. versionchanged:: 8.5.0 All invalid color values raise :exc:`ValueError`. 256-color index - ``0`` is not ignored + ``0`` is no longer ignored. .. versionchanged:: 8.0 A non-string ``message`` is converted to a string. diff --git a/src/click/utils.py b/src/click/utils.py index 6e3291d5d..b529eb04b 100644 --- a/src/click/utils.py +++ b/src/click/utils.py @@ -279,7 +279,7 @@ def echo( default Click will remove color if the output does not look like an interactive terminal. - .. versionchanged:: 8.5 + .. versionchanged:: 8.5.0 Colorama is no longer used for color on Windows. .. versionchanged:: 6.0