mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[python] Slightly simplified code (PyOverloadsInspection.kt)
GitOrigin-RevId: 333affe1d43bf5c8995cd39993643f6c7d8198e6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9d04f67374
commit
8fbb25d4ad
@@ -1041,12 +1041,9 @@ INSP.missing.type.hints.checkbox.only.when.types.are.known=Only when types are k
|
||||
|
||||
# PyOverloadsInspection
|
||||
INSP.NAME.overloads.in.regular.python.files=Overloads in regular Python files
|
||||
INSP.overloads.series.overload.decorated.methods.should.always.be.followed.by.implementation=A series of @overload-decorated methods should always be followed by an implementation that is not @overload-ed
|
||||
INSP.overloads.series.overload.decorated.functions.should.always.be.followed.by.implementation=A series of @overload-decorated functions should always be followed by an implementation that is not @overload-ed
|
||||
INSP.overloads.this.method.overload.signature.not.compatible.with.implementation=Signature of this @overload-decorated method is not compatible with the implementation
|
||||
INSP.overloads.this.function.overload.signature.not.compatible.with.implementation=Signature of this @overload-decorated function is not compatible with the implementation
|
||||
INSP.overloads.at.least.two.overload.decorated.methods.must.be.present=At least two @overload-decorated methods must be present
|
||||
INSP.overloads.at.least.two.overload.decorated.functions.must.be.present=At least two @overload-decorated functions must be present
|
||||
INSP.overloads.series.overloads.should.always.be.followed.by.implementation=A series of @overload-decorated {0,choice,0#functions|1#methods} should always be followed by an implementation that is not @overload-ed
|
||||
INSP.overloads.this.overload.signature.not.compatible.with.implementation=Signature of this @overload-decorated {0,choice,0#function|1#method} is not compatible with the implementation
|
||||
INSP.overloads.at.least.two.overloads.must.be.present=At least two @overload-decorated {0,choice,0#functions|1#methods} must be present
|
||||
INSP.overloads.use.staticmethod.inconsistently=Overloads use @staticmethod inconsistently
|
||||
INSP.overloads.use.classmethod.inconsistently=Overloads use @classmethod inconsistently
|
||||
INSP.overloads.override.should.be.placed.on.the.implementation='@override' should be placed on the implementation
|
||||
|
||||
+9
-18
@@ -50,12 +50,9 @@ class PyOverloadsInspection : PyInspection() {
|
||||
if (overloads.isEmpty()) return
|
||||
|
||||
if (overloads.size == 1) {
|
||||
registerProblem(overloads[0].nameIdentifier, if (owner is PyClass) {
|
||||
PyPsiBundle.message("INSP.overloads.at.least.two.overload.decorated.methods.must.be.present")
|
||||
}
|
||||
else {
|
||||
PyPsiBundle.message("INSP.overloads.at.least.two.overload.decorated.functions.must.be.present")
|
||||
})
|
||||
registerProblem(overloads[0].nameIdentifier,
|
||||
PyPsiBundle.message("INSP.overloads.at.least.two.overloads.must.be.present",
|
||||
if (owner is PyClass) 1 else 0))
|
||||
}
|
||||
|
||||
val implementation = implementations.lastOrNull()
|
||||
@@ -83,12 +80,9 @@ class PyOverloadsInspection : PyInspection() {
|
||||
|
||||
if (requiresImplementation && implementation !== functions.last()) {
|
||||
val problemElement = if (implementation == null) functions.first() else functions.last()
|
||||
registerProblem(problemElement.nameIdentifier, if (owner is PyClass) {
|
||||
PyPsiBundle.message("INSP.overloads.series.overload.decorated.methods.should.always.be.followed.by.implementation")
|
||||
}
|
||||
else {
|
||||
PyPsiBundle.message("INSP.overloads.series.overload.decorated.functions.should.always.be.followed.by.implementation")
|
||||
})
|
||||
registerProblem(problemElement.nameIdentifier,
|
||||
PyPsiBundle.message("INSP.overloads.series.overloads.should.always.be.followed.by.implementation",
|
||||
if (owner is PyClass) 1 else 0))
|
||||
}
|
||||
|
||||
if (implementation != null) {
|
||||
@@ -96,12 +90,9 @@ class PyOverloadsInspection : PyInspection() {
|
||||
.asSequence()
|
||||
.filter { isIncompatibleOverload(implementation, it) }
|
||||
.forEach {
|
||||
registerProblem(it.nameIdentifier, if (owner is PyClass) {
|
||||
PyPsiBundle.message("INSP.overloads.this.method.overload.signature.not.compatible.with.implementation")
|
||||
}
|
||||
else {
|
||||
PyPsiBundle.message("INSP.overloads.this.function.overload.signature.not.compatible.with.implementation")
|
||||
})
|
||||
registerProblem(it.nameIdentifier,
|
||||
PyPsiBundle.message("INSP.overloads.this.overload.signature.not.compatible.with.implementation",
|
||||
if (owner is PyClass) 1 else 0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user