From 445564e03e1ebbe30e695af2f7481a5ba07a2e37 Mon Sep 17 00:00:00 2001 From: Doug Strain Date: Tue, 27 Jun 2023 16:09:47 -0700 Subject: [PATCH 1/5] Add pylint to CI for unitary --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0a71aff7..f4c04a62 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,7 @@ cirq-core>=0.15.0 cirq-google>=0.15.0 # When changing Cirq requirements be sure to update dev_tools/write-ci-requirements.py -seaborn ipython black +pylint +pytest From 944aa3185956bfe603b25e22237330b4860a7857 Mon Sep 17 00:00:00 2001 From: Doug Strain Date: Tue, 27 Jun 2023 16:13:40 -0700 Subject: [PATCH 2/5] Add pylint workflow. --- .github/workflows/pylint.yml | 19 ++++++++++ dev_tools/.pylintrc | 73 ++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 .github/workflows/pylint.yml create mode 100644 dev_tools/.pylintrc diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml new file mode 100644 index 00000000..75de73da --- /dev/null +++ b/.github/workflows/pylint.yml @@ -0,0 +1,19 @@ +name: Pylint + +on: [push, pull_request] + +jobs: + pylint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v1 + with: + python-version: '3.10' + architecture: 'x64' + - name: Install Pylint + run: | + python -m pip install --upgrade pip + pip install pylint + - name: Pylint check + run: dev_tools/pylint diff --git a/dev_tools/.pylintrc b/dev_tools/.pylintrc new file mode 100644 index 00000000..638ba3e6 --- /dev/null +++ b/dev_tools/.pylintrc @@ -0,0 +1,73 @@ +[MASTER] +load-plugins=pylint.extensions.docstyle,pylint.extensions.docparams,pylint_copyright_checker +max-line-length=88 +disable=all +#ignore-paths=cirq-google/cirq_google/cloud/.* +ignore-patterns=.*_pb2\.py +output-format=colorized +score=no +reports=no +enable= + anomalous-backslash-in-string, + assert-on-tuple, + bad-indentation, + bad-option-value, + bad-reversed-sequence, + bad-super-call, + consider-merging-isinstance, + continue-in-finally, + dangerous-default-value, + docstyle, + duplicate-argument-name, + expression-not-assigned, + function-redefined, + inconsistent-mro, + init-is-generator, + line-too-long, + lost-exception, + missing-kwoa, + missing-param-doc, + missing-raises-doc, + mixed-line-endings, + no-value-for-parameter, + nonexistent-operator, + not-in-loop, + pointless-statement, + redefined-builtin, + return-arg-in-generator, + return-in-init, + return-outside-function, + simplifiable-if-statement, + singleton-comparison, + syntax-error, + too-many-function-args, + trailing-whitespace, + undefined-variable, + unexpected-keyword-arg, + unhashable-dict-key, + unnecessary-pass, + unreachable, + unrecognized-inline-option, + unused-import, + unnecessary-semicolon, + unused-variable, + unused-wildcard-import, + wildcard-import, + wrong-import-order, + wrong-import-position, + yield-outside-function + +# Ignore long lines containing urls or pylint directives. +ignore-long-lines=^(.*#\w*pylint: disable.*|\s*(# )?[<\[\(]?https?://\S+[>\]\)]?)$ + +[TYPECHECK] + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E1101 when accessed. Python regular +# expressions are accepted. +generated-members=numpy.* + + +#[IMPORTS] +# Force import order to recognize a module as part of a third party library. +#known-third-party=cirq,cirq_google,cirq_aqt,cirq_ionq From c10f2c9637f4df5f2b95ea38a03322854a0856cb Mon Sep 17 00:00:00 2001 From: Doug Strain Date: Tue, 27 Jun 2023 16:16:54 -0700 Subject: [PATCH 3/5] Add pylint executable. --- dev_tools/pylint | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 dev_tools/pylint diff --git a/dev_tools/pylint b/dev_tools/pylint new file mode 100644 index 00000000..3d88f809 --- /dev/null +++ b/dev_tools/pylint @@ -0,0 +1,15 @@ +#!/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. +cd "$(dirname "${BASH_SOURCE[0]}")" +cd "$(git rev-parse --show-toplevel)" + +# Add dev_tools to $PYTHONPATH so that pylint can find custom checkers +env PYTHONPATH=dev_tools pylint --jobs=0 --rcfile=dev_tools/.pylintrc "$@" . From e288564efdcf3f83716614d9bdbe6343e832ecf1 Mon Sep 17 00:00:00 2001 From: Doug Strain Date: Tue, 27 Jun 2023 16:19:57 -0700 Subject: [PATCH 4/5] Change to execute. --- dev_tools/pylint | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev_tools/pylint b/dev_tools/pylint index 3d88f809..0351b7ff 100644 --- a/dev_tools/pylint +++ b/dev_tools/pylint @@ -2,7 +2,7 @@ ################################################################################ # Runs pylint on the repository using a preconfigured .pylintrc file. -# +# # Usage: # check/pylint [--flags for pylint] ################################################################################ From 231ffec1147e14a81178b32b90520877432a1e85 Mon Sep 17 00:00:00 2001 From: Doug Strain Date: Tue, 27 Jun 2023 17:03:35 -0700 Subject: [PATCH 5/5] Add execute bit. --- dev_tools/pylint | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 dev_tools/pylint diff --git a/dev_tools/pylint b/dev_tools/pylint old mode 100644 new mode 100755