From c32ccb61a930f137ca40630793e96d4fe997cc04 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Fri, 29 Sep 2023 14:33:15 +0200 Subject: [PATCH] Simpler isinstance() calls Supporting Python < 3.10 requires: isinstance(x, (A, B)) instead of: isinstance(x, A | B) --- cramjam-python/benchmarks/test_bench.py | 2 +- cramjam-python/tests/test_rust_io.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cramjam-python/benchmarks/test_bench.py b/cramjam-python/benchmarks/test_bench.py index ae324da1..3bdcb7c3 100644 --- a/cramjam-python/benchmarks/test_bench.py +++ b/cramjam-python/benchmarks/test_bench.py @@ -211,7 +211,7 @@ def test_lz4_block(benchmark, file, use_cramjam: bool): [ f for f in FILES - if not (isinstance(f, FiftyFourMbRandom) or isinstance(f, FiftyFourMbRepeating)) + if not (isinstance(f, (FiftyFourMbRandom, FiftyFourMbRepeating)) ], ids=lambda val: val.name, ) diff --git a/cramjam-python/tests/test_rust_io.py b/cramjam-python/tests/test_rust_io.py index 29ca8e9c..c8f695be 100644 --- a/cramjam-python/tests/test_rust_io.py +++ b/cramjam-python/tests/test_rust_io.py @@ -35,7 +35,7 @@ def test_obj_api(tmpdir, Obj): buf.readinto(out) # Will update the output buffer - if isinstance(out, File) or isinstance(out, Buffer): + if isinstance(out, (File, Buffer)): out.seek(0) assert out.read() == expected elif isinstance(out, bytearray):