Skip to content

Commit

Permalink
Run ruff format
Browse files Browse the repository at this point in the history
by jelmer review by jelmer
  • Loading branch information
jelmer authored and The Breezy Bot committed Jun 19, 2024
2 parents 972953f + c6a76e2 commit b60c4f0
Show file tree
Hide file tree
Showing 157 changed files with 292 additions and 396 deletions.
4 changes: 2 additions & 2 deletions breezy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
locale.setlocale(locale.LC_ALL, "")
except locale.Error as e:
sys.stderr.write(
"brz: warning: %s\n"
"brz: warning: {}\n"
" bzr could not set the application locale.\n"
" Although this should be no problem for bzr itself, it might\n"
" cause problems with some plugins. To investigate the issue,\n"
" look at the output of the locale(1p) tool.\n" % e
" look at the output of the locale(1p) tool.\n".format(e)
)
# Use better default than ascii with posix filesystems that deal in bytes
# natively even when the C locale or no locale at all is given. Note that
Expand Down
5 changes: 2 additions & 3 deletions breezy/builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -1775,10 +1775,9 @@ 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(
"%s\n"
% urlutils.unescape_for_display(
"{}\n".format(urlutils.unescape_for_display(
urlutils.relative_url(t.base, b.base), self.outf.encoding
).rstrip("/")
).rstrip("/"))
)
else:
dir = controldir.ControlDir.open_containing(location)[0]
Expand Down
1 change: 0 additions & 1 deletion breezy/bzr/_dirstate_helpers_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

"""Python implementations of Dirstate Helper functions."""


