-
Notifications
You must be signed in to change notification settings - Fork 113
feat: Lint Python with Ruff #4105
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
feat: Lint Python with Ruff #4105
Conversation
aglinxinyuan
left a comment
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.
Explain how to use the tool in the PR description.
aglinxinyuan
left a comment
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.
LGTM!
Please let people know they need to pip install ruff
Signed-off-by: Xinyuan Lin <xinyual3@uci.edu>
Yicong-Huang
left a comment
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.
Late LGTM. Thanks!
Left some minor comments, it will be good to address them with follow up PRs.
| proto | ||
| )/ | ||
| ''' | ||
| target-version = "py310" |
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.
I think it is better to always target the highest python version we support, in this case, python 3.12.
@LJX2017 can you change it in a follow up PR?
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.
According to the official document from Ruff, target-version = "py310" means we support Python >=3.10, including python 3.12 and 3.13. Is this already the correct behavior or should we change it?
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.
Ok. I had the wrong impression that we should always declare highest version. In this case, let's keep py310. We will need to remember to update it when we drop 3.10 support.
| tx_error "black not found. Install with: pip install black" | ||
| tx_info "Running ruff in amber/src/main/python..." | ||
| if ! command -v ruff >/dev/null 2>&1; then | ||
| tx_error "ruff not found. Install with: pip install ruff" |
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.
here the instruction should come with the exact version of ruff
What changes were proposed in this PR?
Basic Ruff commands:
Under amber/src/main/python
cd amber/src/main/pythonRun Ruff’s formatter in dry mode
ruff format --check .Run Ruff’s formatter
ruff format .Run Ruff’s linter
ruff check .Any related issues, documentation, discussions?
Closes #4078
How was this PR tested?
I created a PR on my own fork to ensure CI is working.
Was this PR authored or co-authored using generative AI tooling?
No