Skip to content

Port deprecations from 0.27.0.post [rebase & merge]#2214

Merged
Borda merged 18 commits into
developfrom
port/deprecations
Apr 15, 2026
Merged

Port deprecations from 0.27.0.post [rebase & merge]#2214
Borda merged 18 commits into
developfrom
port/deprecations

Conversation

@Borda

@Borda Borda commented Apr 14, 2026

Copy link
Copy Markdown
Member

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 pydeprecate library, 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:

  • Replaced the custom deprecated decorator with the pydeprecate library 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]
  • Deprecated the LMM enum and related functions, adding explicit warnings and docstrings to guide users to use the VLM enum instead. (src/supervision/detection/vlm.py, src/supervision/detection/core.py) [1] [2] [3] [4] [5]

Annotator and Type Safety Improvements:

  • Updated the BaseAnnotator.annotate method signature to accept arbitrary arguments and use Any for broader compatibility, and adjusted downstream usage accordingly. (src/supervision/annotators/base.py, src/supervision/annotators/core.py) [1] [2]
  • Improved type safety in annotation and image conversion utilities by using 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:

  • Added assertions for input types in image manipulation functions (e.g., scale_image, resize_image, tint_image) to prevent misuse and clarify expected types. (src/supervision/utils/image.py) [1] [2] [3]
  • Refactored imports and internal logic in src/supervision/utils/image.py for improved clarity, maintainability, and to use new utility functions. (src/supervision/utils/image.py)

Dependency Management:

  • Added pydeprecate as a required dependency in pyproject.toml to support the new deprecation mechanism.

Miscellaneous:

  • Removed unused imports and updated function logic for clarity and to avoid deprecated usage, particularly in detection core modules. (src/supervision/detection/core.py)

These changes collectively modernize the codebase, improve user guidance for deprecated features, and enhance code robustness and maintainability.

Borda added 12 commits April 14, 2026 15:24
…irecting to `supervision.key_points`.

(cherry picked from commit 99e772c)
(cherry picked from commit 0ba57b2)
(cherry picked from commit ae6aa36)
…eprecated` with `warnings.warn`

(cherry picked from commit 27e5fa3)
@Borda Borda force-pushed the port/deprecations branch from ad782a8 to 1c0d1f7 Compare April 14, 2026 15:47
@codecov

codecov Bot commented Apr 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 40.11299% with 106 lines in your changes missing coverage. Please review.
✅ Project coverage is 77%. Comparing base (565cd91) to head (9fab5f2).
⚠️ Report is 18 commits behind head on develop.

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Borda Borda force-pushed the port/deprecations branch from dc1631d to 857fc8b Compare April 14, 2026 18:02
@Borda Borda changed the title Port/deprecations [wip] Port deprecations from 0.27.pot [rebase & merge] Apr 14, 2026
@Borda Borda changed the title Port deprecations from 0.27.pot [rebase & merge] Port deprecations from 0.27.0.post [rebase & merge] Apr 14, 2026
@Borda Borda marked this pull request as ready for review April 14, 2026 19:11
@Borda Borda requested a review from SkalskiP as a code owner April 14, 2026 19:11
Copilot AI review requested due to automatic review settings April 14, 2026 19:11

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 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 pydeprecate as a dependency and replaces the repo’s removed custom deprecated decorator with deprecate.deprecated across updated modules.
  • Introduces deprecation shims/aliases for renamed keypoint validators and for the legacy from_lmm/LMM pathway.
  • Extends utils.image with a (deprecated) create_tiles implementation 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.keypointsupervision.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.

Comment thread src/supervision/utils/image.py Outdated
Comment thread src/supervision/detection/core.py Outdated
Comment thread src/supervision/detection/vlm.py Outdated
Comment thread src/supervision/utils/image.py Outdated
Comment thread src/supervision/utils/image.py Outdated
Comment thread supervision/keypoint/__init__.py Outdated
Comment thread supervision/keypoint/__init__.py Outdated
Comment thread src/supervision/detection/core.py Outdated
Comment thread src/supervision/utils/conversion.py
Borda and others added 5 commits April 15, 2026 13:37
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 Borda merged commit f28874c into develop Apr 15, 2026
27 checks passed
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 Borda deleted the port/deprecations branch April 15, 2026 18:59
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>
@Borda Borda mentioned this pull request Apr 17, 2026
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