Skip to content

Commit aa07762

Browse files
committed
render: Work around backward incompatible change in Beancount master
Since commit 10b6f5efd2385e3d0efe6715584d7f540e2e7abf Beancount assumes the presence of a sign unconditionally, changing the formatting of columns that do not contain negative numbers.
1 parent f45169a commit aa07762

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

beanquery/query_render.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@ class Align(enum.Enum):
2222
RIGHT = 1
2323

2424

25+
class _CurrencyContext(display_context._CurrencyContext):
26+
def __init__(self):
27+
super().__init__()
28+
# Since commit 10b6f5efd2385e3d0efe6715584d7f540e2e7abf
29+
# beancount assumes the presence of a sign unconditionally ,
30+
# changing the formatting of columns that do not contain
31+
# negative numbers. Revert the change.
32+
self.has_sign = False
33+
34+
35+
class _DisplayContext(display_context.DisplayContext):
36+
def __init__(self):
37+
self.ccontexts = collections.defaultdict(_CurrencyContext)
38+
self.ccontexts["__default__"] = _CurrencyContext()
39+
self.commas = False
40+
41+
2542
class RenderContext:
2643
"""Hold the query rendering configuration."""
2744

@@ -235,7 +252,7 @@ def __init__(self, ctx):
235252
# determine the quantization of the column values.
236253
self.quantize = ctx.dcontext.quantize
237254
# Use column specific display context for formatting.
238-
self.dcontext = display_context.DisplayContext()
255+
self.dcontext = _DisplayContext()
239256
# Maximum width of the commodity symbol.
240257
self.curwidth = 0
241258

0 commit comments

Comments
 (0)