pylint throughout (excluding tests) - imports

This commit is contained in:
The MMGen Project 2023-10-11 12:58:48 +00:00
commit 4f42233836
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
40 changed files with 37 additions and 51 deletions

View file

@ -54,7 +54,6 @@ class AddrData(MMGenObject):
return (list(d.values())[0][0]) if d else None
def add(self,addrlist):
from .addrlist import AddrList
if type(addrlist) == AddrList:
self.al_ids[addrlist.al_id] = addrlist
return True

View file

@ -251,7 +251,8 @@ class AddrList(MMGenObject): # Address info for a single seed ID
gen_viewkey = type(self) in (KeyAddrList,ViewKeyAddrList) and 'viewkey' in mmtype.extra_attrs
if self.gen_addrs:
from .addrgen import KeyGenerator,AddrGenerator
from .keygen import KeyGenerator
from .addrgen import AddrGenerator
kg = KeyGenerator( self.cfg, self.proto, mmtype.pubkey_type )
ag = AddrGenerator( self.cfg, self.proto, mmtype )
if self.add_p2pkh:
@ -377,7 +378,8 @@ class AddrList(MMGenObject): # Address info for a single seed ID
"""
def gen_addr(pk,t):
at = self.proto.addr_type(t)
from .addrgen import KeyGenerator,AddrGenerator
from .keygen import KeyGenerator
from .addrgen import AddrGenerator
kg = KeyGenerator( self.cfg, self.proto, at.pubkey_type )
ag = AddrGenerator( self.cfg, self.proto, at )
return ag.to_addr(kg.gen_data(pk))

View file

@ -36,6 +36,7 @@ altcoin.py - Coin constants for Bitcoin-derived altcoins
# NBT: 150/191 c/u, 25/('B'), 26/('B')
import sys
from collections import namedtuple
from .cfg import gc,Config
from .util import msg
@ -57,7 +58,6 @@ def test_equal(desc,a,b,*cdata):
b_desc,
b ))
from collections import namedtuple
ce = namedtuple('CoinInfoEntry',
['name','symbol','wif_ver_num','p2pkh_info','p2sh_info','has_segwit','trust_level'])

View file

@ -14,8 +14,7 @@ autosign: Auto-sign MMGen transactions, message files and XMR wallet output file
import sys,os,asyncio
from pathlib import Path
from subprocess import run,PIPE,DEVNULL
from collections import namedtuple
from subprocess import run,DEVNULL
from .cfg import Config
from .util import msg,msg_r,ymsg,rmsg,gmsg,bmsg,die,suf,fmt,fmt_list,async_run
@ -487,7 +486,6 @@ class Autosign:
cfg = self.cfg,
prompt = f"Default wallet '{wf}' found.\nUse default wallet for autosigning?",
default_yes = True ):
from .cfg import Config
ss_in = Wallet( Config(), wf )
else:
ss_in = Wallet( self.cfg, in_fmt=self.mn_fmts[self.cfg.mnemonic_fmt or self.dfl_mn_fmt] )
@ -497,7 +495,6 @@ class Autosign:
@property
def xmrwallet_cfg(self):
if not hasattr(self,'_xmrwallet_cfg'):
from .cfg import Config
self._xmrwallet_cfg = Config({
'_clone': self.cfg,
'coin': 'xmr',

View file

@ -27,7 +27,7 @@ from collections import namedtuple
from .cfg import gc
from .base_obj import Lockable
from .color import set_vt100
from .util import msg,Msg_r,ymsg,die,remove_dups,oneshot_warning,fmt_list
from .util import msg,Msg_r,die,remove_dups,oneshot_warning,fmt_list
from .flags import ClassFlags,ClassOpts
_dd = namedtuple('daemon_data',['coind_name','coind_version','coind_version_str']) # latest tested version

View file

@ -73,7 +73,6 @@ class LEDControl:
else:
break
else:
from .util import die
die( 'NoLEDSupport', 'Control files not found! LED control not supported on this system' )
msg(f'{board.name} board detected')
@ -93,7 +92,6 @@ class LEDControl:
fp.write(f'{init_val}\n')
return True
except PermissionError:
from .util import die
die(2,'\n'+fmt(f"""
You do not have access to the {desc} file
To allow access, run the following command:

