Python 3.10 fails with TypeError: bit field `{self.name!r}` type must be int-like
The following code works fine in Python 3.9 but fails in Python 3.10:
from plum.int.bitfields import BitField, BitFields
class MyClass(BitFields):
attr: int = BitField(size=1)
The full Traceback is as follows:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python\3.10\lib\site-packages\plum\int\bitfields\_bitfieldstype.py", line 63, in __init__
bitfield.finish_initialization(fieldname, annotations)
File "C:\Python\3.10\lib\site-packages\plum\int\bitfields\_bitfield.py", line 138, in finish_initialization
self.cls = annotations[name]
File "C:\Python\3.10\lib\site-packages\plum\int\bitfields\_bitfield.py", line 115, in cls
raise TypeError(
TypeError: bit field 'attr' type must be int-like
It appears that this is an issue with PEP 563 -- Postponed Evaluation of Annotations now being the default in python 3.10 as Bitfield.cls.setter
does issubclass
checks against cls
which is still a string.