PY-17295 In the quickfix use "if param is None" check instead of "if not param"

This commit is contained in:
Mikhail Golubev
2015-10-30 15:59:44 +03:00
parent e855697cee
commit 919008305a
4 changed files with 5 additions and 4 deletions
@@ -64,7 +64,8 @@ public class PyDefaultArgumentQuickFix implements LocalQuickFix {
final PyNamedParameter newParam = generator.createParameter(defName, PyNames.NONE, null, languageLevel);
param.replace(newParam);
final String conditionalText = "if not " + defName + ":\n\t" + defName + " = " + defaultValue.getText() + "\n";
final String conditionalText = "if " + defName + " is None:" +
"\n\t" + defName + " = " + defaultValue.getText();
final PyIfStatement conditionalAssignment = generator.createFromText(languageLevel, PyIfStatement.class, conditionalText);
PyUtil.addElementToStatementList(conditionalAssignment, function.getStatementList(), true);
}
@@ -1,6 +1,6 @@
def func(x, # comment
mutable=None):
"""Docstring."""
if not mutable:
if mutable is None:
mutable = []
print(mutable)
@@ -1,3 +1,3 @@
def bar(args=None):
if not args:
if args is None:
args = []
@@ -1,3 +1,3 @@
def foo(args=None):
if not args:
if args is None:
args = []