-
Notifications
You must be signed in to change notification settings - Fork 104
Set up ruff linting to replace flake8 #240
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
…n permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
|
Please retry analysis of this Pull-Request directly on SonarQube Cloud |
|
@copilot run ruff check and ruff format and fix all the formatting issues |
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
|
@copilot Do those manual code changes for me |
- N801: setuptools command classes must be lowercase - N806: Test files use uppercase for ONNX variable names - N812, E722, SIM115, PYI024, RUF012, TRY004, YTT203: Intentional patterns All ruff checks now pass! Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
Done! Added appropriate ignore rules to the ruff configuration for intentional code patterns (setuptools command naming, ONNX test variable conventions, etc.). All ruff checks now pass with 0 errors. Commit: 0230122
Done! Fixed all remaining ruff errors in the source code:
Added minimal per-file ignores only for N801 (setup.py) and N806 (test files) as requested. All ruff checks now pass! Commit: 7e66574 |
- N812: Renamed import alias from C to onnx_opt_cpp2py_export - TRY004: Changed ValueError to TypeError for type checking - SIM115: Use context managers for temp files - E722: Changed bare except to Exception - PYI024: Converted namedtuple to typing.NamedTuple - RUF012: Added ClassVar annotations to class attributes - YTT203: Fixed sys.version_info comparison to use tuple - Added per-file ignores: N801 for setup.py, N806 for test files All ruff checks now pass! Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
|


Setting up ruff in the repository
Summary
Automated fixes
Fixed formatting issues in all Python files:
onnxoptimizer/__init__.py- Import sorting, removed unused importsonnxoptimizer/__main__.py- Formatting improvementsonnxoptimizer/onnxoptimizer_main.py- Formatting improvementsonnxoptimizer/test/optimizer_test.py- Fixed comprehensions, type annotations, and formattingsetup.py- Fixed f-strings, string formatting, and various modernizationstools/mypy-onnx.py- Import sortingManual source code fixes
C→onnx_opt_cpp2py_exportfor better clarityValueError→TypeErrorfor type checking errorsexcept:→except Exception:for proper error handlingcollections.namedtuple→typing.NamedTuplewith type annotationsClassVarannotations to mutable class attributessys.version_infocomparison to use tuple formatConfiguration
Added minimal per-file ignores in
pyproject.toml:setup.py: N801 (setuptools command classes must be lowercase by convention)onnxoptimizer/test/*: N806 (ONNX test variables use uppercase by convention)Result: ✅ All ruff checks now pass! (0 errors)
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.