Skip to content

--warn-unused-ignores in non-checked branches #5940

Closed
@srittau

Description

@srittau

Consider the following mixed Python 2 and 3 stub:

import sys

if sys.version_info < (3,):
    class X:
        def foo(self) -> int: ...
    class Y(X):
        def foo(self) -> str: ...  # type: ignore

Using mypy 0.641 and Python 3.6.7 when running this with mypy --warn-unused-ignores mypy wll complain:

foo.pyi:7: note: unused 'type: ignore' comment

As expected it will not complain when running in --py2 mode. I believe mypy should not complain about ignores in branches that are not checked.

See also #2961, which is more generic.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions