From 965067fff1ada312c572111284c9547f4b4ead3f Mon Sep 17 00:00:00 2001 From: David Lord Date: Fri, 15 Sep 2023 12:43:48 -0700 Subject: [PATCH 1/2] deprecate __version__ attribute --- CHANGES.rst | 2 ++ pyproject.toml | 2 +- src/markupsafe/__init__.py | 18 ++++++++++++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index e4306ff0..29b5282f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -16,6 +16,8 @@ Unreleased argument. These methods are conceptually linked to search methods such as ``in``, ``find``, and ``index``, which already do not escape their argument. :issue:`401` +- The ``__version__`` attribute is deprecated. Use feature detection, or + ``importlib.metadata.version("markupsafe")``, instead. :pr:`402` Version 2.1.3 diff --git a/pyproject.toml b/pyproject.toml index 52fb6b3a..4a97d5ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,6 @@ [project] name = "MarkupSafe" +version = "2.2.0.dev" description = "Safely add untrusted strings to HTML/XML markup." readme = "README.rst" license = {text = "BSD-3-Clause"} @@ -15,7 +16,6 @@ classifiers = [ "Topic :: Text Processing :: Markup :: HTML", ] requires-python = ">=3.8" -dynamic = ["version"] [project.urls] Donate = "https://palletsprojects.com/donate" diff --git a/src/markupsafe/__init__.py b/src/markupsafe/__init__.py index 7ff8e8ff..ac9539e7 100644 --- a/src/markupsafe/__init__.py +++ b/src/markupsafe/__init__.py @@ -18,8 +18,6 @@ def __call__(self, s: t.Any, /) -> Markup: ... -__version__ = "2.2.0.dev" - _strip_comments_re = re.compile(r"", re.DOTALL) _strip_tags_re = re.compile(r"<.*?>", re.DOTALL) @@ -315,3 +313,19 @@ def __float__(self, /) -> float: from ._native import escape as escape from ._native import escape_silent as escape_silent # noqa: F401 from ._native import soft_str as soft_str # noqa: F401 + + +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" + " MarkupSafe 3.1. Use feature detection, or" + ' `importlib.metadata.version("markupsafe")`, instead.', + stacklevel=2, + ) + return importlib.metadata.version("flask-classful") + + raise AttributeError(name) From 8d9c72093c726bbac09c775ac611b1c66010a6dc Mon Sep 17 00:00:00 2001 From: David Lord Date: Fri, 15 Sep 2023 12:44:16 -0700 Subject: [PATCH 2/2] next version is 3.0.0 --- CHANGES.rst | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 29b5282f..0347271a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,4 +1,4 @@ -Version 2.2.0 +Version 3.0.0 ------------- Unreleased diff --git a/pyproject.toml b/pyproject.toml index 4a97d5ae..c3eb56ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "MarkupSafe" -version = "2.2.0.dev" +version = "3.0.0.dev" description = "Safely add untrusted strings to HTML/XML markup." readme = "README.rst" license = {text = "BSD-3-Clause"}