From f375360f64d222b36cf63850b5f05342ccb5fa4a Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 30 Aug 2024 11:19:11 -0400 Subject: [PATCH 01/25] add pyproject.toml --- pyproject.toml | 17 +++++++++++++++++ python/requirements.txt | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..f1b097368 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,17 @@ +[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: Add and apply "F", "I", "N", "UP" +select = ["E", "W"] + +[tool.pyright] +include = ["python"] +exclude = ["python/react-series-data-viewer"] + +[tool.pytest.ini-options] +testpaths = ["python/tests"] diff --git a/python/requirements.txt b/python/requirements.txt index 0d1abe193..9e5eaa6ed 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -1,5 +1,4 @@ boto3 -flake8 google mat73 matplotlib @@ -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 From b8727caf11c142e168bee7f7a5917724d4bc23cf Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 30 Aug 2024 11:21:27 -0400 Subject: [PATCH 02/25] keep flake8 (for now) --- python/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/python/requirements.txt b/python/requirements.txt index 9e5eaa6ed..9f258ee1b 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -1,4 +1,5 @@ boto3 +flake8 google mat73 matplotlib From 4cc3bae5d69f110661c07049acfd50cb76979a1c Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Tue, 3 Sep 2024 10:52:17 -0400 Subject: [PATCH 03/25] double type checking --- pyproject.toml | 24 +++++++++++++++++++++++- python/lib/db/connect.py | 2 +- python/requirements.txt | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f1b097368..235685c6c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,12 +6,34 @@ preview = true [tool.ruff.lint] ignore = ["E202", "E203", "E221", "E241", "E251", "E272"] -# TODO: Add and apply "F", "I", "N", "UP" +# TODO: Select "F", "I", "N", "UP" and format the codebase accordingly. select = ["E", "W"] +# We use Mypy to type check modern (typed) modules, and run a few Pyright-specific type checks on +# all code including untyped modules. We could also run a few Mypy type checks on untyped code in +# addition to the typed modules but configuring this behaviour is a little awkward at the time of +# this comment (Mypy 1.11.2). + +[tool.mypy] +files = "python" +exclude = "python/react-series-data-viewer" +ignore_errors = true + +[[tool.mypy.overrides]] +module = [ + "lib.db.*", + "lib.exception.*", + "lib.dataclass.*", +] +ignore_errors = false +strict = true + [tool.pyright] include = ["python"] exclude = ["python/react-series-data-viewer"] +typeCheckingMode = "off" +reportDeprecated = "error" +reportMissingImports = "error" [tool.pytest.ini-options] testpaths = ["python/tests"] diff --git a/python/lib/db/connect.py b/python/lib/db/connect.py index a58912f0f..0e2d406be 100644 --- a/python/lib/db/connect.py +++ b/python/lib/db/connect.py @@ -6,7 +6,7 @@ default_port = 3306 -def connect_to_db(credentials: dict[str, Any]): +def connect_to_db(credentials: dict[str, Any]) -> Session: host = credentials['host'] port = credentials['port'] username = credentials['username'] diff --git a/python/requirements.txt b/python/requirements.txt index 9f258ee1b..80ef36b70 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -5,6 +5,7 @@ mat73 matplotlib mne mne-bids>=0.6 +mypy mysql-connector mysqlclient nilearn From 6feea527ae9001f6745986af7a2952eb381b862a Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Wed, 4 Sep 2024 11:27:22 -0400 Subject: [PATCH 04/25] Use Pyright as main type checker --- pyproject.toml | 33 ++++++++++----------------------- python/lib/db/connect.py | 2 +- python/requirements.txt | 1 - test/pyrightconfig.json | 9 +++++++++ 4 files changed, 20 insertions(+), 25 deletions(-) create mode 100644 test/pyrightconfig.json diff --git a/pyproject.toml b/pyproject.toml index 235685c6c..2d09b6937 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,31 +9,18 @@ ignore = ["E202", "E203", "E221", "E241", "E251", "E272"] # TODO: Select "F", "I", "N", "UP" and format the codebase accordingly. select = ["E", "W"] -# We use Mypy to type check modern (typed) modules, and run a few Pyright-specific type checks on -# all code including untyped modules. We could also run a few Mypy type checks on untyped code in -# addition to the typed modules but configuring this behaviour is a little awkward at the time of -# this comment (Mypy 1.11.2). - -[tool.mypy] -files = "python" -exclude = "python/react-series-data-viewer" -ignore_errors = true - -[[tool.mypy.overrides]] -module = [ - "lib.db.*", - "lib.exception.*", - "lib.dataclass.*", -] -ignore_errors = false -strict = true +# 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"] -exclude = ["python/react-series-data-viewer"] -typeCheckingMode = "off" -reportDeprecated = "error" -reportMissingImports = "error" +include = [ + "python/lib/db", + "python/lib/exception", + "python/lib/validate_subject_ids.py" +] +typeCheckingMode = "strict" +reportMissingTypeStubs = "none" [tool.pytest.ini-options] testpaths = ["python/tests"] diff --git a/python/lib/db/connect.py b/python/lib/db/connect.py index 0e2d406be..a58912f0f 100644 --- a/python/lib/db/connect.py +++ b/python/lib/db/connect.py @@ -6,7 +6,7 @@ default_port = 3306 -def connect_to_db(credentials: dict[str, Any]) -> Session: +def connect_to_db(credentials: dict[str, Any]): host = credentials['host'] port = credentials['port'] username = credentials['username'] diff --git a/python/requirements.txt b/python/requirements.txt index 80ef36b70..9f258ee1b 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -5,7 +5,6 @@ mat73 matplotlib mne mne-bids>=0.6 -mypy mysql-connector mysqlclient nilearn diff --git a/test/pyrightconfig.json b/test/pyrightconfig.json new file mode 100644 index 000000000..cabc7dec9 --- /dev/null +++ b/test/pyrightconfig.json @@ -0,0 +1,9 @@ +// Global Pyright configuration used to check all Python code. +// It is a very lax configuration as it must work even on untyped code. +{ + "include": ["../python"], + "exclude": ["../python/react-series-data-viewer"], + "typeCheckingMode": "off", + "reportDeprecated": "error", + "reportMissingImports": "error" +} From 6a79f7ccbc6c1e029de1c71bf5145205c56ec3fb Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Wed, 4 Sep 2024 12:48:43 -0400 Subject: [PATCH 05/25] remove comment --- test/pyrightconfig.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/pyrightconfig.json b/test/pyrightconfig.json index cabc7dec9..69c890f86 100644 --- a/test/pyrightconfig.json +++ b/test/pyrightconfig.json @@ -1,5 +1,3 @@ -// Global Pyright configuration used to check all Python code. -// It is a very lax configuration as it must work even on untyped code. { "include": ["../python"], "exclude": ["../python/react-series-data-viewer"], From 2d639f8b385f573d51a674c256866a4c6947f82a Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 09:53:10 -0400 Subject: [PATCH 06/25] test --- .github/workflows/flake8_python_linter.yml | 42 ----------------- .github/workflows/python.yml | 54 ++++++++++++++++++++++ 2 files changed, 54 insertions(+), 42 deletions(-) delete mode 100644 .github/workflows/flake8_python_linter.yml create mode 100644 .github/workflows/python.yml diff --git a/.github/workflows/flake8_python_linter.yml b/.github/workflows/flake8_python_linter.yml deleted file mode 100644 index 3c52466ca..000000000 --- a/.github/workflows/flake8_python_linter.yml +++ /dev/null @@ -1,42 +0,0 @@ -# This workflow runs flake8 with reviewdog. The documentation can be found below: -# https://github.com/marketplace/actions/run-flake8-with-reviewdog -# Flake8 is a Python linter that analyzes code and checks for programming and stylistic errors -name: Flake8 Linter - -# This workflow acts only on pull requests -on: pull_request - -jobs: - - flake8-lint: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.11", "3.12"] - - steps: - - name: Check out source repository - uses: actions/checkout@v2 - - - name: Set up Python environment - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Flake8 Lint - uses: reviewdog/action-flake8@v3 - with: - # For more flake 8 arguments, visit the link below: - # https://flake8.pycqa.org/en/latest/user/options.html - # Currently, flake8 ignores the following; - # E202: Whitespace before ')' - # E203: Whitespace before ':' - # E221: Multiple spaces before operator - # E241: Multiple spaces after ',' - # E251: Unexpected spaces around keyword / parameter equals - # E272: Multiple spaces before keyword - flake8_args: "--ignore=W503,E202,E203,E221,E241,E251,E272,E126,E131,E121,E111,E127 - --max-line-length 120 - --exclude python/react-series-data-viewer/protocol_buffers/ - --exclude Loris " - github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 000000000..75afad511 --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,54 @@ +# This workflow runs flake8 with reviewdog. The documentation can be found below: +# https://github.com/marketplace/actions/run-flake8-with-reviewdog +# Flake8 is a Python linter that analyzes code and checks for programming and stylistic errors +name: Flake8 Linter + +# This workflow acts only on pull requests +on: pull_request + +jobs: + + setup: + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: ["3.11", "3.12"] + + steps: + - name: Check out source repository + uses: actions/checkout@v4 + + - name: Set up Python environment + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Python dependencies + run: pip install -r python/requirements.txt + + ruff: + runs-on: ubuntu-latest + needs: setup + + steps: + - name: Run Ruff + run: ruff check + + pyright-strict: + runs-on: ubuntu-latest + needs: setup + + steps: + - name: Run Pyright + run: pyright + + pyright-loose: + runs-on: ubuntu-latest + needs: setup + + steps: + - name: Run Pyright + run: | + cd test + pyright From 42b0187a6dad830e8987693c2ce2b7ac371edfb0 Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 09:59:50 -0400 Subject: [PATCH 07/25] test --- .github/workflows/python.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 75afad511..609920917 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -1,10 +1,8 @@ -# This workflow runs flake8 with reviewdog. The documentation can be found below: -# https://github.com/marketplace/actions/run-flake8-with-reviewdog -# Flake8 is a Python linter that analyzes code and checks for programming and stylistic errors -name: Flake8 Linter +name: Python checks -# This workflow acts only on pull requests -on: pull_request +on: + - push + - pull_request jobs: From e7e531e5bb278ead444bfc89f0ed562983dbb5a2 Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 11:31:12 -0400 Subject: [PATCH 08/25] change configuration --- .github/workflows/python.yml | 55 +++++++++++++++++++++++++++--------- python/requirements.txt | 1 - test/pyrightconfig.json | 2 +- 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 609920917..6835e4f1a 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -6,7 +6,8 @@ on: jobs: - setup: + ruff: + name: "Ruff" runs-on: ubuntu-latest strategy: @@ -14,38 +15,66 @@ jobs: python-version: ["3.11", "3.12"] steps: - - name: Check out source repository + - name: Check out LORIS-MRI uses: actions/checkout@v4 - - name: Set up Python environment + - 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 - ruff: - runs-on: ubuntu-latest - needs: setup - - steps: - - name: Run Ruff - run: ruff check + - name: Run Ruff + run: ruff check pyright-strict: + name: "Pyright strict" runs-on: ubuntu-latest - needs: setup + + strategy: + matrix: + python-version: ["3.11", "3.12"] steps: + - name: Check out LORIS-MRI + uses: actions/checkout@v4 + + - 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 + - name: Run Pyright run: pyright - pyright-loose: + pyrigh-global: + name: "Pyright global" runs-on: ubuntu-latest - needs: setup + + strategy: + matrix: + python-version: ["3.11", "3.12"] steps: + - name: Check out LORIS-MRI + uses: actions/checkout@v4 + + - 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 + - name: Run Pyright run: | cd test diff --git a/python/requirements.txt b/python/requirements.txt index 9f258ee1b..9e5eaa6ed 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -1,5 +1,4 @@ boto3 -flake8 google mat73 matplotlib diff --git a/test/pyrightconfig.json b/test/pyrightconfig.json index 69c890f86..b9189aa38 100644 --- a/test/pyrightconfig.json +++ b/test/pyrightconfig.json @@ -2,6 +2,6 @@ "include": ["../python"], "exclude": ["../python/react-series-data-viewer"], "typeCheckingMode": "off", - "reportDeprecated": "error", + "reportDeprecated": "warning", "reportMissingImports": "error" } From 8011638e0589ab9a44667902084051715a10c38b Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 11:38:28 -0400 Subject: [PATCH 09/25] add python environment variables --- .github/workflows/python.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 6835e4f1a..ffad7b65c 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -27,6 +27,9 @@ jobs: - name: Install Python dependencies run: pip install -r python/requirements.txt + - name: Set up environment variables + run: export PYTHONPATH=$PYTHONPATH:/`pwd`/python:/`pwd`/python/react-series-data-viewer + - name: Run Ruff run: ruff check @@ -51,6 +54,9 @@ jobs: - name: Install Python dependencies run: pip install -r python/requirements.txt + - name: Set up Python environment variables + run: export PYTHONPATH=$PYTHONPATH:/`pwd`/python:/`pwd`/python/react-series-data-viewer + - name: Run Pyright run: pyright @@ -75,6 +81,9 @@ jobs: - name: Install Python dependencies run: pip install -r python/requirements.txt + - name: Set up Python environment variables + run: export PYTHONPATH=$PYTHONPATH:/`pwd`/python:/`pwd`/python/react-series-data-viewer + - name: Run Pyright run: | cd test From d4673ab7f5c223f698ff96b50cee073d9bd7aac2 Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 11:51:21 -0400 Subject: [PATCH 10/25] try factorization --- .github/actions/setup-python.yml | 21 ++++++++++++ .../{python.yml => python-checks.yml} | 33 ++++--------------- 2 files changed, 27 insertions(+), 27 deletions(-) create mode 100644 .github/actions/setup-python.yml rename .github/workflows/{python.yml => python-checks.yml} (51%) diff --git a/.github/actions/setup-python.yml b/.github/actions/setup-python.yml new file mode 100644 index 000000000..000ef0a20 --- /dev/null +++ b/.github/actions/setup-python.yml @@ -0,0 +1,21 @@ +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 + + - name: Set up environment variables + run: export PYTHONPATH=$PYTHONPATH:/`pwd`/python:/`pwd`/python/react-series-data-viewer diff --git a/.github/workflows/python.yml b/.github/workflows/python-checks.yml similarity index 51% rename from .github/workflows/python.yml rename to .github/workflows/python-checks.yml index ffad7b65c..cc99004be 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python-checks.yml @@ -18,17 +18,10 @@ jobs: - name: Check out LORIS-MRI uses: actions/checkout@v4 - - name: Set up the Python environment - uses: actions/setup-python@v5 + - name: Set up Python + uses: setup-python with: python-version: ${{ matrix.python-version }} - cache: 'pip' - - - name: Install Python dependencies - run: pip install -r python/requirements.txt - - - name: Set up environment variables - run: export PYTHONPATH=$PYTHONPATH:/`pwd`/python:/`pwd`/python/react-series-data-viewer - name: Run Ruff run: ruff check @@ -45,17 +38,10 @@ jobs: - name: Check out LORIS-MRI uses: actions/checkout@v4 - - name: Set up the Python environment - uses: actions/setup-python@v5 + - name: Set up Python + uses: setup-python with: python-version: ${{ matrix.python-version }} - cache: 'pip' - - - name: Install Python dependencies - run: pip install -r python/requirements.txt - - - name: Set up Python environment variables - run: export PYTHONPATH=$PYTHONPATH:/`pwd`/python:/`pwd`/python/react-series-data-viewer - name: Run Pyright run: pyright @@ -72,17 +58,10 @@ jobs: - name: Check out LORIS-MRI uses: actions/checkout@v4 - - name: Set up the Python environment - uses: actions/setup-python@v5 + - name: Set up Python + uses: setup-python with: python-version: ${{ matrix.python-version }} - cache: 'pip' - - - name: Install Python dependencies - run: pip install -r python/requirements.txt - - - name: Set up Python environment variables - run: export PYTHONPATH=$PYTHONPATH:/`pwd`/python:/`pwd`/python/react-series-data-viewer - name: Run Pyright run: | From a163069388476cc7bbeeca1bc15ae14132cc1acc Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 11:57:51 -0400 Subject: [PATCH 11/25] test --- .github/workflows/loristest.yml | 4 +--- .github/workflows/python-checks.yml | 7 +++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/loristest.yml b/.github/workflows/loristest.yml index 1937f107b..e033c7c5b 100644 --- a/.github/workflows/loristest.yml +++ b/.github/workflows/loristest.yml @@ -1,8 +1,6 @@ name: LORIS Test Suite -on: - - push - - pull_request +on: workflow_dispatch jobs: docker: diff --git a/.github/workflows/python-checks.yml b/.github/workflows/python-checks.yml index cc99004be..59cdddae9 100644 --- a/.github/workflows/python-checks.yml +++ b/.github/workflows/python-checks.yml @@ -5,7 +5,6 @@ on: - pull_request jobs: - ruff: name: "Ruff" runs-on: ubuntu-latest @@ -19,7 +18,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Python - uses: setup-python + uses: ./.github/actions/setup-python.yml with: python-version: ${{ matrix.python-version }} @@ -39,7 +38,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Python - uses: setup-python + uses: ./.github/actions/setup-python.yml with: python-version: ${{ matrix.python-version }} @@ -59,7 +58,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Python - uses: setup-python + uses: ./.github/actions/setup-python.yml with: python-version: ${{ matrix.python-version }} From 1e4e94a5a2b23ac05ba66e85733801918e73f246 Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 11:59:52 -0400 Subject: [PATCH 12/25] test --- .../actions/{setup-python.yml => setup-python/action.yml} | 0 .github/workflows/python-checks.yml | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) rename .github/actions/{setup-python.yml => setup-python/action.yml} (100%) diff --git a/.github/actions/setup-python.yml b/.github/actions/setup-python/action.yml similarity index 100% rename from .github/actions/setup-python.yml rename to .github/actions/setup-python/action.yml diff --git a/.github/workflows/python-checks.yml b/.github/workflows/python-checks.yml index 59cdddae9..43d06068a 100644 --- a/.github/workflows/python-checks.yml +++ b/.github/workflows/python-checks.yml @@ -18,7 +18,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Python - uses: ./.github/actions/setup-python.yml + uses: ./.github/actions/setup-python with: python-version: ${{ matrix.python-version }} @@ -38,7 +38,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Python - uses: ./.github/actions/setup-python.yml + uses: ./.github/actions/setup-python with: python-version: ${{ matrix.python-version }} @@ -58,7 +58,7 @@ jobs: uses: actions/checkout@v4 - name: Set up Python - uses: ./.github/actions/setup-python.yml + uses: ./.github/actions/setup-python with: python-version: ${{ matrix.python-version }} From 43cda038d99b09a25c88830d3daa77f4fe98ee0a Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 12:03:22 -0400 Subject: [PATCH 13/25] test --- .github/actions/setup-python/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/setup-python/action.yml b/.github/actions/setup-python/action.yml index 000ef0a20..c152a9782 100644 --- a/.github/actions/setup-python/action.yml +++ b/.github/actions/setup-python/action.yml @@ -16,6 +16,8 @@ runs: - name: Install Python dependencies run: pip install -r python/requirements.txt + shell: bash - name: Set up environment variables run: export PYTHONPATH=$PYTHONPATH:/`pwd`/python:/`pwd`/python/react-series-data-viewer + shell: bash From 88e9c19d756b53bb58e82a854c442060e2bcd960 Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 12:11:20 -0400 Subject: [PATCH 14/25] test --- .github/actions/setup-python/action.yml | 2 +- .github/workflows/python-checks.yml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/actions/setup-python/action.yml b/.github/actions/setup-python/action.yml index c152a9782..921d96b61 100644 --- a/.github/actions/setup-python/action.yml +++ b/.github/actions/setup-python/action.yml @@ -19,5 +19,5 @@ runs: shell: bash - name: Set up environment variables - run: export PYTHONPATH=$PYTHONPATH:/`pwd`/python:/`pwd`/python/react-series-data-viewer + run: echo PYTHONPATH=$PYTHONPATH:/`pwd`/python:/`pwd`/python/react-series-data-viewer >> $GITHUB_ENV shell: bash diff --git a/.github/workflows/python-checks.yml b/.github/workflows/python-checks.yml index 43d06068a..872928be8 100644 --- a/.github/workflows/python-checks.yml +++ b/.github/workflows/python-checks.yml @@ -22,6 +22,9 @@ jobs: with: python-version: ${{ matrix.python-version }} + - name: Print Python path + run: echo $PYTHON_PATH + - name: Run Ruff run: ruff check From c5bbd9e9504948f118af34cdcdc9576b5ab56a62 Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 12:18:16 -0400 Subject: [PATCH 15/25] remove temporary things --- .github/workflows/loristest.yml | 4 +++- .github/workflows/python-checks.yml | 3 --- pyproject.toml | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/loristest.yml b/.github/workflows/loristest.yml index e033c7c5b..1937f107b 100644 --- a/.github/workflows/loristest.yml +++ b/.github/workflows/loristest.yml @@ -1,6 +1,8 @@ name: LORIS Test Suite -on: workflow_dispatch +on: + - push + - pull_request jobs: docker: diff --git a/.github/workflows/python-checks.yml b/.github/workflows/python-checks.yml index 872928be8..43d06068a 100644 --- a/.github/workflows/python-checks.yml +++ b/.github/workflows/python-checks.yml @@ -22,9 +22,6 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Print Python path - run: echo $PYTHON_PATH - - name: Run Ruff run: ruff check diff --git a/pyproject.toml b/pyproject.toml index 2d09b6937..bc66769a8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.ruff] -include = ["python/*.py"] +include = ["python/**/*.py"] exclude = ["python/react-series-data-viewer"] line-length = 120 preview = true From e53ea49d29feed5cdb225803f96731ba5a697ba6 Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 12:21:55 -0400 Subject: [PATCH 16/25] test ruff error --- python/lib/bidsreader.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/lib/bidsreader.py b/python/lib/bidsreader.py index 8ccedb3ec..81082a98a 100755 --- a/python/lib/bidsreader.py +++ b/python/lib/bidsreader.py @@ -21,6 +21,7 @@ __license__ = "GPLv3" + class BidsReader: """ This class reads a BIDS structure into a data dictionary using BIDS grabbids. From 954a584ad0ea240c9ae214bd7266e8e15904473f Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 12:26:14 -0400 Subject: [PATCH 17/25] ruff output github --- .github/workflows/python-checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-checks.yml b/.github/workflows/python-checks.yml index 43d06068a..672df5835 100644 --- a/.github/workflows/python-checks.yml +++ b/.github/workflows/python-checks.yml @@ -23,7 +23,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Run Ruff - run: ruff check + run: ruff check --output-format=github pyright-strict: name: "Pyright strict" From b309b97e6c632155eac2c0734254c384ca67ddac Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 12:29:03 -0400 Subject: [PATCH 18/25] further test errors --- .github/workflows/python-checks.yml | 4 ++-- python/lib/db/base.py | 3 +++ python/lib/imaging_io.py | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-checks.yml b/.github/workflows/python-checks.yml index 672df5835..6fc0ce21b 100644 --- a/.github/workflows/python-checks.yml +++ b/.github/workflows/python-checks.yml @@ -43,7 +43,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Run Pyright - run: pyright + run: pyright --outputjson pyrigh-global: name: "Pyright global" @@ -65,4 +65,4 @@ jobs: - name: Run Pyright run: | cd test - pyright + pyright --outputjson diff --git a/python/lib/db/base.py b/python/lib/db/base.py index 7d23cab17..55e0736a1 100644 --- a/python/lib/db/base.py +++ b/python/lib/db/base.py @@ -1,6 +1,9 @@ from sqlalchemy.orm import DeclarativeBase +a: int = "Hello" + + class Base(DeclarativeBase): """ Base SQLAlchemy class that must be inherited by all the ORM model classes. diff --git a/python/lib/imaging_io.py b/python/lib/imaging_io.py index ed048aafb..6aed0d175 100644 --- a/python/lib/imaging_io.py +++ b/python/lib/imaging_io.py @@ -5,6 +5,7 @@ import os import sys from lib.exitcode import COPY_FAILURE +import b """Set of io functions.""" From d0b07b13a9cd937b8e046041ceef9a16edece6d8 Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 12:37:39 -0400 Subject: [PATCH 19/25] test pyright output github --- .github/workflows/python-checks.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-checks.yml b/.github/workflows/python-checks.yml index 6fc0ce21b..58136fa49 100644 --- a/.github/workflows/python-checks.yml +++ b/.github/workflows/python-checks.yml @@ -43,7 +43,11 @@ jobs: python-version: ${{ matrix.python-version }} - name: Run Pyright - run: pyright --outputjson + run: | + pyright --outputjson > pyright-output.json + cat pyright-output.json \ + | jq -r '.generalDiagnostics[] \ + | "::error file=\(.file),line=\(.range.start.line),col=\(.range.start.character)::\(.message)"' pyrigh-global: name: "Pyright global" @@ -65,4 +69,7 @@ jobs: - name: Run Pyright run: | cd test - pyright --outputjson + pyright --outputjson > pyright-output.json + cat pyright-output.json \ + | jq -r '.generalDiagnostics[] \ + | "::error file=\(.file),line=\(.range.start.line),col=\(.range.start.character)::\(.message)"' From 833d532faff7f58297e990c902fec5a66d3e47a8 Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 12:43:37 -0400 Subject: [PATCH 20/25] test --- .github/workflows/python-checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-checks.yml b/.github/workflows/python-checks.yml index 58136fa49..3963b3628 100644 --- a/.github/workflows/python-checks.yml +++ b/.github/workflows/python-checks.yml @@ -44,7 +44,7 @@ jobs: - name: Run Pyright run: | - pyright --outputjson > pyright-output.json + pyright --outputjson > pyright-output.json || true cat pyright-output.json \ | jq -r '.generalDiagnostics[] \ | "::error file=\(.file),line=\(.range.start.line),col=\(.range.start.character)::\(.message)"' @@ -69,7 +69,7 @@ jobs: - name: Run Pyright run: | cd test - pyright --outputjson > pyright-output.json + pyright --outputjson > pyright-output.json || true cat pyright-output.json \ | jq -r '.generalDiagnostics[] \ | "::error file=\(.file),line=\(.range.start.line),col=\(.range.start.character)::\(.message)"' From 69580b5e04f28627de0a5cc5f687052f3af564a5 Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 12:45:55 -0400 Subject: [PATCH 21/25] test --- .github/workflows/python-checks.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-checks.yml b/.github/workflows/python-checks.yml index 3963b3628..24c7d8ddb 100644 --- a/.github/workflows/python-checks.yml +++ b/.github/workflows/python-checks.yml @@ -45,9 +45,7 @@ jobs: - name: Run Pyright run: | pyright --outputjson > pyright-output.json || true - cat pyright-output.json \ - | jq -r '.generalDiagnostics[] \ - | "::error file=\(.file),line=\(.range.start.line),col=\(.range.start.character)::\(.message)"' + cat pyright-output.json | jq -r '.generalDiagnostics[] | "::error file=\(.file),line=\(.range.start.line),col=\(.range.start.character)::\(.message)"' pyrigh-global: name: "Pyright global" @@ -70,6 +68,4 @@ jobs: run: | cd test pyright --outputjson > pyright-output.json || true - cat pyright-output.json \ - | jq -r '.generalDiagnostics[] \ - | "::error file=\(.file),line=\(.range.start.line),col=\(.range.start.character)::\(.message)"' + cat pyright-output.json | jq -r '.generalDiagnostics[] | "::error file=\(.file),line=\(.range.start.line),col=\(.range.start.character)::\(.message)"' From a5558db8a00ce0e9c05f50c73193c4bd90d6a3d5 Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 12:58:12 -0400 Subject: [PATCH 22/25] test --- .github/workflows/python-checks.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-checks.yml b/.github/workflows/python-checks.yml index 24c7d8ddb..35796c7ae 100644 --- a/.github/workflows/python-checks.yml +++ b/.github/workflows/python-checks.yml @@ -42,10 +42,12 @@ jobs: with: python-version: ${{ matrix.python-version }} + # Like in the other run Pyrihgt step, the `jq` arcane is used to format the errors to the + # GitHub actions format - name: Run Pyright run: | - pyright --outputjson > pyright-output.json || true - cat pyright-output.json | jq -r '.generalDiagnostics[] | "::error file=\(.file),line=\(.range.start.line),col=\(.range.start.character)::\(.message)"' + 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" @@ -67,5 +69,5 @@ jobs: - name: Run Pyright run: | cd test - pyright --outputjson > pyright-output.json || true - cat pyright-output.json | jq -r '.generalDiagnostics[] | "::error file=\(.file),line=\(.range.start.line),col=\(.range.start.character)::\(.message)"' + pyright --outputjson | jq -r '.generalDiagnostics[] | "::error file=\(.file),line=\(.range.start.line),col=\(.range.start.character)::\(.message)"' + (exit ${PIPESTATUS[0]}) From 78729df7926debef55bd13f3742208f5c4e5268a Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 13:04:55 -0400 Subject: [PATCH 23/25] change comment --- .github/workflows/python-checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-checks.yml b/.github/workflows/python-checks.yml index 35796c7ae..a9bcdc4e7 100644 --- a/.github/workflows/python-checks.yml +++ b/.github/workflows/python-checks.yml @@ -42,7 +42,7 @@ jobs: with: python-version: ${{ matrix.python-version }} - # Like in the other run Pyrihgt step, the `jq` arcane is used to format the errors to the + # Like in the other Pyrihgt run, the `jq` arcane is used to translate the errors to the # GitHub actions format - name: Run Pyright run: | From 99d5ce681513530b996298bbddd230f115b2c87d Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 13:05:36 -0400 Subject: [PATCH 24/25] remove test errors --- python/lib/bidsreader.py | 1 - python/lib/db/base.py | 3 --- python/lib/imaging_io.py | 1 - 3 files changed, 5 deletions(-) diff --git a/python/lib/bidsreader.py b/python/lib/bidsreader.py index 81082a98a..8ccedb3ec 100755 --- a/python/lib/bidsreader.py +++ b/python/lib/bidsreader.py @@ -21,7 +21,6 @@ __license__ = "GPLv3" - class BidsReader: """ This class reads a BIDS structure into a data dictionary using BIDS grabbids. diff --git a/python/lib/db/base.py b/python/lib/db/base.py index 55e0736a1..7d23cab17 100644 --- a/python/lib/db/base.py +++ b/python/lib/db/base.py @@ -1,9 +1,6 @@ from sqlalchemy.orm import DeclarativeBase -a: int = "Hello" - - class Base(DeclarativeBase): """ Base SQLAlchemy class that must be inherited by all the ORM model classes. diff --git a/python/lib/imaging_io.py b/python/lib/imaging_io.py index 6aed0d175..ed048aafb 100644 --- a/python/lib/imaging_io.py +++ b/python/lib/imaging_io.py @@ -5,7 +5,6 @@ import os import sys from lib.exitcode import COPY_FAILURE -import b """Set of io functions.""" From 924f1f97141549c9cfadee770d1f551a33e9df40 Mon Sep 17 00:00:00 2001 From: Maxime Mulder Date: Fri, 6 Sep 2024 13:08:21 -0400 Subject: [PATCH 25/25] test --- .github/workflows/python-checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-checks.yml b/.github/workflows/python-checks.yml index a9bcdc4e7..fddf5c1f1 100644 --- a/.github/workflows/python-checks.yml +++ b/.github/workflows/python-checks.yml @@ -42,8 +42,8 @@ jobs: with: python-version: ${{ matrix.python-version }} - # Like in the other Pyrihgt run, the `jq` arcane is used to translate the errors to the - # GitHub actions format + # 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)"'