Skip to content

Commit 78c2fdc

Browse files
authored
SchedulerMixin from_pretrained and ConfigMixin Self type annotation (#11192)
1 parent 54dac3a commit 78c2fdc

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/diffusers/configuration_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
validate_hf_hub_args,
3636
)
3737
from requests import HTTPError
38+
from typing_extensions import Self
3839

3940
from . import __version__
4041
from .utils import (
@@ -185,7 +186,9 @@ def save_config(self, save_directory: Union[str, os.PathLike], push_to_hub: bool
185186
)
186187

187188
@classmethod
188-
def from_config(cls, config: Union[FrozenDict, Dict[str, Any]] = None, return_unused_kwargs=False, **kwargs):
189+
def from_config(
190+
cls, config: Union[FrozenDict, Dict[str, Any]] = None, return_unused_kwargs=False, **kwargs
191+
) -> Union[Self, Tuple[Self, Dict[str, Any]]]:
189192
r"""
190193
Instantiate a Python class from a config dictionary.
191194

src/diffusers/schedulers/scheduling_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import torch
2121
from huggingface_hub.utils import validate_hf_hub_args
22+
from typing_extensions import Self
2223

2324
from ..utils import BaseOutput, PushToHubMixin
2425

@@ -99,7 +100,7 @@ def from_pretrained(
99100
subfolder: Optional[str] = None,
100101
return_unused_kwargs=False,
101102
**kwargs,
102-
):
103+
) -> Self:
103104
r"""
104105
Instantiate a scheduler from a pre-defined JSON configuration file in a local directory or Hub repository.
105106

0 commit comments

Comments
 (0)