andreasgerstmayr / fava-dashboards

Custom Dashboards for Beancount in Fava
MIT License
178 stars 21 forks source link

NotImplementedError: Use explicit is_empty() method instead. #22

Closed AlphaJack closed 1 year ago

AlphaJack commented 1 year ago

I cannot open anymore the extension, as it returns the following:

# Starting Fava on http://127.0.0.1:5000
Exception on /accounting/extension/FavaDashboards/ [GET]
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/fava/application.py", line 348, in extension_report
    content = Markup(template.render(ledger=g.ledger, extension=ext))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/usr/lib/python3.11/site-packages/fava_dashboards/templates/FavaDashboards.html", line 6, in top-level template code
    {{ {"ledger": bootstrap["ledger"], "dashboard": bootstrap["dashboards"][dashboard_id]}|tojson }}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/jinja2/filters.py", line 1688, in do_tojson
    return htmlsafe_json_dumps(value, dumps=dumps, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/jinja2/utils.py", line 658, in htmlsafe_json_dumps
    dumps(obj, **kwargs)
  File "/usr/lib/python3.11/site-packages/fava/core/charts.py", line 84, in dumps
    return dumps(obj)
           ^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/fava/core/charts.py", line 67, in dumps
    return simplejson_dumps(
           ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/simplejson/__init__.py", line 395, in dumps
    **kw).encode(obj)
          ^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/simplejson/encoder.py", line 300, in encode
    chunks = list(chunks)
             ^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/simplejson/encoder.py", line 714, in _iterencode
    for chunk in _iterencode_dict(o, _current_indent_level):
  File "/usr/lib/python3.11/site-packages/simplejson/encoder.py", line 668, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib/python3.11/site-packages/simplejson/encoder.py", line 668, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib/python3.11/site-packages/simplejson/encoder.py", line 544, in _iterencode_list
    for chunk in chunks:
  File "/usr/lib/python3.11/site-packages/simplejson/encoder.py", line 668, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib/python3.11/site-packages/simplejson/encoder.py", line 544, in _iterencode_list
    for chunk in chunks:
  File "/usr/lib/python3.11/site-packages/simplejson/encoder.py", line 668, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib/python3.11/site-packages/simplejson/encoder.py", line 544, in _iterencode_list
    for chunk in chunks:
  File "/usr/lib/python3.11/site-packages/simplejson/encoder.py", line 668, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib/python3.11/site-packages/simplejson/encoder.py", line 585, in _iterencode_dict
    if not dct:
  File "/usr/lib/python3.11/site-packages/beancount/core/inventory.py", line 137, in __bool__
    raise NotImplementedError("Use explicit is_empty() method instead.")
NotImplementedError: Use explicit is_empty() method instead.
andreasgerstmayr commented 1 year ago

This error appears when updating to Fava 1.26.1 and is already fixed in the latest fava-dashboards commit. Can you try updating your version of fava-dashboards?

AlphaJack commented 1 year ago

It works, thanks! I wasn't expecting a minor update to break plugins compatibility