refactor: reorganize project structure and update module imports (#2112)

* refactor: reorganize project structure and update module imports
* configure setuptools to use 'src' layout and adjust package discovery
* refactor: move tests to `tests` directory and update imports accordingly
* update lint and mypy configurations to align with `src` and `tests` structure
* update test imports to use corrected `tests.helpers` module path
* fix(pre_commit): 🎨 auto format pre-commit hooks
This commit is contained in:
Jirka Borovec 2026-02-03 23:24:47 +09:00 committed by GitHub
parent 2ca9bee083
commit b8a2a6996c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
156 changed files with 32 additions and 34 deletions

View File

@ -48,7 +48,7 @@ jobs:
run: uv run python -c "import supervision; from supervision import assets; from supervision import metrics; print(supervision.__version__)"
- name: 🧪 Run the Test
run: uv run pytest --cov=supervision --cov-report=xml --ignore=examples
run: uv run pytest src/ tests/ --cov=supervision --cov-report=xml
- name: Generate Coverage Report
run: |

View File

@ -100,8 +100,10 @@ include-package-data = false
supervision = [ "py.typed" ]
[tool.setuptools.packages.find]
where = [ "src" ]
include = [ "supervision*" ]
exclude = [ "docs*", "test*", "examples*" ]
#exclude = [ "docs*", "tests*", "examples*" ]
[tool.ruff]
target-version = "py39"
@ -160,10 +162,10 @@ lint.select = [
]
lint.ignore = [ ]
lint.per-file-ignores."__init__.py" = [ "E402", "F401" ]
lint.per-file-ignores."supervision/**" = [
lint.per-file-ignores."src/**" = [
"S101", # TODO: Replace asserts with proper error handling
]
lint.per-file-ignores."test/**" = [
lint.per-file-ignores."tests/**" = [
"PT011", # TODO: `pytest.raises(Exception)` is too broad, set the `match` parameter or use a more specific exception
"S101", # Use of `assert` detected
]
@ -198,17 +200,17 @@ python_version = "3.9"
ignore_missing_imports = false
explicit_package_bases = true
strict = true
exclude = [
".github",
"docs",
"test",
"examples",
"setup.py",
]
mypy_path = "src"
#exclude = [
# "docs",
# "test",
# "examples",
# "setup.py",
#]
[[tool.mypy.overrides]]
module = [
"test.*",
"tests.*",
"examples.*",
# TODO: fix type errors in the following modules
"supervision.classification.core",

View File

@ -31,7 +31,7 @@ from supervision.annotators.utils import ColorLookup
from supervision.detection.core import Detections
from supervision.draw.color import Color
from supervision.geometry.core import Position
from test.helpers import _create_detections, assert_image_mostly_same
from tests.helpers import _create_detections, assert_image_mostly_same
@pytest.fixture

View File

@ -7,7 +7,7 @@ import pytest
from supervision.annotators.utils import ColorLookup, resolve_color_idx, wrap_text
from supervision.detection.core import Detections
from test.helpers import _create_detections
from tests.helpers import _create_detections
@pytest.mark.parametrize(

View File

@ -2,7 +2,7 @@ import numpy as np
import pytest
import supervision as sv
from test.helpers import _create_key_points
from tests.helpers import _create_key_points
@pytest.fixture

View File

@ -11,7 +11,7 @@ from supervision.dataset.formats.pascal_voc import (
object_to_pascal_voc,
parse_polygon_points,
)
from test.helpers import _create_detections
from tests.helpers import _create_detections
def are_xml_elements_equal(elem1, elem2):

View File

@ -5,7 +5,7 @@ from contextlib import ExitStack as DoesNotRaise
import pytest
from supervision import DetectionDataset
from test.helpers import _create_detections
from tests.helpers import _create_detections
@pytest.mark.parametrize(

View File

@ -16,7 +16,7 @@ from supervision.dataset.utils import (
rle_to_mask,
train_test_split,
)
from test.helpers import _create_detections
from tests.helpers import _create_detections
T = TypeVar("T")

View File

@ -7,7 +7,7 @@ import pytest
from supervision.detection.core import Detections, merge_inner_detection_object_pair
from supervision.geometry.core import Position
from test.helpers import _create_detections
from tests.helpers import _create_detections
PREDICTIONS = np.array(
[

View File

@ -5,7 +5,7 @@ from typing import Any
import pytest
import supervision as sv
from test.helpers import _create_detections
from tests.helpers import _create_detections
@pytest.mark.parametrize(

View File

@ -6,7 +6,7 @@ import pytest
import supervision.detection.core as detection_core
from supervision.config import CLASS_NAME_DATA_FIELD
from supervision.detection.core import Detections
from test.helpers import (
from tests.helpers import (
_FakeUltralyticsBoxes,
_FakeUltralyticsResults,
_FakeYoloNasPrediction,

View File

@ -5,7 +5,7 @@ from typing import Any
import pytest
import supervision as sv
from test.helpers import _create_detections
from tests.helpers import _create_detections
@pytest.mark.parametrize(

Some files were not shown because too many files have changed in this diff Show More