feat: add contextlib

This commit is contained in:
Shunsuke Shibayama 2023-06-29 15:03:56 +09:00
parent 1eabc1f0c0
commit d03dcbd392
3 changed files with 31 additions and 6 deletions

View file

@ -0,0 +1,12 @@
.contextmanager: |F <: GenericCallable|(F) -> F
.closing!: |T|(thing: Structural { .close = (self: T) -> Obj }) => NoneType
.ExitStack!: ClassType
.ExitStack! <: ContextManager
.ExitStack!.
__call__: () -> .ExitStack!
enter_context!: (self: .ExitStack!, cm: ContextManager) => NoneType
push!: (self: .ExitStack!, exit: GenericCallable) => NoneType
callback!: (self: .ExitStack!, callback: GenericCallable) => NoneType
pop_all!: (self: .ExitStack!) => [GenericCallable; _]
close!: (self: .ExitStack!) => NoneType