Merge branch '8.0.x'
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 · parents 051d57c, ee5fdbf · Browse files · 10 files·+43 added−24 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
10 files+43 added−24 removed
- tests:+13 added−0 removed
- other:+30 added−24 removed
Provenance
- Commit
c63c70d- Tree
fceeff9- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent 1
051d57c- Parent 2
ee5fdbf
10 files changed+43 added−24 removed
modified:requirements/dev.txt+10 added-12 removed
4 unmodified lines5 # pip-compile requirements/dev.in6 #7 alabaster==0.7.128 # via sphinx9-attrs==21.2.09+attrs==21.4.010 # via pytest11 babel==2.9.112 # via sphinx13-backports.entry-points-selectable==1.1.114- # via virtualenv13 certifi==2021.10.814 # via requests15 cfgv==3.3.116 # via pre-commit19-charset-normalizer==2.0.917+charset-normalizer==2.0.1018 # via requests19 click==8.0.320 # via pip-tools21 distlib==0.3.45 unmodified lines27 filelock==3.4.228 # via29 # tox30 # virtualenv33-identify==2.4.031+identify==2.4.332 # via pre-commit33 idna==3.334 # via requests35 imagesize==1.3.03 unmodified lines39 jinja2==3.0.340 # via sphinx41 markupsafe==2.0.142 # via jinja245-mypy==0.93043+mypy==0.93144 # via -r requirements/typing.in45 mypy-extensions==0.4.346 # via mypy47 nodeenv==1.6.021 unmodified lines69 py==1.11.070 # via71 # pytest72 # tox75-pygments==2.10.073+pygments==2.11.274 # via75 # sphinx76 # sphinx-tabs77 pyparsing==3.0.63 unmodified lines81 pytz==2021.382 # via babel83 pyyaml==6.084 # via pre-commit87-requests==2.26.085+requests==2.27.186 # via sphinx87 six==1.16.088 # via89 # tox6 unmodified lines96 # pallets-sphinx-themes97 # sphinx-issues98 # sphinx-tabs99 # sphinxcontrib-log-cabinet102-sphinx-issues==1.2.0100+sphinx-issues==3.0.1101 # via -r requirements/docs.in102 sphinx-tabs==3.2.0103 # via -r requirements/docs.in104 sphinxcontrib-applehelp==1.0.218 unmodified lines123 tomli==2.0.0124 # via125 # mypy126 # pep517129-tox==3.24.4127+tox==3.24.5128 # via -r requirements/dev.in129 typing-extensions==4.0.1130 # via mypy133-urllib3==1.26.7131+urllib3==1.26.8132 # via requests135-virtualenv==20.10.0133+virtualenv==20.13.0134 # via135 # pre-commit136 # tox137 wheel==0.37.15 unmodified linesmodified:requirements/docs.txt+5 added-5 removed
8 unmodified lines9 babel==2.9.110 # via sphinx11 certifi==2021.10.812 # via requests13-charset-normalizer==2.0.913+charset-normalizer==2.0.1014 # via requests15 docutils==0.1616 # via17 # sphinx11 unmodified lines29 # pallets-sphinx-themes30 # sphinx31 pallets-sphinx-themes==2.0.232 # via -r requirements/docs.in33-pygments==2.10.033+pygments==2.11.234 # via35 # sphinx36 # sphinx-tabs37 pyparsing==3.0.638 # via packaging39 pytz==2021.340 # via babel41-requests==2.26.041+requests==2.27.142 # via sphinx43 snowballstemmer==2.2.044 # via sphinx45 sphinx==4.3.22 unmodified lines48 # pallets-sphinx-themes49 # sphinx-issues50 # sphinx-tabs51 # sphinxcontrib-log-cabinet52-sphinx-issues==1.2.052+sphinx-issues==3.0.153 # via -r requirements/docs.in54 sphinx-tabs==3.2.055 # via -r requirements/docs.in56 sphinxcontrib-applehelp==1.0.29 unmodified lines66 sphinxcontrib-qthelp==1.0.367 # via sphinx68 sphinxcontrib-serializinghtml==1.1.569 # via sphinx70-urllib3==1.26.770+urllib3==1.26.871 # via requests72 73 # The following packages are considered to be unsafe in a requirements file:74 # setuptoolsmodified:requirements/tests.txt+1 added-1 removed
2 unmodified lines3 # To update, run:4 #5 # pip-compile requirements/tests.in6 #7-attrs==21.2.07+attrs==21.4.08 # via pytest9 iniconfig==1.1.110 # via pytest11 packaging==21.311 unmodified linesmodified:requirements/typing.txt+1 added-1 removed
2 unmodified lines3 # To update, run:4 #5 # pip-compile requirements/typing.in6 #7-mypy==0.9307+mypy==0.9318 # via -r requirements/typing.in9 mypy-extensions==0.4.310 # via mypy11 tomli==2.0.03 unmodified linesmodified:src/click/core.py+2 added-1 removed
1 import enum2 import errno3+import inspect4 import os5 import sys6 import typing as t7 from collections import abc2670 unmodified lines2678 if show_default_is_str:2679 default_string = f"({self.show_default})"2680 elif isinstance(default_value, (list, tuple)):2681 default_string = ", ".join(str(d) for d in default_value)2681- elif callable(default_value):2682+ elif inspect.isfunction(default_value):2683 default_string = _("(dynamic)")2684 elif self.is_bool_flag and self.secondary_opts:2685 # For boolean flags that have distinct True/False opts,2686 # use the opt without prefix instead of the value.228 unmodified linesmodified:src/click/decorators.py+1 added-1 removed
12 unmodified lines13 from .globals import get_current_context14 from .utils import echo15 16 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])18 19 20 def pass_context(f: F) -> F:21 """Marks a callback as wanting to receive the current context415 unmodified linesmodified:src/click/shell_completion.py+2 added-2 removed
100 unmodified lines101 for completion in $response; do102 IFS=',' read type value <<< "$completion"103 104 if [[ $type == 'dir' ]]; then105- COMREPLY=()105+ COMPREPLY=()106 compopt -o dirnames107 elif [[ $type == 'file' ]]; then108- COMREPLY=()108+ COMPREPLY=()109 compopt -o default110 elif [[ $type == 'plain' ]]; then111 COMPREPLY+=($value)112 fi469 unmodified linesmodified:tests/test_options.py+13 added
303 unmodified lines304 assert "lambda" not in result.output305 assert "(current user)" in result.output306 307 308+def test_dynamic_default_help_special_method(runner):309+ class Value:310+ def __call__(self):311+ return 42312+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+321 @pytest.mark.parametrize(322 ("type", "expect"),323 [324 (click.IntRange(1, 32), "1<=x<=32"),551 unmodified linesmodified:.pre-commit-config.yaml+1 added-1 removed
1 ci:2 autoupdate_schedule: monthly3 repos:4 - repo: https://github.com/asottile/pyupgrade5- rev: v2.29.15+ rev: v2.31.06 hooks:7 - id: pyupgrade8 args: ["--py37-plus"]9 - repo: https://github.com/asottile/reorder_python_imports21 unmodified linesmodified:CHANGES.rst+7 added
24 unmodified lines25 Unreleased26 27 - ``open_file`` recognizes ``Path("-")`` as a standard stream, the28 same as the string ``"-"``. :issue:`2106`29+- The ``option`` and ``argument`` decorators preserve the type30+ annotation of the decorated function. :pr:`2155`31+- A callable default value can customize its help text by overriding32+ ``__str__`` instead of always showing ``(dynamic)``. :issue:`2099`33+- Fix a typo in the Bash completion script that affected file and34+ directory completion. If this script was generated by a previous35+ version, it should be regenerated. :issue:`2163`36 37 38 Version 8.0.339 -------------930 unmodified lines