Title: Use `with_annotated` decorator with custom types for allow easy type conversion · Issue #1688 · python-cmd2/cmd2 · GitHub
Open Graph Title: Use `with_annotated` decorator with custom types for allow easy type conversion · Issue #1688 · python-cmd2/cmd2
X Title: Use `with_annotated` decorator with custom types for allow easy type conversion · Issue #1688 · python-cmd2/cmd2
Description: Feature Request When using the argparse approach (with_argparse decorator), the type argument of add_argument can be used for non-basic type conversion (see for example). The same is not possible when using the with_annotated decorator. ...
Open Graph Description: Feature Request When using the argparse approach (with_argparse decorator), the type argument of add_argument can be used for non-basic type conversion (see for example). The same is not possible w...
X Description: Feature Request When using the argparse approach (with_argparse decorator), the type argument of add_argument can be used for non-basic type conversion (see for example). The same is not possible w...
Opengraph URL: https://github.com/python-cmd2/cmd2/issues/1688
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Use `with_annotated` decorator with custom types for allow easy type conversion","articleBody":"# Feature Request\n\nWhen using the `argparse` approach (`with_argparse` decorator), the `type` argument of `add_argument` can be used for non-basic type conversion (see for [example](https://github.com/python-cmd2/cmd2/blob/main/examples/custom_types.py)). The same is not possible when using the `with_annotated` decorator.\n\n## Possible design for a solution\n\nEither allow custom types (as `Typer` does — see [custom types](https://typer.tiangolo.com/tutorial/parameter-types/custom-types/)) and make a best-effort type conversion for arbitrary annotations, or add an additional parameter to `Option` and `Argument` (for example `conversion`) that enables a two-step type conversion approach.","author":{"url":"https://github.com/neoniobium","@type":"Person","name":"neoniobium"},"datePublished":"2026-06-10T14:40:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/1688/cmd2/issues/1688"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7683566d-2011-44c7-0f92-906cd933e8b0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EAAE:2D8184:37F1ED:51584C:6A4E0435 |
| html-safe-nonce | 6fc0d40f71c0f098f865362d1a40a2619672cf6c889bde8c7365eae553fc78af |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQUFFOjJEODE4NDozN0YxRUQ6NTE1ODRDOjZBNEUwNDM1IiwidmlzaXRvcl9pZCI6IjkyMDA5NTYxNDkwNTM5MTYyMTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4b0c590077269fd810557ebbbb61cd169a88c42ef9e15b72e57910e1c09f1e1f |
| hovercard-subject-tag | issue:4632275325 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-cmd2/cmd2/1688/issue_layout |
| twitter:image | https://opengraph.githubassets.com/25b9da195fb36871c07777cc62b6d92d2cb3fd8f04d8d5cff9e47267d6551066/python-cmd2/cmd2/issues/1688 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/25b9da195fb36871c07777cc62b6d92d2cb3fd8f04d8d5cff9e47267d6551066/python-cmd2/cmd2/issues/1688 |
| og:image:alt | Feature Request When using the argparse approach (with_argparse decorator), the type argument of add_argument can be used for non-basic type conversion (see for example). The same is not possible w... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | neoniobium |
| hostname | github.com |
| expected-hostname | github.com |
| None | df0492960db29b4938cb72070351d6b1d0c6c0767b27ceb8394bbf4fcc0223c6 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-cmd2/cmd2 git https://github.com/python-cmd2/cmd2.git |
| octolytics-dimension-user_id | 17161025 |
| octolytics-dimension-user_login | python-cmd2 |
| octolytics-dimension-repository_id | 51442999 |
| octolytics-dimension-repository_nwo | python-cmd2/cmd2 |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 51442999 |
| octolytics-dimension-repository_network_root_nwo | python-cmd2/cmd2 |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 52bde38e24398476f8eb1e0760c81346c6a00812 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width