Skip to content

Commit fefb3a0

Browse files
committed
Don't reassign cls.__new__ for Python 3.10+
1 parent 686cb6c commit fefb3a0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

zigpy_znp/types/basic.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import enum
4+
import sys
45
import typing
56

67
import zigpy.types as zigpy_t
@@ -65,10 +66,12 @@ def __init_subclass__(cls, signed=None, size=None, hex_repr=None) -> None:
6566
cls.__str__ = super().__str__
6667
cls.__repr__ = super().__repr__
6768

68-
# XXX: The enum module uses the first class with __new__ in its __dict__ as the
69-
# member type. We have to ensure this is true for every subclass.
70-
if "__new__" not in cls.__dict__:
71-
cls.__new__ = cls.__new__
69+
if sys.version_info < (3, 10):
70+
# XXX: The enum module uses the first class with __new__ in its __dict__ as the
71+
# member type. We have to ensure this is true for every subclass.
72+
# Fixed with https://github.com/python/cpython/pull/26658
73+
if "__new__" not in cls.__dict__:
74+
cls.__new__ = cls.__new__
7275

7376
def serialize(self) -> bytes:
7477
try:

0 commit comments

Comments
 (0)