Skip to content

# type: ignore doesn't work on wrapped lines #8905

Closed

Description

@Dreamsorcerer
def _exception_handler(self, loop: asyncio.AbstractEventLoop,
                       context: Mapping[str, Any]) -> None:  # type: ignore[misc]

In this example, the error produced is error: Explicit "Any" is not allowed [misc].
It says the error is on line 1, but clearly is on line 2.
That's not a problem in itself, I assume it's just treating the wrapped line as a single line.

However, the ignore comment, which is on the correct line, is not recognised by Mypy unless it is moved to the first line. If Mypy is going to treat wrapped lines as a single line, then the comments should also get wrapped to that same line.

Activity

  1. JelleZijlstra commented on May 27, 2020

    @JelleZijlstra
    Member

    To mypy the error is on line 1, so that's where it wants the type ignore to be.

    However, on Python 3.8+ I believe we should allow this ignore to work, see #6648.

  2. Dreamsorcerer commented on May 27, 2020

    @Dreamsorcerer
    ContributorAuthor

    I'm just suggesting that if Mypy thinks that error is on line 1, then it should also think that the comment is on line 1.

    I'm running 3.8.2, so doesn't seem to work in 3.8+.

  3. emmatyping commented on May 20, 2022

    @emmatyping
    Member

    Checking the OP error, it seems to correctly silence the issue (fixed by #6648).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions