Browse Source

pylint throughout (excluding tests) - imports

The MMGen Project 1 year ago
parent
commit
4f42233836

+ 0 - 1
mmgen/addrdata.py

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

+ 4 - 2
mmgen/addrlist.py

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

+ 1 - 1
mmgen/altcoin.py

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

+ 1 - 4
mmgen/autosign.py

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

+ 1 - 1
mmgen/daemon.py

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

+ 0 - 2
mmgen/led.py

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

+ 1 - 1
mmgen/msg.py

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

+ 1 - 1
mmgen/obj.py

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

+ 1 - 3
mmgen/opts.py

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

+ 2 - 2
mmgen/proto/btc/params.py

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

+ 1 - 2
mmgen/proto/btc/tw/addresses.py

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

+ 0 - 1
mmgen/proto/btc/tw/rpc.py

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

+ 0 - 1
mmgen/proto/btc/tw/unspent.py

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

+ 1 - 1
mmgen/proto/btc/tx/base.py

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

+ 1 - 1
mmgen/proto/btc/tx/new.py

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

+ 2 - 0
mmgen/proto/btc/tx/online.py

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

+ 2 - 1
mmgen/proto/btc/tx/unsigned.py

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

+ 0 - 2
mmgen/proto/eth/tw/addresses.py

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

+ 0 - 1
mmgen/proto/eth/tw/rpc.py

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

+ 2 - 1
mmgen/proto/eth/tx/bump.py

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

+ 1 - 0
mmgen/proto/eth/tx/online.py

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

+ 0 - 1
mmgen/proto/eth/tx/signed.py

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

+ 2 - 1
mmgen/proto/eth/tx/unsigned.py

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

+ 1 - 2
mmgen/proto/zec/params.py

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

+ 0 - 1
mmgen/term.py

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

+ 2 - 1
mmgen/tool/help.py

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

+ 0 - 1
mmgen/tool/rpc.py

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

+ 0 - 1
mmgen/tw/addresses.py

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

+ 0 - 2
mmgen/tw/bal.py

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

+ 0 - 1
mmgen/tw/txhistory.py

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

+ 0 - 1
mmgen/tw/unspent.py

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

+ 1 - 1
mmgen/tw/view.py

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

+ 2 - 2
mmgen/tx/info.py

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

+ 1 - 0
mmgen/tx/new.py

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

+ 0 - 1
mmgen/ui.py

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

+ 1 - 1
mmgen/util2.py

@@ -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=''):

+ 1 - 1
mmgen/wallet/base.py

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

+ 1 - 1
mmgen/xmrwallet.py

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

+ 1 - 1
scripts/uninstall-mmgen.py

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

+ 2 - 2
setup.py

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