forked from LBRYCommunity/lbry-sdk
pylint and mypy fixes
This commit is contained in:
parent
2c5fd4aade
commit
e10f1df321
5 changed files with 13 additions and 20 deletions
|
@ -14,7 +14,7 @@ jobs:
|
||||||
- pip install -e .
|
- pip install -e .
|
||||||
script:
|
script:
|
||||||
- pylint --rcfile=setup.cfg torba
|
- pylint --rcfile=setup.cfg torba
|
||||||
- mypy torba
|
- mypy --ignore-missing-imports torba
|
||||||
after_success: skip
|
after_success: skip
|
||||||
|
|
||||||
- &tests
|
- &tests
|
||||||
|
|
5
setup.py
5
setup.py
|
@ -12,7 +12,7 @@ setup(
|
||||||
description='Wallet library for bitcoin based currencies.',
|
description='Wallet library for bitcoin based currencies.',
|
||||||
keywords='wallet,crypto,currency,money,bitcoin,lbry',
|
keywords='wallet,crypto,currency,money,bitcoin,lbry',
|
||||||
classifiers=(
|
classifiers=(
|
||||||
'Framework :: Twisted',
|
'Framework :: AsyncIO',
|
||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Developers',
|
||||||
'Intended Audience :: System Administrators',
|
'Intended Audience :: System Administrators',
|
||||||
'License :: OSI Approved :: MIT License',
|
'License :: OSI Approved :: MIT License',
|
||||||
|
@ -26,7 +26,8 @@ setup(
|
||||||
packages=find_packages(exclude=('tests',)),
|
packages=find_packages(exclude=('tests',)),
|
||||||
python_requires='>=3.6',
|
python_requires='>=3.6',
|
||||||
install_requires=(
|
install_requires=(
|
||||||
'twisted',
|
'aiorpcx',
|
||||||
|
'aiosqlite',
|
||||||
'coincurve',
|
'coincurve',
|
||||||
'pbkdf2',
|
'pbkdf2',
|
||||||
'cryptography'
|
'cryptography'
|
||||||
|
|
|
@ -362,7 +362,7 @@ class BaseAccount:
|
||||||
return self.ledger.db.get_transaction_count(account=self, **constraints)
|
return self.ledger.db.get_transaction_count(account=self, **constraints)
|
||||||
|
|
||||||
async def fund(self, to_account, amount=None, everything=False,
|
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.'
|
assert self.ledger == to_account.ledger, 'Can only transfer between accounts of the same ledger.'
|
||||||
tx_class = self.ledger.transaction_class
|
tx_class = self.ledger.transaction_class
|
||||||
if everything:
|
if everything:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import logging
|
import logging
|
||||||
from typing import Tuple, List
|
from typing import Tuple, List, Union
|
||||||
|
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import aiosqlite
|
import aiosqlite
|
||||||
|
@ -134,7 +134,8 @@ class SQLiteMixin:
|
||||||
return sql, values
|
return sql, values
|
||||||
|
|
||||||
@staticmethod
|
@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 = [], []
|
columns, values = [], []
|
||||||
for column, value in data.items():
|
for column, value in data.items():
|
||||||
columns.append("{} = ?".format(column))
|
columns.append("{} = ?".format(column))
|
||||||
|
@ -151,16 +152,6 @@ class SQLiteMixin:
|
||||||
log.debug(values)
|
log.debug(values)
|
||||||
return t.execute(sql, 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):
|
class BaseDatabase(SQLiteMixin):
|
||||||
|
|
||||||
|
@ -438,10 +429,11 @@ class BaseDatabase(SQLiteMixin):
|
||||||
|
|
||||||
async def select_addresses(self, cols, **constraints):
|
async def select_addresses(self, cols, **constraints):
|
||||||
return await self.db.execute_fetchall(*query(
|
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)
|
addresses = await self.select_addresses(', '.join(cols), **constraints)
|
||||||
return rows_to_dict(addresses, cols)
|
return rows_to_dict(addresses, cols)
|
||||||
|
|
||||||
|
|
|
@ -425,7 +425,7 @@ class BaseTransaction:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def create(cls, inputs: Iterable[BaseInput], outputs: Iterable[BaseOutput],
|
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
|
""" 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. """
|
outputs if only inputs are provided or if inputs are greater than outputs. """
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue