Skip to content

Commit 13c0c2e

Browse files
committed
Ensure we have a case scenario for None values
1 parent 99a28f3 commit 13c0c2e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

environment_manager/utils.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ def critical(self, message):
9292

9393
def to_bool(value):
9494
"""Converts 'something' to boolean. Raises exception for invalid formats
95-
Possible True values: 1, True, "1", "TRue", "yes", "y", "t"
96-
Possible False values: 0, False, None, [], {}, "", "0", "faLse", "no", "n", "f", 0.0, ..."""
95+
Possible True values: 1, True, "1", "TRue", "yes", "y", "t"
96+
Possible False values: 0, False, None, [], {}, "", "0", "faLse", "no", "n", "f", 0.0, ..."""
97+
if value is None:
98+
return False
9799
if str(value).lower() in ("yes", "y", "true", "t", "1"):
98100
return True
99101
if str(value).lower() in ("no", "n", "false", "f", "0", "0.0", "", "none", "[]", "{}"):
@@ -102,11 +104,15 @@ def to_bool(value):
102104

103105
def to_list(value):
104106
""" Create an array from any kind of object """
107+
if value is None:
108+
return []
105109
initial_list = [x.strip() for x in value.translate(None, '!@#$[]{}\'"').split(',')]
106110
return [x for x in initial_list if x]
107111

108112
def to_dict(value):
109113
""" Create a dictionary from any kind of incoming object """
114+
if value is None:
115+
return {}
110116
if isinstance(value, dict):
111117
myreturn = value
112118
else:

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from setuptools import setup
33

44
setup(name='environment_manager',
5-
version='0.2.13',
5+
version='0.2.14',
66
description="A Client library for Environment Manager",
77
url="https://github.com/trainline/python-environment_manager",
88
author="Trainline Engineering",

0 commit comments

Comments
 (0)