tree: consistently group and sort import statements
This commit is contained in:
parent
35326b2b7b
commit
fb2a4b09bd
|
@ -31,6 +31,17 @@ modules.
|
|||
those bellow) which wont necessarily be shown
|
||||
- use lowercase hexadecimal literals
|
||||
|
||||
### Grouping and sorting of import statements
|
||||
|
||||
In normal modules, import statements should be grouped into standard library
|
||||
modules, modules from third-party libraries, and local modules.
|
||||
|
||||
In test modules, an additional group for test scaffolding modules (inclunding
|
||||
`pytest` and `_testutils`) should come before the standard library modules.
|
||||
|
||||
Within each group, `import` statements should come before `from <...> import`
|
||||
ones. After that, they should be sorted ascending order.
|
||||
|
||||
|
||||
## Use of automatic formatters
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ Copyright (C) 2018–2021 Jonas Malaco
|
|||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""
|
||||
|
||||
from time import sleep
|
||||
import ast
|
||||
from time import sleep
|
||||
|
||||
from docopt import docopt
|
||||
from liquidctl.driver.kraken_two import KrakenTwoDriver
|
||||
|
|
|
@ -44,7 +44,6 @@ import time
|
|||
|
||||
import liquidctl.cli as _borrow
|
||||
import usb
|
||||
|
||||
from docopt import docopt
|
||||
from liquidctl.driver import *
|
||||
|
||||
|
|
|
@ -29,12 +29,12 @@ import logging
|
|||
import sys
|
||||
import time
|
||||
import usb
|
||||
from datetime import timedelta
|
||||
|
||||
from docopt import docopt
|
||||
from liquidctl.driver import *
|
||||
from prometheus_client import start_http_server
|
||||
from prometheus_client.core import GaugeMetricFamily, REGISTRY, InfoMetricFamily
|
||||
from datetime import timedelta
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -63,7 +63,6 @@ import sys
|
|||
import time
|
||||
|
||||
from docopt import docopt
|
||||
|
||||
import liquidctl.cli as _borrow
|
||||
from liquidctl.util import normalize_profile, interpolate_profile
|
||||
from liquidctl.driver import *
|
||||
|
|
|
@ -64,11 +64,11 @@ PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|||
"""
|
||||
|
||||
import datetime
|
||||
import errno
|
||||
import inspect
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import errno
|
||||
|
||||
from docopt import docopt
|
||||
|
||||
|
@ -77,7 +77,6 @@ from liquidctl.error import NotSupportedByDevice, NotSupportedByDriver, UnsafeFe
|
|||
from liquidctl.util import color_from_str
|
||||
from liquidctl.version import __version__
|
||||
|
||||
|
||||
# conversion from CLI arg to internal option; as options as forwarded to bused
|
||||
# and drivers, they must:
|
||||
# - have no default value in the CLI level (not forwarded unless explicitly set);
|
||||
|
|
|
@ -22,16 +22,16 @@ import sys
|
|||
|
||||
from liquidctl.driver.base import BaseBus, find_all_subclasses
|
||||
|
||||
# automatically enabled drivers
|
||||
from liquidctl.driver import asetek
|
||||
from liquidctl.driver import commander_pro
|
||||
from liquidctl.driver import corsair_hid_psu
|
||||
from liquidctl.driver import hydro_platinum
|
||||
from liquidctl.driver import commander_pro
|
||||
from liquidctl.driver import kraken2
|
||||
from liquidctl.driver import kraken3
|
||||
from liquidctl.driver import nzxt_epsu
|
||||
from liquidctl.driver import rgb_fusion2
|
||||
from liquidctl.driver import smart_device
|
||||
|
||||
if sys.platform == 'linux':
|
||||
from liquidctl.driver import ddr4
|
||||
from liquidctl.driver import nvidia
|
||||
|
|
|
@ -4,7 +4,6 @@ Copyright (C) 2018–2019 Jonas Malaco and contributors
|
|||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""
|
||||
|
||||
|
||||
class BaseDriver:
|
||||
"""Base driver API.
|
||||
|
||||
|
|
|
@ -18,14 +18,13 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||
import itertools
|
||||
import logging
|
||||
import re
|
||||
|
||||
from enum import Enum, unique
|
||||
|
||||
from liquidctl.driver.usb import UsbHidDriver
|
||||
from liquidctl.error import NotSupportedByDevice
|
||||
from liquidctl.keyval import RuntimeStorage
|
||||
from liquidctl.pmbus import compute_pec
|
||||
from liquidctl.util import clamp, fraction_of_byte, u16be_from, u16le_from, normalize_profile, check_unsafe
|
||||
from liquidctl.error import NotSupportedByDevice
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from datetime import timedelta
|
||||
from enum import Enum
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@ Copyright (C) 2020–2021 Jonas Malaco and contributors
|
|||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""
|
||||
|
||||
from enum import Enum, unique
|
||||
from collections import namedtuple
|
||||
import itertools
|
||||
import logging
|
||||
from collections import namedtuple
|
||||
from enum import Enum, unique
|
||||
|
||||
from liquidctl.driver.smbus import SmbusDriver
|
||||
from liquidctl.error import ExpectationNotMet, NotSupportedByDevice, NotSupportedByDriver
|
||||
|
|
|
@ -16,7 +16,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||
import itertools
|
||||
import logging
|
||||
import re
|
||||
|
||||
from enum import Enum, unique
|
||||
|
||||
from liquidctl.driver.usb import UsbHidDriver
|
||||
|
|
|
@ -9,8 +9,8 @@ Copyright (C) 2020–2021 Tom Frey, Jonas Malaco and contributors
|
|||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""
|
||||
|
||||
import logging
|
||||
import itertools
|
||||
import logging
|
||||
|
||||
from liquidctl.driver.usb import UsbHidDriver
|
||||
from liquidctl.util import normalize_profile, interpolate_profile, clamp, \
|
||||
|
|
|
@ -4,8 +4,8 @@ Copyright (C) 2020–2021 Jonas Malaco, Marshall Asch and contributors
|
|||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""
|
||||
|
||||
from enum import unique
|
||||
import logging
|
||||
from enum import unique
|
||||
|
||||
from liquidctl.driver.smbus import SmbusDriver
|
||||
from liquidctl.error import NotSupportedByDevice
|
||||
|
|
|
@ -9,9 +9,9 @@ Copyright (C) 2020–2021 CaseySJ, Jonas Malaco and contributors
|
|||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""
|
||||
|
||||
from collections import namedtuple
|
||||
import logging
|
||||
import sys
|
||||
from collections import namedtuple
|
||||
|
||||
from liquidctl.driver.usb import UsbHidDriver
|
||||
from liquidctl.error import NotSupportedByDevice
|
||||
|
|
|
@ -6,11 +6,11 @@ Copyright (C) 2020–2021 Jonas Malaco and contributors
|
|||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""
|
||||
|
||||
from collections import namedtuple
|
||||
from pathlib import Path
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from collections import namedtuple
|
||||
from pathlib import Path
|
||||
|
||||
from liquidctl.driver.base import BaseDriver, BaseBus, find_all_subclasses
|
||||
from liquidctl.util import check_unsafe, LazyHexRepr
|
||||
|
|
|
@ -4,7 +4,6 @@ Copyright (C) 2020–2021 Jonas Malaco and contributors
|
|||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""
|
||||
|
||||
|
||||
class ExpectationNotMet(Exception):
|
||||
"""Unstable."""
|
||||
pass
|
||||
|
|
|
@ -8,7 +8,6 @@ import logging
|
|||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from ast import literal_eval
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
|
|
@ -35,7 +35,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||
"""
|
||||
|
||||
import math
|
||||
|
||||
from enum import IntEnum, IntFlag, unique
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||
|
||||
import colorsys
|
||||
import logging
|
||||
|
||||
from ast import literal_eval
|
||||
from enum import Enum, EnumMeta, unique
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import os
|
||||
from copy import deepcopy
|
||||
from collections import deque, namedtuple
|
||||
from copy import deepcopy
|
||||
|
||||
Report = namedtuple('Report', ['number', 'data'])
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import pytest
|
||||
|
||||
from liquidctl.driver.base import BaseDriver
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import pytest
|
||||
from collections import deque
|
||||
from liquidctl.driver.asetek import Modern690Lc, Legacy690Lc, Hydro690Lc
|
||||
from _testutils import noop
|
||||
|
||||
from collections import deque
|
||||
|
||||
from liquidctl.driver.asetek import Modern690Lc, Legacy690Lc, Hydro690Lc
|
||||
|
||||
|
||||
class _Mock690LcDevice():
|
||||
def __init__(self, vendor_id=None, product_id=None, release_number=None,
|
||||
|
|
|
@ -6,9 +6,10 @@ community.
|
|||
"""
|
||||
|
||||
import pytest
|
||||
from _testutils import MockHidapiDevice
|
||||
|
||||
from liquidctl.driver.kraken_two import KrakenTwoDriver
|
||||
from liquidctl.version import __version__
|
||||
from _testutils import MockHidapiDevice
|
||||
|
||||
SPECTRUM = [
|
||||
(235, 77, 40),
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
"""Test backwards compatibility with liquidctl 1.1.0."""
|
||||
|
||||
import pytest
|
||||
|
||||
import usb
|
||||
|
||||
from liquidctl.driver.kraken2 import Kraken2
|
||||
from liquidctl.driver.usb import hid, HidapiDevice
|
||||
import usb
|
||||
import pytest
|
||||
|
||||
|
||||
class _MockPyUsbHandle(usb.core.Device):
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import pytest
|
||||
|
||||
from _testutils import MockHidapiDevice
|
||||
|
||||
RADICAL_RED = [0xff, 0x35, 0x5e]
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import pytest
|
||||
from _testutils import MockHidapiDevice, Report, MockRuntimeStorage
|
||||
|
||||
from liquidctl.driver.commander_pro import _quoted, _prepare_profile, _get_fan_mode_description, CommanderPro
|
||||
from liquidctl.error import NotSupportedByDevice
|
||||
|
||||
from _testutils import MockHidapiDevice, Report, MockRuntimeStorage
|
||||
|
||||
# hardcoded responce data expected for some of the calls:
|
||||
# commander pro: firmware request (0.9.214)
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import pytest
|
||||
from liquidctl.driver.corsair_hid_psu import CorsairHidPsu
|
||||
from _testutils import MockHidapiDevice, Report
|
||||
|
||||
from liquidctl.driver.corsair_hid_psu import CorsairHidPsu
|
||||
|
||||
|
||||
class _MockPsuDevice(MockHidapiDevice):
|
||||
def write(self, data):
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import pytest
|
||||
from _testutils import VirtualSmbus
|
||||
|
||||
from liquidctl.driver.ddr4 import *
|
||||
from liquidctl.error import *
|
||||
import pytest
|
||||
|
||||
from _testutils import VirtualSmbus
|
||||
|
||||
|
||||
# SPD samples
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from pytest import fixture
|
||||
|
||||
from liquidctl.driver.usb import HidapiDevice
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import pytest
|
||||
from _testutils import MockHidapiDevice, Report, MockRuntimeStorage
|
||||
|
||||
from liquidctl.driver.hydro_platinum import HydroPlatinum, _sequence
|
||||
from liquidctl.pmbus import compute_pec
|
||||
from _testutils import MockHidapiDevice, Report, MockRuntimeStorage
|
||||
|
||||
_SAMPLE_PATH = (r'IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/XHC@14/XH'
|
||||
r'C@14000000/HS11@14a00000/USB2.0 Hub@14a00000/AppleUSB20InternalH'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_fs_backend_handles_values_corupted_with_nulls(tmpdir, caplog):
|
||||
from liquidctl.keyval import _FilesystemBackend
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import pytest
|
||||
from liquidctl.driver.kraken2 import Kraken2
|
||||
from _testutils import MockHidapiDevice
|
||||
|
||||
from liquidctl.driver.kraken2 import Kraken2
|
||||
from liquidctl.error import NotSupportedByDevice
|
||||
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import pytest
|
||||
from _testutils import MockHidapiDevice, Report
|
||||
|
||||
from liquidctl.driver.kraken3 import KrakenX3, KrakenZ3
|
||||
from liquidctl.driver.kraken3 import _COLOR_CHANNELS_KRAKENX
|
||||
from liquidctl.driver.kraken3 import _SPEED_CHANNELS_KRAKENX
|
||||
from liquidctl.driver.kraken3 import _SPEED_CHANNELS_KRAKENZ
|
||||
from liquidctl.util import Hue2Accessory
|
||||
from liquidctl.util import HUE2_MAX_ACCESSORIES_IN_CHANNEL as MAX_ACCESSORIES
|
||||
from liquidctl.util import Hue2Accessory
|
||||
|
||||
from _testutils import MockHidapiDevice, Report
|
||||
|
||||
# https://github.com/liquidctl/liquidctl/issues/160#issuecomment-664044103
|
||||
_SAMPLE_STATUS = bytes.fromhex(
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import pytest
|
||||
from _testutils import VirtualSmbus
|
||||
|
||||
from liquidctl.driver.nvidia import *
|
||||
from liquidctl.error import *
|
||||
import pytest
|
||||
|
||||
from _testutils import VirtualSmbus
|
||||
|
||||
|
||||
# EVGA Pascal
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import pytest
|
||||
from liquidctl.driver.nzxt_epsu import NzxtEPsu
|
||||
from _testutils import MockHidapiDevice, Report
|
||||
|
||||
from liquidctl.driver.nzxt_epsu import NzxtEPsu
|
||||
|
||||
|
||||
class _MockPsuDevice(MockHidapiDevice):
|
||||
def write(self, data):
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import pytest
|
||||
from collections import deque
|
||||
from liquidctl.driver.rgb_fusion2 import RgbFusion2
|
||||
from _testutils import MockHidapiDevice, Report
|
||||
|
||||
from collections import deque
|
||||
|
||||
from liquidctl.driver.rgb_fusion2 import RgbFusion2
|
||||
|
||||
# Sample data for 5702 controller from a Gigabyte Z490 Vision D
|
||||
# https://github.com/liquidctl/liquidctl/issues/151#issuecomment-663213956
|
||||
_INIT_5702_DATA = bytes.fromhex(
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import pytest
|
||||
from liquidctl.driver.smart_device import SmartDevice
|
||||
from _testutils import MockHidapiDevice, Report
|
||||
|
||||
from liquidctl.driver.smart_device import SmartDevice
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mockSmartDevice():
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import pytest
|
||||
from liquidctl.driver.smart_device import SmartDevice2
|
||||
from _testutils import MockHidapiDevice, Report
|
||||
|
||||
from liquidctl.driver.smart_device import SmartDevice2
|
||||
|
||||
|
||||
class _MockSmartDevice2(MockHidapiDevice):
|
||||
def __init__(self, raw_speed_channels, raw_led_channels):
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import pytest
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from liquidctl.driver.smbus import LinuxI2c, LinuxI2cBus, SmbusDriver
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
class Canary(SmbusDriver):
|
||||
"""Canary driver to reveal if SMBus probing is taking place."""
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import pytest
|
||||
from _testutils import MockHidapiDevice
|
||||
|
||||
from liquidctl.driver.usb import UsbDriver, UsbHidDriver
|
||||
|
||||
from _testutils import MockHidapiDevice
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def emulated_hid_device():
|
||||
|
|
Loading…
Reference in New Issue