Stricter types
This commit is contained in:
parent
ee6aa7e527
commit
42574f98a4
|
@ -1,6 +1,6 @@
|
|||
import abc
|
||||
import dataclasses
|
||||
from collections.abc import Iterator
|
||||
from collections.abc import Iterator, Mapping
|
||||
from enum import Enum
|
||||
|
||||
import requests
|
||||
|
@ -38,5 +38,5 @@ class Scraper(abc.ABC):
|
|||
return False
|
||||
|
||||
@abc.abstractmethod
|
||||
def scrape(self) -> Iterator[object]:
|
||||
def scrape(self) -> Iterator[Mapping[str, object]]:
|
||||
pass
|
||||
|
|
|
@ -3,8 +3,11 @@ import datetime
|
|||
import email.utils
|
||||
import json
|
||||
import logging
|
||||
from collections.abc import Iterator, Mapping
|
||||
from decimal import Decimal
|
||||
|
||||
from frozendict import frozendict
|
||||
|
||||
from personal_data.data import DeduplicateMode, Scraper
|
||||
|
||||
from .. import secrets
|
||||
|
@ -61,8 +64,7 @@ class MpcBalance(Scraper):
|
|||
json_data, date = self.get_json(url, data=data)
|
||||
return json_data['coins']['coins']
|
||||
|
||||
def scrape(self):
|
||||
address = secrets.PBC_ACCOUNT_ADDRESS
|
||||
def scrape_latest_values_for(self, address: str) -> frozendict[str, object]:
|
||||
coins = self.determine_coins()
|
||||
|
||||
url = URL_ACCOUNT_PLUGIN.format(
|
||||
|
@ -93,4 +95,7 @@ class MpcBalance(Scraper):
|
|||
data_point['balance.' + coin_data['symbol']] = native_balance
|
||||
del coin_idx, coin_data
|
||||
|
||||
yield data_point
|
||||
return frozendict(data_point)
|
||||
|
||||
def scrape(self) -> Iterator[Mapping[str, object]]:
|
||||
yield self.scrape_latest_values_for(secrets.PBC_ACCOUNT_ADDRESS)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import csv
|
||||
import datetime
|
||||
import decimal
|
||||
import io
|
||||
import logging
|
||||
import decimal
|
||||
from decimal import Decimal
|
||||
|
||||
import requests
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import datetime
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
import pytest
|
||||
|
||||
from personal_data.main import to_value
|
||||
|
|
Loading…
Reference in New Issue
Block a user