From cb2b4ae26fe9408e634bcc8ebacf97e4b67c87e2 Mon Sep 17 00:00:00 2001 From: Petr Date: Wed, 23 Apr 2025 18:11:15 +0200 Subject: [PATCH] PY-76885 Conformance test failure: constructors_call_metaclass.py Added multi-file test. GitOrigin-RevId: e3105c8036c90b9571143ce7b2cc970813a5ed3b --- .../a.py | 9 +++++++++ .../m.py | 4 ++++ .../inspections/Py3ArgumentListInspectionTest.java | 4 ++++ 3 files changed, 17 insertions(+) create mode 100644 python/testData/inspections/PyArgumentListInspection/MetaclassDunderCallReturnTypeIncompatibleWithClassBeingConstructedMultiFile/a.py create mode 100644 python/testData/inspections/PyArgumentListInspection/MetaclassDunderCallReturnTypeIncompatibleWithClassBeingConstructedMultiFile/m.py diff --git a/python/testData/inspections/PyArgumentListInspection/MetaclassDunderCallReturnTypeIncompatibleWithClassBeingConstructedMultiFile/a.py b/python/testData/inspections/PyArgumentListInspection/MetaclassDunderCallReturnTypeIncompatibleWithClassBeingConstructedMultiFile/a.py new file mode 100644 index 000000000000..8a0421f1dbcc --- /dev/null +++ b/python/testData/inspections/PyArgumentListInspection/MetaclassDunderCallReturnTypeIncompatibleWithClassBeingConstructedMultiFile/a.py @@ -0,0 +1,9 @@ +from typing import Self +from m import Meta + + +class MyClass(metaclass=Meta): + def __new__(cls, p) -> Self: ... + + +expr = MyClass() diff --git a/python/testData/inspections/PyArgumentListInspection/MetaclassDunderCallReturnTypeIncompatibleWithClassBeingConstructedMultiFile/m.py b/python/testData/inspections/PyArgumentListInspection/MetaclassDunderCallReturnTypeIncompatibleWithClassBeingConstructedMultiFile/m.py new file mode 100644 index 000000000000..6d3434f8cc73 --- /dev/null +++ b/python/testData/inspections/PyArgumentListInspection/MetaclassDunderCallReturnTypeIncompatibleWithClassBeingConstructedMultiFile/m.py @@ -0,0 +1,4 @@ +class Meta(type): + def call(cls, *args, **kwargs) -> object: ... + + __call__ = call diff --git a/python/testSrc/com/jetbrains/python/inspections/Py3ArgumentListInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/Py3ArgumentListInspectionTest.java index 6f0c98b4640c..6d9b0af2d9c5 100644 --- a/python/testSrc/com/jetbrains/python/inspections/Py3ArgumentListInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/Py3ArgumentListInspectionTest.java @@ -421,6 +421,10 @@ public class Py3ArgumentListInspectionTest extends PyInspectionTestCase { """); } + public void testMetaclassDunderCallReturnTypeIncompatibleWithClassBeingConstructedMultiFile() { + doMultiFileTest(); + } + public void testMetaclassNotAnnotatedDunderCall() { doTestByText(""" from typing import Self