File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 5858# TODO: remove after deprecation period is over (v0.7)
5959def _validate_repo_id_deprecation (repo_id , name , organization ):
6060 """Returns (name, organization) from the input."""
61+ if repo_id and not name and organization :
62+ # this means the user had passed name as positional, now mapped to
63+ # repo_id and is passing organization as well. This wouldn't be an
64+ # issue if they pass everything as kwarg. So we switch the parameters
65+ # here:
66+ repo_id , name = name , repo_id
67+
6168 if not (repo_id or name ):
6269 raise ValueError (
6370 "No name provided. Please pass `repo_id` with a valid repository name."
Original file line number Diff line number Diff line change @@ -227,6 +227,14 @@ def test_validate_repo_id_deprecation():
227227 repo_id = "repo_id" , name = "name" , organization = "organization"
228228 )
229229
230+ # regression test for
231+ # https://github.com/huggingface/huggingface_hub/issues/821
232+ with pytest .warns (FutureWarning , match = "input arguments are deprecated" ):
233+ name , org = _validate_repo_id_deprecation (
234+ repo_id = "repo" , name = None , organization = "org"
235+ )
236+ assert name == "repo" and org == "org"
237+
230238
231239@retry_endpoint
232240def test_name_org_deprecation_warning ():
You can’t perform that action at this time.
0 commit comments