From 9b451f9e6da9baa7c1fae99309595ba508e14150 Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Thu, 14 Dec 2017 17:02:49 +0300 Subject: [PATCH] Register change signature quick fix without highlighting To not to be overlayed with highlighting for arguments --- .../inspections/PyArgumentListInspection.java | 6 ++++-- .../ChangeSignatureAddKeywordOnlyParameter.py | 2 +- ...hangeSignatureKeywordAndPositionalParameters.py | 2 +- .../ChangeSignatureNewParametersNames.py | 2 +- .../ChangeSignatureParametersDefaultValues.py | 2 +- .../InitializingDataclass/a.py | 2 +- .../PyArgumentListInspection/badarglist.py | 12 ++++++------ .../PyArgumentListInspection/decorators.py | 2 +- .../PyArgumentListInspection/kwargsMapToNothing.py | 4 ++-- .../inspections/PyArgumentListInspection/py1268.py | 14 +++++++------- .../inspections/PyArgumentListInspection/py3k.py | 2 +- .../PyArgumentListInspection/tupleVsLiteralList.py | 2 +- .../PyRemoveArgumentQuickFixTest/duplicate.py | 2 +- .../PyRemoveArgumentQuickFixTest/unexpected.py | 2 +- 14 files changed, 29 insertions(+), 27 deletions(-) diff --git a/python/src/com/jetbrains/python/inspections/PyArgumentListInspection.java b/python/src/com/jetbrains/python/inspections/PyArgumentListInspection.java index 224190372396..896dd0ad086d 100644 --- a/python/src/com/jetbrains/python/inspections/PyArgumentListInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyArgumentListInspection.java @@ -4,6 +4,7 @@ package com.jetbrains.python.inspections; import com.google.common.collect.Lists; import com.intellij.codeInspection.LocalInspectionToolSession; import com.intellij.codeInspection.LocalQuickFix; +import com.intellij.codeInspection.ProblemHighlightType; import com.intellij.codeInspection.ProblemsHolder; import com.intellij.lang.ASTNode; import com.intellij.openapi.project.Project; @@ -201,13 +202,14 @@ public class PyArgumentListInspection extends PyInspection { final Set duplicateKeywords = getDuplicateKeywordArguments(node); final PyCallExpression.PyArgumentsMapping mapping = mappings.get(0); - if (!mapping.getUnmappedArguments().isEmpty() && mapping.getUnmappedParameters().isEmpty()) { + if (holder.isOnTheFly() && !mapping.getUnmappedArguments().isEmpty() && mapping.getUnmappedParameters().isEmpty()) { final PyCallExpression.PyMarkedCallee markedCallee = mapping.getMarkedCallee(); if (markedCallee != null) { final PyCallable callable = markedCallee.getElement(); final Project project = node.getProject(); if (callable instanceof PyFunction && !PyChangeSignatureHandler.isNotUnderSourceRoot(project, callable.getContainingFile())) { - holder.registerProblem(node, PyBundle.message("INSP.unexpected.arg(s)"), PyChangeSignatureQuickFix.forMismatchedCall(mapping)); + final String message = PyBundle.message("INSP.unexpected.arg(s)"); + holder.registerProblem(node, message, ProblemHighlightType.INFORMATION, PyChangeSignatureQuickFix.forMismatchedCall(mapping)); } } } diff --git a/python/testData/inspections/ChangeSignatureAddKeywordOnlyParameter.py b/python/testData/inspections/ChangeSignatureAddKeywordOnlyParameter.py index 86ecc3f8fd07..becf596ff5ab 100644 --- a/python/testData/inspections/ChangeSignatureAddKeywordOnlyParameter.py +++ b/python/testData/inspections/ChangeSignatureAddKeywordOnlyParameter.py @@ -1,4 +1,4 @@ def func(x, *args, foo=None): pass -func(1, 2, 3, bar='spam') \ No newline at end of file +func(1, 2, 3, bar='spam') \ No newline at end of file diff --git a/python/testData/inspections/ChangeSignatureKeywordAndPositionalParameters.py b/python/testData/inspections/ChangeSignatureKeywordAndPositionalParameters.py index d557fb3a02f5..272b58e10243 100644 --- a/python/testData/inspections/ChangeSignatureKeywordAndPositionalParameters.py +++ b/python/testData/inspections/ChangeSignatureKeywordAndPositionalParameters.py @@ -2,4 +2,4 @@ def f(x, foo=1): pass -f(x, 42, bar='spam') \ No newline at end of file +f(x, 42, bar='spam') \ No newline at end of file diff --git a/python/testData/inspections/ChangeSignatureNewParametersNames.py b/python/testData/inspections/ChangeSignatureNewParametersNames.py index 1477278aa0db..9dcafab580da 100644 --- a/python/testData/inspections/ChangeSignatureNewParametersNames.py +++ b/python/testData/inspections/ChangeSignatureNewParametersNames.py @@ -2,4 +2,4 @@ def func(i1): i2 = 'Spam' -func(1, 2, 42 or 'str', get_num()) \ No newline at end of file +func(1, 2, 42 or 'str', get_num()) \ No newline at end of file diff --git a/python/testData/inspections/ChangeSignatureParametersDefaultValues.py b/python/testData/inspections/ChangeSignatureParametersDefaultValues.py index eceee62d0ccc..eda05a746fb3 100644 --- a/python/testData/inspections/ChangeSignatureParametersDefaultValues.py +++ b/python/testData/inspections/ChangeSignatureParametersDefaultValues.py @@ -2,5 +2,5 @@ def func(): pass -func(42, foo='spam') +func(42, foo='spam') func() diff --git a/python/testData/inspections/PyArgumentListInspection/InitializingDataclass/a.py b/python/testData/inspections/PyArgumentListInspection/InitializingDataclass/a.py index 3132d91ade04..4f3c1d616950 100644 --- a/python/testData/inspections/PyArgumentListInspection/InitializingDataclass/a.py +++ b/python/testData/inspections/PyArgumentListInspection/InitializingDataclass/a.py @@ -52,4 +52,4 @@ class B2: B2() B2(1) -B2(1, 2) \ No newline at end of file +B2(1, 2) diff --git a/python/testData/inspections/PyArgumentListInspection/badarglist.py b/python/testData/inspections/PyArgumentListInspection/badarglist.py index 08bf20f42b00..8ac2755a27aa 100644 --- a/python/testData/inspections/PyArgumentListInspection/badarglist.py +++ b/python/testData/inspections/PyArgumentListInspection/badarglist.py @@ -18,8 +18,8 @@ def f1(): pass f1() -f1(1) -f1(a = 1) +f1(1) +f1(a = 1) def f2(a): @@ -28,19 +28,19 @@ def f2(a): f2() # ok, fail f2(1) # ok, pass -f2(1, 2) # ok, fail +f2(1, 2) # ok, fail f2(a = 1) # ok, pass f2(b = 1) # ok, fail -f2(a = 1, b = 2) # ok, fail +f2(a = 1, b = 2) # ok, fail def f3(a, b): pass f3(1, 2) -f3(1, 2, 3) +f3(1, 2, 3) f3(b=2, a=1) -f3(b=1, b=2, a=1) +f3(b=1, b=2, a=1) f3(1, b=2) f3(a=1, 2) diff --git a/python/testData/inspections/PyArgumentListInspection/decorators.py b/python/testData/inspections/PyArgumentListInspection/decorators.py index 6cb33c5d4842..71107a13d7df 100644 --- a/python/testData/inspections/PyArgumentListInspection/decorators.py +++ b/python/testData/inspections/PyArgumentListInspection/decorators.py @@ -13,7 +13,7 @@ def f7(): def f8(): pass -@deco(1, 2) # fail: extra param +@deco(1, 2) # fail: extra param def f9(): pass diff --git a/python/testData/inspections/PyArgumentListInspection/kwargsMapToNothing.py b/python/testData/inspections/PyArgumentListInspection/kwargsMapToNothing.py index c285a60cf423..5029c3b56bd8 100644 --- a/python/testData/inspections/PyArgumentListInspection/kwargsMapToNothing.py +++ b/python/testData/inspections/PyArgumentListInspection/kwargsMapToNothing.py @@ -5,5 +5,5 @@ arg = [1, 2, 3] kwarg = {'c':3} f5(*arg, **kwarg) # ok f5(1,2, **kwarg) # ok -f5(1, 2, 3, **kwarg) # fail -f5(1, 2, 3, *arg) # fail +f5(1, 2, 3, **kwarg) # fail +f5(1, 2, 3, *arg) # fail diff --git a/python/testData/inspections/PyArgumentListInspection/py1268.py b/python/testData/inspections/PyArgumentListInspection/py1268.py index 951df27428ee..baaa9fd9e496 100644 --- a/python/testData/inspections/PyArgumentListInspection/py1268.py +++ b/python/testData/inspections/PyArgumentListInspection/py1268.py @@ -3,8 +3,8 @@ def f(a, b, c): f(c=1, *(10, 20)) f(*(10, 20), c=1) -f(*(10, 20, 30), c=1) # fail: duplicate c -f(1, *(10, 20, 30)) # fail: tuple too long +f(*(10, 20, 30), c=1) # fail: duplicate c +f(1, *(10, 20, 30)) # fail: tuple too long f(1, *(10)) # fail: wrong type f(1, *(10,)) # fail: tuple too short, c not mapped @@ -24,14 +24,14 @@ f2(*(1,2), (c=3, a=1, b=2, *(1,2)) # fail: a and b twice -f3(1, 2, *(3,), c=4) # fail: c twice +f3(c=3, a=1, b=2, *(1,2)) # fail: a and b twice +f3(1, 2, *(3,), c=4) # fail: c twice f3(1,2,3, *(1,2)) f3(c=3, *(1,2)) # -f3(1, c=3, *(1,2)) # fail: c twice -f3(c=3, a=1, b=2, d=(1,2)) # fail: unexpected d +f3(1, c=3, *(1,2)) # fail: c twice +f3(c=3, a=1, b=2, d=(1,2)) # fail: unexpected d f3(1, c=3, *(10,)) # ZZZ f3(1, *(10,)) f3(1, *(10,), c=20) f3(*(1,2), c=20) -f3(*(1,2), a=20) # fail: a twice +f3(*(1,2), a=20) # fail: a twice diff --git a/python/testData/inspections/PyArgumentListInspection/py3k.py b/python/testData/inspections/PyArgumentListInspection/py3k.py index 4ac87031c611..70e7820379f0 100644 --- a/python/testData/inspections/PyArgumentListInspection/py3k.py +++ b/python/testData/inspections/PyArgumentListInspection/py3k.py @@ -19,7 +19,7 @@ def a23(a, *b, c=1): pass a23(1,2,3, c=10) # pass -a23(1,2,3, c=10, a=1) # fail +a23(1,2,3, c=10, a=1) # fail a23(c=10, a=1) # pass a23(c=10, 1) # fail a23(*args, c=1) # pass diff --git a/python/testData/inspections/PyArgumentListInspection/tupleVsLiteralList.py b/python/testData/inspections/PyArgumentListInspection/tupleVsLiteralList.py index 3936d0df1780..d3c41a99bd97 100644 --- a/python/testData/inspections/PyArgumentListInspection/tupleVsLiteralList.py +++ b/python/testData/inspections/PyArgumentListInspection/tupleVsLiteralList.py @@ -2,4 +2,4 @@ def f20(a, (b, c)): pass f20(1, [2, 3]) # ok -f20(1, (2, 3, 4)) # fail +f20(1, (2, 3, 4)) # fail diff --git a/python/testData/quickFixes/PyRemoveArgumentQuickFixTest/duplicate.py b/python/testData/quickFixes/PyRemoveArgumentQuickFixTest/duplicate.py index 47b5067cc548..4716f42c8564 100644 --- a/python/testData/quickFixes/PyRemoveArgumentQuickFixTest/duplicate.py +++ b/python/testData/quickFixes/PyRemoveArgumentQuickFixTest/duplicate.py @@ -2,4 +2,4 @@ def foo(a, p): pass -foo(1, p=2, p=33) +foo(1, p=2, p=33) diff --git a/python/testData/quickFixes/PyRemoveArgumentQuickFixTest/unexpected.py b/python/testData/quickFixes/PyRemoveArgumentQuickFixTest/unexpected.py index 2ae09ef56bce..82f42d31e15a 100644 --- a/python/testData/quickFixes/PyRemoveArgumentQuickFixTest/unexpected.py +++ b/python/testData/quickFixes/PyRemoveArgumentQuickFixTest/unexpected.py @@ -2,6 +2,6 @@ def foo(a): pass -foo(1, 23) +foo(1, 23)