Skip to content

Commit

Permalink
Use variable msg instead of tmpl in setuptools/dist
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri authored and Avasam committed Oct 15, 2024
1 parent d457d0e commit 00995c1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions setuptools/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ def _check_marker(marker):
def assert_bool(dist, attr, value):
"""Verify that value is True, False, 0, or 1"""
if bool(value) != value:
tmpl = "{attr!r} must be a boolean value (got {value!r})"
raise DistutilsSetupError(tmpl.format(attr=attr, value=value))
raise DistutilsSetupError(f"{attr!r} must be a boolean value (got {value!r})")


def invalid_unless_false(dist, attr, value):
Expand All @@ -163,20 +162,20 @@ def check_requirements(dist, attr: str, value: _StrOrIter) -> None:
if isinstance(value, (dict, set)):
raise TypeError("Unordered types are not allowed")
except (TypeError, ValueError) as error:
tmpl = (
msg = (
f"{attr!r} must be a string or iterable of strings "
f"containing valid project/version requirement specifiers; {error}"
)
raise DistutilsSetupError(tmpl) from error
raise DistutilsSetupError(msg) from error


def check_specifier(dist, attr, value):
"""Verify that value is a valid version specifier"""
try:
SpecifierSet(value)
except (InvalidSpecifier, AttributeError) as error:
tmpl = "{attr!r} must be a string containing valid version specifiers; {error}"
raise DistutilsSetupError(tmpl.format(attr=attr, error=error)) from error
msg = f"{attr!r} must be a string containing valid version specifiers; {error}"
raise DistutilsSetupError(msg) from error


def check_entry_points(dist, attr, value):
Expand Down

0 comments on commit 00995c1

Please sign in to comment.