【发布时间】:2022-06-11 08:54:20
【问题描述】:
包 1
我创建了一个包 my_utils 并使用 mypy 实用程序 stubgen 生成了 stud 文件
stubgen -p my_utils
# >>> Processed 2 modules
# >>> Generated files under out/my_utils/
将存根移至包根目录
mv out/my_utils/* my_utils
mypy 很高兴
mypy my_utils
# >>> # Success: no issues found in 2 source files
包 2
包 2 有 my_utils 作为依赖项,所以我使用诗歌安装了我的 my_utils
poetry add git+ssh://git@github.com/username/my-utils.git
我的虚拟环境库具有以下包结构:
my_utils
├── __init__.py
├── __init__.pyi
├── os.py
├── os.pyi
└── py.typed
但当我检查我的包裹 2 时 mypy 仍然会抱怨
mypy r26/bwf_converter.py
# r26/bwf_converter.py:12: error: Cannot find implementation or library stub for module named "my_utils.os"
__init__.pyi 为空,os.pyi 有以下内容:
import csv
import json
from typing import Dict, List, Literal, Union
OutputProc = Literal["wait", "raw", "json", "csv", ""]
StdType = Literal["stderr", "stdout"]
JsonContent = Dict[str, str]
CsvContent = List[Dict[str, str]]
class PopenWrapper:
cmd: Union[str, List[str]]
ouput_proc: Literal["wait", "raw", "json", "csv", ""]
log_output: bool
kwargs: Dict[str, str]
def __init__(self, cmd: Union[str, List[str]], ouput_proc: OutputProc = ..., log_output: bool = ..., **kwargs: Dict[str, str]) -> None: ...
def run(self) -> Union[bool, str, CsvContent, JsonContent]: ...
如果有人能提示我我做错了什么......
【问题讨论】: