Skip to content

Commit

Permalink
Switch to using the incremental pylint. Turn on documentation linters. (
Browse files Browse the repository at this point in the history
quantumlib#4267)

This PR is related to: quantumlib#3388

We'd like to add some documentation rules to pylint but doing so would require us to add a significant amount of documentation to the current code.  In order to start enforcing this rule sooner rather than later. I added an incremental lint task to the ci.  The incremental lint task will check more rules but only check them on changed files.
  • Loading branch information
than4213 committed Jul 9, 2021
1 parent cea9eec commit 52aba59
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 2 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@ jobs:
run: check/pylint --version
- name: Lint
run: check/pylint -v
incremental_lint:
name: Incremental Lint check
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v1
with:
python-version: '3.8'
architecture: 'x64'
- name: Install pylint
run: pip install -r dev_tools/requirements/deps/pylint.txt
- name: Display version
run: check/pylint --version
- name: Lint
run: check/pylint-changed-files
doc_test:
name: Doc test
runs-on: ubuntu-20.04
Expand Down
2 changes: 1 addition & 1 deletion check/pylint-changed-files
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ echo "Found ${num_changed} lintable files associated with changes." >&2
if [ "${num_changed}" -eq 0 ]; then
exit 0
fi
pylint --rcfile=dev_tools/conf/.pylintrc ${changed[@]}
pylint --rcfile=dev_tools/conf/incremental.pylintrc ${changed[@]}

2 changes: 1 addition & 1 deletion dev_tools/bash_scripts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def test_pylint_changed_files_file_selection(tmpdir_factory):
).split()
)

intercepted_prefix = 'INTERCEPTED pylint --rcfile=dev_tools/conf/.pylintrc '
intercepted_prefix = 'INTERCEPTED pylint --rcfile=dev_tools/conf/incremental.pylintrc '

result = run(
script_file='check/pylint-changed-files',
Expand Down
75 changes: 75 additions & 0 deletions dev_tools/conf/incremental.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
[MASTER]
load-plugins=pylint.extensions.docparams,pylint.extensions.docstyle
max-line-length=100
disable=all
ignore-patterns=.*_pb2\.py,quantum_engine_service_client.py,engine_pb2_grpc.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,
mixed-indentation,
mixed-line-endings,
not-callable,
no-value-for-parameter,
nonexistent-operator,
not-in-loop,
parameter_documentation,
pointless-statement,
redefined-builtin,
relative-import,
return-arg-in-generator,
return-in-init,
return-outside-function,
simplifiable-if-statement,
syntax-error,
too-many-function-args,
trailing-whitespace,
# Disabling until https://github.com/PyCQA/pylint/issues/3791 is fixed
# 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

0 comments on commit 52aba59

Please sign in to comment.