diff options
author | David Robertson <davidr@element.io> | 2022-06-11 21:32:15 +0100 |
---|---|---|
committer | David Robertson <davidr@element.io> | 2022-06-11 21:45:17 +0100 |
commit | 436081dfcd722b24abf75970a04a6c456930d6c4 (patch) | |
tree | 4fb5297b4bf00c642cc976ed07062e6950872e7e | |
parent | tests.util.rw_lock (diff) | |
download | synapse-436081dfcd722b24abf75970a04a6c456930d6c4.tar.xz |
test.util.test_check_dependencies
-rw-r--r-- | tests/util/test_check_dependencies.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/util/test_check_dependencies.py b/tests/util/test_check_dependencies.py index 5d1aa025d1..813a290ff4 100644 --- a/tests/util/test_check_dependencies.py +++ b/tests/util/test_check_dependencies.py @@ -1,5 +1,5 @@ from contextlib import contextmanager -from typing import Generator, Optional +from typing import Generator, NoReturn, Optional from unittest.mock import patch from synapse.util.check_dependencies import ( @@ -12,17 +12,19 @@ from tests.unittest import TestCase class DummyDistribution(metadata.Distribution): - def __init__(self, version: object): + def __init__(self, version: Optional[str]): self._version = version + # Type-ignore: This really can return None. More context here: + # https://github.com/python/importlib_metadata/issues/371 @property - def version(self): + def version(self) -> Optional[str]: # type: ignore[override] return self._version - def locate_file(self, path): + def locate_file(self, path: object) -> NoReturn: raise NotImplementedError() - def read_text(self, filename): + def read_text(self, filename: object) -> NoReturn: raise NotImplementedError() @@ -42,7 +44,7 @@ class TestDependencyChecker(TestCase): ) -> Generator[None, None, None]: """Pretend that looking up any distribution yields the given `distribution`.""" - def mock_distribution(name: str): + def mock_distribution(name: str) -> DummyDistribution: if distribution is None: raise metadata.PackageNotFoundError else: |