hauntsaninja / useful_types

Useful types for Python
MIT License
99 stars 5 forks source link

Mapping type covariant in key #27

Open iutlu opened 4 months ago

iutlu commented 4 months ago

Is a possible implementation of a Mapping-like type that is covariant in the key as discussed here being considered?

Specifically, a mapping type whose __getitem__ has a key typed object.

The linked thread was referring to this package, so I'd thought I'd ask here. Thanks!

iutlu commented 1 week ago

Sorry, returning to this after some reading; I think I must have gotten my thoughts crossed between the very early discussions (https://github.com/python/typing/issues/445) about making Mapping itself covariant in its key (for which there's nothing to be done), and the later discussions about offering Mapping supertypes that do not define __getitem__ / get, etc. I originally linked to, which could be relevant for this repo.

Apologies for the imprecise initial post!