Files
openide/python/python-psi-impl/resources/inspectionDescriptions/PyDefaultArgumentInspection.html
Louis Vignier 1869ec9da6 [codeInspection] Fix python inspection descriptions
GitOrigin-RevId: 56876a5dd073a06c3fcc92f63ed1f5674830bc25
2023-04-28 13:13:25 +00:00

21 lines
613 B
HTML

<html>
<body>
<p>Reports a problem when a mutable value as a list or dictionary is detected in a default value for
an argument. <br/>
Default argument values are evaluated only once at function definition time,
which means that modifying the
default value of the argument will affect all subsequent calls of that function.</p>
<p><b>Example:</b></p>
<pre><code>
def func(s, cache={}):
cache[s] = None
</code></pre>
<p>When the quick-fix is applied, the code changes to:</p>
<pre><code>
def func(s, cache=None):
if cache is None:
cache = {}
cache[s] = None
</code></pre>
</body>
</html>