Skip to content

Commit 653fd80

Browse files
STY: Apply ruff rule RUF021
RUF021 Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear
1 parent f66a572 commit 653fd80

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

nibabel/cifti2/cifti2_axes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,10 @@ def __eq__(self, other):
634634
return (
635635
(
636636
self.affine is None
637-
or np.allclose(self.affine, other.affine)
638-
and self.volume_shape == other.volume_shape
637+
or (
638+
np.allclose(self.affine, other.affine)
639+
and self.volume_shape == other.volume_shape
640+
)
639641
)
640642
and self.nvertices == other.nvertices
641643
and np.array_equal(self.name, other.name)

nibabel/cmdline/dicomfs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def main(args=None):
231231

232232
if opts.verbose:
233233
logger.addHandler(logging.StreamHandler(sys.stdout))
234-
logger.setLevel(opts.verbose > 1 and logging.DEBUG or logging.INFO)
234+
logger.setLevel((opts.verbose > 1 and logging.DEBUG) or logging.INFO)
235235

236236
if len(files) != 2:
237237
sys.stderr.write(f'Please provide two arguments:\n{parser.usage}\n')

nibabel/tests/test_nifti1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ def test_slice_times(self):
538538
hdr.set_slice_duration(0.1)
539539
# We need a function to print out the Nones and floating point
540540
# values in a predictable way, for the tests below.
541-
_stringer = lambda val: val is not None and f'{val:2.1f}' or None
541+
_stringer = lambda val: (val is not None and f'{val:2.1f}') or None
542542
_print_me = lambda s: list(map(_stringer, s))
543543
# The following examples are from the nifti1.h documentation.
544544
hdr['slice_code'] = slice_order_codes['sequential increasing']

nibabel/volumeutils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
DT = ty.TypeVar('DT', bound=np.generic)
3636

3737
sys_is_le = sys.byteorder == 'little'
38-
native_code = sys_is_le and '<' or '>'
39-
swapped_code = sys_is_le and '>' or '<'
38+
native_code = (sys_is_le and '<') or '>'
39+
swapped_code = (sys_is_le and '>') or '<'
4040

4141
_endian_codes = ( # numpy code, aliases
4242
('<', 'little', 'l', 'le', 'L', 'LE'),

0 commit comments

Comments
 (0)