-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cloud backup support #33
Conversation
aiohasupervisor/client.py
Outdated
@@ -146,7 +155,7 @@ async def get( | |||
self, | |||
uri: str, | |||
*, | |||
params: dict[str, str] | None = None, | |||
params: dict[str, str] | MultiDict[str, str] | None = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mypy tells me MultiDict takes a single type parameter, the keys are always str
Maybe just type this as aiohttp's Query
if aiohasupervisor does not modify it?
https://docs.aiohttp.org/en/stable/client_reference.html#aiohttp.ClientSession.request
https://github.com/aio-libs/aiohttp/blob/dbd77ad6e46a0f89268758cdc06c20afeaf13e96/aiohttp/client.py#L171
params: dict[str, str] | MultiDict[str, str] | None = None, | |
params: Query = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems Query
would need a newer aiohttp version, it came in with this PR in 3.11.0 I think (currently pyproject.toml specifies 3.3.0 as minimum).
Let's go with the fixed MultiDict
typing for now.
@@ -94,42 +117,28 @@ async def _request( | |||
self._close_session = True | |||
|
|||
try: | |||
async with self.session.request( | |||
response = await self.session.request( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it matters, but if want to keep the context manager we could separate the cases where we can use the context manager from the cases we don't:
if response_type == ResponseType.RAW:
response = await self.session.request(
...
)
...
else:
async with self.session.request(
...
) as response:
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally, everything works as expected 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Proposed Changes
| None
added to the wrong field in backups)size_bytes
field which needs to be implemented in supervisor still but is needed for core cloud backups (PR: Add size in bytes to backups home-assistant/supervisor#5473)Related Issues