Skip to content

Commit

Permalink
Enable pyupgrades ruleset
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisfreitag committed Jul 16, 2024
1 parent c62859f commit 9d94aab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions phonenumber_field/phonenumber.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand All @@ -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}"
)
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ select = [
"I", # isort
"B", # flake8-bugbear
"C4", # flake8-comprehension
"U", # pyupgrade
]


Expand Down

0 comments on commit 9d94aab

Please sign in to comment.