-
Notifications
You must be signed in to change notification settings - Fork 20
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
QA: Use ruff instead of black + flake8 for formatting and linting #75
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 task
hnez
force-pushed
the
ruff
branch
3 times, most recently
from
April 29, 2024 10:40
e08d5c4
to
bcf9ec0
Compare
SmithChart
previously approved these changes
May 6, 2024
The main benefit of using ruff for us is that its rules are automatically consistent between the formatter and linter, while black and flake8 are often caught fighting about the correct formatting and need fine tuned configurations to prevent that. Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
Ruff and black are mostly compatible when it comes to their formatting decisions, but there are still subtle differences. Adapt the formatting to ruffs likings. Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
The setup.py and fastentrypoints.py fixes are somewhat superfluous, because they will go away with the switch to pyproject.toml, but fix them anyways. Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
Looks like |
Without this commit `ruff` complains about `i2c_gpio.py`: $ ruff usbsdmux/i2c_gpio.py:26:7: B024 `I2cGpio` is an abstract base class, but it has no abstract methods Found 1 error. The python docs say the following about abstract base classes [1]: Abstract base classes complement duck-typing by providing a way to define interfaces when other techniques like hasattr() would be clumsy or subtly wrong (for example with magic methods). ABCs introduce virtual subclasses, which are classes that don’t inherit from a class but are still recognized by isinstance() and issubclass(); see the abc module documentation. Which is not quite what `I2cGpio` is (a class that should never be used by itself, but should always be subclassed to form a more specifig i²c gpio expander class). `ruff` is thus correct in complaining about the use of ABC here. Fix the linter error by not inheriting from ABC. [1]: https://docs.python.org/3/glossary.html#term-abstract-base-class Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
The SIM rule implements the rules provided by "flake8-simplify", which describes itself as: A flake8 plugin that helps you simplify your code Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
Had a look and added bb17e2e, that removes the |
SmithChart
approved these changes
May 8, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The main benefit of using
ruff
for us is that its rules are automatically consistent between the formatter and linter, whileblack
andflake8
are often caught fighting about the correct formatting and need fine tuned configurations to prevent that.This aligns with changes we have previously made to usbmuxctl and lxa-iobus.
TODO before merging: