diff --git a/archinfo/__init__.py b/archinfo/__init__.py index 419d4c12..e3564186 100644 --- a/archinfo/__init__.py +++ b/archinfo/__init__.py @@ -7,63 +7,62 @@ __version__ = "9.2.72.dev0" -from .types import RegisterOffset, TmpVar, RegisterName, Endness from .arch import ( - Register, Arch, - register_arch, ArchNotFound, + Register, + all_arches, arch_from_id, - reverse_ends, get_host_arch, - all_arches, + register_arch, + reverse_ends, ) -from .defines import defines -from .arch_amd64 import ArchAMD64 -from .arch_x86 import ArchX86 -from .arch_arm import ArchARM, ArchARMEL, ArchARMHF, ArchARMCortexM from .arch_aarch64 import ArchAArch64 +from .arch_amd64 import ArchAMD64 +from .arch_arm import ArchARM, ArchARMCortexM, ArchARMEL, ArchARMHF from .arch_avr import ArchAVR8 -from .arch_ppc32 import ArchPPC32 -from .arch_ppc64 import ArchPPC64 from .arch_mips32 import ArchMIPS32 from .arch_mips64 import ArchMIPS64 -from .arch_soot import ArchSoot -from .archerror import ArchError -from .arch_s390x import ArchS390X from .arch_pcode import ArchPcode +from .arch_ppc32 import ArchPPC32 +from .arch_ppc64 import ArchPPC64 from .arch_riscv64 import ArchRISCV64 - +from .arch_s390x import ArchS390X +from .arch_soot import ArchSoot +from .arch_x86 import ArchX86 +from .archerror import ArchError +from .defines import defines +from .types import Endness, RegisterName, RegisterOffset, TmpVar __all__ = [ - "RegisterOffset", - "TmpVar", - "RegisterName", - "Endness", - "Register", "Arch", - "register_arch", - "ArchNotFound", - "arch_from_id", - "reverse_ends", - "get_host_arch", - "all_arches", - "defines", + "ArchAArch64", "ArchAMD64", - "ArchX86", "ArchARM", + "ArchARMCortexM", "ArchARMEL", "ArchARMHF", - "ArchARMCortexM", - "ArchAArch64", "ArchAVR8", - "ArchPPC32", - "ArchPPC64", + "ArchError", "ArchMIPS32", "ArchMIPS64", - "ArchSoot", - "ArchError", - "ArchS390X", + "ArchNotFound", + "ArchPPC32", + "ArchPPC64", "ArchPcode", "ArchRISCV64", + "ArchS390X", + "ArchSoot", + "ArchX86", + "Endness", + "Register", + "RegisterName", + "RegisterOffset", + "TmpVar", + "all_arches", + "arch_from_id", + "defines", + "get_host_arch", + "register_arch", + "reverse_ends", ] diff --git a/archinfo/arch.py b/archinfo/arch.py index 29f79825..3ffd2bf0 100644 --- a/archinfo/arch.py +++ b/archinfo/arch.py @@ -1,16 +1,16 @@ +import copy import logging -from typing import Dict, List, Tuple, Optional, Type, Any, Set, Union -import struct as _struct import platform as _platform import re +import struct as _struct +from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union + +from archinfo.types import RegisterName, RegisterOffset -from archinfo.types import RegisterOffset, RegisterName from .archerror import ArchError from .tls import TLSArchInfo from .types import Endness -import copy - log = logging.getLogger("archinfo.arch") log.addHandler(logging.NullHandler()) diff --git a/archinfo/arch_aarch64.py b/archinfo/arch_aarch64.py index d8d0c74a..4e57b8df 100644 --- a/archinfo/arch_aarch64.py +++ b/archinfo/arch_aarch64.py @@ -1,5 +1,6 @@ from archinfo.types import RegisterOffset -from .arch import Arch, register_arch, Endness, Register + +from .arch import Arch, Endness, Register, register_arch from .tls import TLSArchInfo try: diff --git a/archinfo/arch_amd64.py b/archinfo/arch_amd64.py index 055ea563..cf49abfb 100644 --- a/archinfo/arch_amd64.py +++ b/archinfo/arch_amd64.py @@ -1,7 +1,8 @@ from archinfo.types import RegisterOffset -from .arch import Arch, register_arch, Endness, Register -from .tls import TLSArchInfo + +from .arch import Arch, Endness, Register, register_arch from .archerror import ArchError +from .tls import TLSArchInfo try: import capstone as _capstone diff --git a/archinfo/arch_arm.py b/archinfo/arch_arm.py index ebe9a97f..2962682b 100644 --- a/archinfo/arch_arm.py +++ b/archinfo/arch_arm.py @@ -2,7 +2,7 @@ from archinfo.types import RegisterOffset -from .arch import Arch, register_arch, Endness, Register +from .arch import Arch, Endness, Register, register_arch from .tls import TLSArchInfo log = logging.getLogger("archinfo.arch_arm") diff --git a/archinfo/arch_avr.py b/archinfo/arch_avr.py index afd8a1b2..fa421b0e 100644 --- a/archinfo/arch_avr.py +++ b/archinfo/arch_avr.py @@ -1,4 +1,4 @@ -from .arch import Arch, register_arch, Endness +from .arch import Arch, Endness, register_arch from .archerror import ArchError from .tls import TLSArchInfo diff --git a/archinfo/arch_mips32.py b/archinfo/arch_mips32.py index 682660c9..5bfdb917 100644 --- a/archinfo/arch_mips32.py +++ b/archinfo/arch_mips32.py @@ -1,4 +1,4 @@ -from .arch import Arch, register_arch, Endness, Register +from .arch import Arch, Endness, Register, register_arch from .tls import TLSArchInfo try: diff --git a/archinfo/arch_mips64.py b/archinfo/arch_mips64.py index 99c64601..4c777082 100644 --- a/archinfo/arch_mips64.py +++ b/archinfo/arch_mips64.py @@ -1,5 +1,6 @@ from archinfo.types import RegisterOffset -from .arch import Arch, register_arch, Endness, Register + +from .arch import Arch, Endness, Register, register_arch from .tls import TLSArchInfo try: diff --git a/archinfo/arch_ppc32.py b/archinfo/arch_ppc32.py index 5a62f68e..8d8228cd 100644 --- a/archinfo/arch_ppc32.py +++ b/archinfo/arch_ppc32.py @@ -1,5 +1,6 @@ from archinfo.types import RegisterOffset -from .arch import Arch, register_arch, Endness, Register + +from .arch import Arch, Endness, Register, register_arch from .tls import TLSArchInfo try: diff --git a/archinfo/arch_ppc64.py b/archinfo/arch_ppc64.py index 9180b909..e567aa0e 100644 --- a/archinfo/arch_ppc64.py +++ b/archinfo/arch_ppc64.py @@ -1,5 +1,6 @@ from archinfo.types import RegisterOffset -from .arch import Arch, register_arch, Endness, Register + +from .arch import Arch, Endness, Register, register_arch from .tls import TLSArchInfo try: diff --git a/archinfo/arch_riscv64.py b/archinfo/arch_riscv64.py index 03f49a88..e5b65f19 100644 --- a/archinfo/arch_riscv64.py +++ b/archinfo/arch_riscv64.py @@ -1,5 +1,6 @@ from archinfo.types import RegisterOffset -from .arch import Arch, register_arch, Endness, Register + +from .arch import Arch, Endness, Register, register_arch from .tls import TLSArchInfo try: diff --git a/archinfo/arch_s390x.py b/archinfo/arch_s390x.py index 2ce46a8e..8cc7abc3 100644 --- a/archinfo/arch_s390x.py +++ b/archinfo/arch_s390x.py @@ -14,7 +14,8 @@ _pyvex = None from archinfo.types import RegisterOffset -from .arch import Arch, register_arch, Endness, Register + +from .arch import Arch, Endness, Register, register_arch from .archerror import ArchError from .tls import TLSArchInfo diff --git a/archinfo/arch_x86.py b/archinfo/arch_x86.py index f42d4d10..c7447738 100644 --- a/archinfo/arch_x86.py +++ b/archinfo/arch_x86.py @@ -1,9 +1,9 @@ -from .arch import Arch, register_arch, Endness, Register -from .tls import TLSArchInfo -from .archerror import ArchError - from archinfo.types import RegisterOffset +from .arch import Arch, Endness, Register, register_arch +from .archerror import ArchError +from .tls import TLSArchInfo + try: import capstone as _capstone except ImportError: diff --git a/archinfo/types.py b/archinfo/types.py index 53318b87..204dcaf1 100644 --- a/archinfo/types.py +++ b/archinfo/types.py @@ -8,6 +8,10 @@ class RegisterOffset(int): + """A register offset is an integer that represents the offset of a register + in VEX's register memory space. + """ + def __add__(self, other): if isinstance(other, int): return RegisterOffset(int(self) + other) diff --git a/pyproject.toml b/pyproject.toml index 780203a4..e1cebbfe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,3 +8,8 @@ target-version = ['py38'] [tool.ruff] line-length = 120 +select = [ + "E", + "F", + "I", +] diff --git a/tests/test_amd64.py b/tests/test_amd64.py index 74aff7fd..aab5d4f8 100644 --- a/tests/test_amd64.py +++ b/tests/test_amd64.py @@ -1,7 +1,7 @@ import unittest -from archinfo.arch import Endness from archinfo import ArchAMD64, ArchError +from archinfo.arch import Endness class TestAmd64(unittest.TestCase): diff --git a/tests/test_pcode.py b/tests/test_pcode.py index 6d587093..15666b12 100644 --- a/tests/test_pcode.py +++ b/tests/test_pcode.py @@ -1,14 +1,14 @@ # pylint:disable=missing-class-docstring,no-self-use -import unittest import pickle +import unittest try: import pypcode except ImportError: pypcode = None +from archinfo import ArchError, ArchPcode from archinfo.arch import Endness -from archinfo import ArchPcode, ArchError @unittest.skipUnless(pypcode is not None, "pypcode not installed")