Skip to content

Commit a4febd2

Browse files
authored
STY: Bump style dependencies, run isort on repo (#206)
* MAINT: Bump style dependencies * MAINT: Add isort to style check * MAINT: Add isort to style action check * STY: Run `isort` on codebase * MAINT: Add file to ignore large style changes when blaming
1 parent 9d3abce commit a4febd2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+238
-185
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# isort addition
2+
6f809fa9950654cbb7f755922c45dffbc88dc45d

.github/workflows/style.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ jobs:
2525
python-version: ${{ matrix.python-version }}
2626
- name: Install dependencies
2727
run: |
28-
python -m pip install --upgrade pip
29-
pip install .[style]
28+
pip install $(grep -e "black" -e "isort" setup.cfg | sed "s/ //g" | tr "\n" " ")
3029
- name: black code formatting check
3130
run: |
3231
black --check nibabies/

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ repos:
1010
rev: 22.3.0
1111
hooks:
1212
- id: black
13+
- repo: https://github.com/pycqa/isort
14+
rev: 5.10.1
15+
hooks:
16+
- id: isort

nibabies/_warnings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Manipulate Python warnings."""
2-
import warnings
32
import logging
3+
import warnings
44

55
_wlog = logging.getLogger("py.warnings")
66
_wlog.addHandler(logging.NullHandler())

nibabies/cli/parser.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
33
"""Parser."""
44
import sys
5+
56
from .. import config
67

78

89
def _build_parser():
910
"""Build parser object."""
11+
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
1012
from functools import partial
1113
from pathlib import Path
12-
from argparse import (
13-
ArgumentParser,
14-
ArgumentDefaultsHelpFormatter,
15-
)
14+
15+
from niworkflows.utils.spaces import OutputReferencesAction, Reference
1616
from packaging.version import Version
17+
1718
from .version import check_latest, is_flagged
18-
from niworkflows.utils.spaces import Reference, OutputReferencesAction
1919

2020
def _path_exists(path, parser):
2121
"""Ensure a given path exists."""
@@ -668,6 +668,7 @@ def parse_args(args=None, namespace=None):
668668
# Initialize --output-spaces if not defined
669669
if config.execution.output_spaces is None:
670670
from niworkflows.utils.spaces import Reference, SpatialReferences
671+
671672
from ..utils.misc import cohort_by_months
672673

673674
if config.workflow.age_months is None:

nibabies/cli/run.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66

77
def main():
88
"""Entry point."""
9+
import gc
10+
import sys
11+
from multiprocessing import Manager, Process
912
from os import EX_SOFTWARE
1013
from pathlib import Path
11-
import sys
12-
import gc
13-
from multiprocessing import Process, Manager
14+
15+
from ..utils.bids import write_bidsignore, write_derivative_description
1416
from .parser import parse_args
15-
from ..utils.bids import write_derivative_description, write_bidsignore
1617

1718
parse_args()
1819

@@ -133,17 +134,18 @@ def main():
133134
)
134135

135136
if config.workflow.run_reconall:
136-
from templateflow import api
137137
from niworkflows.utils.misc import _copy_any
138+
from templateflow import api
138139

139140
dseg_tsv = str(api.get("fsaverage", suffix="dseg", extension=[".tsv"]))
140141
_copy_any(dseg_tsv, str(config.execution.nibabies_dir / "desc-aseg_dseg.tsv"))
141142
_copy_any(dseg_tsv, str(config.execution.nibabies_dir / "desc-aparcaseg_dseg.tsv"))
142143
# errno = 0
143144
finally:
144-
from ..reports.core import generate_reports
145145
from pkg_resources import resource_filename as pkgrf
146146

147+
from ..reports.core import generate_reports
148+
147149
# Generate reports phase
148150
generate_reports(
149151
config.execution.participant_label,

nibabies/cli/version.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
33
"""Version CLI helpers."""
44

5-
from pathlib import Path
65
from datetime import datetime
6+
from pathlib import Path
7+
78
import requests
9+
810
from .. import __version__
911

1012
RELEASE_EXPIRY_DAYS = 14
@@ -13,7 +15,7 @@
1315

1416
def check_latest():
1517
"""Determine whether this is the latest version."""
16-
from packaging.version import Version, InvalidVersion
18+
from packaging.version import InvalidVersion, Version
1719

1820
latest = None
1921
date = None

nibabies/cli/workflow.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212

1313
def build_workflow(config_file, retval):
1414
"""Create the Nipype Workflow that supports the whole execution graph."""
15-
from niworkflows.utils.bids import collect_participants, check_pipeline_version
15+
from niworkflows.utils.bids import check_pipeline_version, collect_participants
1616
from niworkflows.utils.misc import check_valid_fs_license
17-
from ..reports.core import generate_reports
17+
1818
from .. import config
19+
from ..reports.core import generate_reports
1920
from ..utils.misc import check_deps
2021
from ..workflows.base import init_nibabies_wf
2122

@@ -134,9 +135,10 @@ def build_boilerplate(config_file, workflow):
134135
citation_files["md"].write_text(boilerplate)
135136

136137
if not config.execution.md_only_boilerplate and citation_files["md"].exists():
137-
from subprocess import check_call, CalledProcessError, TimeoutExpired
138-
from pkg_resources import resource_filename as pkgrf
139138
from shutil import copyfile
139+
from subprocess import CalledProcessError, TimeoutExpired, check_call
140+
141+
from pkg_resources import resource_filename as pkgrf
140142

141143
# Generate HTML file resolving citations
142144
cmd = [

nibabies/config.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,13 @@
8686
# Defer all custom import for after initializing the forkserver and
8787
# ignoring the most annoying warnings
8888
import random
89-
from uuid import uuid4
89+
from pathlib import Path
9090
from time import strftime
91+
from uuid import uuid4
9192

92-
from pathlib import Path
9393
from nipype import __version__ as _nipype_ver
9494
from templateflow import __version__ as _tf_ver
95+
9596
from . import __version__
9697

9798
if not hasattr(sys, "_is_pytest_session"):
@@ -126,7 +127,9 @@
126127
if not _disable_et:
127128
# Just get so analytics track one hit
128129
from contextlib import suppress
129-
from requests import get as _get_url, ConnectionError, ReadTimeout
130+
131+
from requests import ConnectionError, ReadTimeout
132+
from requests import get as _get_url
130133

131134
with suppress((ConnectionError, ReadTimeout)):
132135
_get_url("https://rig.mit.edu/et/projects/nipy/nipype", timeout=0.05)
@@ -215,7 +218,7 @@ def load(cls, settings, init=True, ignore=None):
215218
@classmethod
216219
def get(cls):
217220
"""Return defined settings."""
218-
from niworkflows.utils.spaces import SpatialReferences, Reference
221+
from niworkflows.utils.spaces import Reference, SpatialReferences
219222

220223
out = {}
221224
for k, v in cls.__dict__.items():
@@ -438,6 +441,7 @@ def init(cls):
438441

439442
if cls._layout is None:
440443
import re
444+
441445
from bids.layout import BIDSLayout, BIDSLayoutIndexer
442446

443447
_db_path = cls.bids_database_dir or (cls.work_dir / cls.run_uuid / "bids_db")

nibabies/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""py.test configuration"""
22
from pathlib import Path
33
from tempfile import TemporaryDirectory
4-
from pkg_resources import resource_filename
54

65
import pytest
6+
from pkg_resources import resource_filename
77

88
FILES = (
99
"functional.nii",

0 commit comments

Comments
 (0)