Skip to content

Conversation

@davidhalter
Copy link
Contributor

@davidhalter davidhalter commented Jan 19, 2026

Changes the error code from additional_stuff to assignment (as Mypy uses it).

This was the proposal Rebecca:

For # type: ignore[additional_stuff], I can see the argument for allowing an error about additional_stuff being an invalid code, but it seems tricky to update that line to allow both mypy’s and pyright’s behavior, since they’re so different. (Mypy also reports an assignment error, since that error code isn’t suppressed.) Maybe we could change it to:

z: int = "" # type: ignore[assignment]

so that the expected behavior in all type checkers is that there’s no error?

@srittau srittau added the topic: conformance tests Issues with the conformance test suite label Jan 19, 2026
@JelleZijlstra
Copy link
Member

This will need changes in the spec text as well as the conformance suite, and it will need to be approved by the Typing Council. (Personally, I'm supportive of doing something like this, but haven't thought too much about the exact proposal yet.)

@davidhalter
Copy link
Contributor Author

@JelleZijlstra What do you have in mind? My problem is that the spec is currently not specific about this at all (see this discussion) and I haven't gotten much feedback on where people would want to take this in the same thread.

Would you want to add something to the spec like this:

Any text following # type: ignore is ignored, provided there is at least one whitespace character after # type: ignore.

The only exception is the form # type: ignore[assignment], where the bracketed portion is used by mypy to restrict the ignored error codes. Other type checkers may ignore the bracketed codes and treat this form as equivalent to # type: ignore.

This is of course just my initial idea, any guidance is appreciated. The current spec doesn't really talk about this, so this should be more of an addition.

@JelleZijlstra
Copy link
Member

Something like that, yes. If the spec doesn't currently discuss this, that means we should add it.

The spec text shouldn't call out any specific type checker (like mypy). Instead, we should generically say that type checkers may use syntax like [code] to restrict the type ignore.

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

Labels

topic: conformance tests Issues with the conformance test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants