Skip to content

Commit

Permalink
deprecate __version__ attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Sep 11, 2023
1 parent e04fc9e commit 644334d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
11 changes: 10 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
Version 3.1.1
-------------

Unreleased

- Deprecate the ``__version__`` attribute. Use feature detection, or
``importlib.metadata.version("flask-sqlalchemy")``, instead. :issue:`5230`


Version 3.1.0
-------------

Released 2023-09-10
Released 2023-09-11

- Drop support for Python 3.7. :pr:`1251`
- Add support for the SQLAlchemy 2.x API via ``model_class`` parameter. :issue:`1140`
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[project]
name = "Flask-SQLAlchemy"
version = "3.1.1.dev"
description = "Add SQLAlchemy support to your Flask application."
readme = "README.rst"
license = { file = "LICENSE.rst" }
Expand All @@ -18,7 +19,6 @@ dependencies = [
"flask>=2.2.5",
"sqlalchemy>=2.0.16",
]
dynamic = ["version"]

[project.urls]
Donate = "https://palletsprojects.com/donate"
Expand Down
21 changes: 19 additions & 2 deletions src/flask_sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
from __future__ import annotations

from .extension import SQLAlchemy
import typing as t

__version__ = "3.1.0"
from .extension import SQLAlchemy

__all__ = [
"SQLAlchemy",
]


def __getattr__(name: str) -> t.Any:
if name == "__version__":
import importlib.metadata
import warnings

warnings.warn(
"The '__version__' attribute is deprecated and will be removed in"
" Flask-SQLAlchemy 3.2. Use feature detection or"
" 'importlib.metadata.version(\"flask-sqlalchemy\")' instead.",
DeprecationWarning,
stacklevel=2,
)
return importlib.metadata.version("flask-sqlalchemy")

raise AttributeError(name)

0 comments on commit 644334d

Please sign in to comment.