Open InSyncWithFoo opened 1 week ago
When removing a key from a dictionary, there's no need to check for its existence, as the end results will be the same anyway. Thus, dict.pop(key, None) is preferred.
dict.pop(key, None)
Also see this issue at @astral-sh/ruff.
if key in dictionary: del dictionary[key] # Good dictionary.pop(key, None)
Explanation
When removing a key from a dictionary, there's no need to check for its existence, as the end results will be the same anyway. Thus,
dict.pop(key, None)
is preferred.Also see this issue at @astral-sh/ruff.
Example