mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-44858 Create regular packages in refactorings initiated from top-level files in source/content roots
Otherwise, if someone wants to move a definition/extract a superclass from there to a brand-new package, e.g. from main.py to pkg/mod.py, a namespace "pkg" package will be created. Restore the original behavior of PyExtractSuperclassTest.testMultifileNew: the origin file was inside a regular project root without __init__.py alongside. GitOrigin-RevId: 750414b18582740076c14bfcfd07fa38992b4428
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1c026ac470
commit
f392777e01
@@ -41,6 +41,7 @@ fun isNamespacePackage(element: PsiElement): Boolean {
|
||||
fun isInNamespacePackage(element: PsiElement): Boolean {
|
||||
val myFile = element.containingFile ?: return false
|
||||
val parentDirectory = myFile.containingDirectory
|
||||
if (parentDirectory.virtualFile in PyUtil.getSourceRoots(element)) return false
|
||||
return parentDirectory != null && isNamespacePackage(parentDirectory)
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
class MyClass:
|
||||
pass
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
class MyClass:
|
||||
pass
|
||||
@@ -427,6 +427,12 @@ public class PyMoveTest extends PyTestCase {
|
||||
});
|
||||
}
|
||||
|
||||
public void testMoveSymbolFromTopLevelModuleToNewPackageCreatesInitPy() {
|
||||
doComparingDirectories(testDir -> {
|
||||
moveSymbols(testDir, "pkg/subpkg/b.py", "MyClass");
|
||||
});
|
||||
}
|
||||
|
||||
//PY-44858
|
||||
public void testMoveNotCreateInitPyForNamespacePackagesToAnotherDirectory() {
|
||||
doMoveSymbolsTest("pkg/subpkg/B/module_b.py", "myfunc");
|
||||
|
||||
Reference in New Issue
Block a user