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 16, 2024
1 parent 15a4fbb commit ec054a8
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 21 deletions.
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:
"""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"}))
2 changes: 2 additions & 0 deletions plugins/modules/project_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@
]
""" # NOQA

# pylint: disable=wrong-import-position,
from ansible.module_utils.basic import AnsibleModule

# pylint: disable=relative-beyon-top-level
from ..module_utils.arguments import AUTH_ARGSPEC
from ..module_utils.client import Client
from ..module_utils.controller import Controller
Expand Down
11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,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 All @@ -65,11 +61,16 @@ module = [
"aiokafka.*", # https://github.com/aio-libs/aiokafka/issues/980
"ansible.*", # https://github.com/ansible/ansible/issues/83801
"asyncmock", # https://github.com/timsavage/asyncmock/issues/8
# "botocore.*", # https://github.com/boto/botocore/issues/2297
"kafka.*", # https://github.com/dpkp/kafka-python/issues/2446
]
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = [
"ansible_collections.ansible.eda.*",
]
ignore_missing_imports = true

[tool.pylint.MASTER]
# Temporary ignore until we are able to address issues on these:
ignore-paths = "^(demos/dynatrace-demo/fake_app.py|tests/|plugins/modules).*$"
Expand Down

0 comments on commit ec054a8

Please sign in to comment.