Skip to content

Commit 6e17ae2

Browse files
committed
configure ruff
1 parent abd7527 commit 6e17ae2

4 files changed

Lines changed: 17 additions & 26 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ jobs:
3333
- uses: astral-sh/setup-uv@v6
3434
- name: Lint
3535
run: |
36-
uvx ruff check
36+
uv run ruff check --no-fix

ruff.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
line-length = 100
3+
fix = true
4+
5+
[lint]
6+
select = ["I"]

scripts/bench.py

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ def serialize_other(obj, mapped):
7171
if __name__ == "__main__":
7272
parser = argparse.ArgumentParser()
7373
parser.add_argument("-n", "--number", type=int, default=25, help="Number of runs")
74-
parser.add_argument(
75-
"-m", "--mapped", action="store_true", help="Use memory mapping"
76-
)
74+
parser.add_argument("-m", "--mapped", action="store_true", help="Use memory mapping")
7775
args = parser.parse_args()
7876

7977
_globals = {
@@ -99,22 +97,10 @@ def serialize_other(obj, mapped):
9997
print(f"stream: {t_stream:.6f}s total, {t_stream / args.number:.6f}s per call")
10098
print(f"other: {t_other:.6f}s total, {t_other / args.number:.6f}s per call")
10199

102-
t_main_s = timeit.timeit(
103-
"main(obj, mapped)", number=args.number, globals=_serialize
104-
)
105-
t_stream_s = timeit.timeit(
106-
"stream(obj, mapped)", number=args.number, globals=_serialize
107-
)
108-
t_other_s = timeit.timeit(
109-
"other(obj, mapped)", number=args.number, globals=_serialize
110-
)
111-
112-
print(
113-
f"main serialize: {t_main_s:.6f}s total, {t_main_s / args.number:.6f}s per call"
114-
)
115-
print(
116-
f"stream serialize: {t_stream_s:.6f}s total, {t_stream_s / args.number:.6f}s per call"
117-
)
118-
print(
119-
f"other serialize: {t_other_s:.6f}s total, {t_other_s / args.number:.6f}s per call"
120-
)
100+
t_main_s = timeit.timeit("main(obj, mapped)", number=args.number, globals=_serialize)
101+
t_stream_s = timeit.timeit("stream(obj, mapped)", number=args.number, globals=_serialize)
102+
t_other_s = timeit.timeit("other(obj, mapped)", number=args.number, globals=_serialize)
103+
104+
print(f"main serialize: {t_main_s:.6f}s total, {t_main_s / args.number:.6f}s per call")
105+
print(f"stream serialize: {t_stream_s:.6f}s total, {t_stream_s / args.number:.6f}s per call")
106+
print(f"other serialize: {t_other_s:.6f}s total, {t_other_s / args.number:.6f}s per call")

src/msgpack_stream/_msgpack.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,7 @@ def pack_stream(stream, obj):
174174
stream.write(b"\xd7\xff" + u64_b_pack(data64))
175175
else:
176176
# timestamp96
177-
stream.write(
178-
b"\xc7\x0c\xff" + u32_b_pack(nanoseconds) + s64_b_pack(seconds)
179-
)
177+
stream.write(b"\xc7\x0c\xff" + u32_b_pack(nanoseconds) + s64_b_pack(seconds))
180178
elif _type is ExtType: # ext
181179
data = obj.data
182180
p_code = s8_b_pack(obj.code)
@@ -316,5 +314,6 @@ def unpack_stream(stream):
316314
ml = u32_b_unpack(stream) # map32
317315
obj = {unpack_stream(stream): unpack_stream(stream) for _ in range(ml)}
318316
else:
317+
# unreachable
319318
raise ValueError("invalid first byte", first_byte, hex(first_byte))
320319
return obj

0 commit comments

Comments
 (0)