Skip to content

Commit

Permalink
Address more typing errors (#264)
Browse files Browse the repository at this point in the history
Related: #258
  • Loading branch information
ssbarnea authored Aug 16, 2024
1 parent 15a4fbb commit 4e21dd2
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ repos:
- xxhash

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.5.7"
rev: "v0.6.0"
hooks:
- id: ruff
args: [
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:
"""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-beyond-top-level
from ..module_utils.arguments import AUTH_ARGSPEC
from ..module_utils.client import Client
from ..module_utils.controller import Controller
Expand Down
5 changes: 0 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,7 +61,6 @@ 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
Expand Down

0 comments on commit 4e21dd2

Please sign in to comment.