Skip to content
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

Update copyright checker and switch to pylint-3 #1439

Merged
merged 6 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dev_tools/conf/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ score=no
reports=no
py-version=3.9
disable=
abstract-class-instantiated, # TODO: #1440 - enable and fix
deprecated-class, # TODO: #1440 - enable and fix
possibly-used-before-assignment, # TODO: #1440 - enable and fix
used-before-assignment, # TODO: #1440 - enable and fix
C,
R,
missing-raises-doc,
Expand Down
25 changes: 13 additions & 12 deletions dev_tools/qualtran_dev_tools/pylint_copyright_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations

from typing import TYPE_CHECKING

from astroid import nodes
from pylint.checkers import BaseChecker
from pylint.interfaces import IRawChecker
from pylint.checkers import BaseRawFileChecker

if TYPE_CHECKING:
from pylint.lint import PyLinter


class CopyrightChecker(BaseChecker):
r"""Check for the copyright notices at the beginning of a Python source file.
class CopyrightChecker(BaseRawFileChecker):
"""Check for the copyright notices at the beginning of a Python source file.

This checker can be disabled by putting `# pylint: disable=wrong-or-nonexistent-copyright-notice`
at the beginning of a file.
"""

__implements__ = IRawChecker

# The priority must be negative. Pylint runs plugins with smaller priorities first.
priority = -1

name = "copyright-notice"
msgs = {
"R0001": (
Expand All @@ -40,7 +41,7 @@ class CopyrightChecker(BaseChecker):
options = ()

def process_module(self, node: nodes.Module) -> None:
r"""Check whether the copyright notice is correctly placed in the source file of a module.
"""Check whether the copyright notice is correctly placed in the source file of a module.

Compare the first lines of a source file against the standard copyright notice (i.e., the
`golden` variable below). Suffix whitespace (including newline symbols) is not considered
Expand Down Expand Up @@ -108,8 +109,8 @@ def skip_shebang(stream):
return


def register(linter):
r"""Register this checker to pylint.
def register(linter: PyLinter):
"""Register this checker to pylint.

The registration is done automatically if this file is in $PYTHONPATH.
"""
Expand Down
4 changes: 2 additions & 2 deletions dev_tools/requirements/deps/pylint.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pylint~=2.15
pylint~=3.3.1

# for checking _test.py files
pytest
Expand All @@ -7,4 +7,4 @@ openfermion[resources]
# dev tools
tensorflow-docs
sphinx
filelock
filelock
20 changes: 8 additions & 12 deletions dev_tools/requirements/envs/dev.env.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ astor==0.8.1
# via
# flynt
# tensorflow-docs
astroid==2.15.8
astroid==3.3.5
# via pylint
asttokens==2.4.1
# via stack-data
Expand Down Expand Up @@ -105,7 +105,7 @@ cryptography==43.0.1
# via secretstorage
cycler==0.12.1
# via matplotlib
cytoolz==0.12.3
cytoolz==1.0.0
# via quimb
dash==2.18.1
# via -r deps/runtime.txt
Expand Down Expand Up @@ -228,9 +228,9 @@ jaraco-context==6.0.1
# via keyring
jaraco-functools==4.1.0
# via keyring
jax==0.4.33
jax==0.4.34
# via openfermion
jaxlib==0.4.33
jaxlib==0.4.34
# via
# jax
# openfermion
Expand Down Expand Up @@ -304,8 +304,6 @@ keyring==25.4.1
# via twine
kiwisolver==1.4.7
# via matplotlib
lazy-object-proxy==1.10.0
# via astroid
llvmlite==0.43.0
# via numba
markdown-it-py==3.0.0
Expand Down Expand Up @@ -515,7 +513,7 @@ pygments==2.18.0
# readme-renderer
# rich
# sphinx
pylint==2.17.7
pylint==3.3.1
# via -r deps/pylint.txt
pyparsing==3.1.4
# via
Expand Down Expand Up @@ -602,7 +600,7 @@ rfc3986-validator==0.1.1
# via
# jsonschema
# jupyter-events
rich==13.9.1
rich==13.9.2
# via twine
rpds-py==0.20.0
# via
Expand Down Expand Up @@ -696,7 +694,7 @@ tomli==2.0.2
# sphinx
tomlkit==0.13.2
# via pylint
toolz==0.12.1
toolz==1.0.0
# via cytoolz
tornado==6.4.1
# via
Expand Down Expand Up @@ -729,7 +727,7 @@ twine==5.1.1
# via -r deps/packaging.txt
types-protobuf==5.28.0.20240924
# via mypy-protobuf
types-python-dateutil==2.9.0.20240906
types-python-dateutil==2.9.0.20241003
# via arrow
typing-extensions==4.12.2
# via
Expand Down Expand Up @@ -780,8 +778,6 @@ wheel==0.44.0
# pip-tools
widgetsnbextension==4.0.13
# via ipywidgets
wrapt==1.16.0
# via astroid
zipp==3.20.2
# via importlib-metadata

Expand Down
6 changes: 3 additions & 3 deletions dev_tools/requirements/envs/docs.env.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ cycler==0.12.1
# via
# -c envs/dev.env.txt
# matplotlib
cytoolz==0.12.3
cytoolz==1.0.0
# via
# -c envs/dev.env.txt
# quimb
Expand Down Expand Up @@ -767,7 +767,7 @@ tomli==2.0.2
# -c envs/dev.env.txt
# jupyterlab
# sphinx
toolz==0.12.1
toolz==1.0.0
# via
# -c envs/dev.env.txt
# cytoolz
Expand Down Expand Up @@ -801,7 +801,7 @@ traitlets==5.14.3
# nbclient
# nbconvert
# nbformat
types-python-dateutil==2.9.0.20240906
types-python-dateutil==2.9.0.20241003
# via
# -c envs/dev.env.txt
# arrow
Expand Down
6 changes: 3 additions & 3 deletions dev_tools/requirements/envs/format.env.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ cycler==0.12.1
# via
# -c envs/dev.env.txt
# matplotlib
cytoolz==0.12.3
cytoolz==1.0.0
# via
# -c envs/dev.env.txt
# quimb
Expand Down Expand Up @@ -658,7 +658,7 @@ tomli==2.0.2
# black
# flynt
# jupyterlab
toolz==0.12.1
toolz==1.0.0
# via
# -c envs/dev.env.txt
# cytoolz
Expand Down Expand Up @@ -692,7 +692,7 @@ traitlets==5.14.3
# nbclient
# nbconvert
# nbformat
types-python-dateutil==2.9.0.20240906
types-python-dateutil==2.9.0.20241003
# via
# -c envs/dev.env.txt
# arrow
Expand Down
22 changes: 7 additions & 15 deletions dev_tools/requirements/envs/pylint.env.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ astor==0.8.1
# via
# -c envs/dev.env.txt
# tensorflow-docs
astroid==2.15.8
astroid==3.3.5
# via
# -c envs/dev.env.txt
# pylint
Expand Down Expand Up @@ -134,7 +134,7 @@ cycler==0.12.1
# via
# -c envs/dev.env.txt
# matplotlib
cytoolz==0.12.3
cytoolz==1.0.0
# via
# -c envs/dev.env.txt
# quimb
Expand Down Expand Up @@ -287,11 +287,11 @@ itsdangerous==2.2.0
# via
# -c envs/dev.env.txt
# flask
jax==0.4.33
jax==0.4.34
# via
# -c envs/dev.env.txt
# openfermion
jaxlib==0.4.33
jaxlib==0.4.34
# via
# -c envs/dev.env.txt
# jax
Expand Down Expand Up @@ -385,10 +385,6 @@ kiwisolver==1.4.7
# via
# -c envs/dev.env.txt
# matplotlib
lazy-object-proxy==1.10.0
# via
# -c envs/dev.env.txt
# astroid
llvmlite==0.43.0
# via
# -c envs/dev.env.txt
Expand Down Expand Up @@ -606,7 +602,7 @@ pygments==2.18.0
# ipython
# nbconvert
# sphinx
pylint==2.17.7
pylint==3.3.1
# via
# -c envs/dev.env.txt
# -r deps/pylint.txt
Expand Down Expand Up @@ -805,7 +801,7 @@ tomlkit==0.13.2
# via
# -c envs/dev.env.txt
# pylint
toolz==0.12.1
toolz==1.0.0
# via
# -c envs/dev.env.txt
# cytoolz
Expand Down Expand Up @@ -839,7 +835,7 @@ traitlets==5.14.3
# nbclient
# nbconvert
# nbformat
types-python-dateutil==2.9.0.20240906
types-python-dateutil==2.9.0.20241003
# via
# -c envs/dev.env.txt
# arrow
Expand Down Expand Up @@ -895,10 +891,6 @@ widgetsnbextension==4.0.13
# via
# -c envs/dev.env.txt
# ipywidgets
wrapt==1.16.0
# via
# -c envs/dev.env.txt
# astroid
zipp==3.20.2
# via
# -c envs/dev.env.txt
Expand Down
10 changes: 5 additions & 5 deletions dev_tools/requirements/envs/pytest.env.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ cycler==0.12.1
# via
# -c envs/dev.env.txt
# matplotlib
cytoolz==0.12.3
cytoolz==1.0.0
# via
# -c envs/dev.env.txt
# quimb
Expand Down Expand Up @@ -263,11 +263,11 @@ itsdangerous==2.2.0
# via
# -c envs/dev.env.txt
# flask
jax==0.4.33
jax==0.4.34
# via
# -c envs/dev.env.txt
# openfermion
jaxlib==0.4.33
jaxlib==0.4.34
# via
# -c envs/dev.env.txt
# jax
Expand Down Expand Up @@ -734,7 +734,7 @@ tomli==2.0.2
# coverage
# jupyterlab
# pytest
toolz==0.12.1
toolz==1.0.0
# via
# -c envs/dev.env.txt
# cytoolz
Expand Down Expand Up @@ -768,7 +768,7 @@ traitlets==5.14.3
# nbclient
# nbconvert
# nbformat
types-python-dateutil==2.9.0.20240906
types-python-dateutil==2.9.0.20241003
# via
# -c envs/dev.env.txt
# arrow
Expand Down
6 changes: 3 additions & 3 deletions dev_tools/requirements/envs/runtime.env.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ cycler==0.12.1
# via
# -c envs/dev.env.txt
# matplotlib
cytoolz==0.12.3
cytoolz==1.0.0
# via
# -c envs/dev.env.txt
# quimb
Expand Down Expand Up @@ -629,7 +629,7 @@ tomli==2.0.2
# via
# -c envs/dev.env.txt
# jupyterlab
toolz==0.12.1
toolz==1.0.0
# via
# -c envs/dev.env.txt
# cytoolz
Expand Down Expand Up @@ -663,7 +663,7 @@ traitlets==5.14.3
# nbclient
# nbconvert
# nbformat
types-python-dateutil==2.9.0.20240906
types-python-dateutil==2.9.0.20241003
# via
# -c envs/dev.env.txt
# arrow
Expand Down
Loading