From c811d6073b42b43ebf67f932c17b2f27932e127b Mon Sep 17 00:00:00 2001 From: Alexey Leshchenko Date: Wed, 20 Mar 2024 21:15:47 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=8B=D0=B4=D0=B0=D0=B2=D0=B0=D1=82?= =?UTF-8?q?=D1=8C=20=D0=BF=D1=80=D0=B5=D0=B4=D1=83=D0=BF=D1=80=D0=B5=D0=B6?= =?UTF-8?q?=D0=B4=D0=B5=D0=BD=D0=B8=D0=B5,=20=D0=BA=D0=BE=D0=B3=D0=B4?= =?UTF-8?q?=D0=B0=20=D0=B2=20=D1=84=D0=B8=D0=BB=D1=8C=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D1=85=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D1=83=D1=8E?= =?UTF-8?q?=D1=82=20None?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Поправить использование warinings.warn Fixes #223 --- fast_bitrix24/user_request.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/fast_bitrix24/user_request.py b/fast_bitrix24/user_request.py index 9fe1915..8da140b 100644 --- a/fast_bitrix24/user_request.py +++ b/fast_bitrix24/user_request.py @@ -50,6 +50,14 @@ def standardized_params(self, p): p = {key.upper().strip(): value for key, value in p.items()} self.check_expected_clause_types(p) + if "FILTER" in p and None in p["FILTER"].values(): + warnings.warn( + "Using None as filter value confuses Bitrix. " + "Try using an empty string, 'null' or 'false'.", + UserWarning, + stacklevel=2, + ) + return p def check_expected_clause_types(self, p): @@ -176,6 +184,7 @@ def dedup_results(self): f"Number of results returned ({len(self.results)}) " f"doesn't equal 'total' from the server reply ({self.total})", RuntimeWarning, + stacklevel=4, ) @@ -305,8 +314,12 @@ def __init__(self, bitrix, method_branch: str, ID_field_name: str = "ID"): self.method_branch = method_branch self.ID_field_name = ID_field_name - logger.warning( - "list_and_get(): 'ListAndGetUserRequest' is deprecated. Use 'get_all()' instead." + warnings.warn( + "list_and_get() is deprecated. It's not efficient to use it " + "now that exceeding Bitrix request rate limitations gets users " + "heavily penalised. Use 'get_all()' instead.", + DeprecationWarning, + stacklevel=2, ) @icontract.require(