Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmer committed Mar 3, 2025
1 parent c212340 commit 6880972
Show file tree
Hide file tree
Showing 241 changed files with 1,478 additions and 724 deletions.
2 changes: 1 addition & 1 deletion breezy/_annotator_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def annotate_flat(self, key):
else:
the_heads = heads(annotation)
if len(the_heads) == 1:
for head in the_heads: # noqa: B007
for head in the_heads: # noqa: B007
break # get the item out of the set
else:
head = self._resolve_annotation_tie(
Expand Down
4 changes: 3 additions & 1 deletion breezy/_known_graph_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ def add_node(self, key, parent_keys):
else:
raise ValueError(
"Parent key mismatch, existing node {}"
" has parents of {} not {}".format(key, existing_parent_keys, parent_keys)
" has parents of {} not {}".format(
key, existing_parent_keys, parent_keys
)
)
else:
node = _KnownGraphNode(key, parent_keys)
Expand Down
2 changes: 1 addition & 1 deletion breezy/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def _expand_annotations(annotations, branch, current_rev=None):
last_origin = None
revisions = {}
if CURRENT_REVISION in revision_ids:
revision_id_to_revno[CURRENT_REVISION] = (f"{branch.revno()+1}?",)
revision_id_to_revno[CURRENT_REVISION] = (f"{branch.revno() + 1}?",)
revisions[CURRENT_REVISION] = current_rev
revisions.update(
entry
Expand Down
9 changes: 7 additions & 2 deletions breezy/archive/tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def prepare_tarball_item(tree, root, final_path, tree_path, entry, force_mtime=N
fileobj = None
else:
raise errors.BzrError(
"don't know how to export {{{}}} of kind {!r}".format(final_path, entry.kind)
"don't know how to export {{{}}} of kind {!r}".format(
final_path, entry.kind
)
)
return (item, fileobj)

Expand All @@ -88,7 +90,10 @@ def tarball_generator(
Returns: A generator that will produce file content chunks.
"""
buf = BytesIO()
with closing(tarfile.open(None, "w:{}".format(format), buf)) as ball, tree.lock_read():
with (
closing(tarfile.open(None, "w:{}".format(format), buf)) as ball,
tree.lock_read(),
):
for final_path, tree_path, entry in _export_iter_entries(
tree, subdir, recurse_nested=recurse_nested
):
Expand Down
4 changes: 3 additions & 1 deletion breezy/breakin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def _debug(signal_number, interrupted_frame):
sys.stderr.write(
"** {} received, entering debugger\n"
"** Type 'c' to continue or 'q' to stop the process\n"
"** Or {} again to quit (and possibly dump core)\n".format(_breakin_signal_name, _breakin_signal_name)
"** Or {} again to quit (and possibly dump core)\n".format(
_breakin_signal_name, _breakin_signal_name
)
)
# It seems that on Windows, when sys.stderr is to a PIPE, then we need to
# flush. Not sure why it is buffered, but that seems to be the case.
Expand Down
38 changes: 21 additions & 17 deletions breezy/builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,15 +1007,13 @@ def run(self, names_list):
) from exc
if src_kind is None:
raise errors.CommandError(
gettext(
"Could not copy %s => %s . %s is not versioned\\."
) % (src, dst, src)
gettext("Could not copy %s => %s . %s is not versioned\\.")
% (src, dst, src)
)
if src_kind == "directory":
raise errors.CommandError(
gettext(
"Could not copy %s => %s . %s is a directory."
) % (src, dst, src)
gettext("Could not copy %s => %s . %s is a directory.")
% (src, dst, src)
)
dst_parent = osutils.split(dst)[0]
if dst_parent != "":
Expand Down Expand Up @@ -1514,10 +1512,12 @@ def run(
gettext(
"No push location known or specified. To push to the "
"parent branch (at %s), use 'brz push :parent'."
) %
(urlutils.unescape_for_display(
)
% (
urlutils.unescape_for_display(
parent_loc, self.outf.encoding
),)
),
)
)
else:
raise errors.CommandError(
Expand Down Expand Up @@ -1765,9 +1765,11 @@ def run(self, location=".", recursive=False):
raise errors.CommandError("Can't scan this type of location.")
for b in controldir.ControlDir.find_branches(t):
self.outf.write(
"{}\n".format(urlutils.unescape_for_display(
urlutils.relative_url(t.base, b.base), self.outf.encoding
).rstrip("/"))
"{}\n".format(
urlutils.unescape_for_display(
urlutils.relative_url(t.base, b.base), self.outf.encoding
).rstrip("/")
)
)
else:
dir = controldir.ControlDir.open_containing(location)[0]
Expand Down Expand Up @@ -1913,9 +1915,7 @@ def run(
revision_id = br_from.last_revision()
if to_location is None:
to_location = urlutils.derive_to_location(from_location)
br_from.controldir.clone(
to_location, revision_id=revision_id
)
br_from.controldir.clone(to_location, revision_id=revision_id)
note(gettext("Created new control directory."))


Expand Down Expand Up @@ -4131,7 +4131,9 @@ def run(
if file_exists:
warning_msg = (
'The commit message is a file name: "{f}".\n'
'(use --file "{f}" to take commit message from that file)'.format(f=message)
'(use --file "{f}" to take commit message from that file)'.format(
f=message
)
)
ui.ui_factory.show_warning(warning_msg)
if "\r" in message:
Expand Down Expand Up @@ -7339,7 +7341,9 @@ def run(self):
found_hooks = list(hook_point)
if found_hooks:
for hook in found_hooks:
self.outf.write(" {}\n".format(some_hooks.get_hook_name(hook)))
self.outf.write(
" {}\n".format(some_hooks.get_hook_name(hook))
)
else:
self.outf.write(gettext(" <no hooks installed>\n"))

Expand Down
7 changes: 3 additions & 4 deletions breezy/bzr/_groupcompress_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ def _update_matching_lines(self, new_lines, index):
start_idx = len(self.lines)
if len(new_lines) != len(index):
raise AssertionError(
"The number of lines to be indexed does" +
f" not match the index/don't index flags: {len(new_lines)} != {len(index)}"
"The number of lines to be indexed does"
+ f" not match the index/don't index flags: {len(new_lines)} != {len(index)}"
)
for idx, do_index in enumerate(index):
if not do_index:
Expand Down Expand Up @@ -450,8 +450,7 @@ def apply_delta(basis, delta):
data = b"".join(lines)
if len(data) != target_length:
raise ValueError(
f"Delta claimed to be {target_length} long, but ended up"
f" {len(bytes)} long"
f"Delta claimed to be {target_length} long, but ended up {len(bytes)} long"
)
return data

Expand Down
8 changes: 6 additions & 2 deletions breezy/bzr/_knit_load_data_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,15 @@ def _load_data_py(kndx, fp):
try:
pos = int(pos)
except ValueError as e:
raise KnitCorrupt(kndx._filename, f"invalid position on line {rec!r}: {e}") from e
raise KnitCorrupt(
kndx._filename, f"invalid position on line {rec!r}: {e}"
) from e
try:
size = int(size)
except ValueError as e:
raise KnitCorrupt(kndx._filename, f"invalid size on line {rec!r}: {e}") from e
raise KnitCorrupt(
kndx._filename, f"invalid size on line {rec!r}: {e}"
) from e

# See kndx._cache_version
# only want the _history index to reference the 1st
Expand Down
8 changes: 6 additions & 2 deletions breezy/bzr/_rio_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def _read_stanza_utf8(line_iter: Iterator[bytes]) -> Optional[Stanza]:
if tag is None:
raise ValueError("invalid continuation line {!r}".format(real_l))
if accum_value is None:
raise ValueError("missing initial line for continuation {!r}".format(real_l))
raise ValueError(
"missing initial line for continuation {!r}".format(real_l)
)
accum_value.append("\n" + line[1:-1])
else: # new tag:value line
if tag is not None:
Expand All @@ -63,7 +65,9 @@ def _read_stanza_utf8(line_iter: Iterator[bytes]) -> Optional[Stanza]:
try:
colon_index = line.index(": ")
except ValueError as e:
raise ValueError("tag/value separator not found in line {!r}".format(real_l)) from e
raise ValueError(
"tag/value separator not found in line {!r}".format(real_l)
) from e
tag = str(line[:colon_index])
if not _valid_tag(tag):
raise ValueError("invalid rio tag {!r}".format(tag))
Expand Down
1 change: 1 addition & 0 deletions breezy/bzr/_static_tuple_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
strings.
"""


class StaticTuple(tuple):
"""A static type, similar to a tuple of strings."""

Expand Down
16 changes: 12 additions & 4 deletions breezy/bzr/branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,9 @@ def _unstack(self):
if len(old_repository._fallback_repositories) != 1:
raise AssertionError(
"can't cope with fallback repositories "
"of {!r} (fallbacks: {!r})".format(old_repository, old_repository._fallback_repositories)
"of {!r} (fallbacks: {!r})".format(
old_repository, old_repository._fallback_repositories
)
)
# Open the new repository object.
# Repositories don't offer an interface to remove fallback
Expand All @@ -555,7 +557,9 @@ def _unstack(self):
new_repository = new_bzrdir.find_repository()
if new_repository._fallback_repositories:
raise AssertionError(
"didn't expect {!r} to have fallback_repositories".format(self.repository)
"didn't expect {!r} to have fallback_repositories".format(
self.repository
)
)
# Replace self.repository with the new repository.
# Do our best to transfer the lock state (i.e. lock-tokens and
Expand Down Expand Up @@ -938,7 +942,9 @@ def open(
if not _found:
format = BranchFormatMetadir.find_format(a_controldir, name=name)
if format.__class__ != self.__class__:
raise AssertionError("wrong format {!r} found for {!r}".format(format, self))
raise AssertionError(
"wrong format {!r} found for {!r}".format(format, self)
)
transport = a_controldir.get_branch_transport(None, name=name)
try:
control_files = lockable_files.LockableFiles(
Expand Down Expand Up @@ -1237,7 +1243,9 @@ def open(
if not _found:
format = BranchFormatMetadir.find_format(a_controldir, name=name)
if format.__class__ != self.__class__:
raise AssertionError("wrong format {!r} found for {!r}".format(format, self))
raise AssertionError(
"wrong format {!r} found for {!r}".format(format, self)
)
if location is None:
location = self.get_reference(a_controldir, name)
real_bzrdir = ControlDir.open(location, possible_transports=possible_transports)
Expand Down
5 changes: 3 additions & 2 deletions breezy/bzr/btree_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -1518,8 +1518,9 @@ def _read_nodes(self, nodes):
else:
if offset > self._size:
raise AssertionError(
"tried to read past the end"
" of the file {} > {}".format(offset, self._size)
"tried to read past the end of the file {} > {}".format(
offset, self._size
)
)
size = min(size, self._size - offset)
ranges.append((base_offset + offset, size))
Expand Down
35 changes: 23 additions & 12 deletions breezy/bzr/bundle/bundle_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ def add_sha(d, revision_id, sha1):
if len(missing) > 0:
# I don't know if this is an error yet
warning(
"Not all revision hashes could be validated."
" Unable validate %d hashes", len(missing)
"Not all revision hashes could be validated. Unable validate %d hashes",
len(missing),
)
mutter("Verified %d sha hashes for the bundle.", count)
self._validated_revisions_against_repo = True
Expand All @@ -276,8 +276,9 @@ def _validate_inventory(self, inv, revision_id):
with open(",,bogus-inv", "wb") as f:
f.writelines(cs)
warning(
"Inventory sha hash mismatch for revision {}. {}"
" != {}".format(revision_id, sha1, rev.inventory_sha1)
"Inventory sha hash mismatch for revision {}. {} != {}".format(
revision_id, sha1, rev.inventory_sha1
)
)

def _testament(self, revision, tree):
Expand All @@ -299,7 +300,9 @@ def _validate_revision(self, tree, revision_id):
if sha1 != rev_info.sha1:
raise TestamentMismatch(rev.revision_id, rev_info.sha1, sha1)
if rev.revision_id in rev_to_sha1:
raise BzrError("Revision {{{}}} given twice in the list".format(rev.revision_id))
raise BzrError(
"Revision {{{}}} given twice in the list".format(rev.revision_id)
)
rev_to_sha1[rev.revision_id] = sha1

def _update_tree(self, bundle_tree, revision_id):
Expand Down Expand Up @@ -408,7 +411,9 @@ def modified(kind, extra, lines):
info = extra.split(" // ")
if len(info) < 1:
raise BzrError(
"modified action lines have at leastthe path in them: {!r}".format(extra)
"modified action lines have at leastthe path in them: {!r}".format(
extra
)
)
path = info[0]

Expand All @@ -426,7 +431,9 @@ def modified(kind, extra, lines):
for action_line, lines in self.get_revision_info(revision_id).tree_actions:
first = action_line.find(" ")
if first == -1:
raise BzrError("Bogus action line (no opening space): {!r}".format(action_line))
raise BzrError(
"Bogus action line (no opening space): {!r}".format(action_line)
)
second = action_line.find(" ", first + 1)
if second == -1:
raise BzrError(
Expand All @@ -436,8 +443,9 @@ def modified(kind, extra, lines):
kind = action_line[first + 1 : second]
if kind not in ("file", "directory", "symlink"):
raise BzrError(
"Bogus action line"
" (invalid object kind {!r}): {!r}".format(kind, action_line)
"Bogus action line (invalid object kind {!r}): {!r}".format(
kind, action_line
)
)
extra = action_line[second + 1 :]

Expand Down Expand Up @@ -502,8 +510,9 @@ def note_id(self, new_id, new_path, kind="file"):
def note_last_changed(self, file_id, revision_id):
if file_id in self._last_changed and self._last_changed[file_id] != revision_id:
raise BzrError(
"Mismatched last-changed revision for file_id {{{}}}"
": {} != {}".format(file_id, self._last_changed[file_id], revision_id)
"Mismatched last-changed revision for file_id {{{}}}: {} != {}".format(
file_id, self._last_changed[file_id], revision_id
)
)
self._last_changed[file_id] = revision_id

Expand Down Expand Up @@ -710,7 +719,9 @@ def add_entry(path, file_id):
if kind == "file":
ie.text_size, ie.text_sha1 = self.get_size_and_sha1(path)
if ie.text_size is None:
raise BzrError("Got a text_size of None for file_id {!r}".format(file_id))
raise BzrError(
"Got a text_size of None for file_id {!r}".format(file_id)
)
inv.add(ie)

sorted_entries = self.sorted_path_id()
Expand Down
4 changes: 3 additions & 1 deletion breezy/bzr/bundle/serializer/v08.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,9 @@ def _read_next_entry(self, line, indent=1):
value = self._read_many(indent=indent + 2)
else:
raise errors.MalformedHeader(
"While looking for key: value pairs, did not find the colon {!r}".format(line)
"While looking for key: value pairs, did not find the colon {!r}".format(
line
)
)

key = key.replace(" ", "_")
Expand Down
Loading

0 comments on commit 6880972

Please sign in to comment.