Repository navigation
Fix docstring examples that do not parse as Python, and add a test that parses them - #1318
Open
Jeremy Rose (jeremyrose-viam) wants to merge 1 commit into
Open
Jeremy Rose (jeremyrose-viam) wants to merge 1 commit into
Jeremy Rose (jeremyrose-viam) wants to merge 1 commit into
Conversation
…parses them Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Jeremy Rose (jeremyrose-viam)
requested a review
from a team
as a code owner
November 25, 2026 20:09
Jeremy Rose (jeremyrose-viam)
requested review from
Naveed Jooma (njooma) and
Sean Pollock (seanavery)
November 25, 2026 20:09
Contributor
|
Warning your change may break code samples. If your change modifies any of the following functions please contact @viamrobotics/fleet-management. Thanks!
|
Member
|
👋 Thanks for requesting a review from the team! We aim to review PRs within one business day. If this is urgent |
This branch has not been deployed
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.
Docstring examples are shown on python.viam.dev and copied into other documentation, so readers paste them. 19 of the 330
::example blocks insrc/viamare not valid Python. This PR fixes only syntax, and adds a test so it stays that way.Fixes
from_robot(robot=machine, "my_detector")becomesfrom_robot(robot=machine, name="my_detector"). 14 call sites inController(4 methods),ServiceBase.do_command(inherited by the Discovery, Generic, Motion, SLAM, Vision, MLModel and WorldStateStore clients) andVision(7 methods).from_robot(cls, robot, name)is unchanged; the examples were rewritten fromfrom_robot(robot, "x")when "robot" became "machine" and picked up the keyword by mistake.get_invoices_summary(<ORG-ID>)becomesget_invoices_summary("<ORG-ID>"), the form other clients already use (for examplepart_id="<PART-ID>"). AffectsBillingClient(class example,get_current_month_usage,get_invoice_pdf,get_invoices_summary,charge_organization) andDataClient.create_data_pipeline(["<YOUR-MQL-PIPELINE-AGGREGATION>"]).start_time=andend_time=inDataClient.export_tabular_data, and afterbbox_id=inDataClient.update_bounding_box.Test
tests/test_docstring_examples.pycollects every::literal block from docstrings undersrc/viam(excludinggen/andproto/) and runsast.parseon it. On currentmainit fails for 19 blocks; with this change all 330 pass. It checks syntax only: it does not run examples or check argument names.Not in this PR
Some examples parse but are still wrong, for example
Motor.go_tousesrevolutions=(the parameter isposition_revolutions),Discovery.discover_resourcespasses a positional argument, andupdate_bounding_boxcalls the old nameupdate_bounding_box_to_image_by_id. I left these for a separate change so this one stays mechanical.Checks
pytest tests/test_docstring_examples.pyandruff check/ruff format --checkon the test file pass. Docstring-only otherwise; no behavior change.Notes
The "Code-Samples Warning" comment is expected: the PR touches
input.pyandvision.py, but only docstring text, not the functions listed inexamples/apis.json.🤖 Generated with Claude Code