Skip to content

Commit 0288f48

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 21d68c9 commit 0288f48

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
@@ -299,12 +299,13 @@ def _convert_new_topic_request(new_topic):
299299
]
300300
)
301301

302-
def create_topics(self, new_topics, timeout_ms=None, validate_only=None):
302+
def create_topics(self, new_topics, timeout_ms=None, validate_only=False):
303303
"""Create new topics in the cluster.
304304
305305
:param new_topics: Array of NewTopic objects
306306
:param timeout_ms: Milliseconds to wait for new topics to be created before broker returns
307-
:param validate_only: If True, don't actually create new topics. Not supported by all versions.
307+
:param validate_only: If True, don't actually create new topics.
308+
Not supported by all versions. Default: False
308309
:return: Appropriate version of CreateTopicResponse class
309310
"""
310311
version = self._matching_api_version(CreateTopicsRequest)
@@ -319,7 +320,6 @@ def create_topics(self, new_topics, timeout_ms=None, validate_only=None):
319320
timeout = timeout_ms
320321
)
321322
elif version <= 2:
322-
validate_only = validate_only or False
323323
request = CreateTopicsRequest[version](
324324
create_topic_requests = [self._convert_new_topic_request(new_topic) for new_topic in new_topics],
325325
timeout = timeout_ms,
@@ -374,13 +374,14 @@ def _convert_describe_config_resource_request(config_resource):
374374
] if config_resource.configs else None
375375
)
376376

377-
def describe_configs(self, config_resources, include_synonyms=None):
377+
def describe_configs(self, config_resources, include_synonyms=False):
378378
"""Fetch configuration parameters for one or more kafka resources.
379379
380380
:param config_resources: An array of ConfigResource objects.
381381
Any keys in ConfigResource.configs dict will be used to filter the result. The configs dict should be None
382382
to get all values. An empty dict will get zero values (as per kafka protocol).
383-
:param include_synonyms: If True, return synonyms in response. Not supported by all versions.
383+
:param include_synonyms: If True, return synonyms in response. Not
384+
supported by all versions. Default: False.
384385
:return: Appropriate version of DescribeConfigsResponse class
385386
"""
386387
version = self._matching_api_version(DescribeConfigsRequest)
@@ -393,7 +394,6 @@ def describe_configs(self, config_resources, include_synonyms=None):
393394
resources = [self._convert_describe_config_resource_request(config_resource) for config_resource in config_resources]
394395
)
395396
elif version <= 1:
396-
include_synonyms = include_synonyms or False
397397
request = DescribeConfigsRequest[version](
398398
resources = [self._convert_describe_config_resource_request(config_resource) for config_resource in config_resources],
399399
include_synonyms = include_synonyms
@@ -445,17 +445,17 @@ def _convert_create_partitions_request(topic_name, new_partitions):
445445
)
446446
)
447447

448-
def create_partitions(self, topic_partitions, timeout_ms=None, validate_only=None):
448+
def create_partitions(self, topic_partitions, timeout_ms=None, validate_only=False):
449449
"""Create additional partitions for an existing topic.
450450
451451
:param topic_partitions: A map of topic name strings to NewPartition objects
452452
:param timeout_ms: Milliseconds to wait for new partitions to be created before broker returns
453453
:param validate_only: If True, don't actually create new partitions.
454+
Default: False
454455
:return: Appropriate version of CreatePartitionsResponse class
455456
"""
456457
version = self._matching_api_version(CreatePartitionsRequest)
457458
timeout_ms = self._validate_timeout(timeout_ms)
458-
validate_only = validate_only or False
459459
if version == 0:
460460
request = CreatePartitionsRequest[version](
461461
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)