Remove deprecated Flask version attribute (#243)

The `flask.__version__` attr is deprecated and will be removed in the Flask 3.1 version. This PR replaced this attr to `importlib.metadata.version`.

We could remove the use of `pkg_resources` when we drop the Python 3.7 support.
This commit is contained in:
Grey Li
2024-04-13 00:20:53 +08:00
committed by GitHub
parent fb28aa9d61
commit 716f05d953
+11 -1
View File
@@ -1,9 +1,19 @@
import os
from sysconfig import get_path
from flask import __version__ as flask_version
from flask_debugtoolbar.panels import DebugPanel
try:
# Python 3.8+
from importlib.metadata import version
flask_version = version('flask')
except ImportError:
import pkg_resources
flask_version = pkg_resources.get_distribution('flask').version
_ = lambda x: x