From 532716e748d7c029301224e0102ee0b913100103 Mon Sep 17 00:00:00 2001
From: A_D <aunderscored@gmail.com>
Date: Wed, 11 Aug 2021 17:38:50 +0200
Subject: [PATCH] use range instead of silly checks

---
 killswitch.py                     | 2 +-
 tests/killswitch.py/test_apply.py | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/killswitch.py b/killswitch.py
index 346d4099..d6e7b4a9 100644
--- a/killswitch.py
+++ b/killswitch.py
@@ -83,7 +83,7 @@ def _apply(target: UPDATABLE_DATA, key: str, to_set: Any = None, delete: bool =
 
         if delete and len(target) > 0:
             length = len(target)
-            if (idx > 0 and length > idx) or idx >= -length:
+            if idx in range(-length, length):
                 target.pop(idx)
 
         elif len(target) == idx:
diff --git a/tests/killswitch.py/test_apply.py b/tests/killswitch.py/test_apply.py
index 29517203..a99c55e0 100644
--- a/tests/killswitch.py/test_apply.py
+++ b/tests/killswitch.py/test_apply.py
@@ -19,6 +19,7 @@ from killswitch import UPDATABLE_DATA
         (['test neg del'], '-1', 'delete', None, []),
         (['test neg del'], '-1337', 'delete', None, ['test neg del']),
         (['test neg del'], '-2', 'delete', None, ['test neg del']),
+        (['test too high del'], '30', 'delete', None, ['test too high del']),
     ]
 )
 def test_apply(source: UPDATABLE_DATA, key: str, action: str, to_set: Any, result: UPDATABLE_DATA) -> None: