Skip to content

Instantly share code, notes, and snippets.

@DrewDennison
Created January 22, 2020 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrewDennison/19e1335e5ab642cc0c80b053e6c7d414 to your computer and use it in GitHub Desktop.
Save DrewDennison/19e1335e5ab642cc0c80b053e6c7d414 to your computer and use it in GitHub Desktop.
rules:
- id: use-default-dict
pattern: |
$DICT = {}
...
if $KEY not in $DICT:
...
$DICT[$KEY] = []
...
$DICT[$KEY].append($ITEM)
message: "You should use a default dict instead of checking if the key not in the dict and setting a default"
languages: [python]
severity: ERROR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment