Skip to content
Myr

Pre-8.5.0 release changelog and doc fixes (#3697)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Rowlando13 · committed by GitHub · parents 5aa8ac4, 0f4738d · Browse files · 11 files+33 added−21 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

11 files+33 added−21 removed

  • other:+33 added−21 removed

11 files+33 added−21 removed

modified:docs/arguments.md+1 added-1 removed
modified:docs/documentation.md+2 added-2 removed
13 unmodified lines
14```{eval-rst}15.. click:example::1617 @click.command()18 @click.argument('name', help='The name to print')18 @click.argument('name', help='The name to print.')19 @click.option('--count', default=1, help='number of greetings')20 def hello(name: str, count: int):21 """This script prints hello and a name one or more times."""22 for x in range(count):
90 unmodified lines
113114## Documenting Arguments115116{class}`click.argument` accepts an optional `help` parameter that is shown in117the ``Positional arguments`` section of the help page. You can still document117the `Positional arguments` section of the help page. You can still document118arguments in the command docstring, especially when you want to describe them119in the main help text by name.120121A brief example:
222 unmodified lines
modified:docs/option-decorators.md+2 added
82 unmodified lines
8384## Version Option8586{func}`version_option` adds a `--version` option which immediately prints the version number and exits the program.8788The 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.
modified:docs/shell-completion.md+2 added-2 removed
3 unmodified lines
45```{currentmodule} click.shell_completion6```78Click provides tab completion support for Bash (version 4.4 and up), Zsh, and Fish. It is possible to add support for9other shells too, and suggestions can be customized at multiple levels.8Click provides tab completion support for Bash (version 4.4 and up), Zsh, Fish, and PowerShell. It is possible to add9support for other shells too, and suggestions can be customized at multiple levels.1011Shell completion suggests command names, option names, and values for choice, file, and path parameter types. Options12are only listed if at least a dash has been entered. Hidden commands and options are not shown.13
262 unmodified lines
modified:docs/utils.md+8 added-5 removed
54 unmodified lines
55The {func}`echo` function supports ANSI colors and styles. It will56automatically strip ANSI color codes if the stream is not connected to a57terminal.5859:::{admonition} Older Windows Support59```{admonition} Older Windows Support60:class: note6162Recent Windows 11 supports ANSI styling by default, in both Terminal and cmd.exe.63If you need to support color output on older versions of Windows, install62Recent versions of Windows 11 support ANSI styling by default, in both63Windows Terminal and cmd.exe. If you need to support color output on older64versions of Windows, install65[colorama](https://pypi.org/project/colorama/) and call `colorama.init()`.65:::66```6768For styling a string, the {func}`style` function can be used:6970```python
53 unmodified lines
124 for idx in range(50000):125 print(idx, file=pager)126```127127```{hint} Why print instead of echo?128```{admonition} Why print() instead of echo()?129:class: hint130131The pager object deals with ANSI color and style codes itself: they are kept or132stripped depending on what the pager supports, exactly as {func}`echo` would do.133Any code that writes to a file, including plain {func}`print`, can therefore be134used with it.
255 unmodified lines
modified:src/click/_compat.py+1 added-1 removed
511 unmodified lines
512 return not isatty(stream) and not _is_jupyter_kernel_output(stream)513 return not color514515516# double check is needed so mypy does not analyze this on Linux516# Double check is needed so mypy does not analyze this on Linux.517if sys.platform.startswith("win") and WIN:518 from ._winconsole import _get_windows_console_stream519520 def _get_argv_encoding() -> str:
70 unmodified lines
modified:src/click/core.py+1 added-1 removed
3660 unmodified lines
3661 All parameters are passed onwards to the constructor of :class:`Parameter`.36623663 :param help: the help string.36643665 .. versionchanged:: 8.53665 .. versionchanged:: 8.5.03666 Added the ``help`` parameter.3667 """36683669 param_type_name = "argument"
123 unmodified lines
modified:src/click/shell_completion.py+2 added-2 removed
519 unmodified lines
520521class PowerShellComplete(ShellComplete):522 """Shell completion for PowerShell (Windows PowerShell 5.1+ and pwsh 7+).523524 .. versionadded:: 8.5524 .. versionadded:: 8.5.0525 """526527 name: t.ClassVar[str] = "powershell"528 source_template: t.ClassVar[str] = _SOURCE_POWERSHELL
93 unmodified lines
622623 lex = shlex.shlex(string, posix=True)624 lex.whitespace_split = True625 lex.commenters = ""626 out = [] # type: list[str]626 out: list[str] = []627628 try:629 out.extend(lex)630 except ValueError:
171 unmodified lines
modified:src/click/termui.py+2 added-2 removed
710 unmodified lines
711 :param reset: by default a reset-all code is added at the end of the712 string which means that styles do not carry over. This713 can be disabled to compose styles.714715 .. versionchanged:: 8.5715 .. versionchanged:: 8.5.0716 All invalid color values raise :exc:`ValueError`. 256-color index717 ``0`` is not ignored717 ``0`` is no longer ignored.718719 .. versionchanged:: 8.0720 A non-string ``message`` is converted to a string.721
282 unmodified lines
modified:src/click/utils.py+1 added-1 removed
277 unmodified lines
278 :param color: Force showing or hiding colors and other styles. By279 default Click will remove color if the output does not look like280 an interactive terminal.281282 .. versionchanged:: 8.5282 .. versionchanged:: 8.5.0283 Colorama is no longer used for color on Windows.284285 .. versionchanged:: 6.0286 Support Unicode output on the Windows console. Click does not
402 unmodified lines
modified:CHANGES.md+11 added-4 removed
3 unmodified lines
45- Add built-in shell completion support for PowerShell (Windows PowerShell6 5.1+ and pwsh 7+) alongside the existing `bash`, `zsh`, and `fish`7 completers. Use `_FOO_BAR_COMPLETE=powershell_source foo-bar` to generate8 the completion script.8 the completion script. {issue}`2672` {pr}`3637`9- Supported versions of Windows enable ANSI terminal styles by default.10 Colorama is no longer a dependency and is not used. {issue}`2986` {pr}`3505`11- {class}`Argument` accepts a `help` parameter, and help output includes12 a `Positional arguments` section when argument help is available. {issue}`2983` {pr}`3473`
1 unmodified line
14 prompt when the output stream does not support them, matching `echo()`.15 This stripping was lost in `8.4.0` when {pr}`2969` began writing the16 prompt with `input()` directly. {issue}`3572` {pr}`3653`17- Fix test failures when using pytest >= 9.1. {pr}`3656`18- {class}`Path` with `allow_dash=True` no longer triggers a `BytesWarning`,19 an error under `python -bb`, when checking a value against the `-`20 convention. {issue}`2877` {pr}`3642`21- Add {func}`custom_version_option`, a `--version` option whose output is22 produced by a callback, covering cases {func}`version_option` intentionally23 does not. The feature set of {func}`version_option` is now frozen; see24 [discussion #3527](https://github.com/pallets/click/discussions/3527). {pr}`3581`25- `style()` and `secho()` no longer silently drop the 256-color index `0`23 (black) passed as `fg` or `bg`, and now validate color arguments. {pr}`3677`26 (black) passed as `fg` or `bg`, and now validate color arguments. Invalid27 colors raise a `ValueError` instead of a `TypeError`. {pr}`3677`28- The automatic help option stores its value under the reserved name29 `_click_default_help` instead of `help`, so a parameter named `help` no30 longer breaks parsing. The new name is visible in31 {meth}`Command.to_info_dict` output. Parameters that overwrite each other's
1 unmodified line
33 parameter, or any parameter claiming the reserved name. Options may still34 share a name to compete for the same value (feature switches).35 {issue}`2819` {pr}`3678`36- `unstyle` and the ANSI handling behind help-text wrapping now strip the full33 CSI escape-sequence grammar.37 CSI escape-sequence grammar. {pr}`3681`38- Streamline `Option` flag handling: the flag-kind, type, lazy-default and39 validation steps in `Option.__init__` move into focused helpers, and40 `flag_value` and `default` keep their unset sentinel at construction41 (resolved lazily on read) so `is UNSET` reliably tells a user-supplied value38 from an auto-derived one. Behavior is unchanged. {pr}`3641`42 from an auto-derived one. Runtime behavior is unchanged, but43 {meth}`Parameter.to_info_dict` now resolves `default=True` on a feature44 switch to its `flag_value`, matching what the function receives at call45 time. {pr}`3641`46- {func}`get_binary_stream` and {func}`get_text_stream` are deprecated and47 will be removed in Click 9.0. {issue}`3481` {pr}`3695`48- The following `click.utils` names were never intentionally public and are49 now private (`_`-prefixed). The old names remain available with a
1581 unmodified lines