Skip to content

Commit

Permalink
codespell
Browse files Browse the repository at this point in the history
  • Loading branch information
andreax79 committed Sep 27, 2024
1 parent 19bbf49 commit 1236e1e
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 8 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ help:
@echo - make typecheck -- Typecheck
@echo - make venv ------- Create virtual environment

.PHONY: isort
codespell:
@codespell -w cstruct tests examples setup.py

.PHONY: isort
isort:
@isort --profile black cstruct tests examples setup.py
Expand Down Expand Up @@ -46,6 +50,6 @@ typecheck:
mypy --strict --no-warn-unused-ignores cstruct

venv:
python3 -m virtualenv .
python3 -m venv . || python3 -m virtualenv .
. bin/activate; pip install -Ur requirements.txt
. bin/activate; pip install -Ur requirements-dev.txt
6 changes: 3 additions & 3 deletions cstruct/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ class AbstractCStruct(metaclass=CStructMeta):
__size__: int = 0
" Size in bytes "
__fields__: List[str] = []
" Struct/union fileds "
" Struct/union fields "
__fields_types__: Dict[str, FieldType]
" Dictionary mapping field names to types "
__byte_order__: Optional[str] = None
" Byte order "
__alignment__: int = 0
" Alignament "
" Alignment "
__is_union__: bool = False
" True if the class is an union, False if it is a struct "

Expand Down Expand Up @@ -125,7 +125,7 @@ def parse(
__is_union__: True for union, False for struct
Returns:
cls: a new class mapping the defintion
cls: a new class mapping the definition
"""
cls_kargs: Dict[str, Any] = dict(kargs)
if __byte_order__ is not None:
Expand Down
2 changes: 1 addition & 1 deletion cstruct/c_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def parse_struct(
for nested_field_name, nested_field_type in field_type.ref.__fields_types__.items():
if nested_field_name in fields_types:
raise ParserError(f"Duplicate member `{nested_field_name}`")
# set the corret offset
# set the correct offset
nested_field_type = nested_field_type.copy()
nested_field_type.base_offset = offset + nested_field_type.base_offset
nested_field_type.offset = offset + nested_field_type.offset
Expand Down
2 changes: 1 addition & 1 deletion cstruct/cstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def unpack_from(self, buffer: Optional[bytes], offset: int = 0, flexible_array_l
Args:
buffer: bytes to be unpacked
offset: optional buffer offset
flexible_array_length: optional flexible array lenght (number of elements)
flexible_array_length: optional flexible array length (number of elements)
"""
self.set_flexible_array_length(flexible_array_length)
if buffer is None:
Expand Down
2 changes: 1 addition & 1 deletion cstruct/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def native_format(self) -> str:
try:
return get_native_type(self.c_type).native_format
except KeyError:
raise ParserError(f"Unknow type `{self.c_type}`")
raise ParserError(f"Unknown type `{self.c_type}`")
elif self.is_enum:
return self.ref.__native_format__
else:
Expand Down
2 changes: 1 addition & 1 deletion cstruct/mem_cstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def unpack_from(self, buffer: Optional[bytes], offset: int = 0, flexible_array_l
Args:
buffer: bytes to be unpacked
offset: optional buffer offset
flexible_array_length: optional flexible array lenght (number of elements)
flexible_array_length: optional flexible array length (number of elements)
"""
self.set_flexible_array_length(flexible_array_length)
self.__base__ = offset # Base offset
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
black
build
codespell
coverage[toml]
flake8
isort
Expand Down

0 comments on commit 1236e1e

Please sign in to comment.