From 724f4d48d2a6258c9bf3960e49a1a19c5049c457 Mon Sep 17 00:00:00 2001 From: thiswillbeyourgithub <26625900+thiswillbeyourgithub@users.noreply.github.com> Date: Wed, 3 Sep 2025 12:44:48 +0200 Subject: [PATCH] fix: avoid crashing if an assay is missing comment Signed-off-by: thiswillbeyourgithub <26625900+thiswillbeyourgithub@users.noreply.github.com> --- pubchempy.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pubchempy.py b/pubchempy.py index 33012ae..b7b8da1 100644 --- a/pubchempy.py +++ b/pubchempy.py @@ -1983,9 +1983,10 @@ def project_category(self) -> ProjectCategory | None: def comments(self) -> list[str]: """Comments and additional information.""" return [ - comment for comment in self.record["assay"]["descr"]["comment"] if comment + comment for comment in self.record["assay"]["descr"].get("comment", "") if comment ] + @property def results(self) -> list[dict[str, t.Any]]: """A list of dictionaries containing details of the results from this Assay."""