From 2ef85d38686b053cb683d3841c033d5cd591dd2e Mon Sep 17 00:00:00 2001 From: UpstreamData Date: Thu, 11 Jan 2024 15:00:48 -0700 Subject: [PATCH] refactor: optimize imports. --- pyasic/miners/backends/bfgminer.py | 3 +-- pyasic/miners/backends/bmminer.py | 3 +-- pyasic/miners/backends/btminer.py | 4 +--- pyasic/miners/backends/cgminer.py | 3 +-- pyasic/miners/backends/cgminer_avalon.py | 1 - pyasic/miners/backends/epic.py | 5 ++--- pyasic/miners/backends/hiveon.py | 2 -- pyasic/miners/backends/luxminer.py | 12 ++---------- pyasic/miners/innosilicon/cgminer/T3X/T3H.py | 1 - pyasic/miners/types/avalonminer/A11X/A1166.py | 1 - pyasic/miners/types/avalonminer/A12X/A1246.py | 1 - pyasic/miners/types/whatsminer/M2X/M20S.py | 2 -- pyasic/miners/types/whatsminer/M2X/M21.py | 2 -- pyasic/miners/types/whatsminer/M2X/M21S.py | 2 -- pyasic/miners/types/whatsminer/M2X/M29.py | 2 -- pyasic/miners/types/whatsminer/M3X/M30.py | 2 -- pyasic/miners/types/whatsminer/M3X/M30K.py | 2 -- pyasic/miners/types/whatsminer/M3X/M30L.py | 2 -- pyasic/miners/types/whatsminer/M3X/M31.py | 2 -- pyasic/miners/types/whatsminer/M3X/M31H.py | 2 -- pyasic/miners/types/whatsminer/M3X/M31L.py | 2 -- pyasic/miners/types/whatsminer/M3X/M31SE.py | 2 -- pyasic/miners/types/whatsminer/M3X/M32.py | 2 -- pyasic/miners/types/whatsminer/M3X/M33.py | 2 -- pyasic/miners/types/whatsminer/M3X/M33S.py | 2 -- pyasic/miners/types/whatsminer/M3X/M36S.py | 2 -- pyasic/miners/types/whatsminer/M3X/M36S_Plus.py | 2 -- pyasic/miners/types/whatsminer/M3X/M36S_Plus_Plus.py | 2 -- pyasic/miners/types/whatsminer/M3X/M39.py | 2 -- pyasic/miners/types/whatsminer/M5X/M53.py | 2 -- pyasic/miners/types/whatsminer/M5X/M56.py | 2 -- pyasic/miners/unknown.py | 1 - pyasic/web/__init__.py | 1 - pyasic/web/epic.py | 3 +-- tests/miners_tests/__init__.py | 6 +----- 35 files changed, 10 insertions(+), 77 deletions(-) diff --git a/pyasic/miners/backends/bfgminer.py b/pyasic/miners/backends/bfgminer.py index 03b9b0de..0ce02197 100644 --- a/pyasic/miners/backends/bfgminer.py +++ b/pyasic/miners/backends/bfgminer.py @@ -14,8 +14,7 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -from collections import namedtuple -from typing import List, Optional, Tuple +from typing import List, Optional from pyasic.API.bfgminer import BFGMinerAPI from pyasic.config import MinerConfig diff --git a/pyasic/miners/backends/bmminer.py b/pyasic/miners/backends/bmminer.py index 8d49c810..1fd9225b 100644 --- a/pyasic/miners/backends/bmminer.py +++ b/pyasic/miners/backends/bmminer.py @@ -15,8 +15,7 @@ # ------------------------------------------------------------------------------ import logging -from collections import namedtuple -from typing import List, Optional, Tuple +from typing import List, Optional from pyasic.API.bmminer import BMMinerAPI from pyasic.config import MinerConfig diff --git a/pyasic/miners/backends/btminer.py b/pyasic/miners/backends/btminer.py index e5c7e991..60fb3e8b 100644 --- a/pyasic/miners/backends/btminer.py +++ b/pyasic/miners/backends/btminer.py @@ -15,8 +15,7 @@ # ------------------------------------------------------------------------------ import logging -from collections import namedtuple -from typing import List, Optional, Tuple +from typing import List, Optional from pyasic.API.btminer import BTMinerAPI from pyasic.config import MinerConfig, MiningModeConfig @@ -29,7 +28,6 @@ from pyasic.miners.base import ( DataLocations, DataOptions, RPCAPICommand, - WebAPICommand, ) BTMINER_DATA_LOC = DataLocations( diff --git a/pyasic/miners/backends/cgminer.py b/pyasic/miners/backends/cgminer.py index 5d533e4d..4789421f 100644 --- a/pyasic/miners/backends/cgminer.py +++ b/pyasic/miners/backends/cgminer.py @@ -15,8 +15,7 @@ # ------------------------------------------------------------------------------ import logging -from collections import namedtuple -from typing import List, Optional, Tuple +from typing import List, Optional from pyasic.API.cgminer import CGMinerAPI from pyasic.config import MinerConfig diff --git a/pyasic/miners/backends/cgminer_avalon.py b/pyasic/miners/backends/cgminer_avalon.py index ebc7b716..23bae3f0 100644 --- a/pyasic/miners/backends/cgminer_avalon.py +++ b/pyasic/miners/backends/cgminer_avalon.py @@ -14,7 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import logging import re from typing import List, Optional diff --git a/pyasic/miners/backends/epic.py b/pyasic/miners/backends/epic.py index 0914d0f8..83452263 100644 --- a/pyasic/miners/backends/epic.py +++ b/pyasic/miners/backends/epic.py @@ -14,10 +14,9 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -from typing import List, Optional, Tuple +from typing import List, Optional -from pyasic import MinerConfig -from pyasic.config import MinerConfig, MiningModeConfig +from pyasic.config import MinerConfig from pyasic.data import Fan, HashBoard from pyasic.data.error_codes import MinerErrorData, X19Error from pyasic.errors import APIError diff --git a/pyasic/miners/backends/hiveon.py b/pyasic/miners/backends/hiveon.py index 3b99bcf6..1ce6c12b 100644 --- a/pyasic/miners/backends/hiveon.py +++ b/pyasic/miners/backends/hiveon.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -from typing import Optional - from pyasic.miners.backends import BMMiner diff --git a/pyasic/miners/backends/luxminer.py b/pyasic/miners/backends/luxminer.py index 49f6ccea..b22260b9 100644 --- a/pyasic/miners/backends/luxminer.py +++ b/pyasic/miners/backends/luxminer.py @@ -13,18 +13,12 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ -import asyncio -import logging -from collections import namedtuple from typing import List, Optional, Tuple, Union -import toml - -from pyasic.API.bosminer import BOSMinerAPI from pyasic.API.luxminer import LUXMinerAPI from pyasic.config import MinerConfig from pyasic.data import Fan, HashBoard -from pyasic.data.error_codes import BraiinsOSError, MinerErrorData +from pyasic.data.error_codes import MinerErrorData from pyasic.errors import APIError from pyasic.miners.base import ( BaseMiner, @@ -32,9 +26,7 @@ from pyasic.miners.base import ( DataLocations, DataOptions, RPCAPICommand, - WebAPICommand, ) -from pyasic.web.braiins_os import BOSMinerWebAPI LUXMINER_DATA_LOC = DataLocations( **{ @@ -341,7 +333,7 @@ class LUXMiner(BaseMiner): return round(expected_rate / 1000000, 2) else: return round(expected_rate, 2) - except LookupError: + except (KeyError, IndexError): pass async def _is_mining(self) -> Optional[bool]: diff --git a/pyasic/miners/innosilicon/cgminer/T3X/T3H.py b/pyasic/miners/innosilicon/cgminer/T3X/T3H.py index 4c512fdd..593ef039 100644 --- a/pyasic/miners/innosilicon/cgminer/T3X/T3H.py +++ b/pyasic/miners/innosilicon/cgminer/T3X/T3H.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ -import logging from typing import List, Optional from pyasic.config import MinerConfig diff --git a/pyasic/miners/types/avalonminer/A11X/A1166.py b/pyasic/miners/types/avalonminer/A11X/A1166.py index e26136f7..685a0f53 100644 --- a/pyasic/miners/types/avalonminer/A11X/A1166.py +++ b/pyasic/miners/types/avalonminer/A11X/A1166.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings from pyasic.miners.makes import AvalonMiner diff --git a/pyasic/miners/types/avalonminer/A12X/A1246.py b/pyasic/miners/types/avalonminer/A12X/A1246.py index 98b3dd1a..b066a02b 100644 --- a/pyasic/miners/types/avalonminer/A12X/A1246.py +++ b/pyasic/miners/types/avalonminer/A12X/A1246.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings from pyasic.miners.makes import AvalonMiner diff --git a/pyasic/miners/types/whatsminer/M2X/M20S.py b/pyasic/miners/types/whatsminer/M2X/M20S.py index ccfa4d80..cbefb29d 100644 --- a/pyasic/miners/types/whatsminer/M2X/M20S.py +++ b/pyasic/miners/types/whatsminer/M2X/M20S.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M2X/M21.py b/pyasic/miners/types/whatsminer/M2X/M21.py index 1a2f811c..5b274895 100644 --- a/pyasic/miners/types/whatsminer/M2X/M21.py +++ b/pyasic/miners/types/whatsminer/M2X/M21.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M2X/M21S.py b/pyasic/miners/types/whatsminer/M2X/M21S.py index dd224341..7c63a150 100644 --- a/pyasic/miners/types/whatsminer/M2X/M21S.py +++ b/pyasic/miners/types/whatsminer/M2X/M21S.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M2X/M29.py b/pyasic/miners/types/whatsminer/M2X/M29.py index e3cd9d34..1d31fcfe 100644 --- a/pyasic/miners/types/whatsminer/M2X/M29.py +++ b/pyasic/miners/types/whatsminer/M2X/M29.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M30.py b/pyasic/miners/types/whatsminer/M3X/M30.py index 4e1aaf0d..a2ea42a6 100644 --- a/pyasic/miners/types/whatsminer/M3X/M30.py +++ b/pyasic/miners/types/whatsminer/M3X/M30.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M30K.py b/pyasic/miners/types/whatsminer/M3X/M30K.py index b951c10b..3177ef08 100644 --- a/pyasic/miners/types/whatsminer/M3X/M30K.py +++ b/pyasic/miners/types/whatsminer/M3X/M30K.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M30L.py b/pyasic/miners/types/whatsminer/M3X/M30L.py index 191b5e60..743ccc69 100644 --- a/pyasic/miners/types/whatsminer/M3X/M30L.py +++ b/pyasic/miners/types/whatsminer/M3X/M30L.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M31.py b/pyasic/miners/types/whatsminer/M3X/M31.py index 0e5b7003..405d64aa 100644 --- a/pyasic/miners/types/whatsminer/M3X/M31.py +++ b/pyasic/miners/types/whatsminer/M3X/M31.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M31H.py b/pyasic/miners/types/whatsminer/M3X/M31H.py index 64612a1b..f86e3467 100644 --- a/pyasic/miners/types/whatsminer/M3X/M31H.py +++ b/pyasic/miners/types/whatsminer/M3X/M31H.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M31L.py b/pyasic/miners/types/whatsminer/M3X/M31L.py index 7b30e980..8981b94e 100644 --- a/pyasic/miners/types/whatsminer/M3X/M31L.py +++ b/pyasic/miners/types/whatsminer/M3X/M31L.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M31SE.py b/pyasic/miners/types/whatsminer/M3X/M31SE.py index 5f6aff90..d8207ab6 100644 --- a/pyasic/miners/types/whatsminer/M3X/M31SE.py +++ b/pyasic/miners/types/whatsminer/M3X/M31SE.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M32.py b/pyasic/miners/types/whatsminer/M3X/M32.py index 15d066d3..01bc0078 100644 --- a/pyasic/miners/types/whatsminer/M3X/M32.py +++ b/pyasic/miners/types/whatsminer/M3X/M32.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M33.py b/pyasic/miners/types/whatsminer/M3X/M33.py index 373a79a8..c8955ea6 100644 --- a/pyasic/miners/types/whatsminer/M3X/M33.py +++ b/pyasic/miners/types/whatsminer/M3X/M33.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M33S.py b/pyasic/miners/types/whatsminer/M3X/M33S.py index 98390fc3..65d846ee 100644 --- a/pyasic/miners/types/whatsminer/M3X/M33S.py +++ b/pyasic/miners/types/whatsminer/M3X/M33S.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M36S.py b/pyasic/miners/types/whatsminer/M3X/M36S.py index b100851b..2bc177dc 100644 --- a/pyasic/miners/types/whatsminer/M3X/M36S.py +++ b/pyasic/miners/types/whatsminer/M3X/M36S.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M36S_Plus.py b/pyasic/miners/types/whatsminer/M3X/M36S_Plus.py index a1dc8826..27d169d2 100644 --- a/pyasic/miners/types/whatsminer/M3X/M36S_Plus.py +++ b/pyasic/miners/types/whatsminer/M3X/M36S_Plus.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M36S_Plus_Plus.py b/pyasic/miners/types/whatsminer/M3X/M36S_Plus_Plus.py index 6ce8dae9..e7e54d0c 100644 --- a/pyasic/miners/types/whatsminer/M3X/M36S_Plus_Plus.py +++ b/pyasic/miners/types/whatsminer/M3X/M36S_Plus_Plus.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M3X/M39.py b/pyasic/miners/types/whatsminer/M3X/M39.py index 6f8b24e1..ebefbc56 100644 --- a/pyasic/miners/types/whatsminer/M3X/M39.py +++ b/pyasic/miners/types/whatsminer/M3X/M39.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M5X/M53.py b/pyasic/miners/types/whatsminer/M5X/M53.py index 9e85eccc..d65c6500 100644 --- a/pyasic/miners/types/whatsminer/M5X/M53.py +++ b/pyasic/miners/types/whatsminer/M5X/M53.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/types/whatsminer/M5X/M56.py b/pyasic/miners/types/whatsminer/M5X/M56.py index 29326152..3d4e07b4 100644 --- a/pyasic/miners/types/whatsminer/M5X/M56.py +++ b/pyasic/miners/types/whatsminer/M5X/M56.py @@ -14,8 +14,6 @@ # limitations under the License. - # ------------------------------------------------------------------------------ -import warnings - from pyasic.miners.makes import WhatsMiner diff --git a/pyasic/miners/unknown.py b/pyasic/miners/unknown.py index c1b1cf97..ddffdc2c 100644 --- a/pyasic/miners/unknown.py +++ b/pyasic/miners/unknown.py @@ -20,7 +20,6 @@ from pyasic.API.unknown import UnknownAPI from pyasic.config import MinerConfig from pyasic.data import Fan, HashBoard, MinerData from pyasic.data.error_codes import MinerErrorData -from pyasic.errors import APIError from pyasic.miners.base import BaseMiner diff --git a/pyasic/web/__init__.py b/pyasic/web/__init__.py index c31c2e9b..72774619 100644 --- a/pyasic/web/__init__.py +++ b/pyasic/web/__init__.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ -import ipaddress import warnings from abc import ABC, abstractmethod from typing import Union diff --git a/pyasic/web/epic.py b/pyasic/web/epic.py index 2784edee..6482bdc5 100644 --- a/pyasic/web/epic.py +++ b/pyasic/web/epic.py @@ -14,13 +14,12 @@ # limitations under the License. - # ------------------------------------------------------------------------------ import json -import warnings from typing import Union import httpx from pyasic import settings -from pyasic.errors import APIError, APIWarning +from pyasic.errors import APIError from pyasic.web import BaseWebAPI diff --git a/tests/miners_tests/__init__.py b/tests/miners_tests/__init__.py index 1f77c638..82d8a246 100644 --- a/tests/miners_tests/__init__.py +++ b/tests/miners_tests/__init__.py @@ -13,16 +13,12 @@ # See the License for the specific language governing permissions and - # limitations under the License. - # ------------------------------------------------------------------------------ -import asyncio -import inspect -import sys import unittest import warnings from dataclasses import asdict from pyasic.miners.backends import CGMiner # noqa -from pyasic.miners.base import BaseMiner -from pyasic.miners.miner_factory import MINER_CLASSES, MinerFactory +from pyasic.miners.miner_factory import MINER_CLASSES class MinersTest(unittest.TestCase):