diff --git a/numcodecs/abc.py b/numcodecs/abc.py index 9fdfd27e..5aba8c25 100644 --- a/numcodecs/abc.py +++ b/numcodecs/abc.py @@ -84,7 +84,7 @@ def get_config(self): # override in sub-class if need special encoding of config values # setup config object - config = dict(id=self.codec_id) + config = {'id': self.codec_id} # by default, assume all non-private members are configuration # parameters - override this in sub-class if not the case diff --git a/numcodecs/categorize.py b/numcodecs/categorize.py index 787c17a5..ed20ad61 100644 --- a/numcodecs/categorize.py +++ b/numcodecs/categorize.py @@ -85,12 +85,12 @@ def decode(self, buf, out=None): return dec def get_config(self): - config = dict( - id=self.codec_id, - labels=self.labels, - dtype=self.dtype.str, - astype=self.astype.str, - ) + config = { + 'id': self.codec_id, + 'labels': self.labels, + 'dtype': self.dtype.str, + 'astype': self.astype.str, + } return config def __repr__(self): diff --git a/numcodecs/delta.py b/numcodecs/delta.py index f6307312..ee4abbc7 100644 --- a/numcodecs/delta.py +++ b/numcodecs/delta.py @@ -91,7 +91,7 @@ def decode(self, buf, out=None): def get_config(self): # override to handle encoding dtypes - return dict(id=self.codec_id, dtype=self.dtype.str, astype=self.astype.str) + return {'id': self.codec_id, 'dtype': self.dtype.str, 'astype': self.astype.str} def __repr__(self): r = f'{type(self).__name__}(dtype={self.dtype.str!r}' diff --git a/numcodecs/fixedscaleoffset.py b/numcodecs/fixedscaleoffset.py index b9f3393a..636e439e 100644 --- a/numcodecs/fixedscaleoffset.py +++ b/numcodecs/fixedscaleoffset.py @@ -116,13 +116,13 @@ def decode(self, buf, out=None): def get_config(self): # override to handle encoding dtypes - return dict( - id=self.codec_id, - scale=self.scale, - offset=self.offset, - dtype=self.dtype.str, - astype=self.astype.str, - ) + return { + 'id': self.codec_id, + 'scale': self.scale, + 'offset': self.offset, + 'dtype': self.dtype.str, + 'astype': self.astype.str, + } def __repr__(self): r = f'{type(self).__name__}(scale={self.scale}, offset={self.offset}, dtype={self.dtype.str!r}' diff --git a/numcodecs/json.py b/numcodecs/json.py index ea3175d5..dc52e1a4 100644 --- a/numcodecs/json.py +++ b/numcodecs/json.py @@ -52,17 +52,17 @@ def __init__( else: separators = ', ', ': ' separators = tuple(separators) - self._encoder_config = dict( - skipkeys=skipkeys, - ensure_ascii=ensure_ascii, - check_circular=check_circular, - allow_nan=allow_nan, - indent=indent, - separators=separators, - sort_keys=sort_keys, - ) + self._encoder_config = { + 'skipkeys': skipkeys, + 'ensure_ascii': ensure_ascii, + 'check_circular': check_circular, + 'allow_nan': allow_nan, + 'indent': indent, + 'separators': separators, + 'sort_keys': sort_keys, + } self._encoder = _json.JSONEncoder(**self._encoder_config) - self._decoder_config = dict(strict=strict) + self._decoder_config = {'strict': strict} self._decoder = _json.JSONDecoder(**self._decoder_config) def encode(self, buf): @@ -89,7 +89,7 @@ def decode(self, buf, out=None): return dec def get_config(self): - config = dict(id=self.codec_id, encoding=self._text_encoding) + config = {'id': self.codec_id, 'encoding': self._text_encoding} config.update(self._encoder_config) config.update(self._decoder_config) return config diff --git a/numcodecs/msgpacks.py b/numcodecs/msgpacks.py index 3f4ea40a..7ba7164f 100644 --- a/numcodecs/msgpacks.py +++ b/numcodecs/msgpacks.py @@ -75,12 +75,12 @@ def decode(self, buf, out=None): return dec def get_config(self): - return dict( - id=self.codec_id, - raw=self.raw, - use_single_float=self.use_single_float, - use_bin_type=self.use_bin_type, - ) + return { + 'id': self.codec_id, + 'raw': self.raw, + 'use_single_float': self.use_single_float, + 'use_bin_type': self.use_bin_type, + } def __repr__(self): return f'MsgPack(raw={self.raw!r}, use_bin_type={self.use_bin_type!r}, use_single_float={self.use_single_float!r})' diff --git a/numcodecs/pickles.py b/numcodecs/pickles.py index 1daec8d6..598368aa 100644 --- a/numcodecs/pickles.py +++ b/numcodecs/pickles.py @@ -49,7 +49,7 @@ def decode(self, buf, out=None): return dec def get_config(self): - return dict(id=self.codec_id, protocol=self.protocol) + return {'id': self.codec_id, 'protocol': self.protocol} def __repr__(self): return f'Pickle(protocol={self.protocol})' diff --git a/numcodecs/quantize.py b/numcodecs/quantize.py index 3594209c..b9a8a311 100644 --- a/numcodecs/quantize.py +++ b/numcodecs/quantize.py @@ -85,12 +85,12 @@ def decode(self, buf, out=None): def get_config(self): # override to handle encoding dtypes - return dict( - id=self.codec_id, - digits=self.digits, - dtype=self.dtype.str, - astype=self.astype.str, - ) + return { + 'id': self.codec_id, + 'digits': self.digits, + 'dtype': self.dtype.str, + 'astype': self.astype.str, + } def __repr__(self): r = f'{type(self).__name__}(digits={self.digits}, dtype={self.dtype.str!r}' diff --git a/numcodecs/tests/test_blosc.py b/numcodecs/tests/test_blosc.py index 95fd4cf1..17b29138 100644 --- a/numcodecs/tests/test_blosc.py +++ b/numcodecs/tests/test_blosc.py @@ -199,12 +199,12 @@ def test_config_blocksize(): # explicitly stated # blocksize not stated - config = dict(cname='lz4', clevel=1, shuffle=Blosc.SHUFFLE) + config = {"cname": 'lz4', "clevel": 1, "shuffle": Blosc.SHUFFLE} codec = Blosc.from_config(config) assert codec.blocksize == 0 # blocksize stated - config = dict(cname='lz4', clevel=1, shuffle=Blosc.SHUFFLE, blocksize=2**8) + config = {"cname": 'lz4', "clevel": 1, "shuffle": Blosc.SHUFFLE, "blocksize": 2**8} codec = Blosc.from_config(config) assert codec.blocksize == 2**8 diff --git a/numcodecs/tests/test_lzma.py b/numcodecs/tests/test_lzma.py index 5e05110c..017f6da6 100644 --- a/numcodecs/tests/test_lzma.py +++ b/numcodecs/tests/test_lzma.py @@ -29,7 +29,7 @@ LZMA(preset=1), LZMA(preset=5), LZMA(preset=9), - LZMA(format=_lzma.FORMAT_RAW, filters=[dict(id=_lzma.FILTER_LZMA2, preset=1)]), + LZMA(format=_lzma.FORMAT_RAW, filters=[{"id": _lzma.FILTER_LZMA2, "preset": 1}]), ] diff --git a/numcodecs/tests/test_registry.py b/numcodecs/tests/test_registry.py index 4a0ba463..3c779df3 100644 --- a/numcodecs/tests/test_registry.py +++ b/numcodecs/tests/test_registry.py @@ -26,7 +26,7 @@ def test_all_classes_registered(): see #346 for more info """ - missing = set( + missing = { obj.codec_id for _, submod in inspect.getmembers(numcodecs, inspect.ismodule) for _, obj in inspect.getmembers(submod) @@ -36,7 +36,7 @@ def test_all_classes_registered(): and obj.codec_id not in numcodecs.registry.codec_registry and obj.codec_id is not None # remove `None` ) - ) + } if missing: raise Exception(f"these codecs are missing: {missing}") # pragma: no cover diff --git a/pyproject.toml b/pyproject.toml index 7c0d1f31..928d901b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -168,6 +168,7 @@ line-length = 100 [tool.ruff.lint] extend-select = [ "B", + "C4", "FLY", "FURB", "G", diff --git a/setup.py b/setup.py index b6db0797..0f5ec481 100644 --- a/setup.py +++ b/setup.py @@ -40,12 +40,12 @@ def info(*msg): - kwargs = dict(file=sys.stdout) + kwargs = {'file': sys.stdout} print('[numcodecs]', *msg, **kwargs) def error(*msg): - kwargs = dict(file=sys.stderr) + kwargs = {'file': sys.stderr} print('[numcodecs]', *msg, **kwargs) @@ -368,7 +368,7 @@ def run_setup(with_extensions): + jenkins_extension() ) - cmdclass = dict(build_ext=ve_build_ext, clean=Sclean) + cmdclass = {'build_ext': ve_build_ext, 'clean': Sclean} else: ext_modules = [] cmdclass = {}