Skip to content

Commit 1b98081

Browse files
committed
isort
1 parent c1ac304 commit 1b98081

28 files changed

+90
-56
lines changed

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ SHELL=/bin/bash -e
22

33
help:
44
@echo - make black ------ Format code
5+
@echo - make isort ------ Sort imports
56
@echo - make clean ------ Clean virtual environment
67
@echo - make coverage --- Run tests coverage
78
@echo - make docs ------- Make docs
@@ -11,8 +12,13 @@ help:
1112
@echo - make typecheck -- Typecheck
1213
@echo - make venv ------- Create virtual environment
1314

14-
black:
15-
black -S cstruct tests examples setup.py
15+
.PHONY: isort
16+
isort:
17+
@isort --profile black cstruct tests examples setup.py
18+
19+
.PHONY: black
20+
black: isort
21+
@black -S cstruct tests examples setup.py
1622

1723
clean:
1824
-rm -rf build dist

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ C-style structs for Python
88
[![PyPI](https://img.shields.io/pypi/pyversions/cstruct.svg)](https://pypi.org/project/cstruct)
99
[![Downloads](https://pepy.tech/badge/cstruct/month)](https://pepy.tech/project/cstruct)
1010
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
11+
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
1112
[![Known Vulnerabilities](https://snyk.io/test/github/andreax79/python-cstruct/badge.svg)](https://snyk.io/test/github/andreax79/python-cstruct)
1213
[![Documentation](https://readthedocs.org/projects/python-cstruct/badge/?version=latest)](https://python-cstruct.readthedocs.io/en/latest/)
1314

cstruct/__init__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,22 @@
2828
__date__ = "15 August 2013"
2929

3030
from typing import Any, Dict, Optional, Type, Union
31+
32+
from .abstract import AbstractCEnum, AbstractCStruct, CStructMeta
3133
from .base import (
32-
LITTLE_ENDIAN,
3334
BIG_ENDIAN,
35+
CHAR_ZERO,
36+
DEFINES,
37+
ENUMS,
38+
LITTLE_ENDIAN,
3439
NATIVE_ORDER,
3540
STRUCTS,
36-
ENUMS,
37-
DEFINES,
3841
TYPEDEFS,
39-
CHAR_ZERO,
4042
)
41-
from .abstract import CStructMeta, AbstractCStruct, AbstractCEnum
42-
from .cstruct import CStruct
4343
from .c_parser import parse_struct_def
44-
from .mem_cstruct import MemCStruct
4544
from .cenum import CEnum
45+
from .cstruct import CStruct
46+
from .mem_cstruct import MemCStruct
4647
from .native_types import get_native_type
4748

4849
__all__ = [

cstruct/abstract.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,19 @@
2424
# IN THE SOFTWARE.
2525
#
2626

27+
import hashlib
28+
import struct
2729
from abc import ABCMeta
2830
from collections import OrderedDict
29-
from typing import Any, BinaryIO, List, Dict, Optional, Type, Tuple, Union
30-
import hashlib
31+
from enum import EnumMeta, IntEnum, _EnumDict
3132
from io import StringIO
32-
from enum import IntEnum, EnumMeta, _EnumDict
33-
import struct
34-
from .base import STRUCTS, ENUMS, DEFAULT_ENUM_SIZE, ENUM_SIZE_TO_C_TYPE
35-
from .c_parser import parse_struct, parse_struct_def, parse_enum_def, parse_enum, Tokens
36-
from .field import calculate_padding, FieldType
37-
from .native_types import get_native_type
33+
from typing import Any, BinaryIO, Dict, List, Optional, Tuple, Type, Union
34+
35+
from .base import DEFAULT_ENUM_SIZE, ENUM_SIZE_TO_C_TYPE, ENUMS, STRUCTS
36+
from .c_parser import Tokens, parse_enum, parse_enum_def, parse_struct, parse_struct_def
3837
from .exceptions import CStructException, ParserError
38+
from .field import FieldType, calculate_padding
39+
from .native_types import get_native_type
3940

4041
__all__ = ["CStructMeta", "AbstractCStruct", "CEnumMeta", "AbstractCEnum"]
4142

cstruct/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
# IN THE SOFTWARE.
2323
#
2424

25-
from typing import Any, Dict, Type, TYPE_CHECKING
25+
from typing import TYPE_CHECKING, Any, Dict, Type
2626

2727
if TYPE_CHECKING:
28-
from .abstract import AbstractCStruct, AbstractCEnum
28+
from .abstract import AbstractCEnum, AbstractCStruct
2929

3030
__all__ = [
3131
"LITTLE_ENDIAN",

cstruct/c_expr.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424

2525
import ast
2626
import operator
27-
from typing import Any, Callable, Dict, Union, Type, TYPE_CHECKING
27+
from typing import TYPE_CHECKING, Any, Callable, Dict, Type, Union
28+
2829
from .base import DEFINES, STRUCTS
2930
from .exceptions import EvalError
3031

cstruct/c_parser.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,16 @@
2424

2525
import re
2626
from collections import OrderedDict
27-
from typing import Union, Optional, Any, Dict, List, Type, TYPE_CHECKING
28-
from .base import DEFINES, ENUMS, TYPEDEFS, STRUCTS
29-
from .field import calculate_padding, Kind, FieldType
27+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Type, Union
28+
29+
from .base import DEFINES, ENUMS, STRUCTS, TYPEDEFS
3030
from .c_expr import c_eval
3131
from .exceptions import CStructException, ParserError
32+
from .field import FieldType, Kind, calculate_padding
3233
from .native_types import get_native_type
3334

3435
if TYPE_CHECKING:
35-
from .abstract import AbstractCStruct, AbstractCEnum
36+
from .abstract import AbstractCEnum, AbstractCStruct
3637

3738
__all__ = ["parse_struct", "parse_struct_def", "parse_enum_def", "Tokens"]
3839

cstruct/cstruct.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
#
2424

2525
from typing import List, Optional
26-
from .base import CHAR_ZERO
26+
2727
from .abstract import AbstractCStruct
28+
from .base import CHAR_ZERO
2829

2930

3031
class CStruct(AbstractCStruct):

cstruct/field.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
import copy
2626
import struct
2727
from enum import Enum
28-
from typing import Optional, Any, List, Type, TYPE_CHECKING
28+
from typing import TYPE_CHECKING, Any, List, Optional, Type
29+
2930
from .base import NATIVE_ORDER
30-
from .native_types import get_native_type
3131
from .exceptions import ParserError
32+
from .native_types import get_native_type
3233

3334
if TYPE_CHECKING:
3435
from .abstract import AbstractCStruct

cstruct/mem_cstruct.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
# IN THE SOFTWARE.
2323
#
2424

25-
from typing import Any, List, Optional
2625
import ctypes
2726
import struct
27+
from typing import Any, List, Optional
28+
2829
from .abstract import AbstractCStruct
2930

3031

0 commit comments

Comments
 (0)