Changeset - 1383dabf3ba8
[Not reviewed]
0 1 0
Brett Smith - 4 years ago 2020-04-27 20:44:39
brettcsmith@brettcsmith.org
beancount_types: Make Error.source a Mapping rather than a Dict.

The Beancount code just needs a mapping, and this lets us use
Metadata or PostingMeta objects for Error sources.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/beancount_types.py
Show inline comments
...
 
@@ -28,46 +28,46 @@ from typing import (
 
    Mapping,
 
    NamedTuple,
 
    Optional,
 
    Set,
 
    Tuple,
 
    Type,
 
    Union,
 
)
 

	
 
if TYPE_CHECKING:
 
    from . import errors as errormod
 

	
 
Account = bc_data.Account
 
MetaKey = str
 
MetaValue = Any
 
MetaValueEnum = str
 
Posting = bc_data.Posting
 

	
 
class Directive(NamedTuple):
 
    meta: bc_data.Meta
 
    date: datetime.date
 

	
 

	
 
class Error(NamedTuple):
 
    source: Optional[bc_data.Meta]
 
    source: Optional[Mapping[MetaKey, MetaValue]]
 
    message: str
 
    entry: Optional[Directive]
 

	
 

	
 
class Transaction(Directive):
 
    flag: bc_data.Flag
 
    payee: Optional[str]
 
    narration: str
 
    tags: Set[str]
 
    links: Set[str]
 
    postings: List[Posting]
 

	
 

	
 
ALL_DIRECTIVES: FrozenSet[Type[Directive]] = frozenset([
 
    Transaction,
 
])
 

	
 
Entries = List[Directive]
 
Errors = List[Union[Error, 'errormod.Error']]
 
OptionsMap = Mapping[str, Any]
 
LoadResult = Tuple[Entries, Errors, OptionsMap]
0 comments (0 inline, 0 general)