Skip to content

Commit 094223d

Browse files
committed
Updated comments.
1 parent 584fbdf commit 094223d

3 files changed

Lines changed: 6 additions & 8 deletions

File tree

cmd2/decorators.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Decorators for ``cmd2`` commands."""
22

33
import argparse
4+
import functools
45
from collections.abc import (
56
Callable,
67
Sequence,
@@ -33,7 +34,7 @@
3334
def with_category(
3435
category: str,
3536
) -> Callable[[UnboundCommandFunc[CmdOrSetT, P]], UnboundCommandFunc[CmdOrSetT, P]]:
36-
"""Decorate a ``do_*`` command method to apply a category.
37+
"""Decorate a ``do_*`` command function to apply a category.
3738
3839
:param category: the name of the category in which this command should
3940
be grouped when displaying the list of commands.
@@ -159,7 +160,6 @@ def do_print_raw(self, arglist: list[str]):
159160
```
160161
161162
"""
162-
import functools
163163

164164
def arg_decorator(func: ArgListCommandFunc[CmdOrSetT]) -> RawCommandFunc[CmdOrSetT]:
165165
"""Decorate function that ingests an Argument List function and returns a raw command function.
@@ -212,7 +212,7 @@ def with_argparser(
212212
preserve_quotes: bool = False,
213213
with_unknown_args: bool = False,
214214
) -> Callable[[ArgparseCommandFunc[CmdOrSetT]], RawCommandFunc[CmdOrSetT]]:
215-
"""Decorate a ``do_*`` method to populate its ``args`` argument with the given instance of Cmd2ArgumentParser.
215+
"""Decorate a ``do_*`` command function to populate its ``args`` argument with a Cmd2ArgumentParser.
216216
217217
:param parser: instance of Cmd2ArgumentParser or a callable that returns a Cmd2ArgumentParser for this command
218218
:param ns_provider: An optional function that accepts a cmd2.Cmd or cmd2.CommandSet object as an argument and returns an
@@ -257,7 +257,6 @@ def do_argprint(self, args, unknown):
257257
```
258258
259259
"""
260-
import functools
261260

262261
def arg_decorator(func: ArgparseCommandFunc[CmdOrSetT]) -> RawCommandFunc[CmdOrSetT]:
263262
"""Decorate function that ingests an Argparse Command Function and returns a raw command function.
@@ -343,7 +342,7 @@ def as_subcommand_to(
343342
aliases: Sequence[str] | None = None,
344343
**add_parser_kwargs: Any,
345344
) -> Callable[[ArgparseCommandFunc[CmdOrSetT]], ArgparseCommandFunc[CmdOrSetT]]:
346-
"""Tag this method as a subcommand to an existing argparse decorated command.
345+
"""Tag this function as a subcommand to an existing argparse decorated command.
347346
348347
:param command: Command Name. Space-delimited subcommands may optionally be specified
349348
:param subcommand: Subcommand name

cmd2/types.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from .command_set import CommandSet
2121
from .completion import Choices, Completions
2222

23-
# TypeVar for function parameters
2423
P = ParamSpec("P")
2524

2625

cmd2/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
else:
4141
PopenTextIO = subprocess.Popen
4242

43-
_T = TypeVar('_T')
43+
T = TypeVar('T')
4444

4545

4646
def to_bool(val: Any) -> bool:
@@ -186,7 +186,7 @@ def is_text_file(file_path: str) -> bool:
186186
return valid_text_file
187187

188188

189-
def remove_duplicates(items: Iterable[_T]) -> list[_T]:
189+
def remove_duplicates(items: Iterable[T]) -> list[T]:
190190
"""Remove duplicates from an iterable while preserving order of the items.
191191
192192
:param items: the items being pruned of duplicates

0 commit comments

Comments
 (0)