single-cell-data / SOMA

A flexible and extensible API for annotated 2D matrix data stored in multiple underlying formats.
MIT License
69 stars 9 forks source link

[python] Don't use `TypeVar` when defining coordinate types #150

Closed thetorpedodog closed 1 year ago

thetorpedodog commented 1 year ago

My previous change which used TypeVar for coordinate types 1 was actually a Bad Idea. While it was better in that it prohibited heterogeneous collections and slices, it was worse in that made the SparseDFCoord type (and derived types) into generic types, which we do not want.

The right way to avoid repeating all the possible types is to make a union of the possible containers, and then specify that with all the possible contents that may go into those containers.