VS Code и Python, isort не выполняет свою работу
Я установил black
а также isort
для форматирования кода в VS Code. Черный работает покаisort
кажется, нет.
Если я убегу isort
из командной строки проблем нет.
Я пробовал изменить setting.json
но безрезультатно. Это последняя версия:
{
"window.zoomLevel": 0,
/** "editor.codeActionsOnSave": null */
/** Enable format on save */
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
/** Pyformat use it's own code action to prevent confliction with other tools. */
"source.organizeImports.pyformat": true,
"source.organizeImports.python": true
},
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"python.languageServer": "Pylance",
/** "python.sortImports.path": "isort", */
"python.sortImports.args": [
"-m 3",
"-tc",
"-w 88"
],
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"--line-length=88"
],
...
Какие-либо предложения?
1 ответ
Решение
VS Code поддерживает одновременное использование только одного модуля форматирования. Однако в этом ответе есть обходной путь:
const firstFormatter = commands.executeCommand('editor.action.formatDocument');
firstFormatter.then(() => myFormat());
Я лично настроил его на использование черного цвета, а затем прикрепил команду для запуска второго.