Skip to content

Convert dict-like args from compatible types - #3798

Merged
jl-wynen merged 1 commit into
mainfrom
flexible-dict-args
Dec 11, 2025
Merged

jl-wynen merged 1 commit into
mainfrom
flexible-dict-args

Conversation

@jl-wynen

Copy link
Copy Markdown
Member

Similarly to #3797 this allows more flexible dict-like arguments in some functions. I specifically ran into this when using da.assign_coords(other.coords) which should intuitively be allowed. But mypy complained because assign_coords required a dict. (There was no problem at runtime.)

Note that there are two changes in behaviour:

  • This PR makes the code more flexible and allows iterators over tuples as well as mappings. This should cover the types that one would typically pass to dict().
  • Passing the same argument via the dict like arg and kwargs now raises TypeError instead of ValueError. This matches the existing behaviour of bin, hist, etc. and more closely matches the typical error you get from bad function calls.

@jl-wynen
jl-wynen merged commit 0315424 into main Dec 11, 2025
4 checks passed
@jl-wynen
jl-wynen deleted the flexible-dict-args branch December 11, 2025 09:52
@jl-wynen jl-wynen mentioned this pull request Jan 5, 2026
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.

2 participants