Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pandas/util/_str_methods.py: 92%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

12 statements  

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