From d9d649d430d81188b0c1b5b0155935c0e5ac14e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Marussy?= Date: Mon, 25 Jan 2021 01:55:43 +0100 Subject: Fix type errors --- beancount_extras_kris7t/plugins/selective_implicit_prices.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'beancount_extras_kris7t/plugins') diff --git a/beancount_extras_kris7t/plugins/selective_implicit_prices.py b/beancount_extras_kris7t/plugins/selective_implicit_prices.py index 07dc893..8f5186d 100644 --- a/beancount_extras_kris7t/plugins/selective_implicit_prices.py +++ b/beancount_extras_kris7t/plugins/selective_implicit_prices.py @@ -9,7 +9,9 @@ __copyright__ = "Copyright (C) 2015-2017 Martin Blais, " + \ __license__ = "GNU GPLv2" import collections -from typing import List, Tuple, Set +import datetime as dt +from decimal import Decimal +from typing import Dict, List, Optional, Set, Tuple from beancount.core.data import Commodity, Entries, Transaction from beancount.core import data @@ -22,6 +24,8 @@ __plugins__ = ('add_implicit_prices',) ImplicitPriceError = collections.namedtuple('ImplicitPriceError', 'source message entry') +EntryId = Tuple[dt.date, data.Currency, Optional[Decimal], data.Currency] + METADATA_FIELD = "__implicit_prices__" IMPLICIT_PRICES_META = "implicit-prices" @@ -65,9 +69,10 @@ def add_implicit_prices(entries: Entries, errors.extend(fetch_errors) # A dict of (date, currency, cost-currency) to price entry. - new_price_entry_map = {} + new_price_entry_map: Dict[EntryId, data.Price] = {} - balances = collections.defaultdict(inventory.Inventory) + balances: Dict[data.Account, inventory.Inventory] = collections.defaultdict( + inventory.Inventory) for entry in entries: # Always replicate the existing entries. new_entries.append(entry) -- cgit v1.2.3