-
Notifications
You must be signed in to change notification settings - Fork 10
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
ci: implement ruff #554
ci: implement ruff #554
Conversation
882115a
to
8ca2ed4
Compare
793373e
to
2422406
Compare
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.
Nice work :D I left very minor comments and seems all great. Three other things:
- You used Prettier on non-python files, what about adding it as the default formatter for non-python files in the vscode settings? It would be even better to have ruff as the default for non-python files as well, but I think that ruff is for python files only, right?
- I had a lower version of ruff (0.1.4 instead of the latest, 0.1.13) and it was giving me 4 errors when running
ruff .
from local. No errors with the updated ruff version. I'd add the version on the dependencies list in the toml file (ruff >= 0.1.13) - When I run
ruff format .
, I get the following warning:
The following rules may cause conflicts when used with the formatter: 'ISC001'. To avoid unexpected behavior, we recommend disabling these rules, either by removing them from the 'select' or 'extend-select' configuration, or adding them to the 'ignore' configuration.
86 files left unchanged
Maybe is a good idea to disable ISC001 adding it to the ignore configuration in the toml file?
README.dev.md
Outdated
|
||
We use [prospector](https://pypi.org/project/prospector/) with pyroma for linting. For running it locally, use `prospector` or `prospector <filepath_or_folderpath>` for specific files/folders. | ||
We use [ruff](https://docs.astral.sh/ruff/) for linting, sorting imports and formatting code. The configurations of `ruff` are set in [pyproject.toml](pyproject.toml) file. If you are using VS code, you can activate the [Ruff extension](charliermarsh.ruff) to automatically format the code and flag linting issues upon saving. Otherwise, please check both linting (`ruff .`) and formatting (`ruff format .`, this automatically formats the entire code base) before requesting a review. |
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.
Add the correct link for project.toml file
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.
The link works like this.
tests/__init__.py
Outdated
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.
I guess that ruff added it. Do we know why? Is also added init files in each tests subfolder
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.
from INP001:
Python packages are directories that contain a file named init.py. The existence of this file indicates that the directory is a Python package, and so it can be imported the same way a module can be imported.
Directories that lack an init.py file can still be imported, but they're indicative of a special kind of package, known as a "namespace package" (see: PEP 420). Namespace packages are less widely used, so a package that lacks an init.py file is typically meant to be a regular package, and the absence of the init.py file is probably an oversight.
d84e2af
to
7dc2526
Compare
Done in 7dc2526 (edited style: format non-python files)
Done in b5767f6 (edited ci: set up ruff linter)
This is because the format may put strings that are on sequential lines onto the same line but keeps them as two separate strings and this creates the linting issue you reference. I think we do want the formatter to do this and for the linter to pick it up. |
Implement ruff linter and formatter in deeprank in lieu of prospector.
best reviewed one commit at a time:
pyproject.toml
and remove.prospector.yml
pyproj.toml
ruff format .
)ruff .
(or suppressed)closes #541