Repository navigation
Releases
8.5.1
This is the Click 8.5.1 fix release, which fixes bugs but does not otherwise change behavior and should not result in breaking changes compared to the latest feature release.
PyPI: https://pypi.org/project/click/8.5.1/
Changes: https://click.palletsprojects.com/page/changes/#version-8-5-1
Milestone: https://github.com/pallets/click/milestone/66
- Fix
copy.deepcopy()andpickleon aParameter,OptionorCommand. #3805 - A
KeyboardInterruptarriving whileCommand.main()reports an abort or an error,
or while it exits, no longer escapes as an unhandled traceback. The command still
exits with the intended code; only the message may be lost. #3802 - Add
Option.get_help_spec(), which returns the option's left help
column even when the option is hidden.Option.get_help_record()still
returnsNonefor hidden options, so help screens are unchanged. #3821 - The
Positional argumentshelp section lists every argument of the command,
not only the documented ones. An argument with nohelpgets an empty
description, the same way an option with nohelpdoes. #3860 Argument.get_help_record()always returns a tuple. It used to return
Nonefor an argument with nohelp. #3860- Document which types are inferred from
default, and what an unrecognized
typecallable does to a command-line value. #3036 #3808 path_typenarrows the converted value's type forconvertandprompt.
#3822 #3858Parameteraccepts a newhelpargument, andOptionandArgument
inherit it.Parameter.to_info_dict()now reportshelpfor every kind of parameter.
#3861- A command's short help no longer stops at an abbreviation such as
vs.ore.g.
inside the first sentence. A period ends the sentence only when it closes the text
or the next word does not start in lowercase. #3865 - With
show_envvar=True, an option's error message now prints all variables of an
envvarsequence instead of thereprof the sequence. #3884 - An empty
envvar, such as[]or"", shows the same help and error message as
noenvvarwhenshow_envvar=True. The help screen used to show[env var: ].
#3884 - Align command's deprecated help text to options and arguments: do not translate the
command's own help text, only the(DEPRECATED)label. #3901
8.5.0
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
8.4.2
This is the Click 8.4.1 fix release, which fixes bugs but does not otherwise change behavior and should not result in breaking changes compared to the latest feature release.
PyPI: https://pypi.org/project/click/8.4.2/
Changes: https://click.palletsprojects.com/page/changes/#version-8-4-2
Milestone: https://github.com/pallets/click/milestone/34
- Fix Fish shell completion broken in
8.4.0by #3126. Newlines and
tabs in option help text are now escaped, keeping the original completion
format while still supporting multi-line help. #3502
#3043 #3504 #3508 - Deprecated commands and options with empty or missing help text no longer
render a stray leading space before the(DEPRECATED)label. #3509 - A {class}
Groupwithinvoke_without_command=Truemarks its subcommand as
optional in the usage help, showing[COMMAND]instead ofCOMMAND.
#3059 #3507 echo_via_pagerflushes after each write, so passing a generator streams
output to the pager incrementally instead of staying hidden until the pipe
buffer fills. #3242 #2542 #3534echo_via_pagerandget_pager_fileno longer close a borrowed stdout
stream when no external pager runs, completing the partial
I/O operation on closed filefix from #3482. #3449
#3533- Fix CLI usage symopsis for optional arguments producing double square brackets
[[a|b|c]]...whose type already brackets their metavar. #3578 - {func}
version_optionresolves apackage_namethat does not match an
installed distribution as an import (top-level module) name via
{func}importlib.metadata.packages_distributions. Packages whose
top-level module name differs from their distribution name (PILvs
Pillow,jwtvsPyJWT) no longer raiseRuntimeErrorout of the
box. #2331 #1884 #3125 #3582
8.4.1
This is the Click 8.4.1 fix release, which fixes bugs but does not otherwise change behavior and should not result in breaking changes compared to the latest feature release.
PyPI: https://pypi.org/project/click/8.4.1/
Changes: https://click.palletsprojects.com/page/changes/#version-8-4-1
Milestone: https://github.com/pallets/click/milestone/32
get_parameter_source()is available during eager callbacks and type conversion again. #3458 #3484- Zsh completion scripts parse correctly on Windows. #3277 # 3466
- Shell completion of
ChoiceEnumvalues produces a valid completion result. #3015 - Fix empty byte-string handling in echo. #3487
- Fix closed file error with
echo_via_pager. #3449
8.4.0
This is the Click 8.4.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.4.0/
Changes: https://click.palletsprojects.com/page/changes/#version-8-4-0
Milestone https://github.com/pallets/click/milestone/30
-
ParamTypetyping improvements. #3371- :class:
ParamTypeis now a generic abstract base class,
parameterized by its converted value type. - :meth:
~ParamType.convertreturn types are narrowed on all
concrete types (strfor :class:STRING,intfor
:class:INT, etc.). - :meth:
~ParamType.to_info_dictreturns specific
:class:~typing.TypedDictsubclasses instead of
dict[str, Any]. - :class:
CompositeParamTypeand the number-range base are now
generic with abstract methods.
- :class:
-
Refactor
convert_typeto extract type inference into a private
_guess_typehelper, and add :func:typing.overloadsignatures.
#3372 -
Parametertyping improvements. #2805- :class:
Parameteris now an abstract base class, making explicit
that it cannot be instantiated directly. - :attr:
Parameter.nameis nowstrinstead ofstr | None.
Whenexpose_value=False, the name is set to""instead
ofNone. - The
ctxparameter of :meth:Parameter.get_error_hintis now
typed asContext | None, matching the runtime behavior.
- :class:
-
Split string values from
default_mapfor parameters withnargs > 1
or :class:Tupletype, matching environment variable behavior.
#2745 #3364 -
Auto-detect
type=UNPROCESSEDforflag_valueof non-basic types
(notstr,int,float, orbool), so programmer-provided
Python objects like classes and enum members are passed through unchanged
instead of being stringified. Previouslytype=click.UNPROCESSEDhad
to be set explicitly. #2012 #3363 -
The error hint now uses
Command.get_help_option_namesto pick
non-shadowed help option names, soTry '... -h'no longer points to a
subcommand option that shadows-h. All surviving names are shown
(-h/--help). #2790 #3208 -
Fix readline functionality on non-Windows platforms. Prompt text is now
passed directly to readline instead of being printed separately, allowing
proper backspace, line editing, and line wrapping behavior. #2968
#2969 -
Use :func:
os.startfileon Windows to open URLs in :func:open_url,
replacing thestartbuilt-in which cannot be invoked without
shell=True. #3164 #3186 -
Fix Fish shell completion errors when option help text contains newlines.
#3043 #3126 -
Add :class:
NoSuchCommandexception with suggestions for misspelled
commands. #3107 #3228 -
Use :class:
ValueErrormessage when conversion in :class:FuncParamTypewould
fail. #3105 #3211 -
Add
click.get_pager_filefor file-like access to an output
pager. #1572 #3405 -
:class:
~click.formatting.TextWrapperand
:func:~click.formatting.wrap_textnow measure line width in visible
characters, ignoring ANSI escape sequences. #3420 -
Fix :meth:
HelpFormatter.write_usageemitting only a blank line when
called withoutargs. The usage prefix and program name are now
written even when no arguments follow, and the trailing separator
space is stripped so the line ends at the program name.
#3360 #3434 -
Show custom error messages from types when :func:
promptwith
hide_input=Truefails validation, instead of always showing a
generic message. Built-in type messages mask the input value.
#2809 #3256 -
Add
captureparameter to :class:CliRunnerwith two modes:sys
(default) andfd.fdredirects file descriptors1and2
via :func:os.dup2so output that bypassessys.stdout(stale stream
references, C extensions, subprocesses,faulthandler) is captured
with proper isolation. #854 #2412 #2468
#2497 #2761 #2827 #2865 -
Revert the
8.3.3change that exposed the original file descriptor
viafileno()on the redirectedCliRunnerstreams in the default
capture mode.os.dup2(w, sys.stdout.fileno())calls inside a CLI no
longer mutate the host runner's stdout, which broke Pytest'sfd-level
capture teardown. C-level consumers that need a realfdshould use
capture="fd". #3384 #3391 -
Mark additional built-in strings with
gettext()to extend translation
coverage. #2902 -
Fix feature switch groups (several
flag_valueoptions sharing one
parameter name) silently dropping an explicitdefaultwhen a sibling
option without an explicit default was declared first. Arbitration is now
source-aware: a more explicit :class:ParameterSourcealways wins, and
withinParameterSource.DEFAULT, an option that received an explicit
default=keyword wins over a sibling whose default was auto-derived.
The 8.3.x first-wins fallback for remaining ties was reverted to the
pre-8.3.x last-wins fallback. #3403 #3404 -
Fix missing space between option help text and the
(DEPRECATED)
label, and localize the option label so it matches the command label.
The label and theDeprecationWarningreason suffix are now produced
by shared helpers. #3423 -
Document short option stacking (
-abcis parsed as-a -b -c) and
clarify that multi-character short option names are not supported.
#2779 #3431
8.3.3
This is the Click 8.3.3 fix release, which fixes bugs but does not otherwise change behavior and should not result in breaking changes compared to the latest feature release.
PyPI: https://pypi.org/project/click/8.3.3/
Changes: https://click.palletsprojects.com/page/changes/#version-8-3-3
Milestone: https://github.com/pallets/click/milestone/30
- Use :func:
shlex.splitto split pager and editor commands intoargv
lists for :class:subprocess.Popen, removingshell=True.
#1026 #1477 #2775 - Fix
TypeErrorwhen rendering help for an option whose default value is
an object that doesn't support equality comparison with strings, such as
semver.Version. #3298 #3299 - Fix pager test pollution under parallel execution by using pytest's
tmp_pathfixture instead of a shared temporary file path. #3238 - Treat
Sentinel.UNSETvalues in adefault_mapas absent, so they fall
through to the next default source instead of being used as the value.
#3224 #3240 - Patch
pdb.PdbinCliRunnerisolation sopdb.set_trace(),
breakpoint(), and debuggers subclassingpdb.Pdb(ipdb, pdbpp) can
interact with the real terminal instead of the captured I/O streams.
#654 #824 #843 #951 #3235 - Add optional randomized parallel test execution using
pytest-randomlyand
pytest-xdistto detect test pollution and race conditions. #3151 - Add contributor documentation for running stress tests, randomized
parallel tests, and Flask smoke tests. #3151 #3177 - Show custom
show_defaultstring in prompts, matching the existing
help text behavior. #2836 #2837 #3165 #3262 #3280
#3328 - Fix
default=Truewith booleanflag_valuealways returning the
flag_valueinstead ofTrue. Thedefault=Truetoflag_value
substitution now only applies to non-boolean flags, whereTrueacts as a
sentinel meaning "activate this flag by default". For boolean flags,
default=Trueis returned as a literal value. #3111 #3239 - Mark
make_default_short_helpas private API. #3189 #3250 CliRunner's redirected streams now expose the original file descriptor
viafileno(), so thatfaulthandler,subprocess, and other
C-level consumers no longer crash withio.UnsupportedOperation.
#2865- Change :class:
ParameterSourceto an :class:~enum.IntEnumand reorder
its members from most to least explicit, so values can be compared to
check whether a parameter was explicitly provided. #2879 #3248
8.3.2
This is the Click 8.3.2 fix release, which fixes bugs but does not otherwise change behavior and should not result in breaking changes compared to the latest feature release.
PyPI: https://pypi.org/project/click/8.3.2/
Changes: https://click.palletsprojects.com/page/changes/#version-8-3-2
Milestone: https://github.com/pallets/click/milestone/29
- Fix handling of
flag_valuewhenis_flag=Falseto allow such options to be
used without an explicit value. #3084 #3152 - Hide
Sentinel.UNSETvalues asNonewhen usinglookup_default().
#3136 #3199 #3202 #3209 #3212 #3224 - Prevent
_NamedTextIOWrapperfrom closing streams owned byStreamMixer.
#824 #2991 #2993 #3110 #3139 #3140 - Add comprehensive tests for
CliRunnerstream lifecycle, covering
logging interaction, multi-threaded safety, and sequential invocation
isolation. Add high-iteration stress tests behind astressmarker
with a dedicated CI job. #3139 - Fix callable
flag_valuebeing instantiated when used as a default via
default=True. #3121 #3201 #3213 #3225
8.3.1
This is the Click 8.3.1 fix release, which fixes bugs but does not otherwise change behavior and should not result in breaking changes compared to the latest feature release.
PyPI: https://pypi.org/project/click/8.3.1/
Changes: https://click.palletsprojects.com/page/changes/#version-8-3-1
Milestone: https://github.com/pallets/click/milestone/28
- Don't discard pager arguments by correctly using
subprocess.Popen. #3039 #3055 - Replace
Sentinel.UNSETdefault values byNoneas they're passed through theContext.invoke()method. #3066 #3065 #3068 - Fix conversion of
Sentinel.UNSEThappening too early, which caused incorrect behavior for multiple parameters using the same name. #3071 #3079 - Fix rendering when
promptandconfirmparameterprompt_suffixis empty. #3019 #3021 - When
Sentinel.UNSETis found during parsing, it will skip calls totype_cast_value. #3069 #3090 - Hide
Sentinel.UNSETvalues asNonewhen looking up for other parameters through the context inside parameter callbacks. #3136 #3137
8.3.0
This is the Click 8.3.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.3.0/
Changes: https://click.palletsprojects.com/page/changes/#version-8-3-0
Milestone https://github.com/pallets/click/milestone/27
-
Improved flag option handling: Reworked the relationship between
flag_value
anddefaultparameters for better consistency:- The
defaultparameter value is now preserved as-is and passed directly
to CLI functions (no more unexpected transformations) - Exception: flag options with
default=Truemaintain backward compatibility
by defaulting to theirflag_value - The
defaultparameter can now be any type (bool,None, etc.) - Fixes inconsistencies reported in: #1992 #2514 #2610
#3024 #3030
- The
-
Allow
defaultto be set onArgumentfornargs = -1. #2164
#3030 -
Show correct auto complete value for
nargsoption in combination with flag
option #2813 -
Show correct auto complete value for nargs option in combination with flag option #2813
-
Fix handling of quoted and escaped parameters in Fish autocompletion. #2995 #3013
-
Lazily import
shutil. #3023 -
Properly forward exception information to resources registered with
click.core.Context.with_resource(). #2447 #3058 -
Fix regression related to EOF handling in CliRunner. #2939 #2940
8.2.2
This is the Click 8.2.2 fix release, which fixes bugs but does not otherwise change behavior and should not result in breaking changes compared to the latest feature release.
PyPI: https://pypi.org/project/click/8.2.2/
Changes: https://click.palletsprojects.com/page/changes/#version-8-2-2
Milestone: https://github.com/pallets/click/milestone/25
- Fix reconciliation of
default,flag_valueandtypeparameters for
flag options, as well as parsing and normalization of environment variables.
#2952 #2956 - Fix typing issue in
BadParameterandMissingParameterexceptions for the
parameterparam_hintthat did not allow for a sequence of string where the
underlying functino_join_param_hintsallows for it. #2777 #2990 - Use the value of
Enumchoices to render their default value in help
screen. #2911 #3004 - Fix completion for the Z shell (
zsh) for completion items containing
colons. #2703 #2846 - Don't include envvar in error hint when not configured. #2971 #2972
- Fix a rare race in
click.testing.StreamMixer's finalization that manifested
as aValueErroron close in a multi-threaded test session.
#2993 #2991