Replies: 4 comments 5 replies
-
CC @meaksh @vzhestkov @juliogonzalez @mcalmer @agraul @renner ; feel free to ping others as well of course. Edit: I see I forgot to ping @ycedres , my apologies, I copy-pasted the pings from the previous discussion. |
Beta Was this translation helpful? Give feedback.
-
As long as it is easy usable I am fine. But I just want to execute 1 command and installation of the environment should be also easy doable. |
Beta Was this translation helpful? Give feedback.
-
I like the approach that's described in the post! There are a few details that I'd like to comment on.
I agree with others that we should include a script that runs the container transparently. A while ago I created a PoC that has some issues passing multiple args but generally works: #!/bin/sh
IMAGE=${IMAGE:-systemsmanagement/uyuni/master/docker/containers/uyuni-master-pgsql}
REGISTRY=${REGISTRY:-registry.opensuse.org}
GITROOT=$(git rev-parse --show-toplevel)
REL_HERE=$(git rev-parse --show-prefix)
ENGINE=${CONTAINER_ENGINE:-podman}
echo "$ENGINE" run -it --rm -v "$GITROOT":/code "$REGISTRY/$IMAGE" /bin/sh -c "cd /code/$REL_HERE && pylint --rcfile /code/pylintrc $@"
"$ENGINE" run -it --rm -v "$GITROOT":/code "$REGISTRY/$IMAGE" /bin/sh -c "cd /code/$REL_HERE && pylint --rcfile /code/pylintrc $@"
|
Beta Was this translation helpful? Give feedback.
-
So I understand that as a first step we would need to run |
Beta Was this translation helpful? Give feedback.
-
Summary
In this discussion, I am proposing the following:
black
to format contributions.pylint
to check contributions.pylintrc
included)80
characters per line rule to88
characters per line to align ourselves with Black's default88
characters per line.If accepted, I will do the following:
uyuni
repository.pylint
issues to bringpylint
reports 10/10 score.pylint
andblack
.After that, we can implement automated checks on every PR, e.g. by using Github Actions or Jenkins, and enforce that contributors use unified formatting rules and adhere to the
pylint
static analysis.Proposal
Currently, different files use different or no standards, contain unused code (e.g. imports), and multiple formatting styles.
The proposed solution is to:
black
.# pylint: disable=...
comment to all lines that currently do not adhere to thepylint
standard.black
andpylint
on every PR.black
andpylint
locally, either by using local environment or a container.Consequently:
Implementation
Black and Pylint
Formatting is automatic, consisting running
black
on all files that we want to modify.Disabling pylint for currently non-conforming lines is automated by custom scripts. I propose automating this task. You can see my proof-of-concept script at https://github.com/m-czernek/autolint/blob/main/autolint.py.
Though the scripts still require manual checking, we can automate the majority of the effort.
Providing Authoritative Execution Environment
I propose creating a container image that includes
black
,pylint
, and its configuration files.Contributors can either create local environment, or use the container image in case they cannot use our local environment (e.g. due to not using the latest Python version).
I propose a new container instead of reusing our testing container to:
You can view a proof-of-concept container at https://github.com/m-czernek/autolint/blob/main/Containerfile.
Discussion
How do we ensure that the output of Pylint and Black is compatible with our currently supported Python version, i.e. Python 3.6?
The
black
CLI enables us to select thepy36
version to ensure compatibility with Python 3.6. Similarly, Pylint enables us to use thepy-version
flag to also ensure compatibility with Python 3.6.We will migrate the options when we move to the newer supported Python versions.
Different users might use different OSes and different Python versions. How do we deal with that?
We provide a containerized environment that produces the authoritative result.
What files do we want to format and check?
Any non-test Python files in the
/python
directory. We can modify other files as well, e.g. Python files in/spacewalk
or Python tests, if the team finds this desirable.On what branches do we want to enforce the changes?
The main branch (
master
). However, due to the fact that the effort is mostly automated, we can implement the changes on any branches if the team finds this desirable.Links
Beta Was this translation helpful? Give feedback.
All reactions