Skip to content

Commit 0aa4df3

Browse files
authored
Fix partial in enum for Python 3.13 (#1993)
Fix Deprecation warning emitted by Python 3.13.1. ``` functools.partial will be a method descriptor in future Python versions; wrap it in enum.member() if you want to preserve the old behavior ``` Ref: python/cpython#125316
1 parent edb06c5 commit 0aa4df3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

miio/miot_device.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import sys
23
from enum import Enum
34
from functools import partial
45
from typing import Any, Optional, Union
@@ -9,6 +10,9 @@
910
from .device import Device, DeviceStatus # noqa: F401
1011
from .exceptions import DeviceException
1112

13+
if sys.version_info >= (3, 11):
14+
from enum import member
15+
1216
_LOGGER = logging.getLogger(__name__)
1317

1418

@@ -20,7 +24,12 @@ def _str2bool(x):
2024

2125
Int = int
2226
Float = float
23-
Bool = partial(_str2bool)
27+
28+
if sys.version_info >= (3, 11):
29+
Bool = member(partial(_str2bool))
30+
else:
31+
Bool = partial(_str2bool)
32+
2433
Str = str
2534

2635

0 commit comments

Comments
 (0)