From 27a4bc1b6d1da25a38fe8e2c5fb27f22308e3260 Mon Sep 17 00:00:00 2001 From: Mahmoud Hashemi Date: Mon, 21 Sep 2015 03:04:33 -0700 Subject: [PATCH] switched reraise_visit to be just a kwarg --- boltons/iterutils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/boltons/iterutils.py b/boltons/iterutils.py index 198d131..feb73dd 100644 --- a/boltons/iterutils.py +++ b/boltons/iterutils.py @@ -639,7 +639,7 @@ def default_exit(path, key, old_parent, new_parent, new_items): def remap(root, visit=default_visit, enter=default_enter, exit=default_exit, - reraise_visit=True): + **kwargs): """The remap ("recursive map") function is used to traverse and transform nested structures. Lists, tuples, sets, and dictionaries are just a few of the data structures commonly nested into @@ -726,13 +726,15 @@ def remap(root, visit=default_visit, enter=default_enter, exit=default_exit, """ # TODO: enter() return (False, items) to continue traverse but cancel copy? - # TODO: reraise_visit to kwarg only if not callable(visit): raise TypeError('visit expected callable, not: %r' % visit) if not callable(enter): raise TypeError('enter expected callable, not: %r' % enter) if not callable(exit): raise TypeError('exit expected callable, not: %r' % exit) + reraise_visit = kwargs.pop('reraise_visit', True) + if kwargs: + raise TypeError('unexpected keyword arguments: %r' % kwargs.keys()) path, registry, stack = (), {}, [(None, root)] new_items_stack = []