Replies: 6 comments 13 replies
-
Please take a look and share your thoughts @meaksh @SchoolGuy @vzhestkov @juliogonzalez @jordimassaguerpla @mcalmer |
Beta Was this translation helpful? Give feedback.
-
I am fan of those tools, even if those changes break something. In the end I think that linters help enforce a common code flavor which is easily understandable for everyone then. I would vote for the strict pylint and iterative approach. This means a lot of one time work but then we do two things with one tasks: tests and removing a lot of code smells. I did it with Cobbler and so far I feel that although some things break, the overall quality is improving. The reason I would vote against the pylint-ignore approach is the fact that although it is a thin wrapper, it is an additional dependency. We already have a lot on our hands and with you guys helping out in Cobbler it will not get less. |
Beta Was this translation helpful? Give feedback.
-
AFAIK there was some effort to create a global pylint job in our CI checking the whole git with 1 pylint call/file. |
Beta Was this translation helpful? Give feedback.
-
I would run pylint on uyuni as a github action but not in spacewalk. First of all, because of what @mcalmer said, different versions of pylint will give you different results, which, a part from being a mess, adds no value on running a different stylecheck on spacewalk than on uyuni. We could certainly run the exact same pylint if we build a containers that we reuse for testing in uyuni and spacewalk. However, again, what is the value of that? I mean, what is the chance that a backport from uyuni to spacewalk is done in a way that the style is wrong, and in that case, what is the problem with that? I understand we want to keep a sane codebase, for code quality (I am all in for this), with all the benefits this gives (maintenance, less probable to introduce bugs, easy to read by everyone, etc) ... for MASTER, given master is what future releases will be forked from. However, for a branch that has a an expiration date, which basically will get only backports .. I don't think is that relevant and worth the effort. Thus, my opinion here is to implement a github action for uyuni. |
Beta Was this translation helpful? Give feedback.
-
Personally I like the system salt has - pre-commit + black + pylint. It catches issues before being pushed to server and avoid rebases or additional commits just to fix linting or codestyle errors. It needs some setup and getting familiar with it though. |
Beta Was this translation helpful? Give feedback.
-
Modeled after the uyuni-rfc template, but not worthy of its own RFC. So let’s try a GH discussion.
Summary
pylint
compliance will be a required check in Uyuni Pull Requests for Python files. Additonally,pylint
will run on codestream branches ongit push
that touch Python files. Current failures are ignored, only new failures causepylint
to fail.Motivation
pylint
is able to enforce consistency for Python code and detect syntatic and semantic issues. We already havepylint
jobs, but the way they are set up makes it very easy to miss them. Linting should be done as early as possible to enforce consistency, if possible before a change is merged.pylint
was not strictly enforced for our codebase and that shows, there are currently more than 2200 reported failures forbackend/
that aren’t caused byimport
failures. Our repository layout adds another *~ 2400*import
failures on top, but that is a problem for another day.Detailed design
Fixing all failures reported by
pylint
is too much work, hence we start by enforcingpylint
compliance for new or changed code only.Ignoring current failures
We use
pylint-ignore
to maintain a list of known failures. The failures are saved in a machine- and human-readable Markdown file namedpylint-ignore.md
.pylint-ignore.md
is only updated manually, never automatically. For this reason, there is nomake
target that updatespylint-ignore.md
. No new ignoredpylint
failures may be added topylint-ignore.md
, updates must only remove outdated ignoredpylint
failures.Makefile.python
defines thepylint
target in two flavors. One that executespylint-ignore
inside a Docker container and one that is executed from inside such a container. This allows developers to run the same version ofpylint-ignore
in their development environment inside a container that is used in GitHub Actions.pylint
, without-ignore
, can be executed manually inside the container usingdocker_shell
target. This can be useful when someone wants to fix ignoredpylint
failures.Iterative improvements
GitHub Actions run on
pull_request
andpush
events targeting codestream branches¹ that contain Python files. In either casepylint-ignore
is executed on the changed files only. This ensures no time is wasted on unchanged files. https://github.com/Ana06/get-changed-files is a maintained GitHub Action that lists added / modified files and is used by the (new)Pylint
workflow.Contributors are encouraged to fix
pylint
failures that are ignored for each file touched in a Git commit, but not required to do so. Pull requests that only fixpylint
failures require exhaustive test coverage, and are generally not accepted.pylint-ignore
compliance is mandatory for each Pull Request.1: In Uyuni there is only one,
master
, but the policy can be used for SUSE Manager as well. In that case, the CI is not run by GitHub Actions but by an SUSE-internal Jenkins instance.Drawbacks
Alternatives
No pylint
It’s what we have right now. Contributions are easy, but reading the code later on is hard. We also have a lot of unused code lying around and use bad practices. One consequence is that Python delevopers have a harder time grasping parts of our codebase than needed.
Strict pylint
No
pylint-ignore
, justpylint
. This is a lot of work up front to get the check green, and we don’t have great test coverage to give use confidence to do large scale refactors. But without those refactors, the check will always be red and won’t provide any information.Unsovled Questions
SUSE Manager CI
Container needs recent Pylint
pylint-ignore
pylint
does not build in systemsmanagement:Uyuni:Utils/python-pylintBeta Was this translation helpful? Give feedback.
All reactions