diff --git a/src/posit/connect/packages.py b/src/posit/connect/packages.py index 7e0d9279..27e24475 100644 --- a/src/posit/connect/packages.py +++ b/src/posit/connect/packages.py @@ -1,7 +1,7 @@ from __future__ import annotations import posixpath -from typing import Generator, Literal, Optional, TypedDict, overload +from typing import Generator, Literal, Optional, TypedDict from typing_extensions import NotRequired, Required, Unpack @@ -57,8 +57,7 @@ class _FindBy(TypedDict, total=False): hash: NotRequired[Optional[str]] """Package description hash for R packages.""" - @overload - def find_by(self, **conditions: Unpack[_FindBy]): + def find_by(self, **conditions: Unpack[_FindBy]): # type: ignore """ Find the first record matching the specified conditions. @@ -86,11 +85,6 @@ def find_by(self, **conditions: Unpack[_FindBy]): Optional[T] The first record matching the specified conditions, or `None` if no such record exists. """ - - @overload - def find_by(self, **conditions): ... - - def find_by(self, **conditions): return super().find_by(**conditions) @@ -152,16 +146,10 @@ class _Fetch(TypedDict, total=False): version: Required[str] """The package version""" - @overload - def fetch(self, **conditions: Unpack[_Fetch]): ... - - @overload - def fetch(self, **conditions): ... - - def fetch(self, **conditions) -> Generator["Package"]: + def fetch(self, **conditions: Unpack[_Fetch]) -> Generator["Package"]: # type: ignore # todo - add pagination support to ActiveSequence url = self._ctx.url + self._path - paginator = Paginator(self._ctx.session, url, conditions) + paginator = Paginator(self._ctx.session, url, dict(**conditions)) for page in paginator.fetch_pages(): results = page.results yield from (self._create_instance("", **result) for result in results) @@ -194,8 +182,7 @@ class _FindBy(TypedDict, total=False): app_guid: NotRequired[str] """The unique identifier of the application this package is associated with""" - @overload - def find_by(self, **conditions: Unpack[_FindBy]) -> "Package | None": + def find_by(self, **conditions: Unpack[_FindBy]) -> "Package | None": # type: ignore """ Find the first record matching the specified conditions. @@ -223,9 +210,4 @@ def find_by(self, **conditions: Unpack[_FindBy]) -> "Package | None": Optional[Package] The first record matching the specified conditions, or `None` if no such record exists. """ - - @overload - def find_by(self, **conditions) -> "Package | None": ... - - def find_by(self, **conditions) -> "Package | None": return super().find_by(**conditions) diff --git a/src/posit/connect/paginator.py b/src/posit/connect/paginator.py index 2889801c..5086057b 100644 --- a/src/posit/connect/paginator.py +++ b/src/posit/connect/paginator.py @@ -1,7 +1,7 @@ from __future__ import annotations from dataclasses import dataclass -from typing import TYPE_CHECKING, Any, Generator, List +from typing import TYPE_CHECKING, Generator, List if TYPE_CHECKING: import requests @@ -45,7 +45,7 @@ def __init__( self, session: requests.Session, url: str, - params: dict[str, Any] | None = None, + params: dict | None = None, ) -> None: if params is None: params = {} diff --git a/src/posit/connect/resources.py b/src/posit/connect/resources.py index 17c9894c..90598e66 100644 --- a/src/posit/connect/resources.py +++ b/src/posit/connect/resources.py @@ -120,7 +120,7 @@ def _create_instance(self, path: str, /, **kwargs: Any) -> T: """Create an instance of 'T'.""" raise NotImplementedError() - def fetch(self, **conditions) -> Iterable[T]: + def fetch(self, **conditions: Any) -> Iterable[T]: """Fetch the collection. Fetches the collection directly from Connect. This operation does not effect the cache state.