Skip to content

import @overload to fix linting error #18

@ed-p-may

Description

@ed-p-may

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions