From 9a38ce0ebba006c2dc4313cba47c9c0cb1a98be7 Mon Sep 17 00:00:00 2001 From: Your NameMykola Date: Sat, 4 Jan 2025 22:08:08 +0200 Subject: [PATCH] all tests passed --- app/main.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 442b381e..dc61aa34 100644 --- a/app/main.py +++ b/app/main.py @@ -1,3 +1,16 @@ +from os import remove +from typing import Optional, Type + + class CleanUpFile: - # write your code here - pass + def __init__(self, name: str) -> None: + self.filename = name + + def __enter__(self) -> "CleanUpFile": + return self + + def __exit__(self, + exc_type: Optional[Type[BaseException]], + exc_val: Optional[Type[BaseException]], + exc_tb: Optional[object]) -> None: + remove(self.filename)