Skip to content

Commit 90bea18

Browse files
committed
Merge branch 'lint_check' into 'dev'
Use ruff format and auto-fix for release lint See merge request mass-spectrometry/corems!257
2 parents 95001e7 + 3808ce9 commit 90bea18

5 files changed

Lines changed: 38 additions & 57 deletions

File tree

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Reviewers check these before merging into **`dev`**:
8888

8989
- Docstrings follow the [NumPy style](https://numpydoc.readthedocs.io/en/latest/format.html).
9090
- API docs are built with [pdoc](https://github.com/mitmproxy/pdoc) (`make docu`). The package landing page (`corems.__doc__`) includes `README.md` and `docs/user/installation.md` so install content uses the same pdoc styling as the API.
91-
- Maintainers: before cutting a release, run package lint (`make lint`) as described in [RELEASE.md](./RELEASE.md). Dev tooling is installed via `pip install -e ".[dev]"`.
91+
- Maintainers: before cutting a release, run `make lint` as described in [RELEASE.md](./RELEASE.md). That command **rewrites** package Python (`ruff format` + `ruff check --fix`). Do not run it on a feature branch unless you intend to commit the diff. Dev tooling is installed via `pip install -e ".[dev]"`.
9292

9393
## Issue reporting
9494

‎Makefile‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,17 @@ uml:
149149
docu: uml
150150
pdoc --output-dir docs --docformat numpy corems
151151

152-
# Package lint (release prep). Requires corems[dev] (pylint). Config: pyproject.toml.
153-
# Advisory for maintainers — see RELEASE.md. Exit code may be non-zero when issues remain.
152+
# Format + auto-fix (release prep). Rewrites files — see RELEASE.md.
153+
# Requires corems[dev] (ruff). Config: pyproject.toml.
154+
# Do not use --unsafe-fixes.
154155
lint:
155-
$(PYTHON) -m pylint corems
156+
$(PYTHON) -m ruff format corems
157+
$(PYTHON) -m ruff check --fix corems
156158

157-
# Broader first-party Python (package + tests + support scripts). Still advisory.
159+
# Broader first-party Python (package + tests + support scripts). Also rewrites.
158160
lint-all:
159-
$(PYTHON) -m pylint corems tests support_code
161+
$(PYTHON) -m ruff format corems tests support_code
162+
$(PYTHON) -m ruff check --fix corems tests support_code
160163

161164
SKIP_LIPIDOMICS_DB ?= 0
162165
SKIP_MOLECULAR_DB ?= 0

‎RELEASE.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Release when `dev` has a coherent set of changes ready for users (features, fixe
2323
| `make minor` | Backwards-compatible new features |
2424
| `make major` | Incompatible API changes |
2525

26-
Each of those updates version metadata (see `.bumpversion.cfg`) and regenerates docs via `make docu` (UML class diagrams via `make uml` / pyreverse + Graphviz, then pdoc). The install how-to source is `docs/user/installation.md`, included on the package landing page through `corems.__doc__`. Maintainers need the `dev` extra (`pylint`) and system Graphviz (`dot`) installed so `make uml` succeeds during a version bump.
26+
Each of those updates version metadata (see `.bumpversion.cfg`) and regenerates docs via `make docu` (UML class diagrams via `make uml` / pyreverse + Graphviz, then pdoc). The install how-to source is `docs/user/installation.md`, included on the package landing page through `corems.__doc__`. Maintainers need the `dev` extra (`ruff` for `make lint`, `pylint` for `pyreverse` / `make uml`, `pdoc`, …) and system Graphviz (`dot`) so format and docs steps succeed during a version bump.
2727

2828
## Release steps (GitLab)
2929

@@ -33,21 +33,21 @@ All release steps should be done on the `dev` branch and then merged into `maste
3333
- Gitlab CI green on `dev`.
3434
- Changelog or release notes drafted (these will be copied into the MR description and later into the release on GitHub).
3535
- No open blockers for the intended version.
36-
- **Lint the package** (advisory maintainer review; not a hard CI gate):
37-
1. Activate the same environment you use for CoreMS development and install/update dev extras so `pylint` is available, e.g.:
36+
- **Format and auto-fix the package** (release prep; not a hard CI gate). This **rewrites files**.
37+
1. Activate the same environment you use for CoreMS development and install/update dev extras so `ruff` is available, e.g.:
3838
```bash
3939
pip install -e ".[dev]"
4040
```
4141
2. From the repo root run:
4242
```bash
4343
make lint
4444
```
45-
This runs `pylint` on `corems` with project config from `pyproject.toml` (high-volume legacy style noise disabled so the report is usable). Use the venv’s Python (activate the venv first, or `make lint PYTHON=.venv/bin/python`) so import resolution matches a real install.
46-
3. Optional broader pass (tests and support scripts):
45+
This runs `ruff format` then `ruff check --fix` on `corems` (config in `pyproject.toml`). Use the venv’s Python (activate the venv first, or `make lint PYTHON=.venv/bin/python`). The first run after ruff is introduced will produce a large diff; later releases should be small.
46+
3. Optional broader pass (tests and support scripts; also rewrites):
4747
```bash
4848
make lint-all
4949
```
50-
4. Review the report: fix release-blocking issues you care about; residual warnings are OK for this step. Proceed when you are satisfied—the step does not require a perfect score or exit code 0.
50+
4. Review `git diff` and commit the formatted/fixed files (a dedicated commit is fine, especially the first time). Findings that `--fix` cannot apply may remain and may make the command exit non-zero; that does not block the release. Do not use `--unsafe-fixes`.
5151

5252
2. **Bump version on `dev` (or a short-lived release branch from `dev`)**
5353
```bash

‎docs/user/installation.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ By default the molecular formula database uses **SQLite** (local file; no extra
4141
Install extras from `pyproject.toml` as needed:
4242

4343
```bash
44-
pip install "corems[dev]" # tests, pylint, docs tooling (incl. pdoc)
44+
pip install "corems[dev]" # tests, ruff, docs tooling (incl. pdoc)
4545
```
4646

47-
With `corems[dev]`, maintainers can run package lint via `make lint` (see [RELEASE.md](../../RELEASE.md)).
47+
With `corems[dev]`, maintainers can format and auto-fix the package via `make lint` at release time (see [RELEASE.md](../../RELEASE.md)). That command rewrites files.
4848

4949
Check the installed package metadata or `pyproject.toml` for the current list of extras.
5050

‎pyproject.toml‎

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ Documentation = "https://emsl-computing.github.io/CoreMS/corems.html"
5959

6060
[project.optional-dependencies]
6161
dev = [
62-
"pylint>=3.0",
62+
"ruff>=0.8",
63+
"pylint>=3.0", # pyreverse for make uml / make docu
6364
"pytest>=8.3.2",
6465
"pytest-cov>=5.0.0",
6566
"pytest-xdist>=3.6.1",
@@ -107,48 +108,25 @@ exclude_lines = [
107108
]
108109

109110
# ---------------------------------------------------------------------------
110-
# Pylint (release / maintainer lint via `make lint`; see RELEASE.md)
111-
# Disable high-volume project-wide style debt so the report is reviewable.
112-
# Tighten this list over time as the codebase is cleaned up.
111+
# Ruff (release / maintainer format+fix via `make lint`; see RELEASE.md)
112+
# `make lint` rewrites files. Do not run it except during release prep
113+
# unless you intend to commit the diff. Default rule set only.
113114
# ---------------------------------------------------------------------------
114-
[tool.pylint.main]
115-
jobs = 0
116-
py-version = "3.10"
117-
ignore-paths = [
118-
"^.venv/.*",
119-
"^corems/mass_spectra/input/win_only/.*",
115+
[tool.ruff]
116+
target-version = "py310"
117+
line-length = 88
118+
src = ["corems"]
119+
extend-exclude = [
120+
"corems/mass_spectra/input/win_only",
120121
]
121122

122-
[tool.pylint.messages_control]
123-
disable = [
124-
# Legacy / project-wide naming and structure
125-
"invalid-name",
126-
"too-few-public-methods",
127-
"too-many-arguments",
128-
"too-many-positional-arguments",
129-
"too-many-locals",
130-
"too-many-statements",
131-
"too-many-branches",
132-
"too-many-instance-attributes",
133-
"too-many-public-methods",
134-
"too-many-return-statements",
135-
"too-many-nested-blocks",
136-
"too-many-lines",
137-
"duplicate-code",
138-
# Formatting and docstring debt
139-
"line-too-long",
140-
"trailing-whitespace",
141-
"missing-module-docstring",
142-
"missing-class-docstring",
143-
"missing-function-docstring",
144-
# Common style nits in this codebase
145-
"no-else-return",
146-
"consider-using-f-string",
147-
"import-outside-toplevel",
148-
"wrong-import-order",
149-
"ungrouped-imports",
150-
"protected-access",
151-
"attribute-defined-outside-init",
152-
# Dynamic attributes (numpy / instrument APIs) — high false-positive rate
153-
"no-member",
154-
]
123+
[tool.ruff.lint]
124+
# Pin ruff defaults so a newer ruff does not enable extra families at release.
125+
select = ["E4", "E7", "E9", "F"]
126+
127+
[tool.ruff.format]
128+
quote-style = "double"
129+
indent-style = "space"
130+
skip-magic-trailing-comma = false
131+
line-ending = "auto"
132+

0 commit comments

Comments
 (0)