diff --git a/kopf/_cogs/aiokits/aioadapters.py b/kopf/_cogs/aiokits/aioadapters.py index 948a646c..8416d9be 100644 --- a/kopf/_cogs/aiokits/aioadapters.py +++ b/kopf/_cogs/aiokits/aioadapters.py @@ -1,11 +1,16 @@ import asyncio import concurrent.futures import threading -from typing import Any, Optional, Union +from typing import TYPE_CHECKING, Any, Optional, Union from kopf._cogs.aiokits import aiotasks -Flag = Union[aiotasks.Future, asyncio.Event, concurrent.futures.Future, threading.Event] +if TYPE_CHECKING: + concurrent_Future = concurrent.futures.Future[Any] +else: + concurrent_Future = concurrent.futures.Future # Python<=3.8 + +Flag = Union[aiotasks.Future, asyncio.Event, concurrent_Future, threading.Event] async def wait_flag( diff --git a/kopf/_cogs/structs/references.py b/kopf/_cogs/structs/references.py index 3782754f..1e788398 100644 --- a/kopf/_cogs/structs/references.py +++ b/kopf/_cogs/structs/references.py @@ -9,7 +9,7 @@ # A namespace specification with globs, negations, and some minimal syntax; see `match_namespace()`. # Regexps are also supported if pre-compiled from the code, not from the CLI options as raw strings. -NamespacePattern = Union[str, Pattern] +NamespacePattern = Union[str, Pattern[str]] # A specific really existing addressable namespace (at least, the one assumed to be so). # Made as a NewType for stricter type-checking to avoid collisions with patterns and other strings. diff --git a/kopf/_core/engines/peering.py b/kopf/_core/engines/peering.py index 75f66502..3dbc87d9 100644 --- a/kopf/_core/engines/peering.py +++ b/kopf/_core/engines/peering.py @@ -303,8 +303,8 @@ async def touch_command( ) -> None: await asyncio.wait({ - insights.ready_namespaces.wait(), - insights.ready_resources.wait(), + asyncio.create_task(insights.ready_namespaces.wait()), + asyncio.create_task(insights.ready_resources.wait()), }) selectors = guess_selectors(settings=settings) diff --git a/kopf/_core/intents/callbacks.py b/kopf/_core/intents/callbacks.py index 90111688..bc19992f 100644 --- a/kopf/_core/intents/callbacks.py +++ b/kopf/_core/intents/callbacks.py @@ -37,7 +37,7 @@ ActivityFn = Callable[ [ NamedArg(configuration.OperatorSettings, "settings"), - NamedArg(ephemera.Index, "*"), + NamedArg(ephemera.Index[Any, Any], "*"), NamedArg(int, "retry"), NamedArg(datetime.datetime, "started"), NamedArg(datetime.timedelta, "runtime"), @@ -175,7 +175,7 @@ TimerFn = Callable[ [ - NamedArg(ephemera.Index, "*"), + NamedArg(ephemera.Index[Any, Any], "*"), NamedArg(bodies.Annotations, "annotations"), NamedArg(bodies.Labels, "labels"), NamedArg(bodies.Body, "body"), diff --git a/requirements.txt b/requirements.txt index 619d8e32..915c2288 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,7 +12,7 @@ freezegun import-linter isort lxml -mypy==1.5.1 +mypy==1.8.0 pre-commit pyngrok pytest>=6.0.0