This rule raises an issue when a dictionary is iterated over without explicitly calling the .items() method.
When iterating directly over a dictionary e.g., for k, v in some_dict: or {k: v for k, v in some_dict}, Python iterates
over the dictionary’s keys by default. If the intention is to access both the key and the value, omitting .items() leads to unexpected
behavior. In such cases, the k variable would receive the key, and the v variable would attempt to unpack the key itself,
which can lead to errors or subtle bugs if the key is iterable, like a string. For example, if a key is a string like
"hi", k would be 'h' and v would be 'i'.
To fix this, simply append .items() to your dictionary when iterating.
some_dict = { "k1": "v1", "k2": "v2"}
{k: v for k, v in some_dict} # Noncompliant: `v` will not receive the value, but the first character of the key
some_dict = { "k1": "v1", "k2": "v2"}
for k, v in some_dict: # Noncompliant: `v` will not receive the value, but the first character of the key
...
some_dict = { "k1": "v1", "k2": "v2"}
{k: v for k, v in some_dict.items()}
some_dict = { "k1": "v1", "k2": "v2"}
for k, v in some_dict.items():
...