-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: replace pylint and black with ruff #1382
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1382 +/- ##
=======================================
Coverage 96.51% 96.51%
=======================================
Files 71 71
Lines 5077 5077
Branches 883 883
=======================================
Hits 4900 4900
Misses 98 98
Partials 79 79
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
9f48ed7
to
7baec78
Compare
/packit test --labels sanity |
tests/integration/tier0/non-destructive/config-file/test_config_file.py
Outdated
Show resolved
Hide resolved
pyproject.toml
Outdated
|
||
# We technically only support py27 py36 due to el7 and el8 but ruff only | ||
# supports py37 as minimum. This is not a huge issue as any rules we do not | ||
# want we can disablew |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# want we can disablew | |
# want we can disable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed
3b13167
to
b29ecad
Compare
I've added the sanity test label just to be sure that nothing is broken. It will not, but just in case. Doesn't hurt to run the sanity tests suite |
b29ecad
to
5a6aff7
Compare
/packit test --labels sanity |
5a6aff7
to
4aac204
Compare
/packit test --labels sanity |
from test_helpers.common_functions import log_file_data | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not remove this line. It is needed in the test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't we just move it to conftest to have it be available without import? It doesn't feel good to have to import a fixture like this as it is a bit confusing. I'd rather have pytest take care of it in something like conftest
diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py
index bfb0596b..0734bf56 100644
--- a/tests/integration/conftest.py
+++ b/tests/integration/conftest.py
@@ -538,3 +538,20 @@ def backup_directory(shell, request):
yield backup_path
shell(f"rm -rf {backup_path}")
+
+
+@pytest.fixture()
+def log_file_data():
+ """
+ Helper fixture.
+ Reads and returns data from the convert2rhel.log file.
+ Mainly used for after conversion checks, where we match required strings to the log output.
+ """
+ convert2rhel_log_file = "/var/log/convert2rhel/convert2rhel.log"
+
+ assert os.path.exists(convert2rhel_log_file), "The c2r log file does not exits."
+
+ with open(convert2rhel_log_file, "r") as logfile:
+ log_data = logfile.read()
+
+ return log_data
diff --git a/tests/integration/test_helpers/common_functions.py b/tests/integration/test_helpers/common_functions.py
index 069626b1..c2cd9e07 100644
--- a/tests/integration/test_helpers/common_functions.py
+++ b/tests/integration/test_helpers/common_functions.py
@@ -108,20 +108,3 @@ def get_custom_repos_names():
f"rhel-{system_version.major}-for-x86_64-appstream-rpms",
]
return repos
-
-
-@pytest.fixture()
-def log_file_data():
- """
- Helper fixture.
- Reads and returns data from the convert2rhel.log file.
- Mainly used for after conversion checks, where we match required strings to the log output.
- """
- convert2rhel_log_file = "/var/log/convert2rhel/convert2rhel.log"
-
- assert os.path.exists(convert2rhel_log_file), "The c2r log file does not exits."
-
- with open(convert2rhel_log_file, "r") as logfile:
- log_data = logfile.read()
-
- return log_data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've moved certain functions to a separate file, so the conftest.py is not that big. It had over 1000 lines, and it was hard for us to navigate in it. The fixture log_file_data
is used only in this test, so we moved it from conftest.
d8b00da
to
2547db4
Compare
/packit test --labels sanity |
1 similar comment
/packit test --labels sanity |
822e3a8
to
9619cb7
Compare
/packit test --labels sanity |
@kokesak All integration tests are passing now with the change I made # We use pytest_plugins to allow us to use fixtures we define in other files without the need to explicitly import them
# inside each test file.
# LINK - https://docs.pytest.org/en/7.0.x/reference/reference.html#globalvar-pytest_plugins
pytest_plugins = (
"test_helpers.common_functions",
"test_helpers.workarounds",
) As for unit tests failing, it is unclear to me at the moment what the underlying issue is with the encoding tests in el7 But for the failing test relating to restorable file it is unrelated to any change I've made. It is just a unit test previously not being executed due to wrong name. Unsure if the error is the test or implementation atm @r0x0d you are a code owner as well atm, wanna give a quick review of the devcontainer stuff that's changed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QE ack, thanks @Venefilyn!
Ruff is a drop-in replacement for black and also handles linting for us in a lot nicer way than pylint. More specifically it is a lot faster than the alternatives and allows us to enforce PyFormat for strings rather than percent-format or f-strings. Signed-off-by: Freya Gustavsson <[email protected]>
Take care of all the errors reported by Ruff with the current rules that are in place. This also takes care of percent-string formatting and replaces it with PyFormat. Signed-off-by: Freya Gustavsson <[email protected]> Co-authored-by: Rodolfo Olivieri <[email protected]>
1c76273
to
3a43a0b
Compare
/packit test --labels sanity |
1 similar comment
/packit test --labels sanity |
Ruff is a drop-in replacement for black and also handles linting
for us in a lot nicer way than pylint. More specifically it is a lot
faster than the alternatives and allows us to enforce PyFormat
for strings rather than percent-format or f-strings.
Jira Issues:
Checklist
[RHELC-]
or[HMS-]
is part of the PR titleRelease Pending
if relevant