From e10f1df3211c428afe2c5d6b2eeb91cc7a9b3f11 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Mon, 15 Oct 2018 00:04:25 -0400 Subject: [PATCH] pylint and mypy fixes --- .travis.yml | 2 +- setup.py | 5 +++-- torba/baseaccount.py | 2 +- torba/basedatabase.py | 22 +++++++--------------- torba/basetransaction.py | 2 +- 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7be2faefb..420998b74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ jobs: - pip install -e . script: - pylint --rcfile=setup.cfg torba - - mypy torba + - mypy --ignore-missing-imports torba after_success: skip - &tests diff --git a/setup.py b/setup.py index f5b827c0c..5d42d03f9 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( description='Wallet library for bitcoin based currencies.', keywords='wallet,crypto,currency,money,bitcoin,lbry', classifiers=( - 'Framework :: Twisted', + 'Framework :: AsyncIO', 'Intended Audience :: Developers', 'Intended Audience :: System Administrators', 'License :: OSI Approved :: MIT License', @@ -26,7 +26,8 @@ setup( packages=find_packages(exclude=('tests',)), python_requires='>=3.6', install_requires=( - 'twisted', + 'aiorpcx', + 'aiosqlite', 'coincurve', 'pbkdf2', 'cryptography' diff --git a/torba/baseaccount.py b/torba/baseaccount.py index 7369f9394..7551c39c8 100644 --- a/torba/baseaccount.py +++ b/torba/baseaccount.py @@ -362,7 +362,7 @@ class BaseAccount: return self.ledger.db.get_transaction_count(account=self, **constraints) async def fund(self, to_account, amount=None, everything=False, - outputs=1, broadcast=False, **constraints): + outputs=1, broadcast=False, **constraints): assert self.ledger == to_account.ledger, 'Can only transfer between accounts of the same ledger.' tx_class = self.ledger.transaction_class if everything: diff --git a/torba/basedatabase.py b/torba/basedatabase.py index e6b74ab57..1493d3c32 100644 --- a/torba/basedatabase.py +++ b/torba/basedatabase.py @@ -1,5 +1,5 @@ import logging -from typing import Tuple, List +from typing import Tuple, List, Union import sqlite3 import aiosqlite @@ -134,7 +134,8 @@ class SQLiteMixin: return sql, values @staticmethod - def _update_sql(table: str, data: dict, where: str, constraints: list) -> Tuple[str, list]: + def _update_sql(table: str, data: dict, where: str, + constraints: Union[list, tuple]) -> Tuple[str, list]: columns, values = [], [] for column, value in data.items(): columns.append("{} = ?".format(column)) @@ -151,16 +152,6 @@ class SQLiteMixin: log.debug(values) return t.execute(sql, values) - def run_operation(self, sql, values): - log.debug(sql) - log.debug(values) - return self.db.runOperation(sql, values) - - def run_query(self, sql, values): - log.debug(sql) - log.debug(values) - return self.db.runQuery(sql, values) - class BaseDatabase(SQLiteMixin): @@ -438,10 +429,11 @@ class BaseDatabase(SQLiteMixin): async def select_addresses(self, cols, **constraints): return await self.db.execute_fetchall(*query( - "SELECT {} FROM pubkey_address".format(cols), **constraints - )) + "SELECT {} FROM pubkey_address".format(cols), **constraints + )) - async def get_addresses(self, cols=('address', 'account', 'chain', 'position', 'used_times'), **constraints): + async def get_addresses(self, cols=('address', 'account', 'chain', 'position', 'used_times'), + **constraints): addresses = await self.select_addresses(', '.join(cols), **constraints) return rows_to_dict(addresses, cols) diff --git a/torba/basetransaction.py b/torba/basetransaction.py index dca0fb2f8..3ac582b88 100644 --- a/torba/basetransaction.py +++ b/torba/basetransaction.py @@ -425,7 +425,7 @@ class BaseTransaction: @classmethod async def create(cls, inputs: Iterable[BaseInput], outputs: Iterable[BaseOutput], - funding_accounts: Iterable[BaseAccount], change_account: BaseAccount): + funding_accounts: Iterable[BaseAccount], change_account: BaseAccount): """ Find optimal set of inputs when only outputs are provided; add change outputs if only inputs are provided or if inputs are greater than outputs. """