From b8b1e7798ef0c53a774ccf235ef04b89e04b03b7 Mon Sep 17 00:00:00 2001 From: Parth Somani Date: Sat, 3 Jan 2026 11:56:58 +0530 Subject: [PATCH 1/2] Replace assert with ValueError in Query initialization --- src/licensedcode/query.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/licensedcode/query.py b/src/licensedcode/query.py index 57f4ce82c3a..fa51fa8e9f7 100644 --- a/src/licensedcode/query.py +++ b/src/licensedcode/query.py @@ -209,7 +209,11 @@ def __init__( or junk-only lines. Line numbers start at ``start_line`` which is 1-based by default. """ - assert (location or query_string) and idx + if not ((location or query_string) and idx): + raise ValueError( + "Either location or query_string must be provided, and idx must be set" + ) + self.location = location self.query_string = query_string From 30ef20ee691679ee851a3507b9d7786ac580e808 Mon Sep 17 00:00:00 2001 From: Parth Somani Date: Sat, 3 Jan 2026 11:59:10 +0530 Subject: [PATCH 2/2] Replace assert with ValueError in maven query validation --- src/packagedcode/maven.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/packagedcode/maven.py b/src/packagedcode/maven.py index a007a361213..09f12d1b830 100644 --- a/src/packagedcode/maven.py +++ b/src/packagedcode/maven.py @@ -422,7 +422,11 @@ def __init__(self, location=None, text=None): """ Build a POM from a location or unicode text. """ - assert (location or text) and (not (location and text)) + if not ((location or text) and not (location and text)): + raise ValueError( + "Either location or text must be provided, but not both" + ) + if location: try: