Adding black formatter to PyCharm | Scribe

    Adding black formatter to PyCharm

      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"
      Documents you might like
      0 Selected
      This Scribe is in tip-top shape!Leave feedback if there are any issues with this Scribe