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,11 +22,17 @@ def execute(evaluator, obj, params):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if obj.parent == compiled.builtin:
|
if obj.parent == compiled.builtin:
|
||||||
# for now we just support builtin functions.
|
module_name = 'builtins'
|
||||||
try:
|
elif isinstance(obj.parent, pr.Module):
|
||||||
return _implemented['builtins'][obj_name](evaluator, obj, params)
|
module_name = str(obj.parent.name)
|
||||||
except KeyError:
|
else:
|
||||||
pass
|
module_name = ''
|
||||||
|
|
||||||
|
# for now we just support builtin functions.
|
||||||
|
try:
|
||||||
|
return _implemented[module_name][obj_name](evaluator, obj, params)
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
raise NotInStdLib()
|
raise NotInStdLib()
|
||||||
|
|
||||||
|
|
||||||
@@ -101,11 +107,21 @@ def builtins_reversed(evaluator, obj, params):
|
|||||||
return [er.Instance(evaluator, obj, objects)]
|
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 = {
|
_implemented = {
|
||||||
'builtins': {
|
'builtins': {
|
||||||
'getattr': builtins_getattr,
|
'getattr': builtins_getattr,
|
||||||
'type': builtins_type,
|
'type': builtins_type,
|
||||||
'super': builtins_super,
|
'super': builtins_super,
|
||||||
'reversed': builtins_reversed,
|
'reversed': builtins_reversed,
|
||||||
}
|
},
|
||||||
|
'copy': {
|
||||||
|
'copy': _return_first_param,
|
||||||
|
'deepcopy': _return_first_param,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,3 +127,16 @@ import hashlib
|
|||||||
|
|
||||||
#? ['md5']
|
#? ['md5']
|
||||||
hashlib.md5
|
hashlib.md5
|
||||||
|
|
||||||
|
# -----------------
|
||||||
|
# copy
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
import copy
|
||||||
|
a = copy.deepcopy(1)
|
||||||
|
#? int()
|
||||||
|
a
|
||||||
|
|
||||||
|
a = copy.copy()
|
||||||
|
#?
|
||||||
|
a
|
||||||
|
|||||||
Reference in New Issue
Block a user