Skip to content

Commit

Permalink
Automatically remove duplicate dictionary keys (#1710)
Browse files Browse the repository at this point in the history
For now, to be safe, we're only removing keys with duplicate _values_.

See: #1647.
  • Loading branch information
charliermarsh authored Jan 7, 2023
1 parent 98856e0 commit 4de6c26
Show file tree
Hide file tree
Showing 12 changed files with 1,094 additions and 77 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,8 @@ For more, see [Pyflakes](https://pypi.org/project/pyflakes/2.5.0/) on PyPI.
| F524 | StringDotFormatMissingArguments | '...'.format(...) is missing argument(s) for placeholder(s): ... | |
| F525 | StringDotFormatMixingAutomatic | '...'.format(...) mixes automatic and manual numbering | |
| F541 | FStringMissingPlaceholders | f-string without any placeholders | 🛠 |
| F601 | MultiValueRepeatedKeyLiteral | Dictionary key literal repeated | |
| F602 | MultiValueRepeatedKeyVariable | Dictionary key `...` repeated | |
| F601 | MultiValueRepeatedKeyLiteral | Dictionary key literal `...` repeated | 🛠 |
| F602 | MultiValueRepeatedKeyVariable | Dictionary key `...` repeated | 🛠 |
| F621 | ExpressionsInStarAssignment | Too many expressions in star-unpacking assignment | |
| F622 | TwoStarredExpressions | Two starred expressions in assignment | |
| F631 | AssertTuple | Assert test is a non-empty tuple, which is always `True` | |
Expand Down
38 changes: 38 additions & 0 deletions resources/test/fixtures/pyflakes/F601.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,41 @@
b"123": 1,
b"123": 4,
}

x = {
"a": 1,
"a": 2,
"a": 3,
"a": 3,
}

x = {
"a": 1,
"a": 2,
"a": 3,
"a": 3,
"a": 4,
}

x = {
"a": 1,
"a": 1,
"a": 2,
"a": 3,
"a": 4,
}

x = {
a: 1,
"a": 1,
a: 1,
"a": 2,
a: 2,
"a": 3,
a: 3,
"a": 3,
a: 4,
}

x = {"a": 1, "a": 1}
x = {"a": 1, "b": 2, "a": 1}
38 changes: 38 additions & 0 deletions resources/test/fixtures/pyflakes/F602.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,41 @@
a: 2,
b: 3,
}

x = {
a: 1,
a: 2,
a: 3,
a: 3,
}

x = {
a: 1,
a: 2,
a: 3,
a: 3,
a: 4,
}

x = {
a: 1,
a: 1,
a: 2,
a: 3,
a: 4,
}

x = {
a: 1,
"a": 1,
a: 1,
"a": 2,
a: 2,
"a": 3,
a: 3,
"a": 3,
a: 4,
}

x = {a: 1, a: 1}
x = {a: 1, b: 2, a: 1}
Loading

0 comments on commit 4de6c26

Please sign in to comment.