【发布时间】:2022-01-16 03:03:01
【问题描述】:
我有两个 python 包。一个是 util 库,一个是将使用 util 库的应用程序(最终我会有更多应用程序共享该库。
我对两者都使用诗歌,并且应用程序使用 path 和 develop 属性将公共库指定为依赖项。
例如,我的布局如下所示:
- common/
- common/
- __init__.py
- py.typed
- pyproject.toml
- myapp/
- myapp/
- __init__.py
- py.typed
- pyproject.toml
myapp\pyproject.toml 看起来像这样:
[tool.poetry]
name = "myapp"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
[tool.poetry.dependencies]
python = "^3.9"
common = { path = "../common", develop = true }
[tool.poetry.dev-dependencies]
mypy = "^0.910"
flake8 = "^4.0.1"
black = {version = "^21.12b0", allow-prereleases = true}
pytest = "^6.2.5"
pytest-cov = "^3.0.0"
pytest-mock = "^3.6.1"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
当我在 myapp 上运行 mypy 时,我得到如下信息:
myapp/__init__.py:1:1: error: Cannot find implementation or library stub for module named "common" [import]
【问题讨论】:
标签: python-3.x mypy python-poetry