diff options
Diffstat (limited to 'mdbp/common.py')
-rw-r--r-- | mdbp/common.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/mdbp/common.py b/mdbp/common.py index e4f4792..c2be081 100644 --- a/mdbp/common.py +++ b/mdbp/common.py @@ -1,7 +1,6 @@ # SPDX-License-Identifier: MIT """Common functions used by multiple backends""" -from __future__ import annotations import argparse import contextlib import fnmatch @@ -23,6 +22,12 @@ try: except ImportError: jsonschema = None +if typing.TYPE_CHECKING: + # pylint: disable=E1101,W0212 + Hash = hashlib._Hash +else: + Hash = typing.Any + def json_load(filecontextmanager: typing.ContextManager[typing.IO[typing.AnyStr]]) -> typing.Any: """Load the json context from a file context manager.""" @@ -83,9 +88,7 @@ def compute_env(build: JsonObject) -> typing.Dict[str, str]: class HashSumMismatch(Exception): """Raised from `hash_check` when validation fails.""" -# pylint does not grok from __future__ import annotations yet -# pylint: disable=E1101,W0212 -def hash_check(iterable: typing.Iterable[bytes], hashobj: hashlib._Hash, +def hash_check(iterable: typing.Iterable[bytes], hashobj: Hash, expected_digest: str) -> \ typing.Iterator[bytes]: """Wraps an iterable that yields bytes. It doesn't modify the sequence, |