8000 Adds ruff for linting + autoformatting by domna · Pull Request #200 · FAIRmat-NFDI/pynxtools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Adds ruff for linting + autoformatting #200

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

Merged
merged 4 commits into from
Dec 19, 2023
Merged
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
10 changes: 5 additions & 5 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ 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
ruff pynxtools tests
- name: ruff formatting
run: |
python -m pylint pynxtools tests --ignore definitions
ruff format --check 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
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.7
hooks:
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
29 changes: 5 additions & 24 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
![](https://github.com/FAIRmat-NFDI/pynxtools/actions/workflows/pytest.yml/badge.svg)
![](https://github.com/FAIRmat-NFDI/pynxtools/actions/workflows/pylint.yml/badge.svg)
![](https://github.com/FAIRmat-NFDI/pynxtools/actions/workflows/publish.yml/badge.svg)
Expand Down Expand Up @@ -61,6 +62,14 @@ python -m pip install -e .
python -m pip install -e ".[dev]"
```

There is also a [pre-commit hook](https://pre-commit.com/#intro) available
which formats the code and checks the linting before actually commiting.
It can be installed with
```shell
pre-commit install
```
from the root of this repository.

## Test this software

Especially relevant for developers, there exists a basic test framework written in
Expand Down
47 changes: 28 additions & 19 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -30,6 +32,8 @@ cattrs==23.2.2
# via requests-cache
certifi==2023.11.17
# via requests
cfgv==3.4.0
# via pre-commit
charset-normalizer==3.3.2
# via requests
click==8.1.7
Expand All @@ -44,13 +48,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
Expand All @@ -71,9 +78,9 @@ diffsims==0.5.2
# kikuchipy
# pyxem
dill==0.3.7
# via
# hyperspy
# pylint
# via hyperspy
distlib==0.3.7
# via virtualenv
entrypoints==0.4
# via ipyparallel
exceptiongroup==1.2.0
Expand All @@ -88,6 +95,8 @@ fabio==2023.10.0
# silx
fasteners==0.19
# via zarr
filelock==3.13.1
# via virtualenv
flatdict==4.0.1
# via pynxtools (pyproject.toml)
fonttools==4.45.1
Expand Down Expand Up @@ -122,6 +131,8 @@ hyperspy==1.7.6
# kikuchipy
# pynxtools (pyproject.toml)
# pyxem
identify==2.5.33
# via pre-commit
idna==3.6
# via requests
ifes-apt-tc-data-modeling==0.1
Expand All @@ -138,6 +149,7 @@ importlib-metadata==6.8.0
# via
# dask
# hyperspy
# pynxtools (pyproject.toml)
iniconfig==2.0.0
# via pytest
ipykernel==6.27.1
Expand All @@ -149,8 +161,6 @@ ipython==8.12.3
# hyperspy
# ipykernel
# ipyparallel
isort==5.12.0
# via pylint
jedi==0.19.1
# via ipython
jinja2==3.1.2
Expand Down Expand Up @@ -200,8 +210,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
Expand Down Expand Up @@ -236,6 +244,8 @@ nionutils==0.4.6
# nionswift
# nionswift-io
# nionui
nodeenv==1.8.0
# via pre-commit
numba==0.58.1
# via
# diffsims
Expand Down Expand Up @@ -339,8 +349,8 @@ platformdirs==4.0.0
# via
# jupyter-core
# pooch
# pylint
# requests-cache
# virtualenv
pluggy==1.3.0
# via pytest
ply==3.11
Expand All @@ -349,6 +359,8 @@ pooch==1.8.0
# via
# kikuchipy
# orix
pre-commit==3.5.0
# via pynxtools (pyproject.toml)
prettytable==3.9.0
# via hyperspy
prompt-toolkit==3.0.41
Expand All @@ -367,14 +379,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
Expand Down Expand Up @@ -411,6 +419,7 @@ pyyaml==6.0.1
# dask
# hyperspy
# kikuchipy
# pre-commit
# pynxtools (pyproject.toml)
pyzmq==25.1.1
# via
Expand All @@ -427,6 +436,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
Expand Down Expand Up @@ -487,11 +498,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
Expand Down Expand Up @@ -535,7 +543,6 @@ types-requests==2.31.0.10
# via pynxtools (pyproject.toml)
typing-extensions==4.8.0
# via
# astroid
# cattrs
# mypy
tzdata==2023.3
Expand All @@ -555,6 +562,8 @@ urllib3==2.1.0
# requests
# requests-cache
# types-requests
virtualenv==20.25.0
# via pre-commit
wcwidth==0.2.12
# via
# prettytable
Expand Down
Loading
0