-
Notifications
You must be signed in to change notification settings - Fork 16
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
add: ruff linter #293
base: master
Are you sure you want to change the base?
add: ruff linter #293
Conversation
We're already using |
We're using semantic-release for (Our own |
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.
Thanks very much for this.
@@ -4,4 +4,3 @@ | |||
|
|||
if not Env.current.is_appmap_repo and Env.current.enables("unittest"): | |||
logger.debug("Test recording is enabled (unittest)") | |||
import _appmap.unittest # pyright: ignore pylint: disable=unused-import |
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.
This import needs to be retained, so it should be marked with # noqa: F401
rather than deleted.
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.
Fixed
pyproject.toml
Outdated
@@ -49,6 +49,7 @@ packaging = ">=19.0" | |||
# | |||
# So, if you'd like to run the tests outside of tox, run `pip install -r requirements-dev.txt` to | |||
# install it and the rest of the dev dependencies. | |||
ruff = "^0.3.3" |
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.
This should be in the dev
dependencies (below).
Updated the commit message. Hopefully chose the correct one. |
Most of projects are now moving from pylint to ruff. Also, the fastapi unused wsgimiddleware import, ruff highlighted it, but I didn't notice it as such in the pylint output. This was a suggestion for replacing pylint with ruff and not both together. I am not aware of other places where you might have to replace pylint in the dev environments/ CI etc. |
We need to retain this functionality if we switch to ruff, so this PR would need to include changes to do that, as well. |
@apotterri Just to confirm, this is executed when running tox? Also, what is the expected outcome here? Tests should fail if there is any pylint error? As pylint-exit only returns 1 on |
Yes, it's run when the pylint computes a score for the code, and has a setting that controls the minimum score: https://github.com/getappmap/appmap-python/blob/master/pylintrc#L3 . If the code that's getting built has a score that's below that threshold, pylint-exit returns non-zero. |
Doesn't seem to be working that way.
|
That would be bug, then. It's intended to work that way, and I thought that was the description from pylint-exit. |
Looking again at the doc for pylint-exit, I see that I misread it. It doesn't clean to exit non-zero if the |
As far as replacing pylint with ruff.... I'm concerned about the statement here that ruff isn't a drop-in replacement for pylint: https://docs.astral.sh/ruff/faq/#how-does-ruffs-linter-compare-to-pylint , and especially that it does less type checking. Also astral-sh/ruff#970 . |
Yes, ruff is used along with mypy. But at this time, adding type annotation for every variable might be a big task. We can leave adding ruff in backlog as a future task, but address the highlighted issues in a separate PR. |
poetry run ruff check --fix appmap
https://docs.astral.sh/ruff/