Skip to content

Commit bed6a3f

Browse files
committed
Update docs and fix type hints.
1 parent 48ede8b commit bed6a3f

File tree

4 files changed

+34
-20
lines changed

4 files changed

+34
-20
lines changed

consolekit/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,15 @@
7979
"""
8080
Shortcut to :func:`click.option`, but using :func:`consolekit.input.confirm` when prompting for a boolean flag.
8181
"""
82+
83+
# Fixes intersphinx links
84+
click.Command.__module__ = "click"
85+
click.Argument.__module__ = "click"
86+
click.Abort.__module__ = "click"
87+
click.Option.__module__ = "click"
88+
click.ParamType.__module__ = "click"
89+
click.Parameter.__module__ = "click"
90+
click.Context.__module__ = "click"
91+
click.HelpFormatter.__module__ = "click"
92+
click.Group.__module__ = "click"
93+
click.OptionParser.__module__ = "click"

consolekit/input.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ def prompt(
125125
"""
126126
Prompts a user for input.
127127
128-
If the user aborts the input by sending an interrupt signal, this
129-
function will catch it and raise a :exc:`click.exceptions.Abort` exception.
128+
If the user aborts the input by sending an interrupt signal,
129+
this function will catch it and raise a :exc:`click.Abort` exception.
130130
131131
:param text: The text to show for the prompt.
132132
:param default: The default value to use if no input happens.
@@ -209,11 +209,11 @@ def confirm(
209209
Prompts for confirmation (yes/no question).
210210
211211
If the user aborts the input by sending a interrupt signal this
212-
function will catch it and raise a :exc:`Abort` exception.
212+
function will catch it and raise a :exc:`click.Abort` exception.
213213
214214
:param text: The question to ask.
215215
:param default: The default for the prompt.
216-
:param abort: If :py:obj:`True` a negative answer aborts the exception by raising :exc:`Abort`.
216+
:param abort: If :py:obj:`True` a negative answer aborts the exception by raising :exc:`click.Abort`.
217217
:param prompt_suffix: A suffix that should be added to the prompt.
218218
:param show_default: Shows or hides the default value in the prompt.
219219
:param err: If :py:obj:`True` the file defaults to ``stderr`` instead of ``stdout``, the same as with echo.
@@ -342,7 +342,7 @@ def choice(
342342
Prompts a user for input.
343343
344344
If the user aborts the input by sending an interrupt signal, this
345-
function will catch it and raise a :exc:`click.exceptions.Abort` exception.
345+
function will catch it and raise a :exc:`click.Abort` exception.
346346
347347
:param options:
348348
:param text: The text to show for the prompt.
@@ -402,7 +402,7 @@ def hide_cursor() -> None:
402402
Hide the cursor.
403403
404404
To show it again use :func:`~.show_cursor`,
405-
or use the :func:`@.hidden_cursor` context manager.
405+
or use the :func:`~.hidden_cursor` context manager.
406406
407407
.. versionadded:: 0.7.0
408408
"""

consolekit/options.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464

6565
# 3rd party
6666
import click
67-
from click import Argument, Context, IntRange, Option, OptionParser
67+
from click import Argument, Context, Option, OptionParser
6868
from click.decorators import _param_memo # type: ignore
6969

7070
# this package
@@ -81,6 +81,8 @@
8181
"flag_option",
8282
"auto_default_option",
8383
"auto_default_argument",
84+
"_A",
85+
"_C",
8486
]
8587

8688
_A = TypeVar("_A", bound=click.Argument)
@@ -105,7 +107,7 @@ def _describe_range(self):
105107
return ''
106108

107109

108-
def verbose_option(help_text: str = "Show verbose output.") -> Callable[..., click.Command]:
110+
def verbose_option(help_text: str = "Show verbose output.") -> Callable[[_C], _C]:
109111
"""
110112
Adds an option (via the parameter ``verbose``: :class:`int`) to enable verbose output.
111113
@@ -119,7 +121,7 @@ def verbose_option(help_text: str = "Show verbose output.") -> Callable[..., cli
119121
return click.option("-v", "--verbose", count=True, help=help_text, type=VerboseVersionCountType())
120122

121123

122-
def version_option(callback: Callable[[Context, Option, int], Any]) -> Callable[..., click.Command]:
124+
def version_option(callback: Callable[[Context, Option, int], Any]) -> Callable[[_C], _C]:
123125
"""
124126
Adds an option to show the version and exit.
125127
@@ -158,7 +160,7 @@ def version_callback(ctx: click.Context, param: click.Option, value: int):
158160
)
159161

160162

161-
def colour_option(help_text="Whether to use coloured output.") -> Callable[..., click.Command]:
163+
def colour_option(help_text="Whether to use coloured output.") -> Callable[[_C], _C]:
162164
"""
163165
Adds an option (via the parameter ``colour``: :class:`bool`) to enable verbose output.
164166
@@ -174,7 +176,7 @@ def colour_option(help_text="Whether to use coloured output.") -> Callable[...,
174176
)
175177

176178

177-
def force_option(help_text: str) -> Callable[..., click.Command]:
179+
def force_option(help_text: str) -> Callable[[_C], _C]:
178180
"""
179181
Decorator to add the ``-f / --force`` option to a click command.
180182
@@ -188,7 +190,7 @@ def force_option(help_text: str) -> Callable[..., click.Command]:
188190
return flag_option("-f", "--force", help=help_text)
189191

190192

191-
def no_pager_option(help_text="Disable the output pager.") -> Callable[..., click.Command]:
193+
def no_pager_option(help_text="Disable the output pager.") -> Callable[[_C], _C]:
192194
"""
193195
Decorator to add the ``--no-pager`` option to a click command.
194196
@@ -202,7 +204,7 @@ def no_pager_option(help_text="Disable the output pager.") -> Callable[..., clic
202204
return flag_option("--no-pager", help=help_text)
203205

204206

205-
def flag_option(*args, default: Optional[bool] = False, **kwargs) -> Callable[..., click.Command]:
207+
def flag_option(*args, default: Optional[bool] = False, **kwargs) -> Callable[[_C], _C]:
206208
r"""
207209
Decorator to a flag option to a click command.
208210
@@ -221,7 +223,7 @@ def flag_option(*args, default: Optional[bool] = False, **kwargs) -> Callable[..
221223
)
222224

223225

224-
def auto_default_option(*param_decls, **attrs) -> Callable[..., click.Command]:
226+
def auto_default_option(*param_decls, **attrs) -> Callable[[_C], _C]:
225227
"""
226228
Attaches an option to the command, with a default value determined from the decorated function's signature.
227229
@@ -264,14 +266,14 @@ def _get_default_from_callback_and_set(command: click.Command, param: click.Para
264266
param.default = param_default
265267

266268

267-
def auto_default_argument(*param_decls, **attrs) -> Callable[..., click.Argument]:
269+
def auto_default_argument(*param_decls, **attrs) -> Callable[[_C], _C]:
268270
"""
269271
Attaches an argument to the command, with a default value determined from the decorated function's signature.
270272
271273
All positional arguments are passed as parameter declarations to :class:`click.Argument`;
272274
all keyword arguments are forwarded unchanged (except ``cls``).
273275
This is equivalent to creating an :class:`click.Argument` instance manually
274-
and attaching it to the :attr:`click.Argument.params` list.
276+
and attaching it to the :attr:`click.Command.params` list.
275277
276278
.. versionadded:: 0.8.0
277279

consolekit/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def overtype(*objects, sep: str = ' ', end: str = '', file: IO = None, flush: bo
119119
All non-keyword arguments are converted to strings like :class:`str` does and written to the stream,
120120
separated by `sep` and followed by `end`.
121121
122-
If no objects are given, :func:`~consolekit.terminal.overtype` will just write ``"\\r"``.
122+
If no objects are given, :func:`~consolekit.utils.overtype` will just write ``"\\r"``.
123123
124124
.. TODO:: This does not currently work in the PyCharm console, at least on Windows
125125
@@ -218,14 +218,14 @@ def coloured_diff(
218218

219219
solidus_spinner = cycle("|/-\\")
220220
"""
221-
:class:`itertools.cycle` of characters to use as a loading spinner.
221+
:func:`itertools.cycle` of characters to use as a loading spinner.
222222
223223
.. versionadded:: 0.7.0
224224
"""
225225

226226
braille_spinner = cycle("⢿ ⣻ ⣽ ⣾ ⣷ ⣯ ⣟ ⡿ ".split(' '))
227227
"""
228-
:class:`itertools.cycle` of braille characters to use as a loading spinner.
228+
:func:`itertools.cycle` of braille characters to use as a loading spinner.
229229
230230
.. versionadded:: 0.7.0
231231
"""
@@ -277,7 +277,7 @@ def traceback_handler():
277277
278278
* :exc:`EOFError`
279279
* :exc:`KeyboardInterrupt`
280-
* :exc:`click.exceptions.ClickException`
280+
* :exc:`click.ClickException`
281281
282282
.. versionadded:: 0.8.0
283283

0 commit comments

Comments
 (0)