Make linting and type checking more rigorous: black, ruff, mypy all green#12
Make linting and type checking more rigorous: black, ruff, mypy all green#12
Conversation
…, and black formatting Co-authored-by: dantzert <47285626+dantzert@users.noreply.github.com>
|
@copilot shouldn't these edits have involved changes to project.toml or the CI workflow? |
Co-authored-by: dantzert <47285626+dantzert@users.noreply.github.com>
Good catch. Updated |
|
@copilot Add fixing those mypy errors to this branch. The linting and type checking should apply to the whole repo. Then make all the files green for these checks. |
dantzert
left a comment
There was a problem hiding this comment.
See my most recent comment. Make the mypy test more rigorous and apply the linting and type checks to the whole repo
… pyproject.toml Co-authored-by: dantzert <47285626+dantzert@users.noreply.github.com>
Done in commit
The linting and type checks now cover the whole repo — |
.github/workflows/ci.yml
Outdated
|
|
||
| - name: Lint with ruff | ||
| run: ruff check tests/ | ||
| run: ruff check modpods.py tests/ |
There was a problem hiding this comment.
Updated to ruff check . in commit 2de4ca8. Fixed the ruff violations in spring-cart-interactive.py (import sorting, trailing whitespace, unused variable) and added # noqa: F403 to the intentional star import in __init__.py.
.github/workflows/ci.yml
Outdated
|
|
||
| - name: Lint with black | ||
| run: black --check tests/ | ||
| run: black --check modpods.py tests/ |
There was a problem hiding this comment.
Why not "black ."? To apply across the whole repo?
There was a problem hiding this comment.
Updated to black --check . in commit 2de4ca8. Also fixed the two additional files that needed reformatting (spring-cart-interactive.py) and the F403 star import in __init__.py.
…-cart-interactive.py and __init__.py Co-authored-by: dantzert <47285626+dantzert@users.noreply.github.com>
modpods.pyhad 335 ruff violations and failed black formatting. This PR cleans up the code so all three tools pass, strengthens the mypy configuration, and enforces all checks across every.pyfile in the repo via CI.Changes
E402,I001): Moved all imports to top of file before any executable code; movedwarnings.filterwarnings()call after imports; sorted imports alphabetically; removed redundantimport control as control→import control; addedfrom typing import AnyW291/W293): ~290 instances removed across the fileF401): Removedfrom scipy import signalF841): ~14 unused local variables prefixed with_except(E722): Twoexcept:clauses →except Exception:F821): Fixed a logic bug in theccmblock where loop variablesforcing_col/dep_colwere never used to fetch data —ccm(forcing, response)→ccm(system_data[forcing_col], system_data[dep_col])E712):== False→notmodpods.pyandspring-cart-interactive.pydelay_modelsandtransformation_approximationsdicts asdict[Any, Any]to prevent mypy from locking indict[K, None]types"diverged": True→"diverged": [True]to match surroundinglist[Any]dict value typeimport matplotlib.pyplot as pltinsideif verboseblocks (plt is already imported at module top; conditional re-imports caused "used before definition" errors at later call sites)prev_step = False/next_step = Falsesentinels toNoneso mypy correctly narrows the type after truthiness checkscastintests/test_modpods.pyto satisfywarn_return_anyin thetrained_camels_modelfixturespring-cart-interactive.py: Fixed import sorting (I001), trailing whitespace (W293), and unused variableani(F841)__init__.py: Added# noqa: F403to the intentional star importpyproject.toml: Enabledcheck_untyped_defs = trueandwarn_return_any = truefor stricter mypy checkingblack --check,ruff check, andmypysteps to use.so every Python file in the repository is covered<issue_title>make linting and type checking more rigorous </issue_title>
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.