From d7ba9e8781c2e300bd0cabf87cdaec6272e6a6f4 Mon Sep 17 00:00:00 2001 From: Laszlo Szomor Date: Mon, 21 Aug 2023 16:06:08 +0200 Subject: [PATCH] Revert - Fix tox issues This reverts commit 7d65d2de297d0698d46f8a8caff877fe94ad568b --- .../eda/plugins/event_source/alertmanager.py | 4 +--- .../eda/plugins/event_source/aws_cloudtrail.py | 10 +++------- .../eda/plugins/event_source/aws_sqs_queue.py | 4 +--- .../eda/plugins/event_source/azure_service_bus.py | 4 +--- extensions/eda/plugins/event_source/file.py | 14 ++++++-------- extensions/eda/plugins/event_source/generic.py | 4 +--- extensions/eda/plugins/event_source/journald.py | 2 -- extensions/eda/plugins/event_source/kafka.py | 4 +--- extensions/eda/plugins/event_source/range.py | 4 +--- extensions/eda/plugins/event_source/tick.py | 5 +---- extensions/eda/plugins/event_source/url_check.py | 4 +--- extensions/eda/plugins/event_source/webhook.py | 9 +++------ 12 files changed, 20 insertions(+), 48 deletions(-) diff --git a/extensions/eda/plugins/event_source/alertmanager.py b/extensions/eda/plugins/event_source/alertmanager.py index eff6abde..7384b347 100644 --- a/extensions/eda/plugins/event_source/alertmanager.py +++ b/extensions/eda/plugins/event_source/alertmanager.py @@ -32,8 +32,6 @@ """ -from __future__ import annotations - import asyncio import logging from typing import Any @@ -146,7 +144,7 @@ async def main(queue: asyncio.Queue, args: dict[str, Any]) -> None: class MockQueue: """A fake queue.""" - async def put(self: MockQueue, event: dict) -> None: + async def put(self: "MockQueue", event: dict) -> None: """Print the event.""" print(event) # noqa: T201 diff --git a/extensions/eda/plugins/event_source/aws_cloudtrail.py b/extensions/eda/plugins/event_source/aws_cloudtrail.py index 56f5c48e..7847fcdf 100644 --- a/extensions/eda/plugins/event_source/aws_cloudtrail.py +++ b/extensions/eda/plugins/event_source/aws_cloudtrail.py @@ -31,18 +31,14 @@ """ -from __future__ import annotations - import asyncio import json from datetime import datetime -from typing import TYPE_CHECKING, Any +from typing import Any +from aiobotocore.client import BaseClient from aiobotocore.session import get_session -if TYPE_CHECKING: - from aiobotocore.client import BaseClient - def _cloudtrail_event_to_dict(event: dict) -> dict: event["EventTime"] = event["EventTime"].isoformat() @@ -135,7 +131,7 @@ def connection_args(args: dict[str, Any]) -> dict[str, Any]: class MockQueue: """A fake queue.""" - async def put(self: MockQueue, event: dict) -> None: + async def put(self: "MockQueue", event: dict) -> None: """Print the event.""" print(event) # noqa: T201 diff --git a/extensions/eda/plugins/event_source/aws_sqs_queue.py b/extensions/eda/plugins/event_source/aws_sqs_queue.py index 90f26383..7dd3afb5 100644 --- a/extensions/eda/plugins/event_source/aws_sqs_queue.py +++ b/extensions/eda/plugins/event_source/aws_sqs_queue.py @@ -21,8 +21,6 @@ """ -from __future__ import annotations - import asyncio import json import logging @@ -111,7 +109,7 @@ def connection_args(args: dict[str, Any]) -> dict[str, Any]: class MockQueue: """A fake queue.""" - async def put(self: MockQueue, event: dict) -> None: + async def put(self: "MockQueue", event: dict) -> None: """Print the event.""" print(event) # noqa: T201 diff --git a/extensions/eda/plugins/event_source/azure_service_bus.py b/extensions/eda/plugins/event_source/azure_service_bus.py index 3b48ea90..940e6ec6 100644 --- a/extensions/eda/plugins/event_source/azure_service_bus.py +++ b/extensions/eda/plugins/event_source/azure_service_bus.py @@ -16,8 +16,6 @@ """ -from __future__ import annotations - import asyncio import concurrent.futures import contextlib @@ -71,7 +69,7 @@ async def main( class MockQueue: """A fake queue.""" - async def put_nowait(self: MockQueue, event: dict) -> None: + async 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 5d845a0d..09403d98 100644 --- a/extensions/eda/plugins/event_source/file.py +++ b/extensions/eda/plugins/event_source/file.py @@ -15,8 +15,6 @@ """ -from __future__ import annotations - import pathlib import yaml @@ -62,21 +60,21 @@ def _observe_files(queue, files: list[str]) -> None: # noqa: ANN001 class Handler(RegexMatchingEventHandler): """A handler for file events.""" - def __init__(self: Handler, **kwargs) -> None: # noqa: ANN003 + 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: dict) -> 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: dict) -> None: pass - def on_modified(self: Handler, event: dict) -> None: + def on_modified(self: "Handler", event: dict) -> 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: dict) -> None: pass observer = Observer() @@ -100,7 +98,7 @@ def on_moved(self: Handler, event: dict) -> None: class MockQueue: """A fake queue.""" - async def put(self: MockQueue, event: dict) -> None: + async def put(self: "MockQueue", event: dict) -> None: """Print the event.""" print(event) # noqa: T201 diff --git a/extensions/eda/plugins/event_source/generic.py b/extensions/eda/plugins/event_source/generic.py index 0b033756..3039d0a7 100644 --- a/extensions/eda/plugins/event_source/generic.py +++ b/extensions/eda/plugins/event_source/generic.py @@ -41,8 +41,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import annotations - import asyncio import random import time @@ -130,7 +128,7 @@ def _create_data( class MockQueue: """A fake queue.""" - async def put(self: MockQueue, event: dict) -> None: + async def put(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 fb727991..be3b2486 100644 --- a/extensions/eda/plugins/event_source/journald.py +++ b/extensions/eda/plugins/event_source/journald.py @@ -23,8 +23,6 @@ """ -from __future__ import annotations - import asyncio from typing import Any diff --git a/extensions/eda/plugins/event_source/kafka.py b/extensions/eda/plugins/event_source/kafka.py index b6512002..d3ee5c01 100644 --- a/extensions/eda/plugins/event_source/kafka.py +++ b/extensions/eda/plugins/event_source/kafka.py @@ -24,8 +24,6 @@ """ -from __future__ import annotations - import asyncio import json import logging @@ -105,7 +103,7 @@ async def main( # pylint: disable=R0914 class MockQueue: """A fake queue.""" - async def put(self: MockQueue, event: dict) -> None: + async def put(self: "MockQueue", event: dict) -> None: """Print the event.""" print(event) # noqa: T201 diff --git a/extensions/eda/plugins/event_source/range.py b/extensions/eda/plugins/event_source/range.py index ab884081..01609c6d 100644 --- a/extensions/eda/plugins/event_source/range.py +++ b/extensions/eda/plugins/event_source/range.py @@ -14,8 +14,6 @@ """ -from __future__ import annotations - import asyncio from typing import Any @@ -35,7 +33,7 @@ async def main(queue: asyncio.Queue, args: dict[str, Any]) -> None: class MockQueue: """A fake queue.""" - async def put(self: MockQueue, event: dict) -> None: + async def put(self: "MockQueue", event: dict) -> None: """Print the event.""" print(event) # noqa: T201 diff --git a/extensions/eda/plugins/event_source/tick.py b/extensions/eda/plugins/event_source/tick.py index 42bd3b60..48632dc7 100644 --- a/extensions/eda/plugins/event_source/tick.py +++ b/extensions/eda/plugins/event_source/tick.py @@ -13,9 +13,6 @@ delay: 5 """ - -from __future__ import annotations - import asyncio import itertools from typing import Any @@ -36,7 +33,7 @@ async def main(queue: asyncio.Queue, args: dict[str, Any]) -> None: class MockQueue: """A fake queue.""" - async def put(self: MockQueue, event: dict) -> None: + async def put(self: "MockQueue", event: dict) -> None: """Print the event.""" print(event) # noqa: T201 diff --git a/extensions/eda/plugins/event_source/url_check.py b/extensions/eda/plugins/event_source/url_check.py index 772afa05..f02ca55e 100644 --- a/extensions/eda/plugins/event_source/url_check.py +++ b/extensions/eda/plugins/event_source/url_check.py @@ -19,8 +19,6 @@ """ -from __future__ import annotations - import asyncio from typing import Any @@ -74,7 +72,7 @@ async def main(queue: asyncio.Queue, args: dict[str, Any]) -> None: class MockQueue: """A fake queue.""" - async def put(self: MockQueue, event: dict) -> None: + async def put(self: "MockQueue", event: dict) -> None: """Print the event.""" print(event) # noqa: T201 diff --git a/extensions/eda/plugins/event_source/webhook.py b/extensions/eda/plugins/event_source/webhook.py index 2023fcf9..8ae85259 100644 --- a/extensions/eda/plugins/event_source/webhook.py +++ b/extensions/eda/plugins/event_source/webhook.py @@ -23,7 +23,6 @@ Defaults to hex """ -from __future__ import annotations import asyncio import base64 @@ -32,13 +31,11 @@ import json import logging import ssl -from typing import TYPE_CHECKING, Any +from collections.abc import Callable +from typing import Any from aiohttp import web -if TYPE_CHECKING: - from collections.abc import Callable - logger = logging.getLogger(__name__) routes = web.RouteTableDef() @@ -194,7 +191,7 @@ async def main(queue: asyncio.Queue, args: dict[str, Any]) -> None: class MockQueue: """A fake queue.""" - async def put(self: MockQueue, event: dict) -> None: + async def put(self: "MockQueue", event: dict) -> None: """Print the event.""" print(event) # noqa: T201