8000 Allow Fire to serialize empty dictionaries (#5) · tywin1104/python-fire@59d9095 · GitHub
[go: up one dir, main page]

Skip to content

Commit 59d9095

Browse files
ubershmekeldbieber
authored andcommitted
Allow Fire to serialize empty dictionaries (google#5)
* Fix for empty dictionary print outs This should handle google#4 * pep8 prefers `if not seq` over `len == 0` * Use single quotes
1 parent f8ad6b7 commit 59d9095

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fire/core.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ def _DictAsString(result, verbose=False):
193193
Returns:
194194
A string representing the dict
195195
"""
196+
if not result:
197+
return '{}'
198+
196199
longest_key = max(
197200
len(str(key)) for key in result.keys()
198201
if _ComponentVisible(key, verbose)

0 commit comments

Comments
 (0)
0