Skip to content

Commit

Permalink
Rely on jaraco.compat.py38 for removeprefix.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jun 14, 2024
1 parent bc2b254 commit e64823b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 25 deletions.
23 changes: 0 additions & 23 deletions jaraco/home/compat/py38.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,3 @@
import importlib_resources as resources
else:
from importlib import resources # noqa: F401


if sys.version_info < (3, 9):

def removesuffix(self, suffix):
# suffix='' should not call self[:-0].
if suffix and self.endswith(suffix):
return self[: -len(suffix)]
else:
return self[:]

def removeprefix(self, prefix):
if self.startswith(prefix):
return self[len(prefix) :]
else:
return self[:]
else:

def removesuffix(self, suffix):
return self.removesuffix(suffix)

def removeprefix(self, prefix):
return self.removeprefix(prefix)
4 changes: 2 additions & 2 deletions jaraco/home/report-spam-call.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import autocommand
import dateutil.parser
from splinter import Browser
from jaraco.compat.py38 import r_fix

from . import contact as contact_info
from .compat.py38 import removeprefix


DROPPED_CALL = '2'
Expand All @@ -17,7 +17,7 @@ def clean_phone(number):
>>> clean_phone("+1 202 555 1212")
'2025551212'
"""
return re.sub(r'[-. ]', '', removeprefix(number, '+1'))
return re.sub(r'[-. ]', '', r_fix(number).removeprefix('+1'))


@autocommand.autocommand(__name__)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies = [
"python-dateutil",
"victor-smart-kill",
'importlib_resources; python_version < "3.9"',
"jaraco.compat>=4.1",
]
dynamic = ["version"]

Expand Down

0 comments on commit e64823b

Please sign in to comment.