beanquery icon indicating copy to clipboard operation
beanquery copied to clipboard

Better error messages when `beancount` format does not apply

Open tbm opened this issue 4 months ago • 5 comments

It's late and maybe I'm doing something wrong but I get a Python syntax error with `.format beancount``:

beanquery> .format beancount
beanquery> SELECT date, META("receipt")  WHERE account ~ "^Expenses:" 

gives me:

  File "/home/tbm/.local/lib/python3.11/site-packages/beanquery/render/beancount.py", line 11, in render
    return printer.print_entries([entry for entry, in rows], dcontext, file=file)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tbm/.local/lib/python3.11/site-packages/beanquery/render/beancount.py", line 11, in <listcomp>
    return printer.print_entries([entry for entry, in rows], dcontext, file=file)
                                            ^^^^^^
ValueError: too many values to unpack (expected 1)

After removing the comma after entry,, I get the following (note that I'm on beancount 2.x):

  File "/home/tbm/.local/lib/python3.11/site-packages/beanquery/shell.py", line 595, in on_Select
    return render(desc, rows, out, dcontext=dcontext, **self.settings.todict())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tbm/.local/lib/python3.11/site-packages/beanquery/render/beancount.py", line 11, in render
    return printer.print_entries([entry for entry in rows], dcontext, file=file)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tbm/.local/lib/python3.11/site-packages/beancount/parser/printer.py", line 423, in print_entries
    string = eprinter(entry)
             ^^^^^^^^^^^^^^^
  File "/home/tbm/.local/lib/python3.11/site-packages/beancount/parser/printer.py", line 123, in __call__
    method = getattr(self, obj.__class__.__name__)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'EntryPrinter' object has no attribute 'tuple'
bean-query --version
beanquery 0.3.0.dev0, beancount 2.3.6

tbm avatar Jul 08 '25 14:07 tbm