Open wbrenton opened 1 year ago
Thanks for your interest in chex!
This suggestion is very interesting. Many of us working with arrays in python on a daily basis are eagerly awaiting PEP 646, which was accepted into python version 3.11.
Once python 3.11 becomes more mainstream we will definitely consider incorporating shape annotations into chex. And perhaps we could augment or fork chex.Dimensions to return TypeVarTuples, along the lines of your suggestion.
For the time being, however, we will not implement such a change. In particular, mixing runtime checks with static type annotation is out of scope, at least for now.
P.S. If you're interested in doing type annotation at runtime, you might find the pydantic project useful: https://docs.pydantic.dev/
I would like to propose an API enhancement that allow the use of chex.Dimensions inside function annotations. If there is interest I'd like to contribute. Example below:
This is particularly useful for dataclasses e.g.
Pros:
Cons: