Skip to content

WeightsEnum.get_state_dict: fix return type - #9286

Merged
NicolasHug merged 3 commits into
pytorch:mainfrom
adamjstewart:types/weightsenum
Jan 5, 2026
Merged

NicolasHug merged 3 commits into
pytorch:mainfrom
adamjstewart:types/weightsenum

Conversation

@adamjstewart

Copy link
Copy Markdown
Contributor

https://docs.pytorch.org/docs/stable/hub.html#torch.hub.load_state_dict_from_url returns dict[str, Any], which is more specific than Mapping[str, Any].

@pytorch-bot

pytorch-bot Bot commented Nov 29, 2025

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9286

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the cla signed label Nov 29, 2025
@NicolasHug

NicolasHug commented Dec 1, 2025

Copy link
Copy Markdown
Member

Thanks for the PR, CI has been disabled so I can't validate the changes for now - feel free to ping again in a few days.

Out of curiosity though, what's the actual value of changing the type from Mapping to dict? It's more specific, but why is it better? This is a genuine question, I'm not trying to be snarky.

@adamjstewart

Copy link
Copy Markdown
Contributor Author

Mapping supports __getitem__, but does not support __setitem__ (docs). In our case (TorchGeo), we want to be able to later insert more values into this dictionary. The type checker is currently complaining that this isn't allowed.

@adamjstewart

Copy link
Copy Markdown
Contributor Author

@NicolasHug anything else needed to merge this PR?

@NicolasHug
NicolasHug merged commit 3e61e22 into pytorch:main Jan 5, 2026
3 checks passed
@github-actions

github-actions Bot commented Jan 5, 2026

Copy link
Copy Markdown

Hey @NicolasHug!

You merged this PR, but no labels were added.
The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py

@adamjstewart
adamjstewart deleted the types/weightsenum branch January 5, 2026 18:00
@adamjstewart

Copy link
Copy Markdown
Contributor Author

Looks like this didn't make it into 0.25.0. Will it automatically be added to the next release?

@NicolasHug

Copy link
Copy Markdown
Member

Yes, it'll be part of the next one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants