summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdoc/exts/pylint_extensions.py2
-rwxr-xr-xdoc/exts/pylint_features.py7
-rw-r--r--script/create_contributor_list.py2
-rw-r--r--tests/checkers/base/unittest_base.py2
-rw-r--r--tests/checkers/unittest_non_ascii_name.py2
-rw-r--r--tests/checkers/unittest_spelling.py10
-rw-r--r--tests/checkers/unittest_utils.py2
-rw-r--r--tests/config/test_find_default_config_files.py2
-rw-r--r--tests/conftest.py21
-rw-r--r--tests/extensions/test_check_docs_utils.py6
-rw-r--r--tests/lint/unittest_expand_modules.py10
-rw-r--r--tests/message/unittest_message_definition_store.py9
-rw-r--r--tests/primer/test_primer_stdlib.py5
-rw-r--r--tests/profile/test_profile_against_externals.py9
-rw-r--r--tests/pyreverse/test_printer_factory.py7
-rw-r--r--tests/pyreverse/test_utils.py8
-rw-r--r--tests/pyreverse/test_writer.py2
-rw-r--r--tests/reporters/unittest_json_reporter.py2
-rw-r--r--tests/reporters/unittest_reporting.py26
-rw-r--r--tests/test_check_parallel.py12
-rw-r--r--tests/test_func.py2
-rw-r--r--tests/test_numversion.py4
-rw-r--r--tests/test_self.py2
-rw-r--r--tests/test_similar.py2
-rw-r--r--tests/utils/unittest_ast_walker.py17
25 files changed, 113 insertions, 60 deletions
diff --git a/doc/exts/pylint_extensions.py b/doc/exts/pylint_extensions.py
index e5949b1ed..406d2d39d 100755
--- a/doc/exts/pylint_extensions.py
+++ b/doc/exts/pylint_extensions.py
@@ -155,7 +155,7 @@ def get_plugins_info(
return by_checker
-def setup(app):
+def setup(app: Sphinx) -> dict[str, str]:
app.connect("builder-inited", builder_inited)
return {"version": sphinx.__display_version__}
diff --git a/doc/exts/pylint_features.py b/doc/exts/pylint_features.py
index 8654046d3..fcf4f01c8 100755
--- a/doc/exts/pylint_features.py
+++ b/doc/exts/pylint_features.py
@@ -8,8 +8,9 @@
documentation.
"""
+from __future__ import annotations
+
import os
-from typing import Optional
import sphinx
from sphinx.application import Sphinx
@@ -19,7 +20,7 @@ from pylint.utils import get_rst_title, print_full_documentation
# pylint: disable-next=unused-argument
-def builder_inited(app: Optional[Sphinx]) -> None:
+def builder_inited(app: Sphinx | None) -> None:
# PACKAGE/docs/exts/pylint_extensions.py --> PACKAGE/
base_path = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -39,7 +40,7 @@ def builder_inited(app: Optional[Sphinx]) -> None:
print_full_documentation(linter, stream, False)
-def setup(app):
+def setup(app: Sphinx) -> dict[str, str]:
app.connect("builder-inited", builder_inited)
return {"version": sphinx.__display_version__}
diff --git a/script/create_contributor_list.py b/script/create_contributor_list.py
index 9b336a01b..a1c2df2cd 100644
--- a/script/create_contributor_list.py
+++ b/script/create_contributor_list.py
@@ -11,7 +11,7 @@ ALIASES_FILE = BASE_DIRECTORY / "script/.contributors_aliases.json"
DEFAULT_CONTRIBUTOR_PATH = BASE_DIRECTORY / "CONTRIBUTORS.txt"
-def main():
+def main() -> None:
create_contributors_txt(
aliases_file=ALIASES_FILE, output=DEFAULT_CONTRIBUTOR_PATH, verbose=True
)
diff --git a/tests/checkers/base/unittest_base.py b/tests/checkers/base/unittest_base.py
index 05a7271cd..99a8f659e 100644
--- a/tests/checkers/base/unittest_base.py
+++ b/tests/checkers/base/unittest_base.py
@@ -9,7 +9,7 @@ import unittest
class TestNoSix(unittest.TestCase):
@unittest.skip("too many dependencies need six :(")
- def test_no_six(self):
+ def test_no_six(self) -> None:
try:
has_six = True
except ImportError:
diff --git a/tests/checkers/unittest_non_ascii_name.py b/tests/checkers/unittest_non_ascii_name.py
index 7b1c9d7c6..4f854dddc 100644
--- a/tests/checkers/unittest_non_ascii_name.py
+++ b/tests/checkers/unittest_non_ascii_name.py
@@ -23,7 +23,7 @@ class TestNonAsciiChecker(pylint.testutils.CheckerTestCase):
@pytest.mark.skipif(
sys.version_info < (3, 8), reason="requires python3.8 or higher"
)
- def test_kwargs_and_position_only(self):
+ def test_kwargs_and_position_only(self) -> None:
"""Even the new position only and keyword only should be found."""
node = astroid.extract_node(
"""
diff --git a/tests/checkers/unittest_spelling.py b/tests/checkers/unittest_spelling.py
index b07212a19..abeb9dcf8 100644
--- a/tests/checkers/unittest_spelling.py
+++ b/tests/checkers/unittest_spelling.py
@@ -308,10 +308,10 @@ class TestSpellingChecker(CheckerTestCase): # pylint:disable=too-many-public-me
# to show up in the pytest output as part of the test name
# when running parameterized tests.
self,
- misspelled_portion_of_directive,
- second_portion_of_directive,
- description,
- ):
+ misspelled_portion_of_directive: str,
+ second_portion_of_directive: str,
+ description: str,
+ ) -> None:
full_comment = f"# {misspelled_portion_of_directive}{second_portion_of_directive} {misspelled_portion_of_directive}"
with self.assertAddsMessages(
MessageTest(
@@ -386,7 +386,7 @@ class TestSpellingChecker(CheckerTestCase): # pylint:disable=too-many-public-me
spelling_dict=spell_dict,
spelling_ignore_comment_directives="newdirective:,noqa",
)
- def test_skip_directives_specified_in_pylintrc(self):
+ def test_skip_directives_specified_in_pylintrc(self) -> None:
full_comment = "# newdirective: do this newdirective"
with self.assertAddsMessages(
MessageTest(
diff --git a/tests/checkers/unittest_utils.py b/tests/checkers/unittest_utils.py
index f68a48dbb..187c38c6a 100644
--- a/tests/checkers/unittest_utils.py
+++ b/tests/checkers/unittest_utils.py
@@ -25,7 +25,7 @@ from pylint.checkers.base_checker import BaseChecker
("mybuiltin", False),
],
)
-def testIsBuiltin(name, expected):
+def testIsBuiltin(name: str, expected: bool) -> None:
assert utils.is_builtin(name) == expected
diff --git a/tests/config/test_find_default_config_files.py b/tests/config/test_find_default_config_files.py
index 10484be1d..2fd66544d 100644
--- a/tests/config/test_find_default_config_files.py
+++ b/tests/config/test_find_default_config_files.py
@@ -233,7 +233,7 @@ disable = logging-not-lazy,logging-format-interpolation
],
],
)
-def test_cfg_has_config(content: str, expected: str, tmp_path: Path) -> None:
+def test_cfg_has_config(content: str, expected: bool, tmp_path: Path) -> None:
"""Test that a cfg file has a pylint config."""
fake_cfg = tmp_path / "fake.cfg"
with open(fake_cfg, "w", encoding="utf8") as f:
diff --git a/tests/conftest.py b/tests/conftest.py
index a60cd0cb4..04fab5762 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -7,13 +7,16 @@
from __future__ import annotations
import os
+from collections.abc import Callable
from pathlib import Path
import pytest
from pylint import checkers
+from pylint.checkers import BaseChecker
from pylint.lint import PyLinter
from pylint.lint.run import _cpu_count
+from pylint.reporters import BaseReporter
from pylint.testutils import MinimalTestReporter
HERE = Path(__file__).parent
@@ -25,7 +28,13 @@ def tests_directory() -> Path:
@pytest.fixture
-def linter(checker, register, enable, disable, reporter):
+def linter(
+ checker: type[BaseChecker] | None,
+ register: Callable[[PyLinter], None],
+ enable: str | None,
+ disable: str | None,
+ reporter: type[BaseReporter],
+) -> PyLinter:
_linter = PyLinter()
_linter.set_reporter(reporter())
checkers.initialize(_linter)
@@ -44,27 +53,27 @@ def linter(checker, register, enable, disable, reporter):
@pytest.fixture(scope="module")
-def checker():
+def checker() -> None:
return None
@pytest.fixture(scope="module")
-def register():
+def register() -> None:
return None
@pytest.fixture(scope="module")
-def enable():
+def enable() -> None:
return None
@pytest.fixture(scope="module")
-def disable():
+def disable() -> None:
return None
@pytest.fixture(scope="module")
-def reporter():
+def reporter() -> type[MinimalTestReporter]:
return MinimalTestReporter
diff --git a/tests/extensions/test_check_docs_utils.py b/tests/extensions/test_check_docs_utils.py
index 3e70ffbfd..692c14859 100644
--- a/tests/extensions/test_check_docs_utils.py
+++ b/tests/extensions/test_check_docs_utils.py
@@ -3,8 +3,12 @@
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
"""Unit tests for utils functions in :mod:`pylint.extensions._check_docs_utils`."""
+
+from __future__ import annotations
+
import astroid
import pytest
+from astroid import nodes
from pylint.extensions import _check_docs_utils as utils
@@ -134,7 +138,7 @@ def test_space_indentation(string: str, count: int) -> None:
),
],
)
-def test_exception(raise_node, expected):
+def test_exception(raise_node: nodes.NodeNG, expected: set[str]) -> None:
found_nodes = utils.possible_exc_types(raise_node)
for node in found_nodes:
assert isinstance(node, astroid.nodes.ClassDef)
diff --git a/tests/lint/unittest_expand_modules.py b/tests/lint/unittest_expand_modules.py
index 6a3123aab..1883db543 100644
--- a/tests/lint/unittest_expand_modules.py
+++ b/tests/lint/unittest_expand_modules.py
@@ -12,7 +12,7 @@ import pytest
from pylint.checkers import BaseChecker
from pylint.lint.expand_modules import _is_in_ignore_list_re, expand_modules
from pylint.testutils import CheckerTestCase, set_config
-from pylint.typing import MessageDefinitionTuple
+from pylint.typing import MessageDefinitionTuple, ModuleDescriptionDict
def test__is_in_ignore_list_re_match() -> None:
@@ -117,7 +117,9 @@ class TestExpandModules(CheckerTestCase):
],
)
@set_config(ignore_paths="")
- def test_expand_modules(self, files_or_modules, expected):
+ def test_expand_modules(
+ self, files_or_modules: list[str], expected: list[ModuleDescriptionDict]
+ ) -> None:
"""Test expand_modules with the default value of ignore-paths."""
ignore_list: list[str] = []
ignore_list_re: list[re.Pattern[str]] = []
@@ -144,7 +146,9 @@ class TestExpandModules(CheckerTestCase):
],
)
@set_config(ignore_paths=".*/lint/.*")
- def test_expand_modules_with_ignore(self, files_or_modules, expected):
+ def test_expand_modules_with_ignore(
+ self, files_or_modules: list[str], expected: list[ModuleDescriptionDict]
+ ) -> None:
"""Test expand_modules with a non-default value of ignore-paths."""
ignore_list: list[str] = []
ignore_list_re: list[re.Pattern[str]] = []
diff --git a/tests/message/unittest_message_definition_store.py b/tests/message/unittest_message_definition_store.py
index 6a7914334..d36b1b42a 100644
--- a/tests/message/unittest_message_definition_store.py
+++ b/tests/message/unittest_message_definition_store.py
@@ -2,6 +2,8 @@
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+from __future__ import annotations
+
from contextlib import redirect_stdout
from io import StringIO
@@ -13,6 +15,7 @@ from pylint.exceptions import InvalidMessageError, UnknownMessageError
from pylint.lint.pylinter import PyLinter
from pylint.message import MessageDefinition
from pylint.message.message_definition_store import MessageDefinitionStore
+from pylint.typing import MessageDefinitionTuple
@pytest.mark.parametrize(
@@ -120,7 +123,11 @@ from pylint.message.message_definition_store import MessageDefinitionStore
),
],
)
-def test_register_error(empty_store, messages, expected):
+def test_register_error(
+ empty_store: MessageDefinitionStore,
+ messages: dict[str, MessageDefinitionTuple],
+ expected: str,
+) -> None:
class Checker(BaseChecker):
def __init__(self) -> None:
super().__init__(PyLinter())
diff --git a/tests/primer/test_primer_stdlib.py b/tests/primer/test_primer_stdlib.py
index 6cae6fd36..7496e67c8 100644
--- a/tests/primer/test_primer_stdlib.py
+++ b/tests/primer/test_primer_stdlib.py
@@ -2,10 +2,13 @@
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+from __future__ import annotations
+
import contextlib
import io
import os
import sys
+from collections.abc import Iterator
import pytest
from pytest import CaptureFixture
@@ -22,7 +25,7 @@ def is_package(filename: str, location: str) -> bool:
@contextlib.contextmanager
-def _patch_stdout(out):
+def _patch_stdout(out: io.StringIO) -> Iterator[None]:
sys.stdout = out
try:
yield
diff --git a/tests/profile/test_profile_against_externals.py b/tests/profile/test_profile_against_externals.py
index 579a5bc9c..7a429fad8 100644
--- a/tests/profile/test_profile_against_externals.py
+++ b/tests/profile/test_profile_against_externals.py
@@ -6,8 +6,11 @@
# pylint: disable=missing-function-docstring
+from __future__ import annotations
+
import os
import pprint
+from pathlib import Path
import pytest
@@ -15,10 +18,10 @@ from pylint.testutils import GenericTestReporter as Reporter
from pylint.testutils._run import _Run as Run
-def _get_py_files(scanpath):
+def _get_py_files(scanpath: str) -> list[str]:
assert os.path.exists(scanpath), f"Dir not found {scanpath}"
- filepaths = []
+ filepaths: list[str] = []
for dirpath, dirnames, filenames in os.walk(scanpath):
dirnames[:] = [dirname for dirname in dirnames if dirname != "__pycache__"]
filepaths.extend(
@@ -38,7 +41,7 @@ def _get_py_files(scanpath):
@pytest.mark.parametrize(
"name,git_repo", [("numpy", "https://github.com/numpy/numpy.git")]
)
-def test_run(tmp_path, name, git_repo):
+def test_run(tmp_path: Path, name: str, git_repo: str) -> None:
"""Runs pylint against external sources."""
checkoutdir = tmp_path / name
checkoutdir.mkdir()
diff --git a/tests/pyreverse/test_printer_factory.py b/tests/pyreverse/test_printer_factory.py
index 97ee1179c..76406f0a8 100644
--- a/tests/pyreverse/test_printer_factory.py
+++ b/tests/pyreverse/test_printer_factory.py
@@ -4,11 +4,14 @@
"""Unit tests for pylint.pyreverse.printer_factory."""
+from __future__ import annotations
+
import pytest
from pylint.pyreverse import printer_factory
from pylint.pyreverse.dot_printer import DotPrinter
from pylint.pyreverse.plantuml_printer import PlantUmlPrinter
+from pylint.pyreverse.printer import Printer
from pylint.pyreverse.vcg_printer import VCGPrinter
@@ -22,5 +25,7 @@ from pylint.pyreverse.vcg_printer import VCGPrinter
("png", DotPrinter),
],
)
-def test_get_printer_for_filetype(filetype, expected_printer_class):
+def test_get_printer_for_filetype(
+ filetype: str, expected_printer_class: type[Printer]
+) -> None:
assert printer_factory.get_printer_for_filetype(filetype) == expected_printer_class
diff --git a/tests/pyreverse/test_utils.py b/tests/pyreverse/test_utils.py
index adf7579b1..bedc5247f 100644
--- a/tests/pyreverse/test_utils.py
+++ b/tests/pyreverse/test_utils.py
@@ -4,6 +4,8 @@
"""Tests for pylint.pyreverse.utils."""
+from __future__ import annotations
+
from typing import Any
from unittest.mock import patch
@@ -31,7 +33,7 @@ from pylint.pyreverse.utils import (
),
],
)
-def test_get_visibility(names, expected):
+def test_get_visibility(names: list[str], expected: str) -> None:
for name in names:
got = get_visibility(name)
assert got == expected, f"got {got} instead of {expected} for value {name}"
@@ -46,7 +48,7 @@ def test_get_visibility(names, expected):
("a: Optional[str] = None", "Optional[str]"),
],
)
-def test_get_annotation_annassign(assign, label):
+def test_get_annotation_annassign(assign: str, label: str) -> None:
"""AnnAssign."""
node: nodes.AnnAssign = astroid.extract_node(assign)
annotation = get_annotation(node.value)
@@ -67,7 +69,7 @@ def test_get_annotation_annassign(assign, label):
("def __init__(self, x: Optional[str] = 'str'): self.x = x", "Optional[str]"),
],
)
-def test_get_annotation_assignattr(init_method, label):
+def test_get_annotation_assignattr(init_method: str, label: str) -> None:
"""AssignAttr."""
assign = rf"""
class A:
diff --git a/tests/pyreverse/test_writer.py b/tests/pyreverse/test_writer.py
index 383dac94d..805f8fab5 100644
--- a/tests/pyreverse/test_writer.py
+++ b/tests/pyreverse/test_writer.py
@@ -50,7 +50,7 @@ HTML_FILES = ["packages_No_Name.html", "classes_No_Name.html"]
class Config:
"""Config object for tests."""
- def __init__(self):
+ def __init__(self) -> None:
for attr, value in _DEFAULTS.items():
setattr(self, attr, value)
diff --git a/tests/reporters/unittest_json_reporter.py b/tests/reporters/unittest_json_reporter.py
index 90a67fceb..a4a3d65d3 100644
--- a/tests/reporters/unittest_json_reporter.py
+++ b/tests/reporters/unittest_json_reporter.py
@@ -131,7 +131,7 @@ def get_linter_result(score: bool, message: dict[str, Any]) -> list[dict[str, An
)
],
)
-def test_serialize_deserialize(message):
+def test_serialize_deserialize(message: Message) -> None:
# TODO: 3.0: Add confidence handling, add path and abs path handling or a new JSONReporter
json_message = JSONReporter.serialize(message)
assert message == JSONReporter.deserialize(json_message)
diff --git a/tests/reporters/unittest_reporting.py b/tests/reporters/unittest_reporting.py
index ea7d6758b..f08546679 100644
--- a/tests/reporters/unittest_reporting.py
+++ b/tests/reporters/unittest_reporting.py
@@ -11,9 +11,11 @@ import warnings
from contextlib import redirect_stdout
from io import StringIO
from json import dumps
-from typing import TYPE_CHECKING
+from pathlib import Path
+from typing import TYPE_CHECKING, TextIO
import pytest
+from _pytest.recwarn import WarningsRecorder
from pylint import checkers
from pylint.lint import PyLinter
@@ -26,12 +28,12 @@ if TYPE_CHECKING:
@pytest.fixture(scope="module")
-def reporter():
+def reporter() -> type[TextReporter]:
return TextReporter
@pytest.fixture(scope="module")
-def disable():
+def disable() -> list[str]:
return ["I"]
@@ -111,7 +113,7 @@ def test_template_option_non_existing(linter: PyLinter) -> None:
assert out_lines[2] == "my_mod:2::()"
-def test_deprecation_set_output(recwarn):
+def test_deprecation_set_output(recwarn: WarningsRecorder) -> None:
"""TODO remove in 3.0."""
reporter = BaseReporter()
# noinspection PyDeprecation
@@ -121,7 +123,7 @@ def test_deprecation_set_output(recwarn):
assert reporter.out == sys.stdout
-def test_parseable_output_deprecated():
+def test_parseable_output_deprecated() -> None:
with warnings.catch_warnings(record=True) as cm:
warnings.simplefilter("always")
ParseableTextReporter()
@@ -130,7 +132,7 @@ def test_parseable_output_deprecated():
assert isinstance(cm[0].message, DeprecationWarning)
-def test_parseable_output_regression():
+def test_parseable_output_regression() -> None:
output = StringIO()
with warnings.catch_warnings(record=True):
linter = PyLinter(reporter=ParseableTextReporter())
@@ -153,18 +155,18 @@ class NopReporter(BaseReporter):
name = "nop-reporter"
extension = ""
- def __init__(self, output=None):
+ def __init__(self, output: TextIO | None = None) -> None:
super().__init__(output)
print("A NopReporter was initialized.", file=self.out)
- def writeln(self, string=""):
+ def writeln(self, string: str = "") -> None:
pass
def _display(self, layout: Section) -> None:
pass
-def test_multi_format_output(tmp_path):
+def test_multi_format_output(tmp_path: Path) -> None:
text = StringIO(newline=None)
json = tmp_path / "somefile.json"
@@ -189,7 +191,9 @@ def test_multi_format_output(tmp_path):
linter.reporter.out = text
linter.open()
- linter.check_single_file_item(FileItem("somemodule", source_file, "somemodule"))
+ linter.check_single_file_item(
+ FileItem("somemodule", str(source_file), "somemodule")
+ )
linter.add_message("line-too-long", line=1, args=(1, 2))
linter.generate_reports()
linter.reporter.writeln("direct output")
@@ -330,7 +334,7 @@ def test_multi_format_output(tmp_path):
)
-def test_display_results_is_renamed():
+def test_display_results_is_renamed() -> None:
class CustomReporter(TextReporter):
def _display(self, layout: Section) -> None:
return None
diff --git a/tests/test_check_parallel.py b/tests/test_check_parallel.py
index 3b6d82e04..0c872ff8d 100644
--- a/tests/test_check_parallel.py
+++ b/tests/test_check_parallel.py
@@ -109,7 +109,7 @@ class ParallelTestChecker(BaseRawFileChecker):
for _ in self.data[1::2]: # Work on pairs of files, see class docstring.
self.add_message("R9999", args=("From process_module, two files seen.",))
- def get_map_data(self):
+ def get_map_data(self) -> list[str]:
return self.data
def reduce_map_data(self, linter: PyLinter, data: list[list[str]]) -> None:
@@ -160,10 +160,10 @@ class ThirdParallelTestChecker(ParallelTestChecker):
class TestCheckParallelFramework:
"""Tests the check_parallel() function's framework."""
- def setup_class(self):
+ def setup_class(self) -> None:
self._prev_global_linter = pylint.lint.parallel._worker_linter
- def teardown_class(self):
+ def teardown_class(self) -> None:
pylint.lint.parallel._worker_linter = self._prev_global_linter
def test_worker_initialize(self) -> None:
@@ -411,7 +411,9 @@ class TestCheckParallel:
(10, 2, 3),
],
)
- def test_compare_workers_to_single_proc(self, num_files, num_jobs, num_checkers):
+ def test_compare_workers_to_single_proc(
+ self, num_files: int, num_jobs: int, num_checkers: int
+ ) -> None:
"""Compares the 3 key parameters for check_parallel() produces the same results.
The intent here is to ensure that the check_parallel() operates on each file,
@@ -508,7 +510,7 @@ class TestCheckParallel:
(10, 2, 3),
],
)
- def test_map_reduce(self, num_files, num_jobs, num_checkers):
+ def test_map_reduce(self, num_files: int, num_jobs: int, num_checkers: int) -> None:
"""Compares the 3 key parameters for check_parallel() produces the same results.
The intent here is to validate the reduce step: no stats should be lost.
diff --git a/tests/test_func.py b/tests/test_func.py
index 528019692..493489aee 100644
--- a/tests/test_func.py
+++ b/tests/test_func.py
@@ -94,7 +94,7 @@ class LintTestUsingModule:
class LintTestUpdate(LintTestUsingModule):
- def _check_result(self, got):
+ def _check_result(self, got: str) -> None:
if not self._has_output():
return
try:
diff --git a/tests/test_numversion.py b/tests/test_numversion.py
index 1bfb451da..2c34c1aa3 100644
--- a/tests/test_numversion.py
+++ b/tests/test_numversion.py
@@ -2,6 +2,8 @@
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
+from __future__ import annotations
+
import pytest
from pylint.__pkginfo__ import get_numversion_from_version
@@ -23,5 +25,5 @@ from pylint.__pkginfo__ import get_numversion_from_version
["2.8.3.dev3+g28c093c2.d20210428", (2, 8, 3)],
],
)
-def test_numversion(version, expected_numversion):
+def test_numversion(version: str, expected_numversion: tuple[int, int, int]) -> None:
assert get_numversion_from_version(version) == expected_numversion
diff --git a/tests/test_self.py b/tests/test_self.py
index a375ae6f5..873bd2344 100644
--- a/tests/test_self.py
+++ b/tests/test_self.py
@@ -140,7 +140,7 @@ class TestRunTC:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
Run(args, reporter=reporter)
- return cm.value.code
+ return int(cm.value.code)
@staticmethod
def _clean_paths(output: str) -> str:
diff --git a/tests/test_similar.py b/tests/test_similar.py
index d59602ff6..f054d7473 100644
--- a/tests/test_similar.py
+++ b/tests/test_similar.py
@@ -48,7 +48,7 @@ class TestSimilarCodeChecker:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
Run(args)
- return cm.value.code
+ return int(cm.value.code)
@staticmethod
def _clean_paths(output: str) -> str:
diff --git a/tests/utils/unittest_ast_walker.py b/tests/utils/unittest_ast_walker.py
index 43614c0ed..5a2dc6609 100644
--- a/tests/utils/unittest_ast_walker.py
+++ b/tests/utils/unittest_ast_walker.py
@@ -7,6 +7,7 @@ from __future__ import annotations
import warnings
import astroid
+from astroid import nodes
from pylint.checkers.base_checker import BaseChecker
from pylint.checkers.utils import only_required_for_messages
@@ -27,19 +28,23 @@ class TestASTWalker:
self.called: set[str] = set()
@only_required_for_messages("first-message")
- def visit_module(self, module): # pylint: disable=unused-argument
+ def visit_module(
+ self, module: nodes.Module # pylint: disable=unused-argument
+ ) -> None:
self.called.add("module")
@only_required_for_messages("second-message")
- def visit_call(self, module):
+ def visit_call(self, module: nodes.Call) -> None:
raise NotImplementedError
@only_required_for_messages("second-message", "third-message")
- def visit_assignname(self, module): # pylint: disable=unused-argument
+ def visit_assignname(
+ self, module: nodes.AssignName # pylint: disable=unused-argument
+ ) -> None:
self.called.add("assignname")
@only_required_for_messages("second-message")
- def leave_assignname(self, module):
+ def leave_assignname(self, module: nodes.AssignName) -> None:
raise NotImplementedError
def test_only_required_for_messages(self) -> None:
@@ -59,7 +64,9 @@ class TestASTWalker:
self.called = False
@only_required_for_messages("first-message")
- def visit_assname(self, node): # pylint: disable=unused-argument
+ def visit_assname(
+ self, node: nodes.AssignName # pylint: disable=unused-argument
+ ) -> None:
self.called = True
linter = self.MockLinter({"first-message": True})