Skip to content

Commit c0bb4bb

Browse files
chore: remove collection type doc and sort
1 parent 4fc726c commit c0bb4bb

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

cmd2/annotated.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,13 +495,13 @@ def _resolve_enum(tp: Any, _args: tuple[Any, ...], **_ctx: Any) -> dict[str, Any
495495
Path: _resolve_path,
496496
# Exact-match entries (order among these doesn't affect subclass lookup).
497497
bool: _resolve_bool,
498-
int: _make_simple_resolver(int),
499-
float: _make_simple_resolver(float),
500498
decimal.Decimal: _make_simple_resolver(decimal.Decimal),
499+
float: _make_simple_resolver(float),
500+
int: _make_simple_resolver(int),
501+
Literal: _resolve_literal,
501502
list: _make_collection_resolver(list),
502503
set: _make_collection_resolver(set),
503504
tuple: _resolve_tuple,
504-
Literal: _resolve_literal,
505505
}
506506

507507

docs/features/annotated.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,25 @@ them as keyword arguments.
7878

7979
The decorator converts Python type annotations into `add_argument()` calls:
8080

81-
| Type annotation | Generated argparse setting |
82-
| -------------------------------------------------------- | ---------------------------------------------------------- |
83-
| `str` | default (no `type=` needed) |
84-
| `int`, `float` | `type=int` or `type=float` |
85-
| `bool` with a default | boolean optional flag via `BooleanOptionalAction` |
86-
| positional `bool` | parsed from `true/false`, `yes/no`, `on/off`, `1/0` |
87-
| `Path` | `type=Path` |
88-
| `Enum` subclass | `type=converter`, `choices` from member values |
89-
| `decimal.Decimal` | `type=decimal.Decimal` |
90-
| `Literal[...]` | `type=literal-converter`, `choices` from values |
91-
| `Collection[T]` / `list[T]` / `set[T]` / `tuple[T, ...]` | `nargs='+'` (or `'*'` if it has a default or is `\| None`) |
92-
| `tuple[T, T]` | fixed `nargs=N` with `type=T` |
93-
| `T \| None` (no default) | positional with `nargs='?'` (accepts 0-or-1 tokens) |
94-
| `T \| None = None` | `--flag` option with `default=None` |
81+
| Type annotation | Generated argparse setting |
82+
| -------------------------------------- | ---------------------------------------------------------- |
83+
| `str` | default (no `type=` needed) |
84+
| `int`, `float` | `type=int` or `type=float` |
85+
| `bool` with a default | boolean optional flag via `BooleanOptionalAction` |
86+
| positional `bool` | parsed from `true/false`, `yes/no`, `on/off`, `1/0` |
87+
| `Path` | `type=Path` |
88+
| `Enum` subclass | `type=converter`, `choices` from member values |
89+
| `decimal.Decimal` | `type=decimal.Decimal` |
90+
| `Literal[...]` | `type=literal-converter`, `choices` from values |
91+
| `list[T]` / `set[T]` / `tuple[T, ...]` | `nargs='+'` (or `'*'` if it has a default or is `\| None`) |
92+
| `tuple[T, T]` | fixed `nargs=N` with `type=T` |
93+
| `T \| None` (no default) | positional with `nargs='?'` (accepts 0-or-1 tokens) |
94+
| `T \| None = None` | `--flag` option with `default=None` |
9595

9696
When collection types are used with `@with_annotated`, parsed values are passed to the command
9797
function as:
9898

99-
- `list[T]` and `Collection[T]` as `list`
99+
- `list[T]` as `list`
100100
- `set[T]` as `set`
101101
- `tuple[T, ...]` as `tuple`
102102

0 commit comments

Comments
 (0)