Files
revng-revng/python/revng/support/__init__.py
T
Davide Depau d02237ea5e python: import CIterable from collections.abc
Importing from `collection` has been deprecated for a while now.
2022-07-05 10:31:36 +02:00

20 lines
458 B
Python

#
# This file is distributed under the MIT License. See LICENSE.md for details.
#
from collections.abc import Iterable as CIterable
from pathlib import Path
from typing import Iterable, TypeVar, Union
T = TypeVar("T")
SingleOrIterable = Union[T, Iterable[T]]
AnyPath = Union[str, Path]
AnyPaths = SingleOrIterable[AnyPath]
def to_iterable(obj: SingleOrIterable[T]) -> Iterable[T]:
if isinstance(obj, CIterable):
return obj
return (obj,)