Import Iterable and Iterator depending on Python version

libkeyringctl/{keyring,sequoia,util}.py:
As Iterable and Iterator are only used for type hints, switch to using
typing.{Iterable,Iterator} instead of
collections.abc.{Iterable,Iterator} for Python < 3.9.0, as older Python
interpreters will otherwise raise TypeError.
This commit is contained in:
David Runge 2022-04-14 15:41:08 +02:00
parent 67d898d12f
commit 29dc5d228d
No known key found for this signature in database
GPG Key ID: 7258734B41C31549
3 changed files with 23 additions and 4 deletions

View File

@ -1,16 +1,22 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from collections import defaultdict
from collections.abc import Iterable
from itertools import chain
from logging import debug
from logging import error
from pathlib import Path
from platform import python_version_tuple
from re import match
from shutil import copytree
from tempfile import NamedTemporaryFile
from tempfile import mkdtemp
from typing import Dict
# NOTE: remove after python 3.8.x is no longer supported upstream
if int(python_version_tuple()[1]) < 9: # pragma: no cover
from typing import Iterable
else:
from collections.abc import Iterable
from typing import List
from typing import Optional
from typing import Set

View File

@ -1,12 +1,18 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from collections.abc import Iterable
from datetime import datetime
from functools import reduce
from pathlib import Path
from platform import python_version_tuple
from re import sub
from tempfile import mkdtemp
from typing import Dict
# NOTE: remove after python 3.8.x is no longer supported upstream
if int(python_version_tuple()[1]) < 9: # pragma: no cover
from typing import Iterable
else:
from collections.abc import Iterable
from typing import List
from typing import Optional

View File

@ -1,12 +1,11 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from collections.abc import Iterable
from collections.abc import Iterator
from contextlib import contextmanager
from hashlib import sha256
from os import chdir
from os import environ
from os import getcwd
from pathlib import Path
from platform import python_version_tuple
from re import escape
from re import split
from re import sub
@ -22,6 +21,14 @@ from traceback import print_stack
from typing import IO
from typing import AnyStr
from typing import Dict
# NOTE: remove after python 3.8.x is no longer supported upstream
if int(python_version_tuple()[1]) < 9: # pragma: no cover
from typing import Iterable
from typing import Iterator
else:
from collections.abc import Iterable
from collections.abc import Iterator
from typing import List
from typing import Optional
from typing import Set