diff options
author | Emile Anclin <emile.anclin@logilab.fr> | 2010-12-13 18:48:28 +0100 |
---|---|---|
committer | Emile Anclin <emile.anclin@logilab.fr> | 2010-12-13 18:48:28 +0100 |
commit | 9c0e2aa622a8d8f85fae48d6795b4bfabe1ccaa4 (patch) | |
tree | 0e32234bfaa99e1f0b9a9d979cf800402cdf932e | |
parent | 5d3f2a5255224c15c316d0854fd9db2b41a201a0 (diff) | |
download | astroid-git-9c0e2aa622a8d8f85fae48d6795b4bfabe1ccaa4.tar.gz |
minor cleanup: remove useless optional attributes
-rw-r--r-- | manager.py | 21 | ||||
-rw-r--r-- | node_classes.py | 7 |
2 files changed, 13 insertions, 15 deletions
@@ -227,22 +227,21 @@ class ASTNGManager(OptionsProviderMixIn): return modastng.getattr(klass.__name__)[0] # XXX - def infer_astng_from_something(self, obj, modname=None, context=None): + def infer_astng_from_something(self, obj, context=None): """infer astng for the given class""" if hasattr(obj, '__class__') and not isinstance(obj, type): klass = obj.__class__ else: klass = obj - if modname is None: - try: - modname = klass.__module__ - except AttributeError: - raise ASTNGBuildingException( - 'Unable to get module for %s' % safe_repr(klass)) - except Exception, ex: - raise ASTNGBuildingException( - 'Unexpected error while retrieving module for %s: %s' - % (safe_repr(klass), ex)) + try: + modname = klass.__module__ + except AttributeError: + raise ASTNGBuildingException( + 'Unable to get module for %s' % safe_repr(klass)) + except Exception, ex: + raise ASTNGBuildingException( + 'Unexpected error while retrieving module for %s: %s' + % (safe_repr(klass), ex)) try: name = klass.__name__ except AttributeError: diff --git a/node_classes.py b/node_classes.py index 0fc83745..27a7af30 100644 --- a/node_classes.py +++ b/node_classes.py @@ -23,7 +23,7 @@ import sys from logilab.astng.exceptions import NoDefault -from logilab.astng.bases import (NodeNG, Statement, Instance, copy_context, +from logilab.astng.bases import (NodeNG, Statement, Instance, InferenceContext, _infer_stmts, YES) from logilab.astng.mixins import BlockRangeMixIn, AssignTypeMixin, \ ParentAssignTypeMixin, FromImportMixIn @@ -115,15 +115,14 @@ class LookupMixIn(object): """ return self.scope().scope_lookup(self, name) - def ilookup(self, name, context=None): + def ilookup(self, name): """infered lookup return an iterator on infered values of the statements returned by the lookup method """ frame, stmts = self.lookup(name) - context = copy_context(context) - context.lookupname = name + context = InferenceContext() return _infer_stmts(stmts, context, frame) def _filter_stmts(self, stmts, frame, offset): |