From 331675d4132ac9b07c154c1ddf775e9de153b803 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 28 Jun 2021 20:40:10 +0530 Subject: [PATCH] Fix ResourceWarning --- kitty/conf/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kitty/conf/utils.py b/kitty/conf/utils.py index 002d377fc..c6d601182 100644 --- a/kitty/conf/utils.py +++ b/kitty/conf/utils.py @@ -310,7 +310,8 @@ def save_type_stub(text: str, fpath: str) -> None: fpath += 'i' preamble = '# Update this file by running: ./test.py mypy\n\n' try: - existing = open(fpath).read() + with open(fpath) as fs: + existing = fs.read() except FileNotFoundError: existing = '' current = preamble + text