如何禁用模块中导入类的自动linting?

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

在我的项目中,我正在导入一系列不同的其他模块/类,例如:

from my_project.filesystem import create_dir
from my_project.filesystem import file_size
from my_project.hashing import hash_from_file
from my_project.multiprocessing import max_workers_for
from my_project.multiprocessing import multiprocessing

保存文件时,Python extension会自动将这些行拖入:

from my_project.filesystem import create_dir, file_size
from my_project.hashing import hash_from_file
from my_project.multiprocessing import max_workers_for, multiprocessing

在设置中,我尝试禁用自动linting:

{
    "python.linting.lintOnSave": false,
    "python.linting.enabled": false,
    "python.linting.pylintArgs": [
        "--disable=all"
    ]
}

为清楚起见,我更喜欢将我的导入分开,但现在我面临着在修改任何更改之前“修复修复”的艰巨任务。

有没有办法禁用此功能(禁用整个扩展,这有效但删除了我希望继续使用的扩展的其他功能)?

python visual-studio-code
1个回答
0
投票

我认为您的进口按isort排序。您可以通过向其传递自定义参数来解决问题。提到here的“force_single_line”选项似乎就是你想要的。要将此配置选项传递给isort,请将以下行添加到vs代码配置中:

"python.sortImports.args": ["-sl"]

如果能解决这个问题,请告诉我。

© www.soinside.com 2019 - 2024. All rights reserved.