Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

tvoinarovskyi
Copy link
Collaborator

Fixes #1442


__all__ = ["MemoryRecords"]
__all__ = ["MemoryRecords", "MemoryRecordsBuilder"]
Copy link
Contributor

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?

Copy link
Collaborator Author

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

Copy link
Contributor

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)
Copy link
Owner

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
Copy link

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.

@dpkp
Copy link
Owner

dpkp commented Apr 18, 2018

Merged manually

@dpkp dpkp closed this Apr 18, 2018
@jeffwidman jeffwidman deleted the fix_memory_records_typo branch April 18, 2018 23:24
88manpreet pushed a commit to Yelp/kafka-python that referenced this pull request Aug 1, 2018
88manpreet pushed a commit to Yelp/kafka-python that referenced this pull request Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants