docs: convert fenced pycon examples to doctests in boxes.py and draw/utils.py#2425
Draft
shaoming11 wants to merge 2 commits into
Draft
docs: convert fenced pycon examples to doctests in boxes.py and draw/utils.py#2425shaoming11 wants to merge 2 commits into
shaoming11 wants to merge 2 commits into
Conversation
Convert all fenced ```python and ```pycon examples in draw/utils.py to >>> doctest format so they are automatically verified by the test suite via --doctest-modules. Also normalises 'Examples:' to 'Example:' for Google-style consistency. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace all ```pycon fenced blocks with bare >>> doctest format so examples are automatically verified by the test suite via --doctest-modules. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Member
@shaoming11 ^^ pls 🦝 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR converts fenced code blocks in docstring examples to plain >>> doctest format for two core modules, so examples are automatically executed and validated by the existing --doctest-modules test configuration.
Changes:
- Replaced fenced
python /pycon docstring blocks indraw/utils.pywith runnable doctest prompts and simple assertions (e.g.,result.shape). - Removed fenced block markers in
detection/utils/boxes.pyso existing examples are parsed as doctests. - Standardized docstring example headings (e.g.,
Example:) where blocks were converted.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/supervision/draw/utils.py | Converts drawing utility docstring examples to runnable doctests (using result = ... and lightweight checks). |
| src/supervision/detection/utils/boxes.py | Removes fenced markers so existing >>> examples become active doctests. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2425 +/- ##
=======================================
Coverage 87% 87%
=======================================
Files 71 71
Lines 10485 10485
=======================================
Hits 9098 9098
Misses 1387 1387 🚀 New features to boost your workflow:
|
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.
Summary
```pycon/```pythonexample blocks insrc/supervision/detection/utils/boxes.pyandsrc/supervision/draw/utils.pyto bare>>>doctest format--doctest-modulesAddresses the project preference stated in CONTRIBUTING.md:
Files changed
src/supervision/detection/utils/boxes.py— 9 fenced blocks converted (clip_boxes,pad_boxes,denormalize_boxes,move_boxes,move_oriented_boxes,xyxyxyxy_to_xyxy,_oriented_box_anchors,scale_boxes,spread_out_boxes)src/supervision/draw/utils.py— 7 fenced blocks converted (draw_line,draw_rectangle,draw_filled_rectangle,draw_rounded_rectangle,draw_polygon,draw_filled_polygon,draw_image)Test plan
uv run pytest --doctest-modules src/supervision/detection/utils/boxes.py— 10 passeduv run pytest --doctest-modules src/supervision/draw/utils.py— all passed🤖 Generated with Claude Code