Wrong class type reference in docstring type hint

Viewed 44

Filesystem tree of my project:

  • first_package

    • __init__.py
    • first.py
  • second_package

    • __init__.py
    • second.py
  • main.py

first.py contains:

class Product:
    pass

second.py contains:

class Product:
    pass

In the main file, I want to create a function and point the type hint to both Product classes from different modules:

from first_package.first import Product
from second_package.second import Product as SecondProduct


def test(a: Product, b: SecondProduct):
    pass

The function documentation (ctrl+q) generates links to Product classes, however they both lead to the first module when clicked.

main 
def test(a: Product,
         b: Product) -> None

*here I clicked on the type link of the argument b*

first_package.first 
class Product

I also tried import from second_package import second, specifying second.Product for argument b, but that didn't change anything.

Can you tell me how to avoid this?

0 Answers
Related