I have a function as below to get managed resource:
from contextlib import contextmanager
@contextmanager
def getMyClass() -> MyClass:
...
obj = ...
try:
yield obj
...
except:
...
finally:
...
by specifying Type for the getMyClass function, I suppose this got object can be recognized in with...as statement as below:
with getMyClass() as obj:
obj.fun1()
However, VSCode can't recognize the type of obj and the intellisense pop-up menu is not shown. Is it possible to get what I need?
PS: I also check PyCharm, it doesn't show the intellisense pop-up menu either.