chore: postpone annotations in src typing#2356
Merged
Merged
Conversation
Add postponed annotation evaluation to remaining source modules that already use modern annotation syntax. Keep the change limited to typing syntax cleanup for Python 3.10 compatibility. Co-authored-by: Codex <codex@openai.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #2356 +/- ##
=======================================
- Coverage 82% 82% -0%
=======================================
Files 68 68
Lines 9507 9523 +16
=======================================
+ Hits 7811 7823 +12
- Misses 1696 1700 +4 🚀 New features to boost your workflow:
|
Port docstring-preserving Python 3.10 typing improvements under src/. Keep changes limited to typing syntax, untyped deprecate import boundaries, and a safe icon image cast. Co-authored-by: Codex <codex@openai.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR standardizes typing syntax across remaining modules as part of the Python 3.10 baseline work (referenced by #2260), primarily by enabling postponed annotation evaluation and migrating legacy typing constructs (e.g., Optional/Union) to modern syntax.
Changes:
- Added
from __future__ import annotationsto additional modules to postpone annotation evaluation consistently. - Replaced
Optional[...]/Union[...]usage withT | None/A | Bwhere applicable. - Added
# type: ignore[import-untyped]ondeprecateimports to keep type checking clean.
Assessment (n/5):
- Code quality: 3/5
- Testing: 3/5
- Documentation: 3/5
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/supervision/validators/init.py | Add postponed annotations and modernize optional dict typing; mark deprecate as untyped import. |
| src/supervision/utils/iterables.py | Add postponed annotation evaluation import. |
| src/supervision/utils/image.py | Mark deprecate import as untyped. |
| src/supervision/utils/conversion.py | Add postponed annotations and mark deprecate import as untyped. |
| src/supervision/tracker/byte_tracker/core.py | Mark deprecate import as untyped. |
| src/supervision/metrics/detection.py | Reformat deprecate imports and mark as untyped. |
| src/supervision/key_points/skeletons.py | Add postponed annotation evaluation import. |
| src/supervision/key_points/core.py | Replace Union[...] aliases with ` |
| src/supervision/geometry/utils.py | Add postponed annotation evaluation import. |
| src/supervision/draw/base.py | Add postponed annotation evaluation import. |
| src/supervision/detection/utils/internal.py | Replace Union[...] in cast with ` |
| src/supervision/detection/utils/boxes.py | Mark deprecate import as untyped. |
| src/supervision/detection/tools/inference_slicer.py | Switch TypeGuard import to stdlib typing (Py3.10+) and simplify typing imports. |
| src/supervision/dataset/utils.py | Mark deprecate import as untyped. |
| src/supervision/dataset/formats/coco.py | Add postponed annotations; replace Union[...] with ` |
| src/supervision/assets/list.py | Add postponed annotations and use unquoted Assets return annotation. |
| src/supervision/annotators/core.py | Refactor _load_icon typing around letterbox_image call. |
Port useful source-only typing refinements from the Python 3.10 branch while preserving docstrings and current runtime behavior. Co-authored-by: Codex <codex@openai.com>
Replace Python 3.10 pipe-based typings (`|`) with `Union[...]` for compatibility and consistency across source modules.
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.
Add postponed annotation evaluation to remaining source modules that already use modern annotation syntax.
Keep the change limited to typing syntax cleanup for Python 3.10 compatibility.
Part of #2260