Skip to content

Commit

Permalink
Улучшения типизации
Browse files Browse the repository at this point in the history
  • Loading branch information
dext0r committed Oct 13, 2024
1 parent c1c2102 commit d79e10b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions custom_components/yandex_station_intents/yandex_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ async def async_refresh(self) -> None:

async def async_validate(self) -> bool:
r = await self._session.get("https://quasar.yandex.ru/get_account_config")
return r.status == HTTPStatus.OK and (await r.json()).get("status") == "ok"
return bool(r.status == HTTPStatus.OK and (await r.json()).get("status") == "ok")

async def get(self, url: str, **kwargs: Any) -> ClientResponse:
return await self._request(hdrs.METH_GET, url, **kwargs)
Expand All @@ -193,7 +193,7 @@ async def delete(self, url: str, **kwargs: Any) -> ClientResponse:
return await self._request(hdrs.METH_DELETE, url, **kwargs)

async def ws_connect(self, *args: Any, **kwargs: Any) -> ClientWebSocketResponse:
return await self._session.ws_connect(*args, **kwargs)
return cast(ClientWebSocketResponse, await self._session.ws_connect(*args, **kwargs))

async def _request(self, method: str, url: str, retry: int = 2, **kwargs: Any) -> ClientResponse:
if method != hdrs.METH_GET:
Expand All @@ -215,7 +215,7 @@ async def _request(self, method: str, url: str, retry: int = 2, **kwargs: Any) -
ir.async_delete_issue(self._hass, DOMAIN, f"{ISSUE_ID_CAPTCHA}_{self._entry.entry_id}")
ir.async_delete_issue(self._hass, DOMAIN, f"{ISSUE_ID_REAUTH_REQUIRED}_{self._entry.entry_id}")

return r
return cast(ClientResponse, r)
elif r.status == HTTPStatus.BAD_REQUEST:
retry = 0
elif r.status == HTTPStatus.UNAUTHORIZED:
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ warn_unreachable = true

[tool.pytest.ini_options]
asyncio_mode = "auto"

[[tool.mypy.overrides]]
module = "custom_components.yandex_station_intents.config_flow"
warn_return_any = false

0 comments on commit d79e10b

Please sign in to comment.