Skip to content

Commit ecd1d2a

Browse files
committed
format with ruff
1 parent 8f71a0c commit ecd1d2a

File tree

5 files changed

+26
-27
lines changed

5 files changed

+26
-27
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ C-style structs for Python
77
[![PyPI version](https://badge.fury.io/py/cstruct.svg)](https://badge.fury.io/py/cstruct)
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)
10-
[![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/)
10+
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
1211
[![Known Vulnerabilities](https://snyk.io/test/github/andreax79/python-cstruct/badge.svg)](https://snyk.io/test/github/andreax79/python-cstruct)
1312
[![Documentation](https://readthedocs.org/projects/python-cstruct/badge/?version=latest)](https://python-cstruct.readthedocs.io/en/latest/)
1413

examples/fdisk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import cstruct
88

9-
UNITS = ['B', 'K', 'M', 'G', 'T']
9+
UNITS = ["B", "K", "M", "G", "T"]
1010
SECTOR_SIZE = 512
1111
TYPES = {
1212
0x00: "Empty",
@@ -129,7 +129,7 @@ def disk_signature_str(self):
129129

130130
def print_info(self):
131131
print(f"Sector size: {cstruct.getdef('MBR_SIZE')}")
132-
if self.signature != cstruct.getdef('MBR_BOOT_SIGNATURE'):
132+
if self.signature != cstruct.getdef("MBR_BOOT_SIGNATURE"):
133133
print("Invalid MBR signature")
134134

135135
print(f"Disk identifier: 0x{self.disk_signature_str}")

examples/who.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def __str__(self):
110110
return f"{self.user:<10s} {self.line:<12s} {self.time:<15s} {self.ut_pid:>15} {self.host:<8s}"
111111

112112
def print_info(self, show_all):
113-
if show_all or self.ut_type in (getdef('LOGIN_PROCESS'), getdef('USER_PROCESS')):
113+
if show_all or self.ut_type in (getdef("LOGIN_PROCESS"), getdef("USER_PROCESS")):
114114
print(self)
115115

116116

tests/test_cstruct_var.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Struct3(cstruct.MemCStruct):
8080

8181

8282
def test_v():
83-
assert c_eval('10') == 10
83+
assert c_eval("10") == 10
8484

8585
s0 = Struct0()
8686
assert len(s0) == 10

tests/test_nested.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -255,21 +255,21 @@ def test_nested_struct_offset():
255255
)
256256

257257
o = Op()
258-
o.preamble = b'ciao_ciao'
258+
o.preamble = b"ciao_ciao"
259259
o.magic = 3771778641802345472
260260
o.u1.a_op.a = 2022
261261
o.aaa.a = 0x33333333
262-
assert o.u1.b_op.a == b'\xe6'
263-
assert o.u1.b_op.b == b'\x07'
264-
assert o.u1.b_op.c == b'\x00'
262+
assert o.u1.b_op.a == b"\xe6"
263+
assert o.u1.b_op.b == b"\x07"
264+
assert o.u1.b_op.c == b"\x00"
265265
assert o.__base__ == 0
266266
assert o.u1.__base__ >= 10
267267
assert o.u1.__base__ == o.u1.a_op.__base__
268268
assert o.u1.__base__ == o.u1.b_op.__base__
269269
assert o.aaa.__base__ > o.u1.__base__
270-
assert o.pack() == b'ciao_ciao\x00\x00\xbc\x08\xe4\xb0\x0cX4\xe6\x07\x00\x003333'
271-
assert o.u1.pack() == b'\xe6\x07\x00\x00'
272-
assert o.aaa.pack() == b'3333'
270+
assert o.pack() == b"ciao_ciao\x00\x00\xbc\x08\xe4\xb0\x0cX4\xe6\x07\x00\x003333"
271+
assert o.u1.pack() == b"\xe6\x07\x00\x00"
272+
assert o.aaa.pack() == b"3333"
273273
assert o.u1.a_op.inspect() == "00000000 e6 07 00 00 |.... |\n"
274274
assert o.u1.b_op.inspect() == "00000000 e6 07 00 |... |\n"
275275

@@ -306,41 +306,41 @@ def test_nested_anonymous_struct_offset():
306306
)
307307

308308
o = Opu()
309-
o.preamble = b'ciao_ciao'
309+
o.preamble = b"ciao_ciao"
310310
o.magic = 3771778641802345472
311311
o.__anonymous0.a_op.a = 2022
312312
o.aaa.a = 0x33333333
313-
assert o.__anonymous0.b_op.a == b'\xe6'
314-
assert o.__anonymous0.b_op.b == b'\x07'
315-
assert o.__anonymous0.b_op.c == b'\x00'
313+
assert o.__anonymous0.b_op.a == b"\xe6"
314+
assert o.__anonymous0.b_op.b == b"\x07"
315+
assert o.__anonymous0.b_op.c == b"\x00"
316316
assert o.__base__ == 0
317317
assert o.__anonymous0.__base__ >= 10
318318
assert o.__anonymous0.__base__ == o.__anonymous0.a_op.__base__
319319
assert o.__anonymous0.__base__ == o.__anonymous0.b_op.__base__
320320
assert o.aaa.__base__ > o.__anonymous0.__base__
321-
assert o.pack() == b'ciao_ciao\x00\x00\xbc\x08\xe4\xb0\x0cX4\xe6\x07\x00\x003333'
322-
assert o.__anonymous0.pack() == b'\xe6\x07\x00\x00'
323-
assert o.aaa.pack() == b'3333'
321+
assert o.pack() == b"ciao_ciao\x00\x00\xbc\x08\xe4\xb0\x0cX4\xe6\x07\x00\x003333"
322+
assert o.__anonymous0.pack() == b"\xe6\x07\x00\x00"
323+
assert o.aaa.pack() == b"3333"
324324
assert o.__anonymous0.inspect() == "00000000 e6 07 00 00 |.... |\n"
325325
assert o.__anonymous0.a_op.inspect() == "00000000 e6 07 00 00 |.... |\n"
326326
assert o.__anonymous0.b_op.inspect() == "00000000 e6 07 00 |... |\n"
327327

328328
o = Opu()
329-
o.preamble = b'ciao_ciao'
329+
o.preamble = b"ciao_ciao"
330330
o.magic = 3771778641802345472
331331
o.a_op.a = 2022
332332
o.aaa.a = 0x33333333
333-
assert o.b_op.a == b'\xe6'
334-
assert o.b_op.b == b'\x07'
335-
assert o.b_op.c == b'\x00'
333+
assert o.b_op.a == b"\xe6"
334+
assert o.b_op.b == b"\x07"
335+
assert o.b_op.c == b"\x00"
336336
assert o.__base__ == 0
337337
assert o.__anonymous0.__base__ >= 10
338338
assert o.__anonymous0.__base__ == o.a_op.__base__
339339
assert o.__anonymous0.__base__ == o.b_op.__base__
340340
assert o.aaa.__base__ > o.__base__
341-
assert o.pack() == b'ciao_ciao\x00\x00\xbc\x08\xe4\xb0\x0cX4\xe6\x07\x00\x003333'
342-
assert o.a_op.pack() == b'\xe6\x07\x00\x00'
343-
assert o.aaa.pack() == b'3333'
341+
assert o.pack() == b"ciao_ciao\x00\x00\xbc\x08\xe4\xb0\x0cX4\xe6\x07\x00\x003333"
342+
assert o.a_op.pack() == b"\xe6\x07\x00\x00"
343+
assert o.aaa.pack() == b"3333"
344344
assert o.a_op.inspect() == "00000000 e6 07 00 00 |.... |\n"
345345
assert o.b_op.inspect() == "00000000 e6 07 00 |... |\n"
346346

0 commit comments

Comments
 (0)