Skip to content

Commit 0432ba2

Browse files
chore: fix test
1 parent e80427b commit 0432ba2

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

cmd2/decorators.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ def team_create(self, name: str): ...
394394
build_parser_from_function,
395395
build_subcommand_handler,
396396
)
397-
from .argparse_custom import Cmd2AttributeWrapper
398397

399398
if (help is not None or aliases is not None) and subcommand_to is None:
400399
raise TypeError("'help' and 'aliases' are only valid with subcommand_to")
@@ -487,13 +486,11 @@ def cmd_wrapper(*args: Any, **kwargs: Any) -> bool | None:
487486
except SystemExit as exc:
488487
raise Cmd2ArgparseError from exc
489488

490-
ns.cmd2_statement = Cmd2AttributeWrapper(statement)
489+
setattr(ns, constants.NS_ATTR_STATEMENT, statement)
491490
handler = getattr(ns, constants.NS_ATTR_SUBCMD_HANDLER, None)
492491
if base_command and handler is not None:
493492
handler = functools.partial(handler, ns)
494-
ns.cmd2_handler = Cmd2AttributeWrapper(handler)
495-
if hasattr(ns, constants.NS_ATTR_SUBCMD_HANDLER):
496-
delattr(ns, constants.NS_ATTR_SUBCMD_HANDLER)
493+
ns.cmd2_handler = handler
497494

498495
func_kwargs = _filtered_namespace_kwargs(ns, accepted=accepted, exclude_subcommand=base_command)
499496

docs/features/argument_processing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def do_rawish(self, name: str, _unknown: list[str] | None = None):
217217
```py
218218
@with_annotated(base_command=True)
219219
def do_manage(self, *, cmd2_handler):
220-
handler = cmd2_handler.get()
220+
handler = cmd2_handler
221221
if handler:
222222
handler()
223223

@@ -233,7 +233,7 @@ creates its own subparsers:
233233
```py
234234
@with_annotated(subcommand_to="manage", base_command=True, help="manage projects")
235235
def manage_project(self, *, cmd2_handler):
236-
handler = cmd2_handler.get()
236+
handler = cmd2_handler
237237
if handler:
238238
handler()
239239

tests/test_annotated.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ def do_manage(self, cmd2_handler, verbose: bool = False) -> None:
12041204
"""Management command with subcommands."""
12051205
if verbose:
12061206
self.poutput("verbose mode")
1207-
handler = cmd2_handler.get()
1207+
handler = cmd2_handler
12081208
if handler:
12091209
handler()
12101210

@@ -1220,7 +1220,7 @@ def manage_list(self) -> None:
12201220
# Level 2: intermediate subcommand (also a base for level 3)
12211221
@cmd2.with_annotated(subcommand_to='manage', base_command=True, help='manage members')
12221222
def manage_member(self, cmd2_handler) -> None:
1223-
handler = cmd2_handler.get()
1223+
handler = cmd2_handler
12241224
if handler:
12251225
handler()
12261226

@@ -1328,7 +1328,7 @@ def test_subcommand_with_mutually_exclusive_groups(self) -> None:
13281328
class App(cmd2.Cmd):
13291329
@cmd2.with_annotated(base_command=True)
13301330
def do_fmt(self, cmd2_handler) -> None:
1331-
handler = cmd2_handler.get()
1331+
handler = cmd2_handler
13321332
if handler:
13331333
handler()
13341334

0 commit comments

Comments
 (0)