【发布时间】:2020-06-21 16:13:43
【问题描述】:
我目前在 VSCode 中使用默认的 python linter。然而,linter(Format Document)不断改变模块的导入顺序,如下所示。由于模块(project_settings.py)在当前脚本(preprocess.py)的父目录下,所以我相信我必须在导入之前添加系统路径(在this_01之后)。
我没有遵循正确的PEP8 规则吗? (关注this_02)如何在 linter 不更改导入顺序的情况下将模块导入不同的目录?我需要为 linter 设置某种忽略规则吗?
内部preprocess.py
(在格式化程序之前)
import sys
sys.path.insert(0, './scripts/')
from project_settings import *
(格式化后)
from project_settings import *
import sys
sys.path.insert(0, './scripts/')
项目结构
root
└── scripts
├── data-preparation
│ └── **preprocess.py**
├── ...
├── main.py
├── project_settings.py
└── utils.py
附言我仍然想使用 Python linter,但想正确使用它,以便 linter 不会改变导入顺序
【问题讨论】:
标签: visual-studio-code vscode-settings pep8 linter