Common mistakes
default-mutable-dict
default-mutable-dict
Function D. Python only instantiates default function arguments once and shares the instance across the function calls. If the default function argument is mutated, that will modify the instance used by all future function calls. This can cause unexpected results, or lead to security vulnerabilities whereby one function consumer can view or modify the data of another function consumer. Instead, use a default argument (like None) to indicate that no argument was provided and instantiate a new dictionary at that time. For example: if $D is None: $D = {}
.
is-not-is-not
is-not-is-not
In Python ‘X is not …’ is different from ‘X is (not …)’. In the latter the ‘not’ converts the ’…’ directly to boolean.
string-concat-in-list
string-concat-in-list
Detected strings that are implicitly concatenated inside a list. Python will implicitly concatenate strings when not explicitly delimited. Was this supposed to be individual elements of the list?
default-mutable-list
default-mutable-list
Function D. Python only instantiates default function arguments once and shares the instance across the function calls. If the default function argument is mutated, that will modify the instance used by all future function calls. This can cause unexpected results, or lead to security vulnerabilities whereby one function consumer can view or modify the data of another function consumer. Instead, use a default argument (like None) to indicate that no argument was provided and instantiate a new list at that time. For example: if $D is None: $D = []
.
identical-is-comparison
identical-is-comparison
Found identical comparison using is. Ensure this is what you intended.
string-is-comparison
string-is-comparison
Found string comparison using ‘is’ operator. The ‘is’ operator is for reference equality, not value equality, and therefore should not be used to compare strings. For more information, see https://github.com/satwikkansal/wtfpython#-how-not-to-use-is-operator”