Skip to content

Commit

Permalink
Don't reassign cls.__new__ for Python 3.10+
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p committed Jul 20, 2023
1 parent 686cb6c commit fefb3a0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions zigpy_znp/types/basic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import enum
import sys
import typing

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

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

def serialize(self) -> bytes:
try:
Expand Down

0 comments on commit fefb3a0

Please sign in to comment.