-
Consider the defined type variables, K = TypeVar('K')
V = TypeVar('V') and a custom generic dictionary, class MyGenericDict(collections.UserDict[K, V]):
... I am trying to define, class MyGenericDict(collections.UserDict[K, V]):
@multimethod.multimethod
def __mul__(self, other: MyGenericDict[K, Any]):
return self.__class__({key: value * other[key] for key, value in self.items()})
@multimethod.multimethod
def __mul__(self, other: V):
return self.__class__({key: value * other for key, value in self.items()}) It seems that as long as Is this a limitation of the typing system in python, or that of the |
Beta Was this translation helpful? Give feedback.
Answered by
coady
Dec 16, 2023
Replies: 1 comment 3 replies
-
There are no constraints on |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
snwnde
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are no constraints on
TypeVar('V')
, so it matches anything.