-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Feature: reveal_type should work from comments #8864
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
Comments
I'm not sure if this would be a net improvement. Now it's possible to comment out uses of Also, this may be tricky to support since the parser we use drops most comments, I think. |
Thanks for you response and your work on Mypy, @JukkaL. The syntax for the comment can be different, to accommodate the current use of commenting out uses of
Before focusing on the syntax of the comment, what do people think of the idea of having a way to put calls to |
It doesn't seem to me that it would be enough less cumbersome than `if
TYPE_CHECKING` to be worth having and documenting as an extra feature
…On Fri, May 22, 2020 at 11:35 AM Luciano Ramalho ***@***.***> wrote:
Thanks for you response and your work on Mypy, @JukkaL
<https://github.com/JukkaL>.
The syntax for the comment can be different, to accommodate the current
use of commenting out uses of reveal_type, and make it easier for the
parser. Maybe this:
a = some_func() # type: reveal_type(a)
Before focusing on the syntax of the comment, what do people think of the
idea of having a way to put calls to reveal_type in test suites in a way
that does not interfere with running the tests, and also doesn't require
the cumbersome if TYPE_CHECKING guards?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#8864 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACTC7N6A2XJ2LGNWBP6VODRS3AVHANCNFSM4NGJPS2Q>
.
|
My use case is as a teacher and a writer: I have code that is tested with pytest, and is sprinkled with I am biased, but I do believe that features that help with learning should be carefully considered, even if they don't seem useful to those with a lot of experience with the tool. |
@ramalho, does the recent addition of |
No, it does not solve my use case. Please consider my initial feature request and my responses to the other comments. Thanks! |
The use case seems too marginal to justify the complexity, especially now that we have the runtime |
I agree @JelleZijlstra. I did not know that |
It would be great if reveal_type could be called from comments.
Mypy already looks at various comments to do its job, and reveal_type is not a runtime function, it only exists during a type check.
While experimenting with type hints in test code, I could write this:
a = some_func() # reveal_type(a)
Instead of:
The text was updated successfully, but these errors were encountered: