Skip to content

Commit 4cd043d

Browse files
committed
🚨 Add \ # pylint: disable\ comments to \ # noqa:\s
[skip ci]
1 parent 069782b commit 4cd043d

File tree

7 files changed

+43
-31
lines changed

7 files changed

+43
-31
lines changed

CPAC/cwas/tests/test_cwas.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ def run_cwas(self):
7878

7979
# Read in list of subject functionals
8080
subjects_list = [
81-
l.strip().strip('"') for l in open(sfile).readlines() # noqa: E741
81+
l.strip().strip('"') for # noqa: E741
82+
l in open(sfile).readlines() # pylint: disable=consider-using-with
8283
]
8384

8485
# Read in design/regressor file
@@ -93,7 +94,7 @@ def run_cwas(self):
9394
c.inputs.inputspec.f_samples = nperms
9495
c.inputs.inputspec.parallel_nodes = 4
9596
# c.base_dir = op.join(obase, 'results_fs%i_pn%i' % \
96-
# (c.inputs.inputspec.f_samples, c.inputs.inputspec.parallel_nodes)) # noqa: E501
97+
# (c.inputs.inputspec.f_samples, c.inputs.inputspec.parallel_nodes)) # noqa: E501 # pylint: disable=line-too-long
9798
c.base_dir = op.join(self.base, "results_%s.py" % self.name)
9899

99100
# export MKL_NUM_THREADS=X # in command line

CPAC/seg_preproc/seg_preproc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ def process_segment_map(wf_name, use_priors, use_custom_threshold, reg_tool):
136136
:width: 1100
137137
:height: 480
138138
139-
""" # noqa:
139+
"""
140+
# pylint: disable=import-outside-toplevel,redefined-outer-name,reimported
140141
import nipype.interfaces.utility as util
141142

142143
preproc = pe.Workflow(name=wf_name)
@@ -457,7 +458,7 @@ def create_seg_preproc_freesurfer(config=None,
457458
458459
outputspec.wm_mask : string (nifti file)
459460
outputs White Matter mask
460-
""" # noqa:
461+
"""
461462
preproc = pe.Workflow(name=wf_name)
462463

463464
inputnode = pe.Node(util.IdentityInterface(fields=['subject_dir']),

CPAC/seg_preproc/utils.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def pick_wm_prob_0(probability_maps):
4646
4747
file : string
4848
Path to segment_prob_0.nii.gz is returned
49-
""" # noqa:
49+
"""
5050
if isinstance(probability_maps, list):
5151
if len(probability_maps) == 1:
5252
probability_maps = probability_maps[0]
@@ -70,7 +70,7 @@ def pick_wm_prob_1(probability_maps):
7070
7171
file : string
7272
Path to segment_prob_1.nii.gz is returned
73-
""" # noqa:
73+
"""
7474
if isinstance(probability_maps, list):
7575
if len(probability_maps) == 1:
7676
probability_maps = probability_maps[0]
@@ -94,7 +94,7 @@ def pick_wm_prob_2(probability_maps):
9494
9595
file : string
9696
Path to segment_prob_2.nii.gz is returned
97-
""" # noqa:
97+
"""
9898
if isinstance(probability_maps, list):
9999
if len(probability_maps) == 1:
100100
probability_maps = probability_maps[0]
@@ -118,7 +118,7 @@ def pick_wm_class_0(tissue_class_files):
118118
119119
file : string
120120
Path to segment_seg_0.nii.gz is returned
121-
""" # noqa:
121+
"""
122122
if isinstance(tissue_class_files, list):
123123
if len(tissue_class_files) == 1:
124124
tissue_class_files = tissue_class_files[0]
@@ -142,7 +142,7 @@ def pick_wm_class_1(tissue_class_files):
142142
143143
file : string
144144
Path to segment_seg_1.nii.gz is returned
145-
""" # noqa:
145+
"""
146146
if isinstance(tissue_class_files, list):
147147
if len(tissue_class_files) == 1:
148148
tissue_class_files = tissue_class_files[0]
@@ -166,7 +166,7 @@ def pick_wm_class_2(tissue_class_files):
166166
167167
file : string
168168
Path to segment_seg_2.nii.gz is returned
169-
""" # noqa:
169+
"""
170170
if isinstance(tissue_class_files, list):
171171
if len(tissue_class_files) == 1:
172172
tissue_class_files = tissue_class_files[0]
@@ -363,11 +363,15 @@ def hardcoded_antsJointLabelFusion(anatomical_brain, anatomical_brain_mask,
363363
bash_cmd = str.join(cmd)
364364

365365
try:
366-
retcode = subprocess.check_output(bash_cmd, shell=True) # noqa: F841
367-
except Exception as e:
366+
retcode = subprocess.check_output(bash_cmd, shell=True) \
367+
# noqa: F841 # pylint: disable=unused-variable
368+
except Exception as e: # pylint: disable=broad-except,invalid-name
369+
# pylint: disable=raise-missing-from
368370
raise Exception('[!] antsJointLabel segmentation method did not '
369371
'complete successfully.\n\nError '
370-
'details:\n{0}\n{1}\n'.format(e, e.output))
372+
'details:\n{0}\n{1}\n'.format(
373+
e,
374+
getattr(e, 'output', '')))
371375

372376
multiatlas_Intensity = None
373377
multiatlas_Labels = None
@@ -414,7 +418,8 @@ def pick_tissue_from_labels_file(multiatlas_Labels, csf_label=[4,14,15,24,43],
414418
gm_mask : string (nifti file)
415419
416420
wm_mask : string (nifti file)
417-
""" # noqa:
421+
"""
422+
# pylint: disable=import-outside-toplevel,redefined-outer-name,reimported
418423
import os
419424
import nibabel as nb
420425
import numpy as np

CPAC/utils/monitoring/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'''Module to customize Nipype's process monitoring for use in C-PAC
22
33
See https://fcp-indi.github.io/docs/developer/nodes for C-PAC-specific documentation.
4-
See https://nipype.readthedocs.io/en/latest/api/generated/nipype.utils.profiler.html for Nipype's documentation.''' # noqa: E501
4+
See https://nipype.readthedocs.io/en/latest/api/generated/nipype.utils.profiler.html for Nipype's documentation.''' # noqa: E501 # pylint: disable=line-too-long
55
from .custom_logging import set_up_logger
66
from .monitoring import LoggingHTTPServer, LoggingRequestHandler, \
77
log_nodes_cb, log_nodes_initial, monitor_server, \

CPAC/utils/utils.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ def get_zscore(map_node=False, wf_name='z_score'):
251251
>>> wf.inputs.inputspec.input_file = '/home/data/graph_working_dir/calculate_centrality/degree_centrality_binarize.nii.gz'
252252
>>> wf.inputs.inputspec.mask_file = '/home/data/graphs/GraphGeneration/new_mask_3m.nii.gz'
253253
>>> wf.run() # doctest: +SKIP
254-
""" # noqa:
255-
254+
""" # noqa: E501 # pylint: disable=line-too-long
255+
# pylint: disable=import-outside-toplevel,redefined-outer-name,reimported
256256
from CPAC.pipeline import nipype_pipeline_engine as pe
257257
import nipype.interfaces.utility as util
258258
import nipype.interfaces.fsl as fsl
@@ -1666,7 +1666,7 @@ def dct_diff(dct1, dct2):
16661666
... 'pipeline_config_fmriprep-options.yml')
16671667
>>> dct_diff(pipeline, pipeline2)['pipeline_setup']['pipeline_name']
16681668
('cpac-default-pipeline', 'cpac_fmriprep-options')
1669-
''' # noqa:
1669+
'''
16701670
diff = {}
16711671
for key in dct1:
16721672
if isinstance(dct1[key], dict):
@@ -1697,7 +1697,8 @@ def dct_diff(dct1, dct2):
16971697
return {}
16981698

16991699

1700-
def list_item_replace(l, old, new): # noqa: E741
1700+
def list_item_replace(l, # noqa: E741 # pylint: disable=invalid-name
1701+
old, new):
17011702
'''Function to replace an item in a list
17021703
17031704
Parameters
@@ -1917,14 +1918,15 @@ def update_config_dict(old_dict):
19171918
19181919
Examples
19191920
--------
1920-
>>> a, b, c = update_config_dict({'pipelineName': 'example-pipeline', '2': None})
1921+
>>> a, b, c = update_config_dict({
1922+
... 'pipelineName': 'example-pipeline', '2': None})
19211923
>>> a
19221924
{'pipeline_setup': {'pipeline_name': 'example-pipeline'}}
19231925
>>> b
19241926
{'2': None}
19251927
>>> c
19261928
{'pipeline_setup': {'pipeline_name': 'example-pipeline'}, '2': None}
1927-
''' # noqa:
1929+
'''
19281930
def _append_to_list(current_value, new_value):
19291931
'''Helper function to add new_value to the current_value list
19301932
or create a list if one does not exist. Skips falsy elements
@@ -2288,7 +2290,7 @@ def update_nested_dict(d_base, d_update, fully_specified=False):
22882290
... '/cpac_templates/aal_mask_pad.nii.gz': 'Voxel'
22892291
... }, 'realignment': 'ROI_to_func'}})
22902292
True
2291-
""" # noqa:
2293+
""" # noqa: E501 # pylint: disable=line-too-long
22922294

