Skip to content
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

Add ruff Python linter and suppress reported issues #1099

Merged
merged 2 commits into from
Jan 6, 2024

Conversation

jiridanek
Copy link
Member

Even though ruff is not as good a linter as Pylint, it is still quite good and is much faster:

$ time pylint ods_ci
real    0m10.980s, user    0m10.745s, sys     0m0.179s
$ time ruff ods_ci
real    0m0.023s, user    0m0.040s, sys     0m0.017s

@jiridanek jiridanek self-assigned this Jan 5, 2024
@jiridanek jiridanek added the utils Enhancements in scripts and CI/CD (PR will be listed in release-notes) label Jan 5, 2024
…kages in PyCharm

Signed-off-by: Jakub Stejskal <[email protected]>
Signed-off-by: Jiri Daněk <[email protected]>
* [Ruff: a fast Python linter](https://lwn.net/Articles/930487/)
* [Ruff: The First 200 Releases](https://notes.crmarsh.com/ruff-the-first-200-releases)

Even though ruff is not as good a linter as Pylint, it is still quite good and is _much_ faster:

```
$ time pylint ods_ci
real    0m10.980s, user    0m10.745s, sys     0m0.179s
$ time ruff ods_ci
real    0m0.023s, user    0m0.040s, sys     0m0.017s
```

Signed-off-by: Jiri Daněk <[email protected]>
Copy link
Contributor

github-actions bot commented Jan 5, 2024

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
391 0 0 391 100

Copy link

sonarqubecloud bot commented Jan 5, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@jiridanek
Copy link
Member Author

jiridanek commented Jan 5, 2024

This PR originally comes from an older draft. I am splitting it into three PRs. This PR is second in the series. It adds the linter as a dev dependency, configuration for it, and github action for it. I will send a PR that fixes the found issues after this PR is merged.

It follows up on this other PR (which should be merged first)

Comment on lines +128 to +150
# TODO(jdanek)
"C416", # Unnecessary `list` comprehension (rewrite using `list()`)
"E117", # Over-indented
"E231", # Missing whitespace after ','
"E401", # Multiple imports on one line
"E402", # Module level import not at top of file
"E711", # Comparison to `None` should be `cond is not None`
"E712", # Comparison to `True` should be `cond is True` or `if cond:`
"E721", # Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
"E722", # Do not use bare `except`
"F401", # `re` imported but unused
"F403", # `from python_terraform import *` used; unable to detect undefined names
"F405", # `IsNotFlagged` may be undefined, or defined from star imports
"F541", # f-string without any placeholders
"F811", # Redefinition of unused `hide_values_in_op_json` from line 565
"F821", # Undefined name `os`
"PIE790", # Unnecessary `pass` statement
"PLR1714", # Consider merging multiple comparisons. Use a `set` if the elements are hashable.
"Q004", # Unnecessary escape on inner quote character
"RET507", # Unnecessary `else` after `continue` statement
"RET508", # Unnecessary `elif` after `break` statement
"W292", # No newline at end of file
"W293", # Blank line contains whitespace
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll send a subsequent PR(s) to fix all this.

@jstourac jstourac merged commit 2582458 into red-hat-data-services:master Jan 6, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
utils Enhancements in scripts and CI/CD (PR will be listed in release-notes)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants