Skip to content

Commit 915a348

Browse files
authored
Third party stubtest: Print time per distribution (#13547)
1 parent 527d724 commit 915a348

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

lib/ts_utils/utils.py

+4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ def print_divider() -> None:
7272
print()
7373

7474

75+
def print_time(t: float) -> None:
76+
print(f"({t:.2f} s) ", end="")
77+
78+
7579
# ====================================================================
7680
# Dynamic venv creation
7781
# ====================================================================

pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ ignore = [
112112
###
113113
# We're not a library, no need to document everything
114114
"D1", # Missing docstring in ...
115+
# Sometimes, an extra blank line is more readable
116+
"D202", # No blank lines allowed after function docstring
115117
# Doesn't support split "summary line"
116118
"D205", # 1 blank line required between summary line and description
117119
# Used for direct, non-subclass type comparison, for example: `type(val) is str`

tests/stubtest_third_party.py

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from pathlib import Path
1313
from shutil import rmtree
1414
from textwrap import dedent
15+
from time import time
1516
from typing import NoReturn
1617

1718
from ts_utils.metadata import NoSuchStubError, get_recursive_requirements, read_metadata
@@ -25,6 +26,7 @@
2526
print_error,
2627
print_info,
2728
print_success_msg,
29+
print_time,
2830
)
2931

3032

@@ -36,13 +38,17 @@ def run_stubtest(
3638
specified_platforms_only: bool = False,
3739
keep_tmp_dir: bool = False,
3840
) -> bool:
41+
"""Run stubtest for a single distribution."""
42+
3943
dist_name = dist.name
4044
try:
4145
metadata = read_metadata(dist_name)
4246
except NoSuchStubError as e:
4347
parser.error(str(e))
4448
print(f"{dist_name}... ", end="", flush=True)
4549

50+
t = time()
51+
4652
stubtest_settings = metadata.stubtest_settings
4753
if stubtest_settings.skip:
4854
print(colored("skipping", "yellow"))
@@ -136,6 +142,7 @@ def run_stubtest(
136142
try:
137143
subprocess.run(stubtest_cmd, env=stubtest_env, check=True, capture_output=True)
138144
except subprocess.CalledProcessError as e:
145+
print_time(time() - t)
139146
print_error("fail")
140147

141148
print_divider()
@@ -175,6 +182,7 @@ def run_stubtest(
175182

176183
return False
177184
else:
185+
print_time(time() - t)
178186
print_success_msg()
179187
if keep_tmp_dir:
180188
print_info(f"Virtual environment kept at: {venv_dir}")

0 commit comments

Comments
 (0)