PyCharm PEP8 Code Style highlights not working

时间:2017-04-09 23:49:44

标签: python pycharm pep8

I've been having this PEP8 style highlighting issue. The issue is it's not highlighting obvious style issues, like no blank lines before class definitions, or no empty lines at the end of the file. It could have to do with my VM and vagrant, but the project code is hosted locally so I don't think that should be an issue.

If I do Code > Run Inspection By Name > PEP 8 coding style violation it says it finds no instances.

Under File > Settings > Editor > Code Style > Python > Blank Lines I have blank lines set around the class. An oddity is that if I change the number of lines "around method", it changes them in real time in the example text on the right, but it doesn't do the same for lines "around class".

Under File > Settings > Editor > Inspections > Python I have "PEP 8 coding style violation" selected. I've tried changing it from warning to error and I still can't see the highlights in my file.

I don't have power saver mode on, which I've learned is a way to deactivate the background style checking in the editor.

I searched in Help > Show Log in Files for PEP8 and found "Pep8ExternalAnnotator - Found no suitable interpreter", but I don't know what that means and I couldn't find any references to it online.

I'm running PyCharms professional 2016.3

PyCharm 2016.3.2
Build #PY-163.10154.50, built on December 28, 2016
Licensed to arbaerbearfaerfa
Subscription is active until October 17, 2017
For educational use only.
JRE: 1.8.0_112-release-408-b6 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

3 个答案:

答案 0 :(得分:3)

还有三件事要检查:

  • 单击“检查器”图标,确保您拥有highlighting level set to Inspections
  • 第二次PEP8检查," PEP 8命名约定违规"。
  • 确保为整个项目设置检查范围。

答案 1 :(得分:0)

我在Windows 10(https://docs.anaconda.com/anaconda/install/windows/)上安装了Anaconda后,保持选中“将Anaconda注册为我的默认Python 3.7”复选框,它最终可以正常工作。我现在有两个项目解释器,并且突出显示了PEP 8代码样式违规。

答案 2 :(得分:0)

我遇到了同样的问题(在 mac、python3.8、pycharm v2020.3 上)。我能够通过将新项目中的 .idea/inspectionProfiles/Project_Default.xml 与我没有显示 pep8 检查警告的项目进行比较来修复它。新项目有以下一行

    <inspection_tool class="PyClassicStyleClassInspection" enabled="true" level="WARNING" enabled_by_default="true" />

我将此行添加到我的项目中,该行无法与 pep8 一起使用,然后它立即开始工作。注意:项目的首选项显示启用了 pep8 检查,但它不起作用。