From 2669f97a03d3abd89a033a376a8913bb6f5ae581 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 22 Jan 2010 13:39:47 +0300 Subject: [PATCH] highlight tuple parameter unpacking as error in Py3 code (http://www.python.org/dev/peps/pep-3113/) --- python/src/com/jetbrains/python/PyBundle.properties | 1 + .../python/validation/ParameterListAnnotator.java | 8 ++++++++ python/testData/highlighting/keywordOnlyArguments.py | 4 +++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/python/src/com/jetbrains/python/PyBundle.properties b/python/src/com/jetbrains/python/PyBundle.properties index 543c87254414..fdfed0b8ef02 100644 --- a/python/src/com/jetbrains/python/PyBundle.properties +++ b/python/src/com/jetbrains/python/PyBundle.properties @@ -164,6 +164,7 @@ ANN.regular.param.after.vararg=regular parameter after * parameter ANN.regular.param.after.keyword=regular parameter after ** parameter ANN.non.default.param.after.default=non-default parameter follows default parameter ANN.named.arguments.after.star=named arguments must follow bare * +ANN.tuple.py3=tuple parameter unpacking is not supported in Python 3 ANN.star.import.at.top.only='import *' only allowed at module level diff --git a/python/src/com/jetbrains/python/validation/ParameterListAnnotator.java b/python/src/com/jetbrains/python/validation/ParameterListAnnotator.java index b5ee19d4fb38..4c6374cedd4c 100644 --- a/python/src/com/jetbrains/python/validation/ParameterListAnnotator.java +++ b/python/src/com/jetbrains/python/validation/ParameterListAnnotator.java @@ -62,6 +62,14 @@ public class ParameterListAnnotator extends PyAnnotator { } } + @Override + public void enterTupleParameter(PyTupleParameter param, boolean first, boolean last) { + super.enterTupleParameter(param, first, last); + if (languageLevel.isPy3K()) { + markError(param, PyBundle.message("ANN.tuple.py3")); + } + } + @Override public void visitSingleStarParameter(PySingleStarParameter param, boolean first, boolean last) { hadSingleStar = true; diff --git a/python/testData/highlighting/keywordOnlyArguments.py b/python/testData/highlighting/keywordOnlyArguments.py index b9feafa3c368..0e5f10baf995 100644 --- a/python/testData/highlighting/keywordOnlyArguments.py +++ b/python/testData/highlighting/keywordOnlyArguments.py @@ -9,4 +9,6 @@ def keywordonly_sum_bad2(p1, *, (k1, k2), **kw): + pass