From ccc944efb238a0f9a5d32f04aeeb308018993c97 Mon Sep 17 00:00:00 2001 From: Seth Foster Date: Wed, 22 May 2024 14:44:32 -0400 Subject: [PATCH] refactor(api): conditionally import usb dep (#15247) I think the intent was always that AsyncByonoy and thus pyusb would only be imported when actually building an AsyncByonoy instance, but at some point it got imported globally for a typecheck. Make that typecheck typecheck-only with a different name, and the problem goes away. Other side of #15206 --- api/src/opentrons/drivers/absorbance_reader/driver.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/api/src/opentrons/drivers/absorbance_reader/driver.py b/api/src/opentrons/drivers/absorbance_reader/driver.py index 538bc83d70d..8777f8cbbf7 100644 --- a/api/src/opentrons/drivers/absorbance_reader/driver.py +++ b/api/src/opentrons/drivers/absorbance_reader/driver.py @@ -1,12 +1,14 @@ from __future__ import annotations import asyncio -from typing import Dict, Optional, List +from typing import Dict, Optional, List, TYPE_CHECKING from opentrons.drivers.types import AbsorbanceReaderLidStatus from opentrons.drivers.absorbance_reader.abstract import AbstractAbsorbanceReaderDriver from opentrons.drivers.rpi_drivers.types import USBPort -from .async_byonoy import AsyncByonoy + +if TYPE_CHECKING: + from .async_byonoy import AsyncByonoy as AsyncByonoyType class AbsorbanceReaderDriver(AbstractAbsorbanceReaderDriver): @@ -23,7 +25,7 @@ async def create( connection = await AsyncByonoy.create(port=port, usb_port=usb_port, loop=loop) return cls(connection=connection) - def __init__(self, connection: AsyncByonoy) -> None: + def __init__(self, connection: AsyncByonoyType) -> None: self._connection = connection async def get_device_info(self) -> Dict[str, str]: