1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-13 07:47:14 +03:00

use range instead of silly checks

This commit is contained in:
A_D 2021-08-11 17:38:50 +02:00
parent 3133cba0a4
commit 532716e748
No known key found for this signature in database
GPG Key ID: 4BE9EB7DF45076C4
2 changed files with 2 additions and 1 deletions

View File

@ -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:

View File

@ -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: