Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(🐞) An error should be reported when reveal_type is used but not called #12285

Open
KotlinIsland opened this issue Mar 4, 2022 · 5 comments
Labels
feature priority-2-low topic-reveal-type reveal_type() and reveal_locals()

Comments

@KotlinIsland
Copy link
Contributor

KotlinIsland commented Mar 4, 2022

reveal_type
not_defined
main.py:2:1: error: Name "not_defined" is not defined  [name-defined]
Found 1 error in 1 file (checked 1 source file)

Issue:

When reveal_type is called (reveal_type(1)) mypy reports a note and exits with status 1, but when reveal_type is used as a value without being called mypy doesn't report any error or note.

reveal_type

actual:

Success: no issues found in 1 source file

expected:

main.py:1:1: error: reveal_type must be called [misc]
Found 1 error in 1 file (checked 1 source file)
@KotlinIsland KotlinIsland added the bug mypy got something wrong label Mar 4, 2022
@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Mar 4, 2022

This is intentional and documented. mypy (and other type checkers) treat reveal_type like a builtin

@KotlinIsland
Copy link
Contributor Author

@hauntsaninja Thanks for the quick response!, but I think you might have mis-understood my bug report. I'm well aware of how reveal_type works, this issue I'm reporting is that when reveal_type is called (reveal_type(1)) mypy reports a note and exits with status 1, but when reveal_type is used as a value without being called mypy doesn't report any error or note.

I've updated the OP to clarify.

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Mar 4, 2022

Okay, I can see how a non-zero exit code would be nice to have there, but this is low priority for me.

On a similar note, maybe we shouldn't have non-zero exit status code for use of typing.reveal_type in 3.11 cc @JelleZijlstra

@hauntsaninja hauntsaninja reopened this Mar 4, 2022
@hauntsaninja hauntsaninja added feature priority-2-low and removed bug mypy got something wrong labels Mar 4, 2022
@hauntsaninja hauntsaninja changed the title (🐞) mypy thinks reveal_type is defined Make mypy's exit status indicative of runtime success when using reveal_type Mar 4, 2022
@JelleZijlstra
Copy link
Member

I think the exit status issue is muddling the waters here. That's an unrelated change.

The original request was for an error if you use reveal_type without calling it. I guess we could do that but it doesn't seem worth the effort.

@KotlinIsland
Copy link
Contributor Author

KotlinIsland commented Mar 4, 2022

I think that exit 1 on typing.reveal_type is still good, it's completely useless and just gonna spam up the output of runs so mypy failing would be good to stop committing of code like that IMO.

@KotlinIsland KotlinIsland changed the title Make mypy's exit status indicative of runtime success when using reveal_type (🐞) An error should be reported when reveal_type is used but not called Mar 4, 2022
@AlexWaygood AlexWaygood added the topic-reveal-type reveal_type() and reveal_locals() label Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature priority-2-low topic-reveal-type reveal_type() and reveal_locals()
Projects
None yet
Development

No branches or pull requests

4 participants