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:
parent
67d898d12f
commit
29dc5d228d
@ -1,16 +1,22 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from collections.abc import Iterable
|
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
from logging import debug
|
from logging import debug
|
||||||
from logging import error
|
from logging import error
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from platform import python_version_tuple
|
||||||
from re import match
|
from re import match
|
||||||
from shutil import copytree
|
from shutil import copytree
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
from tempfile import mkdtemp
|
from tempfile import mkdtemp
|
||||||
from typing import Dict
|
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 List
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from typing import Set
|
from typing import Set
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from collections.abc import Iterable
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from platform import python_version_tuple
|
||||||
from re import sub
|
from re import sub
|
||||||
from tempfile import mkdtemp
|
from tempfile import mkdtemp
|
||||||
from typing import Dict
|
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 List
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
from collections.abc import Iterable
|
|
||||||
from collections.abc import Iterator
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from os import chdir
|
from os import chdir
|
||||||
from os import environ
|
from os import environ
|
||||||
from os import getcwd
|
from os import getcwd
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from platform import python_version_tuple
|
||||||
from re import escape
|
from re import escape
|
||||||
from re import split
|
from re import split
|
||||||
from re import sub
|
from re import sub
|
||||||
@ -22,6 +21,14 @@ from traceback import print_stack
|
|||||||
from typing import IO
|
from typing import IO
|
||||||
from typing import AnyStr
|
from typing import AnyStr
|
||||||
from typing import Dict
|
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 List
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from typing import Set
|
from typing import Set
|
||||||
|
Loading…
Reference in New Issue
Block a user