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

后端 未结 14 2202
眼角桃花
眼角桃花 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:22

    My one cent

    find . -type f -name "*.py" | xargs pylint 
    

    How does it work?

    find finds all files ends with py and pass to xargs, xargs runs pylint command on each file.

    NOTE: You can give any argument to pylint command as well.

    EDIT:

    According to doc we can use

    1. pylint mymodule.py

    2. pylint directory/mymodule.py

    number 2 will work if directory is a python package (i.e. has an __init__.py file or it is an implicit namespace package) or if “directory” is in the python path.

提交回复
热议问题