GotYa
GotYa

Reputation: 121

Editing PyCharm's Pep8

As most people using PyCharm know, PyCharm has a built-in PEP8 'rule book' that (if you enable it) checks your code, sees if it has any inconsistenties according to those 'rules'. But I noticed something strange, if I go on the python.org website and check the PEP8 rules they have in place, they don't seem to correlate with the PEP8 rules that exist in my version of PyCharm. The college I go to requires me to adhere to PEP8 (in the future) and it would be a great help if I could use the PEP8 rules on the python.org website, but I don't know how.

(MAIN POINT) Is there any way I could edit the PEP8 rules that you see in PyCharm? I'm not talking about ignoring specific things, that's what I've seen in every other post about this topic. I mean really changing it, editing the file it's in, whatever you'd have to do. An example of one of these inconsistencies would be PyCharm's 120 characters per line rule and the actual PEP8 saying it should be 79 characters per line. I'd have to change that in PyCharm's PEP8 rules, I just really don't know how. Is there anyone who knows how to do this? Or maybe even someone who can explain why the PEP8 rules are different in PyCharm?

Extra info: I am currently using PyCharm Community edition 2017.2.3 but will be upgrading to the Professional version very soon. Link to the official PEP8 page: https://www.python.org/dev/peps/pep-0008/#maximum-line-length

Upvotes: 3

Views: 4908

Answers (2)

smsearcy
smsearcy

Reputation: 573

You can change line length in PyCharm's settings to match PEP8's line length. It's under Editor > Code Style (either per project or in the Default Settings). In my experience most of the other rules are very close to PEP8.

Note: In newer versions of PyCharm the settings has been renamed to Hard wrap at but it behaves the same and there is an additional option allows for more visual guides.

PyCharm Editor Settings

Upvotes: 1

thebjorn
thebjorn

Reputation: 27311

There is no direct way to get pep8 conformance from PyCharm (although you can, of course, set all the individual options).

You could create an external tool (which can be connected to a shortcut key to make it convenient).

Here is my definition (the pep8 tool has been renamed to pycodestyle):

pep8 as external tool

Upvotes: 2

Related Questions