Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable pyupgrades ruleset #612

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading