From 3ea9acfb99593c9143468d98490297706a988ddc Mon Sep 17 00:00:00 2001 From: nateraw Date: Wed, 24 Aug 2022 18:22:08 -0400 Subject: [PATCH] :memo: add typehints to repocard.py --- src/huggingface_hub/repocard.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/huggingface_hub/repocard.py b/src/huggingface_hub/repocard.py index 05409f99c7..5abb520e85 100644 --- a/src/huggingface_hub/repocard.py +++ b/src/huggingface_hub/repocard.py @@ -122,7 +122,12 @@ def save(self, filepath: Union[Path, str]): filepath.write_text(str(self)) @classmethod - def load(cls, repo_id_or_path: Union[str, Path], repo_type=None, token=None): + def load( + cls, + repo_id_or_path: Union[str, Path], + repo_type: Optional[str] = None, + token: Optional[str] = None, + ): """Initialize a RepoCard from a Hugging Face Hub repo's README.md or a local filepath. Args: @@ -164,7 +169,7 @@ def load(cls, repo_id_or_path: Union[str, Path], repo_type=None, token=None): with Path(card_path).open(mode="r", newline="") as f: return cls(f.read()) - def validate(self, repo_type=None): + def validate(self, repo_type: Optional[str] = None): """Validates card against Hugging Face Hub's card validation logic. Using this function requires access to the internet, so it is only called internally by [`huggingface_hub.repocard.RepoCard.push_to_hub`]. @@ -207,14 +212,14 @@ def validate(self, repo_type=None): def push_to_hub( self, - repo_id, - token=None, - repo_type=None, - commit_message=None, - commit_description=None, - revision=None, - create_pr=None, - parent_commit=None, + repo_id: str, + token: Optional[str] = None, + repo_type: Optional[str] = None, + commit_message: Optional[str] = None, + commit_description: Optional[str] = None, + revision: Optional[str] = None, + create_pr: Optional[bool] = None, + parent_commit: Optional[str] = None, ): """Push a RepoCard to a Hugging Face Hub repo.