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: