Describe your environment
OS: Any
Python version: Any
Package version: 0.61b0
What happened?
The flask.__version__ attribute is deprecated and will be removed, it raises a DeprecationWarning on access.
.tox/tests/lib/python3.14/site-packages/app/telemetry.py:9: in <module>
from opentelemetry.instrumentation.flask import FlaskInstrumentor
.tox/tests/lib/python3.14/site-packages/opentelemetry/instrumentation/flask/__init__.py:306: in <module>
_IS_FLASK_31_PLUS = hasattr(flask, "__version__") and package_version.parse(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.tox/tests/lib/python3.14/site-packages/flask/__init__.py:52: in __getattr__
warnings.warn(
DeprecationWarning: The '__version__' attribute is deprecated and will be removed in Flask 3.2. Use feature detection or 'importlib.metadata.version("flask")' instead.
Steps to Reproduce
from opentelemetry.instrumentation.flask import FlaskInstrumentor
Expected Result
No deprecation warning is emitted.
Actual Result
A deprecation warning is emitted.
Additional context
The code that causes this was added recently in #3938:
|
# Global constants for Flask 3.1+ streaming context cleanup |
|
_IS_FLASK_31_PLUS = hasattr(flask, "__version__") and package_version.parse( |
|
flask.__version__ |
|
) >= package_version.parse("3.1.0") |
However, it ignores the existing flask_version attribute defined a few lines below, which was added to address this warning the first time it was reported:
|
flask_version = version("flask") |
The version 3.1 detection should be moved below this line, and use the existing metadata rather than trying to access flask.__version__ again.
Would you like to implement a fix?
None
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
Describe your environment
OS: Any
Python version: Any
Package version: 0.61b0
What happened?
The
flask.__version__attribute is deprecated and will be removed, it raises aDeprecationWarningon access..tox/tests/lib/python3.14/site-packages/app/telemetry.py:9: in <module> from opentelemetry.instrumentation.flask import FlaskInstrumentor .tox/tests/lib/python3.14/site-packages/opentelemetry/instrumentation/flask/__init__.py:306: in <module> _IS_FLASK_31_PLUS = hasattr(flask, "__version__") and package_version.parse( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .tox/tests/lib/python3.14/site-packages/flask/__init__.py:52: in __getattr__ warnings.warn( DeprecationWarning: The '__version__' attribute is deprecated and will be removed in Flask 3.2. Use feature detection or 'importlib.metadata.version("flask")' instead.Steps to Reproduce
Expected Result
No deprecation warning is emitted.
Actual Result
A deprecation warning is emitted.
Additional context
The code that causes this was added recently in #3938:
opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py
Lines 305 to 308 in 0f92478
However, it ignores the existing
flask_versionattribute defined a few lines below, which was added to address this warning the first time it was reported:opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py
Line 318 in 0f92478
The version 3.1 detection should be moved below this line, and use the existing metadata rather than trying to access
flask.__version__again.Would you like to implement a fix?
None
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding
+1orme too, to help us triage it. Learn more here.