aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_tools/kafka.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2021-11-03 12:29:39 -0700
committerBryan Newbold <bnewbold@robocracy.org>2021-11-03 12:31:07 -0700
commit10a2374051568edf3d872988e730328d899a0fdd (patch)
tree795be5e149a021f84bc4305c1811e63cc86f7aa1 /python/fatcat_tools/kafka.py
parentcfab1ddcd8a05b62ecc16763d18a6ecee8fa234f (diff)
downloadfatcat-10a2374051568edf3d872988e730328d899a0fdd.tar.gz
fatcat-10a2374051568edf3d872988e730328d899a0fdd.zip
typing: first batch of python bulk type annotations
While these changes are more delicate than simple lint changes, this specific batch of edits and annotations was *relatively* simple, and resulted in few code changes other than function signature additions.
Diffstat (limited to 'python/fatcat_tools/kafka.py')
-rw-r--r--python/fatcat_tools/kafka.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/python/fatcat_tools/kafka.py b/python/fatcat_tools/kafka.py
index 2a4451ad..fe9f36e9 100644
--- a/python/fatcat_tools/kafka.py
+++ b/python/fatcat_tools/kafka.py
@@ -1,7 +1,9 @@
+from typing import Any, Optional
+
from confluent_kafka import KafkaException, Producer
-def kafka_fail_fast(err, msg):
+def kafka_fail_fast(err: Optional[Any], _msg: Any) -> None:
if err is not None:
print("Kafka producer delivery error: {}".format(err))
print("Bailing out...")
@@ -9,7 +11,11 @@ def kafka_fail_fast(err, msg):
raise KafkaException(err)
-def simple_kafka_producer(kafka_hosts):
+def simple_kafka_producer(kafka_hosts: str) -> Producer:
+ """
+ kafka_hosts should be a string with hostnames separated by ',', not a list
+ of hostnames
+ """
kafka_config = {
"bootstrap.servers": kafka_hosts,