Repository navigation
[Docs] Pass keyword-only arguments by name in Jobs and create_branch examples - #5212
Merged
hanouticelina merged 2 commits intoOct 20, 2026
Merged
Conversation
…examples Several examples in the Jobs guide and in HfApi docstrings passed job_id / scheduled_job_id / branch positionally, which raises TypeError since these parameters are keyword-only. Also fix the inspect_scheduled_job example importing inspect_job.
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5212 +/- ##
===========================================
- Coverage 75.00% 53.81% -21.19%
===========================================
Files 145 178 +33
Lines 13978 25110 +11132
===========================================
+ Hits 10484 13514 +3030
- Misses 3494 11596 +8102 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
This PR has been shipped as part of the v2.3.0 release. |
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
HfApidocstrings passed keyword-only arguments positionally, so they raisedTypeErrorwhen copy-pasted:guides/jobs.md:update_job_labels,update_scheduled_job_labels,inspect_scheduled_job,suspend_scheduled_job,resume_scheduled_job,trigger_scheduled_job,delete_scheduled_jobinspect_job(job.id),inspect_scheduled_job(scheduled_job.id)(which also importedinspect_jobinstead ofinspect_scheduled_job), andcreate_branch("gpt2", "new_empty_branch", ...)in thelist_repo_commitsexamplejob_id=/scheduled_job_id=/branch=, like the neighbouring examples.How I found them: I extracted every Python snippet from
docs/source/en/guidesand every>>>docstring example fromsrc/, then checked the calls against theHfApisignatures with a small AST script and with pyright. After this PR, the only remaining hit is aupload_file(..., ...)placeholder in the upload guide, which is intentional. No code changes, so I didn't add a test.make styleandmake qualitypass.Note
Low Risk
Documentation-only edits to examples and docstrings; no production code paths change.
Overview
This PR fixes copy-pasteable Python examples in the Jobs guide and in
HfApidocstrings so they match APIs that require keyword-only arguments after*.In
guides/jobs.md, scheduled-job helpers (update_job_labels,update_scheduled_job_labels,inspect_scheduled_job,suspend/resume,trigger,delete) now passjob_id=orscheduled_job_id=instead of positional IDs. Inhf_api.py, docstring examples forinspect_job,inspect_scheduled_job, andcreate_branchare aligned the same way; the scheduled-job example also importsinspect_scheduled_jobinstead ofinspect_job.No runtime or library behavior changes—only documentation so pasted snippets no longer raise
TypeError.Reviewed by Cursor Bugbot for commit f9991b3. Bugbot is set up for automated code reviews on this repo. Configure here.