diff --git a/src/licensedcode/query.py b/src/licensedcode/query.py index 57f4ce82c3..fa51fa8e9f 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 diff --git a/src/packagedcode/maven.py b/src/packagedcode/maven.py index a007a36121..09f12d1b83 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: