[ty] Add blanket ignore comment rule - #26426
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 94.54%. The percentage of expected errors that received a diagnostic held steady at 90.31%. The number of fully passing files held steady at 96/134. |
Memory usage reportMemory usage unchanged ✅ |
|
carljm
left a comment
There was a problem hiding this comment.
Thanks! I would like to better understand the rationale for some of the design choices here, left comments inline.
I also think the interaction between this rule and --add-ignore should at least be explicitly documented and tested. The current interaction is a bit strange, in that --add-ignore will change:
value = missing # ty: ignoreinto
value = missing # ty: ignore # ty: ignore[blanket-ignore-comment]Which feels a bit strange, but might actually be the most straightforward and intuitive option?
|
Regarding |
6af7fdf to
971eed5
Compare
…t_ignore.md Co-authored-by: Carl Meyer <carl@astral.sh>
|
Having thought about this again, I actually think what I had before was better. Maybe not in this every exact form but raising a However, we should report any blanked ignore comment if The current design is also unfavorable to value = 1 # ty: ignoreFirst produces value = 1 # ty: ignore # ty:ignore[blanket-ignore-comment]If you now run
|
|
Sorry, I still strongly disagree here. I think it is confusing for different rules to interact in this way and silence each other. Each rule should have simple documented rules for what causes it to fire, and follow those rules, independent of other rules, even if that results in two diagnostics on one line. It is not necessarily the case that "The right fix is always to remove the unused ignore comment." -- that's an unwarranted assumption that is trying too hard to read the user's mind. This is up to the user to decide. They've asked us to error on blanket ignores, and we should do that. Consider the case where the configuration specifies |
That would imply that
Fix also doesn't make this distinction. |
|
I think it is reasonable for I don't think that whether |
|
The error/warning case is interesting. But I still think raising |
|
IMO those cases are not parallel. |
|
I don't fully agree, but it seems you feel more strongly about this than I. So I'll back out of my last change for now, so that this gets merged (and I can put it behind me :)) |
e784e32 to
6f985de
Compare
|
It would be great to add this rule to https://docs.astral.sh/ty/coming-from-mypy-or-pyright/#recommended-configuration and https://docs.astral.sh/ty/coming-from-mypy-or-pyright/#mapping-pyrightmypy-rules-to-tyruff-rules — mypy enables an equivalent rule in its strict mode |
Summary
Adds an opt-in
blanket-ignore-commentrule that requires rule codes onty: ignorecomments.Closes astral-sh/ty#3324.
Test Plan
Testing: Added mdtest coverage and ran the ty semantic test suite, Clippy, and repository hooks.