Content-Length: 323530 | pFad | http://github.com/python/typeshed/commit/da50b5c4112bc44dce08685f9e30708b8cb88489

B9 Move error handling to main function (#13630) · python/typeshed@da50b5c · GitHub
Skip to content

Commit da50b5c

Browse files
authored
Move error handling to main function (#13630)
* This makes is easier to call `run_stubtest()` manually, for example when testing the script - no need to construct an `ArgumentParser` instance. * This concentrates argument error handling in the `main()` function and prevents an unexpected process exit when calling `run_stubtest()`.
1 parent acac58a commit da50b5c

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

tests/stubtest_third_party.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,12 @@
3131

3232

3333
def run_stubtest(
34-
dist: Path,
35-
*,
36-
parser: argparse.ArgumentParser,
37-
verbose: bool = False,
38-
specified_platforms_only: bool = False,
39-
keep_tmp_dir: bool = False,
34+
dist: Path, *, verbose: bool = False, specified_platforms_only: bool = False, keep_tmp_dir: bool = False
4035
) -> bool:
4136
"""Run stubtest for a single distribution."""
4237

4338
dist_name = dist.name
44-
try:
45-
metadata = read_metadata(dist_name)
46-
except NoSuchStubError as e:
47-
parser.error(str(e))
39+
metadata = read_metadata(dist_name)
4840
print(f"{dist_name}... ", end="", flush=True)
4941

5042
t = time()
@@ -410,14 +402,13 @@ def main() -> NoReturn:
410402
for i, dist in enumerate(dists):
411403
if i % args.num_shards != args.shard_index:
412404
continue
413-
if not run_stubtest(
414-
dist,
415-
parser=parser,
416-
verbose=args.verbose,
417-
specified_platforms_only=args.specified_platforms_only,
418-
keep_tmp_dir=args.keep_tmp_dir,
419-
):
420-
result = 1
405+
try:
406+
if not run_stubtest(
407+
dist, verbose=args.verbose, specified_platforms_only=args.specified_platforms_only, keep_tmp_dir=args.keep_tmp_dir
408+
):
409+
result = 1
410+
except NoSuchStubError as e:
411+
parser.error(str(e))
421412
sys.exit(result)
422413

423414

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/python/typeshed/commit/da50b5c4112bc44dce08685f9e30708b8cb88489

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy