Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jesuspv opened this issue Apr 7, 2021 · 0 comments · Fixed by #2556

Comments

@jesuspv
Copy link

jesuspv commented Apr 7, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant