From 8bac3056f59a3d7c24ca6157a4b4d011ffec8d15 Mon Sep 17 00:00:00 2001 From: Alexandr Artemyev Date: Thu, 6 Jun 2024 18:45:03 +0500 Subject: [PATCH] Fix "ResourceWarning: unclosed file" --- django_inlinecss/css_loaders.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/django_inlinecss/css_loaders.py b/django_inlinecss/css_loaders.py index 9a1aca3..102b83d 100644 --- a/django_inlinecss/css_loaders.py +++ b/django_inlinecss/css_loaders.py @@ -34,4 +34,5 @@ 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 css_file: + return css_file.read().decode("utf-8")