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

Feature: 在加载 driver 引发 ImportError 时,使用 raise from e #1689

Merged
merged 1 commit into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions nonebot/drivers/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@

try:
import aiohttp
except ImportError: # pragma: no cover
except ImportError as e: # pragma: no cover
raise ImportError(
"Please install aiohttp first to use this driver. `pip install nonebot2[aiohttp]`"
) from None
) from e


class Mixin(ForwardMixin):
Expand Down
4 changes: 2 additions & 2 deletions nonebot/drivers/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
from fastapi.responses import Response
from fastapi import FastAPI, Request, UploadFile, status
from starlette.websockets import WebSocket, WebSocketState, WebSocketDisconnect
except ImportError: # pragma: no cover
except ImportError as e: # pragma: no cover
raise ImportError(
"Please install FastAPI by using `pip install nonebot2[fastapi]`"
) from None
) from e


def catch_closed(func):
Expand Down
4 changes: 2 additions & 2 deletions nonebot/drivers/httpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@

try:
import httpx
except ImportError: # pragma: no cover
except ImportError as e: # pragma: no cover
raise ImportError(
"Please install httpx by using `pip install nonebot2[httpx]`"
) from None
) from e


class Mixin(ForwardMixin):
Expand Down
4 changes: 2 additions & 2 deletions nonebot/drivers/quart.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
from quart import Quart, Request, Response
from quart.datastructures import FileStorage
from quart import Websocket as QuartWebSocket
except ImportError: # pragma: no cover
except ImportError as e: # pragma: no cover
raise ImportError(
"Please install Quart by using `pip install nonebot2[quart]`"
) from None
) from e

_AsyncCallable = TypeVar("_AsyncCallable", bound=Callable[..., Coroutine])

Expand Down
4 changes: 2 additions & 2 deletions nonebot/drivers/websockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
try:
from websockets.exceptions import ConnectionClosed
from websockets.legacy.client import Connect, WebSocketClientProtocol
except ImportError: # pragma: no cover
except ImportError as e: # pragma: no cover
raise ImportError(
"Please install websockets by using `pip install nonebot2[websockets]`"
) from None
) from e

logger = logging.Logger("websockets.client", "INFO")
logger.addHandler(LoguruHandler())
Expand Down