python / python/mypy

Improve multiline reporting

Open
#15,273 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Current multiline error/notice reporting is hacky, e.g.
https://github.com/python/mypy/blob/c1fb57d38116adf6c1c1ea5c4b998cae597ec156/mypy/messages.py#L1161-L1169

Notice how

  • we call notice multiple times even as it relates to the same core issue
  • we pass allow_dups=True to suppress deduplication of, say, the same type
  • we mistakenly(?) dedup the "Superclass:" and "Subclass:" notices
  • by always doing allow_dups=False, we can effectively dedup when it would make sense

I think it'll be better if the extra lines could be part of the error, also reducing code duplication (we end up passing a lot of the same parameters multiple times). Is there a reason why we didn't? Is it a pattern elsewhere in the code?

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.

Research direction

Start in mypy/messages.py at the linked lines 1161-1169 and trace the related notice and deduplication behavior. Look for other multiline reporting patterns and determine how extra lines could belong to one error without incorrect deduplication. Done should reduce repeated parameter passing while preserving the intended distinction between related notices.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.