immutables
immutables copied to clipboard
Add PEP 585 (__class_getitem__ -> GenericAlias) support
This commit add supports for PEP 585 on Python 3.9+.
This is useful for runtime introspection ( resolves #83 ).
For example, on Python 3.9+:
>>> immutables.Map[str, int]
immutables._map.Map[int, str]
On Python 3.8-:
>>> immutables.Map[str, int]
<class 'immutables.map.Map'>
This does not affect type checkers, as they do not utilize runtime introspection.
This is immediately useful for applications that would like to use type information for (de)serialization. Examples:
- https://github.com/python-attrs/cattrs
- https://github.com/konradhalas/dacite
Thank you for your work on this library (and PEP, to boot!).