22932295
# short-circuit if d_update has `*_roi_paths` and
22942296
# `roi_paths_fully_specified` children
@@ -2330,8 +2332,9 @@ def update_pipeline_values_1_8(d_old):
23302332
>>> update_pipeline_values_1_8({'segmentation': {'tissue_segmentation': {
23312333
... 'using': ['FSL-FAST Thresholding']}}})
23322334
{'segmentation': {'tissue_segmentation': {'using': ['FSL-FAST'], 'FSL-FAST': {'thresholding': {'use': 'Auto'}}}}}
2333-
''' # noqa:
2334-
from CPAC.pipeline.schema import valid_options
2335+
''' # noqa: E501 # pylint: disable=line-too-long
2336+
from CPAC.pipeline.schema import valid_options \
2337+
# pylint: disable=import-outside-toplevel
23352338

23362339
d = replace_in_strings(d_old.copy())
23372340

CPAC/utils/yaml_template.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def _create_import_dict(diff):
7676
... 'run': ([True], False),
7777
... 'using': (['3dSkullStrip'], ['niworkflows-ants'])}}}})
7878
{'anatomical_preproc': {'brain_extraction': {'extraction': {'run': False, 'using': ['niworkflows-ants']}}}}
79-
''' # noqa:
79+
''' # noqa: E501 # pylint: disable=line-too-long
8080
if isinstance(diff, tuple) and len(diff) == 2:
8181
return diff[1]
8282
if isinstance(diff, dict):
@@ -112,7 +112,8 @@ def _format_key(key, level):
112112
'''
113113
return f'\n{" " * level * 2}{key}: '
114114

115-
def _format_list_items(l, line_level): # noqa: E741
115+
def _format_list_items(l, # noqa: E741 # pylint:disable=invalid-name
116+
line_level):
116117
'''Helper method to handle lists in the YAML
117118
118119
Parameters
@@ -131,11 +132,11 @@ def _format_list_items(l, line_level): # noqa: E741
131132
' - 1\n - 2\n - nested: 3'
132133
>>> _format_list_items([1, 2, {'nested': [3, {'deep': [4]}]}], 1)
133134
' - 1\n - 2\n - nested:\n - 3\n - deep:\n - 4'
134-
''' # noqa:
135+
''' # noqa: E501 # pylint: disable=line-too-long
135136
# keep short, simple lists in square brackets
136-
if all([any([isinstance(item, item_type) for item_type in {
137+
if all(any(isinstance(item, item_type) for item_type in {
137138
str, bool, int, float
138-
}]) for item in l]):
139+
}) for item in l):
139140
if len(str(l)) < 50:
140141
return str(l).replace("'", '').replace('"', '')
141142
# list long or complex lists on lines with indented '-' lead-ins

dev/circleci_data/test_external_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
sys.path.append(CPAC_DIR)
88
DATA_DIR = os.path.join(CPAC_DIR, 'dev', 'circleci_data')
99

10-
from CPAC.__main__ import utils as CPAC_main_utils # noqa: E402
10+
from CPAC.__main__ import utils as CPAC_main_utils \
11+
# noqa: E402 # pylint: disable=wrong-import-position
1112

1213

1314
def test_build_data_config(cli_runner):
@@ -103,8 +104,8 @@ def _delete_test_yaml(test_yaml):
103104

104105

105106
def _test_repickle(pickle_path, gzipped=False):
107+
# pylint: disable=import-outside-toplevel,unused-import
106108
backup = _Backup(pickle_path)
107109
if gzipped:
108110
import gzip # noqa: F401
109-
110111
backup.restore()

0 commit comments

Comments
 (0)