This ledger is valid even though the amount for the second posting of the 
transaction is omitted:

2024-01-01 open Assets:Checking
2024-01-01 open Expenses:Groceries

2024-01-01 * "Groceries"
  Expenses:Groceries 10 USD
  Assets:Checking

But Beancount's core data type for Posting requires a non-None amount for 
the units field 
<https://github.com/beancount/beancount/blob/ca9551980dbf0f13faeed5f9042de68540bb2ec6/beancount/core/data.py#L208>,
 
even though it's not a runtime error to pass None into it (example repro 
<https://gist.github.com/aaronj1335/f282a97d38d7f01b99af290254f7b468>). I 
also notice, the beancount.loader module will insert an Amount when loading 
the Python objects. 

I can see why this might be desirable for code maintenance, but it seems to 
constrain the ledger unnecessarily. My question is *should Posting#units 
have the type Optional[Amount]?* I'd be happy to mail a pull request.

The background is that I upgraded to v3; I really love the nice static 
typing, but I've got a h̴e̴r̴d̴ ̴o̴f̴ ̴f̴e̴r̴a̴l̴ ̴c̴a̴t̴s̴ handful of 
scripts for importing transactions, and those create Posting objects to be 
output with beancount.parser.printer, and for that I prefer the cleaner 
ledger syntax of omitting the second posting's amount.

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/77829801-22e7-4b25-87a3-b337aaedbeb3n%40googlegroups.com.

Reply via email to