Skip to content

Commit

Permalink
MNT: Bump ruff version
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos committed Mar 5, 2024
1 parent 156455d commit 96846b0
Show file tree
Hide file tree
Showing 131 changed files with 168 additions and 163 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
- id: check-merge-conflict
- id: check-vcs-permalinks
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
rev: v0.3.0
hooks:
- id: ruff
args: [--fix, --show-fix, --exit-non-zero-on-fix]
Expand Down
1 change: 1 addition & 0 deletions nibabel/_compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""Constants and types for dealing transparently with compression"""

from __future__ import annotations

import bz2
Expand Down
1 change: 1 addition & 0 deletions nibabel/affines.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""Utility routines for working with points and affine transforms"""

from functools import reduce

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions nibabel/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
can be loaded with and without a default flip, so the saved zoom will not
constrain the affine.
"""

from __future__ import annotations

import numpy as np
Expand Down
15 changes: 7 additions & 8 deletions nibabel/arrayproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
See :mod:`nibabel.tests.test_proxy_api` for proxy API conformance checks.
"""

from __future__ import annotations

import typing as ty
Expand Down Expand Up @@ -74,21 +75,19 @@ class ArrayLike(ty.Protocol):
shape: tuple[int, ...]

@property
def ndim(self) -> int:
... # pragma: no cover
def ndim(self) -> int: ... # pragma: no cover

# If no dtype is passed, any dtype might be returned, depending on the array-like
@ty.overload
def __array__(self, dtype: None = ..., /) -> np.ndarray[ty.Any, np.dtype[ty.Any]]:
... # pragma: no cover
def __array__(
self, dtype: None = ..., /
) -> np.ndarray[ty.Any, np.dtype[ty.Any]]: ... # pragma: no cover

# Any dtype might be passed, and *that* dtype must be returned
@ty.overload
def __array__(self, dtype: _DType, /) -> np.ndarray[ty.Any, _DType]:
... # pragma: no cover
def __array__(self, dtype: _DType, /) -> np.ndarray[ty.Any, _DType]: ... # pragma: no cover

def __getitem__(self, key, /) -> npt.NDArray:
... # pragma: no cover
def __getitem__(self, key, /) -> npt.NDArray: ... # pragma: no cover


class ArrayProxy(ArrayLike):
Expand Down
1 change: 1 addition & 0 deletions nibabel/arraywriters.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self, array, out_dtype=None)
something else to make sense of conversions between float and int, or between
larger ints and smaller.
"""

import numpy as np

from .casting import best_float, floor_exact, int_abs, shared_range, type_info
Expand Down
3 changes: 1 addition & 2 deletions nibabel/benchmarks/butils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Benchmarking utilities
"""
"""Benchmarking utilities"""

from .. import get_info

Expand Down
1 change: 1 addition & 0 deletions nibabel/brikhead.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
am aware) always be >= 1. This permits sub-brick indexing common in AFNI
programs (e.g., example4d+orig'[0]').
"""

import os
import re
from copy import deepcopy
Expand Down
1 change: 1 addition & 0 deletions nibabel/casting.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Most routines work round some numpy oddities in floating point precision and
casting. Others work round numpy casting to and from python ints
"""

from __future__ import annotations

import warnings
Expand Down
1 change: 1 addition & 0 deletions nibabel/cifti2/cifti2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
http://www.nitrc.org/projects/cifti
"""

import re
from collections import OrderedDict
from collections.abc import Iterable, MutableMapping, MutableSequence
Expand Down
1 change: 1 addition & 0 deletions nibabel/cifti2/cifti2_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
... bm_cortex)))
<class 'nibabel.cifti2.cifti2.Cifti2Header'>
"""

import abc
from operator import xor

Expand Down
4 changes: 2 additions & 2 deletions nibabel/cifti2/tests/test_cifti2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Testing CIFTI-2 objects
"""
"""Testing CIFTI-2 objects"""

import collections
from xml.etree import ElementTree

Expand Down
1 change: 1 addition & 0 deletions nibabel/cifti2/tests/test_new_cifti2.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
These functions are used in the tests to generate most CIFTI file types from
scratch.
"""

import numpy as np
import pytest

Expand Down
3 changes: 1 addition & 2 deletions nibabel/cmdline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
# copyright and license terms.
#
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""Functionality to be exposed in the command line
"""
"""Functionality to be exposed in the command line"""
6 changes: 3 additions & 3 deletions nibabel/cmdline/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ def get_data_diff(files, max_abs=0, max_rel=0, dtype=np.float64):
sub_thr = rel_diff <= max_rel
# Since we operated on sub-selected values already, we need
# to plug them back in
candidates[
tuple(indexes[sub_thr] for indexes in np.where(candidates))
] = False
candidates[tuple(indexes[sub_thr] for indexes in np.where(candidates))] = (
False
)
max_rel_diff = np.max(rel_diff)
else:
max_rel_diff = 0
Expand Down
3 changes: 1 addition & 2 deletions nibabel/cmdline/parrec2nii.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Code for PAR/REC to NIfTI converter command
"""
"""Code for PAR/REC to NIfTI converter command"""

import csv
import os
Expand Down
1 change: 1 addition & 0 deletions nibabel/cmdline/tck2trk.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Convert tractograms (TCK -> TRK).
"""

import argparse
import os

Expand Down
4 changes: 2 additions & 2 deletions nibabel/cmdline/tests/test_parrec2nii.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Tests for the parrec2nii exe code
"""
"""Tests for the parrec2nii exe code"""

