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

DM-37025: Enable type checking for click commands #755

Merged
merged 2 commits into from Nov 17, 2022
Merged

Conversation

timj
Copy link
Member

@timj timj commented Nov 16, 2022

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes

@timj timj requested a review from andy-slac November 16, 2022 19:52
) -> ContextManager[ProgressBar[_T]]:
# Docstring inherited.
return click.progressbar(iterable=iterable, length=total, label=desc, **self._kwargs)
return click.progressbar(iterable=iterable, length=total, label=desc, **self._kwargs) # type: ignore
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't really sure what to do with this one. The error was:

Incompatible return value type (got "Union[click._termui_impl.ProgressBar[_T], click._termui_impl.ProgressBar[int]]", expected "AbstractContextManager[lsst.daf.butler.core.progress.ProgressBar[_T]]")  [return-value]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether it complains about click.ProgressBar not matching daf.butler.ProgressBar protocol, or that click.ProgressBar does not inherit from ContextManager.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs for click.progressbar say it returns ProgressBar[V] and then says "This function creates an iterable context manager", so for all I know the type annotation is wrong in click.

Copy link
Contributor

@andy-slac andy-slac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, couple of minor comments.

python/lsst/daf/butler/cli/butler.py Outdated Show resolved Hide resolved
python/lsst/daf/butler/cli/butler.py Outdated Show resolved Hide resolved
) -> ContextManager[ProgressBar[_T]]:
# Docstring inherited.
return click.progressbar(iterable=iterable, length=total, label=desc, **self._kwargs)
return click.progressbar(iterable=iterable, length=total, label=desc, **self._kwargs) # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether it complains about click.ProgressBar not matching daf.butler.ProgressBar protocol, or that click.ProgressBar does not inherit from ContextManager.

@codecov
Copy link

codecov bot commented Nov 16, 2022

Codecov Report

Base: 85.30% // Head: 85.29% // Decreases project coverage by -0.00% ⚠️

Coverage data is based on head (9fabea2) compared to base (b7b9b38).
Patch coverage: 93.85% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #755      +/-   ##
==========================================
- Coverage   85.30%   85.29%   -0.01%     
==========================================
  Files         260      260              
  Lines       34424    34468      +44     
  Branches     5802     5810       +8     
==========================================
+ Hits        29366    29401      +35     
- Misses       3819     3824       +5     
- Partials     1239     1243       +4     
Impacted Files Coverage Δ
python/lsst/daf/butler/cli/opt/options.py 93.18% <57.14%> (-4.32%) ⬇️
python/lsst/daf/butler/cli/butler.py 89.39% <90.32%> (-0.77%) ⬇️
python/lsst/daf/butler/cli/cliLog.py 76.72% <95.65%> (-0.20%) ⬇️
python/lsst/daf/butler/cli/utils.py 93.48% <95.65%> (-0.69%) ⬇️
python/lsst/daf/butler/cli/cmd/commands.py 90.67% <96.55%> (-0.09%) ⬇️
...hon/lsst/daf/butler/cli/cmd/_remove_collections.py 100.00% <100.00%> (ø)
python/lsst/daf/butler/cli/cmd/_remove_runs.py 96.72% <100.00%> (+0.16%) ⬆️
python/lsst/daf/butler/cli/opt/optionGroups.py 88.88% <100.00%> (ø)
python/lsst/daf/butler/cli/progress.py 100.00% <100.00%> (ø)
python/lsst/daf/butler/script/_pruneDatasets.py 97.67% <100.00%> (+0.05%) ⬆️
... and 2 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@timj timj merged commit b839107 into main Nov 17, 2022
@timj timj deleted the tickets/DM-37025 branch November 17, 2022 03:57
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.

None yet

2 participants