#!/usr/bin/env bash

################################################################################
# Runs pylint on the repository using a preconfigured .pylintrc file.
#
# Usage:
#     check/pylint [--flags for pylint]
################################################################################

# Get the working directory to the repo root.
thisdir="$(dirname "${BASH_SOURCE[0]}")" || exit $?
topdir="$(git -C "${thisdir}" rev-parse --show-toplevel)" || exit $?
cd "${topdir}" || exit $?

read -r -a CIRQ_MODULES < \
    <(env PYTHONPATH=. python dev_tools/modules.py list --mode package-path)

# Add dev_tools to $PYTHONPATH so that pylint can find custom checkers
env PYTHONPATH=dev_tools pylint --jobs=0 --rcfile=dev_tools/conf/.pylintrc "$@" "${CIRQ_MODULES[@]}" dev_tools examples
