From 321b36e8b213055583e7a5a672711bf3e043dd99 Mon Sep 17 00:00:00 2001 From: Callahan Kovacs Date: Mon, 30 Sep 2024 10:43:24 -0500 Subject: [PATCH] fix: improve types Signed-off-by: Callahan Kovacs --- snapcraft/models/assertions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/snapcraft/models/assertions.py b/snapcraft/models/assertions.py index 7dbbad30f6..efe6a30a4e 100644 --- a/snapcraft/models/assertions.py +++ b/snapcraft/models/assertions.py @@ -17,6 +17,7 @@ """Assertion models.""" import numbers +from collections import abc from typing import Any, Literal import pydantic @@ -41,10 +42,10 @@ def _to_string(data: Any) -> Any: if isinstance(data, str): return data - if isinstance(data, dict): + if isinstance(data, abc.Mapping): return {_to_string(key): _to_string(value) for key, value in data.items()} - if isinstance(data, list): + if isinstance(data, abc.Collection): return [_to_string(i) for i in data] if isinstance(data, (numbers.Number, bool)):