File: py313-partial-in-enum.patch

package info (click to toggle)
python-miio 0.5.12-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,888 kB
  • sloc: python: 23,425; makefile: 9
file content (45 lines) | stat: -rw-r--r-- 1,191 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Date: Sun, 15 Dec 2024 00:22:51 +0100
Subject: Fix partial in enum for Python 3.13

Origin: other, https://github.com/rytilahti/python-miio/pull/1993
Bug-Debian: https://bugs.debian.org/1090278
Last-Update: 2024-12-29
---
 miio/miot_device.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/miio/miot_device.py b/miio/miot_device.py
index 43cafcc..094701c 100644
--- a/miio/miot_device.py
+++ b/miio/miot_device.py
@@ -1,4 +1,5 @@
 import logging
+import sys
 from enum import Enum
 from functools import partial
 from typing import Any, Dict, Union
@@ -9,6 +10,9 @@ from .click_common import EnumType, LiteralParamType, command
 from .device import Device, DeviceStatus  # noqa: F401
 from .exceptions import DeviceException
 
+if sys.version_info >= (3, 11):
+    from enum import member
+
 _LOGGER = logging.getLogger(__name__)
 
 
@@ -20,7 +24,12 @@ class MiotValueType(Enum):
 
     Int = int
     Float = float
-    Bool = partial(_str2bool)
+
+    if sys.version_info >= (3, 11):
+        Bool = member(partial(_str2bool))
+    else:
+        Bool = partial(_str2bool)
+
     Str = str