aboutsummaryrefslogtreecommitdiffstats
path: root/beancount_extras_kris7t/importers
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/importers
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/importers')
-rw-r--r--beancount_extras_kris7t/importers/otpbank/otpbank_csv.py3
-rw-r--r--beancount_extras_kris7t/importers/transferwise/__main__.py2
-rw-r--r--beancount_extras_kris7t/importers/transferwise/client.py12
-rw-r--r--beancount_extras_kris7t/importers/transferwise/transferwise_json.py2
4 files changed, 12 insertions, 7 deletions
diff --git a/beancount_extras_kris7t/importers/otpbank/otpbank_csv.py b/beancount_extras_kris7t/importers/otpbank/otpbank_csv.py
index 9e12ec3..c0f66ba 100644
--- a/beancount_extras_kris7t/importers/otpbank/otpbank_csv.py
+++ b/beancount_extras_kris7t/importers/otpbank/otpbank_csv.py
@@ -236,7 +236,8 @@ def extract_foreign_currencies(
236 236
237def extract_cards(card_accounts: Dict[str, str]) -> Extractor: 237def extract_cards(card_accounts: Dict[str, str]) -> Extractor:
238 def do_extract(row: Row) -> None: 238 def do_extract(row: Row) -> None:
239 if row.entry_type.lower() not in [ 239 entry_type = row.entry_type
240 if not entry_type or entry_type.lower() not in [
240 'vásárlás kártyával', 241 'vásárlás kártyával',
241 'bankkártyával kapcs. díj', 242 'bankkártyával kapcs. díj',
242 ]: 243 ]:
diff --git a/beancount_extras_kris7t/importers/transferwise/__main__.py b/beancount_extras_kris7t/importers/transferwise/__main__.py
index e25580d..4ac2058 100644
--- a/beancount_extras_kris7t/importers/transferwise/__main__.py
+++ b/beancount_extras_kris7t/importers/transferwise/__main__.py
@@ -4,7 +4,7 @@ Importer for Transferwise API transaction history.
4__copyright__ = 'Copyright (c) 2020 Kristóf Marussy <kristof@marussy.com>' 4__copyright__ = 'Copyright (c) 2020 Kristóf Marussy <kristof@marussy.com>'
5__license__ = 'GNU GPLv2' 5__license__ = 'GNU GPLv2'
6 6
7from importers.transferwise.client import main 7from beancount_extras_kris7t.importers.transferwise.client import main
8 8
9 9
10if __name__ == '__main__': 10if __name__ == '__main__':
diff --git a/beancount_extras_kris7t/importers/transferwise/client.py b/beancount_extras_kris7t/importers/transferwise/client.py
index a4b6629..5198122 100644
--- a/beancount_extras_kris7t/importers/transferwise/client.py
+++ b/beancount_extras_kris7t/importers/transferwise/client.py
@@ -25,8 +25,8 @@ def _parse_date_arg(date_str: str) -> dt.date:
25def _import_config(config_path: str) -> Importer: 25def _import_config(config_path: str) -> Importer:
26 import runpy 26 import runpy
27 27
28 config = runpy.run_path(config_path) 28 config = runpy.run_path(config_path) # type: ignore
29 importer = config['TRANSFERWISE_CONFIG'] # type: ignore 29 importer = config['TRANSFERWISE_CONFIG']
30 if isinstance(importer, Importer): 30 if isinstance(importer, Importer):
31 LOG.info('Loaded configuration from %s', config_path) 31 LOG.info('Loaded configuration from %s', config_path)
32 return importer 32 return importer
@@ -65,7 +65,7 @@ def _get_last_transaction_date(ledger_path: str, skip_references: Set[str]) -> O
65def _get_date_range(from_date: Optional[dt.date], 65def _get_date_range(from_date: Optional[dt.date],
66 to_date: dt.date, 66 to_date: dt.date,
67 ledger_path: Optional[str]) -> Tuple[dt.date, dt.date, Set[str]]: 67 ledger_path: Optional[str]) -> Tuple[dt.date, dt.date, Set[str]]:
68 skip_references = set() 68 skip_references: Set[str] = set()
69 if not from_date and ledger_path: 69 if not from_date and ledger_path:
70 from_date = _get_last_transaction_date(ledger_path, skip_references) 70 from_date = _get_last_transaction_date(ledger_path, skip_references)
71 if not from_date: 71 if not from_date:
@@ -79,6 +79,7 @@ def _get_secrets(importer: Importer,
79 proxy_uri: Optional[str]) -> Tuple[str, Optional[str]]: 79 proxy_uri: Optional[str]) -> Tuple[str, Optional[str]]:
80 import urllib.parse 80 import urllib.parse
81 81
82 uri_parts: Optional[urllib.parse.SplitResult]
82 if proxy_uri: 83 if proxy_uri:
83 uri_parts = urllib.parse.urlsplit(proxy_uri) 84 uri_parts = urllib.parse.urlsplit(proxy_uri)
84 else: 85 else:
@@ -122,7 +123,7 @@ def _get_secrets(importer: Importer,
122 proxy_uri = uri 123 proxy_uri = uri
123 else: 124 else:
124 LOG.info('No proxy password secret was found in SecretService') 125 LOG.info('No proxy password secret was found in SecretService')
125 assert api_key # Make pyright happy 126 assert api_key # Make mypy happy
126 return api_key, proxy_uri 127 return api_key, proxy_uri
127 128
128 129
@@ -141,8 +142,9 @@ def _fetch_statements(importer: Importer,
141 uri_prefix = f'https://api.transferwise.com/v3/profiles/{importer.profile_id}/' + \ 142 uri_prefix = f'https://api.transferwise.com/v3/profiles/{importer.profile_id}/' + \
142 f'borderless-accounts/{importer.borderless_account_id}/statement.json' + \ 143 f'borderless-accounts/{importer.borderless_account_id}/statement.json' + \
143 f'?intervalStart={from_time_str}&intervalEnd={to_time_str}&type=COMPACT&currency=' 144 f'?intervalStart={from_time_str}&intervalEnd={to_time_str}&type=COMPACT&currency='
145 beancount_version = beancount.__version__ # type: ignore # noqa: unused-type-ignore
144 headers = { 146 headers = {
145 'User-Agent': f'Beancount {beancount.__version__} Transferwise importer {__copyright__}', 147 'User-Agent': f'Beancount {beancount_version} Transferwise importer {__copyright__}',
146 'Authorization': f'Bearer {api_key}', 148 'Authorization': f'Bearer {api_key}',
147 } 149 }
148 proxy_dict: Dict[str, str] = {} 150 proxy_dict: Dict[str, str] = {}
diff --git a/beancount_extras_kris7t/importers/transferwise/transferwise_json.py b/beancount_extras_kris7t/importers/transferwise/transferwise_json.py
index c42de90..68ddc6d 100644
--- a/beancount_extras_kris7t/importers/transferwise/transferwise_json.py
+++ b/beancount_extras_kris7t/importers/transferwise/transferwise_json.py
@@ -211,6 +211,8 @@ class Row(utils.Row):
211 # Also add the "fudge" amounts to the fees generated by rounding currency conversions. 211 # Also add the "fudge" amounts to the fees generated by rounding currency conversions.
212 all_fees = Inventory() 212 all_fees = Inventory()
213 all_fees.add_inventory(self._fees) 213 all_fees.add_inventory(self._fees)
214 if not self.postings:
215 raise InvalidEntry('Trying to create transaction without postings')
214 for acc, assigned_units in self.postings: 216 for acc, assigned_units in self.postings:
215 for conversion in self._conversions: 217 for conversion in self._conversions:
216 units, price, fudge = conversion.get_fraction( 218 units, price, fudge = conversion.get_fraction(