From 9d992abb4468ff420cc4b530691922e04f7ef507 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Sun, 2 Jun 2024 18:01:18 +0200 Subject: [PATCH] Ruff --- personal_data/_version.py | 2 +- personal_data/fetchers/defi_kucoin.py | 23 ++++++++++++----------- personal_data/main.py | 2 +- setup.py | 3 +++ 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/personal_data/_version.py b/personal_data/_version.py index 63eb0cb..2fb2513 100644 --- a/personal_data/_version.py +++ b/personal_data/_version.py @@ -1 +1 @@ -__version__ = '0.1.6' \ No newline at end of file +__version__ = '0.1.6' diff --git a/personal_data/fetchers/defi_kucoin.py b/personal_data/fetchers/defi_kucoin.py index eb9d5c3..9d6bd56 100644 --- a/personal_data/fetchers/defi_kucoin.py +++ b/personal_data/fetchers/defi_kucoin.py @@ -1,13 +1,12 @@ +import abc import dataclasses import datetime import logging from collections.abc import Iterator, Mapping -from decimal import Decimal -import abc +import fin_depo import kucoin.client from frozendict import frozendict -import fin_depo from personal_data.data import DeduplicateMode, Scraper @@ -23,9 +22,9 @@ client = kucoin.client.Client( secrets.KUCOIN_PASS, ) + @dataclasses.dataclass(frozen=True) class FinanceDepoScraper(Scraper): - @abc.abstractmethod def get_depo_fetcher(self): pass @@ -38,7 +37,7 @@ class FinanceDepoScraper(Scraper): } for asset in depo.assets(): - key = f"balance.{asset}" + key = f'balance.{asset}' data_point[key] = depo.get_amount_of_asset(asset) print(data_point) @@ -54,10 +53,11 @@ class KrakenAccountBalances(FinanceDepoScraper): def get_depo_fetcher(self): return fin_depo.defi_kraken.KrakenDepoFetcher( - kraken_key = secrets.KRAKEN_KEY, - kraken_secret = secrets.KRAKEN_SECRET, + kraken_key=secrets.KRAKEN_KEY, + kraken_secret=secrets.KRAKEN_SECRET, ) + @dataclasses.dataclass(frozen=True) class KucoinAccountBalances(FinanceDepoScraper): dataset_name = 'defi_kucoin_balance' @@ -66,12 +66,13 @@ class KucoinAccountBalances(FinanceDepoScraper): def get_depo_fetcher(self): return fin_depo.defi_kucoin.KucoinDepoFetcher( - kucoin_key = secrets.KUCOIN_KEY, - kucoin_secret = secrets.KUCOIN_SECRET, - kucoin_pass = secrets.KUCOIN_PASS, + kucoin_key=secrets.KUCOIN_KEY, + kucoin_secret=secrets.KUCOIN_SECRET, + kucoin_pass=secrets.KUCOIN_PASS, ) -def addresses_to_data_points(addresses: list[dict[str,str]]) -> frozendict: + +def addresses_to_data_points(addresses: list[dict[str, str]]) -> frozendict: data_point = {} data_point['account.update_time'] = datetime.datetime.now(tz=datetime.UTC) data_point['account.num_deposit_addresses'] = len(addresses) diff --git a/personal_data/main.py b/personal_data/main.py index 566ec4a..7a8b8e1 100644 --- a/personal_data/main.py +++ b/personal_data/main.py @@ -1,7 +1,7 @@ import csv import datetime -import inspect import decimal +import inspect import io import logging from collections.abc import Iterable, Mapping, Sequence diff --git a/setup.py b/setup.py index dccf70b..d93812e 100644 --- a/setup.py +++ b/setup.py @@ -15,6 +15,7 @@ PACKAGE_NAME = 'personal_data' with open('README.md') as f: readme = f.read() + def parse_version_file(text: str) -> str: match = re.match(r'^__version__\s*=\s*(["\'])([\d\.]+)\1$', text) if match is None: @@ -22,9 +23,11 @@ def parse_version_file(text: str) -> str: raise Exception(msg) return match.group(2) + with open(PACKAGE_NAME + '/_version.py') as f: version = parse_version_file(f.read()) + def parse_requirements(text: str) -> list[str]: return text.strip().split('\n')