mirror of
https://gitlab.com/itsulu-odoo/runboat.git
synced 2026-05-30 23:41:27 +00:00
ruff auto fixes
This commit is contained in:
parent
5040f8dee7
commit
56918f7472
4 changed files with 12 additions and 12 deletions
|
|
@ -224,7 +224,7 @@ class BuildEventSource:
|
||||||
return
|
return
|
||||||
self.queue.put_nowait(self._serialize(event, build))
|
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(
|
for build in controller.db.search(
|
||||||
repo=self.repo,
|
repo=self.repo,
|
||||||
target_branch=self.target_branch,
|
target_branch=self.target_branch,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ from . import __version__, api, controller, k8s, webhooks, webui
|
||||||
|
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
|
async def lifespan(app: FastAPI) -> AsyncGenerator[None]:
|
||||||
await k8s.load_kube_config()
|
await k8s.load_kube_config()
|
||||||
await controller.controller.start()
|
await controller.controller.start()
|
||||||
yield
|
yield
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ class WatchException(Exception):
|
||||||
|
|
||||||
def _watch(
|
def _watch(
|
||||||
list_method: Callable[..., Any], *args: Any, **kwargs: Any
|
list_method: Callable[..., Any], *args: Any, **kwargs: Any
|
||||||
) -> Generator[tuple[str | None, Any], None, None]:
|
) -> Generator[tuple[str | None, Any]]:
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
# perform a first query
|
# perform a first query
|
||||||
|
|
@ -121,7 +121,7 @@ def _watch(
|
||||||
|
|
||||||
|
|
||||||
@sync_to_async_iterator
|
@sync_to_async_iterator
|
||||||
def watch_deployments() -> Generator[V1Deployment, None, None]:
|
def watch_deployments() -> Generator[V1Deployment]:
|
||||||
appsv1 = client.AppsV1Api()
|
appsv1 = client.AppsV1Api()
|
||||||
yield from _watch(
|
yield from _watch(
|
||||||
appsv1.list_namespaced_deployment, namespace=settings.build_namespace
|
appsv1.list_namespaced_deployment, namespace=settings.build_namespace
|
||||||
|
|
@ -129,7 +129,7 @@ def watch_deployments() -> Generator[V1Deployment, None, None]:
|
||||||
|
|
||||||
|
|
||||||
@sync_to_async_iterator
|
@sync_to_async_iterator
|
||||||
def watch_jobs() -> Generator[V1Job, None, None]:
|
def watch_jobs() -> Generator[V1Job]:
|
||||||
batchv1 = client.BatchV1Api()
|
batchv1 = client.BatchV1Api()
|
||||||
yield from _watch(batchv1.list_namespaced_job, namespace=settings.build_namespace)
|
yield from _watch(batchv1.list_namespaced_job, namespace=settings.build_namespace)
|
||||||
|
|
||||||
|
|
@ -178,7 +178,7 @@ def make_deployment_vars(
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@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:
|
if kubefiles_path:
|
||||||
yield kubefiles_path
|
yield kubefiles_path
|
||||||
else:
|
else:
|
||||||
|
|
@ -191,7 +191,7 @@ def _get_kubefiles_path(kubefiles_path: Path | None) -> Generator[Path, None, No
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def _render_kubefiles(
|
def _render_kubefiles(
|
||||||
kubefiles_path: Path | None, deployment_vars: DeploymentVars
|
kubefiles_path: Path | None, deployment_vars: DeploymentVars
|
||||||
) -> Generator[Path, None, None]:
|
) -> Generator[Path]:
|
||||||
with (
|
with (
|
||||||
_get_kubefiles_path(kubefiles_path) as kubefiles_path,
|
_get_kubefiles_path(kubefiles_path) as kubefiles_path,
|
||||||
tempfile.TemporaryDirectory() as tmp_dir,
|
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(
|
container=pod.metadata.annotations.get(
|
||||||
"kubectl.kubernetes.io/default-container"
|
"kubectl.kubernetes.io/default-container"
|
||||||
),
|
),
|
||||||
tail_lines=None if job_kind else None,
|
tail_lines=None,
|
||||||
follow=False,
|
follow=False,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ def sync_to_async(func: Callable[P, R]) -> Callable[P, Awaitable[R]]:
|
||||||
|
|
||||||
|
|
||||||
def sync_to_async_iterator(
|
def sync_to_async_iterator(
|
||||||
iterator_func: Callable[P, Generator[R, None, None]],
|
iterator_func: Callable[P, Generator[R]],
|
||||||
) -> Callable[P, AsyncGenerator[R, None]]:
|
) -> Callable[P, AsyncGenerator[R]]:
|
||||||
@sync_to_async
|
@sync_to_async
|
||||||
def async_next(iterator: Iterator[R]) -> R:
|
def async_next(iterator: Iterator[R]) -> R:
|
||||||
try:
|
try:
|
||||||
|
|
@ -38,11 +38,11 @@ def sync_to_async_iterator(
|
||||||
raise StopAsyncIteration() from e
|
raise StopAsyncIteration() from e
|
||||||
|
|
||||||
@sync_to_async
|
@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)
|
return iterator_func(*args, **kwargs)
|
||||||
|
|
||||||
@wraps(iterator_func)
|
@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)
|
iterator = await async_iterator_func(*args, **kwargs)
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue