英文:
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
但如果上传到testpypl并下载到新项目,它就不再起作用了 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.
但对我来说不起作用。
英文:
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.
答案1
得分: 1
感谢 @chepner 和 @Mikko,我知道这与文档字符串无关。所以我检查了所有其他的东西,才意识到我导入的方式不正确。我进行了更正,现在它可以工作:
from src.package_name.types import *
from .types import *
英文:
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 *
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论