Skip to content

Commit

Permalink
ruff: Apply single line import format
Browse files Browse the repository at this point in the history
# Usage
pre-commit run --all-files

Related #2295
  • Loading branch information
MattHag committed Mar 13, 2024
1 parent be09206 commit 5e0a0c0
Show file tree
Hide file tree
Showing 30 changed files with 149 additions and 73 deletions.
11 changes: 10 additions & 1 deletion lib/hid_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@
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
Expand Down
6 changes: 5 additions & 1 deletion lib/hid_parser/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
52 changes: 24 additions & 28 deletions lib/hidapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
6 changes: 4 additions & 2 deletions lib/hidapi/hidconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
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

Expand Down
3 changes: 2 additions & 1 deletion lib/logitech_receiver/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@

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
Expand Down
3 changes: 2 additions & 1 deletion lib/logitech_receiver/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 10 additions & 2 deletions lib/logitech_receiver/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@
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__)
Expand Down
15 changes: 12 additions & 3 deletions lib/logitech_receiver/hidpp20.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@

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
Expand All @@ -35,7 +37,14 @@
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__)
Expand Down
3 changes: 2 additions & 1 deletion lib/logitech_receiver/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
import queue
import threading

from . import base, exceptions
from . import base
from . import exceptions

logger = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion lib/logitech_receiver/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
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
Expand Down
4 changes: 3 additions & 1 deletion lib/logitech_receiver/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@

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):
Expand Down
7 changes: 5 additions & 2 deletions lib/logitech_receiver/receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@
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__)

Expand Down
6 changes: 4 additions & 2 deletions lib/solaar/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
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

Expand Down
3 changes: 2 additions & 1 deletion lib/solaar/cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion lib/solaar/cli/probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
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

Expand Down
7 changes: 5 additions & 2 deletions lib/solaar/cli/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion lib/solaar/gtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
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__)

Expand Down
13 changes: 10 additions & 3 deletions lib/solaar/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@
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__)

Expand Down
3 changes: 2 additions & 1 deletion lib/solaar/ui/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

from gi.repository import Gtk

from solaar import NAME, __version__
from solaar import NAME
from solaar import __version__
from solaar.i18n import _

#
Expand Down
3 changes: 2 additions & 1 deletion lib/solaar/ui/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 _

Expand Down
3 changes: 2 additions & 1 deletion lib/solaar/ui/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
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__)

Expand Down
7 changes: 5 additions & 2 deletions lib/solaar/ui/config_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@
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__)

Expand Down
18 changes: 13 additions & 5 deletions lib/solaar/ui/diversion_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,25 @@
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
Expand Down
Loading

0 comments on commit 5e0a0c0

Please sign in to comment.