mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 14:34:31 +08:00
custom copy.copy and copy.deepcopy implementations to not confuse autocompletion (just return the first param)
This commit is contained in:
@@ -22,9 +22,15 @@ def execute(evaluator, obj, params):
|
||||
pass
|
||||
else:
|
||||
if obj.parent == compiled.builtin:
|
||||
module_name = 'builtins'
|
||||
elif isinstance(obj.parent, pr.Module):
|
||||
module_name = str(obj.parent.name)
|
||||
else:
|
||||
module_name = ''
|
||||
|
||||
# for now we just support builtin functions.
|
||||
try:
|
||||
return _implemented['builtins'][obj_name](evaluator, obj, params)
|
||||
return _implemented[module_name][obj_name](evaluator, obj, params)
|
||||
except KeyError:
|
||||
pass
|
||||
raise NotInStdLib()
|
||||
@@ -101,11 +107,21 @@ def builtins_reversed(evaluator, obj, params):
|
||||
return [er.Instance(evaluator, obj, objects)]
|
||||
|
||||
|
||||
def _return_first_param(evaluator, obj, params):
|
||||
if len(params) == 1:
|
||||
return _follow_param(evaluator, params, 0)
|
||||
return []
|
||||
|
||||
|
||||
_implemented = {
|
||||
'builtins': {
|
||||
'getattr': builtins_getattr,
|
||||
'type': builtins_type,
|
||||
'super': builtins_super,
|
||||
'reversed': builtins_reversed,
|
||||
}
|
||||
},
|
||||
'copy': {
|
||||
'copy': _return_first_param,
|
||||
'deepcopy': _return_first_param,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -127,3 +127,16 @@ import hashlib
|
||||
|
||||
#? ['md5']
|
||||
hashlib.md5
|
||||
|
||||
# -----------------
|
||||
# copy
|
||||
# -----------------
|
||||
|
||||
import copy
|
||||
a = copy.deepcopy(1)
|
||||
#? int()
|
||||
a
|
||||
|
||||
a = copy.copy()
|
||||
#?
|
||||
a
|
||||
|
||||
Reference in New Issue
Block a user