Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type hints: basic usage to infer argument types #203

Closed
neithere opened this issue Oct 22, 2023 · 2 comments
Closed

Type hints: basic usage to infer argument types #203

neithere opened this issue Oct 22, 2023 · 2 comments
Milestone

Comments

@neithere
Copy link
Owner

Look at #107 and see what can be implemented quickly.

@neithere neithere added this to the 0.31 milestone Oct 22, 2023
@neithere
Copy link
Owner Author

neithere commented Oct 22, 2023

MVP:

  • add support for str, int, float (and their deprecated aliases: Str, etc. until we drop support for Python 3.8 around Q4 2024)
  • deprecate or just drop support for the old mechanism (if possible, move it to a policy, like with name mapping).

Nice to have:

  • nargs=ZERO_OR_MORE:
    • list[str]nargs=ZERO_OR_MORE, type=str
      • (same for list[str] | None, list[str | None] and list[str | None] | None — there's no difference for us in the context of mapping).
  • nargs=N
  • Choices:
  • Passing add_argument() params via hints instead of @arg:
    • Annotated[x, ExtraParams(type=some_callable, help="something", nargs="+")]

@neithere
Copy link
Owner Author

Not doing the following:

  • Tuple[T, ...] — not sure how to support mixed nested types, AFAIK argparse only allows one type. Maybe limit to uniform? But that also needs to be validated, etc.
  • Annotated[T, ...] — definitely must have, but Annotated was introduced in Python 3.9, so using it will require dropping support for Python 3.8. While we don't need to wait until EOY 2024 with this, it's good to at least ship whatever works before cutting support for the sake of an enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant