From 2257208ec3d3d862ce2b03d72397a33989e96f92 Mon Sep 17 00:00:00 2001 From: Alexander Goscinski Date: Mon, 18 Nov 2024 15:44:14 +0100 Subject: [PATCH] Update linter to aiida-core usage --- .pre-commit-config.yaml | 86 ++++++++++++++++++++++++----------------- pyproject.toml | 51 +++++++++++++++--------- 2 files changed, 83 insertions(+), 54 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cd32648..3548a7c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,23 +1,24 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 - hooks: - - id: end-of-file-fixer - - id: fix-encoding-pragma - - id: mixed-line-ending - - id: trailing-whitespace - - id: check-json - - id: check-yaml - - - repo: https://github.com/pycqa/isort - rev: '5.12.0' - hooks: - - id: isort - - - repo: https://github.com/psf/black - rev: '22.10.0' + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 hooks: - - id: black + - id: check-merge-conflict + - id: check-yaml + - id: double-quote-string-fixer + - id: end-of-file-fixer + exclude: &exclude_pre_commit_hooks > + (?x)^( + tests/.*(? + - id: check-github-workflows + + - repo: https://github.com/ikamensh/flynt/ + rev: 1.0.1 + hooks: + - id: flynt + args: [--line-length=120, --fail-on-change] + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.5.0 + hooks: + - id: ruff-format + exclude: &exclude_ruff > (?x)^( - docs/.*| + docs/source/topics/processes/include/snippets/functions/parse_docstring_expose_ipython.py| + docs/source/topics/processes/include/snippets/functions/signature_plain_python_call_illegal.py| + )$ + - id: ruff + exclude: *exclude_ruff + args: [--fix, --exit-non-zero-on-fix, --show-fixes] + + - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks + rev: v2.13.0 + hooks: + - id: pretty-format-toml + args: [--autofix] + - id: pretty-format-yaml + args: [--autofix] + exclude: >- + (?x)^( + tests/.*| + environment.yml| )$ diff --git a/pyproject.toml b/pyproject.toml index 8d1e264..c7392bf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,10 +25,10 @@ classifiers = [ keywords = ['aiida', 'workflows'] requires-python = '>=3.8' dependencies = [ - 'aiida-core~=2.0', - 'fastapi~=0.65.1', + #'aiida-core~=2.0', + #'fastapi~=0.65.1', 'uvicorn[standard]~=0.19.0', - 'pydantic~=1.10', + #'pydantic~=1.10', 'graphene~=2.0', 'python-dateutil~=2.0', 'lark~=0.11.0', @@ -84,23 +84,36 @@ exclude = [ [tool.isort] profile = 'black' -[tool.pylint.master] -extension-pkg-whitelist = ['pydantic'] - -[tool.pylint.format] -max-line-length = 125 - -[tool.pylint.messages_control] -disable = [ - 'duplicate-code', - 'fixme', - 'invalid-name', - 'too-many-ancestors', - 'too-many-arguments', +[tool.ruff] +line-length = 120 + +[tool.ruff.format] +quote-style = 'single' + +[tool.ruff.lint] +ignore = [ + 'F403', # Star imports unable to detect undefined names + 'F405', # Import may be undefined or defined from star imports + 'PLR0911', # Too many return statements + 'PLR0912', # Too many branches + 'PLR0913', # Too many arguments in function definition + 'PLR0915', # Too many statements + 'PLR2004', # Magic value used in comparison + 'RUF005', # Consider iterable unpacking instead of concatenation + 'RUF012' # Mutable class attributes should be annotated with `typing.ClassVar` +] +select = [ + 'E', # pydocstyle + 'W', # pydocstyle + 'F', # pyflakes + 'I', # isort + 'N', # pep8-naming + 'PLC', # pylint-convention + 'PLE', # pylint-error + 'PLR', # pylint-refactor + 'PLW', # pylint-warning + 'RUF' # ruff ] - -[tool.pylint.similarities] -ignore-imports = 'yes' [tool.pytest.ini_options] python_files = 'test_*.py example_*.py'