From 2b6934c55ae709b77d0f6a0ae77490eb1cee5b09 Mon Sep 17 00:00:00 2001 From: JamesParrott <80779630+JamesParrott@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:25:31 +0000 Subject: [PATCH] Use hardcoded list of CallbackAPIVersions --- src/paho/mqtt/client.py | 2 +- src/paho/mqtt/enums.py | 2 +- src/paho/mqtt/simpler_enum.py | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/paho/mqtt/client.py b/src/paho/mqtt/client.py index 4ccc8696..5ee4fc75 100644 --- a/src/paho/mqtt/client.py +++ b/src/paho/mqtt/client.py @@ -772,7 +772,7 @@ def __init__( raise ValueError( "Unsupported callback API version: version 2.0 added a callback_api_version, see docs/migrations.rst for details" ) - if self._callback_api_version not in CallbackAPIVersion: + if self._callback_api_version not in [CallbackAPIVersion.VERSION1, CallbackAPIVersion.VERSION2]: raise ValueError("Unsupported callback API version") self._clean_start: int = MQTT_CLEAN_START_FIRST_ONLY diff --git a/src/paho/mqtt/enums.py b/src/paho/mqtt/enums.py index 5506aad6..e76e4af4 100644 --- a/src/paho/mqtt/enums.py +++ b/src/paho/mqtt/enums.py @@ -1,7 +1,7 @@ try: import enum except ImportError: - from . import simpler_enum as enum + import .simpler_enum as enum class MQTTErrorCode(enum.IntEnum): MQTT_ERR_AGAIN = -1 diff --git a/src/paho/mqtt/simpler_enum.py b/src/paho/mqtt/simpler_enum.py index 6660fe93..89874170 100644 --- a/src/paho/mqtt/simpler_enum.py +++ b/src/paho/mqtt/simpler_enum.py @@ -1,10 +1,11 @@ - -class IntEnum: +class SimplerEnum: pass -class Enum: +class Enum(SimplerEnum): pass +IntEnum = Enum + class _Auto: def __init__(self): self._i = -1