Skip to content

Commit f9fe122

Browse files
committed
fix pylint complaints
1 parent 41d1326 commit f9fe122

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/artisanlib/aillio/aillio.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
# mikefsq, r2 2025
2020

2121
import usb.core # type: ignore[import-untyped]
22-
from typing import Optional, Union, List, TypedDict, cast, TYPE_CHECKING, Any
2322
import logging
24-
from platform import system
2523
import importlib.util
2624
import os
25+
from platform import system
26+
from typing import Optional, Union, List, TypedDict, cast, TYPE_CHECKING, Any
2727

2828
if TYPE_CHECKING:
2929
from artisanlib.aillio.aillio_r1 import AillioR1
@@ -101,9 +101,7 @@ def detect_device() -> Optional[DEVICE_VARIANT]:
101101
# Fallback to pyusb backend
102102
try:
103103
_log.debug('Trying fallback pyusb backend')
104-
import usb.backend.libusb1 # type: ignore[import-untyped, unused-ignore]
105-
import usb.core
106-
import os
104+
import usb.backend.libusb1 # type: ignore[import-untyped, unused-ignore] # pylint: disable=redefined-outer-name
107105

108106
# Look for libusb DLL in common locations
109107
dll_paths = [
@@ -149,7 +147,6 @@ def detect_device() -> Optional[DEVICE_VARIANT]:
149147
backend = None
150148
if system().startswith('Linux'):
151149
# Try to find system libusb
152-
import os
153150
for shared_libusb_path in [
154151
'/usr/lib/x86_64-linux-gnu/libusb-1.0.so',
155152
'/usr/lib/x86_64-linux-gnu/libusb-1.0.so.0',
@@ -164,7 +161,6 @@ def detect_device() -> Optional[DEVICE_VARIANT]:
164161
break
165162

166163
# Try to find device with the backend
167-
import usb.core
168164
for variant in AillioBase.DEVICE_VARIANTS:
169165
device = usb.core.find(idVendor=variant['vid'], idProduct=variant['pid'], backend=backend)
170166
if device is not None:
@@ -212,7 +208,7 @@ def create(debug: bool = False) -> 'Optional[Union[AillioR1,AillioR2]]':
212208
except usb.core.NoBackendError:
213209
_log.error('No USB backend available. Please ensure libusb is installed.')
214210
return None
215-
except Exception as e:
211+
except Exception as e: # pylint: disable=broad-except
216212
_log.exception('Unexpected error creating Aillio instance: %s', str(e))
217213
return None
218214

0 commit comments

Comments
 (0)