Closed mdickinson closed 2 years ago
The Dict type stubs (from https://github.com/enthought/traits/blob/f17231ebb166294d2d6d544424d52820f1979bff/traits-stubs/traits-stubs/trait_types.pyi#L444-L459) look like this:
Dict
class _Dict(_TraitType[_DictType[_S, _T], _DictType[_S, _T]]): def __init__( self, key_trait: _Union[ _TraitType[_S, _T], _Type[_TraitType[_S, _T]]] = ..., value_trait: _Union[ _TraitType[_S, _T], _Type[_TraitType[_S, _T]]] = ..., value: dict = ..., items: bool = ..., **metadata: _Any ) -> None: ... class Dict(_Dict[_S, _T]): ...
That doesn't look right to me: from the _DictType[_S, _T] part (where _DictType is an alias for typing.Dict), the _S and _T metavariables should correspond to the key and value types, respectively. But then later we have:
_DictType[_S, _T]
_DictType
typing.Dict
_S
_T
key_trait: _Union[_TraitType[_S, _T], _Type[_TraitType[_S, _T]]] = ...,
So the definition of key_trait mentions the value type, and vice versa.
key_trait
Also, for the "accepted" type we should probably be using Mapping rather than _DictType.
Mapping
The
Dict
type stubs (from https://github.com/enthought/traits/blob/f17231ebb166294d2d6d544424d52820f1979bff/traits-stubs/traits-stubs/trait_types.pyi#L444-L459) look like this:That doesn't look right to me: from the
_DictType[_S, _T]
part (where_DictType
is an alias fortyping.Dict
), the_S
and_T
metavariables should correspond to the key and value types, respectively. But then later we have:So the definition of
key_trait
mentions the value type, and vice versa.Also, for the "accepted" type we should probably be using
Mapping
rather than_DictType
.