From 4d303552a713421a2bb07b5c90ee097360e45981 Mon Sep 17 00:00:00 2001 From: Russ Garrett Date: Sat, 7 Dec 2024 13:57:55 +0000 Subject: [PATCH] Handle error when importlib can't get the package version --- polybot/service.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/polybot/service.py b/polybot/service.py index 3b5e122..5393b27 100644 --- a/polybot/service.py +++ b/polybot/service.py @@ -7,12 +7,15 @@ from atproto import Client, models # type: ignore from atproto_client.exceptions import RequestException # type: ignore from mastodon import Mastodon as MastodonClient # type: ignore -from importlib.metadata import version +from importlib.metadata import PackageNotFoundError, version import httpx from .image import Image -POLYBOT_VERSION = version("polybot") +try: + POLYBOT_VERSION = version("polybot") +except PackageNotFoundError: + POLYBOT_VERSION = "dev" class PostError(Exception):