Skip to content

Commit

Permalink
implement more str methods
Browse files Browse the repository at this point in the history
casefold, removeprefix, removesuffix
  • Loading branch information
davidism committed Jun 2, 2023
1 parent 391aa07 commit c438e4d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ Version 2.1.3

Unreleased

- Implement ``format_map``, ``casefold``, ``removeprefix``, and ``removesuffix``
methods. :issue:`370`
- Fix static typing for basic ``str`` methods on ``Markup``. :issue:`358`
- Implement ``format_map`` method. :issue:`370`


Version 2.1.2
Expand Down
6 changes: 6 additions & 0 deletions src/markupsafe/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import functools
import re
import string
import sys
import typing as t

if t.TYPE_CHECKING:
Expand Down Expand Up @@ -193,6 +194,11 @@ def escape(cls, s: t.Any) -> "Markup":
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["Markup", "Markup", "Markup"]:
l, s, r = super().partition(self.escape(sep))
Expand Down

0 comments on commit c438e4d

Please sign in to comment.