Skip to content

Commit 552d1e3

Browse files
committed
chore: replace flake8 with ruff
1 parent 4ec6837 commit 552d1e3

File tree

5 files changed

+95
-200
lines changed

5 files changed

+95
-200
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
run_tests:
22
pytest --cov=pyais tests/
33

4-
flake:
5-
flake8
4+
ruff:
5+
ruff check
66

77
.PHONY: build
88
build:
@@ -26,7 +26,7 @@ clean:
2626
ensure-no-print:
2727
grep -r --exclude ais_encode.py --exclude ais_decode.py --exclude '*.pyc' -i 'print(' ./pyais && (echo "Debug print statement found"; exit 1)||true
2828

29-
test: run_tests flake type-check ensure-no-print
29+
test: run_tests ruff type-check ensure-no-print
3030

3131
install:
3232
pip install -U setuptools wheel build

pyais/messages.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -744,13 +744,13 @@ def to_bitarray(self) -> bitarray:
744744

745745
if d_type in (bool, int):
746746
bits = int_to_bin(val, width, signed=signed)
747-
elif d_type == float:
747+
elif d_type is float:
748748
val = int(val)
749749
bits = int_to_bin(val, width, signed=signed)
750-
elif d_type == str:
750+
elif d_type is str:
751751
trailing_spaces = not variable_length
752752
bits = str_to_bin(val, width, trailing_spaces=trailing_spaces)
753-
elif d_type == bytes:
753+
elif d_type is bytes:
754754
bits = bytes2bits(val, default=bitarray('0' * width))
755755
else:
756756
raise InvalidDataTypeException(d_type)
@@ -816,21 +816,21 @@ def from_bitarray(cls, bit_arr: bitarray) -> "ANY_MESSAGE":
816816

817817
val: typing.Any
818818
# Get the correct data type and decoding function
819-
if d_type == int or d_type == bool or d_type == float:
819+
if d_type is int or d_type is bool or d_type is float:
820820
shift = (8 - ((end - cur) % 8)) % 8
821821
if field.metadata['signed']:
822822
val = from_bytes_signed(bits) >> shift
823823
else:
824824
val = from_bytes(bits) >> shift
825825

826-
if d_type == float:
826+
if d_type is float:
827827
val = float(val)
828-
elif d_type == bool:
828+
elif d_type is bool:
829829
val = bool(val)
830830

831-
elif d_type == str:
831+
elif d_type is str:
832832
val = decode_bin_as_ascii6(bits)
833-
elif d_type == bytes:
833+
elif d_type is bytes:
834834
val = bits2bytes(bits)
835835
else:
836836
raise InvalidDataTypeException(d_type)

pyais/util.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def b64encode_str(val: bytes, encoding: str = 'utf-8') -> str:
231231

232232
def coerce_val(val: typing.Any, d_type: typing.Type[T]) -> T:
233233
"""Forces a given value in a given datatype"""
234-
if d_type == bytes and not isinstance(val, bytes):
234+
if d_type is bytes and not isinstance(val, bytes):
235235
raise ValueError(f"Expected bytes, but got: {type(val)}")
236236

237237
return d_type(val) # type: ignore
@@ -417,7 +417,6 @@ def get_itdma_comm_state(radio: int) -> Dict[str, typing.Optional[int]]:
417417
'sync_state': sync_state,
418418
'slot_increment': slot_increment,
419419
'num_slots': num_slots,
420-
'keep_flag': keep_flag,
421420
}
422421

423422

pyproject.toml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ dependencies = [
3535
"attrs"
3636
]
3737

38-
[project.optional-dependencies]
39-
dev = ['mypy', 'flake8', 'coverage', 'twine', 'sphinx', 'pytest', 'pytest-cov']
40-
4138
[project.urls]
4239
"Homepage" = "https://github.com/M0r13n/pyais"
4340
"Source" = "https://github.com/M0r13n/pyais"
@@ -54,5 +51,16 @@ packages = ["pyais"]
5451
requires = ["setuptools>=43.0.0", "wheel"]
5552
build-backend = "setuptools.build_meta"
5653

54+
[dependency-groups]
55+
dev = [
56+
"coverage>=7.6.1",
57+
"mypy>=1.14.1",
58+
"pytest>=8.3.5",
59+
"pytest-cov>=5.0.0",
60+
"ruff>=0.12.4",
61+
"sphinx>=7.1.2",
62+
"twine>=6.1.0",
63+
]
64+
5765
[tool.setuptools.dynamic]
5866
version = {attr = "pyais.__version__"}

0 commit comments

Comments
 (0)