-
Notifications
You must be signed in to change notification settings - Fork 672
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 for Python file format and lint #1584
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #1584 +/- ##
==========================================
- Coverage 82.89% 82.88% -0.02%
==========================================
Files 273 273
Lines 46205 46205
Branches 9274 9288 +14
==========================================
- Hits 38300 38295 -5
+ Misses 7091 7049 -42
- Partials 814 861 +47
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
This reverts commit 2402bbb.
@@ -21,10 +35,6 @@ repos: | |||
- id: mixed-line-ending | |||
args: ['--fix=lf'] | |||
- id: trailing-whitespace | |||
- repo: https://github.com/psf/black |
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.
no need black now.
ci/check-ruff-version.py
Outdated
import subprocess | ||
|
||
EXPECTED_RUFF_VERSION = "0.6.5" | ||
|
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.
check the version.
@@ -75,7 +75,7 @@ def convert_line(line: str) -> list[str]: | |||
|
|||
|
|||
def parse_mac_and_vendor(line_parts: list[str]) -> Optional[LineElements]: | |||
if line_parts == None or len(line_parts) < 3: | |||
if line_parts is None or len(line_parts) < 3: |
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.
lint errors from Ruff.
@seladb could you take a look? |
.pre-commit-config.yaml
Outdated
- id: check-ruff-format-version | ||
name: Check ruff-format version | ||
entry: python3 ./ci/check-ruff-version.py | ||
language: system | ||
- id: ruff | ||
name: ruff | ||
entry: ruff check | ||
types_or: [python] | ||
language: system | ||
- id: ruff-format | ||
name: ruff-format | ||
entry: ruff format --check | ||
types_or: [python] | ||
language: system |
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.
Shouldn't we use ruff-pre-commit
?
It can make it easier to upgrade ruff
if we need to
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.
Originally I think it's more flexible to do it on our side, but I think it also works to use other's scripts.
.github/workflows/build_and_test.yml
Outdated
@@ -34,7 +34,7 @@ jobs: | |||
- name: Install dependencies | |||
run: | | |||
apk update && apk add cppcheck python3-dev | |||
python3 -m pip install cmake-format clang-format==18.1.6 | |||
python3 -m pip install cmake-format clang-format==18.1.6 ruff==0.6.5 |
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.
Now that we use ruff-pre-commit
I don't think this is needed
.pre-commit-config.yaml
Outdated
- id: check-ruff-format-version | ||
name: Check ruff-format version | ||
entry: python3 ./ci/check-ruff-version.py | ||
language: system |
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.
Now that we use ruff-pre-commit
this is not needed
As discussed in #1562, use Ruff for Python file formatting and linting.