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

Add detailed type annotations for param and command decorators, explicitly listing all kwargs #47

Merged
merged 6 commits into from
Jun 17, 2021

Conversation

janluke
Copy link
Owner

@janluke janluke commented Jun 17, 2021

Closes #21.

Why a stub file?

I used a stub .pyi file for annotating @argument and @option. This was convenient because of how Click handles arguments passed to these decorators, sometimes assuming an argument is not None just because it is in **kwargs. For this reasons, arguments must be collected and processed to remove all None. Given the large number of arguments in these decorators, this also has a performance impact (arguably irrelevant, but still an order of magnitude increase).

Work left out for the future

  • (In @command and @group make all arguments but name keyword-only #46) Make all arguments of @command and @group but name keyword-only.

  • Autocompletion arguments. The arguments:

    • autocompletion, which is deprecated in Click 8.0 and will be removed in Click 8.1
    • shell_complete, which supersedes the previous

    were not included because Cloup currently supports both click >= 7.2. I'll add shell_complete when support for Click 7 is dropped.

…file

Using a stub was convenient in this case because:
- the alternative complicates the implementation since
  it requires additional processing of kwargs
  (e.g. removal of None args)
- worsen performance of one order of magnitude.
@janluke janluke merged commit efa5e85 into master Jun 17, 2021
@janluke janluke deleted the chore/explicit-kwargs branch June 17, 2021 18:30
@janluke
Copy link
Owner Author

janluke commented Jun 17, 2021

It looks like GitHub included some commits (the first 4) that were already in my local master because I opened this PR before updating that remote master. Git history is fine though.

janluke added a commit that referenced this pull request Jun 18, 2021
This refines the work done in #47.

- Add Cloup-specific args to @group check that cls is a subclass of cloup.Group.
- Improve docstrings.
@janluke janluke added this to the v0.9.0 milestone Jun 30, 2021
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.

Explicitly list arguments in decorators to improve DX
1 participant