Skip to content

The '__version__' attribute is deprecated and will be removed in Flask 3.2. #2626

@OrangeDog

Description

@OrangeDog

Describe the bug:
Warnings reported when using the latest version of Flask.

.venv\Lib\site-packages\elasticapm\contrib\flask\__init__.py:126: DeprecationWarning: The '__version__' attribute is deprecated and will be removed in Flask 3.2. Use feature detection or 'importlib.metadata.version("flask")' instead.
    defaults["framework_version"] = getattr(flask, "__version__", "<0.7")

To Reproduce

app = Flask(__name__, instance_relative_config=True)
app.config.from_object('config')
apm = ElasticAPM(app)

Environment (please complete the following information)

  • OS: Windows

  • Python version: 3.12.6

  • Framework and version: Flask 3.1.3

  • APM Server version: N/A

  • Agent version: 6.25.0

  • Agent config options

    Click to expand
    ENABLED = False
    
  • requirements.txt:

    Click to expand
    blinker==1.9.0; python_version >= '3.9'
    certifi==2026.4.22; python_version >= '3.7'
    cffi==2.0.0; python_version >= '3.9'
    click==8.3.3; python_version >= '3.10'
    colorama==0.4.6; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6'
    ecs-logging==2.3.0; python_version >= '3.8'
    elastic-apm[flask]==6.25.0; python_version >= '3.6' and python_version < '4'
    flask==3.1.3; python_version >= '3.9'
    flask-basicauth==0.2.0
    geographiclib==2.1; python_version >= '3.7'
    geopy==2.4.1; python_version >= '3.7'
    gevent==26.4.0; python_version >= '3.9'
    greenlet==3.5.0; python_version >= '3.10'
    gunicorn[gevent]==25.3.0; python_version >= '3.10'
    itsdangerous==2.2.0; python_version >= '3.8'
    jinja2==3.1.6; python_version >= '3.7'
    markupsafe==3.0.3; python_version >= '3.9'
    packaging==26.2; python_version >= '3.8'
    pycparser==3.0; python_version >= '3.10'
    urllib3==2.6.3; python_version >= '3.9'
    werkzeug==3.1.8; python_version >= '3.9'
    wrapt==2.1.2; python_version >= '3.9'
    zope.event==6.1; python_version >= '3.10'
    zope.interface==8.4; python_version >= '3.10'
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions