Skip to content

Commit

Permalink
deprecate __version__
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Apr 30, 2024
1 parent 1d990e7 commit cf69fb7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "Flask-DebugToolbar"
version = "0.15.1"
version = "0.16.0.dev"
description = "A toolbar overlay for debugging Flask applications."
readme = "README.md"
license = { file = "LICENSE.txt" }
Expand Down
17 changes: 16 additions & 1 deletion src/flask_debugtoolbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from .utils import gzip_compress
from .utils import gzip_decompress

__version__ = importlib.metadata.version("flask-debugtoolbar")
_jinja_version = importlib.metadata.version("jinja2")

module: Blueprint = Blueprint("debugtoolbar", __name__)
Expand Down Expand Up @@ -298,3 +297,19 @@ def teardown_request(self, exc: BaseException | None) -> None:
def render(self, template_name: str, context: dict[str, t.Any]) -> str:
template = self.jinja_env.get_template(template_name)
return template.render(**context)


def __getattr__(name: str) -> t.Any:
import warnings

if name == "__version__":
warnings.warn(
"The '__version__' attribute is deprecated and will be removed in"
" Flask-DebugToolbar 0.17. Use feature detection or"
" 'importlib.metadata.version(\"flask-debugtoolbar\")' instead.",
DeprecationWarning,
stacklevel=2,
)
return importlib.metadata.version("flask-debugtoolbar")

raise AttributeError(name)

0 comments on commit cf69fb7

Please sign in to comment.