New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix PyCharm/VSCode static type checking for dummy objects #1596
Conversation
src/diffusers/__init__.py
Outdated
try: | ||
if not (is_torch_available() and is_librosa_available()): | ||
raise OptionalDependencyNotAvailable() | ||
except OptionalDependencyNotAvailable: | ||
from ..utils.dummy_torch_and_librosa_objects import * # noqa F403 | ||
else: | ||
from .utils.dummy_torch_and_transformers_and_onnx_objects import * # noqa F403 | ||
from .pipelines import AudioDiffusionPipeline, Mel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were under is_torch_available()
before, so I suspect the dummies in dummy_torch_and_librosa_objects.py
were created manually, instead of using make fix-copies
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And there were no import errors because is_torch_available() and is_librosa_available()
was correctly used in pipelines.__init__.py
instead.
The documentation is not available anymore as the PR was closed or merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Many thanks!
Co-authored-by: Pedro Cuenca <pedro@huggingface.co>
@@ -29,14 +36,12 @@ | |||
) | |||
from .pipeline_utils import DiffusionPipeline | |||
from .pipelines import ( | |||
AudioDiffusionPipeline, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah it's further down
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
…e#1596) * Fix PyCharm/VSCode static type checking for dummy objects * Re-add dummies * Fix AudioDiffusion imports * fix import * fix import * Update utils/check_dummies.py Co-authored-by: Pedro Cuenca <pedro@huggingface.co> * Update src/diffusers/utils/import_utils.py * Update src/diffusers/__init__.py Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> * Update src/diffusers/pipelines/stable_diffusion/__init__.py * fix double import Co-authored-by: Pedro Cuenca <pedro@huggingface.co> Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
…e#1596) * Fix PyCharm/VSCode static type checking for dummy objects * Re-add dummies * Fix AudioDiffusion imports * fix import * fix import * Update utils/check_dummies.py Co-authored-by: Pedro Cuenca <pedro@huggingface.co> * Update src/diffusers/utils/import_utils.py * Update src/diffusers/__init__.py Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> * Update src/diffusers/pipelines/stable_diffusion/__init__.py * fix double import Co-authored-by: Pedro Cuenca <pedro@huggingface.co> Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
…e#1596) * Fix PyCharm/VSCode static type checking for dummy objects * Re-add dummies * Fix AudioDiffusion imports * fix import * fix import * Update utils/check_dummies.py Co-authored-by: Pedro Cuenca <pedro@huggingface.co> * Update src/diffusers/utils/import_utils.py * Update src/diffusers/__init__.py Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> * Update src/diffusers/pipelines/stable_diffusion/__init__.py * fix double import Co-authored-by: Pedro Cuenca <pedro@huggingface.co> Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
Applies the fix from huggingface/transformers#16578 to allow PyCharm and VSCode users to jump to the real class definition instead of the
Dummy
one (which is picked up by the type checker if not wrapped in an extratry-except
).PyCharm needed an index rebuild to see the changes, closing and reopening the IDE should do the trick.
Fixes #1479