Skip to content

Commit

Permalink
Make aiohttp_session is Optional
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet committed Nov 4, 2020
1 parent 855c75b commit 99238aa
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/renault_api/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import asyncio
import functools
import logging
from typing import Dict
from typing import Dict, Optional

from aiohttp import ClientSession
from aiohttp.client_exceptions import ClientResponseError
Expand All @@ -19,7 +19,9 @@


async def get_api_keys(
locale: str, force_load: bool = False, aiohttp_session: ClientSession = None
locale: str,
force_load: bool = False,
aiohttp_session: Optional[ClientSession] = None,
) -> Dict[str, str]:
"""Get the API keys for specified locale.
Expand All @@ -40,7 +42,7 @@ async def get_api_keys(
else:
_LOGGER.warning(
"Locale %s was not found in AVAILABLE_LOCALES "
"(or force_load used)."
"(or force_load used). "
"Attempting to load details from Renault servers.",
locale,
)
Expand All @@ -53,7 +55,7 @@ async def get_api_keys(
response.raise_for_status()
except ClientResponseError as exc:
raise RenaultException(
f"Locale not found on Renault server ({exc.status})."
f"Locale not found on Renault server (HTTPStatus = {exc.status})."
) from exc
# Server sometimes returns invalid content-type
# eg. application/octet-stream
Expand Down

0 comments on commit 99238aa

Please sign in to comment.