From 29e05c689e058d634a604a7246c151d5765e4350 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 17 Nov 2023 16:45:31 +0100 Subject: [PATCH] osbuild. add comment why AST is used and not importlib Add comment why the `ModuleInfo.load()` code uses open()/ast.parse() instead of just using `importlib`. The reason is that while `importlib` is more convenient and much shorter it would require that all python modules of the osbuild modules are actually installed on the system just to inspect the schema/documentation of the stage. --- osbuild/meta.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osbuild/meta.py b/osbuild/meta.py index 12cecb02..36ec9068 100644 --- a/osbuild/meta.py +++ b/osbuild/meta.py @@ -429,6 +429,8 @@ class ModuleInfo: except FileNotFoundError: return None + # using AST here and not importlib because we can read/parse + # even if some python imports that the module may need are missing tree = ast.parse(data, name) docstring = ast.get_docstring(tree)