forked from VimPlug/jedi
more unicode casts instead of str casts
This commit is contained in:
@@ -285,14 +285,14 @@ class Script(object):
|
|||||||
if next(context) in ('class', 'def'):
|
if next(context) in ('class', 'def'):
|
||||||
user_scope = self.parser.user_scope
|
user_scope = self.parser.user_scope
|
||||||
definitions = set([user_scope.name])
|
definitions = set([user_scope.name])
|
||||||
search_name = str(user_scope.name)
|
search_name = unicode(user_scope.name)
|
||||||
elif isinstance(self.parser.user_stmt, parsing.Import):
|
elif isinstance(self.parser.user_stmt, parsing.Import):
|
||||||
s, name_part = self._get_on_import_stmt()
|
s, name_part = self._get_on_import_stmt()
|
||||||
try:
|
try:
|
||||||
definitions = [s.follow(is_goto=True)[0]]
|
definitions = [s.follow(is_goto=True)[0]]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
definitions = []
|
definitions = []
|
||||||
search_name = str(name_part)
|
search_name = unicode(name_part)
|
||||||
|
|
||||||
if add_import_name:
|
if add_import_name:
|
||||||
import_name = self.parser.user_stmt.get_defined_names()
|
import_name = self.parser.user_stmt.get_defined_names()
|
||||||
@@ -320,7 +320,7 @@ class Script(object):
|
|||||||
and self.pos < user_stmt.get_assignment_calls().start_pos:
|
and self.pos < user_stmt.get_assignment_calls().start_pos:
|
||||||
# the search_name might be before `=`
|
# the search_name might be before `=`
|
||||||
definitions = [v for v in user_stmt.set_vars
|
definitions = [v for v in user_stmt.set_vars
|
||||||
if str(v) == search_name]
|
if unicode(v) == search_name]
|
||||||
if not isinstance(user_stmt, parsing.Import):
|
if not isinstance(user_stmt, parsing.Import):
|
||||||
# import case is looked at with add_import_name option
|
# import case is looked at with add_import_name option
|
||||||
definitions = dynamic.related_name_add_import_modules(definitions,
|
definitions = dynamic.related_name_add_import_modules(definitions,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from _compatibility import unicode
|
||||||
import cache
|
import cache
|
||||||
import dynamic
|
import dynamic
|
||||||
import helpers
|
import helpers
|
||||||
@@ -51,7 +52,7 @@ class BaseDefinition(object):
|
|||||||
self.is_keyword = isinstance(definition, keywords.Keyword)
|
self.is_keyword = isinstance(definition, keywords.Keyword)
|
||||||
|
|
||||||
# generate a path to the definition
|
# generate a path to the definition
|
||||||
self.module_path = str(definition.get_parent_until().path)
|
self.module_path = unicode(definition.get_parent_until().path)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def type(self):
|
def type(self):
|
||||||
@@ -104,20 +105,20 @@ class BaseDefinition(object):
|
|||||||
def raw_doc(self):
|
def raw_doc(self):
|
||||||
""" Returns the raw docstring `__doc__` for any object """
|
""" Returns the raw docstring `__doc__` for any object """
|
||||||
try:
|
try:
|
||||||
return str(self.definition.docstr)
|
return unicode(self.definition.docstr)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def description(self):
|
def description(self):
|
||||||
return str(self.definition)
|
return unicode(self.definition)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def full_name(self):
|
def full_name(self):
|
||||||
"""
|
"""
|
||||||
Returns the path to a certain class/function, see #61.
|
Returns the path to a certain class/function, see #61.
|
||||||
"""
|
"""
|
||||||
path = [str(p) for p in self.path]
|
path = [unicode(p) for p in self.path]
|
||||||
# TODO add further checks, the mapping should only occur on stdlib.
|
# TODO add further checks, the mapping should only occur on stdlib.
|
||||||
try:
|
try:
|
||||||
path[0] = self._mapping[path[0]]
|
path[0] = self._mapping[path[0]]
|
||||||
@@ -174,7 +175,7 @@ class Completion(BaseDefinition):
|
|||||||
|
|
||||||
would return 'isinstance'.
|
would return 'isinstance'.
|
||||||
"""
|
"""
|
||||||
return str(self.name.names[-1])
|
return unicode(self.name.names[-1])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def description(self):
|
def description(self):
|
||||||
@@ -187,7 +188,7 @@ class Completion(BaseDefinition):
|
|||||||
if t == 'Statement' or t == 'Import':
|
if t == 'Statement' or t == 'Import':
|
||||||
desc = self.definition.get_code(False)
|
desc = self.definition.get_code(False)
|
||||||
else:
|
else:
|
||||||
desc = '.'.join(str(p) for p in self.path)
|
desc = '.'.join(unicode(p) for p in self.path)
|
||||||
|
|
||||||
line_nr = '' if self.in_builtin_module else '@%s' % self.line_nr
|
line_nr = '' if self.in_builtin_module else '@%s' % self.line_nr
|
||||||
return '%s: %s%s' % (t, desc, line_nr)
|
return '%s: %s%s' % (t, desc, line_nr)
|
||||||
@@ -237,9 +238,9 @@ class Definition(BaseDefinition):
|
|||||||
if isinstance(d, evaluate.Array):
|
if isinstance(d, evaluate.Array):
|
||||||
d = 'class ' + d.type
|
d = 'class ' + d.type
|
||||||
elif isinstance(d, (parsing.Class, evaluate.Class, evaluate.Instance)):
|
elif isinstance(d, (parsing.Class, evaluate.Class, evaluate.Instance)):
|
||||||
d = 'class ' + str(d.name)
|
d = 'class ' + unicode(d.name)
|
||||||
elif isinstance(d, (evaluate.Function, evaluate.parsing.Function)):
|
elif isinstance(d, (evaluate.Function, evaluate.parsing.Function)):
|
||||||
d = 'def ' + str(d.name)
|
d = 'def ' + unicode(d.name)
|
||||||
elif isinstance(d, evaluate.parsing.Module):
|
elif isinstance(d, evaluate.parsing.Module):
|
||||||
# only show module name
|
# only show module name
|
||||||
d = 'module %s' % self.module_name
|
d = 'module %s' % self.module_name
|
||||||
@@ -268,7 +269,7 @@ class RelatedName(BaseDefinition):
|
|||||||
def __init__(self, name_part, scope):
|
def __init__(self, name_part, scope):
|
||||||
super(RelatedName, self).__init__(scope, name_part.start_pos)
|
super(RelatedName, self).__init__(scope, name_part.start_pos)
|
||||||
self.name_part = name_part
|
self.name_part = name_part
|
||||||
self.text = str(name_part)
|
self.text = unicode(name_part)
|
||||||
self.end_pos = name_part.end_pos
|
self.end_pos = name_part.end_pos
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -317,7 +318,7 @@ class CallDef(object):
|
|||||||
@property
|
@property
|
||||||
def call_name(self):
|
def call_name(self):
|
||||||
""" The name (e.g. 'isinstance') as a string. """
|
""" The name (e.g. 'isinstance') as a string. """
|
||||||
return str(self.executable.name)
|
return unicode(self.executable.name)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def module(self):
|
def module(self):
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ as input and ignores just all the non-python stuff. Basically you could feed it
|
|||||||
a perl script, and it should still work (which means throw no error).
|
a perl script, and it should still work (which means throw no error).
|
||||||
TODO remove docstr params from Scope.__init__()
|
TODO remove docstr params from Scope.__init__()
|
||||||
"""
|
"""
|
||||||
from _compatibility import (next, literal_eval, StringIO,
|
from _compatibility import (next, literal_eval, StringIO, unicode,
|
||||||
property, cleandoc, Python3Method)
|
property, cleandoc, Python3Method)
|
||||||
|
|
||||||
import tokenize
|
import tokenize
|
||||||
@@ -1471,7 +1471,7 @@ class PyFuzzyParser(object):
|
|||||||
:rtype: (Statement, str)
|
:rtype: (Statement, str)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
string = ''
|
string = unicode('')
|
||||||
set_vars = []
|
set_vars = []
|
||||||
used_funcs = []
|
used_funcs = []
|
||||||
used_vars = []
|
used_vars = []
|
||||||
@@ -1634,7 +1634,7 @@ class PyFuzzyParser(object):
|
|||||||
def __next__(self):
|
def __next__(self):
|
||||||
""" Generate the next tokenize pattern. """
|
""" Generate the next tokenize pattern. """
|
||||||
try:
|
try:
|
||||||
type, tok, self.start_pos, self.end_pos, \
|
typ, tok, self.start_pos, self.end_pos, \
|
||||||
self.parserline = next(self.gen)
|
self.parserline = next(self.gen)
|
||||||
except (StopIteration, common.MultiLevelStopIteration):
|
except (StopIteration, common.MultiLevelStopIteration):
|
||||||
# on finish, set end_pos correctly
|
# on finish, set end_pos correctly
|
||||||
@@ -1651,7 +1651,7 @@ class PyFuzzyParser(object):
|
|||||||
(self.parserline.replace('\n', ''), repr(self.scope)))
|
(self.parserline.replace('\n', ''), repr(self.scope)))
|
||||||
self.user_scope = self.scope
|
self.user_scope = self.scope
|
||||||
self.last_token = self.current
|
self.last_token = self.current
|
||||||
self.current = (type, tok)
|
self.current = (typ, tok)
|
||||||
return self.current
|
return self.current
|
||||||
|
|
||||||
def parse(self):
|
def parse(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user