Skip to content

Commit c63c70d

Browse files
committed
Merge branch '8.0.x'
2 parents 051d57c + ee5fdbf commit c63c70d

10 files changed

Lines changed: 43 additions & 24 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ci:
22
autoupdate_schedule: monthly
33
repos:
44
- repo: https://github.com/asottile/pyupgrade
5-
rev: v2.29.1
5+
rev: v2.31.0
66
hooks:
77
- id: pyupgrade
88
args: ["--py37-plus"]

CHANGES.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ Unreleased
2626

2727
- ``open_file`` recognizes ``Path("-")`` as a standard stream, the
2828
same as the string ``"-"``. :issue:`2106`
29+
- The ``option`` and ``argument`` decorators preserve the type
30+
annotation of the decorated function. :pr:`2155`
31+
- A callable default value can customize its help text by overriding
32+
``__str__`` instead of always showing ``(dynamic)``. :issue:`2099`
33+
- Fix a typo in the Bash completion script that affected file and
34+
directory completion. If this script was generated by a previous
35+
version, it should be regenerated. :issue:`2163`
2936

3037

3138
Version 8.0.3

requirements/dev.txt

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@
66
#
77
alabaster==0.7.12
88
# via sphinx
9-
attrs==21.2.0
9+
attrs==21.4.0
1010
# via pytest
1111
babel==2.9.1
1212
# via sphinx
13-
backports.entry-points-selectable==1.1.1
14-
# via virtualenv
1513
certifi==2021.10.8
1614
# via requests
1715
cfgv==3.3.1
1816
# via pre-commit
19-
charset-normalizer==2.0.9
17+
charset-normalizer==2.0.10
2018
# via requests
2119
click==8.0.3
2220
# via pip-tools
@@ -30,7 +28,7 @@ filelock==3.4.2
3028
# via
3129
# tox
3230
# virtualenv
33-
identify==2.4.0
31+
identify==2.4.3
3432
# via pre-commit
3533
idna==3.3
3634
# via requests
@@ -42,7 +40,7 @@ jinja2==3.0.3
4240
# via sphinx
4341
markupsafe==2.0.1
4442
# via jinja2
45-
mypy==0.930
43+
mypy==0.931
4644
# via -r requirements/typing.in
4745
mypy-extensions==0.4.3
4846
# via mypy
@@ -72,7 +70,7 @@ py==1.11.0
7270
# via
7371
# pytest
7472
# tox
75-
pygments==2.10.0
73+
pygments==2.11.2
7674
# via
7775
# sphinx
7876
# sphinx-tabs
@@ -84,7 +82,7 @@ pytz==2021.3
8482
# via babel
8583
pyyaml==6.0
8684
# via pre-commit
87-
requests==2.26.0
85+
requests==2.27.1
8886
# via sphinx
8987
six==1.16.0
9088
# via
@@ -99,7 +97,7 @@ sphinx==4.3.2
9997
# sphinx-issues
10098
# sphinx-tabs
10199
# sphinxcontrib-log-cabinet
102-
sphinx-issues==1.2.0
100+
sphinx-issues==3.0.1
103101
# via -r requirements/docs.in
104102
sphinx-tabs==3.2.0
105103
# via -r requirements/docs.in
@@ -126,13 +124,13 @@ tomli==2.0.0
126124
# via
127125
# mypy
128126
# pep517
129-
tox==3.24.4
127+
tox==3.24.5
130128
# via -r requirements/dev.in
131129
typing-extensions==4.0.1
132130
# via mypy
133-
urllib3==1.26.7
131+
urllib3==1.26.8
134132
# via requests
135-
virtualenv==20.10.0
133+
virtualenv==20.13.0
136134
# via
137135
# pre-commit
138136
# tox

requirements/docs.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ babel==2.9.1
1010
# via sphinx
1111
certifi==2021.10.8
1212
# via requests
13-
charset-normalizer==2.0.9
13+
charset-normalizer==2.0.10
1414
# via requests
1515
docutils==0.16
1616
# via
@@ -30,15 +30,15 @@ packaging==21.3
3030
# sphinx
3131
pallets-sphinx-themes==2.0.2
3232
# via -r requirements/docs.in
33-
pygments==2.10.0
33+
pygments==2.11.2
3434
# via
3535
# sphinx
3636
# sphinx-tabs
3737
pyparsing==3.0.6
3838
# via packaging
3939
pytz==2021.3
4040
# via babel
41-
requests==2.26.0
41+
requests==2.27.1
4242
# via sphinx
4343
snowballstemmer==2.2.0
4444
# via sphinx
@@ -49,7 +49,7 @@ sphinx==4.3.2
4949
# sphinx-issues
5050
# sphinx-tabs
5151
# sphinxcontrib-log-cabinet
52-
sphinx-issues==1.2.0
52+
sphinx-issues==3.0.1
5353
# via -r requirements/docs.in
5454
sphinx-tabs==3.2.0
5555
# via -r requirements/docs.in
@@ -67,7 +67,7 @@ sphinxcontrib-qthelp==1.0.3
6767
# via sphinx
6868
sphinxcontrib-serializinghtml==1.1.5
6969
# via sphinx
70-
urllib3==1.26.7
70+
urllib3==1.26.8
7171
# via requests
7272

7373
# The following packages are considered to be unsafe in a requirements file:

requirements/tests.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# pip-compile requirements/tests.in
66
#
7-
attrs==21.2.0
7+
attrs==21.4.0
88
# via pytest
99
iniconfig==1.1.1
1010
# via pytest

requirements/typing.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# pip-compile requirements/typing.in
66
#
7-
mypy==0.930
7+
mypy==0.931
88
# via -r requirements/typing.in
99
mypy-extensions==0.4.3
1010
# via mypy

src/click/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import enum
22
import errno
3+
import inspect
34
import os
45
import sys
56
import typing as t
@@ -2678,7 +2679,7 @@ def _write_opts(opts: t.Sequence[str]) -> str:
26782679
default_string = f"({self.show_default})"
26792680
elif isinstance(default_value, (list, tuple)):
26802681
default_string = ", ".join(str(d) for d in default_value)
2681-
elif callable(default_value):
2682+
elif inspect.isfunction(default_value):
26822683
default_string = _("(dynamic)")
26832684
elif self.is_bool_flag and self.secondary_opts:
26842685
# For boolean flags that have distinct True/False opts,

src/click/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from .utils import echo
1515

1616
F = t.TypeVar("F", bound=t.Callable[..., t.Any])
17-
FC = t.TypeVar("FC", t.Callable[..., t.Any], Command)
17+
FC = t.TypeVar("FC", bound=t.Union[t.Callable[..., t.Any], Command])
1818

1919

2020
def pass_context(f: F) -> F:

src/click/shell_completion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ def __getattr__(self, name: str) -> t.Any:
102102
IFS=',' read type value <<< "$completion"
103103
104104
if [[ $type == 'dir' ]]; then
105-
COMREPLY=()
105+
COMPREPLY=()
106106
compopt -o dirnames
107107
elif [[ $type == 'file' ]]; then
108-
COMREPLY=()
108+
COMPREPLY=()
109109
compopt -o default
110110
elif [[ $type == 'plain' ]]; then
111111
COMPREPLY+=($value)

tests/test_options.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,19 @@ def cmd(username):
305305
assert "(current user)" in result.output
306306

307307

308+
def test_dynamic_default_help_special_method(runner):
309+
class Value:
310+
def __call__(self):
311+
return 42
312+
313+
def __str__(self):
314+
return "special value"
315+
316+
opt = click.Option(["-a"], default=Value(), show_default=True)
317+
ctx = click.Context(click.Command("cli"))
318+
assert "special value" in opt.get_help_record(ctx)[1]
319+
320+
308321
@pytest.mark.parametrize(
309322
("type", "expect"),
310323
[

0 commit comments

Comments
 (0)