如何阻止python linter(VSCode)切换导入顺序

问题描述 投票:0回答:1

我目前在VSCode中使用默认的python linter。但是,短绒棉绒裤(格式文档)不断更改模块的导入顺序,如下所示。由于模块(project_settings.py)在当前脚本(preprocess.py)的父目录中,因此我相信我必须在导入之前添加系统路径(this_01之后)。

我是否没有遵循正确的PEP8规则? (紧随this_02之后)如何在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

ps.s。我仍然想使用Python linter,但想正确使用它,以使linter不会更改导入顺序

visual-studio-code vscode-settings pep8 linter
1个回答
0
投票
"[python]": { "editor.formatOnPaste": false }
© www.soinside.com 2019 - 2024. All rights reserved.