From 56918f7472851f8e54207db2fff99992c8a8e2b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Sat, 1 Mar 2025 13:14:55 +0100 Subject: [PATCH] ruff auto fixes --- src/runboat/api.py | 2 +- src/runboat/app.py | 2 +- src/runboat/k8s.py | 12 ++++++------ src/runboat/utils.py | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/runboat/api.py b/src/runboat/api.py index 018681a..8e141c0 100644 --- a/src/runboat/api.py +++ b/src/runboat/api.py @@ -224,7 +224,7 @@ class BuildEventSource: return self.queue.put_nowait(self._serialize(event, build)) - async def events(self) -> AsyncGenerator[str, None]: + async def events(self) -> AsyncGenerator[str]: for build in controller.db.search( repo=self.repo, target_branch=self.target_branch, diff --git a/src/runboat/app.py b/src/runboat/app.py index 20f052e..8734299 100644 --- a/src/runboat/app.py +++ b/src/runboat/app.py @@ -7,7 +7,7 @@ from . import __version__, api, controller, k8s, webhooks, webui @asynccontextmanager -async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]: +async def lifespan(app: FastAPI) -> AsyncGenerator[None]: await k8s.load_kube_config() await controller.controller.start() yield diff --git a/src/runboat/k8s.py b/src/runboat/k8s.py index e1dbbbe..9233343 100644 --- a/src/runboat/k8s.py +++ b/src/runboat/k8s.py @@ -86,7 +86,7 @@ class WatchException(Exception): def _watch( list_method: Callable[..., Any], *args: Any, **kwargs: Any -) -> Generator[tuple[str | None, Any], None, None]: +) -> Generator[tuple[str | None, Any]]: while True: try: # perform a first query @@ -121,7 +121,7 @@ def _watch( @sync_to_async_iterator -def watch_deployments() -> Generator[V1Deployment, None, None]: +def watch_deployments() -> Generator[V1Deployment]: appsv1 = client.AppsV1Api() yield from _watch( appsv1.list_namespaced_deployment, namespace=settings.build_namespace @@ -129,7 +129,7 @@ def watch_deployments() -> Generator[V1Deployment, None, None]: @sync_to_async_iterator -def watch_jobs() -> Generator[V1Job, None, None]: +def watch_jobs() -> Generator[V1Job]: batchv1 = client.BatchV1Api() yield from _watch(batchv1.list_namespaced_job, namespace=settings.build_namespace) @@ -178,7 +178,7 @@ def make_deployment_vars( @contextmanager -def _get_kubefiles_path(kubefiles_path: Path | None) -> Generator[Path, None, None]: +def _get_kubefiles_path(kubefiles_path: Path | None) -> Generator[Path]: if kubefiles_path: yield kubefiles_path else: @@ -191,7 +191,7 @@ def _get_kubefiles_path(kubefiles_path: Path | None) -> Generator[Path, None, No @contextmanager def _render_kubefiles( kubefiles_path: Path | None, deployment_vars: DeploymentVars -) -> Generator[Path, None, None]: +) -> Generator[Path]: with ( _get_kubefiles_path(kubefiles_path) as kubefiles_path, tempfile.TemporaryDirectory() as tmp_dir, @@ -299,7 +299,7 @@ def log(build_name: str, job_kind: DeploymentMode | None) -> str | None: container=pod.metadata.annotations.get( "kubectl.kubernetes.io/default-container" ), - tail_lines=None if job_kind else None, + tail_lines=None, follow=False, ), ) diff --git a/src/runboat/utils.py b/src/runboat/utils.py index 361c283..753b4d7 100644 --- a/src/runboat/utils.py +++ b/src/runboat/utils.py @@ -28,8 +28,8 @@ def sync_to_async(func: Callable[P, R]) -> Callable[P, Awaitable[R]]: def sync_to_async_iterator( - iterator_func: Callable[P, Generator[R, None, None]], -) -> Callable[P, AsyncGenerator[R, None]]: + iterator_func: Callable[P, Generator[R]], +) -> Callable[P, AsyncGenerator[R]]: @sync_to_async def async_next(iterator: Iterator[R]) -> R: try: @@ -38,11 +38,11 @@ def sync_to_async_iterator( raise StopAsyncIteration() from e @sync_to_async - def async_iterator_func(*args: Any, **kwargs: Any) -> Generator[R, None, None]: + def async_iterator_func(*args: Any, **kwargs: Any) -> Generator[R]: return iterator_func(*args, **kwargs) @wraps(iterator_func) - async def inner(*args: Any, **kwargs: Any) -> AsyncGenerator[R, None]: + async def inner(*args: Any, **kwargs: Any) -> AsyncGenerator[R]: iterator = await async_iterator_func(*args, **kwargs) while True: try: