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 (fixes #203) #211

Merged
merged 21 commits into from
Dec 30, 2023

Conversation

neithere
Copy link
Owner

@neithere neithere commented Nov 5, 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)
  • docs with examples (tutorial / cookbook)

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="+")]

Also drop argh.utils.get_arg_spec().  It is no longer needed because
while getfullargspec() did not handle decorated functions properly,
signature() does.

A backwards incompatible change (an extremely rare edge case)
is documented in the changelog.
@neithere neithere added this to the 0.31 milestone Nov 5, 2023
@neithere neithere self-assigned this Nov 5, 2023
@neithere neithere merged commit 6180ca9 into release/v0.31.0 Dec 30, 2023
8 checks passed
@neithere neithere deleted the 203_basic_type_hints branch December 30, 2023 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant