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 authored and GitHub committed 2026-02-03 15:24:47 +01:00
1 parent 2ca9bee083
commit b8a2a6996c
156 files changed
+32 -34

No files matched your search

+1 -1
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: |
+13 -11
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",
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -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
@@ -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(
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1 -1
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -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):
File renamed without changes.
@@ -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(
@@ -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")
File renamed without changes.
@@ -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(
[
@@ -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(
@@ -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,
@@ -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(
Loaded 100 of 156 files, more files were not shown because too many files have changed in this diff. Show more