from os.path import basename, isfile, join
from unittest.mock import MagicMock, Mock, patch

Expand Down
1 change: 0 additions & 1 deletion nibabel/cmdline/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
Helper utilities to be used in cmdline applications
"""


# global verbosity switch
import re
from io import StringIO
Expand Down
1 change: 1 addition & 0 deletions nibabel/data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""Utilities to find files from NIPY data packages"""

import configparser
import glob
import os
Expand Down
1 change: 1 addition & 0 deletions nibabel/dataobj_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* returns an array from ``numpy.asanyarray(obj)``;
* has an attribute or property ``shape``.
"""

from __future__ import annotations

import typing as ty
Expand Down
1 change: 1 addition & 0 deletions nibabel/deprecated.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module to help with deprecating objects and classes"""

from __future__ import annotations

import typing as ty
Expand Down
1 change: 1 addition & 0 deletions nibabel/deprecator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Class for recording and reporting deprecations"""

from __future__ import annotations

import functools
Expand Down
2 changes: 0 additions & 2 deletions nibabel/dft.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# Copyright (C) 2011 Christian Haselgrove
"""DICOM filesystem tools"""


import contextlib
import getpass
import logging
Expand Down Expand Up @@ -44,7 +43,6 @@ class VolumeError(DFTError):


class InstanceStackError(DFTError):

"""bad series of instance numbers"""

def __init__(self, series, i, si):
Expand Down
1 change: 1 addition & 0 deletions nibabel/ecat.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
GPL and some of the header files are adapted from CTI files (called CTI code
below). It's not clear what the licenses are for these files.
"""

import warnings
from numbers import Integral

Expand Down
1 change: 1 addition & 0 deletions nibabel/environment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""Settings from the system environment relevant to NIPY"""

import os
from os.path import join as pjoin

Expand Down
1 change: 1 addition & 0 deletions nibabel/eulerangles.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
``y``, followed by rotation around ``x``, is known (confusingly) as
"xyz", pitch-roll-yaw, Cardan angles, or Tait-Bryan angles.
"""

import math
from functools import reduce

Expand Down
1 change: 1 addition & 0 deletions nibabel/filebasedimages.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""Common interface for any image format--volume or surface, binary or xml"""

from __future__ import annotations

import io
Expand Down
1 change: 1 addition & 0 deletions nibabel/fileholders.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""Fileholder class"""

from __future__ import annotations

import io
Expand Down
1 change: 1 addition & 0 deletions nibabel/filename_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""Create filename pairs, triplets etc, with expected extensions"""

from __future__ import annotations

import os
Expand Down
1 change: 1 addition & 0 deletions nibabel/fileslice.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities for getting array slices out of file-like objects"""

import operator
from functools import reduce
from mmap import mmap
Expand Down
3 changes: 1 addition & 2 deletions nibabel/freesurfer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Reading functions for freesurfer files
"""
"""Reading functions for freesurfer files"""

# ruff: noqa: F401

Expand Down
3 changes: 1 addition & 2 deletions nibabel/freesurfer/io.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Read / write FreeSurfer geometry, morphometry, label, annotation formats
"""
"""Read / write FreeSurfer geometry, morphometry, label, annotation formats"""

import getpass
import time
Expand Down
1 change: 1 addition & 0 deletions nibabel/freesurfer/mghformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Author: Krish Subramaniam
"""

from os.path import splitext

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions nibabel/funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""Processor functions for images"""

import numpy as np

from .loadsave import load
Expand Down
1 change: 1 addition & 0 deletions nibabel/gifti/gifti.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
The Gifti specification was (at time of writing) available as a PDF download
from http://www.nitrc.org/projects/gifti/
"""

from __future__ import annotations

import base64
Expand Down
4 changes: 2 additions & 2 deletions nibabel/gifti/tests/test_gifti.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Testing gifti objects
"""
"""Testing gifti objects"""

import itertools
import sys
from io import BytesIO
Expand Down
1 change: 1 addition & 0 deletions nibabel/imageclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""Define supported image classes and names"""

from __future__ import annotations

from .analyze import AnalyzeImage
Expand Down
1 change: 1 addition & 0 deletions nibabel/imageglobals.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Use ``logger.level = 1`` to see all messages.
"""

import logging

error_level = 40
Expand Down
1 change: 1 addition & 0 deletions nibabel/imagestats.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""Functions for computing image statistics"""

import numpy as np

from nibabel.imageclasses import spatial_axes_first
Expand Down
1 change: 1 addition & 0 deletions nibabel/loadsave.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
# module imports
"""Utilities to load and save image objects"""

from __future__ import annotations

import os
Expand Down
1 change: 1 addition & 0 deletions nibabel/minc1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""Read MINC1 format images"""

from __future__ import annotations

from numbers import Integral
Expand Down
1 change: 1 addition & 0 deletions nibabel/minc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
mincstats my_funny.mnc
"""

import warnings

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions nibabel/nicom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
dwiparams
structreader
"""

import warnings

warnings.warn(
Expand Down
1 change: 1 addition & 0 deletions nibabel/nicom/ascconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
Parse the "ASCCONV" meta data format found in a variety of Siemens MR files.
"""

import ast
import re
from collections import OrderedDict
Expand Down
4 changes: 2 additions & 2 deletions nibabel/nicom/csareader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""CSA header reader from SPM spec
"""
"""CSA header reader from SPM spec"""

import numpy as np

from .structreader import Unpacker
Expand Down
Loading

0 comments on commit 96846b0

Please sign in to comment.