Search code examples
makefilepylint

Makefile + Pylint + Find files - recipe for target 'lint' failed


Would you know where is my syntax / code error in my following Makefile please ?

.PHONY: lint

PYTHON_SCRIPTS_LIST := $(shell find . -type f -name "*.py")
PYTHON ?= python

lint:
    $(PYTHON) -m pylint --rcfile=.pylintrc $(PYTHON_SCRIPTS_LIST)

When I execute make lint, it works well but returns :

Makefile:7: recipe for target 'lint' failed
make: *** [lint] Error 30

Thank you in advance for your help.


Solution

  • After clarifying in comments, it seems that you're running pylint and it still emits message. pylint will exit with error code 0 only if there isn't any message emitted. So you can either:

    • Fix all the messages
    • Disable all the messages
    • Fix some message and disable some of them
    • Stop caring about the makefile output if you only want to run pylint
    • Catch the exit code in the makefile command by adding || true after the command ( $(PYTHON) -m pylint --rcfile=.pylintrc $(PYTHON_SCRIPTS_LIST) || true)
    • Use pylint exit-zero option ( $(PYTHON) -m pylint --rcfile=.pylintrc $(PYTHON_SCRIPTS_LIST) --exit-zero)