From 7891bc0e595d22c3cdc1cb0c45506d3dcc19f24b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Tue, 16 Jul 2024 10:38:53 +0200 Subject: [PATCH] Enable pyupgrades ruleset --- phonenumber_field/phonenumber.py | 10 +++++----- pyproject.toml | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/phonenumber_field/phonenumber.py b/phonenumber_field/phonenumber.py index 0f85f520..84a9963a 100644 --- a/phonenumber_field/phonenumber.py +++ b/phonenumber_field/phonenumber.py @@ -125,7 +125,7 @@ def __lt__(self, other): elif not isinstance(other, type(self)): raise TypeError( "'<' not supported between instances of " - "'%s' and '%s'" % (type(self).__name__, type(other).__name__) + f"'{type(self).__name__}' and '{type(other).__name__}'" ) invalid = None @@ -134,7 +134,7 @@ def __lt__(self, other): elif not other.is_valid(): invalid = other if invalid is not None: - raise ValueError("Invalid phone number: %r" % invalid) + raise ValueError(f"Invalid phone number: {invalid!r}") format_string = getattr(settings, "PHONENUMBER_DB_FORMAT", "E164") fmt = self.format_map[format_string] @@ -159,13 +159,13 @@ def to_python(value, region=None): phone_number = PhoneNumber() phone_number.merge_from(value) else: - raise TypeError("Can't convert %s to PhoneNumber." % type(value).__name__) + raise TypeError(f"Can't convert {type(value).__name__} to PhoneNumber.") return phone_number def validate_region(region): if region is not None and region not in phonenumbers.SUPPORTED_REGIONS: raise ValueError( - "ā€œ%sā€ is not a valid region code. Choices are %r" - % (region, phonenumbers.SUPPORTED_REGIONS) + f"ā€œ{region}ā€ is not a valid region code. " + f"Choices are {phonenumbers.SUPPORTED_REGIONS!r}" ) diff --git a/pyproject.toml b/pyproject.toml index b274b40d..a82f1e92 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,6 +55,7 @@ select = [ "I", # isort "B", # flake8-bugbear "C4", # flake8-comprehension + "U", # pyupgrade ]