Check unused imports via ruff - #299
Conversation
|
@JBloss1517 👋🏻 |
6ba8309 to
59aca05
Compare
|
Rebased and ready for review. |
|
Thanks for following up and keeping this PR alive! I can get it reviewed this week. |
jonbiemond
left a comment
There was a problem hiding this comment.
Awesome to see! Amazing how many unused imports stick around.
I just want to note that by running ruff via prek we're missing out on inline annotations in GitHub. See the workflow examples provided by Astral: https://docs.astral.sh/ruff/integrations/#github-actions
Of course, in the case maintainers or contributors choose to adopt prek locally, the benefit of using prek in CI is that the lint config is specified in only one location.
|
I agree the inline annotations looks nice, but they are limited to certain tools and normally the expectation is that the developers will fix these issues in their local and CI check is there just to ensure they are running it locally. |
|
Thanks for kicking off the ruff stack — nice to see #299 → #300 laddering up the ruleset incrementally. Keeping this PR to F401 only is the right call; my notes are all small/config-level so the foundation grows cleanly: Worth fixing here:
On @jonbiemond's annotation point — agreed, and since ruff is currently the only check, I'd lean toward Astral's native Optional: bump All good as-is — the |
|
I agree with @JBloss1517's assessment. @ulgens, if you address @JBloss1517's comments I'll merge the pull request. Thanks for your work on this! |
Resolves > imported but unused; consider removing, adding to `__all__`, or using a redundant alias warnings
59aca05 to
7f8e0e0
Compare
Fixed.
I believe that the auto-fix feature is useful for the development process, and personally, I use it a lot to auto-apply the fixes. This is also the common behaviour among the git hooks. That being said, I agree that a non-descriptive message in CI can be improved. I think this can be solved by https://docs.astral.sh/ruff/configuration/#full-command-line-interface I added On a personal note; not all git hooks provide this feature and my take is that for this specific setup, it's more important to show that the workflow is failing than showing the exact details of why it's failing. If we assume that the expectation from contributors is to run it (automatically) before committing their changes and the CI is here to check that. In case of a failure, the only thing they need to do is to do run the hooks locally - they are not expected to observe and fix individual issues. About the annotations vs git hooks case, I think the git hooks setup can be enriched a lot beyond ruff. This is the standard config I use for the projects I work on. Afaik, except zizmor, none of the other tools provide this annotation feature and I value the uniformity of the reports, so I lean towards the git hooks option. Applied the rest of the recommendations. |
Adds a very basic ruff config to check F401 - unused import rule.
The ruff setup can be extended later.
I added a simple workflow to run pre-commit hooks in CI.