Skip to content

docs: convert fenced examples to doctests in draw/utils.py#2424

Open
shaoming11 wants to merge 1 commit into
roboflow:developfrom
shaoming11:docs/convert-draw-utils-fenced-examples-to-doctests
Open

docs: convert fenced examples to doctests in draw/utils.py#2424
shaoming11 wants to merge 1 commit into
roboflow:developfrom
shaoming11:docs/convert-draw-utils-fenced-examples-to-doctests

Conversation

@shaoming11

Copy link
Copy Markdown

Summary

  • Converts all 8 fenced ```python examples in draw/utils.py to >>> doctest format
  • Unwraps 2 ```pycon blocks (calculate_optimal_text_scale, calculate_optimal_line_thickness) to raw >>> format
  • Normalises Examples:Example: for Google-style consistency

Per the contributing guidelines, >>> doctest format is strongly preferred when an example only uses supervision, NumPy, and the standard library — all 10 examples in this file qualify. They are now automatically verified by uv run pytest --doctest-modules src/.

Test plan

  • uv run pytest --doctest-modules src/supervision/draw/utils.py — 10 passed

🤖 Generated with Claude Code

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>
@shaoming11 shaoming11 requested a review from SkalskiP as a code owner July 12, 2026 19:18
@CLAassistant

CLAassistant commented Jul 12, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Borda Borda requested a review from Copilot July 13, 2026 07:31
@Borda

Borda commented Jul 13, 2026

Copy link
Copy Markdown
Member

Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.

@shaoming11 ^^ pls 🦝

@Borda Borda marked this pull request as draft July 13, 2026 07:31

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 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 / ```pycon example blocks with doctest prompts (>>> / ...) across the module.
  • Normalizes docstring headings from Examples: to Example: 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

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87%. Comparing base (d5cadf5) to head (bb605e5).

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

@Borda Borda marked this pull request as ready for review July 14, 2026 10:30
Recommended line thickness in pixels.

Examples:
```pycon

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how it ends up when you remove it

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants