upgrade-guides.md
This file
upgrade-guides.md
Upgrade Guides
:depth: 1
:local: true
Upgrading 8.3.X to 9.0
This is under active construction and will not be finalized until 9.0.0 is released.
This guide assumes the user is on version 8.3.X.
Deprecations
For each deprecation, provide a brief explanation, and direct users to new function / class if available.
- A parameter name that is not a valid Python identifier, or that is a Python keyword, is deprecated and raises
TypeErrorin 9.0.str.isidentifier()decides the first case, soclick.argument("0foo")fails it. It accepts a keyword, soclick.option("--from")names a parameterfrom, which no callback can declare. Soft keywords such asmatchandtypeare contextual and unaffected, and--Trueand--Nonelower case out of the keyword set. To migrate, pass an explicit name (click.option("--from", "source"),click.option("--0-file", "zero_file")). An argument takes one declaration and has no explicit-name channel, so rename it and passmetavarto keep its old display (click.argument("zero_file", metavar="0-FILE")). See #3827 and #3866. - An option name written as a Python identifier is deprecated when it is not already lower cased:
click.option("--x", "Foo_Bar")namesfoo_barrather thanFoo_Bar. To migrate, spell the name the way the callback declares it. See #3827. CliRunner.isolated_filesystem()is deprecated and will be removed in Click 9.0. The helper predates Python 3 and modern pytest, and it relies onos.chdir, which mutates process-global state and is therefore not thread-safe. Replace it with a temporary directory (tempfile.TemporaryDirectory, or pytest'stmp_pathfixture) and pass absolute paths to the command instead of relying on the current working directory. To run commands in parallel, use process-based isolation (such aspytest-xdist) rather than threads, sinceCliRunner.invoke()also redirects the process-global standard streams and other interpreter-wide state. See #3700, #3501 and the testing guide.Parameter.human_readable_nameis deprecated and will be removed in Click 9.0. UseParameter.specinstead, which returns how the user spells the parameter on the command line. For an argument the two agree, since both return the metavar. For an option the old property returned the internalname, so the value changes frommy_optionto--my-option. Click no longer reads the property, so an override in a subclass has no effect: overrideParameter.specinstead. Defining a subclass that still overrideshuman_readable_nameemits aDeprecationWarning. See the parameter names section for the three strings that designate a parameter.
Removals with prior deprecation
For each removal, provide a brief explanation, and direct users to new function / class if available. If possible, deprecate and remove in 10.0.0, rather than removing outright.
- TBD
Removals with no prior deprecation
The changes were not able to be deprecated prior to removal. Explain clearly why then were not able to be deprecated first.
- TBD
Changes
- Error messages and deprecation warnings name an option by its spec rather than its internal name, so
The option 'my_option' is deprecated.now readsThe option '--my-option' is deprecated.Tests asserting on the old wording need updating.
Fixes
- TBD