Skip to content

Commit

Permalink
Merge pull request #1137 from nolar/upgrade-mypy
Browse files Browse the repository at this point in the history
Upgrade the CI tooling (MyPy to 1.13.0, K8s/K3s, etc)
  • Loading branch information
nolar authored Nov 19, 2024
2 parents 6b8ce27 + 6260e59 commit 3d1c8ef
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
strategy:
fail-fast: false
matrix:
k3s: [latest, v1.28, v1.27, v1.26]
k3s: [latest, v1.31, v1.30, v1.29]
name: K3s ${{matrix.k3s}}
runs-on: ubuntu-22.04
timeout-minutes: 10 # usually 4-5 mins
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/thorough.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
strategy:
fail-fast: false
matrix:
k3s: [latest, v1.28, v1.27, v1.26]
k3s: [latest, v1.31, v1.30, v1.29]
name: K3s ${{matrix.k3s}}
runs-on: ubuntu-22.04
timeout-minutes: 10 # usually 4-5 mins
Expand All @@ -127,7 +127,7 @@ jobs:
strategy:
fail-fast: false
matrix:
k8s: [latest, v1.28.5, v1.27.9, v1.26.13]
k8s: [latest, v1.31.2, v1.30.6, v1.29.10]
name: K8s ${{matrix.k8s}}
runs-on: ubuntu-22.04
timeout-minutes: 10 # usually 4-5 mins
Expand Down
3 changes: 0 additions & 3 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@ sphinx>=2.0.0
sphinx-autobuild
sphinx-autodoc-typehints
sphinx_rtd_theme>=0.5

# Added 2023-05-06. TODO: Remove when resolved: https://github.com/psf/requests/issues/6432
urllib3<2.0.0
4 changes: 2 additions & 2 deletions kopf/_core/intents/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
IndexingFn = Callable[..., invocation.SyncOrAsync[Optional[object]]]
WatchingFn = Callable[..., invocation.SyncOrAsync[Optional[object]]]
ChangingFn = Callable[..., invocation.SyncOrAsync[Optional[object]]]
WebhookFn = Callable[..., invocation.SyncOrAsync[None]]
WebhookFn = Callable[..., invocation.SyncOrAsync[Optional[object]]]
DaemonFn = Callable[..., invocation.SyncOrAsync[Optional[object]]]
TimerFn = Callable[..., invocation.SyncOrAsync[Optional[object]]]
WhenFilterFn = Callable[..., bool] # strictly sync, no async!
Expand Down Expand Up @@ -145,7 +145,7 @@
DefaultNamedArg(Any, "param"),
KwArg(Any),
],
invocation.SyncOrAsync[None]
invocation.SyncOrAsync[Optional[object]]
]

DaemonFn = Callable[
Expand Down
24 changes: 19 additions & 5 deletions kopf/_core/reactor/orchestration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ freezegun
import-linter
isort
lxml
mypy==1.8.0
mypy==1.13.0
pre-commit
pyngrok
pytest>=6.0.0
Expand Down

0 comments on commit 3d1c8ef

Please sign in to comment.