-
a = lambda: {42}
b = lambda: set() # E: Return type of lambda, "set[Unknown]", is partially unknown Same for literal empty dict I can work around that using What am I doing wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It looks like you have enabled the If you don't want pyright to report errors of this sort, I recommend not using strict mode. If you want to use strict mode, you will need to provide additional information to the type checker in cases like this. There are a couple of options here:
b: Callable[[], set[int]] = lambda: set() |
Beta Was this translation helpful? Give feedback.
It looks like you have enabled the
reportUnknownLambda
type checking rules, which is off be default. Or more likely you've enabled "strict" mode. In this case, pyright will report when a lambda expression is evaluated with a partially-unknown type.If you don't want pyright to report errors of this sort, I recommend not using strict mode.
If you want to use strict mode, you will need to provide additional information to the type checker in cases like this. There are a couple of options here:
set
constructor, provide explicit specialization such asset[int]()
.