python / python/mypy

New analyzer: Ensure that mangled -redefinition names don't appear in error messages

Open
#6,978 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

priority-1-normal semantic-analyzer topic-usability
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

For example:

class A:
    x: str
    def x(self) -> str: ...

class B:
    x: int
    def x(self) -> int: ...

class C(A, B): ...

fails with

main:3: error: Name 'x' already defined on line 2
main:7: error: Name 'x' already defined on line 6
main:9: error: Definition of "x-redefinition" in base class "A" is incompatible with definition in base class "B"
main:9: error: Definition of "x" in base class "A" is incompatible with definition in base class "B"

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

Reproduce the Python example from the issue with mypy and trace the analyzer path that formats the base-class incompatibility diagnostics. Done means the errors no longer expose the mangled "-redefinition" name while still reporting the relevant incompatibility.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.