1
0
forked from VimPlug/jedi

Merge branch 'master' of github.com:davidhalter/jedi

This commit is contained in:
ANtlord
2020-04-18 14:25:24 +03:00
177 changed files with 6972 additions and 3225 deletions

View File

@@ -44,8 +44,6 @@ from operator import itemgetter as _itemgetter
from collections import OrderedDict
class {typename}(tuple):
'{typename}({arg_list})'
__slots__ = ()
_fields = {field_names!r}
@@ -160,7 +158,6 @@ def argument_clinic(string, want_value=False, want_context=False,
callback = kwargs.pop('callback')
assert not kwargs # Python 2...
debug.dbg('builtin start %s' % value, color='MAGENTA')
result = NO_VALUES
if want_context:
kwargs['context'] = arguments.context
if want_value:
@@ -473,13 +470,12 @@ def collections_namedtuple(value, arguments, callback):
return ValueSet([ClassValue(inference_state, parent_context, generated_class)])
class PartialObject(object):
def __init__(self, actual_value, arguments):
class PartialObject(ValueWrapper):
def __init__(self, actual_value, arguments, instance=None):
super(PartialObject, self).__init__(actual_value)
self._actual_value = actual_value
self._arguments = arguments
def __getattr__(self, name):
return getattr(self._actual_value, name)
self._instance = instance
def _get_function(self, unpacked_arguments):
key, lazy_value = next(unpacked_arguments, (None, None))
@@ -495,6 +491,8 @@ class PartialObject(object):
return []
arg_count = 0
if self._instance is not None:
arg_count = 1
keys = set()
for key, _ in unpacked_arguments:
if key is None:
@@ -509,9 +507,17 @@ class PartialObject(object):
return NO_VALUES
return func.execute(
MergedPartialArguments(self._arguments, arguments)
MergedPartialArguments(self._arguments, arguments, self._instance)
)
def py__get__(self, instance, class_value):
return ValueSet([self])
class PartialMethodObject(PartialObject):
def py__get__(self, instance, class_value):
return ValueSet([PartialObject(self._actual_value, self._arguments, instance)])
class PartialSignature(SignatureWrapper):
def __init__(self, wrapped_signature, skipped_arg_count, skipped_arg_set):
@@ -525,15 +531,18 @@ class PartialSignature(SignatureWrapper):
class MergedPartialArguments(AbstractArguments):
def __init__(self, partial_arguments, call_arguments):
def __init__(self, partial_arguments, call_arguments, instance=None):
self._partial_arguments = partial_arguments
self._call_arguments = call_arguments
self._instance = instance
def unpack(self, funcdef=None):
unpacked = self._partial_arguments.unpack(funcdef)
# Ignore this one, it's the function. It was checked before that it's
# there.
next(unpacked)
next(unpacked, None)
if self._instance is not None:
yield None, LazyKnownValue(self._instance)
for key_lazy_value in unpacked:
yield key_lazy_value
for key_lazy_value in self._call_arguments.unpack(funcdef):
@@ -547,6 +556,13 @@ def functools_partial(value, arguments, callback):
)
def functools_partialmethod(value, arguments, callback):
return ValueSet(
PartialMethodObject(instance, arguments)
for instance in value.py__call__(arguments)
)
@argument_clinic('first, /')
def _return_first_param(firsts):
return firsts
@@ -744,6 +760,7 @@ _implemented = {
},
'functools': {
'partial': functools_partial,
'partialmethod': functools_partialmethod,
'wraps': _functools_wraps,
},
'_weakref': {