summaryrefslogtreecommitdiff
path: root/mdbp
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2021-07-10 08:09:42 +0200
committerHelmut Grohne <helmut@subdivi.de>2021-07-10 14:28:13 +0200
commitcd3ccf289dff2d75bf91fa969bc691159eb6581f (patch)
tree7e7afd7fb53cebf666a70c57e9cf0b08f3c6f9fe /mdbp
parent18617835be3b4e9604082056e6117df2b11599c0 (diff)
downloadmdbp-cd3ccf289dff2d75bf91fa969bc691159eb6581f.tar.gz
stop using from __future__ import annotations
Its future in Python upstream sees uncertain.
Diffstat (limited to 'mdbp')
-rw-r--r--mdbp/common.py11
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,