Skip to content

Commit c438e4d

Browse files
committed
implement more str methods
casefold, removeprefix, removesuffix
1 parent 391aa07 commit c438e4d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGES.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ Version 2.1.3
33

44
Unreleased
55

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

910

1011
Version 2.1.2

src/markupsafe/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import functools
22
import re
33
import string
4+
import sys
45
import typing as t
56

67
if t.TYPE_CHECKING:
@@ -193,6 +194,11 @@ def escape(cls, s: t.Any) -> "Markup":
193194
expandtabs = _simple_escaping_wrapper(str.expandtabs)
194195
swapcase = _simple_escaping_wrapper(str.swapcase)
195196
zfill = _simple_escaping_wrapper(str.zfill)
197+
casefold = _simple_escaping_wrapper(str.casefold)
198+
199+
if sys.version_info >= (3, 9):
200+
removeprefix = _simple_escaping_wrapper(str.removeprefix)
201+
removesuffix = _simple_escaping_wrapper(str.removesuffix)
196202

197203
def partition(self, sep: str) -> t.Tuple["Markup", "Markup", "Markup"]:
198204
l, s, r = super().partition(self.escape(sep))

0 commit comments

Comments
 (0)