Configuring PEP8 (not ignoring rules, really changing it!!!)

已回答

(Before I say anything, correct me if I'm wrong here! Also, here is the PEP8 from the Python website: https://www.python.org/dev/peps/pep-0008/)

Alright, so here's the deal;
It seems that PEP8 in PyCharm is somewhat different from the PEP8 on the official python website. There are slight differences, a good example being line length. The PEP8 limit in PyCharm is 120 characters per line, while the Python website states the maximum is 79 (and 72 for comments). I'd like to know if I can change these values to the ones that you can see on the Python website. And if there is anyone who knows why these two differ from each other I'd love to know!
Thanks for the help :)

2
Avatar
Permanently deleted user

I think they might differ because either one of them might be outdated, but again, I really don't know.

-1

Hi, you can configure this option in Settings | Editor | Code Style | Right margin. 120 is just a default value in PyCharm.

4
Avatar
Permanently deleted user

Alright, that already helps a lot, thank you :)

0

Can this be read from the project somehow?

0

The "Hard wrap" setting is global I'm afraid.

1
Avatar
Permanently deleted user

For the newer version, this is what I have to do to comply with pylint:

1. crtl + alt + s > Editor > Code Style > Python

2. Click on the "Wrapping and Braces" tab

3. Edit the value in the row "Hard wrap at" to 100

2

I think the code inspection should be configurable. PEP8 recommends (or prescribes) many, but in it's introduction it states clearly "Many projects have their own coding style guidelines. In the event of any conflicts, such project-specific guides take precedence for that project." Which means, when in Rome do as the Romans do.

In my case I contribute to a library that deviates from PEP8 in that it uses lowerCamelCase for properties / object instance members. While pycharm's inspection flags these properties as violations, this is not correct. I really should be able to tell the checker that the rule of this library is lowerCamelCase and not the pep8 default of snake_case. 

0
Avatar
Permanently deleted user

@Maxdw, thank you. It is stupid that if the "Hard wrap at" is set to its default (i.e., 0), everything gets underlined as violating PEP-8. At the very least, the default of 79 should be used for PEP-8 checks if the user has not explicitly specified a hard wrap column.

0

请先登录再写评论。