From 03a05fc2ebb6230b258e44be219fe1fa64cdd59c Mon Sep 17 00:00:00 2001 From: Valentina Kiryushkina Date: Tue, 28 Jun 2016 18:55:43 +0300 Subject: [PATCH] PY-8325 Don't show unresolved reference warning inside format strings: show warnings provided by String Format Inspection Merge remote-tracking branch 'origin/master' --- .../PyUnresolvedReferencesInspection.java | 6 + .../NewStyleDictLiteralExprInsideDictCall.py | 2 + .../NewStyleDictLiteralWithNumericKeys.py | 1 + .../NewStyleDictLiteralWithReferenceKeys.py} | 0 .../NewStyleEmptyDictArg.py | 1 + .../NewStylePackedAndNonPackedArgs.py | 6 + .../NewStylePackedFunctionCall.py | 6 + .../NewStylePackedReference.py | 4 + ...wStylePositionalSubstitutionWithDictArg.py | 1 + .../NewStyleStringMapArg.py} | 0 .../NewStyleStringRegularExpression.py} | 0 .../NewStyleStringWithPercentSymbol.py | 2 + .../PercentStringKeywordListArgument.py | 1 + .../PercentStringKeywordSetArgument.py | 1 + .../PercentStringPositionalDictArgument.py | 1 + .../PercentStringPositionalListArgument.py | 1 + ...PercentStringPositionalWithEmptyDictArg.py | 2 + .../PercentStringWithDictArgument.py | 2 + .../PercentStringWithDictCall.py | 1 + .../PercentStringWithDictElement.py | 2 + ...tringWithFormatStringReplacementSymbols.py | 2 + .../TooFewArgumentsNewStyleFormat.py | 3 +- .../UnusedMappingNewStyleFormat.py | 3 +- ...gDictLiteralArgumentWithNumericExprKeys.py | 1 - .../formatStringKeyword.py | 1 - .../formatStringPackedFunctionCall.py | 5 - .../formatStringPackedReference.py | 2 - .../formatStringPositional.py | 1 - ...StringPositionalSubstitutionWithDictArg.py | 1 - .../formatStringWithDictArgWithCallExprKey.py | 3 - ...StringWithDictLiteralExprInsideDictCall.py | 1 - .../formatStringWithEmptyDictArg.py | 1 - .../formatStringWithPackedAndNonPackedArgs.py | 4 - ...ringWithPercentStringReplacementSymbols.py | 1 - ...ictLiteralArgumentWithReferenceExprKeys.py | 3 - .../percentStringFunctionCall.py | 4 - .../percentStringKeyword.py | 1 - ...ordArgumentWithReferenceKeyDictArgument.py | 2 - .../percentStringKeywordListArgument.py | 1 - .../percentStringKeywordSetArgument.py | 1 - .../percentStringKeywordTupleArgument.py | 1 - .../percentStringPositional.py | 1 - .../percentStringPositionalDictArgument.py | 1 - .../percentStringPositionalListArgument.py | 1 - .../percentStringPositionalSetArgument.py | 1 - .../percentStringReference.py | 2 - .../percentStringWithCallArgument.py | 3 - .../percentStringWithDictArgument.py | 1 - .../percentStringWithDictCall.py | 1 - .../percentStringWithDictCallArgument.py | 1 - .../percentStringWithDictElement.py | 1 - .../percentStringWithEmptyDict.py | 1 - ...tringWithFormatStringReplacementSymbols.py | 1 - .../percentStringWithTupleSlicing.py | 1 - .../PyUnresolvedReferencesInspectionTest.java | 173 +----------------- 55 files changed, 47 insertions(+), 224 deletions(-) create mode 100644 python/testData/inspections/PyStringFormatInspection/NewStyleDictLiteralExprInsideDictCall.py create mode 100644 python/testData/inspections/PyStringFormatInspection/NewStyleDictLiteralWithNumericKeys.py rename python/testData/inspections/{PyUnresolvedReferencesInspection/formatStringDictLiteralArgumentWithReferenceExprKeys.py => PyStringFormatInspection/NewStyleDictLiteralWithReferenceKeys.py} (100%) create mode 100644 python/testData/inspections/PyStringFormatInspection/NewStyleEmptyDictArg.py create mode 100644 python/testData/inspections/PyStringFormatInspection/NewStylePackedAndNonPackedArgs.py create mode 100644 python/testData/inspections/PyStringFormatInspection/NewStylePackedFunctionCall.py create mode 100644 python/testData/inspections/PyStringFormatInspection/NewStylePackedReference.py create mode 100644 python/testData/inspections/PyStringFormatInspection/NewStylePositionalSubstitutionWithDictArg.py rename python/testData/inspections/{PyUnresolvedReferencesInspection/formatStringInMapExpression.py => PyStringFormatInspection/NewStyleStringMapArg.py} (100%) rename python/testData/inspections/{PyUnresolvedReferencesInspection/formatStringInRegularExpressions.py => PyStringFormatInspection/NewStyleStringRegularExpression.py} (100%) create mode 100644 python/testData/inspections/PyStringFormatInspection/NewStyleStringWithPercentSymbol.py create mode 100644 python/testData/inspections/PyStringFormatInspection/PercentStringKeywordListArgument.py create mode 100644 python/testData/inspections/PyStringFormatInspection/PercentStringKeywordSetArgument.py create mode 100644 python/testData/inspections/PyStringFormatInspection/PercentStringPositionalDictArgument.py create mode 100644 python/testData/inspections/PyStringFormatInspection/PercentStringPositionalListArgument.py create mode 100644 python/testData/inspections/PyStringFormatInspection/PercentStringPositionalWithEmptyDictArg.py create mode 100644 python/testData/inspections/PyStringFormatInspection/PercentStringWithDictArgument.py create mode 100644 python/testData/inspections/PyStringFormatInspection/PercentStringWithDictCall.py create mode 100644 python/testData/inspections/PyStringFormatInspection/PercentStringWithDictElement.py create mode 100644 python/testData/inspections/PyStringFormatInspection/PercentStringWithFormatStringReplacementSymbols.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/formatStringDictLiteralArgumentWithNumericExprKeys.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/formatStringKeyword.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/formatStringPackedFunctionCall.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/formatStringPackedReference.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/formatStringPositional.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/formatStringPositionalSubstitutionWithDictArg.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithDictArgWithCallExprKey.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithDictLiteralExprInsideDictCall.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithEmptyDictArg.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithPackedAndNonPackedArgs.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithPercentStringReplacementSymbols.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringDictLiteralArgumentWithReferenceExprKeys.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringFunctionCall.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeyword.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeywordArgumentWithReferenceKeyDictArgument.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeywordListArgument.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeywordSetArgument.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeywordTupleArgument.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringPositional.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringPositionalDictArgument.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringPositionalListArgument.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringPositionalSetArgument.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringReference.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithCallArgument.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithDictArgument.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithDictCall.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithDictCallArgument.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithDictElement.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithEmptyDict.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithFormatStringReplacementSymbols.py delete mode 100644 python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithTupleSlicing.py diff --git a/python/src/com/jetbrains/python/inspections/unresolvedReference/PyUnresolvedReferencesInspection.java b/python/src/com/jetbrains/python/inspections/unresolvedReference/PyUnresolvedReferencesInspection.java index 4c26d8e8318d..7dfe8b9e403e 100644 --- a/python/src/com/jetbrains/python/inspections/unresolvedReference/PyUnresolvedReferencesInspection.java +++ b/python/src/com/jetbrains/python/inspections/unresolvedReference/PyUnresolvedReferencesInspection.java @@ -41,6 +41,8 @@ import com.jetbrains.python.PyCustomType; import com.jetbrains.python.PyNames; import com.jetbrains.python.codeInsight.PyCodeInsightSettings; import com.jetbrains.python.codeInsight.PyCustomMember; +import com.jetbrains.python.codeInsight.PyFunctionTypeCommentReferenceContributor; +import com.jetbrains.python.codeInsight.PySubstitutionChunkReference; import com.jetbrains.python.codeInsight.controlflow.ScopeOwner; import com.jetbrains.python.codeInsight.dataflow.scope.ScopeUtil; import com.jetbrains.python.codeInsight.imports.AutoImportHintAction; @@ -648,6 +650,10 @@ public class PyUnresolvedReferencesInspection extends PyInspection { } } + if (reference instanceof PySubstitutionChunkReference) { + return; + } + registerProblem(node, description, hl_type, null, rangeInElement, actions.toArray(new LocalQuickFix[actions.size()])); } diff --git a/python/testData/inspections/PyStringFormatInspection/NewStyleDictLiteralExprInsideDictCall.py b/python/testData/inspections/PyStringFormatInspection/NewStyleDictLiteralExprInsideDictCall.py new file mode 100644 index 000000000000..088f47884072 --- /dev/null +++ b/python/testData/inspections/PyStringFormatInspection/NewStyleDictLiteralExprInsideDictCall.py @@ -0,0 +1,2 @@ +print("{foo}".format(**dict({'foo': 'bar'}))) +"{}".format() \ No newline at end of file diff --git a/python/testData/inspections/PyStringFormatInspection/NewStyleDictLiteralWithNumericKeys.py b/python/testData/inspections/PyStringFormatInspection/NewStyleDictLiteralWithNumericKeys.py new file mode 100644 index 000000000000..c66217b62525 --- /dev/null +++ b/python/testData/inspections/PyStringFormatInspection/NewStyleDictLiteralWithNumericKeys.py @@ -0,0 +1 @@ +print ("first is {fst}".format(**{1: "3"}) \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringDictLiteralArgumentWithReferenceExprKeys.py b/python/testData/inspections/PyStringFormatInspection/NewStyleDictLiteralWithReferenceKeys.py similarity index 100% rename from python/testData/inspections/PyUnresolvedReferencesInspection/formatStringDictLiteralArgumentWithReferenceExprKeys.py rename to python/testData/inspections/PyStringFormatInspection/NewStyleDictLiteralWithReferenceKeys.py diff --git a/python/testData/inspections/PyStringFormatInspection/NewStyleEmptyDictArg.py b/python/testData/inspections/PyStringFormatInspection/NewStyleEmptyDictArg.py new file mode 100644 index 000000000000..3db74777d680 --- /dev/null +++ b/python/testData/inspections/PyStringFormatInspection/NewStyleEmptyDictArg.py @@ -0,0 +1 @@ +print("{foo}".format(**{})) \ No newline at end of file diff --git a/python/testData/inspections/PyStringFormatInspection/NewStylePackedAndNonPackedArgs.py b/python/testData/inspections/PyStringFormatInspection/NewStylePackedAndNonPackedArgs.py new file mode 100644 index 000000000000..e6fc38f46707 --- /dev/null +++ b/python/testData/inspections/PyStringFormatInspection/NewStylePackedAndNonPackedArgs.py @@ -0,0 +1,6 @@ +def foo(): + return {"foo": "bar"} + +print("pos: {} {} {}".format(1, *[2, 3])) + +"%s" %() \ No newline at end of file diff --git a/python/testData/inspections/PyStringFormatInspection/NewStylePackedFunctionCall.py b/python/testData/inspections/PyStringFormatInspection/NewStylePackedFunctionCall.py new file mode 100644 index 000000000000..ae4b437bde43 --- /dev/null +++ b/python/testData/inspections/PyStringFormatInspection/NewStylePackedFunctionCall.py @@ -0,0 +1,6 @@ +def f(): + return dict(foo=0) + +'{foo}'.format(**f()) + +"{}".format() \ No newline at end of file diff --git a/python/testData/inspections/PyStringFormatInspection/NewStylePackedReference.py b/python/testData/inspections/PyStringFormatInspection/NewStylePackedReference.py new file mode 100644 index 000000000000..2d042d15456b --- /dev/null +++ b/python/testData/inspections/PyStringFormatInspection/NewStylePackedReference.py @@ -0,0 +1,4 @@ +ref = {"fst": 1, "snd": 2} +print "first is {fst}, second is {snd}".format(**ref) + +"{}".format() \ No newline at end of file diff --git a/python/testData/inspections/PyStringFormatInspection/NewStylePositionalSubstitutionWithDictArg.py b/python/testData/inspections/PyStringFormatInspection/NewStylePositionalSubstitutionWithDictArg.py new file mode 100644 index 000000000000..bce6628d4d40 --- /dev/null +++ b/python/testData/inspections/PyStringFormatInspection/NewStylePositionalSubstitutionWithDictArg.py @@ -0,0 +1 @@ +print('{}'.format(foo='foo')) \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringInMapExpression.py b/python/testData/inspections/PyStringFormatInspection/NewStyleStringMapArg.py similarity index 100% rename from python/testData/inspections/PyUnresolvedReferencesInspection/formatStringInMapExpression.py rename to python/testData/inspections/PyStringFormatInspection/NewStyleStringMapArg.py diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringInRegularExpressions.py b/python/testData/inspections/PyStringFormatInspection/NewStyleStringRegularExpression.py similarity index 100% rename from python/testData/inspections/PyUnresolvedReferencesInspection/formatStringInRegularExpressions.py rename to python/testData/inspections/PyStringFormatInspection/NewStyleStringRegularExpression.py diff --git a/python/testData/inspections/PyStringFormatInspection/NewStyleStringWithPercentSymbol.py b/python/testData/inspections/PyStringFormatInspection/NewStyleStringWithPercentSymbol.py new file mode 100644 index 000000000000..55db8d6436a4 --- /dev/null +++ b/python/testData/inspections/PyStringFormatInspection/NewStyleStringWithPercentSymbol.py @@ -0,0 +1,2 @@ +"{0}%64".format("cVar") +"%s" % () \ No newline at end of file diff --git a/python/testData/inspections/PyStringFormatInspection/PercentStringKeywordListArgument.py b/python/testData/inspections/PyStringFormatInspection/PercentStringKeywordListArgument.py new file mode 100644 index 000000000000..5163655f1e6c --- /dev/null +++ b/python/testData/inspections/PyStringFormatInspection/PercentStringKeywordListArgument.py @@ -0,0 +1 @@ +"%(foo)s" % [1, 2, 3] \ No newline at end of file diff --git a/python/testData/inspections/PyStringFormatInspection/PercentStringKeywordSetArgument.py b/python/testData/inspections/PyStringFormatInspection/PercentStringKeywordSetArgument.py new file mode 100644 index 000000000000..e9ca8379a6e5 --- /dev/null +++ b/python/testData/inspections/PyStringFormatInspection/PercentStringKeywordSetArgument.py @@ -0,0 +1 @@ +"%(foo)s" % {1, 2} \ No newline at end of file diff --git a/python/testData/inspections/PyStringFormatInspection/PercentStringPositionalDictArgument.py b/python/testData/inspections/PyStringFormatInspection/PercentStringPositionalDictArgument.py new file mode 100644 index 000000000000..289bc99bd087 --- /dev/null +++ b/python/testData/inspections/PyStringFormatInspection/PercentStringPositionalDictArgument.py @@ -0,0 +1 @@ +"%s%s" % {"foo": 1} \ No newline at end of file diff --git a/python/testData/inspections/PyStringFormatInspection/PercentStringPositionalListArgument.py b/python/testData/inspections/PyStringFormatInspection/PercentStringPositionalListArgument.py new file mode 100644 index 000000000000..fda0078575c5 --- /dev/null +++ b/python/testData/inspections/PyStringFormatInspection/PercentStringPositionalListArgument.py @@ -0,0 +1 @@ +"%s%s" % [1, 2, 3] \ No newline at end of file diff --git a/python/testData/inspections/PyStringFormatInspection/PercentStringPositionalWithEmptyDictArg.py b/python/testData/inspections/PyStringFormatInspection/PercentStringPositionalWithEmptyDictArg.py new file mode 100644 index 000000000000..0f5db71b70d3 --- /dev/null +++ b/python/testData/inspections/PyStringFormatInspection/PercentStringPositionalWithEmptyDictArg.py @@ -0,0 +1,2 @@ +"%s" % dict() +"%s" % () \ No newline at end of file diff --git a/python/testData/inspections/PyStringFormatInspection/PercentStringWithDictArgument.py b/python/testData/inspections/PyStringFormatInspection/PercentStringWithDictArgument.py new file mode 100644 index 000000000000..4faeefefd1c3 --- /dev/null +++ b/python/testData/inspections/PyStringFormatInspection/PercentStringWithDictArgument.py @@ -0,0 +1,2 @@ +"%s" % dict(a=1) +"%s" % () \ No newline at end of file diff --git a/python/testData/inspections/PyStringFormatInspection/PercentStringWithDictCall.py b/python/testData/inspections/PyStringFormatInspection/PercentStringWithDictCall.py new file mode 100644 index 000000000000..8e1489dc8fd3 --- /dev/null +++ b/python/testData/inspections/PyStringFormatInspection/PercentStringWithDictCall.py @@ -0,0 +1 @@ +var = "%s %s" % dict(), 1 \ No newline at end of file diff --git a/python/testData/inspections/PyStringFormatInspection/PercentStringWithDictElement.py b/python/testData/inspections/PyStringFormatInspection/PercentStringWithDictElement.py new file mode 100644 index 000000000000..f626bfdf952f --- /dev/null +++ b/python/testData/inspections/PyStringFormatInspection/PercentStringWithDictElement.py @@ -0,0 +1,2 @@ +"%s" % dict(a=1)["a"] +"%s" % () \ No newline at end of file diff --git a/python/testData/inspections/PyStringFormatInspection/PercentStringWithFormatStringReplacementSymbols.py b/python/testData/inspections/PyStringFormatInspection/PercentStringWithFormatStringReplacementSymbols.py new file mode 100644 index 000000000000..c70f24a18266 --- /dev/null +++ b/python/testData/inspections/PyStringFormatInspection/PercentStringWithFormatStringReplacementSymbols.py @@ -0,0 +1,2 @@ +var = "if (1 == x)\n{\n%s;\n}" % "return 0" +"%s" % () \ No newline at end of file diff --git a/python/testData/inspections/PyStringFormatInspection/TooFewArgumentsNewStyleFormat.py b/python/testData/inspections/PyStringFormatInspection/TooFewArgumentsNewStyleFormat.py index 1e7856e07014..049f92affc37 100644 --- a/python/testData/inspections/PyStringFormatInspection/TooFewArgumentsNewStyleFormat.py +++ b/python/testData/inspections/PyStringFormatInspection/TooFewArgumentsNewStyleFormat.py @@ -1 +1,2 @@ -"{} {}".format(1) \ No newline at end of file +"{} {}".format(1) +'{}'.format() \ No newline at end of file diff --git a/python/testData/inspections/PyStringFormatInspection/UnusedMappingNewStyleFormat.py b/python/testData/inspections/PyStringFormatInspection/UnusedMappingNewStyleFormat.py index 6b469a3baf3c..8db44f22ec77 100644 --- a/python/testData/inspections/PyStringFormatInspection/UnusedMappingNewStyleFormat.py +++ b/python/testData/inspections/PyStringFormatInspection/UnusedMappingNewStyleFormat.py @@ -1 +1,2 @@ -"{name}".format() \ No newline at end of file +"{name}".format() +'{foo}'.format(boo=1) \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringDictLiteralArgumentWithNumericExprKeys.py b/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringDictLiteralArgumentWithNumericExprKeys.py deleted file mode 100644 index cb6df8b5221c..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringDictLiteralArgumentWithNumericExprKeys.py +++ /dev/null @@ -1 +0,0 @@ -print ("first is %(fst)s" % {1: "3"}) \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringKeyword.py b/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringKeyword.py deleted file mode 100644 index 454a39f84094..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringKeyword.py +++ /dev/null @@ -1 +0,0 @@ -'{foo}'.format(boo=1) \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringPackedFunctionCall.py b/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringPackedFunctionCall.py deleted file mode 100644 index 8aafa5a24125..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringPackedFunctionCall.py +++ /dev/null @@ -1,5 +0,0 @@ -def f(): - return dict(foo=0) - - -'{foo}'.format(**f()) \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringPackedReference.py b/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringPackedReference.py deleted file mode 100644 index c3e726eb7ab4..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringPackedReference.py +++ /dev/null @@ -1,2 +0,0 @@ -ref = {"fst": 1, "snd": 2} -print "first is {fst}, second is {snd}".format(**ref) \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringPositional.py b/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringPositional.py deleted file mode 100644 index fa8faafa8734..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringPositional.py +++ /dev/null @@ -1 +0,0 @@ -v = '{}'.format() \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringPositionalSubstitutionWithDictArg.py b/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringPositionalSubstitutionWithDictArg.py deleted file mode 100644 index 890855209fa8..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringPositionalSubstitutionWithDictArg.py +++ /dev/null @@ -1 +0,0 @@ -print('{}'.format(foo='foo')) \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithDictArgWithCallExprKey.py b/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithDictArgWithCallExprKey.py deleted file mode 100644 index d2f29b8eff4a..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithDictArgWithCallExprKey.py +++ /dev/null @@ -1,3 +0,0 @@ -def foo(): - return 'foo' -print("{foo}".format(**{'bar': 10, foo(): 20})) \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithDictLiteralExprInsideDictCall.py b/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithDictLiteralExprInsideDictCall.py deleted file mode 100644 index 9555a24b4565..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithDictLiteralExprInsideDictCall.py +++ /dev/null @@ -1 +0,0 @@ -print("{foo}".format(**dict({'foo': 'bar'}))) \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithEmptyDictArg.py b/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithEmptyDictArg.py deleted file mode 100644 index 5bd7625b2c71..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithEmptyDictArg.py +++ /dev/null @@ -1 +0,0 @@ -print("{foo}".format(**{})) \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithPackedAndNonPackedArgs.py b/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithPackedAndNonPackedArgs.py deleted file mode 100644 index 9f57c3e29b14..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithPackedAndNonPackedArgs.py +++ /dev/null @@ -1,4 +0,0 @@ -def foo(): - return {"foo":"bar"} - -print("pos: {} {} {}".format(1, *[2, 3])) \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithPercentStringReplacementSymbols.py b/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithPercentStringReplacementSymbols.py deleted file mode 100644 index 2bdabc3375b0..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/formatStringWithPercentStringReplacementSymbols.py +++ /dev/null @@ -1 +0,0 @@ -"{0}%64".format("cVar") \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringDictLiteralArgumentWithReferenceExprKeys.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringDictLiteralArgumentWithReferenceExprKeys.py deleted file mode 100644 index b1c1a1b61319..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringDictLiteralArgumentWithReferenceExprKeys.py +++ /dev/null @@ -1,3 +0,0 @@ -f = "fst" -s = "snd" -print ("first is %(fst)s, second is %(snd)s" % {s: "3", f: "1"}) \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringFunctionCall.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringFunctionCall.py deleted file mode 100644 index c7dc76fd26dc..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringFunctionCall.py +++ /dev/null @@ -1,4 +0,0 @@ -def f(): - return [1] - -"%s" % f() \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeyword.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeyword.py deleted file mode 100644 index f4152f4c7ce3..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeyword.py +++ /dev/null @@ -1 +0,0 @@ -v = "first is %(fst)s" % {"snd": 2} \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeywordArgumentWithReferenceKeyDictArgument.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeywordArgumentWithReferenceKeyDictArgument.py deleted file mode 100644 index cb9585bbcc1e..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeywordArgumentWithReferenceKeyDictArgument.py +++ /dev/null @@ -1,2 +0,0 @@ -snd = "snd" -print "%(f)s %(snd)s" % { "f": 2, 1: 1, snd: 2} \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeywordListArgument.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeywordListArgument.py deleted file mode 100644 index 7f007d55ff35..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeywordListArgument.py +++ /dev/null @@ -1 +0,0 @@ -"%(foo)s" % [1, 2, 3] \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeywordSetArgument.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeywordSetArgument.py deleted file mode 100644 index b50493ba5518..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeywordSetArgument.py +++ /dev/null @@ -1 +0,0 @@ -"%(foo)s" % {1, 2} \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeywordTupleArgument.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeywordTupleArgument.py deleted file mode 100644 index ade2aa6079ec..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringKeywordTupleArgument.py +++ /dev/null @@ -1 +0,0 @@ -"%(foo)s" % (1,2,3) \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringPositional.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringPositional.py deleted file mode 100644 index 36ad546c900a..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringPositional.py +++ /dev/null @@ -1 +0,0 @@ -v = '%s' % (1) \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringPositionalDictArgument.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringPositionalDictArgument.py deleted file mode 100644 index 70ba0ed76b33..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringPositionalDictArgument.py +++ /dev/null @@ -1 +0,0 @@ -"%s%s" % {"foo": 1} \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringPositionalListArgument.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringPositionalListArgument.py deleted file mode 100644 index b52aa49bb3bd..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringPositionalListArgument.py +++ /dev/null @@ -1 +0,0 @@ -"%s%s" % [1, 2, 3] \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringPositionalSetArgument.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringPositionalSetArgument.py deleted file mode 100644 index 68aa001665b9..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringPositionalSetArgument.py +++ /dev/null @@ -1 +0,0 @@ -"%s%s" % {1, 2, 3} \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringReference.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringReference.py deleted file mode 100644 index 6f3a61ff0013..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringReference.py +++ /dev/null @@ -1,2 +0,0 @@ -d = {"fst": 1, "snd": 2} -print "first is %(fst)s, second is %(snd)s" % d \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithCallArgument.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithCallArgument.py deleted file mode 100644 index 9cab28de4105..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithCallArgument.py +++ /dev/null @@ -1,3 +0,0 @@ -def f(): - return 'foo', 'bar' -print('%s %s' % f()) \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithDictArgument.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithDictArgument.py deleted file mode 100644 index ef24f5687e2c..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithDictArgument.py +++ /dev/null @@ -1 +0,0 @@ -"%s" % {"foo": 1} \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithDictCall.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithDictCall.py deleted file mode 100644 index 5e0bbe3a8f88..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithDictCall.py +++ /dev/null @@ -1 +0,0 @@ -var = "%s %s" % dict(), 1 \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithDictCallArgument.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithDictCallArgument.py deleted file mode 100644 index e6117be95e0f..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithDictCallArgument.py +++ /dev/null @@ -1 +0,0 @@ -"%s" % dict(a=1) \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithDictElement.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithDictElement.py deleted file mode 100644 index d896c4d8b797..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithDictElement.py +++ /dev/null @@ -1 +0,0 @@ -"%s" % dict(a=1)["a"] \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithEmptyDict.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithEmptyDict.py deleted file mode 100644 index 58154eb0b2e3..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithEmptyDict.py +++ /dev/null @@ -1 +0,0 @@ -"%s" % dict() \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithFormatStringReplacementSymbols.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithFormatStringReplacementSymbols.py deleted file mode 100644 index 76f17bc9dd85..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithFormatStringReplacementSymbols.py +++ /dev/null @@ -1 +0,0 @@ -var = "if (1 == x)\n{\n%s;\n}" % "return 0" \ No newline at end of file diff --git a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithTupleSlicing.py b/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithTupleSlicing.py deleted file mode 100644 index c98efef7818a..000000000000 --- a/python/testData/inspections/PyUnresolvedReferencesInspection/percentStringWithTupleSlicing.py +++ /dev/null @@ -1 +0,0 @@ -"%s" % (0, 1, 2)[0] \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java index 5731ba00eb44..7c24a6cbf812 100644 --- a/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/PyUnresolvedReferencesInspectionTest.java @@ -529,71 +529,6 @@ public class PyUnresolvedReferencesInspectionTest extends PyInspectionTestCase { public void testPropertyNotListedInSlots() { doTest(); } - - // PY-2748 - public void testFormatStringPositional() { - doTest(); - } - - // PY-2748 - public void testFormatStringKeyword() { - doTest(); - } - - // PY-2748 - public void testPercentStringPositional() { - doTest(); - } - - // PY-2748 - public void testPercentStringKeyword() { - doTest(); - } - - // PY-2748 - public void testFormatStringPackedFunctionCall() { - doTest(); - } - - // PY-2748 - public void testPercentStringFunctionCall() { - doTest(); - } - - // PY-2748 - public void testFormatStringPackedReference() { - doTest(); - } - - // PY-2748 - public void testPercentStringReference() { - doTest(); - } - - // PY-2748 - public void testFormatStringDictLiteralArgumentWithReferenceExprKeys() { - doTest(); - } - - // PY-2748 - public void testPercentStringDictLiteralArgumentWithReferenceExprKeys() { - doTest(); - } - - // PY-2748 - public void testFormatStringDictLiteralArgumentWithNumericExprKeys() { - doTest(); - } - - // PY-18769 - public void testFormatStringInRegularExpressions() { - doTest(); - } - - // PY-18751 - public void testFormatStringInMapExpression() { - doTest(); - } // PY-18751 public void testStringWithFormatSyntax() { @@ -605,82 +540,6 @@ public class PyUnresolvedReferencesInspectionTest extends PyInspectionTestCase { doTest(); } - // PY-18751 - public void testPercentStringWithFormatStringReplacementSymbols() { - doTest(); - } - - // PY-18751, PY-18824 - public void testFormatStringWithPercentStringReplacementSymbols() { - doTest(); - } - - // PY-18837 - public void testPercentStringWithDictArgument() { - doTest(); - } - - // PY-18115 - public void testPercentStringWithDictCallArgument() { - doTest(); - } - - // PY-18115 - public void testPercentStringWithTupleSlicing() { - doTest(); - } - - // PY-18115 - public void testPercentStringWithDictElement() { - doTest(); - } - - // PY-18115 - public void testPercentStringWithEmptyDict() { - doTest(); - } - - // PY-18115 - public void testPercentStringWithDictCall() { - doTest(); - } - - // PY-18115 - public void testFormatStringPositionalSubstitutionWithDictArg() { - doTest(); - } - - // PY-18115 - public void testPercentStringWithCallArgument() { - doTest(); - } - - // PY-18115 - public void testFormatStringWithEmptyDictArg() { - doTest(); - } - - // PY-18115 - public void testFormatStringWithDictLiteralExprInsideDictCall() { - doTest(); - } - - // PY-18115 - public void testFormatStringWithDictArgWithCallExprKey() { - doTest(); - } - - // PY-18115 - public void testFormatStringWithPackedAndNonPackedArgs() { - doTest(); - } - - - // PY-18950 - public void testPercentStringKeywordArgumentWithReferenceKeyDictArgument() { - doTest(); - } - // PY-18254 public void testVarargsAnnotatedWithFunctionComment() { doTest(); @@ -691,42 +550,12 @@ public class PyUnresolvedReferencesInspectionTest extends PyInspectionTestCase { myFixture.copyDirectoryToProject("typing", ""); runWithLanguageLevel(LanguageLevel.PYTHON30, this::doTest); } - + // PY-22620 public void testTupleTypeCommentsUseImportsFromTyping() { myFixture.copyDirectoryToProject("typing", ""); doTest(); } - - // PY-19084 - public void testPercentStringPositionalListArgument() { - doTest(); - } - - // PY-19084 - public void testPercentStringPositionalSetArgument() { - doTest(); - } - - // PY-19084 - public void testPercentStringPositionalDictArgument() { - doTest(); - } - - // PY-19084 - public void testPercentStringKeywordListArgument() { - doTest(); - } - - // PY-19084 - public void testPercentStringKeywordSetArgument() { - doTest(); - } - - // PY-19084 - public void testPercentStringKeywordTupleArgument() { - doTest(); - } // PY-13734 public void testDunderClass() {