fix(modeling_attn_mask_utils): remove FutureWarning from logger.warning_once()#44307
Merged
vasqu merged 2 commits intohuggingface:mainfrom Feb 26, 2026
Merged
Conversation
|
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. |
vasqu
reviewed
Feb 26, 2026
|
|
||
| def __init__(self, is_causal: bool, sliding_window: int | None = None): | ||
| logger.warning_once(DEPRECATION_MESSAGE, FutureWarning) | ||
| logger.warning_once(DEPRECATION_MESSAGE) |
Contributor
There was a problem hiding this comment.
Oops, that's on me #42848 😬
Let's use warnings.warn instead, would like to keep the future warning type in this case - we can safely remove the logger in this file then iirc.
This was referenced Feb 27, 2026
zvik
pushed a commit
to zvik/transformers
that referenced
this pull request
Mar 1, 2026
…ng_once() (huggingface#44307) * fix(modeling_attn_mask_utils): remove FutureWarning from logger.warning_once() * refactor(modeling_attn_mask_utils): use warnings instead of logger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR fixes a
TypeError: not all arguments converted during string formattingcaused by incorrectly passingFutureWarningas a second argument tologger.warning_once()in this file, introduced in #42848. Because Python's logging module expects string formatting arguments (like%s) rather than warning categories, passingFutureWarningwithout a placeholder triggered a crash when the warning evaluated.I prioritized the use of-> This was later changed to preferlogger.warning_once()instead ofwarnings.warn(msg, FutureWarning)to align with the logging patterns in similar transformersmodeling_utils files.warningsfor sake of preserving theFutureWarning: #44307 (comment)I didn't test this locally, but here's a small snippet for reproduction:
Here's an example of this happening in downstream libraries: https://github.com/huggingface/lerobot/actions/runs/22455225460/job/65035766998
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?