LaunchPlatform / beancount-black

Opinionated code formatter, just like Python's black code formatter but for Beancount
MIT License
37 stars 3 forks source link

Blows up on certain comments that bean-check is fine with #13

Closed peterhoeg closed 1 year ago

peterhoeg commented 1 year ago

Using the following sample file:

2000-01-01 open Assets:Cash
2000-01-01 open Expenses:Food

;; comment OK

2010-01-01 txn "P. Escobar" "White flour"
  Assets:Cash 1000.00 USD
  Expenses:Food

;; this comment blows up

Error message:

AttributeError: 'Token' object has no attribute 'data'

Removing the last comment makes it OK.

bean-check is fine with and without the last comment.

fangpenlin commented 1 year ago

Hi, thanks for reporting the issue. The bean-check command passing or not has nothing to do beancount-black would work or not. Since the whole beancount-black project is based on top of a standalone beancount file parser we developed and open-sourced:

https://github.com/LaunchPlatform/beancount-parser

So it doesn't not rely on the original beancount code, and it does not validate anything at all. It assumes the beancount file is correct, then just parse it and reformat.

The sample code you provided seems like a legit one. This looks more like a bug in beancount-black itself. I will look into this issue tomorrow.