Bump markupsafe from 2.1.2 to 2.1.3 (#2130)

* Bump markupsafe from 2.1.2 to 2.1.3

Bumps [markupsafe](https://github.com/pallets/markupsafe) from 2.1.2 to 2.1.3.
- [Release notes](https://github.com/pallets/markupsafe/releases)
- [Changelog](https://github.com/pallets/markupsafe/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets/markupsafe/compare/2.1.2...2.1.3)

---
updated-dependencies:
- dependency-name: markupsafe
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update markupsave==2.1.3

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>

[skip ci]
This commit is contained in:
dependabot[bot] 2023-08-24 12:09:39 -07:00 committed by GitHub
parent 371d35433c
commit d0c7f25a3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 60 additions and 51 deletions

View file

@ -1,6 +1,7 @@
import functools import functools
import re import re
import string import string
import sys
import typing as t import typing as t
if t.TYPE_CHECKING: if t.TYPE_CHECKING:
@ -10,23 +11,23 @@ if t.TYPE_CHECKING:
def __html__(self) -> str: def __html__(self) -> str:
pass pass
_P = te.ParamSpec("_P")
__version__ = "2.1.2"
__version__ = "2.1.3"
_strip_comments_re = re.compile(r"<!--.*?-->", re.DOTALL) _strip_comments_re = re.compile(r"<!--.*?-->", re.DOTALL)
_strip_tags_re = re.compile(r"<.*?>", re.DOTALL) _strip_tags_re = re.compile(r"<.*?>", re.DOTALL)
def _simple_escaping_wrapper(name: str) -> t.Callable[..., "Markup"]: def _simple_escaping_wrapper(func: "t.Callable[_P, str]") -> "t.Callable[_P, Markup]":
orig = getattr(str, name) @functools.wraps(func)
def wrapped(self: "Markup", *args: "_P.args", **kwargs: "_P.kwargs") -> "Markup":
@functools.wraps(orig) arg_list = _escape_argspec(list(args), enumerate(args), self.escape)
def wrapped(self: "Markup", *args: t.Any, **kwargs: t.Any) -> "Markup":
args = _escape_argspec(list(args), enumerate(args), self.escape) # type: ignore
_escape_argspec(kwargs, kwargs.items(), self.escape) _escape_argspec(kwargs, kwargs.items(), self.escape)
return self.__class__(orig(self, *args, **kwargs)) return self.__class__(func(self, *arg_list, **kwargs)) # type: ignore[arg-type]
return wrapped return wrapped # type: ignore[return-value]
class Markup(str): class Markup(str):
@ -69,7 +70,7 @@ class Markup(str):
def __new__( def __new__(
cls, base: t.Any = "", encoding: t.Optional[str] = None, errors: str = "strict" cls, base: t.Any = "", encoding: t.Optional[str] = None, errors: str = "strict"
) -> "Markup": ) -> "te.Self":
if hasattr(base, "__html__"): if hasattr(base, "__html__"):
base = base.__html__() base = base.__html__()
@ -78,22 +79,22 @@ class Markup(str):
return super().__new__(cls, base, encoding, errors) return super().__new__(cls, base, encoding, errors)
def __html__(self) -> "Markup": def __html__(self) -> "te.Self":
return self return self
def __add__(self, other: t.Union[str, "HasHTML"]) -> "Markup": def __add__(self, other: t.Union[str, "HasHTML"]) -> "te.Self":
if isinstance(other, str) or hasattr(other, "__html__"): if isinstance(other, str) or hasattr(other, "__html__"):
return self.__class__(super().__add__(self.escape(other))) return self.__class__(super().__add__(self.escape(other)))
return NotImplemented return NotImplemented
def __radd__(self, other: t.Union[str, "HasHTML"]) -> "Markup": def __radd__(self, other: t.Union[str, "HasHTML"]) -> "te.Self":
if isinstance(other, str) or hasattr(other, "__html__"): if isinstance(other, str) or hasattr(other, "__html__"):
return self.escape(other).__add__(self) return self.escape(other).__add__(self)
return NotImplemented return NotImplemented
def __mul__(self, num: "te.SupportsIndex") -> "Markup": def __mul__(self, num: "te.SupportsIndex") -> "te.Self":
if isinstance(num, int): if isinstance(num, int):
return self.__class__(super().__mul__(num)) return self.__class__(super().__mul__(num))
@ -101,7 +102,7 @@ class Markup(str):
__rmul__ = __mul__ __rmul__ = __mul__
def __mod__(self, arg: t.Any) -> "Markup": def __mod__(self, arg: t.Any) -> "te.Self":
if isinstance(arg, tuple): if isinstance(arg, tuple):
# a tuple of arguments, each wrapped # a tuple of arguments, each wrapped
arg = tuple(_MarkupEscapeHelper(x, self.escape) for x in arg) arg = tuple(_MarkupEscapeHelper(x, self.escape) for x in arg)
@ -117,26 +118,28 @@ class Markup(str):
def __repr__(self) -> str: def __repr__(self) -> str:
return f"{self.__class__.__name__}({super().__repr__()})" return f"{self.__class__.__name__}({super().__repr__()})"
def join(self, seq: t.Iterable[t.Union[str, "HasHTML"]]) -> "Markup": def join(self, seq: t.Iterable[t.Union[str, "HasHTML"]]) -> "te.Self":
return self.__class__(super().join(map(self.escape, seq))) return self.__class__(super().join(map(self.escape, seq)))
join.__doc__ = str.join.__doc__ join.__doc__ = str.join.__doc__
def split( # type: ignore def split( # type: ignore[override]
self, sep: t.Optional[str] = None, maxsplit: int = -1 self, sep: t.Optional[str] = None, maxsplit: int = -1
) -> t.List["Markup"]: ) -> t.List["te.Self"]:
return [self.__class__(v) for v in super().split(sep, maxsplit)] return [self.__class__(v) for v in super().split(sep, maxsplit)]
split.__doc__ = str.split.__doc__ split.__doc__ = str.split.__doc__
def rsplit( # type: ignore def rsplit( # type: ignore[override]
self, sep: t.Optional[str] = None, maxsplit: int = -1 self, sep: t.Optional[str] = None, maxsplit: int = -1
) -> t.List["Markup"]: ) -> t.List["te.Self"]:
return [self.__class__(v) for v in super().rsplit(sep, maxsplit)] return [self.__class__(v) for v in super().rsplit(sep, maxsplit)]
rsplit.__doc__ = str.rsplit.__doc__ rsplit.__doc__ = str.rsplit.__doc__
def splitlines(self, keepends: bool = False) -> t.List["Markup"]: # type: ignore def splitlines( # type: ignore[override]
self, keepends: bool = False
) -> t.List["te.Self"]:
return [self.__class__(v) for v in super().splitlines(keepends)] return [self.__class__(v) for v in super().splitlines(keepends)]
splitlines.__doc__ = str.splitlines.__doc__ splitlines.__doc__ = str.splitlines.__doc__
@ -163,10 +166,10 @@ class Markup(str):
value = _strip_comments_re.sub("", self) value = _strip_comments_re.sub("", self)
value = _strip_tags_re.sub("", value) value = _strip_tags_re.sub("", value)
value = " ".join(value.split()) value = " ".join(value.split())
return Markup(value).unescape() return self.__class__(value).unescape()
@classmethod @classmethod
def escape(cls, s: t.Any) -> "Markup": def escape(cls, s: t.Any) -> "te.Self":
"""Escape a string. Calls :func:`escape` and ensures that for """Escape a string. Calls :func:`escape` and ensures that for
subclasses the correct type is returned. subclasses the correct type is returned.
""" """
@ -175,45 +178,51 @@ class Markup(str):
if rv.__class__ is not cls: if rv.__class__ is not cls:
return cls(rv) return cls(rv)
return rv return rv # type: ignore[return-value]
for method in ( __getitem__ = _simple_escaping_wrapper(str.__getitem__)
"__getitem__", capitalize = _simple_escaping_wrapper(str.capitalize)
"capitalize", title = _simple_escaping_wrapper(str.title)
"title", lower = _simple_escaping_wrapper(str.lower)
"lower", upper = _simple_escaping_wrapper(str.upper)
"upper", replace = _simple_escaping_wrapper(str.replace)
"replace", ljust = _simple_escaping_wrapper(str.ljust)
"ljust", rjust = _simple_escaping_wrapper(str.rjust)
"rjust", lstrip = _simple_escaping_wrapper(str.lstrip)
"lstrip", rstrip = _simple_escaping_wrapper(str.rstrip)
"rstrip", center = _simple_escaping_wrapper(str.center)
"center", strip = _simple_escaping_wrapper(str.strip)
"strip", translate = _simple_escaping_wrapper(str.translate)
"translate", expandtabs = _simple_escaping_wrapper(str.expandtabs)
"expandtabs", swapcase = _simple_escaping_wrapper(str.swapcase)
"swapcase", zfill = _simple_escaping_wrapper(str.zfill)
"zfill", casefold = _simple_escaping_wrapper(str.casefold)
):
locals()[method] = _simple_escaping_wrapper(method)
del method 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["Markup", "Markup", "Markup"]: def partition(self, sep: str) -> t.Tuple["te.Self", "te.Self", "te.Self"]:
l, s, r = super().partition(self.escape(sep)) l, s, r = super().partition(self.escape(sep))
cls = self.__class__ cls = self.__class__
return cls(l), cls(s), cls(r) return cls(l), cls(s), cls(r)
def rpartition(self, sep: str) -> t.Tuple["Markup", "Markup", "Markup"]: def rpartition(self, sep: str) -> t.Tuple["te.Self", "te.Self", "te.Self"]:
l, s, r = super().rpartition(self.escape(sep)) l, s, r = super().rpartition(self.escape(sep))
cls = self.__class__ cls = self.__class__
return cls(l), cls(s), cls(r) return cls(l), cls(s), cls(r)
def format(self, *args: t.Any, **kwargs: t.Any) -> "Markup": def format(self, *args: t.Any, **kwargs: t.Any) -> "te.Self":
formatter = EscapeFormatter(self.escape) formatter = EscapeFormatter(self.escape)
return self.__class__(formatter.vformat(self, args, kwargs)) return self.__class__(formatter.vformat(self, args, kwargs))
def __html_format__(self, format_spec: str) -> "Markup": 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: if format_spec:
raise ValueError("Unsupported format specification for Markup.") raise ValueError("Unsupported format specification for Markup.")
@ -268,8 +277,8 @@ class _MarkupEscapeHelper:
self.obj = obj self.obj = obj
self.escape = escape self.escape = escape
def __getitem__(self, item: t.Any) -> "_MarkupEscapeHelper": def __getitem__(self, item: t.Any) -> "te.Self":
return _MarkupEscapeHelper(self.obj[item], self.escape) return self.__class__(self.obj[item], self.escape)
def __str__(self) -> str: def __str__(self) -> str:
return str(self.escape(self.obj)) return str(self.escape(self.obj))

View file

@ -24,7 +24,7 @@ importlib-resources==6.0.1
git+https://github.com/Tautulli/ipwhois.git@master#egg=ipwhois git+https://github.com/Tautulli/ipwhois.git@master#egg=ipwhois
IPy==1.01 IPy==1.01
Mako==1.2.4 Mako==1.2.4
MarkupSafe==2.1.2 MarkupSafe==2.1.3
musicbrainzngs==0.7.1 musicbrainzngs==0.7.1
packaging==23.1 packaging==23.1
paho-mqtt==1.6.1 paho-mqtt==1.6.1