mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix return type for dataclass callable type (PY-28442)
This commit is contained in:
@@ -108,7 +108,7 @@ class PyDataclassTypeProvider : PyTypeProviderBase() {
|
||||
.mapNotNull { fieldToParameter(cls, it, dataclassParameters.type, ellipsis, context) }
|
||||
.toList()
|
||||
|
||||
return PyCallableTypeImpl(parameters, context.getType(cls))
|
||||
return PyCallableTypeImpl(parameters, context.getType(cls)?.let { if (it is PyInstantiableType<*>) it.toInstance() else it })
|
||||
}
|
||||
|
||||
private fun fieldToParameter(cls: PyClass,
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class Point:
|
||||
x: int
|
||||
y: int
|
||||
|
||||
@classmethod
|
||||
def from_str(cls, string: str) -> 'Point':
|
||||
return cls(1, 2)
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
def dataclass(_cls=None, *, init=True, repr=True, eq=True, order=False,
|
||||
unsafe_hash=False, frozen=False):
|
||||
pass
|
||||
@@ -297,6 +297,11 @@ public class Py3TypeCheckerInspectionTest extends PyInspectionTestCase {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON37, () -> super.doMultiFileTest());
|
||||
}
|
||||
|
||||
// PY-28442
|
||||
public void testDataclassClsCallType() {
|
||||
runWithLanguageLevel(LanguageLevel.PYTHON37, () -> super.doMultiFileTest());
|
||||
}
|
||||
|
||||
// PY-26354
|
||||
public void testInitializingAttrs() {
|
||||
doTestByText("import attr\n" +
|
||||
|
||||
Reference in New Issue
Block a user