From 8717de49bea6af83069d8dc532229010fb914e5d Mon Sep 17 00:00:00 2001 From: Fish Date: Thu, 12 Dec 2024 00:01:52 -0700 Subject: [PATCH] Lint code. --- ailment/converter_vex.py | 5 +++-- ailment/expression.py | 36 +++++++++--------------------------- ailment/utils.py | 7 ++----- 3 files changed, 14 insertions(+), 34 deletions(-) diff --git a/ailment/converter_vex.py b/ailment/converter_vex.py index 04731c1..dd473be 100644 --- a/ailment/converter_vex.py +++ b/ailment/converter_vex.py @@ -297,7 +297,7 @@ def Binop(expr, manager): manager.next_atom(), op2_size, op1_size, - False if op._from_signed == "U" else True, + op._from_signed != "U", operands[1], ins_addr=manager.ins_addr, vex_block_addr=manager.block_addr, @@ -389,7 +389,8 @@ def Triop(expr, manager): ) raise TypeError( - "Please figure out what kind of operation this is (smart money says fused multiply) and convert it into multiple binops" + "Please figure out what kind of operation this is (smart money says fused multiply) and convert it into " + "multiple binops" ) @staticmethod diff --git a/ailment/expression.py b/ailment/expression.py index 652b4bf..1ecdded 100644 --- a/ailment/expression.py +++ b/ailment/expression.py @@ -2,9 +2,9 @@ from __future__ import annotations from typing import TYPE_CHECKING, cast from collections.abc import Sequence -from typing_extensions import Self from enum import Enum, IntEnum from abc import abstractmethod +from typing_extensions import Self try: @@ -26,7 +26,10 @@ class Expression(TaggedObject): bits: int - __slots__ = ("depth",) + __slots__ = ( + "bits", + "depth", + ) def __init__(self, idx, depth, **kwargs): super().__init__(idx, **kwargs) @@ -92,10 +95,7 @@ def copy(self) -> Self: # pylint:disable=no-self-use class Const(Atom): - __slots__ = ( - "value", - "bits", - ) + __slots__ = ("value",) def __init__(self, idx: int | None, variable, value: int | float, bits: int, **kwargs): super().__init__(idx, variable, **kwargs) @@ -141,10 +141,7 @@ def copy(self) -> Const: class Tmp(Atom): - __slots__ = ( - "tmp_idx", - "bits", - ) + __slots__ = ("tmp_idx",) def __init__(self, idx: int | None, variable, tmp_idx: int, bits, **kwargs): super().__init__(idx, variable, **kwargs) @@ -176,10 +173,7 @@ def copy(self) -> Tmp: class Register(Atom): - __slots__ = ( - "reg_offset", - "bits", - ) + __slots__ = ("reg_offset",) def __init__(self, idx: int | None, variable, reg_offset: int, bits: int, **kwargs): super().__init__(idx, variable, **kwargs) @@ -227,7 +221,6 @@ class VirtualVariableCategory(IntEnum): class VirtualVariable(Atom): __slots__ = ( - "bits", "varid", "category", "oident", @@ -331,10 +324,7 @@ def copy(self) -> VirtualVariable: class Phi(Atom): - __slots__ = ( - "bits", - "src_and_vvars", - ) + __slots__ = ("src_and_vvars",) def __init__( self, @@ -456,7 +446,6 @@ def verbose_op(self): class UnaryOp(Op): __slots__ = ( "operand", - "bits", "variable", "variable_offset", ) @@ -759,7 +748,6 @@ def copy(self) -> Reinterpret: class BinaryOp(Op): __slots__ = ( "operands", - "bits", "variable", "variable_offset", "floating_point", @@ -1012,7 +1000,6 @@ class Load(Expression): "variable_offset", "guard", "alt", - "bits", ) def __init__( @@ -1120,7 +1107,6 @@ class ITE(Expression): "cond", "iffalse", "iftrue", - "bits", "variable", "variable_offset", ) @@ -1233,7 +1219,6 @@ class DirtyExpression(Expression): "mfx", "maddr", "msize", - "bits", ) def __init__( @@ -1371,7 +1356,6 @@ class VEXCCallExpression(Expression): __slots__ = ( "callee", "operands", - "bits", ) def __init__(self, idx: int | None, callee: str, operands: tuple[Expression, ...], bits: int, **kwargs): @@ -1456,7 +1440,6 @@ class MultiStatementExpression(Expression): __slots__ = ( "stmts", "expr", - "bits", ) def __init__(self, idx: int | None, stmts: list[Statement], expr: Expression, **kwargs): @@ -1532,7 +1515,6 @@ def copy(self) -> MultiStatementExpression: class BasePointerOffset(Expression): __slots__ = ( - "bits", "base", "offset", "variable", diff --git a/ailment/utils.py b/ailment/utils.py index 51bf290..833e4cc 100644 --- a/ailment/utils.py +++ b/ailment/utils.py @@ -1,3 +1,4 @@ +# pylint:disable=ungrouped-imports from __future__ import annotations from typing import TypeAlias import struct @@ -86,8 +87,6 @@ def is_none_or_likeable(arg1, arg2, is_list=False): """ Returns whether two things are both None or can like each other """ - from .expression import Expression # pylint:disable=import-outside-toplevel - if arg1 is None or arg2 is None: if arg1 == arg2: return True @@ -105,8 +104,6 @@ def is_none_or_matchable(arg1, arg2, is_list=False): """ Returns whether two things are both None or can match each other """ - from .expression import Expression # pylint:disable=import-outside-toplevel - if arg1 is None or arg2 is None: if arg1 == arg2: return True @@ -120,4 +117,4 @@ def is_none_or_matchable(arg1, arg2, is_list=False): return arg1 == arg2 -from .expression import Expression +from .expression import Expression # pylint:disable=wrong-import-position