Skip to content

Commit

Permalink
fix up versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
sfoster1 committed Jun 3, 2024
1 parent 0bea516 commit 12a491a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions api/src/opentrons/hardware_control/modules/mod_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import asyncio
import logging
import re
from typing import ClassVar, Mapping, Optional, TypeVar
from typing import ClassVar, Mapping, Optional, TypeVar, cast
from packaging.version import InvalidVersion, parse, Version
from opentrons.config import IS_ROBOT, ROBOT_FIRMWARE_DIR
from opentrons.drivers.rpi_drivers.types import USBPort
Expand All @@ -18,9 +18,14 @@
def parse_fw_version(version: str) -> Version:
try:
device_version = parse(version)
# This is a patch for older versions of packaging - they would try and parse old
# kidns of versions and return a LegacyVersion object. We can't check for that
# explicitly because they removed it in modern versions of packaging.
if not isinstance(device_version, Version):
raise InvalidVersion()
except InvalidVersion:
device_version = parse("v0.0.0")
return device_version
return cast(Version, device_version)


class AbstractModule(abc.ABC):
Expand Down

0 comments on commit 12a491a

Please sign in to comment.