Skip to content

chore: postpone annotations and add validation refinements#2357

Merged
Borda merged 3 commits into
developfrom
typing/tests
Jun 27, 2026
Merged

chore: postpone annotations and add validation refinements#2357
Borda merged 3 commits into
developfrom
typing/tests

Conversation

@Borda

@Borda Borda commented Jun 27, 2026

Copy link
Copy Markdown
Member

This pull request ports the useful Python typing and validation refinements from #2260 while keeping the branch focused.

Summary:

  • Adds postponed annotation evaluation to the touched test modules.
  • Modernizes the _yolo_dataset_factory classes annotation to list[str] | None.
  • Adds targeted runtime validation for metric inputs so missing class_id or prediction confidence raises clear ValueErrors instead of lower-level NumPy/type errors.
  • Adds COCO mask handling for malformed RLE segmentation dictionaries missing counts, preserving mask alignment with an empty mask and warning.
  • Adds draw_image validation for undecodable files and unsupported image channel shapes.

Compatibility note:

  • Metric classes now fail fast on missing required detection fields instead of silently skipping some prediction-only invalid inputs. This is intentional because those fields are required to compute meaningful detection metrics.

Add postponed annotations to test modules and modernize one test helper annotation for Python 3.9-compatible collection.

Co-authored-by: Codex <codex@openai.com>
@Borda Borda requested a review from Copilot June 27, 2026 05:51
@Borda Borda requested a review from SkalskiP as a code owner June 27, 2026 05:51
@Borda Borda added the enhancement New feature or request label Jun 27, 2026
@codecov

codecov Bot commented Jun 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.55556% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 82%. Comparing base (f34a940) to head (79abaf5).

Additional details and impacted files
@@           Coverage Diff           @@
##           develop   #2357   +/-   ##
=======================================
  Coverage       82%     82%           
=======================================
  Files           68      68           
  Lines         9523    9560   +37     
=======================================
+ Hits          7823    7881   +58     
+ Misses        1700    1679   -21     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes the test suite by enabling postponed evaluation of type annotations (from __future__ import annotations) across test modules, aligning test typing behavior with newer Python typing patterns while keeping runtime behavior unchanged in tests.

Changes:

  • Added from __future__ import annotations at the top of the test modules touched to postpone annotation evaluation.
  • Updated _yolo_dataset_factory’s classes parameter annotation in tests/metrics/conftest.py from Optional[list[str]] to list[str] | None.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/utils/test_video.py Adds postponed-annotations future import.
tests/utils/test_iterables.py Adds postponed-annotations future import.
tests/utils/test_internal.py Adds postponed-annotations future import.
tests/utils/test_image.py Adds postponed-annotations future import.
tests/utils/test_conversion.py Adds postponed-annotations future import.
tests/utils/conftest.py Adds postponed-annotations future import.
tests/tracker/test_byte_tracker.py Adds postponed-annotations future import.
tests/metrics/test_recall.py Adds postponed-annotations future import.
tests/metrics/test_precision.py Adds postponed-annotations future import.
tests/metrics/test_oriented_bounding_box_metrics.py Adds postponed-annotations future import.
tests/metrics/test_mean_average_recall.py Adds postponed-annotations future import.
tests/metrics/test_mean_average_precision.py Adds postponed-annotations future import.
tests/metrics/test_f1_score.py Adds postponed-annotations future import.
tests/metrics/conftest.py Adds postponed-annotations future import and modernizes one Optional[...] annotation to `
tests/key_points/test_skeletons.py Adds postponed-annotations future import.
tests/key_points/test_core.py Adds postponed-annotations future import.
tests/key_points/test_annotators.py Adds postponed-annotations future import.
tests/geometry/test_utils.py Adds postponed-annotations future import.
tests/geometry/test_core.py Adds postponed-annotations future import.
tests/detection/utils/test_vlms.py Adds postponed-annotations future import.
tests/detection/test_polygonzone.py Adds postponed-annotations future import.
tests/detection/test_polygon_zone_annotator.py Adds postponed-annotations future import.
tests/conftest.py Adds postponed-annotations future import.
tests/assets/test_list.py Adds postponed-annotations future import.
tests/assets/test_downloader.py Adds postponed-annotations future import.
tests/annotators/test_docs.py Adds postponed-annotations future import after module docstring.
tests/annotators/test_core.py Adds postponed-annotations future import after module docstring.

Co-authored-by: Codex <codex@openai.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 35 out of 35 changed files in this pull request and generated 2 comments.

Comment thread src/supervision/draw/utils.py
Comment thread src/supervision/metrics/precision.py
@Borda Borda changed the title chore: postpone test annotations chore: postpone annotations and add validation refinements Jun 27, 2026
Co-authored-by: Codex <codex@openai.com>
@Borda Borda merged commit 10b5383 into develop Jun 27, 2026
29 checks passed
@Borda Borda deleted the typing/tests branch June 27, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants