Can Black be configured to ignore imports?
In this question, they added
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
in setting.json to control whether using black to format imports or not. But I like to use shortcut in vscode (opt+shift+f) to format my code, because I need to select if implementing black in my code and I must need to save files at the same time. It seems this json doesn't work for shortcuts in vscode.
I added the
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": false
in my setting.json.
But when I use shortcut to format imports, it still doesn't work.
I want to use black for code and isort for imports with shortcuts to choose if implementing them.
You could try to set
isortas your preferred import sorter by add the following codes to yoursettings.json: