Skip to content

refactor: privatize validation helpers#2294

Merged
Borda merged 6 commits into
developfrom
depr/validate_
Jun 6, 2026
Merged

refactor: privatize validation helpers#2294
Borda merged 6 commits into
developfrom
depr/validate_

Conversation

@Borda

@Borda Borda commented Jun 6, 2026

Copy link
Copy Markdown
Member

This pull request deprecates several public validate_* helper functions, replacing them with private _validate_* implementations throughout the codebase. The public functions remain available but now issue a FutureWarning and delegate to the private versions via pydeprecate shims. All internal usage has been updated to use the new private helpers, and the deprecation is documented in the changelog and deprecation notes.

Deprecation and Refactoring of Validation Helpers:

  • Deprecated all public validate_* helper functions (e.g., validate_labels, validate_custom_values, validate_vlm_parameters, validate_fields_both_defined_or_none, validate_key_points_fields, validate_detections_fields, validate_resolution) and replaced their internal usage with private _validate_* equivalents. Public functions now issue deprecation warnings and delegate to the private implementations via pydeprecate shims. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27]

Documentation Updates:

  • Added deprecation notes for public validate_* functions to the changelog and deprecation documentation, specifying their removal in version 0.31.0 and the migration to private helpers. [1] [2]

Dependency Changes:

  • Added import of deprecate utilities (deprecated, void) to relevant modules to support the new deprecation shims. [1] [2] [3] [4] [5]

These changes ensure a smooth transition for users by maintaining backward compatibility with warnings, while streamlining and clarifying internal validation logic.

Rename internal validate_* helpers to private _validate_* names and route Supervision internals through the private implementations.

Keep public validate_* functions as pydeprecate-backed compatibility shims and add focused warning coverage.

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

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 79%. Comparing base (5a8e211) to head (0a5b9e7).

Additional details and impacted files
@@           Coverage Diff           @@
##           develop   #2294   +/-   ##
=======================================
- Coverage       79%     79%   -0%     
=======================================
  Files           66      66           
  Lines         8569    8622   +53     
=======================================
+ Hits          6806    6846   +40     
- Misses        1763    1776   +13     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Borda Borda marked this pull request as ready for review June 6, 2026 17:39
@Borda Borda requested a review from SkalskiP as a code owner June 6, 2026 17:39
Copilot AI review requested due to automatic review settings June 6, 2026 17:39

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 refactors Supervision’s validation helpers by introducing private _validate_* implementations for internal use while keeping the existing public validate_* APIs as FutureWarning-emitting deprecated shims (via deprecate/pydeprecate), and documents the deprecation in the docs/changelog.

Changes:

  • Added private _validate_* helpers and converted public validate_* functions into deprecation shims delegating to the private implementations.
  • Updated internal call sites across annotators, detections, keypoints, and metrics to use _validate_* to avoid emitting deprecation warnings during normal usage.
  • Added regression tests to ensure public shims warn and private paths remain warning-free; documented the deprecation in docs.

Quality Assessment (n/5)

  • Code quality: 4/5
  • Testing: 4/5
  • Documentation: 4/5

Reviewed changes

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

Show a summary per file
File Description
tests/test_validate_deprecations.py Adds tests asserting public validate_* shims emit FutureWarning and private _validate_* paths do not.
src/supervision/validators/__init__.py Introduces private _validate_* implementations and deprecates public validators via shim wrappers.
src/supervision/metrics/detection.py Switches internal validation to _validate_input_tensors and adds deprecated shim for validate_input_tensors.
src/supervision/key_points/core.py Updates KeyPoints initialization to use _validate_keypoints_fields internally.
src/supervision/detection/vlm.py Moves VLM parameter validation to _validate_vlm_parameters and deprecates the public validator.
src/supervision/detection/core.py Updates internal validation calls to private helpers and deprecates validate_fields_both_defined_or_none.
src/supervision/annotators/utils.py Adds _validate_labels and deprecates validate_labels as a shim.
src/supervision/annotators/core.py Uses _validate_labels internally and deprecates PercentageBarAnnotator.validate_custom_values.
docs/deprecated.md Documents the deprecation/removal timeline for public validate_* helpers.
docs/changelog.md Adds a changelog entry describing the deprecation shims and internal migration to _validate_*.

Comment thread src/supervision/validators/__init__.py
Comment thread src/supervision/validators/__init__.py
Borda and others added 5 commits June 6, 2026 12:44
[resolve #1] Review by @Copilot (PR #2294):
"_validate_keypoint_confidence validates a 2D array with shape (n, m),
but expected_shape uses f"({n, m})" (set literal) and message says 1D"
Challenge: evidence=VALID suggestion=VALID resolution=as-suggested

- Fix f"({n, m})" -> f"({n}, {m})" (set literal -> proper shape string)
- Fix error message "1D" -> "2D" to match actual array dimensionality

---
Co-authored-by: Claude Code <noreply@anthropic.com>
[resolve #2] Review by @Copilot (PR #2294):
"_validate_xy accepts (n,m,2)|(n,m,3) but expected_shape uses set literal
f"({n, m},)" and error message says 2D for a 3D array"
Challenge: evidence=VALID suggestion=VALID resolution=as-suggested

- Fix f"({n, m},)" -> f"({n}, {m}, 2) or ({n}, {m}, 3)"
- Fix error message "2D" -> "3D" to match actual array dimensionality

---
Co-authored-by: Claude Code <noreply@anthropic.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 11 out of 11 changed files in this pull request and generated 5 comments.

Comment thread src/supervision/validators/__init__.py
Comment thread src/supervision/validators/__init__.py
Comment thread src/supervision/validators/__init__.py
Comment thread src/supervision/validators/__init__.py
Comment thread src/supervision/validators/__init__.py
@Borda Borda merged commit 3410d92 into develop Jun 6, 2026
30 of 31 checks passed
@Borda Borda deleted the depr/validate_ branch June 6, 2026 19:15
Borda added a commit to Khanz9664/supervision that referenced this pull request Jun 9, 2026
Resolve conflict in detection.py: develop (roboflow#2294) privatized
validate_input_tensors → _validate_input_tensors; PR adds metric_target.
Resolution: call _validate_input_tensors directly with metric_target forwarded.

---
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
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.

2 participants