| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Part of the documentation was taken from mypy: https://mypy.readthedocs.io/en/stable/common_issues.html#reveal-type
|
Thank you! This solves my old pain with redefining reveal_type as: from typing import TYPE_CHECKING
if not TYPE_CHECKING:
reveal_type = print |
Sorry, something went wrong.
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
|
Hold on. This feels awkward, since previously this was a builtin. I don’t want to have to import it. |
Sorry, something went wrong.
Type checkers would still allow using it without the import. You'll have the option to import it if you want to run your code or document to readers what reveal_type() means. |
Sorry, something went wrong.
|
It needs more discussion. Please wait until I have a keyboard. |
Sorry, something went wrong.
|
No hurry! I also opened a thread on typing-sig about this, that's probably the best place to discuss how it should work. |
Sorry, something went wrong.
|
@gvanrossum based on the discussion on typing-sig, are you satisfied with this change now? I'm planning to also add reveal_locals() in a separate PR. |
Sorry, something went wrong.
|
Wait, I didn't address Nikita's review yet. |
Sorry, something went wrong.
|
Did we bikeshed yet whether it should write to stdout or stderr? |
Sorry, something went wrong.
No, though there have been some suggestions about the output format; I just sent a typing-sig email about that too. Personally I don't care much but I'd like to keep it simple. |
Sorry, something went wrong.
I'm just thinking that sending the output to stderr would be more in line with the debug nature of the API. |
Sorry, something went wrong.
|
Pushed a change to make it write to stderr instead. |
Sorry, something went wrong.
Co-authored-by: Guido van Rossum <guido@python.org>
| sys.modules[re.__name__] = re | ||
|
|
||
|
|
||
| def reveal_type(obj: T, /) -> T: |
There was a problem hiding this comment.
Do we use type hints in typing.py? 🤔
Sorry, something went wrong.
There was a problem hiding this comment.
If this is merged, we will :). I don't see any reason not to, especially in cases like this where the type is simple and helps document the behavior.
Sorry, something went wrong.
There was a problem hiding this comment.
There are type annotations in a few lines of typing.py:
Line 2531 in 270a091
It's just about the only module in the stdlib in which I've spotted any type annotations other than importlib :)
Sorry, something went wrong.
|
@gvanrossum do you think this is ready to merge now? The discussion on typing-sig has died down. (You added the "Do not merge" label a while ago.) I think the other new function PRs are also ready, but I can ping you on those later. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM.
Sorry, something went wrong.
|
@gvanrossum: Please replace # with GH- in the commit message next time. Thanks! |
Sorry, something went wrong.
|
Should probably post the resolution to typing-sig. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Part of the documentation was taken from mypy:
https://mypy.readthedocs.io/en/stable/common_issues.html#reveal-type
https://bugs.python.org/issue46414