custom copy.copy and copy.deepcopy implementations to not confuse autocompletion (just return the first param)

This commit is contained in:
Dave Halter
2014-06-27 11:49:26 +02:00
parent 8cd7f9a288
commit cf1fd691da
2 changed files with 35 additions and 6 deletions

View File

@@ -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,
},
}

View File

@@ -127,3 +127,16 @@ import hashlib
#? ['md5']
hashlib.md5
# -----------------
# copy
# -----------------
import copy
a = copy.deepcopy(1)
#? int()
a
a = copy.copy()
#?
a