I have
find . -iname \"*.py\" -exec pylint -E {} ;\\
and
FILES=$(find . -iname \"*.py\")
pylint -E $FILES
If
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
pylint mymodule.py
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.
Im using the "pylint_runner" in order to run pylint on all files in the directory and the subdirectories. Python 3.7.4
pylint_runner 0.54
pylint 2.4.1
https://pypi.org/project/pylint_runner/
Here is the command to run it from the Docker container:
docker run -i --rm --name my_container \
-v "$PWD":"$PWD" -w "$PWD" \
python:3.7 \
/bin/sh -c "pip3 install -r requirements.txt; pylint_runner -v"
requirements.txt
- should exist in the "$PWD" directory and contain "pylint_runner" entry.
Just pass the directory name to the pylint command. To lint all files in ./server
:
pylint server
If your goal is to run pylint on all files in the current working directory and subfolders, here is one workaround. This script runs pylint on the current directory. If __init__.py
does not exist, it creates it, runs pylint, then removes it.
#! /bin/bash -
if [[ ! -e __init__.py ]]; then
touch __init__.py
pylint `pwd`
rm __init__.py
else
pylint `pwd`
fi
touch __init__.py
in the current directorytouch __init__.py
in every subdirectory that you want pylint to look atpylint $(pwd)
(or equivalently pylint /absolute/path/to/current/directory
)To run pylint on all *.py files in a directory and its subdirectories, you can run:
shopt -s globstar # for Bash
pylint ./**/*.py