#python
#python
Вопрос:
У меня есть test.py
файл, который я хочу проверить с помощью pylint в checking.py
файле с экранирующими сообщениями о рефакторинге (R) и соглашении (C). Что я сделал не так?
test.py
print("hello!")
checking.py
import pylint.lint
from pylint import epylint as lint
pylint_opts = ['--disable=R,C']
pylint.lint.Run(pylint_opts)
(pylint_stdout, pylint_stderr) = lint.py_run('test.py', return_std=True)
Он возвращает мне сообщение о помощи, предполагая, что у меня опечатка при написании параметров pylint, но я написал это нормально, как указано в документации:
Messages control
-d <msg ids>, --disable=<msg ids>
Disable the message, report, category or checker with
the given id(s). You can either give multiple
identifiers separated by comma (,) or put this option
multiple times (only on the command line, not in the
configuration file where it should appear only once).
You can also use "--disable=all" to disable everything
first and then reenable specific checks. For example,
if you want to run only the similarities checker, you
can use "--disable=all --enable=similarities". If you
want to run only the classes checker, but have no
Warning level messages displayed, use "--disable=all
--enable=classes --disable=W".
There are 5 kind of message types :
* (C) convention, for programming standard violation
* (R) refactor, for bad code smell
* (W) warning, for python specific problems
* (E) error, for probable bugs in the code
* (F) fatal, if an error occurred which prevented pylint from doing
further processing.
Ответ №1:
epylint()
выполняет свою собственную инициализацию (вызов Run
) с sys.argv
помощью, ie. аргументы, используемые при вызове вашего checking.py
Я предполагаю, что вы просто вызываете python checking.py
, so sys.argv[1:] == []
, что означает, что в bash вы бы выполняли pylint
(с любым аргументом).
Я думаю, что ваше решение слишком сложное. почему вы не вызываете pylint --disable R,C test.py
из командной строки?
Вы могли бы даже написать .pylintrc :
[MESSAGES CONTROL]
disable=R,C
и просто вызовите pylint test.py
Комментарии:
1. У меня есть причина — потому что я хочу автоматизировать это и хочу понять, как запускать lint с помощью кода