Skip to content

Commit cc4796e

Browse files
committed
fix: trying to get ahold of warnings
1 parent a48c66c commit cc4796e

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

fmriprep/config.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,13 @@
9898
import warnings
9999
from multiprocessing import set_start_method
100100

101-
102-
def redirect_warnings(message, category, filename, lineno, file=None, line=None):
103-
"""Redirect other warnings."""
104-
import logging
105-
logger = logging.getLogger()
106-
logger.debug('Captured warning (%s): %s', category, message)
107-
108-
109101
# cmp is not used by fmriprep, so ignore nipype-generated warnings
110-
warnings.filterwarnings('ignore', r'cmp not installed')
111-
warnings.filterwarnings('ignore', r'This has not been fully tested. Please report any failures.')
112-
warnings.filterwarnings('ignore', r"can't resolve package from __spec__ or __package__")
102+
warnings.filterwarnings('ignore', 'cmp not installed')
103+
warnings.filterwarnings('ignore', 'This has not been fully tested. Please report any failures.')
104+
warnings.filterwarnings('ignore', "can't resolve package from __spec__ or __package__")
113105
warnings.simplefilter('ignore', DeprecationWarning)
114106
warnings.simplefilter('ignore', FutureWarning)
115107
warnings.simplefilter('ignore', ResourceWarning)
116-
warnings.showwarning = redirect_warnings
117108

118109

119110
try:
@@ -135,6 +126,14 @@ def redirect_warnings(message, category, filename, lineno, file=None, line=None)
135126
from . import __version__
136127

137128

129+
def redirect_warnings(message, category, filename, lineno, file=None, line=None):
130+
"""Redirect other warnings."""
131+
logger = logging.getLogger()
132+
logger.debug('Captured warning (%s): %s', category, message)
133+
134+
135+
warnings.showwarning = redirect_warnings
136+
138137
logging.addLevelName(25, 'IMPORTANT') # Add a new level between INFO and WARNING
139138
logging.addLevelName(15, 'VERBOSE') # Add a new level between INFO and DEBUG
140139

0 commit comments

Comments
 (0)