Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#1057)
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.0.282 → v0.0.284](astral-sh/ruff-pre-commit@v0.0.282...v0.0.284)

* Fix ruff complaints

---------

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 Aug 14, 2023
1 parent d1a78a5 commit d972a4d
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ repos:
- id: rm-unneeded-f-str

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.282
rev: v0.0.284
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
4 changes: 2 additions & 2 deletions angrmanagement/data/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ def add_breakpoint(self, obj: Union[str, int], type_: Optional[str] = None, size
- `instance.add_breakpoint('global_value')` sets a write breakpoint on `global_value`
- `instance.add_breakpoint('global_value', 'read', 1)` sets a 1-byte read breakpoint on `global_value`
"""
if type(obj) is int:
if isinstance(obj, int):
addr = obj
elif type(obj) is str:
elif isinstance(obj, str):
sym = self.project.loader.find_symbol(obj)
if sym is None:
_l.error("Couldn't resolve '%s'", obj)
Expand Down
2 changes: 1 addition & 1 deletion angrmanagement/plugins/value_search/qsearch_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def sort(self, column, order=None) -> Any:
def _get_column_text(self, v: "MemoryData", col: int):
if col < len(self.HEADER):
data = self._get_column_data(v, col)
if col == self.ADDRESS_COL and type(data) is int:
if col == self.ADDRESS_COL and isinstance(data, int):
return f"{data:x}"
return data

Expand Down
2 changes: 1 addition & 1 deletion angrmanagement/ui/dialogs/new_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def mode_changed():
parent = QTreeWidgetItem(options_tree)
parent.setText(0, "All options")
parent.setFlags(parent.flags() | Qt.ItemIsAutoTristate | Qt.ItemIsUserCheckable)
for option in {x for x in angr.sim_options.__dict__.values() if type(x) is str and is_option(x)}:
for option in {x for x in angr.sim_options.__dict__.values() if isinstance(x, str) and is_option(x)}:
child = QTreeWidgetItem(parent)
child.setText(0, option)
child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
Expand Down
4 changes: 2 additions & 2 deletions angrmanagement/ui/dialogs/type_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ def edit_field(ty, field, predefined_types=None):
raise TypeError("Struct or union's fields are of type %s - that's bad" % type(fields))
fields_list = list(fields.items())

if type(field) is int:
if isinstance(field, int):
if not 0 <= field < len(fields):
raise IndexError(field)
fieldno = field
elif type(field) is str:
elif isinstance(field, str):
try:
fieldno = [i for i, (name, _) in fields_list if name == field][0]
except IndexError:
Expand Down
10 changes: 5 additions & 5 deletions angrmanagement/ui/views/hex_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -975,14 +975,14 @@ def set_pen_brush_for_active_selection(active):
val = self.read_func(addr)
pt.setX(self.byte_column_offsets[col])

if type(val) is int:
if isinstance(val, int):
if is_printable(val):
color = Conf.disasm_view_printable_byte_color
else:
color = Conf.disasm_view_unprintable_byte_color
byte_text = "%02x" % val
else:
byte_text = val * 2 if type(val) is str and len(val) == 1 else "??"
byte_text = val * 2 if isinstance(val, str) and len(val) == 1 else "??"
color = Conf.disasm_view_unknown_byte_color

pt.setX(self.byte_column_offsets[col])
Expand All @@ -997,7 +997,7 @@ def set_pen_brush_for_active_selection(active):
val = self.read_func(addr)
pt.setX(self.ascii_column_offsets[col])

if type(val) is int:
if isinstance(val, int):
if is_printable(val):
color = Conf.disasm_view_printable_character_color
ch = chr(val)
Expand All @@ -1006,7 +1006,7 @@ def set_pen_brush_for_active_selection(active):
ch = "."
else:
color = Conf.disasm_view_unknown_character_color
ch = val if type(val) is str and len(val) == 1 else "?"
ch = val if isinstance(val, str) and len(val) == 1 else "?"

pt.setX(self.ascii_column_offsets[col])
painter.setPen(color)
Expand Down Expand Up @@ -1661,7 +1661,7 @@ def _copy_selected_bytes(self):
self._clipboard = bytearray(num_bytes_selected)
for addr in range(minaddr, maxaddr + 1):
d = self.project_memory_read_func(addr) # FIXME: Support multibyte read
if type(d) is int:
if isinstance(d, int):
self._clipboard[addr - minaddr] = d

def _paste_copied_bytes_at_cursor(self):
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 @@ -105,7 +105,7 @@ def render_to_doc(self, cursor):
self.recreate_subobjs()
span_min = cursor.position()
for obj in self.subobjs:
if type(obj) is str:
if isinstance(obj, str):
cursor.insertText(obj, self._fmt_current)
else:
obj.render_to_doc(cursor)
Expand All @@ -125,7 +125,7 @@ def get_hit_obj(self, pos: int) -> "QBlockCodeObj":
if not self.hit_test(pos):
return None
for obj in self.subobjs:
if type(obj) is not str:
if not isinstance(obj, str):
hit = obj.get_hit_obj(pos)
if hit is not None:
return hit
Expand Down Expand Up @@ -492,7 +492,7 @@ class QIROpTextObj(QIROpObj):
"""

def create_subobjs(self, obj: Any):
if type(obj) is int:
if isinstance(obj, int):
self.add_text("%#x" % obj)
else:
self.add_text(str(obj))
Expand Down
2 changes: 1 addition & 1 deletion angrmanagement/ui/widgets/qfunction_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def _func_match_keyword(self, func, keyword, extra_columns: int = 0):
demangled_name = func.demangled_name
if demangled_name and keyword in demangled_name.lower():
return True
if type(func.addr) is int:
if isinstance(func.addr, int):
if keyword in "%x" % func.addr:
return True
if keyword in "%#x" % func.addr:
Expand Down
4 changes: 2 additions & 2 deletions angrmanagement/ui/widgets/qmemory_data_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def _init_line(self, addr, byte_offset, all_bytes):
# draw each byte
bytes_list = []
for idx, byt in enumerate(all_bytes):
if type(byt) is int:
if isinstance(byt, int):
color = printable_byte_color if is_printable(byt) else unprintable_byte_color
o = QGraphicsSimpleTextItem("%02x" % byt, self)
o.setFont(Conf.disasm_font)
Expand All @@ -181,7 +181,7 @@ def _init_line(self, addr, byte_offset, all_bytes):
# printable characters
character_list = []
for byt in all_bytes:
if type(byt) is int:
if isinstance(byt, int):
if is_printable(byt):
color = printable_char_color
ch = chr(byt)
Expand Down
2 changes: 1 addition & 1 deletion angrmanagement/ui/widgets/qstring_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def sort(self, column, order=None) -> Any:
def _get_column_text(self, v: "MemoryData", col: int):
if col < len(self.HEADER):
data = self._get_column_data(v, col)
if col == self.ADDRESS_COL and type(data) is int:
if col == self.ADDRESS_COL and isinstance(data, int):
return f"{data:x}"
return data

Expand Down
2 changes: 1 addition & 1 deletion angrmanagement/ui/widgets/qxref_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def sort(self, column, order):
def _get_column_text(self, xref, idx):
if idx < len(self.HEADER):
data = self._get_column_data(xref, idx)
if type(data) is int:
if isinstance(data, int):
return hex(data)
return data

Expand Down
12 changes: 6 additions & 6 deletions angrmanagement/ui/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,13 +408,13 @@ def viz(self, obj):
- For strings, look up the symbol of that name and jump there
"""

if type(obj) is int:
if isinstance(obj, int):
self.jump_to(obj)
elif type(obj) is str:
elif isinstance(obj, str):
sym = self.main_instance.project.loader.find_symbol(obj)
if sym is not None:
self.jump_to(sym.rebased_addr)
elif type(obj) is Function:
elif isinstance(obj, Function):
self.jump_to(obj.addr)

def jump_to(self, addr, view=None, use_animation=False):
Expand All @@ -435,9 +435,9 @@ def add_breakpoint(self, obj: Union[str, int], type_: Optional[str] = None, size
- `workspace.add_breakpoint('global_value')` sets a write breakpoint on `global_value`
- `workspace.add_breakpoint('global_value', 'read', 1)` sets a 1-byte read breakpoint on `global_value`
"""
if type(obj) is int:
if isinstance(obj, int):
addr = obj
elif type(obj) is str:
elif isinstance(obj, str):
sym = self.main_instance.project.loader.find_symbol(obj)
if sym is None:
_l.error("Couldn't resolve '%s'", obj)
Expand All @@ -447,7 +447,7 @@ def add_breakpoint(self, obj: Union[str, int], type_: Optional[str] = None, size
size = sym.size
if not type_:
type_ = "execute" if sym.type == SymbolType.TYPE_FUNCTION else "write"
elif type(obj) is Function:
elif isinstance(obj, Function):
addr = obj.addr
if not type_:
type_ = "execute"
Expand Down

0 comments on commit d972a4d

Please sign in to comment.