Skip to content

Commit

Permalink
Merge pull request buildbot#8198 from pmisik/dep-update-2024-w44-ruff
Browse files Browse the repository at this point in the history
Update ruff from 0.7.0 to 0.7.2
  • Loading branch information
p12tic authored Nov 6, 2024
2 parents 60e9fdc + 3eb6e9e commit e54308e
Show file tree
Hide file tree
Showing 61 changed files with 125 additions and 190 deletions.
2 changes: 1 addition & 1 deletion common/gather_dependabot.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def main():
print(pr['number'], pr['title'])
pr_text += f"#{pr['number']}: {pr['title']}\n"
os.system(
"git fetch https://github.com/buildbot/buildbot " f"refs/pull/{pr['number']}/head"
f"git fetch https://github.com/buildbot/buildbot refs/pull/{pr['number']}/head"
)
os.system("git cherry-pick FETCH_HEAD")

Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/changes/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def reconfigService(
self.project = bytes2unicode(project)

def describe(self):
return "GitHubPullrequestPoller watching the " f"GitHub repository {self.owner}/{self.repo}"
return f"GitHubPullrequestPoller watching the GitHub repository {self.owner}/{self.repo}"

@defer.inlineCallbacks
def _getPullInformation(self, pull_number):
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/changes/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self, maildir, prefix=None, category='', repository=''):
self.repository = repository
if prefix and not prefix.endswith("/"):
log.msg(
f"MaildirSource: you probably want your prefix=('{prefix}') to end with " "a slash"
f"MaildirSource: you probably want your prefix=('{prefix}') to end with a slash"
)

def describe(self):
Expand Down
3 changes: 1 addition & 2 deletions master/buildbot/config/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def check_param_length(value, name, max_length):
shortest_value = value.fmtstring % interpolations
if len(shortest_value) > max_length:
error(
f"{name} '{value}' (shortest interpolation) exceeds maximum length of "
f"{max_length}"
f"{name} '{value}' (shortest interpolation) exceeds maximum length of {max_length}"
)


Expand Down
3 changes: 1 addition & 2 deletions master/buildbot/data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ def get_kwargs_from_graphql_parent(self, parent, parent_type):
parentid = rtype.keyField
else:
raise NotImplementedError(
"Collection endpoint should implement "
"get_kwargs_from_graphql or parentMapping"
"Collection endpoint should implement get_kwargs_from_graphql or parentMapping"
)
else:
parentid = self.parentMapping[parent_type]
Expand Down
11 changes: 4 additions & 7 deletions master/buildbot/data/resultspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@
class NotSupportedFieldTypeError(TypeError):
def __init__(self, data, *args: object) -> None:
super().__init__(
(
f"Unsupported data type '{type(data)}': "
"must be an instance of Dict or a Dataclass."
),
(f"Unsupported data type '{type(data)}': must be an instance of Dict or a Dataclass."),
*args,
)

Expand Down Expand Up @@ -429,9 +426,9 @@ def includeFields(d):
# item collection
if isinstance(data, base.ListResult):
# if pagination was applied, then fields, etc. must be empty
assert (
not fields and not order and not filters
), "endpoint must apply fields, order, and filters if it performs pagination"
assert not fields and not order and not filters, (
"endpoint must apply fields, order, and filters if it performs pagination"
)
offset = data.offset
total = data.total
limit = data.limit
Expand Down
18 changes: 9 additions & 9 deletions master/buildbot/db/compression/zstd.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,19 @@ def compress(self, data: bytes) -> bytes:
self._compressor = ZStdCompressor._compressor_pool.acquire()
self._compressobj = self._compressor.compressobj()
else:
assert (
self._compressobj is not None
), "Programming error: _compressobj is None when _compressor is not"
assert self._compressobj is not None, (
"Programming error: _compressobj is None when _compressor is not"
)

return self._compressobj.compress(data)

def flush(self) -> bytes:
assert (
self._compressor is not None
), "Programming error: Flush called without previous compress"
assert (
self._compressobj is not None
), "Programming error: _compressobj is None when _compressor is not"
assert self._compressor is not None, (
"Programming error: Flush called without previous compress"
)
assert self._compressobj is not None, (
"Programming error: _compressobj is None when _compressor is not"
)

try:
return self._compressobj.flush(flush_mode=zstandard.COMPRESSOBJ_FLUSH_FINISH)
Expand Down
6 changes: 3 additions & 3 deletions master/buildbot/db/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ def __thd(
try:
try:
rv = callable(arg, *args, **kwargs)
assert not isinstance(
rv, self.forbidded_callable_return_type
), "do not return ResultProxy objects!"
assert not isinstance(rv, self.forbidded_callable_return_type), (
"do not return ResultProxy objects!"
)
except sa.exc.OperationalError as e:
if not self.engine.should_retry(e):
log.err(e, 'Got fatal OperationalError on DB')
Expand Down
3 changes: 1 addition & 2 deletions master/buildbot/db/test_result_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ def thd(conn) -> None:
conn.commit()
if res.rowcount == 0:
raise TestResultSetAlreadyCompleted(
f'Test result set {test_result_setid} '
f'is already completed or does not exist'
f'Test result set {test_result_setid} is already completed or does not exist'
)

return self.db.pool.do(thd)
Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def reconfig(self):
# longer on larger installations and may take a while.
self.reconfig_notifier = task.LoopingCall(
lambda: log.msg(
"reconfig is ongoing for " f"{self.reactor.seconds() - self.reconfig_active:.3f} s"
f"reconfig is ongoing for {self.reactor.seconds() - self.reconfig_active:.3f} s"
)
)
self.reconfig_notifier.start(10, now=False)
Expand Down
5 changes: 2 additions & 3 deletions master/buildbot/process/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ def _parse_substitution_src(self, arg):
repl = None
except ValueError:
config.error(
"Must specify both codebase and attribute for " f"src Interpolation '{arg}'"
f"Must specify both codebase and attribute for src Interpolation '{arg}'"
)
return {}, None, None

Expand Down Expand Up @@ -763,8 +763,7 @@ def _parseColon_ternary(self, d, kw, repl, defaultWhenFalse=False):
truePart, falsePart = self._splitBalancedParen(delim, repl[1:])
except ValueError:
config.error(
f"invalid Interpolate ternary expression '{repl[1:]}' "
f"with delimiter '{repl[0]}'"
f"invalid Interpolate ternary expression '{repl[1:]}' with delimiter '{repl[0]}'"
)
return None
return _Lookup(
Expand Down
6 changes: 3 additions & 3 deletions master/buildbot/process/users/manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ class CommandlineUserManager(service.AsyncMultiService):

def __init__(self, username=None, passwd=None, port=None):
super().__init__()
assert (
username and passwd
), "A username and password pair must be given to connect and use `buildbot user`"
assert username and passwd, (
"A username and password pair must be given to connect and use `buildbot user`"
)
self.username = username
self.passwd = passwd

Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/reporters/gerrit.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _old_add_label(label, value):
elif label == GERRIT_LABEL_REVIEWED:
return [f"--code-review {int(value)}"]
warnings.warn(
'Gerrit older than 2.6 does not support custom labels. ' f'Setting {label} is ignored.',
f'Gerrit older than 2.6 does not support custom labels. Setting {label} is ignored.',
stacklevel=1,
)
return []
Expand Down
8 changes: 2 additions & 6 deletions master/buildbot/reporters/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ def getProjectId(self, sourcestamp):
proj = yield response.json()
if response.code not in (200,):
log.msg(
'Unknown (or hidden) gitlab project'
f'{project_full_name}: {proj.get("message")}'
f'Unknown (or hidden) gitlab project{project_full_name}: {proj.get("message")}'
)
return None
self.project_ids[project_full_name] = proj['id']
Expand Down Expand Up @@ -223,8 +222,5 @@ def sendMessage(self, reports):
except Exception as e:
log.err(
e,
(
f'Failed to send status "{state}" for '
f'{sourcestamp["repository"]} at {sha}'
),
(f'Failed to send status "{state}" for {sourcestamp["repository"]} at {sha}'),
)
2 changes: 1 addition & 1 deletion master/buildbot/reporters/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def command_FORCE(self, args, tquery=None, partial=None, **kwargs):
sched = next(iter(forceschedulers))
else:
raise UsageError(
"Try '/force' and follow the instructions" f" (no force scheduler {sched})"
f"Try '/force' and follow the instructions (no force scheduler {sched})"
)
scheduler = forceschedulers[sched]

Expand Down
8 changes: 3 additions & 5 deletions master/buildbot/reporters/words.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ def validate_notification_event(self, event):
def list_notified_events(self):
if self.notify_events:
yield self.send(
'The following events are being notified: '
f'{", ".join(sorted(self.notify_events))}.'
f'The following events are being notified: {", ".join(sorted(self.notify_events))}.'
)
else:
yield self.send("No events are being notified.")
Expand Down Expand Up @@ -633,7 +632,7 @@ def command_LIST(self, args, **kwargs):

if not args:
raise UsageError(
"Try " f"'{self.bot.commandPrefix}list [all|N] builders|workers|changes'."
f"Try '{self.bot.commandPrefix}list [all|N] builders|workers|changes'."
)

if args[0] == 'builders':
Expand Down Expand Up @@ -1041,8 +1040,7 @@ def command_HELP(self, args, **kwargs):
self.send("No usage info for " + ' '.join([f"'{arg}'" for arg in args]))

command_HELP.usage = ( # type: ignore[attr-defined]
"help [_command_ _arg_ [_subarg_ ...]] - "
"Give help for _command_ or one of it's arguments"
"help [_command_ _arg_ [_subarg_ ...]] - Give help for _command_ or one of it's arguments"
)

def command_SOURCE(self, args, **kwargs):
Expand Down
3 changes: 1 addition & 2 deletions master/buildbot/schedulers/canceller.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ def on_complete_buildrequest(self, brid):
br_dict = self.br_by_ss.get(ss_tuple, None)
if br_dict is None:
raise KeyError(
f'{self.__class__.__name__}: Could not find finished builds '
f'by tuple {ss_tuple}'
f'{self.__class__.__name__}: Could not find finished builds by tuple {ss_tuple}'
)

del br_dict[tracked_br.brid]
Expand Down
3 changes: 1 addition & 2 deletions master/buildbot/schedulers/forcesched.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,7 @@ def __init__(

if not self.checkIfListOfType(builderNames, (str,)):
config.error(
f"ForceScheduler '{name}': builderNames must be a list of strings: "
f"{builderNames!r}"
f"ForceScheduler '{name}': builderNames must be a list of strings: {builderNames!r}"
)

if reason is None:
Expand Down
7 changes: 3 additions & 4 deletions master/buildbot/scripts/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ def _checkValidTypes(self, info):
for attr_type in user:
if attr_type not in valid:
raise usage.UsageError(
"Type not a valid attr_type, must be in: " f"{', '.join(valid)}"
f"Type not a valid attr_type, must be in: {', '.join(valid)}"
)

def postOptions(self):
Expand All @@ -637,7 +637,7 @@ def postOptions(self):
if not op:
raise usage.UsageError("you must specify an operation: add, remove, update, get")
if op not in ['add', 'remove', 'update', 'get']:
raise usage.UsageError(f"bad op {op!r}, use 'add', 'remove', 'update', " "or 'get'")
raise usage.UsageError(f"bad op {op!r}, use 'add', 'remove', 'update', or 'get'")

if not self.get('username') or not self.get('passwd'):
raise usage.UsageError("A username and password must be given")
Expand Down Expand Up @@ -665,8 +665,7 @@ def postOptions(self):
for user in info:
if 'identifier' not in user:
raise usage.UsageError(
"no ids found in update info; "
"use: --info=id:type=value,type=value,.."
"no ids found in update info; use: --info=id:type=value,type=value,.."
)
if op == 'add':
for user in info:
Expand Down
5 changes: 2 additions & 3 deletions master/buildbot/scripts/windows_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ def SvcDoRun(self):
)

self.warning(
f"BuildBot for directory {bbdir!r} terminated with "
f"exit code {status}.\n{output}"
f"BuildBot for directory {bbdir!r} terminated with exit code {status}.\n{output}"
)

del child_infos[index]
Expand All @@ -284,7 +283,7 @@ def SvcDoRun(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
# If necessary, kill it
if win32process.GetExitCodeProcess(h) == win32con.STILL_ACTIVE:
self.warning(f"BuildBot process at {bbdir!r} failed to terminate - " "killing it")
self.warning(f"BuildBot process at {bbdir!r} failed to terminate - killing it")
win32api.TerminateProcess(h, 3)
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)

Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/steps/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def subst(match):
if v is not None:
if not isinstance(v, (str, bytes)):
raise RuntimeError(
"'env' values must be strings or " f"lists; key '{key}' is incorrect"
f"'env' values must be strings or lists; key '{key}' is incorrect"
)
newenv[key] = p.sub(subst, env[key])

Expand Down
14 changes: 7 additions & 7 deletions master/buildbot/steps/source/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,16 @@ def updateSourceProperty(self, name, value, source=''):
source = self.__class__.__name__

if self.codebase != '':
assert not isinstance(
self.getProperty(name, None), str
), f"Sourcestep {self.name} has a codebase, other sourcesteps don't"
assert not isinstance(self.getProperty(name, None), str), (
f"Sourcestep {self.name} has a codebase, other sourcesteps don't"
)
property_dict = self.getProperty(name, {})
property_dict[self.codebase] = value
super().setProperty(name, property_dict, source)
else:
assert not isinstance(
self.getProperty(name, None), dict
), f"Sourcestep {self.name} does not have a codebase, other sourcesteps do"
assert not isinstance(self.getProperty(name, None), dict), (
f"Sourcestep {self.name} does not have a codebase, other sourcesteps do"
)
super().setProperty(name, value, source)

def computeSourceRevision(self, changes):
Expand Down Expand Up @@ -296,7 +296,7 @@ def run(self):
log.msg(f"No sourcestamp found in build for codebase '{self.codebase}'")
self.descriptionDone = f"Codebase {self.codebase} not in build"
yield self.addCompleteLog(
"log", "No sourcestamp found in build for " f"codebase '{self.codebase}'"
"log", f"No sourcestamp found in build for codebase '{self.codebase}'"
)
return FAILURE

Expand Down
5 changes: 1 addition & 4 deletions master/buildbot/steps/source/svn.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,7 @@ def parseGotRevision(self):
try:
revision = stdout_xml.getElementsByTagName('commit')[0].attributes['revision'].value
except (KeyError, IndexError):
msg = (
"SVN.parseGotRevision unable to detect Last Changed Rev in"
" output of svn info"
)
msg = "SVN.parseGotRevision unable to detect Last Changed Rev in output of svn info"
log.msg(msg)
# fall through and try to get 'Revision' instead

Expand Down
3 changes: 1 addition & 2 deletions master/buildbot/steps/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ def addBuildUrls(self, rclist):
num = build.number
url = getURLForBuild(self.master, builderid, num)
yield self.addURL(
f'{statusToString(build.results)}: '
f'{builderNames[builderid]} #{num}',
f'{statusToString(build.results)}: {builderNames[builderid]} #{num}',
url,
)

Expand Down
2 changes: 1 addition & 1 deletion master/buildbot/steps/vstudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def getResultSummary(self):
return {"step": results.statusToString(self.results)}

description = (
f'compile {self.logobserver.nbProjects} projects {self.logobserver.nbFiles} ' 'files'
f'compile {self.logobserver.nbProjects} projects {self.logobserver.nbFiles} files'
)

if self.logobserver.nbWarnings > 0:
Expand Down
5 changes: 2 additions & 3 deletions master/buildbot/test/integration/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ def comp(engine):
exp_info = dict((idx['name'], idx) for idx in exp)
for name in got_names - exp_names:
diff.append(
f"got unexpected index {name} on table {tbl.name}: "
f"{got_info[name]!r}"
f"got unexpected index {name} on table {tbl.name}: {got_info[name]!r}"
)
for name in exp_names - got_names:
diff.append(f"missing index {name} on table {tbl.name}")
Expand Down Expand Up @@ -242,7 +241,7 @@ def test_emptydb_modelmatches(self):
# Default encoding of Windows console is 'cp1252'
# which cannot encode the snowman.
raise unittest.SkipTest(
"Cannot encode weird unicode " f"on this platform with {os_encoding}"
f"Cannot encode weird unicode on this platform with {os_encoding}"
) from e

yield self.db.model.upgrade()
Expand Down
Loading

0 comments on commit e54308e

Please sign in to comment.