diff --git a/src/pricehist/isocurrencies.py b/src/pricehist/isocurrencies.py index f7079c4..fe02678 100644 --- a/src/pricehist/isocurrencies.py +++ b/src/pricehist/isocurrencies.py @@ -25,6 +25,7 @@ Functions: from dataclasses import dataclass, field from importlib.resources import read_binary +from typing import List from lxml import etree @@ -36,7 +37,7 @@ class ISOCurrency: minor_units: int = None name: str = None is_fund: bool = False - countries: list[str] = field(default_factory=list) + countries: List[str] = field(default_factory=list) historical: bool = False withdrawal_date: str = None diff --git a/src/pricehist/series.py b/src/pricehist/series.py index d063b90..88a1de3 100644 --- a/src/pricehist/series.py +++ b/src/pricehist/series.py @@ -1,5 +1,6 @@ from dataclasses import dataclass, field, replace from decimal import Decimal, getcontext +from typing import List from pricehist.price import Price @@ -11,7 +12,7 @@ class Series: type: str start: str end: str - prices: list[Price] = field(default_factory=list) + prices: List[Price] = field(default_factory=list) def invert(self): return replace( diff --git a/src/pricehist/sources/alphavantage.py b/src/pricehist/sources/alphavantage.py index d0eac8c..75cda5d 100644 --- a/src/pricehist/sources/alphavantage.py +++ b/src/pricehist/sources/alphavantage.py @@ -5,6 +5,7 @@ import logging import os from datetime import datetime, timedelta from decimal import Decimal +from typing import List, Tuple import requests @@ -334,15 +335,15 @@ class AlphaVantage(BaseSource): if "Error Message" in data and "apikey " in data["Error Message"]: raise exceptions.CredentialsError([self.API_KEY_NAME], self) - def _physical_symbols(self) -> list[(str, str)]: + def _physical_symbols(self) -> List[Tuple[str, str]]: url = "https://www.alphavantage.co/physical_currency_list/" return self._get_symbols(url, "Physical: ") - def _digital_symbols(self) -> list[(str, str)]: + def _digital_symbols(self) -> List[Tuple[str, str]]: url = "https://www.alphavantage.co/digital_currency_list/" return self._get_symbols(url, "Digital: ") - def _get_symbols(self, url, prefix) -> list[(str, str)]: + def _get_symbols(self, url, prefix) -> List[Tuple[str, str]]: try: response = self.log_curl(requests.get(url)) except Exception as e: diff --git a/src/pricehist/sources/basesource.py b/src/pricehist/sources/basesource.py index 4273678..cab423f 100644 --- a/src/pricehist/sources/basesource.py +++ b/src/pricehist/sources/basesource.py @@ -1,6 +1,7 @@ import logging from abc import ABC, abstractmethod from textwrap import TextWrapper +from typing import List, Tuple import curlify @@ -30,7 +31,7 @@ class BaseSource(ABC): pass # pragma: nocover @abstractmethod - def types(self) -> list[str]: + def types(self) -> List[str]: pass # pragma: nocover @abstractmethod @@ -41,10 +42,10 @@ class BaseSource(ABC): return str.upper() @abstractmethod - def symbols(self) -> list[(str, str)]: + def symbols(self) -> List[Tuple[str, str]]: pass # pragma: nocover - def search(self, query) -> list[(str, str)]: + def search(self, query) -> List[Tuple[str, str]]: pass # pragma: nocover @abstractmethod diff --git a/tests/pricehist/sources/test_basesource.py b/tests/pricehist/sources/test_basesource.py index cfd5e80..478d5c2 100644 --- a/tests/pricehist/sources/test_basesource.py +++ b/tests/pricehist/sources/test_basesource.py @@ -1,4 +1,5 @@ import logging +from typing import List, Tuple import pytest @@ -22,13 +23,13 @@ class TestSource(BaseSource): def start(self) -> str: return "" - def types(self) -> list[str]: + def types(self) -> List[str]: return [] def notes(self) -> str: return "" - def symbols(self) -> list[(str, str)]: + def symbols(self) -> List[Tuple[str, str]]: return [] def fetch(self, series: Series) -> Series: