@@ -57,7 +57,9 @@ def batch(self, items: Sequence[Item]) -> List[Batch]:
5757 individual_owners : Dict [str , List [Item ]] = {}
5858 no_owners : List [Item ] = []
5959
60- with open (self .codeowners_location , mode = "r" , encoding = "UTF-8" ) as codeowners_file :
60+ with open (
61+ self .codeowners_location , mode = "r" , encoding = "UTF-8"
62+ ) as codeowners_file :
6163 codeowners = CodeOwners (codeowners_file .read ())
6264
6365 # Build Owner Dictionaries
@@ -83,7 +85,8 @@ def batch(self, items: Sequence[Item]) -> List[Batch]:
8385 # Add batches based on individual owners
8486 batches .extend (self ._create_batches (individual_owners , "reviewers" ))
8587 # Add unowned batch
86- batches .extend (self ._create_batches ({"unowned" : no_owners }))
88+ if no_owners :
89+ batches .extend (self ._create_batches ({"unowned" : no_owners }))
8790
8891 return batches
8992
@@ -92,9 +95,15 @@ def _create_batches(
9295 ) -> List [Batch ]:
9396 batches = []
9497 for owner , items in owners .items ():
95- num_chunks = math .ceil (len (items ) / self .max_batch_size ) if self .max_batch_size else 1
98+ num_chunks = (
99+ math .ceil (len (items ) / self .max_batch_size )
100+ if self .max_batch_size
101+ else 1
102+ )
96103 chunk_size = math .ceil (len (items ) / num_chunks )
97- item_chunks = [items [i : i + chunk_size ] for i in range (0 , len (items ), chunk_size )]
104+ item_chunks = [
105+ items [i : i + chunk_size ] for i in range (0 , len (items ), chunk_size )
106+ ]
98107 for i , chunk_items in enumerate (item_chunks , start = 1 ):
99108 title = (
100109 f"[{ i } /{ num_chunks } ]{ self .prefix } { owner } "
0 commit comments