Skip to content

Commit f97a396

Browse files
committed
set_str & remove useless defaults
Signed-off-by: Alexey Stepanov <penguinolog@gmail.com>
1 parent 7195b57 commit f97a396

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ Object signature:
143143
144144
def __init__(
145145
self,
146-
simple_formatters=None, # Will be used to repr not complex. Keys is data types and 'default'.
147-
complex_formatters=None, # Currently only legacy pretty_repr formatters is supported, will be extended in the future
146+
simple_formatters, # Will be used to repr not complex. Keys is data types and 'default'.
147+
complex_formatters, # Currently only legacy pretty_repr formatters is supported, will be extended in the future
148148
keyword='repr', # Currently 'repr' is supported, will be extended in the future
149149
max_indent=20, # maximum allowed indent level
150150
indent_step=4, # step between indents

logwrap/_formatters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ def _set_str(indent, val):
101101
return "{spc:<{indent}}{val}".format(
102102
spc='',
103103
indent=indent,
104-
val='{' + "{}".format(
104+
val="set({})".format(
105105
' ,'.join(
106106
map(
107-
'{!s}'.format, # unicode -> !repr
107+
'{!s}'.format,
108108
val
109109
)
110110
)
111-
) + '}'
111+
)
112112
)
113113

114114

logwrap/_repr_utils.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ class PrettyFormat(object):
104104

105105
def __init__(
106106
self,
107-
simple_formatters=None,
108-
complex_formatters=None,
107+
simple_formatters,
108+
complex_formatters,
109109
keyword='repr',
110110
max_indent=20,
111111
indent_step=4,
@@ -125,11 +125,6 @@ def __init__(
125125
:param py2_str: use Python 2.x compatible strings instead of unicode
126126
:type py2_str: bool
127127
"""
128-
if simple_formatters is None:
129-
simple_formatters = s_repr_formatters
130-
if complex_formatters is None:
131-
complex_formatters = c_repr_formatters
132-
133128
self.__s_formatters = simple_formatters
134129
self.__c_formatters = complex_formatters
135130
self.__keyword = keyword

test/test_pretty_str.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ def test_iterable(self):
5656
res.startswith('\n{') and res.endswith('\n}')
5757
)
5858

59+
def test_simple_set(self):
60+
self.assertEqual(
61+
logwrap.pretty_str(set()),
62+
'set()'
63+
)
64+
5965
def test_dict(self):
6066
self.assertEqual(
6167
logwrap.pretty_str({1: 1, 2: 2, 33: 33}),

0 commit comments

Comments
 (0)