Skip to content

Commit 52aba59

Browse files
authored
Switch to using the incremental pylint. Turn on documentation linters. (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.
1 parent cea9eec commit 52aba59

File tree

4 files changed

+94
-2
lines changed

4 files changed

+94
-2
lines changed

.github/workflows/ci.yml

+17
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,23 @@ jobs:
102102
run: check/pylint --version
103103
- name: Lint
104104
run: check/pylint -v
105+
incremental_lint:
106+
name: Incremental Lint check
107+
runs-on: ubuntu-20.04
108+
steps:
109+
- uses: actions/checkout@v2
110+
with:
111+
fetch-depth: 0
112+
- uses: actions/setup-python@v1
113+
with:
114+
python-version: '3.8'
115+
architecture: 'x64'
116+
- name: Install pylint
117+
run: pip install -r dev_tools/requirements/deps/pylint.txt
118+
- name: Display version
119+
run: check/pylint --version
120+
- name: Lint
121+
run: check/pylint-changed-files
105122
doc_test:
106123
name: Doc test
107124
runs-on: ubuntu-20.04

check/pylint-changed-files

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ echo "Found ${num_changed} lintable files associated with changes." >&2
6464
if [ "${num_changed}" -eq 0 ]; then
6565
exit 0
6666
fi
67-
pylint --rcfile=dev_tools/conf/.pylintrc ${changed[@]}
67+
pylint --rcfile=dev_tools/conf/incremental.pylintrc ${changed[@]}
6868

dev_tools/bash_scripts_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ def test_pylint_changed_files_file_selection(tmpdir_factory):
617617
).split()
618618
)
619619

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

622622
result = run(
623623
script_file='check/pylint-changed-files',

dev_tools/conf/incremental.pylintrc

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
[MASTER]
2+
load-plugins=pylint.extensions.docparams,pylint.extensions.docstyle
3+
max-line-length=100
4+
disable=all
5+
ignore-patterns=.*_pb2\.py,quantum_engine_service_client.py,engine_pb2_grpc.py
6+
output-format=colorized
7+
score=no
8+
reports=no
9+
enable=
10+
anomalous-backslash-in-string,
11+
assert-on-tuple,
12+
bad-indentation,
13+
bad-option-value,
14+
bad-reversed-sequence,
15+
bad-super-call,
16+
consider-merging-isinstance,
17+
continue-in-finally,
18+
dangerous-default-value,
19+
docstyle,
20+
duplicate-argument-name,
21+
expression-not-assigned,
22+
function-redefined,
23+
inconsistent-mro,
24+
init-is-generator,
25+
line-too-long,
26+
lost-exception,
27+
missing-kwoa,
28+
mixed-indentation,
29+
mixed-line-endings,
30+
not-callable,
31+
no-value-for-parameter,
32+
nonexistent-operator,
33+
not-in-loop,
34+
parameter_documentation,
35+
pointless-statement,
36+
redefined-builtin,
37+
relative-import,
38+
return-arg-in-generator,
39+
return-in-init,
40+
return-outside-function,
41+
simplifiable-if-statement,
42+
syntax-error,
43+
too-many-function-args,
44+
trailing-whitespace,
45+
# Disabling until https://github.com/PyCQA/pylint/issues/3791 is fixed
46+
# undefined-variable,
47+
unexpected-keyword-arg,
48+
unhashable-dict-key,
49+
unnecessary-pass,
50+
unreachable,
51+
unrecognized-inline-option,
52+
unused-import,
53+
unnecessary-semicolon,
54+
unused-variable,
55+
unused-wildcard-import,
56+
wildcard-import,
57+
wrong-import-order,
58+
wrong-import-position,
59+
yield-outside-function
60+
61+
# Ignore long lines containing urls or pylint directives.
62+
ignore-long-lines=^(.*#\w*pylint: disable.*|\s*(# )?<?https?://\S+>?)$
63+
64+
[TYPECHECK]
65+
66+
# List of members which are set dynamically and missed by pylint inference
67+
# system, and so shouldn't trigger E1101 when accessed. Python regular
68+
# expressions are accepted.
69+
generated-members=numpy.*
70+
71+
72+
[IMPORTS]
73+
74+
# Force import order to recognize a module as part of a third party library.
75+
known-third-party=cirq,cirq_google,cirq_aqt,cirq_ionq

0 commit comments

Comments
 (0)