deprecate `__version__` (#2098)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Lord · committed by GitHub · parents dfe82ad, b7ce542 · Browse files · 4 files·+24 added−2 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+24 added−2 removed
- other:+24 added−2 removed
Provenance
- Commit
9e49736- Tree
43cd1ef- Author
David Lord <davidism@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
dfe82ad- Parent 2
b7ce542
4 files changed+24 added−2 removed
modified:src/jinja2/__init__.py+20 added-1 removed
1 unmodified line2 non-XML syntax that supports inline expressions and an optional3 sandboxed environment.4 """5 6+from __future__ import annotations7+8+import typing as t9+10 from .bccache import BytecodeCache as BytecodeCache11 from .bccache import FileSystemBytecodeCache as FileSystemBytecodeCache12 from .bccache import MemcachedBytecodeCache as MemcachedBytecodeCache13 from .environment import Environment as Environment24 unmodified lines38 from .utils import pass_environment as pass_environment39 from .utils import pass_eval_context as pass_eval_context40 from .utils import select_autoescape as select_autoescape41 38-__version__ = "3.2.0.dev0"42+43+def __getattr__(name: str) -> t.Any:44+ if name == "__version__":45+ import importlib.metadata46+ import warnings47+48+ warnings.warn(49+ "The `__version__` attribute is deprecated and will be removed in"50+ " Werkzeug 3.3. Use feature detection or"51+ ' `importlib.metadata.version("werkzeug")` instead.',52+ DeprecationWarning,53+ stacklevel=2,54+ )55+ return importlib.metadata.version("werkzeug")56+57+ raise AttributeError(name)modified:CHANGES.rst+2 added
6 unmodified lines7 8 - Drop support for Python 3.7, 3.8, and 3.9.9 - Update minimum MarkupSafe version to >= 3.0.10 - Update minimum Babel version to >= 2.17.11+- Deprecate the ``__version__`` attribute. Use feature detection or12+ ``importlib.metadata.version("jinja2")`` instead.13 - Use modern packaging metadata with ``pyproject.toml`` instead of ``setup.cfg``.14 :pr:`1793`15 - Use ``flit_core`` instead of ``setuptools`` as build backend.16 1056 unmodified linesmodified:pyproject.toml+1 added-1 removed
1 [project]2 name = "Jinja2"3+version = "3.2.0.dev"4 description = "A very fast and expressive template engine."5 readme = "README.md"6 license = "BSD-3-Clause"7 license-files = ["LICENSE.txt"]9 unmodified lines17 "Typing :: Typed",18 ]19 requires-python = ">=3.10"20 dependencies = ["MarkupSafe>=3.0"]20-dynamic = ["version"]21 22 [project.urls]23 Donate = "https://palletsprojects.com/donate"24 Documentation = "https://jinja.palletsprojects.com/"187 unmodified linesmodified:uv.lock+1 added
311 unmodified lines312 ]313 314 [[package]]315 name = "jinja2"316+version = "3.2.0.dev0"317 source = { editable = "." }318 dependencies = [319 { name = "markupsafe" },320 ]924 unmodified lines