Skip to content

Commit 2d0040d

Browse files
committed
STY: More style fixes
1 parent 24f8b52 commit 2d0040d

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

nibabel/_compression.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
try:
1919
from compression import zstd # type: ignore[import-not-found]
20+
2021
HAVE_ZSTD = True
2122
except ImportError: # PY313
2223
HAVE_ZSTD = False
@@ -25,11 +26,11 @@
2526
from .optpkg import optional_package
2627

2728
if ty.TYPE_CHECKING:
28-
2929
import indexed_gzip # type: ignore[import]
3030

3131
if not HAVE_ZSTD: # PY313
3232
from backports import zstd # type: ignore[import]
33+
3334
HAVE_ZSTD = True
3435

3536
HAVE_INDEXED_GZIP = True
@@ -70,7 +71,6 @@
7071
COMPRESSION_ERRORS += (zstd.ZstdError,)
7172

7273

73-
7474
class DeterministicGzipFile(gzip.GzipFile):
7575
"""Deterministic variant of GzipFile
7676
@@ -107,6 +107,7 @@ def __init__(
107107
mtime=mtime,
108108
)
109109

110+
110111
def gzip_open(
111112
filename: str,
112113
mode: Mode = 'rb',
@@ -154,10 +155,10 @@ def zstd_open(
154155
filename: str,
155156
mode: Mode = 'r',
156157
*,
157-
level : int | None = None,
158-
options : dict | None = None,
158+
level: int | None = None,
159+
options: dict | None = None,
159160
zstd_dict: zstd.ZstdDict | None = None,
160-
level_or_option: int | dict | None = None
161+
level_or_option: int | dict | None = None,
161162
) -> zstd.ZstdFile:
162163
"""Open a zstd file for reading or writing.
163164
@@ -180,25 +181,21 @@ def zstd_open(
180181
"""
181182
if level_or_option is not None:
182183
alert_future_error(
183-
'The level_or_option parameter will be removed in a future '
184-
'version of nibabel',
184+
'The level_or_option parameter will be removed in a future version of nibabel',
185185
'7.0',
186186
warning_rec='This warning can be silenced by using the separate '
187187
'level/option parameters',
188-
error_rec='Future errors can be avoided by using the separate '
189-
'level/option parameters',
190-
error_class=TypeError)
191-
level_or_option_provided = sum((level_or_option is not None,
192-
level is not None,
193-
options is not None))
188+
error_rec='Future errors can be avoided by using the separate level/option parameters',
189+
error_class=TypeError,
190+
)
191+
level_or_option_provided = sum(
192+
(level_or_option is not None, level is not None, options is not None)
193+
)
194194
if level_or_option_provided > 1:
195-
raise ValueError(
196-
'Only one of level_or_option, level or options may be '
197-
'specified')
195+
raise ValueError('Only one of level_or_option, level or options may be specified')
198196
if level_or_option is not None:
199197
if isinstance(level_or_option, int):
200198
level = level_or_option
201199
else:
202200
options = level_or_option
203-
return zstd.ZstdFile(
204-
filename, mode, level=level, options=options, zstd_dict=zstd_dict)
201+
return zstd.ZstdFile(filename, mode, level=level, options=options, zstd_dict=zstd_dict)

nibabel/openers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ def __init__(self, fileish: str | io.IOBase, *args, **kwargs):
9999
if 'compresslevel' in arg_names and 'compresslevel' not in kwargs:
100100
kwargs['compresslevel'] = self.default_compresslevel
101101
# Default zstd compression level
102-
if ('level' in arg_names and 'level' not in kwargs and
103-
'option' not in kwargs):
102+
if 'level' in arg_names and 'level' not in kwargs and 'option' not in kwargs:
104103
kwargs['level'] = self.default_zst_level[mode]
105104
# Default keep_open hint
106105
if 'keep_open' in arg_names:

0 commit comments

Comments
 (0)