More compatible type hints.

This commit is contained in:
Chris Berkhout 2021-09-14 09:07:11 +02:00
parent 38beaef3be
commit 77a77e76c8
5 changed files with 15 additions and 10 deletions

View file

@ -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

View file

@ -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(

View file

@ -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:

View file

@ -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

View file

@ -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: