> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Remove Duplicate Dict Key

#### Sourcery suggestion id: `remove-duplicate-dict-key`

#### Description:

Remove duplicate keys when instantiating `dict`s.

#### Before:

```python
my_dict = {a: 1, b: 2, a: 3, **d1, **d2, **d1}
```

#### After:

```python
my_dict = {b: 2, a: 3, **d2, **d1}
```

#### Explanation:

Dictionary keys must be unique. Hence, repeated keys are redundant and can be
removed from its inialization to increase the conciseness and clarity of the
code.

!!! note "Note"
    This is a breaking change in Python 3.7+ since `dict` keys are kept in their
    insertion order. By applying this *suggestion*, the order of insertion is
    changed. If your application does not rely on this ordering, then there won't be
    any changes in behaviour.
