multilspy
multilspy copied to clipboard
fix: finalize even when exiting contextmanager by exception
Contextmanager does not process the finalize process in try-finally and may not execute when exiting contextmanager with an error. Unintended results were observed due to the different state of the file from the application using LSP.
from contextlib import contextmanager
@contextmanager
def sample():
try:
yield
print("a")
finally:
print("b")
with sample():
raise Exception # Show only b
@microsoft-github-policy-service agree