Changeset - 5706273bbe72
[Not reviewed]
0 1 0
Brett Smith - 4 years ago 2020-06-12 17:24:25
brettcsmith@brettcsmith.org
accrual: Clean up types and imports.

Mostly I wanted to write the documentation about groups, and then
I kept pulling the thread.
1 file changed with 14 insertions and 6 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reports/accrual.py
Show inline comments
...
 
@@ -72,3 +72,2 @@ import enum
 
import logging
 
import re
 
import sys
...
 
@@ -121,5 +120,3 @@ PROGNAME = 'accrual-report'
 

	
 
CompoundAmount = TypeVar('CompoundAmount', data.Amount, core.Balance)
 
PostGroups = Mapping[Optional[MetaValue], 'AccrualPostings']
 
RTObject = Mapping[str, str]
 
PostGroups = Mapping[Optional[str], 'AccrualPostings']
 
T = TypeVar('T')
...
 
@@ -215,3 +212,3 @@ class AccrualPostings(core.RelatedPostings):
 

	
 
    def make_consistent(self) -> Iterator[Tuple[MetaValue, 'AccrualPostings']]:
 
    def make_consistent(self) -> Iterator[Tuple[str, 'AccrualPostings']]:
 
        account_ok = isinstance(self.account, str)
...
 
@@ -223,3 +220,6 @@ class AccrualPostings(core.RelatedPostings):
 
        if account_ok and entity_ok and invoice_ok:
 
            yield (self.invoice, self)
 
            # mypy loses track of the fact that self.invoice must be a str in
 
            # this case (gated on the invoice_ok boolean) and complains it
 
            # doesn't match the type of the return value.
 
            yield (self.invoice, self)  # type:ignore[misc]
 
            return
...
 
@@ -698,2 +698,10 @@ def main(arglist: Optional[Sequence[str]]=None,
 
        returncode |= ReturnFlag.NOTHING_TO_REPORT
 
    # groups is a mapping of metadata value strings to AccrualPostings.
 
    # The keys are basically arbitrary, the report classes don't rely on them,
 
    # but they do help symbolize what's being grouped.
 
    # For the outgoing approval report, groups maps rt-id link strings to
 
    # associated accruals.
 
    # For all other reports, groups starts by grouping postings together by
 
    # invoice link string, then uses AccrualReport.make_consistent() to split
 
    # out groups that need it.
 
    groups: PostGroups
0 comments (0 inline, 0 general)