Skip to content

Report incorrect assigning of dictionary entries with a colon (:) #756

@dannysepler

Description

@dannysepler

Consider the following code

dct = {
    'a': 1,
}
dct['b']: 2
print(dct)  # {'a': 1}

This is actually valid python syntax, because it is typing the 'b' entry as a 2 type. But we can assume the user meant to assign an element rather than type it (especially if there's no equal on this line).

Maybe this is better for flake8-bugbear instead, happy to open an issue there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions