Skip to content

Commit

Permalink
fix mypy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ahartel committed Feb 13, 2023
1 parent 61307e8 commit 3ad7c65
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions aleph_alpha_client/aleph_alpha_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ def _build_json_body(
json_body["hosting"] = self.hosting
return json_body

def models(self) -> Mapping[str, Any]:
def models(self) -> List[Mapping[str, Any]]:
"""
Queries all models which are currently available.
Expand Down Expand Up @@ -1357,7 +1357,9 @@ async def _get_request_text(self, endpoint: str) -> str:
_raise_for_status(response.status, await response.text())
return await response.text()

async def _get_request_json(self, endpoint: str) -> Mapping[str, Any]:
async def _get_request_json(
self, endpoint: str
) -> Union[List[Mapping[str, Any]], Mapping[str, Any]]:
async with self.session.get(
self.host + endpoint,
) as response:
Expand Down Expand Up @@ -1401,13 +1403,13 @@ def _build_json_body(
json_body["hosting"] = self.hosting
return json_body

async def models(self) -> Mapping[str, Any]:
async def models(self) -> List[Mapping[str, Any]]:
"""
Queries all models which are currently available.
For documentation of the response, see https://docs.aleph-alpha.com/api/available-models/
"""
return await self._get_request_json("models_available")
return await self._get_request_json("models_available") # type: ignore

async def complete(
self,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async def test_nice_flag_on_async_client(httpserver: HTTPServer):
@pytest.mark.system_test
def test_available_models_sync_client(sync_client: Client, model_name: str):
models = sync_client.models()
assert model_name in [model["name"] for model in models]
assert model_name in {model["name"] for model in models}


@pytest.mark.system_test
Expand Down

0 comments on commit 3ad7c65

Please sign in to comment.