Skip to content

Is pyright too picky about empty containers? #8815

Answered by erictraut
dimaqq asked this question in Q&A
Discussion options

You must be logged in to vote

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:

  1. When calling the set constructor, provide explicit specialization such as set[int]().
  2. Provide a type annotation for the variable you are assigning the lambda to. Pyright will then use bidirectional t…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dimaqq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants