summaryrefslogtreecommitdiff
path: root/doc/test_messages_documentation.py
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2023-02-12 12:39:21 +0100
committerGitHub <noreply@github.com>2023-02-12 12:39:21 +0100
commit81ed650d4655f65231d9caa0056dc92b0fcc257d (patch)
treed60890107d1304a9e8099a4d97e729b26d7b8ff7 /doc/test_messages_documentation.py
parenta0b28f9019fabddd8ef428be75659082377abb4c (diff)
downloadpylint-git-81ed650d4655f65231d9caa0056dc92b0fcc257d.tar.gz
[typing] Use __future__ annotations where possible (#8264)
Diffstat (limited to 'doc/test_messages_documentation.py')
-rw-r--r--doc/test_messages_documentation.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/doc/test_messages_documentation.py b/doc/test_messages_documentation.py
index 663fa3aab..fad79256b 100644
--- a/doc/test_messages_documentation.py
+++ b/doc/test_messages_documentation.py
@@ -4,6 +4,8 @@
"""Functional tests for the code examples in the messages' documentation."""
+from __future__ import annotations
+
import sys
if sys.version_info[:2] > (3, 9):
@@ -18,7 +20,7 @@ else:
from pathlib import Path
from typing import Counter as CounterType
-from typing import List, Optional, TextIO, Tuple
+from typing import TextIO, Tuple
import pytest
@@ -32,12 +34,12 @@ from pylint.testutils.reporter_for_tests import FunctionalTestReporter
MessageCounter = CounterType[Tuple[int, str]]
-def get_functional_test_files_from_directory(input_dir: Path) -> List[Tuple[str, Path]]:
+def get_functional_test_files_from_directory(input_dir: Path) -> list[tuple[str, Path]]:
"""Get all functional tests in the input_dir.
This also checks the formatting of related.rst files.
"""
- suite: List[Tuple[str, Path]] = []
+ suite: list[tuple[str, Path]] = []
for subdirectory in input_dir.iterdir():
for message_dir in subdirectory.iterdir():
@@ -69,7 +71,7 @@ TESTS_NAMES = [f"{t[0]}-{t[1].stem}" for t in TESTS]
class LintModuleTest:
- def __init__(self, test_file: Tuple[str, Path]) -> None:
+ def __init__(self, test_file: tuple[str, Path]) -> None:
self._test_file = test_file
_test_reporter = FunctionalTestReporter()
@@ -80,7 +82,7 @@ class LintModuleTest:
# Check if this message has a custom configuration file (e.g. for enabling optional checkers).
# If not, use the default configuration.
- config_file: Optional[Path]
+ config_file: Path | None
msgid, full_path = test_file
pylintrc = full_path.parent / "pylintrc"
config_file = pylintrc if pylintrc.exists() else None
@@ -136,7 +138,7 @@ class LintModuleTest:
def _get_actual(self) -> MessageCounter:
"""Get the actual messages after a run."""
- messages: List[Message] = self._linter.reporter.messages
+ messages: list[Message] = self._linter.reporter.messages
messages.sort(key=lambda m: (m.line, m.symbol, m.msg))
received_msgs: MessageCounter = Counter()
for msg in messages:
@@ -176,6 +178,6 @@ See:
@pytest.mark.parametrize("test_file", TESTS, ids=TESTS_NAMES)
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
-def test_code_examples(test_file: Tuple[str, Path]) -> None:
+def test_code_examples(test_file: tuple[str, Path]) -> None:
lint_test = LintModuleTest(test_file)
lint_test.runTest()