python / python/mypy

Inconsistency in `reveal_type(some_type)`

Open
#13,062 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-reveal-type topic-usability
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Consider this example:

t1 = int
t2: type[int] = t1

reveal_type(int) # huge overload
reveal_type(t1) # huge overload
reveal_type(t2) # Type[builtins.int]

I expect get the same result in all three reveal_type's, but in two cases i get huge overload: Overload(def (Union[builtins.str, builtins.bytes, array.array[Any], mmap.mmap, ctypes._CData, pickle.PickleBuffer, typing.SupportsInt, typing_extensions.SupportsIndex, _typeshed.SupportsTrunc] =) -> builtins.int, def (Union[builtins.str, builtins.bytes], base: typing_extensions.SupportsIndex) -> builtins.int), and in one case i get Type[builtins.int]

My Environment

  • mypy 0.961 (compiled: no)
  • no command-line flags, no config file
  • CPython 3.10.4
  • Windows 10

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 by running the supplied example with mypy 0.961 and compare the three reveal_type outputs. Trace how the checker handles int, the alias t1, and the annotated type t2; done means the behavior is consistent with the issue's expected result and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
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.