`karapace.protobuf.encoding_variants.write_varint` is broken
aiven-anton opened this issue · 1 comments
aiven-anton commented
What happened?
Another bug found while adding type-hints. BytesIO.write()
does not accept an int, which is always the result of subscripting a bytearray
. There does not seem to be any unit test coverage here.
>>> from karapace.protobuf.encoding_variants import *
>>> b = BytesIO()
>>> write_varint(b, 123)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/anton/aiven/karapace/karapace/protobuf/encoding_variants.py", line 65, in write_varint
bio.write(bytearray(to_write)[0])
TypeError: a bytes-like object is required, not 'int'
Not entirely clear what to do about this as it indicates that quite a lot of code is unused, i.e. if this breakage isn't affecting functionality.
aiven-anton commented
Tests in this PR encodes this failure as well as other oddities in the same module: https://github.com/aiven/karapace/pull/653/files