我使用 PyCharm 编写代码,并且还配置了 CI 服务器以在每个 PR 上运行 PyLint。问题是 PyCharm 和 PyLint 使用不同的注释来抑制警告:
# noinspection PyMethodMayBeStatic
# pylint: disable=no-self-use
我不喜欢对 PyCharm 和 PyLint 都有两条评论。有没有办法配置 PyLint 以理解 PyCharm 注释或配置 PyCharm 以理解 PyLint 注释?
最佳答案
Is there a way to configure PyLint to understand PyCharm comments or to configure PyCharm to understand PyLint comments?
没有。至少据我所知目前还没有。你总是可以写一些东西,尽管我相信有一个更简单的选择。
I am looking for a way to make PyCharm understand the PyLint syntax, that is comments like # pylint: disable=unused-argument to supress specific linter warnings.
而不是让“PyCharm 理解 PyLint 语法”为什么不 integrate PyLint 与 PyCharm:
Within PyCharm:
Navigate to the preferences window
Select “External Tools”
Click the plus sign at the bottom of the dialog to add a new external task
In the dialog, populate the following fields:
Name: Pylint
Description: A Python source code analyzer which looks for programming errors, helps enforcing a coding standard and sniffs for some code smells.
Synchronize files after execution:
unchecked
Program: /path/to/pylint
Parameters: $FilePath$
Click OK
The option to check the current file with Pylint should now be available in Tools > External Tools > Pylint.
然后禁用 PyCharm 中的 PyCharm 特定警告。现在您只需要使用 PyLint 警告即可。我意识到这并不完全是您想要的,但我希望它有所帮助。它至少对我有用。仅使用 PyLint 警告的好处是与使用其他编辑器的人共享代码更简单。
关于pycharm - 抑制 pycharm 和 pylint 的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41979763/