1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-03-12 04:58:34 +03:00

Some more func documentation and small fixes

This commit is contained in:
Adolfo Gómez García 2024-04-15 21:21:36 +02:00
parent a5bfec3aa9
commit 229962cbd2
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
2 changed files with 13 additions and 2 deletions

View File

@ -33,6 +33,18 @@ import collections.abc
def is_list(obj: typing.Any) -> list[typing.Any]:
"""
Checks if the given object is a list or can be converted into a list.
Args:
obj (Any): The object to check.
Returns:
list[Any]: If the object is a list, it is returned as is.
If the object is a string or bytes, it is wrapped in a list and returned.
If the object is not iterable, a list containing the object is returned.
"""
if not obj:
return []
@ -55,7 +67,7 @@ def is_iterable(obj: typing.Any) -> typing.Generator[typing.Any, None, None]:
typing.Generator[T, None, None]: Iterable object
Yields:
Iterator[typing.Generator[T, None, None]]: Iterator of the object
Iterator[typing.Generator[T, None, None]]: The object itself or the objects as iterated
"""
if not obj:
return

View File

@ -30,7 +30,6 @@
@author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import typing
import collections.abc
import logging