mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-36158 Add all star import sources if imported element qname not locally resolved
GitOrigin-RevId: 0f65429042ebde43cbf04ec66abf6f392e71ae67
This commit is contained in:
committed by
intellij-monorepo-bot
parent
cc380088de
commit
531c8dbdef
@@ -179,11 +179,23 @@ public final class PyResolveUtil {
|
||||
: ContainerUtil.map(resolveImportedElementQNameLocally((PyReferenceExpression)qualifier), qn -> qn.append(name));
|
||||
}
|
||||
else {
|
||||
return fullMultiResolveLocally(expression, new HashSet<>())
|
||||
List<QualifiedName> result = fullMultiResolveLocally(expression, new HashSet<>())
|
||||
.select(PyImportElement.class)
|
||||
.map(PyResolveUtil::getImportedElementQName)
|
||||
.nonNull()
|
||||
.toList();
|
||||
if (!result.isEmpty()) return result;
|
||||
if (expression.getName() == null) return result;
|
||||
|
||||
PsiFile containingFile = expression.getContainingFile();
|
||||
if (!(containingFile instanceof PyFile)) return result;
|
||||
List<PyFromImportStatement> fromImports = ((PyFile)containingFile).getFromImports();
|
||||
return StreamEx.of(fromImports)
|
||||
.filter(it -> it.isStarImport())
|
||||
.map(it -> it.getImportSourceQName())
|
||||
.nonNull()
|
||||
.map(it -> it.append(expression.getName()))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
from dataclasses import *
|
||||
|
||||
|
||||
@dataclass(eq=True)
|
||||
class Foo:
|
||||
foo: int
|
||||
|
||||
|
||||
print(Foo(foo=42))
|
||||
# <ref>
|
||||
@@ -777,6 +777,11 @@ public class Py3ResolveTest extends PyResolveTestCase {
|
||||
assertNull(doResolve());
|
||||
}
|
||||
|
||||
// PY-36158
|
||||
public void testDataclassFieldsDataclassesStarImport() {
|
||||
assertResolvesTo(PyTargetExpression.class, "foo");
|
||||
}
|
||||
|
||||
public void testInstanceAttrAbove() {
|
||||
assertResolvesTo(PyTargetExpression.class, "foo");
|
||||
}
|
||||
|
||||
@@ -18,6 +18,20 @@ public class Py3ArgumentListInspectionTest extends PyInspectionTestCase {
|
||||
return ourPyLatestDescriptor;
|
||||
}
|
||||
|
||||
// PY-36158
|
||||
public void testDataclassesStarImportNoUnexpectedArgumentWarning() {
|
||||
doTestByText("from dataclasses import *\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"@dataclass(eq=True)\n" +
|
||||
"class Foo:\n" +
|
||||
" a: float\n" +
|
||||
" b: float\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"print(Foo(1, 2))\n");
|
||||
}
|
||||
|
||||
// PY-50404
|
||||
public void testPassingKeywordArgumentsToParamSpec() {
|
||||
doTestByText("""
|
||||
|
||||
Reference in New Issue
Block a user