-
q = {'bool': {'must': []}}
q['query_parsed'] = False $ pyright x.py |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Pyright is working as designed here, so I don't consider this a bug. The inferred type of the expression assigned to For details about pyright's default inference behaviors for dict expressions, refer to this documentation. You can override the default inference behaviors by providing a type declaration for from typing import Any
q: dict[str, Any] = {"bool": {"must": []}}
q["query_parsed"] = False |
Beta Was this translation helpful? Give feedback.
Pyright is working as designed here, so I don't consider this a bug.
The inferred type of the expression assigned to
q
isdict[str, dict[str, list[Any]]]
. The second line attempts to set a value in this dict object that violates its type, hence the type error.For details about pyright's default inference behaviors for dict expressions, refer to this documentation.
You can override the default inference behaviors by providing a type declaration for
q
in this case.