我如何设置“组织进口”将每个导入到新线上
我希望每个导入在同一行上从同一软件包中导入,而要避免合并冲突。但是,当我按 shift + alt + o 时,它将所有导入都放在支架之间的相同行上。有没有办法自定义此快捷方式,以便将每个导入都放在单独的线上?
例如,
from typing import Dict, List, Tuple, Union
我不想拥有
from typing import Dict
from typing import List
等。
Instead of having imports from the same package on the same line I would like each import to be on a separate line to avoid merge conflicts. When I press Shift + Alt + O however, it puts all the imports on the same line between brackets. Is there a way to customise this shortcut so that it puts each import on a separate line?
e.g. instead of having
from typing import Dict, List, Tuple, Union
I would like to have
from typing import Dict
from typing import List
etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(2)
在幕后,组织python的导入使用
isort
。通过查看随之而来的是,您可以转到设置,搜索
python>排序导入:args
,并添加以下内容:
Behind the scenes, Organize Imports for python uses
isort
. By looking at isort's command line arguments, we see that you can achieve this functionality by adding the following arguments:With that said, you can go to your settings, search for
Python > Sort Imports: Args
, and add the following:Or you can manually add the entry in
settings.json
:isort -sl。
这应该足够了。isort --sl .
This should be enough.