Skip to content

Commit dbcb866

Browse files
Merge pull request #106 from MiWeiss/feat/tqdm-progress
tqdm progress bar
2 parents b99b23e + a7a53f1 commit dbcb866

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
@@ -341,7 +341,8 @@ def execute(paths, **kwargs):
341341
)
342342

343343
# Calculate docstring coverage
344-
results = analyze(all_paths, ignore_config=ignore_config)
344+
show_progress = not kwargs["percentage_only"]
345+
results = analyze(all_paths, ignore_config=ignore_config, show_progress=show_progress)
345346

346347
LegacyPrinter(verbosity=kwargs["verbose"], ignore_config=ignore_config).print(results)
347348

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, Optional, 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
@@ -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
##################################################

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==4.0.1", "black==22.3.0", "isort==5.10.1"],
3131
"test": ["pytest==6.2.5", "pytest-mock==3.4.0"],

0 commit comments

Comments
 (0)