From 5f14fa51d4289e2eb39b5d0ba452732c85d971be Mon Sep 17 00:00:00 2001 From: Sergey Vasilyev Date: Mon, 18 Nov 2024 19:26:26 +0100 Subject: [PATCH] Upgrade mypy to 1.13.0 Signed-off-by: Sergey Vasilyev --- kopf/_core/reactor/orchestration.py | 24 +++++++++++++++++++----- requirements.txt | 2 +- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/kopf/_core/reactor/orchestration.py b/kopf/_core/reactor/orchestration.py index 1931a202..64bfd9e6 100644 --- a/kopf/_core/reactor/orchestration.py +++ b/kopf/_core/reactor/orchestration.py @@ -27,11 +27,12 @@ import functools import itertools import logging -from typing import Any, Collection, Container, Dict, Iterable, MutableMapping, NamedTuple, Optional +from typing import Any, Collection, Container, Dict, Iterable, \ + MutableMapping, NamedTuple, Optional, Protocol from kopf._cogs.aiokits import aiotasks, aiotoggles from kopf._cogs.configs import configuration -from kopf._cogs.structs import references +from kopf._cogs.structs import bodies, references from kopf._core.engines import peering from kopf._core.reactor import queueing @@ -43,6 +44,19 @@ class EnsembleKey(NamedTuple): namespace: references.Namespace +# Differs from queueing.WatchStreamProcessor by the resource=… kwarg. +class ResourceWatchStreamProcessor(Protocol): + async def __call__( + self, + *, + resource: references.Resource, + raw_event: bodies.RawEvent, + stream_pressure: Optional[asyncio.Event] = None, # None for tests + resource_indexed: Optional[aiotoggles.Toggle] = None, # None for tests & observation + operator_indexed: Optional[aiotoggles.ToggleSet] = None, # None for tests & observation + ) -> None: ... + + @dataclasses.dataclass class Ensemble: @@ -89,7 +103,7 @@ def del_keys(self, keys: Container[EnsembleKey]) -> None: async def ochestrator( *, - processor: queueing.WatchStreamProcessor, + processor: ResourceWatchStreamProcessor, settings: configuration.OperatorSettings, identity: peering.Identity, insights: references.Insights, @@ -122,7 +136,7 @@ async def ochestrator( # for a simulation of the insights (inputs) and an assertion of the tasks & toggles (outputs). async def adjust_tasks( *, - processor: queueing.WatchStreamProcessor, + processor: ResourceWatchStreamProcessor, insights: references.Insights, settings: configuration.OperatorSettings, identity: peering.Identity, @@ -213,7 +227,7 @@ async def spawn_missing_peerings( async def spawn_missing_watchers( *, - processor: queueing.WatchStreamProcessor, + processor: ResourceWatchStreamProcessor, settings: configuration.OperatorSettings, indexed_resources: Container[references.Resource], # only "if in", never "for in"! watched_resources: Iterable[references.Resource], diff --git a/requirements.txt b/requirements.txt index 88ee4ebe..00d3f20b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,7 +12,7 @@ freezegun import-linter isort lxml -mypy==1.8.0 +mypy==1.13.0 pre-commit pyngrok pytest>=6.0.0