You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to PyLint some of these default values may be harmful:
dangerous-default-value / W0102
Message emitted:
Dangerous default value %s as argument
Description:
Used when a mutable value as list or dictionary is detected in a default value for an argument.
Problematic code:
defwhats\_on\_the\_telly(penguin\=\[\]): \# \[dangerous-default-value\]
penguin.append("property of the zoo")
returnpenguin
Correct code:
defwhats\_on\_the\_telly(penguin\=None):
ifpenguinisNone:
penguin \= \[\]
penguin.append("property of the zoo")
returnpenguin
Additional details:
With a mutable default value, with each call the default value is modified, i.e.:
whats\_on\_the\_telly() \# \["property of the zoo"\]
whats\_on\_the\_telly() \# \["property of the zoo", "property of the zoo"\]
whats\_on\_the\_telly() \# \["property of the zoo", "property of the zoo", "property of the zoo"\]
The text was updated successfully, but these errors were encountered:
Currently, many default values are set to
None
by proxy (e.g.,""
,[]
,{}
) to be compliant with the given type hint, e.g.instead of:
According to PyLint some of these default values may be harmful:
The text was updated successfully, but these errors were encountered: