Skip to content

Commit

Permalink
Update copyright checker and switch to pylint-3 (#6751)
Browse files Browse the repository at this point in the history
- Bump up to the latest pylint-3.3.1 allowing patch-level updates.

- Adjust `pylint_copyright_checker` for the pylint-3 API.
  Follow the `examples/custom_raw.py` in the pylint repository.

Fixes #6351
  • Loading branch information
pavoljuhas authored Oct 4, 2024
1 parent 55b2c30 commit 769ad50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions dev_tools/pylint_copyright_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +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 BaseRawFileChecker

from pylint.checkers import BaseChecker
from pylint.interfaces import IRawChecker
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 negtive. Pylint runs plugins with smaller priorities first.
priority = -1

name = "copyright-notice"
msgs = {
"R0001": (
Expand All @@ -41,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 @@ -109,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
2 changes: 1 addition & 1 deletion dev_tools/requirements/deps/pylint.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# for linting
pylint~=2.13.0
pylint~=3.3.1

0 comments on commit 769ad50

Please sign in to comment.