Skip to content
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

linting: change linter to ruff #522

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
extras-require: test
- name: Check style against standards using prospector
run: prospector --die-on-tool-error
- name: Check style against standards using ruff
run: ruff .

50 changes: 0 additions & 50 deletions .prospector.yml

This file was deleted.

19 changes: 15 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
{
"editor.rulers": [
80,
100
],
// python
"[python]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.organizeImports": true
"source.fixAll.ruff": true,
"source.organizeImports.ruff": true,
},
"linting.prospectorEnabled": false,
"files.trimTrailingWhitespace": true,
"defaultInterpreterPath": "",
"python.languageServer": "Pylance",
},

"python.linting.prospectorEnabled": true,
// python docstring
"autoDocstring.docstringFormat": "google",
"notebook.lineNumbers": "on",

"notebook.diff.ignoreMetadata": true,
"[*.yml]": {
"files.trimTrailingWhitespace": true,
},
Expand Down
2 changes: 1 addition & 1 deletion README.dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ coverage report

## Linting

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.

## Versioning

Expand Down
53 changes: 50 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,14 @@ dependencies = [
"tqdm >= 4.63.0",
"freesasa >= 2.1.0",
"tensorboard >= 0.9.0",
"protobuf >= 3.20.1"
"protobuf >= 3.20.1",
"ruff"
]

[project.optional-dependencies]
# development dependency groups
test = [
"pytest >= 7.4.0",
"pylint <= 2.17.5",
"prospector[with_pyroma] <= 1.10.2",
"bump2version",
"coverage",
"pycodestyle",
Expand All @@ -83,3 +82,51 @@ source = ["deeprank2"]
[tool.setuptools.packages.find]
include = ["deeprank2*"]
exclude = ["tests*"]

[tool.ruff]
# Exclude a variety of commonly ignored directories.
exclude = [
"docs",
"reduce"
]
target-version = "py310"
line-length = 159
select = [
"F", # Pyflakes
"E", # pycodestyle (error)
"W", # pycodestyle (warning)
"I", # isort
"D", # pydocstyle
]
ignore = [
"D100", # Missing module docstring
"D101", # Missing docstring in public class
"D102", # Missing docstring in public method
"D103", # Missing docstring in public function
"D104", # Missing public package docstring
"D105", # Missing docstring in magic method
"D107", # Missing docstring in `__init__`
# The following list excludes rules irrelevant to the Google style
"D203", # 1 blank line required before class docstring
"D204",
"D212", # Multi-line docstring summary should start at the first line
"D213", # Multi-line docstring summary should start at the second line
"D215",
"D400",
"D401",
"D404", # First word of the docstring should not be This
"D406",
"D407",
"D408",
"D409",
"D413",
]

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "I"]

[tool.ruff.isort]
known-first-party = ["deeprank2"]
force-single-line = true
lines-after-imports = 2
no-lines-before = ["future","standard-library","third-party","first-party","local-folder"]
Loading