diff --git a/swh/lister/core/indexing_lister.py b/swh/lister/core/indexing_lister.py --- a/swh/lister/core/indexing_lister.py +++ b/swh/lister/core/indexing_lister.py @@ -130,6 +130,9 @@ return bound.isoformat() min_index = dateutil.parser.parse(min_index) max_index = dateutil.parser.parse(max_index) + elif isinstance(max_index - min_index, int): + def format_bound(bound): + return int(bound) else: def format_bound(bound): return bound diff --git a/swh/lister/core/tests/test_indexing_lister.py b/swh/lister/core/tests/test_indexing_lister.py --- a/swh/lister/core/tests/test_indexing_lister.py +++ b/swh/lister/core/tests/test_indexing_lister.py @@ -103,3 +103,20 @@ expected_bounds[0] = expected_bounds[-1] = None assert partitions == list(zip(expected_bounds[:-1], expected_bounds[1:])) + + +def test_db_partition_indices_uneven_int_index_range(): + m = MockedIndexingListerDbPartitionIndices( + num_entries=5641, + first_index=0, + last_index=10000, + ) + assert m + + partitions = m.db_partition_indices(500) + + assert len(partitions) == 5641 // 500 + + for i, (start, end) in enumerate(partitions): + assert isinstance(start, int) or (i == 0 and start is None) + assert isinstance(end, int) or (i == 10 and end is None)