Skip to content

Add an optional error code for unimported reveal_type / reveal_locals #16270

@sobolevn

Description

@sobolevn

Some of our users report that reveal_type causes problems in runtime: typeddjango/django-stubs#590

I agree that this is indeed problematic. For example:

x = 1
reveal_type(x)

Mypy checks this code, finds 0 issues, returns 0 as the return code. This script will pass the CI, but will break in runtime. This is not what mypy is expected to do: it is expected to find bugs.

So, I propose adding a new error code:

  • We can name it unimported-reveal
  • It will be turned off by default
  • It will raise errors on all plain reveal_type / reveal_locals usages
  • If you want to keep reveal_type even in production (for some reason), use from typing[_extensions] import reveal_type or type: ignore[unimported-reveal]

Do others have any objections?

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions