Skip to content

Comments

Add flag to reveal simpler types#20854

Open
ilevkivskyi wants to merge 3 commits intopython:masterfrom
ilevkivskyi:simple-reveal
Open

Add flag to reveal simpler types#20854
ilevkivskyi wants to merge 3 commits intopython:masterfrom
ilevkivskyi:simple-reveal

Conversation

@ilevkivskyi
Copy link
Member

Something that always bothered me is that our revealed types are verbose. Sometimes they are painful to visually parse (especially for complex types). Here I propose to add a flag that for more clean/compact revealed types. With just few tweaks a typical length of a revealed type is reduced by ~half.

I know this may sometimes cause ambiguous types, but IMO such situations are very rare. We can polish this if people will like it, and maybe make the default in a distant future.

@ilevkivskyi ilevkivskyi marked this pull request as ready for review February 21, 2026 01:26
@github-actions
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@ilevkivskyi
Copy link
Member Author

@JukkaL Any objections to this? This makes long revealed types much readable.

@JukkaL
Copy link
Collaborator

JukkaL commented Feb 23, 2026

I need to think about this. One of the use cases of reveal_type is to investigate what a non-specific type name which could be defined in any number of modules actually refers to. In large codebases it's quite common to have multiple classes with the same short name. It might be better to just simplify builtins prefixes and maybe TypeVar prefixes as well, as these are unlikely to be confusing and will account for a large fraction of the noise probably.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants