Skip to content

Commit

Permalink
Set a clear default value for validate_only
Browse files Browse the repository at this point in the history
Be explicit with the `validate_only`. The code was previously sending a
`False` so this just makes it more explicit and reduces ambiguity.
  • Loading branch information
jeffwidman committed Nov 17, 2018
1 parent 21d68c9 commit ca51544
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions kafka/admin/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,13 @@ def _convert_new_topic_request(new_topic):
]
)

def create_topics(self, new_topics, timeout_ms=None, validate_only=None):
def create_topics(self, new_topics, timeout_ms=None, validate_only=False):
"""Create new topics in the cluster.
:param new_topics: Array of NewTopic objects
:param timeout_ms: Milliseconds to wait for new topics to be created before broker returns
:param validate_only: If True, don't actually create new topics. Not supported by all versions.
:param validate_only: If True, don't actually create new topics.
Not supported by all versions. Default: False
:return: Appropriate version of CreateTopicResponse class
"""
version = self._matching_api_version(CreateTopicsRequest)
Expand All @@ -319,7 +320,6 @@ def create_topics(self, new_topics, timeout_ms=None, validate_only=None):
timeout = timeout_ms
)
elif version <= 2:
validate_only = validate_only or False
request = CreateTopicsRequest[version](
create_topic_requests = [self._convert_new_topic_request(new_topic) for new_topic in new_topics],
timeout = timeout_ms,
Expand Down Expand Up @@ -445,17 +445,17 @@ def _convert_create_partitions_request(topic_name, new_partitions):
)
)

def create_partitions(self, topic_partitions, timeout_ms=None, validate_only=None):
def create_partitions(self, topic_partitions, timeout_ms=None, validate_only=False):
"""Create additional partitions for an existing topic.
:param topic_partitions: A map of topic name strings to NewPartition objects
:param timeout_ms: Milliseconds to wait for new partitions to be created before broker returns
:param validate_only: If True, don't actually create new partitions.
Default: False
:return: Appropriate version of CreatePartitionsResponse class
"""
version = self._matching_api_version(CreatePartitionsRequest)
timeout_ms = self._validate_timeout(timeout_ms)
validate_only = validate_only or False
if version == 0:
request = CreatePartitionsRequest[version](
topic_partitions = [self._convert_create_partitions_request(topic_name, new_partitions) for topic_name, new_partitions in topic_partitions.items()],
Expand Down

0 comments on commit ca51544

Please sign in to comment.