How to avoid this VSCode + Pylance static type check error?
def process_row(row: dict[str, Any]):
row = SimpleNamespace(**row)
For this, vscode shows red underline for SimpleNamespace(**row)
with messsage: Expression of type "SimpleNamespace" cannot be assigned to declared type "dict[str, Any]"
After more searching and going through
github
issues forpylance
andmypy
, it appears that this is legitimate open issue forpylance
.mypy
kind of fixed this. For above function, runningmypy typetest.py
gave 1 error:Name "row" already defined on line 5
but rnunning withmypy --allow-redefinition typetest.py
was all green.You can not yet turn of this in
pylance
it seems but let people know here if anyone point this out. Thanks.