Skip to content

Commit 665f1e4

Browse files
committed
Set a clear default value for validate_only/include_synonyms
Set a clear default value for `validate_only` / `include_synonyms` Previously the kwarg defaulted to `None`, but then sent a `False` so this makes it more explicit and reduces ambiguity.
1 parent 232a2d6 commit 665f1e4

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
@@ -354,12 +354,13 @@ def _convert_new_topic_request(new_topic):
354354
]
355355
)
356356

357-
def create_topics(self, new_topics, timeout_ms=None, validate_only=None):
357+
def create_topics(self, new_topics, timeout_ms=None, validate_only=False):
358358
"""Create new topics in the cluster.
359359
360360
:param new_topics: Array of NewTopic objects
361361
:param timeout_ms: Milliseconds to wait for new topics to be created before broker returns
362-
:param validate_only: If True, don't actually create new topics. Not supported by all versions.
362+
:param validate_only: If True, don't actually create new topics.
363+
Not supported by all versions. Default: False
363364
:return: Appropriate version of CreateTopicResponse class
364365
"""
365366
version = self._matching_api_version(CreateTopicsRequest)
@@ -374,7 +375,6 @@ def create_topics(self, new_topics, timeout_ms=None, validate_only=None):
374375
timeout = timeout_ms
375376
)
376377
elif version <= 2:
377-
validate_only = validate_only or False
378378
request = CreateTopicsRequest[version](
379379
create_topic_requests = [self._convert_new_topic_request(new_topic) for new_topic in new_topics],
380380
timeout = timeout_ms,
@@ -434,13 +434,14 @@ def _convert_describe_config_resource_request(config_resource):
434434
] if config_resource.configs else None
435435
)
436436

437-
def describe_configs(self, config_resources, include_synonyms=None):
437+
def describe_configs(self, config_resources, include_synonyms=False):
438438
"""Fetch configuration parameters for one or more kafka resources.
439439
440440
:param config_resources: An array of ConfigResource objects.
441441
Any keys in ConfigResource.configs dict will be used to filter the result. The configs dict should be None
442442
to get all values. An empty dict will get zero values (as per kafka protocol).
443-
:param include_synonyms: If True, return synonyms in response. Not supported by all versions.
443+
:param include_synonyms: If True, return synonyms in response. Not
444+
supported by all versions. Default: False.
444445
:return: Appropriate version of DescribeConfigsResponse class
445446
"""
446447
version = self._matching_api_version(DescribeConfigsRequest)
@@ -453,7 +454,6 @@ def describe_configs(self, config_resources, include_synonyms=None):
453454
resources = [self._convert_describe_config_resource_request(config_resource) for config_resource in config_resources]
454455
)
455456
elif version <= 1:
456-
include_synonyms = include_synonyms or False
457457
request = DescribeConfigsRequest[version](
458458
resources = [self._convert_describe_config_resource_request(config_resource) for config_resource in config_resources],
459459
include_synonyms = include_synonyms
@@ -519,17 +519,17 @@ def _convert_create_partitions_request(topic_name, new_partitions):
519519
)
520520
)
521521

522-
def create_partitions(self, topic_partitions, timeout_ms=None, validate_only=None):
522+
def create_partitions(self, topic_partitions, timeout_ms=None, validate_only=False):
523523
"""Create additional partitions for an existing topic.
524524
525525
:param topic_partitions: A map of topic name strings to NewPartition objects
526526
:param timeout_ms: Milliseconds to wait for new partitions to be created before broker returns
527527
:param validate_only: If True, don't actually create new partitions.
528+
Default: False
528529
:return: Appropriate version of CreatePartitionsResponse class
529530
"""
530531
version = self._matching_api_version(CreatePartitionsRequest)
531532
timeout_ms = self._validate_timeout(timeout_ms)
532-
validate_only = validate_only or False
533533
if version == 0:
534534
request = CreatePartitionsRequest[version](
535535
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)