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

Apply ruff/pyupgrade rule (UP032) #219

Merged
merged 1 commit into from
Mar 30, 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
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