Skip to content

Commit

Permalink
fix: RUF012 fixes across codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
synchon committed Jun 21, 2023
1 parent cf1e336 commit 69f8ad1
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 29 deletions.
4 changes: 2 additions & 2 deletions junifer/markers/ets_rss.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Synchon Mandal <s.mandal@fz-juelich.de>
# License: AGPL

from typing import Any, Dict, List, Optional, Union
from typing import Any, ClassVar, Dict, List, Optional, Set, Union

import numpy as np

Expand Down Expand Up @@ -42,7 +42,7 @@ class RSSETSMarker(BaseMarker):
"""

_DEPENDENCIES = {"nilearn"}
_DEPENDENCIES: ClassVar[Set[str]] = {"nilearn"}

def __init__(
self,
Expand Down
6 changes: 4 additions & 2 deletions junifer/markers/falff/falff_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# License: AGPL

from abc import abstractmethod
from typing import Dict, List, Optional
from typing import ClassVar, Dict, List, Optional, Union

from ...utils.logging import raise_error
from ..base import BaseMarker
Expand Down Expand Up @@ -44,7 +44,9 @@ class ALFFBase(BaseMarker):
"""

_EXT_DEPENDENCIES = [
_EXT_DEPENDENCIES: ClassVar[
List[Dict[str, Union[str, bool, List[str]]]]
] = [
{
"name": "afni",
"optional": True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Kaustubh R. Patil <k.patil@fz-juelich.de>
# License: AGPL

from typing import Any, Dict, List, Optional, Union
from typing import Any, ClassVar, Dict, List, Optional, Set, Union

import pandas as pd

Expand Down Expand Up @@ -39,7 +39,7 @@ class CrossParcellationFC(BaseMarker):
(default None).
"""

_DEPENDENCIES = {"nilearn"}
_DEPENDENCIES: ClassVar[Set[str]] = {"nilearn"}

def __init__(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


from abc import abstractmethod
from typing import Any, Dict, List, Optional, Union
from typing import Any, ClassVar, Dict, List, Optional, Set, Union

from nilearn.connectome import ConnectivityMeasure
from sklearn.covariance import EmpiricalCovariance
Expand Down Expand Up @@ -42,7 +42,7 @@ class FunctionalConnectivityBase(BaseMarker):
"""

_DEPENDENCIES = {"nilearn", "scikit-learn"}
_DEPENDENCIES: ClassVar[Set[str]] = {"nilearn", "scikit-learn"}

def __init__(
self,
Expand Down
4 changes: 2 additions & 2 deletions junifer/markers/parcel_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Synchon Mandal <s.mandal@fz-juelich.de>
# License: AGPL

from typing import Any, Dict, List, Optional, Union
from typing import Any, ClassVar, Dict, List, Optional, Set, Union

import numpy as np
from nilearn.image import math_img, resample_to_img
Expand Down Expand Up @@ -51,7 +51,7 @@ class ParcelAggregation(BaseMarker):
None).
"""

_DEPENDENCIES = {"nilearn", "numpy"}
_DEPENDENCIES: ClassVar[Set[str]] = {"nilearn", "numpy"}

def __init__(
self,
Expand Down
6 changes: 4 additions & 2 deletions junifer/markers/reho/reho_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# License: AGPL


from typing import TYPE_CHECKING, Any, Dict, List, Optional
from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union

from ...utils import logger, raise_error
from ..base import BaseMarker
Expand All @@ -29,7 +29,9 @@ class ReHoBase(BaseMarker):
"""

_EXT_DEPENDENCIES = [
_EXT_DEPENDENCIES: ClassVar[
List[Dict[str, Union[str, bool, List[str]]]]
] = [
{
"name": "afni",
"optional": True,
Expand Down
4 changes: 2 additions & 2 deletions junifer/markers/sphere_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Synchon Mandal <s.mandal@fz-juelich.de>
# License: AGPL

from typing import Any, Dict, List, Optional, Union
from typing import Any, ClassVar, Dict, List, Optional, Set, Union

from ..api.decorators import register_marker
from ..data import get_mask, load_coordinates
Expand Down Expand Up @@ -57,7 +57,7 @@ class SphereAggregation(BaseMarker):
"""

_DEPENDENCIES = {"nilearn", "numpy"}
_DEPENDENCIES: ClassVar[Set[str]] = {"nilearn", "numpy"}

def __init__(
self,
Expand Down
4 changes: 2 additions & 2 deletions junifer/markers/temporal_snr/temporal_snr_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


from abc import abstractmethod
from typing import Any, Dict, List, Optional, Union
from typing import Any, ClassVar, Dict, List, Optional, Set, Union

from nilearn import image as nimg

Expand Down Expand Up @@ -34,7 +34,7 @@ class TemporalSNRBase(BaseMarker):
"""

_DEPENDENCIES = {"nilearn"}
_DEPENDENCIES: ClassVar[Set[str]] = {"nilearn"}

def __init__(
self,
Expand Down
26 changes: 15 additions & 11 deletions junifer/pipeline/tests/test_pipeline_step_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# License: AGPL

import warnings
from typing import Dict, List
from typing import ClassVar, Dict, List, Set, Union

import pytest

Expand All @@ -30,7 +30,7 @@ def test_pipeline_step_mixin_validate_correct_dependencies() -> None:
class CorrectMixer(PipelineStepMixin):
"""Test class for validation."""

_DEPENDENCIES = {"setuptools"}
_DEPENDENCIES: ClassVar[Set[str]] = {"setuptools"}

def validate_input(self, input: List[str]) -> List[str]:
return input
Expand All @@ -51,7 +51,7 @@ def test_pipeline_step_mixin_validate_incorrect_dependencies() -> None:
class IncorrectMixer(PipelineStepMixin):
"""Test class for validation."""

_DEPENDENCIES = {"foobar"}
_DEPENDENCIES: ClassVar[Set[str]] = {"foobar"}

def validate_input(self, input: List[str]) -> List[str]:
return input
Expand All @@ -76,7 +76,9 @@ def test_pipeline_step_mixin_validate_correct_ext_dependencies() -> None:
class CorrectMixer(PipelineStepMixin):
"""Test class for validation."""

_EXT_DEPENDENCIES = [{"name": "afni", "optional": False}]
_EXT_DEPENDENCIES: ClassVar[List[Dict[str, Union[str, bool]]]] = [
{"name": "afni", "optional": False}
]

def validate_input(self, input: List[str]) -> List[str]:
return input
Expand All @@ -100,9 +102,9 @@ def test_pipeline_step_mixin_validate_ext_deps_correct_commands() -> None:
class CorrectMixer(PipelineStepMixin):
"""Test class for validation."""

_EXT_DEPENDENCIES = [
{"name": "afni", "optional": False, "commands": ["3dReHo"]}
]
_EXT_DEPENDENCIES: ClassVar[
List[Dict[str, Union[str, bool, List[str]]]]
] = [{"name": "afni", "optional": False, "commands": ["3dReHo"]}]

def validate_input(self, input: List[str]) -> List[str]:
return input
Expand All @@ -128,9 +130,9 @@ def test_pipeline_step_mixin_validate_ext_deps_incorrect_commands() -> None:
class CorrectMixer(PipelineStepMixin):
"""Test class for validation."""

_EXT_DEPENDENCIES = [
{"name": "afni", "optional": False, "commands": ["3d"]}
]
_EXT_DEPENDENCIES: ClassVar[
List[Dict[str, Union[str, bool, List[str]]]]
] = [{"name": "afni", "optional": False, "commands": ["3d"]}]

def validate_input(self, input: List[str]) -> List[str]:
return input
Expand All @@ -152,7 +154,9 @@ def test_pipeline_step_mixin_validate_incorrect_ext_dependencies() -> None:
class IncorrectMixer(PipelineStepMixin):
"""Test class for validation."""

_EXT_DEPENDENCIES = [{"name": "foobar", "optional": True}]
_EXT_DEPENDENCIES: ClassVar[List[Dict[str, Union[str, bool]]]] = [
{"name": "foobar", "optional": True}
]

def validate_input(self, input: List[str]) -> List[str]:
return input
Expand Down
14 changes: 12 additions & 2 deletions junifer/preprocess/confounds/fmriprep_confound_remover.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@
# Synchon Mandal <s.mandal@fz-juelich.de>
# License: AGPL

from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
from typing import (
TYPE_CHECKING,
Any,
ClassVar,
Dict,
List,
Optional,
Set,
Tuple,
Union,
)

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -141,7 +151,7 @@ class fMRIPrepConfoundRemover(BasePreprocessor):
"""

_DEPENDENCIES = {"numpy", "nilearn"}
_DEPENDENCIES: ClassVar[Set[str]] = {"numpy", "nilearn"}

def __init__(
self,
Expand Down

0 comments on commit 69f8ad1

Please sign in to comment.