Skip to content
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

Fix formatting for aiohttp post #299

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions tibber/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def execute(
self,
document: str,
variable_values: dict[Any, Any] | None = None,
timeout: int | None = None,
timeout: int | None = None, # noqa: ASYNC109
retry: int = 3,
) -> dict[Any, Any] | None:
"""Execute a GraphQL query and return the data.
Expand All @@ -92,15 +92,16 @@ async def execute(

payload = {"query": document, "variables": variable_values or {}}

post_args = {
"headers": {
"Authorization": "Bearer " + self._access_token,
aiohttp.hdrs.USER_AGENT: self._user_agent,
},
"data": payload,
}
try:
resp = await self.websession.post(API_ENDPOINT, **post_args, timeout=self.timeout)
resp = await self.websession.post(
API_ENDPOINT,
headers={
"Authorization": "Bearer " + self._access_token,
aiohttp.hdrs.USER_AGENT: self._user_agent,
},
data=payload,
timeout=aiohttp.ClientTimeout(total=self.timeout),
)
return (await extract_response_data(resp)).get("data")
except (TimeoutError, aiohttp.ClientError) as err:
if retry > 0:
Expand Down
Loading