Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use consistent order for messages from mypy daemon #13141

Closed
JukkaL opened this issue Jul 16, 2022 · 1 comment · Fixed by #13780
Closed

Use consistent order for messages from mypy daemon #13141

JukkaL opened this issue Jul 16, 2022 · 1 comment · Fixed by #13780

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Jul 16, 2022

If mypy daemon generates errors in multiple files, successive daemon runs can change the order of messages even if they are otherwise identical (e.g. the first run produces messages from mod1 first followed by messages from mod2, and the second runs produces errors from mod2 first and mod1 next). Try to keep the order of error messages consistent across runs, since the varying order can be distracting when you are trying to fix errors one by one.

Suggested approach:

  • Store the order of files where we reported errors after each daemon run as a list
  • If we had errors in the previous run, sort the errors in the next run so that the order of files matches the previous run (and errors in additional files are at the end, for example)

Errors are already sorted consistently within a single file, but not across multiple files.

Another way would be to sort the messages by the file before reporting them, but this would be a bigger change conceptually and might have some issues (e.g. can't stream errors during the initial run). Preserving the order of errors from the immediate previous run shouldn't cause any additional issues. Related issue: #2144

Test cases to cover:

  • Initial, non-daemon run generates errors.
  • Two successive incremental runs generate errors.
  • There is a successful run between runs that generate errors. In this case the errors can be reported in an arbitrary order.
@michelececcacci
Copy link

michelececcacci commented Aug 19, 2022

I'm working on this right now, but i'm wondering what the best way to store state in-between function calls is, since the client is composed by functions and not by a class. how should i deal with this? Should i just store the file list in args? I also tried changing do_run into a callable class, but the tests didn't like it @JukkaL

JukkaL added a commit that referenced this issue Sep 30, 2022
This fixes an annoyance where the messages got reshuffled between
daemon runs.

Also if there are messages from files that didn't generate messages
during the previous run, move them towards the end to make them
more visible.

Fix #13141.
JukkaL added a commit that referenced this issue Sep 30, 2022
This fixes an annoyance where the messages got reshuffled between daemon
runs.

Also if there are messages from files that didn't generate messages
during the previous run, move them towards the end to make them more
visible.

The implementation is a bit messy since we only have a list of formatted
lines where it's most natural to sort the messages, but individual
messages can be split across multiple lines.

Fix #13141.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants