Skip to content

KafkaConsumer & ClusterMetadata partitions_for_topic methods may return None instead of (empty) set for missing topics #2222

Closed
@jesuspv

Description

@jesuspv

According to documentation:

https://kafka-python.readthedocs.io/en/master/apidoc/KafkaConsumer.html
https://kafka-python.readthedocs.io/en/master/apidoc/ClusterMetadata.html

partitions_for_topic method return type is set. However, if the topic does not exists, ClusterMetadata's method returns None (and thus KafkaConsumer's, which calls ClusterMetadata's partitions_for_topic for that topic).

Notice that the solution should either update the documentation (explictly stating that the method may return None, its type is Optional[set]) or even better, just returning an empty set if the topic is not found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions