1"""
2Python3.9 introduces removesuffix and remove prefix.
3
4They're reimplemented here for use in Python3.8.
5
6NOTE: when pyupgrade --py39-plus removes nearly everything in this file,
7this file and the associated tests should be removed.
8"""
9from __future__ import annotations
10
11import sys
12
13if sys.version_info < (3, 9):
14
15 def removesuffix(string: str, suffix: str) -> str:
16 if string.endswith(suffix):
17 return string[: -len(suffix)]
18 return string
19
20 def removeprefix(string: str, prefix: str) -> str:
21 if string.startswith(prefix):
22 return string[len(prefix) :]
23 return string
24
25else:
26 # NOTE: remove this file when pyupgrade --py39-plus removes
27 # the above block
28 pass