Skip to content

Commit 5b1dcd1

Browse files
SahilCarterrhlky
andauthored
[Fix] Type Hint in from_pretrained() to Ensure Correct Type Inference (#10714)
* Update pipeline_utils.py Added Self in from_pretrained method so inference will correctly recognize pipeline * Use typing_extensions --------- Co-authored-by: hlky <[email protected]>
1 parent dbe0094 commit 5b1dcd1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/diffusers/pipelines/pipeline_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from packaging import version
4242
from requests.exceptions import HTTPError
4343
from tqdm.auto import tqdm
44+
from typing_extensions import Self
4445

4546
from .. import __version__
4647
from ..configuration_utils import ConfigMixin
@@ -513,7 +514,7 @@ def dtype(self) -> torch.dtype:
513514

514515
@classmethod
515516
@validate_hf_hub_args
516-
def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.PathLike]], **kwargs):
517+
def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.PathLike]], **kwargs) -> Self:
517518
r"""
518519
Instantiate a PyTorch diffusion pipeline from pretrained pipeline weights.
519520

0 commit comments

Comments
 (0)