From f57fe5c9a337a4cc61b22c770abbb5dde70deff5 Mon Sep 17 00:00:00 2001 From: pyrco <105293448+pyrco@users.noreply.github.com> Date: Tue, 7 Feb 2023 09:38:50 +0100 Subject: [PATCH] Add isort to flake8 linting (#26) (DIS-1789) --- dissect/cstruct/__init__.py | 40 ++++++++++++----------------- dissect/cstruct/bitbuffer.py | 2 +- dissect/cstruct/cstruct.py | 2 +- dissect/cstruct/types/base.py | 2 +- dissect/cstruct/types/chartype.py | 2 +- dissect/cstruct/types/enum.py | 2 +- dissect/cstruct/types/packedtype.py | 2 +- dissect/cstruct/types/pointer.py | 2 +- dissect/cstruct/types/structure.py | 2 +- dissect/cstruct/utils.py | 2 +- tests/test_bitbuffer.py | 2 +- tests/test_bitfield.py | 1 - tests/test_bytesinteger.py | 2 +- tests/test_ctypes_type.py | 3 +-- tests/test_enum.py | 1 - tests/test_expression.py | 3 +-- tests/test_packedtype.py | 2 +- tests/test_pointer.py | 2 +- tests/test_struct.py | 1 - tests/test_util.py | 2 +- tox.ini | 1 + 21 files changed, 33 insertions(+), 45 deletions(-) diff --git a/dissect/cstruct/__init__.py b/dissect/cstruct/__init__.py index a7bea3d..346f9d0 100644 --- a/dissect/cstruct/__init__.py +++ b/dissect/cstruct/__init__.py @@ -1,51 +1,43 @@ +from dissect.cstruct.bitbuffer import BitBuffer from dissect.cstruct.compiler import Compiler +from dissect.cstruct.cstruct import cstruct, ctypes, ctypes_type +from dissect.cstruct.exceptions import ( + Error, + NullPointerDereference, + ParserError, + ResolveError, +) from dissect.cstruct.expression import Expression from dissect.cstruct.types.base import Array, BaseType, RawType +from dissect.cstruct.types.bytesinteger import BytesInteger from dissect.cstruct.types.chartype import CharType +from dissect.cstruct.types.enum import Enum, EnumInstance +from dissect.cstruct.types.flag import Flag, FlagInstance from dissect.cstruct.types.instance import Instance -from dissect.cstruct.types.structure import Structure, Field, Union -from dissect.cstruct.types.voidtype import VoidType -from dissect.cstruct.types.wchartype import WcharType from dissect.cstruct.types.packedtype import PackedType -from dissect.cstruct.types.flag import Flag, FlagInstance -from dissect.cstruct.types.enum import Enum, EnumInstance -from dissect.cstruct.types.bytesinteger import BytesInteger from dissect.cstruct.types.pointer import Pointer, PointerInstance - -from dissect.cstruct.exceptions import ( - Error, - ParserError, - ResolveError, - NullPointerDereference, -) - -from dissect.cstruct.cstruct import ( - cstruct, - ctypes, - ctypes_type, -) - +from dissect.cstruct.types.structure import Field, Structure, Union +from dissect.cstruct.types.voidtype import VoidType +from dissect.cstruct.types.wchartype import WcharType from dissect.cstruct.utils import ( dumpstruct, hexdump, - pack, p8, p16, p32, p64, + pack, swap, swap16, swap32, swap64, - unpack, u8, u16, u32, u64, + unpack, ) -from dissect.cstruct.bitbuffer import BitBuffer - __all__ = [ "Compiler", "Array", diff --git a/dissect/cstruct/bitbuffer.py b/dissect/cstruct/bitbuffer.py index 957d270..5ab0644 100644 --- a/dissect/cstruct/bitbuffer.py +++ b/dissect/cstruct/bitbuffer.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import BinaryIO, TYPE_CHECKING, Union +from typing import TYPE_CHECKING, BinaryIO, Union if TYPE_CHECKING: from dissect.cstruct.types import RawType diff --git a/dissect/cstruct/cstruct.py b/dissect/cstruct/cstruct.py index 7a0dc95..7af9cbf 100644 --- a/dissect/cstruct/cstruct.py +++ b/dissect/cstruct/cstruct.py @@ -11,9 +11,9 @@ BaseType, BytesInteger, CharType, - Structure, PackedType, Pointer, + Structure, VoidType, WcharType, ) diff --git a/dissect/cstruct/types/base.py b/dissect/cstruct/types/base.py index 5d4c0b7..9ad51bf 100644 --- a/dissect/cstruct/types/base.py +++ b/dissect/cstruct/types/base.py @@ -1,7 +1,7 @@ from __future__ import annotations from io import BytesIO -from typing import Any, BinaryIO, List, TYPE_CHECKING +from typing import TYPE_CHECKING, Any, BinaryIO, List from dissect.cstruct.exceptions import ArraySizeError from dissect.cstruct.expression import Expression diff --git a/dissect/cstruct/types/chartype.py b/dissect/cstruct/types/chartype.py index dd2e4ca..5c71b7d 100644 --- a/dissect/cstruct/types/chartype.py +++ b/dissect/cstruct/types/chartype.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Any, BinaryIO, TYPE_CHECKING +from typing import TYPE_CHECKING, Any, BinaryIO from dissect.cstruct.types import RawType diff --git a/dissect/cstruct/types/enum.py b/dissect/cstruct/types/enum.py index 5546456..e4fc9e3 100644 --- a/dissect/cstruct/types/enum.py +++ b/dissect/cstruct/types/enum.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Any, BinaryIO, Dict, List, Union, TYPE_CHECKING +from typing import TYPE_CHECKING, Any, BinaryIO, Dict, List, Union from dissect.cstruct.types import BaseType, RawType diff --git a/dissect/cstruct/types/packedtype.py b/dissect/cstruct/types/packedtype.py index ece6bd4..fc42a95 100644 --- a/dissect/cstruct/types/packedtype.py +++ b/dissect/cstruct/types/packedtype.py @@ -1,7 +1,7 @@ from __future__ import annotations import struct -from typing import Any, BinaryIO, List, TYPE_CHECKING +from typing import TYPE_CHECKING, Any, BinaryIO, List from dissect.cstruct.types import RawType diff --git a/dissect/cstruct/types/pointer.py b/dissect/cstruct/types/pointer.py index 1a0678d..cc9312e 100644 --- a/dissect/cstruct/types/pointer.py +++ b/dissect/cstruct/types/pointer.py @@ -1,7 +1,7 @@ from __future__ import annotations import operator -from typing import Any, BinaryIO, Callable, Dict, Union, TYPE_CHECKING +from typing import TYPE_CHECKING, Any, BinaryIO, Callable, Dict, Union from dissect.cstruct.exceptions import NullPointerDereference from dissect.cstruct.types import BaseType, CharType, RawType diff --git a/dissect/cstruct/types/structure.py b/dissect/cstruct/types/structure.py index 447a991..d6a24be 100644 --- a/dissect/cstruct/types/structure.py +++ b/dissect/cstruct/types/structure.py @@ -2,7 +2,7 @@ import io from collections import OrderedDict -from typing import Any, BinaryIO, List, TYPE_CHECKING +from typing import TYPE_CHECKING, Any, BinaryIO, List from dissect.cstruct.bitbuffer import BitBuffer from dissect.cstruct.types import BaseType, Enum, Instance diff --git a/dissect/cstruct/utils.py b/dissect/cstruct/utils.py index 296b233..3286784 100644 --- a/dissect/cstruct/utils.py +++ b/dissect/cstruct/utils.py @@ -1,5 +1,5 @@ -import string import pprint +import string from typing import List, Tuple from dissect.cstruct.types import Instance, Structure diff --git a/tests/test_bitbuffer.py b/tests/test_bitbuffer.py index 2028d04..88db91f 100644 --- a/tests/test_bitbuffer.py +++ b/tests/test_bitbuffer.py @@ -1,8 +1,8 @@ from io import BytesIO import pytest - from dissect import cstruct + from dissect.cstruct.bitbuffer import BitBuffer diff --git a/tests/test_bitfield.py b/tests/test_bitfield.py index 9a4d195..4590b12 100644 --- a/tests/test_bitfield.py +++ b/tests/test_bitfield.py @@ -1,5 +1,4 @@ import pytest - from dissect import cstruct from .utils import verify_compiled diff --git a/tests/test_bytesinteger.py b/tests/test_bytesinteger.py index ced98b9..0f26fe2 100644 --- a/tests/test_bytesinteger.py +++ b/tests/test_bytesinteger.py @@ -1,6 +1,6 @@ import pytest - from dissect import cstruct + from dissect.cstruct.types import BytesInteger from .utils import verify_compiled diff --git a/tests/test_ctypes_type.py b/tests/test_ctypes_type.py index ec72496..31e2d95 100644 --- a/tests/test_ctypes_type.py +++ b/tests/test_ctypes_type.py @@ -1,9 +1,8 @@ -import pytest import ctypes as _ctypes +import pytest from dissect import cstruct - DUMMY_CSTRUCT = cstruct.cstruct() PACKED_TYPE_INT8 = cstruct.PackedType(DUMMY_CSTRUCT, "int8", 1, "b") diff --git a/tests/test_enum.py b/tests/test_enum.py index bfd9a32..71c77bd 100644 --- a/tests/test_enum.py +++ b/tests/test_enum.py @@ -1,5 +1,4 @@ import pytest - from dissect import cstruct from .utils import verify_compiled diff --git a/tests/test_expression.py b/tests/test_expression.py index 17a6893..549c8c3 100644 --- a/tests/test_expression.py +++ b/tests/test_expression.py @@ -1,8 +1,7 @@ import pytest - from dissect import cstruct -from dissect.cstruct.expression import Expression +from dissect.cstruct.expression import Expression testdata = [ ("1 * 0", 0), diff --git a/tests/test_packedtype.py b/tests/test_packedtype.py index 34d9a98..af6b0da 100644 --- a/tests/test_packedtype.py +++ b/tests/test_packedtype.py @@ -1,6 +1,6 @@ import pytest - from dissect import cstruct + from dissect.cstruct.types import PackedType from .utils import verify_compiled diff --git a/tests/test_pointer.py b/tests/test_pointer.py index 6583cf3..a0e094e 100644 --- a/tests/test_pointer.py +++ b/tests/test_pointer.py @@ -1,6 +1,6 @@ import pytest - from dissect import cstruct + from dissect.cstruct.types.pointer import PointerInstance from .utils import verify_compiled diff --git a/tests/test_struct.py b/tests/test_struct.py index 599f4ed..c94dae1 100644 --- a/tests/test_struct.py +++ b/tests/test_struct.py @@ -1,7 +1,6 @@ from io import BytesIO import pytest - from dissect import cstruct from .utils import verify_compiled diff --git a/tests/test_util.py b/tests/test_util.py index afc08ce..ae4d572 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1,6 +1,6 @@ import pytest - from dissect import cstruct + from dissect.cstruct.utils import dumpstruct, hexdump from .utils import verify_compiled diff --git a/tox.ini b/tox.ini index 2160d23..f2b225f 100644 --- a/tox.ini +++ b/tox.ini @@ -39,6 +39,7 @@ deps = black==23.1.0 flake8 flake8-black + flake8-isort vermin commands = flake8 dissect tests setup.py