Hi. I would like to propose that a dictionary accepts a mapping to the or operation. Something like:
classdict(MutableMapping[_KT, _VT]):
...
@overloaddef__or__(self, __value: Mapping[_KT, _VT]) ->dict[_KT, _VT]: ...
@overloaddef__or__(self, __value: Mapping[_T1, _T2]) ->dict[_KT|_T1, _VT|_T2]: ...
It would be useful in scenarios like the following:
fromcollections.abcimportMappingfromtypingimportcasta=cast(Mapping[str, int], {"a": 1})
{"b": 2} |aAt this point, pyright complains with # error: Operator "|" not supported for types "dict[str, int]" and "Mapping[str, int]".
I referenced this problem in this issue. Thanks.
Hi. I would like to propose that a dictionary accepts a mapping to the or operation. Something like:
It would be useful in scenarios like the following:
At this point, pyright complains with
# error: Operator "|" not supported for types "dict[str, int]" and "Mapping[str, int]".I referenced this problem in this issue. Thanks.