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
...
 
@@ -4,70 +4,70 @@
 
# This program is free software: you can redistribute it and/or modify
 
# it under the terms of the GNU Affero General Public License as published by
 
# the Free Software Foundation, either version 3 of the License, or
 
# (at your option) any later version.
 
#
 
# This program is distributed in the hope that it will be useful,
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU Affero General Public License for more details.
 
#
 
# You should have received a copy of the GNU Affero General Public License
 
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 

	
 
import abc
 
import datetime
 

	
 
import beancount.core.data as bc_data
 

	
 
from typing import (
 
    TYPE_CHECKING,
 
    Any,
 
    FrozenSet,
 
    Iterable,
 
    List,
 
    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)