From 36d507f809af4afdf49d814e0d9329ddf2cf50c5 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Thu, 23 Jan 2014 18:56:05 +0400 Subject: [PATCH] fixed PY-11277 Python: Wrong "argument equals default" inspection --- .../inspections/PyArgumentEqualDefaultInspection.java | 4 ++++ .../inspections/PyArgumentEqualDefaultInspection/test.py | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/python/src/com/jetbrains/python/inspections/PyArgumentEqualDefaultInspection.java b/python/src/com/jetbrains/python/inspections/PyArgumentEqualDefaultInspection.java index 82013d3a0d99..6a06f875b1b2 100644 --- a/python/src/com/jetbrains/python/inspections/PyArgumentEqualDefaultInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyArgumentEqualDefaultInspection.java @@ -131,6 +131,10 @@ public class PyArgumentEqualDefaultInspection extends PyInspection { if (key.getText().equals(defaultValue.getText())) return true; } + if (key instanceof PyBinaryExpression && defaultValue instanceof PyBinaryExpression) { + if (key.getText().equals(defaultValue.getText())) + return true; + } else if (key instanceof PyStringLiteralExpression && defaultValue instanceof PyStringLiteralExpression) { if (((PyStringLiteralExpression)key).getStringValue().equals(((PyStringLiteralExpression)defaultValue).getStringValue())) return true; diff --git a/python/testData/inspections/PyArgumentEqualDefaultInspection/test.py b/python/testData/inspections/PyArgumentEqualDefaultInspection/test.py index bda25d328cd9..b75341f4e48a 100644 --- a/python/testData/inspections/PyArgumentEqualDefaultInspection/test.py +++ b/python/testData/inspections/PyArgumentEqualDefaultInspection/test.py @@ -67,3 +67,9 @@ kw['customerPaymentProfileId'] = kw.get("customerPaymentProfileId", {1: 2}.get('foo', None) #pass {1: 2}.pop('foo', None) #pass + +def a(foo=1*1024): + print foo + +a( 1024*1024) +