refactor: privatize validation helpers#2294
Merged
Merged
Conversation
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 Report❌ Patch coverage is 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:
|
Contributor
There was a problem hiding this comment.
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 publicvalidate_*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_*. |
[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>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 aFutureWarningand delegate to the private versions viapydeprecateshims. 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:
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 viapydeprecateshims. [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:
validate_*functions to the changelog and deprecation documentation, specifying their removal in version0.31.0and the migration to private helpers. [1] [2]Dependency Changes:
deprecateutilities (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.