mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
d02237ea5e
Importing from `collection` has been deprecated for a while now.
20 lines
458 B
Python
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,)
|