Skip to content

"# type: ignore" does not seem to work on multiline dicts #627

Closed
@josephharrington

Description

@josephharrington

There seems to be inconsistent behavior between these two equivalent pieces of code.

mypy is happy with this:

import http.client
errors = {'not_found': http.client.NOT_FOUND}  # type: ignore

but this fails with "module" has no attribute "NOT_FOUND" (no matter where I put the annotation):

import http.client
errors = {                              # type: ignore
    'not_found': http.client.NOT_FOUND  # type: ignore
}                                       # type: ignore

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions