Skip to content

chore(typing): relax from_dict to use Mapping#2022

Merged
dangotbanned merged 2 commits intomainfrom
relax-from-dict-dict
Feb 16, 2025
Merged

chore(typing): relax from_dict to use Mapping#2022
dangotbanned merged 2 commits intomainfrom
relax-from-dict-dict

Conversation

@dangotbanned
Copy link
Copy Markdown
Member

@dangotbanned dangotbanned commented Feb 16, 2025

What type of PR is this? (check all applicable)

  • 💾 Refactor
  • ✨ Feature
  • 🐛 Bug Fix
  • 🔧 Optimization
  • 📝 Documentation
  • ✅ Test
  • 🐳 Other

Related issues

  • Related issue #<issue number>
  • Closes #<issue number>

Checklist

  • Code follows style guide (ruff)
  • Tests added
  • Documented the changes

If you have comments or can explain your changes, please do so below

Current dict[str, Any] will reject Mapping[str, Sequence[Any]].
I noticed this in altair, where I needed to cast to dict[str, Any]:

For reference, polars.from_dict uses Mapping but with some constraints on the value type

@dangotbanned dangotbanned marked this pull request as ready for review February 16, 2025 11:17
dangotbanned added a commit that referenced this pull request Feb 16, 2025
- Similar to #2022
- There's more variation between backends here, so `pandas` and `pyarrow` still convert `Sequence` -> `list` to be safe
Copy link
Copy Markdown
Collaborator

@EdAbati EdAbati left a comment

Choose a reason for hiding this comment

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

Thank you! :) This makes sense since it's more similar to polars

@dangotbanned
Copy link
Copy Markdown
Member Author

Thanks @EdAbati

@dangotbanned dangotbanned merged commit 92a3faf into main Feb 16, 2025
28 of 29 checks passed
@dangotbanned dangotbanned deleted the relax-from-dict-dict branch February 16, 2025 13:29
dangotbanned added a commit to dangotbanned/altair that referenced this pull request Sep 11, 2025
dangotbanned added a commit to vega/altair that referenced this pull request Mar 4, 2026
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