-
Notifications
You must be signed in to change notification settings - Fork 44
tapify
support positional-only arguments
#133
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
tapify
support positional-only arguments
#133
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #133 +/- ##
==========================================
+ Coverage 94.01% 94.09% +0.07%
==========================================
Files 5 5
Lines 685 694 +9
==========================================
+ Hits 644 653 +9
Misses 41 41 ☔ View full report in Codecov by Sentry. |
c90e1ca
to
dfa6cd5
Compare
@martinjm97 Does Looks like the answer is no.# script.py
from tap import Tap
class MyTap(Tap):
x: int
if __name__ == "__main__":
print(MyTap().parse_args()) Command:
Given this, maybe it's too early to allow There are some complications in supporting positional command line arguments. Namely, handling a I lean towards keeping the current behavior for now: no positional command line arguments / all options. Maybe you can consider it in the future if many people want it. Regardless, I'll make the fix to allow |
Demo you can run and mess with# script.py
from tap import tapify
def foo(num1: int, num2: float, /, bar: str, kwarg1: list[int] = None) -> None:
"""Foo does nothing.
:param num1: num1 is a number
:param num2: also a number
:param bar: foobar
:param kwarg1: something, defaults to None
"""
print(locals())
if __name__ == "__main__":
tapify(foo) Help message:
Run it:
|
tapify
support positional-only arguments
…ort-positional-only-arguments
Thank you! It looks like you solved the issue! |
You're welcome :-) Though to be clear, this PR only addresses one part of #100: this PR makes Lmk if you'd like that feature/enhancement as well. I jotted down some of its complications in this comment. |
I see. I think addressing the challenges you mentioned in #133 (comment) would be quite challenging. As a result, I'd advocate for stopping Kyle and I discussed some of the challenges and didn't have great ideas for what to do for positional arguments that are collections. It's not clear where one list ends and the next one starts! In general, it's not clear to me that we'd like There'd probably be additional complications with optional positional list arguments (argparse reference).
I agree! I think you've resolved the original issue to the level where |
tapify
currently doesn't work when the signature contains positional-only arguments.For data models, AFAIK, there isn't such a thing as a positional-only argument. So the change only needs to be applied to (non-data-model) functions or classes.