Allow Mypy/Zuban to ignore specific error codes#2153
Allow Mypy/Zuban to ignore specific error codes#2153davidhalter wants to merge 1 commit intopython:mainfrom
Conversation
57549ff to
8d74622
Compare
|
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.) |
|
@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:
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. |
|
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 |
8d74622 to
f4a919a
Compare
|
I have pushed a new update to the spec. It's just a small addition and I hope it reflects the general sentiment of the discussion in the typing discuss. As always I'm happy to integrate feedback. |
|
@JelleZijlstra Would you mind looking at this spec change? I'd prefer at least a single opinion before I bring this to the typing council. |
|
|
||
| Any text following ``# type: ignore`` is ignored, provided there is at least one | ||
| whitespace character after ``# type: ignore``. The form of | ||
| ``# type: ignore[error_code1, error_code2]`` can be used to filter error codes |
There was a problem hiding this comment.
I'm not sure I follow this line. The spec should primarily say how type checkers should behave, not what it's good for. Can you make sure the spec text makes it very precise exactly what behavior is expected?
There was a problem hiding this comment.
I would expect the behavior to be something like this:
# type: ignoremust ignore all errors# type: ignore[code]may ignore errors, depending on the type checker.
That is, pyright's behavior of ignoring the code and always ignoring errors remains conformant, but mypy's behavior of ignoring the error only when the code matches newly becomes conformant.
We'll also need to be clear about what the following do:
s: str = 1 # type: ignored
s: str = 1 # type: ignore, because I feel like it
s: str = 1 # type: ignore because why not
Changes the error code from
additional_stufftoassignment(as Mypy uses it).This was the proposal Rebecca: