diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index f1b418fbe..cd9bb422d 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -22,12 +22,9 @@ jobs: - name: Install dev requirements run: | python -m pip install -r dev-requirements.txt - - name: pycodestyle + - name: ruff run: | - python -m pycodestyle --ignore=E501,E701,E731,W503 pynxtools tests --exclude=pynxtools/definitions - - name: pylint - run: | - python -m pylint pynxtools tests --ignore definitions + ruff pynxtools tests - name: mypy run: | - python -m mypy --ignore-missing-imports --follow-imports=silent --no-strict-optional --exclude=pynxtools/definitions pynxtools tests + mypy pynxtools tests diff --git a/.vscode/settings.json b/.vscode/settings.json index 94dada964..48b73f9c2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,33 +2,14 @@ "editor.rulers": [90], "editor.renderWhitespace": "all", "editor.tabSize": 4, - "[javascript]": { - "editor.tabSize": 2 - }, "files.trimTrailingWhitespace": true, - "python.linting.pycodestylePath": "pycodestyle", - "python.linting.pycodestyleEnabled": true, - "python.linting.pycodestyleArgs": ["--ignore=E501,E701,E731,W503"], - "python.linting.mypyEnabled": true, - "python.linting.mypyArgs": [ - "--ignore-missing-imports", - "--follow-imports=silent", - "--no-strict-optional", - "--show-error-codes" - ], - "python.linting.pylintEnabled": true, - "python.linting.enabled": true, - "python.linting.pylintArgs": [ - "--load-plugins=nomad.metainfo.pylint_plugin", - "pynxtools", - "tests" - ], "[python]": { - "editor.defaultFormatter": "ms-python.black-formatter", - "editor.formatOnSave": false, + "editor.formatOnSave": true, "editor.codeActionsOnSave": { - "source.organizeImports": false - } + "source.fixAll": true, + "source.organizeImports": true + }, + "editor.defaultFormatter": "charliermarsh.ruff" }, "python.testing.pytestArgs": ["tests"], "python.testing.unittestEnabled": false, diff --git a/dev-requirements.txt b/dev-requirements.txt index f6ac22e2f..b081dcdd5 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -4,6 +4,10 @@ # # pip-compile --extra=dev --output-file=dev-requirements.txt pyproject.toml # +appnope==0.1.3 + # via + # ipykernel + # ipython asciitree==0.3.3 # via zarr ase==3.22.1 @@ -12,8 +16,6 @@ ase==3.22.1 # pynxtools (pyproject.toml) asteval==0.9.31 # via lmfit -astroid==3.0.1 - # via pylint asttokens==2.4.1 # via stack-data attrs==23.1.0 @@ -44,13 +46,16 @@ comm==0.2.0 contourpy==1.1.1 # via matplotlib coverage[toml]==7.3.2 - # via pytest-cov + # via + # coverage + # pytest-cov cycler==0.12.1 # via matplotlib cython==3.0.6 # via tables dask[array]==2023.5.0 # via + # dask # hyperspy # kikuchipy # orix @@ -71,9 +76,7 @@ diffsims==0.5.2 # kikuchipy # pyxem dill==0.3.7 - # via - # hyperspy - # pylint + # via hyperspy entrypoints==0.4 # via ipyparallel exceptiongroup==1.2.0 @@ -138,6 +141,7 @@ importlib-metadata==6.8.0 # via # dask # hyperspy + # pynxtools (pyproject.toml) iniconfig==2.0.0 # via pytest ipykernel==6.27.1 @@ -149,8 +153,6 @@ ipython==8.12.3 # hyperspy # ipykernel # ipyparallel -isort==5.12.0 - # via pylint jedi==0.19.1 # via ipython jinja2==3.1.2 @@ -200,8 +202,6 @@ matplotlib-inline==0.1.6 # ipython matplotlib-scalebar==0.8.1 # via orix -mccabe==0.7.0 - # via pylint mergedeep==1.3.4 # via pynxtools (pyproject.toml) mpmath==1.3.0 @@ -339,7 +339,6 @@ platformdirs==4.0.0 # via # jupyter-core # pooch - # pylint # requests-cache pluggy==1.3.0 # via pytest @@ -367,14 +366,10 @@ py-cpuinfo==9.0.0 # via tables pycifrw==4.4.6 # via diffpy-structure -pycodestyle==2.11.1 - # via pynxtools (pyproject.toml) pyfai==2023.9.0 # via pyxem pygments==2.17.2 # via ipython -pylint==3.0.2 - # via pynxtools (pyproject.toml) pyparsing==3.1.1 # via matplotlib pyproject-hooks==1.0.0 @@ -427,6 +422,8 @@ requests==2.31.0 # requests-cache requests-cache==1.1.1 # via pynxtools (pyproject.toml) +ruff==0.1.7 + # via pynxtools (pyproject.toml) scikit-image==0.20.0 # via # hyperspy @@ -487,11 +484,8 @@ tomli==2.0.1 # coverage # mypy # pip-tools - # pylint # pyproject-hooks # pytest -tomlkit==0.12.3 - # via pylint toolz==0.12.0 # via # dask @@ -535,7 +529,6 @@ types-requests==2.31.0.10 # via pynxtools (pyproject.toml) typing-extensions==4.8.0 # via - # astroid # cattrs # mypy tzdata==2023.3 diff --git a/pyproject.toml b/pyproject.toml index 4cd3568c4..1b68efa7a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,8 +54,7 @@ dependencies = [ [project.optional-dependencies] dev = [ "mypy", - "pylint", - "pycodestyle", + "ruff", "pytest", "pytest-timeout", "pytest-cov", @@ -83,3 +82,36 @@ exclude = ["pynxtools/definitions*"] [tool.setuptools_scm] version_scheme = "no-guess-dev" local_scheme = "node-and-date" + +[tool.ruff] +include = ["pynxtools/*.py", "tests/*.py"] +select = [ + "E", # pycodestyle + "W", # pycodestyle + "PL", # pylint +] +ignore = [ + "E501", # Line too long ({width} > {limit} characters) + "E701", # Multiple statements on one line (colon) + "E731", # Do not assign a lambda expression, use a def + "E402", # Module level import not at top of file + "PLR0911", # Too many return statements + "PLR0912", # Too many branches + "PLR0913", # Too many arguments in function definition + "PLR0915", # Too many statements + "PLR2004", # Magic value used instead of constant + "PLW0603", # Using the global statement + "PLW2901", # redefined-loop-name + "PLR1714", # consider-using-in + "PLR5501", # else-if-used +] +fixable = ["ALL"] +exclude = ["pynxtools/definitions/*"] + +[tool.mypy] +strict = false +ignore_missing_imports = true +follow_imports = "silent" +no_strict_optional = true +disable_error_code = "import, annotation-unchecked" +exclude = ["pynxtools/definitions/*"]