According to the docs,

PyCharm adheres to PEP8 rules and requirements for arranging and formatting Python code.

From how I understand it, there is still some flexibility under pep8.

For example, the default formatter on Pycharm allows for use of single or double quotes on strings and does not require that to be consistent in the code.

Whereas, Black is very specific to expect double quotes on strings across all files unless configured otherwise.

I presume Pycharm's default IDE python formatter will make the minimum changes necessary to fulfill pep8 and the exact behavior is determined by the individual's coding preferences.

Answer from Rob on Stack Overflow
🌐
JetBrains
jetbrains.com › help › pycharm › reformat-and-rearrange-code.html
Reformat and rearrange code | PyCharm Documentation
In the Settings dialog (Ctrl+Alt+S) , go to Editor | Code Style. Switch to the Formatter tab and enable the Turn formatter on/off with markers in code comments option.
🌐
JetBrains
jetbrains.com › help › pycharm › reformat-file-dialog.html
Reformat File dialog | PyCharm Documentation
You can define rules and format your code as you write it. To define formatting rules for Python, open the Settings dialog (Ctrl+Alt+S) and navigate to Editor | Code Style | Python.
🌐
JetBrains
jetbrains.com › help › pycharm › prettier.html
Prettier | PyCharm Documentation
In the editor, select the code fragment to reformat. To reformat a file or a folder, select it in the Project tool window Alt+1. Then select Reformat with Prettier from the context menu.
🌐
JetBrains
jetbrains.com › help › pycharm › code-style-python.html
Code Style. Python | PyCharm Documentation
In this tab, customize the code style options, which PyCharm will apply on reformatting the source code. The left-hand pane contains the list of exceptions (Keep when reformatting), and placement and alignment options for the various code constructs (lists, statements, operations, annotations, and so on).
🌐
JetBrains
jetbrains.com › pycharm › guide › tips › reformat-code
Reformat Code - PyCharm Guide
February 17, 2023 - You can quickly reformat the whole file by invoking "Reformat Code" ⌘⌥L (macOS) / Ctrl+Alt+L (Windows/Linux).
🌐
Read the Docs
black.readthedocs.io › en › stable › integrations › editors.html
Editor integration - Black 26.3.0 documentation
Open plugin configuration in PyCharm/IntelliJ IDEA ... Check Start local blackd instance when plugin loads. Press the Detect button near Path input. The plugin should detect the blackd executable. In Trigger Settings section check Trigger on code reformat to enable code reformatting with Black.
Find elsewhere
🌐
JetBrains
jetbrains.com › help › pycharm › command-line-formatter.html
Format files from the command line | PyCharm Documentation
The command-line formatter launches an instance of PyCharm in the background and applies the formatting. It will not work if another instance of PyCharm is already running. In this case, you can perform code style formatting from the running instance.
🌐
YouTube
youtube.com › watch
How To Format Code In PyCharm? - Next LVL Programming - YouTube
How To Format Code In PyCharm? Are you looking to keep your Python code organized and maintain a consistent style in PyCharm? In this video, we’ll guide you ...
Published   February 26, 2025
🌐
YouTube
youtube.com › pycharm by jetbrains
How to reformat your code in PyCharm - YouTube
In this very short video you will learn how to tell PyCharm to clean up indentation and other code styles in your file. 00:00 - Start 00:13 - Look at 3 PEP s...
Published   May 29, 2020
Views   417
🌐
Medium
akshay-jain.medium.com › pycharm-black-with-formatting-on-auto-save-4797972cf5de
Pycharm + Black with Formatting on Auto-save | by Akshay Jain | Medium
June 11, 2021 - Pycharm + Black with Formatting on Auto-save So, lately, I’ve been working with Black for Python code formatting. Pretty cool huh! I’ve seen Black do wonders to my code. It made my (already …
🌐
Xebia
xebia.com › home › blog › partial python code formatting with black & pycharm
Partial Python Code Formatting With Black & PyCharm | Xebia
December 10, 2018 - This causes me to reformat the code, copy the changed lines I wanted to format, revert formatting, and replace my lines by the copied lines. This felt clumsy and so I went to investigate. First, we need to install Black and configure it in PyCharm. It's available via both Pip and Conda, and runs on Python 3.6 and higher, although it can format older Python code too.
🌐
Reddit
reddit.com › r/pycharm › how to use linters and code formatter in pycharm ide with pyproject.toml configuration file
r/pycharm on Reddit: How to use linters and code formatter in PyCharm IDE with pyproject.toml configuration file
July 22, 2023 -

I have created a project using cookiecutter-django. In the root of the project, there is a file named pyproject.toml, it has some configs, among these configs there are linters and black (a code formatter) configs.

However, I am unsure how to configure these linters and code formatter in PyCharm using the pyproject.toml file. I'm not sure if I have to create a separate configuration file for each of these tools or if they can work together within the same file.

I'm wondering if there is a way to set up the Pycharm IDE to use these configs so that every time I save a file I get my code linted and formatted.

Could someone share their knowledge or experience in using these tools in PyCharm?

Thank you in advance for any help you can provide!

🌐
YouTube
youtube.com › watch
How To Format Python Code In PyCharm? - Next LVL Programming - YouTube
How To Format Python Code In PyCharm? Are you looking to improve the appearance and readability of your Python code in PyCharm? In this informative video, we...
Published   March 21, 2025
🌐
JetBrains
jetbrains.com › help › pycharm › settings-code-style.html
Code Style | PyCharm Documentation
PyCharm displays the indentation information in the status bar of the editor. You can click the indentation information to see the available actions, such as enable or disable this option, and change the current indentation to the ones specified in the Code Style settings for the specific language.
🌐
JetBrains
jetbrains.com › help › pycharm › configuring-code-style.html
Configuring code style | PyCharm Documentation
In the Project view, right-click a source directory containing the files whose code style you want to define and choose New | EditorConfig from the context menu. Select the properties that you want to define so that PyCharm creates stubs for ...
🌐
JetBrains
jetbrains.com › help › pycharm › formatting.html
Formatting | PyCharm Documentation
Use this page to configure common formatting options, regardless of the type of a particular file.
🌐
Medium
johschmidt42.medium.com › automate-linting-formatting-in-pycharm-with-your-favourite-tools-de03e856ee17
Automate linting & formatting in PyCharm with your favourite tools | by Johannes Schmidt | Medium
June 19, 2023 - Automate linting & formatting in PyCharm with your favourite tools Run black, flake8 & other tools automatically with every file change If you’ve ever worked in a team, you know that to achieve …