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 for httpx==0.19.0 stricter enforcement of client lifespan styles #7

Merged
merged 1 commit into from
Aug 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 4 additions & 6 deletions pylitterbot/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ def raise_on_error(response): # pragma: no cover

async def fetch_token(self, username: str, password: str) -> Dict[str, str]:
"""Fetch an access token via oauth2."""
async with self._client:
return await self._client.fetch_token(username=username, password=password)
return await self._client.fetch_token(username=username, password=password)

async def get(self, path: str, **kwargs) -> Response:
"""Make a get request."""
Expand All @@ -103,10 +102,9 @@ async def call(self, method: MethodType, path: str, **kwargs) -> Response:
url = self.urljoin(path)
headers = self.generate_headers(kwargs.pop("headers", None))
try:
async with self._client:
response = await method(url, headers=headers, **kwargs)
response.raise_for_status()
return response
response = await method(url, headers=headers, **kwargs)
response.raise_for_status()
return response
except (HTTPStatusError, HTTPError, ConnectTimeout, ConnectError) as ex:
if isinstance(ex, HTTPStatusError) and ex.response.status_code == 500:
raise InvalidCommandException(
Expand Down