MagicStack / immutables

A high-performance immutable mapping type for Python.
Other
1.14k stars 57 forks source link

Map type arguments aren't introspectible in runtime #83

Closed Tinche closed 1 year ago

Tinche commented 2 years ago

Currently I don't see a way of getting the key and value types from a map type. Ideally, the Map.__class_getitem__ should return an object with __origin__ set to Map and __args__ set to a tuple of the key and value types, so that typing.get_origin() and typing.get_args() work with it.

Without this information, libraries like cattrs have no way of correctly serializing and deserializing Map instances.