Changeset - 43a2e1bec828
[Not reviewed]
0 2 0
Brett Smith - 4 years ago 2020-04-21 15:57:54
brettcsmith@brettcsmith.org
beancount_types: Add types related to loading the books.

These will help support loading methods in the books module.
2 files changed with 24 insertions and 4 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/beancount_types.py
Show inline comments
...
 
@@ -22,2 +22,3 @@ import beancount.core.data as bc_data
 
from typing import (
 
    TYPE_CHECKING,
 
    Any,
...
 
@@ -26,2 +27,3 @@ from typing import (
 
    List,
 
    Mapping,
 
    NamedTuple,
...
 
@@ -31,4 +33,8 @@ from typing import (
 
    Type,
 
    Union,
 
)
 

	
 
if TYPE_CHECKING:
 
    from . import errors as errormod
 

	
 
Account = bc_data.Account
...
 
@@ -44,2 +50,8 @@ class Directive(NamedTuple):
 

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

	
 

	
 
class Transaction(Directive):
...
 
@@ -56 +68,6 @@ ALL_DIRECTIVES: FrozenSet[Type[Directive]] = frozenset([
 
])
 

	
 
Entries = List[Directive]
 
Errors = List[Union[Error, 'errormod.Error']]
 
OptionsMap = Mapping[str, Any]
 
LoadResult = Tuple[Entries, Errors, OptionsMap]
conservancy_beancount/plugin/__init__.py
Show inline comments
...
 
@@ -34,2 +34,5 @@ from ..beancount_types import (
 
    Directive,
 
    Entries,
 
    Errors,
 
    OptionsMap,
 
)
...
 
@@ -119,7 +122,7 @@ class HookRegistry:
 
def run(
 
        entries: List[Directive],
 
        options_map: Dict[str, Any],
 
        entries: Entries,
 
        options_map: OptionsMap,
 
        config: str='',
 
        hook_registry: Optional[HookRegistry]=None,
 
) -> Tuple[List[Directive], List[Error]]:
 
) -> Tuple[Entries, Errors]:
 
    if hook_registry is None:
...
 
@@ -127,3 +130,3 @@ def run(
 
        hook_registry.load_included_hooks()
 
    errors: List[Error] = []
 
    errors: Errors = []
 
    hooks: Dict[HookName, List[Hook]] = {
0 comments (0 inline, 0 general)