This is the Click 8.5.0 feature release. A feature release may include new features, remove previously deprecated code, add new deprecation, or introduce potentially breaking changes.
We encourage everyone to upgrade. You can read more about our Version Support Policy on our website.
PyPI: https://pypi.org/project/click/8.5.0/
Changes: https://click.palletsprojects.com/page/changes/#version-8-5-0
Milestone https://github.com/pallets/click/milestone/33
- Add built-in shell completion support for PowerShell (Windows PowerShell
5.1+ and pwsh 7+) alongside the existingbash,zsh, andfish
completers. Use_FOO_BAR_COMPLETE=powershell_source foo-barto generate
the completion script. #2672 #3637 - Supported versions of Windows enable ANSI terminal styles by default.
Colorama is no longer a dependency and is not used. #2986 #3505 - {class}
Argumentaccepts ahelpparameter, and help output includes
aPositional argumentssection when argument help is available. #2983 #3473 confirm()andprompt()strip ANSI color and style codes from the
prompt when the output stream does not support them, matchingecho().
This stripping was lost in8.4.0when #2969 began writing the
prompt withinput()directly. #3572 #3653- {class}
Pathwithallow_dash=Trueno longer triggers aBytesWarning,
an error underpython -bb, when checking a value against the-
convention. #2877 #3642 - Add {func}
custom_version_option, a--versionoption whose output is
produced by a callback, covering cases {func}version_optionintentionally
does not. The feature set of {func}version_optionis now frozen; see
discussion #3527. #3581 style()andsecho()no longer silently drop the 256-color index0
(black) passed asfgorbg, and now validate color arguments. Invalid
colors raise aValueErrorinstead of aTypeError. #3677- The automatic help option stores its value under the reserved name
_click_default_helpinstead ofhelp, so a parameter namedhelpno
longer breaks parsing. The new name is visible in
{meth}Command.to_info_dictoutput. Parameters that overwrite each other's
value trigger a warning: an argument sharing its name with another
parameter, or any parameter claiming the reserved name. Options may still
share a name to compete for the same value (feature switches).
#2819 #3678 unstyleand the ANSI handling behind help-text wrapping now strip the full
CSI escape-sequence grammar. #3681- Streamline
Optionflag handling: the flag-kind, type, lazy-default and
validation steps inOption.__init__move into focused helpers, and
flag_valueanddefaultkeep their unset sentinel at construction
(resolved lazily on read) sois UNSETreliably tells a user-supplied value
from an auto-derived one. Runtime behavior is unchanged, but
{meth}Parameter.to_info_dictnow resolvesdefault=Trueon a feature
switch to itsflag_value, matching what the function receives at call
time. #3641 - {func}
get_binary_streamand {func}get_text_streamare deprecated and
will be removed in Click 9.0. #3481 #3695 - The following
click.utilsnames were never intentionally public and are
now private (_-prefixed). The old names remain available with a
DeprecationWarninguntil Click 9.0:LazyFile,KeepOpenFile,
make_default_short_help,PacifyFlushWrapper, andsafecall.
#3099 #3695 - Deprecate {meth}
CliRunner.isolated_filesystem. It relies on
{func}os.chdir, which mutates process-global state and is not
thread-safe. The helper predates Python 3 and modern pytest: use a
temporary directory ({class}tempfile.TemporaryDirectoryor pytest's
tmp_pathfixture) with absolute paths instead. For running tests in
parallel, use process-based isolation (such aspytest-xdist) rather
than threads, since {meth}CliRunner.invokealso redirects the
process-global standard streams. #3501 #3700 #3704 prompt()is now generically typed and returns the type produced by
type,value_proc, or a matchingdefaultinstead ofAny.
{class}ParamTypetakes a second optional type parameter describing the
input value it accepts (ParamType[int, str]for a type converting
strings to integers), defaulting toAny. #3407- {meth}
Command.get_help_option_namesreturns the help option names in the
order they were declared. #3728 - {func}
get_pager_fileyields a text stream on Windows again. The temporary
file backend opened its file in binary mode, so writing astrto the pager
raisedTypeError: a bytes-like object is required, not 'str', and the
colorargument was ignored on that path. Regression introduced in8.4.0
by #1572. #3731 #3732 #3740 #3739 - {func}
progressbarsettles on its final position whenupdate_min_steps
does not divide the total. Steps below that threshold are applied when the
bar finishes, soshow_posrenders20/20rather than the last multiple
it reached. #3571 #3769 - An error raised while writing to the pager no longer gets replaced by
PermissionError: [WinError 32]on Windows. The temporary file backend
unlinked its file without closing it first, and Windows refuses to remove a
file the process still holds open, so the cleanup failure masked the real
exception. #3731 #3764 - The temporary file the pager writes to on Windows is opened with the encoding
{func}get_pager_filepicked for the output stream, and with
errors="replace"to match the pipe backend. Any text stdout can encode
reaches the pager. - The temporary file pager backend forwards any parameters the user set in
PAGERto the pager command instead of silently dropping them. On Windows,
PAGER="less -R"now invokesless -Ron the temporary file rather than
bareless. #3777 - Improve raw mode detection by parsing the option tokens. #3416
#3777 - {func}
editacceptsos.PathLikevalues forfilename, in addition to
strings. #2869 #3781