docs: convert fenced examples to doctests in dataset/formats/createml.py - #2475
Merged
Merged
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2475 +/- ##
=======================================
- Coverage 88% 88% -0%
=======================================
Files 85 85
Lines 12042 12042
=======================================
- Hits 10543 10540 -3
- Misses 1499 1502 +3 🚀 New features to boost your workflow:
|
Borda
approved these changes
Aug 7, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates src/supervision/dataset/formats/createml.py docstrings to convert runnable fenced python examples into pycon-style doctests so they are executed under the repository’s pytest --doctest-modules configuration, reducing documentation drift.
Changes:
- Converted the
createml_annotations_to_detectionsdocstring example from a fencedpythonsnippet to apycondoctest and added an explicit assertion ofclass_id. - Converted the
detections_to_createml_annotationsdocstring example to apycondoctest with verified structured output. - Normalized docstring section heading from
Examples:toExample:(including keepingsave_createml_annotationsas a fenced block due to filesystem writes).
This was referenced Aug 8, 2026
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.
Before submitting
Description
Converts the 2 runnable fenced
```pythonexamples indataset/formats/createml.pytopycondoctest format so they are executed and verified bypytest --doctest-modules. Follow-up to #2474 (same conversion fordataset/formats/coco.py) and #2451 (draw/utils.py).The
save_createml_annotationsexample is intentionally left as a fenced block — it writes a file to disk, which CONTRIBUTING.md §Doctests lists as a case where fenced blocks are appropriate.Type of Change
Motivation and Context
Fenced examples are rendered in the docs but never executed, so they can silently drift from real behaviour. Both converted examples use only
supervisionand NumPy, so per the contributing guidelines they should be doctests.Changes Made
createml_annotations_to_detections: fenced example → doctest; verified output now also assertsclass_id, covering the label→id mapping half of the function's contract alongside the centre→corner box conversion. Removed animport supervision as svthat the example never used.detections_to_createml_annotations: fenced example → doctest with the full coordinates dict as verified output (round-trip of the example above).Examples:→Example:for Google-style consistency.Testing
uv run pytest --doctest-modules src/supervision/dataset/formats/createml.py— 2 passed.Full suite: 3565 passed, 20 skipped (+2 doctests, no regressions).
pre-commit run— all hooks pass, includingcheck doctest fences.🤖 Generated with Claude Code