From f3bb22194fe56228c16b56dc5fb5c7a8e3bee0e0 Mon Sep 17 00:00:00 2001 From: Tim Hatch Date: Thu, 1 Feb 2024 20:58:56 -0800 Subject: [PATCH] Optionally support orjson for loading api json --- Makefile | 2 +- honesty/releases.py | 5 +++++ setup.cfg | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fbfd8ae..9c78148 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ lint: touch honesty/__version__.py python -m ufmt check $(SOURCES) python -m flake8 $(SOURCES) - python -m checkdeps --allow-names honesty honesty + python -m checkdeps --allow-names honesty --metadata-extras orjson honesty mypy --strict --install-types --non-interactive honesty .PHONY: pessimist diff --git a/honesty/releases.py b/honesty/releases.py index 5ecc265..69e6eab 100644 --- a/honesty/releases.py +++ b/honesty/releases.py @@ -15,6 +15,11 @@ from .cache import Cache +try: + import orjson as json # type: ignore[no-redef] # noqa: F811 +except ImportError: + pass + LOG = logging.getLogger(__name__) # Apologies in advance, "parsing" html via regex diff --git a/setup.cfg b/setup.cfg index 2cbcb15..45acb46 100644 --- a/setup.cfg +++ b/setup.cfg @@ -57,6 +57,8 @@ dev = test = coverage >= 6 setuptools >= 65 ; python_version >= '3.12' +orjson = + orjson [options.entry_points] console_scripts =