remove trailing commas in HyDict reprs

This commit is contained in:
gilch 2017-09-18 00:58:14 -06:00
parent af8d209496
commit d38956fb9e
3 changed files with 9 additions and 9 deletions

View File

@ -633,7 +633,7 @@ arguments. If the argument list only has one element, return it.
=> (list* 1 10 2 20 '{})
HyDict([
HyInteger(1), HyInteger(10),
HyInteger(2), HyInteger(20),])
HyInteger(2), HyInteger(20)])
=> (list* 1 10 2 20 {})
<HyCons (
HyInteger(1)

View File

@ -275,14 +275,14 @@ class HyDict(HyList):
for k, v in zip(self[::2],self[1::2]):
k, v = repr_indent(k), repr_indent(v)
pairs.append(
("{0}{c}\n {1}\n {c}"
("{0}{c}\n {1}\n "
if '\n' in k+v
else "{0}{c} {1}{c}").format(k, v, c=g(',')))
else "{0}{c} {1}").format(k, v, c=g(',')))
if len(self) % 2 == 1:
pairs.append("{} {}\n".format(
repr_indent(self[-1]), g("# odd")))
return "{}\n {}{}".format(
g("HyDict(["), ("\n ".join(pairs)), g("])"))
g("HyDict(["), ("{c}\n ".format(c=g(',')).join(pairs)), g("])"))
else:
return '' + g("HyDict()")

View File

@ -213,27 +213,27 @@ PRETTY_STRINGS.update({
'{{1j 2j} {1j 2j [][1j]} {[1j][] 1j 2j} {[1j][1j]}}':
"""HyDict([
HyDict([
HyComplex(1j), HyComplex(2j),]),
HyComplex(1j), HyComplex(2j)]),
HyDict([
HyComplex(1j), HyComplex(2j),
HyList(),
HyList([
HyComplex(1j)])
,])
])
,
HyDict([
HyList([
HyComplex(1j)]),
HyList()
,
HyComplex(1j), HyComplex(2j),]),
HyComplex(1j), HyComplex(2j)]),
HyDict([
HyList([
HyComplex(1j)]),
HyList([
HyComplex(1j)])
,])
,])"""})
])
])"""})
def test_compound_model_repr():