-
Notifications
You must be signed in to change notification settings - Fork 11
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
feature request: support positional argument of type Sequence in additional to *args #96
Comments
Thanks for the suggestion. Let's keep the discussion in #95 for now, as I think the two requests share some points. |
? I think they are completely different issue? This one is about how positional |
I read your comments in #95 and now I understand you're proposing using a similar solution to tackle 2 different issues. |
Copied from #95:
|
Sorry, giving up for now. I don't seem to understand the design of defopt. For example, #!/usr/bin/env python
from typing import Annotated
from inspect import Parameter
import defopt
def main(args: Annotated[list[str], Parameter.VAR_POSITIONAL]):
pass
if __name__ == "__main__":
defopt.run(main) In param.annotation == typing.List[str]
getattr(param.annotation, "__metadata__", []) == [] It doesn't seem to be able to get the Annotated types and its metadata. |
Right now there is no support for Annotated at all, the suggestion is also to add such support. |
MWE
resulted in
Notes
The feature request is to support
main(args: list[TypeX], *, ...)
to be equivalent in terms of defopt tomain(*args: TypeX, ...)
.In the function case,
main
, the user could have written it as the functionok
instead.In the dataclass case however, since Python's dataclass doesn't support variable positional arguments, one cannot defines
*args
. So the only sensible choice here is to defineargs: list
instead.The text was updated successfully, but these errors were encountered: