Skip to content

Commit b019082

Browse files
committed
tqdm progress bar
1 parent c0310d2 commit b019082

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

docstr_coverage/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ def execute(paths, **kwargs):
323323
)
324324

325325
# Calculate docstring coverage
326-
results = analyze(all_paths, ignore_config=ignore_config)
326+
show_progress = not kwargs["percentage_only"]
327+
results = analyze(all_paths, ignore_config=ignore_config, show_progress=show_progress)
327328

328329
LegacyPrinter(verbosity=kwargs["verbose"], ignore_config=ignore_config).print(results)
329330

docstr_coverage/coverage.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from ast import parse
66
from typing import Dict, List, Tuple
77

8+
from tqdm import tqdm
9+
810
from docstr_coverage.ignore_config import IgnoreConfig
911
from docstr_coverage.printers import LegacyPrinter
1012
from 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
##################################################

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def readme():
2525
author_email="hunter@mcgushion.com",
2626
license="MIT",
2727
packages=["docstr_coverage"],
28-
install_requires=["click", "PyYAML"],
28+
install_requires=["click", "PyYAML", "tqdm==4.63.1"],
2929
extras_require={
3030
"lint": ["flake8==3.9.2", "black==21.5b2", "isort==5.9.0"],
3131
"test": ["pytest==5.4.2", "pytest-mock==3.4.0"],

0 commit comments

Comments
 (0)