From 0c933dce5e6422490a0e4807f844522bfac41ac0 Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com> Date: Wed, 18 Dec 2024 15:24:19 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Use=20`str.removesuffix`=20(#348?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- markdown_it/tree.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/markdown_it/tree.py b/markdown_it/tree.py index 7e775204..5369157b 100644 --- a/markdown_it/tree.py +++ b/markdown_it/tree.py @@ -162,7 +162,7 @@ def type(self) -> str: if self.token: return self.token.type assert self.nester_tokens - return _removesuffix(self.nester_tokens.opening.type, "_open") + return self.nester_tokens.opening.type.removesuffix("_open") @property def next_sibling(self: _NodeType) -> _NodeType | None: @@ -331,14 +331,3 @@ def hidden(self) -> bool: """If it's true, ignore this element when rendering. Used for tight lists to hide paragraphs.""" return self._attribute_token().hidden - - -def _removesuffix(string: str, suffix: str) -> str: - """Remove a suffix from a string. - - Replace this with str.removesuffix() from stdlib when minimum Python - version is 3.9. - """ - if suffix and string.endswith(suffix): - return string[: -len(suffix)] - return string