Port deprecations from 0.27.0.post [rebase & merge]#2214
Merged
Conversation
…irecting to `supervision.key_points`. (cherry picked from commit 99e772c)
…cies (cherry picked from commit 219161f)
…ersion utilities (cherry picked from commit c976151)
(cherry picked from commit 224c756)
…sion (cherry picked from commit e36fbe0)
…across modules (cherry picked from commit 7f3dcae)
…multiple modules (cherry picked from commit bc521bc)
(cherry picked from commit 650ca0a)
(cherry picked from commit fd4845a)
…eprecated` with `warnings.warn` (cherry picked from commit 27e5fa3)
ad782a8 to
1c0d1f7
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #2214 +/- ##
========================================
- Coverage 78% 77% -2%
========================================
Files 63 66 +3
Lines 7979 8115 +136
========================================
- Hits 6257 6232 -25
- Misses 1722 1883 +161 🚀 New features to boost your workflow:
|
dc1631d to
857fc8b
Compare
0.27.pot [rebase & merge]
0.27.pot [rebase & merge]0.27.0.post [rebase & merge]
Contributor
There was a problem hiding this comment.
Pull request overview
This PR ports and standardizes deprecations across Supervision by introducing pydeprecate-based deprecation decorators, refining some annotator/type-handling utilities, and adding/adjusting deprecation shims for renamed APIs.
Changes:
- Adds
pydeprecateas a dependency and replaces the repo’s removed customdeprecateddecorator withdeprecate.deprecatedacross updated modules. - Introduces deprecation shims/aliases for renamed keypoint validators and for the legacy
from_lmm/LMMpathway. - Extends
utils.imagewith a (deprecated)create_tilesimplementation and refactors/expands image utility internals.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Locks pydeprecate and includes it in dependency resolution. |
| pyproject.toml | Adds pydeprecate>=0.4,<0.5 to core dependencies. |
| supervision/keypoint/init.py | Adds deprecated import shim for supervision.keypoint → supervision.key_points (but currently outside src/). |
| supervision/keypoint/core.py | Deprecated shim re-exporting KeyPoints from new module. |
| supervision/keypoint/annotators.py | Deprecated shim re-exporting keypoint annotators from new module. |
| src/supervision/utils/internal.py | Removes the legacy custom deprecated decorator implementation. |
| src/supervision/validators/init.py | Adds deprecated aliases for renamed keypoint validator functions using deprecate. |
| src/supervision/utils/conversion.py | Improves typing of decorator helpers and adds deprecated aliases for older decorator names. |
| src/supervision/utils/image.py | Adds new tiling utilities (create_tiles + helpers), updates imports, and adjusts deprecations/assertions. |
| src/supervision/metrics/detection.py | Switches to deprecate.deprecated for MeanAveragePrecision and adds a workaround for wrapped staticmethods. |
| src/supervision/detection/vlm.py | Deprecates LMM enum usage via warnings and docstring directives. |
| src/supervision/detection/core.py | Removes decorator-based deprecation for from_lmm and replaces with runtime warning + mapping to from_vlm. |
| src/supervision/annotators/base.py | Broadens BaseAnnotator.annotate signature to accept arbitrary args/kwargs and loosens typing to Any. |
| src/supervision/annotators/core.py | Adjusts annotator signatures/defaults and adds casts to satisfy updated typing expectations. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Replace FutureWarning with warn_deprecated (SupervisionWarnings) in Detections.from_lmm to respect SUPERVISON_DEPRECATION_WARNING env var - Align removal version from 0.30.0 to 0.31.0 for consistency with all other deprecations introduced in this PR [resolve #3] Review comment by @copilot (PR #2214): "Deprecation warning says from_lmm will be removed in supervision-0.30.0..." [resolve #4] Review comment by @copilot (PR #2214): "Emitting deprecation warnings with the standard FutureWarning here byp..." --- Co-authored-by: Claude Code <noreply@anthropic.com>
Replace FutureWarning with warn_deprecated so the LMM deprecation respects the SUPERVISON_DEPRECATION_WARNING env var filter, consistent with other deprecations across the library. [resolve #4] Review comment by @copilot (PR #2214): "Same as Detections.from_lmm: this uses the standard FutureWarning..." --- Co-authored-by: Claude Code <noreply@anthropic.com>
Decorated functions now preserve __name__, __doc__, and __wrapped__ metadata, fixing introspection and documentation generation for all annotators using ensure_cv2/pil_image_for_* decorators. [resolve #9] Review comment by @copilot (PR #2214): "The decorator wrappers in this file no longer use functools.wraps..." --- Co-authored-by: Claude Code <noreply@anthropic.com>
- Move supervision/keypoint/ → src/supervision/keypoint/ so shims are included in built wheels (project uses src layout) - Replace raw DeprecationWarning with warn_deprecated (SupervisionWarnings) in all three shim files for consistent warning behaviour - Fix wrong import path (supervision.utils.deprecation → .internal) and remove unsupported stacklevel arg from warn_deprecated call [resolve #7] Review comment by @copilot (PR #2214): "This warning uses the standard DeprecationWarning..." [resolve #8] Review comment by @copilot (PR #2214): "These deprecation shim modules are added under the top-level supervision/..." --- Co-authored-by: Claude Code <noreply@anthropic.com>
Borda
added a commit
that referenced
this pull request
Apr 15, 2026
- Replace FutureWarning with warn_deprecated (SupervisionWarnings) in Detections.from_lmm to respect SUPERVISON_DEPRECATION_WARNING env var - Align removal version from 0.30.0 to 0.31.0 for consistency with all other deprecations introduced in this PR [resolve #3] Review comment by @copilot (PR #2214): "Deprecation warning says from_lmm will be removed in supervision-0.30.0..." [resolve #4] Review comment by @copilot (PR #2214): "Emitting deprecation warnings with the standard FutureWarning here byp..." --- Co-authored-by: Claude Code <noreply@anthropic.com>
Borda
added a commit
that referenced
this pull request
Apr 15, 2026
Replace FutureWarning with warn_deprecated so the LMM deprecation respects the SUPERVISON_DEPRECATION_WARNING env var filter, consistent with other deprecations across the library. [resolve #4] Review comment by @copilot (PR #2214): "Same as Detections.from_lmm: this uses the standard FutureWarning..." --- Co-authored-by: Claude Code <noreply@anthropic.com>
Borda
added a commit
that referenced
this pull request
Apr 15, 2026
Decorated functions now preserve __name__, __doc__, and __wrapped__ metadata, fixing introspection and documentation generation for all annotators using ensure_cv2/pil_image_for_* decorators. [resolve #9] Review comment by @copilot (PR #2214): "The decorator wrappers in this file no longer use functools.wraps..." --- Co-authored-by: Claude Code <noreply@anthropic.com>
Merged
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 introduces several improvements and refactors across the codebase, focusing on modernizing deprecation handling, improving type safety, and enhancing annotation and image utility functions. The most significant changes include replacing the internal deprecation mechanism with the
pydeprecatelibrary, updating function signatures for better flexibility and type safety, and clarifying deprecation warnings for users. Below are the most important changes grouped by theme:Deprecation Handling Modernization:
deprecateddecorator with thepydeprecatelibrary throughout the codebase, updating all relevant imports and usages to standardize deprecation warnings and future removals. (src/supervision/utils/conversion.py,src/supervision/metrics/detection.py,src/supervision/utils/image.py,src/supervision/detection/core.py,src/supervision/detection/vlm.py,src/supervision/metrics/detection.py) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]LMMenum and related functions, adding explicit warnings and docstrings to guide users to use theVLMenum instead. (src/supervision/detection/vlm.py,src/supervision/detection/core.py) [1] [2] [3] [4] [5]Annotator and Type Safety Improvements:
BaseAnnotator.annotatemethod signature to accept arbitrary arguments and useAnyfor broader compatibility, and adjusted downstream usage accordingly. (src/supervision/annotators/base.py,src/supervision/annotators/core.py) [1] [2]TypeVar,cast, and more precise return types, including for decorator wrappers. (src/supervision/utils/conversion.py,src/supervision/annotators/core.py) [1] [2] [3] [4] [5] [6]Image Utility Enhancements:
scale_image,resize_image,tint_image) to prevent misuse and clarify expected types. (src/supervision/utils/image.py) [1] [2] [3]src/supervision/utils/image.pyfor improved clarity, maintainability, and to use new utility functions. (src/supervision/utils/image.py)Dependency Management:
pydeprecateas a required dependency inpyproject.tomlto support the new deprecation mechanism.Miscellaneous:
src/supervision/detection/core.py)These changes collectively modernize the codebase, improve user guidance for deprecated features, and enhance code robustness and maintainability.