mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed augmented assignment inspection for non-commutative operations on weak union types (PY-7605)
This commit is contained in:
@@ -74,7 +74,7 @@ public class PyAugmentAssignmentInspection extends PyInspection {
|
||||
if ((operations.contains(op) && !changedParts) || (changedParts && commutativeOperations.contains(op))) {
|
||||
if (leftExpression instanceof PyReferenceExpression || leftExpression instanceof PySubscriptionExpression) {
|
||||
final PyType type = myTypeEvalContext.getType(rightExpression);
|
||||
if (type != null) {
|
||||
if (type != null && !PyTypeChecker.isUnknown(type)) {
|
||||
final PyBuiltinCache cache = PyBuiltinCache.getInstance(rightExpression);
|
||||
final LanguageLevel languageLevel = LanguageLevel.forElement(rightExpression);
|
||||
if (isNumeric(type, cache) || (isString(type, cache, languageLevel) && !changedParts)) {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
def foo(c, x, y):
|
||||
if c:
|
||||
z = x
|
||||
else:
|
||||
z = ''
|
||||
y = z + y # pass
|
||||
return y
|
||||
@@ -47,6 +47,11 @@ public class PyAugmentAssignmentInspectionTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-7605
|
||||
public void testStrOrUnknownFirstArg() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.configureByFile("inspections/PyAugmentAssignmentInspection/" + getTestName(true) + ".py");
|
||||
myFixture.enableInspections(PyAugmentAssignmentInspection.class);
|
||||
|
||||
Reference in New Issue
Block a user