Closed tlinhart closed 3 days ago
This is indeed strange - item
is of type dict[str, str|None]
, which should be a valid JsonValue
- str | None
is a JsonValue
and dict[str, JsonValue]
should also be a JsonValue
.
Please correct me if I'm missing something. If I'm not, this is a problem both in mypy and pyright.
This is what Pylance reports when hovering over the first of the two lines:
Argument typu dict[str, str | None] není možné přiřadit k parametru value typu JsonValue ve funkci __setitem__
Type "dict[str, str | None]" is not assignable to type "JsonValue"
"dict[str, str | None]" is not assignable to "List[JsonValue]"
"dict[str, str | None]" is not assignable to "Dict[str, JsonValue]"
Parametr typu „_VT@dict“ je invariantní, ale „str | None“ není stejný jako „JsonValue“.
Zvažte přepnutí z „diktování“ na „mapování“, které je v typu hodnoty kovariantní
"dict[str, str | None]" is not assignable to "str"
"dict[str, str | None]" is not assignable to "bool"
"dict[str, str | None]" is not assignable to "int"Pylance[reportArgumentType](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportArgumentType)
(variable) user_data: dict[str, JsonValue]
Yeah, I believe that line 4 is not correct. We should see if this has already been reported with pyright, pylance, mypy or pydantic.
Maybe this – https://github.com/pydantic/pydantic/issues/9445?
After the merge of this PR I receive type errors working with
user_data
. Consider this sample:Both in VS Code (with Pylance) and CLI (mypy) I get type errors on the highlighted spots. Mypy reports this: