Skip to content

Add missing dunder methods to SizeDict#44884

Merged
hmellor merged 1 commit intohuggingface:mainfrom
hmellor:add-dict-methods-to-sizedict
Mar 20, 2026
Merged

Add missing dunder methods to SizeDict#44884
hmellor merged 1 commit intohuggingface:mainfrom
hmellor:add-dict-methods-to-sizedict

Conversation

@hmellor
Copy link
Copy Markdown
Member

@hmellor hmellor commented Mar 20, 2026

Some libraries that use Transformers (i.e. vLLM) use | on the size config.

This PR adds __or__ and __ror__ so that the following works:

$ {"longest_edge": 20} | SizeDict(height=10, width=20)
{'longest_edge': 20, 'height': 10, 'width': 20}
$ SizeDict(height=10, width=20) | {"longest_edge": 20}
SizeDict(height=10, width=20, longest_edge=20, shortest_edge=None, max_height=None, max_width=None)
$ SizeDict(height=10, width=20) | SizeDict(longest_edge=20)
SizeDict(height=10, width=20, longest_edge=20, shortest_edge=None, max_height=None, max_width=None)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Comment thread src/transformers/image_utils.py
Copy link
Copy Markdown
Member

@zucchini-nlp zucchini-nlp left a comment

Choose a reason for hiding this comment

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

Looks reasonable, I think we want to keep treating SizeDict as normal dict. Approving to unblock vlllm

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

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.

@hmellor hmellor enabled auto-merge March 20, 2026 12:04
@hmellor hmellor added this pull request to the merge queue Mar 20, 2026
Merged via the queue into huggingface:main with commit 7cd9b98 Mar 20, 2026
28 checks passed
@hmellor hmellor deleted the add-dict-methods-to-sizedict branch March 20, 2026 12:21
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