pycharm - 抑制 pycharm 和 pylint 的警告

标签 pycharm pylint

我使用 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/

相关文章:

javascript - 如何跳转到JavaScript库源?

python - 自定义包已安装但在另一个项目中找不到

django - 'staticmethod' 对象没有属性 'short_description'

pylint - 如何创建 pylintrc 文件

python - VSCode/Pylint 在同一目录中找不到模块

python - 防止 self 分配的 pylint 保护

python - 如果我使用 % 格式化字符串,PyCharm 应该警告我

python - 打印到 CSV 会导致每个字符之间有一个空格?

python - 如何将 Pylint 与 Geany 集成,以便我可以将 Geany 用作 python IDE?

python-3.x - 如何在 pytest 中使用 Cython?