Skip to content
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 tqdm #1629

Merged
merged 3 commits into from
Aug 29, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/huggingface_hub/utils/tqdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ def __init__(self, *args, **kwargs):
kwargs["disable"] = True
super().__init__(*args, **kwargs)

def __delattr__(self, attr):
"""fix for https://github.com/huggingface/huggingface_hub/issues/1603"""
try:
del self.__dict__[attr]
except KeyError:
if attr != "_lock":
raise AttributeError(attr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to use the "real" underlying __delattr__ and raise the default exception generated by it instead of creating a new AttributeError(attr) that is less verbose.

Suggested change
def __delattr__(self, attr):
"""fix for https://github.com/huggingface/huggingface_hub/issues/1603"""
try:
del self.__dict__[attr]
except KeyError:
if attr != "_lock":
raise AttributeError(attr)
def __delattr__(self, attr: str) -> None:
"""Fix for https://github.com/huggingface/huggingface_hub/issues/1603"""
try:
super().__delattr__(attr)
except AttributeError:
if attr != "_lock":
raise



@contextmanager
def tqdm_stream_file(path: Union[Path, str]) -> Iterator[io.BufferedReader]:
Expand Down