From 8ecc408c5f832ab13a356367d898d8877ce0594c Mon Sep 17 00:00:00 2001 From: Oz N Tiram Date: Tue, 5 Dec 2023 10:45:02 +0100 Subject: [PATCH] Drop markupsafe - way too late for that This was added in commit c863ca1a4b1575274ef316953dc9fe5d978e26bb as a depencdency of Jinja2 which was long removed. --- pipenv/vendor/markupsafe/LICENSE.rst | 28 --- pipenv/vendor/markupsafe/__init__.py | 304 ------------------------- pipenv/vendor/markupsafe/_native.py | 63 ----- pipenv/vendor/markupsafe/_speedups.pyi | 9 - pipenv/vendor/markupsafe/py.typed | 0 pipenv/vendor/vendor.txt | 1 - 6 files changed, 405 deletions(-) delete mode 100644 pipenv/vendor/markupsafe/LICENSE.rst delete mode 100644 pipenv/vendor/markupsafe/__init__.py delete mode 100644 pipenv/vendor/markupsafe/_native.py delete mode 100644 pipenv/vendor/markupsafe/_speedups.pyi delete mode 100644 pipenv/vendor/markupsafe/py.typed diff --git a/pipenv/vendor/markupsafe/LICENSE.rst b/pipenv/vendor/markupsafe/LICENSE.rst deleted file mode 100644 index 9d227a0cc4..0000000000 --- a/pipenv/vendor/markupsafe/LICENSE.rst +++ /dev/null @@ -1,28 +0,0 @@ -Copyright 2010 Pallets - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/pipenv/vendor/markupsafe/__init__.py b/pipenv/vendor/markupsafe/__init__.py deleted file mode 100644 index 21d3196038..0000000000 --- a/pipenv/vendor/markupsafe/__init__.py +++ /dev/null @@ -1,304 +0,0 @@ -import functools -import re -import string -import sys -import typing as t - -if t.TYPE_CHECKING: - import typing_extensions as te - - class HasHTML(te.Protocol): - def __html__(self) -> str: - pass - - _P = te.ParamSpec("_P") - - -__version__ = "2.1.3" - -_strip_comments_re = re.compile(r"", re.DOTALL) -_strip_tags_re = re.compile(r"<.*?>", re.DOTALL) - - -def _simple_escaping_wrapper(func: "t.Callable[_P, str]") -> "t.Callable[_P, Markup]": - @functools.wraps(func) - def wrapped(self: "Markup", *args: "_P.args", **kwargs: "_P.kwargs") -> "Markup": - arg_list = _escape_argspec(list(args), enumerate(args), self.escape) - _escape_argspec(kwargs, kwargs.items(), self.escape) - return self.__class__(func(self, *arg_list, **kwargs)) # type: ignore[arg-type] - - return wrapped # type: ignore[return-value] - - -class Markup(str): - """A string that is ready to be safely inserted into an HTML or XML - document, either because it was escaped or because it was marked - safe. - - Passing an object to the constructor converts it to text and wraps - it to mark it safe without escaping. To escape the text, use the - :meth:`escape` class method instead. - - >>> Markup("Hello, World!") - Markup('Hello, World!') - >>> Markup(42) - Markup('42') - >>> Markup.escape("Hello, World!") - Markup('Hello <em>World</em>!') - - This implements the ``__html__()`` interface that some frameworks - use. Passing an object that implements ``__html__()`` will wrap the - output of that method, marking it safe. - - >>> class Foo: - ... def __html__(self): - ... return 'foo' - ... - >>> Markup(Foo()) - Markup('foo') - - This is a subclass of :class:`str`. It has the same methods, but - escapes their arguments and returns a ``Markup`` instance. - - >>> Markup("%s") % ("foo & bar",) - Markup('foo & bar') - >>> Markup("Hello ") + "" - Markup('Hello <foo>') - """ - - __slots__ = () - - def __new__( - cls, base: t.Any = "", encoding: t.Optional[str] = None, errors: str = "strict" - ) -> "te.Self": - if hasattr(base, "__html__"): - base = base.__html__() - - if encoding is None: - return super().__new__(cls, base) - - return super().__new__(cls, base, encoding, errors) - - def __html__(self) -> "te.Self": - return self - - def __add__(self, other: t.Union[str, "HasHTML"]) -> "te.Self": - if isinstance(other, str) or hasattr(other, "__html__"): - return self.__class__(super().__add__(self.escape(other))) - - return NotImplemented - - def __radd__(self, other: t.Union[str, "HasHTML"]) -> "te.Self": - if isinstance(other, str) or hasattr(other, "__html__"): - return self.escape(other).__add__(self) - - return NotImplemented - - def __mul__(self, num: "te.SupportsIndex") -> "te.Self": - if isinstance(num, int): - return self.__class__(super().__mul__(num)) - - return NotImplemented - - __rmul__ = __mul__ - - def __mod__(self, arg: t.Any) -> "te.Self": - if isinstance(arg, tuple): - # a tuple of arguments, each wrapped - arg = tuple(_MarkupEscapeHelper(x, self.escape) for x in arg) - elif hasattr(type(arg), "__getitem__") and not isinstance(arg, str): - # a mapping of arguments, wrapped - arg = _MarkupEscapeHelper(arg, self.escape) - else: - # a single argument, wrapped with the helper and a tuple - arg = (_MarkupEscapeHelper(arg, self.escape),) - - return self.__class__(super().__mod__(arg)) - - def __repr__(self) -> str: - return f"{self.__class__.__name__}({super().__repr__()})" - - def join(self, seq: t.Iterable[t.Union[str, "HasHTML"]]) -> "te.Self": - return self.__class__(super().join(map(self.escape, seq))) - - join.__doc__ = str.join.__doc__ - - def split( # type: ignore[override] - self, sep: t.Optional[str] = None, maxsplit: int = -1 - ) -> t.List["te.Self"]: - return [self.__class__(v) for v in super().split(sep, maxsplit)] - - split.__doc__ = str.split.__doc__ - - def rsplit( # type: ignore[override] - self, sep: t.Optional[str] = None, maxsplit: int = -1 - ) -> t.List["te.Self"]: - return [self.__class__(v) for v in super().rsplit(sep, maxsplit)] - - rsplit.__doc__ = str.rsplit.__doc__ - - def splitlines( # type: ignore[override] - self, keepends: bool = False - ) -> t.List["te.Self"]: - return [self.__class__(v) for v in super().splitlines(keepends)] - - splitlines.__doc__ = str.splitlines.__doc__ - - def unescape(self) -> str: - """Convert escaped markup back into a text string. This replaces - HTML entities with the characters they represent. - - >>> Markup("Main » About").unescape() - 'Main » About' - """ - from html import unescape - - return unescape(str(self)) - - def striptags(self) -> str: - """:meth:`unescape` the markup, remove tags, and normalize - whitespace to single spaces. - - >>> Markup("Main »\tAbout").striptags() - 'Main » About' - """ - # Use two regexes to avoid ambiguous matches. - value = _strip_comments_re.sub("", self) - value = _strip_tags_re.sub("", value) - value = " ".join(value.split()) - return self.__class__(value).unescape() - - @classmethod - def escape(cls, s: t.Any) -> "te.Self": - """Escape a string. Calls :func:`escape` and ensures that for - subclasses the correct type is returned. - """ - rv = escape(s) - - if rv.__class__ is not cls: - return cls(rv) - - return rv # type: ignore[return-value] - - __getitem__ = _simple_escaping_wrapper(str.__getitem__) - capitalize = _simple_escaping_wrapper(str.capitalize) - title = _simple_escaping_wrapper(str.title) - lower = _simple_escaping_wrapper(str.lower) - upper = _simple_escaping_wrapper(str.upper) - replace = _simple_escaping_wrapper(str.replace) - ljust = _simple_escaping_wrapper(str.ljust) - rjust = _simple_escaping_wrapper(str.rjust) - lstrip = _simple_escaping_wrapper(str.lstrip) - rstrip = _simple_escaping_wrapper(str.rstrip) - center = _simple_escaping_wrapper(str.center) - strip = _simple_escaping_wrapper(str.strip) - translate = _simple_escaping_wrapper(str.translate) - expandtabs = _simple_escaping_wrapper(str.expandtabs) - swapcase = _simple_escaping_wrapper(str.swapcase) - zfill = _simple_escaping_wrapper(str.zfill) - casefold = _simple_escaping_wrapper(str.casefold) - - if sys.version_info >= (3, 9): - removeprefix = _simple_escaping_wrapper(str.removeprefix) - removesuffix = _simple_escaping_wrapper(str.removesuffix) - - def partition(self, sep: str) -> t.Tuple["te.Self", "te.Self", "te.Self"]: - l, s, r = super().partition(self.escape(sep)) - cls = self.__class__ - return cls(l), cls(s), cls(r) - - def rpartition(self, sep: str) -> t.Tuple["te.Self", "te.Self", "te.Self"]: - l, s, r = super().rpartition(self.escape(sep)) - cls = self.__class__ - return cls(l), cls(s), cls(r) - - def format(self, *args: t.Any, **kwargs: t.Any) -> "te.Self": - formatter = EscapeFormatter(self.escape) - return self.__class__(formatter.vformat(self, args, kwargs)) - - def format_map( # type: ignore[override] - self, map: t.Mapping[str, t.Any] - ) -> "te.Self": - formatter = EscapeFormatter(self.escape) - return self.__class__(formatter.vformat(self, (), map)) - - def __html_format__(self, format_spec: str) -> "te.Self": - if format_spec: - raise ValueError("Unsupported format specification for Markup.") - - return self - - -class EscapeFormatter(string.Formatter): - __slots__ = ("escape",) - - def __init__(self, escape: t.Callable[[t.Any], Markup]) -> None: - self.escape = escape - super().__init__() - - def format_field(self, value: t.Any, format_spec: str) -> str: - if hasattr(value, "__html_format__"): - rv = value.__html_format__(format_spec) - elif hasattr(value, "__html__"): - if format_spec: - raise ValueError( - f"Format specifier {format_spec} given, but {type(value)} does not" - " define __html_format__. A class that defines __html__ must define" - " __html_format__ to work with format specifiers." - ) - rv = value.__html__() - else: - # We need to make sure the format spec is str here as - # otherwise the wrong callback methods are invoked. - rv = string.Formatter.format_field(self, value, str(format_spec)) - return str(self.escape(rv)) - - -_ListOrDict = t.TypeVar("_ListOrDict", list, dict) - - -def _escape_argspec( - obj: _ListOrDict, iterable: t.Iterable[t.Any], escape: t.Callable[[t.Any], Markup] -) -> _ListOrDict: - """Helper for various string-wrapped functions.""" - for key, value in iterable: - if isinstance(value, str) or hasattr(value, "__html__"): - obj[key] = escape(value) - - return obj - - -class _MarkupEscapeHelper: - """Helper for :meth:`Markup.__mod__`.""" - - __slots__ = ("obj", "escape") - - def __init__(self, obj: t.Any, escape: t.Callable[[t.Any], Markup]) -> None: - self.obj = obj - self.escape = escape - - def __getitem__(self, item: t.Any) -> "te.Self": - return self.__class__(self.obj[item], self.escape) - - def __str__(self) -> str: - return str(self.escape(self.obj)) - - def __repr__(self) -> str: - return str(self.escape(repr(self.obj))) - - def __int__(self) -> int: - return int(self.obj) - - def __float__(self) -> float: - return float(self.obj) - - -# circular import -try: - from ._speedups import escape as escape - from ._speedups import escape_silent as escape_silent - from ._speedups import soft_str as soft_str -except ImportError: - 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 diff --git a/pipenv/vendor/markupsafe/_native.py b/pipenv/vendor/markupsafe/_native.py deleted file mode 100644 index 8117b2716d..0000000000 --- a/pipenv/vendor/markupsafe/_native.py +++ /dev/null @@ -1,63 +0,0 @@ -import typing as t - -from . import Markup - - -def escape(s: t.Any) -> Markup: - """Replace the characters ``&``, ``<``, ``>``, ``'``, and ``"`` in - the string with HTML-safe sequences. Use this if you need to display - text that might contain such characters in HTML. - - If the object has an ``__html__`` method, it is called and the - return value is assumed to already be safe for HTML. - - :param s: An object to be converted to a string and escaped. - :return: A :class:`Markup` string with the escaped text. - """ - if hasattr(s, "__html__"): - return Markup(s.__html__()) - - return Markup( - str(s) - .replace("&", "&") - .replace(">", ">") - .replace("<", "<") - .replace("'", "'") - .replace('"', """) - ) - - -def escape_silent(s: t.Optional[t.Any]) -> Markup: - """Like :func:`escape` but treats ``None`` as the empty string. - Useful with optional values, as otherwise you get the string - ``'None'`` when the value is ``None``. - - >>> escape(None) - Markup('None') - >>> escape_silent(None) - Markup('') - """ - if s is None: - return Markup() - - return escape(s) - - -def soft_str(s: t.Any) -> str: - """Convert an object to a string if it isn't already. This preserves - a :class:`Markup` string rather than converting it back to a basic - string, so it will still be marked as safe and won't be escaped - again. - - >>> value = escape("") - >>> value - Markup('<User 1>') - >>> escape(str(value)) - Markup('&lt;User 1&gt;') - >>> escape(soft_str(value)) - Markup('<User 1>') - """ - if not isinstance(s, str): - return str(s) - - return s diff --git a/pipenv/vendor/markupsafe/_speedups.pyi b/pipenv/vendor/markupsafe/_speedups.pyi deleted file mode 100644 index f673240f6d..0000000000 --- a/pipenv/vendor/markupsafe/_speedups.pyi +++ /dev/null @@ -1,9 +0,0 @@ -from typing import Any -from typing import Optional - -from . import Markup - -def escape(s: Any) -> Markup: ... -def escape_silent(s: Optional[Any]) -> Markup: ... -def soft_str(s: Any) -> str: ... -def soft_unicode(s: Any) -> str: ... diff --git a/pipenv/vendor/markupsafe/py.typed b/pipenv/vendor/markupsafe/py.typed deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/pipenv/vendor/vendor.txt b/pipenv/vendor/vendor.txt index 9b0c801de2..02c6d6cdd6 100644 --- a/pipenv/vendor/vendor.txt +++ b/pipenv/vendor/vendor.txt @@ -2,7 +2,6 @@ click-didyoumean==0.3.0 click==8.1.7 colorama==0.4.6 dparse==0.6.3 -markupsafe==2.1.3 pexpect==4.8.0 pipdeptree==2.8.0 plette==0.4.4