View file

@ -15,7 +15,7 @@ msg: base message signing classes
import os,importlib,json
from .cfg import gc
from .objmethods import MMGenObject,Hilite,InitErrors
from .util import msg,die,suf,make_chksum_6,fmt_list,remove_dups
from .util import msg,die,make_chksum_6,fmt_list,remove_dups
from .color import red,orange,grnbg
from .protocol import init_proto
from .fileutil import get_data_from_file,write_data_to_file

View file

@ -20,7 +20,7 @@
obj: MMGen native classes
"""
import sys,os,re,unicodedata
import unicodedata
from .objmethods import MMGenObject,Hilite,InitErrors

View file

@ -21,10 +21,9 @@ opts: MMGen-specific command-line options processing after generic processing by
"""
import sys,os
from .share import Opts
from .cfg import gc
import mmgen.share.Opts as Opts
def opt_preproc_debug(po):
d = (
('Cmdline', ' '.join(sys.argv), False),
@ -34,7 +33,6 @@ def opt_preproc_debug(po):
('Opts', po.opts, True),
)
from .util import Msg,fmt_list
from pprint import pformat
Msg('\n=== opts.py debug ===')
for label,data,pretty in d:
Msg(' {:<20}: {}'.format(label,'\n' + fmt_list(data,fmt='col',indent=' '*8) if pretty else data))

View file

@ -78,7 +78,7 @@ class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp
def decode_addr(self,addr):
if 'B' in self.mmtypes and addr[:len(self.bech32_hrp)] == self.bech32_hrp:
import mmgen.contrib.bech32 as bech32
from ...contrib import bech32
ret = bech32.decode(self.bech32_hrp,addr)
if ret[0] != self.witness_vernum:
@ -109,7 +109,7 @@ class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp
p2sh = True )
def pubhash2bech32addr(self,pubhash):
import mmgen.contrib.bech32 as bech32
from ...contrib import bech32
return bech32.bech32_encode(
hrp = self.bech32_hrp,
data = [self.witness_vernum] + bech32.convertbits(list(pubhash),8,5) )

View file

@ -15,8 +15,7 @@ proto.btc.tw.addresses: Bitcoin base protocol tracking wallet address list class
from ....tw.addresses import TwAddresses
from ....tw.shared import TwLabel
from ....util import msg,msg_r
from ....addr import CoinAddr
from ....obj import NonNegativeInt,get_obj
from ....obj import get_obj
from .rpc import BitcoinTwRPC
class BitcoinTwAddresses(TwAddresses,BitcoinTwRPC):

View file

@ -14,7 +14,6 @@ proto.btc.tw.rpc: Bitcoin base protocol tracking wallet RPC classes
from ....addr import CoinAddr
from ....util import die,msg,rmsg
from ....obj import MMGenList
from ....tw.shared import get_tw_label
from ....tw.rpc import TwRPC

View file

@ -13,7 +13,6 @@ proto.btc.tw.unspent: Bitcoin base protocol tracking wallet unspent outputs clas
"""
from ....tw.unspent import TwUnspentOutputs
from ....addr import CoinAddr
class BitcoinTwUnspentOutputs(TwUnspentOutputs):

View file

@ -15,7 +15,7 @@ proto.btc.tx.base: Bitcoin base transaction class
from collections import namedtuple
import mmgen.tx.base as TxBase
from ....obj import MMGenObject,MMGenList,HexStr
from ....obj import MMGenList,HexStr
from ....util import msg,make_chksum_6,die,pp_fmt
def addr2scriptPubKey(proto,addr):

View file

@ -14,7 +14,7 @@ proto.btc.tx.new: Bitcoin new transaction class
import mmgen.tx.new as TxBase
from .base import Base
from ....obj import HexStr,MMGenTxID
from ....obj import MMGenTxID
from ....util import msg,fmt,make_chksum_6,die
class New(Base,TxBase.New):

View file

@ -12,6 +12,8 @@
proto.btc.tx.online: Bitcoin online signed transaction class
"""
import sys
import mmgen.tx.online as TxBase
from .signed import Signed
from ....util import msg,ymsg,rmsg,die

