Skip to content

Commit 8353342

Browse files
authored
Merge pull request #32 from CerebusOSS/cboulay/class_property
Replaced stacked @classmethod @Property decorator with custom @classproperty to fix compatibility with Python 3.13.
2 parents 8a77897 + 9b109f2 commit 8353342

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

src/pycbsdk/cbhw/packet/abstract.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
from ctypes import *
33
import struct
44
import numpy as np
5+
6+
7+
class classproperty(object):
8+
def __init__(self, f):
9+
self.f = f
10+
11+
def __get__(self, obj, owner):
12+
return self.f(owner)
13+
514
import numpy.typing
615
from .common import (
716
CBPacketType,

src/pycbsdk/cbhw/packet/header/v311.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
from ctypes import *
22

33

4+
from ..abstract import classproperty
5+
6+
47
class CBPacketHeader(Structure):
58
_pack_ = 1
69
_fields_ = [
@@ -13,7 +16,6 @@ class CBPacketHeader(Structure):
1316
), # Number of 32-bit elements in packet body. * 4 to get number of bytes.
1417
]
1518

16-
@classmethod
17-
@property
19+
@classproperty
1820
def HEADER_FORMAT(cls):
1921
return "<LHBB"

src/pycbsdk/cbhw/packet/header/v40.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from ctypes import *
2+
from ..abstract import classproperty
23

34

45
class CBPacketHeader(Structure):
@@ -15,7 +16,6 @@ class CBPacketHeader(Structure):
1516
("reserved", 2 * c_uint8),
1617
]
1718

18-
@classmethod
19-
@property
19+
@classproperty
2020
def HEADER_FORMAT(cls):
2121
return "<QHBHBH"

src/pycbsdk/cbhw/packet/header/v41.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from ctypes import *
2+
from ..abstract import classproperty
23
from ..common import print_pretty
34

45

@@ -17,7 +18,6 @@ class CBPacketHeader(Structure):
1718
("reserved", c_uint8), # Changed in this version; used to be 2 * c_uint8
1819
]
1920

20-
@classmethod
21-
@property
21+
@classproperty
2222
def HEADER_FORMAT(cls):
2323
return "<QHHHBB"

0 commit comments

Comments
 (0)