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

Fixing deprecated version attribute #2338

Merged
merged 11 commits into from
Sep 6, 2023
4 changes: 3 additions & 1 deletion sentry_sdk/integrations/flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from sentry_sdk.integrations import DidNotEnable, Integration
from sentry_sdk.integrations._wsgi_common import RequestExtractor
from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware
from sentry_sdk.integrations.modules import _get_installed_modules
from sentry_sdk.scope import Scope
from sentry_sdk.tracing import SOURCE_FOR_STYLE
from sentry_sdk.utils import (
Expand All @@ -28,7 +29,6 @@

try:
from flask import Flask, Request # type: ignore
from flask import __version__ as FLASK_VERSION
from flask import request as flask_request
from flask.signals import (
before_render_template,
Expand All @@ -44,6 +44,8 @@
except ImportError:
raise DidNotEnable("blinker is not installed")

installed_packages = _get_installed_modules()
FLASK_VERSION = installed_packages("flask")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_get_installed_modules() returns a dict, so you'd want:

Suggested change
FLASK_VERSION = installed_packages("flask")
FLASK_VERSION = installed_packages["flask"]

I'm also thinking we could move these two lines into the setup_once method instead, so that all the version checking code is in one place.

TRANSACTION_STYLE_VALUES = ("endpoint", "url")


Expand Down