diff options
author | Ceridwen <ceridwenv@gmail.com> | 2015-11-03 00:42:57 -0500 |
---|---|---|
committer | Ceridwen <ceridwenv@gmail.com> | 2015-11-03 00:42:57 -0500 |
commit | bc55c015163aab7d6be292f67687afec07aeacae (patch) | |
tree | c0ec1f71becf50fa56c1e90ec1918e8195ab5b50 | |
parent | 1ba0f2d96fbc45ff0b6014b12db98716183e8277 (diff) | |
download | astroid-bc55c015163aab7d6be292f67687afec07aeacae.tar.gz |
Improve InferenceError for remove_nodes
-rw-r--r-- | astroid/decorators.py | 1 | ||||
-rw-r--r-- | astroid/scoped_nodes.py | 7 |
2 files changed, 5 insertions, 3 deletions
diff --git a/astroid/decorators.py b/astroid/decorators.py index 27ce983..815b540 100644 --- a/astroid/decorators.py +++ b/astroid/decorators.py @@ -129,5 +129,6 @@ def raise_if_nothing_inferred(func, instance, args, kwargs): yield node except exceptions.DefaultStop as e: fields = vars(e) + del fields['message'] if not inferred: raise exceptions.InferenceError(**fields) diff --git a/astroid/scoped_nodes.py b/astroid/scoped_nodes.py index eb7baf7..9b52135 100644 --- a/astroid/scoped_nodes.py +++ b/astroid/scoped_nodes.py @@ -91,10 +91,11 @@ def remove_nodes(cls): def decorator(func, instance, args, kwargs): nodes = [n for n in func(*args, **kwargs) if not isinstance(n, cls)] if not nodes: - # TODO: no way to access the name or context when raising - # this error. + # TODO: no way to access the context when raising this error. raise exceptions.AttributeInferenceError( - 'No nodes left after filtering.', target=instance) + 'No nodes left after removing all {remove_type!r} from ' + 'inferring for {node!r}.', + node=instance, remove_type=cls) return nodes return decorator |