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 OverflowVideos
I am having trouble with formatting a dir of python code with a certain standard style. Are there any good tools and/or plugins in PyCharm that work?
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!
That action is called Reformat code. You can find it in Code menu, somewhere in the middle, or use the hotkey CTRL + Shift + L
The latest version of PyCharm uses CTRL + SHIFT + ALT + L in both Linux and Windows. Then from the reformat dialog box, choose what reformatting option you want to perform.