Run Pylint for all Python files in a directory and all subdirectories

后端 未结 14 2371
眼角桃花
眼角桃花 2021-01-30 19:45

I have

find . -iname \"*.py\" -exec pylint -E {} ;\\

and

FILES=$(find . -iname \"*.py\")
pylint -E $FILES

If

14条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-30 20:36

    To run Pylint in all subdirectories,

    pylint $(find [a-z]* -type d)
    

    This solution is simpler and more direct than others. It works with no setup, including on macOS which doesn't have Bash 4.

    The reason for the [a-z]* is because most projects have Git or other magic subdirectories, which would pollute the results. If you have subdirectories starting with Capital Letters, use this variant:

    pylint $(find [a-zA-Z]* -type d)
    

提交回复
热议问题