remove old upgrading notes
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Lord · committed by David Lord · parent 56db546 · Browse files · 2 files·+0 added−132 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+0 added−132 removed
- other:+0 added−132 removed
Provenance
- Commit
883feba- Tree
a222200- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent
56db546
2 files changed+0 added−132 removed
modified:docs/index.rst-1 removed
100 unmodified lines101 .. toctree::102 :maxdepth: 2103 104 contrib105- upgrading105 license106 changesdeleted:docs/upgrading.rst-131 removed
1-Upgrading To Newer Releases2-===========================3-4-Click attempts the highest level of backwards compatibility but sometimes5-this is not entirely possible. In case we need to break backwards6-compatibility this document gives you information about how to upgrade or7-handle backwards compatibility properly.8-9-.. _upgrade-to-7.0:10-11-Upgrading to 7.012-----------------13-14-Commands that take their name from the decorated function now replace15-underscores with dashes. For example, the Python function ``run_server``16-will get the command name ``run-server`` now. There are a few options17-to address this:18-19-- To continue with the new behavior, pin your dependency to20- ``Click>=7`` and update any documentation to use dashes.21-- To keep existing behavior, add an explicit command name with22- underscores, like ``@click.command("run_server")``.23-- To try a name with dashes if the name with underscores was not24- found, pass a ``token_normalize_func`` to the context:25-26- .. code-block:: python27-28- def normalize(name):29- return name.replace("_", "-")30-31- @click.group(context_settings={"token_normalize_func": normalize})32- def group():33- ...34-35- @group.command()36- def run_server():37- ...38-39-40-.. _upgrade-to-3.2:41-42-Upgrading to 3.243-----------------44-45-Click 3.2 had to perform two changes to groups which were46-triggered by a change between Click 2 and Click 3 that had bigger47-consequences than anticipated.48-49-Context Invokes50-```````````````51-52-Click 3.2 contains a fix for the :meth:`Context.invoke` function when used53-with other commands. The original intention of this function was to54-invoke the other command as as if it came from the command line when it55-was passed a context object instead of a function. This use was only56-documented in a single place in the documentation before and there was no57-proper explanation for the method in the API documentation.58-59-The core issue is that before 3.2 this call worked against intentions::60-61- ctx.invoke(other_command, 'arg1', 'arg2')62-63-This was never intended to work as it does not allow Click to operate on64-the parameters. Given that this pattern was never documented and ill65-intended the decision was made to change this behavior in a bugfix release66-before it spreads by accident and developers depend on it.67-68-The correct invocation for the above command is the following::69-70- ctx.invoke(other_command, name_of_arg1='arg1', name_of_arg2='arg2')71-72-This also allowed us to fix the issue that defaults were not handled73-properly by this function.74-75-Command Chaining API76-````````````````````77-78-Click 3 introduced command chaining. This required a change in how79-Click internally dispatches. Unfortunately this change was not correctly80-implemented and it appeared that it was possible to provide an API that81-can inform the super command about all the subcommands that will be82-invoked.83-84-This assumption however does not work with one of the API guarantees that85-have been given in the past. As such this functionality has been removed86-in 3.2 as it was already broken. Instead the accidentally broken87-functionality of the :attr:`Context.invoked_subcommand` attribute was88-restored.89-90-If you do require the know which exact commands will be invoked there are91-different ways to cope with this. The first one is to let the subcommands92-all return functions and then to invoke the functions in a93-:meth:`Context.result_callback`.94-95-96-.. _upgrade-to-2.0:97-98-Upgrading to 2.099-----------------100-101-Click 2.0 has one breaking change which is the signature for parameter102-callbacks. Before 2.0, the callback was invoked with ``(ctx, value)``103-whereas now it's ``(ctx, param, value)``. This change was necessary as it104-otherwise made reusing callbacks too complicated.105-106-To ease the transition Click will still accept old callbacks. Starting107-with Click 3.0 it will start to issue a warning to stderr to encourage you108-to upgrade.109-110-In case you want to support both Click 1.0 and Click 2.0, you can make a111-simple decorator that adjusts the signatures::112-113- import click114- from functools import update_wrapper115-116- def compatcallback(f):117- # Click 1.0 does not have a version string stored, so we need to118- # use getattr here to be safe.119- if getattr(click, '__version__', '0.0') >= '2.0':120- return f121- return update_wrapper(lambda ctx, value: f(ctx, None, value), f)122-123-With that helper you can then write something like this::124-125- @compatcallback126- def callback(ctx, param, value):127- return value.upper()128-129-Note that because Click 1.0 did not pass a parameter, the `param` argument130-here would be `None`, so a compatibility callback could not use that131-argument.