aboutsummaryrefslogtreecommitdiffstats
path: root/beancount_extras_kris7t/plugins
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2021-01-25 01:55:43 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2021-01-25 01:55:43 +0100
commitd9d649d430d81188b0c1b5b0155935c0e5ac14e2 (patch)
treeb02d1ab8aa43a0f2aeb79e91eeb340b5de27e718 /beancount_extras_kris7t/plugins
parentMake Pyright happy by importing load_doc directly (diff)
downloadbeancount-extras-kris7t-d9d649d430d81188b0c1b5b0155935c0e5ac14e2.tar.gz
beancount-extras-kris7t-d9d649d430d81188b0c1b5b0155935c0e5ac14e2.tar.zst
beancount-extras-kris7t-d9d649d430d81188b0c1b5b0155935c0e5ac14e2.zip
Fix type errors
Diffstat (limited to 'beancount_extras_kris7t/plugins')
-rw-r--r--beancount_extras_kris7t/plugins/selective_implicit_prices.py11
1 files changed, 8 insertions, 3 deletions
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, " + \
9__license__ = "GNU GPLv2" 9__license__ = "GNU GPLv2"
10 10
11import collections 11import collections
12from typing import List, Tuple, Set 12import datetime as dt
13from decimal import Decimal
14from typing import Dict, List, Optional, Set, Tuple
13 15
14from beancount.core.data import Commodity, Entries, Transaction 16from beancount.core.data import Commodity, Entries, Transaction
15from beancount.core import data 17from beancount.core import data
@@ -22,6 +24,8 @@ __plugins__ = ('add_implicit_prices',)
22 24
23ImplicitPriceError = collections.namedtuple('ImplicitPriceError', 'source message entry') 25ImplicitPriceError = collections.namedtuple('ImplicitPriceError', 'source message entry')
24 26
27EntryId = Tuple[dt.date, data.Currency, Optional[Decimal], data.Currency]
28
25 29
26METADATA_FIELD = "__implicit_prices__" 30METADATA_FIELD = "__implicit_prices__"
27IMPLICIT_PRICES_META = "implicit-prices" 31IMPLICIT_PRICES_META = "implicit-prices"
@@ -65,9 +69,10 @@ def add_implicit_prices(entries: Entries,
65 errors.extend(fetch_errors) 69 errors.extend(fetch_errors)
66 70
67 # A dict of (date, currency, cost-currency) to price entry. 71 # A dict of (date, currency, cost-currency) to price entry.
68 new_price_entry_map = {} 72 new_price_entry_map: Dict[EntryId, data.Price] = {}
69 73
70 balances = collections.defaultdict(inventory.Inventory) 74 balances: Dict[data.Account, inventory.Inventory] = collections.defaultdict(
75 inventory.Inventory)
71 for entry in entries: 76 for entry in entries:
72 # Always replicate the existing entries. 77 # Always replicate the existing entries.
73 new_entries.append(entry) 78 new_entries.append(entry)