diff --git a/extensions/eda/plugins/event_source/alertmanager.py b/extensions/eda/plugins/event_source/alertmanager.py index ffd1f032..b4efd5d6 100644 --- a/extensions/eda/plugins/event_source/alertmanager.py +++ b/extensions/eda/plugins/event_source/alertmanager.py @@ -141,7 +141,7 @@ async def main(queue: asyncio.Queue, args: dict[str, Any]) -> None: if __name__ == "__main__": """MockQueue if running directly.""" - class MockQueue: + class MockQueue(asyncio.Queue[Any]): """A fake queue.""" async def put(self: "MockQueue", event: dict) -> None: diff --git a/extensions/eda/plugins/event_source/aws_cloudtrail.py b/extensions/eda/plugins/event_source/aws_cloudtrail.py index c09e716b..b2719c05 100644 --- a/extensions/eda/plugins/event_source/aws_cloudtrail.py +++ b/extensions/eda/plugins/event_source/aws_cloudtrail.py @@ -60,7 +60,7 @@ def _get_events(events: list[dict], last_event_ids: list) -> list: elif event_time == event["EventTime"]: event_ids.append(event["EventId"]) result.append(event) - return result, event_time, event_ids + return [result, event_time, event_ids] async def _get_cloudtrail_events(client: BaseClient, params: dict) -> list[dict]: @@ -128,7 +128,7 @@ def connection_args(args: dict[str, Any]) -> dict[str, Any]: if __name__ == "__main__": """MockQueue if running directly.""" - class MockQueue: + class MockQueue(asyncio.Queue[Any]): """A fake queue.""" async def put(self: "MockQueue", event: dict) -> None: diff --git a/extensions/eda/plugins/event_source/aws_sqs_queue.py b/extensions/eda/plugins/event_source/aws_sqs_queue.py index 0fc2c749..af77bb22 100644 --- a/extensions/eda/plugins/event_source/aws_sqs_queue.py +++ b/extensions/eda/plugins/event_source/aws_sqs_queue.py @@ -106,7 +106,7 @@ def connection_args(args: dict[str, Any]) -> dict[str, Any]: if __name__ == "__main__": # MockQueue if running directly - class MockQueue: + class MockQueue(asyncio.Queue[Any]): """A fake queue.""" async def put(self: "MockQueue", event: dict) -> None: diff --git a/extensions/eda/plugins/event_source/azure_service_bus.py b/extensions/eda/plugins/event_source/azure_service_bus.py index 940e6ec6..dcd51d98 100644 --- a/extensions/eda/plugins/event_source/azure_service_bus.py +++ b/extensions/eda/plugins/event_source/azure_service_bus.py @@ -66,7 +66,7 @@ async def main( if __name__ == "__main__": """MockQueue if running directly.""" - class MockQueue: + class MockQueue(asyncio.Queue[Any]): """A fake queue.""" async def put_nowait(self: "MockQueue", event: dict) -> None: diff --git a/extensions/eda/plugins/event_source/file_watch.py b/extensions/eda/plugins/event_source/file_watch.py index 6d643b62..aa2b09aa 100644 --- a/extensions/eda/plugins/event_source/file_watch.py +++ b/extensions/eda/plugins/event_source/file_watch.py @@ -20,6 +20,7 @@ import asyncio import concurrent.futures +from typing import Any from watchdog.events import RegexMatchingEventHandler from watchdog.observers import Observer @@ -106,7 +107,7 @@ async def main(queue: asyncio.Queue, args: dict) -> None: if __name__ == "__main__": """MockQueue if running directly.""" - class MockQueue: + class MockQueue(asyncio.Queue[Any]): """A fake queue.""" async def put_nowait(self: "MockQueue", event: dict) -> None: diff --git a/extensions/eda/plugins/event_source/generic.py b/extensions/eda/plugins/event_source/generic.py index e3636d80..d524b373 100644 --- a/extensions/eda/plugins/event_source/generic.py +++ b/extensions/eda/plugins/event_source/generic.py @@ -215,7 +215,7 @@ async def main( # pylint: disable=R0914 if __name__ == "__main__": - class MockQueue: + class MockQueue(asyncio.Queue[Any]): """A fake queue.""" async def put(self: MockQueue, event: dict) -> None: diff --git a/extensions/eda/plugins/event_source/journald.py b/extensions/eda/plugins/event_source/journald.py index 969c6f26..71332fd6 100644 --- a/extensions/eda/plugins/event_source/journald.py +++ b/extensions/eda/plugins/event_source/journald.py @@ -33,7 +33,7 @@ from systemd import journal # type: ignore -async def main(queue: asyncio.Queue, args: dict[str, Any]) -> str: # noqa: D417 +async def main(queue: asyncio.Queue, args: dict[str, Any]) -> None: # noqa: D417 """Read journal entries and add them to the provided queue. Args: @@ -76,11 +76,12 @@ async def main(queue: asyncio.Queue, args: dict[str, Any]) -> str: # noqa: D417 Entry point of the program. """ - class MockQueue: + class MockQueue(asyncio.Queue[Any]): """A mock implementation of a queue that prints the event.""" async def put(self: str, event: str) -> str: """Add the event to the queue and print it.""" print(event) # noqa: T201 + return "" asyncio.run(main(MockQueue(), {"match": "ALL"})) diff --git a/extensions/eda/plugins/event_source/kafka.py b/extensions/eda/plugins/event_source/kafka.py index c26e057b..09220cb4 100644 --- a/extensions/eda/plugins/event_source/kafka.py +++ b/extensions/eda/plugins/event_source/kafka.py @@ -156,7 +156,7 @@ async def receive_msg( if __name__ == "__main__": """MockQueue if running directly.""" - class MockQueue: + class MockQueue(asyncio.Queue[Any]): """A fake queue.""" async def put(self: "MockQueue", event: dict) -> None: diff --git a/extensions/eda/plugins/event_source/pg_listener.py b/extensions/eda/plugins/event_source/pg_listener.py index b551a7e4..01f67803 100644 --- a/extensions/eda/plugins/event_source/pg_listener.py +++ b/extensions/eda/plugins/event_source/pg_listener.py @@ -169,7 +169,7 @@ async def _handle_chunked_message( if __name__ == "__main__": # MockQueue if running directly - class MockQueue: + class MockQueue(asyncio.Queue[Any]): """A fake queue.""" async def put(self: "MockQueue", event: dict) -> None: diff --git a/extensions/eda/plugins/event_source/range.py b/extensions/eda/plugins/event_source/range.py index 01609c6d..1862c51d 100644 --- a/extensions/eda/plugins/event_source/range.py +++ b/extensions/eda/plugins/event_source/range.py @@ -30,7 +30,7 @@ async def main(queue: asyncio.Queue, args: dict[str, Any]) -> None: if __name__ == "__main__": # MockQueue if running directly - class MockQueue: + class MockQueue(asyncio.Queue[Any]): """A fake queue.""" async def put(self: "MockQueue", event: dict) -> None: diff --git a/extensions/eda/plugins/event_source/tick.py b/extensions/eda/plugins/event_source/tick.py index eb368150..da6227dd 100644 --- a/extensions/eda/plugins/event_source/tick.py +++ b/extensions/eda/plugins/event_source/tick.py @@ -31,7 +31,7 @@ async def main(queue: asyncio.Queue, args: dict[str, Any]) -> None: if __name__ == "__main__": """MockQueue if running directly.""" - class MockQueue: + class MockQueue(asyncio.Queue[Any]): """A fake queue.""" async def put(self: "MockQueue", event: dict) -> None: diff --git a/extensions/eda/plugins/event_source/url_check.py b/extensions/eda/plugins/event_source/url_check.py index f02ca55e..cfefce51 100644 --- a/extensions/eda/plugins/event_source/url_check.py +++ b/extensions/eda/plugins/event_source/url_check.py @@ -69,7 +69,7 @@ async def main(queue: asyncio.Queue, args: dict[str, Any]) -> None: if __name__ == "__main__": """MockQueue if running directly.""" - class MockQueue: + class MockQueue(asyncio.Queue[Any]): """A fake queue.""" async def put(self: "MockQueue", event: dict) -> None: diff --git a/extensions/eda/plugins/event_source/webhook.py b/extensions/eda/plugins/event_source/webhook.py index 9bc02a08..aa93e1c5 100644 --- a/extensions/eda/plugins/event_source/webhook.py +++ b/extensions/eda/plugins/event_source/webhook.py @@ -147,6 +147,9 @@ def _get_ssl_context(args: dict[str, Any]) -> ssl.SSLContext | None: password = args.get("password", None) context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) try: + if not isinstance(certfile, str): # pragma: no-cover + msg = f"certfile is not a string, got a {type(certfile)} instead." + raise ValueError(msg) context.load_cert_chain(certfile, keyfile, password) except Exception: logger.exception("Failed to load certificates. Check they are valid") @@ -218,7 +221,7 @@ async def main(queue: asyncio.Queue, args: dict[str, Any]) -> None: if __name__ == "__main__": """MockQueue if running directly.""" - class MockQueue: + class MockQueue(asyncio.Queue[Any]): """A fake queue.""" async def put(self: MockQueue, event: dict) -> None: diff --git a/pyproject.toml b/pyproject.toml index 00ff6ca1..d24466c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,14 +41,11 @@ error_summary = true # TODO: Remove temporary skips and close https://github.com/ansible/event-driven-ansible/issues/258 disable_error_code = [ - "arg-type", "assignment", "attr-defined", "index", "misc", "override", - "return", - "return-value", "union-attr", "var-annotated", ]