From ae997fd0bfbb7f419f77cc92e88e5f3a49e23a7d Mon Sep 17 00:00:00 2001 From: Hazel Noack Date: Wed, 11 Jun 2025 13:53:53 +0200 Subject: [PATCH] implemented silent connection which should not throw any errors --- python_requests/__main__.py | 2 +- python_requests/connections.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/python_requests/__main__.py b/python_requests/__main__.py index f2f2323..d669be2 100644 --- a/python_requests/__main__.py +++ b/python_requests/__main__.py @@ -1,7 +1,7 @@ import argparse import logging -from .connections import Connection +from .connections import Connection, SilentConnection from . import cache diff --git a/python_requests/connections.py b/python_requests/connections.py index 35f4e25..5e41d1c 100644 --- a/python_requests/connections.py +++ b/python_requests/connections.py @@ -151,3 +151,11 @@ class Connection: json=json, **kwargs, )) + + +class SilentConnection(Connection): + def send_request(self, request: requests.Request, attempt: int = 0) -> Optional[requests.Response]: + try: + return super().send_request(request, attempt) + except requests.HTTPError as e: + log.warning(str(e))