Pylint recursively for a given filename
I have a Django project and I'm working on Pylinting my way through it.
I have a couple situations where I'd like to be able to recursively find all files with a given name and pylint them differently (using different options). For example, I'd like to set different options for pylinting urls.py and admin.py
The following works for 1 directory..
pylint ./project_name/*/urls.py
But I'd like to make that *
recursive... s开发者_Python百科o that it drills into sub directories.
Any way to achieve that?
Update I'd also like them all to run as a single pylint output, not sequentially
Depending on your operating system, you could use:
find project_name -name urls.py | xargs pylint
Try with find:
find ./project_name/ -name "urls.py" -exec pylint '{}' \;
If you want to run multiple files in a single call to pylint
:
find ./project_name/ -name "urls.py" -exec pylint '{}' +
- Get all python files (recursive)
- Pass them all at once to pylint (from answer by Robin)
- Show output in console and put it in a file
find . -name "*.py" -print0 | xargs -0 pylint 2>&1 | tee err_pylint.rst~
精彩评论