docs: convert fenced examples to doctests in draw/utils.py#2424
Open
shaoming11 wants to merge 1 commit into
Open
docs: convert fenced examples to doctests in draw/utils.py#2424shaoming11 wants to merge 1 commit into
shaoming11 wants to merge 1 commit 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>
Member
@shaoming11 ^^ pls 🦝 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates src/supervision/draw/utils.py docstrings to use >>>-style doctest examples so they are automatically exercised by pytest --doctest-modules, aligning the file with the project’s doctest guidance.
Changes:
- Replaces fenced
```python/```pyconexample blocks with doctest prompts (>>>/...) across the module. - Normalizes docstring headings from
Examples:toExample:for Google-style consistency. - Adjusts examples to assert lightweight, deterministic properties (e.g.,
result.shape) instead of only performing side-effect calls.
Review checklist scores (n/5):
- Code quality: 5/5
- Testing: 3/5
- Docs: 3/5
| >>> from supervision.draw.utils import draw_polygon | ||
| >>> from supervision.draw.color import Color | ||
| >>> scene = np.zeros((100, 100, 3), dtype=np.uint8) | ||
| >>> polygon = np.array([[10, 10], [90, 10], [90, 90], [10, 90]]) |
| >>> from supervision.draw.utils import draw_filled_polygon | ||
| >>> from supervision.draw.color import Color | ||
| >>> scene = np.zeros((100, 100, 3), dtype=np.uint8) | ||
| >>> polygon = np.array([[10, 10], [90, 10], [90, 90], [10, 90]]) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2424 +/- ##
=======================================
Coverage 87% 87%
=======================================
Files 71 71
Lines 10485 10485
=======================================
Hits 9098 9098
Misses 1387 1387 🚀 New features to boost your workflow:
|
Borda
reviewed
Jul 14, 2026
| Recommended line thickness in pixels. | ||
|
|
||
| Examples: | ||
| ```pycon |
Member
Borda
requested changes
Jul 14, 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.

Summary
```pythonexamples indraw/utils.pyto>>>doctest format```pyconblocks (calculate_optimal_text_scale,calculate_optimal_line_thickness) to raw>>>formatExamples:→Example:for Google-style consistencyPer the contributing guidelines,
>>>doctest format is strongly preferred when an example only usessupervision, NumPy, and the standard library — all 10 examples in this file qualify. They are now automatically verified byuv run pytest --doctest-modules src/.Test plan
uv run pytest --doctest-modules src/supervision/draw/utils.py— 10 passed🤖 Generated with Claude Code