summaryrefslogtreecommitdiff
path: root/tests/pyreverse
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2022-04-14 19:37:49 +0200
committerGitHub <noreply@github.com>2022-04-14 19:37:49 +0200
commit8f872bf49c344d1d16b3573136d53b2cbda007c6 (patch)
treed203652d9d515b2a5d47cca6e1f7519a157d5990 /tests/pyreverse
parentadf660a7300148a31cdb8bc25301bfd21af0602b (diff)
downloadpylint-git-8f872bf49c344d1d16b3573136d53b2cbda007c6.tar.gz
Use ``python-typing-update`` on half of the ``tests`` directory (#6317)
Diffstat (limited to 'tests/pyreverse')
-rw-r--r--tests/pyreverse/conftest.py6
-rw-r--r--tests/pyreverse/test_diadefs.py12
-rw-r--r--tests/pyreverse/test_diagrams.py5
-rw-r--r--tests/pyreverse/test_inspector.py5
-rw-r--r--tests/pyreverse/test_main.py6
-rw-r--r--tests/pyreverse/test_printer.py6
-rw-r--r--tests/pyreverse/test_writer.py5
7 files changed, 31 insertions, 14 deletions
diff --git a/tests/pyreverse/conftest.py b/tests/pyreverse/conftest.py
index 52b919883..d8b6ea9f4 100644
--- a/tests/pyreverse/conftest.py
+++ b/tests/pyreverse/conftest.py
@@ -2,7 +2,9 @@
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
-from typing import Callable, Optional
+from __future__ import annotations
+
+from collections.abc import Callable
import pytest
from astroid.nodes.scoped_nodes import Module
@@ -65,7 +67,7 @@ def html_config() -> PyreverseConfig:
@pytest.fixture(scope="session")
def get_project() -> Callable:
- def _get_project(module: str, name: Optional[str] = "No Name") -> Project:
+ def _get_project(module: str, name: str | None = "No Name") -> Project:
"""Return an astroid project representation."""
def _astroid_wrapper(func: Callable, modname: str) -> Module:
diff --git a/tests/pyreverse/test_diadefs.py b/tests/pyreverse/test_diadefs.py
index ecb601b0c..059f756bc 100644
--- a/tests/pyreverse/test_diadefs.py
+++ b/tests/pyreverse/test_diadefs.py
@@ -3,10 +3,14 @@
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
"""Unit test for the extensions.diadefslib modules."""
+
# pylint: disable=redefined-outer-name
+
+from __future__ import annotations
+
import sys
+from collections.abc import Callable
from pathlib import Path
-from typing import Callable, Dict, List, Tuple
import pytest
from astroid import nodes
@@ -22,14 +26,14 @@ from pylint.pyreverse.inspector import Linker, Project
from pylint.testutils.pyreverse import PyreverseConfig
-def _process_classes(classes: List[DiagramEntity]) -> List[Tuple[bool, str]]:
+def _process_classes(classes: list[DiagramEntity]) -> list[tuple[bool, str]]:
"""Extract class names of a list."""
return sorted((isinstance(c.node, nodes.ClassDef), c.title) for c in classes)
def _process_relations(
- relations: Dict[str, List[Relationship]]
-) -> List[Tuple[str, str, str]]:
+ relations: dict[str, list[Relationship]]
+) -> list[tuple[str, str, str]]:
"""Extract relation indices from a relation list."""
result = []
for rel_type, rels in relations.items():
diff --git a/tests/pyreverse/test_diagrams.py b/tests/pyreverse/test_diagrams.py
index f10af571d..b4a59a571 100644
--- a/tests/pyreverse/test_diagrams.py
+++ b/tests/pyreverse/test_diagrams.py
@@ -3,7 +3,10 @@
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
"""Unit test for the diagrams modules."""
-from typing import Callable
+
+from __future__ import annotations
+
+from collections.abc import Callable
from pylint.pyreverse.diadefslib import DefaultDiadefGenerator, DiadefsHandler
from pylint.pyreverse.inspector import Linker
diff --git a/tests/pyreverse/test_inspector.py b/tests/pyreverse/test_inspector.py
index 8f053c148..db0f4656a 100644
--- a/tests/pyreverse/test_inspector.py
+++ b/tests/pyreverse/test_inspector.py
@@ -3,10 +3,13 @@
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
"""For the visitors.diadefs module."""
+
# pylint: disable=redefined-outer-name
+from __future__ import annotations
+
import os
-from typing import Callable
+from collections.abc import Callable
import astroid
import pytest
diff --git a/tests/pyreverse/test_main.py b/tests/pyreverse/test_main.py
index 072542c3a..b5ea3fda9 100644
--- a/tests/pyreverse/test_main.py
+++ b/tests/pyreverse/test_main.py
@@ -3,9 +3,13 @@
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
"""Unittest for the main module."""
+
+from __future__ import annotations
+
import os
import sys
-from typing import Any, Iterator
+from collections.abc import Iterator
+from typing import Any
from unittest import mock
import pytest
diff --git a/tests/pyreverse/test_printer.py b/tests/pyreverse/test_printer.py
index 9128fc6dd..3822383db 100644
--- a/tests/pyreverse/test_printer.py
+++ b/tests/pyreverse/test_printer.py
@@ -2,7 +2,7 @@
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
-from typing import Type
+from __future__ import annotations
import pytest
from astroid import nodes
@@ -29,7 +29,7 @@ from pylint.pyreverse.vcg_printer import VCGPrinter
],
)
def test_explicit_layout(
- layout: Layout, printer_class: Type[Printer], expected_content: str, line_index: int
+ layout: Layout, printer_class: type[Printer], expected_content: str, line_index: int
) -> None:
printer = printer_class(title="unittest", layout=layout)
assert printer.lines[line_index].strip() == expected_content
@@ -39,7 +39,7 @@ def test_explicit_layout(
"layout, printer_class",
[(Layout.BOTTOM_TO_TOP, PlantUmlPrinter), (Layout.RIGHT_TO_LEFT, PlantUmlPrinter)],
)
-def test_unsupported_layout(layout: Layout, printer_class: Type[Printer]):
+def test_unsupported_layout(layout: Layout, printer_class: type[Printer]):
with pytest.raises(ValueError):
printer_class(title="unittest", layout=layout)
diff --git a/tests/pyreverse/test_writer.py b/tests/pyreverse/test_writer.py
index d3b2d8f44..a03105092 100644
--- a/tests/pyreverse/test_writer.py
+++ b/tests/pyreverse/test_writer.py
@@ -4,11 +4,12 @@
"""Unit test for ``DiagramWriter``."""
+from __future__ import annotations
import codecs
import os
+from collections.abc import Callable, Iterator
from difflib import unified_diff
-from typing import Callable, Iterator, List
from unittest.mock import Mock
import pytest
@@ -53,7 +54,7 @@ class Config:
setattr(self, attr, value)
-def _file_lines(path: str) -> List[str]:
+def _file_lines(path: str) -> list[str]:
# we don't care about the actual encoding, but python3 forces us to pick one
with codecs.open(path, encoding="latin1") as stream:
lines = [