I really like when the VS Code sorts Python imports on file save, it’s a perfect addition to the Black code formatter.

To enable this option, you need the isort utility.
pipenv install isort --devNow let’s enable it. Open the settings (⇧⌘P or Ctrl+Shift+P), find Preferences: Configure Language Specific Settings... and then find the Python. It will open the settings.json file. The configuration is very simple.
"[python]": { "editor.codeActionsOnSave": { "source.organizeImports": true }}That’s all. Whenever you save the *.py file, the VS Code will run isort automatically to sort the imports.
VS Code documentation: https://code.visualstudio.com/docs/python/editing#_sort-imports