mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 04:19:18 +00:00
![]() Support using `reveal_type` without importing it, as implied by the type spec and supported by existing type checkers. We use `typing_extensions.reveal_type` for the implicit built-in; this way it exists on all Python versions. (It imports from `typing` on newer Python versions.) Emits an "undefined name" diagnostic whenever `reveal_type` is referenced in this way (in addition to the revealed-type diagnostic when it is called). This follows the mypy example (with `--enable-error-code unimported-reveal`) and I think provides a good (and easily understandable) balance for user experience. If you are using `reveal_type` for quick temporary debugging, the additional undefined-name diagnostic doesn't hinder that use case. If we make the revealed-type diagnostic a non-failing one, the undefined-name diagnostic can still be a failing diagnostic, helping prevent accidentally leaving it in place. For any use cases where you want to leave it in place, you can always import it to avoid the undefined-name diagnostic. In the future, we can easily provide configuration options to a) turn off builtin-reveal_type altogether, and/or b) silence the undefined-name diagnostic when using it, if we have users on either side (loving or hating pseudo-builtin `reveal_type`) who are dissatisfied with this compromise. |
||
---|---|---|
.. | ||
module_resolver | ||
semantic_index | ||
types | ||
ast_node_ref.rs | ||
db.rs | ||
lib.rs | ||
module_name.rs | ||
node_key.rs | ||
program.rs | ||
python_version.rs | ||
semantic_index.rs | ||
semantic_model.rs | ||
site_packages.rs | ||
stdlib.rs | ||
types.rs |