Closed m-fila closed 2 months ago
No ruff in the LCG releases? :eyes:
Should I also add cmake targets as in https://github.com/key4hep/EDM4hep/pull/257?
We either adapt that to run the same checks as this, or we have to include flake8
and pylint
in this PR as well. Alternatively, we close that and include the changes here.
Added cmake targets here so #257 can be closed if this is merged
Very nice. Thanks :)
What about including formatting as part of Key4hepConfig.cmake
? For python ruff is very fast so it won't change much, clang-format
for every file I don't know :thinking:
I like the idea. We would probably then also need a pre-commit setup that checks in all repositories. In the end the targets are only defined but not run by default, so it would be a somewhat easy way for users to fix formatting issues that are flagged by pre-commit.
Hmm pre-commit config is just a single file and if we want to centrally manage it then the projects are not supposed to modify it, right?
So if we decide that we don't want for instance clang-tidy
in pre-commit everywhere then adding clang-tidy
just to selected repos would be a problem?
Similar problem with ruff config, ruff format and lint are in the same file so if we want to have managed ruff config with just format then it wont be possible to add lint to it. Also the config then should be probably moved from recommended pyproject.toml
to ruff specific otherwise it won't be possible to modify pyproject.toml
?
I think some of the configuration files simply can't be managed centrally, or at least not for all packages. It's not entirely clear to me where to draw the line, but e.g. pyproject.toml
is not something I would manage centrally, since there is a lot of project specific metadata that goes into there.
So should we centrally manage just the cmake target with ruff format but no linting target, pre-commit config, ruff config? Ruff can run on the defaults without any config file, the only difference between the defaults and the config here is the target-version = "py38"
vs target-version = "py310"
Maybe python related targets need to go into a separate .cmake
file? I am not entirely sure if all the repositories will need it in the end. Additionally, Gaudi option files are not easily lintable, I think, since most of the things are dynamically populated.
I would leave the pre-commit config on a per repository basis at least. (The github action can then again be distributed centrally). For the linting, I am not entirely sure, in principle we should apply the same rules for all repositories. However, that would then mean that we would need to go the way of ruff specific config files, right? Because pyproject.toml
is definitely repository specific, IMHO.
Should we merge this still before the tag (tomorrow)? Or do we postpone this until later and conclude the discussion first?
I think there is no hurry for this one I just realized I missed there is a black config in k4FWCore with different line width (99). I think I'll change it here to 99 too for some consistency
No ruff in the LCG releases? 👀
There will in the next one: https://lcginfo.cern.ch/pkg/ruff/
(Hopefully happening Monday)
We could also switch over to use a key4hep stack, since that is what we are doing on other repositories, I think. Using an LCG stack was done historically, because we could more easily get an LLVM based stack (for clang-format
), but that is now also available from a key4hep stack
BEGINRELEASENOTES
ruff
andruff-format
to lint and format python codeENDRELEASENOTES
Linting and formatting done with ruff which should be compatible with black, flake8 and pylint while having a single configuration file. ruff is already in the stack
CI added as local hook
Selected rules
["F", "E", "W", "PLE", "PLW", "PLC"]
from flake8 (pyflakes "F", pycodestyle errors "E" and warnings "W") and pylint (errors "PLE", warnings "PLW" and conventions "PLC") I'd also consider adding some of theD1
checks for docstrings but there seems to be only a few docstrings now :upside_down_face:The codebase seems to use mixed 2-space and 4-space indent, now the default 4-space is used in formatter
Should I also add cmake targets as in #257?
Closes #364