diff options
| author | David Lord <davidism@gmail.com> | 2020-03-09 07:39:08 -0700 |
|---|---|---|
| committer | David Lord <davidism@gmail.com> | 2020-03-09 07:39:08 -0700 |
| commit | f605f9576b69dd185dfbaae18dbc27a0b7f9ded5 (patch) | |
| tree | a1f4d15677dec7808606b5de603de91db55652cf /src | |
| parent | 38ba2e6c7f7a48a7208902e5ee7046622b35b716 (diff) | |
| download | click-f605f9576b69dd185dfbaae18dbc27a0b7f9ded5.tar.gz | |
deprecate old param callback style
Diffstat (limited to 'src')
| -rw-r--r-- | src/click/core.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/click/core.py b/src/click/core.py index 2102696..f58bf26 100644 --- a/src/click/core.py +++ b/src/click/core.py @@ -110,18 +110,16 @@ def invoke_param_callback(callback, ctx, param, value): args = getattr(code, "co_argcount", 3) if args < 3: - # This will become a warning in Click 3.0: from warnings import warn warn( - Warning( - "Invoked legacy parameter callback '{}'. The new" - " signature for such callbacks starting with Click 2.0" - " is (ctx, param, value).".format(callback) - ), + "Parameter callbacks take 3 args, (ctx, param, value). The" + " 2-arg style is deprecated and will be removed in 8.0.".format(callback), + DeprecationWarning, stacklevel=3, ) return callback(ctx, value) + return callback(ctx, param, value) @@ -1440,8 +1438,7 @@ class Parameter(object): without any arguments. :param callback: a callback that should be executed after the parameter was matched. This is called as ``fn(ctx, param, - value)`` and needs to return the value. Before Click - 2.0, the signature was ``(ctx, value)``. + value)`` and needs to return the value. :param nargs: the number of arguments to match. If not ``1`` the return value is a tuple instead of single value. The default for nargs is ``1`` (except if the type is a tuple, then it's |
