diff --git a/python/testData/types/ImportedBoundMethodDecoratedWithParamSpec/mod.py b/python/testData/types/ImportedBoundMethodDecoratedWithParamSpec/mod.py new file mode 100644 index 000000000000..9dbe75f88fb2 --- /dev/null +++ b/python/testData/types/ImportedBoundMethodDecoratedWithParamSpec/mod.py @@ -0,0 +1,11 @@ +from typing import Callable + + +def outer_decorator[**P, T](f: Callable[P, T]) -> Callable[P, T]: + return f + + +class NonWorkingClass: + @outer_decorator + def add_two(self, x: float, y: float) -> float: + return x + y diff --git a/python/testSrc/com/jetbrains/python/PyTypingTest.java b/python/testSrc/com/jetbrains/python/PyTypingTest.java index c75addb6c0ef..24946f5ccbb7 100644 --- a/python/testSrc/com/jetbrains/python/PyTypingTest.java +++ b/python/testSrc/com/jetbrains/python/PyTypingTest.java @@ -6808,6 +6808,34 @@ public class PyTypingTest extends PyTestCase { """); } + // PY-85027 + public void testImportedBoundMethodDecoratedWithParamSpec() { + doMultiFileStubAwareTest("(x: float, y: float) -> float", """ + from mod import NonWorkingClass + + expr = NonWorkingClass().add_two + """); + } + + // PY-85027 + public void testBoundMethodDecoratedWithParamSpec() { + doTest("(x: float, y: float) -> float", """ + from typing import Callable + + def outer_decorator[**P, T](f: Callable[P, T]) -> Callable[P, T]: + return f + + + class NonWorkingClass: + @outer_decorator + def add_two(self, x: float, y: float) -> float: + return x + y + + + expr = NonWorkingClass().add_two + """); + } + private void doTestNoInjectedText(@NotNull String text) { myFixture.configureByText(PythonFileType.INSTANCE, text); final InjectedLanguageManager languageManager = InjectedLanguageManager.getInstance(myFixture.getProject()); diff --git a/python/testSrc/com/jetbrains/python/inspections/Py3ArgumentListInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/Py3ArgumentListInspectionTest.java index 4c724e00f462..0b1dda76eb05 100644 --- a/python/testSrc/com/jetbrains/python/inspections/Py3ArgumentListInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/Py3ArgumentListInspectionTest.java @@ -644,4 +644,22 @@ public class Py3ArgumentListInspectionTest extends PyInspectionTestCase { public void testImportedDecoratedFunctionWithParamSpec() { doMultiFileTest(); } + + // PY-85027 + public void testBoundMethodDecoratedWithParamSpec() { + doTestByText(""" + from typing import Callable + + def outer_decorator[**P, T](f: Callable[P, T]) -> Callable[P, T]: + return f + + class NonWorkingClass: + @outer_decorator + def add_two(self, x: float, y: float) -> float: + return x + y + + + NonWorkingClass().add_two() + """); + } }