You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a class that inherits from ModelHubMixin, I don't have any auto-completion in VS Code (although I think it's probably not related to VS Code).
For instance, if I create a class class Dummy(ModelHubMixin) as below, then VS Code believes any instance of Dummy is of type ModelHubMixin, instead of Dummy.
After some quick investigation, I think it's because of the __new__ method in ModelHubMixin. I found an ugly way to fix that, by setting the return type of __new__ in the Dummy class as below.
fromhuggingface_hubimportModelHubMixinclassDummy(ModelHubMixin):
def__new__(cls, *args, **kwargs) ->"Dummy":
returnsuper().__new__(cls, *args, **kwargs)
defdummy_example(self, x: str) ->str:
returnxa=Dummy()
a.dummy_example("Hello, world!") # now, auto-completion works fine
What do you think? Is there a way to fix that without overwriting the __new__ method?
Maybe I'm missing something, but I spent quite some time to understand that the problem comes from ModelHubMixin, and I was very annoyed about not having auto-completion...
The text was updated successfully, but these errors were encountered:
Hello,
When creating a class that inherits from
ModelHubMixin
, I don't have any auto-completion in VS Code (although I think it's probably not related to VS Code).For instance, if I create a class
class Dummy(ModelHubMixin)
as below, then VS Code believes any instance ofDummy
is of typeModelHubMixin
, instead ofDummy
.After some quick investigation, I think it's because of the
__new__
method inModelHubMixin
. I found an ugly way to fix that, by setting the return type of__new__
in theDummy
class as below.What do you think? Is there a way to fix that without overwriting the
__new__
method?Maybe I'm missing something, but I spent quite some time to understand that the problem comes from
ModelHubMixin
, and I was very annoyed about not having auto-completion...The text was updated successfully, but these errors were encountered: