Minor Fix according to review

This commit is contained in:
Valentina Kiryushkina
2017-05-15 14:37:55 +03:00
parent 2c52d397ab
commit 092f97d2e2
5 changed files with 11 additions and 12 deletions
@@ -382,7 +382,7 @@ INSP.first.arg.$0.assigned=Method''s parameter ''{0}'' reassigned
# PyStringFormatInspection
INSP.NAME.str.format=Errors in string formatting operations
INSP.format.requires.no.mapping=Format doesn't require a mapping
INSP.key.$0.has.no.arg=Key ''{0}'' has no following argument
INSP.key.$0.has.no.arg=Key ''{0}'' has no corresponding argument
INSP.unexpected.type.$0=Unexpected type {0}
INSP.too.few.keys=Too few mapping keys
INSP.no.format.specifier.char=Format specifier character missing
@@ -71,7 +71,7 @@ public class PySubstitutionChunkReference extends PsiReferenceBase<PyStringLiter
final TextRange textRange = chunk.getTextRange();
if (chunk.getMappingKey() != null) {
final int start = textRange.getStartOffset() + chunk.getTextRange().substring(element.getText()).indexOf(chunk.getMappingKey());
return new TextRange(start, start + chunk.getMappingKey().length());
return TextRange.from(start, chunk.getMappingKey().length());
}
return textRange;
}
@@ -292,7 +292,7 @@ public class PySubstitutionChunkReference extends PsiReferenceBase<PyStringLiter
if (returnValueExpr instanceof PyDictLiteralExpression) {
Ref<PyExpression> resolvedRef;
try {
final Integer index = Integer.getInteger(key);
final Integer index = Integer.parseInt(key);
resolvedRef = getElementFromDictLiteral((PyDictLiteralExpression)returnValueExpr, index, resolveContext);
}
catch (NumberFormatException e) {
@@ -681,7 +681,7 @@ public class PyResolveTest extends PyResolveTestCase {
PsiElement target = resolve();
assertTrue(target instanceof PyNumericLiteralExpression);
assertNotNull(((PyNumericLiteralExpression)target).getLongValue());
assertTrue(4181 == ((PyNumericLiteralExpression)target).getLongValue());
assertTrue(((PyNumericLiteralExpression)target).getLongValue() == 4181);
}
public void testPercentStringKeyWordArgWithParentheses() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -69,6 +69,11 @@ public class Py3StringFormatInspectionTest extends PyTestCase {
runWithLanguageLevel(LanguageLevel.PYTHON35, this::doTest);
}
// PY-20599
public void testPy3kAsciiFormatSpecifier() {
runWithLanguageLevel(LanguageLevel.PYTHON35, () -> doTest());
}
private void doTest() {
myFixture.configureByFile(TEST_DIRECTORY + getTestName(false) + ".py");
myFixture.enableInspections(PyStringFormatInspection.class);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
package com.jetbrains.python.inspections;
import com.jetbrains.python.fixtures.PyTestCase;
import com.jetbrains.python.psi.LanguageLevel;
/**
* @author vlan
@@ -193,11 +192,6 @@ public class PyStringFormatInspectionTest extends PyTestCase {
public void testTooFewMappingKeys() {
doTest();
}
// PY-20599
public void testPy3kAsciiFormatSpecifier() {
runWithLanguageLevel(LanguageLevel.PYTHON35, () -> doTest());
}
//PY-21166
public void testUnsupportedFormatSpecifierNewStyleFormatting() {