我目前使用下面的脚本来构建我的包并将其发布到私有 Azure Artifacts 源。在每个脚本中,我都必须运行该行source $HOME/.poetry/env,否则它找不到诗歌命令。
有没有办法消除这种重复?
完整脚本:
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
strategy:
matrix:
Python38:
python.version: '3.8'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
displayName: 'Use Python $(python.version)'
- script: |
sudo apt-get install texlive texlive-latex-extra latexmk
python -m pip install --upgrade pip
python -m pip install keyring artifacts-keyring
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
source $HOME/.poetry/env
poetry install
displayName: 'Install package and tools'
- script: |
source $HOME/.poetry/env
poetry run python -m isort -rc
poetry run python …Run Code Online (Sandbox Code Playgroud) 我有一个具有以下(部分)目录结构的项目
.
??? mypy.ini
??? src
? ??? preppy
? ? ??? cli.py
? ? ??? __main__.py
? ? ??? model.py
? ? ??? tools.py
??? pyproject.toml
??? tests
Run Code Online (Sandbox Code Playgroud)
在 中cli.py,我有以下代码(文件中的第 13 和 14 行):
from .model import Problem
from .tools import get_abs_path, transcode
Run Code Online (Sandbox Code Playgroud)
我也有类似样式的相对导入,当工具在我的 IDE(代码 - OSS)中自动运行时model.py,__main__.py
所有类似的导入都会在pylint(2.5.3) 和mypy(0.761) 中抛出错误,例如:
Attempted relative import beyond top-level package pylint(relative-beyond-top-level) [13,1]
Cannot find implementation or library stub for module named '.model' mypy(error) [13,1] …Run Code Online (Sandbox Code Playgroud)