Skip to content

Commit b7d3b05

Browse files
committed
Designed the @with_annotated feature as stabilized in the CHANGELOG and docs
Also: - Prepare for 4.3.0 release
1 parent ce132b4 commit b7d3b05

6 files changed

Lines changed: 17 additions & 41 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
## 4.3.0 (TBD)
2-
1+
## 4.3.0 (October 13, 2026)
2+
3+
- Stabilized features
4+
- `@with_annotated` is no longer experimental. It was introduced as an experimental feature in
5+
4.0.0 and is now a fully supported way to define a command's arguments, alongside
6+
`@with_argparser`. This covers the decorator and its supporting API in `cmd2.annotated`,
7+
including `Argument`, `Option`, `Group`, and `ArgumentBlock`.
8+
[Annotated Argument Processing](https://cmd2.readthedocs.io/en/latest/features/annotated/).
39
- Bug Fixes
410
- On POSIX, piping a command's output to an interactive program such as `less`
511
(`help -v | less`) now runs that program as the terminal's foreground job, as a shell pipeline

‎CLAUDE.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ Three layers, all producing a `Cmd2ArgumentParser`:
7171
range `nargs` tuples, per-argument completion metadata, and subcommand records.
7272
- `cmd2/decorators.py` — `@with_argparser`, `@with_argument_list`, `@with_category`,
7373
`@as_subcommand_to` attach parsers/metadata to `do_*` methods.
74-
- `cmd2/annotated.py` — the newer, still-experimental Typer-style path: `@with_annotated` builds a
75-
parser from a function's type hints, with `Argument`/`Option` metadata via `typing.Annotated`.
74+
- `cmd2/annotated.py` — the newer Typer-style path (experimental in 4.0.0, stable as of 4.3.0):
75+
`@with_annotated` builds a parser from a function's type hints, with `Argument`/`Option` metadata
76+
via `typing.Annotated`.
7677

7778
Parsers are built lazily and cached by the `CommandParsers` class in `cmd2.py` (`_build_parser`), so
7879
that `CommandSet`-supplied subcommands can be attached and detached at runtime.

‎README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ to build a more complete application.
8989

9090
- Define commands as Python methods and use familiar
9191
[`argparse`](https://cmd2.readthedocs.io/en/latest/features/argument_processing/) parsers for
92-
arguments and subcommands. A single parser definition drives validation, help, and completion.
92+
arguments and subcommands, or plain type hints via
93+
[`@with_annotated`](https://cmd2.readthedocs.io/en/latest/features/annotated/). A single parser
94+
definition drives validation, help, and completion.
9395
- Render Rich tables and other styled objects, with consistent helpers for
9496
[normal output, errors, warnings, and paging](https://cmd2.readthedocs.io/en/latest/features/generating_output/).
9597
- Organize large applications into independently testable and dynamically loadable

‎cmd2/annotated.py‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
"""Build argparse parsers from type-annotated function signatures.
22
3-
!!! warning "Experimental"
4-
5-
This module is experimental and its behavior may change in future releases.
6-
73
The [`with_annotated`][cmd2.annotated.with_annotated] decorator inspects a command function's type hints and
84
default values to build a ``Cmd2ArgumentParser``. [`Argument`][cmd2.annotated.Argument] and
95
[`Option`][cmd2.annotated.Option] metadata classes give finer per-parameter control via

‎docs/features/annotated.md‎

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
# Annotated Argument Processing
22

3-
!!! warning "Experimental"
4-
5-
The `@with_annotated` decorator and its supporting `Argument` / `Option` metadata classes are
6-
**experimental**. The public API, the surface of accepted type annotations, and the generated
7-
argparse behavior may all change in future releases without a deprecation cycle. Pin a specific
8-
`cmd2` version if you depend on the exact current semantics, and expect to revisit your usage on
9-
upgrades.
10-
11-
For production code that needs stable behavior, use
12-
[@with_argparser](argument_processing.md#with_argparser-decorator) instead.
13-
143
The [@with_annotated][cmd2.with_annotated] decorator builds an argparse parser automatically from
154
the decorated function's type annotations. No manual `add_argument()` calls are required, and the
165
command body receives typed keyword arguments directly instead of an `argparse.Namespace`.
@@ -45,9 +34,8 @@ The two decorators are interchangeable -- here is the same command written both
4534

4635
The annotated version is more concise, gives you typed parameters, and supports several advanced
4736
cmd2 features directly, including `ns_provider`, `with_unknown_args`, and typed subcommands. Pick
48-
`@with_argparser` when you need a stable, well-established API or fine-grained control over the
49-
parser; pick `@with_annotated` when you want type-hint-driven ergonomics and can accept the
50-
experimental status.
37+
`@with_argparser` when you want direct control over the parser or already have one; pick
38+
`@with_annotated` when you want type-hint-driven ergonomics.
5139

5240
## Basic usage
5341

@@ -815,16 +803,3 @@ Specifically:
815803

816804
With `@with_argparser`, provide `choices`, `choices_provider`, or `completer` explicitly when you
817805
want completion behavior.
818-
819-
## Stability and feedback
820-
821-
Because this feature is experimental:
822-
823-
- Behavior of edge cases (mixed-type tuples, deeply-nested `Annotated`, conflicting metadata) may
824-
change.
825-
- Diagnostic error messages may be reworded.
826-
- The set of supported type annotations may be expanded or trimmed.
827-
828-
If you depend on `@with_annotated`, please share feedback and edge cases via the
829-
[issue tracker](https://github.com/python-cmd2/cmd2/issues) so behavior can be locked in before the
830-
feature graduates out of experimental.

‎docs/features/argument_processing.md‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,10 @@ stores internally. A consequence is that parsers don't need to be unique across
5757

5858
## with_annotated decorator
5959

60-
!!! warning "Experimental"
61-
62-
The `@with_annotated` decorator is **experimental** and its API may change in future releases.
63-
6460
The [@with_annotated][cmd2.with_annotated] decorator builds an argparse parser automatically from
6561
the decorated function's type annotations -- no manual `add_argument()` calls required. See
6662
[Annotated Argument Processing](annotated.md) for the full reference, including type mapping,
67-
metadata classes, subcommands, and stability caveats.
63+
metadata classes, and subcommands.
6864

6965
## Argument Parsing
7066

0 commit comments

Comments
 (0)