From 2b7fb6ff08a49618ee441f80b07bd622e1ee0b1b Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Thu, 29 Oct 2015 07:40:05 -0700 Subject: Removes the use of mutables as default args Passing mutable objects as default args is a known Python pitfall. We'd better avoid this. This commit changes mutable default args with None, then use 'arg = arg or {}', 'arg = arg or []'. For unit code which doesn't use the args , just set with None. This commit also adds hacking check. This code was taken from commit 0bea84ac20fe498bd08f7212a0017196c8cb0812 in Nova. Change-Id: I36d07cade687690dc02a8f6cc3d70f5d00caf112 Co-Authored-By: ChangBo Guo(gcb) --- HACKING.rst | 1 + 1 file changed, 1 insertion(+) (limited to 'HACKING.rst') diff --git a/HACKING.rst b/HACKING.rst index 6b9df25901..0eade2778f 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -18,6 +18,7 @@ Neutron Specific Commandments - [N326] Python 3: do not use basestring. - [N327] Python 3: do not use dict.iteritems. - [N328] Detect wrong usage with assertEqual +- [N329] Method's default argument shouldn't be mutable Creating Unit Tests ------------------- -- cgit v1.2.1