Skip to content

Commit 96dc7fe

Browse files
pavoljuhasshab5
authored andcommitted
Update copyright checker and switch to pylint-3 (#1439)
* Bump up to the latest pylint-3.3.1 * Adjust `pylint_copyright_checker` for the pylint-3 API Follow the `examples/custom_raw.py` in the pylint repository. * Refresh development dependencies * Temporarily disable rules that started failing in pylint-3 Cherry-picked from quantumlib/Cirq#6751 Related to #1440
1 parent 88beb17 commit 96dc7fe

File tree

9 files changed

+48
-55
lines changed

9 files changed

+48
-55
lines changed

dev_tools/conf/.pylintrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ score=no
77
reports=no
88
py-version=3.9
99
disable=
10+
abstract-class-instantiated, # TODO: #1440 - enable and fix
11+
deprecated-class, # TODO: #1440 - enable and fix
12+
possibly-used-before-assignment, # TODO: #1440 - enable and fix
13+
used-before-assignment, # TODO: #1440 - enable and fix
1014
C,
1115
R,
1216
missing-raises-doc,

dev_tools/qualtran_dev_tools/pylint_copyright_checker.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,24 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from __future__ import annotations
16+
17+
from typing import TYPE_CHECKING
18+
1519
from astroid import nodes
16-
from pylint.checkers import BaseChecker
17-
from pylint.interfaces import IRawChecker
20+
from pylint.checkers import BaseRawFileChecker
21+
22+
if TYPE_CHECKING:
23+
from pylint.lint import PyLinter
1824

1925

20-
class CopyrightChecker(BaseChecker):
21-
r"""Check for the copyright notices at the beginning of a Python source file.
26+
class CopyrightChecker(BaseRawFileChecker):
27+
"""Check for the copyright notices at the beginning of a Python source file.
2228
2329
This checker can be disabled by putting `# pylint: disable=wrong-or-nonexistent-copyright-notice`
2430
at the beginning of a file.
2531
"""
2632

27-
__implements__ = IRawChecker
28-
29-
# The priority must be negative. Pylint runs plugins with smaller priorities first.
30-
priority = -1
31-
3233
name = "copyright-notice"
3334
msgs = {
3435
"R0001": (
@@ -40,7 +41,7 @@ class CopyrightChecker(BaseChecker):
4041
options = ()
4142

4243
def process_module(self, node: nodes.Module) -> None:
43-
r"""Check whether the copyright notice is correctly placed in the source file of a module.
44+
"""Check whether the copyright notice is correctly placed in the source file of a module.
4445
4546
Compare the first lines of a source file against the standard copyright notice (i.e., the
4647
`golden` variable below). Suffix whitespace (including newline symbols) is not considered
@@ -108,8 +109,8 @@ def skip_shebang(stream):
108109
return
109110

110111

111-
def register(linter):
112-
r"""Register this checker to pylint.
112+
def register(linter: PyLinter):
113+
"""Register this checker to pylint.
113114
114115
The registration is done automatically if this file is in $PYTHONPATH.
115116
"""
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pylint~=2.15
1+
pylint~=3.3.1
22

33
# for checking _test.py files
44
pytest
@@ -7,4 +7,4 @@ openfermion[resources]
77
# dev tools
88
tensorflow-docs
99
sphinx
10-
filelock
10+
filelock

dev_tools/requirements/envs/dev.env.txt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ astor==0.8.1
3030
# via
3131
# flynt
3232
# tensorflow-docs
33-
astroid==2.15.8
33+
astroid==3.3.5
3434
# via pylint
3535
asttokens==2.4.1
3636
# via stack-data
@@ -105,7 +105,7 @@ cryptography==43.0.1
105105
# via secretstorage
106106
cycler==0.12.1
107107
# via matplotlib
108-
cytoolz==0.12.3
108+
cytoolz==1.0.0
109109
# via quimb
110110
dash==2.18.1
111111
# via -r deps/runtime.txt
@@ -228,9 +228,9 @@ jaraco-context==6.0.1
228228
# via keyring
229229
jaraco-functools==4.1.0
230230
# via keyring
231-
jax==0.4.33
231+
jax==0.4.34
232232
# via openfermion
233-
jaxlib==0.4.33
233+
jaxlib==0.4.34
234234
# via
235235
# jax
236236
# openfermion
@@ -304,8 +304,6 @@ keyring==25.4.1
304304
# via twine
305305
kiwisolver==1.4.7
306306
# via matplotlib
307-
lazy-object-proxy==1.10.0
308-
# via astroid
309307
llvmlite==0.43.0
310308
# via numba
311309
markdown-it-py==3.0.0
@@ -515,7 +513,7 @@ pygments==2.18.0
515513
# readme-renderer
516514
# rich
517515
# sphinx
518-
pylint==2.17.7
516+
pylint==3.3.1
519517
# via -r deps/pylint.txt
520518
pyparsing==3.1.4
521519
# via
@@ -602,7 +600,7 @@ rfc3986-validator==0.1.1
602600
# via
603601
# jsonschema
604602
# jupyter-events
605-
rich==13.9.1
603+
rich==13.9.2
606604
# via twine
607605
rpds-py==0.20.0
608606
# via
@@ -696,7 +694,7 @@ tomli==2.0.2
696694
# sphinx
697695
tomlkit==0.13.2
698696
# via pylint
699-
toolz==0.12.1
697+
toolz==1.0.0
700698
# via cytoolz
701699
tornado==6.4.1
702700
# via
@@ -729,7 +727,7 @@ twine==5.1.1
729727
# via -r deps/packaging.txt
730728
types-protobuf==5.28.0.20240924
731729
# via mypy-protobuf
732-
types-python-dateutil==2.9.0.20240906
730+
types-python-dateutil==2.9.0.20241003
733731
# via arrow
734732
typing-extensions==4.12.2
735733
# via
@@ -780,8 +778,6 @@ wheel==0.44.0
780778
# pip-tools
781779
widgetsnbextension==4.0.13
782780
# via ipywidgets
783-
wrapt==1.16.0
784-
# via astroid
785781
zipp==3.20.2
786782
# via importlib-metadata
787783

dev_tools/requirements/envs/docs.env.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ cycler==0.12.1
133133
# via
134134
# -c envs/dev.env.txt
135135
# matplotlib
136-
cytoolz==0.12.3
136+
cytoolz==1.0.0
137137
# via
138138
# -c envs/dev.env.txt
139139
# quimb
@@ -767,7 +767,7 @@ tomli==2.0.2
767767
# -c envs/dev.env.txt
768768
# jupyterlab
769769
# sphinx
770-
toolz==0.12.1
770+
toolz==1.0.0
771771
# via
772772
# -c envs/dev.env.txt
773773
# cytoolz
@@ -801,7 +801,7 @@ traitlets==5.14.3
801801
# nbclient
802802
# nbconvert
803803
# nbformat
804-
types-python-dateutil==2.9.0.20240906
804+
types-python-dateutil==2.9.0.20241003
805805
# via
806806
# -c envs/dev.env.txt
807807
# arrow

dev_tools/requirements/envs/format.env.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ cycler==0.12.1
121121
# via
122122
# -c envs/dev.env.txt
123123
# matplotlib
124-
cytoolz==0.12.3
124+
cytoolz==1.0.0
125125
# via
126126
# -c envs/dev.env.txt
127127
# quimb
@@ -658,7 +658,7 @@ tomli==2.0.2
658658
# black
659659
# flynt
660660
# jupyterlab
661-
toolz==0.12.1
661+
toolz==1.0.0
662662
# via
663663
# -c envs/dev.env.txt
664664
# cytoolz
@@ -692,7 +692,7 @@ traitlets==5.14.3
692692
# nbclient
693693
# nbconvert
694694
# nbformat
695-
types-python-dateutil==2.9.0.20240906
695+
types-python-dateutil==2.9.0.20241003
696696
# via
697697
# -c envs/dev.env.txt
698698
# arrow

dev_tools/requirements/envs/pylint.env.txt

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ astor==0.8.1
4545
# via
4646
# -c envs/dev.env.txt
4747
# tensorflow-docs
48-
astroid==2.15.8
48+
astroid==3.3.5
4949
# via
5050
# -c envs/dev.env.txt
5151
# pylint
@@ -134,7 +134,7 @@ cycler==0.12.1
134134
# via
135135
# -c envs/dev.env.txt
136136
# matplotlib
137-
cytoolz==0.12.3
137+
cytoolz==1.0.0
138138
# via
139139
# -c envs/dev.env.txt
140140
# quimb
@@ -287,11 +287,11 @@ itsdangerous==2.2.0
287287
# via
288288
# -c envs/dev.env.txt
289289
# flask
290-
jax==0.4.33
290+
jax==0.4.34
291291
# via
292292
# -c envs/dev.env.txt
293293
# openfermion
294-
jaxlib==0.4.33
294+
jaxlib==0.4.34
295295
# via
296296
# -c envs/dev.env.txt
297297
# jax
@@ -385,10 +385,6 @@ kiwisolver==1.4.7
385385
# via
386386
# -c envs/dev.env.txt
387387
# matplotlib
388-
lazy-object-proxy==1.10.0
389-
# via
390-
# -c envs/dev.env.txt
391-
# astroid
392388
llvmlite==0.43.0
393389
# via
394390
# -c envs/dev.env.txt
@@ -606,7 +602,7 @@ pygments==2.18.0
606602
# ipython
607603
# nbconvert
608604
# sphinx
609-
pylint==2.17.7
605+
pylint==3.3.1
610606
# via
611607
# -c envs/dev.env.txt
612608
# -r deps/pylint.txt
@@ -805,7 +801,7 @@ tomlkit==0.13.2
805801
# via
806802
# -c envs/dev.env.txt
807803
# pylint
808-
toolz==0.12.1
804+
toolz==1.0.0
809805
# via
810806
# -c envs/dev.env.txt
811807
# cytoolz
@@ -839,7 +835,7 @@ traitlets==5.14.3
839835
# nbclient
840836
# nbconvert
841837
# nbformat
842-
types-python-dateutil==2.9.0.20240906
838+
types-python-dateutil==2.9.0.20241003
843839
# via
844840
# -c envs/dev.env.txt
845841
# arrow
@@ -895,10 +891,6 @@ widgetsnbextension==4.0.13
895891
# via
896892
# -c envs/dev.env.txt
897893
# ipywidgets
898-
wrapt==1.16.0
899-
# via
900-
# -c envs/dev.env.txt
901-
# astroid
902894
zipp==3.20.2
903895
# via
904896
# -c envs/dev.env.txt

dev_tools/requirements/envs/pytest.env.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ cycler==0.12.1
121121
# via
122122
# -c envs/dev.env.txt
123123
# matplotlib
124-
cytoolz==0.12.3
124+
cytoolz==1.0.0
125125
# via
126126
# -c envs/dev.env.txt
127127
# quimb
@@ -263,11 +263,11 @@ itsdangerous==2.2.0
263263
# via
264264
# -c envs/dev.env.txt
265265
# flask
266-
jax==0.4.33
266+
jax==0.4.34
267267
# via
268268
# -c envs/dev.env.txt
269269
# openfermion
270-
jaxlib==0.4.33
270+
jaxlib==0.4.34
271271
# via
272272
# -c envs/dev.env.txt
273273
# jax
@@ -734,7 +734,7 @@ tomli==2.0.2
734734
# coverage
735735
# jupyterlab
736736
# pytest
737-
toolz==0.12.1
737+
toolz==1.0.0
738738
# via
739739
# -c envs/dev.env.txt
740740
# cytoolz
@@ -768,7 +768,7 @@ traitlets==5.14.3
768768
# nbclient
769769
# nbconvert
770770
# nbformat
771-
types-python-dateutil==2.9.0.20240906
771+
types-python-dateutil==2.9.0.20241003
772772
# via
773773
# -c envs/dev.env.txt
774774
# arrow

dev_tools/requirements/envs/runtime.env.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ cycler==0.12.1
112112
# via
113113
# -c envs/dev.env.txt
114114
# matplotlib
115-
cytoolz==0.12.3
115+
cytoolz==1.0.0
116116
# via
117117
# -c envs/dev.env.txt
118118
# quimb
@@ -629,7 +629,7 @@ tomli==2.0.2
629629
# via
630630
# -c envs/dev.env.txt
631631
# jupyterlab
632-
toolz==0.12.1
632+
toolz==1.0.0
633633
# via
634634
# -c envs/dev.env.txt
635635
# cytoolz
@@ -663,7 +663,7 @@ traitlets==5.14.3
663663
# nbclient
664664
# nbconvert
665665
# nbformat
666-
types-python-dateutil==2.9.0.20240906
666+
types-python-dateutil==2.9.0.20241003
667667
# via
668668
# -c envs/dev.env.txt
669669
# arrow

0 commit comments

Comments
 (0)