Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#1355)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.7.4 → v0.8.3](astral-sh/ruff-pre-commit@v0.7.4...v0.8.3)

* Convert various strings to f-string

* Improve lint

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Kevin Phoenix <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and twizmwazin authored Dec 16, 2024
1 parent 746c4a8 commit 90b8bb5
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ repos:
- id: rm-unneeded-f-str

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.4
rev: v0.8.3
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
4 changes: 2 additions & 2 deletions angrmanagement/data/jobs/dependency_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _perform(self, ctx: JobContext, inst: Instance):

for depth in range(min_depth, max_depth):
base_progress: float = 30.0 + (depth - min_depth) * progress_chunk
ctx.set_progress(base_progress, text="Calculating reaching definitions... depth %d." % depth)
ctx.set_progress(base_progress, text=f"Calculating reaching definitions... depth {depth}.")
# generate RDA observation points
observation_points = set()
for pred in inst.cfg.am_obj.get_predecessors(inst.cfg.am_obj.get_any_node(self.func_addr)):
Expand All @@ -115,7 +115,7 @@ def _perform(self, ctx: JobContext, inst: Instance):
):
ctx.set_progress(
base_progress + idx / total * progress_chunk,
text="Computing transitive closures: %d/%d - depth %d" % (idx + 1, total, depth),
text=f"Computing transitive closures: {idx + 1}/{total} - depth {depth}",
)

all_defs = set()
Expand Down
2 changes: 1 addition & 1 deletion angrmanagement/plugins/dep_viewer/sinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, lib: str | None, func_name: str, arg_idx, platforms: list[str
self.platforms = platforms

def __repr__(self) -> str:
return "<TS %s:arg %d>" % (self.func_name, self.arg_idx)
return f"<TS {self.func_name}:arg {self.arg_idx}>"


class SinkManager:
Expand Down
2 changes: 1 addition & 1 deletion angrmanagement/plugins/plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def _register_toolbar_actions(self, plugin_cls: type[BasePlugin], plugin: BasePl
for idx, (icon, tooltip) in enumerate(plugin_cls.TOOLBAR_BUTTONS):
action = ToolbarAction(
icon,
"plugin %s toolbar %d" % (plugin_cls, idx),
f"plugin {plugin_cls} toolbar {idx}",
tooltip,
functools.partial(self._dispatch_single, plugin, BasePlugin.handle_click_toolbar, False, idx),
)
Expand Down
4 changes: 2 additions & 2 deletions angrmanagement/plugins/trace_viewer/trace_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def _open_bitmap_multi_trace(self, trace_path, base_addr):
self.workspace._main_window,
"Downloading failed",
"angr management failed to retrieve the header of the file. "
"The HTTP request returned an unexpected status code %d." % ex.status_code,
f"The HTTP request returned an unexpected status code {ex.status_code}.",
)
return None
else:
Expand Down Expand Up @@ -332,7 +332,7 @@ def _open_trace(self, trace_path, base_addr):
self.workspace._main_window,
"Downloading failed",
"angr management failed to retrieve the header of the file. "
"The HTTP request returned an unexpected status code %d." % ex.status_code,
f"The HTTP request returned an unexpected status code {ex.status_code}.",
)
trace = None
else:
Expand Down
2 changes: 1 addition & 1 deletion angrmanagement/ui/dialogs/socket_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def _action_accepted_socket(self) -> None:
current = self.currentIndex()
if current.parent().isValid():
current = current.parent()
ident = "Accept, " + current.internalPointer().ident + (", %d" % (current.internalPointer().childCount() + 1))
ident = f"Accept, {current.internalPointer().ident}, {current.internalPointer().childCount() + 1}"
self.model().add_item(ident, current, "Accepted")

def _action_add_package(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion angrmanagement/ui/widgets/qast_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def _build_strings(self) -> None:
else:
# claripy.AST
if self._display_size:
self._size_label.setText("[%d]" % (len(ast) // 8)) # in bytes
self._size_label.setText(f"[{len(ast) // 8}]") # in bytes
if not ast.symbolic:
format = "%02x" if self._byte_format is None else self._byte_format
self._ast_str = format % self._ast._model_concrete.value
Expand Down
6 changes: 3 additions & 3 deletions angrmanagement/ui/widgets/qblock_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def create_subobjs(self, obj: ailment.expression.Register) -> None:
if obj.variable is not None and self.options.show_variables:
self.add_variable(obj.variable)
else:
s = f"{obj.reg_name}" if hasattr(obj, "reg_name") else "reg_%d<%d>" % (obj.reg_offset, obj.bits // 8)
s = f"{obj.reg_name}" if hasattr(obj, "reg_name") else f"reg_{obj.reg_offset}<{obj.bits // 8}>"
self.add_text(s)

def should_highlight(self) -> bool:
Expand Down Expand Up @@ -441,7 +441,7 @@ class QAilConvertObj(QAilTextObj):
"""

def create_subobjs(self, obj: ailment.expression.Convert) -> None:
self.add_text("Conv(%d->%d, " % (obj.from_bits, obj.to_bits))
self.add_text(f"Conv({obj.from_bits}->{obj.to_bits}, ")
self.add_ailobj(obj.operand)
self.add_text(")")

Expand Down Expand Up @@ -546,7 +546,7 @@ class VexIRTmpWrapper:

def __init__(self, tid: TmpVar, reg_name: str | None = None) -> None:
self.tid = tid
self.reg_name = reg_name or ("t%d" % self.tid)
self.reg_name = reg_name or (f"t{self.tid}")

def __str__(self) -> str:
return self.reg_name
Expand Down
2 changes: 1 addition & 1 deletion angrmanagement/ui/widgets/qfunction_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def _init_widgets(self) -> None:
if self.prototype.arg_names and i < len(self.prototype.arg_names):
arg_name = self.prototype.arg_names[i]
else:
arg_name = "arg_%d" % i
arg_name = f"arg_{i}"
proto_str += arg_name

if i < len(self.prototype.args) - 1:
Expand Down
4 changes: 2 additions & 2 deletions angrmanagement/ui/widgets/qfunction_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,9 @@ def update_displayed_function_count(self) -> None:
self._status_label.setText("")
return
if cnt == len(self.function_manager):
self._status_label.setText("%d functions" % cnt)
self._status_label.setText(f"{cnt} functions")
else:
self._status_label.setText("%d/%d functions" % (cnt, len(self.function_manager)))
self._status_label.setText(f"{cnt}/{len(self.function_manager)} functions")

def filter_functions(self, text: str) -> None:
self._table_view.filter(text)
Expand Down
10 changes: 5 additions & 5 deletions angrmanagement/ui/widgets/qoperand.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def _init_widgets(self) -> None:
if "custom_values_str" not in formatting:
formatting["custom_values_str"] = {}
if variable_sort == "memory":
custom_value_str = variable_str if offset == 0 else "%s[%d]" % (variable_str, offset)
custom_value_str = f"{variable_str}" if offset == 0 else f"{variable_str}[{offset}]"
else:
custom_value_str = ""

Expand All @@ -310,15 +310,15 @@ def _init_widgets(self) -> None:
if self.infodock.induction_variable_analysis is not None:
r = self.infodock.induction_variable_analysis.variables.get(variable.ident, None)
if r is not None and r.expr.__class__.__name__ == "InductionExpr":
custom_value_str = "i*%d+%d" % (r.expr.stride, r.expr.init)
custom_value_str = f"i*{r.expr.stride}+{r.expr.init}"
if (
r is not None
and r.expr.__class__.__name__ == "Add"
and r.expr.operands[0].__class__.__name__ == "InductionExpr"
):
custom_value_str = "i*%d+%d" % (
r.expr.operands[0].stride,
r.expr.operands[0].init + r.expr.operands[1].value,
custom_value_str = (
f"i*{r.expr.operands[0].stride}+"
"{r.expr.operands[0].init + r.expr.operands[1].value}"
)

formatting["custom_values_str"][ident] = custom_value_str
Expand Down
2 changes: 1 addition & 1 deletion angrmanagement/ui/widgets/qsimulation_manager_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def refresh(self) -> None:
if self.stash_name == "errored" and getattr(state, "state", None):
state = state.state
self.addChild(StateTreeItem(state, self.simgr_viewer))
self.setText(0, "%s (%d)" % (self.stash_name, len(self.states)))
self.setText(0, f"{self.stash_name} ({len(self.states)})")

def handle_context_menu_event(self, event) -> None:
menu = QMenu()
Expand Down
4 changes: 2 additions & 2 deletions angrmanagement/ui/widgets/qstate_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def _get_copied_state_name(self, current_name: str):
ctr = int(ctr_str) + 1 if ctr_str else 1

current_name = m.group(1)
name = current_name + " copy %d" % ctr
name = f"{current_name} copy {ctr}"
else:
ctr = 0
name = current_name + " copy"
Expand All @@ -188,5 +188,5 @@ def _get_copied_state_name(self, current_name: str):
all_names = {s.gui_data.name for s in self.states}
while name in all_names:
ctr += 1
name = current_name + " copy %d" % ctr
name = f"{current_name} copy {ctr}"
return name
2 changes: 1 addition & 1 deletion angrmanagement/ui/widgets/qvextemps_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _load_tmps(self) -> None:

lbl_tmp_name = QLabel(self)
lbl_tmp_name.setProperty("class", "reg_viewer_label")
lbl_tmp_name.setText("tmp_%d" % tmp_id)
lbl_tmp_name.setText(f"tmp_{tmp_id}")
lbl_tmp_name.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
sublayout.addWidget(lbl_tmp_name)

Expand Down
2 changes: 1 addition & 1 deletion angrmanagement/utils/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ def last_move(self):
return 1 # NO_MOVE

def __repr__(self) -> str:
return "<Edge between %s and %s, %d coordinates>" % (self.src, self.dst, len(self.coordinates))
return f"<Edge between {self.src} and {self.dst}, {len(self.coordinates)} coordinates>"
2 changes: 1 addition & 1 deletion angrmanagement/utils/func.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def function_prototype_str(func: Function) -> str:
if func.prototype.arg_names and i < len(func.prototype.arg_names):
arg_name = func.prototype.arg_names[i]
else:
arg_name = "arg_%d" % i
arg_name = f"arg_{i}"

s += type_str + " " + arg_name

Expand Down
6 changes: 1 addition & 5 deletions angrmanagement/utils/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,7 @@ def merge(self, other) -> None:
self.out_branches[ins_addr][item.stmt_idx] = item

def __repr__(self) -> str:
return "<SuperCFGNode %#08x, %d blocks, %d out branches>" % (
self.addr,
len(self.cfg_nodes),
len(self.out_branches),
)
return f"<SuperCFGNode {self.addr:#08x}, {len(self.cfg_nodes)} blocks, {len(self.out_branches)} out branches>"

def __hash__(self):
return hash(("supercfgnode", self.addr))
Expand Down

0 comments on commit 90b8bb5

Please sign in to comment.