mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
IDEA-CR-49176: function inline: remove typing overloads together with the function (PY-36465)
GitOrigin-RevId: ef532069cd2d8bb06b35fb7d6ef7be2563b9b76d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1b5d272f4e
commit
f6c70470d6
@@ -275,6 +275,11 @@ class PyInlineFunctionProcessor(project: Project,
|
||||
if (stubFunction != null && stubFunction.isWritable) {
|
||||
stubFunction.delete()
|
||||
}
|
||||
val typingOverloads = PyiUtil.getOverloads(myFunction, TypeEvalContext.userInitiated(myProject, myFunction.containingFile))
|
||||
if (typingOverloads.isNotEmpty()) {
|
||||
typingOverloads.forEach { it.delete() }
|
||||
PyClassRefactoringUtil.optimizeImports(myFunction.containingFile)
|
||||
}
|
||||
myFunction.delete()
|
||||
dunderAll.forEach { it.element?.delete() }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class MyClass:
|
||||
def __init__(self, my_val):
|
||||
self.my_val = my_val
|
||||
|
||||
|
||||
my_class = MyClass(1)
|
||||
print(my_class.my_val)
|
||||
print(2)
|
||||
res = 2
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import overload
|
||||
|
||||
|
||||
class MyClass:
|
||||
def __init__(self, my_val):
|
||||
self.my_val = my_val
|
||||
|
||||
@overload
|
||||
def method(self, x: int) -> int:
|
||||
pass
|
||||
|
||||
@overload
|
||||
def method(self, x: str) -> str:
|
||||
pass
|
||||
|
||||
def method(self, x):
|
||||
print(self.my_val)
|
||||
print(x)
|
||||
return x
|
||||
|
||||
|
||||
my_class = MyClass(1)
|
||||
res = my_class.met<caret>hod(2)
|
||||
@@ -66,6 +66,7 @@ class PyInlineFunctionTest : PyTestCase() {
|
||||
fun testNoReturnsAsCallExpression() = doTest()
|
||||
fun testInlineAll() = doTest(inlineThis = false)
|
||||
fun testRemoving() = doTest(inlineThis = false, remove = true)
|
||||
fun testRemoveTypingOverrides() = doTest(inlineThis = false, remove = true)
|
||||
fun testDefaultValues() = doTest()
|
||||
fun testPositionalOnlyArgs() = doTest()
|
||||
fun testKeywordOnlyArgs() = doTest()
|
||||
|
||||
Reference in New Issue
Block a user