Enable testing doctest in the package docstrings (#2111)

* Exclude examples directory from test coverage in CI workflow
* demo * case
This commit is contained in:
Jirka Borovec 2026-01-29 18:08:10 +09:00 committed by GitHub
parent 44614dea94
commit 93d419d7c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 1 deletions

View File

@ -44,7 +44,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
run: uv run pytest --cov=supervision --cov-report=xml --ignore=examples
- name: Generate Coverage Report
run: |

View File

@ -187,6 +187,13 @@ count = true
quiet-level = 3
ignore-words-list = "STrack,sTrack,strack"
[tool.pytest.ini_options]
addopts = [
"--doctest-modules",
"--color=yes",
]
doctest_optionflags = "ELLIPSIS NORMALIZE_WHITESPACE"
[tool.mypy]
python_version = "3.9"
ignore_missing_imports = false

View File

@ -4,6 +4,10 @@ import numpy as np
def validate_xyxy(xyxy: Any) -> None:
"""Validate that xyxy is a 2D np.ndarray with shape (N, 4).
>>> validate_xyxy(np.array([[0, 0, 1, 1], [1, 1, 2, 2]]))
"""
expected_shape = "(_, 4)"
actual_shape = str(getattr(xyxy, "shape", None))
is_valid = isinstance(xyxy, np.ndarray) and xyxy.ndim == 2 and xyxy.shape[1] == 4