Question
How can I configure Black to run automatically on save in PyCharm 2026.2?
Answer
Starting from PyCharm 2026.2, the integration for Black has changed and its settings have been moved to a combined "External Tools" page, with on-save formatting being disabled by default. To re-enable on-save formatting for Black, follow these steps:
-
Remove any File Watcher currently set for Black:
- Go to PyCharm | Settings | Tools | File Watchers and delete any File Watcher set for Black.
- File Watchers run on every autosave, which can cause frequent and unwanted formatting actions such as Black executing while typing.
-
Enable Black in the Python tools settings:
- Navigate to PyCharm | Settings | Python | Tools | External Tools.
- Turn Black on. PyCharm runs Black itself and passes the file to it, so you do not need to add any arguments.
- Do not add Black under PyCharm | Settings | Tools | External Tools. That is a different page with the same name. A tool added there runs only from the Tools menu, and it does not run on save.
-
Configure on-save actions to include Black:
- Go to PyCharm | Settings | Tools | Actions on Save.
- Enable the checkbox for Reformat code (this option triggers Black on save).
-
Adjust autosave behavior if needed:
- In the Actions on Save section, use the "Activated On" selector next to "Reformat code" to control which save events trigger this action.
Once these steps are completed, Black should properly execute on save, replicating the behavior from earlier versions of PyCharm.
Black reports "One of 'SRC' or 'code' is required"
Black prints this error when it starts without a file to format. The built-in Black integration from step 2 always passes the file, so this error comes from somewhere else. Usually it is a Black entry under PyCharm | Settings | Tools | External Tools, or a Black File Watcher, with an empty Arguments field.
- Delete that entry or File Watcher.
- Follow steps 2 and 3 above.
If you do not see the "Reformat code" option or encounter further issues, please double-check that Black is still enabled under PyCharm | Settings | Python | Tools | External Tools. Additionally, you can send your exact PyCharm 2026.2 build information (available in the About dialog) to JetBrains support for further assistance.
Comments
0 comments
Please sign in to leave a comment.