From 10d341f51442b5611c89d6e9521c45ab53137e7f Mon Sep 17 00:00:00 2001 From: Benjamin Locher Date: Wed, 15 May 2024 16:50:30 -0400 Subject: [PATCH] fixing ResourceWarning: unclosed file error --- django_inlinecss/css_loaders.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/django_inlinecss/css_loaders.py b/django_inlinecss/css_loaders.py index 9a1aca3..1e86339 100644 --- a/django_inlinecss/css_loaders.py +++ b/django_inlinecss/css_loaders.py @@ -34,4 +34,6 @@ def load(self, path): """ Retrieve CSS contents with staticfiles storage """ - return staticfiles_storage.open(path).read().decode("utf-8") + with staticfiles_storage.open(path) as file: + return file.read().decode("utf-8") +