@@ -249,7 +249,9 @@ def pytask_log_session_footer(session: Session) -> None:
249249 grouped_warnings [warning .message ].append (location )
250250 sorted_gw = {k : sorted (v ) for k , v in grouped_warnings .items ()}
251251
252- renderable = MyRenderable (sorted_gw )
252+ reduced_gw = _reduce_grouped_warnings (sorted_gw )
253+
254+ renderable = MyRenderable (reduced_gw )
253255
254256 panel = Panel (renderable , title = "Warnings" , style = "warning" )
255257 console .print (panel )
@@ -271,3 +273,19 @@ def __rich_console__(
271273 "[bold red]♥[/bold red] "
272274 + "https://pytask-dev.rtdf.io/en/stable/how_to_guides/capture_warnings.html"
273275 )
276+
277+
278+ def _reduce_grouped_warnings (
279+ grouped_warnings : dict [str , list [str ]], max_locations : int = 5
280+ ) -> dict [str , list [str ]]:
281+ """Reduce grouped warnings."""
282+ reduced_gw = {}
283+ for message , locations in grouped_warnings .items ():
284+ if len (locations ) > max_locations :
285+ adjusted_locations = locations [:max_locations ]
286+ n_more_locations = len (locations [max_locations :])
287+ adjusted_locations .append (f"... in { n_more_locations } more locations." )
288+ else :
289+ adjusted_locations = locations
290+ reduced_gw [message ] = adjusted_locations
291+ return reduced_gw
0 commit comments