Errors are not sorted by file

Open
#2,144 6 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
tooling

Research direction

Start in mypy/errors.py at Errors.sort_messages(), then review the issue discussion for the intended ordering: by filename or by command-line/package input order. Define the expected behavior before changing the sorting path, and verify that errors from many files are emitted in the agreed deterministic order.

Written by the indexing model from the issue text.

Description

priority-1-normal topic-usability

I just noticed that when you run mypy on a large number of files, the errors don't come out sorted by filename, even if you pass the filenames in sorted order on the command line. I presume this is some kind of side effect of processing files in an order determined by the dependency graph.

Maybe we should just sort them all by filename? Or sort them back in the order in which they were passed on the command line (or expanded from packages/directories)?

It seems the Errors.sort_messages() method in mypy/errors.py could easily sort messages by filename; sorting them by original order would require the original order to be passed in to that function (not rocket science, but perhaps requiring some small refactoring).

Dominant language
Python
Stars
20.6k
Forks
3.3k
Avg merge
1d 18h
Merged PRs (30d)
54

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python/mypy

All issues in python/mypy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.