Repository navigation
CI Add lock files for linting - #34303
Conversation
|
@AnneBeyer thanks for the fix. The EDIT: same for the circle CI config. |
|
Pinning is useful (e.g. for security and CI stability) beyond the workaround for the mypy failure. Pinning to the oldest version of pytest is a bit weird though. I would rather pin to the latest stable version of the dependencies and use the weekly lockfile refresh to also bump up those version to get CI environments that are more closely related to the average dev environments. But unfortunately we do not have a lock file dedicated for linting environments (yet). Shall we add one in our |
|
There are actually also a few more places, see the changes here. Line 125 in d6a3652 so now I'm not sure if the decision to not pin it to the min version was actually on purpose. Should we instead pin on the version before the latest release (similar to the quickfix in #32688)? |
|
Maybe we could add an inline comment to tell the reader to regularly bump up the pytest dependency (or configure a dedicated lockfile config and register this for automated weekly refresh as we do for other lockfiles). |
|
@ogrisel do you think we also need to update the wheel builder scripts as in the PR linked above? |
lint.ymlpytest to version before latest to avoid mypy errors
pytest to version before latest to avoid mypy errorspytest to version before latest to avoid mypy errors
ogrisel
left a comment
There was a problem hiding this comment.
After syncing with main the following should work and then the PR will LGTM.
Let's stick with a simple manual pin as a first step. It would be great to set the linter version config in |
betatim
left a comment
There was a problem hiding this comment.
Thanks for working on this fix!
I think this is a good idea and we should merge it once Olivier's suggestions are applied.
I think maybe we once discussed dev environments and decided that having "variety" in what people use was a feature. So maybe that inspired using the oldest version? Either way, I think using a "reasonably new" version of pytest is a good thing.
In https://scikit-learn.org/dev/developers/development_setup.html#set-up-a-dedicated-environment-and-install-dependencies we mention a particular version of ruff in the command to setup a new dev environment. It would be nice if that remained the only case. But that requires that most of the time you can use "what ever the latest version is" of the dev tools. Basically, if on 95% of days running that command leads to a working env, I'd keep the command as is. Otherwise we need to add explicit versions there or consider something like pixi
|
I'm not sure that I see the usefulness of pinning if it requires a manual update at an undefined point in time. From what I learned from @lesteve, we want to avoid these kinds of pins as much as possible, no?
I might still be missing things here, and I'm happy to make the changes if you still think it's useful. |
I'm not sure I understand all of this :-/ from what you said and looking at the diff again I now think you are saying we should use And after seeing #34300 I am even more puzzled. Doesn't that PR fix what ever was broken with using mypy and the latest pytest? In which case why do we even need this PR anymore? |
That was my intention for a quick fix before we merged #34300. But then the discussion moved towards pinning to a more recent version and setting up a more elaborate linting environment (and lockfile) instead, which would take me some more time to understand and set up. (Plus there are the pixi experiments, which might chnage a lot more of the CI set-up, if I understand correctly.)
Exactly, I'm not sure we do. |
Pinning is useful (e.g. for security and CI stability to avoid future disruptions on all PRs in a next pytest/mypy update) beyond the need for a workaround for the recent mypy/pytest failure. |
pytest to version before latest to avoid mypy errorspytest version used by linters
|
Ok, pinning for security and stability makes sense. In that case I think we should use a lockfile like we do for other CI environments. I'm not sure if we should wait for the decision on using pixi or not. |
|
Ok, I think I understand some parts of the CI better now (with a little help from Claude). I will update the PR towards using a lockfile for the linting steps. |
pytest version used by linters| "type": "pip", | ||
| "tag": "lint", | ||
| "folder": "build_tools/github", | ||
| "pip_dependencies": ["pytest", "ruff", "mypy", "cython-lint"], |
There was a problem hiding this comment.
We need to keep on using the "min" supported version of ruff, mypy and cython-lint because linters might change their rules and we want to avoid weekly linter-rule-change-induced code churn.
There was a problem hiding this comment.
Oh, hang on, for cython-lint this was not done previously, should I add it as well?
There was a problem hiding this comment.
I think we should for the sake of consistency.
|
FYI, I just merged #34331. We should pin cython-lint and other linters to version that is consistent with what is configured in our |
That makes sense. I'm still trying to understand how everything fits together. Here is what I have so far (please correct me if I got something wrong): The version pin for What I'm not sure about is if and how to pin
I'm not sure what the best approach is here.
WDYT? |
|
I would go with option 1. for now. I think we want linters to work on recent enough versions of the dependencies ("min" dependencies are not really intended for that) but the usual weekly update schedule of the "latest" dependencies lock files might introduce too much formatting related code churn. EDIT: maybe I am overly worried and the "latest" policy of our lock files (with weekly updates) is not that bad for linters. However, the pre-commit config cannot reuse our custom lock files setup I believe and maintaining them in sync would be tedious. If we ever find a way for |
|
Thanks this branch LGTM. @betatim are you still green with the latest changes? |
| # We set `pytest` to an arbitrary recent version to keep it consistent with | ||
| # the settings in `.pre-commit-config.yml`. They should be updated from | ||
| # time to time in both places. | ||
| "pytest": "9.1.0", |
There was a problem hiding this comment.
I am puzzled by this, why does pre-commit use pytest? To add to my confusion, when I looked in .pre-commit-config.yml to figure out what is what the only reference I found was as part of mypy, but we require pytest==6.2.4 there. Maybe we can expand the comment here to help future me/readers to understand?
There was a problem hiding this comment.
ok, I should have read the full diff first. We set the pytest version that mypy uses in .pre-commit-config.yml to match the one here. So I think the answer is: mypy needs pytest, which is why we mention pre-commit and pytest in the same sentence
Co-authored-by: Olivier Grisel <[email protected]>
Co-authored-by: Olivier Grisel <[email protected]>
Reference Issues/PRs
Follow-up from #34292
What does this implement/fix? Explain your changes.
Uses the min version ofpytestinlint.ymlas a quick fix to the currentmypyfailures.This adds a pip-based lock file workflow for the linting step.
First time contributor introduction
AI usage disclosure
I used AI assistance for:
Any other comments?