pythonstubs
pythonstubs copied to clipboard
import @overload to fix linting error
Hi,
I am using Grasshopper-stubs in VSCode and I am running into a problem with some overloaded classes? It appears that the fix is to include an explicit overload
import in the stub .pyi file?
Scenario:
from Grasshopper.Kernel.Data import GH_Path
test_path = GH_Path(1)
give me the linting error:
Argument of type "Literal[1]" cannot be assigned to parameter "Other" of type "GH_Path" in function "init" "Literal[1]" is incompatible with "GH_Path"
It works fine at runtime of course, since an int
is an acceptable argument type for GH_Path
.
Proposed Fix
It appears that VSCode is not able to automatically resolve the @overload in the stub file for some reason, which is leading to this error?
However, if overload
is imported from typing: from typing import Tuple, Set, Iterable, List, overload
Then in that case, the linting seems to resolve properly: