py: query: avoid assert triggering on None family

lib.getFileFamily() returns None for many files. Our assert to ensure
the family is valid should only be done once we have checked the family
is NOT None.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
This commit is contained in:
Théo Lebrun 2025-01-06 15:16:18 +01:00
parent 6c9decb84b
commit 56156027f1

View file

@ -173,9 +173,10 @@ class Query:
filename = os.path.basename(path)
family = lib.getFileFamily(filename)
assert family in lib.CACHED_DEFINITIONS_FAMILIES, f"family {family} must have its definitions cached"
if family != None:
assert family in lib.CACHED_DEFINITIONS_FAMILIES, f"family {family} must have its definitions cached"
buffer = BytesIO()
tokens = self.scriptLines('tokenize-file', version, path, family)
even = True