From 4d4a52f0e586fbd904fa8513b52127ec174305b4 Mon Sep 17 00:00:00 2001 From: Cyberes Date: Thu, 27 Jul 2023 21:59:16 -0600 Subject: [PATCH] allow user to override the Limiter subclass check --- token_bucket/limiter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/token_bucket/limiter.py b/token_bucket/limiter.py index f99da1e..e581293 100644 --- a/token_bucket/limiter.py +++ b/token_bucket/limiter.py @@ -65,7 +65,7 @@ class Limiter(object): '_storage', ) - def __init__(self, rate, capacity, storage): + def __init__(self, rate, capacity, storage, ignore_subclass: bool = False): if not isinstance(rate, (float, int)): raise TypeError('rate must be an int or float') @@ -78,7 +78,7 @@ def __init__(self, rate, capacity, storage): if capacity < 1: raise ValueError('capacity must be >= 1') - if not isinstance(storage, StorageBase): + if not isinstance(storage, StorageBase) and not ignore_subclass: raise TypeError('storage must be a subclass of StorageBase') self._rate = rate