Merge branch 'dev' of github.com:davidhalter/jedi into dev

This commit is contained in:
David Halter
2013-07-17 14:01:13 +02:00
21 changed files with 203 additions and 208 deletions

View File

@@ -42,8 +42,8 @@ import sys
# imports and circular imports... Just avoid it: # imports and circular imports... Just avoid it:
sys.path.insert(0, __path__[0]) sys.path.insert(0, __path__[0])
from .api import Script, Interpreter, NotFoundError, set_debug_function, \ from .api import Script, Interpreter, NotFoundError, set_debug_function
preload_module, defined_names from .api import preload_module, defined_names
from . import settings from . import settings
sys.path.pop(0) sys.path.pop(0)

View File

@@ -33,7 +33,6 @@ import builtin
class NotFoundError(Exception): class NotFoundError(Exception):
"""A custom error to avoid catching the wrong exceptions.""" """A custom error to avoid catching the wrong exceptions."""
pass
class Script(object): class Script(object):

View File

@@ -376,7 +376,6 @@ class Completion(BaseDefinition):
warnings.warn("Use name instead.", DeprecationWarning) warnings.warn("Use name instead.", DeprecationWarning)
return self.name return self.name
@property @property
def description(self): def description(self):
""" """

View File

@@ -321,7 +321,7 @@ def _generate_code(scope, mixin_funcs={}, depth=0):
file_type = io.TextIOWrapper file_type = io.TextIOWrapper
else: else:
file_type = types.FileType file_type = types.FileType
if type(value) == file_type: if isinstance(value, file_type):
value = 'open()' value = 'open()'
elif name == 'None': elif name == 'None':
value = '' value = ''
@@ -336,13 +336,6 @@ def _generate_code(scope, mixin_funcs={}, depth=0):
value = '%s.%s' % (mod, value) value = '%s.%s' % (mod, value)
code += '%s = %s\n' % (name, value) code += '%s = %s\n' % (name, value)
if depth == 0:
#with open('writeout.py', 'w') as f:
# f.write(code)
#import sys
#sys.stdout.write(code)
#exit()
pass
return code return code

View File

@@ -403,7 +403,9 @@ class ArrayInstance(pr.Base):
if self.var_args.start_pos != array.var_args.start_pos: if self.var_args.start_pos != array.var_args.start_pos:
items += array.iter_content() items += array.iter_content()
else: else:
debug.warning('ArrayInstance recursion', self.var_args) debug.warning(
'ArrayInstance recursion',
self.var_args)
continue continue
items += evaluate.get_iterator_types([typ]) items += evaluate.get_iterator_types([typ])
@@ -524,7 +526,7 @@ def check_statement_information(stmt, search_name):
# this might be removed if we analyze and, etc # this might be removed if we analyze and, etc
assert len(commands) == 1 assert len(commands) == 1
call = commands[0] call = commands[0]
assert type(call) == pr.Call and str(call.name) == 'isinstance' assert type(call) is pr.Call and str(call.name) == 'isinstance'
assert bool(call.execution) assert bool(call.execution)
# isinstance check # isinstance check

View File

@@ -170,8 +170,7 @@ def get_names_of_scope(scope, position=None, star_search=True,
if not (scope != non_flow and scope.isinstance(pr.Class) if not (scope != non_flow and scope.isinstance(pr.Class)
or scope.isinstance(pr.Flow) or scope.isinstance(pr.Flow)
or scope.isinstance(er.Instance) or scope.isinstance(er.Instance)
and non_flow.isinstance(er.Function) and non_flow.isinstance(er.Function)):
):
try: try:
if isinstance(scope, er.Instance): if isinstance(scope, er.Instance):
for g in scope.scope_generator(): for g in scope.scope_generator():

View File

@@ -53,7 +53,9 @@ class Executable(pr.IsScope):
class Instance(use_metaclass(cache.CachedMetaClass, Executable)): class Instance(use_metaclass(cache.CachedMetaClass, Executable)):
""" This class is used to evaluate instances. """ """ This class is used to evaluate instances. """
def __init__(self, base, var_args=()): def __init__(self, base, var_args=()):
super(Instance, self).__init__(base, var_args) super(Instance, self).__init__(base, var_args)
if str(base.name) in ['list', 'set'] \ if str(base.name) in ['list', 'set'] \
@@ -641,7 +643,7 @@ class Execution(Executable):
call = key_stmt.get_commands()[0] call = key_stmt.get_commands()[0]
if isinstance(call, pr.Name): if isinstance(call, pr.Name):
yield call, value_stmt yield call, value_stmt
elif type(call) == pr.Call: elif type(call) is pr.Call:
yield call.name, value_stmt yield call.name, value_stmt
# Normal arguments (including key arguments). # Normal arguments (including key arguments).
else: else:

View File

@@ -136,7 +136,7 @@ class ModuleWithCursor(Module):
self._line_length = len(line) self._line_length = len(line)
line = line + '\n' line = line + '\n'
# add lines with a backslash at the end # add lines with a backslash at the end
while 1: while True:
self._line_temp -= 1 self._line_temp -= 1
last_line = self.get_line(self._line_temp) last_line = self.get_line(self._line_temp)
if last_line and last_line[-1] == '\\': if last_line and last_line[-1] == '\\':

View File

@@ -532,7 +532,7 @@ class Parser(object):
defunct = False defunct = False
# take care for relative imports # take care for relative imports
relative_count = 0 relative_count = 0
while 1: while True:
token_type, tok = self.next() token_type, tok = self.next()
if tok != '.': if tok != '.':
break break

View File

@@ -208,7 +208,8 @@ def generate_tokens(readline):
yield TokenInfo(NL, line[nl_pos:], yield TokenInfo(NL, line[nl_pos:],
(lnum, nl_pos), (lnum, len(line)), line) (lnum, nl_pos), (lnum, len(line)), line)
else: else:
yield TokenInfo((NL, COMMENT)[line[pos] == '#'], line[pos:], yield TokenInfo(
(NL, COMMENT)[line[pos] == '#'], line[pos:],
(lnum, pos), (lnum, len(line)), line) (lnum, pos), (lnum, len(line)), line)
continue continue

View File

@@ -7,7 +7,7 @@ The twisted equivalent of this module is ``twisted.trial._synctest``.
""" """
from __future__ import absolute_import from __future__ import absolute_import
import unittest # this is stdlib unittest, but jedi gets the local one import unittest
class Assertions(unittest.TestCase): class Assertions(unittest.TestCase):