【问题标题】:Pylint warn the usage of print statementPylint 警告打印语句的使用
【发布时间】:2023-01-12 20:48:00
【问题描述】:

我正在为我的 Django 项目使用 pylint_django。我想禁用 print 语句使用或至少警告它。因为我正在使用自定义记录器类。但是没有任何关于打印使用的警告。


extension-pkg-whitelist=

ignore=CVS

ignore-patterns=

jobs=1


limit-inference-results=100

load-plugins=

persistent=yes

suggestion-mode=yes

unsafe-load-any-extension=no


[MESSAGES CONTROL]
confidence=

disable=missing-docstring,
        invalid-name,
        astroid-error,
        protected-access,
        broad-except

enable=c-extension-no-member, print-statement


[REPORTS]
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)

output-format=text

reports=no

score=yes


[REFACTORING]

max-nested-blocks=5

never-returning-functions=sys.exit


[LOGGING]

logging-format-style=old

logging-modules=logging

....

我该如何解决这个问题?

VsCode 设置.json

{
  "python.linting.pylintEnabled": true,
  "python.linting.enabled": true,
  "python.linting.flake8Enabled": false,
  "python.linting.prospectorEnabled": false,
  "python.linting.pylintArgs": [
    "--load-plugins=pylint_django",
    "--rcfile=.pylintrc",
    "--enable=print-statement"
  ]
}

【问题讨论】:

    标签: django pylint


    【解决方案1】:

    你可以使用the deprecated checkers bad-functions options来做到这一点:

    [tool.pylint]
    bad-functions = ["map", "filter", "print"]
    

    【讨论】:

      猜你喜欢
      • 2017-11-22
      • 2020-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-19
      相关资源
      最近更新 更多