Adding black formatter to PyCharm | Scribe

    Adding black formatter to PyCharm

    • |
    • 0 step |
    • 3 minutes

      Adding an external tool

      Go to your Terminal and type [[pip install black]]
      Click on "PyCharm" in the menu bar and then "Settings"
      Click this unknown
      Click "Tools" and then "External Tools"
      Click +
      Click on the name field and name your new tool
      To add the path for the tool, click + next to the Program Field, then select "PyInterpreterDirectory" and add /black at the end
      To add the arguments for the tool, click + next to the Arguments, then select "FilePath"
      To add the working directory for the tool, click + next to the Working Directory, then select "ProjectFileDir"
      Click "OK"
      Click Apply
      You've successfully added a tool for formatting files with black
      Now you've added a tool, but it doesn't auto-apply on save. For that to happen, follow the rest of the guide.

      Running black automatically on file save

      While in the Settings window, click "File Watchers"
      Click +
      Select "<custom>"
      Name your File Watcher
      From File type dropdown, select "Python"
      Was this Scribe helpful?
      Save this document for future reference.
      click-target-circles-background
      This Scribe is in tip-top shape!Leave feedback if there are any issues with this Scribe