Skip to content
Myr

upgrading.rst

This file

Path

docs/upgrading.rst

44 lines · 1.5 KiB

Last changed by

Documentation fixesKevin Yapbefore adoption67523af

History of this file

Take it

Updated docs for upgrade information.Armin Ronacherbefore adoptionebde9a0

lines 1–8why, one step back
1Upgrading To Newer Releases
2===========================34Click attempts the highest level of backwards compatibility but sometimes5this is not entirely possible. In case we need to break backwards6compatibility this document gives you information about how to upgrade or7handle backwards compatibility properly.8

Added notes on callback changes to the docsArmin Ronacherbefore adoptiond27f3a6

lines 9–10why, one step back
9.. _upgrade-to-2.0:
10

Updated docs for upgrade information.Armin Ronacherbefore adoptionebde9a0

lines 11–14why, one step back
11Upgrading to 2.0
12----------------1314Click 2.0 has one breaking change which is the signature for parameter

Documentation fixesKevin Yapbefore adoption67523af

line 15why, one step back
15callbacks. Before 2.0, the callback was invoked with ``(ctx, value)``

Merge branch 'master' of https://github.com/mitsuhiko/clickArmin Ronacherbefore adoption8bd9f7a

line 16why, one step back
16whereas now it's ``(ctx, param, value)``. This change was necessary as it

Updated docs for upgrade information.Armin Ronacherbefore adoptionebde9a0

lines 17–18why, one step back
17otherwise made reusing callbacks too complicated.
18

Changed upgrade note to be more correct.Armin Ronacherbefore adoption830ab09

line 19why, one step back
19To ease the transition click will still accept old callbacks. Starting

Merge pull request #112 from julen/doc-fixesArmin Ronacherbefore adoptionf48761a

line 20why, one step back
20with click 3.0 it will start to issue a warning to stderr to encourage you

Changed upgrade note to be more correct.Armin Ronacherbefore adoption830ab09

line 21why, one step back
21to upgrade.

Updated docs for upgrade information.Armin Ronacherbefore adoptionebde9a0

line 22why, one step back
22

Documentation fixesKevin Yapbefore adoption67523af

line 23why, one step back
23In case you want to support both click 1.0 and click 2.0, you can make a

Updated docs for upgrade information.Armin Ronacherbefore adoptionebde9a0

lines 24–41why, one step back
24simple decorator that adjusts the signatures::
2526 import click27 from functools import update_wrapper2829 def compatcallback(f):30 # Click 1.0 does not have a version string stored, so we need to31 # use getattr here to be safe.32 if getattr(click, '__version__', '0.0') >= '2.0':33 return f34 return update_wrapper(lambda ctx, value: f(ctx, None, value), f)3536With that helper you can then write something like this::3738 @compatcallback39 def callback(ctx, param, value):40 return value.upper()41

Documentation fixesKevin Yapbefore adoption67523af

lines 42–43why, one step back
42Note that because click 1.0 did not pass a parameter, the `param` argument
43here would be `None`, so a compatibility callback could not use that

Updated docs for upgrade information.Armin Ronacherbefore adoptionebde9a0

line 44why, one step back
44argument.