Skip to content

Commit

Permalink
Address index, union-attr and misc typing errors (#262)
Browse files Browse the repository at this point in the history
Related: #258
  • Loading branch information
ssbarnea authored Aug 15, 2024
1 parent b3e584b commit b036117
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
13 changes: 10 additions & 3 deletions extensions/eda/plugins/event_source/aws_sqs_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,20 @@ async def main(queue: asyncio.Queue, args: dict[str, Any]) -> None:
while True:
# This loop won't spin really fast as there is
# essentially a sleep in the receive_message call
response = await client.receive_message(
response_msg = await client.receive_message(
QueueUrl=queue_url,
WaitTimeSeconds=wait_seconds,
)

if "Messages" in response:
for msg in response["Messages"]: # type: ignore[typeddict-item]
if "Messages" in response_msg:
for msg in response_msg["Messages"]:
if (
not isinstance(msg, dict) or "MessageId" not in msg
): # pragma: no cover
err_msg = (
f"Unexpected response {response_msg}, missing MessageId."
)
raise ValueError(err_msg)
meta = {"MessageId": msg["MessageId"]}
try:
msg_body = json.loads(msg["Body"])
Expand Down
2 changes: 1 addition & 1 deletion extensions/eda/plugins/event_source/journald.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async def main(queue: asyncio.Queue, args: dict[str, Any]) -> None: # noqa: D41
class MockQueue(asyncio.Queue[Any]):
"""A mock implementation of a queue that prints the event."""

async def put(self: str, event: str) -> str:
async def put(self, event: str) -> str:
"""Add the event to the queue and print it."""
print(event) # noqa: T201
return ""
Expand Down
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ error_summary = true
disable_error_code = [
"assignment",
"attr-defined",
"index",
"misc",
"override",
"union-attr",
"var-annotated",
]
# strict = true
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/event_source_webhook/test_webhook_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def wait_for_events(proc: subprocess.Popen, timeout: float = 15.0):
Requires the process to be running in debug mode.
"""
start = time.time()
if not proc.stdout: # pragma: no cover
return
while stdout := proc.stdout.readline().decode():
if "Waiting for events" in stdout:
break
Expand Down

0 comments on commit b036117

Please sign in to comment.