Skip to content

LORIS-MRI tooling configuration #1170

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 25 commits into from
Sep 13, 2024
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
23 changes: 23 additions & 0 deletions .github/actions/setup-python/action.yml
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
42 changes: 0 additions & 42 deletions .github/workflows/flake8_python_linter.yml

This file was deleted.

73 changes: 73 additions & 0 deletions .github/workflows/python-checks.yml
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]})
26 changes: 26 additions & 0 deletions pyproject.toml
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"]
4 changes: 3 additions & 1 deletion python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
boto3
flake8
google
mat73
matplotlib
Expand All @@ -13,7 +12,10 @@ nose
numpy
protobuf>=3.0.0
pybids==0.17.0
pyright
pytest
python-dateutil
ruff
scikit-learn
scipy
sqlalchemy>=2.0.0
Expand Down
7 changes: 7 additions & 0 deletions test/pyrightconfig.json
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"
}
Loading