-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a test for MemoryRecordsBuilder and fixed some problems there #1448
Conversation
|
||
__all__ = ["MemoryRecords"] | ||
__all__ = ["MemoryRecords", "MemoryRecordsBuilder"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not very familiar with this code, but I don't understand why this import is needed? Reading the bug description, it looks like the problems were all due to the code fixed in kafka/record/memory_records.py
below... If the import were just forgotten, I would have thought it would have thrown problems before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No particular reason, just used in tests. We can remove it, yea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine leaving it in if you think it should be there, I just didn't understand if there was something I was missing.
@@ -166,7 +166,7 @@ def size_in_bytes(self): | |||
|
|||
def compression_rate(self): | |||
assert self._closed | |||
return self.size_in_bytes() / self._bytes_written | |||
return self.size_in_bytes() / float(self._bytes_written) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only required for python2; python3 division returns a float by default. I think a cleaner way to handle this compatibility is with __future__
:
from __future__ import division
With that you shouldn't need to cast to float
@@ -135,7 +135,7 @@ def append(self, timestamp, key, value, headers=[]): | |||
(int, int): checksum and bytes written |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return type in docstring is incorrect.
Merged manually |
Fixes #1442