@@ -80,16 +80,16 @@ def value_to_string(
8080 >>> value_to_string("invalid", mapping={"mean": "a", "mad": "d", "full": "g"})
8181 'invalid'
8282 """
83- # None or False means the parameter is not specified, returns None .
83+ # Return None if the value is None or False .
8484 if value is None or value is False :
8585 return None
86- # True means the parameter is specified, returns an empty string with the optional
87- # prefix. We don't have to check 'prefix' since it defaults to an empty string!
86+ # Return an empty string if the value is True. We don't have to check 'prefix' since
87+ # it defaults to an empty string!
8888 if value is True :
8989 return f"{ prefix } "
9090
9191 # Convert any value to a string or a sequence of strings.
92- if is_nonstr_iter (value ): # Is a sequence
92+ if is_nonstr_iter (value ): # Is a sequence.
9393 value = [str (item ) for item in value ] # Convert to a sequence of strings
9494 if separator is None :
9595 # A sequence is given but separator is not specified. In this case, return
@@ -99,6 +99,7 @@ def value_to_string(
9999 value = separator .join (value ) # Join the sequence with the separator.
100100 elif mapping : # Mapping long-form arguments to short-form arguments.
101101 value = value [0 ] if mapping is True else mapping .get (value , value )
102+ # Return the final string with the optional prefix.
102103 return f"{ prefix } { value } "
103104
104105
0 commit comments