🏗️ Split CI into lint/typecheck/test/build and type-clean src/devol#10
Merged
Conversation
…checks Replace the single-job CI with four parallel jobs: - lint: ruff check + ruff format --check (Python 3.13) - typecheck: mypy --strict on src/devol (Python 3.13) - test: pytest on Python 3.11, 3.12, 3.13 - build: uv build + twine check to validate release artifacts All jobs are blocking. To make the new jobs actually pass, this also: - Fixes the CLI bug mypy caught (run() was missing a default for initial_population, so `devol --config ... --function sphere` crashed with a TypeError) - Introduces a FloatArray = NDArray[np.float64] alias per module and parametrizes every NDArray annotation in src/devol - Resolves numpy "returning Any" typing quirks by explicitly typing intermediate results - Casts np.sum/np.cos results to float where a plain float is declared - Removes stale TODO scratch comments from algorithm.py - Excludes examples/ from ruff (they are demo code, not part of the published wheel, and will get their own cleanup PR) - Applies ruff auto-fixes (unused imports, f-strings without placeholders, import ordering) across the repo - Runs ruff format across the repo so the check passes - Adds noqa: N806 for numpy meshgrid X, Y, Z convention in tests/ci After these changes: ruff, ruff format, mypy --strict, and pytest (x3) all pass locally and in CI.
dariocazzani
added a commit
that referenced
this pull request
May 3, 2026
The core devol package only uses numpy, pydantic, and pydantic-yaml, but the shipped dependency list forced every user to install torch, torchvision, gymnasium, and matplotlib — a ~2 GB footprint for a library whose runtime doesn't touch any of them. - Required deps reduced to numpy, pydantic, pydantic-yaml - Drop unused pydantic-settings (leftover from an abandoned branch) - Move torch, torchvision, gymnasium[classic-control], matplotlib into the examples extra (where cartpole/mnist/live-two-peaks actually use them) - Add twine to the dev extra so the build CI job works from a sync - Add an `all` meta-extra that pulls dev + examples + benchmark - Narrow the wheel target to src/devol so examples/ and benchmark/ ship only in the repo, not in the pip install - Add pytest pythonpath config — narrowing the wheel removed the accidental side-effect that let `tests.ci.n_peaks` resolve via editable install, so configure it explicitly - Update README with an Installation section covering the extras - Update CHANGELOG with the dependency changes, the wheel narrowing, and the earlier CI/typing work from PR #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Upgrades CI from a single pytest-only job on Python 3.11 to four parallel jobs (lint, typecheck, test, build) running across a 3.11/3.12/3.13 matrix. To make the new gates actually pass, the src package is brought up to full
mypy --strictcleanliness and the whole tree is brought up to ruff cleanliness. A real CLI bug surfaced by mypy is fixed along the way.Details
CI workflow
ci.ymlwith four jobs:lint,typecheck,test(3.11/3.12/3.13 matrix),buildlintrunsruff check+ruff format --checktypecheckrunsmypywith existing strict settings, scoped tosrc/devolbuildrunsuv build+twine checkto validate release artifactsType cleanup in
src/devol/NDArrayannotation asNDArray[np.float64]via a per-moduleFloatArrayaliasnp.sum/np.cosresults tofloatin functions declared to return plainfloatIdentity/Energyfitness classes up to strict typing (previously had untyped defs)# TODOscratch comments fromalgorithm.pyReal bug fix caught by mypy
DiffusionEvolution.run()requiredinitial_populationwith no default, but the CLI calledalgo.run()with no argument. Runningdevol --config … --function spherewould have crashed. Default is nowNone, matching the public docstring in the README.Ruff cleanup
ruff formatso the format check passesexamples/from ruff viapyproject.toml— they're demo code not in the published wheel, and they'll get their own cleanup PRnoqa: N806on numpymeshgridX, Y, Zintests/ci/n_peaks.py(matrix capital-letter convention)Verification
Locally, all four gates pass:
Out of scope
examples/(deferred, separate PR)benchmark/is already ruff-clean and runs on 3.11+; its types are not yet strict but mypy doesn't cover it by design