aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/kafka.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2021-11-03 15:45:35 -0700
committerBryan Newbold <bnewbold@robocracy.org>2021-11-03 16:52:44 -0700
commit91bd35a1ee0993126c369e39fbf8f81f775840ee (patch)
tree87e8bc6257359326f26102e7765e508d5529f0f5 /python/fatcat_web/kafka.py
parent2e92e28df34d302fe02d1e1ff7169b7888648b9c (diff)
downloadfatcat-91bd35a1ee0993126c369e39fbf8f81f775840ee.tar.gz
fatcat-91bd35a1ee0993126c369e39fbf8f81f775840ee.zip
web: add type annotations
This commit does not include type fixes, only annotations. A small number of tuples were also converted to lists.
Diffstat (limited to 'python/fatcat_web/kafka.py')
-rw-r--r--python/fatcat_web/kafka.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/python/fatcat_web/kafka.py b/python/fatcat_web/kafka.py
index 36dafade..a05b97e0 100644
--- a/python/fatcat_web/kafka.py
+++ b/python/fatcat_web/kafka.py
@@ -1,9 +1,13 @@
+from typing import Any, Dict, Optional
+
import requests
from fatcat_web import Config
-def kafka_pixy_produce(topic, msg, key=None, sync=True, timeout=25):
+def kafka_pixy_produce(
+ topic: str, msg: str, key: Optional[bytes] = None, sync: bool = True, timeout: float = 25
+) -> None:
"""
Simple helper to public a message to the given Kafka topic, via the
configured kafka-pixy HTTP gateway
@@ -17,7 +21,7 @@ def kafka_pixy_produce(topic, msg, key=None, sync=True, timeout=25):
if not Config.KAFKA_PIXY_ENDPOINT:
raise Exception("Kafka produce error: kafka-pixy endpoint not configured")
- params = dict()
+ params: Dict[str, Any] = dict()
if key:
params["key"] = key
if sync: