55from ast import parse
66from typing import Dict , List , Optional , 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
@@ -215,7 +217,9 @@ def get_docstring_coverage(
215217 return results .to_legacy ()
216218
217219
218- def analyze (filenames : list , ignore_config : IgnoreConfig = IgnoreConfig ()) -> ResultCollection :
220+ def analyze (
221+ filenames : list , ignore_config : IgnoreConfig = IgnoreConfig (), show_progress = True
222+ ) -> ResultCollection :
219223 """EXPERIMENTAL: More expressive alternative to `get_docstring_coverage`.
220224
221225 Checks contents of `filenames` for missing docstrings, and produces a report detailing
@@ -232,13 +236,26 @@ def analyze(filenames: list, ignore_config: IgnoreConfig = IgnoreConfig()) -> Re
232236 ignore_config: IgnoreConfig
233237 Information about which docstrings are to be ignored
234238
239+ show_progress: Boolean, default=True
240+ If True, prints a progress bar to stdout
241+
235242 Returns
236243 -------
237244 ResultCollection
238245 The collected information about docstring presence"""
239246 results = ResultCollection ()
240247
241- for filename in filenames :
248+ iterator = iter (filenames )
249+ if show_progress :
250+ iterator = tqdm (
251+ iterator ,
252+ desc = "Checking python files" ,
253+ unit = "files" ,
254+ unit_scale = True ,
255+ total = len (filenames ),
256+ )
257+
258+ for filename in iterator :
242259 file_result = results .get_file (file_path = filename )
243260
244261 ##################################################
0 commit comments