Skip to content

Commit

Permalink
Avoid import of pkg_resource with Starlette integration
Browse files Browse the repository at this point in the history
By changing the order in the condition, we can avoid the call to
`_get_installed_modules` (which imports `pkg_resources`) when the
`mechanism_type` is set to `"starlette"`.
  • Loading branch information
Mickaël Guérin authored and mgu committed Jan 17, 2023
1 parent ffe7737 commit d4623f6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/asgi.py
Expand Up @@ -108,7 +108,7 @@ def __init__(
)

asgi_middleware_while_using_starlette_or_fastapi = (
"starlette" in _get_installed_modules() and mechanism_type == "asgi"
mechanism_type == "asgi" and "starlette" in _get_installed_modules()
)
if asgi_middleware_while_using_starlette_or_fastapi:
logger.warning(
Expand Down

0 comments on commit d4623f6

Please sign in to comment.