-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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
if key in dictionary:
del dictionary[key]
# Good
dictionary.pop(key, None)
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request