diff --git a/build-tools/get_appimage.py b/build-tools/get_appimage.py index 82b5d0f..7b417e6 100644 --- a/build-tools/get_appimage.py +++ b/build-tools/get_appimage.py @@ -5,7 +5,10 @@ import os import pathlib import stat -import requests +try: + import niquests as requests +except ImportError: + import requests parser = argparse.ArgumentParser() parser.add_argument("APPIMAGETOOL", default="build/appimagetool-x86_64.AppImage", type=pathlib.Path, nargs="?") diff --git a/comictaggerlib/imagefetcher.py b/comictaggerlib/imagefetcher.py index a6cd167..33be192 100644 --- a/comictaggerlib/imagefetcher.py +++ b/comictaggerlib/imagefetcher.py @@ -25,7 +25,10 @@ import sqlite3 as lite import tempfile from typing import TYPE_CHECKING -import requests +try: + import niquests as requests +except ImportError: + import requests from comictaggerlib import ctversion diff --git a/comictaggerlib/versionchecker.py b/comictaggerlib/versionchecker.py index c054908..e1c4fc4 100644 --- a/comictaggerlib/versionchecker.py +++ b/comictaggerlib/versionchecker.py @@ -18,7 +18,10 @@ from __future__ import annotations import logging -import requests +try: + import niquests as requests +except ImportError: + import requests from comictaggerlib import ctversion diff --git a/comictalker/talkers/comicvine.py b/comictalker/talkers/comicvine.py index 93dc0c5..9207b73 100644 --- a/comictalker/talkers/comicvine.py +++ b/comictalker/talkers/comicvine.py @@ -25,7 +25,6 @@ import time from typing import Any, Callable, Generic, TypeVar from urllib.parse import urljoin -import requests import settngs from pyrate_limiter import Limiter, RequestRate from typing_extensions import Required, TypedDict @@ -38,6 +37,10 @@ from comictalker import talker_utils from comictalker.comiccacher import ComicCacher, Issue, Series from comictalker.comictalker import ComicTalker, TalkerDataError, TalkerNetworkError +try: + import niquests as requests +except ImportError: + import requests logger = logging.getLogger(__name__) diff --git a/tests/conftest.py b/tests/conftest.py index e8b1096..fa478fe 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -10,7 +10,6 @@ from collections.abc import Generator from typing import Any import pytest -import requests import settngs from PIL import Image from pyrate_limiter import Limiter, RequestRate @@ -26,6 +25,11 @@ from comicapi import utils from testing import comicvine, filenames from testing.comicdata import all_seed_imprints, seed_imprints +try: + import niquests as requests +except ImportError: + import requests + @pytest.fixture def cbz(): @@ -55,7 +59,14 @@ def cbz_double_cover(tmp_path, tmp_comic): @pytest.fixture(autouse=True) def no_requests(monkeypatch) -> None: """Remove requests.sessions.Session.request for all tests.""" - monkeypatch.delattr("requests.sessions.Session.request") + try: + monkeypatch.delattr("niquests.sessions.Session.request") + except Exception: + ... + try: + monkeypatch.delattr("requests.sessions.Session.request") + except Exception: + ... @pytest.fixture