【发布时间】:2021-09-14 10:25:21
【问题描述】:
我最近偶然发现 IntelliJ PyCharm PE 开始自动优化我的导入的问题,但我从未启用/安装过这样的功能,但我确实有 isort 已安装,但我不记得它有自动优化选项。有谁知道如何解决这个问题?
示例: 我在看代码:
from here import this
from here2 import this2
from here1 import this1
当我通过 (Alt+0) PyCharm 的提交接口进行提交阶段时,它会将这些导入自动格式化为:
from here import this
from here1 import this1
from here2 import this2
【问题讨论】:
-
我并不是真的在寻找样式指南,而是出于某种原因 isort 自动格式化我的导入,有时它甚至会格式化我没有触摸或打开的文件。
-
我认为这是第一个选项"Sort imported names in "from" imports"你在IDE中启用了optimize imports吗?