Skip to content

Commit

Permalink
fix: ensure lib can be imported in windows (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Dec 16, 2023
1 parent ac7c86b commit 27435cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ repos:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.13.0
hooks:
- id: isort
- repo: https://github.com/psf/black
Expand Down
9 changes: 8 additions & 1 deletion src/usb_devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
__version__ = "0.4.1"

import asyncio
from fcntl import ioctl

try:
from fcntl import ioctl
except ImportError:
ioctl = None # type: ignore

from pathlib import Path

BLUETOOTH_DEVICE_PATH = Path("/sys/class/bluetooth")
Expand Down Expand Up @@ -125,6 +130,8 @@ def setup(self) -> None:

def reset(self) -> bool:
"""Reset the USB device."""
if ioctl is None:
return False # type: ignore
if self.usb_devfs_path is None:
self.setup()
assert self.usb_devfs_path is not None # nosec
Expand Down

0 comments on commit 27435cb

Please sign in to comment.