Skip to content
Myr

update project files

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* update pre-commit hooks * add devcontainer * show url in publish environment * update actions versions * separate typing job * use dependabot grouped updates * use sphinx.ext.extlinks instead of sphinx-issues * update .editorconfig * update .gitignore * update .readthedocs.yaml * license is txt, readme is md * use pyproject.toml and flit_core instead of setuptools add typed classifier add pyright config simplify urls * tox builds docs in place * add tox env to update all dev dependencies * update issue and pr templates * simplify matrix

authored by David Lord · committed by David Lord · parent 76cb841 · Browse files · 50 files+406 added−518 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

50 files+406 added−518 removed

  • tests:+10 added−7 removed
  • other:+396 added−511 removed

50 files+406 added−518 removed

added:.devcontainer/devcontainer.json+17 added
added:.devcontainer/on-create-command.sh+7 added
modified:.github/ISSUE_TEMPLATE/bug-report.md+1 added-1 removed
modified:.github/ISSUE_TEMPLATE/config.yml+5 added-8 removed
modified:.github/ISSUE_TEMPLATE/feature-request.md+3 added-3 removed
modified:.github/workflows/lock.yaml+7 added-9 removed
modified:.github/workflows/publish.yaml+16 added-15 removed
modified:.github/workflows/tests.yaml+32 added-28 removed
7 unmodified lines
8 - 'docs/**'9 - '*.md'10 - '*.rst'11 pull_request:12 branches:13 - main14 - '*.x'12 paths-ignore:13 - 'docs/**'14 - '*.md'15 - '*.rst'16jobs:17 tests:21 name: ${{ matrix.name }}22 runs-on: ${{ matrix.os }}18 name: ${{ matrix.name || matrix.python }}19 runs-on: ${{ matrix.os || 'ubuntu-latest' }}20 strategy:21 fail-fast: false22 matrix:23 include:27 - {name: Linux, python: '3.11', os: ubuntu-latest, tox: py311}28 - {name: Windows, python: '3.11', os: windows-latest, tox: py311}29 - {name: Mac, python: '3.11', os: macos-latest, tox: py311}30 - {name: '3.12-dev', python: '3.12-dev', os: ubuntu-latest, tox: py312}31 - {name: '3.10', python: '3.10', os: ubuntu-latest, tox: py310}32 - {name: '3.9', python: '3.9', os: ubuntu-latest, tox: py39}33 - {name: '3.8', python: '3.8', os: ubuntu-latest, tox: py38}34 - {name: '3.7', python: '3.7', os: ubuntu-latest, tox: py37}35 - {name: 'PyPy', python: 'pypy-3.10', os: ubuntu-latest, tox: pypy310}36 - {name: Typing, python: '3.11', os: ubuntu-latest, tox: typing}24 - {python: '3.12'}25 - {name: Windows, python: '3.12', os: windows-latest}26 - {name: Mac, python: '3.12', os: macos-latest}27 - {python: '3.11'}28 - {python: '3.10'}29 - {python: '3.9'}30 - {python: '3.8'}31 - {python: '3.7'}32 - {name: PyPy, python: 'pypy-3.10', tox: pypy310}33 - {name: Minimum Versions, python: '3.12', tox: py-min}34 - {name: Development Versions, python: '3.8', tox: py-dev}35 steps:38 - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c39 - uses: actions/setup-python@5ccb29d8773c3f3f653e1705f474dfaa8a06a91236 - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.237 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.038 with:39 python-version: ${{ matrix.python }}42 cache: 'pip'43 cache-dependency-path: 'requirements/*.txt'44 - name: update pip45 run: |46 pip install -U wheel47 pip install -U setuptools48 python -m pip install -U pip40 allow-prereleases: true41 cache: pip42 cache-dependency-path: requirements*/*.txt43 - run: pip install tox44 - run: tox run -e ${{ matrix.tox || format('py{0}', matrix.python) }}45 typing:46 runs-on: ubuntu-latest47 steps:48 - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.249 - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.050 with:51 python-version: '3.x'52 cache: pip53 cache-dependency-path: requirements*/*.txt54 - name: cache mypy50 uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a1255 uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.256 with:57 path: ./.mypy_cache53 key: mypy|${{ matrix.python }}|${{ hashFiles('setup.cfg') }}54 if: matrix.tox == 'typing'58 key: mypy|${{ hashFiles('pyproject.toml') }}59 - run: pip install tox56 - run: tox run -e ${{ matrix.tox }}60 - run: tox run -e typing
modified:.github/dependabot.yml+16 added-7 removed
1version: 22updates:3- package-ecosystem: "github-actions"4 directory: "/"5 schedule:6 interval: "monthly"7 day: "monday"8 time: "16:00"9 timezone: "UTC"3 - package-ecosystem: github-actions4 directory: /5 schedule:6 interval: monthly7 groups:8 github-actions:9 patterns:10 - '*'11 - package-ecosystem: pip12 directory: /requirements/13 schedule:14 interval: monthly15 groups:16 python-requirements:17 patterns:18 - '*'
modified:.github/pull_request_template.md+10 added-15 removed
1<!--2Before opening a PR, open a ticket describing the issue or feature the3PR will address. Follow the steps in CONTRIBUTING.rst.3PR will address. An issue is not required for fixing typos in4documentation, or other simple non-code changes.56Replace this comment with a description of the change. Describe how it7addresses the linked ticket.8-->910<!--11Link to relevant issues or previous PRs, one per line. Use "fixes" to12automatically close an issue.1314fixes #<issue number>15-->1614- fixes #<issue number>1517<!--17Ensure each step in CONTRIBUTING.rst is complete by adding an "x" to18each box below.18Ensure each step in CONTRIBUTING.rst is complete, especially the following:1920If only docs were changed, these aren't relevant and can be removed.20- Add tests that demonstrate the correct behavior of the change. Tests21 should fail without the change.22- Add or update relevant docs, in the docs folder and in code.23- Add an entry in CHANGES.rst summarizing the change and linking to the issue.24- Add `.. versionchanged::` entries in any relevant code docs.25-->2223Checklist:2425- [ ] Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.26- [ ] Add or update relevant docs, in the docs folder and in code.27- [ ] Add an entry in `CHANGES.rst` summarizing the change and linking to the issue.28- [ ] Add `.. versionchanged::` entries in any relevant code docs.29- [ ] Run `pre-commit` hooks and fix any issues.30- [ ] Run `pytest` and `tox`, no tests failed.
modified:docs/conf.py+12 added-9 removed
8 unmodified lines
9release, version = get_version("Click")1011# General --------------------------------------------------------------1213master_doc = "index"13default_role = "code"14extensions = [15 "sphinx.ext.autodoc",16 "sphinx.ext.extlinks",17 "sphinx.ext.intersphinx",18 "sphinx_tabs.tabs",19 "sphinxcontrib.log_cabinet",20 "pallets_sphinx_themes",19 "sphinx_issues",20 "sphinx_tabs.tabs",21]22autodoc_member_order = "bysource"23autodoc_typehints = "description"23intersphinx_mapping = {"python": ("https://docs.python.org/3/", None)}24issues_github_path = "pallets/click"24autodoc_preserve_defaults = True25extlinks = {26 "issue": ("https://github.com/pallets/flask/issues/%s", "#%s"),27 "pr": ("https://github.com/pallets/flask/pull/%s", "#%s"),28}29intersphinx_mapping = {30 "python": ("https://docs.python.org/3/", None),31}3233# HTML -----------------------------------------------------------------3435html_theme = "click"
16 unmodified lines
52html_favicon = "_static/click-icon.png"53html_logo = "_static/click-logo-sidebar.png"54html_title = f"Click Documentation ({version})"55html_show_sourcelink = False4950# LaTeX ----------------------------------------------------------------5152latex_documents = [(master_doc, f"Click-{version}.tex", html_title, author, "manual")]
modified:docs/license.rst+2 added-1 removed
1BSD-3-Clause License2====================34.. include:: ../LICENSE.rst4.. literalinclude:: ../LICENSE.txt5 :language: text
modified:requirements/dev.txt+1 added-1 removed
42 unmodified lines
43pyproject-api==1.5.244 # via tox45pyproject-hooks==1.0.046 # via build47pyyaml==6.047pyyaml==6.0.148 # via pre-commit49toposort==1.1050 # via pip-compile-multi51tox==4.6.3
11 unmodified lines
modified:requirements/docs.txt+1 added-1 removed
46 unmodified lines
47 # sphinx-tabs48 # sphinxcontrib-log-cabinet49sphinx-issues==3.0.150 # via -r requirements/docs.in51sphinx-tabs==3.4.151sphinx-tabs==3.4.552 # via -r requirements/docs.in53sphinxcontrib-applehelp==1.0.454 # via sphinx55sphinxcontrib-devhelp==1.0.2
13 unmodified lines
modified:src/click/__init__.py+1 added
2 unmodified lines
3writing command line scripts fun. Unlike other modules, it's based4around a simple API that does not come with too much magic and is5composable.6"""78from .core import Argument as Argument9from .core import BaseCommand as BaseCommand10from .core import Command as Command11from .core import CommandCollection as CommandCollection
63 unmodified lines
modified:src/click/_compat.py+1 added-1 removed
514 unmodified lines
515 return locale.getpreferredencoding()516517 _ansi_stream_wrappers: t.MutableMapping[t.TextIO, t.TextIO] = WeakKeyDictionary()518519 def auto_wrap_for_ansi( # noqa: F811519 def auto_wrap_for_ansi(520 stream: t.TextIO, color: t.Optional[bool] = None521 ) -> t.TextIO:522 """Support ANSI color and style codes on Windows by wrapping a523 stream with colorama.
100 unmodified lines
modified:src/click/_termui_impl.py+2 added-1 removed
1 unmodified line
2This module contains implementations for the termui module. To keep the3import time of Click down, some infrequently used functionality is4placed in this module and only imported as needed.5"""67import contextlib8import math9import os10import sys
687 unmodified lines
698 _translate_ch_to_exc(rv)699 return rv700701else:701 import tty702 import termios703 import tty704705 @contextlib.contextmanager706 def raw_terminal() -> t.Iterator[int]:707 f: t.Optional[t.TextIO]
33 unmodified lines
modified:src/click/core.py+26 added-38 removed
37 unmodified lines
38from .utils import PacifyFlushWrapper3940if t.TYPE_CHECKING:41 import typing_extensions as te4243 from .shell_completion import CompletionItem4445F = t.TypeVar("F", bound=t.Callable[..., t.Any])46V = t.TypeVar("V")
336 unmodified lines
383 token_normalize_func = parent.token_normalize_func384385 #: An optional normalization function for tokens. This is386 #: options, choices, commands etc.386 self.token_normalize_func: t.Optional[387 t.Callable[[str], str]388 ] = token_normalize_func387 self.token_normalize_func: t.Optional[t.Callable[[str], str]] = (388 token_normalize_func389 )390391 #: Indicates if resilient parsing is enabled. In that case Click392 #: will do its best to not cause any failures and default values393 #: will be ignored. Useful for completion.
252 unmodified lines
646647 @t.overload648 def lookup_default(649 self, name: str, call: "te.Literal[True]" = True649 ) -> t.Optional[t.Any]:650 ...650 ) -> t.Optional[t.Any]: ...651652 @t.overload653 def lookup_default(654 self, name: str, call: "te.Literal[False]" = ...655 ) -> t.Optional[t.Union[t.Any, t.Callable[[], t.Any]]]:656 ...655 ) -> t.Optional[t.Union[t.Any, t.Callable[[], t.Any]]]: ...656657 def lookup_default(self, name: str, call: bool = True) -> t.Optional[t.Any]:658 """Get the default for a parameter from :attr:`default_map`.659
51 unmodified lines
711 return type(self)(command, info_name=command.name, parent=self)712713 @t.overload714 def invoke(716 __self, # noqa: B902715 __self,716 __callback: "t.Callable[..., V]",717 *args: t.Any,718 **kwargs: t.Any,720 ) -> V:721 ...719 ) -> V: ...720721 @t.overload722 def invoke(725 __self, # noqa: B902723 __self,724 __callback: "Command",725 *args: t.Any,726 **kwargs: t.Any,729 ) -> t.Any:730 ...727 ) -> t.Any: ...728729 def invoke(733 __self, # noqa: B902730 __self,731 __callback: t.Union["Command", "t.Callable[..., V]"],732 *args: t.Any,733 **kwargs: t.Any,734 ) -> t.Union[t.Any, V]:
43 unmodified lines
778 with augment_usage_errors(__self):779 with ctx:780 return __callback(*args, **kwargs)781785 def forward(786 __self, __cmd: "Command", *args: t.Any, **kwargs: t.Any # noqa: B902787 ) -> t.Any:782 def forward(__self, __cmd: "Command", *args: t.Any, **kwargs: t.Any) -> t.Any:783 """Similar to :meth:`invoke` but fills in default keyword784 arguments from the current context if the other command expects785 it. This cannot invoke callbacks directly, only other commands.786
143 unmodified lines
930 if key not in extra:931 extra[key] = value932933 ctx = self.context_class(939 self, info_name=info_name, parent=parent, **extra # type: ignore934 self, # type: ignore[arg-type]935 info_name=info_name,936 parent=parent,937 **extra,938 )939940 with ctx.scope(cleanup=False):941 self.parse_args(ctx, args)
48 unmodified lines
990 prog_name: t.Optional[str] = None,991 complete_var: t.Optional[str] = None,992 standalone_mode: "te.Literal[True]" = True,993 **extra: t.Any,996 ) -> "te.NoReturn":997 ...994 ) -> "te.NoReturn": ...995996 @t.overload997 def main(998 self,
1 unmodified line
1000 prog_name: t.Optional[str] = None,1001 complete_var: t.Optional[str] = None,1002 standalone_mode: bool = ...,1003 **extra: t.Any,1007 ) -> t.Any:1008 ...1004 ) -> t.Any: ...10051006 def main(1007 self,1008 args: t.Optional[t.Sequence[str]] = None,
829 unmodified lines
1838 _check_multicommand(self, name, cmd, register=True)1839 self.commands[name] = cmd18401841 @t.overload1846 def command(self, __func: t.Callable[..., t.Any]) -> Command:1847 ...1842 def command(self, __func: t.Callable[..., t.Any]) -> Command: ...18431844 @t.overload1845 def command(1846 self, *args: t.Any, **kwargs: t.Any1852 ) -> t.Callable[[t.Callable[..., t.Any]], Command]:1853 ...1847 ) -> t.Callable[[t.Callable[..., t.Any]], Command]: ...18481849 def command(1850 self, *args: t.Any, **kwargs: t.Any1851 ) -> t.Union[t.Callable[[t.Callable[..., t.Any]], Command], Command]:
35 unmodified lines
18871888 return decorator18891890 @t.overload1897 def group(self, __func: t.Callable[..., t.Any]) -> "Group":1898 ...1891 def group(self, __func: t.Callable[..., t.Any]) -> "Group": ...18921893 @t.overload1894 def group(1895 self, *args: t.Any, **kwargs: t.Any1903 ) -> t.Callable[[t.Callable[..., t.Any]], "Group"]:1904 ...1896 ) -> t.Callable[[t.Callable[..., t.Any]], "Group"]: ...18971898 def group(1899 self, *args: t.Any, **kwargs: t.Any1900 ) -> t.Union[t.Callable[[t.Callable[..., t.Any]], "Group"], "Group"]:
317 unmodified lines
22182219 @t.overload2220 def get_default(2221 self, ctx: Context, call: "te.Literal[True]" = True2230 ) -> t.Optional[t.Any]:2231 ...2222 ) -> t.Optional[t.Any]: ...22232224 @t.overload2225 def get_default(2226 self, ctx: Context, call: bool = ...2236 ) -> t.Optional[t.Union[t.Any, t.Callable[[], t.Any]]]:2237 ...2227 ) -> t.Optional[t.Union[t.Any, t.Callable[[], t.Any]]]: ...22282229 def get_default(2230 self, ctx: Context, call: bool = True2231 ) -> t.Optional[t.Union[t.Any, t.Callable[[], t.Any]]]:
599 unmodified lines
28312832 @t.overload2833 def get_default(2834 self, ctx: Context, call: "te.Literal[True]" = True2845 ) -> t.Optional[t.Any]:2846 ...2835 ) -> t.Optional[t.Any]: ...28362837 @t.overload2838 def get_default(2839 self, ctx: Context, call: bool = ...2851 ) -> t.Optional[t.Union[t.Any, t.Callable[[], t.Any]]]:2852 ...2840 ) -> t.Optional[t.Union[t.Any, t.Callable[[], t.Any]]]: ...28412842 def get_default(2843 self, ctx: Context, call: bool = True2844 ) -> t.Optional[t.Union[t.Any, t.Callable[[], t.Any]]]:
186 unmodified lines
modified:src/click/decorators.py+9 added-17 removed
132 unmodified lines
133134135# variant: no call, directly as decorator for a function.136@t.overload137def command(name: _AnyCallable) -> Command:138 ...137def command(name: _AnyCallable) -> Command: ...138139140# variant: with positional name and with positional or keyword cls argument:141# @command(namearg, CommandCls, ...) or @command(namearg, cls=CommandCls, ...)
1 unmodified line
143def command(144 name: t.Optional[str],145 cls: t.Type[CmdType],146 **attrs: t.Any,148) -> t.Callable[[_AnyCallable], CmdType]:149 ...147) -> t.Callable[[_AnyCallable], CmdType]: ...148149150# variant: name omitted, cls _must_ be a keyword argument, @command(cls=CommandCls, ...)151@t.overload
1 unmodified line
153 name: None = None,154 *,155 cls: t.Type[CmdType],156 **attrs: t.Any,159) -> t.Callable[[_AnyCallable], CmdType]:160 ...157) -> t.Callable[[_AnyCallable], CmdType]: ...158159160# variant: with optional string name, no cls argument provided.161@t.overload162def command(163 name: t.Optional[str] = ..., cls: None = None, **attrs: t.Any167) -> t.Callable[[_AnyCallable], Command]:168 ...164) -> t.Callable[[_AnyCallable], Command]: ...165166167def command(168 name: t.Union[t.Optional[str], _AnyCallable] = None,
81 unmodified lines
250251252# variant: no call, directly as decorator for a function.253@t.overload258def group(name: _AnyCallable) -> Group:259 ...254def group(name: _AnyCallable) -> Group: ...255256257# variant: with positional name and with positional or keyword cls argument:258# @group(namearg, GroupCls, ...) or @group(namearg, cls=GroupCls, ...)
1 unmodified line
260def group(261 name: t.Optional[str],262 cls: t.Type[GrpType],263 **attrs: t.Any,269) -> t.Callable[[_AnyCallable], GrpType]:270 ...264) -> t.Callable[[_AnyCallable], GrpType]: ...265266267# variant: name omitted, cls _must_ be a keyword argument, @group(cmd=GroupCls, ...)268@t.overload
1 unmodified line
270 name: None = None,271 *,272 cls: t.Type[GrpType],273 **attrs: t.Any,280) -> t.Callable[[_AnyCallable], GrpType]:281 ...274) -> t.Callable[[_AnyCallable], GrpType]: ...275276277# variant: with optional string name, no cls argument provided.278@t.overload279def group(280 name: t.Optional[str] = ..., cls: None = None, **attrs: t.Any288) -> t.Callable[[_AnyCallable], Group]:289 ...281) -> t.Callable[[_AnyCallable], Group]: ...282283284def group(285 name: t.Union[str, _AnyCallable, None] = None,
200 unmodified lines
486 if version is None and package_name is not None:487 metadata: t.Optional[types.ModuleType]488489 try:498 from importlib import metadata # type: ignore490 from importlib import metadata491 except ImportError:492 # Python < 3.8493 import importlib_metadata as metadata # type: ignore494
59 unmodified lines
modified:src/click/exceptions.py+1 added-1 removed
11 unmodified lines
12 from .core import Parameter131415def _join_param_hints(16 param_hint: t.Optional[t.Union[t.Sequence[str], str]]16 param_hint: t.Optional[t.Union[t.Sequence[str], str]],17) -> t.Optional[str]:18 if param_hint is not None and not isinstance(param_hint, str):19 return " / ".join(repr(x) for x in param_hint)20
268 unmodified lines
modified:src/click/globals.py+3 added-4 removed
1 unmodified line
2from threading import local34if t.TYPE_CHECKING:5 import typing_extensions as te67 from .core import Context89_local = local()101112@t.overload12def get_current_context(silent: "te.Literal[False]" = False) -> "Context":13 ...13def get_current_context(silent: "te.Literal[False]" = False) -> "Context": ...141516@t.overload17def get_current_context(silent: bool = ...) -> t.Optional["Context"]:18 ...17def get_current_context(silent: bool = ...) -> t.Optional["Context"]: ...181920def get_current_context(silent: bool = False) -> t.Optional["Context"]:21 """Returns the current click context. This can be used as a way to
46 unmodified lines
modified:src/click/parser.py+2 added
15 unmodified lines
1617Copyright 2001-2006 Gregory P. Ward. All rights reserved.18Copyright 2002-2006 Python Software Foundation. All rights reserved.19"""2021# This code uses parts of optparse written by Gregory P. Ward and22# maintained by the Python Software Foundation.23# Copyright 2001-2006 Gregory P. Ward24# Copyright 2002-2006 Python Software Foundation
8 unmodified lines
33from .exceptions import UsageError3435if t.TYPE_CHECKING:36 import typing_extensions as te3738 from .core import Argument as CoreArgument39 from .core import Context40 from .core import Option as CoreOption41 from .core import Parameter as CoreParameter
490 unmodified lines
modified:src/click/termui.py+1 added-1 removed
171 unmodified lines
172 except UsageError as e:173 if hide_input:174 echo(_("Error: The value you entered was invalid."), err=err)175 else:176 echo(_("Error: {e.message}").format(e=e), err=err) # noqa: B306176 echo(_("Error: {e.message}").format(e=e), err=err)177 continue178 if not confirmation_prompt:179 return result180 while True:
604 unmodified lines
modified:src/click/testing.py+1 added-1 removed
473 unmodified lines
474475 if temp_dir is None:476 try:477 shutil.rmtree(dt)478 except OSError: # noqa: B014478 except OSError:479 pass
modified:src/click/types.py+2 added-1 removed
13 unmodified lines
14from .utils import safecall1516if t.TYPE_CHECKING:17 import typing_extensions as te1819 from .core import Context20 from .core import Parameter21 from .shell_completion import CompletionItem22
714 unmodified lines
737 else:738 ctx.call_on_close(safecall(f.flush))739740 return f740 except OSError as e: # noqa: B014741 except OSError as e:742 self.fail(f"'{format_filename(value)}': {e.strerror}", param, ctx)743744 def shell_complete(745 self, ctx: "Context", param: "Parameter", incomplete: str
345 unmodified lines
modified:src/click/utils.py+1 added-1 removed
154 unmodified lines
155 try:156 rv, self.should_close = open_stream(157 self.name, self.mode, self.encoding, self.errors, atomic=self.atomic158 )159 except OSError as e: # noqa: E402159 except OSError as e:160 from .exceptions import FileError161162 raise FileError(self.name, hint=e.strerror) from e163 self._f = rv
461 unmodified lines
modified:tests/typing/typing_aliased_group.py+1 added
1"""Example from https://click.palletsprojects.com/en/8.1.x/advanced/#command-aliases"""23from __future__ import annotations45from typing_extensions import assert_type6
40 unmodified lines
modified:tests/typing/typing_confirmation_option.py+1 added
1"""From https://click.palletsprojects.com/en/8.1.x/options/#yes-parameters"""23from typing_extensions import assert_type45import click6
8 unmodified lines
modified:tests/typing/typing_options.py+1 added
1"""From https://click.palletsprojects.com/en/8.1.x/quickstart/#adding-parameters"""23from typing_extensions import assert_type45import click6
10 unmodified lines
modified:tests/typing/typing_simple_example.py+1 added
1"""The simple example from https://github.com/pallets/click#a-simple-example."""23from typing_extensions import assert_type45import click6
11 unmodified lines
modified:tests/typing/typing_version_option.py+1 added
1"""2From https://click.palletsprojects.com/en/8.1.x/options/#callbacks-and-eager-options.3"""45from typing_extensions import assert_type67import click8
8 unmodified lines
modified:tests/test_defaults.py+2 added-2 removed
3 unmodified lines
4def test_basic_defaults(runner):5 @click.command()6 @click.option("--foo", default=42, type=click.FLOAT)7 def cli(foo):8 assert type(foo) is float8 assert type(foo) is float # noqa E7219 click.echo(f"FOO:[{foo}]")1011 result = runner.invoke(cli, [])12 assert not result.exception
4 unmodified lines
17 @click.command()18 @click.option("--foo", default=[23, 42], type=click.FLOAT, multiple=True)19 def cli(foo):20 for item in foo:21 assert type(item) is float21 assert type(item) is float # noqa E72122 click.echo(item)2324 result = runner.invoke(cli, [])25 assert not result.exception
36 unmodified lines
modified:tests/test_imports.py-1 removed
2 unmodified lines
3import sys45from click._compat import WIN677IMPORT_TEST = b"""\8import builtins910found_imports = set()
57 unmodified lines
modified:tests/test_normalization.py-1 removed
1import click233CONTEXT_SETTINGS = dict(token_normalize_func=lambda x: x.lower())456def test_option_normalization(runner):
32 unmodified lines
modified:tests/test_testing.py+1 added-1 removed
319 unmodified lines
320 assert result_mix.output == "stdout\nstderr\n"321 assert result_mix.stdout == "stdout\nstderr\n"322323 with pytest.raises(ValueError):324 result_mix.stderr324 result_mix.stderr # noqa B018325326 @click.command()327 def cli_empty_stderr():328 click.echo("stdout")
92 unmodified lines
modified:tests/test_utils.py+2 added-2 removed
239 unmodified lines
240def test_prompt_cast_default(capfd, monkeypatch):241 monkeypatch.setattr(sys, "stdin", StringIO("\n"))242 value = click.prompt("value", default="100", type=int)243 capfd.readouterr()244 assert type(value) is int244 assert type(value) is int # noqa E721245246247@pytest.mark.skipif(WIN, reason="Test too complex to make work windows.")248def test_echo_writing_to_standard_error(capfd, monkeypatch):
214 unmodified lines
463 user = os.path.expanduser("~")464 assert user in click.utils._expand_args(["~"])465 monkeypatch.setenv("CLICK_TEST", "hello")466 assert "hello" in click.utils._expand_args(["$CLICK_TEST"])467 assert "setup.cfg" in click.utils._expand_args(["*.cfg"])467 assert "pyproject.toml" in click.utils._expand_args(["*.toml"])468 assert os.path.join("docs", "conf.py") in click.utils._expand_args(["**/conf.py"])469 assert "*.not-found" in click.utils._expand_args(["*.not-found"])470 # a bad glob pattern, such as a pytest identifier, should return itself471 assert click.utils._expand_args(["test.py::test_bad"])[0] == "test.py::test_bad"
36 unmodified lines
modified:.editorconfig+1 added-1 removed
7 unmodified lines
8end_of_line = lf9charset = utf-810max_line_length = 881112[*.{yml,yaml,json,js,css,html}]12[*.{css,html,js,json,jsx,scss,ts,tsx,yaml,yml}]13indent_size = 2
modified:.gitignore+9 added-15 removed
1/.idea/2/.vscode/3.DS_Store/4/env/5/venv/1.idea/2.vscode/3.venv*/4venv*/5__pycache__/7*.pyc8*.egg-info/9/build/10/dist/11/.pytest_cache/12/.tox/13.coverage14.coverage.*15/htmlcov/16/docs/_build/6dist/7.coverage*8htmlcov/9.tox/10docs/_build/
modified:.pre-commit-config.yaml+7 added-22 removed
1ci:2 autoupdate_branch: "8.1.x"2 autoupdate_schedule: monthly3repos:5 - repo: https://github.com/asottile/pyupgrade6 rev: v3.15.04 - repo: https://github.com/astral-sh/ruff-pre-commit5 rev: v0.4.16 hooks:8 - id: pyupgrade9 args: ["--py37-plus"]10 - repo: https://github.com/asottile/reorder-python-imports11 rev: v3.12.012 hooks:13 - id: reorder-python-imports14 args: ["--application-directories", "src"]15 - repo: https://github.com/psf/black16 rev: 23.11.017 hooks:18 - id: black19 - repo: https://github.com/PyCQA/flake820 rev: 6.1.021 hooks:22 - id: flake823 additional_dependencies:24 - flake8-bugbear25 - flake8-implicit-str-concat7 - id: ruff8 - id: ruff-format9 - repo: https://github.com/pre-commit/pre-commit-hooks27 rev: v4.5.010 rev: v4.6.011 hooks:12 - id: check-merge-conflict13 - id: debug-statements14 - id: fix-byte-order-marker15 - id: trailing-whitespace16 - id: end-of-file-fixer
modified:.readthedocs.yaml+2 added-2 removed
1version: 22build:3 os: ubuntu-20.043 os: ubuntu-22.044 tools:5 python: "3.10"5 python: '3.12'6python:7 install:8 - requirements: requirements/docs.txt9 - method: pip
4 unmodified lines
deleted:CODE_OF_CONDUCT.md-76 removed
1# Contributor Covenant Code of Conduct23## Our Pledge45In the interest of fostering an open and welcoming environment, we as6contributors and maintainers pledge to making participation in our project and7our community a harassment-free experience for everyone, regardless of age, body8size, disability, ethnicity, sex characteristics, gender identity and expression,9level of experience, education, socio-economic status, nationality, personal10appearance, race, religion, or sexual identity and orientation.1112## Our Standards1314Examples of behavior that contributes to creating a positive environment15include:1617* Using welcoming and inclusive language18* Being respectful of differing viewpoints and experiences19* Gracefully accepting constructive criticism20* Focusing on what is best for the community21* Showing empathy towards other community members2223Examples of unacceptable behavior by participants include:2425* The use of sexualized language or imagery and unwelcome sexual attention or26 advances27* Trolling, insulting/derogatory comments, and personal or political attacks28* Public or private harassment29* Publishing others' private information, such as a physical or electronic30 address, without explicit permission31* Other conduct which could reasonably be considered inappropriate in a32 professional setting3334## Our Responsibilities3536Project maintainers are responsible for clarifying the standards of acceptable37behavior and are expected to take appropriate and fair corrective action in38response to any instances of unacceptable behavior.3940Project maintainers have the right and responsibility to remove, edit, or41reject comments, commits, code, wiki edits, issues, and other contributions42that are not aligned to this Code of Conduct, or to ban temporarily or43permanently any contributor for other behaviors that they deem inappropriate,44threatening, offensive, or harmful.4546## Scope4748This Code of Conduct applies both within project spaces and in public spaces49when an individual is representing the project or its community. Examples of50representing a project or community include using an official project e-mail51address, posting via an official social media account, or acting as an appointed52representative at an online or offline event. Representation of a project may be53further defined and clarified by project maintainers.5455## Enforcement5657Instances of abusive, harassing, or otherwise unacceptable behavior may be58reported by contacting the project team at report@palletsprojects.com. All59complaints will be reviewed and investigated and will result in a response that60is deemed necessary and appropriate to the circumstances. The project team is61obligated to maintain confidentiality with regard to the reporter of an incident.62Further details of specific enforcement policies may be posted separately.6364Project maintainers who do not follow or enforce the Code of Conduct in good65faith may face temporary or permanent repercussions as determined by other66members of the project's leadership.6768## Attribution6970This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,71available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html7273[homepage]: https://www.contributor-covenant.org7475For answers to common questions about this code of conduct, see76https://www.contributor-covenant.org/faq
deleted:LICENSE.rst-28 removed
1Copyright 2014 Pallets23Redistribution and use in source and binary forms, with or without4modification, are permitted provided that the following conditions are5met:671. Redistributions of source code must retain the above copyright8 notice, this list of conditions and the following disclaimer.9102. Redistributions in binary form must reproduce the above copyright11 notice, this list of conditions and the following disclaimer in the12 documentation and/or other materials provided with the distribution.13143. Neither the name of the copyright holder nor the names of its15 contributors may be used to endorse or promote products derived from16 this software without specific prior written permission.1718THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS19"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT20LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A21PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT22HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,23SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED24TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR25PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF26LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING27NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS28SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
added:LICENSE.txt+28 added
1Copyright 2014 Pallets23Redistribution and use in source and binary forms, with or without4modification, are permitted provided that the following conditions are5met:671. Redistributions of source code must retain the above copyright8 notice, this list of conditions and the following disclaimer.9102. Redistributions in binary form must reproduce the above copyright11 notice, this list of conditions and the following disclaimer in the12 documentation and/or other materials provided with the distribution.13143. Neither the name of the copyright holder nor the names of its15 contributors may be used to endorse or promote products derived from16 this software without specific prior written permission.1718THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS19"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT20LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A21PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT22HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,23SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED24TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR25PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF26LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING27NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS28SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
deleted:MANIFEST.in-10 removed
1include CHANGES.rst2include tox.ini3include requirements/*.txt4graft artwork5graft docs6prune docs/_build7graft examples8graft tests9include src/click/py.typed10global-exclude *.pyc
added:pyproject.toml+99 added
1[project]2name = "click"3description = "Composable command line interface toolkit"4readme = "README.md"5license = {file = "LICENSE.txt"}6maintainers = [{name = "Pallets", email = "contact@palletsprojects.com"}]7classifiers = [8 "Development Status :: 5 - Production/Stable",9 "Intended Audience :: Developers",10 "License :: OSI Approved :: BSD License",11 "Operating System :: OS Independent",12 "Programming Language :: Python",13 "Typing :: Typed",14]15requires-python = ">=3.7"16dependencies = [17 "colorama; platform_system == 'Windows'",18 "importlib-metadata; python_version < '3.8'",19]20dynamic = ["version"]2122[project.urls]23Donate = "https://palletsprojects.com/donate"24Documentation = "https://click.palletsprojects.com/"25Changes = "https://click.palletsprojects.com/changes/"26Source = "https://github.com/pallets/click/"27Chat = "https://discord.gg/pallets"2829[build-system]30requires = ["flit_core<4"]31build-backend = "flit_core.buildapi"3233[tool.flit.module]34name = "click"3536[tool.flit.sdist]37include = [38 "docs/",39 "requirements/",40 "tests/",41 "CHANGES.rst",42 "tox.ini",43]44exclude = [45 "docs/_build/",46]4748[tool.pytest.ini_options]49testpaths = ["tests"]50filterwarnings = [51 "error",52]5354[tool.coverage.run]55branch = true56source = ["click", "tests"]5758[tool.coverage.paths]59source = ["src", "*/site-packages"]6061[tool.mypy]62python_version = "3.8"63files = ["src/click", "tests/typing"]64show_error_codes = true65pretty = true66strict = true6768[[tool.mypy.overrides]]69module = [70 "colorama.*",71]72ignore_missing_imports = true7374[tool.pyright]75pythonVersion = "3.8"76include = ["src/click", "tests/typing"]77typeCheckingMode = "basic"7879[tool.ruff]80extend-exclude = ["examples/"]81src = ["src"]82fix = true83show-fixes = true84output-format = "full"8586[tool.ruff.lint]87select = [88 "B", # flake8-bugbear89 "E", # pycodestyle error90 "F", # pyflakes91 "I", # isort92 "UP", # pyupgrade93 "W", # pycodestyle warning94]95ignore-init-module-imports = true9697[tool.ruff.lint.isort]98force-single-line = true99order-by-type = false
added:README.md+52 added
1# $ click_23Click is a Python package for creating beautiful command line interfaces4in a composable way with as little code as necessary. It's the "Command5Line Interface Creation Kit". It's highly configurable but comes with6sensible defaults out of the box.78It aims to make the process of writing command line tools quick and fun9while also preventing any frustration caused by the inability to10implement an intended CLI API.1112Click in three points:1314- Arbitrary nesting of commands15- Automatic help page generation16- Supports lazy loading of subcommands at runtime171819## A Simple Example2021```python22import click2324@click.command()25@click.option("--count", default=1, help="Number of greetings.")26@click.option("--name", prompt="Your name", help="The person to greet.")27def hello(count, name):28 """Simple program that greets NAME for a total of COUNT times."""29 for _ in range(count):30 click.echo(f"Hello, {name}!")3132if __name__ == '__main__':33 hello()34```3536```37$ python hello.py --count=338Your name: Click39Hello, Click!40Hello, Click!41Hello, Click!42```434445## Donate4647The Pallets organization develops and supports Click and other popular48packages. In order to grow the community of contributors and users, and49allow the maintainers to devote more time to the projects, [please50donate today][].5152[please donate today]: https://palletsprojects.com/donate
deleted:README.rst-78 removed
1\$ click\_2==========34Click is a Python package for creating beautiful command line interfaces5in a composable way with as little code as necessary. It's the "Command6Line Interface Creation Kit". It's highly configurable but comes with7sensible defaults out of the box.89It aims to make the process of writing command line tools quick and fun10while also preventing any frustration caused by the inability to11implement an intended CLI API.1213Click in three points:1415- Arbitrary nesting of commands16- Automatic help page generation17- Supports lazy loading of subcommands at runtime181920Installing21----------2223Install and update using `pip`_:2425.. code-block:: text2627 $ pip install -U click2829.. _pip: https://pip.pypa.io/en/stable/getting-started/303132A Simple Example33----------------3435.. code-block:: python3637 import click3839 @click.command()40 @click.option("--count", default=1, help="Number of greetings.")41 @click.option("--name", prompt="Your name", help="The person to greet.")42 def hello(count, name):43 """Simple program that greets NAME for a total of COUNT times."""44 for _ in range(count):45 click.echo(f"Hello, {name}!")4647 if __name__ == '__main__':48 hello()4950.. code-block:: text5152 $ python hello.py --count=353 Your name: Click54 Hello, Click!55 Hello, Click!56 Hello, Click!575859Donate60------6162The Pallets organization develops and supports Click and other popular63packages. In order to grow the community of contributors and users, and64allow the maintainers to devote more time to the projects, `please65donate today`_.6667.. _please donate today: https://palletsprojects.com/donate686970Links71-----7273- Documentation: https://click.palletsprojects.com/74- Changes: https://click.palletsprojects.com/changes/75- PyPI Releases: https://pypi.org/project/click/76- Source Code: https://github.com/pallets/click77- Issue Tracker: https://github.com/pallets/click/issues78- Chat: https://discord.gg/pallets
deleted:setup.cfg-104 removed
1[metadata]2name = click3version = attr: click.__version__4url = https://palletsprojects.com/p/click/5project_urls =6 Donate = https://palletsprojects.com/donate7 Documentation = https://click.palletsprojects.com/8 Changes = https://click.palletsprojects.com/changes/9 Source Code = https://github.com/pallets/click/10 Issue Tracker = https://github.com/pallets/click/issues/11 Chat = https://discord.gg/pallets12license = BSD-3-Clause13license_files = LICENSE.rst14maintainer = Pallets15maintainer_email = contact@palletsprojects.com16description = Composable command line interface toolkit17long_description = file: README.rst18long_description_content_type = text/x-rst19classifiers =20 Development Status :: 5 - Production/Stable21 Intended Audience :: Developers22 License :: OSI Approved :: BSD License23 Operating System :: OS Independent24 Programming Language :: Python2526[options]27packages = find:28package_dir = = src29include_package_data = True30python_requires = >= 3.731# Dependencies are in setup.py for GitHub's dependency graph.3233[options.packages.find]34where = src3536[tool:pytest]37testpaths = tests38filterwarnings =39 error4041[coverage:run]42branch = True43source =44 click45 tests4647[coverage:paths]48source =49 src50 */site-packages5152[flake8]53# B = bugbear54# E = pycodestyle errors55# F = flake8 pyflakes56# W = pycodestyle warnings57# B9 = bugbear opinions58# ISC = implicit str concat59select = B, E, F, W, B9, ISC60ignore =61 # slice notation whitespace, invalid62 E20363 # line length, handled by bugbear B95064 E50165 # bare except, handled by bugbear B00166 E72267 # bin op line break, invalid68 W50369 # zip with strict=, requires python >= 3.1070 B90571 # string formatting opinion, B028 renamed to B90772 B02873 B90774# up to 88 allowed by bugbear B95075max-line-length = 8076per-file-ignores =77 # __init__ exports names78 src/click/__init__.py: F4017980[mypy]81files = src/click, tests/typing82python_version = 3.783show_error_codes = True84disallow_subclassing_any = True85disallow_untyped_calls = True86disallow_untyped_defs = True87disallow_incomplete_defs = True88disallow_any_generics = True89check_untyped_defs = True90no_implicit_optional = True91local_partial_types = True92no_implicit_reexport = True93strict_equality = True94warn_redundant_casts = True95warn_unused_configs = True96warn_unused_ignores = True97warn_return_any = True98warn_unreachable = True99100[mypy-colorama.*]101ignore_missing_imports = True102103[mypy-importlib_metadata.*]104ignore_missing_imports = True
deleted:setup.py-9 removed
1from setuptools import setup23setup(4 name="click",5 install_requires=[6 "colorama; platform_system == 'Windows'",7 "importlib-metadata; python_version < '3.8'",8 ],9)
modified:tox.ini+18 added-2 removed
8 unmodified lines
910[testenv]11package = wheel12wheel_build_env = .pkg13constrain_package_deps = true14use_frozen_constraints = true15deps = -r requirements/tests.txt16commands = pytest -v --tb=short --basetemp={envtmpdir} {posargs}1718[testenv:style]
4 unmodified lines
23[testenv:typing]24deps = -r requirements/typing.txt25commands =26 mypy25 pyright --verifytypes click27 pyright tests/typing28 pyright --verifytypes click --ignoreexternal2930[testenv:docs]31deps = -r requirements/docs.txt30commands = sphinx-build -W -b html -d {envtmpdir}/doctrees docs {envtmpdir}/html32commands = sphinx-build -E -W -b dirhtml docs docs/_build/dirhtml3334[testenv:update-requirements]35deps =36 pip-tools37 pre-commit38skip_install = true39change_dir = requirements40commands =41 pre-commit autoupdate -j442 pip-compile -U build.in43 pip-compile -U docs.in44 pip-compile -U tests.in45 pip-compile -U typing.in46 pip-compile -U dev.in