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 incorrect syntax in _deprecation.py warning message for _deprecate_list_output() #1485

Merged

Conversation

mcgrath-k
Copy link
Contributor

Micro edit!

I was cleaning up some code that leverages huggingface_hub, specifically I was using the method len(list_models(...)), which gave the deprecation warning:

FutureWarning: 'list_models' currently returns a list of objects but is planned to be a generator starting from version 0.14 in order to implement pagination. Please avoid to use `list_models(...).__len__` or explicitly convert the output to a list first with `list(iter(list_models)(...))`.
  warnings.warn(self._deprecation_msg.format(attr_name=attr_name), FutureWarning)

For some reason I read list(iter(list_models)(...)) way too literally, and thought that iter() worked similarly to a decorator or contained a nested function (that also took in ellipses as an arg).

I believe it is a typo, where the inside of this statement meant to express list_models(...) where the ellipses mean the optional function arguments to list_models. So just one misplaced parentheses haha.

Sorry for the silly nitpick, but perhaps it will save somebody the 20 minutes I spent looking at this! 😅

Please let me know if any modifications are needed, thanks!

Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

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

Yep thanks, clearly a typo here. I changed it to a list comprehension to be even more explicit

src/huggingface_hub/utils/_deprecation.py Outdated Show resolved Hide resolved
@Wauplin Wauplin merged commit cbd2a0e into huggingface:main May 30, 2023
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

@mcgrath-k mcgrath-k deleted the kmcgrath/_deprecation_warning_syntax_error branch May 31, 2023 21:03
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