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,
@singleton
def Bit():
"""A 1-bit integer, must be enclosed in a Bitwise (eg. BitStruct)"""
return BitsInteger(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.
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:
Gives this error:
Potential solution
It might be simpler, especially for things like
Bit, to just use a variable. For example,is functionally identical to:
This should cause fewer problems with type checking and make the code easier to read and maintain.