-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CI checks for mypy and pylint #55
Open
dstrain115
wants to merge
9
commits into
quantumlib:main
Choose a base branch
from
dstrain115:additional_ci_checks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fd8a88f
Add CI checks for mypy and pylint
dstrain115 0ba2105
Try to fix pylint
dstrain115 d71936d
Try again.
dstrain115 284eafd
Fix some stubs.
dstrain115 e822f52
Allow mypy to succeed temporarily.
dstrain115 58d52fb
Merge branch 'main' into additional_ci_checks
dstrain115 b79135d
Slim down requirements.
dstrain115 3fa180c
Slim down mypy deps.
dstrain115 a6114a6
Adjust numpy mypy
dstrain115 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Type Check | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
mypy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v1 | ||
with: | ||
python-version: '3.8' | ||
architecture: 'x64' | ||
- name: Install mypy | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install mypy | ||
- name: Type check | ||
run: dev_tools/mypy || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.8' | ||
architecture: 'x64' | ||
- name: Install Pylint | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pylint | ||
- name: Pylint check | ||
run: dev_tools/pylint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
[MASTER] | ||
load-plugins=pylint.extensions.docstyle,pylint.extensions.docparams,pylint_copyright_checker | ||
max-line-length=100 | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
################################################################################ | ||
# Runs mypy on the repository using a preconfigured mypy.ini file. | ||
# | ||
# Usage: | ||
# check/mypy [--flags] | ||
################################################################################ | ||
|
||
# Get the working directory to the repo root. | ||
cd "$(dirname "${BASH_SOURCE[0]}")" | ||
cd "$(git rev-parse --show-toplevel)" | ||
|
||
|
||
echo -e -n "\033[31m" | ||
mypy --config-file=dev_tools/mypy.ini "$@" . | ||
result=$? | ||
echo -e -n "\033[0m" | ||
|
||
exit ${result} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[mypy] | ||
show_error_codes = true | ||
|
||
[mypy-__main__] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this mean? |
||
follow_imports = silent | ||
ignore_missing_imports = true | ||
|
||
# 3rd-party libs for which we don't have stubs | ||
[mypy-apiclient.*,matplotlib.*,mpl_toolkits,oauth2client.*,pandas.*,proto.*,pytest.*,scipy.*,setuptools.*,networkx.*,_pytest.*,codeowners.*,pylint.*,numpy.*,cirq.*,flask.*,numpy.*,cirq_google.*] | ||
follow_imports = silent | ||
ignore_missing_imports = true | ||
|
||
# There was no type information before numpy 1.20, so there are numpy mypy issues in the codebase | ||
[mypy-numpy.*] | ||
follow_imports = skip | ||
follow_imports_for_stubs = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "$@" . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,14 @@ cirq-core>=0.14.0 | |
cirq-google>=0.14.0 | ||
# When changing Cirq requirements be sure to update dev_tools/write-ci-requirements.py | ||
|
||
seaborn | ||
sphinx | ||
numpy | ||
sympy | ||
|
||
# dev tools | ||
ipython | ||
black | ||
mypy | ||
pylint | ||
pytest | ||
pytest-cov | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why install coverage tools? |
||
coverage<=6.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
88 to agree with black?