Skip to content

Commit

Permalink
Apply ruff/pyupgrade rule (UP032)
Browse files Browse the repository at this point in the history
UP032 Use f-string instead of `format` call

https://docs.astral.sh/ruff/rules/f-string/
  • Loading branch information
DimitriPapadopoulos committed Mar 10, 2024
1 parent e50e78e commit fda54a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
12 changes: 4 additions & 8 deletions src/installer/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ def __init__(
self.elements = elements

def __repr__(self) -> str:
return "InvalidRecordEntry(elements={!r}, issues={!r})".format(
self.elements, self.issues
)
return f"InvalidRecordEntry(elements={self.elements!r}, issues={self.issues!r})"


class Hash:
Expand Down Expand Up @@ -130,8 +128,8 @@ def to_row(self, path_prefix: Optional[str] = None) -> Tuple[str, str, str]:
)

def __repr__(self) -> str:
return "RecordEntry(path={!r}, hash_={!r}, size={!r})".format(
self.path, self.hash_, self.size
return (
f"RecordEntry(path={self.path!r}, hash_={self.hash!r}, size={self.size!r})"
)

def __eq__(self, other: object) -> bool:
Expand Down Expand Up @@ -243,9 +241,7 @@ def parse_record_file(rows: Iterable[str]) -> Iterator[Tuple[str, str, str]]:
reader = csv.reader(rows, delimiter=",", quotechar='"', lineterminator="\n")
for row_index, elements in enumerate(reader):
if len(elements) != 3:
message = "Row Index {}: expected 3 elements, got {}".format(
row_index, len(elements)
)
message = f"Row Index {row_index}: expected 3 elements, got {len(elements)}"
raise InvalidRecordEntry(elements=elements, issues=[message])

# Convert Windows paths to use / for consistency
Expand Down
6 changes: 1 addition & 5 deletions src/installer/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,7 @@ def __init__(
self.section = section

def __repr__(self) -> str:
return "Script(name={!r}, module={!r}, attr={!r}".format(
self.name,
self.module,
self.attr,
)
return f"Script(name={self.name!r}, module={self.module!r}, attr={self.attr!r}"

def _get_launcher_data(self, kind: "LauncherKind") -> Optional[bytes]:
if kind == "posix":
Expand Down

0 comments on commit fda54a1

Please sign in to comment.