Check if docstring is None before formating it (#20592)

docstrings could be `None` if Python optimize level is set to 2.
This commit is contained in:
xxyzz
2022-12-06 20:44:17 +08:00
committed by GitHub
parent ae06bce888
commit b9a0ede6ab
7 changed files with 28 additions and 21 deletions

View File

@@ -3768,6 +3768,7 @@ def get_fast_tokenizer_file(tokenization_files: List[str]) -> str:
# To update the docstring, we need to copy the method, otherwise we change the original docstring.
PreTrainedTokenizerBase.push_to_hub = copy_func(PreTrainedTokenizerBase.push_to_hub)
PreTrainedTokenizerBase.push_to_hub.__doc__ = PreTrainedTokenizerBase.push_to_hub.__doc__.format(
object="tokenizer", object_class="AutoTokenizer", object_files="tokenizer files"
)
if PreTrainedTokenizerBase.push_to_hub.__doc__ is not None:
PreTrainedTokenizerBase.push_to_hub.__doc__ = PreTrainedTokenizerBase.push_to_hub.__doc__.format(
object="tokenizer", object_class="AutoTokenizer", object_files="tokenizer files"
)