55from ast import parse
66from typing import Dict , List , Tuple
77
8+ from tqdm import tqdm
9+
810from docstr_coverage .ignore_config import IgnoreConfig
911from docstr_coverage .printers import LegacyPrinter
1012from docstr_coverage .result_collection import File , FileStatus , ResultCollection
@@ -209,7 +211,9 @@ def get_docstring_coverage(
209211 return results .to_legacy ()
210212
211213
212- def analyze (filenames : list , ignore_config : IgnoreConfig = IgnoreConfig ()) -> ResultCollection :
214+ def analyze (
215+ filenames : list , ignore_config : IgnoreConfig = IgnoreConfig (), show_progress = True
216+ ) -> ResultCollection :
213217 """EXPERIMENTAL: More expressive alternative to `get_docstring_coverage`.
214218
215219 Checks contents of `filenames` for missing docstrings, and produces a report detailing
@@ -226,13 +230,26 @@ def analyze(filenames: list, ignore_config: IgnoreConfig = IgnoreConfig()) -> Re
226230 ignore_config: IgnoreConfig
227231 Information about which docstrings are to be ignored
228232
233+ show_progress: Boolean, default=True
234+ If True, prints a progress bar to stdout
235+
229236 Returns
230237 -------
231238 ResultCollection
232239 The collected information about docstring presence"""
233240 results = ResultCollection ()
234241
235- for filename in filenames :
242+ iterator = iter (filenames )
243+ if show_progress :
244+ iterator = tqdm (
245+ iterator ,
246+ desc = "Checking python files" ,
247+ unit = "files" ,
248+ unit_scale = True ,
249+ total = len (filenames ),
250+ )
251+
252+ for filename in iterator :
236253 file_result = results .get_file (file_path = filename )
237254
238255 ##################################################
0 commit comments