You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
I'm having an issue with the returned value of the enter_context(...) instance method of contextlib.ExitStack.
If you enter the following snippet into VSCode and mouse-over the file variable, the tool-tip says that the inferred type is __NoneType__ but it should be TextIOWrapper.
importcontextlibwithcontextlib.ExitStack() asstack:
file=stack.enter_context(open("temporary-file.txt", mode="w"))
# reveal_type(file) # Revealed type is 'typing.TextIO*'
You can uncomment the reveal_type(file) line with mypy enabled and it will tell you that the revealed type is typing.TextIO*, which is fine for this case.
I've also observed this behavior with tempfile.NamedTemporaryFile.
I'm having an issue with the returned value of the
enter_context(...)instance method ofcontextlib.ExitStack.If you enter the following snippet into VSCode and mouse-over the
filevariable, the tool-tip says that the inferred type is__NoneType__but it should beTextIOWrapper.You can uncomment the
reveal_type(file)line withmypyenabled and it will tell you that the revealed type istyping.TextIO*, which is fine for this case.I've also observed this behavior with
tempfile.NamedTemporaryFile.Any idea what's going on here?
Thanks!