-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LORIS-MRI tooling configuration (#1170)
* add pyproject.toml * keep flake8 (for now) * double type checking * Use Pyright as main type checker * remove comment * test * test * change configuration * add python environment variables * try factorization * test * test * test * test * remove temporary things * test ruff error * ruff output github * further test errors * test pyright output github * test * test * test * change comment * remove test errors * test --------- Co-authored-by: Maxime Mulder <[email protected]>
- Loading branch information
1 parent
79520d7
commit 72634dd
Showing
6 changed files
with
132 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Set up Python | ||
input: | ||
inputs: | ||
python-version: | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- name: Set up the Python environment | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: 'pip' | ||
|
||
- name: Install Python dependencies | ||
run: pip install -r python/requirements.txt | ||
shell: bash | ||
|
||
- name: Set up environment variables | ||
run: echo PYTHONPATH=$PYTHONPATH:/`pwd`/python:/`pwd`/python/react-series-data-viewer >> $GITHUB_ENV | ||
shell: bash |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Python checks | ||
|
||
on: | ||
- push | ||
- pull_request | ||
|
||
jobs: | ||
ruff: | ||
name: "Ruff" | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: ["3.11", "3.12"] | ||
|
||
steps: | ||
- name: Check out LORIS-MRI | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: ./.github/actions/setup-python | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Run Ruff | ||
run: ruff check --output-format=github | ||
|
||
pyright-strict: | ||
name: "Pyright strict" | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: ["3.11", "3.12"] | ||
|
||
steps: | ||
- name: Check out LORIS-MRI | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: ./.github/actions/setup-python | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
# Like in the other Pyright run, the `jq` arcane is used to translate the errors from JSON to | ||
# the GitHub actions format | ||
- name: Run Pyright | ||
run: | | ||
pyright --outputjson | jq -r '.generalDiagnostics[] | "::error file=\(.file),line=\(.range.start.line),col=\(.range.start.character)::\(.message)"' | ||
(exit ${PIPESTATUS[0]}) | ||
pyrigh-global: | ||
name: "Pyright global" | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
python-version: ["3.11", "3.12"] | ||
|
||
steps: | ||
- name: Check out LORIS-MRI | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: ./.github/actions/setup-python | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Run Pyright | ||
run: | | ||
cd test | ||
pyright --outputjson | jq -r '.generalDiagnostics[] | "::error file=\(.file),line=\(.range.start.line),col=\(.range.start.character)::\(.message)"' | ||
(exit ${PIPESTATUS[0]}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[tool.ruff] | ||
include = ["python/**/*.py"] | ||
exclude = ["python/react-series-data-viewer"] | ||
line-length = 120 | ||
preview = true | ||
|
||
[tool.ruff.lint] | ||
ignore = ["E202", "E203", "E221", "E241", "E251", "E272"] | ||
# TODO: Select "F", "I", "N", "UP" and format the codebase accordingly. | ||
select = ["E", "W"] | ||
|
||
# The strict type checking configuration is used to type check only the modern (typed) modules. An | ||
# additional basic type checking configuration to type check legacy modules can be found in the | ||
# `test` directory. | ||
|
||
[tool.pyright] | ||
include = [ | ||
"python/lib/db", | ||
"python/lib/exception", | ||
"python/lib/validate_subject_ids.py" | ||
] | ||
typeCheckingMode = "strict" | ||
reportMissingTypeStubs = "none" | ||
|
||
[tool.pytest.ini-options] | ||
testpaths = ["python/tests"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"include": ["../python"], | ||
"exclude": ["../python/react-series-data-viewer"], | ||
"typeCheckingMode": "off", | ||
"reportDeprecated": "warning", | ||
"reportMissingImports": "error" | ||
} |