From c95ef5d11126e6a923c24d30c5a47a95f66964ba Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 5 Jul 2010 21:06:05 +0400 Subject: [PATCH] don't highlight dict comprehensions as unsupported in Python 2.7 --- .../jetbrains/python/validation/UnsupportedFeatures.java | 7 +++++-- .../testData/highlighting/unsupportedFeaturesInPython2.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/python/src/com/jetbrains/python/validation/UnsupportedFeatures.java b/python/src/com/jetbrains/python/validation/UnsupportedFeatures.java index 1aa62c2aa648..50a905b86bdc 100644 --- a/python/src/com/jetbrains/python/validation/UnsupportedFeatures.java +++ b/python/src/com/jetbrains/python/validation/UnsupportedFeatures.java @@ -49,8 +49,11 @@ public class UnsupportedFeatures extends PyAnnotator { @Override public void visitPyDictCompExpression(PyDictCompExpression node) { super.visitPyDictCompExpression(node); - if (isPy2(node)) { - getHolder().createWarningAnnotation(node, "Dictionary comprehension is not supported in Python 2").registerFix(new ConvertDictCompIntention()); + LanguageLevel languageLevel = getLanguageLevel(node); + if (!languageLevel.supportsSetLiterals()) { + getHolder() + .createWarningAnnotation(node, "Python version " + languageLevel + " does not support dictionary comprehensions") + .registerFix(new ConvertDictCompIntention()); } } diff --git a/python/testData/highlighting/unsupportedFeaturesInPython2.py b/python/testData/highlighting/unsupportedFeaturesInPython2.py index 41f60f9a36f5..daef8c115147 100644 --- a/python/testData/highlighting/unsupportedFeaturesInPython2.py +++ b/python/testData/highlighting/unsupportedFeaturesInPython2.py @@ -1,6 +1,6 @@ from __future__ import with_statement -{k: v for k, v in stuff} +{k: v for k, v in stuff} try: pass