From e64823be1bda3db1112d4fd5481cda6e499c669c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 14 Jun 2024 16:36:52 -0400 Subject: [PATCH] Rely on jaraco.compat.py38 for removeprefix. --- jaraco/home/compat/py38.py | 23 ----------------------- jaraco/home/report-spam-call.py | 4 ++-- pyproject.toml | 1 + 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/jaraco/home/compat/py38.py b/jaraco/home/compat/py38.py index d78e2be..e34d07f 100644 --- a/jaraco/home/compat/py38.py +++ b/jaraco/home/compat/py38.py @@ -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) diff --git a/jaraco/home/report-spam-call.py b/jaraco/home/report-spam-call.py index 0c627fb..712cb94 100644 --- a/jaraco/home/report-spam-call.py +++ b/jaraco/home/report-spam-call.py @@ -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' @@ -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__) diff --git a/pyproject.toml b/pyproject.toml index 09c33cd..5782d83 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,7 @@ dependencies = [ "python-dateutil", "victor-smart-kill", 'importlib_resources; python_version < "3.9"', + "jaraco.compat>=4.1", ] dynamic = ["version"]