Skip to content

[Docs] Pass keyword-only arguments by name in Jobs and create_branch examples - #5212

Merged
hanouticelina merged 2 commits into
huggingface:mainfrom
Blacksujit:docs-keyword-only-examples
Oct 20, 2026
Merged

hanouticelina merged 2 commits into
huggingface:mainfrom
Blacksujit:docs-keyword-only-examples

Conversation

@Blacksujit

@Blacksujit Blacksujit commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Docs-only change. Some examples in the Jobs guide and in HfApi docstrings passed keyword-only arguments positionally, so they raised TypeError when 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_job
    • docstrings: inspect_job(job.id), inspect_scheduled_job(scheduled_job.id) (which also imported inspect_job instead of inspect_scheduled_job), and create_branch("gpt2", "new_empty_branch", ...) in the list_repo_commits example
  • They now use job_id= / scheduled_job_id= / branch=, like the neighbouring examples.
>>> HfApi().update_job_labels("my-job-id", labels={"env": "prod"})
TypeError: HfApi.update_job_labels() takes 1 positional argument but 2 were given

How I found them: I extracted every Python snippet from docs/source/en/guides and every >>> docstring example from src/, then checked the calls against the HfApi signatures with a small AST script and with pyright. After this PR, the only remaining hit is a upload_file(..., ...) placeholder in the upload guide, which is intentional. No code changes, so I didn't add a test. make style and make quality pass.


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 HfApi docstrings 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 pass job_id= or scheduled_job_id= instead of positional IDs. In hf_api.py, docstring examples for inspect_job, inspect_scheduled_job, and create_branch are aligned the same way; the scheduled-job example also imports inspect_scheduled_job instead of inspect_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.

Blacksujit and others added 2 commits October 20, 2026 05:08
…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.

@hanouticelina hanouticelina left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks!

@bot-ci-comment

Copy link
Copy Markdown

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

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 53.81%. Comparing base (1daa48b) to head (ea47a8a).
⚠️ Report is 804 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hanouticelina
hanouticelina merged commit 3d14963 into huggingface:main Oct 20, 2026
22 of 27 checks passed
@huggingface-hub-bot

Copy link
Copy Markdown
Contributor

This PR has been shipped as part of the v2.3.0 release.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants