ruff: Apply single line import format
# Usage pre-commit run --all-files Related #2295
This commit is contained in:
parent
66d31885e4
commit
5b09ace1f5
|
@ -9,7 +9,16 @@ import textwrap
|
|||
import typing
|
||||
import warnings
|
||||
|
||||
from typing import Any, Dict, Iterable, Iterator, List, Optional, Sequence, TextIO, Tuple, Union
|
||||
from typing import Any
|
||||
from typing import Dict
|
||||
from typing import Iterable
|
||||
from typing import Iterator
|
||||
from typing import List
|
||||
from typing import Optional
|
||||
from typing import Sequence
|
||||
from typing import TextIO
|
||||
from typing import Tuple
|
||||
from typing import Union
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import Literal
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
|
||||
import enum
|
||||
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
from typing import Any
|
||||
from typing import Dict
|
||||
from typing import List
|
||||
from typing import Optional
|
||||
from typing import Tuple
|
||||
|
||||
|
||||
class _DataMeta(type):
|
||||
|
|
|
@ -18,34 +18,30 @@
|
|||
import platform as _platform
|
||||
|
||||
if _platform.system() in ("Darwin", "Windows"):
|
||||
from hidapi.hidapi import (
|
||||
close, # noqa: F401
|
||||
enumerate, # noqa: F401
|
||||
find_paired_node, # noqa: F401
|
||||
find_paired_node_wpid, # noqa: F401
|
||||
get_manufacturer, # noqa: F401
|
||||
get_product, # noqa: F401
|
||||
get_serial, # noqa: F401
|
||||
monitor_glib, # noqa: F401
|
||||
open, # noqa: F401
|
||||
open_path, # noqa: F401
|
||||
read, # noqa: F401
|
||||
write, # noqa: F401
|
||||
)
|
||||
from hidapi.hidapi import close # noqa: F401
|
||||
from hidapi.hidapi import enumerate # noqa: F401
|
||||
from hidapi.hidapi import find_paired_node # noqa: F401
|
||||
from hidapi.hidapi import find_paired_node_wpid # noqa: F401
|
||||
from hidapi.hidapi import get_manufacturer # noqa: F401
|
||||
from hidapi.hidapi import get_product # noqa: F401
|
||||
from hidapi.hidapi import get_serial # noqa: F401
|
||||
from hidapi.hidapi import monitor_glib # noqa: F401
|
||||
from hidapi.hidapi import open # noqa: F401
|
||||
from hidapi.hidapi import open_path # noqa: F401
|
||||
from hidapi.hidapi import read # noqa: F401
|
||||
from hidapi.hidapi import write # noqa: F401
|
||||
else:
|
||||
from hidapi.udev import (
|
||||
close, # noqa: F401
|
||||
enumerate, # noqa: F401
|
||||
find_paired_node, # noqa: F401
|
||||
find_paired_node_wpid, # noqa: F401
|
||||
get_manufacturer, # noqa: F401
|
||||
get_product, # noqa: F401
|
||||
get_serial, # noqa: F401
|
||||
monitor_glib, # noqa: F401
|
||||
open, # noqa: F401
|
||||
open_path, # noqa: F401
|
||||
read, # noqa: F401
|
||||
write, # noqa: F401
|
||||
)
|
||||
from hidapi.udev import close # noqa: F401
|
||||
from hidapi.udev import enumerate # noqa: F401
|
||||
from hidapi.udev import find_paired_node # noqa: F401
|
||||
from hidapi.udev import find_paired_node_wpid # noqa: F401
|
||||
from hidapi.udev import get_manufacturer # noqa: F401
|
||||
from hidapi.udev import get_product # noqa: F401
|
||||
from hidapi.udev import get_serial # noqa: F401
|
||||
from hidapi.udev import monitor_glib # noqa: F401
|
||||
from hidapi.udev import open # noqa: F401
|
||||
from hidapi.udev import open_path # noqa: F401
|
||||
from hidapi.udev import read # noqa: F401
|
||||
from hidapi.udev import write # noqa: F401
|
||||
|
||||
__version__ = "0.9"
|
||||
|
|
|
@ -21,9 +21,11 @@ import readline
|
|||
import sys
|
||||
import time
|
||||
|
||||
from binascii import hexlify, unhexlify
|
||||
from binascii import hexlify
|
||||
from binascii import unhexlify
|
||||
from select import select as _select
|
||||
from threading import Lock, Thread
|
||||
from threading import Lock
|
||||
from threading import Thread
|
||||
|
||||
import hidapi as _hid
|
||||
|
||||
|
|
|
@ -30,8 +30,9 @@ from time import time as _timestamp
|
|||
|
||||
import hidapi as _hid
|
||||
|
||||
from . import exceptions, hidpp20
|
||||
from . import exceptions
|
||||
from . import hidpp10_constants as _hidpp10_constants
|
||||
from . import hidpp20
|
||||
from . import hidpp20_constants as _hidpp20_constants
|
||||
from .base_usb import ALL as _RECEIVER_USB_IDS
|
||||
from .common import strhex as _strhex
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
from binascii import hexlify as _hexlify
|
||||
from collections import namedtuple
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional, Union
|
||||
from typing import Optional
|
||||
from typing import Union
|
||||
|
||||
import yaml as _yaml
|
||||
|
||||
|
|
|
@ -25,8 +25,16 @@ from typing import Optional
|
|||
import hidapi as _hid
|
||||
import solaar.configuration as _configuration
|
||||
|
||||
from . import base, descriptors, exceptions, hidpp10, hidpp10_constants, hidpp20, hidpp20_constants, settings
|
||||
from .common import ALERT, Battery
|
||||
from . import base
|
||||
from . import descriptors
|
||||
from . import exceptions
|
||||
from . import hidpp10
|
||||
from . import hidpp10_constants
|
||||
from . import hidpp20
|
||||
from . import hidpp20_constants
|
||||
from . import settings
|
||||
from .common import ALERT
|
||||
from .common import Battery
|
||||
from .settings_templates import check_feature_settings as _check_feature_settings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
|
@ -21,12 +21,14 @@ import threading as _threading
|
|||
|
||||
from struct import pack as _pack
|
||||
from struct import unpack as _unpack
|
||||
from typing import List, Optional
|
||||
from typing import List
|
||||
from typing import Optional
|
||||
|
||||
import yaml as _yaml
|
||||
|
||||
from . import exceptions, special_keys
|
||||
from . import exceptions
|
||||
from . import hidpp10_constants as _hidpp10_constants
|
||||
from . import special_keys
|
||||
from .common import Battery
|
||||
from .common import FirmwareInfo as _FirmwareInfo
|
||||
from .common import NamedInt as _NamedInt
|
||||
|
@ -35,7 +37,14 @@ from .common import UnsortedNamedInts as _UnsortedNamedInts
|
|||
from .common import bytes2int as _bytes2int
|
||||
from .common import crc16 as _crc16
|
||||
from .common import int2bytes as _int2bytes
|
||||
from .hidpp20_constants import CHARGE_LEVEL, CHARGE_STATUS, CHARGE_TYPE, DEVICE_KIND, ERROR, FEATURE, FIRMWARE_KIND, GESTURE
|
||||
from .hidpp20_constants import CHARGE_LEVEL
|
||||
from .hidpp20_constants import CHARGE_STATUS
|
||||
from .hidpp20_constants import CHARGE_TYPE
|
||||
from .hidpp20_constants import DEVICE_KIND
|
||||
from .hidpp20_constants import ERROR
|
||||
from .hidpp20_constants import FEATURE
|
||||
from .hidpp20_constants import FIRMWARE_KIND
|
||||
from .hidpp20_constants import GESTURE
|
||||
from .i18n import _
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
|
@ -19,7 +19,8 @@ import logging
|
|||
import queue
|
||||
import threading
|
||||
|
||||
from . import base, exceptions
|
||||
from . import base
|
||||
from . import exceptions
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -23,8 +23,9 @@ import threading as _threading
|
|||
from struct import unpack as _unpack
|
||||
|
||||
from . import diversion as _diversion
|
||||
from . import hidpp10, hidpp20
|
||||
from . import hidpp10
|
||||
from . import hidpp10_constants as _hidpp10_constants
|
||||
from . import hidpp20
|
||||
from . import hidpp20_constants as _hidpp20_constants
|
||||
from . import settings_templates as _st
|
||||
from .base import DJ_MESSAGE_ID as _DJ_MESSAGE_ID
|
||||
|
|
|
@ -23,7 +23,9 @@ try:
|
|||
|
||||
gi.require_version("Notify", "0.7")
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import GLib, Gtk, Notify # this import is allowed to fail making the entire feature unavailable
|
||||
from gi.repository import GLib # this import is allowed to fail making the entire feature unavailable
|
||||
from gi.repository import Gtk # this import is allowed to fail making the entire feature unavailable
|
||||
from gi.repository import Notify # this import is allowed to fail making the entire feature unavailable
|
||||
|
||||
available = True
|
||||
except (ValueError, ImportError):
|
||||
|
|
|
@ -24,10 +24,13 @@ from typing import Optional
|
|||
import hidapi as _hid
|
||||
|
||||
from . import base as _base
|
||||
from . import exceptions, hidpp10, hidpp10_constants
|
||||
from . import exceptions
|
||||
from . import hidpp10
|
||||
from . import hidpp10_constants
|
||||
from .common import ALERT
|
||||
from .device import Device
|
||||
from .i18n import _, ngettext
|
||||
from .i18n import _
|
||||
from .i18n import ngettext
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -19,12 +19,14 @@ import logging
|
|||
import sys as _sys
|
||||
|
||||
from importlib import import_module
|
||||
from traceback import extract_tb, format_exc
|
||||
from traceback import extract_tb
|
||||
from traceback import format_exc
|
||||
|
||||
import logitech_receiver.device as _device
|
||||
import logitech_receiver.receiver as _receiver
|
||||
|
||||
from logitech_receiver.base import receivers, receivers_and_devices
|
||||
from logitech_receiver.base import receivers
|
||||
from logitech_receiver.base import receivers_and_devices
|
||||
|
||||
from solaar import NAME
|
||||
|
||||
|
|
|
@ -188,7 +188,8 @@ def run(receivers, args, find_receiver, find_device):
|
|||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gio, Gtk
|
||||
from gi.repository import Gio
|
||||
from gi.repository import Gtk
|
||||
|
||||
if Gtk.init_check()[0]: # can Gtk be initialized?
|
||||
APP_ID = "io.github.pwr_solaar.solaar"
|
||||
|
|
|
@ -18,7 +18,8 @@ from logitech_receiver import base as _base
|
|||
from logitech_receiver import hidpp10_constants as _hidpp10_constants
|
||||
from logitech_receiver.common import strhex as _strhex
|
||||
|
||||
from solaar.cli.show import _print_device, _print_receiver
|
||||
from solaar.cli.show import _print_device
|
||||
from solaar.cli.show import _print_receiver
|
||||
|
||||
_R = _hidpp10_constants.REGISTERS
|
||||
|
||||
|
|
|
@ -14,15 +14,18 @@
|
|||
## with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
from logitech_receiver import exceptions, hidpp10, hidpp20
|
||||
from logitech_receiver import exceptions
|
||||
from logitech_receiver import hidpp10
|
||||
from logitech_receiver import hidpp10_constants as _hidpp10_constants
|
||||
from logitech_receiver import hidpp20
|
||||
from logitech_receiver import hidpp20_constants as _hidpp20_constants
|
||||
from logitech_receiver import receiver as _receiver
|
||||
from logitech_receiver import settings_templates as _settings_templates
|
||||
from logitech_receiver.common import NamedInt as _NamedInt
|
||||
from logitech_receiver.common import strhex as _strhex
|
||||
|
||||
from solaar import NAME, __version__
|
||||
from solaar import NAME
|
||||
from solaar import __version__
|
||||
|
||||
_hidpp10 = hidpp10.Hidpp10()
|
||||
_hidpp20 = hidpp20.Hidpp20()
|
||||
|
|
|
@ -36,7 +36,8 @@ import solaar.ui as _ui
|
|||
import solaar.ui.common as _common
|
||||
import solaar.upower as _upower
|
||||
|
||||
from solaar import NAME, __version__
|
||||
from solaar import NAME
|
||||
from solaar import __version__
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -22,13 +22,20 @@ import yaml as _yaml
|
|||
from logitech_receiver.common import ALERT
|
||||
|
||||
from solaar.i18n import _
|
||||
from solaar.ui.config_panel import change_setting, record_setting
|
||||
from solaar.ui.config_panel import change_setting
|
||||
from solaar.ui.config_panel import record_setting
|
||||
from solaar.ui.window import find_device
|
||||
|
||||
from . import common, diversion_rules, notify, tray, window
|
||||
from . import common
|
||||
from . import diversion_rules
|
||||
from . import notify
|
||||
from . import tray
|
||||
from . import window
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gio, GLib, Gtk # NOQA: E402
|
||||
from gi.repository import Gio # NOQA: E402
|
||||
from gi.repository import GLib # NOQA: E402
|
||||
from gi.repository import Gtk # NOQA: E402
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@ import logging
|
|||
|
||||
from gi.repository import Gtk
|
||||
|
||||
from solaar import NAME, __version__
|
||||
from solaar import NAME
|
||||
from solaar import __version__
|
||||
from solaar.i18n import _
|
||||
|
||||
#
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
## with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
from gi.repository import Gdk, Gtk
|
||||
from gi.repository import Gdk
|
||||
from gi.repository import Gtk
|
||||
|
||||
from solaar.i18n import _
|
||||
|
||||
|
|
|
@ -22,7 +22,8 @@ from solaar.i18n import _
|
|||
from solaar.tasks import TaskRunner as _TaskRunner
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import GLib, Gtk # NOQA: E402
|
||||
from gi.repository import GLib # NOQA: E402
|
||||
from gi.repository import Gtk # NOQA: E402
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -25,12 +25,15 @@ from logitech_receiver.hidpp20 import LEDEffectSetting as _LEDEffectSetting
|
|||
from logitech_receiver.settings import KIND as _SETTING_KIND
|
||||
from logitech_receiver.settings import SENSITIVITY_IGNORE as _SENSITIVITY_IGNORE
|
||||
|
||||
from solaar.i18n import _, ngettext
|
||||
from solaar.i18n import _
|
||||
from solaar.i18n import ngettext
|
||||
|
||||
from .common import ui_async as _ui_async
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gdk, GLib, Gtk # NOQA: E402
|
||||
from gi.repository import Gdk # NOQA: E402
|
||||
from gi.repository import GLib # NOQA: E402
|
||||
from gi.repository import Gtk # NOQA: E402
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -17,17 +17,25 @@ import logging
|
|||
import string
|
||||
import threading
|
||||
|
||||
from collections import defaultdict, namedtuple
|
||||
from collections import defaultdict
|
||||
from collections import namedtuple
|
||||
from contextlib import contextmanager as contextlib_contextmanager
|
||||
from copy import copy
|
||||
from dataclasses import dataclass, field
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import field
|
||||
from shlex import quote as shlex_quote
|
||||
from typing import Dict
|
||||
|
||||
from gi.repository import Gdk, GObject, Gtk
|
||||
from gi.repository import Gdk
|
||||
from gi.repository import GObject
|
||||
from gi.repository import Gtk
|
||||
from logitech_receiver import diversion as _DIV
|
||||
from logitech_receiver.common import NamedInt, NamedInts, UnsortedNamedInts
|
||||
from logitech_receiver.diversion import CLICK, DEPRESS, RELEASE
|
||||
from logitech_receiver.common import NamedInt
|
||||
from logitech_receiver.common import NamedInts
|
||||
from logitech_receiver.common import UnsortedNamedInts
|
||||
from logitech_receiver.diversion import CLICK
|
||||
from logitech_receiver.diversion import DEPRESS
|
||||
from logitech_receiver.diversion import RELEASE
|
||||
from logitech_receiver.diversion import XK_KEYS as _XK_KEYS
|
||||
from logitech_receiver.diversion import Key as _Key
|
||||
from logitech_receiver.diversion import buttons as _buttons
|
||||
|
|
|
@ -34,7 +34,8 @@ try:
|
|||
|
||||
gi.require_version("Notify", "0.7")
|
||||
# this import is allowed to fail, in which case the entire feature is unavailable
|
||||
from gi.repository import GLib, Notify
|
||||
from gi.repository import GLib
|
||||
from gi.repository import Notify
|
||||
|
||||
# assumed to be working since the import succeeded
|
||||
available = True
|
||||
|
|
|
@ -16,10 +16,12 @@
|
|||
|
||||
import logging
|
||||
|
||||
from gi.repository import GLib, Gtk
|
||||
from gi.repository import GLib
|
||||
from gi.repository import Gtk
|
||||
from logitech_receiver import hidpp10_constants as _hidpp10_constants
|
||||
|
||||
from solaar.i18n import _, ngettext
|
||||
from solaar.i18n import _
|
||||
from solaar.i18n import ngettext
|
||||
|
||||
from . import icons as _icons
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@ from time import time as _timestamp
|
|||
|
||||
import gi
|
||||
|
||||
from gi.repository import GLib, Gtk
|
||||
from gi.repository import GLib
|
||||
from gi.repository import Gtk
|
||||
from gi.repository.Gdk import ScrollDirection
|
||||
|
||||
import solaar.gtk as gtk
|
||||
|
|
|
@ -24,7 +24,8 @@ from logitech_receiver.common import NamedInt as _NamedInt
|
|||
from logitech_receiver.common import NamedInts as _NamedInts
|
||||
|
||||
from solaar import NAME
|
||||
from solaar.i18n import _, ngettext
|
||||
from solaar.i18n import _
|
||||
from solaar.i18n import ngettext
|
||||
|
||||
from . import action as _action
|
||||
from . import config_panel as _config_panel
|
||||
|
@ -36,7 +37,9 @@ from .diversion_rules import show_window as _show_diversion_window
|
|||
# from solaar import __version__ as VERSION
|
||||
|
||||
gi.require_version("Gdk", "3.0")
|
||||
from gi.repository import Gdk, GLib, Gtk # NOQA: E402
|
||||
from gi.repository import Gdk # NOQA: E402
|
||||
from gi.repository import GLib # NOQA: E402
|
||||
from gi.repository import Gtk # NOQA: E402
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import pytest
|
||||
|
||||
from lib.logitech_receiver import hidpp10, hidpp10_constants
|
||||
from lib.logitech_receiver import hidpp10
|
||||
from lib.logitech_receiver import hidpp10_constants
|
||||
|
||||
|
||||
class FakeDevice:
|
||||
|
|
|
@ -5,7 +5,8 @@ from unittest import mock
|
|||
|
||||
import pytest
|
||||
|
||||
from lib.logitech_receiver import hidpp20, hidpp20_constants
|
||||
from lib.logitech_receiver import hidpp20
|
||||
from lib.logitech_receiver import hidpp20_constants
|
||||
|
||||
DEVICE = "test_device"
|
||||
_hidpp20 = hidpp20.Hidpp20()
|
||||
|
|
|
@ -2,7 +2,8 @@ from unittest import mock
|
|||
|
||||
import pytest
|
||||
|
||||
from logitech_receiver import exceptions, receiver
|
||||
from logitech_receiver import exceptions
|
||||
from logitech_receiver import receiver
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
Loading…
Reference in New Issue