ensure_list validator - Allow None to return an empty list (#5133)

This commit is contained in:
Johann Kellerman 2017-01-05 21:33:22 +02:00 committed by GitHub
parent cb85128304
commit cbda516af9
2 changed files with 62 additions and 36 deletions

View file

@ -85,6 +85,8 @@ def isfile(value: Any) -> str:
def ensure_list(value: Union[T, Sequence[T]]) -> Sequence[T]:
"""Wrap value in list if it is not one."""
if value is None:
return []
return value if isinstance(value, list) else [value]