Stuart Yellow
Stuart Yellow

Reputation: 89

How do i correctly type hint in my own python package

Im currently creating my first own package in python using twine. In my test folder the autocompletion in pycharm works like a charm. See 1 2

But if uploaded to testpypl and downloaded to a new project its not working anymore 3 4

Currently my method looks like this:

async def championships(self, game: Game, type: MatchType = MatchType.ALL, offset: int = 0,
                        limit: int = 10) -> Collection[Championship]:

Do I need to add some special docstrings for this to work? I saw other packages with this kind of docstrings:

"""
:param summoner_id: summoner ID
:return: list of masteries for the given summoner
:type summoner_id: str
:rtype: List[:class:`~types.ChampionMasteryDto`]
"""

But its not working for me.

Upvotes: 2

Views: 106

Answers (1)

Stuart Yellow
Stuart Yellow

Reputation: 89

Thanks to @chepner and @Mikko i knew it had nothing to do with the doc string. So i checked all the other things and just realized i did the import wrong. I changed it and now it works:

from src.package_name.types import *
from .types import *

Upvotes: 1

Related Questions