mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
PY-8473 Fixed: Recognize copy() and deepcopy() methods in code insight
Add skeletons for copy.copy and copy.deepcopy
This commit is contained in:
19
python/helpers/python-skeletons/copy.py
Normal file
19
python/helpers/python-skeletons/copy.py
Normal file
@@ -0,0 +1,19 @@
|
||||
"""Skeleton for 'copy' stdlib module."""
|
||||
|
||||
|
||||
def copy(x):
|
||||
"""Return a shallow copy of x.
|
||||
|
||||
:type x: T
|
||||
:rtype: T
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def deepcopy(x):
|
||||
"""Return a deep copy of x.
|
||||
|
||||
:type x: T
|
||||
:rtype: T
|
||||
"""
|
||||
pass
|
||||
2
python/testData/types/CopyDotCopy/copy.py
Normal file
2
python/testData/types/CopyDotCopy/copy.py
Normal file
@@ -0,0 +1,2 @@
|
||||
def copy(x):
|
||||
pass
|
||||
2
python/testData/types/CopyDotDeepCopy/copy.py
Normal file
2
python/testData/types/CopyDotDeepCopy/copy.py
Normal file
@@ -0,0 +1,2 @@
|
||||
def deepcopy(x):
|
||||
pass
|
||||
@@ -1258,6 +1258,24 @@ public class PyTypeTest extends PyTestCase {
|
||||
"expr = defaultdict(lambda: [])['x']\n");
|
||||
}
|
||||
|
||||
// PY-8473
|
||||
public void testCopyDotCopy() {
|
||||
doMultiFileTest("A",
|
||||
"import copy\n" +
|
||||
"class A(object):\n" +
|
||||
" pass\n" +
|
||||
"expr = copy.copy(A())\n");
|
||||
}
|
||||
|
||||
// PY-8473
|
||||
public void testCopyDotDeepCopy() {
|
||||
doMultiFileTest("A",
|
||||
"import copy\n" +
|
||||
"class A(object):\n" +
|
||||
" pass\n" +
|
||||
"expr = copy.deepcopy(A())\n");
|
||||
}
|
||||
|
||||
private static List<TypeEvalContext> getTypeEvalContexts(@NotNull PyExpression element) {
|
||||
return ImmutableList.of(TypeEvalContext.codeAnalysis(element.getProject(), element.getContainingFile()).withTracing(),
|
||||
TypeEvalContext.userInitiated(element.getProject(), element.getContainingFile()).withTracing());
|
||||
|
||||
Reference in New Issue
Block a user