2424import re
2525from collections import OrderedDict
2626from pathlib import Path
27- from typing import Any , Dict , Optional , Tuple , Union
27+ from typing import Any , Optional , Union
2828
2929import numpy as np
3030from huggingface_hub import DDUFEntry , create_repo , hf_hub_download
@@ -94,10 +94,10 @@ class ConfigMixin:
9494 Class attributes:
9595 - **config_name** (`str`) -- A filename under which the config should stored when calling
9696 [`~ConfigMixin.save_config`] (should be overridden by parent class).
97- - **ignore_for_config** (`List [str]`) -- A list of attributes that should not be saved in the config (should be
97+ - **ignore_for_config** (`list [str]`) -- A list of attributes that should not be saved in the config (should be
9898 overridden by subclass).
9999 - **has_compatibles** (`bool`) -- Whether the class has compatible classes (should be overridden by subclass).
100- - **_deprecated_kwargs** (`List [str]`) -- Keyword arguments that are deprecated. Note that the `init` function
100+ - **_deprecated_kwargs** (`list [str]`) -- Keyword arguments that are deprecated. Note that the `init` function
101101 should only have a `kwargs` argument if at least one argument is deprecated (should be overridden by
102102 subclass).
103103 """
@@ -155,7 +155,7 @@ def save_config(self, save_directory: Union[str, os.PathLike], push_to_hub: bool
155155 Whether or not to push your model to the Hugging Face Hub after saving it. You can specify the
156156 repository you want to push to with `repo_id` (will default to the name of `save_directory` in your
157157 namespace).
158- kwargs (`Dict [str, Any]`, *optional*):
158+ kwargs (`dict [str, Any]`, *optional*):
159159 Additional keyword arguments passed along to the [`~utils.PushToHubMixin.push_to_hub`] method.
160160 """
161161 if os .path .isfile (save_directory ):
@@ -189,13 +189,13 @@ def save_config(self, save_directory: Union[str, os.PathLike], push_to_hub: bool
189189
190190 @classmethod
191191 def from_config (
192- cls , config : Union [FrozenDict , Dict [str , Any ]] = None , return_unused_kwargs = False , ** kwargs
193- ) -> Union [Self , Tuple [Self , Dict [str , Any ]]]:
192+ cls , config : Union [FrozenDict , dict [str , Any ]] = None , return_unused_kwargs = False , ** kwargs
193+ ) -> Union [Self , tuple [Self , dict [str , Any ]]]:
194194 r"""
195195 Instantiate a Python class from a config dictionary.
196196
197197 Parameters:
198- config (`Dict [str, Any]`):
198+ config (`dict [str, Any]`):
199199 A config dictionary from which the Python class is instantiated. Make sure to only load configuration
200200 files of compatible classes.
201201 return_unused_kwargs (`bool`, *optional*, defaults to `False`):
@@ -296,7 +296,7 @@ def load_config(
296296 return_unused_kwargs = False ,
297297 return_commit_hash = False ,
298298 ** kwargs ,
299- ) -> Tuple [ Dict [str , Any ], Dict [str , Any ]]:
299+ ) -> tuple [ dict [str , Any ], dict [str , Any ]]:
300300 r"""
301301 Load a model or scheduler configuration.
302302
@@ -315,7 +315,7 @@ def load_config(
315315 force_download (`bool`, *optional*, defaults to `False`):
316316 Whether or not to force the (re-)download of the model weights and configuration files, overriding the
317317 cached versions if they exist.
318- proxies (`Dict [str, str]`, *optional*):
318+ proxies (`dict [str, str]`, *optional*):
319319 A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128',
320320 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request.
321321 output_loading_info(`bool`, *optional*, defaults to `False`):
@@ -352,7 +352,7 @@ def load_config(
352352 _ = kwargs .pop ("mirror" , None )
353353 subfolder = kwargs .pop ("subfolder" , None )
354354 user_agent = kwargs .pop ("user_agent" , {})
355- dduf_entries : Optional [Dict [str , DDUFEntry ]] = kwargs .pop ("dduf_entries" , None )
355+ dduf_entries : Optional [dict [str , DDUFEntry ]] = kwargs .pop ("dduf_entries" , None )
356356
357357 user_agent = {** user_agent , "file_type" : "config" }
358358 user_agent = http_user_agent (user_agent )
@@ -564,7 +564,7 @@ def extract_init_dict(cls, config_dict, **kwargs):
564564
565565 @classmethod
566566 def _dict_from_json_file (
567- cls , json_file : Union [str , os .PathLike ], dduf_entries : Optional [Dict [str , DDUFEntry ]] = None
567+ cls , json_file : Union [str , os .PathLike ], dduf_entries : Optional [dict [str , DDUFEntry ]] = None
568568 ):
569569 if dduf_entries :
570570 text = dduf_entries [json_file ].read_text ()
@@ -577,12 +577,12 @@ def __repr__(self):
577577 return f"{ self .__class__ .__name__ } { self .to_json_string ()} "
578578
579579 @property
580- def config (self ) -> Dict [str , Any ]:
580+ def config (self ) -> dict [str , Any ]:
581581 """
582582 Returns the config of the class as a frozen dictionary
583583
584584 Returns:
585- `Dict [str, Any]`: Config of the class.
585+ `dict [str, Any]`: Config of the class.
586586 """
587587 return self ._internal_dict
588588
@@ -637,7 +637,7 @@ def to_json_file(self, json_file_path: Union[str, os.PathLike]):
637637 writer .write (self .to_json_string ())
638638
639639 @classmethod
640- def _get_config_file_from_dduf (cls , pretrained_model_name_or_path : str , dduf_entries : Dict [str , DDUFEntry ]):
640+ def _get_config_file_from_dduf (cls , pretrained_model_name_or_path : str , dduf_entries : dict [str , DDUFEntry ]):
641641 # paths inside a DDUF file must always be "/"
642642 config_file = (
643643 cls .config_name
@@ -756,7 +756,7 @@ class LegacyConfigMixin(ConfigMixin):
756756 """
757757
758758 @classmethod
759- def from_config (cls , config : Union [FrozenDict , Dict [str , Any ]] = None , return_unused_kwargs = False , ** kwargs ):
759+ def from_config (cls , config : Union [FrozenDict , dict [str , Any ]] = None , return_unused_kwargs = False , ** kwargs ):
760760 # To prevent dependency import problem.
761761 from .models .model_loading_utils import _fetch_remapped_cls_from_config
762762
0 commit comments