Pylint pokazujący tylko ostrzeżenia i błędy
Chciałbym użyć pylint do sprawdzenia kodu, ale interesuje mnie tylko poziom błędów i ostrzeżeń. Czy można to zrobić w wierszu poleceń lub w pylintrc?
Nie interesuje mnie filtrowanie podanych spraw (np. lista wszystkich komunikatów w kontroli komunikatów), chcę tylko, aby pylint ignorował wszystkie konwencje i komunikaty refaktoringowe.
Uwaga: nie wydaje mi się, aby to był duplikat używający Pylint do wyświetlania błędów i ostrzeżeń
2 answers
Użyj -d
/ --disable
opcja wyłączenia klas komunikatów " C " i " R " (konwencja i refaktor):
-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"
Bez opcji disable
(6 konwencja, 1 refaktor, 2 ostrzeżenie, 1 Błąd):
$ pylint x.py
C: 1, 0: Missing module docstring (missing-docstring)
C: 3, 0: Missing function docstring (missing-docstring)
R: 3, 0: Too many statements (775/50) (too-many-statements)
W:780,15: Redefining name 'path' from outer scope (line 796) (redefined-outer-name)
C:780, 0: Invalid function name "getSection" (invalid-name)
C:780, 0: Empty function docstring (empty-docstring)
C:782,23: Invalid variable name "inPath" (invalid-name)
W:785, 4: Statement seems to have no effect (pointless-statement)
E:785, 4: Undefined variable 'something' (undefined-variable)
C:796, 4: Invalid constant name "path" (invalid-name)
Po użyciu opcji disable
(0 konwencja, 0 refaktor, 2 ostrzeżenie, 1 Błąd):
$ pylint --disable=R,C x.py
W:780,15: Redefining name 'path' from outer scope (line 796) (redefined-outer-name)
W:785, 4: Statement seems to have no effect (pointless-statement)
E:785, 4: Undefined variable 'something' (undefined-variable)
Aby ustawić tę opcję w pylintrc
:
disable=R,C
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-08-09 19:34:22
> python -m pylint --errors-only script_to_validate.py
No config file found, using default configuration
************* Module script_to_validate
E: 7,10: Module 'cv2' has no 'imread' member (no-member)
E: 8,15: Module 'cv2' has no 'threshold' member (no-member)
Moje Ustawienia to Python2.7. 6 32 bit & pylint 1.6.4
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-02-01 13:32:19