Skip to content

Commit 3f174e6

Browse files
authored
deprecate __version__ attribute (#1256)
2 parents e04fc9e + 644334d commit 3f174e6

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

CHANGES.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
Version 3.1.1
2+
-------------
3+
4+
Unreleased
5+
6+
- Deprecate the ``__version__`` attribute. Use feature detection, or
7+
``importlib.metadata.version("flask-sqlalchemy")``, instead. :issue:`5230`
8+
9+
110
Version 3.1.0
211
-------------
312

4-
Released 2023-09-10
13+
Released 2023-09-11
514

615
- Drop support for Python 3.7. :pr:`1251`
716
- Add support for the SQLAlchemy 2.x API via ``model_class`` parameter. :issue:`1140`

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[project]
22
name = "Flask-SQLAlchemy"
3+
version = "3.1.1.dev"
34
description = "Add SQLAlchemy support to your Flask application."
45
readme = "README.rst"
56
license = { file = "LICENSE.rst" }
@@ -18,7 +19,6 @@ dependencies = [
1819
"flask>=2.2.5",
1920
"sqlalchemy>=2.0.16",
2021
]
21-
dynamic = ["version"]
2222

2323
[project.urls]
2424
Donate = "https://palletsprojects.com/donate"

src/flask_sqlalchemy/__init__.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
from __future__ import annotations
22

3-
from .extension import SQLAlchemy
3+
import typing as t
44

5-
__version__ = "3.1.0"
5+
from .extension import SQLAlchemy
66

77
__all__ = [
88
"SQLAlchemy",
99
]
10+
11+
12+
def __getattr__(name: str) -> t.Any:
13+
if name == "__version__":
14+
import importlib.metadata
15+
import warnings
16+
17+
warnings.warn(
18+
"The '__version__' attribute is deprecated and will be removed in"
19+
" Flask-SQLAlchemy 3.2. Use feature detection or"
20+
" 'importlib.metadata.version(\"flask-sqlalchemy\")' instead.",
21+
DeprecationWarning,
22+
stacklevel=2,
23+
)
24+
return importlib.metadata.version("flask-sqlalchemy")
25+
26+
raise AttributeError(name)

0 commit comments

Comments
 (0)