From 110a9d66a68d21874a5a34a01d0d87ed5a63cfbe Mon Sep 17 00:00:00 2001 From: Vaclav Rehak Date: Wed, 27 Mar 2024 15:25:17 +0100 Subject: [PATCH] Fix "ResourceWarning: unclosed file" in compilescss --- sass_processor/management/commands/compilescss.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sass_processor/management/commands/compilescss.py b/sass_processor/management/commands/compilescss.py index ef8e15f..de52866 100644 --- a/sass_processor/management/commands/compilescss.py +++ b/sass_processor/management/commands/compilescss.py @@ -4,6 +4,7 @@ from importlib import import_module import sass from compressor.exceptions import TemplateDoesNotExist, TemplateSyntaxError +from pathlib import Path from django.apps import apps from django.conf import settings @@ -200,7 +201,7 @@ def parse_source(self, filename): `sass_processor(scss_file)` and compile the filename into CSS. """ callvisitor = FuncCallVisitor('sass_processor') - tree = ast.parse(open(filename, 'rb').read()) + tree = ast.parse(Path(filename).read_bytes()) callvisitor.visit(tree) for sass_fileurl in callvisitor.sass_files: sass_filename = find_file(sass_fileurl)