forked from VimPlug/jedi
Remove __str__ from name.
This commit is contained in:
@@ -160,7 +160,7 @@ class Evaluator(object):
|
||||
# `=` is always the last character in aug assignments -> -1
|
||||
operator = copy.copy(first_operator)
|
||||
operator.value = operator.value[:-1]
|
||||
name = str(stmt.get_defined_names()[0])
|
||||
name = stmt.get_defined_names()[0].value
|
||||
left = context.py__getattribute__(
|
||||
name, position=stmt.start_pos, search_global=True)
|
||||
|
||||
@@ -175,7 +175,7 @@ class Evaluator(object):
|
||||
ordered = list(iterable.py__iter__(self, cn.infer(), cn))
|
||||
|
||||
for lazy_context in ordered:
|
||||
dct = {str(for_stmt.children[1]): lazy_context.infer()}
|
||||
dct = {for_stmt.children[1].value: lazy_context.infer()}
|
||||
with helpers.predefine_names(context, for_stmt, dct):
|
||||
t = self.eval_element(context, rhs)
|
||||
left = precedence.calculate(self, context, left, operator, t)
|
||||
@@ -210,8 +210,8 @@ class Evaluator(object):
|
||||
# names in the suite.
|
||||
if_names = helpers.get_names_of_node(if_stmt_test)
|
||||
element_names = helpers.get_names_of_node(element)
|
||||
str_element_names = [str(e) for e in element_names]
|
||||
if any(str(i) in str_element_names for i in if_names):
|
||||
str_element_names = [e.value for e in element_names]
|
||||
if any(i.value in str_element_names for i in if_names):
|
||||
for if_name in if_names:
|
||||
definitions = self.goto_definitions(context, if_name)
|
||||
# Every name that has multiple different definitions
|
||||
@@ -232,12 +232,12 @@ class Evaluator(object):
|
||||
new_name_dicts = list(original_name_dicts)
|
||||
for i, name_dict in enumerate(new_name_dicts):
|
||||
new_name_dicts[i] = name_dict.copy()
|
||||
new_name_dicts[i][str(if_name)] = set([definition])
|
||||
new_name_dicts[i][if_name.value] = set([definition])
|
||||
|
||||
name_dicts += new_name_dicts
|
||||
else:
|
||||
for name_dict in name_dicts:
|
||||
name_dict[str(if_name)] = definitions
|
||||
name_dict[if_name.value] = definitions
|
||||
if len(name_dicts) > 1:
|
||||
result = set()
|
||||
for name_dict in name_dicts:
|
||||
|
||||
@@ -190,7 +190,7 @@ def _check_for_exception_catch(node_context, jedi_name, exception, payload=None)
|
||||
key, lazy_context = args[1]
|
||||
names = list(lazy_context.infer())
|
||||
assert len(names) == 1 and isinstance(names[0], CompiledObject)
|
||||
assert names[0].obj == str(payload[1])
|
||||
assert names[0].obj == payload[1].value
|
||||
|
||||
# Check objects
|
||||
key, lazy_context = args[0]
|
||||
|
||||
@@ -188,8 +188,9 @@ def _execute_array_values(evaluator, array):
|
||||
def follow_param(module_context, param):
|
||||
def eval_docstring(docstring):
|
||||
return set(
|
||||
[p for param_str in _search_param_in_docstr(docstring, str(param.name))
|
||||
for p in _evaluate_for_statement_string(module_context, param_str)]
|
||||
p
|
||||
for param_str in _search_param_in_docstr(docstring, param.name.value)
|
||||
for p in _evaluate_for_statement_string(module_context, param_str)
|
||||
)
|
||||
func = param.get_parent_function()
|
||||
if func.type == 'lambdef':
|
||||
|
||||
@@ -118,7 +118,7 @@ class NameFinder(object):
|
||||
break
|
||||
|
||||
for filter in filters:
|
||||
names = filter.get(self._name)
|
||||
names = filter.get(self._string_name)
|
||||
if names:
|
||||
break
|
||||
debug.dbg('finder.filter_name "%s" in (%s): %s@%s', self._string_name,
|
||||
@@ -199,7 +199,7 @@ def _name_to_types(evaluator, context, tree_name):
|
||||
types = _apply_decorators(evaluator, context, node)
|
||||
elif typ == 'global_stmt':
|
||||
context = evaluator.create_context(context, tree_name)
|
||||
finder = NameFinder(evaluator, context, context, str(tree_name))
|
||||
finder = NameFinder(evaluator, context, context, tree_name.value)
|
||||
filters = finder.get_filters(search_global=True)
|
||||
# For global_stmt lookups, we only need the first possible scope,
|
||||
# which means the function itself.
|
||||
|
||||
@@ -63,7 +63,7 @@ def infer_import(context, tree_name, is_goto=False):
|
||||
if from_import_name is not None:
|
||||
types = unite(
|
||||
t.py__getattribute__(
|
||||
unicode(from_import_name),
|
||||
from_import_name.value if isinstance(from_import_name, tree.Name) else from_import_name,
|
||||
name_context=context,
|
||||
is_goto=is_goto
|
||||
) for t in types
|
||||
@@ -229,7 +229,9 @@ class Importer(object):
|
||||
@property
|
||||
def str_import_path(self):
|
||||
"""Returns the import path as pure strings instead of `Name`."""
|
||||
return tuple(str(name) for name in self.import_path)
|
||||
return tuple(
|
||||
name.value if isinstance(name, tree.Name) else name
|
||||
for name in self.import_path)
|
||||
|
||||
def sys_path_with_modifications(self):
|
||||
in_path = []
|
||||
@@ -262,7 +264,10 @@ class Importer(object):
|
||||
"""
|
||||
This method is very similar to importlib's `_gcd_import`.
|
||||
"""
|
||||
import_parts = [str(i) for i in import_path]
|
||||
import_parts = [
|
||||
i.value if isinstance(i, tree.Name) else i
|
||||
for i in import_path
|
||||
]
|
||||
|
||||
# Handle "magic" Flask extension imports:
|
||||
# ``flask.ext.foo`` is really ``flask_foo`` or ``flaskext.foo``.
|
||||
@@ -297,7 +302,7 @@ class Importer(object):
|
||||
# ``os.path``, because it's a very important one in Python
|
||||
# that is being achieved by messing with ``sys.modules`` in
|
||||
# ``os``.
|
||||
if [str(i) for i in import_path] == ['os', 'path']:
|
||||
if import_parts == ['os', 'path']:
|
||||
return parent_module.py__getattribute__('path')
|
||||
|
||||
try:
|
||||
|
||||
@@ -236,7 +236,7 @@ def get_params(evaluator, parent_context, func, var_args):
|
||||
result_params = []
|
||||
param_dict = {}
|
||||
for param in func.params:
|
||||
param_dict[str(param.name)] = param
|
||||
param_dict[param.name.value] = param
|
||||
unpacked_va = list(var_args.unpack(func))
|
||||
var_arg_iterator = common.PushBackIterator(iter(unpacked_va))
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ def calculate_children(evaluator, context, children):
|
||||
for operator in iterator:
|
||||
right = next(iterator)
|
||||
if operator.type == 'comp_op': # not in / is not
|
||||
operator = ' '.join(str(c.value) for c in operator.children)
|
||||
operator = ' '.join(c.value for c in operator.children)
|
||||
|
||||
# handle lazy evaluation of and/or here.
|
||||
if operator in ('and', 'or'):
|
||||
|
||||
@@ -397,7 +397,7 @@ class FunctionExecutionContext(context.TreeContext):
|
||||
ordered = iterable.py__iter__(evaluator, cn.infer(), cn)
|
||||
ordered = list(ordered)
|
||||
for lazy_context in ordered:
|
||||
dct = {str(for_stmt.children[1]): lazy_context.infer()}
|
||||
dct = {str(for_stmt.children[1].value): lazy_context.infer()}
|
||||
with helpers.predefine_names(self, for_stmt, dct):
|
||||
for yield_in_same_for_stmt in yields:
|
||||
for result in self._eval_yield(yield_in_same_for_stmt):
|
||||
|
||||
Reference in New Issue
Block a user