diff --git a/python/testData/paramInfo/OverloadsInImportedModule/a.py b/python/testData/paramInfo/OverloadsInImportedModule/a.py new file mode 100644 index 000000000000..5dc01f5f29f7 --- /dev/null +++ b/python/testData/paramInfo/OverloadsInImportedModule/a.py @@ -0,0 +1,3 @@ +import b + +b.foo() \ No newline at end of file diff --git a/python/testData/paramInfo/OverloadsInImportedModule/b.py b/python/testData/paramInfo/OverloadsInImportedModule/b.py new file mode 100644 index 000000000000..d5e3ab93dc5e --- /dev/null +++ b/python/testData/paramInfo/OverloadsInImportedModule/b.py @@ -0,0 +1,2 @@ +def foo(a, b): + pass \ No newline at end of file diff --git a/python/testData/paramInfo/OverloadsInImportedModule/b.pyi b/python/testData/paramInfo/OverloadsInImportedModule/b.pyi new file mode 100644 index 000000000000..099586670567 --- /dev/null +++ b/python/testData/paramInfo/OverloadsInImportedModule/b.pyi @@ -0,0 +1,7 @@ +from typing import overload + +@overload +def foo(a: str, b: str) -> str: ... + +@overload +def foo(a: int, b: int) -> str: ... \ No newline at end of file diff --git a/python/testData/paramInfo/OverloadsWithDifferentNumberOfArgumentsInImportedModule/a.py b/python/testData/paramInfo/OverloadsWithDifferentNumberOfArgumentsInImportedModule/a.py new file mode 100644 index 000000000000..5dc01f5f29f7 --- /dev/null +++ b/python/testData/paramInfo/OverloadsWithDifferentNumberOfArgumentsInImportedModule/a.py @@ -0,0 +1,3 @@ +import b + +b.foo() \ No newline at end of file diff --git a/python/testData/paramInfo/OverloadsWithDifferentNumberOfArgumentsInImportedModule/b.py b/python/testData/paramInfo/OverloadsWithDifferentNumberOfArgumentsInImportedModule/b.py new file mode 100644 index 000000000000..fba27b6b9743 --- /dev/null +++ b/python/testData/paramInfo/OverloadsWithDifferentNumberOfArgumentsInImportedModule/b.py @@ -0,0 +1,2 @@ +def foo(a, b=None): + pass \ No newline at end of file diff --git a/python/testData/paramInfo/OverloadsWithDifferentNumberOfArgumentsInImportedModule/b.pyi b/python/testData/paramInfo/OverloadsWithDifferentNumberOfArgumentsInImportedModule/b.pyi new file mode 100644 index 000000000000..8abb4cdd8f47 --- /dev/null +++ b/python/testData/paramInfo/OverloadsWithDifferentNumberOfArgumentsInImportedModule/b.pyi @@ -0,0 +1,7 @@ +from typing import overload + +@overload +def foo(a: str, b: str) -> str: ... + +@overload +def foo(a: int) -> str: ... \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyParameterInfoTest.java b/python/testSrc/com/jetbrains/python/PyParameterInfoTest.java index 4ea200ad2f2a..dcc148960493 100644 --- a/python/testSrc/com/jetbrains/python/PyParameterInfoTest.java +++ b/python/testSrc/com/jetbrains/python/PyParameterInfoTest.java @@ -487,6 +487,22 @@ public class PyParameterInfoTest extends LightMarkedTestCase { ); } + public void testOverloadsInImportedModule() { + myFixture.copyDirectoryToProject("typing", ""); + + runWithLanguageLevel( + LanguageLevel.PYTHON35, + () -> { + final int offset = loadMultiFileTest(1).get("").getTextOffset(); + + final List texts = Arrays.asList("a: int, b: int", "a: str, b: str"); + final List highlighted = Arrays.asList(new String[]{"a: int, "}, new String[]{"a: str, "}); + + feignCtrlP(offset).check(texts, highlighted, Arrays.asList(ArrayUtil.EMPTY_STRING_ARRAY, ArrayUtil.EMPTY_STRING_ARRAY)); + } + ); + } + public void testOverloadsWithDifferentNumberOfArgumentsInImportedClass() { myFixture.copyDirectoryToProject("typing", ""); @@ -504,6 +520,22 @@ public class PyParameterInfoTest extends LightMarkedTestCase { ); } + public void testOverloadsWithDifferentNumberOfArgumentsInImportedModule() { + myFixture.copyDirectoryToProject("typing", ""); + + runWithLanguageLevel( + LanguageLevel.PYTHON35, + () -> { + final int offset = loadMultiFileTest(1).get("").getTextOffset(); + + final List texts = Arrays.asList("a: int", "a: str, b: str"); + final List highlighted = Arrays.asList(new String[]{"a: int"}, new String[]{"a: str, "}); + + feignCtrlP(offset).check(texts, highlighted, Arrays.asList(ArrayUtil.EMPTY_STRING_ARRAY, ArrayUtil.EMPTY_STRING_ARRAY)); + } + ); + } + /** * Imitates pressing of Ctrl+P; fails if results are not as expected. * @param offset offset of 'cursor' where Ctrl+P is pressed.