-
Notifications
You must be signed in to change notification settings - Fork 910
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
Introducing ruff as a linter to replace pylint, flake8 and isort #2634
Conversation
Playing around with it, it's amazingly fast. I get confused a little bit with max-length. It seems that it can only warn the line is too long but couldn't fix it. So I configure it to ignore E501(line-length), and just run black over it instead. There are subtle difference so they are not 1:1 mapping, but I guess |
Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
…nto replace-pylint Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
To test this you can still uncomment the existing setup. They are mostly identical but with some slight difference as |
❤️ |
This still calls pylint right? Maybe we can remove it from CI to see the difference in execution times |
Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
@astrojuanlu Ruff run almost instantly compare to pylint :) I have removed it from the pre-commit config now. |
Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
test_requirements.txt
Outdated
@@ -20,7 +20,6 @@ holoviews~=1.13.0 | |||
import-linter[toml]==1.8.0 | |||
ipython>=7.31.1, <8.0; python_version < '3.8' | |||
ipython~=8.10; python_version >= '3.8' | |||
isort~=5.0 | |||
Jinja2<3.1.0 | |||
joblib>=0.14 | |||
jupyterlab_server>=2.11.1, <2.16.0 # 2.16.0 requires importlib_metedata >= 4.8.3 which conflicts with flake8 requirement |
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.
Does this mean that we don't need to cap jupyterlab_server
anymore?
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.
xref #2700
Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
… of `else` then `if`, to reduce indentation Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
There are many linting error, many of them are not difference between For the changes that are obvious and meaningful, I have applied the changes and suppressed the rest. For example, this is a good fix hinted by |
.pre-commit-config.yaml
Outdated
name: "ruff on tests/ and docs/" | ||
# PLR2004: Magic value used | ||
# PLR0913: Too many arguments | ||
args: ["--fix", "--exit-non-zero-on-fix", "--ignore=PLR2004,PLR0913"] |
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.
Ruff allows you to have different sets of rules for these cases. Run the linter once, and select/ignore rules for testing.
For an example, check GitHub.com/ing-bank/popmon
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.
@sbrugman Could you share a link? Not sure if I missed anything, I checked their config but it does not use any arguments.
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.
See the section [tool.ruff.per-file-ignores] in pyproject.toml
Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
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.
Great work @noklam ⭐ I went through most of the changed files and can see that the changes minimal and mostly just changing # pylint: disable
to # noqa
.
Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
I don't want this PR stuck forever, since this is already very useful to speed up dev. Follows up:
|
I agree it would be super cool to get this in ASAP. Plugins can follow suit.
Just to clarify, is that something you want to do in this PR for the CI to pass? |
No, I will save this for future PRs. The lining is still failing for weird reason, I cannot reproduce it anywhere so I may have to ssh into it. Other than that it's block by the E2e test. |
The unsort import error is mysteriou, I cannot reproduce it anywhere. It's not important at all so I silent this error for the |
Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
Linting now all pass, only blocked by #2816, enable auto-merge. |
Signed-off-by: Nok nok.lam.chan@quantumblack.com
Description
The goal for this is to use
ruff
to replacepylint
, we should aim at compatible (99.9%) for this scope. We can decide later rather we should enable extra rule set.ruff
is much fast thanpylint
, which kills dev productivity for trivial changes.black
will be kept becauseruff
is not a formatter although it can flag issues with formatting.Development notes
linting.md
isort
,flake8
,pylint
from our CI (noted the dependencies are still here because we only deprecatekedro lint
in 0.19.0`Checklist
RELEASE.md
file