From a0942915e09b8df2298ba21ad6d34b1f29fd7392 Mon Sep 17 00:00:00 2001 From: Tomasz Zurkowski Date: Tue, 16 Mar 2021 23:40:36 +0100 Subject: [PATCH] Small fixes to typing information. I run `mypy` on the source code and found one place that had incorrect type, and one where mypy could not automatically deduce the right type. --- beanprice/sources/yahoo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/beanprice/sources/yahoo.py b/beanprice/sources/yahoo.py index 734c557..9705382 100644 --- a/beanprice/sources/yahoo.py +++ b/beanprice/sources/yahoo.py @@ -19,7 +19,7 @@ from datetime import datetime, timedelta, timezone from decimal import Decimal -from typing import Any, Dict, List, Optional, Tuple +from typing import Any, Dict, List, Optional, Tuple, Union import requests @@ -55,7 +55,7 @@ def parse_response(response: requests.models.Response) -> Dict: } -def parse_currency(result: Dict[str, Any]) -> str: +def parse_currency(result: Dict[str, Any]) -> Optional[str]: """Infer the currency from the result.""" if 'market' not in result: return None @@ -77,7 +77,7 @@ def get_price_series(ticker: str, if requests is None: raise YahooError("You must install the 'requests' library.") url = "https://query1.finance.yahoo.com/v8/finance/chart/{}".format(ticker) - payload = { + payload: Dict[str, Union[int, str]] = { 'period1': int(time_begin.timestamp()), 'period2': int(time_end.timestamp()), 'interval': '1d',