# We cannot import the dirstate module, because it loads this module
# All we really need is the IN_MEMORY_MODIFIED constant
from .dirstate import DirState, DirstateCorrupt, _fields_per_entry
Expand Down
4 changes: 2 additions & 2 deletions breezy/bzr/branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,8 @@ def _open_hook(self, possible_transports=None):
if url is None:
hook_name = Branch.hooks.get_hook_name(hook)
raise AssertionError(
"'transform_fallback_location' hook %s returned "
"None, not a URL." % hook_name
"'transform_fallback_location' hook {} returned "
"None, not a URL.".format(hook_name)
)
self._activate_fallback_location(
url, possible_transports=possible_transports
Expand Down
18 changes: 9 additions & 9 deletions breezy/bzr/bundle/bundle_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ 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 {%s} given twice in the list" % (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 @@ -349,7 +349,7 @@ def renamed(kind, extra, lines):
info = extra.split(" // ")
if len(info) < 2:
raise BzrError(
"renamed action lines need both a from and to" ": %r" % extra
"renamed action lines need both a from and to" ": {!r}".format(extra)
)
old_path = info[0]
new_path = info[1][3:] if info[1].startswith("=> ") else info[1]
Expand All @@ -366,7 +366,7 @@ def removed(kind, extra, lines):
# TODO: in the future we might allow file ids to be
# given for removed entries
raise BzrError(
"removed action lines should only have the path" ": %r" % extra
"removed action lines should only have the path" ": {!r}".format(extra)
)
path = info[0]
bundle_tree.note_deletion(path)
Expand All @@ -375,16 +375,16 @@ def added(kind, extra, lines):
info = extra.split(" // ")
if len(info) <= 1:
raise BzrError(
"add action lines require the path and file id" ": %r" % extra
"add action lines require the path and file id" ": {!r}".format(extra)
)
elif len(info) > 5:
raise BzrError(
"add action lines have fewer than 5 entries." ": %r" % extra
"add action lines have fewer than 5 entries." ": {!r}".format(extra)
)
path = info[0]
if not info[1].startswith("file-id:"):
raise BzrError(
"The file-id should follow the path for an add" ": %r" % extra
"The file-id should follow the path for an add" ": {!r}".format(extra)
)
# This will be Unicode because of how the stream is read. Turn it
# back into a utf8 file_id
Expand All @@ -403,7 +403,7 @@ def modified(kind, extra, lines):
info = extra.split(" // ")
if len(info) < 1:
raise BzrError(
"modified action lines have at least" "the path in them: %r" % extra
"modified action lines have at least" "the path in them: {!r}".format(extra)
)
path = info[0]

Expand All @@ -425,7 +425,7 @@ def modified(kind, extra, lines):
second = action_line.find(" ", first + 1)
if second == -1:
raise BzrError(
"Bogus action line" " (missing second space): %r" % action_line
"Bogus action line" " (missing second space): {!r}".format(action_line)
)
action = action_line[:first]
kind = action_line[first + 1 : second]
Expand All @@ -438,7 +438,7 @@ def modified(kind, extra, lines):

if action not in valid_actions:
raise BzrError(
"Bogus action line" " (unrecognized action): %r" % action_line
"Bogus action line" " (unrecognized action): {!r}".format(action_line)
)
valid_actions[action](kind, extra, lines)

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

key = key.replace(" ", "_")
Expand Down Expand Up @@ -510,7 +510,7 @@ def _read_one_patch(self):
raise errors.MalformedPatches(
"The first line of all patches"
' should be a bzr meta line "==="'
": %r" % line
": {!r}".format(line)
)
action = line[4:-1].decode("utf-8")
elif line.startswith(b"... "):
Expand Down
2 changes: 1 addition & 1 deletion breezy/bzr/bzrdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ def create(cls, base, format=None, possible_transports=None) -> "BzrDir":
if cls is not BzrDir:
raise AssertionError(
"BzrDir.create always creates the "
"default format, not one of %r" % cls
"default format, not one of {!r}".format(cls)
)
if format is None:
format = BzrDirFormat.get_default_format()
Expand Down
10 changes: 5 additions & 5 deletions breezy/bzr/dirstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ def _apply_removals(self, removals):
self._raise_invalid(
path,
file_id,
"Attempt to remove path has wrong id - found %r." % entry[0][2],
"Attempt to remove path has wrong id - found {!r}.".format(entry[0][2]),
)
self._make_absent(entry)
# See if we have a malformed delta: deleting a directory must not
Expand Down Expand Up @@ -2833,9 +2833,9 @@ def advance(iterator):
fingerprint = b""
else:
# for safety disable variables
new_path_utf8 = (
new_dirname
) = new_basename = new_id = new_entry_key = None
new_path_utf8 = new_dirname = new_basename = new_id = new_entry_key = (
None
)
# 5 cases, we dont have a value that is strictly greater than everything, so
# we make both end conditions explicit
if not current_old:
Expand Down Expand Up @@ -3060,7 +3060,7 @@ def update_minimal(
(b"%s/%s" % key[0:2]).decode("utf8"),
key[2],
"Attempt to add item at path already occupied by "
"id %r" % entry[0][2],
"id {!r}".format(entry[0][2]),
)
low_index += 1
else:
Expand Down
2 changes: 1 addition & 1 deletion breezy/bzr/groupcompress.py
Original file line number Diff line number Diff line change
Expand Up @@ -2096,7 +2096,7 @@ def add_records(self, records, random_id=False):
details = f"{key} {value, node_refs} {passed}"
if self._inconsistency_fatal:
raise knit.KnitCorrupt(
self, "inconsistent details" " in add_records: %s" % details
self, "inconsistent details" " in add_records: {}".format(details)
)
else:
trace.warning(
Expand Down
2 changes: 1 addition & 1 deletion breezy/bzr/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ def create_by_apply_delta(
raise errors.InconsistentDelta(
old_path,
file_id,
"Entry was at wrong other path %r." % self.id2path(file_id),
"Entry was at wrong other path {!r}.".format(self.id2path(file_id)),
)
altered.add(file_id)
id_to_entry_delta.append(StaticTuple(old_key, new_key, new_value))
Expand Down
1 change: 0 additions & 1 deletion breezy/bzr/smart/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
client and server.
"""


import _thread
import struct
import sys
Expand Down
1 change: 0 additions & 1 deletion breezy/bzr/smart/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
# SmartServerRequestHandler, whose dispatch_command method creates an instance
# of a SmartServerRequest subclass.


import threading
from _thread import get_ident

Expand Down
1 change: 0 additions & 1 deletion breezy/bzr/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

"""The basic test suite for bzr."""


from ... import tests

TestCase = tests.TestCase
Expand Down
4 changes: 2 additions & 2 deletions breezy/bzr/tests/matchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ def __init__(self, vfs_calls):
self.vfs_calls = vfs_calls

def describe(self):
return "no VFS calls expected, got: %s" % ",".join(
return "no VFS calls expected, got: {}".format(",".join(
[
"{}({})".format(c.method, ", ".join([repr(a) for a in c.args]))
for c in self.vfs_calls
]
)
))


class ContainsNoVfsCalls(Matcher):
Expand Down
4 changes: 2 additions & 2 deletions breezy/bzr/tests/per_bzrdir/test_bzrdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def skipIfNoWorkingTree(self, a_controldir):
a_controldir.open_workingtree()
except (errors.NotLocalUrl, errors.NoWorkingTree) as e:
raise TestSkipped(
"bzrdir on transport %r has no working tree" % a_controldir.transport
"bzrdir on transport {!r} has no working tree".format(a_controldir.transport)
) from e

def createWorkingTreeOrSkip(self, a_controldir):
Expand All @@ -235,7 +235,7 @@ def createWorkingTreeOrSkip(self, a_controldir):
)
except errors.NotLocalUrl as e:
raise TestSkipped(
"cannot make working tree with transport %r" % a_controldir.transport
"cannot make working tree with transport {!r}".format(a_controldir.transport)
) from e

def test_clone_bzrdir_repository_under_shared_force_new_repo(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

"""Tests for the _generate_text_key_index API."""


from breezy.bzr.tests.per_repository_vf import (
TestCaseWithRepository,
all_repository_vf_format_scenarios,
Expand Down
1 change: 0 additions & 1 deletion breezy/bzr/tests/per_repository_vf/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

"""Test operations that check the repository for corruption."""


from breezy import errors
from breezy.bzr.tests.per_repository_vf import (
TestCaseWithRepository,
Expand Down
2 changes: 1 addition & 1 deletion breezy/bzr/tests/per_repository_vf/test_fileid_involved.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def test_utf8_file_ids_and_revision_ids(self):
main_wt.commit("a", rev_id=revision_id)
except errors.NonAsciiRevisionId as e:
raise tests.TestSkipped(
"non-ascii revision ids not supported by %s" % self.repository_format
"non-ascii revision ids not supported by {}".format(self.repository_format)
) from e

repo = main_wt.branch.repository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

"""Test the find_text_key_references API."""


from breezy.bzr.tests.per_repository_vf import (
TestCaseWithRepository,
all_repository_vf_format_scenarios,
Expand Down
3 changes: 1 addition & 2 deletions breezy/bzr/tests/per_repository_vf/test_refresh_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ def fetch_new_revision_into_concurrent_instance(self, repo, token):
server_repo.lock_write(token)
except errors.TokenLockingNotSupported:
self.skipTest(
"Cannot concurrently insert into repo format %r"
% self.repository_format
"Cannot concurrently insert into repo format {!r}".format(self.repository_format)
)
try:
server_repo.fetch(source.branch.repository, revid)
Expand Down
1 change: 0 additions & 1 deletion breezy/bzr/tests/per_repository_vf/test_write_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

"""Tests for repository write groups."""


from breezy import controldir, errors, memorytree, tests
from breezy.bzr import branch as bzrbranch
from breezy.bzr import remote, versionedfile
Expand Down
16 changes: 8 additions & 8 deletions breezy/bzr/tests/test_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,14 +529,14 @@ def _valid_apply_bundle(self, base_rev_id, info, to_tree):
for rev in info.real_revisions:
self.assertTrue(
not repository.has_revision(rev.revision_id),
"Revision {%s} present before applying bundle" % rev.revision_id,
"Revision {{{}}} present before applying bundle".format(rev.revision_id),
)
merge_bundle(info, to_tree, True, merge.Merge3Merger, False, False)

for rev in info.real_revisions:
self.assertTrue(
repository.has_revision(rev.revision_id),
"Missing revision {%s} after applying bundle" % rev.revision_id,
"Missing revision {{{}}} after applying bundle".format(rev.revision_id),
)

self.assertTrue(to_tree.branch.repository.has_revision(info.target))
Expand Down Expand Up @@ -732,7 +732,7 @@ def test_symlink_bundle(self):
def test_unicode_symlink_bundle(self):
self.requireFeature(features.UnicodeFilenameFeature)
self._test_symlink_bundle(
"\N{Euro Sign}link", "bar/\N{Euro Sign}foo", "mars\N{Euro Sign}"
"\N{EURO SIGN}link", "bar/\N{EURO SIGN}foo", "mars\N{EURO SIGN}"
)

def test_binary_bundle(self):
Expand Down Expand Up @@ -847,7 +847,7 @@ def test_unicode_bundle(self):
self.requireFeature(features.UnicodeFilenameFeature)
# Handle international characters
os.mkdir("b1")
f = open("b1/with Dod\N{Euro Sign}", "wb")
f = open("b1/with Dod\N{EURO SIGN}", "wb")

self.tree1 = self.make_branch_and_tree("b1")
self.b1 = self.tree1.branch
Expand All @@ -859,7 +859,7 @@ def test_unicode_bundle(self):
)
f.close()

self.tree1.add(["with Dod\N{Euro Sign}"], ids=[b"withdod-id"])
self.tree1.add(["with Dod\N{EURO SIGN}"], ids=[b"withdod-id"])
self.tree1.commit(
"i18n commit from William Dod\xe9",
rev_id=b"i18n-1",
Expand All @@ -870,23 +870,23 @@ def test_unicode_bundle(self):
self.get_valid_bundle(b"null:", b"i18n-1")

# Modified
f = open("b1/with Dod\N{Euro Sign}", "wb")
f = open("b1/with Dod\N{EURO SIGN}", "wb")
f.write("Modified \xb5\n".encode())
f.close()
self.tree1.commit("modified", rev_id=b"i18n-2")

self.get_valid_bundle(b"i18n-1", b"i18n-2")

# Renamed
self.tree1.rename_one("with Dod\N{Euro Sign}", "B\N{Euro Sign}gfors")
self.tree1.rename_one("with Dod\N{EURO SIGN}", "B\N{EURO SIGN}gfors")
self.tree1.commit(
"renamed, the new i18n man", rev_id=b"i18n-3", committer="Erik B\xe5gfors"
)

self.get_valid_bundle(b"i18n-2", b"i18n-3")

# Removed
self.tree1.remove(["B\N{Euro Sign}gfors"])
self.tree1.remove(["B\N{EURO SIGN}gfors"])
self.tree1.commit("removed", rev_id=b"i18n-4")

self.get_valid_bundle(b"i18n-3", b"i18n-4")
Expand Down
6 changes: 3 additions & 3 deletions breezy/bzr/tests/test_dirstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1604,7 +1604,7 @@ def test_add_symlink_to_root_no_parents_all_data(self):
def test_add_symlink_unicode_to_root_no_parents_all_data(self):
self.requireFeature(features.UnicodeFilenameFeature)
self._test_add_symlink_to_root_no_parents_all_data(
"\N{Euro Sign}link", "targ\N{Euro Sign}et"
"\N{EURO SIGN}link", "targ\N{EURO SIGN}et"
)

def test_add_directory_and_child_no_parents_all_data(self):
Expand Down Expand Up @@ -2917,10 +2917,10 @@ def assertDetails(self, expected, inv_entry):
self.assertIsInstance(tree_data, bytes)

def test_unicode_symlink(self):
target = "link-targ\N{Euro Sign}t"
target = "link-targ\N{EURO SIGN}t"
inv_entry = inventory.InventoryLink(
b"link-file-id",
"nam\N{Euro Sign}e",
"nam\N{EURO SIGN}e",
b"link-parent-id",
b"link-revision-id",
symlink_target=target,
Expand Down
Loading

0 comments on commit b60c4f0

Please sign in to comment.