Skip to content

Better error messages when beancount format does not apply #257

@tbm

Description

@tbm

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions