python - 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.typed
到procrustes
目录。没有不同。
解决方案
推荐阅读
- java - Selenium WebDriver 方法与 JavaScript 执行器
- javascript - 如何检测 div 是否可见并包含输入字段
- google-bigquery - 我可以在 Google BigQuery 中对 3 个不同的表进行完全外部联接吗
- angular - Angular 7 的简单模态服务未打开:找不到组件工厂
- angular - Angular Component - 奇怪的渲染问题
- css - 图像在悬停时闪烁并且不调整大小
- r - 使用 Keras 和 R 为 CNN 重塑平面向量
- ios - 如何设置 iOS WkWebview 缩放比例
- reactjs - react-cache/suspense 中的不稳定_createResource 失效
- javascript - 如何避免 Angular2+ 中的重复服务