1#!/bin/bash 2# Copyright 2017 The gRPC Authors 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16set -ex 17 18# NOTE(rbellevi): We ignore generated code. 19IGNORE_PATTERNS=--ignore-patterns='.*pb2\.py,.*pb2_grpc\.py' 20 21# change to root directory 22cd "$(dirname "$0")/../.." 23 24DIRS=( 25 'src/python/grpcio/grpc' 26 'src/python/grpcio_channelz/grpc_channelz' 27 'src/python/grpcio_health_checking/grpc_health' 28 'src/python/grpcio_reflection/grpc_reflection' 29 'src/python/grpcio_testing/grpc_testing' 30 'src/python/grpcio_status/grpc_status' 31) 32 33TEST_DIRS=( 34 'src/python/grpcio_tests/tests' 35) 36 37VIRTUALENV=python_pylint_venv 38python3 -m virtualenv $VIRTUALENV -p $(which python3) 39 40PYTHON=$VIRTUALENV/bin/python 41 42$PYTHON -m pip install --upgrade pip==19.3.1 43 44# TODO(https://github.com/grpc/grpc/issues/23394): Update Pylint. 45$PYTHON -m pip install --upgrade astroid==2.3.3 pylint==2.2.2 "isort>=4.3.0,<5.0.0" 46 47EXIT=0 48for dir in "${DIRS[@]}"; do 49 $PYTHON -m pylint --rcfile=.pylintrc -rn "$dir" ${IGNORE_PATTERNS} || EXIT=1 50done 51 52for dir in "${TEST_DIRS[@]}"; do 53 $PYTHON -m pylint --rcfile=.pylintrc-tests -rn "$dir" ${IGNORE_PATTERNS} || EXIT=1 54done 55 56find examples/python \ 57 -iname "*.py" \ 58 -not -name "*_pb2.py" \ 59 -not -name "*_pb2_grpc.py" \ 60 | xargs $PYTHON -m pylint --rcfile=.pylintrc-examples -rn ${IGNORE_PATTERNS} 61 62exit $EXIT 63