-
Notifications
You must be signed in to change notification settings - Fork 36
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
Apply Scientific Python repo-review suggestions #112
Comments
Thanks for sharing and distilling the results. I'll go through them one by one.
On this one, I'm at -0. If it's best practice to have this config, perhaps GitHub should make it the default. I see setuptools has adopted it, but with an additional I've had other users propose to disable fail-fast, which is kind-of the opposite of this change. I find it a little frustrating that the authors of GH102 don't explain why I should override the presumably sensible defaults that GitHub provides. I'd really like to see GH102 rewritten to include the motivation (what's the value in tweaking the configuration) and either a feature request or guidance from GitHub that this setting is preferred. It should probably be updated too to recommend a tweak that doesn't break releases. |
I've previously explored enabling pre-commit, but I've found it adds too much toil and noise to a project. The project is insistent on pinning and frequently updating the config, which at the very least results in lots of nuisance PRs and commits in the history. I've stumbled on a few projects that are using pre-commit, and especially for the stable ones, the commits in the repo are littered with pre-commit bumps. I absolutely don't want to adopt a process that's unwilling to go with the flow and work at head. See also #109. |
These sound good. I was tempted to enable isort when migrating from flake8/black, but I wanted to wait for the projects to stabilize, which they basically are now (little risk of having to roll back the migration). There are still probably many projects that haven't yet been updated to support the code style tweaks in ruff, but that's fine. Enabling these settings will cause a lot of toil on the downstream projects, but I'm willing to do it, especially if we can devise a routine to apply |
I'm not fond of pre-commit myself 😄 Do you have a complete list of downstream projects that use this skeleton? I have already started applying B and UP rules in some of them. Not all rules can be enforced with About GH102, I must admit I don't understand the gory details of GitHub jobs. Yet, I think concurrency groups could be enabled and fast-fail disabled at the same time:
|
I experimented adding "I", "B", and "UP" to ruff.toml in the keyring project. It revealed 73 errors of which all but 17 could be mechanically fixed (all but 33 safely):
After applying the fixes, there were new failures in the tests, including "needs formatting" and mypy failures... so that's annoying. It doesn't appear there's a way to diff --git a/keyring/_compat.py b/keyring/_compat.py
index 46868a8..7d7c8fa 100644
--- a/keyring/_compat.py
+++ b/keyring/_compat.py
@@ -4,4 +4,6 @@ __all__ = ['properties']
try:
from jaraco.classes import properties # pragma: no-cover
except ImportError:
- from . import _properties_compat as properties # type: ignore[no-redef] # pragma: no-cover
+ from . import (
+ _properties_compat as properties, # type: ignore[no-redef] # pragma: no-cover
+ ) That's a little discouraging, suggesting there's a lot of toil ahead.
I have a list of projects I contribute to, but that's a superset of projects I maintain and only a subset of projects utilizing skeleton. The Coherent OSS page has a curated list of projects. That's probably a pretty good representation of projects dependent on skeleton that I (and others in Coherent OSS) maintain. For projects others maintain, probably the best way to find those would be to search GitHub for non-fork projects containing the badge (note that the year changes, so you'd want to search without the year). @bswck do you have any other advice on how to find skeleton-based projects (based on the work you've done)? |
Yet B are often the most interesting rules. For example, they detect tests that contain |
I've filed astral-sh/ruff#10516 to track ruff isort fixes breaking mypy tests. |
I'll provide a script for it. We could include it in your article later. |
I did some work this evening to make
Only ~3300 lints to clean up. Next, I'll see if I can use this routine to enact some of the automatic fixes. |
I've spent some time cleaning up those projects so at least they're building at HEAD. I've also spent some time fixing some of these checks in the projects and learned a few things:
(prior to an edit, I had B904 and B028 swapped above) If we're going to adopt bugbear checks, I'd suggest to disable B028 and B904 to start. |
Indeed, I have caught many missing
That's especially true of tests. Perhaps disable in tests?
Adding
to:
I doubt the default behaviour will ever change in Python now that that distinction has been introduced. Is doing the "right thing" such a nuisance? On the other hand, is the difference in wording that important and useful? |
It's four elements to two lines, so no, it's not horrible, but it does start to litter the codebase. Especially when by my estimation 99% of the time, if one is explicitly raising an exception in If Python had the intention for every piece of code everywhere to choose between Oh, but I see now, there are in fact three different modes: no indication, I still contend, if Python recommends for everyone to write I realize bugbear doesn't speak for the whole community, but it's annoying to be adding all of these changes and persistent noise to all the code bases for such little value. |
Here's what B028 looks like, and here's what B904 looks like across the projects. |
With As a sidenote, for projects relying on both setuptools and distutils, (like setuptools itself) you can add them to https://docs.astral.sh/ruff/settings/#lint_isort_extra-standard-library, https://docs.astral.sh/ruff/settings/#lint_isort_known-third-party, https://docs.astral.sh/ruff/settings/#lint_isort_known-first-party, or https://docs.astral.sh/ruff/settings/#lint_isort_known-local-folder such that setuptools is grouped to always be imported before distutils. (not necessarily something to add in skeleton, but a consideration you can have whenever you hit that issue of import order mattering across a codebase) |
Apply those rules that make sense:
https://learn.scientific-python.org/development/guides/repo-review/?repo=jaraco%2Fskeleton&branch=main
Suggestions:
GH102
: Auto-cancel on repeated PRsAt least one workflow should auto-cancel.
PC100: Has pre-commit-hooks
Must have
https://github.com/pre-commit/pre-commit-hooks
repo in.pre-commit-config.yaml
PC901: Custom pre-commit CI message
Should have something like this in .pre-commit-config.yaml:
RF101: Bugbear must be selected
Must select the flake8-bugbear B checks. Recommended:
RF102: isort must be selected
Must select the isort I checks. Recommended:
RF103: pyupgrade must be selected
Must select the pyupgrade UP checks. Recommended:
The text was updated successfully, but these errors were encountered: