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:
@@ -942,6 +942,7 @@ def get_configuration_file(configuration_files: List[str]) -> str:
|
|||||||
|
|
||||||
|
|
||||||
PretrainedConfig.push_to_hub = copy_func(PretrainedConfig.push_to_hub)
|
PretrainedConfig.push_to_hub = copy_func(PretrainedConfig.push_to_hub)
|
||||||
PretrainedConfig.push_to_hub.__doc__ = PretrainedConfig.push_to_hub.__doc__.format(
|
if PretrainedConfig.push_to_hub.__doc__ is not None:
|
||||||
|
PretrainedConfig.push_to_hub.__doc__ = PretrainedConfig.push_to_hub.__doc__.format(
|
||||||
object="config", object_class="AutoConfig", object_files="configuration file"
|
object="config", object_class="AutoConfig", object_files="configuration file"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -598,6 +598,7 @@ class FeatureExtractionMixin(PushToHubMixin):
|
|||||||
|
|
||||||
|
|
||||||
FeatureExtractionMixin.push_to_hub = copy_func(FeatureExtractionMixin.push_to_hub)
|
FeatureExtractionMixin.push_to_hub = copy_func(FeatureExtractionMixin.push_to_hub)
|
||||||
FeatureExtractionMixin.push_to_hub.__doc__ = FeatureExtractionMixin.push_to_hub.__doc__.format(
|
if FeatureExtractionMixin.push_to_hub.__doc__ is not None:
|
||||||
|
FeatureExtractionMixin.push_to_hub.__doc__ = FeatureExtractionMixin.push_to_hub.__doc__.format(
|
||||||
object="feature extractor", object_class="AutoFeatureExtractor", object_files="feature extractor file"
|
object="feature extractor", object_class="AutoFeatureExtractor", object_files="feature extractor file"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -523,6 +523,7 @@ def get_size_dict(
|
|||||||
|
|
||||||
|
|
||||||
ImageProcessingMixin.push_to_hub = copy_func(ImageProcessingMixin.push_to_hub)
|
ImageProcessingMixin.push_to_hub = copy_func(ImageProcessingMixin.push_to_hub)
|
||||||
ImageProcessingMixin.push_to_hub.__doc__ = ImageProcessingMixin.push_to_hub.__doc__.format(
|
if ImageProcessingMixin.push_to_hub.__doc__ is not None:
|
||||||
|
ImageProcessingMixin.push_to_hub.__doc__ = ImageProcessingMixin.push_to_hub.__doc__.format(
|
||||||
object="image processor", object_class="AutoImageProcessor", object_files="image processor file"
|
object="image processor", object_class="AutoImageProcessor", object_files="image processor file"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1073,9 +1073,10 @@ class FlaxPreTrainedModel(PushToHubMixin, FlaxGenerationMixin):
|
|||||||
|
|
||||||
# To update the docstring, we need to copy the method, otherwise we change the original docstring.
|
# To update the docstring, we need to copy the method, otherwise we change the original docstring.
|
||||||
FlaxPreTrainedModel.push_to_hub = copy_func(FlaxPreTrainedModel.push_to_hub)
|
FlaxPreTrainedModel.push_to_hub = copy_func(FlaxPreTrainedModel.push_to_hub)
|
||||||
FlaxPreTrainedModel.push_to_hub.__doc__ = FlaxPreTrainedModel.push_to_hub.__doc__.format(
|
if FlaxPreTrainedModel.push_to_hub.__doc__ is not None:
|
||||||
|
FlaxPreTrainedModel.push_to_hub.__doc__ = FlaxPreTrainedModel.push_to_hub.__doc__.format(
|
||||||
object="model", object_class="FlaxAutoModel", object_files="model checkpoint"
|
object="model", object_class="FlaxAutoModel", object_files="model checkpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def overwrite_call_docstring(model_class, docstring):
|
def overwrite_call_docstring(model_class, docstring):
|
||||||
|
|||||||
@@ -2810,9 +2810,10 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
|
|||||||
|
|
||||||
|
|
||||||
PreTrainedModel.push_to_hub = copy_func(PreTrainedModel.push_to_hub)
|
PreTrainedModel.push_to_hub = copy_func(PreTrainedModel.push_to_hub)
|
||||||
PreTrainedModel.push_to_hub.__doc__ = PreTrainedModel.push_to_hub.__doc__.format(
|
if PreTrainedModel.push_to_hub.__doc__ is not None:
|
||||||
|
PreTrainedModel.push_to_hub.__doc__ = PreTrainedModel.push_to_hub.__doc__.format(
|
||||||
object="model", object_class="AutoModel", object_files="model file"
|
object="model", object_class="AutoModel", object_files="model file"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class PoolerStartLogits(nn.Module):
|
class PoolerStartLogits(nn.Module):
|
||||||
|
|||||||
@@ -234,6 +234,7 @@ class ProcessorMixin(PushToHubMixin):
|
|||||||
|
|
||||||
|
|
||||||
ProcessorMixin.push_to_hub = copy_func(ProcessorMixin.push_to_hub)
|
ProcessorMixin.push_to_hub = copy_func(ProcessorMixin.push_to_hub)
|
||||||
ProcessorMixin.push_to_hub.__doc__ = ProcessorMixin.push_to_hub.__doc__.format(
|
if ProcessorMixin.push_to_hub.__doc__ is not None:
|
||||||
|
ProcessorMixin.push_to_hub.__doc__ = ProcessorMixin.push_to_hub.__doc__.format(
|
||||||
object="processor", object_class="AutoProcessor", object_files="processor files"
|
object="processor", object_class="AutoProcessor", object_files="processor files"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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.
|
# 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 = copy_func(PreTrainedTokenizerBase.push_to_hub)
|
||||||
PreTrainedTokenizerBase.push_to_hub.__doc__ = PreTrainedTokenizerBase.push_to_hub.__doc__.format(
|
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"
|
object="tokenizer", object_class="AutoTokenizer", object_files="tokenizer files"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user