From b866870e34a7e555c61f8fde03613549656f5849 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 22:44:55 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- gufe/compression.py | 2 ++ gufe/custom_codecs.py | 3 +-- gufe/tests/test_custom_json.py | 12 ++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/gufe/compression.py b/gufe/compression.py index 1aade100..2fe3e35e 100644 --- a/gufe/compression.py +++ b/gufe/compression.py @@ -1,10 +1,12 @@ import zstandard as zstd from zstandard import ZstdError + def zst_compress(data: bytes): compressor = zstd.ZstdCompressor() return compressor.compress(data) + def zst_decompress(data: bytes): try: decompressor = zstd.ZstdDecompressor() diff --git a/gufe/custom_codecs.py b/gufe/custom_codecs.py index 62564093..096584cc 100644 --- a/gufe/custom_codecs.py +++ b/gufe/custom_codecs.py @@ -11,11 +11,10 @@ from openff.units import DEFAULT_UNIT_REGISTRY import gufe +from gufe.compression import zst_compress, zst_decompress from gufe.custom_json import JSONCodec from gufe.settings.models import SettingsBaseModel -from gufe.compression import zst_compress, zst_decompress - def default_from_dict(dct): dct = dict(dct) # make a copy diff --git a/gufe/tests/test_custom_json.py b/gufe/tests/test_custom_json.py index 4051c26d..9df52d61 100644 --- a/gufe/tests/test_custom_json.py +++ b/gufe/tests/test_custom_json.py @@ -25,7 +25,7 @@ SETTINGS_CODEC, UUID_CODEC, ) -from gufe.custom_json import JSONSerializerDeserializer, custom_json_factory, JSONCodec +from gufe.custom_json import JSONCodec, JSONSerializerDeserializer, custom_json_factory from gufe.settings import models @@ -106,13 +106,13 @@ def test_legacy_bytes_uncompressed(self): legacy_bytes_codec = JSONCodec( cls=bytes, to_dict=lambda obj: {"latin-1": obj.decode("latin-1")}, - from_dict=lambda dct: dct["latin-1"].encode("latin-1") - ) + from_dict=lambda dct: dct["latin-1"].encode("latin-1"), + ) required_codecs = [codec for codec in self.required_codecs if not codec is BYTES_CODEC] legacy_encoder, _ = custom_json_factory([legacy_bytes_codec, *required_codecs]) - _, decoder= custom_json_factory([BYTES_CODEC, *required_codecs]) + _, decoder = custom_json_factory([BYTES_CODEC, *required_codecs]) self._test_round_trip(legacy_encoder, decoder) @@ -201,13 +201,13 @@ class TestBytesCodec(CustomJSONCodingTest): def setup_method(self): self.codec = BYTES_CODEC self.required_codecs = [self.codec] - self.objs =[b'a test string'] + self.objs = [b"a test string"] self.dcts = [ { ":is_custom:": True, "__class__": "bytes", "__module__": "builtins", - "latin-1": '(µ/ý \ri\x00\x00a test string' + "latin-1": "(µ/ý \ri\x00\x00a test string", } ]