diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 4c0e1c9f4..e508d70bd 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -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 . + \ No newline at end of file diff --git a/.prospector.yml b/.prospector.yml deleted file mode 100644 index 75f1e737b..000000000 --- a/.prospector.yml +++ /dev/null @@ -1,50 +0,0 @@ -# prospector configuration file - ---- - -output-format: grouped - -strictness: medium -doc-warnings: false -test-warnings: true -member-warnings: false - -ignore-paths: - - docs - - reduce - -ignore-patterns: - - setup.py - -pyroma: - run: true - # pyroma gives errors in the setup.py file, - # thus we disable here these errors. - # This should not be happening, because - # prospector should be ignoring the setup.py - # file (see ignore-patterns above) - disable: - - PYR10 - - PYR11 - - PYRUNKNOWN - -pycodestyle: - full: true - options: - max-line-length: 159 - -pydocstyle: - disable: [ - # Disable because not part of PEP257 official convention: - # see http://pep257.readthedocs.io/en/latest/error_codes.html - D203, # 1 blank line required before class docstring - D212, # Multi-line docstring summary should start at the first line - D213, # Multi-line docstring summary should start at the second line - D404, # First word of the docstring should not be This - ] - -pylint: - disable: [ - logging-fstring-interpolation, - logging-not-lazy, - ] diff --git a/.vscode/settings.json b/.vscode/settings.json index 4b74dfbcf..fd61b6b4d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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, }, diff --git a/README.dev.md b/README.dev.md index d26caa755..501cdc8cf 100644 --- a/README.dev.md +++ b/README.dev.md @@ -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 ` 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 diff --git a/pyproject.toml b/pyproject.toml index bda2eac21..e2a65db8f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", @@ -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"]