首页 > 解决方案 > mypy:找到模块但没有类型提示或库存根(不是第 3 方库)

问题描述

我有一个项目,在模块中输入提示。

├── src
│   ├── damastes
│   │   ├── __init__.py
│   │   ├── main.py
│   ├── __init__.py
│   ├── procrustes
│   │   ├── __init__.py
│   │   └── run.py
└── tests
    ├── __init__.py
    └── test_procrustes.py

src/procrustes/__init__.py

from .run import *

src/damastes/main.py

from src.procrustes import run

可以,从mypy的角度来看。更合适的导入

from procrustes import run  # type: ignore

需要忽略。

与以下相同tests/test_procrustes.py

要么

from procrustes import *  # type: ignore

或者

from src.procrustes import *

为什么 mypy 在没有合格导入的情况下看不到类型提示?如果找到该模块,是什么阻止了 mypy 对其进行分析?

error: Skipping analyzing 'procrustes': found module but no type hints or library stubs

我尝试添加py.typedprocrustes目录。没有不同。

标签: pythontype-hintingmypy

解决方案


推荐阅读