From cd3ccf289dff2d75bf91fa969bc691159eb6581f Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Sat, 10 Jul 2021 08:09:42 +0200 Subject: stop using from __future__ import annotations Its future in Python upstream sees uncertain. --- mdbp/common.py | 11 +++++++---- 1 file 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, -- cgit v1.2.3