mirror of
https://github.com/davidhalter/jedi.git
synced 2026-01-16 00:46:43 +08:00
Move a paragraph
This commit is contained in:
@@ -43,7 +43,6 @@ class NameFinder(object):
|
||||
else:
|
||||
self._string_name = name_or_str
|
||||
self._position = position
|
||||
self._found_predefined_types = None
|
||||
self._analysis_errors = analysis_errors
|
||||
|
||||
def find(self, names, attribute_lookup):
|
||||
@@ -51,7 +50,24 @@ class NameFinder(object):
|
||||
:params bool attribute_lookup: Tell to logic if we're accessing the
|
||||
attribute or the contents of e.g. a function.
|
||||
"""
|
||||
if self._found_predefined_types is not None and names:
|
||||
found_predefined_types = None
|
||||
# This paragraph is currently needed for proper branch type inference
|
||||
# (static analysis).
|
||||
if self._context.predefined_names and isinstance(self._name, tree.Name):
|
||||
node = self._name
|
||||
while node is not None and not is_scope(node):
|
||||
node = node.parent
|
||||
if node.type in ("if_stmt", "for_stmt", "comp_for", 'sync_comp_for'):
|
||||
try:
|
||||
name_dict = self._context.predefined_names[node]
|
||||
types = name_dict[self._string_name]
|
||||
except KeyError:
|
||||
continue
|
||||
else:
|
||||
found_predefined_types = types
|
||||
break
|
||||
|
||||
if found_predefined_types is not None and names:
|
||||
check = flow_analysis.reachability_check(
|
||||
context=self._context,
|
||||
value_scope=self._context.tree_node,
|
||||
@@ -59,7 +75,7 @@ class NameFinder(object):
|
||||
)
|
||||
if check is flow_analysis.UNREACHABLE:
|
||||
return NO_VALUES
|
||||
return self._found_predefined_types
|
||||
return found_predefined_types
|
||||
|
||||
types = self._names_to_types(names)
|
||||
self.check_issues(names, types, attribute_lookup)
|
||||
@@ -84,22 +100,6 @@ class NameFinder(object):
|
||||
``filters``), until a name fits.
|
||||
"""
|
||||
names = []
|
||||
# This paragraph is currently needed for proper branch type inference
|
||||
# (static analysis).
|
||||
if self._context.predefined_names and isinstance(self._name, tree.Name):
|
||||
node = self._name
|
||||
while node is not None and not is_scope(node):
|
||||
node = node.parent
|
||||
if node.type in ("if_stmt", "for_stmt", "comp_for", 'sync_comp_for'):
|
||||
try:
|
||||
name_dict = self._context.predefined_names[node]
|
||||
types = name_dict[self._string_name]
|
||||
except KeyError:
|
||||
continue
|
||||
else:
|
||||
self._found_predefined_types = types
|
||||
break
|
||||
|
||||
for filter in filters:
|
||||
names = filter.get(self._string_name)
|
||||
if names:
|
||||
|
||||
Reference in New Issue
Block a user