Skip to content

add kwargs to _warnings.py #3483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .maint/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Before every release, unlisted contributors will be invited again to add their n
| Bellec | Pierre | | 0000-0002-9111-0699 | SIMEXP Lab, CRIUGM, University of Montréal, Montréal, Canada |
| Benson | Noah C. | | 0000-0002-2365-8265 | Department of Psychology, New York University |
| Bhagwat | Nikhil | | 0000-0001-6073-7141 | Montreal Neurological Institute, McGill University |
| Camacho | Milton | | 0000-0002-5379-5076 | Department of Pediadrics, University of Calgary |
| Callenberg | Keith | | 0000-0001-7786-9300 | Department of Psychiatry, University of Pittsburgh |
| Cieslak | Matthew | | 0000-0002-1931-4734 | Perelman School of Medicine, University of Pennsylvania, PA, USA |
| de la Vega | Alejandro | | 0000-0001-9062-3778 | University of Texas at Austin |
Expand Down
9 changes: 6 additions & 3 deletions fmriprep/_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,20 @@
_wlog.addHandler(logging.NullHandler())


def _warn(message, category=None, stacklevel=1, source=None):
def _warn(message, category=None, stacklevel=1, source=None, **kwargs):
"""Redefine the warning function."""
if category is not None:
category = type(category).__name__
category = category.replace('type', 'WARNING')

if kwargs:
logging.getLogger('py.warnings').warning(f'Extra warning kwargs: {kwargs}')

logging.getLogger('py.warnings').warning(f'{category or "WARNING"}: {message}')


def _showwarning(message, category, filename, lineno, file=None, line=None):
_warn(message, category=category)
def _showwarning(message, category, filename, lineno, file=None, line=None, **kwargs):
_warn(message, category=category, **kwargs)


warnings.warn = _warn
Expand Down
Loading