pylint and mypy fixes

This commit is contained in:
Lex Berezhny 2018-10-15 00:04:25 -04:00
parent 2c5fd4aade
commit e10f1df321
5 changed files with 13 additions and 20 deletions

View file

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

View file

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

View file

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

View file

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

View file

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