Skip to content

fix tqdm_class argument of subclass of tqdm #3111

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

Conversation

andyxning
Copy link
Contributor

According to the doc of tqdm_class argument, tqdm_class should accept any class that are subclass of tqdm.

@andyxning
Copy link
Contributor Author

/cc @hanouticelina

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Contributor

@hanouticelina hanouticelina left a comment

Choose a reason for hiding this comment

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

thanks for aligning the type hint! indeed the parameter can be a type object that is either base_tqdm itself or a subclass of base_tqdm or None. So Optional[type[base_tqdm]] is more accurrate

@@ -44,7 +44,7 @@ def snapshot_download(
allow_patterns: Optional[Union[List[str], str]] = None,
ignore_patterns: Optional[Union[List[str], str]] = None,
max_workers: int = 8,
tqdm_class: Optional[base_tqdm] = None,
tqdm_class: Optional[type[base_tqdm]] = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
tqdm_class: Optional[type[base_tqdm]] = None,
tqdm_class: Optional[Type[base_tqdm]] = None,

and import Type from typing to make it work with python 3.8 (generic types was introduced in Python 3.9)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. CI should be green later.

@andyxning andyxning force-pushed the fix_tqdm_class_argument_of_subclass_of_tqdm branch from 353b3ea to 9b270dd Compare May 27, 2025 09:25
@andyxning andyxning requested a review from hanouticelina May 27, 2025 09:52
@andyxning andyxning force-pushed the fix_tqdm_class_argument_of_subclass_of_tqdm branch from 9b270dd to 43d7f0b Compare May 27, 2025 15:51
@hanouticelina
Copy link
Contributor

@bot /style

Copy link
Contributor

Style fixes have been applied. View the workflow run here.

@hanouticelina hanouticelina merged commit db9862c into huggingface:main May 28, 2025
@andyxning andyxning deleted the fix_tqdm_class_argument_of_subclass_of_tqdm branch June 2, 2025 07:56
@andyxning
Copy link
Contributor Author

@hanouticelina sorry for the interrupt, when can this PR be released in a new version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants