Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import @overload to fix linting error #18

Open
ed-p-may opened this issue Jan 26, 2024 · 0 comments
Open

import @overload to fix linting error #18

ed-p-may opened this issue Jan 26, 2024 · 0 comments

Comments

@ed-p-may
Copy link

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"

Screenshot 2024-01-26 at 4 12 44 PM

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?
Screenshot 2024-01-26 at 4 13 56 PM

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:

Screenshot 2024-01-26 at 4 15 31 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant