1
0
forked from VimPlug/jedi

more builtin replacements with compiled

This commit is contained in:
Dave Halter
2014-01-09 02:02:33 +01:00
parent df6317f8b0
commit d2358c60b7
3 changed files with 10 additions and 10 deletions

View File

@@ -76,7 +76,6 @@ from jedi import common
from jedi.parser import representation as pr from jedi.parser import representation as pr
from jedi import debug from jedi import debug
from jedi.evaluate import representation as er from jedi.evaluate import representation as er
from jedi.evaluate import builtin
from jedi.evaluate import imports from jedi.evaluate import imports
from jedi.evaluate import recursion from jedi.evaluate import recursion
from jedi.evaluate import iterable from jedi.evaluate import iterable
@@ -312,7 +311,7 @@ class Evaluator(object):
search_global=True) search_global=True)
else: else:
# for pr.Literal # for pr.Literal
scopes = self.find_types(builtin.Builtin.scope, current.type_as_string()) scopes = self.find_types(compiled.builtin, current.type_as_string())
# Make instances of those number/string objects. # Make instances of those number/string objects.
scopes = itertools.chain.from_iterable( scopes = itertools.chain.from_iterable(
self.execute(s, (current.value,)) for s in scopes self.execute(s, (current.value,)) for s in scopes

View File

@@ -7,7 +7,7 @@ from jedi import common
from jedi import settings from jedi import settings
from jedi.evaluate import representation as er from jedi.evaluate import representation as er
from jedi.evaluate import dynamic from jedi.evaluate import dynamic
from jedi.evaluate import builtin from jedi.evaluate import compiled
from jedi.evaluate import docstrings from jedi.evaluate import docstrings
from jedi.evaluate import iterable from jedi.evaluate import iterable
@@ -82,7 +82,7 @@ class NameFinder(object):
def _check_getattr(self, inst): def _check_getattr(self, inst):
"""Checks for both __getattr__ and __getattribute__ methods""" """Checks for both __getattr__ and __getattribute__ methods"""
result = [] result = []
module = builtin.Builtin.scope module = compiled.builtin
# str is important to lose the NamePart! # str is important to lose the NamePart!
name = pr.String(module, "'%s'" % self.name_str, (0, 0), (0, 0), inst) name = pr.String(module, "'%s'" % self.name_str, (0, 0), (0, 0), inst)
with common.ignored(KeyError): with common.ignored(KeyError):
@@ -242,7 +242,8 @@ class NameFinder(object):
c = r.expression_list()[0] c = r.expression_list()[0]
if c in ('*', '**'): if c in ('*', '**'):
t = 'tuple' if c == '*' else 'dict' t = 'tuple' if c == '*' else 'dict'
res_new = evaluator.execute(evaluator.find_types(builtin.Builtin.scope, t)[0]) typ = evaluator.find_types(compiled.builtin, t)[0]
res_new = evaluator.execute(typ)
if not r.assignment_details: if not r.assignment_details:
# this means that there are no default params, # this means that there are no default params,
# so just ignore it. # so just ignore it.

View File

@@ -16,7 +16,7 @@ from jedi.parser import representation as pr
from jedi import debug from jedi import debug
from jedi import common from jedi import common
from jedi.evaluate.cache import memoize_default, CachedMetaClass from jedi.evaluate.cache import memoize_default, CachedMetaClass
from jedi.evaluate import builtin from jedi.evaluate import compiled
from jedi.evaluate import recursion from jedi.evaluate import recursion
from jedi.evaluate import iterable from jedi.evaluate import iterable
from jedi.evaluate import docstrings from jedi.evaluate import docstrings
@@ -49,7 +49,7 @@ class Instance(use_metaclass(CachedMetaClass, Executable)):
def __init__(self, evaluator, base, var_args=()): def __init__(self, evaluator, base, var_args=()):
super(Instance, self).__init__(evaluator, base, var_args) super(Instance, self).__init__(evaluator, base, var_args)
if str(base.name) in ['list', 'set'] \ if str(base.name) in ['list', 'set'] \
and builtin.Builtin.scope == base.get_parent_until(): and compiled.builtin == base.get_parent_until():
# compare the module path with the builtin name. # compare the module path with the builtin name.
self.var_args = iterable.check_array_instances(evaluator, self) self.var_args = iterable.check_array_instances(evaluator, self)
else: else:
@@ -256,9 +256,9 @@ class Class(use_metaclass(CachedMetaClass, pr.IsScope)):
debug.warning('Received non class, as a super class') debug.warning('Received non class, as a super class')
continue # Just ignore other stuff (user input error). continue # Just ignore other stuff (user input error).
supers.append(cls) supers.append(cls)
if not supers and self.base.parent != builtin.Builtin.scope: if not supers and self.base.parent != compiled.builtin:
# add `object` to classes # add `object` to classes
supers += self._evaluator.find_types(builtin.Builtin.scope, 'object') supers += self._evaluator.find_types(compiled.builtin, 'object')
return supers return supers
@memoize_default(default=()) @memoize_default(default=())
@@ -286,7 +286,7 @@ class Class(use_metaclass(CachedMetaClass, pr.IsScope)):
@memoize_default(default=()) @memoize_default(default=())
def get_defined_names(self): def get_defined_names(self):
result = self.instance_names() result = self.instance_names()
type_cls = self._evaluator.find_types(builtin.Builtin.scope, 'type')[0] type_cls = self._evaluator.find_types(compiled.builtin, 'type')[0]
return result + type_cls.base.get_defined_names() return result + type_cls.base.get_defined_names()
def get_subscope_by_name(self, name): def get_subscope_by_name(self, name):