Skip to content

Commit 875d8ca

Browse files
committed
Remove code for Python 3.8 compatibility
1 parent 8ed0fa9 commit 875d8ca

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

pylsp/_utils.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -262,18 +262,6 @@ class BlackFormatter(Formatter):
262262
formatters = {"ruff": RuffFormatter(), "black": BlackFormatter()}
263263

264264

265-
def removeprefix(text: str, prefix: str) -> str:
266-
if text.startswith(prefix):
267-
return text[len(prefix) :]
268-
return text
269-
270-
271-
def removesuffix(text: str, suffix: str) -> str:
272-
if suffix and text.endswith(suffix):
273-
return text[: -len(suffix)]
274-
return text
275-
276-
277265
def format_signature(signature: str, config: dict, signature_formatter: str) -> str:
278266
"""Formats signature using ruff or black if either is available."""
279267
as_func = f"def {signature.strip()}:\n pass"
@@ -282,14 +270,9 @@ def format_signature(signature: str, config: dict, signature_formatter: str) ->
282270
if formatter.is_installed:
283271
try:
284272
return (
285-
# TODO: replace with str.removeprefix and str.removesuffix
286-
# once Python 3.8 support is no longer required
287-
removesuffix(
288-
removeprefix(
289-
formatter.format(as_func, line_length=line_length), "def "
290-
),
291-
":\n pass",
292-
)
273+
formatter.format(as_func, line_length=line_length)
274+
.removeprefix("def ")
275+
.removesuffix(":\n pass")
293276
)
294277
except subprocess.CalledProcessError as e:
295278
log.warning("Signature formatter failed %s", e)

0 commit comments

Comments
 (0)