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
Calling typing.get_type_hints on a class that inherits from ModelHubMixin results in a NameError when trying to resolve its type. This happens because "DataclassInstance" (used in ModelHubMixin annotations) isn't available in the scope at the time.
I'll look into fixing this and submit a PR.
Reproduction
import typing
from huggingface_hub import ModelHubMixin
Traceback (most recent call last):
File "/Users/simon/projects/draccus/demo2.py", line 7, in<module>
typing.get_type_hints(my_model)
File "/opt/homebrew/Caskroom/miniconda/base/envs/hub_310/lib/python3.10/typing.py", line 1871, in get_type_hints
value = _eval_type(value, globalns, localns)
File "/opt/homebrew/Caskroom/miniconda/base/envs/hub_310/lib/python3.10/typing.py", line 329, in _eval_type
ev_args = tuple(_eval_type(a, globalns, localns, recursive_guard) forain t.__args__)
File "/opt/homebrew/Caskroom/miniconda/base/envs/hub_310/lib/python3.10/typing.py", line 329, in<genexpr>
ev_args = tuple(_eval_type(a, globalns, localns, recursive_guard) forain t.__args__)
File "/opt/homebrew/Caskroom/miniconda/base/envs/hub_310/lib/python3.10/typing.py", line 327, in _eval_type
return t._evaluate(globalns, localns, recursive_guard)
File "/opt/homebrew/Caskroom/miniconda/base/envs/hub_310/lib/python3.10/typing.py", line 694, in _evaluate
eval(self.__forward_code__, globalns, localns),
File "<string>", line 1, in<module>
NameError: name 'DataclassInstance' is not defined
System info
huggingface_hub Version: 0.27.0
Platform: macOS-15.2-arm64-arm-64bit
Python Version: 3.10.16
Running in iPython?: No
Running in Notebook?: No
Running in Google Colab?: No
Running in Google Colab Enterprise?: No
Token Path: /Users/simon/.cache/huggingface/token
Has Saved Token?: Yes
User: aliberts
Configured Git Credential Helpers: cache, osxkeychain
FastAI: Not Available
TensorFlow: Not Available
Torch: Not Available
Jinja2: Not Available
Graphviz: Not Available
Keras: Not Available
Pydot: Not Available
Pillow: Not Available
hf_transfer: Not Available
Gradio: Not Available
Tensorboard: Not Available
NumPy: Not Available
Pydantic: Not Available
aiohttp: Not Available
Endpoint: https://huggingface.co
HF Hub Cache: /Users/simon/.cache/huggingface/hub
HF Assets Cache: /Users/simon/.cache/huggingface/assets
HF Token Path: /Users/simon/.cache/huggingface/token
HF Stored Tokens Path: /Users/simon/.cache/huggingface/stored_tokens
HF Hub Offline: False
HF Hub Disable Telemetry: False
HF Hub Disable Progress Bars: None
HF Hub Disable Symlinks Warning: False
HF Hub Disable Experimental Warning: False
HF Hub Disable Implicit Token: False
HF Hub Enable HF Transfer: False
HF Hub ETag Timeout: 10
HF Hub Download Timeout: 10
The text was updated successfully, but these errors were encountered:
Describe the bug
Calling
typing.get_type_hints
on a class that inherits fromModelHubMixin
results in aNameError
when trying to resolve its type. This happens because "DataclassInstance" (used inModelHubMixin
annotations) isn't available in the scope at the time.I'll look into fixing this and submit a PR.
Reproduction
import typing
from huggingface_hub import ModelHubMixin
class MyModel(ModelHubMixin): ...
my_model = MyModel()
typing.get_type_hints(type(my_model))
Logs
System info
The text was updated successfully, but these errors were encountered: