Skip to content

Commit

Permalink
Add type hints to other APIObjectSyncMixin methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtomlinson committed Jan 22, 2025
1 parent 9848dc4 commit 6915d07
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions kr8s/_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ async def async_scale(self, replicas: int | None = None) -> None:
await self.async_refresh()
await anyio.sleep(0.1)

async def async_watch(self):
async def async_watch(self) -> AsyncGenerator[tuple[str, Self]]:
"""Watch this object in Kubernetes."""
since = self.metadata.get("resourceVersion")
assert self.api
Expand All @@ -470,7 +470,7 @@ async def async_watch(self):
self.raw = obj.raw
yield event, self

async def watch(self):
async def watch(self) -> AsyncGenerator[tuple[str, Self]]:
"""Watch this object in Kubernetes."""
async for event, obj in self.async_watch():
yield event, obj
Expand Down Expand Up @@ -771,7 +771,7 @@ class APIObjectSyncMixin(APIObject):
_asyncio = False

@classmethod
def get( # type: ignore
def get( # type: ignore[override]
cls,
name: str | None = None,
namespace: str | None = None,
Expand All @@ -791,45 +791,45 @@ def get( # type: ignore
**kwargs,
) # type: ignore

def exists(self, ensure=False) -> bool: # type: ignore
def exists(self, ensure=False) -> bool: # type: ignore[override]
return run_sync(self.async_exists)(ensure=ensure) # type: ignore

def create(self) -> None: # type: ignore
def create(self) -> None: # type: ignore[override]
return run_sync(self.async_create)() # type: ignore

def delete(self, propagation_policy: str | None = None) -> None: # type: ignore
def delete(self, propagation_policy: str | None = None) -> None: # type: ignore[override]
return run_sync(self.async_delete)(propagation_policy=propagation_policy) # type: ignore

def refresh(self):
def refresh(self) -> None: # type: ignore[override]
return run_sync(self.async_refresh)() # type: ignore

def patch(self, patch, *, subresource=None, type=None):
def patch(self, patch, *, subresource=None, type=None) -> None: # type: ignore[override]
return run_sync(self.async_patch)(patch, subresource=subresource, type=type) # type: ignore

def scale(self, replicas=None):
def scale(self, replicas=None) -> None: # type: ignore[override]
return run_sync(self.async_scale)(replicas=replicas) # type: ignore

def watch(self):
def watch(self) -> Generator[tuple[str, Self]]: # type: ignore[override]
yield from run_sync(self.async_watch)()

def wait(
def wait( # type: ignore[override]
self,
conditions: list[str] | str,
mode: Literal["any", "all"] = "any",
timeout: int | float | None = None,
):
) -> None:
return run_sync(self.async_wait)(conditions, mode=mode, timeout=timeout) # type: ignore

def annotate(self, annotations=None, **kwargs):
def annotate(self, annotations=None, **kwargs) -> None: # type: ignore[override]
return run_sync(self.async_annotate)(annotations, **kwargs) # type: ignore

def label(self, labels=None, **kwargs):
def label(self, labels=None, **kwargs) -> None: # type: ignore[override]
return run_sync(self.async_label)(labels, **kwargs) # type: ignore

def set_owner(self, owner):
def set_owner(self, owner) -> None: # type: ignore[override]
return run_sync(self.async_set_owner)(owner) # type: ignore

def adopt(self, child):
def adopt(self, child) -> None: # type: ignore[override]
return run_sync(self.async_adopt)(child) # type: ignore

@classmethod
Expand Down

0 comments on commit 6915d07

Please sign in to comment.