-
Notifications
You must be signed in to change notification settings - Fork 426
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
Switch pre-commit hooks to ruff (100x faster pre-commit, updated code style) #2295
Comments
Sounds like a good idea for after 1.1.11. |
Replace yapf and flake8 with ruff. Install: pip install ."[dev]"" pre-commit install Run pre-commit hooks: pre-commit run -a Related pwr-Solaar#2295
@MattHag Go ahead and create a PR for this. |
@MattHag One potential issue is that it currently doesn' t look as if roff has the --fix flag when run from pre-commit. That would be useful. |
Another potential issue is that the line-length in Solaar is currently set to 127, not 120. |
That's all not an issue, might fix it later today. |
Excellent. |
Replace yapf, isort and flake8 with much faster ruff formatter. Install: pip install ."[dev]" pre-commit install Run pre-commit hooks: pre-commit run -a Related pwr-Solaar#2295
Format code: make format Lint code (automatically fixing issues when possible): make lint Related pwr-Solaar#2295
Run ruff formatter using: ruff format . Related pwr-Solaar#2295
Run ruff formatter using: ruff format . Related pwr-Solaar#2295
Replace yapf, isort and flake8 with much faster ruff formatter and enforce double quote strings. Install: pip install ."[dev]" pre-commit install Run pre-commit hooks: pre-commit run -a Related pwr-Solaar#2295
Format code: make format Lint code (automatically fixing issues when possible): make lint Related pwr-Solaar#2295
Run ruff formatter using: ruff format . Related pwr-Solaar#2295
Replace yapf, isort and flake8 with much faster ruff formatter. Remove conflicting rule and switch to double quotes for strings. Install: pip install ."[dev]" pre-commit install Run pre-commit hooks: pre-commit run -a Related pwr-Solaar#2295
Format code: make format Lint code (automatically fixing issues when possible): make lint Related pwr-Solaar#2295
Run ruff formatter using: ruff format . Related pwr-Solaar#2295
Replace yapf, isort and flake8 with much faster ruff formatter. Remove conflicting rule and switch to double quotes for strings. Install: pip install ."[dev]" pre-commit install Run pre-commit hooks: pre-commit run -a Related pwr-Solaar#2295
Format code: make format Lint code (automatically fixing issues when possible): make lint Related pwr-Solaar#2295
Run ruff formatter using: ruff format . Related pwr-Solaar#2295
Format code: make format Lint code (automatically fixing issues when possible): make lint Related pwr-Solaar#2295
Run ruff auto formatting using: ruff format . Related pwr-Solaar#2295
Run ruff auto formatting using: ruff format . Related pwr-Solaar#2295
Replace yapf, isort and flake8 with much faster ruff formatter. Remove conflicting rule and switch to double quotes for strings. Install: pip install ."[dev]" pre-commit install Run pre-commit hooks: pre-commit run -a Related #2295
Format code: make format Lint code (automatically fixing issues when possible): make lint Related #2295
Run ruff auto formatting using: ruff format . Related #2295
@MattHag |
Install latest pre-commit hooks Run ruff lint (with autofix, where possible) |
When I do a commit ruff doesn't fix the files, like yapf and isort used to. For example,
But the file is not changed. |
Ah wait, I switched the pre-commit to |
Try again |
That's got it, thanks. |
Fixed by #2316 |
This makes commits easier to compare. Related pwr-Solaar#2295
# Usage pre-commit run --all-files Related pwr-Solaar#2295
This makes commits easier to compare. Related pwr-Solaar#2295
# Usage pre-commit run --all-files Related pwr-Solaar#2295
This makes commits easier to compare. Related pwr-Solaar#2295
# Usage pre-commit run --all-files Related pwr-Solaar#2295
This makes commits easier to compare. Related #2295
# Usage pre-commit run --all-files Related #2295
Information
Is your feature request related to a problem? Please describe.
Unique formatting of code and linting is enforced by CI checks using a pre-commit hook with yapf, isort and flake8.
Especially, the yapf code formatter and flake8 linter are slow compared to modern tools. This renders yapf
Describe the solution you'd like
The fastest Python code formatter on the market is currently ruff format, which is 100x faster than yapf. In addition to code formatting, the ruff linter can also replace isort and flake8. That would reduce the development dependencies from three to one and dramatically speed up pre-commit hooks.
pre-commit run -a
or just ruff format. You then leverage a shortcut for auto-formatting or your IDE's format-on-save feature, ruff plugin etc. This saves you from reformatting, lists, dictionaries etc. during coding manually.Describe alternatives you've considered
The Black formatter is roughly twice as fast as yapf, but still slow in comparison to ruff. The capabilities of ruff are now 99.9% on par with black, but it runs 30x faster. That's a big difference as pre-commit hook, but also results in a faster CI pipeline.
The text was updated successfully, but these errors were encountered: