LaunchPlatform/beancount-black

AttributeError on number metadata values

brush701 opened this issue · 0 comments

On v0.2.1, I run bean-black on a file that contains the following directive:

2001-09-26 commodity ACME
  total: 50000

This throws the error:

Traceback (most recent call last):
  File "/opt/homebrew/bin/bean-black", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/beancount_black/main.py", line 87, in main
    formatter.format(tree, output_file)
  File "/opt/homebrew/lib/python3.11/site-packages/beancount_black/formatter.py", line 645, in format
    sections.append(self.format_statement_group(group))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/beancount_black/formatter.py", line 579, in format_statement_group
    lines.append(self.format_entry(entry))
                 ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/beancount_black/formatter.py", line 492, in format_entry
    metadata_lines = self.format_metadata_lines(entry.metadata)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/beancount_black/formatter.py", line 448, in format_metadata_lines
    line = self.format_metadata_item(metadata.statement.children[0])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/beancount_black/formatter.py", line 349, in format_metadata_item
    return f"{key_token.value}: {value_token.value}"
                                 ^^^^^^^^^^^^^^^^^
AttributeError: 'Tree' object has no attribute 'value'

Other metadata types work fine.