You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add new syntax to let the mypy test file syntax anticipate --pretty output #20811
The thing that makes #19510 complex is the differences in test output. One possible approach to this is to update the test output to be what it will be if --pretty is enabled. This is complicated by the fact that our current syntax for inline errors in the test data does not actually support what --pretty outputs. Adding that feature could possibly be useful.
(Additionally, #19940 should probably be fixed, and #19546 merged, before this issue is addressed, if one wants the process to be maximally smooth.)
Huh, it hadn't even occurred to me — there's no syntax for multi-line inline comments, is there? Nor for ignoring subsequent lines of a pretty comment in a test...
Or alternatively we can disable it in (most) tests, even if it is on by default. We already do this with some flags, like e.g. we allow empty function bodies in tests.
I do think it would be nice to have some syntax to annotate spans in the test syntax. Maybe || (or |||) on both sides of the expression? That doesn't show up in our test cases. I think this could be useful even if we don't enable --pretty!
This could maybe look something like:
print(5+||"5"||) # E: Unsupported operand types for + ("int" and "str")
(wow the span for that error is super wrong)
To implement this, the test case runner could use the JSON output format which I think has start/end col info, check if the spans match, and check that the error message is one of the comments. (I don't think there's a good syntax for matching specific areas to specific spans. Maybe just going in order?)
Activity
ilevkivskyi commentedon Feb 14, 2026
Or alternatively we can disable it in (most) tests, even if it is on by default. We already do this with some flags, like e.g. we allow empty function bodies in tests.
A5rocks commentedon Feb 14, 2026
I do think it would be nice to have some syntax to annotate spans in the test syntax. Maybe
||(or|||) on both sides of the expression? That doesn't show up in our test cases. I think this could be useful even if we don't enable--pretty!This could maybe look something like:
(wow the span for that error is super wrong)
To implement this, the test case runner could use the JSON output format which I think has start/end col info, check if the spans match, and check that the error message is one of the comments. (I don't think there's a good syntax for matching specific areas to specific spans. Maybe just going in order?)