我使用PyCharm编写代码,我也配置CI服务器在每个PR上运行PyLint.问题是PyCharm和PyLint使用不同的注释来抑制警告:
# noinspection PyMethodMayBeStatic
# pylint: disable=no-self-use
Run Code Online (Sandbox Code Playgroud)
我不喜欢对PyCharm和PyLint都有两条评论.有没有办法配置PyLint来理解PyCharm注释或配置PyCharm来理解PyLint注释?
有没有办法配置 PyLint 来理解 PyCharm 注释或配置 PyCharm 来理解 PyLint 注释?
不。至少目前我不知道。你总是可以写一些东西,虽然我相信有一个更简单的选择。
我正在寻找一种方法让 PyCharm 理解 PyLint 语法,即像 # pylint: disable=unused-argument 这样的注释来抑制特定的 linter 警告。
与其让“PyCharm 理解 PyLint 语法”,不如将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.
Run Code Online (Sandbox Code Playgroud)
然后在 PyCharm 中禁用 PyCharm 特定警告。现在您只需要使用 PyLint 警告。我意识到这不是你想要的,但我希望它有所帮助。它至少对我有用。仅使用 PyLint 警告的好处是与使用其他编辑器的人共享代码更简单。
| 归档时间: |
|
| 查看次数: |
1498 次 |
| 最近记录: |