Skip to content

Commit e2fa419

Browse files
authored
Don't reassign cls.__new__ for Python 3.10+ (#219)
* Don't reassign cls.__new__ for Python 3.10+ * Fix lint
1 parent 686cb6c commit e2fa419

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

zigpy_znp/types/basic.py

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

3+
import sys
34
import enum
45
import typing
56

@@ -65,10 +66,13 @@ 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__
71+
# as the member type. We have to ensure this is true for
72+
# every subclass.
73+
# Fixed with https://github.com/python/cpython/pull/26658
74+
if "__new__" not in cls.__dict__:
75+
cls.__new__ = cls.__new__
7276

7377
def serialize(self) -> bytes:
7478
try:

0 commit comments

Comments
 (0)