Skip to content

Commit 698b5ce

Browse files
committed
Set a clear default value for validate_only/include_synonyms
The code was previously sending a `False` so this just makes it more explicit and reduces ambiguity.
1 parent b10dc3b commit 698b5ce

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

kafka/admin/kafka.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,13 @@ def _convert_new_topic_request(new_topic):
364364
]
365365
)
366366

367-
def create_topics(self, new_topics, timeout_ms=None, validate_only=None):
367+
def create_topics(self, new_topics, timeout_ms=None, validate_only=False):
368368
"""Create new topics in the cluster.
369369
370370
:param new_topics: Array of NewTopic objects
371371
:param timeout_ms: Milliseconds to wait for new topics to be created before broker returns
372-
:param validate_only: If True, don't actually create new topics. Not supported by all versions.
372+
:param validate_only: If True, don't actually create new topics.
373+
Not supported by all versions. Default: False
373374
:return: Appropriate version of CreateTopicResponse class
374375
"""
375376
version = self._matching_api_version(CreateTopicsRequest)
@@ -384,7 +385,6 @@ def create_topics(self, new_topics, timeout_ms=None, validate_only=None):
384385
timeout = timeout_ms
385386
)
386387
elif version <= 2:
387-
validate_only = validate_only or False
388388
request = CreateTopicsRequest[version](
389389
create_topic_requests = [self._convert_new_topic_request(new_topic) for new_topic in new_topics],
390390
timeout = timeout_ms,
@@ -444,13 +444,14 @@ def _convert_describe_config_resource_request(config_resource):
444444
] if config_resource.configs else None
445445
)
446446

447-
def describe_configs(self, config_resources, include_synonyms=None):
447+
def describe_configs(self, config_resources, include_synonyms=False):
448448
"""Fetch configuration parameters for one or more kafka resources.
449449
450450
:param config_resources: An array of ConfigResource objects.
451451
Any keys in ConfigResource.configs dict will be used to filter the result. The configs dict should be None
452452
to get all values. An empty dict will get zero values (as per kafka protocol).
453-
:param include_synonyms: If True, return synonyms in response. Not supported by all versions.
453+
:param include_synonyms: If True, return synonyms in response. Not
454+
supported by all versions. Default: False.
454455
:return: Appropriate version of DescribeConfigsResponse class
455456
"""
456457
version = self._matching_api_version(DescribeConfigsRequest)
@@ -463,7 +464,6 @@ def describe_configs(self, config_resources, include_synonyms=None):
463464
resources = [self._convert_describe_config_resource_request(config_resource) for config_resource in config_resources]
464465
)
465466
elif version <= 1:
466-
include_synonyms = include_synonyms or False
467467
request = DescribeConfigsRequest[version](
468468
resources = [self._convert_describe_config_resource_request(config_resource) for config_resource in config_resources],
469469
include_synonyms = include_synonyms
@@ -529,17 +529,17 @@ def _convert_create_partitions_request(topic_name, new_partitions):
529529
)
530530
)
531531

532-
def create_partitions(self, topic_partitions, timeout_ms=None, validate_only=None):
532+
def create_partitions(self, topic_partitions, timeout_ms=None, validate_only=False):
533533
"""Create additional partitions for an existing topic.
534534
535535
:param topic_partitions: A map of topic name strings to NewPartition objects
536536
:param timeout_ms: Milliseconds to wait for new partitions to be created before broker returns
537537
:param validate_only: If True, don't actually create new partitions.
538+
Default: False
538539
:return: Appropriate version of CreatePartitionsResponse class
539540
"""
540541
version = self._matching_api_version(CreatePartitionsRequest)
541542
timeout_ms = self._validate_timeout(timeout_ms)
542-
validate_only = validate_only or False
543543
if version == 0:
544544
request = CreatePartitionsRequest[version](
545545
topic_partitions = [self._convert_create_partitions_request(topic_name, new_partitions) for topic_name, new_partitions in topic_partitions.items()],

0 commit comments

Comments
 (0)