Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a helpful errorwhen commit_message is empty in create_commit #962

Merged
merged 1 commit into from
Aug 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/huggingface_hub/hf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1858,6 +1858,8 @@ def create_commit(
If `create_pr` is `True`, returns the URL to the newly created Pull Request
on the Hub. Otherwise returns `None`.
"""
if commit_message is None or len(commit_message) == 0:
Copy link
Contributor

@SBrandeis SBrandeis Aug 2, 2022

Choose a reason for hiding this comment

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

Suggested change
if commit_message is None or len(commit_message) == 0:
if not commit_message:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have been burned too many times by relying on Python bool-conversion magic so I prefer explicit tests :-) But feel free to merge the suggestion if it fits the style of huggingface_hub better.

raise ValueError("`commit_message` can't be empty, please pass a value.")
commit_description = (
commit_description if commit_description is not None else ""
)
Expand Down