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

Support overriding behavior hint in argument helptext #161

Merged
merged 4 commits into from
Sep 18, 2024

Conversation

brentyi
Copy link
Owner

@brentyi brentyi commented Sep 14, 2024

cc #159

Copy link

codecov bot commented Sep 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.70%. Comparing base (072dd5f) to head (52bb3a2).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #161   +/-   ##
=======================================
  Coverage   99.70%   99.70%           
=======================================
  Files          24       24           
  Lines        2035     2040    +5     
=======================================
+ Hits         2029     2034    +5     
  Misses          6        6           
Flag Coverage Δ
unittests 99.70% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stevapple
Copy link

stevapple commented Sep 14, 2024

Looks good. I wonder if it's possible to achieve:

  • Explicitly passing in None or a special value to omit the behavioral description;
  • Using some placeholder for the default value string so that users can keep the description in sync if it includes the default value.

A cent on implementation of the two feature requests:

  • The latter is easy to achieve by substring replacement, although we need to figure out what the ideal placeholder is.
  • The former is a bit tricky because Python doesn't have something like JavaScript's undefined, so we might need a dict or a new placeholder type for such case... I think a judgement for '' should work.

@brentyi
Copy link
Owner Author

brentyi commented Sep 15, 2024

Great!

Using some placeholder for the default value string so that users can keep the description in sync if it includes the default value.

Do you have concrete/example use cases for this? The maintenance burden here is small so I could entertain this if it's useful enough, but I'm not a fan of the substring replacement from an API perspective. One other option is help_behavior_hint: str | Callable[[str], str] | None, where the lambda function is internally called with the default string representation.

@stevapple
Copy link

One other option is help_behavior_hint: str | Callable[[str], str] | None, where the lambda function is internally called with the default string representation.

I also like this idea! It looks very neat and familiar.

Do you have concrete/example use cases for this?

This would help if the user is passing in a default value with a dict, so that the initial Args may not know what the default value is. It’s also risking forgetting to update the hint text after the default value changed.

@brentyi brentyi merged commit 3b436a7 into main Sep 18, 2024
15 checks passed
@brentyi brentyi deleted the brent/behavior_hint_override branch September 18, 2024 17:10
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

Successfully merging this pull request may close these issues.

2 participants