1111from _pytask .config import hookimpl
1212from _pytask .config import IS_FILE_SYSTEM_CASE_SENSITIVE
1313from _pytask .console import console
14+ from _pytask .console import generate_collection_status
1415from _pytask .enums import ColorCode
1516from _pytask .exceptions import CollectionError
1617from _pytask .mark import has_marker
2021from _pytask .nodes import reduce_node_name
2122from _pytask .path import find_case_sensitive_path
2223from _pytask .report import CollectionReport
24+ from rich .live import Live
2325from rich .traceback import Traceback
2426
2527
@@ -28,17 +30,14 @@ def pytask_collect(session):
2830 """Collect tasks."""
2931 session .collection_start = time .time ()
3032
31- reports = _collect_from_paths ( session )
32- tasks = _extract_successfully_collected_tasks_from_reports ( reports )
33+ with Live ( generate_collection_status ( 0 ), console = console , transient = True ) as live :
34+ _collect_from_paths ( session , live )
3335
3436 try :
35- session .hook .pytask_collect_modify_tasks (session = session , tasks = tasks )
37+ session .hook .pytask_collect_modify_tasks (session = session , tasks = session . tasks )
3638 except Exception :
3739 report = CollectionReport .from_exception (exc_info = sys .exc_info ())
38- reports .append (report )
39-
40- session .collection_reports = reports
41- session .tasks = tasks
40+ session .collection_reports .append (report )
4241
4342 session .hook .pytask_collect_log (
4443 session = session , reports = session .collection_reports , tasks = session .tasks
@@ -47,21 +46,21 @@ def pytask_collect(session):
4746 return True
4847
4948
50- def _collect_from_paths (session ):
49+ def _collect_from_paths (session , live = None ):
5150 """Collect tasks from paths.
5251
5352 Go through all paths, check if the path is ignored, and collect the file if not.
5453
5554 """
56- collected_reports = session .collection_reports
5755 for path in _not_ignored_paths (session .config ["paths" ], session ):
5856 reports = session .hook .pytask_collect_file_protocol (
59- session = session , path = path , reports = collected_reports
57+ session = session , path = path , reports = session . collection_reports
6058 )
6159 if reports is not None :
62- collected_reports .extend (reports )
63-
64- return collected_reports
60+ session .collection_reports .extend (reports )
61+ session .tasks .extend (i .node for i in reports if i .successful )
62+ if live is not None :
63+ live .update (generate_collection_status (len (session .tasks )))
6564
6665
6766@hookimpl
@@ -230,11 +229,6 @@ def _not_ignored_paths(paths: List[Path], session) -> Generator[Path, None, None
230229 yield path
231230
232231
233- def _extract_successfully_collected_tasks_from_reports (reports ):
234- """Extract successfully collected tasks from reports."""
235- return [i .node for i in reports if i .successful ]
236-
237-
238232@hookimpl
239233def pytask_collect_log (session , reports , tasks ):
240234 """Log collection."""
0 commit comments