Skip to content

Loss of type-hinting benefits #64

@edan-bainglass

Description

@edan-bainglass

I have two methods in my Gradient class that I would like to overload as scalar_product:

def scalar_gradient_product(self, gradient: Gradient) -> Density:
    ...

and

def scalar_density_product(self, density: Density) -> ndarray:
    ...

I decorated both with multimethod as follows:

@multimethod
def scalar_product(self, gradient: Gradient) -> Density:
    ...

and

@multimethod
def scalar_product(self, density: Density) -> ndarray:
    ...

This works, i.e. calling scalar_product with Gradient or Density arguments yields the expected respective results. However, I seem to have lost my type-hinting benefits. My editor (VS code) now thinks scalar_product is a property with a return type of multimethod or MethodType.

image

Am I missing something? Is there some way of gaining the overloading functionality without losing type-hinting?

Thanks in advance 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions