Skip to content

Draft: Update Pipeline#253

Draft
ErikGro wants to merge 7 commits into
mainfrom
erik/244-pipeline-update
Draft

Draft: Update Pipeline#253
ErikGro wants to merge 7 commits into
mainfrom
erik/244-pipeline-update

Conversation

@ErikGro
Copy link
Copy Markdown
Collaborator

@ErikGro ErikGro commented Apr 22, 2026

Draft: This is WIP

poetry run ruff check
Found 92 errors.

poetry run basedpyright  # with basic
138 errors, 2 warnings, 0 notes

poetry run basedpyright  # with standard
195 errors, 2 warnings, 0 notes

poetry run basedpyright  # with strict
2943 errors, 0 warnings, 0 notes ouch

TODO:

  • run_lint / black seems to be configured via Settings? Its appears to run - but its not configured anywhere in this repository
  • Fix all the errors :D

@Hendrik-code
Copy link
Copy Markdown
Collaborator

Hendrik-code commented Apr 23, 2026

Nice that you already started on this, I thought I set this up haha. @ErikGro

What we setup in https://github.com/Hendrik-code/TPTBox:

name: ruff linter

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  ruff:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-python@v3
    - run: pip install ruff
    - run: ruff check .
    - uses: stefanzweifel/git-auto-commit-action@v4
      with:
        commit_message: 'style fixes by ruff'

This will automatically commit the fixes ruff can take, which I find neat.

As .pre-commit-config.yaml, we utilize:

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v3.2.0
    hooks:
    -   id: trailing-whitespace
    -   id: end-of-file-fixer
    -   id: check-yaml
    -   id: check-added-large-files

- repo: https://github.com/astral-sh/ruff-pre-commit
  # Ruff version.
  rev: v0.11.0
  hooks:
    # Run the linter.
    - id: ruff
      types_or: [ python, pyi ]
      args: [ --fix ]
    # Run the formatter.
    - id: ruff-format
      types_or: [ python, pyi ]

so for every commit, it will automatically fix the things ruff can do before even comitting, and blocks the commit if ruff finds things it cannot automatically fix.

These are the rules we set to ignore because too annoying or useless:

ignore = [
    "C901",
    "RUF059",
    "RUF100",
    "F401",
    "BLE001",
    "E501",
    "N801",
    "NPY002",
    "PD002",
    "PERF203",
    "PTH123",
    "PGH003",
    "PLR0911",
    "PLR0912",
    "PLR0913",
    "PLR0915",
    "PLR2004",
    "SIM105",
    "TRY003",
    "UP038",
    "N999",
    "E741",
    "SIM118",
    "N802",
    "F811",
    "N803",
    "N806",
    "FURB171", 
    "PLW0108",
    "B905",
    "UP007",
    "PLC0415",
    ]

Maybe this is a help to you, or you can just use this setup.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This draft PR updates the repository’s code-quality pipeline by introducing Ruff + BasedPyright configuration, adding pre-commit hooks, and performing broad import/formatting cleanup across library code, tests, docs, and examples.

Changes:

  • Add Ruff + BasedPyright to the dev dependency group and configure them in pyproject.toml.
  • Replace the PR lint workflow with dedicated Ruff lint/format and BasedPyright typecheck jobs; add a Ruff pre-commit configuration.
  • Apply widespread formatting/import-order cleanups across panoptica/, unit_tests/, examples/, and docs.

Reviewed changes

Copilot reviewed 60 out of 61 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
unit_tests/test_voronoi_regions.py Import order / formatting cleanup.
unit_tests/test_utils.py Import order cleanup.
unit_tests/test_spatial_caching.py Minor whitespace/format cleanup.
unit_tests/test_serialization.py Import ordering of serialization helpers.
unit_tests/test_part_metrics.py Import order cleanup.
unit_tests/test_panoptic_statistics.py Import order cleanup.
unit_tests/test_panoptic_pipeline.py Import cleanup/reorder.
unit_tests/test_panoptic_pipeline_region_wise.py Import reorder and formatting.
unit_tests/test_panoptic_evaluator.py Import cleanup/reorder.
unit_tests/test_panoptic_aggregator.py Import cleanup/reorder.
unit_tests/test_metrics.py Import cleanup/reorder.
unit_tests/test_matcher_variations.py Remove duplicate/unused imports and whitespace cleanup.
unit_tests/test_labelgroup.py Import reorder + minor formatting.
unit_tests/test_input_sanity_checker.py Import reordering and optional-import structure cleanup.
unit_tests/test_edgecasehandler.py Import cleanup/reorder.
unit_tests/test_datatype.py Import reorder and formatting.
unit_tests/test_config.py Import reorder and formatting.
unit_tests/test_cli.py Import reorder.
unit_tests/test_autc.py Import spacing cleanup.
unit_tests_visual/test_part_metrics.ipynb Notebook cell import order / minor cleanup.
pyproject.toml Add Ruff/BasedPyright config; add ruff/basedpyright deps; bump pre-commit; remove flake8.
poetry.lock Lockfile update reflecting new dev tooling and dependency resolution changes.
panoptica/utils/segmentation_class.py Remove unused import / formatting.
panoptica/utils/processing_pair.py Import order cleanup + line wrapping.
panoptica/utils/parallel_processing.py Remove unused import (Pool).
panoptica/utils/label_group.py Minor formatting simplification.
panoptica/utils/input_check_and_conversion/sanity_checker.py Import order cleanup and minor exception handler tweak.
panoptica/utils/input_check_and_conversion/input_data_type_checker.py Import ordering cleanup.
panoptica/utils/input_check_and_conversion/check_torch_image.py Import order cleanup.
panoptica/utils/input_check_and_conversion/check_sitk_image.py Import order cleanup.
panoptica/utils/input_check_and_conversion/check_numpy_array.py Import order cleanup.
panoptica/utils/input_check_and_conversion/check_nrrd_image.py Import order cleanup.
panoptica/utils/input_check_and_conversion/check_nibabel_image.py Import order cleanup.
panoptica/utils/edge_case_handling.py Import order cleanup.
panoptica/utils/constants.py Import order cleanup.
panoptica/utils/config.py Import reorder (notably abstractmethod).
panoptica/utils/__init__.py Reorder and extend re-exports.
panoptica/panoptica_statistics.py Consolidate/clean imports and minor formatting.
panoptica/panoptica_result.py Import consolidation and minor formatting cleanup.
panoptica/panoptica_pipeline.py Import cleanup; simplify TYPE_CHECKING block.
panoptica/panoptica_evaluator.py Import consolidation + formatting improvements.
panoptica/panoptica_aggregator.py Import consolidation/reorder.
panoptica/metrics/normalized_surface_dice.py Split multi-import; import formatting.
panoptica/metrics/metrics.py Import ordering and formatting tweaks.
panoptica/metrics/hausdorff_distance.py Remove unused import.
panoptica/metrics/__init__.py Reorder imports without changing exports.
panoptica/instance_matcher.py Import reordering.
panoptica/instance_evaluator.py Import reorder; remove unused multiprocessing import.
panoptica/instance_approximator.py Import reorder and minor comment placement.
panoptica/cli.py Import reorder; remove unused import.
panoptica/_functionals.py Import reorder and cleanup.
panoptica/__init__.py Import/re-export ordering cleanup.
examples/example_spine_statistics.py Import reorder.
examples/example_spine_semantic.py Minor whitespace/import reorder.
examples/example_spine_instance.py Import reorder.
examples/example_spine_instance_config.py Minor whitespace cleanup.
examples/example_spine_autc.py Import reorder.
docs/source/preprocess_readme.py Lambda formatting change for readability.
.pre-commit-config.yaml Add Ruff lint + Ruff format pre-commit hooks.
.github/workflows/pr-lint.yml Replace reusable workflow with Ruff lint/format + BasedPyright jobs.
.github/workflows/autoformat.yml Remove old reusable autoformat workflow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread panoptica/utils/config.py
Comment on lines +1 to +5
from abc import abstractmethod
from pathlib import Path

from ruamel.yaml import YAML

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants