diff options
| author | Adam Turner <9087854+aa-turner@users.noreply.github.com> | 2022-12-30 21:13:29 +0000 |
|---|---|---|
| committer | Adam Turner <9087854+aa-turner@users.noreply.github.com> | 2023-01-01 20:48:38 +0000 |
| commit | 26f79b0d2dd88b353ac65623897bdfbe8bc07cab (patch) | |
| tree | 0d2f0c752cf1f49a45cde1d7f414d75a6114f1ce /sphinx/testing/comparer.py | |
| parent | f4c8a0a68e0013808d169357c9f77ebdf19d0f4e (diff) | |
| download | sphinx-git-26f79b0d2dd88b353ac65623897bdfbe8bc07cab.tar.gz | |
Use PEP 595 types
Diffstat (limited to 'sphinx/testing/comparer.py')
| -rw-r--r-- | sphinx/testing/comparer.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sphinx/testing/comparer.py b/sphinx/testing/comparer.py index 142d15348..72494ae5a 100644 --- a/sphinx/testing/comparer.py +++ b/sphinx/testing/comparer.py @@ -3,7 +3,7 @@ from __future__ import annotations import difflib import pathlib -from typing import Any, List, Union +from typing import Any, Union class PathComparer: @@ -41,7 +41,7 @@ class PathComparer: def __eq__(self, other: Union[str, pathlib.Path]) -> bool: # type: ignore return not bool(self.ldiff(other)) - def diff(self, other: Union[str, pathlib.Path]) -> List[str]: + def diff(self, other: Union[str, pathlib.Path]) -> list[str]: """compare self and other. When different is not exist, return empty list. @@ -60,19 +60,19 @@ class PathComparer: """ return self.ldiff(other) - def ldiff(self, other: Union[str, pathlib.Path]) -> List[str]: + def ldiff(self, other: Union[str, pathlib.Path]) -> list[str]: return self._diff( self.path, pathlib.Path(other), ) - def rdiff(self, other: Union[str, pathlib.Path]) -> List[str]: + def rdiff(self, other: Union[str, pathlib.Path]) -> list[str]: return self._diff( pathlib.Path(other), self.path, ) - def _diff(self, lhs: pathlib.Path, rhs: pathlib.Path) -> List[str]: + def _diff(self, lhs: pathlib.Path, rhs: pathlib.Path) -> list[str]: if lhs == rhs: return [] @@ -88,7 +88,7 @@ class PathComparer: return [line.strip() for line in difflib.Differ().compare([s_path], [o_path])] -def pytest_assertrepr_compare(op: str, left: Any, right: Any) -> List[str]: +def pytest_assertrepr_compare(op: str, left: Any, right: Any) -> list[str]: if isinstance(left, PathComparer) and op == "==": return ['Comparing path:'] + left.ldiff(right) elif isinstance(right, PathComparer) and op == "==": |