View file

@ -14,7 +14,7 @@ proto.btc.tx.unsigned: Bitcoin unsigned transaction class
import mmgen.tx.unsigned as TxBase
from .completed import Completed
from ....obj import HexStr,CoinTxID,MMGenDict
from ....obj import CoinTxID,MMGenDict
from ....util import msg,msg_r,ymsg,suf,die
class Unsigned(Completed,TxBase.Unsigned):
@ -22,6 +22,7 @@ class Unsigned(Completed,TxBase.Unsigned):
async def sign(self,tx_num_str,keys): # return signed object or False; don't exit or raise exception
from ....exception import TransactionChainMismatch
try:
self.check_correct_chain()
except TransactionChainMismatch:

View file

@ -13,8 +13,6 @@ proto.eth.tw.addresses: Ethereum base protocol tracking wallet address list clas
"""
from ....tw.addresses import TwAddresses
from ....tw.ctl import TwCtl
from ....addr import CoinAddr
from .view import EthereumTwView
from .rpc import EthereumTwRPC

View file

@ -12,7 +12,6 @@
proto.eth.tw.rpc: Ethereum base protocol tracking wallet RPC class
"""
from ....tw.ctl import TwCtl
from ....addr import CoinAddr
from ....tw.shared import TwLabel
from ....tw.rpc import TwRPC

View file

@ -12,10 +12,11 @@
proto.eth.tx.bump: Ethereum transaction bump class
"""
from decimal import Decimal
import mmgen.tx.bump as TxBase
from .completed import Completed,TokenCompleted
from .new import New,TokenNew
from decimal import Decimal
class Bump(Completed,New,TxBase.Bump):
desc = 'fee-bumped transaction'

View file

@ -47,6 +47,7 @@ class OnlineSigned(Signed,TxBase.OnlineSigned):
if ret is False: # TODO: unreachable code
rmsg(f'Send of MMGen transaction {self.txid} failed')
if exit_on_fail:
import sys
sys.exit(1)
return False
else:

View file

@ -14,7 +14,6 @@ proto.eth.tx.signed: Ethereum signed transaction class
import mmgen.tx.signed as TxBase
from .completed import Completed,TokenCompleted
from ..contract import Token
from ....obj import Str,CoinTxID,ETHNonce,HexStr
from ....addr import CoinAddr,TokenAddr

View file

@ -17,7 +17,7 @@ import json
import mmgen.tx.unsigned as TxBase
from .completed import Completed,TokenCompleted
from ..contract import Token
from ....util import msg,msg_r,ymsg
from ....util import msg,msg_r
from ....obj import Str,CoinTxID,ETHNonce,Int,HexStr
from ....addr import CoinAddr,TokenAddr
@ -68,6 +68,7 @@ class Unsigned(Completed,TxBase.Unsigned):
async def sign(self,tx_num_str,keys): # return TX object or False; don't exit or raise exception
from ....exception import TransactionChainMismatch
try:
self.check_correct_chain()
except TransactionChainMismatch:

View file

@ -13,8 +13,7 @@ proto.zec.params: Zcash protocol
"""
from ..btc.params import mainnet
from ..btc.common import b58chk_decode
from ...protocol import decoded_wif,decoded_addr
from ...protocol import decoded_addr
from ...addr import CoinAddr
class ZcashViewKey(CoinAddr):

View file

@ -25,7 +25,6 @@ term: Terminal classes for the MMGen suite
import sys,os,time
from collections import namedtuple
from .cfg import gc
from .util import msg,msg_r,die
try:

View file

@ -20,8 +20,9 @@
tool.help: Help screen routines for the 'mmgen-tool' utility
"""
from mmgen import main_tool
from .common import tool_cmd_base
import mmgen.main_tool as main_tool
def main_help():

View file

@ -178,7 +178,6 @@ class tool_cmd(tool_cmd_base):
from ..tw.ctl import TwCtl
ret = await (await TwCtl(self.cfg,self.proto,mode='w')).resolve_address( mmgen_or_coin_addr )
if ret:
from ..util import Msg
from ..addr import is_coin_addr
return ret.twmmid if is_coin_addr(self.proto,mmgen_or_coin_addr) else ret.coinaddr
else:

View file

@ -13,7 +13,6 @@ tw.addresses: Tracking wallet listaddresses class for the MMGen suite
"""
from ..util import msg,suf,is_int
from ..objmethods import MMGenObject
from ..obj import MMGenListItem,ImmutableAttr,ListItemAttr,TwComment,NonNegativeInt
from ..addr import CoinAddr,MMGenID,MMGenAddrType
from ..color import red,green,yellow

View file

@ -20,8 +20,6 @@
tw.bal: Tracking wallet getbalance class for the MMGen suite
"""
from collections import namedtuple
from ..base_obj import AsyncInit
from ..objmethods import MMGenObject
from ..obj import NonNegativeInt

View file

@ -15,7 +15,6 @@ tw.txhistory: Tracking wallet transaction history class for the MMGen suite
from collections import namedtuple
from ..util import fmt
from ..objmethods import MMGenObject
from ..obj import NonNegativeInt
from .view import TwView

View file

@ -21,7 +21,6 @@ tw.unspent: Tracking wallet unspent outputs class for the MMGen suite
"""
from ..util import msg,suf,fmt
from ..objmethods import MMGenObject
from ..obj import (
ImmutableAttr,
ListItemAttr,

View file

@ -24,7 +24,7 @@ import sys,time,asyncio
from collections import namedtuple
from ..cfg import gc,gv
from ..objmethods import Hilite,InitErrors,MMGenObject
from ..objmethods import MMGenObject
from ..obj import get_obj,MMGenIdx,MMGenList
from ..color import nocolor,yellow,green,red,blue
from ..util import msg,msg_r,fmt,die,capfirst,make_timestr

View file

@ -12,12 +12,12 @@
tx.info: transaction info class
"""
import importlib
from ..cfg import gc
from ..color import red,green,orange
from ..util import msg,msg_r
import importlib
class TxInfo:
def __init__(self,tx):

View file

@ -58,6 +58,7 @@ def mmaddr2coinaddr(cfg,mmaddr,ad_w,ad_f,proto):
msg(wmsg('addr_in_addrfile_only'))
from ..ui import keypress_confirm
if not (cfg.yes or keypress_confirm( cfg, 'Continue anyway?' )):
import sys
sys.exit(1)
else:
die(2,wmsg('addr_not_found'))

View file

@ -14,7 +14,6 @@ ui: Interactive user interface functions for the MMGen suite
import sys,os
from .cfg import gc
from .util import msg,msg_r,Msg,die
def confirm_or_raise(cfg,message,action,expect='YES',exit_msg='Exiting at user request'):

View file

@ -12,7 +12,7 @@
util2: Less frequently-used variables, classes and utility functions for the MMGen suite
"""
import re,time
import sys,re,time
from .util import msg,suf,hexdigits,die
def die_wait(delay,ev=0,s=''):

View file

@ -16,7 +16,7 @@ import os
from ..util import msg,die
from ..objmethods import MMGenObject
from . import Wallet,wallet_data,get_wallet_cls
from . import wallet_data,get_wallet_cls
class WalletMeta(type):

View file

@ -25,7 +25,7 @@ from collections import namedtuple
from pathlib import Path
from .objmethods import MMGenObject,Hilite,InitErrors
from .obj import CoinTxID,Int
from .obj import CoinTxID
from .color import red,yellow,green,blue,cyan,pink,orange,purple
from .util import (
msg,

View file

@ -18,7 +18,7 @@
import sys,os
import mmgen.opts as opts
from mmgen import opts
from mmgen.cfg import gc,Config
from mmgen.util import msg,die

View file

@ -8,10 +8,10 @@
# https://github.com/mmgen/mmgen
# https://gitlab.com/mmgen/mmgen
import sys,os
import os
from subprocess import run,PIPE
from setuptools import setup,Extension
from setuptools.command.build_ext import build_ext
from subprocess import run,PIPE
cache_path = os.path.join(os.environ['HOME'],'.cache','mmgen')
ext_path = os.path.join(cache_path,'secp256k1')