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 for Python file format and lint #1584

Merged
merged 13 commits into from
Sep 25, 2024
Merged

Conversation

tigercosmos
Copy link
Collaborator

@tigercosmos tigercosmos commented Sep 19, 2024

As discussed in #1562, use Ruff for Python file formatting and linting.

@tigercosmos tigercosmos changed the base branch from master to dev September 19, 2024 01:53
Copy link

codecov bot commented Sep 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.88%. Comparing base (4417695) to head (ff50bee).
Report is 1 commits behind head on dev.

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     
Flag Coverage Δ
fedora40 74.38% <ø> (+0.01%) ⬆️
macos-12 80.85% <ø> (-0.02%) ⬇️
macos-13 80.27% <ø> (+<0.01%) ⬆️
macos-14 80.20% <ø> (ø)
mingw32 70.20% <ø> (-0.03%) ⬇️
mingw64 70.17% <ø> (-0.03%) ⬇️
npcap 84.74% <ø> (-0.09%) ⬇️
rhel94 74.23% <ø> (-0.01%) ⬇️
ubuntu2004 57.78% <ø> (-0.04%) ⬇️
ubuntu2004-zstd 57.91% <ø> (+<0.01%) ⬆️
ubuntu2204 74.16% <ø> (-0.01%) ⬇️
ubuntu2204-icpx 58.32% <ø> (-0.04%) ⬇️
ubuntu2404 74.42% <ø> (-0.01%) ⬇️
unittest 82.88% <ø> (-0.02%) ⬇️
windows-2019 84.86% <ø> (-0.02%) ⬇️
windows-2022 84.86% <ø> (-0.02%) ⬇️
winpcap 84.83% <ø> (-0.02%) ⬇️
xdp 49.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tigercosmos tigercosmos marked this pull request as ready for review September 19, 2024 04:25
@tigercosmos tigercosmos changed the title add Ruff add Ruff for Python file format and lint Sep 19, 2024
@@ -21,10 +35,6 @@ repos:
- id: mixed-line-ending
args: ['--fix=lf']
- id: trailing-whitespace
- repo: https://github.com/psf/black
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no need black now.

import subprocess

EXPECTED_RUFF_VERSION = "0.6.5"

Copy link
Collaborator Author

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:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

lint errors from Ruff.

@tigercosmos
Copy link
Collaborator Author

@seladb could you take a look?

Comment on lines 10 to 23
- 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
Copy link
Owner

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

Copy link
Collaborator Author

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.

@@ -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
Copy link
Owner

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

Comment on lines 10 to 13
- id: check-ruff-format-version
name: Check ruff-format version
entry: python3 ./ci/check-ruff-version.py
language: system
Copy link
Owner

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

@tigercosmos tigercosmos merged commit bd7884b into seladb:dev Sep 25, 2024
40 checks passed
@tigercosmos tigercosmos deleted the ruff branch September 25, 2024 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants