You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Operator not supported" type error when using singleton constructs #1115
When using any of the singleton constructs (Bit, Int8ub, etc.) Pyright gives a false type error. This appears to be related #1018, but in this case its the type checker that thinks its a function when its actually been changed to variable.
The following struct:
BitParser=BitStruct(
"is_bit"/Bit,
)
Gives this error:
Operator "/" not supported for types "Literal['is_bit']" and "() -> BitsInteger"
Potential solution
It might be simpler, especially for things like Bit, to just use a variable. For example,
@singletondefBit():
"""A 1-bit integer, must be enclosed in a Bitwise (eg. BitStruct)"""returnBitsInteger(1)
is functionally identical to:
Bit=BitsInteger(1)
"""A 1-bit integer, must be enclosed in a Bitwise (eg. BitStruct)"""
This should cause fewer problems with type checking and make the code easier to read and maintain.
Activity
arekbulski commentedon Aug 13, 2025
Type checking is not supported by Construct. See: https://github.com/timrid/construct-typing