Replies: 2 comments 9 replies
-
This looks like a bug in mypy. If you change the last line to |
Beta Was this translation helpful? Give feedback.
-
This error makes sense to me, since even though You can add some overloads to deal with this: @overload
def test_fun(
cache: MutableMapping[tuple[Hashable, ...], _T] = {},
hashfun: CacheableFunction[tuple[Hashable, ...]] = hashkey,
*args: Hashable
) -> _T: ...
@overload
def test_fun(
cache: MutableMapping[_KT, _T] ,
hashfun: CacheableFunction[_KT],
*args: Hashable
) -> _T: ...
def test_fun(
cache: MutableMapping[Any, _T] = {},
hashfun: CacheableFunction[Any] = hashkey,
*args: Hashable
) -> _T: As a side note, I don't think |
Beta Was this translation helpful? Give feedback.
-
While trying to create type stubs for
asyncache
, I came across this difference in behaviour betweenmypy
andpyright
.The following code is accepted in the pyright playground
However, mypy gives the error
Is this a bug? If so, of which type checker?
Beta Was this translation helpful? Give feedback.
All reactions