Makefile + Pylint + 查找文件 - 目标 'lint' 的配方失败

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

你能知道我下面的 Makefile 中的语法/代码错误在哪里吗?

.PHONY: lint

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

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

当我执行 make lint 时,效果很好,但是 returns :

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

预先感谢您的帮助。

在评论中澄清后,您似乎 运行ning pylint 并且它仍然发出消息。仅当未发出任何消息时,pylint 才会以错误代码 0 退出。所以你可以:

  • 修复所有消息
  • 禁用所有消息
  • 修复了一些消息并禁用了其中的一些
  • 如果您只想运行 pylint
  • ,请停止关心 makefile 输出
  • 通过在命令后添加 || true 来捕获 makefile 命令中的退出代码 ($(PYTHON) -m pylint --rcfile=.pylintrc $(PYTHON_SCRIPTS_LIST) || true)
  • 使用pylint exit-zero option ( $(PYTHON) -m pylint --rcfile=.pylintrc $(PYTHON_SCRIPTS_LIST) --exit-zero)