-
Notifications
You must be signed in to change notification settings - Fork 675
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
Changes from 9 commits
da60863
300a528
3c95c28
5a93d58
4effd74
2402bbb
019e2fc
8715337
0fb9dce
ebf9832
b2ab889
0ed97e3
ff50bee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,20 @@ repos: | |
name: Check clang-format version | ||
entry: python3 ./ci/check-clang-format-version.py | ||
language: system | ||
- 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 commentThe reason will be displayed to describe this comment to others. Learn more. Now that we use |
||
- 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 commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we use It can make it easier to upgrade There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.6.0 | ||
hooks: | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. no need black now. |
||
rev: 24.8.0 | ||
hooks: | ||
- id: black | ||
- repo: https://github.com/pocc/pre-commit-hooks | ||
rev: v1.3.5 | ||
hooks: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. lint errors from Ruff. |
||
return None | ||
|
||
if len(line_parts[0]) == 6: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import os | ||
import filecmp | ||
import pytest | ||
from .test_utils import ( | ||
ExampleTest, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import subprocess | ||
|
||
EXPECTED_RUFF_VERSION = "0.6.5" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check the version. |
||
|
||
def main(): | ||
result = subprocess.run(("ruff", "--version"), capture_output=True) | ||
result.check_returncode() | ||
|
||
version_str = result.stdout.decode("utf-8").split(" ")[1].strip() | ||
if version_str != EXPECTED_RUFF_VERSION: | ||
raise ValueError( | ||
f"Error: Found ruff version {version_str}, but {EXPECTED_RUFF_VERSION} is required." | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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