Skip to content

Conformance Tests directives_type_ignore should probably allow Mypy-like type ignores #2126

@davidhalter

Description

@davidhalter

The conformance test directives_type_ignore feels a bit weird since it disallows the Mypy syntax:

z: int = ""  # type: ignore[<some-error-code>]
# It has the following line where the violation should be suppressed:
z: int = ""  # type: ignore[additional_stuff]

The documentation says:

In some cases, linting tools or other comments may be needed on the same line as a type comment. In these cases, the type comment should be before other comments and linting markers:

# type: ignore # <comment or other marker>

I feel it is therefore not really clear if the conformance tests are correct or not and I would really like to avoid adding a flag to Zuban with the name --make-conformance-tests-pass. # type: ignore[misc] can also be found in numerous places in Typeshed.

I would just suggest allowing an error there.


There's also this line that should be ignored to the conformance tests:

y: int = ""  # type: ignore - additional stuff

where I'm not sure if it's better to allow an error there, but I don't have an opinion there really. It might be useful to generate an error that the - additional stuff is not conformant with the spec that says we should use an additional comment. Mypy for example has the error Invalid "type: ignore" comment [syntax]. I'm however totally fine if the conformance tests disallow this.

cc @erictraut since you wrote these tests AFAIK.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions