diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c3c44f34..b8c64628 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -98,7 +98,7 @@ repos: - pytest - pyyaml - requests - - types-aiobotocore + - types-aiobotocore[cloudtrail,sqs] - watchdog - xxhash - repo: local diff --git a/extensions/eda/plugins/event_source/aws_cloudtrail.py b/extensions/eda/plugins/event_source/aws_cloudtrail.py index 5f9bcb00..6f6b680e 100644 --- a/extensions/eda/plugins/event_source/aws_cloudtrail.py +++ b/extensions/eda/plugins/event_source/aws_cloudtrail.py @@ -36,8 +36,8 @@ from datetime import datetime from typing import Any -from aiobotocore.client import BaseClient from aiobotocore.session import get_session +from botocore.client import BaseClient def _cloudtrail_event_to_dict(event: dict) -> dict: diff --git a/extensions/eda/plugins/event_source/azure_service_bus.py b/extensions/eda/plugins/event_source/azure_service_bus.py index dcd51d98..f00d14c5 100644 --- a/extensions/eda/plugins/event_source/azure_service_bus.py +++ b/extensions/eda/plugins/event_source/azure_service_bus.py @@ -69,7 +69,7 @@ async def main( class MockQueue(asyncio.Queue[Any]): """A fake queue.""" - async def put_nowait(self: "MockQueue", event: dict) -> None: + def put_nowait(self: "MockQueue", event: dict) -> None: """Print the event.""" print(event) # noqa: T201 diff --git a/extensions/eda/plugins/event_source/file.py b/extensions/eda/plugins/event_source/file.py index 09403d98..df5809e9 100644 --- a/extensions/eda/plugins/event_source/file.py +++ b/extensions/eda/plugins/event_source/file.py @@ -18,7 +18,7 @@ import pathlib import yaml -from watchdog.events import RegexMatchingEventHandler +from watchdog.events import FileSystemEvent, RegexMatchingEventHandler from watchdog.observers import Observer @@ -63,18 +63,18 @@ class Handler(RegexMatchingEventHandler): def __init__(self: "Handler", **kwargs) -> None: # noqa: ANN003 RegexMatchingEventHandler.__init__(self, **kwargs) - def on_created(self: "Handler", event: dict) -> None: + def on_created(self: "Handler", event: FileSystemEvent) -> None: if event.src_path in files: send_facts(queue, event.src_path) - def on_deleted(self: "Handler", event: dict) -> None: + def on_deleted(self: "Handler", event: FileSystemEvent) -> None: pass - def on_modified(self: "Handler", event: dict) -> None: + def on_modified(self: "Handler", event: FileSystemEvent) -> None: if event.src_path in files: send_facts(queue, event.src_path) - def on_moved(self: "Handler", event: dict) -> None: + def on_moved(self: "Handler", event: FileSystemEvent) -> None: pass observer = Observer() diff --git a/extensions/eda/plugins/event_source/file_watch.py b/extensions/eda/plugins/event_source/file_watch.py index aa2b09aa..2c28306e 100644 --- a/extensions/eda/plugins/event_source/file_watch.py +++ b/extensions/eda/plugins/event_source/file_watch.py @@ -22,7 +22,7 @@ import concurrent.futures from typing import Any -from watchdog.events import RegexMatchingEventHandler +from watchdog.events import FileSystemEvent, RegexMatchingEventHandler from watchdog.observers import Observer @@ -37,10 +37,10 @@ def watch( class Handler(RegexMatchingEventHandler): """A handler for file system events.""" - def __init__(self: "Handler", **kwargs: dict) -> None: + def __init__(self: "Handler", **kwargs: FileSystemEvent) -> None: RegexMatchingEventHandler.__init__(self, **kwargs) - def on_created(self: "Handler", event: dict) -> None: + def on_created(self: "Handler", event: FileSystemEvent) -> None: loop.call_soon_threadsafe( queue.put_nowait, { @@ -51,7 +51,7 @@ def on_created(self: "Handler", event: dict) -> None: }, ) - def on_deleted(self: "Handler", event: dict) -> None: + def on_deleted(self: "Handler", event: FileSystemEvent) -> None: loop.call_soon_threadsafe( queue.put_nowait, { @@ -62,7 +62,7 @@ def on_deleted(self: "Handler", event: dict) -> None: }, ) - def on_modified(self: "Handler", event: dict) -> None: + def on_modified(self: "Handler", event: FileSystemEvent) -> None: loop.call_soon_threadsafe( queue.put_nowait, { @@ -73,7 +73,7 @@ def on_modified(self: "Handler", event: dict) -> None: }, ) - def on_moved(self: "Handler", event: dict) -> None: + def on_moved(self: "Handler", event: FileSystemEvent) -> None: loop.call_soon_threadsafe( queue.put_nowait, { @@ -110,7 +110,7 @@ async def main(queue: asyncio.Queue, args: dict) -> None: class MockQueue(asyncio.Queue[Any]): """A fake queue.""" - async def put_nowait(self: "MockQueue", event: dict) -> None: + def put_nowait(self: "MockQueue", event: dict) -> None: """Print the event.""" print(event) # noqa: T201 diff --git a/extensions/eda/plugins/event_source/journald.py b/extensions/eda/plugins/event_source/journald.py index 2de64c50..67087e0e 100644 --- a/extensions/eda/plugins/event_source/journald.py +++ b/extensions/eda/plugins/event_source/journald.py @@ -79,9 +79,8 @@ 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, event: str) -> str: + async def put(self, event: str) -> None: """Add the event to the queue and print it.""" print(event) # noqa: T201 - return "" asyncio.run(main(MockQueue(), {"match": "ALL"})) diff --git a/pyproject.toml b/pyproject.toml index 0e59c5e0..640997e6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,10 +40,6 @@ color_output = true error_summary = true # TODO: Remove temporary skips and close https://github.com/ansible/event-driven-ansible/issues/258 -disable_error_code = [ - "attr-defined", - "override", -] # strict = true # disallow_untyped_calls = true # disallow_untyped_defs = true