Skip to content

Add a way to suppress unknown-name diagnostics for reveal_type usages #2550

@sharkdp

Description

@sharkdp

Please consider this a very-low-priority request, and feel free to close it.

When checking a file with pyrefly, reveal_type already works fine without importing it from typing/typing_extensions, but an additional unknown-name diagnostic is emitted which makes it hard(er) to find the revealed type:

▶ cat test.py
reveal_type(1 + 1)

▶ pyrefly check test.py 
ERROR `reveal_type` must be imported from `typing` for runtime usage [unknown-name]
 --> test.py:1:1
  |
1 | reveal_type(1 + 1)
  | ^^^^^^^^^^^
  |
 INFO revealed type: int [reveal-type]
 --> test.py:1:12
  |
1 | reveal_type(1 + 1)
  |            -------
  |
 INFO 1 error

Other type checkers (mypy, pyrefly, ty) all suppress their version of the unknown-name diagnostic for reveal_type usages, or give users a way to suppress them in the config (without silencing all unknown-name diagnostics). This is a nice quality-of-life improvement when working with reveal_type as a debugging tool, especially if you have multiple reveal_type's in a single file.

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions