More compatible type hints.
This commit is contained in:
parent
38beaef3be
commit
77a77e76c8
5 changed files with 15 additions and 10 deletions
|
@ -25,6 +25,7 @@ Functions:
|
||||||
|
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from importlib.resources import read_binary
|
from importlib.resources import read_binary
|
||||||
|
from typing import List
|
||||||
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ class ISOCurrency:
|
||||||
minor_units: int = None
|
minor_units: int = None
|
||||||
name: str = None
|
name: str = None
|
||||||
is_fund: bool = False
|
is_fund: bool = False
|
||||||
countries: list[str] = field(default_factory=list)
|
countries: List[str] = field(default_factory=list)
|
||||||
historical: bool = False
|
historical: bool = False
|
||||||
withdrawal_date: str = None
|
withdrawal_date: str = None
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from dataclasses import dataclass, field, replace
|
from dataclasses import dataclass, field, replace
|
||||||
from decimal import Decimal, getcontext
|
from decimal import Decimal, getcontext
|
||||||
|
from typing import List
|
||||||
|
|
||||||
from pricehist.price import Price
|
from pricehist.price import Price
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@ class Series:
|
||||||
type: str
|
type: str
|
||||||
start: str
|
start: str
|
||||||
end: str
|
end: str
|
||||||
prices: list[Price] = field(default_factory=list)
|
prices: List[Price] = field(default_factory=list)
|
||||||
|
|
||||||
def invert(self):
|
def invert(self):
|
||||||
return replace(
|
return replace(
|
||||||
|
|
|
@ -5,6 +5,7 @@ import logging
|
||||||
import os
|
import os
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
from typing import List, Tuple
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
@ -334,15 +335,15 @@ class AlphaVantage(BaseSource):
|
||||||
if "Error Message" in data and "apikey " in data["Error Message"]:
|
if "Error Message" in data and "apikey " in data["Error Message"]:
|
||||||
raise exceptions.CredentialsError([self.API_KEY_NAME], self)
|
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/"
|
url = "https://www.alphavantage.co/physical_currency_list/"
|
||||||
return self._get_symbols(url, "Physical: ")
|
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/"
|
url = "https://www.alphavantage.co/digital_currency_list/"
|
||||||
return self._get_symbols(url, "Digital: ")
|
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:
|
try:
|
||||||
response = self.log_curl(requests.get(url))
|
response = self.log_curl(requests.get(url))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from textwrap import TextWrapper
|
from textwrap import TextWrapper
|
||||||
|
from typing import List, Tuple
|
||||||
|
|
||||||
import curlify
|
import curlify
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ class BaseSource(ABC):
|
||||||
pass # pragma: nocover
|
pass # pragma: nocover
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def types(self) -> list[str]:
|
def types(self) -> List[str]:
|
||||||
pass # pragma: nocover
|
pass # pragma: nocover
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
@ -41,10 +42,10 @@ class BaseSource(ABC):
|
||||||
return str.upper()
|
return str.upper()
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def symbols(self) -> list[(str, str)]:
|
def symbols(self) -> List[Tuple[str, str]]:
|
||||||
pass # pragma: nocover
|
pass # pragma: nocover
|
||||||
|
|
||||||
def search(self, query) -> list[(str, str)]:
|
def search(self, query) -> List[Tuple[str, str]]:
|
||||||
pass # pragma: nocover
|
pass # pragma: nocover
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import logging
|
import logging
|
||||||
|
from typing import List, Tuple
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
@ -22,13 +23,13 @@ class TestSource(BaseSource):
|
||||||
def start(self) -> str:
|
def start(self) -> str:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def types(self) -> list[str]:
|
def types(self) -> List[str]:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def notes(self) -> str:
|
def notes(self) -> str:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def symbols(self) -> list[(str, str)]:
|
def symbols(self) -> List[Tuple[str, str]]:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def fetch(self, series: Series) -> Series:
|
def fetch(self, series: Series) -> Series:
|
||||||
|
|
Loading…
Add table
Reference in a new issue