Skip to content

Commit

Permalink
Set a clear default value for validate_only/include_synonyms
Browse files Browse the repository at this point in the history
The code was previously sending a `False` so this just makes it more
explicit and reduces ambiguity.
  • Loading branch information
jeffwidman committed Nov 18, 2018
1 parent 7bd6b5d commit a2fcbc2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 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 @@ -374,13 +374,14 @@ def _convert_describe_config_resource_request(config_resource):
] if config_resource.configs else None
)

def describe_configs(self, config_resources, include_synonyms=None):
def describe_configs(self, config_resources, include_synonyms=False):
"""Fetch configuration parameters for one or more kafka resources.
:param config_resources: An array of ConfigResource objects.
Any keys in ConfigResource.configs dict will be used to filter the result. The configs dict should be None
to get all values. An empty dict will get zero values (as per kafka protocol).
:param include_synonyms: If True, return synonyms in response. Not supported by all versions.
:param include_synonyms: If True, return synonyms in response. Not
supported by all versions. Default: False.
:return: Appropriate version of DescribeConfigsResponse class
"""
version = self._matching_api_version(DescribeConfigsRequest)
Expand All @@ -393,7 +394,6 @@ def describe_configs(self, config_resources, include_synonyms=None):
resources = [self._convert_describe_config_resource_request(config_resource) for config_resource in config_resources]
)
elif version <= 1:
include_synonyms = include_synonyms or False
request = DescribeConfigsRequest[version](
resources = [self._convert_describe_config_resource_request(config_resource) for config_resource in config_resources],
include_synonyms = include_synonyms
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 a2fcbc2

Please sign in to comment.