Skip to content

Commit 769ad50

Browse files
authored
Update copyright checker and switch to pylint-3 (#6751)
- 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
1 parent 55b2c30 commit 769ad50

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

dev_tools/pylint_copyright_checker.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +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
20+
from pylint.checkers import BaseRawFileChecker
1621

17-
from pylint.checkers import BaseChecker
18-
from pylint.interfaces import IRawChecker
22+
if TYPE_CHECKING:
23+
from pylint.lint import PyLinter
1924

2025

21-
class CopyrightChecker(BaseChecker):
22-
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.
2328
2429
This checker can be disabled by putting `# pylint: disable=wrong-or-nonexistent-copyright-notice`
2530
at the beginning of a file.
2631
"""
2732

28-
__implements__ = IRawChecker
29-
30-
# The priority must be negtive. Pylint runs plugins with smaller priorities first.
31-
priority = -1
32-
3333
name = "copyright-notice"
3434
msgs = {
3535
"R0001": (
@@ -41,7 +41,7 @@ class CopyrightChecker(BaseChecker):
4141
options = ()
4242

4343
def process_module(self, node: nodes.Module) -> None:
44-
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.
4545
4646
Compare the first lines of a source file against the standard copyright notice (i.e., the
4747
`golden` variable below). Suffix whitespace (including newline symbols) is not considered
@@ -109,8 +109,8 @@ def skip_shebang(stream):
109109
return
110110

111111

112-
def register(linter):
113-
r"""Register this checker to pylint.
112+
def register(linter: PyLinter):
113+
"""Register this checker to pylint.
114114
115115
The registration is done automatically if this file is in $PYTHONPATH.
116116
"""
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# for linting
2-
pylint~=2.13.0
2+
pylint~=3.3.1

0 commit comments

Comments
 (0)