Skip to content

Commit

Permalink
Address more typing errors
Browse files Browse the repository at this point in the history
Related: #258
  • Loading branch information
ssbarnea committed Aug 15, 2024
1 parent 67be178 commit 707fc95
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ repos:
- pytest
- pyyaml
- requests
- types-aiobotocore
- types-aiobotocore[cloudtrail,sqs]
- watchdog
- xxhash
- repo: local
Expand Down
2 changes: 1 addition & 1 deletion extensions/eda/plugins/event_source/aws_cloudtrail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion extensions/eda/plugins/event_source/azure_service_bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Check warning on line 72 in extensions/eda/plugins/event_source/azure_service_bus.py

View check run for this annotation

Codecov / codecov/patch

extensions/eda/plugins/event_source/azure_service_bus.py#L72

Added line #L72 was not covered by tests
"""Print the event."""
print(event) # noqa: T201

Expand Down
10 changes: 5 additions & 5 deletions extensions/eda/plugins/event_source/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import pathlib

import yaml
from watchdog.events import RegexMatchingEventHandler
from watchdog.events import FileSystemEvent, RegexMatchingEventHandler
from watchdog.observers import Observer


Expand Down Expand Up @@ -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()
Expand Down
14 changes: 7 additions & 7 deletions extensions/eda/plugins/event_source/file_watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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,
{
Expand All @@ -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,
{
Expand All @@ -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,
{
Expand All @@ -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,
{
Expand Down Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions extensions/eda/plugins/event_source/journald.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}))
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 707fc95

Please sign in to comment.