File: beancount-3.2.0.patch

package info (click to toggle)
beanquery 0.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 672 kB
  • sloc: python: 8,421; makefile: 3; sh: 2
file content (52 lines) | stat: -rw-r--r-- 1,970 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From: Daniele Nicolodi <daniele@grinta.net>
Date: Tue, 29 Jul 2025 00:35:26 +0200
Subject: 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.

Origin: upstream, https://github.com/beancount/beanquery/commit/aa0776285a25baeedf151e9f582bef0314f76004
Bug-Debian: https://bugs.debian.org/1117386
Last-Update: 2025-10-10
---
 beanquery/query_render.py | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/beanquery/query_render.py b/beanquery/query_render.py
index ebcfbca..24d5361 100644
--- a/beanquery/query_render.py
+++ b/beanquery/query_render.py
@@ -22,6 +22,23 @@ class Align(enum.Enum):
     RIGHT = 1
 
 
+class _CurrencyContext(display_context._CurrencyContext):
+    def __init__(self):
+        super().__init__()
+        # Since commit 10b6f5efd2385e3d0efe6715584d7f540e2e7abf
+        # beancount assumes the presence of a sign unconditionally ,
+        # changing the formatting of columns that do not contain
+        # negative numbers. Revert the change.
+        self.has_sign = False
+
+
+class _DisplayContext(display_context.DisplayContext):
+    def __init__(self):
+        self.ccontexts = collections.defaultdict(_CurrencyContext)
+        self.ccontexts["__default__"] = _CurrencyContext()
+        self.commas = False
+
+
 class RenderContext:
     """Hold the query rendering configuration."""
 
@@ -235,7 +252,7 @@ class AmountRenderer(ColumnRenderer):
         # determine the quantization of the column values.
         self.quantize = ctx.dcontext.quantize
         # Use column specific display context for formatting.
-        self.dcontext = display_context.DisplayContext()
+        self.dcontext = _DisplayContext()
         # Maximum width of the commodity symbol.
         self.curwidth = 0