summaryrefslogtreecommitdiff
path: root/scoped_nodes.py
diff options
context:
space:
mode:
authorEevee (Alex Munroe) <amunroe@yelp.com>2014-03-24 16:09:34 -0700
committerEevee (Alex Munroe) <amunroe@yelp.com>2014-07-01 17:33:00 -0700
commit2e13d989dbf9a097c679e4e1ca71e59fc9e5524f (patch)
treef7f8f96d3867f81d6155f77f8a670f92b2364be2 /scoped_nodes.py
parent2bf7e926b234bf8376a63f672380d2f1ae8eeb8d (diff)
downloadastroid-git-2e13d989dbf9a097c679e4e1ca71e59fc9e5524f.tar.gz
Remove context.lookupname; make it an argument to infer() when appropriate.
Diffstat (limited to 'scoped_nodes.py')
-rw-r--r--scoped_nodes.py45
1 files changed, 21 insertions, 24 deletions
diff --git a/scoped_nodes.py b/scoped_nodes.py
index a5bc37e9..389ebe71 100644
--- a/scoped_nodes.py
+++ b/scoped_nodes.py
@@ -310,12 +310,10 @@ class Module(LocalsDictNodeNG):
# instance
if not context:
context = InferenceContext()
- with context.scope(lookupname=name):
- try:
- for infered in _infer_stmts(self.getattr(name, context), context, frame=self):
- yield infered
- except NotFoundError:
- raise InferenceError(name)
+ try:
+ return _infer_stmts(self.getattr(name, context), context, frame=self, lookupname=name)
+ except NotFoundError:
+ raise InferenceError(name)
def fully_defined(self):
"""return True if this module has been built from a .py file
@@ -997,26 +995,25 @@ class Class(Statement, LocalsDictNodeNG, FilterStmtsMixin):
# instance
if not context:
context = InferenceContext()
- with context.scope(lookupname=name):
- try:
- for infered in _infer_stmts(self.getattr(name, context), context,
- frame=self):
- # yield YES object instead of descriptors when necessary
- if not isinstance(infered, Const) and isinstance(infered, Instance):
- try:
- infered._proxied.getattr('__get__', context)
- except NotFoundError:
- yield infered
- else:
- yield YES
+ try:
+ for infered in _infer_stmts(self.getattr(name, context), context,
+ frame=self, lookupname=name):
+ # yield YES object instead of descriptors when necessary
+ if not isinstance(infered, Const) and isinstance(infered, Instance):
+ try:
+ infered._proxied.getattr('__get__', context)
+ except NotFoundError:
+ yield infered
else:
- yield function_to_method(infered, self)
- except NotFoundError:
- if not name.startswith('__') and self.has_dynamic_getattr(context):
- # class handle some dynamic attributes, return a YES object
- yield YES
+ yield YES
else:
- raise InferenceError(name)
+ yield function_to_method(infered, self)
+ except NotFoundError:
+ if not name.startswith('__') and self.has_dynamic_getattr(context):
+ # class handle some dynamic attributes, return a YES object
+ yield YES
+ else:
+ raise InferenceError(name)
def has_dynamic_getattr(self, context=None):
"""return True if the class has a custom __getattr__ or