Skip to content

Document methods that return None #1504

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

Merged
merged 1 commit into from
May 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions kafka/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def available_partitions_for_topic(self, topic):

Returns:
set: {partition (int), ...}
None if topic not found.
"""
if topic not in self._partitions:
return None
Expand All @@ -119,6 +120,7 @@ def partitions_for_broker(self, broker_id):

Returns:
set: {TopicPartition, ...}
None if the broker either has no partitions or does not exist.
"""
return self._broker_partitions.get(broker_id)
Copy link
Contributor Author

@jeffwidman jeffwidman May 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where the None comes from if a broker exists but has no partitions. Alternatively, could instead change this to get(broker_id, set()), although this would make non-existent brokers return an empty set rather than None.


Expand All @@ -130,6 +132,7 @@ def coordinator_for_group(self, group):

Returns:
int: node_id for group coordinator
None if the group does not exist.
"""
return self._groups.get(group)

Expand Down