µfmt: safe, atomic formatting and import sortingµfmt is a code formatter and import sorter for Python and Visual Studio Code, built on top of black and µsort, with experimental support for ruff-api:
µfmt formats files in-memory, first with µsort and then with black, before writing any changes back to disk. This enables a combined, atomic formatting steps in VS Code, without any chance of conflict or intermediate changes between the import sorter and the code formatter. Note:
UsageOnce installed, "µfmt" will be available as a formatter for Python files
(extension id:
or through the command pallete option "Format Document With...": Be sure to disable the legacy Python formatter, if enabled:
Format on SaveVS Code can automatically format your Python files when saving by adding the following to your settings:
Resources |