Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

Commit

Permalink
fix Attribute exception during function param infering
Browse files Browse the repository at this point in the history
  • Loading branch information
baverman committed Oct 21, 2010
1 parent 9ae24d3 commit fb35562
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions snaked/plugins/python/ropehints.py
Expand Up @@ -98,9 +98,11 @@ def get_function_param_type(self, pyfunc, name):
scope_path = self.get_scope_path(pyfunc.get_scope())
type_name = self.find_type_for(scope_path, name)
if type_name:
return self.get_type(pyfunc.pycore, type_name).get_object()
else:
return None
pyname = self.get_type(pyfunc.pycore, type_name)
if pyname:
return pyname.get_object()

return None

def get_scope_path(self, scope):
result = []
Expand Down Expand Up @@ -129,12 +131,15 @@ def get_type(self, pycore, type_name):
module, sep, name = type_name.strip('()').rpartition('.')
if module:
module = pycore.get_module(module)
obj = module[name]
try:
pyname = module[name]
except exceptions.AttributeNotFoundError:
pyname = None
else:
obj = pycore.get_module(name)
pyname = pycore.get_module(name)

self.type_cache[type_name] = obj
return obj
self.type_cache[type_name] = pyname
return pyname

def get_module_attribute(self, pymodule, name, original_pyname):
try:
Expand Down Expand Up @@ -190,6 +195,7 @@ def refresh(self):
def load_hints(self):
self.db[:] = []
self.module_attrs_cache.clear()
self.type_cache.clear()

if os.path.exists(self.hints_filename):
with open(self.hints_filename) as f:
Expand Down

0 comments on commit fb35562

Please sign in to comment.