Skip to content

Commit

Permalink
deprecate __version__ (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism authored May 23, 2024
1 parent 1932b74 commit 56914a8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Unreleased
- Use `pyproject.toml` for packaging metadata.
- Use `flit_core` as build backend.
- Apply code formatting and linting tools.
- Deprecate the `__version__` attribute. Use feature detection or
`importlib.metadata.version("flask-mail")` instead.


## Version 0.9.1
Expand Down
19 changes: 17 additions & 2 deletions src/flask_mail/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
__version__ = "0.10.0.dev"

import re
import smtplib
import time
import unicodedata
import warnings
from contextlib import contextmanager
from email import charset
from email import policy
Expand Down Expand Up @@ -591,3 +590,19 @@ def __getattr__(self, name):
in testing mode, even though the email will not actually be sent.
""",
)


def __getattr__(name):
if name == "__version__":
import importlib.metadata

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

raise AttributeError(name)

0 comments on commit 56914a8

Please sign in to comment.